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