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