src/CCL/type.thy
author wenzelm
Mon Oct 04 15:44:54 1993 +0100 (1993-10-04)
changeset 22 41dc6b189412
parent 0 a5a9c433f639
permissions -rw-r--r--
added parse rules for -> and *;
removed ndependent_tr;
clasohm@0
     1
(*  Title:      CCL/types.thy
clasohm@0
     2
    ID:         $Id$
clasohm@0
     3
    Author:     Martin Coen
clasohm@0
     4
    Copyright   1993  University of Cambridge
clasohm@0
     5
clasohm@0
     6
Types in CCL are defined as sets of terms.
clasohm@0
     7
clasohm@0
     8
*)
clasohm@0
     9
clasohm@0
    10
Type = Term +
clasohm@0
    11
clasohm@0
    12
consts
clasohm@0
    13
clasohm@0
    14
  Subtype       :: "['a set, 'a => o] => 'a set"
clasohm@0
    15
  Bool          :: "i set"
clasohm@0
    16
  Unit          :: "i set"
clasohm@0
    17
  "+"           :: "[i set, i set] => i set"            (infixr 55)
clasohm@0
    18
  Pi            :: "[i set, i => i set] => i set"
clasohm@0
    19
  Sigma         :: "[i set, i => i set] => i set"
clasohm@0
    20
  Nat           :: "i set"
clasohm@0
    21
  List          :: "i set => i set"
clasohm@0
    22
  Lists         :: "i set => i set"
clasohm@0
    23
  ILists        :: "i set => i set"
clasohm@0
    24
  TAll          :: "(i set => i set) => i set"          (binder "TALL " 55)
clasohm@0
    25
  TEx           :: "(i set => i set) => i set"          (binder "TEX " 55)
clasohm@0
    26
  Lift          :: "i set => i set"                     ("(3[_])")
clasohm@0
    27
clasohm@0
    28
  SPLIT         :: "[i, [i, i] => i set] => i set"
clasohm@0
    29
clasohm@0
    30
  "@Pi"         :: "[idt, i set, i set] => i set"       ("(3PROD _:_./ _)" [] 60)
clasohm@0
    31
  "@Sigma"      :: "[idt, i set, i set] => i set"       ("(3SUM _:_./ _)" [] 60)
clasohm@0
    32
  "@->"         :: "[i set, i set] => i set"            ("(_ ->/ _)"  [54, 53] 53)
clasohm@0
    33
  "@*"          :: "[i set, i set] => i set"            ("(_ */ _)" [56, 55] 55)
clasohm@0
    34
  "@Subtype"    :: "[idt, 'a set, o] => 'a set"         ("(1{_: _ ./ _})")
clasohm@0
    35
clasohm@0
    36
translations
clasohm@0
    37
  "PROD x:A. B" => "Pi(A, %x. B)"
wenzelm@22
    38
  "A -> B"      => "Pi(A, _K(B))"
clasohm@0
    39
  "SUM x:A. B"  => "Sigma(A, %x. B)"
wenzelm@22
    40
  "A * B"       => "Sigma(A, _K(B))"
clasohm@0
    41
  "{x: A. B}"   == "Subtype(A, %x. B)"
clasohm@0
    42
clasohm@0
    43
rules
clasohm@0
    44
clasohm@0
    45
  Subtype_def "{x:A.P(x)} == {x.x:A & P(x)}"
clasohm@0
    46
  Unit_def          "Unit == {x.x=one}"
clasohm@0
    47
  Bool_def          "Bool == {x.x=true | x=false}"
clasohm@0
    48
  Plus_def           "A+B == {x. (EX a:A.x=inl(a)) | (EX b:B.x=inr(b))}"
clasohm@0
    49
  Pi_def         "Pi(A,B) == {x.EX b.x=lam x.b(x) & (ALL x:A.b(x):B(x))}"
clasohm@0
    50
  Sigma_def   "Sigma(A,B) == {x.EX a:A.EX b:B(a).x=<a,b>}"
clasohm@0
    51
  Nat_def            "Nat == lfp(% X.Unit + X)"
clasohm@0
    52
  List_def       "List(A) == lfp(% X.Unit + A*X)"
clasohm@0
    53
clasohm@0
    54
  Lists_def     "Lists(A) == gfp(% X.Unit + A*X)"
clasohm@0
    55
  ILists_def   "ILists(A) == gfp(% X.{} + A*X)"
clasohm@0
    56
clasohm@0
    57
  Tall_def   "TALL X.B(X) == Inter({X.EX Y.X=B(Y)})"
clasohm@0
    58
  Tex_def     "TEX X.B(X) == Union({X.EX Y.X=B(Y)})"
clasohm@0
    59
  Lift_def           "[A] == A Un {bot}"
clasohm@0
    60
clasohm@0
    61
  SPLIT_def   "SPLIT(p,B) == Union({A.EX x y.p=<x,y> & A=B(x,y)})"
clasohm@0
    62
clasohm@0
    63
end
clasohm@0
    64
clasohm@0
    65
clasohm@0
    66
ML
clasohm@0
    67
clasohm@0
    68
val print_translation =
clasohm@0
    69
  [("Pi", dependent_tr' ("@Pi", "@->")),
clasohm@0
    70
   ("Sigma", dependent_tr' ("@Sigma", "@*"))];
clasohm@0
    71