Skip to content

Iterative fibonacci example proof#245

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

Iterative fibonacci example proof#245
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?


text\<open>Lastly, prove that the iterative Fibonacci is correct with the mathematical definition.\<close>

definition fib_correct_contract :: \<open>64 word \<Rightarrow> ('s, nat, 'b) function_contract\<close> 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.

Strictly speaking this is the only contract and functional correctness proof we need...

@nagyors nagyors force-pushed the iterative-fibonacci branch from 7edac3f to d18d99a Compare July 8, 2026 10:31
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.

2 participants