Skip to content

Iterative fibonacci example proof - #245

Open
nagyors wants to merge 2 commits into
awslabs:mainfrom
jonasmittun:iterative-fibonacci
Open

nagyors wants to merge 2 commits into
awslabs:mainfrom
jonasmittun:iterative-fibonacci

Conversation

@nagyors

@nagyors nagyors commented Jun 17, 2026

Copy link
Copy Markdown

Issue #6 : Implements one of the examples suggested (iterative Fibonacci correctness proof).

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@dominic-mulligan-aws dominic-mulligan-aws left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution! Could you rebase and push again? I've just got some minor comments...

text\<open>First, we define the mathematical Fibonacci function recursively.
Solution taken from: https://isabelle.in.tum.de/library/HOL/HOL-Number_Theory/Fib.html \<close>

fun fib :: "nat \<Rightarrow> nat" where

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can you use cartouches instead of quotation marks, and match our prevailing style?


text\<open>Some basic properties of the mathematical definition\<close>

lemma fib_plus_2: "fib (n + 2) = fib (n + 1) + fib n"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can you phrase lemmas using assumes and shows and match our prevailing style?

Comment thread Micro_Rust_Examples/Fibonacci_Iterative.thy
@nagyors
nagyors force-pushed the iterative-fibonacci branch from 7edac3f to d18d99a Compare July 8, 2026 10:31
@hanno-becker
hanno-becker force-pushed the iterative-fibonacci branch 2 times, most recently from 9653020 to fc49322 Compare September 8, 2026 09:07

@hanno-becker hanno-becker left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies for the late reply, @nagyors. The change looks good. I took the liberty to squash your two commits into one, but could you please add a DCO signoff? Please also consider if you want to add your name to the Copyright header in the newly added file.

nagyors and others added 2 commits October 10, 2026 10:11
Add a Micro Rust function that computes Fibonacci numbers with two
mutable `nat` accumulators. Its contract returns `fib (unat n)`, and
the loop invariant relates the accumulators to consecutive Fibonacci
values.

Import the theory from `Micro_Rust_Examples`.

Signed-off-by: Örs Nagy <nagyors456@gmail.com>
Add the standard copyright and SPDX header to the new iterative
Fibonacci theory.

Remove the three trailing spaces reported by `git diff --check`. The
definitions and proof are unchanged.

Signed-off-by: Hanno Becker <beckphan@amazon.com>
@nagyors
nagyors force-pushed the iterative-fibonacci branch from fc49322 to 5c56179 Compare October 10, 2026 08:14
@nagyors

nagyors commented Oct 10, 2026

Copy link
Copy Markdown
Author

@hanno-becker I signed off my commit, but didn't feel the need to add my name to the copyright header. Thank you for letting me contribute!

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants