-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathC4_ex.v
142 lines (117 loc) · 2.38 KB
/
C4_ex.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
Require Arith.
Lemma le_n_plus_pn n p : n <= p + n.
Proof.
Print le.
induction p as [ | p IHp ]; simpl.
+ constructor 1.
+ constructor 2; assumption.
Qed.
Check le_ind.
Lemma le_plus n m : n <= m -> exists p, p+n = m.
Proof.
Print le.
induction 1 as [ | m H IH ].
+ exists 0; simpl; trivial.
+ destruct IH as (p & Hp).
exists (S p); simpl; f_equal; trivial.
Qed.
Lemma foo_gen n : 1 <= n -> n = 0 -> False.
Proof.
intros H.
induction H.
+ discriminate.
+ discriminate.
Qed.
Lemma foo_1 : ~ 1 <= 0.
Proof.
red.
intros H.
destruct foo_gen with (1 := H).
reflexivity.
Qed.
Lemma foo : ~ 1 <= 0.
Proof.
intros H.
inversion H.
Qed.
Lemma le_n_0 n : n <= 0 -> n = 0.
Proof.
Print le.
inversion 1.
reflexivity.
Qed.
Fixpoint leb n m : bool :=
match n, m with
| 0, _ => true
| S _, 0 => false
| S n, S m => leb n m
end.
Lemma le_5_45 : 5 <= 45.
Proof.
(* do 40 constructor.
constructor 1. *)
repeat constructor.
Qed.
Lemma leb_5_45 : leb 5 45 = true.
Proof. reflexivity. Qed.
Print leb_5_45.
Lemma le_trans : forall n p q, n <= p -> p <= q -> n <= q.
Proof.
(* intros n p q Hpq.
induction 1 as [ | q H1 IH1 ].
+ trivial.
+ constructor; trivial. *)
induction 2; [ | constructor ]; trivial.
Qed.
Lemma le_Sn_Sp_inv n p : S n <= S p -> n <= p.
Proof.
inversion 1.
+ constructor.
+ apply le_trans with (2 := H1).
do 2 constructor.
Qed.
Lemma le_Sn_Sp n p : n <= p -> S n <= S p.
Proof.
induction 1; constructor; auto.
Qed.
Lemma le_leb_iff n m : n <= m <-> leb n m = true.
Proof.
split.
+ revert m.
induction n as [ | n IHn ]; intros [ | m ]; simpl; auto.
* inversion 1.
* intro; apply IHn, le_Sn_Sp_inv; auto.
+ revert m.
induction n as [ | n IHn ].
* induction m; simpl; auto.
* intros [ | m ]; simpl; auto.
- discriminate.
- intros H; apply IHn in H.
apply le_Sn_Sp; trivial.
Qed.
Fact le_78_1090 : 78 <= 1090.
Proof.
apply le_leb_iff.
reflexivity.
Qed.
Print le_78_1090.
Require Import Arith.
Fact leb_n_np n p : leb n (n+p) = true.
Proof.
apply le_leb_iff.
rewrite plus_comm.
apply le_n_plus_pn.
Qed.
Print le.
Inductive le' : nat -> nat -> Prop :=
| le'_n : forall n, le' n n
| le'_S : forall n m, le' n m -> le' n (S m).
Print le.
Print and.
Print or.
Print ex.
Print eq.
Print True.
Print False.
Check refl_equal.
Definition two_two_four : 2+2 = 4 := eq_refl.