src/HOL/ex/Intuitionistic.thy
changeset 67613 ce654b0e6d69
parent 61343 5b5656a63bd6
equal deleted inserted replaced
67610:4939494ed791 67613:ce654b0e6d69
    84      An Intuitionistic Predicate Logic Theorem Prover.
    84      An Intuitionistic Predicate Logic Theorem Prover.
    85      J. Logic and Comp. 2 (5), October 1992, 619-656.
    85      J. Logic and Comp. 2 (5), October 1992, 619-656.
    86 ***)
    86 ***)
    87 
    87 
    88 (*Problem 1.1*)
    88 (*Problem 1.1*)
    89 lemma "(ALL x. EX y. ALL z. p(x) & q(y) & r(z)) =
    89 lemma "(\<forall>x. \<exists>y. \<forall>z. p(x) \<and> q(y) \<and> r(z)) =
    90        (ALL z. EX y. ALL x. p(x) & q(y) & r(z))"
    90        (\<forall>z. \<exists>y. \<forall>x. p(x) \<and> q(y) \<and> r(z))"
    91   by (iprover del: allE elim 2: allE')
    91   by (iprover del: allE elim 2: allE')
    92 
    92 
    93 (*Problem 3.1*)
    93 (*Problem 3.1*)
    94 lemma "~ (EX x. ALL y. p y x = (~ p x x))"
    94 lemma "\<not> (\<exists>x. \<forall>y. p y x = (\<not> p x x))"
    95   by iprover
    95   by iprover
    96 
    96 
    97 
    97 
    98 (* Intuitionistic FOL: propositional problems based on Pelletier. *)
    98 (* Intuitionistic FOL: propositional problems based on Pelletier. *)
    99 
    99 
   175 
   175 
   176 (****Examples with quantifiers****)
   176 (****Examples with quantifiers****)
   177 
   177 
   178 (* The converse is classical in the following implications... *)
   178 (* The converse is classical in the following implications... *)
   179 
   179 
   180 lemma "(EX x. P(x)-->Q)  -->  (ALL x. P(x)) --> Q"
   180 lemma "(\<exists>x. P(x)\<longrightarrow>Q)  \<longrightarrow>  (\<forall>x. P(x)) \<longrightarrow> Q"
   181   by iprover
   181   by iprover
   182 
   182 
   183 lemma "((ALL x. P(x))-->Q) --> ~ (ALL x. P(x) & ~Q)"
   183 lemma "((\<forall>x. P(x))\<longrightarrow>Q) \<longrightarrow> \<not> (\<forall>x. P(x) \<and> \<not>Q)"
   184   by iprover
   184   by iprover
   185 
   185 
   186 lemma "((ALL x. ~P(x))-->Q)  -->  ~ (ALL x. ~ (P(x)|Q))"
   186 lemma "((\<forall>x. \<not>P(x))\<longrightarrow>Q)  \<longrightarrow>  \<not> (\<forall>x. \<not> (P(x)\<or>Q))"
   187   by iprover
   187   by iprover
   188 
   188 
   189 lemma "(ALL x. P(x)) | Q  -->  (ALL x. P(x) | Q)"
   189 lemma "(\<forall>x. P(x)) \<or> Q  \<longrightarrow>  (\<forall>x. P(x) \<or> Q)"
   190   by iprover 
   190   by iprover 
   191 
   191 
   192 lemma "(EX x. P --> Q(x)) --> (P --> (EX x. Q(x)))"
   192 lemma "(\<exists>x. P \<longrightarrow> Q(x)) \<longrightarrow> (P \<longrightarrow> (\<exists>x. Q(x)))"
   193   by iprover
   193   by iprover
   194 
   194 
   195 
   195 
   196 (* Hard examples with quantifiers *)
   196 (* Hard examples with quantifiers *)
   197 
   197 
   198 (*The ones that have not been proved are not known to be valid!
   198 (*The ones that have not been proved are not known to be valid!
   199   Some will require quantifier duplication -- not currently available*)
   199   Some will require quantifier duplication -- not currently available*)
   200 
   200 
   201 (* Problem ~~19 *)
   201 (* Problem ~~19 *)
   202 lemma "~~(EX x. ALL y z. (P(y)-->Q(z)) --> (P(x)-->Q(x)))"
   202 lemma "\<not>\<not>(\<exists>x. \<forall>y z. (P(y)\<longrightarrow>Q(z)) \<longrightarrow> (P(x)\<longrightarrow>Q(x)))"
   203   by iprover
   203   by iprover
   204 
   204 
   205 (* Problem 20 *)
   205 (* Problem 20 *)
   206 lemma "(ALL x y. EX z. ALL w. (P(x)&Q(y)-->R(z)&S(w)))
   206 lemma "(\<forall>x y. \<exists>z. \<forall>w. (P(x)\<and>Q(y)\<longrightarrow>R(z)\<and>S(w)))
   207     --> (EX x y. P(x) & Q(y)) --> (EX z. R(z))"
   207     \<longrightarrow> (\<exists>x y. P(x) \<and> Q(y)) \<longrightarrow> (\<exists>z. R(z))"
   208   by iprover
   208   by iprover
   209 
   209 
   210 (* Problem 21 *)
   210 (* Problem 21 *)
   211 lemma "(EX x. P-->Q(x)) & (EX x. Q(x)-->P) --> ~~(EX x. P=Q(x))"
   211 lemma "(\<exists>x. P\<longrightarrow>Q(x)) \<and> (\<exists>x. Q(x)\<longrightarrow>P) \<longrightarrow> \<not>\<not>(\<exists>x. P=Q(x))"
   212   by iprover
   212   by iprover
   213 
   213 
   214 (* Problem 22 *)
   214 (* Problem 22 *)
   215 lemma "(ALL x. P = Q(x))  -->  (P = (ALL x. Q(x)))"
   215 lemma "(\<forall>x. P = Q(x))  \<longrightarrow>  (P = (\<forall>x. Q(x)))"
   216   by iprover
   216   by iprover
   217 
   217 
   218 (* Problem ~~23 *)
   218 (* Problem ~~23 *)
   219 lemma "~~ ((ALL x. P | Q(x))  =  (P | (ALL x. Q(x))))"
   219 lemma "\<not>\<not> ((\<forall>x. P \<or> Q(x))  =  (P \<or> (\<forall>x. Q(x))))"
   220   by iprover
   220   by iprover
   221 
   221 
   222 (* Problem 25 *)
   222 (* Problem 25 *)
   223 lemma "(EX x. P(x)) &
   223 lemma "(\<exists>x. P(x)) \<and>
   224        (ALL x. L(x) --> ~ (M(x) & R(x))) &
   224        (\<forall>x. L(x) \<longrightarrow> \<not> (M(x) \<and> R(x))) \<and>
   225        (ALL x. P(x) --> (M(x) & L(x))) &
   225        (\<forall>x. P(x) \<longrightarrow> (M(x) \<and> L(x))) \<and>
   226        ((ALL x. P(x)-->Q(x)) | (EX x. P(x)&R(x)))
   226        ((\<forall>x. P(x)\<longrightarrow>Q(x)) \<or> (\<exists>x. P(x)\<and>R(x)))
   227    --> (EX x. Q(x)&P(x))"
   227    \<longrightarrow> (\<exists>x. Q(x)\<and>P(x))"
   228   by iprover
   228   by iprover
   229 
   229 
   230 (* Problem 27 *)
   230 (* Problem 27 *)
   231 lemma "(EX x. P(x) & ~Q(x)) &
   231 lemma "(\<exists>x. P(x) \<and> \<not>Q(x)) \<and>
   232              (ALL x. P(x) --> R(x)) &
   232              (\<forall>x. P(x) \<longrightarrow> R(x)) \<and>
   233              (ALL x. M(x) & L(x) --> P(x)) &
   233              (\<forall>x. M(x) \<and> L(x) \<longrightarrow> P(x)) \<and>
   234              ((EX x. R(x) & ~ Q(x)) --> (ALL x. L(x) --> ~ R(x)))
   234              ((\<exists>x. R(x) \<and> \<not> Q(x)) \<longrightarrow> (\<forall>x. L(x) \<longrightarrow> \<not> R(x)))
   235          --> (ALL x. M(x) --> ~L(x))"
   235          \<longrightarrow> (\<forall>x. M(x) \<longrightarrow> \<not>L(x))"
   236   by iprover
   236   by iprover
   237 
   237 
   238 (* Problem ~~28.  AMENDED *)
   238 (* Problem ~~28.  AMENDED *)
   239 lemma "(ALL x. P(x) --> (ALL x. Q(x))) &
   239 lemma "(\<forall>x. P(x) \<longrightarrow> (\<forall>x. Q(x))) \<and>
   240        (~~(ALL x. Q(x)|R(x)) --> (EX x. Q(x)&S(x))) &
   240        (\<not>\<not>(\<forall>x. Q(x)\<or>R(x)) \<longrightarrow> (\<exists>x. Q(x)&S(x))) \<and>
   241        (~~(EX x. S(x)) --> (ALL x. L(x) --> M(x)))
   241        (\<not>\<not>(\<exists>x. S(x)) \<longrightarrow> (\<forall>x. L(x) \<longrightarrow> M(x)))
   242    --> (ALL x. P(x) & L(x) --> M(x))"
   242    \<longrightarrow> (\<forall>x. P(x) \<and> L(x) \<longrightarrow> M(x))"
   243   by iprover
   243   by iprover
   244 
   244 
   245 (* Problem 29.  Essentially the same as Principia Mathematica *11.71 *)
   245 (* Problem 29.  Essentially the same as Principia Mathematica *11.71 *)
   246 lemma "(((EX x. P(x)) & (EX y. Q(y))) -->
   246 lemma "(((\<exists>x. P(x)) \<and> (\<exists>y. Q(y))) \<longrightarrow>
   247    (((ALL x. (P(x) --> R(x))) & (ALL y. (Q(y) --> S(y)))) =
   247    (((\<forall>x. (P(x) \<longrightarrow> R(x))) \<and> (\<forall>y. (Q(y) \<longrightarrow> S(y)))) =
   248     (ALL x y. ((P(x) & Q(y)) --> (R(x) & S(y))))))"
   248     (\<forall>x y. ((P(x) \<and> Q(y)) \<longrightarrow> (R(x) \<and> S(y))))))"
   249   by iprover
   249   by iprover
   250 
   250 
   251 (* Problem ~~30 *)
   251 (* Problem ~~30 *)
   252 lemma "(ALL x. (P(x) | Q(x)) --> ~ R(x)) &
   252 lemma "(\<forall>x. (P(x) \<or> Q(x)) \<longrightarrow> \<not> R(x)) \<and>
   253        (ALL x. (Q(x) --> ~ S(x)) --> P(x) & R(x))
   253        (\<forall>x. (Q(x) \<longrightarrow> \<not> S(x)) \<longrightarrow> P(x) \<and> R(x))
   254    --> (ALL x. ~~S(x))"
   254    \<longrightarrow> (\<forall>x. \<not>\<not>S(x))"
   255   by iprover
   255   by iprover
   256 
   256 
   257 (* Problem 31 *)
   257 (* Problem 31 *)
   258 lemma "~(EX x. P(x) & (Q(x) | R(x))) & 
   258 lemma "\<not>(\<exists>x. P(x) \<and> (Q(x) \<or> R(x))) \<and>
   259         (EX x. L(x) & P(x)) &
   259         (\<exists>x. L(x) \<and> P(x)) \<and>
   260         (ALL x. ~ R(x) --> M(x))
   260         (\<forall>x. \<not> R(x) \<longrightarrow> M(x))
   261     --> (EX x. L(x) & M(x))"
   261     \<longrightarrow> (\<exists>x. L(x) \<and> M(x))"
   262   by iprover
   262   by iprover
   263 
   263 
   264 (* Problem 32 *)
   264 (* Problem 32 *)
   265 lemma "(ALL x. P(x) & (Q(x)|R(x))-->S(x)) &
   265 lemma "(\<forall>x. P(x) \<and> (Q(x)|R(x))\<longrightarrow>S(x)) \<and>
   266        (ALL x. S(x) & R(x) --> L(x)) &
   266        (\<forall>x. S(x) \<and> R(x) \<longrightarrow> L(x)) \<and>
   267        (ALL x. M(x) --> R(x))
   267        (\<forall>x. M(x) \<longrightarrow> R(x))
   268    --> (ALL x. P(x) & M(x) --> L(x))"
   268    \<longrightarrow> (\<forall>x. P(x) \<and> M(x) \<longrightarrow> L(x))"
   269   by iprover
   269   by iprover
   270 
   270 
   271 (* Problem ~~33 *)
   271 (* Problem ~~33 *)
   272 lemma "(ALL x. ~~(P(a) & (P(x)-->P(b))-->P(c)))  =
   272 lemma "(\<forall>x. \<not>\<not>(P(a) \<and> (P(x)\<longrightarrow>P(b))\<longrightarrow>P(c)))  =
   273        (ALL x. ~~((~P(a) | P(x) | P(c)) & (~P(a) | ~P(b) | P(c))))"
   273        (\<forall>x. \<not>\<not>((\<not>P(a) \<or> P(x) \<or> P(c)) \<and> (\<not>P(a) \<or> \<not>P(b) \<or> P(c))))"
   274   oops
   274   oops
   275 
   275 
   276 (* Problem 36 *)
   276 (* Problem 36 *)
   277 lemma
   277 lemma
   278      "(ALL x. EX y. J x y) &
   278      "(\<forall>x. \<exists>y. J x y) \<and>
   279       (ALL x. EX y. G x y) &
   279       (\<forall>x. \<exists>y. G x y) \<and>
   280       (ALL x y. J x y | G x y --> (ALL z. J y z | G y z --> H x z))
   280       (\<forall>x y. J x y \<or> G x y \<longrightarrow> (\<forall>z. J y z \<or> G y z \<longrightarrow> H x z))
   281   --> (ALL x. EX y. H x y)"
   281   \<longrightarrow> (\<forall>x. \<exists>y. H x y)"
   282   by iprover
   282   by iprover
   283 
   283 
   284 (* Problem 39 *)
   284 (* Problem 39 *)
   285 lemma "~ (EX x. ALL y. F y x = (~F y y))"
   285 lemma "\<not> (\<exists>x. \<forall>y. F y x = (\<not>F y y))"
   286   by iprover
   286   by iprover
   287 
   287 
   288 (* Problem 40.  AMENDED *)
   288 (* Problem 40.  AMENDED *)
   289 lemma "(EX y. ALL x. F x y = F x x) -->
   289 lemma "(\<exists>y. \<forall>x. F x y = F x x) \<longrightarrow>
   290              ~(ALL x. EX y. ALL z. F z y = (~ F z x))"
   290              \<not>(\<forall>x. \<exists>y. \<forall>z. F z y = (\<not> F z x))"
   291   by iprover
   291   by iprover
   292 
   292 
   293 (* Problem 44 *)
   293 (* Problem 44 *)
   294 lemma "(ALL x. f(x) -->
   294 lemma "(\<forall>x. f(x) \<longrightarrow>
   295              (EX y. g(y) & h x y & (EX y. g(y) & ~ h x y)))  &
   295              (\<exists>y. g(y) \<and> h x y \<and> (\<exists>y. g(y) \<and> ~ h x y)))  \<and>
   296              (EX x. j(x) & (ALL y. g(y) --> h x y))
   296              (\<exists>x. j(x) \<and> (\<forall>y. g(y) \<longrightarrow> h x y))
   297              --> (EX x. j(x) & ~f(x))"
   297              \<longrightarrow> (\<exists>x. j(x) \<and> \<not>f(x))"
   298   by iprover
   298   by iprover
   299 
   299 
   300 (* Problem 48 *)
   300 (* Problem 48 *)
   301 lemma "(a=b | c=d) & (a=c | b=d) --> a=d | b=c"
   301 lemma "(a=b \<or> c=d) \<and> (a=c \<or> b=d) \<longrightarrow> a=d \<or> b=c"
   302   by iprover
   302   by iprover
   303 
   303 
   304 (* Problem 51 *)
   304 (* Problem 51 *)
   305 lemma "((EX z w. (ALL x y. (P x y = ((x = z) & (y = w))))) -->
   305 lemma "((\<exists>z w. (\<forall>x y. (P x y = ((x = z) \<and> (y = w))))) \<longrightarrow>
   306   (EX z. (ALL x. (EX w. ((ALL y. (P x y = (y = w))) = (x = z))))))"
   306   (\<exists>z. (\<forall>x. (\<exists>w. ((\<forall>y. (P x y = (y = w))) = (x = z))))))"
   307   by iprover
   307   by iprover
   308 
   308 
   309 (* Problem 52 *)
   309 (* Problem 52 *)
   310 (*Almost the same as 51. *)
   310 (*Almost the same as 51. *)
   311 lemma "((EX z w. (ALL x y. (P x y = ((x = z) & (y = w))))) -->
   311 lemma "((\<exists>z w. (\<forall>x y. (P x y = ((x = z) \<and> (y = w))))) \<longrightarrow>
   312    (EX w. (ALL y. (EX z. ((ALL x. (P x y = (x = z))) = (y = w))))))"
   312    (\<exists>w. (\<forall>y. (\<exists>z. ((\<forall>x. (P x y = (x = z))) = (y = w))))))"
   313   by iprover
   313   by iprover
   314 
   314 
   315 (* Problem 56 *)
   315 (* Problem 56 *)
   316 lemma "(ALL x. (EX y. P(y) & x=f(y)) --> P(x)) = (ALL x. P(x) --> P(f(x)))"
   316 lemma "(\<forall>x. (\<exists>y. P(y) \<and> x=f(y)) \<longrightarrow> P(x)) = (\<forall>x. P(x) \<longrightarrow> P(f(x)))"
   317   by iprover
   317   by iprover
   318 
   318 
   319 (* Problem 57 *)
   319 (* Problem 57 *)
   320 lemma "P (f a b) (f b c) & P (f b c) (f a c) &
   320 lemma "P (f a b) (f b c) & P (f b c) (f a c) \<and>
   321      (ALL x y z. P x y & P y z --> P x z) --> P (f a b) (f a c)"
   321      (\<forall>x y z. P x y \<and> P y z \<longrightarrow> P x z) \<longrightarrow> P (f a b) (f a c)"
   322   by iprover
   322   by iprover
   323 
   323 
   324 (* Problem 60 *)
   324 (* Problem 60 *)
   325 lemma "ALL x. P x (f x) = (EX y. (ALL z. P z y --> P z (f x)) & P x y)"
   325 lemma "\<forall>x. P x (f x) = (\<exists>y. (\<forall>z. P z y \<longrightarrow> P z (f x)) \<and> P x y)"
   326   by iprover
   326   by iprover
   327 
   327 
   328 end
   328 end