Compare commits
1 commit
master
...
rocq_playg
| Author | SHA1 | Date | |
|---|---|---|---|
| 17964b6224 |
1 changed files with 115 additions and 0 deletions
115
crates/fayalite/tests/rocq_playground.v
Normal file
115
crates/fayalite/tests/rocq_playground.v
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
Module test1.
|
||||
Record S := { a: bool }.
|
||||
Definition initial (s: S) :=
|
||||
a s = false.
|
||||
Example teste1: initial {| a := false|}.
|
||||
Proof. unfold initial. trivial. Qed.
|
||||
Definition assert (s: S) :=
|
||||
a s = false.
|
||||
Theorem base1: forall s0, initial s0 -> assert s0.
|
||||
Proof. trivial. Qed.
|
||||
Definition t (s1 s2 : S) :=
|
||||
a s2 = a s1.
|
||||
Example induct1:
|
||||
forall s0 s1, assert s0 -> t s0 s1 -> assert s1.
|
||||
Proof.
|
||||
unfold t, assert.
|
||||
intros s0 s1 A T.
|
||||
transitivity (a s0).
|
||||
apply T. apply A.
|
||||
Qed.
|
||||
Example teste3:
|
||||
forall s0 s1, initial s0 -> t s0 s1 -> assert s1.
|
||||
Proof.
|
||||
unfold initial, t, assert.
|
||||
intros s0 s1 I T.
|
||||
transitivity (a s0).
|
||||
apply T. apply I.
|
||||
Qed.
|
||||
Example teste4:
|
||||
forall s0 s1, initial s0 -> t s0 s1 -> assert s1.
|
||||
Proof.
|
||||
apply induct1.
|
||||
Qed.
|
||||
End test1.
|
||||
|
||||
Module test2.
|
||||
Record S :=
|
||||
{ a: bool
|
||||
; b: bool
|
||||
}.
|
||||
Definition initial (s: S) :=
|
||||
a s = false /\ b s = false.
|
||||
Definition assert (s: S) :=
|
||||
b s = false.
|
||||
Definition t (s1 s2 : S) :=
|
||||
a s2 = a s1 /\ b s2 = a s1.
|
||||
Theorem base1:
|
||||
forall s0,
|
||||
initial s0 -> assert s0.
|
||||
Proof.
|
||||
unfold initial, assert.
|
||||
intros s0 [_ H].
|
||||
apply H.
|
||||
Qed.
|
||||
Theorem induct1:
|
||||
forall s0 s1,
|
||||
assert s0 -> t s0 s1 -> assert s1.
|
||||
Proof.
|
||||
unfold t, assert.
|
||||
intros s0 s1 A T.
|
||||
destruct T as [_ Tb].
|
||||
transitivity (a s0). apply Tb.
|
||||
Abort.
|
||||
Theorem not_induct1:
|
||||
not (forall s0 s1,
|
||||
assert s0 -> t s0 s1 -> assert s1).
|
||||
Proof.
|
||||
unfold not, assert, t.
|
||||
intros H.
|
||||
specialize H with (s0 := {|a := true; b := false|}).
|
||||
simpl in H.
|
||||
specialize H with (s1 := {|a := true; b := true|}).
|
||||
simpl in H.
|
||||
discriminate H. reflexivity. auto.
|
||||
Qed.
|
||||
Theorem base2:
|
||||
forall s0 s1,
|
||||
initial s0 -> assert s0 -> t s0 s1 -> assert s1.
|
||||
Proof.
|
||||
intros s0 s1 [Ia _] _ [_ Tb].
|
||||
unfold assert.
|
||||
transitivity (a s0). apply Tb.
|
||||
apply Ia.
|
||||
Qed.
|
||||
Theorem induct2:
|
||||
forall s0 s1 s2,
|
||||
assert s0 -> t s0 s1 -> assert s1 -> t s1 s2 -> assert s2.
|
||||
Proof.
|
||||
intros s0 s1 s2 A0 [T0a T0b] A1 [T1a T1b].
|
||||
unfold assert in *.
|
||||
transitivity (a s1). apply T1b.
|
||||
transitivity (a s0). apply T0a.
|
||||
transitivity (b s1). symmetry. apply T0b.
|
||||
apply A1.
|
||||
Qed.
|
||||
Theorem base3:
|
||||
forall s0 s1 s2,
|
||||
initial s0 -> assert s0 -> t s0 s1 -> assert s1 -> t s1 s2 -> assert s2.
|
||||
Proof.
|
||||
intros s0 s1 s2 [Ia Ib] A0 [T0a T0b] A1 [T1a T1b].
|
||||
unfold assert in *.
|
||||
transitivity (a s1). apply T1b.
|
||||
transitivity (a s0). apply T0a.
|
||||
apply Ia.
|
||||
Qed.
|
||||
Theorem base3':
|
||||
forall s0 s1 s2,
|
||||
initial s0 -> t s0 s1 -> assert s1 -> t s1 s2 -> assert s2.
|
||||
Proof.
|
||||
intros s0 s1 s2 H.
|
||||
apply induct2.
|
||||
apply base1.
|
||||
trivial.
|
||||
Qed.
|
||||
End test2.
|
||||
Loading…
Add table
Add a link
Reference in a new issue