Coq < Definition
predecesor1: nat->nat :=
Coq <
[n:nat]Cases n of
Coq <
O =>O
Coq <
|(S p)=>p
Coq <
end.
predecesor1 is defined
Coq < Recursive
Definition predecesor2: nat -> nat :=
Coq <
O => O
Coq <
|(S p)=> p.
predecesor2_eq1 is
defined
predecesor2_eq2 is
defined
predecesor2 is recursively
defined.
Coq < Fixpoint
predecesor3 [n:nat]:nat :=
Coq < Cases n
of
Coq <
O=>O
Coq < |(S p)=>
p
Coq < end.
Warning:
predecesor3 is non-recursively defined
Coq < Eval Compute
in (predecesor1 (S (S O))).
= (S O)
: nat
Coq < Eval Compute
in (predecesor2 (S (S O))).
= (S O)
: nat
Coq < Eval Compute
in (predecesor3 (S (S O))).
= (S O)
: nat
Coq < Fixpoint
f [C:Set;f0:C;fc:C->C;n:nat]: C :=
Cases n of
O => f0
|(S p)=> (fc (f C f0 fc p))
end.
f is recursively
defined
Coq
< Definition f:= [x:nat](plus (2) x).
f
is defined
Coq
< Check f.
f
: nat->nat
Coq
< Eval Compute in (f (89)).
= (91)
: nat
Coq < Recursive
Definition plus : nat->nat->nat :=
Coq <
O b => b
Coq < |(S a) b
=> (S (plus a b)).
plus_eq1 is defined
plus_eq2 is defined
plus is recursively
defined.
Coq < Eval Compute
in (plus (S O) (S O)).
= (S (S O))
: nat
La táctica Simpl trata
de reducir el objetivo utilizando el valor de funciones.