author  wenzelm 
Wed, 03 Nov 2010 21:53:56 +0100  
changeset 40335  3e4bb6e7c3ca 
parent 39557  fe5722fce758 
child 41310  65631ca437c9 
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 

39557
fe5722fce758
renamed structure PureThy to Pure_Thy and moved most content to Global_Theory, to emphasize that this is globalonly;
wenzelm
parents:
38800
diff
changeset

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

14 

17480  15 
classes "term" 
36452  16 
default_sort "term" 
0  17 

17480  18 
typedecl p 
19 
typedecl o 

0  20 

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

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

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

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

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

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

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

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

0  42 

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

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

17480  46 
fst :: "p=>p" 
47 
snd :: "p=>p" 

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

17480  50 
inl :: "p=>p" 
51 
inr :: "p=>p" 

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

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

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

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

17480  61 
nrm :: p 
62 
NRM :: p 

0  63 

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

38800  66 
parse_translation {* 
67 
let fun proof_tr [p, P] = Const (@{const_syntax Proof}, dummyT) $ P $ p 

68 
in [(@{syntax_const "_Proof"}, proof_tr)] end 

17480  69 
*} 
70 

38800  71 
(*show_proofs = true displays the proof terms  they are ENORMOUS*) 
72 
ML {* val (show_proofs, setup_show_proofs) = Attrib.config_bool "show_proofs" (K false) *} 

73 
setup setup_show_proofs 

74 

75 
print_translation (advanced) {* 

76 
let 

77 
fun proof_tr' ctxt [P, p] = 

78 
if Config.get ctxt show_proofs then Const (@{syntax_const "_Proof"}, dummyT) $ p $ P 

79 
else P 

80 
in [(@{const_syntax Proof}, proof_tr')] end 

81 
*} 

17480  82 

83 
axioms 

0  84 

85 
(**** Propositional logic ****) 

86 

87 
(*Equality*) 

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

89 

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

0  92 

93 
(* Truth and Falsity *) 

94 

17480  95 
TrueI: "tt : True" 
96 
FalseE: "a:False ==> contr(a):P" 

0  97 

98 
(* Conjunction *) 

99 

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

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

0  103 

104 
(* Disjunction *) 

105 

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

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

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

0  110 

111 
(* Implication *) 

112 

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

0  115 

116 
(*Quantifiers*) 

117 

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

0  120 

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

0  123 

124 
(**** Equality between proofs ****) 

125 

17480  126 
prefl: "a : P ==> a = a : P" 
127 
psym: "a = b : P ==> b = a : P" 

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

0  129 

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

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

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

0  135 

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

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

0  139 

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

0  142 

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

145 

146 
(**** Definitions ****) 

147 

17480  148 
not_def: "~P == P>False" 
149 
iff_def: "P<>Q == (P>Q) & (Q>P)" 

0  150 

151 
(*Unique existence*) 

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

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

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

157 

26322  158 
(*** Sequentstyle elimination rules for & > and ALL ***) 
159 

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

163 
shows "?a:R" 

164 
apply (rule assms(2)) 

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

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

167 
done 

168 

36319  169 
schematic_lemma impE: 
26322  170 
assumes "p:P>Q" 
171 
and "q:P" 

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

173 
shows "?p:R" 

174 
apply (rule assms mp)+ 

175 
done 

176 

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

180 
shows "?p:R" 

181 
apply (rule assms spec)+ 

182 
done 

183 

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

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

188 
shows "?p:R" 

189 
apply (rule assms spec)+ 

190 
done 

191 

192 

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

194 

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

198 
unfolding not_def 

199 
apply (assumption  rule assms impI)+ 

200 
done 

201 

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

205 
apply (erule FalseE) 

206 
done 

207 

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

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

212 
shows "?p:Q" 

213 
apply (assumption  rule assms impI notE)+ 

214 
done 

215 

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

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

221 

222 

223 
(*Contrapositive of an inference rule*) 

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

227 
shows "?a:~P" 

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

229 
apply (erule minor) 

230 
done 

231 

232 
(** Unique assumption tactic. 

233 
Ignores proof objects. 

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

235 
**) 

236 

237 
ML {* 

238 
local 

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

240 
in 

241 
val uniq_assume_tac = 

242 
SUBGOAL 

243 
(fn (prem,i) => 

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

245 
and concl = discard_proof (Logic.strip_assums_concl prem) 

246 
in 

247 
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

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

251 
else no_tac 

252 
end); 

253 
end; 

254 
*} 

255 

256 

257 
(*** Modus Ponens Tactics ***) 

258 

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

260 
ML {* 

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

262 
*} 

263 

264 
(*Like mp_tac but instantiates no variables*) 

265 
ML {* 

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

267 
*} 

268 

269 

270 
(*** Ifandonlyif ***) 

271 

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

275 
shows "?p:P<>Q" 

276 
unfolding iff_def 

277 
apply (assumption  rule assms conjI impI)+ 

278 
done 

279 

280 

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

282 

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

286 
shows "?p:R" 

287 
apply (rule conjE) 

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

289 
apply (rule assms(2)) 

290 
apply assumption+ 

291 
done 

292 

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

294 

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

298 
done 

299 

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

303 
done 

304 

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

308 
done 

309 

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

313 
apply (erule (1) mp)+ 

314 
done 

315 

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

319 
done 

320 

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

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

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

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

325 
***) 

326 

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

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

331 
unfolding ex1_def 

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

333 
done 

334 

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

338 
shows "?a : R" 

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

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

29305  341 
apply (erule assms(2), assumption) 
26322  342 
done 
343 

344 

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

346 

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

348 
ML {* 

349 
fun iff_tac prems i = 

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

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

352 
*} 

353 

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

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

358 
apply (insert assms(1)) 

359 
apply (assumption  rule iffI conjI  

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

361 
done 

362 

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

366 
done 

367 

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

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

372 
apply (insert assms(1)) 

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

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

375 
done 

376 

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

380 
done 

381 

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

385 
done 

386 

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

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

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

392 
done 

393 

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

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

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

399 
done 

400 

401 
(*NOT PROVED 

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

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

404 
(fn prems => 

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

406 
ORELSE mp_tac 1 

407 
ORELSE iff_tac prems 1)) ])) 

