forked from mvmramos/pumping
-
Notifications
You must be signed in to change notification settings - Fork 0
/
misc_arith.v
222 lines (201 loc) · 3.53 KB
/
misc_arith.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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
(* ---------------------------------------------------------------------
This file contains definitions and proof scripts related to
(i) closure operations for context-free grammars,
(ii) context-free grammars simplification
(iii) context-free grammar Chomsky normalization and
(iv) pumping lemma for context-free languages.
More information can be found in the paper "Formalization of the
pumping lemma for context-free languages", submitted to
LATA 2016.
Marcus Vinícius Midena Ramos
--------------------------------------------------------------------- *)
(* --------------------------------------------------------------------- *)
(* BASIC LEMMAS *)
(* --------------------------------------------------------------------- *)
Require Import Ring.
Require Import Omega.
Require Import NPeano.
Require Import Even.
Require Import NZPow.
Lemma lep1m2_ltp1:
forall i x: nat, i <= x + 1 - 2 -> i < x + 1.
Proof.
intros i x H.
omega.
Qed.
Lemma lep1m2_lt:
forall i x: nat, x > 0 -> i <= x + 1 - 2 -> i < x.
Proof.
intros i x H1 H2.
omega.
Qed.
Lemma gt_any_gt_0:
forall i j: nat,
i > j -> i > 0.
Proof.
intros i j H.
destruct i.
- apply lt_n_0 in H.
contradiction.
- apply gt_Sn_O.
Qed.
Lemma lt_1_eq_0:
forall i: nat,
i < 1 -> i = 0.
Proof.
intros i H.
destruct i.
- reflexivity.
- apply lt_S_n in H.
apply lt_n_0 in H.
contradiction.
Qed.
Lemma n_minus_1:
forall n: nat,
n <> 0 -> n-1 < n.
Proof.
intros n H.
destruct n.
- omega.
- omega.
Qed.
Lemma gt_zero_exists:
forall i: nat,
i > 0 ->
exists j: nat, i = S j.
Proof.
intros i H.
destruct i.
- omega.
- exists i.
reflexivity.
Qed.
Lemma max_n_n:
forall n: nat,
max n n = n.
Proof.
induction n.
- simpl.
reflexivity.
- simpl.
rewrite IHn.
reflexivity.
Qed.
Lemma max_n_0:
forall n: nat,
max n 0 = n.
Proof.
destruct n.
- simpl.
reflexivity.
- simpl.
reflexivity.
Qed.
Definition injective (A B: Type) (f: A -> B): Prop:=
forall e1 e2: A,
f e1 = f e2 -> e1 = e2.
Lemma odd_1:
odd 1.
Proof.
apply odd_S.
apply even_O.
Qed.
Lemma pow_le:
forall n n1 n2: nat,
n > 0 ->
n1 <= n2 ->
n ^ n1 <= n ^ n2.
Proof.
intros n n1 n2 H1 H2.
apply Nat.pow_le_mono_r.
- omega.
- exact H2.
Qed.
Lemma pow_lt:
forall n n1 n2: nat,
n > 1 ->
n1 < n2 ->
n ^ n1 < n ^ n2.
Proof.
intros n n1 n2 H1 H2.
apply Nat.pow_lt_mono_r.
- exact H1.
- exact H2.
Qed.
Lemma nat_struct:
forall n: nat,
n = 0 \/ exists n': nat, n = S n'.
destruct n.
- left.
reflexivity.
- right.
exists n.
reflexivity.
Qed.
Lemma sum_double:
forall n: nat,
n + n = 2 * n.
Proof.
induction n.
- simpl.
reflexivity.
- rewrite plus_Sn_m.
rewrite plus_comm.
rewrite plus_Sn_m.
rewrite IHn.
simpl.
repeat rewrite plus_0_r.
symmetry.
rewrite plus_comm.
rewrite plus_Sn_m.
reflexivity.
Qed.
Lemma add_exp:
forall n: nat,
n >= 1 -> 2 * 2 ^ (n - 1) = 2 ^ n.
Proof.
destruct n.
- intros H.
omega.
- intros H.
assert (H1: n = 0 \/ n >= 1) by omega.
destruct H1 as [H1 | H1].
+ subst.
simpl.
reflexivity.
+ simpl.
rewrite <- minus_n_O.
rewrite <- plus_n_O.
reflexivity.
Qed.
Lemma ge_exists:
forall x y: nat,
x >= y ->
exists z: nat,
x = z + y.
Proof.
induction y.
- intros H.
exists x.
rewrite plus_0_r.
reflexivity.
- intros H.
assert (H1: x >= y) by omega.
specialize (IHy H1).
destruct IHy as [z IHy].
rewrite IHy.
exists (z - 1).
assert (H2: z >= 1) by omega.
omega.
Qed.
Lemma pow_2_gt_0:
forall n: nat,
2 ^ n > 0.
Proof.
induction n.
- simpl.
omega.
- simpl.
omega.
Qed.