| 1 |
(* cbn is able to refold mutual recursive calls *) |
| 2 |
|
| 3 |
Fixpoint foo (n : nat) := |
| 4 |
match n with |
| 5 |
| 0 => true |
| 6 |
| S n => g n |
| 7 |
end |
| 8 |
with g (n : nat) : bool := |
| 9 |
match n with |
| 10 |
| 0 => true |
| 11 |
| S n => foo n |
| 12 |
end. |
| 13 |
Goal forall n, foo (S n) = g n. |
| 14 |
intros. cbn. |
| 15 |
match goal with |
| 16 |
|- g _ = g _ => reflexivity |
| 17 |
end. |
| 18 |
Qed. |
| 19 |
|
| 20 |
(* simpl nomatch *) |
| 21 |
|
| 22 |
Definition thing n := match n with 0 => True | S n => False end. |
| 23 |
|
| 24 |
Arguments thing _ / : simpl nomatch. |
| 25 |
|
| 26 |
Goal forall x, thing x. |
| 27 |
intros. cbn. |
| 28 |
match goal with |- thing x => idtac end. |
| 29 |
Abort. |
| 30 |
|
| 31 |
Definition thing' n := n + n. |
| 32 |
|
| 33 |
Arguments thing' !_ / : simpl nomatch. |
| 34 |
Lemma bar n : thing' n = 0. |
| 35 |
Proof. |
| 36 |
cbn. |
| 37 |
match goal with |- thing' _ = _ => idtac end. |
| 38 |
Arguments thing' _ / : simpl nomatch. |
| 39 |
cbn. |
| 40 |
match goal with |- _ + _ = _ => idtac end. |
| 41 |
Abort. |
| 42 |
|
| 43 |
Module MutualFixCoFixInSection. |
| 44 |
|
| 45 |
Section S. |
| 46 |
Variable p:nat. |
| 47 |
Fixpoint f n := match n with 0 => p | S n => f n + g n end |
| 48 |
with g n := match n with 0 => p | S n => f n + g n end. |
| 49 |
End S. |
| 50 |
|
| 51 |
Goal forall n, f n (S n) = g 0 (S n). |
| 52 |
intros. cbn. |
| 53 |
match goal with [ |- f n n + g n n = f 0 n + g 0 n ] => idtac end. |
| 54 |
Abort. |
| 55 |
|
| 56 |
CoInductive stream {A:Type} : Type := |
| 57 |
| scons: A->stream->stream. |
| 58 |
Definition stream_unfold {A} (s: @ stream A) := match s with |
| 59 |
| scons a s' => (a, scons a s') |
| 60 |
end. |
| 61 |
|
| 62 |
Section C. |
| 63 |
Variable (x:nat). |
| 64 |
CoFixpoint mut_stream1 (n:nat) := scons n (mut_stream2 (n+x)) |
| 65 |
with mut_stream2 (n:nat) := scons n (mut_stream1 (n+x)). |
| 66 |
End C. |
| 67 |
|
| 68 |
Goal (forall x n, stream_unfold (mut_stream1 x n) = stream_unfold (mut_stream2 x n)). |
| 69 |
intros. cbn. |
| 70 |
match goal with [ |- (n, scons n (mut_stream2 x (n + x))) = (n, scons n (mut_stream1 x (n + x))) ] => idtac end. |
| 71 |
Abort. |
| 72 |
|
| 73 |
End MutualFixCoFixInSection. |