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 include "logic/pts.ma".
16 include "logic/equality.ma".
18 ncoinductive cprop: Type[0] ≝
21 | maybe: cprop → cprop.
24 ∀c. c = match c with [ false ⇒ false | true ⇒ true | maybe c ⇒ maybe c ].
28 ninductive cconv : cprop → cprop → CProp[0] ≝
29 true_true: cconv true true
30 | false_false: cconv false false
31 | maybe1: ∀c1,c2. cconv c1 c2 → cconv (maybe c1) c2
32 | maybe2: ∀c1,c2. cconv c1 c2 → cconv c1 (maybe c2).
34 ncoinductive cdiv: cprop → cprop → CProp[0] ≝
35 cdodiv: ∀c,d. cdiv c d → cdiv (maybe c) (maybe d).
37 ndefinition cdiv1: ∀c. cdiv (maybe false) c → False.
38 #c K; ninversion K; #a b K1 K2 K3; ndestruct; ninversion K1; #; ndestruct.
41 ndefinition cdiv2: ∀c. cdiv (maybe true) c → False.
42 #c K; ninversion K; #a b K1 K2 K3; ndestruct; ninversion K1; #; ndestruct.
45 ndefinition cdiv3: ∀c. cdiv c false → False.
46 #c K; ninversion K; #; ndestruct.
49 ndefinition cdiv4: ∀c. cdiv c true → False.
50 #c K; ninversion K; #; ndestruct.
53 nlet corec cdiv5 c d (K: cdiv (maybe c) d) : cdiv c d ≝ ?.
54 ngeneralize in match K; ncases c
55 [ #E; ncases (cdiv1 … E)
56 | #E; ncases (cdiv2 … E)
58 [ #e E; ncases (cdiv3 … E)
59 | #e E; ncases (cdiv4 … E)
60 | #x y K1; @; napply cdiv5; ninversion K1; #; ndestruct; nassumption]##]
63 nlemma cconv_cdiv_false: ∀c,d,e. cconv c e → cdiv c d → False.
65 [##1,2: #U; ninversion U; #; ndestruct
69 ndefinition ceq ≝ λc1,c2. cconv c1 c2 ∨ cdiv c1 c2.
71 ndefinition committed ≝ λc. ceq c c.
73 nrecord cval : Type[0] ≝ {
75 ccomm: committed ccarr
78 ntheorem ceq_refl: ∀c:cval. ceq c c.
82 nlet corec cdiv_sym c d (K: cdiv c d) : cdiv d c ≝ ?.
86 nlet rec cconv_sym c d (K: cconv c d) on K : cconv d c ≝ ?.
90 ntheorem ceq_sym: ∀c,d:cval. ceq c d → ceq d c.
91 #x; ncases x; #c Kc; #y; ncases y; #d Kd;
92 ncases Kc; #K1; *; /3/.
95 nlet corec cand c1 c2 : cprop ≝
103 | maybe d ⇒ maybe (cand c d) ]].
105 nlemma cand_false: ∀c. cand false c = false.
106 #c; ncases c; nrewrite > (ccases (cand …)); //; #d;
107 nrewrite > (ccases (cand …)); //.
110 nlemma cand_true: ∀c. cand true c = c.
111 #c; ncases c; nrewrite > (ccases (cand \ldots)); //; #d;
112 nrewrite > (ccases (cand …)); //.
115 ntheorem cand_true: ∀c1,c2. ceq c1 true → ceq (cand c1 c2) c2.
117 [##2: #X; ncases (cdiv4 … X)
118 | #E; ninversion E (* induction inversion qui *)
119 [ #_; #_; nrewrite > (cand_true …); napply ceq_refl;
123 ncoinductive cprop: Type[0] ≝
126 | hmm: cprop → cprop.
128 nlet corec cand c1 c2 : cprop ≝
132 | hmm c ⇒ hmm (cand c c2) ].
134 nlet corec cor c1 c2 : cprop ≝
138 | hmm c ⇒ hmm (cor c c2) ].
140 nlet corec cimpl c1 c2 : cprop ≝
146 | hmm c ⇒ hmm (cimpl c c2) ]
148 | hmm c ⇒ hmm (cimpl c1 c) ].
150 include "Plogic/equality.ma".
152 nlet corec ceq c1 c2 : cprop ≝
158 | hmm c ⇒ hmm (ceq c1 c) ]
160 | hmm c ⇒ hmm (ceq c c2) ].
162 ninductive holds: cprop → Prop ≝
163 holds_true: holds true
164 | holds_hmm: ∀c. holds c → holds (hmm c).
166 include "Plogic/connectives.ma".
173 | hmm c' ⇒ holds c'].
174 #c; #H; ninversion H; //.
182 | hmm c' ⇒ holds c'] → holds c ≝ ?.
183 #c; ncases c; nnormalize; /2/; *.
187 naxiom cimpl1: ∀c. holds (cimpl true c) → holds c.
189 nlemma ceq1: ∀c. holds c → holds (ceq c true).
193 ncoinductive EQ: cprop → cprop → Prop ≝
194 EQ_true: EQ true true
195 | EQ_false: EQ false false
196 | EQ_hmm1: ∀x,y. EQ x y → EQ (hmm x) y
197 | EQ_hmm2: ∀x,y. EQ x y → EQ x (hmm y).
199 naxiom daemon: False.
201 nlet corec tech1 x: ∀y. EQ (hmm x) y → EQ x y ≝ ?.
203 [##1,2: #X; ninversion X; #; ndestruct; //
204 | #c; #X; ninversion X; #; ndestruct; //;
205 @4; ncases daemon (* napply tech1; //*) (* BUG GBC??? *)
214 | hmm c' ⇒ EQ c' d] ≝ ?.
215 #c d H; ninversion H; //;
216 #x y H H1 H2; ndestruct; ncases x in H ⊢ %; nnormalize; #; @4; //;
225 | hmm c' ⇒ EQ c' d] → EQ c d ≝ ?.
226 #c; ncases c; nnormalize; /2/.
229 nlet corec heyting5 x: ∀y. EQ (cimpl (cand x y) x) true ≝ ?.
230 #y; napply Ccases2; ncases x; ncases y; nnormalize; /3/
231 [ #c; napply heyting5;
234 nlemma heyting3: ∀x,y. holds (cimpl x (cimpl y x)).
235 #x; #y; ncases x; ncases y; /3/; nnormalize
236 [ #d; napply ccases2; nnormalize; napply ccases2; nnormalize;
238 nlemma heyting1: ∀x,y. holds (cimpl x y) → holds (cimpl y x) → holds (ceq x y).
239 #x y; #H; ngeneralize in match (refl … (cimpl x y));
240 nelim H in ⊢ (???% → % → %)
241 [ #K1; #K2; nrewrite > K1 in K2; #X1;
243 napply ccases2; nlapply (ccases1 … H1); nlapply (ccases1 … H2);
244 ncases x; ncases y; nnormalize; /2/
245 [ #c; #H3 H4; nlapply (cimpl1 … H3); napply ceq1
251 [ #H1; ninversion H1; ##[##1,4: #; ndestruct]
252 ##[ ncases (cimpl true false);
253 [ ninversion H1; #; ndestruct;