1 (**************************************************************************)
4 (* ||A|| A project by Andrea Asperti *)
6 (* ||I|| Developers: *)
7 (* ||T|| The HELM team. *)
8 (* ||A|| http://helm.cs.unibo.it *)
10 (* \ / This file is distributed under the terms of the *)
11 (* v GNU General Public License Version 2 *)
13 (**************************************************************************)
15 set "baseuri" "cic:/matita/tests/decl".
17 include "nat/times.ma".
18 include "nat/orders.ma".
20 theorem easy: ∀n,m. n * m = O → n = O ∨ m = O.
24 by (refl_eq ? O) we proved (O = O) (trivial).
25 by (or_introl ? ? trivial) we proved (O = O ∨ m = O) (trivial2).
26 by (λ_.trivial2) we proved (O*m=O → O=O ∨ m=O) (base_case).
29 (∀n1. (n1 * m = O → n1 = O ∨ m = O) → (S n1) * m = O → (S n1) = O ∨ m = O)
32 suppose (n1 * m = O → n1 = O ∨ m = O) (inductive_hyp).
34 by (or_intror ? ? trivial) we proved (S n1 = O ∨ O = O) (pre_base_case2).
35 by (λ_.pre_base_case2) we proved (S n1*O = O → S n1 = O ∨ O = O) (base_case2).
38 (∀m1. (S n1 * m1 = O → S n1 = O ∨ m1 = O) →
39 (S n1 * S m1 = O → S n1 = O ∨ S m1 = O)) (inductive_hyp2).
41 suppose (S n1 * m1 = O → S n1 = O ∨ m1 = O) (useless).
42 suppose (S n1 * S m1 = O) (absurd_hyp).
43 simplify in absurd_hyp.
44 by (sym_eq ? ? ? absurd_hyp) we proved (O = S (m1+n1*S m1)) (absurd_hyp').
45 by (not_eq_O_S ? absurd_hyp') we proved False (the_absurd).
46 by (False_ind ? the_absurd)
49 by (nat_ind (λm.S n1 * m = O → S n1 = O ∨ m = O) base_case2 inductive_hyp2 m)
52 by (nat_ind (λn.n*m=O → n=O ∨ m=O) base_case inductive_case n)
56 theorem easy2: ∀n,m. n * m = O → n = O ∨ m = O.
69 lapply (sym_eq ? ? ? H2);
70 elim (not_eq_O_S ? Hletin)
75 theorem easy15: ∀n,m. n * m = O → n = O ∨ m = O.
79 by _ we proved (O = O) (trivial).
80 by _ we proved (O = O ∨ m = O) (trivial2).
81 by _ we proved (O*m=O → O=O ∨ m=O) (base_case).
84 (∀n1. (n1 * m = O → n1 = O ∨ m = O) → (S n1) * m = O → (S n1) = O ∨ m = O)
87 suppose (n1 * m = O → n1 = O ∨ m = O) (inductive_hyp).
89 by _ we proved (S n1 = O ∨ O = O) (pre_base_case2).
90 by _ we proved (S n1*O = O → S n1 = O ∨ O = O) (base_case2).
93 (∀m1. (S n1 * m1 = O → S n1 = O ∨ m1 = O) →
94 (S n1 * S m1 = O → S n1 = O ∨ S m1 = O)) (inductive_hyp2).
96 suppose (S n1 * m1 = O → S n1 = O ∨ m1 = O) (useless).
97 suppose (S n1 * S m1 = O) (absurd_hyp).
98 simplify in absurd_hyp.
99 by _ we proved (O = S (m1+n1*S m1)) (absurd_hyp').
100 (* BUG: automation failure *)
101 by (not_eq_O_S ? absurd_hyp') we proved False (the_absurd).
102 (* BUG: automation failure *)
103 by (False_ind ? the_absurd)
106 by (nat_ind (λm.S n1 * m = O → S n1 = O ∨ m = O) base_case2 inductive_hyp2 m)
109 by (nat_ind (λn.n*m=O → n=O ∨ m=O) base_case inductive_case n)
113 theorem easy3: ∀A:Prop. (A ∧ ∃n:nat.n ≠ n) → True.
115 suppose (P ∧ ∃m:nat.m ≠ m) (H).
116 by H we have P (H1) and (∃x:nat.x≠x) (H2).
118 by H2 let q:nat such that (q ≠ q) (Ineq).
120 (* the next line is wrong, but for the moment it does the job *)
121 by H2 let q:nat such that False (Ineq).
125 theorem easy4: ∀n,m,p. n = m → S m = S p → n = S p → S n = n.
130 suppose (S m = S p) (K).
131 suppose (n = S p) (L).
132 conclude (S n) = (S m) by (eq_f ? ? ? ? ? H).
134 = n by (sym_eq ? ? ? L)
138 theorem easy45: ∀n,m,p. n = m → S m = S p → n = S p → S n = n.
143 suppose (S m = S p) (K).
144 suppose (n = S p) (L).
145 conclude (S n) = (S m) by _.
151 theorem easy5: ∀n:nat. n*O=O.
153 (* Bug here: False should be n*0=0 *)
154 we proceed by induction on n to prove False.
156 the thesis becomes (O*O=O).
157 by (refl_eq ? O) done.
159 by induction hypothesis we know (m*O=O) (I).
160 the thesis becomes (S m * O = O).
161 (* Bug here: missing that is equivalent to *)
166 inductive tree : Type ≝
168 | Node: tree → tree → tree.
173 | (Node t1 t2) ⇒ S ((size t1) + (size t2))
176 theorem easy6: ∀t. O ≮ O → O < size t → t ≠ Empty.
178 suppose (O ≮ O) (trivial).
179 (*Bug here: False should be something else *)
180 we proceed by induction on t to prove False.
182 the thesis becomes (O < size Empty → Empty ≠ Empty).
183 suppose (O < size Empty) (absurd)
184 that is equivalent to (O < O).
185 (* Here the "natural" language is not natural at all *)
186 we proceed by induction on (trivial absurd) to prove False.
187 (*Bug here: this is what we want
188 case Node (t1:tree) (t2:tree).
189 by induction hypothesis we know (O < size t1 → t1 ≠ Empty) (Ht1).
190 by induction hypothesis we know (O < size t2 → t2 ≠ Empty) (Ht2). *)
191 (*This is the best we can do right now*)
194 by induction hypothesis we know (O < size t1 → t1 ≠ Empty) (Ht1).
196 by induction hypothesis we know (O < size t2 → t2 ≠ Empty) (Ht2).
197 suppose (O < size (Node t1 t2)) (useless).
198 we need to prove (Node t1 t2 ≠ Empty) (final)
199 or equivalently (Node t1 t2 = Empty → False).
200 suppose (Node t1 t2 = Empty) (absurd).
201 (* Discriminate should really generate a theorem to be useful with
202 declarative tactics *)