src/FOLP/IFOLP.thy
author paulson
Fri Feb 16 18:00:47 1996 +0100 (1996-02-16)
changeset 1512 ce37c64244c0
parent 1477 4c51ab632cda
child 2714 b0fbdfbbad66
permissions -rw-r--r--
Elimination of fully-functorial style.
Type tactic changed to a type abbrevation (from a datatype).
Constructor tactic and function apply deleted.
clasohm@1477
     1
(*  Title:      FOLP/IFOLP.thy
lcp@1142
     2
    ID:         $Id$
clasohm@1477
     3
    Author:     Martin D Coen, Cambridge University Computer Laboratory
lcp@1142
     4
    Copyright   1992  University of Cambridge
lcp@1142
     5
lcp@1142
     6
Intuitionistic First-Order Logic with Proofs
lcp@1142
     7
*)
lcp@1142
     8
clasohm@0
     9
IFOLP = Pure +
clasohm@0
    10
clasohm@0
    11
classes term < logic
clasohm@0
    12
clasohm@0
    13
default term
clasohm@0
    14
lcp@283
    15
types
lcp@283
    16
  p
lcp@283
    17
  o
clasohm@0
    18
lcp@283
    19
arities
lcp@283
    20
  p,o :: logic
clasohm@0
    21
clasohm@1477
    22
consts  
clasohm@0
    23
      (*** Judgements ***)
clasohm@1477
    24
 "@Proof"       ::   "[p,o]=>prop"      ("(_ /: _)" [51,10] 5)
clasohm@1477
    25
 Proof          ::   "[o,p]=>prop"
clasohm@0
    26
 EqProof        ::   "[p,p,o]=>prop"    ("(3_ /= _ :/ _)" [10,10,10] 5)
clasohm@0
    27
        
clasohm@0
    28
      (*** Logical Connectives -- Type Formers ***)
clasohm@1477
    29
 "="            ::      "['a,'a] => o"  (infixl 50)
clasohm@1477
    30
 True,False     ::      "o"
clasohm@1477
    31
 "Not"          ::      "o => o"        ("~ _" [40] 40)
clasohm@1477
    32
 "&"            ::      "[o,o] => o"    (infixr 35)
clasohm@1477
    33
 "|"            ::      "[o,o] => o"    (infixr 30)
clasohm@1477
    34
 "-->"          ::      "[o,o] => o"    (infixr 25)
clasohm@1477
    35
 "<->"          ::      "[o,o] => o"    (infixr 25)
clasohm@0
    36
      (*Quantifiers*)
clasohm@1477
    37
 All            ::      "('a => o) => o"        (binder "ALL " 10)
clasohm@1477
    38
 Ex             ::      "('a => o) => o"        (binder "EX " 10)
clasohm@1477
    39
 Ex1            ::      "('a => o) => o"        (binder "EX! " 10)
clasohm@0
    40
      (*Rewriting gadgets*)
clasohm@1477
    41
 NORM           ::      "o => o"
clasohm@1477
    42
 norm           ::      "'a => 'a"
clasohm@0
    43
lcp@648
    44
      (*** Proof Term Formers: precedence must exceed 50 ***)
clasohm@1477
    45
 tt             :: "p"
clasohm@1477
    46
 contr          :: "p=>p"
clasohm@1477
    47
 fst,snd        :: "p=>p"
clasohm@1477
    48
 pair           :: "[p,p]=>p"           ("(1<_,/_>)")
clasohm@1477
    49
 split          :: "[p, [p,p]=>p] =>p"
clasohm@1477
    50
 inl,inr        :: "p=>p"
clasohm@1477
    51
 when           :: "[p, p=>p, p=>p]=>p"
clasohm@1477
    52
 lambda         :: "(p => p) => p"      (binder "lam " 55)
clasohm@1477
    53
 "`"            :: "[p,p]=>p"           (infixl 60)
lcp@648
    54
 alll           :: "['a=>p]=>p"         (binder "all " 55)
lcp@648
    55
 "^"            :: "[p,'a]=>p"          (infixl 55)
clasohm@1477
    56
 exists         :: "['a,p]=>p"          ("(1[_,/_])")
clasohm@0
    57
 xsplit         :: "[p,['a,p]=>p]=>p"
clasohm@0
    58
 ideq           :: "'a=>p"
clasohm@0
    59
 idpeel         :: "[p,'a=>p]=>p"
clasohm@0
    60
 nrm, NRM       :: "p"
clasohm@0
    61
clasohm@0
    62
rules
clasohm@0
    63
clasohm@0
    64
(**** Propositional logic ****)
clasohm@0
    65
clasohm@0
    66
(*Equality*)
clasohm@0
    67
(* Like Intensional Equality in MLTT - but proofs distinct from terms *)
clasohm@0
    68
clasohm@1477
    69
ieqI      "ideq(a) : a=a"
clasohm@0
    70
ieqE      "[| p : a=b;  !!x.f(x) : P(x,x) |] ==> idpeel(p,f) : P(a,b)"
clasohm@0
    71
clasohm@0
    72
(* Truth and Falsity *)
clasohm@0
    73
clasohm@0
    74
TrueI     "tt : True"
clasohm@0
    75
FalseE    "a:False ==> contr(a):P"
clasohm@0
    76
clasohm@0
    77
