src/FOLP/FOLP.thy
author blanchet
Mon May 19 23:43:53 2014 +0200 (2014-05-19)
changeset 57009 8cb6a5f1ae84
parent 48891 c0eafbd55de3
child 58889 5b7a9633cfa8
permissions -rw-r--r--
added SML implementation of MaSh
clasohm@1477
     1
(*  Title:      FOLP/FOLP.thy
clasohm@1477
     2
    Author:     Martin D Coen, Cambridge University Computer Laboratory
lcp@1142
     3
    Copyright   1992  University of Cambridge
lcp@1142
     4
*)
lcp@1142
     5
wenzelm@17480
     6
header {* Classical First-Order Logic with Proofs *}
wenzelm@17480
     7
wenzelm@17480
     8
theory FOLP
wenzelm@17480
     9
imports IFOLP
wenzelm@17480
    10
begin
wenzelm@17480
    11
wenzelm@41779
    12
axiomatization cla :: "[p=>p]=>p"
wenzelm@41779
    13
  where classical: "(!!x. x:~P ==> f(x):P) ==> cla(f):P"
wenzelm@17480
    14
wenzelm@26322
    15
wenzelm@26322
    16
(*** Classical introduction rules for | and EX ***)
wenzelm@26322
    17
wenzelm@36319
    18
schematic_lemma disjCI:
wenzelm@26322
    19
  assumes "!!x. x:~Q ==> f(x):P"
wenzelm@26322
    20
  shows "?p : P|Q"
wenzelm@26322
    21
  apply (rule classical)
wenzelm@26322
    22
  apply (assumption | rule assms disjI1 notI)+
wenzelm@26322
    23
  apply (assumption | rule disjI2 notE)+
wenzelm@26322
    24
  done
wenzelm@26322
    25
wenzelm@26322
    26
(*introduction rule involving only EX*)
wenzelm@36319
    27
schematic_lemma ex_classical:
wenzelm@26322
    28
  assumes "!!u. u:~(EX x. P(x)) ==> f(u):P(a)"
wenzelm@26322
    29
  shows "?p : EX x. P(x)"
wenzelm@26322
    30
  apply (rule classical)
wenzelm@26322
    31
  apply (rule exI, rule assms, assumption)
wenzelm@26322
    32
  done
wenzelm@26322
    33
wenzelm@26322
    34
(*version of above, simplifying ~EX to ALL~ *)
wenzelm@36319
    35
schematic_lemma exCI:
wenzelm@26322
    36
  assumes "!!u. u:ALL x. ~P(x) ==> f(u):P(a)"
wenzelm@26322
    37
  shows "?p : EX x. P(x)"
wenzelm@26322
    38
  apply (rule ex_classical)
wenzelm@26322
    39
  apply (rule notI [THEN allI, THEN assms])
wenzelm@26322
    40
  apply (erule notE)
wenzelm@26322
    41
  apply (erule exI)
wenzelm@26322
    42
  done
wenzelm@26322
    43
wenzelm@36319
    44
schematic_lemma excluded_middle: "?p : ~P | P"
wenzelm@26322
    45
  apply (rule disjCI)
wenzelm@26322
    46
  apply assumption
wenzelm@26322
    47
  done
wenzelm@26322
    48
wenzelm@26322
    49
wenzelm@26322
    50
(*** Special elimination rules *)
wenzelm@17480
    51
wenzelm@26322
    52
(*Classical implies (-->) elimination. *)
wenzelm@36319
    53
schematic_lemma impCE:
wenzelm@26322
    54
  assumes major: "p:P-->Q"
wenzelm@26322
    55
    and r1: "!!x. x:~P ==> f(x):R"
wenzelm@26322
    56
    and r2: "!!y. y:Q ==> g(y):R"
wenzelm@26322
    57
  shows "?p : R"
wenzelm@26322
    58
  apply (rule excluded_middle [THEN disjE])
wenzelm@26322
    59
   apply (tactic {* DEPTH_SOLVE (atac 1 ORELSE
wenzelm@26322
    60
       resolve_tac [@{thm r1}, @{thm r2}, @{thm major} RS @{thm mp}] 1) *})
wenzelm@26322
    61
  done
wenzelm@26322
    62
wenzelm@26322
    63
(*Double negation law*)
wenzelm@36319
    64
schematic_lemma notnotD: "p:~~P ==> ?p : P"
wenzelm@26322
    65
  apply (rule classical)
wenzelm@26322
    66
  apply (erule notE)
wenzelm@26322
    67
  apply assumption
wenzelm@26322
    68
  done
wenzelm@26322
    69
wenzelm@26322
    70
wenzelm@26322
    71
(*** Tactics for implication and contradiction ***)
wenzelm@17480
    72
wenzelm@26322
    73
(*Classical <-> elimination.  Proof substitutes P=Q in
wenzelm@26322
    74
    ~P ==> ~Q    and    P ==> Q  *)
