author  wenzelm 
Wed, 27 Mar 2013 16:38:25 +0100  
changeset 51553  63327f679cff 
parent 51309  473303ef6e34 
child 52143  36ffe23b25f8 
permissions  rwrr 
41959  1 
(* Title: Sequents/LK0.thy 
7093  2 
Author: Lawrence C Paulson, Cambridge University Computer Laboratory 
3 
Copyright 1993 University of Cambridge 

4 

5 
There may be printing problems if a seqent is in expanded normal form 

35113  6 
(etaexpanded, betacontracted). 
7093  7 
*) 
8 

17481  9 
header {* Classical FirstOrder Sequent Calculus *} 
10 

11 
theory LK0 

12 
imports Sequents 

13 
begin 

7093  14 

17481  15 
classes "term" 
36452  16 
default_sort "term" 
7093  17 

18 
consts 

19 

21524  20 
Trueprop :: "two_seqi" 
7093  21 

17481  22 
True :: o 
23 
False :: o 

22894  24 
equal :: "['a,'a] => o" (infixl "=" 50) 
17481  25 
Not :: "o => o" ("~ _" [40] 40) 
22894  26 
conj :: "[o,o] => o" (infixr "&" 35) 
27 
disj :: "[o,o] => o" (infixr "" 30) 

28 
imp :: "[o,o] => o" (infixr ">" 25) 

29 
iff :: "[o,o] => o" (infixr "<>" 25) 

17481  30 
The :: "('a => o) => 'a" (binder "THE " 10) 
31 
All :: "('a => o) => o" (binder "ALL " 10) 

32 
Ex :: "('a => o) => o" (binder "EX " 10) 

7093  33 

34 
syntax 

35113  35 
"_Trueprop" :: "two_seqe" ("((_)/  (_))" [6,6] 5) 
17481  36 

