src/HOL/ex/Intuitionistic.thy
author haftmann
Wed Mar 12 19:38:14 2008 +0100 (2008-03-12)
changeset 26265 4b63b9e9b10d
parent 17589 58eeffd73be1
child 41460 ea56b98aee83
permissions -rw-r--r--
separated Random.thy from Quickcheck.thy
     1 (*  Title:      HOL/ex/Intuitionistic.thy
     2     ID:         $Id$
     3     Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
     4     Copyright   1991  University of Cambridge
     5 
     6 Taken from FOL/ex/int.ML
     7 *)
     8 
     9 header {* Higher-Order Logic: Intuitionistic predicate calculus problems *}
    10 
    11 theory Intuitionistic imports Main begin
    12 
    13 
    14 (*Metatheorem (for PROPOSITIONAL formulae...):
    15   P is classically provable iff ~~P is intuitionistically provable.
    16   Therefore ~P is classically provable iff it is intuitionistically provable.  
    17 
    18 Proof: Let Q be the conjuction of the propositions A|~A, one for each atom A
    19 in P.  Now ~~Q is intuitionistically provable because ~~(A|~A) is and because
    20 ~~ distributes over &.  If P is provable classically, then clearly Q-->P is
    21 provable intuitionistically, so ~~(Q-->P) is also provable intuitionistically.
    22 The latter is intuitionistically equivalent to ~~Q-->~~P, hence to ~~P, since
    23 ~~Q is intuitionistically provable.  Finally, if P is a negation then ~~P is
    24 intuitionstically equivalent to P.  [Andy Pitts] *)
    25 
    26 lemma "(~~(P&Q)) = ((~~P) & (~~Q))"
    27   by iprover
    28 
    29 lemma "~~ ((~P --> Q) --> (~P --> ~Q) --> P)"
    30   by iprover
    31 
    32 (* ~~ does NOT distribute over | *)
    33 
    34 lemma "(~~(P-->Q))  = (~~P --> ~~Q)"
    35   by iprover
    36 
    37 lemma "(~~~P) = (~P)"
    38   by iprover
    39 
    40 lemma "~~((P --> Q | R)  -->  (P-->Q) | (P-->R))"
    41   by iprover
    42 
    43 lemma "(P=Q) = (Q=P)"
    44   by iprover
    45 
    46 lemma "((P --> (Q | (Q-->R))) --> R) --> R"
    47   by iprover
    48 
    49 lemma "(((G-->A) --> J) --> D --> E) --> (((H-->B)-->I)-->C-->J)
    50       --> (A-->H) --> F --> G --> (((C-->B)-->I)-->D)-->(A-->C)
    51       --> (((F-->A)-->B) --> I) --> E"
    52   by iprover
    53 
    54 
    55 (* Lemmas for the propositional double-negation translation *)
    56 
    57 lemma "P --> ~~P"
    58   by iprover
    59 
    60 lemma "~~(~~P --> P)"
    61   by iprover
    62 
    63 lemma "~~P & ~~(P --> Q) --> ~~Q"
    64   by iprover
    65 
    66 
    67 (* de Bruijn formulae *)
    68 
    69 (*de Bruijn formula with three predicates*)
    70 lemma "((P=Q) --> P&Q&R) &
    71        ((Q=R) --> P&Q&R) &
    72        ((R=P) --> P&Q&R) --> P&Q&R"
    73   by iprover
    74 
    75 (*de Bruijn formula with five predicates*)
    76 lemma "((P=Q) --> P&Q&R&S&T) &
    77        ((Q=R) --> P&Q&R&S&T) &
    78        ((R=S) --> P&Q&R&S&T) &
    79        ((S=T) --> P&Q&R&S&T) &
    80        ((T=P) --> P&Q&R&S&T) --> P&Q&R&S&T"
    81   by iprover
    82 
    83 
    84 (*** Problems from Sahlin, Franzen and Haridi, 
    85      An Intuitionistic Predicate Logic Theorem Prover.
    86      J. Logic and Comp. 2 (5), October 1992, 619-656.
    87 ***)
    88 
    89 (*Problem 1.1*)
    90 lemma "(ALL x. EX y. ALL z. p(x) & q(y) & r(z)) =
    91        (ALL z. EX y. ALL x. p(x) & q(y) & r(z))"
    92   by (iprover del: allE elim 2: allE')
    93 
    94 (*Problem 3.1*)
    95 lemma "~ (EX x. ALL y. p y x = (~ p x x))"
    96   by iprover
    97 
    98 
    99 (* Intuitionistic FOL: propositional problems based on Pelletier. *)
   100 
   101 (* Problem ~~1 *)
   102 lemma "~~((P-->Q)  =  (~Q --> ~P))"
   103   by iprover
   104 
   105 (* Problem ~~2 *)
   106 lemma "~~(~~P  =  P)"
   107   by iprover
   108 
   109 (* Problem 3 *)
   110 lemma "~(P-->Q) --> (Q-->P)"
   111   by iprover
   112 
   113 (* Problem ~~4 *)
   114 lemma "~~((~P-->Q)  =  (~Q --> P))"
   115   by iprover
   116 
   117 (* Problem ~~5 *)
   118 lemma "~~((P|Q-->P|R) --> P|(Q-->R))"
   119   by iprover
   120 
   121 (* Problem ~~6 *)
   122 lemma "~~(P | ~P)"
   123   by iprover
   124 
   125 (* Problem ~~7 *)
   126 lemma "~~(P | ~~~P)"
   127   by iprover
   128 
   129 (* Problem ~~8.  Peirce's law *)
   130 lemma "~~(((P-->Q) --> P)  -->  P)"
   131   by iprover
   132 
   133 (* Problem 9 *)
   134 lemma "((P|Q) & (~P|Q) & (P| ~Q)) --> ~ (~P | ~Q)"
   135   by iprover
   136 
   137 (* Problem 10 *)
   138 lemma "(Q-->R) --> (R-->P&Q) --> (P-->(Q|R)) --> (P=Q)"
   139   by iprover
   140 
   141 (* 11.  Proved in each direction (incorrectly, says Pelletier!!) *)
   142 lemma "P=P"
   143   by iprover
   144 
   145 (* Problem ~~12.  Dijkstra's law *)
   146 lemma "~~(((P = Q) = R)  =  (P = (Q = R)))"
   147   by iprover
   148 
   149 lemma "((P = Q) = R)  -->  ~~(P = (Q = R))"
   150   by iprover
   151 
   152 (* Problem 13.  Distributive law *)
   153 lemma "(P | (Q & R))  = ((P | Q) & (P | R))"
   154   by iprover
   155 
   156 (* Problem ~~14 *)
   157 lemma "~~((P = Q) = ((Q | ~P) & (~Q|P)))"
   158   by iprover
   159 
   160 (* Problem ~~15 *)
   161 lemma "~~((P --> Q) = (~P | Q))"
   162   by iprover
   163 
   164 (* Problem ~~16 *)
   165 lemma "~~((P-->Q) | (Q-->P))"
   166 by iprover
   167 
   168 (* Problem ~~17 *)
   169 lemma "~~(((P & (Q-->R))-->S) = ((~P | Q | S) & (~P | ~R | S)))"
   170   oops
   171 
   172 (*Dijkstra's "Golden Rule"*)
   173 lemma "(P&Q) = (P = (Q = (P|Q)))"
   174   by iprover
   175 
   176 
   177 (****Examples with quantifiers****)
   178 
   179 (* The converse is classical in the following implications... *)
   180 
   181 lemma "(EX x. P(x)-->Q)  -->  (ALL x. P(x)) --> Q"
   182   by iprover
   183 
   184 lemma "((ALL x. P(x))-->Q) --> ~ (ALL x. P(x) & ~Q)"
   185   by iprover
   186 
   187 lemma "((ALL x. ~P(x))-->Q)  -->  ~ (ALL x. ~ (P(x)|Q))"
   188   by iprover
   189 
   190 lemma "(ALL x. P(x)) | Q  -->  (ALL x. P(x) | Q)"
   191   by iprover 
   192 
   193 lemma "(EX x. P --> Q(x)) --> (P --> (EX x. Q(x)))"
   194   by iprover
   195 
   196 
   197 (* Hard examples with quantifiers *)
   198 
   199 (*The ones that have not been proved are not known to be valid!
   200   Some will require quantifier duplication -- not currently available*)
   201 
   202 (* Problem ~~19 *)
   203 lemma "~~(EX x. ALL y z. (P(y)-->Q(z)) --> (P(x)-->Q(x)))"
   204   by iprover
   205 
   206 (* Problem 20 *)
   207 lemma "(ALL x y. EX z. ALL w. (P(x)&Q(y)-->R(z)&S(w)))
   208     --> (EX x y. P(x) & Q(y)) --> (EX z. R(z))"
   209   by iprover
   210 
   211 (* Problem 21 *)
   212 lemma "(EX x. P-->Q(x)) & (EX x. Q(x)-->P) --> ~~(EX x. P=Q(x))"
   213   by iprover
   214 
   215 (* Problem 22 *)
   216 lemma "(ALL x. P = Q(x))  -->  (P = (ALL x. Q(x)))"
   217   by iprover
   218 
   219 (* Problem ~~23 *)
   220 lemma "~~ ((ALL x. P | Q(x))  =  (P | (ALL x. Q(x))))"
   221   by iprover
   222 
   223 (* Problem 25 *)
   224 lemma "(EX x. P(x)) &
   225        (ALL x. L(x) --> ~ (M(x) & R(x))) &
   226        (ALL x. P(x) --> (M(x) & L(x))) &
   227        ((ALL x. P(x)-->Q(x)) | (EX x. P(x)&R(x)))
   228    --> (EX x. Q(x)&P(x))"
   229   by iprover
   230 
   231 (* Problem 27 *)
   232 lemma "(EX x. P(x) & ~Q(x)) &
   233              (ALL x. P(x) --> R(x)) &
   234              (ALL x. M(x) & L(x) --> P(x)) &
   235              ((EX x. R(x) & ~ Q(x)) --> (ALL x. L(x) --> ~ R(x)))
   236          --> (ALL x. M(x) --> ~L(x))"
   237   by iprover
   238 
   239 (* Problem ~~28.  AMENDED *)
   240 lemma "(ALL x. P(x) --> (ALL x. Q(x))) &
   241        (~~(ALL x. Q(x)|R(x)) --> (EX x. Q(x)&S(x))) &
   242        (~~(EX x. S(x)) --> (ALL x. L(x) --> M(x)))
   243    --> (ALL x. P(x) & L(x) --> M(x))"
   244   by iprover
   245 
   246 (* Problem 29.  Essentially the same as Principia Mathematica *11.71 *)
   247 lemma "(((EX x. P(x)) & (EX y. Q(y))) -->
   248    (((ALL x. (P(x) --> R(x))) & (ALL y. (Q(y) --> S(y)))) =
   249     (ALL x y. ((P(x) & Q(y)) --> (R(x) & S(y))))))"
   250   by iprover
   251 
   252 (* Problem ~~30 *)
   253 lemma "(ALL x. (P(x) | Q(x)) --> ~ R(x)) &
   254        (ALL x. (Q(x) --> ~ S(x)) --> P(x) & R(x))
   255    --> (ALL x. ~~S(x))"
   256   by iprover
   257 
   258 (* Problem 31 *)
   259 lemma "~(EX x. P(x) & (Q(x) | R(x))) & 
   260         (EX x. L(x) & P(x)) &
   261         (ALL x. ~ R(x) --> M(x))
   262     --> (EX x. L(x) & M(x))"
   263   by iprover
   264 
   265 (* Problem 32 *)
   266 lemma "(ALL x. P(x) & (Q(x)|R(x))-->S(x)) &
   267        (ALL x. S(x) & R(x) --> L(x)) &
   268        (ALL x. M(x) --> R(x))
   269    --> (ALL x. P(x) & M(x) --> L(x))"
   270   by iprover
   271 
   272 (* Problem ~~33 *)
   273 lemma "(ALL x. ~~(P(a) & (P(x)-->P(b))-->P(c)))  =
   274        (ALL x. ~~((~P(a) | P(x) | P(c)) & (~P(a) | ~P(b) | P(c))))"
   275   oops
   276 
   277 (* Problem 36 *)
   278 lemma
   279      "(ALL x. EX y. J x y) &
   280       (ALL x. EX y. G x y) &
   281       (ALL x y. J x y | G x y --> (ALL z. J y z | G y z --> H x z))
   282   --> (ALL x. EX y. H x y)"
   283   by iprover
   284 
   285 (* Problem 39 *)
   286 lemma "~ (EX x. ALL y. F y x = (~F y y))"
   287   by iprover
   288 
   289 (* Problem 40.  AMENDED *)
   290 lemma "(EX y. ALL x. F x y = F x x) -->
   291              ~(ALL x. EX y. ALL z. F z y = (~ F z x))"
   292   by iprover
   293 
   294 (* Problem 44 *)
   295 lemma "(ALL x. f(x) -->
   296              (EX y. g(y) & h x y & (EX y. g(y) & ~ h x y)))  &
   297              (EX x. j(x) & (ALL y. g(y) --> h x y))
   298              --> (EX x. j(x) & ~f(x))"
   299   by iprover
   300 
   301 (* Problem 48 *)
   302 lemma "(a=b | c=d) & (a=c | b=d) --> a=d | b=c"
   303   by iprover
   304 
   305 (* Problem 51 *)
   306 lemma "((EX z w. (ALL x y. (P x y = ((x = z) & (y = w))))) -->
   307   (EX z. (ALL x. (EX w. ((ALL y. (P x y = (y = w))) = (x = z))))))"
   308   by iprover
   309 
   310 (* Problem 52 *)
   311 (*Almost the same as 51. *)
   312 lemma "((EX z w. (ALL x y. (P x y = ((x = z) & (y = w))))) -->
   313    (EX w. (ALL y. (EX z. ((ALL x. (P x y = (x = z))) = (y = w))))))"
   314   by iprover
   315 
   316 (* Problem 56 *)
   317 lemma "(ALL x. (EX y. P(y) & x=f(y)) --> P(x)) = (ALL x. P(x) --> P(f(x)))"
   318   by iprover
   319 
   320 (* Problem 57 *)
   321 lemma "P (f a b) (f b c) & P (f b c) (f a c) &
   322      (ALL x y z. P x y & P y z --> P x z) --> P (f a b) (f a c)"
   323   by iprover
   324 
   325 (* Problem 60 *)
   326 lemma "ALL x. P x (f x) = (EX y. (ALL z. P z y --> P z (f x)) & P x y)"
   327   by iprover
   328 
   329 end