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