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