35113  37 
parse_translation {* [(@{syntax_const "_Trueprop"}, two_seq_tr @{const_syntax Trueprop})] *} 
38 
print_translation {* [(@{const_syntax Trueprop}, two_seq_tr' @{syntax_const "_Trueprop"})] *} 

7093  39 

22894  40 
abbreviation 
41 
not_equal (infixl "~=" 50) where 

42 
"x ~= y == ~ (x = y)" 

7093  43 

35355
613e133966ea
modernized syntax declarations, and make them actually work with authentic syntax;
wenzelm
parents:
35113
diff
changeset

44 
notation (xsymbols) 
613e133966ea
modernized syntax declarations, and make them actually work with authentic syntax;
wenzelm
parents:
35113
diff
changeset

45 
Not ("\<not> _" [40] 40) and 
613e133966ea
modernized syntax declarations, and make them actually work with authentic syntax;
wenzelm
parents:
35113
diff
changeset

46 
conj (infixr "\<and>" 35) and 
613e133966ea
modernized syntax declarations, and make them actually work with authentic syntax;
wenzelm
parents:
35113
diff
changeset

47 
disj (infixr "\<or>" 30) and 
613e133966ea
modernized syntax declarations, and make them actually work with authentic syntax;
wenzelm
parents:
35113
diff
changeset

48 
imp (infixr "\<longrightarrow>" 25) and 
613e133966ea
modernized syntax declarations, and make them actually work with authentic syntax;
wenzelm
parents:
35113
diff
changeset

49 
iff (infixr "\<longleftrightarrow>" 25) and 
613e133966ea
modernized syntax declarations, and make them actually work with authentic syntax;
wenzelm
parents:
35113
diff
changeset

50 
All (binder "\<forall>" 10) and 
613e133966ea
modernized syntax declarations, and make them actually work with authentic syntax;
wenzelm
parents:
35113
diff
changeset

51 
Ex (binder "\<exists>" 10) and 
613e133966ea
modernized syntax declarations, and make them actually work with authentic syntax;
wenzelm
parents:
35113
diff
changeset

52 
not_equal (infixl "\<noteq>" 50) 
7093  53 

35355
613e133966ea
modernized syntax declarations, and make them actually work with authentic syntax;
wenzelm
parents:
35113
diff
changeset

54 
notation (HTML output) 
613e133966ea
modernized syntax declarations, and make them actually work with authentic syntax;
wenzelm
parents:
35113
diff
changeset

55 
Not ("\<not> _" [40] 40) and 
613e133966ea
modernized syntax declarations, and make them actually work with authentic syntax;
wenzelm
parents:
35113
diff
changeset

56 
conj (infixr "\<and>" 35) and 
613e133966ea
modernized syntax declarations, and make them actually work with authentic syntax;
wenzelm
parents:
35113
diff
changeset

57 
disj (infixr "\<or>" 30) and 
613e133966ea
modernized syntax declarations, and make them actually work with authentic syntax;
wenzelm
parents:
35113
diff
changeset

58 
All (binder "\<forall>" 10) and 
613e133966ea
modernized syntax declarations, and make them actually work with authentic syntax;
wenzelm
parents:
35113
diff
changeset

59 
Ex (binder "\<exists>" 10) and 
613e133966ea
modernized syntax declarations, and make them actually work with authentic syntax;
wenzelm
parents:
35113
diff
changeset

60 
not_equal (infixl "\<noteq>" 50) 
7093  61 

51309  62 
axiomatization where 
7093  63 

64 
(*Structural rules: contraction, thinning, exchange [Soren Heilmann] *) 

65 

51309  66 
contRS: "$H  $E, $S, $S, $F ==> $H  $E, $S, $F" and 
67 
contLS: "$H, $S, $S, $G  $E ==> $H, $S, $G  $E" and 

7093  68 

51309  69 
thinRS: "$H  $E, $F ==> $H  $E, $S, $F" and 
70 
thinLS: "$H, $G  $E ==> $H, $S, $G  $E" and 

7093  71 

51309  72 
exchRS: "$H  $E, $R, $S, $F ==> $H  $E, $S, $R, $F" and 
73 
exchLS: "$H, $R, $S, $G  $E ==> $H, $S, $R, $G  $E" and 

7093  74 

51309  75 
cut: "[ $H  $E, P; $H, P  $E ] ==> $H  $E" and 
7093  76 

77 
(*Propositional rules*) 

78 

51309  79 
basic: "$H, P, $G  $E, P, $F" and 
7093  80 

51309  81 
conjR: "[ $H $E, P, $F; $H $E, Q, $F ] ==> $H $E, P&Q, $F" and 
82 
conjL: "$H, P, Q, $G  $E ==> $H, P & Q, $G  $E" and 

7093  83 

51309  84 
disjR: "$H  $E, P, Q, $F ==> $H  $E, PQ, $F" and 
85 
disjL: "[ $H, P, $G  $E; $H, Q, $G  $E ] ==> $H, PQ, $G  $E" and 

7093  86 

51309  87 
impR: "$H, P  $E, Q, $F ==> $H  $E, P>Q, $F" and 
88 
impL: "[ $H,$G  $E,P; $H, Q, $G  $E ] ==> $H, P>Q, $G  $E" and 

7093  89 

51309  90 
notR: "$H, P  $E, $F ==> $H  $E, ~P, $F" and 
91 
notL: "$H, $G  $E, P ==> $H, ~P, $G  $E" and 

7093  92 

51309  93 
FalseL: "$H, False, $G  $E" and 
7093  94 

51309  95 
True_def: "True == False>False" and 
17481  96 
iff_def: "P<>Q == (P>Q) & (Q>P)" 
7093  97 

51309  98 
axiomatization where 
7093  99 
(*Quantifiers*) 
100 

51309  101 
allR: "(!!x.$H  $E, P(x), $F) ==> $H  $E, ALL x. P(x), $F" and 
102 
allL: "$H, P(x), $G, ALL x. P(x)  $E ==> $H, ALL x. P(x), $G  $E" and 

7093  103 

51309  104 
exR: "$H  $E, P(x), $F, EX x. P(x) ==> $H  $E, EX x. P(x), $F" and 
105 
exL: "(!!x.$H, P(x), $G  $E) ==> $H, EX x. P(x), $G  $E" and 

7093  106 

107 
(*Equality*) 

51309  108 
refl: "$H  $E, a=a, $F" and 
109 
subst: "\<And>G H E. $H(a), $G(a)  $E(a) ==> $H(b), a=b, $G(b)  $E(b)" 

7093  110 

111 
(* Reflection *) 

112 

51309  113 
axiomatization where 
114 
eq_reflection: " x=y ==> (x==y)" and 

17481  115 
iff_reflection: " P<>Q ==> (P==Q)" 
7093  116 

117 
(*Descriptions*) 

118 

51309  119 
axiomatization where 
17481  120 
The: "[ $H  $E, P(a), $F; !!x.$H, P(x)  $E, x=a, $F ] ==> 
7093  121 
$H  $E, P(THE x. P(x)), $F" 
122 

51309  123 
definition If :: "[o, 'a, 'a] => 'a" ("(if (_)/ then (_)/ else (_))" 10) 
124 
where "If(P,x,y) == THE z::'a. (P > z=x) & (~P > z=y)" 

7093  125 

21426  126 

127 
(** Structural Rules on formulas **) 

128 

129 
(*contraction*) 

130 

131 
lemma contR: "$H  $E, P, P, $F ==> $H  $E, P, $F" 

132 
by (rule contRS) 

133 

134 
lemma contL: "$H, P, P, $G  $E ==> $H, P, $G  $E" 

135 
by (rule contLS) 

136 

137 
(*thinning*) 

138 

139 
lemma thinR: "$H  $E, $F ==> $H  $E, P, $F" 

140 
by (rule thinRS) 

141 

142 
lemma thinL: "$H, $G  $E ==> $H, P, $G  $E" 

143 
by (rule thinLS) 

144 

145 
(*exchange*) 

146 

147 
lemma exchR: "$H  $E, Q, P, $F ==> $H  $E, P, Q, $F" 

148 
by (rule exchRS) 

149 

150 
lemma exchL: "$H, Q, P, $G  $E ==> $H, P, Q, $G  $E" 

151 
by (rule exchLS) 

152 

153 
ML {* 

154 
(*Cut and thin, replacing the rightside formula*) 

27208
5fe899199f85
proper context for tactics derived from res_inst_tac;
wenzelm
parents:
27146
diff
changeset

155 
fun cutR_tac ctxt s i = 
27239  156 
res_inst_tac ctxt [(("P", 0), s) ] @{thm cut} i THEN rtac @{thm thinR} i 
21426  157 

158 
(*Cut and thin, replacing the leftside formula*) 

27208
5fe899199f85
proper context for tactics derived from res_inst_tac;
wenzelm
parents:
27146
diff
changeset

159 
fun cutL_tac ctxt s i = 
27239  160 
res_inst_tac ctxt [(("P", 0), s)] @{thm cut} i THEN rtac @{thm thinL} (i+1) 
21426  161 
*} 
162 

163 

164 
(** Ifandonlyif rules **) 

165 
lemma iffR: 

166 
"[ $H,P  $E,Q,$F; $H,Q  $E,P,$F ] ==> $H  $E, P <> Q, $F" 

167 
apply (unfold iff_def) 

168 
apply (assumption  rule conjR impR)+ 

169 
done 

170 

171 
lemma iffL: 

172 
"[ $H,$G  $E,P,Q; $H,Q,P,$G  $E ] ==> $H, P <> Q, $G  $E" 

173 
apply (unfold iff_def) 

174 
apply (assumption  rule conjL impL basic)+ 

175 
done 

176 

177 
lemma iff_refl: "$H  $E, (P <> P), $F" 

178 
apply (rule iffR basic)+ 

179 
done 

180 

181 
lemma TrueR: "$H  $E, True, $F" 

182 
apply (unfold True_def) 

183 
apply (rule impR) 

184 
apply (rule basic) 

185 
done 

186 

187 
(*Descriptions*) 

188 
lemma the_equality: 

189 
assumes p1: "$H  $E, P(a), $F" 

190 
and p2: "!!x. $H, P(x)  $E, x=a, $F" 

191 
shows "$H  $E, (THE x. P(x)) = a, $F" 

192 
apply (rule cut) 

193 
apply (rule_tac [2] p2) 

194 
apply (rule The, rule thinR, rule exchRS, rule p1) 

195 
apply (rule thinR, rule exchRS, rule p2) 

196 
done 

197 

198 

199 
(** Weakened quantifier rules. Incomplete, they let the search terminate.**) 

200 

201 
lemma allL_thin: "$H, P(x), $G  $E ==> $H, ALL x. P(x), $G  $E" 

202 
apply (rule allL) 

203 
apply (erule thinL) 

204 
done 

205 

206 
lemma exR_thin: "$H  $E, P(x), $F ==> $H  $E, EX x. P(x), $F" 

207 
apply (rule exR) 

208 
apply (erule thinR) 

209 
done 

210 

211 
(*The rules of LK*) 

212 

213 
ML {* 

214 
val prop_pack = empty_pack add_safes 

39159  215 
[@{thm basic}, @{thm refl}, @{thm TrueR}, @{thm FalseL}, 
216 
@{thm conjL}, @{thm conjR}, @{thm disjL}, @{thm disjR}, @{thm impL}, @{thm impR}, 

217 
@{thm notL}, @{thm notR}, @{thm iffL}, @{thm iffR}]; 

21426  218 

39159  219 
val LK_pack = prop_pack add_safes [@{thm allR}, @{thm exL}] 
220 
add_unsafes [@{thm allL_thin}, @{thm exR_thin}, @{thm the_equality}]; 

21426  221 

39159  222 
val LK_dup_pack = prop_pack add_safes [@{thm allR}, @{thm exL}] 
223 
add_unsafes [@{thm allL}, @{thm exR}, @{thm the_equality}]; 

21426  224 

225 

226 
fun lemma_tac th i = 

39159  227 
rtac (@{thm thinR} RS @{thm cut}) i THEN REPEAT (rtac @{thm thinL} i) THEN rtac th i; 
21426  228 
*} 
229 

42814  230 
method_setup fast_prop = {* Scan.succeed (K (SIMPLE_METHOD' (fast_tac prop_pack))) *} 
231 
method_setup fast = {* Scan.succeed (K (SIMPLE_METHOD' (fast_tac LK_pack))) *} 

232 
method_setup fast_dup = {* Scan.succeed (K (SIMPLE_METHOD' (fast_tac LK_dup_pack))) *} 

233 
method_setup best = {* Scan.succeed (K (SIMPLE_METHOD' (best_tac LK_pack))) *} 

234 
method_setup best_dup = {* Scan.succeed (K (SIMPLE_METHOD' (best_tac LK_dup_pack))) *} 

7093  235 

7118
ee384c7b7416
adding missing declarations for the <<...>> notation
paulson
parents:
7093
diff
changeset

236 

21426  237 
lemma mp_R: 
238 
assumes major: "$H  $E, $F, P > Q" 

239 
and minor: "$H  $E, $F, P" 

240 
shows "$H  $E, Q, $F" 

241 
apply (rule thinRS [THEN cut], rule major) 

242 
apply (tactic "step_tac LK_pack 1") 

243 
apply (rule thinR, rule minor) 

244 
done 

245 

246 
lemma mp_L: 

247 
assumes major: "$H, $G  $E, P > Q" 

248 
and minor: "$H, $G, Q  $E" 

249 
shows "$H, P, $G  $E" 

250 
apply (rule thinL [THEN cut], rule major) 

251 
apply (tactic "step_tac LK_pack 1") 

252 
apply (rule thinL, rule minor) 

253 
done 

254 

255 

256 
(** Two rules to generate left and right rules from implications **) 

257 

258 
lemma R_of_imp: 

259 
assumes major: " P > Q" 

260 
and minor: "$H  $E, $F, P" 

261 
shows "$H  $E, Q, $F" 

262 
apply (rule mp_R) 

263 
apply (rule_tac [2] minor) 

264 
apply (rule thinRS, rule major [THEN thinLS]) 

265 
done 

266 

267 
lemma L_of_imp: 

268 
assumes major: " P > Q" 

269 
and minor: "$H, $G, Q  $E" 

270 
shows "$H, P, $G  $E" 

271 
apply (rule mp_L) 

272 
apply (rule_tac [2] minor) 

273 
apply (rule thinRS, rule major [THEN thinLS]) 

274 
done 

275 

276 
(*Can be used to create implications in a subgoal*) 

277 
lemma backwards_impR: 

278 
assumes prem: "$H, $G  $E, $F, P > Q" 

279 
shows "$H, P, $G  $E, Q, $F" 

280 
apply (rule mp_L) 

281 
apply (rule_tac [2] basic) 

282 
apply (rule thinR, rule prem) 

283 
done 

284 

285 
lemma conjunct1: "P&Q ==> P" 

286 
apply (erule thinR [THEN cut]) 

287 
apply fast 

288 
done 

289 

290 
lemma conjunct2: "P&Q ==> Q" 

291 
apply (erule thinR [THEN cut]) 

292 
apply fast 

293 
done 

294 

295 
lemma spec: " (ALL x. P(x)) ==>  P(x)" 

296 
apply (erule thinR [THEN cut]) 

297 
apply fast 

298 
done 

299 

300 

301 
(** Equality **) 

302 

303 
lemma sym: " a=b > b=a" 

39159  304 
by (tactic {* safe_tac (LK_pack add_safes [@{thm subst}]) 1 *}) 
21426  305 

306 
lemma trans: " a=b > b=c > a=c" 

39159  307 
by (tactic {* safe_tac (LK_pack add_safes [@{thm subst}]) 1 *}) 
21426  308 

309 
(* Symmetry of equality in hypotheses *) 

45602  310 
lemmas symL = sym [THEN L_of_imp] 
21426  311 

312 
(* Symmetry of equality in hypotheses *) 

45602  313 
lemmas symR = sym [THEN R_of_imp] 
21426  314 

315 
lemma transR: "[ $H $E, $F, a=b; $H $E, $F, b=c ] ==> $H $E, a=c, $F" 

316 
by (rule trans [THEN R_of_imp, THEN mp_R]) 

317 

318 
(* Two theorms for rewriting only one instance of a definition: 

319 
the first for definitions of formulae and the second for terms *) 

320 

321 
lemma def_imp_iff: "(A == B) ==>  A <> B" 

322 
apply unfold 

323 
apply (rule iff_refl) 

324 
done 

325 

326 
lemma meta_eq_to_obj_eq: "(A == B) ==>  A = B" 

327 
apply unfold 

328 
apply (rule refl) 

329 
done 

330 

331 

332 
(** ifthenelse rules **) 

333 

334 
lemma if_True: " (if True then x else y) = x" 

335 
unfolding If_def by fast 

336 

337 
lemma if_False: " (if False then x else y) = y" 

338 
unfolding If_def by fast 

339 

340 
lemma if_P: " P ==>  (if P then x else y) = x" 

341 
apply (unfold If_def) 

342 
apply (erule thinR [THEN cut]) 

343 
apply fast 

344 
done 

345 

346 
lemma if_not_P: " ~P ==>  (if P then x else y) = y"; 

347 
apply (unfold If_def) 

348 
apply (erule thinR [THEN cut]) 

349 
apply fast 

350 
done 

351 

352 
end 