src/FOLP/IFOLP.thy
author wenzelm
Wed, 11 Jun 2008 15:41:57 +0200
changeset 27150 a42aef558ce3
parent 26956 1309a6a0a29f
child 27152 192954a9a549
permissions -rw-r--r--
tuned comments;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1477
4c51ab632cda expanded tabs
clasohm
parents: 1149
diff changeset
     1
(*  Title:      FOLP/IFOLP.thy
1142
eb0e2ff8f032 Corrected comments in headers
lcp
parents: 648
diff changeset
     2
    ID:         $Id$
1477
4c51ab632cda expanded tabs
clasohm
parents: 1149
diff changeset
     3
    Author:     Martin D Coen, Cambridge University Computer Laboratory
1142
eb0e2ff8f032 Corrected comments in headers
lcp
parents: 648
diff changeset
     4
    Copyright   1992  University of Cambridge
eb0e2ff8f032 Corrected comments in headers
lcp
parents: 648
diff changeset
     5
*)
eb0e2ff8f032 Corrected comments in headers
lcp
parents: 648
diff changeset
     6
17480
fd19f77dcf60 converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
     7
header {* Intuitionistic First-Order Logic with Proofs *}
fd19f77dcf60 converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
     8
fd19f77dcf60 converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
     9
theory IFOLP
fd19f77dcf60 converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    10
imports Pure
26322
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
    11
uses ("hypsubst.ML") ("intprover.ML")
17480
fd19f77dcf60 converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    12
begin
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    13
26956
1309a6a0a29f setup PureThy.old_appl_syntax_setup -- theory Pure provides regular application syntax by default;
wenzelm
parents: 26480
diff changeset
    14
setup PureThy.old_appl_syntax_setup
1309a6a0a29f setup PureThy.old_appl_syntax_setup -- theory Pure provides regular application syntax by default;
wenzelm
parents: 26480
diff changeset
    15
3942
1f1c1f524d19 adapted to qualified names;
wenzelm
parents: 3836
diff changeset
    16
global
1f1c1f524d19 adapted to qualified names;
wenzelm
parents: 3836
diff changeset
    17
17480
fd19f77dcf60 converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    18
classes "term"
fd19f77dcf60 converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    19
defaultsort "term"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    20
17480
fd19f77dcf60 converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    21
typedecl p
fd19f77dcf60 converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    22
typedecl o
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    23
17480
fd19f77dcf60 converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    24
consts
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    25
      (*** Judgements ***)
1477
4c51ab632cda expanded tabs
clasohm
parents: 1149
diff changeset
    26
 "@Proof"       ::   "[p,o]=>prop"      ("(_ /: _)" [51,10] 5)
4c51ab632cda expanded tabs
clasohm
parents: 1149
diff changeset
    27
 Proof          ::   "[o,p]=>prop"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    28
 EqProof        ::   "[p,p,o]=>prop"    ("(3_ /= _ :/ _)" [10,10,10] 5)
17480
fd19f77dcf60 converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    29
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    30
      (*** Logical Connectives -- Type Formers ***)
1477
4c51ab632cda expanded tabs
clasohm
parents: 1149
diff changeset
    31
 "="            ::      "['a,'a] => o"  (infixl 50)
17480
fd19f77dcf60 converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    32
 True           ::      "o"
fd19f77dcf60 converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    33
 False          ::      "o"
2714
b0fbdfbbad66 Removed needless quotes
paulson
parents: 1477
diff changeset
    34
 Not            ::      "o => o"        ("~ _" [40] 40)
1477
4c51ab632cda expanded tabs
clasohm
parents: 1149
diff changeset
    35
 "&"            ::      "[o,o] => o"    (infixr 35)
4c51ab632cda expanded tabs
clasohm
parents: 1149
diff changeset
    36
 "|"            ::      "[o,o] => o"    (infixr 30)
4c51ab632cda expanded tabs
clasohm
parents: 1149
diff changeset
    37
 "-->"          ::      "[o,o] => o"    (infixr 25)
4c51ab632cda expanded tabs
clasohm
parents: 1149
diff changeset
    38
 "<->"          ::      "[o,o] => o"    (infixr 25)
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    39
      (*Quantifiers*)
1477
4c51ab632cda expanded tabs
clasohm
parents: 1149
diff changeset
    40
 All            ::      "('a => o) => o"        (binder "ALL " 10)
4c51ab632cda expanded tabs
clasohm
parents: 1149
diff changeset
    41
 Ex             ::      "('a => o) => o"        (binder "EX " 10)
4c51ab632cda expanded tabs
clasohm
parents: 1149
diff changeset
    42
 Ex1            ::      "('a => o) => o"        (binder "EX! " 10)
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    43
      (*Rewriting gadgets*)
1477
4c51ab632cda expanded tabs
clasohm
parents: 1149
diff changeset
    44
 NORM           ::      "o => o"
4c51ab632cda expanded tabs
clasohm
parents: 1149
diff changeset
    45
 norm           ::      "'a => 'a"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    46
648
e27c9ec2b48b FOLP/IFOLP.thy: tightening precedences to eliminate syntactic ambiguities.
lcp
parents: 283
diff changeset
    47
      (*** Proof Term Formers: precedence must exceed 50 ***)
1477
4c51ab632cda expanded tabs
clasohm
parents: 1149
diff changeset
    48
 tt             :: "p"
4c51ab632cda expanded tabs
clasohm
parents: 1149
diff changeset
    49
 contr          :: "p=>p"
17480
fd19f77dcf60 converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    50
 fst            :: "p=>p"
fd19f77dcf60 converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    51
 snd            :: "p=>p"
1477
4c51ab632cda expanded tabs
clasohm
parents: 1149
diff changeset
    52
 pair           :: "[p,p]=>p"           ("(1<_,/_>)")
4c51ab632cda expanded tabs
clasohm
parents: 1149
diff changeset
    53
 split          :: "[p, [p,p]=>p] =>p"
17480
fd19f77dcf60 converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    54
 inl            :: "p=>p"
fd19f77dcf60 converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    55
 inr            :: "p=>p"
1477
4c51ab632cda expanded tabs
clasohm
parents: 1149
diff changeset
    56
 when           :: "[p, p=>p, p=>p]=>p"
4c51ab632cda expanded tabs
clasohm
parents: 1149
diff changeset
    57
 lambda         :: "(p => p) => p"      (binder "lam " 55)
4c51ab632cda expanded tabs
clasohm
parents: 1149
diff changeset
    58
 "`"            :: "[p,p]=>p"           (infixl 60)
648
e27c9ec2b48b FOLP/IFOLP.thy: tightening precedences to eliminate syntactic ambiguities.
lcp
parents: 283
diff changeset
    59
 alll           :: "['a=>p]=>p"         (binder "all " 55)
e27c9ec2b48b FOLP/IFOLP.thy: tightening precedences to eliminate syntactic ambiguities.
lcp
parents: 283
diff changeset
    60
 "^"            :: "[p,'a]=>p"          (infixl 55)
1477
4c51ab632cda expanded tabs
clasohm
parents: 1149
diff changeset
    61
 exists         :: "['a,p]=>p"          ("(1[_,/_])")
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    62
 xsplit         :: "[p,['a,p]=>p]=>p"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    63
 ideq           :: "'a=>p"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    64
 idpeel         :: "[p,'a=>p]=>p"
17480
fd19f77dcf60 converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    65
 nrm            :: p
fd19f77dcf60 converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    66
 NRM            :: p
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    67
3942
1f1c1f524d19 adapted to qualified names;
wenzelm
parents: 3836
diff changeset
    68
local
1f1c1f524d19 adapted to qualified names;
wenzelm
parents: 3836
diff changeset
    69
