130 lines
1.8 KiB
Coq
130 lines
1.8 KiB
Coq
Check nat.
|
|
|
|
Eval cbv zeta in
|
|
let i:=2 in i+1.
|
|
(*
|
|
= 2 + 1
|
|
: nat
|
|
*)
|
|
|
|
Eval cbv zeta in
|
|
let i:=(2+3*4) in i+1.
|
|
(*
|
|
|
|
= 2 + 3 * 4 + 1
|
|
: nat
|
|
*)
|
|
|
|
Eval cbv zeta in
|
|
let x:=6+1*8 in
|
|
let i:=(2+x*4) in i+1.
|
|
(*
|
|
= 2 + (6 + 1 * 8) * 4 + 1
|
|
: nat
|
|
*)
|
|
|
|
Eval cbv beta in
|
|
(fun x:nat => x+1) 5.
|
|
(*
|
|
= 5 + 1
|
|
: nat
|
|
*)
|
|
|
|
Eval cbv beta in
|
|
(fun x:nat =>
|
|
fun y:nat => x + y) 4.
|
|
(*
|
|
= fun y : nat => 4 + y
|
|
: nat -> nat
|
|
*)
|
|
|
|
Eval cbv beta in
|
|
(fun x:nat => 2*x+1) 5.
|
|
(*
|
|
= 2 * 5 + 1
|
|
: nat
|
|
*)
|
|
|
|
Definition incr (n:nat):nat:=S n.
|
|
Eval cbv delta in
|
|
(fun x:nat => incr x) 5.
|
|
(*
|
|
= (fun x : nat => (fun n : nat => S n) x) 5
|
|
: nat
|
|
*)
|
|
|
|
Opaque incr.
|
|
|
|
Eval cbv delta in
|
|
(fun x:nat => incr x) 5.
|
|
(*
|
|
= (fun x : nat => incr x) 5
|
|
: nat
|
|
*)
|
|
|
|
Transparent incr.
|
|
|
|
Eval cbv delta in
|
|
(fun x:nat => incr x) 5.
|
|
(*
|
|
= (fun x : nat => (fun n : nat => S n) x) 5
|
|
: nat
|
|
*)
|
|
|
|
Definition plus_2 (n:nat):nat := S (S n).
|
|
Opaque plus_2.
|
|
|
|
Eval cbv delta in
|
|
(fun x:nat => incr x) 5.
|
|
|
|
Transparent plus_2.
|
|
|
|
Goal
|
|
3 + 2 = 5.
|
|
Proof.
|
|
(*
|
|
cbv delta.
|
|
|
|
(fix add (n m : nat) {struct n} : nat :=
|
|
match n with
|
|
| 0 => m
|
|
| S p => S (add p m)
|
|
end) 3 2 = 5
|
|
*)
|
|
cbv delta.
|
|
cbv fix.
|
|
repeat (cbv fix; cbv beta; cbv match).
|
|
constructor.
|
|
Qed.
|
|
|
|
Eval cbv fix in
|
|
(fix addition (n m:nat) : nat :=
|
|
match n with
|
|
| O => m
|
|
| S n' => S (addition n' m)
|
|
end) 3 2.
|
|
(*
|
|
= (fun n m : nat =>
|
|
match n with
|
|
| 0 => m
|
|
| S n' =>
|
|
S
|
|
((fix addition (n0 m0 : nat) {struct n0} : nat :=
|
|
match n0 with
|
|
| 0 => m0
|
|
| S n'0 => S (addition n'0 m0)
|
|
end) n' m)
|
|
end) 3 2
|
|
: nat
|
|
*)
|
|
|
|
Eval cbv match in
|
|
(match 3 with
|
|
| O => true
|
|
| _ => false
|
|
end).
|
|
(*
|
|
= false
|
|
: bool
|
|
*)
|