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