17480
fd19f77dcf60 converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    70
ML {*
fd19f77dcf60 converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    71
fd19f77dcf60 converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    72
(*show_proofs:=true displays the proof terms -- they are ENORMOUS*)
fd19f77dcf60 converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    73
val show_proofs = ref false;
fd19f77dcf60 converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    74
26322
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
    75
fun proof_tr [p,P] = Const (@{const_name Proof}, dummyT) $ P $ p;
17480
fd19f77dcf60 converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    76
fd19f77dcf60 converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    77
fun proof_tr' [P,p] =
fd19f77dcf60 converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    78
    if !show_proofs then Const("@Proof",dummyT) $ p $ P
fd19f77dcf60 converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    79
    else P  (*this case discards the proof term*);
fd19f77dcf60 converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    80
*}
fd19f77dcf60 converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    81
fd19f77dcf60 converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    82
parse_translation {* [("@Proof", proof_tr)] *}
fd19f77dcf60 converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    83
print_translation {* [("Proof", proof_tr')] *}
fd19f77dcf60 converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    84
fd19f77dcf60 converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    85
axioms
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    86
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    87
(**** Propositional logic ****)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    88
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    89
(*Equality*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    90
(* Like Intensional Equality in MLTT - but proofs distinct from terms *)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    91
17480
fd19f77dcf60 converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    92
ieqI:      "ideq(a) : a=a"
fd19f77dcf60 converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    93
ieqE:      "[| p : a=b;  !!x. f(x) : P(x,x) |] ==> idpeel(p,f) : P(a,b)"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    94
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    95
(* Truth and Falsity *)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    96
17480
fd19f77dcf60 converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    97
TrueI:     "tt : True"
fd19f77dcf60 converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    98
FalseE:    "a:False ==> contr(a):P"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    99
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   100
(* Conjunction *)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   101
17480
fd19f77dcf60 converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
   102
conjI:     "[| a:P;  b:Q |] ==> <a,b> : P&Q"
fd19f77dcf60 converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
   103
conjunct1: "p:P&Q ==> fst(p):P"
fd19f77dcf60 converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
   104
conjunct2: "p:P&Q ==> snd(p):Q"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   105
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   106
(* Disjunction *)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   107
17480
fd19f77dcf60 converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
   108
disjI1:    "a:P ==> inl(a):P|Q"
fd19f77dcf60 converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
   109
disjI2:    "b:Q ==> inr(b):P|Q"
fd19f77dcf60 converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
   110
disjE:     "[| a:P|Q;  !!x. x:P ==> f(x):R;  !!x. x:Q ==> g(x):R
fd19f77dcf60 converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
   111
           |] ==> when(a,f,g):R"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   112
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   113
(* Implication *)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   114
17480
fd19f77dcf60 converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
   115
impI:      "(!!x. x:P ==> f(x):Q) ==> lam x. f(x):P-->Q"
fd19f77dcf60 converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
   116
mp:        "[| f:P-->Q;  a:P |] ==> f`a:Q"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   117
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   118
(*Quantifiers*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   119
17480
fd19f77dcf60 converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
   120
allI:      "(!!x. f(x) : P(x)) ==> all x. f(x) : ALL x. P(x)"
fd19f77dcf60 converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
   121
spec:      "(f:ALL x. P(x)) ==> f^x : P(x)"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   122
17480
fd19f77dcf60 converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
   123
exI:       "p : P(x) ==> [x,p] : EX x. P(x)"
fd19f77dcf60 converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
   124
exE:       "[| p: EX x. P(x);  !!x u. u:P(x) ==> f(x,u) : R |] ==> xsplit(p,f):R"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   125
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   126
(**** Equality between proofs ****)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   127
17480
fd19f77dcf60 converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
   128
prefl:     "a : P ==> a = a : P"
fd19f77dcf60 converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
   129
psym:      "a = b : P ==> b = a : P"
fd19f77dcf60 converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
   130
ptrans:    "[| a = b : P;  b = c : P |] ==> a = c : P"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   131
17480
fd19f77dcf60 converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
   132
idpeelB:   "[| !!x. f(x) : P(x,x) |] ==> idpeel(ideq(a),f) = f(a) : P(a,a)"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   133
17480
fd19f77dcf60 converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
   134
fstB:      "a:P ==> fst(<a,b>) = a : P"
fd19f77dcf60 converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
   135
sndB:      "b:Q ==> snd(<a,b>) = b : Q"
fd19f77dcf60 converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
   136
pairEC:    "p:P&Q ==> p = <fst(p),snd(p)> : P&Q"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   137
17480
fd19f77dcf60 converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
   138
whenBinl:  "[| a:P;  !!x. x:P ==> f(x) : Q |] ==> when(inl(a),f,g) = f(a) : Q"
fd19f77dcf60 converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
   139
whenBinr:  "[| b:P;  !!x. x:P ==> g(x) : Q |] ==> when(inr(b),f,g) = g(b) : Q"
fd19f77dcf60 converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
   140
plusEC:    "a:P|Q ==> when(a,%x. inl(x),%y. inr(y)) = a : P|Q"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   141
17480
fd19f77dcf60 converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
   142
applyB:     "[| a:P;  !!x. x:P ==> b(x) : Q |] ==> (lam x. b(x)) ` a = b(a) : Q"
fd19f77dcf60 converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
   143
funEC:      "f:P ==> f = lam x. f`x : P"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   144
17480
fd19f77dcf60 converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
   145
specB:      "[| !!x. f(x) : P(x) |] ==> (all x. f(x)) ^ a = f(a) : P(a)"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   146
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   147
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   148
(**** Definitions ****)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   149
17480
fd19f77dcf60 converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
   150
not_def:              "~P == P-->False"
fd19f77dcf60 converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
   151
iff_def:         "P<->Q == (P-->Q) & (Q-->P)"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   152
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   153
(*Unique existence*)
17480
fd19f77dcf60 converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
   154
ex1_def:   "EX! x. P(x) == EX x. P(x) & (ALL y. P(y) --> y=x)"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   155
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   156
(*Rewriting -- special constants to flag normalized terms and formulae*)
17480
fd19f77dcf60 converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
   157
norm_eq: "nrm : norm(x) = x"
fd19f77dcf60 converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
   158
NORM_iff:        "NRM : NORM(P) <-> P"
fd19f77dcf60 converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
   159
26322
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   160
(*** Sequent-style elimination rules for & --> and ALL ***)
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   161
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   162
lemma conjE:
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   163
  assumes "p:P&Q"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   164
    and "!!x y.[| x:P; y:Q |] ==> f(x,y):R"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   165
  shows "?a:R"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   166
  apply (rule assms(2))
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   167
   apply (rule conjunct1 [OF assms(1)])
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   168
  apply (rule conjunct2 [OF assms(1)])
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   169
  done
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   170
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   171
lemma impE:
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   172
  assumes "p:P-->Q"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   173
    and "q:P"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   174
    and "!!x. x:Q ==> r(x):R"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   175
  shows "?p:R"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   176
  apply (rule assms mp)+
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   177
  done
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   178
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   179
lemma allE:
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   180
  assumes "p:ALL x. P(x)"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   181
    and "!!y. y:P(x) ==> q(y):R"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   182
  shows "?p:R"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   183
  apply (rule assms spec)+
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   184
  done
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   185
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   186
(*Duplicates the quantifier; for use with eresolve_tac*)
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   187
lemma all_dupE:
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   188
  assumes "p:ALL x. P(x)"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   189
    and "!!y z.[| y:P(x); z:ALL x. P(x) |] ==> q(y,z):R"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   190
  shows "?p:R"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   191
  apply (rule assms spec)+
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   192
  done
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   193
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   194
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   195
(*** Negation rules, which translate between ~P and P-->False ***)
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   196
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   197
lemma notI:
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   198
  assumes "!!x. x:P ==> q(x):False"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   199
  shows "?p:~P"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   200
  unfolding not_def
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   201
  apply (assumption | rule assms impI)+
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   202
  done
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   203
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   204
lemma notE: "p:~P \<Longrightarrow> q:P \<Longrightarrow> ?p:R"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   205
  unfolding not_def
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   206
  apply (drule (1) mp)
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   207
  apply (erule FalseE)
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   208
  done
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   209
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   210
(*This is useful with the special implication rules for each kind of P. *)
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   211
lemma not_to_imp:
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   212
  assumes "p:~P"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   213
    and "!!x. x:(P-->False) ==> q(x):Q"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   214
  shows "?p:Q"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   215
  apply (assumption | rule assms impI notE)+
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   216
  done
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   217
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   218
(* For substitution int an assumption P, reduce Q to P-->Q, substitute into
27150
a42aef558ce3 tuned comments;
wenzelm
parents: 26956
diff changeset
   219
   this implication, then apply impI to move P back into the assumptions.*)
26322
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   220
lemma rev_mp: "[| p:P;  q:P --> Q |] ==> ?p:Q"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   221
  apply (assumption | rule mp)+
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   222
  done
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   223
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   224
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   225
(*Contrapositive of an inference rule*)
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   226
lemma contrapos:
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   227
  assumes major: "p:~Q"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   228
    and minor: "!!y. y:P==>q(y):Q"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   229
  shows "?a:~P"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   230
  apply (rule major [THEN notE, THEN notI])
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   231
  apply (erule minor)
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   232
  done
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   233
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   234
(** Unique assumption tactic.
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   235
    Ignores proof objects.
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   236
    Fails unless one assumption is equal and exactly one is unifiable
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   237
**)
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   238
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   239
ML {*
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   240
local
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   241
  fun discard_proof (Const (@{const_name Proof}, _) $ P $ _) = P;
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   242
in
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   243
val uniq_assume_tac =
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   244
  SUBGOAL
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   245
    (fn (prem,i) =>
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   246
      let val hyps = map discard_proof (Logic.strip_assums_hyp prem)
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   247
          and concl = discard_proof (Logic.strip_assums_concl prem)
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   248
      in
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   249
          if exists (fn hyp => hyp aconv concl) hyps
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   250
          then case distinct (op =) (filter (fn hyp => could_unify (hyp, concl)) hyps) of
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   251
                   [_] => assume_tac i
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   252
                 |  _  => no_tac
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   253
          else no_tac
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   254
      end);
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   255
end;
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   256
*}
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   257
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   258
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   259
(*** Modus Ponens Tactics ***)
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   260
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   261
(*Finds P-->Q and P in the assumptions, replaces implication by Q *)
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   262
ML {*
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   263
  fun mp_tac i = eresolve_tac [@{thm notE}, make_elim @{thm mp}] i  THEN  assume_tac i
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   264
*}
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   265
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   266
(*Like mp_tac but instantiates no variables*)
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   267
ML {*
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   268
  fun int_uniq_mp_tac i = eresolve_tac [@{thm notE}, @{thm impE}] i  THEN  uniq_assume_tac i
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   269
*}
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   270
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   271
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   272
(*** If-and-only-if ***)
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   273
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   274
lemma iffI:
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   275
  assumes "!!x. x:P ==> q(x):Q"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   276
    and "!!x. x:Q ==> r(x):P"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   277
  shows "?p:P<->Q"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   278
  unfolding iff_def
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   279
  apply (assumption | rule assms conjI impI)+
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   280
  done
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   281
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   282
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   283
(*Observe use of rewrite_rule to unfold "<->" in meta-assumptions (prems) *)
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   284
  
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   285
lemma iffE:
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   286
  assumes "p:P <-> Q"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   287
    and "!!x y.[| x:P-->Q; y:Q-->P |] ==> q(x,y):R"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   288
  shows "?p:R"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   289
  apply (rule conjE)
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   290
   apply (rule assms(1) [unfolded iff_def])
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   291
  apply (rule assms(2))
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   292
   apply assumption+
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   293
  done
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   294
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   295
(* Destruct rules for <-> similar to Modus Ponens *)
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   296
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   297
lemma iffD1: "[| p:P <-> Q; q:P |] ==> ?p:Q"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   298
  unfolding iff_def
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   299
  apply (rule conjunct1 [THEN mp], assumption+)
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   300
  done
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   301
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   302
lemma iffD2: "[| p:P <-> Q; q:Q |] ==> ?p:P"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   303
  unfolding iff_def
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   304
  apply (rule conjunct2 [THEN mp], assumption+)
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   305
  done
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   306
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   307
lemma iff_refl: "?p:P <-> P"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   308
  apply (rule iffI)
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   309
   apply assumption+
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   310
  done
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   311
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   312
lemma iff_sym: "p:Q <-> P ==> ?p:P <-> Q"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   313
  apply (erule iffE)
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   314
  apply (rule iffI)
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   315
   apply (erule (1) mp)+
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   316
  done
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   317
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   318
lemma iff_trans: "[| p:P <-> Q; q:Q<-> R |] ==> ?p:P <-> R"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   319
  apply (rule iffI)
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   320
   apply (assumption | erule iffE | erule (1) impE)+
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   321
  done
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   322
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   323
(*** Unique existence.  NOTE THAT the following 2 quantifications
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   324
   EX!x such that [EX!y such that P(x,y)]     (sequential)
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   325
   EX!x,y such that P(x,y)                    (simultaneous)
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   326
 do NOT mean the same thing.  The parser treats EX!x y.P(x,y) as sequential.
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   327
***)
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   328
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   329
lemma ex1I:
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   330
  assumes "p:P(a)"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   331
    and "!!x u. u:P(x) ==> f(u) : x=a"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   332
  shows "?p:EX! x. P(x)"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   333
  unfolding ex1_def
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   334
  apply (assumption | rule assms exI conjI allI impI)+
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   335
  done
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   336
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   337
lemma ex1E:
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   338
  assumes "p:EX! x. P(x)"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   339
    and "!!x u v. [| u:P(x);  v:ALL y. P(y) --> y=x |] ==> f(x,u,v):R"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   340
  shows "?a : R"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   341
  apply (insert assms(1) [unfolded ex1_def])
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   342
  apply (erule exE conjE | assumption | rule assms(1))+
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   343
  done
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   344
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   345
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   346
(*** <-> congruence rules for simplification ***)
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   347
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   348
(*Use iffE on a premise.  For conj_cong, imp_cong, all_cong, ex_cong*)
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   349
ML {*
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   350
fun iff_tac prems i =
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   351
    resolve_tac (prems RL [@{thm iffE}]) i THEN
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   352
    REPEAT1 (eresolve_tac [asm_rl, @{thm mp}] i)
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   353
*}
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   354
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   355
lemma conj_cong:
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   356
  assumes "p:P <-> P'"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   357
    and "!!x. x:P' ==> q(x):Q <-> Q'"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   358
  shows "?p:(P&Q) <-> (P'&Q')"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   359
  apply (insert assms(1))
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   360
  apply (assumption | rule iffI conjI |
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   361
    erule iffE conjE mp | tactic {* iff_tac @{thms assms} 1 *})+
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   362
  done
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   363
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   364
lemma disj_cong:
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   365
  "[| p:P <-> P'; q:Q <-> Q' |] ==> ?p:(P|Q) <-> (P'|Q')"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   366
  apply (erule iffE disjE disjI1 disjI2 | assumption | rule iffI | tactic {* mp_tac 1 *})+
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   367
  done
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   368
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   369
lemma imp_cong:
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   370
  assumes "p:P <-> P'"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   371
    and "!!x. x:P' ==> q(x):Q <-> Q'"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   372
  shows "?p:(P-->Q) <-> (P'-->Q')"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   373
  apply (insert assms(1))
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   374
  apply (assumption | rule iffI impI | erule iffE | tactic {* mp_tac 1 *} |
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   375
    tactic {* iff_tac @{thms assms} 1 *})+
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   376
  done
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   377
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   378
lemma iff_cong:
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   379
  "[| p:P <-> P'; q:Q <-> Q' |] ==> ?p:(P<->Q) <-> (P'<->Q')"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   380
  apply (erule iffE | assumption | rule iffI | tactic {* mp_tac 1 *})+
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   381
  done
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   382
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   383
lemma not_cong:
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   384
  "p:P <-> P' ==> ?p:~P <-> ~P'"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   385
  apply (assumption | rule iffI notI | tactic {* mp_tac 1 *} | erule iffE notE)+
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   386
  done
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   387
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   388
lemma all_cong:
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   389
  assumes "!!x. f(x):P(x) <-> Q(x)"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   390
  shows "?p:(ALL x. P(x)) <-> (ALL x. Q(x))"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   391
  apply (assumption | rule iffI allI | tactic {* mp_tac 1 *} | erule allE |
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   392
    tactic {* iff_tac @{thms assms} 1 *})+
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   393
  done
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   394
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   395
lemma ex_cong:
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   396
  assumes "!!x. f(x):P(x) <-> Q(x)"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   397
  shows "?p:(EX x. P(x)) <-> (EX x. Q(x))"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   398
  apply (erule exE | assumption | rule iffI exI | tactic {* mp_tac 1 *} |
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   399
    tactic {* iff_tac @{thms assms} 1 *})+
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   400
  done
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   401
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   402
(*NOT PROVED
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   403
bind_thm ("ex1_cong", prove_goal (the_context ())
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   404
    "(!!x.f(x):P(x) <-> Q(x)) ==> ?p:(EX! x.P(x)) <-> (EX! x.Q(x))"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   405
 (fn prems =>
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   406
  [ (REPEAT   (eresolve_tac [ex1E, spec RS mp] 1 ORELSE ares_tac [iffI,ex1I] 1
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   407
      ORELSE   mp_tac 1
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   408
      ORELSE   iff_tac prems 1)) ]))
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   409
*)
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   410
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   411
(*** Equality rules ***)
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   412
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   413
lemmas refl = ieqI
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   414
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   415
lemma subst:
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   416
  assumes prem1: "p:a=b"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   417
    and prem2: "q:P(a)"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   418
  shows "?p : P(b)"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   419
  apply (rule prem2 [THEN rev_mp])
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   420
  apply (rule prem1 [THEN ieqE])
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   421
  apply (rule impI)
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   422
  apply assumption
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   423
  done
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   424
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   425
lemma sym: "q:a=b ==> ?c:b=a"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   426
  apply (erule subst)
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   427
  apply (rule refl)
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   428
  done
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   429
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   430
lemma trans: "[| p:a=b;  q:b=c |] ==> ?d:a=c"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   431
  apply (erule (1) subst)
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   432
  done
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   433
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   434
(** ~ b=a ==> ~ a=b **)
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   435
lemma not_sym: "p:~ b=a ==> ?q:~ a=b"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   436
  apply (erule contrapos)
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   437
  apply (erule sym)
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   438
  done
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   439
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   440
(*calling "standard" reduces maxidx to 0*)
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   441
lemmas ssubst = sym [THEN subst, standard]
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   442
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   443
(*A special case of ex1E that would otherwise need quantifier expansion*)
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   444
lemma ex1_equalsE: "[| p:EX! x. P(x);  q:P(a);  r:P(b) |] ==> ?d:a=b"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   445
  apply (erule ex1E)
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   446
  apply (rule trans)
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   447
   apply (rule_tac [2] sym)
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   448
   apply (assumption | erule spec [THEN mp])+
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   449
  done
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   450
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   451
(** Polymorphic congruence rules **)
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   452
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   453
lemma subst_context: "[| p:a=b |]  ==>  ?d:t(a)=t(b)"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   454
  apply (erule ssubst)
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   455
  apply (rule refl)
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   456
  done
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   457
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   458
lemma subst_context2: "[| p:a=b;  q:c=d |]  ==>  ?p:t(a,c)=t(b,d)"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   459
  apply (erule ssubst)+
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   460
  apply (rule refl)
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   461
  done
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   462
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   463
lemma subst_context3: "[| p:a=b;  q:c=d;  r:e=f |]  ==>  ?p:t(a,c,e)=t(b,d,f)"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   464
  apply (erule ssubst)+
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   465
  apply (rule refl)
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   466
  done
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   467
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   468
(*Useful with eresolve_tac for proving equalties from known equalities.
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   469
        a = b
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   470
        |   |
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   471
        c = d   *)
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   472
lemma box_equals: "[| p:a=b;  q:a=c;  r:b=d |] ==> ?p:c=d"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   473
  apply (rule trans)
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   474
   apply (rule trans)
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   475
    apply (rule sym)
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   476
    apply assumption+
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   477
  done
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   478
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   479
(*Dual of box_equals: for proving equalities backwards*)
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   480
lemma simp_equals: "[| p:a=c;  q:b=d;  r:c=d |] ==> ?p:a=b"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   481
  apply (rule trans)
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   482
   apply (rule trans)
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   483
    apply (assumption | rule sym)+
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   484
  done
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   485
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   486
(** Congruence rules for predicate letters **)
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   487
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   488
lemma pred1_cong: "p:a=a' ==> ?p:P(a) <-> P(a')"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   489
  apply (rule iffI)
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   490
   apply (tactic {* DEPTH_SOLVE (atac 1 ORELSE eresolve_tac [@{thm subst}, @{thm ssubst}] 1) *})
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   491
  done
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   492
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   493
lemma pred2_cong: "[| p:a=a';  q:b=b' |] ==> ?p:P(a,b) <-> P(a',b')"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   494
  apply (rule iffI)
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   495
   apply (tactic {* DEPTH_SOLVE (atac 1 ORELSE eresolve_tac [@{thm subst}, @{thm ssubst}] 1) *})
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   496
  done
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   497
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   498
lemma pred3_cong: "[| p:a=a';  q:b=b';  r:c=c' |] ==> ?p:P(a,b,c) <-> P(a',b',c')"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   499
  apply (rule iffI)
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   500
   apply (tactic {* DEPTH_SOLVE (atac 1 ORELSE eresolve_tac [@{thm subst}, @{thm ssubst}] 1) *})
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   501
  done
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   502
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   503
(*special cases for free variables P, Q, R, S -- up to 3 arguments*)
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   504
26480
544cef16045b replaced 'ML_setup' by 'ML';
wenzelm
parents: 26322
diff changeset
   505
ML {*
26322
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   506
  bind_thms ("pred_congs",
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   507
    flat (map (fn c =>
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   508
               map (fn th => read_instantiate [("P",c)] th)
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   509
                   [@{thm pred1_cong}, @{thm pred2_cong}, @{thm pred3_cong}])
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   510
               (explode"PQRS")))
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   511
*}
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   512
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   513
(*special case for the equality predicate!*)
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   514
lemmas eq_cong = pred2_cong [where P = "op =", standard]
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   515
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   516
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   517
(*** Simplifications of assumed implications.
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   518
     Roy Dyckhoff has proved that conj_impE, disj_impE, and imp_impE
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   519
     used with mp_tac (restricted to atomic formulae) is COMPLETE for
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   520
     intuitionistic propositional logic.  See
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   521
   R. Dyckhoff, Contraction-free sequent calculi for intuitionistic logic
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   522
    (preprint, University of St Andrews, 1991)  ***)
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   523
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   524
lemma conj_impE:
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   525
  assumes major: "p:(P&Q)-->S"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   526
    and minor: "!!x. x:P-->(Q-->S) ==> q(x):R"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   527
  shows "?p:R"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   528
  apply (assumption | rule conjI impI major [THEN mp] minor)+
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   529
  done
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   530
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   531
lemma disj_impE:
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   532
  assumes major: "p:(P|Q)-->S"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   533
    and minor: "!!x y.[| x:P-->S; y:Q-->S |] ==> q(x,y):R"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   534
  shows "?p:R"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   535
  apply (tactic {* DEPTH_SOLVE (atac 1 ORELSE
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   536
      resolve_tac [@{thm disjI1}, @{thm disjI2}, @{thm impI},
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   537
        @{thm major} RS @{thm mp}, @{thm minor}] 1) *})
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   538
  done
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   539
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   540
(*Simplifies the implication.  Classical version is stronger.
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   541
  Still UNSAFE since Q must be provable -- backtracking needed.  *)
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   542
lemma imp_impE:
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   543
  assumes major: "p:(P-->Q)-->S"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   544
    and r1: "!!x y.[| x:P; y:Q-->S |] ==> q(x,y):Q"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   545
    and r2: "!!x. x:S ==> r(x):R"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   546
  shows "?p:R"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   547
  apply (assumption | rule impI major [THEN mp] r1 r2)+
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   548
  done
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   549
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   550
(*Simplifies the implication.  Classical version is stronger.
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   551
  Still UNSAFE since ~P must be provable -- backtracking needed.  *)
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   552
lemma not_impE:
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   553
  assumes major: "p:~P --> S"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   554
    and r1: "!!y. y:P ==> q(y):False"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   555
    and r2: "!!y. y:S ==> r(y):R"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   556
  shows "?p:R"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   557
  apply (assumption | rule notI impI major [THEN mp] r1 r2)+
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   558
  done
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   559
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   560
(*Simplifies the implication.   UNSAFE.  *)
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   561
lemma iff_impE:
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   562
  assumes major: "p:(P<->Q)-->S"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   563
    and r1: "!!x y.[| x:P; y:Q-->S |] ==> q(x,y):Q"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   564
    and r2: "!!x y.[| x:Q; y:P-->S |] ==> r(x,y):P"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   565
    and r3: "!!x. x:S ==> s(x):R"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   566
  shows "?p:R"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   567
  apply (assumption | rule iffI impI major [THEN mp] r1 r2 r3)+
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   568
  done
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   569
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   570
(*What if (ALL x.~~P(x)) --> ~~(ALL x.P(x)) is an assumption? UNSAFE*)
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   571
lemma all_impE:
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   572
  assumes major: "p:(ALL x. P(x))-->S"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   573
    and r1: "!!x. q:P(x)"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   574
    and r2: "!!y. y:S ==> r(y):R"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   575
  shows "?p:R"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   576
  apply (assumption | rule allI impI major [THEN mp] r1 r2)+
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   577
  done
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   578
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   579
(*Unsafe: (EX x.P(x))-->S  is equivalent to  ALL x.P(x)-->S.  *)
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   580
lemma ex_impE:
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   581
  assumes major: "p:(EX x. P(x))-->S"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   582
    and r: "!!y. y:P(a)-->S ==> q(y):R"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   583
  shows "?p:R"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   584
  apply (assumption | rule exI impI major [THEN mp] r)+
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   585
  done
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   586
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   587
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   588
lemma rev_cut_eq:
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   589
  assumes "p:a=b"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   590
    and "!!x. x:a=b ==> f(x):R"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   591
  shows "?p:R"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   592
  apply (rule assms)+
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   593
  done
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   594
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   595
lemma thin_refl: "!!X. [|p:x=x; PROP W|] ==> PROP W" .
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   596
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   597
use "hypsubst.ML"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   598
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   599
ML {*
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   600
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   601
(*** Applying HypsubstFun to generate hyp_subst_tac ***)
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   602
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   603
structure Hypsubst_Data =
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   604
struct
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   605
  (*Take apart an equality judgement; otherwise raise Match!*)
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   606
  fun dest_eq (Const (@{const_name Proof}, _) $
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   607
    (Const (@{const_name "op ="}, _)  $ t $ u) $ _) = (t, u);
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   608
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   609
  val imp_intr = @{thm impI}
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   610
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   611
  (*etac rev_cut_eq moves an equality to be the last premise. *)
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   612
  val rev_cut_eq = @{thm rev_cut_eq}
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   613
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   614
  val rev_mp = @{thm rev_mp}
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   615
  val subst = @{thm subst}
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   616
  val sym = @{thm sym}
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   617
  val thin_refl = @{thm thin_refl}
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   618
end;
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   619
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   620
structure Hypsubst = HypsubstFun(Hypsubst_Data);
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   621
open Hypsubst;
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   622
*}
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   623
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   624
use "intprover.ML"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   625
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   626
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   627
(*** Rewrite rules ***)
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   628
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   629
lemma conj_rews:
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   630
  "?p1 : P & True <-> P"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   631
  "?p2 : True & P <-> P"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   632
  "?p3 : P & False <-> False"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   633
  "?p4 : False & P <-> False"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   634
  "?p5 : P & P <-> P"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   635
  "?p6 : P & ~P <-> False"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   636
  "?p7 : ~P & P <-> False"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   637
  "?p8 : (P & Q) & R <-> P & (Q & R)"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   638
  apply (tactic {* fn st => IntPr.fast_tac 1 st *})+
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   639
  done
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   640
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   641
lemma disj_rews:
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   642
  "?p1 : P | True <-> True"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   643
  "?p2 : True | P <-> True"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   644
  "?p3 : P | False <-> P"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   645
  "?p4 : False | P <-> P"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   646
  "?p5 : P | P <-> P"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   647
  "?p6 : (P | Q) | R <-> P | (Q | R)"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   648
  apply (tactic {* IntPr.fast_tac 1 *})+
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   649
  done
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   650
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   651
lemma not_rews:
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   652
  "?p1 : ~ False <-> True"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   653
  "?p2 : ~ True <-> False"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   654
  apply (tactic {* IntPr.fast_tac 1 *})+
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   655
  done
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   656
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   657
lemma imp_rews:
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   658
  "?p1 : (P --> False) <-> ~P"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   659
  "?p2 : (P --> True) <-> True"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   660
  "?p3 : (False --> P) <-> True"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   661
  "?p4 : (True --> P) <-> P"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   662
  "?p5 : (P --> P) <-> True"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   663
  "?p6 : (P --> ~P) <-> ~P"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   664
  apply (tactic {* IntPr.fast_tac 1 *})+
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   665
  done
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   666
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   667
lemma iff_rews:
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   668
  "?p1 : (True <-> P) <-> P"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   669
  "?p2 : (P <-> True) <-> P"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   670
  "?p3 : (P <-> P) <-> True"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   671
  "?p4 : (False <-> P) <-> ~P"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   672
  "?p5 : (P <-> False) <-> ~P"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   673
  apply (tactic {* IntPr.fast_tac 1 *})+
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   674
  done
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   675
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   676
lemma quant_rews:
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   677
  "?p1 : (ALL x. P) <-> P"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   678
  "?p2 : (EX x. P) <-> P"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   679
  apply (tactic {* IntPr.fast_tac 1 *})+
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   680
  done
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   681
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   682
(*These are NOT supplied by default!*)
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   683
lemma distrib_rews1:
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   684
  "?p1 : ~(P|Q) <-> ~P & ~Q"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   685
  "?p2 : P & (Q | R) <-> P&Q | P&R"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   686
  "?p3 : (Q | R) & P <-> Q&P | R&P"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   687
  "?p4 : (P | Q --> R) <-> (P --> R) & (Q --> R)"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   688
  apply (tactic {* IntPr.fast_tac 1 *})+
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   689
  done
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   690
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   691
lemma distrib_rews2:
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   692
  "?p1 : ~(EX x. NORM(P(x))) <-> (ALL x. ~NORM(P(x)))"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   693
  "?p2 : ((EX x. NORM(P(x))) --> Q) <-> (ALL x. NORM(P(x)) --> Q)"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   694
  "?p3 : (EX x. NORM(P(x))) & NORM(Q) <-> (EX x. NORM(P(x)) & NORM(Q))"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   695
  "?p4 : NORM(Q) & (EX x. NORM(P(x))) <-> (EX x. NORM(Q) & NORM(P(x)))"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   696
  apply (tactic {* IntPr.fast_tac 1 *})+
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   697
  done
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   698
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   699
lemmas distrib_rews = distrib_rews1 distrib_rews2
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   700
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   701
lemma P_Imp_P_iff_T: "p:P ==> ?p:(P <-> True)"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   702
  apply (tactic {* IntPr.fast_tac 1 *})
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   703
  done
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   704
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   705
lemma not_P_imp_P_iff_F: "p:~P ==> ?p:(P <-> False)"
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   706
  apply (tactic {* IntPr.fast_tac 1 *})
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 17480
diff changeset
   707
  done
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   708
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   709
end