(* Conjunction *)
clasohm@0
    78
clasohm@0
    79
conjI     "[| a:P;  b:Q |] ==> <a,b> : P&Q"
clasohm@0
    80
conjunct1 "p:P&Q ==> fst(p):P"
clasohm@0
    81
conjunct2 "p:P&Q ==> snd(p):Q"
clasohm@0
    82
clasohm@0
    83
(* Disjunction *)
clasohm@0
    84
clasohm@0
    85
disjI1    "a:P ==> inl(a):P|Q"
clasohm@0
    86
disjI2    "b:Q ==> inr(b):P|Q"
clasohm@1149
    87
disjE     "[| a:P|Q;  !!x.x:P ==> f(x):R;  !!x.x:Q ==> g(x):R 
clasohm@1149
    88
          |] ==> when(a,f,g):R"
clasohm@0
    89
clasohm@0
    90
(* Implication *)
clasohm@0
    91
clasohm@0
    92
impI      "(!!x.x:P ==> f(x):Q) ==> lam x.f(x):P-->Q"
clasohm@0
    93
mp        "[| f:P-->Q;  a:P |] ==> f`a:Q"
clasohm@0
    94
clasohm@0
    95
(*Quantifiers*)
clasohm@0
    96
clasohm@1477
    97
allI      "(!!x. f(x) : P(x)) ==> all x.f(x) : ALL x.P(x)"
clasohm@1477
    98
spec      "(f:ALL x.P(x)) ==> f^x : P(x)"
clasohm@0
    99
clasohm@1477
   100
exI       "p : P(x) ==> [x,p] : EX x.P(x)"
clasohm@1477
   101
exE       "[| p: EX x.P(x);  !!x u. u:P(x) ==> f(x,u) : R |] ==> xsplit(p,f):R"
clasohm@0
   102
clasohm@0
   103
(**** Equality between proofs ****)
clasohm@0
   104
clasohm@0
   105
prefl     "a : P ==> a = a : P"
clasohm@0
   106
psym      "a = b : P ==> b = a : P"
clasohm@0
   107
ptrans    "[| a = b : P;  b = c : P |] ==> a = c : P"
clasohm@0
   108
clasohm@0
   109
idpeelB   "[| !!x.f(x) : P(x,x) |] ==> idpeel(ideq(a),f) = f(a) : P(a,a)"
clasohm@0
   110
clasohm@0
   111
fstB      "a:P ==> fst(<a,b>) = a : P"
clasohm@0
   112
sndB      "b:Q ==> snd(<a,b>) = b : Q"
clasohm@0
   113
pairEC    "p:P&Q ==> p = <fst(p),snd(p)> : P&Q"
clasohm@0
   114
clasohm@0
   115
whenBinl  "[| a:P;  !!x.x:P ==> f(x) : Q |] ==> when(inl(a),f,g) = f(a) : Q"
clasohm@0
   116
whenBinr  "[| b:P;  !!x.x:P ==> g(x) : Q |] ==> when(inr(b),f,g) = g(b) : Q"
clasohm@0
   117
plusEC    "a:P|Q ==> when(a,%x.inl(x),%y.inr(y)) = p : P|Q"
clasohm@0
   118
clasohm@0
   119
applyB     "[| a:P;  !!x.x:P ==> b(x) : Q |] ==> (lam x.b(x)) ` a = b(a) : Q"
clasohm@0
   120
funEC      "f:P ==> f = lam x.f`x : P"
clasohm@0
   121
clasohm@0
   122
specB      "[| !!x.f(x) : P(x) |] ==> (all x.f(x)) ^ a = f(a) : P(a)"
clasohm@0
   123
clasohm@0
   124
clasohm@0
   125
(**** Definitions ****)
clasohm@0
   126
clasohm@1477
   127
not_def              "~P == P-->False"
clasohm@0
   128
iff_def         "P<->Q == (P-->Q) & (Q-->P)"
clasohm@0
   129
clasohm@0
   130
(*Unique existence*)
clasohm@0
   131
ex1_def   "EX! x. P(x) == EX x. P(x) & (ALL y. P(y) --> y=x)"
clasohm@0
   132
clasohm@0
   133
(*Rewriting -- special constants to flag normalized terms and formulae*)
clasohm@1477
   134
norm_eq "nrm : norm(x) = x"
clasohm@1477
   135
NORM_iff        "NRM : NORM(P) <-> P"
clasohm@0
   136
clasohm@0
   137
end
clasohm@0
   138
clasohm@0
   139
ML
clasohm@0
   140
clasohm@0
   141
(*show_proofs:=true displays the proof terms -- they are ENORMOUS*)
clasohm@0
   142
val show_proofs = ref false;
clasohm@0
   143
clasohm@0
   144
fun proof_tr [p,P] = Const("Proof",dummyT) $ P $ p;
clasohm@0
   145
clasohm@0
   146
fun proof_tr' [P,p] = 
clasohm@0
   147
    if !show_proofs then Const("@Proof",dummyT) $ p $ P 
clasohm@0
   148
    else P  (*this case discards the proof term*);
clasohm@0
   149
clasohm@0
   150
val  parse_translation = [("@Proof", proof_tr)];
clasohm@0
   151
val print_translation  = [("Proof", proof_tr')];
clasohm@0
   152