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