408 
*) 

409 

410 
(*** Equality rules ***) 

411 

412 
lemmas refl = ieqI 

413 

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

417 
shows "?p : P(b)" 

418 
apply (rule prem2 [THEN rev_mp]) 

419 
apply (rule prem1 [THEN ieqE]) 

420 
apply (rule impI) 

421 
apply assumption 

422 
done 

423 

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

427 
done 

428 

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

432 

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

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

437 
done 

438 

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

440 
lemmas ssubst = sym [THEN subst, standard] 

441 

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

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

446 
apply (rule_tac [2] sym) 

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

448 
done 

449 

450 
(** Polymorphic congruence rules **) 

451 

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

455 
done 

456 

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

460 
done 

461 

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

465 
done 

466 

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

468 
a = b 

469 
  

470 
c = d *) 

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

474 
apply (rule sym) 

475 
apply assumption+ 

476 
done 

477 

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

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

482 
apply (assumption  rule sym)+ 

483 
done 

484 

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

486 

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

490 
done 

491 

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

495 
done 

496 

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

500 
done 

501 

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

502 
lemmas pred_congs = pred1_cong pred2_cong pred3_cong 
26322  503 

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

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

506 

507 

508 
(*** Simplifications of assumed implications. 

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

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

511 
intuitionistic propositional logic. See 

512 
R. Dyckhoff, Contractionfree sequent calculi for intuitionistic logic 

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

514 

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

518 
shows "?p:R" 

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

520 
done 

521 

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

525 
shows "?p:R" 

526 
apply (tactic {* DEPTH_SOLVE (atac 1 ORELSE 

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

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

529 
done 

530 

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

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

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

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

537 
shows "?p:R" 

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

539 
done 

540 

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

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

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

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

547 
shows "?p:R" 

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

549 
done 

550 

551 
(*Simplifies the implication. UNSAFE. *) 

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

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

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

557 
shows "?p:R" 

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

559 
done 

560 

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

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

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

566 
shows "?p:R" 

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

568 
done 

569 

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

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

574 
shows "?p:R" 

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

576 
done 

577 

578 

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

582 
shows "?p:R" 

583 
apply (rule assms)+ 

584 
done 

585 

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

587 

588 
use "hypsubst.ML" 

589 

590 
ML {* 

591 

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

593 

594 
structure Hypsubst_Data = 

595 
struct 

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

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

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

599 

600 
val imp_intr = @{thm impI} 

601 

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

603 
val rev_cut_eq = @{thm rev_cut_eq} 

604 

605 
val rev_mp = @{thm rev_mp} 

606 
val subst = @{thm subst} 

607 
val sym = @{thm sym} 

608 
val thin_refl = @{thm thin_refl} 

609 
end; 

610 

611 
structure Hypsubst = HypsubstFun(Hypsubst_Data); 

612 
open Hypsubst; 

613 
*} 

614 

615 
use "intprover.ML" 

616 

617 

618 
(*** Rewrite rules ***) 

619 

36319  620 
schematic_lemma conj_rews: 
26322  621 
"?p1 : P & True <> P" 
622 
"?p2 : True & P <> P" 

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

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

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

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

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

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

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

630 
done 

631 

36319  632 
schematic_lemma disj_rews: 
26322  633 
"?p1 : P  True <> True" 
634 
"?p2 : True  P <> True" 

635 
"?p3 : P  False <> P" 

636 
"?p4 : False  P <> P" 

637 
"?p5 : P  P <> P" 

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

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

640 
done 

641 

36319  642 
schematic_lemma not_rews: 
26322  643 
"?p1 : ~ False <> True" 
644 
"?p2 : ~ True <> False" 

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

646 
done 

647 

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

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

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

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

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

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

656 
done 

657 

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

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

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

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

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

665 
done 

666 

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

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

671 
done 

672 

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

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

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

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

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

680 
done 

681 

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

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

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

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

688 
done 

689 

690 
lemmas distrib_rews = distrib_rews1 distrib_rews2 

691 

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

695 

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

0  699 

700 
end 