Commit f3f49b3b by Jean-Christophe Filliâtre

### new library int.Fibonacci

parent 496c8a36
 (* Fibonacci function with memoisation *) module M module FibMemo use import int.Int use import int.Fibonacci use import ref.Ref function fib int : int axiom Fib_def : forall n:int. fib n = if n <= 1 then 1 else fib (n-1) + fib (n-2) type option 'a = None | Some 'a use import map.Map as M ... ... @@ -36,7 +32,7 @@ module M ensures { result = fib n /\ inv !table } variant { 2*n } if n <= 1 then 1 n else memo_fibo (n-1) + memo_fibo (n-2) ... ...
 ... ... @@ -7,6 +7,10 @@ version="0.95.1"/> shape="iainvV5Aainfix =ainfix +afibV4afibV2afibV0IainvV5FAainvV3Aainfix <=c0V4Aainfix <ainfix +ainfix *c2V4c1ainfix *c2V0Aainfix <=c0ainfix *c2V0Lainfix -V0c1IainvV3FAainvV1Aainfix <=c0V2Aainfix <ainfix +ainfix *c2V2c1ainfix *c2V0Aainfix <=c0ainfix *c2V0Lainfix -V0c2ainvV1Aainfix =V0afibV0ainfix <=V0c1IainvV1Aainfix <=c0V0FF">
 theory Fibonacci "Fibonacci numbers" use export int.Int function fib int : int axiom fib0: fib 0 = 0 axiom fib1: fib 1 = 1 axiom fibn: forall n:int. n >= 2 -> fib n = fib (n-1) + fib (n-2) end theory FibonacciTest use import Fibonacci use import int.Fibonacci lemma isfib_2_1 : fib 2 = 1 lemma isfib_6_8 : fib 6 = 8 ... ... @@ -24,7 +12,7 @@ end module FibonacciLinear use import Fibonacci use import int.Fibonacci use import int.Int use import ref.Ref ... ... @@ -45,7 +33,7 @@ end module FibRecGhost "recursive version, using ghost code" use import Fibonacci use import int.Fibonacci use import int.Int let rec fib_aux (ghost n: int) (a b k: int) : int ... ... @@ -71,7 +59,7 @@ end module FibRecNoGhost "recursive version, without ghost code" use import Fibonacci use import int.Fibonacci use import int.Int let rec fib_aux (a b k: int) : int ... ... @@ -113,7 +101,7 @@ end module FibonacciLogarithmic use import Fibonacci use import int.Fibonacci use import int.EuclideanDivision use import Mat22 ... ...
This diff is collapsed.
 ... ... @@ -444,3 +444,16 @@ theory Induction forall n:int. bound <= n -> p n end theory Fibonacci "Fibonacci numbers" use export Int function fib int : int axiom fib0: fib 0 = 0 axiom fib1: fib 1 = 1 axiom fibn: forall n:int. n >= 2 -> fib n = fib (n-1) + fib (n-2) end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!