author  haftmann 
Thu, 08 Jul 2010 16:19:24 +0200  
changeset 37744  3daaf23b9ab4 
parent 36452  d37c6eed8117 
child 38522  de7984a7172b 
permissions  rwrr 
1477  1 
(* Title: FOLP/IFOLP.thy 
2 
Author: Martin D Coen, Cambridge University Computer Laboratory 

1142  3 
Copyright 1992 University of Cambridge 
4 
*) 

5 

17480  6 
header {* Intuitionistic FirstOrder Logic with Proofs *} 
7 

8 
theory IFOLP 

9 
imports Pure 

26322  10 
uses ("hypsubst.ML") ("intprover.ML") 
17480  11 
begin 
0  12 

26956
1309a6a0a29f
setup PureThy.old_appl_syntax_setup  theory Pure provides regular application syntax by default;
wenzelm
parents:
26480
diff
changeset

13 
setup PureThy.old_appl_syntax_setup 
1309a6a0a29f
setup PureThy.old_appl_syntax_setup  theory Pure provides regular application syntax by default;
wenzelm
parents:
26480
diff
changeset

14 

3942  15 
global 
16 

17480  17 
classes "term" 
36452  18 
default_sort "term" 
0  19 

17480  20 
typedecl p 
21 
typedecl o 

0  22 

17480  23 
consts 
0  24 
(*** Judgements ***) 
1477  25 
Proof :: "[o,p]=>prop" 
0  26 
EqProof :: "[p,p,o]=>prop" ("(3_ /= _ :/ _)" [10,10,10] 5) 
17480  27 

0  28 
(*** Logical Connectives  Type Formers ***) 
35128  29 
"op =" :: "['a,'a] => o" (infixl "=" 50) 
17480  30 
True :: "o" 
31 
False :: "o" 

2714  32 
Not :: "o => o" ("~ _" [40] 40) 
35128  33 
"op &" :: "[o,o] => o" (infixr "&" 35) 
34 
"op " :: "[o,o] => o" (infixr "" 30) 

35 
"op >" :: "[o,o] => o" (infixr ">" 25) 

36 
"op <>" :: "[o,o] => o" (infixr "<>" 25) 

0  37 
(*Quantifiers*) 
1477  38 
All :: "('a => o) => o" (binder "ALL " 10) 
39 
Ex :: "('a => o) => o" (binder "EX " 10) 

40 
Ex1 :: "('a => o) => o" (binder "EX! " 10) 

0  41 
(*Rewriting gadgets*) 
1477  42 
NORM :: "o => o" 
43 
norm :: "'a => 'a" 

0  44 

648
e27c9ec2b48b
FOLP/IFOLP.thy: tightening precedences to eliminate syntactic ambiguities.
lcp
parents:
283
diff
changeset

45 
(*** Proof Term Formers: precedence must exceed 50 ***) 
1477  46 
tt :: "p" 
47 
contr :: "p=>p" 

17480  48 
fst :: "p=>p" 
49 
snd :: "p=>p" 

1477  50 
pair :: "[p,p]=>p" ("(1<_,/_>)") 
51 
split :: "[p, [p,p]=>p] =>p" 

17480  52 
inl :: "p=>p" 
53 
inr :: "p=>p" 

1477  54 
when :: "[p, p=>p, p=>p]=>p" 
55 
lambda :: "(p => p) => p" (binder "lam " 55) 

35128  56 
"op `" :: "[p,p]=>p" (infixl "`" 60) 
648
e27c9ec2b48b
FOLP/IFOLP.thy: tightening precedences to eliminate syntactic ambiguities.
lcp
parents:
283
diff
changeset

57 
alll :: "['a=>p]=>p" (binder "all " 55) 
35128  58 
"op ^" :: "[p,'a]=>p" (infixl "^" 55) 
1477  59 
exists :: "['a,p]=>p" ("(1[_,/_])") 
0  60 
xsplit :: "[p,['a,p]=>p]=>p" 
61 
ideq :: "'a=>p" 

62 
idpeel :: "[p,'a=>p]=>p" 

17480  63 
nrm :: p 
64 
NRM :: p 

0  65 

3942  66 
local 
67 

35113  68 
syntax "_Proof" :: "[p,o]=>prop" ("(_ /: _)" [51, 10] 5) 
69 

17480  70 
ML {* 
71 

72 
(*show_proofs:=true displays the proof terms  they are ENORMOUS*) 

32740  73 
val show_proofs = Unsynchronized.ref false; 
17480  74 

26322  75 
fun proof_tr [p,P] = Const (@{const_name Proof}, dummyT) $ P $ p; 
17480  76 

77 
fun proof_tr' [P,p] = 

35113  78 
if ! show_proofs then Const (@{syntax_const "_Proof"}, dummyT) $ p $ P 
79 
else P (*this case discards the proof term*); 

17480  80 
*} 
81 

35113  82 
parse_translation {* [(@{syntax_const "_Proof"}, proof_tr)] *} 
83 
print_translation {* [(@{const_syntax Proof}, proof_tr')] *} 

17480  84 

85 
axioms 

0  86 

87 
(**** Propositional logic ****) 

88 

89 
(*Equality*) 

90 
(* Like Intensional Equality in MLTT  but proofs distinct from terms *) 

91 

17480  92 
ieqI: "ideq(a) : a=a" 
93 
ieqE: "[ p : a=b; !!x. f(x) : P(x,x) ] ==> idpeel(p,f) : P(a,b)" 

0  94 

95 
(* Truth and Falsity *) 

96 

17480  97 
TrueI: "tt : True" 
98 
FalseE: "a:False ==> contr(a):P" 

0  99 

100 
(* Conjunction *) 

101 

17480  102 
conjI: "[ a:P; b:Q ] ==> <a,b> : P&Q" 
103 
conjunct1: "p:P&Q ==> fst(p):P" 

104 
conjunct2: "p:P&Q ==> snd(p):Q" 

0  105 

106 
(* Disjunction *) 

107 

17480  108 
disjI1: "a:P ==> inl(a):PQ" 
109 
disjI2: "b:Q ==> inr(b):PQ" 

110 
disjE: "[ a:PQ; !!x. x:P ==> f(x):R; !!x. x:Q ==> g(x):R 

111 
] ==> when(a,f,g):R" 

0  112 

113 
(* Implication *) 

114 

17480  115 
impI: "(!!x. x:P ==> f(x):Q) ==> lam x. f(x):P>Q" 
116 
mp: "[ f:P>Q; a:P ] ==> f`a:Q" 

0  117 

118 
(*Quantifiers*) 

119 

17480  120 
allI: "(!!x. f(x) : P(x)) ==> all x. f(x) : ALL x. P(x)" 
121 
spec: "(f:ALL x. P(x)) ==> f^x : P(x)" 

0  122 

17480  123 
exI: "p : P(x) ==> [x,p] : EX x. P(x)" 
124 
exE: "[ p: EX x. P(x); !!x u. u:P(x) ==> f(x,u) : R ] ==> xsplit(p,f):R" 

0  125 

126 
(**** Equality between proofs ****) 

127 

17480  128 
prefl: "a : P ==> a = a : P" 
129 
psym: "a = b : P ==> b = a : P" 

130 
ptrans: "[ a = b : P; b = c : P ] ==> a = c : P" 

0  131 

17480  132 
idpeelB: "[ !!x. f(x) : P(x,x) ] ==> idpeel(ideq(a),f) = f(a) : P(a,a)" 
0  133 

17480  134 
fstB: "a:P ==> fst(<a,b>) = a : P" 
135 
sndB: "b:Q ==> snd(<a,b>) = b : Q" 

136 
pairEC: "p:P&Q ==> p = <fst(p),snd(p)> : P&Q" 

0  137 

17480  138 
whenBinl: "[ a:P; !!x. x:P ==> f(x) : Q ] ==> when(inl(a),f,g) = f(a) : Q" 
139 
whenBinr: "[ b:P; !!x. x:P ==> g(x) : Q ] ==> when(inr(b),f,g) = g(b) : Q" 

140 
plusEC: "a:PQ ==> when(a,%x. inl(x),%y. inr(y)) = a : PQ" 

0  141 

17480  142 
applyB: "[ a:P; !!x. x:P ==> b(x) : Q ] ==> (lam x. b(x)) ` a = b(a) : Q" 
143 
funEC: "f:P ==> f = lam x. f`x : P" 

0  144 

17480  145 
specB: "[ !!x. f(x) : P(x) ] ==> (all x. f(x)) ^ a = f(a) : P(a)" 
0  146 

147 

148 
(**** Definitions ****) 

149 

17480  150 
not_def: "~P == P>False" 
151 
iff_def: "P<>Q == (P>Q) & (Q>P)" 

0  152 

153 
(*Unique existence*) 

17480  154 
ex1_def: "EX! x. P(x) == EX x. P(x) & (ALL y. P(y) > y=x)" 
0  155 

156 
(*Rewriting  special constants to flag normalized terms and formulae*) 

17480  157 
norm_eq: "nrm : norm(x) = x" 
158 
NORM_iff: "NRM : NORM(P) <> P" 

159 

26322  160 
(*** Sequentstyle elimination rules for & > and ALL ***) 
161 

36319  162 
schematic_lemma conjE: 
26322  163 
assumes "p:P&Q" 
164 
and "!!x y.[ x:P; y:Q ] ==> f(x,y):R" 

165 
shows "?a:R" 

166 
apply (rule assms(2)) 

167 
apply (rule conjunct1 [OF assms(1)]) 

168 
apply (rule conjunct2 [OF assms(1)]) 

169 
done 

170 

36319  171 
schematic_lemma impE: 
26322  172 
assumes "p:P>Q" 
173 
and "q:P" 

174 
and "!!x. x:Q ==> r(x):R" 

175 
shows "?p:R" 

176 
apply (rule assms mp)+ 

177 
done 

178 

36319  179 
schematic_lemma allE: 
26322  180 
assumes "p:ALL x. P(x)" 
181 
and "!!y. y:P(x) ==> q(y):R" 

182 
shows "?p:R" 

183 
apply (rule assms spec)+ 

184 
done 

185 

186 
(*Duplicates the quantifier; for use with eresolve_tac*) 

36319  187 
schematic_lemma all_dupE: 
26322  188 
assumes "p:ALL x. P(x)" 
189 
and "!!y z.[ y:P(x); z:ALL x. P(x) ] ==> q(y,z):R" 

190 
shows "?p:R" 

191 
apply (rule assms spec)+ 

192 
done 

193 

194 

195 
(*** Negation rules, which translate between ~P and P>False ***) 

196 

36319  197 
schematic_lemma notI: 
26322  198 
assumes "!!x. x:P ==> q(x):False" 
199 
shows "?p:~P" 

200 
unfolding not_def 

201 
apply (assumption  rule assms impI)+ 

202 
done 

203 

36319  204 
schematic_lemma notE: "p:~P \<Longrightarrow> q:P \<Longrightarrow> ?p:R" 
26322  205 
unfolding not_def 
206 
apply (drule (1) mp) 

207 
apply (erule FalseE) 

208 
done 

209 

210 
(*This is useful with the special implication rules for each kind of P. *) 

36319  211 
schematic_lemma not_to_imp: 
26322  212 
assumes "p:~P" 
213 
and "!!x. x:(P>False) ==> q(x):Q" 

214 
shows "?p:Q" 

215 
apply (assumption  rule assms impI notE)+ 

216 
done 

217 

218 
(* For substitution int an assumption P, reduce Q to P>Q, substitute into 

27150  219 
this implication, then apply impI to move P back into the assumptions.*) 
36319  220 
schematic_lemma rev_mp: "[ p:P; q:P > Q ] ==> ?p:Q" 
26322  221 
apply (assumption  rule mp)+ 
222 
done 

223 

224 

225 
(*Contrapositive of an inference rule*) 

36319  226 
schematic_lemma contrapos: 
26322  227 
assumes major: "p:~Q" 
228 
and minor: "!!y. y:P==>q(y):Q" 

229 
shows "?a:~P" 

230 
apply (rule major [THEN notE, THEN notI]) 

231 
apply (erule minor) 

232 
done 

233 

234 
(** Unique assumption tactic. 

235 
Ignores proof objects. 

236 
Fails unless one assumption is equal and exactly one is unifiable 

237 
**) 

238 

239 
ML {* 

240 
local 

241 
fun discard_proof (Const (@{const_name Proof}, _) $ P $ _) = P; 

242 
in 

243 
val uniq_assume_tac = 

244 
SUBGOAL 

245 
(fn (prem,i) => 

246 
let val hyps = map discard_proof (Logic.strip_assums_hyp prem) 

247 
and concl = discard_proof (Logic.strip_assums_concl prem) 

248 
in 

249 
if exists (fn hyp => hyp aconv concl) hyps 

29269
5c25a2012975
moved term order operations to structure TermOrd (cf. Pure/term_ord.ML);
wenzelm
parents:
27152
diff
changeset

250 
then case distinct (op =) (filter (fn hyp => Term.could_unify (hyp, concl)) hyps) of 
26322  251 
[_] => assume_tac i 
252 
 _ => no_tac 

253 
else no_tac 

254 
end); 

255 
end; 

256 
*} 

257 

258 

259 
(*** Modus Ponens Tactics ***) 

260 

261 
(*Finds P>Q and P in the assumptions, replaces implication by Q *) 

262 
ML {* 

263 
fun mp_tac i = eresolve_tac [@{thm notE}, make_elim @{thm mp}] i THEN assume_tac i 

264 
*} 

265 

266 
(*Like mp_tac but instantiates no variables*) 

267 
ML {* 

268 
fun int_uniq_mp_tac i = eresolve_tac [@{thm notE}, @{thm impE}] i THEN uniq_assume_tac i 

269 
*} 

270 

271 

272 
(*** Ifandonlyif ***) 

273 

36319  274 
schematic_lemma iffI: 
26322  275 
assumes "!!x. x:P ==> q(x):Q" 
276 
and "!!x. x:Q ==> r(x):P" 

277 
shows "?p:P<>Q" 

278 
unfolding iff_def 

279 
apply (assumption  rule assms conjI impI)+ 

280 
done 

281 

282 

283 
(*Observe use of rewrite_rule to unfold "<>" in metaassumptions (prems) *) 

284 

36319  285 
schematic_lemma iffE: 
26322  286 
assumes "p:P <> Q" 
287 
and "!!x y.[ x:P>Q; y:Q>P ] ==> q(x,y):R" 

288 
shows "?p:R" 

289 
apply (rule conjE) 

290 
apply (rule assms(1) [unfolded iff_def]) 

291 
apply (rule assms(2)) 

292 
apply assumption+ 

293 
done 

294 

295 
(* Destruct rules for <> similar to Modus Ponens *) 

296 

36319  297 
schematic_lemma iffD1: "[ p:P <> Q; q:P ] ==> ?p:Q" 
26322  298 
unfolding iff_def 
299 
apply (rule conjunct1 [THEN mp], assumption+) 

300 
done 

301 

36319  302 
schematic_lemma iffD2: "[ p:P <> Q; q:Q ] ==> ?p:P" 
26322  303 
unfolding iff_def 
304 
apply (rule conjunct2 [THEN mp], assumption+) 

305 
done 

306 

36319  307 
schematic_lemma iff_refl: "?p:P <> P" 
26322  308 
apply (rule iffI) 
309 
apply assumption+ 

310 
done 

311 

36319  312 
schematic_lemma iff_sym: "p:Q <> P ==> ?p:P <> Q" 
26322  313 
apply (erule iffE) 
314 
apply (rule iffI) 

315 
apply (erule (1) mp)+ 

316 
done 

317 

36319  318 
schematic_lemma iff_trans: "[ p:P <> Q; q:Q<> R ] ==> ?p:P <> R" 
26322  319 
apply (rule iffI) 
320 
apply (assumption  erule iffE  erule (1) impE)+ 

321 
done 

322 

323 
(*** Unique existence. NOTE THAT the following 2 quantifications 

324 
EX!x such that [EX!y such that P(x,y)] (sequential) 

325 
EX!x,y such that P(x,y) (simultaneous) 

326 
do NOT mean the same thing. The parser treats EX!x y.P(x,y) as sequential. 

327 
***) 

328 

36319  329 
schematic_lemma ex1I: 
26322  330 
assumes "p:P(a)" 
331 
and "!!x u. u:P(x) ==> f(u) : x=a" 

332 
shows "?p:EX! x. P(x)" 

333 
unfolding ex1_def 

334 
apply (assumption  rule assms exI conjI allI impI)+ 

335 
done 

336 

36319  337 
schematic_lemma ex1E: 
26322  338 
assumes "p:EX! x. P(x)" 
339 
and "!!x u v. [ u:P(x); v:ALL y. P(y) > y=x ] ==> f(x,u,v):R" 

340 
shows "?a : R" 

341 
apply (insert assms(1) [unfolded ex1_def]) 

342 
apply (erule exE conjE  assumption  rule assms(1))+ 

29305  343 
apply (erule assms(2), assumption) 
26322  344 
done 
345 

346 

347 
(*** <> congruence rules for simplification ***) 

348 

349 
(*Use iffE on a premise. For conj_cong, imp_cong, all_cong, ex_cong*) 

350 
ML {* 

351 
fun iff_tac prems i = 

352 
resolve_tac (prems RL [@{thm iffE}]) i THEN 

353 
REPEAT1 (eresolve_tac [asm_rl, @{thm mp}] i) 

354 
*} 

355 

36319  356 
schematic_lemma conj_cong: 
26322  357 
assumes "p:P <> P'" 
358 
and "!!x. x:P' ==> q(x):Q <> Q'" 

359 
shows "?p:(P&Q) <> (P'&Q')" 

360 
apply (insert assms(1)) 

361 
apply (assumption  rule iffI conjI  

362 
erule iffE conjE mp  tactic {* iff_tac @{thms assms} 1 *})+ 

363 
done 

364 

36319  365 
schematic_lemma disj_cong: 
26322  366 
"[ p:P <> P'; q:Q <> Q' ] ==> ?p:(PQ) <> (P'Q')" 
367 
apply (erule iffE disjE disjI1 disjI2  assumption  rule iffI  tactic {* mp_tac 1 *})+ 

368 
done 

369 

36319  370 
schematic_lemma imp_cong: 
26322  371 
assumes "p:P <> P'" 
372 
and "!!x. x:P' ==> q(x):Q <> Q'" 

373 
shows "?p:(P>Q) <> (P'>Q')" 

374 
apply (insert assms(1)) 

375 
apply (assumption  rule iffI impI  erule iffE  tactic {* mp_tac 1 *}  

376 
tactic {* iff_tac @{thms assms} 1 *})+ 

377 
done 

378 

36319  379 
schematic_lemma iff_cong: 
26322  380 
"[ p:P <> P'; q:Q <> Q' ] ==> ?p:(P<>Q) <> (P'<>Q')" 
381 
apply (erule iffE  assumption  rule iffI  tactic {* mp_tac 1 *})+ 

382 
done 

383 

36319  384 
schematic_lemma not_cong: 
26322  385 
"p:P <> P' ==> ?p:~P <> ~P'" 
386 
apply (assumption  rule iffI notI  tactic {* mp_tac 1 *}  erule iffE notE)+ 

387 
done 

388 

36319  389 
schematic_lemma all_cong: 
26322  390 
assumes "!!x. f(x):P(x) <> Q(x)" 
391 
shows "?p:(ALL x. P(x)) <> (ALL x. Q(x))" 

392 
apply (assumption  rule iffI allI  tactic {* mp_tac 1 *}  erule allE  

393 
tactic {* iff_tac @{thms assms} 1 *})+ 

394 
done 

395 

36319  396 
schematic_lemma ex_cong: 
26322  397 
assumes "!!x. f(x):P(x) <> Q(x)" 
398 
shows "?p:(EX x. P(x)) <> (EX x. Q(x))" 

399 
apply (erule exE  assumption  rule iffI exI  tactic {* mp_tac 1 *}  

400 
tactic {* iff_tac @{thms assms} 1 *})+ 

401 
done 

402 

403 
(*NOT PROVED 

404 
bind_thm ("ex1_cong", prove_goal (the_context ()) 

405 
"(!!x.f(x):P(x) <> Q(x)) ==> ?p:(EX! x.P(x)) <> (EX! x.Q(x))" 

406 
(fn prems => 

407 
[ (REPEAT (eresolve_tac [ex1E, spec RS mp] 1 ORELSE ares_tac [iffI,ex1I] 1 

408 
ORELSE mp_tac 1 

409 
ORELSE iff_tac prems 1)) ])) 

410 
*) 

411 

412 
(*** Equality rules ***) 

413 

414 
lemmas refl = ieqI 

415 

36319  416 
schematic_lemma subst: 
26322  417 
assumes prem1: "p:a=b" 
418 
and prem2: "q:P(a)" 

419 
shows "?p : P(b)" 

420 
apply (rule prem2 [THEN rev_mp]) 

421 
apply (rule prem1 [THEN ieqE]) 

422 
apply (rule impI) 

423 
apply assumption 

424 
done 

425 

36319  426 
schematic_lemma sym: "q:a=b ==> ?c:b=a" 
26322  427 
apply (erule subst) 
428 
apply (rule refl) 

429 
done 

430 

36319  431 
schematic_lemma trans: "[ p:a=b; q:b=c ] ==> ?d:a=c" 
26322  432 
apply (erule (1) subst) 
433 
done 

434 

435 
(** ~ b=a ==> ~ a=b **) 

36319  436 
schematic_lemma not_sym: "p:~ b=a ==> ?q:~ a=b" 
26322  437 
apply (erule contrapos) 
438 
apply (erule sym) 

439 
done 

440 

441 
(*calling "standard" reduces maxidx to 0*) 

442 
lemmas ssubst = sym [THEN subst, standard] 

443 

444 
(*A special case of ex1E that would otherwise need quantifier expansion*) 

36319  445 
schematic_lemma ex1_equalsE: "[ p:EX! x. P(x); q:P(a); r:P(b) ] ==> ?d:a=b" 
26322  446 
apply (erule ex1E) 
447 
apply (rule trans) 

448 
apply (rule_tac [2] sym) 

449 
apply (assumption  erule spec [THEN mp])+ 

450 
done 

451 

452 
(** Polymorphic congruence rules **) 

453 

36319  454 
schematic_lemma subst_context: "[ p:a=b ] ==> ?d:t(a)=t(b)" 
26322  455 
apply (erule ssubst) 
456 
apply (rule refl) 

457 
done 

458 

36319  459 
schematic_lemma subst_context2: "[ p:a=b; q:c=d ] ==> ?p:t(a,c)=t(b,d)" 
26322  460 
apply (erule ssubst)+ 
461 
apply (rule refl) 

462 
done 

463 

36319  464 
schematic_lemma subst_context3: "[ p:a=b; q:c=d; r:e=f ] ==> ?p:t(a,c,e)=t(b,d,f)" 
26322  465 
apply (erule ssubst)+ 
466 
apply (rule refl) 

467 
done 

468 

469 
(*Useful with eresolve_tac for proving equalties from known equalities. 

470 
a = b 

471 
  

472 
c = d *) 

36319  473 
schematic_lemma box_equals: "[ p:a=b; q:a=c; r:b=d ] ==> ?p:c=d" 
26322  474 
apply (rule trans) 
475 
apply (rule trans) 

476 
apply (rule sym) 

477 
apply assumption+ 

478 
done 

479 

480 
(*Dual of box_equals: for proving equalities backwards*) 

36319  481 
schematic_lemma simp_equals: "[ p:a=c; q:b=d; r:c=d ] ==> ?p:a=b" 
26322  482 
apply (rule trans) 
483 
apply (rule trans) 

484 
apply (assumption  rule sym)+ 

485 
done 

486 

487 
(** Congruence rules for predicate letters **) 

488 

36319  489 
schematic_lemma pred1_cong: "p:a=a' ==> ?p:P(a) <> P(a')" 
26322  490 
apply (rule iffI) 
491 
apply (tactic {* DEPTH_SOLVE (atac 1 ORELSE eresolve_tac [@{thm subst}, @{thm ssubst}] 1) *}) 

492 
done 

493 

36319  494 
schematic_lemma pred2_cong: "[ p:a=a'; q:b=b' ] ==> ?p:P(a,b) <> P(a',b')" 
26322  495 
apply (rule iffI) 
496 
apply (tactic {* DEPTH_SOLVE (atac 1 ORELSE eresolve_tac [@{thm subst}, @{thm ssubst}] 1) *}) 

497 
done 

498 

36319  499 
schematic_lemma pred3_cong: "[ p:a=a'; q:b=b'; r:c=c' ] ==> ?p:P(a,b,c) <> P(a',b',c')" 
26322  500 
apply (rule iffI) 
501 
apply (tactic {* DEPTH_SOLVE (atac 1 ORELSE eresolve_tac [@{thm subst}, @{thm ssubst}] 1) *}) 

502 
done 

503 

27152
192954a9a549
changed pred_congs: merely cover pred1_cong pred2_cong pred3_cong;
wenzelm
parents:
27150
diff
changeset

504 
lemmas pred_congs = pred1_cong pred2_cong pred3_cong 
26322  505 

506 
(*special case for the equality predicate!*) 

507 
lemmas eq_cong = pred2_cong [where P = "op =", standard] 

508 

509 

510 
(*** Simplifications of assumed implications. 

511 
Roy Dyckhoff has proved that conj_impE, disj_impE, and imp_impE 

512 
used with mp_tac (restricted to atomic formulae) is COMPLETE for 

513 
intuitionistic propositional logic. See 

514 
R. Dyckhoff, Contractionfree sequent calculi for intuitionistic logic 

515 
(preprint, University of St Andrews, 1991) ***) 

516 

36319  517 
schematic_lemma conj_impE: 
26322  518 
assumes major: "p:(P&Q)>S" 
519 
and minor: "!!x. x:P>(Q>S) ==> q(x):R" 

520 
shows "?p:R" 

521 
apply (assumption  rule conjI impI major [THEN mp] minor)+ 

522 
done 

523 

36319  524 
schematic_lemma disj_impE: 
26322  525 
assumes major: "p:(PQ)>S" 
526 
and minor: "!!x y.[ x:P>S; y:Q>S ] ==> q(x,y):R" 

527 
shows "?p:R" 

528 
apply (tactic {* DEPTH_SOLVE (atac 1 ORELSE 

529 
resolve_tac [@{thm disjI1}, @{thm disjI2}, @{thm impI}, 

530 
@{thm major} RS @{thm mp}, @{thm minor}] 1) *}) 

531 
done 

532 

533 
(*Simplifies the implication. Classical version is stronger. 

534 
Still UNSAFE since Q must be provable  backtracking needed. *) 

36319  535 
schematic_lemma imp_impE: 
26322  536 
assumes major: "p:(P>Q)>S" 
537 
and r1: "!!x y.[ x:P; y:Q>S ] ==> q(x,y):Q" 

538 
and r2: "!!x. x:S ==> r(x):R" 

539 
shows "?p:R" 

540 
apply (assumption  rule impI major [THEN mp] r1 r2)+ 

541 
done 

542 

543 
(*Simplifies the implication. Classical version is stronger. 

544 
Still UNSAFE since ~P must be provable  backtracking needed. *) 

36319  545 
schematic_lemma not_impE: 
26322  546 
assumes major: "p:~P > S" 
547 
and r1: "!!y. y:P ==> q(y):False" 

548 
and r2: "!!y. y:S ==> r(y):R" 

549 
shows "?p:R" 

550 
apply (assumption  rule notI impI major [THEN mp] r1 r2)+ 

551 
done 

552 

553 
(*Simplifies the implication. UNSAFE. *) 

36319  554 
schematic_lemma iff_impE: 
26322  555 
assumes major: "p:(P<>Q)>S" 
556 
and r1: "!!x y.[ x:P; y:Q>S ] ==> q(x,y):Q" 

557 
and r2: "!!x y.[ x:Q; y:P>S ] ==> r(x,y):P" 

558 
and r3: "!!x. x:S ==> s(x):R" 

559 
shows "?p:R" 

560 
apply (assumption  rule iffI impI major [THEN mp] r1 r2 r3)+ 

561 
done 

562 

563 
(*What if (ALL x.~~P(x)) > ~~(ALL x.P(x)) is an assumption? UNSAFE*) 

36319  564 
schematic_lemma all_impE: 
26322  565 
assumes major: "p:(ALL x. P(x))>S" 
566 
and r1: "!!x. q:P(x)" 

567 
and r2: "!!y. y:S ==> r(y):R" 

568 
shows "?p:R" 

569 
apply (assumption  rule allI impI major [THEN mp] r1 r2)+ 

570 
done 

571 

572 
(*Unsafe: (EX x.P(x))>S is equivalent to ALL x.P(x)>S. *) 

36319  573 
schematic_lemma ex_impE: 
26322  574 
assumes major: "p:(EX x. P(x))>S" 
575 
and r: "!!y. y:P(a)>S ==> q(y):R" 

576 
shows "?p:R" 

577 
apply (assumption  rule exI impI major [THEN mp] r)+ 

578 
done 

579 

580 

36319  581 
schematic_lemma rev_cut_eq: 
26322  582 
assumes "p:a=b" 
583 
and "!!x. x:a=b ==> f(x):R" 

584 
shows "?p:R" 

585 
apply (rule assms)+ 

586 
done 

587 

588 
lemma thin_refl: "!!X. [p:x=x; PROP W] ==> PROP W" . 

589 

590 
use "hypsubst.ML" 

591 

592 
ML {* 

593 

594 
(*** Applying HypsubstFun to generate hyp_subst_tac ***) 

595 

596 
structure Hypsubst_Data = 

597 
struct 

598 
(*Take apart an equality judgement; otherwise raise Match!*) 

599 
fun dest_eq (Const (@{const_name Proof}, _) $ 

600 
(Const (@{const_name "op ="}, _) $ t $ u) $ _) = (t, u); 

601 

602 
val imp_intr = @{thm impI} 

603 

604 
(*etac rev_cut_eq moves an equality to be the last premise. *) 

605 
val rev_cut_eq = @{thm rev_cut_eq} 

606 

607 
val rev_mp = @{thm rev_mp} 

608 
val subst = @{thm subst} 

609 
val sym = @{thm sym} 

610 
val thin_refl = @{thm thin_refl} 

611 
end; 

612 

613 
structure Hypsubst = HypsubstFun(Hypsubst_Data); 

614 
open Hypsubst; 

615 
*} 

616 

617 
use "intprover.ML" 

618 

619 

620 
(*** Rewrite rules ***) 

621 

36319  622 
schematic_lemma conj_rews: 
26322  623 
"?p1 : P & True <> P" 
624 
"?p2 : True & P <> P" 

625 
"?p3 : P & False <> False" 

626 
"?p4 : False & P <> False" 

627 
"?p5 : P & P <> P" 

628 
"?p6 : P & ~P <> False" 

629 
"?p7 : ~P & P <> False" 

630 
"?p8 : (P & Q) & R <> P & (Q & R)" 

631 
apply (tactic {* fn st => IntPr.fast_tac 1 st *})+ 

632 
done 

633 

36319  634 
schematic_lemma disj_rews: 
26322  635 
"?p1 : P  True <> True" 
636 
"?p2 : True  P <> True" 

637 
"?p3 : P  False <> P" 

638 
"?p4 : False  P <> P" 

639 
"?p5 : P  P <> P" 

640 
"?p6 : (P  Q)  R <> P  (Q  R)" 

641 
apply (tactic {* IntPr.fast_tac 1 *})+ 

642 
done 

643 

36319  644 
schematic_lemma not_rews: 
26322  645 
"?p1 : ~ False <> True" 
646 
"?p2 : ~ True <> False" 

647 
apply (tactic {* IntPr.fast_tac 1 *})+ 

648 
done 

649 

36319  650 
schematic_lemma imp_rews: 
26322  651 
"?p1 : (P > False) <> ~P" 
652 
"?p2 : (P > True) <> True" 

653 
"?p3 : (False > P) <> True" 

654 
"?p4 : (True > P) <> P" 

655 
"?p5 : (P > P) <> True" 

656 
"?p6 : (P > ~P) <> ~P" 

657 
apply (tactic {* IntPr.fast_tac 1 *})+ 

658 
done 

659 

36319  660 
schematic_lemma iff_rews: 
26322  661 
"?p1 : (True <> P) <> P" 
662 
"?p2 : (P <> True) <> P" 

663 
"?p3 : (P <> P) <> True" 

664 
"?p4 : (False <> P) <> ~P" 

665 
"?p5 : (P <> False) <> ~P" 

666 
apply (tactic {* IntPr.fast_tac 1 *})+ 

667 
done 

668 

36319  669 
schematic_lemma quant_rews: 
26322  670 
"?p1 : (ALL x. P) <> P" 
671 
"?p2 : (EX x. P) <> P" 

672 
apply (tactic {* IntPr.fast_tac 1 *})+ 

673 
done 

674 

675 
(*These are NOT supplied by default!*) 

36319  676 
schematic_lemma distrib_rews1: 
26322  677 
"?p1 : ~(PQ) <> ~P & ~Q" 
678 
"?p2 : P & (Q  R) <> P&Q  P&R" 

679 
"?p3 : (Q  R) & P <> Q&P  R&P" 

680 
"?p4 : (P  Q > R) <> (P > R) & (Q > R)" 

681 
apply (tactic {* IntPr.fast_tac 1 *})+ 

682 
done 

683 

36319  684 
schematic_lemma distrib_rews2: 
26322  685 
"?p1 : ~(EX x. NORM(P(x))) <> (ALL x. ~NORM(P(x)))" 
686 
"?p2 : ((EX x. NORM(P(x))) > Q) <> (ALL x. NORM(P(x)) > Q)" 

687 
"?p3 : (EX x. NORM(P(x))) & NORM(Q) <> (EX x. NORM(P(x)) & NORM(Q))" 

688 
"?p4 : NORM(Q) & (EX x. NORM(P(x))) <> (EX x. NORM(Q) & NORM(P(x)))" 

689 
apply (tactic {* IntPr.fast_tac 1 *})+ 

690 
done 

691 

692 
lemmas distrib_rews = distrib_rews1 distrib_rews2 

693 

36319  694 
schematic_lemma P_Imp_P_iff_T: "p:P ==> ?p:(P <> True)" 
26322  695 
apply (tactic {* IntPr.fast_tac 1 *}) 
696 
done 

697 

36319  698 
schematic_lemma not_P_imp_P_iff_F: "p:~P ==> ?p:(P <> False)" 
26322  699 
apply (tactic {* IntPr.fast_tac 1 *}) 
700 
done 

0  701 

702 
end 