author | wenzelm |
Wed, 22 Feb 2006 22:18:31 +0100 | |
changeset 19120 | 353d349740de |
parent 18861 | 38269ef5175a |
child 19363 | 667b5ea637dd |
permissions | -rw-r--r-- |
1268 | 1 |
(* Title: FOL/IFOL.thy |
35 | 2 |
ID: $Id$ |
11677 | 3 |
Author: Lawrence C Paulson and Markus Wenzel |
4 |
*) |
|
35 | 5 |
|
11677 | 6 |
header {* Intuitionistic first-order logic *} |
35 | 7 |
|
15481 | 8 |
theory IFOL |
9 |
imports Pure |
|
16417 | 10 |
uses ("IFOL_lemmas.ML") ("fologic.ML") ("hypsubstdata.ML") ("intprover.ML") |
15481 | 11 |
begin |
7355
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
12 |
|
0 | 13 |
|
11677 | 14 |
subsection {* Syntax and axiomatic basis *} |
15 |
||
3906 | 16 |
global |
17 |
||
14854 | 18 |
classes "term" |
18523 | 19 |
finalconsts term_class |
7355
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
20 |
defaultsort "term" |
0 | 21 |
|
7355
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
22 |
typedecl o |
79 | 23 |
|
11747 | 24 |
judgment |
25 |
Trueprop :: "o => prop" ("(_)" 5) |
|
0 | 26 |
|
11747 | 27 |
consts |
7355
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
28 |
True :: o |
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
29 |
False :: o |
79 | 30 |
|
31 |
(* Connectives *) |
|
32 |
||
17276 | 33 |
"op =" :: "['a, 'a] => o" (infixl "=" 50) |
35 | 34 |
|
7355
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
35 |
Not :: "o => o" ("~ _" [40] 40) |
17276 | 36 |
"op &" :: "[o, o] => o" (infixr "&" 35) |
37 |
"op |" :: "[o, o] => o" (infixr "|" 30) |
|
38 |
"op -->" :: "[o, o] => o" (infixr "-->" 25) |
|
39 |
"op <->" :: "[o, o] => o" (infixr "<->" 25) |
|
79 | 40 |
|
41 |
(* Quantifiers *) |
|
42 |
||
7355
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
43 |
All :: "('a => o) => o" (binder "ALL " 10) |
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
44 |
Ex :: "('a => o) => o" (binder "EX " 10) |
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
45 |
Ex1 :: "('a => o) => o" (binder "EX! " 10) |
79 | 46 |
|
0 | 47 |
|
19120
353d349740de
not_equal: replaced syntax translation by abbreviation;
wenzelm
parents:
18861
diff
changeset
|
48 |
abbreviation (output) |
353d349740de
not_equal: replaced syntax translation by abbreviation;
wenzelm
parents:
18861
diff
changeset
|
49 |
not_equal :: "['a, 'a] => o" (infixl "~=" 50) |
353d349740de
not_equal: replaced syntax translation by abbreviation;
wenzelm
parents:
18861
diff
changeset
|
50 |
"x ~= y == ~ (x = y)" |
79 | 51 |
|
12114
a8e860c86252
eliminated old "symbols" syntax, use "xsymbols" instead;
wenzelm
parents:
12019
diff
changeset
|
52 |
syntax (xsymbols) |
11677 | 53 |
Not :: "o => o" ("\<not> _" [40] 40) |
54 |
"op &" :: "[o, o] => o" (infixr "\<and>" 35) |
|
55 |
"op |" :: "[o, o] => o" (infixr "\<or>" 30) |
|
56 |
"ALL " :: "[idts, o] => o" ("(3\<forall>_./ _)" [0, 10] 10) |
|
57 |
"EX " :: "[idts, o] => o" ("(3\<exists>_./ _)" [0, 10] 10) |
|
58 |
"EX! " :: "[idts, o] => o" ("(3\<exists>!_./ _)" [0, 10] 10) |
|
19120
353d349740de
not_equal: replaced syntax translation by abbreviation;
wenzelm
parents:
18861
diff
changeset
|
59 |
not_equal :: "['a, 'a] => o" (infixl "\<noteq>" 50) |
11677 | 60 |
"op -->" :: "[o, o] => o" (infixr "\<longrightarrow>" 25) |
61 |
"op <->" :: "[o, o] => o" (infixr "\<longleftrightarrow>" 25) |
|
35 | 62 |
|
6340 | 63 |
syntax (HTML output) |
11677 | 64 |
Not :: "o => o" ("\<not> _" [40] 40) |
14565 | 65 |
"op &" :: "[o, o] => o" (infixr "\<and>" 35) |
66 |
"op |" :: "[o, o] => o" (infixr "\<or>" 30) |
|
67 |
"ALL " :: "[idts, o] => o" ("(3\<forall>_./ _)" [0, 10] 10) |
|
68 |
"EX " :: "[idts, o] => o" ("(3\<exists>_./ _)" [0, 10] 10) |
|
69 |
"EX! " :: "[idts, o] => o" ("(3\<exists>!_./ _)" [0, 10] 10) |
|
19120
353d349740de
not_equal: replaced syntax translation by abbreviation;
wenzelm
parents:
18861
diff
changeset
|
70 |
not_equal :: "['a, 'a] => o" (infixl "\<noteq>" 50) |
6340 | 71 |
|
72 |
||
3932 | 73 |
local |
3906 | 74 |
|
14236 | 75 |
finalconsts |
76 |
False All Ex |
|
77 |
"op =" |
|
78 |
"op &" |
|
79 |
"op |" |
|
80 |
"op -->" |
|
81 |
||
7355
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
82 |
axioms |
0 | 83 |
|
79 | 84 |
(* Equality *) |
0 | 85 |
|
7355
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
86 |
refl: "a=a" |
0 | 87 |
|
79 | 88 |
(* Propositional logic *) |
0 | 89 |
|
7355
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
90 |
conjI: "[| P; Q |] ==> P&Q" |
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
91 |
conjunct1: "P&Q ==> P" |
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
92 |
conjunct2: "P&Q ==> Q" |
0 | 93 |
|
7355
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
94 |
disjI1: "P ==> P|Q" |
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
95 |
disjI2: "Q ==> P|Q" |
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
96 |
disjE: "[| P|Q; P ==> R; Q ==> R |] ==> R" |
0 | 97 |
|
7355
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
98 |
impI: "(P ==> Q) ==> P-->Q" |
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
99 |
mp: "[| P-->Q; P |] ==> Q" |
0 | 100 |
|
7355
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
101 |
FalseE: "False ==> P" |
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
102 |
|
79 | 103 |
(* Quantifiers *) |
0 | 104 |
|
7355
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
105 |
allI: "(!!x. P(x)) ==> (ALL x. P(x))" |
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
106 |
spec: "(ALL x. P(x)) ==> P(x)" |
0 | 107 |
|
7355
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
108 |
exI: "P(x) ==> (EX x. P(x))" |
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
109 |
exE: "[| EX x. P(x); !!x. P(x) ==> R |] ==> R" |
0 | 110 |
|
111 |
(* Reflection *) |
|
112 |
||
7355
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
113 |
eq_reflection: "(x=y) ==> (x==y)" |
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
114 |
iff_reflection: "(P<->Q) ==> (P==Q)" |
0 | 115 |
|
4092 | 116 |
|
15377 | 117 |
text{*Thanks to Stephan Merz*} |
118 |
theorem subst: |
|
119 |
assumes eq: "a = b" and p: "P(a)" |
|
120 |
shows "P(b)" |
|
121 |
proof - |
|
122 |
from eq have meta: "a \<equiv> b" |
|
123 |
by (rule eq_reflection) |
|
124 |
from p show ?thesis |
|
125 |
by (unfold meta) |
|
126 |
qed |
|
127 |
||
128 |
||
14236 | 129 |
defs |
130 |
(* Definitions *) |
|
131 |
||
132 |
True_def: "True == False-->False" |
|
133 |
not_def: "~P == P-->False" |
|
134 |
iff_def: "P<->Q == (P-->Q) & (Q-->P)" |
|
135 |
||
136 |
(* Unique existence *) |
|
137 |
||
138 |
ex1_def: "Ex1(P) == EX x. P(x) & (ALL y. P(y) --> y=x)" |
|
139 |
||
13779 | 140 |
|
11677 | 141 |
subsection {* Lemmas and proof tools *} |
142 |
||
9886 | 143 |
use "IFOL_lemmas.ML" |
11734 | 144 |
|
18481 | 145 |
ML {* |
146 |
structure ProjectRule = ProjectRuleFun |
|
147 |
(struct |
|
148 |
val conjunct1 = thm "conjunct1"; |
|
149 |
val conjunct2 = thm "conjunct2"; |
|
150 |
val mp = thm "mp"; |
|
151 |
end) |
|
152 |
*} |
|
153 |
||
7355
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
154 |
use "fologic.ML" |
9886 | 155 |
use "hypsubstdata.ML" |
156 |
setup hypsubst_setup |
|
7355
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
157 |
use "intprover.ML" |
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
158 |
|
4092 | 159 |
|
12875 | 160 |
subsection {* Intuitionistic Reasoning *} |
12368 | 161 |
|
12349 | 162 |
lemma impE': |
12937
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12875
diff
changeset
|
163 |
assumes 1: "P --> Q" |
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12875
diff
changeset
|
164 |
and 2: "Q ==> R" |
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12875
diff
changeset
|
165 |
and 3: "P --> Q ==> P" |
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12875
diff
changeset
|
166 |
shows R |
12349 | 167 |
proof - |
168 |
from 3 and 1 have P . |
|
12368 | 169 |
with 1 have Q by (rule impE) |
12349 | 170 |
with 2 show R . |
171 |
qed |
|
172 |
||
173 |
lemma allE': |
|
12937
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12875
diff
changeset
|
174 |
assumes 1: "ALL x. P(x)" |
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12875
diff
changeset
|
175 |
and 2: "P(x) ==> ALL x. P(x) ==> Q" |
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12875
diff
changeset
|
176 |
shows Q |
12349 | 177 |
proof - |
178 |
from 1 have "P(x)" by (rule spec) |
|
179 |
from this and 1 show Q by (rule 2) |
|
180 |
qed |
|
181 |
||
12937
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12875
diff
changeset
|
182 |
lemma notE': |
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12875
diff
changeset
|
183 |
assumes 1: "~ P" |
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12875
diff
changeset
|
184 |
and 2: "~ P ==> P" |
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12875
diff
changeset
|
185 |
shows R |
12349 | 186 |
proof - |
187 |
from 2 and 1 have P . |
|
188 |
with 1 show R by (rule notE) |
|
189 |
qed |
|
190 |
||
191 |
lemmas [Pure.elim!] = disjE iffE FalseE conjE exE |
|
192 |
and [Pure.intro!] = iffI conjI impI TrueI notI allI refl |
|
193 |
and [Pure.elim 2] = allE notE' impE' |
|
194 |
and [Pure.intro] = exI disjI2 disjI1 |
|
195 |
||
18708 | 196 |
setup {* ContextRules.addSWrapper (fn tac => hyp_subst_tac ORELSE' tac) *} |
12349 | 197 |
|
198 |
||
12368 | 199 |
lemma iff_not_sym: "~ (Q <-> P) ==> ~ (P <-> Q)" |
17591 | 200 |
by iprover |
12368 | 201 |
|
202 |
lemmas [sym] = sym iff_sym not_sym iff_not_sym |
|
203 |
and [Pure.elim?] = iffD1 iffD2 impE |
|
204 |
||
205 |
||
13435 | 206 |
lemma eq_commute: "a=b <-> b=a" |
207 |
apply (rule iffI) |
|
208 |
apply (erule sym)+ |
|
209 |
done |
|
210 |
||
211 |
||
11677 | 212 |
subsection {* Atomizing meta-level rules *} |
213 |
||
11747 | 214 |
lemma atomize_all [atomize]: "(!!x. P(x)) == Trueprop (ALL x. P(x))" |
11976 | 215 |
proof |
11677 | 216 |
assume "!!x. P(x)" |
12368 | 217 |
show "ALL x. P(x)" .. |
11677 | 218 |
next |
219 |
assume "ALL x. P(x)" |
|
12368 | 220 |
thus "!!x. P(x)" .. |
11677 | 221 |
qed |
222 |
||
11747 | 223 |
lemma atomize_imp [atomize]: "(A ==> B) == Trueprop (A --> B)" |
11976 | 224 |
proof |
12368 | 225 |
assume "A ==> B" |
226 |
thus "A --> B" .. |
|
11677 | 227 |
next |
228 |
assume "A --> B" and A |
|
229 |
thus B by (rule mp) |
|
230 |
qed |
|
231 |
||
11747 | 232 |
lemma atomize_eq [atomize]: "(x == y) == Trueprop (x = y)" |
11976 | 233 |
proof |
11677 | 234 |
assume "x == y" |
235 |
show "x = y" by (unfold prems) (rule refl) |
|
236 |
next |
|
237 |
assume "x = y" |
|
238 |
thus "x == y" by (rule eq_reflection) |
|
239 |
qed |
|
240 |
||
18813 | 241 |
lemma atomize_iff [atomize]: "(A == B) == Trueprop (A <-> B)" |
242 |
proof |
|
243 |
assume "A == B" |
|
244 |
show "A <-> B" by (unfold prems) (rule iff_refl) |
|
245 |
next |
|
246 |
assume "A <-> B" |
|
247 |
thus "A == B" by (rule iff_reflection) |
|
248 |
qed |
|
249 |
||
12875 | 250 |
lemma atomize_conj [atomize]: |
19120
353d349740de
not_equal: replaced syntax translation by abbreviation;
wenzelm
parents:
18861
diff
changeset
|
251 |
includes meta_conjunction_syntax |
353d349740de
not_equal: replaced syntax translation by abbreviation;
wenzelm
parents:
18861
diff
changeset
|
252 |
shows "(A && B) == Trueprop (A & B)" |
11976 | 253 |
proof |
19120
353d349740de
not_equal: replaced syntax translation by abbreviation;
wenzelm
parents:
18861
diff
changeset
|
254 |
assume conj: "A && B" |
353d349740de
not_equal: replaced syntax translation by abbreviation;
wenzelm
parents:
18861
diff
changeset
|
255 |
show "A & B" |
353d349740de
not_equal: replaced syntax translation by abbreviation;
wenzelm
parents:
18861
diff
changeset
|
256 |
proof (rule conjI) |
353d349740de
not_equal: replaced syntax translation by abbreviation;
wenzelm
parents:
18861
diff
changeset
|
257 |
from conj show A by (rule conjunctionD1) |
353d349740de
not_equal: replaced syntax translation by abbreviation;
wenzelm
parents:
18861
diff
changeset
|
258 |
from conj show B by (rule conjunctionD2) |
353d349740de
not_equal: replaced syntax translation by abbreviation;
wenzelm
parents:
18861
diff
changeset
|
259 |
qed |
11953 | 260 |
next |
19120
353d349740de
not_equal: replaced syntax translation by abbreviation;
wenzelm
parents:
18861
diff
changeset
|
261 |
assume conj: "A & B" |
353d349740de
not_equal: replaced syntax translation by abbreviation;
wenzelm
parents:
18861
diff
changeset
|
262 |
show "A && B" |
353d349740de
not_equal: replaced syntax translation by abbreviation;
wenzelm
parents:
18861
diff
changeset
|
263 |
proof - |
353d349740de
not_equal: replaced syntax translation by abbreviation;
wenzelm
parents:
18861
diff
changeset
|
264 |
from conj show A .. |
353d349740de
not_equal: replaced syntax translation by abbreviation;
wenzelm
parents:
18861
diff
changeset
|
265 |
from conj show B .. |
11953 | 266 |
qed |
267 |
qed |
|
268 |
||
12368 | 269 |
lemmas [symmetric, rulify] = atomize_all atomize_imp |
18861 | 270 |
and [symmetric, defn] = atomize_all atomize_imp atomize_eq atomize_iff |
11771 | 271 |
|
11848 | 272 |
|
273 |
subsection {* Calculational rules *} |
|
274 |
||
275 |
lemma forw_subst: "a = b ==> P(b) ==> P(a)" |
|
276 |
by (rule ssubst) |
|
277 |
||
278 |
lemma back_subst: "P(a) ==> a = b ==> P(b)" |
|
279 |
by (rule subst) |
|
280 |
||
281 |
text {* |
|
282 |
Note that this list of rules is in reverse order of priorities. |
|
283 |
*} |
|
284 |
||
12019 | 285 |
lemmas basic_trans_rules [trans] = |
11848 | 286 |
forw_subst |
287 |
back_subst |
|
288 |
rev_mp |
|
289 |
mp |
|
290 |
trans |
|
291 |
||
13779 | 292 |
subsection {* ``Let'' declarations *} |
293 |
||
294 |
nonterminals letbinds letbind |
|
295 |
||
296 |
constdefs |
|
14854 | 297 |
Let :: "['a::{}, 'a => 'b] => ('b::{})" |
13779 | 298 |
"Let(s, f) == f(s)" |
299 |
||
300 |
syntax |
|
301 |
"_bind" :: "[pttrn, 'a] => letbind" ("(2_ =/ _)" 10) |
|
302 |
"" :: "letbind => letbinds" ("_") |
|
303 |
"_binds" :: "[letbind, letbinds] => letbinds" ("_;/ _") |
|
304 |
"_Let" :: "[letbinds, 'a] => 'a" ("(let (_)/ in (_))" 10) |
|
305 |
||
306 |
translations |
|
307 |
"_Let(_binds(b, bs), e)" == "_Let(b, _Let(bs, e))" |
|
308 |
"let x = a in e" == "Let(a, %x. e)" |
|
309 |
||
310 |
||
311 |
lemma LetI: |
|
312 |
assumes prem: "(!!x. x=t ==> P(u(x)))" |
|
313 |
shows "P(let x=t in u(x))" |
|
314 |
apply (unfold Let_def) |
|
315 |
apply (rule refl [THEN prem]) |
|
316 |
done |
|
317 |
||
318 |
ML |
|
319 |
{* |
|
320 |
val Let_def = thm "Let_def"; |
|
321 |
val LetI = thm "LetI"; |
|
322 |
*} |
|
323 |
||
4854 | 324 |
end |