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