author berghofe Mon Dec 10 15:36:05 2001 +0100 (2001-12-10) changeset 12450 1162b280700a parent 12449 95fb2e206dc7 child 12451 0224f472be71
Added example file for intuitionistic logic (taken from FOL).
 src/HOL/ex/Intuitionistic.thy file | annotate | diff | revisions src/HOL/ex/ROOT.ML file | annotate | diff | revisions
```     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/src/HOL/ex/Intuitionistic.thy	Mon Dec 10 15:36:05 2001 +0100
1.3 @@ -0,0 +1,329 @@
1.4 +(*  Title:      HOL/ex/Intuitionistic.thy
1.5 +    ID:         \$Id\$
1.6 +    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
1.7 +    Copyright   1991  University of Cambridge
1.8 +
1.9 +Higher-Order Logic: Intuitionistic predicate calculus problems
1.10 +
1.11 +Taken from FOL/ex/int.ML
1.12 +*)
1.13 +
1.14 +theory Intuitionistic = Main:
1.15 +
1.16 +
1.17 +(*Metatheorem (for PROPOSITIONAL formulae...):
1.18 +  P is classically provable iff ~~P is intuitionistically provable.
1.19 +  Therefore ~P is classically provable iff it is intuitionistically provable.
1.20 +
1.21 +Proof: Let Q be the conjuction of the propositions A|~A, one for each atom A
1.22 +in P.  Now ~~Q is intuitionistically provable because ~~(A|~A) is and because
1.23 +~~ distributes over &.  If P is provable classically, then clearly Q-->P is
1.24 +provable intuitionistically, so ~~(Q-->P) is also provable intuitionistically.
1.25 +The latter is intuitionistically equivalent to ~~Q-->~~P, hence to ~~P, since
1.26 +~~Q is intuitionistically provable.  Finally, if P is a negation then ~~P is
1.27 +intuitionstically equivalent to P.  [Andy Pitts] *)
1.28 +
1.29 +lemma "(~~(P&Q)) = ((~~P) & (~~Q))"
1.30 +  by rules
1.31 +
1.32 +lemma "~~ ((~P --> Q) --> (~P --> ~Q) --> P)"
1.33 +  by rules
1.34 +
1.35 +(* ~~ does NOT distribute over | *)
1.36 +
1.37 +lemma "(~~(P-->Q))  = (~~P --> ~~Q)"
1.38 +  by rules
1.39 +
1.40 +lemma "(~~~P) = (~P)"
1.41 +  by rules
1.42 +
1.43 +lemma "~~((P --> Q | R)  -->  (P-->Q) | (P-->R))"
1.44 +  by rules
1.45 +
1.46 +lemma "(P=Q) = (Q=P)"
1.47 +  by rules
1.48 +
1.49 +lemma "((P --> (Q | (Q-->R))) --> R) --> R"
1.50 +  by rules
1.51 +
1.52 +lemma "(((G-->A) --> J) --> D --> E) --> (((H-->B)-->I)-->C-->J)
1.53 +      --> (A-->H) --> F --> G --> (((C-->B)-->I)-->D)-->(A-->C)
1.54 +      --> (((F-->A)-->B) --> I) --> E"
1.55 +  by rules
1.56 +
1.57 +
1.58 +(* Lemmas for the propositional double-negation translation *)
1.59 +
1.60 +lemma "P --> ~~P"
1.61 +  by rules
1.62 +
1.63 +lemma "~~(~~P --> P)"
1.64 +  by rules
1.65 +
1.66 +lemma "~~P & ~~(P --> Q) --> ~~Q"
1.67 +  by rules
1.68 +
1.69 +
1.70 +(* de Bruijn formulae *)
1.71 +
1.72 +(*de Bruijn formula with three predicates*)
1.73 +lemma "((P=Q) --> P&Q&R) &
1.74 +       ((Q=R) --> P&Q&R) &
1.75 +       ((R=P) --> P&Q&R) --> P&Q&R"
1.76 +  by rules
1.77 +
1.78 +(*de Bruijn formula with five predicates*)
1.79 +lemma "((P=Q) --> P&Q&R&S&T) &
1.80 +       ((Q=R) --> P&Q&R&S&T) &
1.81 +       ((R=S) --> P&Q&R&S&T) &
1.82 +       ((S=T) --> P&Q&R&S&T) &
1.83 +       ((T=P) --> P&Q&R&S&T) --> P&Q&R&S&T"
1.84 +  by rules
1.85 +
1.86 +
1.87 +(*** Problems from Sahlin, Franzen and Haridi,
1.88 +     An Intuitionistic Predicate Logic Theorem Prover.
1.89 +     J. Logic and Comp. 2 (5), October 1992, 619-656.
1.90 +***)
1.91 +
1.92 +(*Problem 1.1*)
1.93 +lemma "(ALL x. EX y. ALL z. p(x) & q(y) & r(z)) =
1.94 +       (ALL z. EX y. ALL x. p(x) & q(y) & r(z))"
1.95 +  by (rules del: allE elim 2: allE')
1.96 +
1.97 +(*Problem 3.1*)
1.98 +lemma "~ (EX x. ALL y. p y x = (~ p x x))"
1.99 +  by rules
1.100 +
1.101 +
1.102 +(* Intuitionistic FOL: propositional problems based on Pelletier. *)
1.103 +
1.104 +(* Problem ~~1 *)
1.105 +lemma "~~((P-->Q)  =  (~Q --> ~P))"
1.106 +  by rules
1.107 +
1.108 +(* Problem ~~2 *)
1.109 +lemma "~~(~~P  =  P)"
1.110 +  by rules
1.111 +
1.112 +(* Problem 3 *)
1.113 +lemma "~(P-->Q) --> (Q-->P)"
1.114 +  by rules
1.115 +
1.116 +(* Problem ~~4 *)
1.117 +lemma "~~((~P-->Q)  =  (~Q --> P))"
1.118 +  by rules
1.119 +
1.120 +(* Problem ~~5 *)
1.121 +lemma "~~((P|Q-->P|R) --> P|(Q-->R))"
1.122 +  by rules
1.123 +
1.124 +(* Problem ~~6 *)
1.125 +lemma "~~(P | ~P)"
1.126 +  by rules
1.127 +
1.128 +(* Problem ~~7 *)
1.129 +lemma "~~(P | ~~~P)"
1.130 +  by rules
1.131 +
1.132 +(* Problem ~~8.  Peirce's law *)
1.133 +lemma "~~(((P-->Q) --> P)  -->  P)"
1.134 +  by rules
1.135 +
1.136 +(* Problem 9 *)
1.137 +lemma "((P|Q) & (~P|Q) & (P| ~Q)) --> ~ (~P | ~Q)"
1.138 +  by rules
1.139 +
1.140 +(* Problem 10 *)
1.141 +lemma "(Q-->R) --> (R-->P&Q) --> (P-->(Q|R)) --> (P=Q)"
1.142 +  by rules
1.143 +
1.144 +(* 11.  Proved in each direction (incorrectly, says Pelletier!!) *)
1.145 +lemma "P=P"
1.146 +  by rules
1.147 +
1.148 +(* Problem ~~12.  Dijkstra's law *)
1.149 +lemma "~~(((P = Q) = R)  =  (P = (Q = R)))"
1.150 +  by rules
1.151 +
1.152 +lemma "((P = Q) = R)  -->  ~~(P = (Q = R))"
1.153 +  by rules
1.154 +
1.155 +(* Problem 13.  Distributive law *)
1.156 +lemma "(P | (Q & R))  = ((P | Q) & (P | R))"
1.157 +  by rules
1.158 +
1.159 +(* Problem ~~14 *)
1.160 +lemma "~~((P = Q) = ((Q | ~P) & (~Q|P)))"
1.161 +  by rules
1.162 +
1.163 +(* Problem ~~15 *)
1.164 +lemma "~~((P --> Q) = (~P | Q))"
1.165 +  by rules
1.166 +
1.167 +(* Problem ~~16 *)
1.168 +lemma "~~((P-->Q) | (Q-->P))"
1.169 +by rules
1.170 +
1.171 +(* Problem ~~17 *)
1.172 +lemma "~~(((P & (Q-->R))-->S) = ((~P | Q | S) & (~P | ~R | S)))"
1.173 +  oops
1.174 +
1.175 +(*Dijkstra's "Golden Rule"*)
1.176 +lemma "(P&Q) = (P = (Q = (P|Q)))"
1.177 +  by rules
1.178 +
1.179 +
1.180 +(****Examples with quantifiers****)
1.181 +
1.182 +(* The converse is classical in the following implications... *)
1.183 +
1.184 +lemma "(EX x. P(x)-->Q)  -->  (ALL x. P(x)) --> Q"
1.185 +  by rules
1.186 +
1.187 +lemma "((ALL x. P(x))-->Q) --> ~ (ALL x. P(x) & ~Q)"
1.188 +  by rules
1.189 +
1.190 +lemma "((ALL x. ~P(x))-->Q)  -->  ~ (ALL x. ~ (P(x)|Q))"
1.191 +  by rules
1.192 +
1.193 +lemma "(ALL x. P(x)) | Q  -->  (ALL x. P(x) | Q)"
1.194 +  by rules
1.195 +
1.196 +lemma "(EX x. P --> Q(x)) --> (P --> (EX x. Q(x)))"
1.197 +  by rules
1.198 +
1.199 +
1.200 +(* Hard examples with quantifiers *)
1.201 +
1.202 +(*The ones that have not been proved are not known to be valid!
1.203 +  Some will require quantifier duplication -- not currently available*)
1.204 +
1.205 +(* Problem ~~19 *)
1.206 +lemma "~~(EX x. ALL y z. (P(y)-->Q(z)) --> (P(x)-->Q(x)))"
1.207 +  by rules
1.208 +
1.209 +(* Problem 20 *)
1.210 +lemma "(ALL x y. EX z. ALL w. (P(x)&Q(y)-->R(z)&S(w)))
1.211 +    --> (EX x y. P(x) & Q(y)) --> (EX z. R(z))"
1.212 +  by rules
1.213 +
1.214 +(* Problem 21 *)
1.215 +lemma "(EX x. P-->Q(x)) & (EX x. Q(x)-->P) --> ~~(EX x. P=Q(x))"
1.216 +  by rules
1.217 +
1.218 +(* Problem 22 *)
1.219 +lemma "(ALL x. P = Q(x))  -->  (P = (ALL x. Q(x)))"
1.220 +  by rules
1.221 +
1.222 +(* Problem ~~23 *)
1.223 +lemma "~~ ((ALL x. P | Q(x))  =  (P | (ALL x. Q(x))))"
1.224 +  by rules
1.225 +
1.226 +(* Problem 25 *)
1.227 +lemma "(EX x. P(x)) &
1.228 +       (ALL x. L(x) --> ~ (M(x) & R(x))) &
1.229 +       (ALL x. P(x) --> (M(x) & L(x))) &
1.230 +       ((ALL x. P(x)-->Q(x)) | (EX x. P(x)&R(x)))
1.231 +   --> (EX x. Q(x)&P(x))"
1.232 +  by rules
1.233 +
1.234 +(* Problem 27 *)
1.235 +lemma "(EX x. P(x) & ~Q(x)) &
1.236 +             (ALL x. P(x) --> R(x)) &
1.237 +             (ALL x. M(x) & L(x) --> P(x)) &
1.238 +             ((EX x. R(x) & ~ Q(x)) --> (ALL x. L(x) --> ~ R(x)))
1.239 +         --> (ALL x. M(x) --> ~L(x))"
1.240 +  by rules
1.241 +
1.242 +(* Problem ~~28.  AMENDED *)
1.243 +lemma "(ALL x. P(x) --> (ALL x. Q(x))) &
1.244 +       (~~(ALL x. Q(x)|R(x)) --> (EX x. Q(x)&S(x))) &
1.245 +       (~~(EX x. S(x)) --> (ALL x. L(x) --> M(x)))
1.246 +   --> (ALL x. P(x) & L(x) --> M(x))"
1.247 +  by rules
1.248 +
1.249 +(* Problem 29.  Essentially the same as Principia Mathematica *11.71 *)
1.250 +lemma "(((EX x. P(x)) & (EX y. Q(y))) -->
1.251 +   (((ALL x. (P(x) --> R(x))) & (ALL y. (Q(y) --> S(y)))) =
1.252 +    (ALL x y. ((P(x) & Q(y)) --> (R(x) & S(y))))))"
1.253 +  by rules
1.254 +
1.255 +(* Problem ~~30 *)
1.256 +lemma "(ALL x. (P(x) | Q(x)) --> ~ R(x)) &
1.257 +       (ALL x. (Q(x) --> ~ S(x)) --> P(x) & R(x))
1.258 +   --> (ALL x. ~~S(x))"
1.259 +  by rules
1.260 +
1.261 +(* Problem 31 *)
1.262 +lemma "~(EX x. P(x) & (Q(x) | R(x))) &
1.263 +        (EX x. L(x) & P(x)) &
1.264 +        (ALL x. ~ R(x) --> M(x))
1.265 +    --> (EX x. L(x) & M(x))"
1.266 +  by rules
1.267 +
1.268 +(* Problem 32 *)
1.269 +lemma "(ALL x. P(x) & (Q(x)|R(x))-->S(x)) &
1.270 +       (ALL x. S(x) & R(x) --> L(x)) &
1.271 +       (ALL x. M(x) --> R(x))
1.272 +   --> (ALL x. P(x) & M(x) --> L(x))"
1.273 +  by rules
1.274 +
1.275 +(* Problem ~~33 *)
1.276 +lemma "(ALL x. ~~(P(a) & (P(x)-->P(b))-->P(c)))  =
1.277 +       (ALL x. ~~((~P(a) | P(x) | P(c)) & (~P(a) | ~P(b) | P(c))))"
1.278 +  oops
1.279 +
1.280 +(* Problem 36 *)
1.281 +lemma
1.282 +     "(ALL x. EX y. J x y) &
1.283 +      (ALL x. EX y. G x y) &
1.284 +      (ALL x y. J x y | G x y --> (ALL z. J y z | G y z --> H x z))
1.285 +  --> (ALL x. EX y. H x y)"
1.286 +  by rules
1.287 +
1.288 +(* Problem 39 *)
1.289 +lemma "~ (EX x. ALL y. F y x = (~F y y))"
1.290 +  by rules
1.291 +
1.292 +(* Problem 40.  AMENDED *)
1.293 +lemma "(EX y. ALL x. F x y = F x x) -->
1.294 +             ~(ALL x. EX y. ALL z. F z y = (~ F z x))"
1.295 +  by rules
1.296 +
1.297 +(* Problem 44 *)
1.298 +lemma "(ALL x. f(x) -->
1.299 +             (EX y. g(y) & h x y & (EX y. g(y) & ~ h x y)))  &
1.300 +             (EX x. j(x) & (ALL y. g(y) --> h x y))
1.301 +             --> (EX x. j(x) & ~f(x))"
1.302 +  by rules
1.303 +
1.304 +(* Problem 48 *)
1.305 +lemma "(a=b | c=d) & (a=c | b=d) --> a=d | b=c"
1.306 +  by rules
1.307 +
1.308 +(* Problem 51 *)
1.309 +lemma "((EX z w. (ALL x y. (P x y = ((x = z) & (y = w))))) -->
1.310 +  (EX z. (ALL x. (EX w. ((ALL y. (P x y = (y = w))) = (x = z))))))"
1.311 +  by rules
1.312 +
1.313 +(* Problem 52 *)
1.314 +(*Almost the same as 51. *)
1.315 +lemma "((EX z w. (ALL x y. (P x y = ((x = z) & (y = w))))) -->
1.316 +   (EX w. (ALL y. (EX z. ((ALL x. (P x y = (x = z))) = (y = w))))))"
1.317 +  by rules
1.318 +
1.319 +(* Problem 56 *)
1.320 +lemma "(ALL x. (EX y. P(y) & x=f(y)) --> P(x)) = (ALL x. P(x) --> P(f(x)))"
1.321 +  by rules
1.322 +
1.323 +(* Problem 57 *)
1.324 +lemma "P (f a b) (f b c) & P (f b c) (f a c) &
1.325 +     (ALL x y z. P x y & P y z --> P x z) --> P (f a b) (f a c)"
1.326 +  by rules
1.327 +
1.328 +(* Problem 60 *)
1.329 +lemma "ALL x. P x (f x) = (EX y. (ALL z. P z y --> P z (f x)) & P x y)"
1.330 +  by rules
1.331 +
1.332 +end
```
```     2.1 --- a/src/HOL/ex/ROOT.ML	Mon Dec 10 15:35:03 2001 +0100
2.2 +++ b/src/HOL/ex/ROOT.ML	Mon Dec 10 15:36:05 2001 +0100
2.3 @@ -19,6 +19,7 @@
2.4  time_use_thy "Tuple";
2.5
2.6  time_use_thy "NatSum";
2.7 +time_use_thy "Intuitionistic";
2.8  time_use     "cla.ML";
2.9  time_use     "mesontest.ML";
2.10  time_use_thy "mesontest2";
```