Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
18
Task/Ackermann-function/Coq/ackermann-function-1.coq
Normal file
18
Task/Ackermann-function/Coq/ackermann-function-1.coq
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
Fixpoint ack (m : nat) : nat -> nat :=
|
||||
fix ack_m (n : nat) : nat :=
|
||||
match m with
|
||||
| 0 => S n
|
||||
| S pm =>
|
||||
match n with
|
||||
| 0 => ack pm 1
|
||||
| S pn => ack pm (ack_m pn)
|
||||
end
|
||||
end.
|
||||
|
||||
|
||||
(*
|
||||
Example:
|
||||
A(3, 2) = 29
|
||||
*)
|
||||
|
||||
Eval compute in ack 3 2.
|
||||
13
Task/Ackermann-function/Coq/ackermann-function-2.coq
Normal file
13
Task/Ackermann-function/Coq/ackermann-function-2.coq
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
Require Import Utf8.
|
||||
|
||||
Section FOLD.
|
||||
Context {A : Type} (f : A → A) (a : A).
|
||||
Fixpoint fold (n : nat) : A :=
|
||||
match n with
|
||||
| O => a
|
||||
| S k => f (fold k)
|
||||
end.
|
||||
End FOLD.
|
||||
|
||||
Definition ackermann : nat → nat → nat :=
|
||||
fold (λ g, fold g (g (S O))) S.
|
||||
Loading…
Add table
Add a link
Reference in a new issue