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