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/RELATIONAL/NPlus/fwd".
18 include "NPlus/defs.ma".
20 (* primitive generation lemmas proved by elimination and inversion *)
22 theorem nplus_gen_zero_1: \forall q,r. (zero + q == r) \to q = r.
23 intros. elim H; clear H q r; intros;
25 | clear H1. auto new timeout=30
29 theorem nplus_gen_succ_1: \forall p,q,r. ((succ p) + q == r) \to
30 \exists s. r = (succ s) \land p + q == s.
31 intros. elim H; clear H q r; intros;
36 ]; apply ex_intro; [| auto new timeout=30 || auto new timeout=30 ]. (**)
39 theorem nplus_gen_zero_2: \forall p,r. (p + zero == r) \to p = r.
40 intros. inversion H; clear H; intros;
43 lapply eq_gen_zero_succ to H2 as H0. decompose.
47 theorem nplus_gen_succ_2: \forall p,q,r. (p + (succ q) == r) \to
48 \exists s. r = (succ s) \land p + q == s.
49 intros. inversion H; clear H; intros;
50 [ lapply eq_gen_succ_zero to H as H0. decompose.
52 lapply linear eq_gen_succ_succ to H2 as H0.
54 apply ex_intro; [| auto new timeout=30 ] (**)
58 theorem nplus_gen_zero_3: \forall p,q. (p + q == zero) \to
59 p = zero \land q = zero.
60 intros. inversion H; clear H; intros;
61 [ subst. auto new timeout=30
63 lapply eq_gen_zero_succ to H3 as H0. decompose.
67 theorem nplus_gen_succ_3: \forall p,q,r. (p + q == (succ r)) \to
68 \exists s. p = succ s \land (s + q == r) \lor
69 q = succ s \land p + s == r.
70 intros. inversion H; clear H; intros;
73 lapply linear eq_gen_succ_succ to H3 as H0.
75 ]; apply ex_intro; [| auto new timeout=30 || auto new timeout=30 ] (**)
78 (* alternative proofs invoking nplus_gen_2 *)
80 variant nplus_gen_zero_3_alt: \forall p,q. (p + q == zero) \to
81 p = zero \land q = zero.
82 intros 2. elim q; clear q; intros;
83 [ lapply linear nplus_gen_zero_2 to H as H0.
84 subst. auto new timeout=30
86 lapply linear nplus_gen_succ_2 to H1 as H0.
88 lapply linear eq_gen_zero_succ to H1 as H0. apply H0
92 variant nplus_gen_succ_3_alt: \forall p,q,r. (p + q == (succ r)) \to
93 \exists s. p = succ s \land (s + q == r) \lor
94 q = succ s \land p + s == r.
95 intros 2. elim q; clear q; intros;
96 [ lapply linear nplus_gen_zero_2 to H as H0.
99 lapply linear nplus_gen_succ_2 to H1 as H0.
101 lapply linear eq_gen_succ_succ to H1 as H0.
103 ]; apply ex_intro; [| auto new timeout=30 || auto new timeout=30 ]. (**)
106 (* other simplification lemmas *)
108 theorem nplus_gen_eq_2_3: \forall p,q. (p + q == q) \to p = zero.
109 intros 2. elim q; clear q; intros;
110 [ lapply linear nplus_gen_zero_2 to H as H0.
112 | lapply linear nplus_gen_succ_2 to H1 as H0.
114 lapply linear eq_gen_succ_succ to H2 as H0.
116 ]; auto new timeout=30.
119 theorem nplus_gen_eq_1_3: \forall p,q. (p + q == p) \to q = zero.
120 intros 1. elim p; clear p; intros;
121 [ lapply linear nplus_gen_zero_1 to H as H0.
123 | lapply linear nplus_gen_succ_1 to H1 as H0.
125 lapply linear eq_gen_succ_succ to H2 as H0.
127 ]; auto new timeout=30.