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. NPlus zero q r \to q = r.
23 intros. elim H; clear H q r; intros;
29 theorem nplus_gen_succ_1: \forall p,q,r. NPlus (succ p) q r \to
30 \exists s. r = (succ s) \land NPlus p q s.
31 intros. elim H; clear H q r; intros;
35 rewrite > H1. clear H1 n2
36 ]; apply ex_intro; [| auto || auto ]. (**)
39 theorem nplus_gen_zero_2: \forall p,r. NPlus p zero r \to p = r.
40 intros. inversion H; clear H; intros;
43 lapply eq_gen_zero_succ to H2 as H0. apply H0
47 theorem nplus_gen_succ_2: \forall p,q,r. NPlus p (succ q) r \to
48 \exists s. r = (succ s) \land NPlus p q s.
49 intros. inversion H; clear H; intros;
50 [ lapply eq_gen_succ_zero to H as H0. apply H0
52 lapply linear eq_gen_succ_succ to H2 as H0.
53 rewrite > H0. clear H0 q.
54 apply ex_intro; [| auto ] (**)
58 theorem nplus_gen_zero_3: \forall p,q. NPlus p q zero \to p = zero \land q = zero.
59 intros. inversion H; clear H; intros;
60 [ rewrite < H1. clear H1 p.
63 lapply eq_gen_zero_succ to H3 as H0. apply H0
67 theorem nplus_gen_succ_3: \forall p,q,r. NPlus p q (succ r) \to
68 \exists s. p = succ s \land NPlus s q r \lor
69 q = succ s \land NPlus p s r.
70 intros. inversion H; clear H; intros;
71 [ rewrite < H1. clear H1 p
73 lapply linear eq_gen_succ_succ to H3 as H0.
74 rewrite > H0. clear H0 r.
75 ]; apply ex_intro; [| auto || auto ] (**)
78 (* alternative proofs invoking nplus_gen_2 *)
80 variant nplus_gen_zero_3_alt: \forall p,q. NPlus p q zero \to p = zero \land q = zero.
81 intros 2. elim q; clear q; intros;
82 [ lapply linear nplus_gen_zero_2 to H as H0.
83 rewrite > H0. clear H0 p.
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. NPlus p q (succ r) \to
93 \exists s. p = succ s \land NPlus s q r \lor
94 q = succ s \land NPlus p s r.
95 intros 2. elim q; clear q; intros;
96 [ lapply linear nplus_gen_zero_2 to H as H0.
97 rewrite > H0. clear H0 p
99 lapply linear nplus_gen_succ_2 to H1 as H0.
101 lapply linear eq_gen_succ_succ to H1 as H0.
102 rewrite > H0. clear H0 r.
103 ]; apply ex_intro; [| auto || auto ]. (**)
106 (* other simplification lemmas *)
108 theorem nplus_gen_eq_2_3: \forall p,q. NPlus 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.
111 rewrite > H0. clear H0 p
112 | lapply linear nplus_gen_succ_2 to H1 as H0.
114 lapply linear eq_gen_succ_succ to H2 as H0.
115 rewrite < H0 in H3. clear H0 a
119 theorem nplus_gen_eq_1_3: \forall p,q. NPlus 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.
122 rewrite > H0. clear H0 q
123 | lapply linear nplus_gen_succ_1 to H1 as H0.
125 lapply linear eq_gen_succ_succ to H2 as H0.
126 rewrite < H0 in H3. clear H0 a