forked from coq-community/coq-art
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfib_log.html
46 lines (43 loc) · 1.12 KB
/
fib_log.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<title>An efficient way to compute the fibonacci function
</title>
</head>
<body>
<h1>An efficient way to compute the fibonacci function
</h1>
<p>
Here is a definition of the Fibonacci function.
</p>
<pre>
Fixpoint fib (n:nat) : nat :=
match n with
0 => 1
| 1 => 1
| S ((S p) as q) => fib p + fib q
end.
</pre>
<p>
Prove the following statements:
</p>
<pre>
forall n, fib (2*n) = fib (n) * fib (n) +
(fib (n+1) - fib n)*(fib (n+1) - fib n).
forall n, fib (2*n+1) = 2 * fib n * fib (n+1) - fib n * fib n.
forall n, fib (S (2*n+1)) = fib (n+1) * (fib (n+1)) + fib n * fib n.
</pre>
<p>
Use these formulas to define another function that computes the
values of the Fibonacci function for n, with only a logarithmic number
of recursive calls (to compute the values for 17 and 18, this function
should only compute the values for 8, 9, 4, 5, 2, and 3).
</p>
<h2>Solution</h2>
<a href="SRC/fib_log.v">Follow this link</a>
<br><br>
<hr>
<hr>
<address><a href="mailto:[email protected]">Pierre Castéran</a></address>
</body>
</html>