wenzelm@36319
    75
schematic_lemma iffCE:
wenzelm@26322
    76
  assumes major: "p:P<->Q"
wenzelm@26322
    77
    and r1: "!!x y.[| x:P; y:Q |] ==> f(x,y):R"
wenzelm@26322
    78
    and r2: "!!x y.[| x:~P; y:~Q |] ==> g(x,y):R"
wenzelm@26322
    79
  shows "?p : R"
wenzelm@26322
    80
  apply (insert major)
wenzelm@26322
    81
  apply (unfold iff_def)
wenzelm@26322
    82
  apply (rule conjE)
wenzelm@26322
    83
  apply (tactic {* DEPTH_SOLVE_1 (etac @{thm impCE} 1 ORELSE
wenzelm@26322
    84
      eresolve_tac [@{thm notE}, @{thm impE}] 1 THEN atac 1 ORELSE atac 1 ORELSE
wenzelm@26322
    85
      resolve_tac [@{thm r1}, @{thm r2}] 1) *})+
wenzelm@26322
    86
  done
wenzelm@26322
    87
wenzelm@26322
    88
wenzelm@26322
    89
(*Should be used as swap since ~P becomes redundant*)
wenzelm@36319
    90
schematic_lemma swap:
wenzelm@26322
    91
  assumes major: "p:~P"
wenzelm@26322
    92
    and r: "!!x. x:~Q ==> f(x):P"
wenzelm@26322
    93
  shows "?p : Q"
wenzelm@26322
    94
  apply (rule classical)
wenzelm@26322
    95
  apply (rule major [THEN notE])
wenzelm@26322
    96
  apply (rule r)
wenzelm@26322
    97
  apply assumption
wenzelm@26322
    98
  done
wenzelm@26322
    99
wenzelm@48891
   100
ML_file "classical.ML"      (* Patched because matching won't instantiate proof *)
wenzelm@48891
   101
ML_file "simp.ML"           (* Patched because matching won't instantiate proof *)
wenzelm@17480
   102
wenzelm@17480
   103
ML {*
wenzelm@42799
   104
structure Cla = Classical
wenzelm@42799
   105
(
wenzelm@17480
   106
  val sizef = size_of_thm
wenzelm@26322
   107
  val mp = @{thm mp}
wenzelm@26322
   108
  val not_elim = @{thm notE}
wenzelm@26322
   109
  val swap = @{thm swap}
wenzelm@26322
   110
  val hyp_subst_tacs = [hyp_subst_tac]
wenzelm@42799
   111
);
wenzelm@17480
   112
open Cla;
wenzelm@17480
   113
wenzelm@17480
   114
(*Propositional rules
wenzelm@17480
   115
  -- iffCE might seem better, but in the examples in ex/cla
wenzelm@17480
   116
     run about 7% slower than with iffE*)
wenzelm@26322
   117
val prop_cs =
wenzelm@26322
   118
  empty_cs addSIs [@{thm refl}, @{thm TrueI}, @{thm conjI}, @{thm disjCI},
wenzelm@26322
   119
      @{thm impI}, @{thm notI}, @{thm iffI}]
wenzelm@26322
   120
    addSEs [@{thm conjE}, @{thm disjE}, @{thm impCE}, @{thm FalseE}, @{thm iffE}];
wenzelm@17480
   121
wenzelm@17480
   122
(*Quantifier rules*)
wenzelm@26322
   123
val FOLP_cs =
wenzelm@26322
   124
  prop_cs addSIs [@{thm allI}] addIs [@{thm exI}, @{thm ex1I}]
wenzelm@26322
   125
    addSEs [@{thm exE}, @{thm ex1E}] addEs [@{thm allE}];
wenzelm@17480
   126
wenzelm@26322
   127
val FOLP_dup_cs =
wenzelm@26322
   128
  prop_cs addSIs [@{thm allI}] addIs [@{thm exCI}, @{thm ex1I}]
wenzelm@26322
   129
    addSEs [@{thm exE}, @{thm ex1E}] addEs [@{thm all_dupE}];
wenzelm@26322
   130
*}
wenzelm@17480
   131
wenzelm@36319
   132
schematic_lemma cla_rews:
wenzelm@26322
   133
  "?p1 : P | ~P"
wenzelm@26322
   134
  "?p2 : ~P | P"
wenzelm@26322
   135
  "?p3 : ~ ~ P <-> P"
wenzelm@26322
   136
  "?p4 : (~P --> P) <-> P"
wenzelm@26322
   137
  apply (tactic {* ALLGOALS (Cla.fast_tac FOLP_cs) *})
wenzelm@26322
   138
  done
wenzelm@17480
   139
wenzelm@48891
   140
ML_file "simpdata.ML"
wenzelm@17480
   141
clasohm@0
   142
end