author | wenzelm |
Tue, 01 Jun 2004 12:33:50 +0200 | |
changeset 14854 | 61bdf2ae4dc5 |
parent 14565 | c6dc17aab88a |
child 15377 | 3d99eea28a9b |
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" |
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
85 |
subst: "[| a=b; P(a) |] ==> P(b)" |
0 | 86 |
|
79 | 87 |
(* Propositional logic *) |
0 | 88 |
|
7355
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
89 |
conjI: "[| P; Q |] ==> P&Q" |
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
90 |
conjunct1: "P&Q ==> P" |
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
91 |
conjunct2: "P&Q ==> Q" |
0 | 92 |
|
7355
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
93 |
disjI1: "P ==> P|Q" |
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
94 |
disjI2: "Q ==> P|Q" |
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
95 |
disjE: "[| P|Q; P ==> R; Q ==> R |] ==> R" |
0 | 96 |
|
7355
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
97 |
impI: "(P ==> Q) ==> P-->Q" |
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
98 |
mp: "[| P-->Q; P |] ==> Q" |
0 | 99 |
|
7355
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
100 |
FalseE: "False ==> P" |
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
101 |
|
79 | 102 |
(* Quantifiers *) |
0 | 103 |
|
7355
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
104 |
allI: "(!!x. P(x)) ==> (ALL x. P(x))" |
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
105 |
spec: "(ALL x. P(x)) ==> P(x)" |
0 | 106 |
|
7355
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
107 |
exI: "P(x) ==> (EX x. P(x))" |
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
108 |
exE: "[| EX x. P(x); !!x. P(x) ==> R |] ==> R" |
0 | 109 |
|
110 |
(* Reflection *) |
|
111 |
||
7355
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
112 |
eq_reflection: "(x=y) ==> (x==y)" |
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
113 |
iff_reflection: "(P<->Q) ==> (P==Q)" |
0 | 114 |
|
4092 | 115 |
|
14236 | 116 |
defs |
117 |
(* Definitions *) |
|
118 |
||
119 |
True_def: "True == False-->False" |
|
120 |
not_def: "~P == P-->False" |
|
121 |
iff_def: "P<->Q == (P-->Q) & (Q-->P)" |
|
122 |
||
123 |
(* Unique existence *) |
|
124 |
||
125 |
ex1_def: "Ex1(P) == EX x. P(x) & (ALL y. P(y) --> y=x)" |
|
126 |
||
13779 | 127 |
|
11677 | 128 |
subsection {* Lemmas and proof tools *} |
129 |
||
9886 | 130 |
setup Simplifier.setup |
131 |
use "IFOL_lemmas.ML" |
|
11734 | 132 |
|
7355
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
133 |
use "fologic.ML" |
9886 | 134 |
use "hypsubstdata.ML" |
135 |
setup hypsubst_setup |
|
7355
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
136 |
use "intprover.ML" |
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
137 |
|
4092 | 138 |
|
12875 | 139 |
subsection {* Intuitionistic Reasoning *} |
12368 | 140 |
|
12349 | 141 |
lemma impE': |
12937
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12875
diff
changeset
|
142 |
assumes 1: "P --> Q" |
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12875
diff
changeset
|
143 |
and 2: "Q ==> R" |
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12875
diff
changeset
|
144 |
and 3: "P --> Q ==> P" |
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12875
diff
changeset
|
145 |
shows R |
12349 | 146 |
proof - |
147 |
from 3 and 1 have P . |
|
12368 | 148 |
with 1 have Q by (rule impE) |
12349 | 149 |
with 2 show R . |
150 |
qed |
|
151 |
||
152 |
lemma allE': |
|
12937
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12875
diff
changeset
|
153 |
assumes 1: "ALL x. P(x)" |
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12875
diff
changeset
|
154 |
and 2: "P(x) ==> ALL x. P(x) ==> Q" |
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12875
diff
changeset
|
155 |
shows Q |
12349 | 156 |
proof - |
157 |
from 1 have "P(x)" by (rule spec) |
|
158 |
from this and 1 show Q by (rule 2) |
|
159 |
qed |
|
160 |
||
12937
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12875
diff
changeset
|
161 |
lemma notE': |
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12875
diff
changeset
|
162 |
assumes 1: "~ P" |
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12875
diff
changeset
|
163 |
and 2: "~ P ==> P" |
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12875
diff
changeset
|
164 |
shows R |
12349 | 165 |
proof - |
166 |
from 2 and 1 have P . |
|
167 |
with 1 show R by (rule notE) |
|
168 |
qed |
|
169 |
||
170 |
lemmas [Pure.elim!] = disjE iffE FalseE conjE exE |
|
171 |
and [Pure.intro!] = iffI conjI impI TrueI notI allI refl |
|
172 |
and [Pure.elim 2] = allE notE' impE' |
|
173 |
and [Pure.intro] = exI disjI2 disjI1 |
|
174 |
||
175 |
ML_setup {* |
|
12352 | 176 |
Context.>> (ContextRules.addSWrapper (fn tac => hyp_subst_tac ORELSE' tac)); |
12349 | 177 |
*} |
178 |
||
179 |
||
12368 | 180 |
lemma iff_not_sym: "~ (Q <-> P) ==> ~ (P <-> Q)" |
181 |
by rules |
|
182 |
||
183 |
lemmas [sym] = sym iff_sym not_sym iff_not_sym |
|
184 |
and [Pure.elim?] = iffD1 iffD2 impE |
|
185 |
||
186 |
||
13435 | 187 |
lemma eq_commute: "a=b <-> b=a" |
188 |
apply (rule iffI) |
|
189 |
apply (erule sym)+ |
|
190 |
done |
|
191 |
||
192 |
||
11677 | 193 |
subsection {* Atomizing meta-level rules *} |
194 |
||
11747 | 195 |
lemma atomize_all [atomize]: "(!!x. P(x)) == Trueprop (ALL x. P(x))" |
11976 | 196 |
proof |
11677 | 197 |
assume "!!x. P(x)" |
12368 | 198 |
show "ALL x. P(x)" .. |
11677 | 199 |
next |
200 |
assume "ALL x. P(x)" |
|
12368 | 201 |
thus "!!x. P(x)" .. |
11677 | 202 |
qed |
203 |
||
11747 | 204 |
lemma atomize_imp [atomize]: "(A ==> B) == Trueprop (A --> B)" |
11976 | 205 |
proof |
12368 | 206 |
assume "A ==> B" |
207 |
thus "A --> B" .. |
|
11677 | 208 |
next |
209 |
assume "A --> B" and A |
|
210 |
thus B by (rule mp) |
|
211 |
qed |
|
212 |
||
11747 | 213 |
lemma atomize_eq [atomize]: "(x == y) == Trueprop (x = y)" |
11976 | 214 |
proof |
11677 | 215 |
assume "x == y" |
216 |
show "x = y" by (unfold prems) (rule refl) |
|
217 |
next |
|
218 |
assume "x = y" |
|
219 |
thus "x == y" by (rule eq_reflection) |
|
220 |
qed |
|
221 |
||
12875 | 222 |
lemma atomize_conj [atomize]: |
223 |
"(!!C. (A ==> B ==> PROP C) ==> PROP C) == Trueprop (A & B)" |
|
11976 | 224 |
proof |
11953 | 225 |
assume "!!C. (A ==> B ==> PROP C) ==> PROP C" |
226 |
show "A & B" by (rule conjI) |
|
227 |
next |
|
228 |
fix C |
|
229 |
assume "A & B" |
|
230 |
assume "A ==> B ==> PROP C" |
|
231 |
thus "PROP C" |
|
232 |
proof this |
|
233 |
show A by (rule conjunct1) |
|
234 |
show B by (rule conjunct2) |
|
235 |
qed |
|
236 |
qed |
|
237 |
||
12368 | 238 |
lemmas [symmetric, rulify] = atomize_all atomize_imp |
11771 | 239 |
|
11848 | 240 |
|
241 |
subsection {* Calculational rules *} |
|
242 |
||
243 |
lemma forw_subst: "a = b ==> P(b) ==> P(a)" |
|
244 |
by (rule ssubst) |
|
245 |
||
246 |
lemma back_subst: "P(a) ==> a = b ==> P(b)" |
|
247 |
by (rule subst) |
|
248 |
||
249 |
text {* |
|
250 |
Note that this list of rules is in reverse order of priorities. |
|
251 |
*} |
|
252 |
||
12019 | 253 |
lemmas basic_trans_rules [trans] = |
11848 | 254 |
forw_subst |
255 |
back_subst |
|
256 |
rev_mp |
|
257 |
mp |
|
258 |
trans |
|
259 |
||
13779 | 260 |
|
261 |
||
262 |
subsection {* ``Let'' declarations *} |
|
263 |
||
264 |
nonterminals letbinds letbind |
|
265 |
||
266 |
constdefs |
|
14854 | 267 |
Let :: "['a::{}, 'a => 'b] => ('b::{})" |
13779 | 268 |
"Let(s, f) == f(s)" |
269 |
||
270 |
syntax |
|
271 |
"_bind" :: "[pttrn, 'a] => letbind" ("(2_ =/ _)" 10) |
|
272 |
"" :: "letbind => letbinds" ("_") |
|
273 |
"_binds" :: "[letbind, letbinds] => letbinds" ("_;/ _") |
|
274 |
"_Let" :: "[letbinds, 'a] => 'a" ("(let (_)/ in (_))" 10) |
|
275 |
||
276 |
translations |
|
277 |
"_Let(_binds(b, bs), e)" == "_Let(b, _Let(bs, e))" |
|
278 |
"let x = a in e" == "Let(a, %x. e)" |
|
279 |
||
280 |
||
281 |
lemma LetI: |
|
282 |
assumes prem: "(!!x. x=t ==> P(u(x)))" |
|
283 |
shows "P(let x=t in u(x))" |
|
284 |
apply (unfold Let_def) |
|
285 |
apply (rule refl [THEN prem]) |
|
286 |
done |
|
287 |
||
288 |
ML |
|
289 |
{* |
|
290 |
val Let_def = thm "Let_def"; |
|
291 |
val LetI = thm "LetI"; |
|
292 |
*} |
|
293 |
||
4854 | 294 |
end |