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