src/CTT/CTT.thy
author paulson
Tue, 14 Nov 2000 13:26:48 +0100
changeset 10467 e6e7205e9e91
parent 3837 d7f033c74b38
child 12110 f8b4b11cd79d
permissions -rw-r--r--
x-symbol support for Pi, Sigma, -->, : (membership) note that "lam" is displayed as TWO lambda-symbols
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     1
(*  Title:      CTT/ctt.thy
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     2
    ID:         $Id$
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     4
    Copyright   1993  University of Cambridge
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     5
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     6
Constructive Type Theory
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     7
*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     8
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     9
CTT = Pure +
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    10
283
76caebd18756 new type declaration syntax instead of numbers
lcp
parents: 23
diff changeset
    11
types
76caebd18756 new type declaration syntax instead of numbers
lcp
parents: 23
diff changeset
    12
  i
76caebd18756 new type declaration syntax instead of numbers
lcp
parents: 23
diff changeset
    13
  t
76caebd18756 new type declaration syntax instead of numbers
lcp
parents: 23
diff changeset
    14
  o
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    15
283
76caebd18756 new type declaration syntax instead of numbers
lcp
parents: 23
diff changeset
    16
arities
76caebd18756 new type declaration syntax instead of numbers
lcp
parents: 23
diff changeset
    17
   i,t,o :: logic
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    18
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    19
consts
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    20
  (*Types*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    21
  F,T       :: "t"          (*F is empty, T contains one element*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    22
  contr     :: "i=>i"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    23
  tt        :: "i"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    24
  (*Natural numbers*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    25
  N         :: "t"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    26
  succ      :: "i=>i"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    27
  rec       :: "[i, i, [i,i]=>i] => i"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    28
  (*Unions*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    29
  inl,inr   :: "i=>i"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    30
  when      :: "[i, i=>i, i=>i]=>i"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    31
  (*General Sum and Binary Product*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    32
  Sum       :: "[t, i=>t]=>t"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    33
  fst,snd   :: "i=>i"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    34
  split     :: "[i, [i,i]=>i] =>i"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    35
  (*General Product and Function Space*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    36
  Prod      :: "[t, i=>t]=>t"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    37
  (*Equality type*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    38
  Eq        :: "[t,i,i]=>t"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    39
  eq        :: "i"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    40
  (*Judgements*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    41
  Type      :: "t => prop"          ("(_ type)" [10] 5)
10467
e6e7205e9e91 x-symbol support for Pi, Sigma, -->, : (membership)
paulson
parents: 3837
diff changeset
    42
  Eqtype    :: "[t,t]=>prop"        ("(_ =/ _)" [10,10] 5)
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    43
  Elem      :: "[i, t]=>prop"       ("(_ /: _)" [10,10] 5)
10467
e6e7205e9e91 x-symbol support for Pi, Sigma, -->, : (membership)
paulson
parents: 3837
diff changeset
    44
  Eqelem    :: "[i,i,t]=>prop"      ("(_ =/ _ :/ _)" [10,10,10] 5)
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    45
  Reduce    :: "[i,i]=>prop"        ("Reduce[_,_]")
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    46
  (*Types*)
23
1cd377c2f7c6 replaced id by idt;
wenzelm
parents: 0
diff changeset
    47
  "@PROD"   :: "[idt,t,t]=>t"       ("(3PROD _:_./ _)" 10)
1cd377c2f7c6 replaced id by idt;
wenzelm
parents: 0
diff changeset
    48
  "@SUM"    :: "[idt,t,t]=>t"       ("(3SUM _:_./ _)" 10)
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    49
  "+"       :: "[t,t]=>t"           (infixr 40)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    50
  (*Invisible infixes!*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    51
  "@-->"    :: "[t,t]=>t"           ("(_ -->/ _)" [31,30] 30)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    52
  "@*"      :: "[t,t]=>t"           ("(_ */ _)" [51,50] 50)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    53
  (*Functions*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    54
  lambda    :: "(i => i) => i"      (binder "lam " 10)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    55
  "`"       :: "[i,i]=>i"           (infixl 60)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    56
  (*Natural numbers*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    57
  "0"       :: "i"                  ("0")
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    58
  (*Pairing*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    59
  pair      :: "[i,i]=>i"           ("(1<_,/_>)")
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    60
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    61
translations
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    62
  "PROD x:A. B" => "Prod(A, %x. B)"
23
1cd377c2f7c6 replaced id by idt;
wenzelm
parents: 0
diff changeset
    63
  "A --> B"     => "Prod(A, _K(B))"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    64
  "SUM x:A. B"  => "Sum(A, %x. B)"
23
1cd377c2f7c6 replaced id by idt;
wenzelm
parents: 0
diff changeset
    65
  "A * B"       => "Sum(A, _K(B))"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    66
10467
e6e7205e9e91 x-symbol support for Pi, Sigma, -->, : (membership)
paulson
parents: 3837
diff changeset
    67
syntax (xsymbols)
e6e7205e9e91 x-symbol support for Pi, Sigma, -->, : (membership)
paulson
parents: 3837
diff changeset
    68
  "@-->"    :: "[t,t]=>t"           ("(_ \\<longrightarrow>/ _)" [31,30] 30)
e6e7205e9e91 x-symbol support for Pi, Sigma, -->, : (membership)
paulson
parents: 3837
diff changeset
    69
  "@*"      :: "[t,t]=>t"           ("(_ \\<times>/ _)"          [51,50] 50)
e6e7205e9e91 x-symbol support for Pi, Sigma, -->, : (membership)
paulson
parents: 3837
diff changeset
    70
e6e7205e9e91 x-symbol support for Pi, Sigma, -->, : (membership)
paulson
parents: 3837
diff changeset
    71
syntax (symbols)
e6e7205e9e91 x-symbol support for Pi, Sigma, -->, : (membership)
paulson
parents: 3837
diff changeset
    72
  Elem      :: "[i, t]=>prop"     ("(_ /\\<in> _)" [10,10] 5)
e6e7205e9e91 x-symbol support for Pi, Sigma, -->, : (membership)
paulson
parents: 3837
diff changeset
    73
  Eqelem    :: "[i,i,t]=>prop"    ("(2_ =/ _ \\<in>/ _)" [10,10,10] 5)
e6e7205e9e91 x-symbol support for Pi, Sigma, -->, : (membership)
paulson
parents: 3837
diff changeset
    74
  "@SUM"    :: "[idt,t,t] => t"   ("(3\\<Sigma> _\\<in>_./ _)" 10)
e6e7205e9e91 x-symbol support for Pi, Sigma, -->, : (membership)
paulson
parents: 3837
diff changeset
    75
  "@PROD"   :: "[idt,t,t] => t"   ("(3\\<Pi> _\\<in>_./ _)"    10)
e6e7205e9e91 x-symbol support for Pi, Sigma, -->, : (membership)
paulson
parents: 3837
diff changeset
    76
  "lam "    :: "[idts, i] => i"   ("(3\\<lambda>\\<lambda>_./ _)" 10)
e6e7205e9e91 x-symbol support for Pi, Sigma, -->, : (membership)
paulson
parents: 3837
diff changeset
    77
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    78
rules
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    79
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    80
  (*Reduction: a weaker notion than equality;  a hack for simplification.
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    81
    Reduce[a,b] means either that  a=b:A  for some A or else that "a" and "b"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    82
    are textually identical.*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    83
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    84
  (*does not verify a:A!  Sound because only trans_red uses a Reduce premise
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    85
    No new theorems can be proved about the standard judgements.*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    86
  refl_red "Reduce[a,a]"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    87
  red_if_equal "a = b : A ==> Reduce[a,b]"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    88
  trans_red "[| a = b : A;  Reduce[b,c] |] ==> a = c : A"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    89
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    90
  (*Reflexivity*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    91
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    92
  refl_type "A type ==> A = A"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    93
  refl_elem "a : A ==> a = a : A"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    94
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    95
  (*Symmetry*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    96
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    97
  sym_type  "A = B ==> B = A"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    98
  sym_elem  "a = b : A ==> b = a : A"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    99
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   100
  (*Transitivity*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   101
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   102
  trans_type   "[| A = B;  B = C |] ==> A = C"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   103
  trans_elem   "[| a = b : A;  b = c : A |] ==> a = c : A"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   104
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   105
  equal_types  "[| a : A;  A = B |] ==> a : B"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   106
  equal_typesL "[| a = b : A;  A = B |] ==> a = b : B"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   107
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   108
  (*Substitution*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   109
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   110
  subst_type   "[| a : A;  !!z. z:A ==> B(z) type |] ==> B(a) type"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   111
  subst_typeL  "[| a = c : A;  !!z. z:A ==> B(z) = D(z) |] ==> B(a) = D(c)"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   112
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   113
  subst_elem   "[| a : A;  !!z. z:A ==> b(z):B(z) |] ==> b(a):B(a)"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   114
  subst_elemL
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   115
    "[| a=c : A;  !!z. z:A ==> b(z)=d(z) : B(z) |] ==> b(a)=d(c) : B(a)"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   116
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   117
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   118
  (*The type N -- natural numbers*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   119
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   120
  NF "N type"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   121
  NI0 "0 : N"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   122
  NI_succ "a : N ==> succ(a) : N"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   123
  NI_succL  "a = b : N ==> succ(a) = succ(b) : N"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   124
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   125
  NE
1149
5750eba8820d removed \...\ inside strings
clasohm
parents: 283
diff changeset
   126
   "[| p: N;  a: C(0);  !!u v. [| u: N; v: C(u) |] ==> b(u,v): C(succ(u)) |] 
3837
d7f033c74b38 fixed dots;
wenzelm
parents: 1149
diff changeset
   127
   ==> rec(p, a, %u v. b(u,v)) : C(p)"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   128
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   129
  NEL
1149
5750eba8820d removed \...\ inside strings
clasohm
parents: 283
diff changeset
   130
   "[| p = q : N;  a = c : C(0);  
5750eba8820d removed \...\ inside strings
clasohm
parents: 283
diff changeset
   131
      !!u v. [| u: N; v: C(u) |] ==> b(u,v) = d(u,v): C(succ(u)) |] 
3837
d7f033c74b38 fixed dots;
wenzelm
parents: 1149
diff changeset
   132
   ==> rec(p, a, %u v. b(u,v)) = rec(q,c,d) : C(p)"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   133
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   134
  NC0
1149
5750eba8820d removed \...\ inside strings
clasohm
parents: 283
diff changeset
   135
   "[| a: C(0);  !!u v. [| u: N; v: C(u) |] ==> b(u,v): C(succ(u)) |] 
3837
d7f033c74b38 fixed dots;
wenzelm
parents: 1149
diff changeset
   136
   ==> rec(0, a, %u v. b(u,v)) = a : C(0)"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   137
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   138
  NC_succ
1149
5750eba8820d removed \...\ inside strings
clasohm
parents: 283
diff changeset
   139
   "[| p: N;  a: C(0);  
5750eba8820d removed \...\ inside strings
clasohm
parents: 283
diff changeset
   140
       !!u v. [| u: N; v: C(u) |] ==> b(u,v): C(succ(u)) |] ==>  
3837
d7f033c74b38 fixed dots;
wenzelm
parents: 1149
diff changeset
   141
   rec(succ(p), a, %u v. b(u,v)) = b(p, rec(p, a, %u v. b(u,v))) : C(succ(p))"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   142
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   143
  (*The fourth Peano axiom.  See page 91 of Martin-Lof's book*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   144
  zero_ne_succ
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   145
    "[| a: N;  0 = succ(a) : N |] ==> 0: F"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   146
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   147
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   148
  (*The Product of a family of types*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   149
3837
d7f033c74b38 fixed dots;
wenzelm
parents: 1149
diff changeset
   150
  ProdF  "[| A type; !!x. x:A ==> B(x) type |] ==> PROD x:A. B(x) type"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   151
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   152
  ProdFL
1149
5750eba8820d removed \...\ inside strings
clasohm
parents: 283
diff changeset
   153
   "[| A = C;  !!x. x:A ==> B(x) = D(x) |] ==> 
3837
d7f033c74b38 fixed dots;
wenzelm
parents: 1149
diff changeset
   154
   PROD x:A. B(x) = PROD x:C. D(x)"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   155
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   156
  ProdI
3837
d7f033c74b38 fixed dots;
wenzelm
parents: 1149
diff changeset
   157
   "[| A type;  !!x. x:A ==> b(x):B(x)|] ==> lam x. b(x) : PROD x:A. B(x)"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   158
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   159
  ProdIL
1149
5750eba8820d removed \...\ inside strings
clasohm
parents: 283
diff changeset
   160
   "[| A type;  !!x. x:A ==> b(x) = c(x) : B(x)|] ==> 
3837
d7f033c74b38 fixed dots;
wenzelm
parents: 1149
diff changeset
   161
   lam x. b(x) = lam x. c(x) : PROD x:A. B(x)"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   162
3837
d7f033c74b38 fixed dots;
wenzelm
parents: 1149
diff changeset
   163
  ProdE  "[| p : PROD x:A. B(x);  a : A |] ==> p`a : B(a)"
d7f033c74b38 fixed dots;
wenzelm
parents: 1149
diff changeset
   164
  ProdEL "[| p=q: PROD x:A. B(x);  a=b : A |] ==> p`a = q`b : B(a)"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   165
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   166
  ProdC
1149
5750eba8820d removed \...\ inside strings
clasohm
parents: 283
diff changeset
   167
   "[| a : A;  !!x. x:A ==> b(x) : B(x)|] ==> 
3837
d7f033c74b38 fixed dots;
wenzelm
parents: 1149
diff changeset
   168
   (lam x. b(x)) ` a = b(a) : B(a)"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   169
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   170
  ProdC2
3837
d7f033c74b38 fixed dots;
wenzelm
parents: 1149
diff changeset
   171
   "p : PROD x:A. B(x) ==> (lam x. p`x) = p : PROD x:A. B(x)"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   172
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   173
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   174
  (*The Sum of a family of types*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   175
3837
d7f033c74b38 fixed dots;
wenzelm
parents: 1149
diff changeset
   176
  SumF  "[| A type;  !!x. x:A ==> B(x) type |] ==> SUM x:A. B(x) type"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   177
  SumFL
3837
d7f033c74b38 fixed dots;
wenzelm
parents: 1149
diff changeset
   178
    "[| A = C;  !!x. x:A ==> B(x) = D(x) |] ==> SUM x:A. B(x) = SUM x:C. D(x)"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   179
3837
d7f033c74b38 fixed dots;
wenzelm
parents: 1149
diff changeset
   180
  SumI  "[| a : A;  b : B(a) |] ==> <a,b> : SUM x:A. B(x)"
d7f033c74b38 fixed dots;
wenzelm
parents: 1149
diff changeset
   181
  SumIL "[| a=c:A;  b=d:B(a) |] ==> <a,b> = <c,d> : SUM x:A. B(x)"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   182
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   183
  SumE
3837
d7f033c74b38 fixed dots;
wenzelm
parents: 1149
diff changeset
   184
    "[| p: SUM x:A. B(x);  !!x y. [| x:A; y:B(x) |] ==> c(x,y): C(<x,y>) |] 
d7f033c74b38 fixed dots;
wenzelm
parents: 1149
diff changeset
   185
    ==> split(p, %x y. c(x,y)) : C(p)"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   186
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   187
  SumEL
3837
d7f033c74b38 fixed dots;
wenzelm
parents: 1149
diff changeset
   188
    "[| p=q : SUM x:A. B(x); 
1149
5750eba8820d removed \...\ inside strings
clasohm
parents: 283
diff changeset
   189
       !!x y. [| x:A; y:B(x) |] ==> c(x,y)=d(x,y): C(<x,y>)|] 
3837
d7f033c74b38 fixed dots;
wenzelm
parents: 1149
diff changeset
   190
    ==> split(p, %x y. c(x,y)) = split(q, % x y. d(x,y)) : C(p)"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   191
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   192
  SumC
1149
5750eba8820d removed \...\ inside strings
clasohm
parents: 283
diff changeset
   193
    "[| a: A;  b: B(a);  !!x y. [| x:A; y:B(x) |] ==> c(x,y): C(<x,y>) |] 
3837
d7f033c74b38 fixed dots;
wenzelm
parents: 1149
diff changeset
   194
    ==> split(<a,b>, %x y. c(x,y)) = c(a,b) : C(<a,b>)"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   195
3837
d7f033c74b38 fixed dots;
wenzelm
parents: 1149
diff changeset
   196
  fst_def   "fst(a) == split(a, %x y. x)"
d7f033c74b38 fixed dots;
wenzelm
parents: 1149
diff changeset
   197
  snd_def   "snd(a) == split(a, %x y. y)"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   198
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   199
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   200
  (*The sum of two types*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   201
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   202
  PlusF   "[| A type;  B type |] ==> A+B type"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   203
  PlusFL  "[| A = C;  B = D |] ==> A+B = C+D"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   204
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   205
  PlusI_inl   "[| a : A;  B type |] ==> inl(a) : A+B"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   206
  PlusI_inlL "[| a = c : A;  B type |] ==> inl(a) = inl(c) : A+B"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   207
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   208
  PlusI_inr   "[| A type;  b : B |] ==> inr(b) : A+B"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   209
  PlusI_inrL "[| A type;  b = d : B |] ==> inr(b) = inr(d) : A+B"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   210
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   211
  PlusE
1149
5750eba8820d removed \...\ inside strings
clasohm
parents: 283
diff changeset
   212
    "[| p: A+B;  !!x. x:A ==> c(x): C(inl(x));  
5750eba8820d removed \...\ inside strings
clasohm
parents: 283
diff changeset
   213
                !!y. y:B ==> d(y): C(inr(y)) |] 
3837
d7f033c74b38 fixed dots;
wenzelm
parents: 1149
diff changeset
   214
    ==> when(p, %x. c(x), %y. d(y)) : C(p)"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   215
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   216
  PlusEL
1149
5750eba8820d removed \...\ inside strings
clasohm
parents: 283
diff changeset
   217
    "[| p = q : A+B;  !!x. x: A ==> c(x) = e(x) : C(inl(x));   
5750eba8820d removed \...\ inside strings
clasohm
parents: 283
diff changeset
   218
                     !!y. y: B ==> d(y) = f(y) : C(inr(y)) |] 
3837
d7f033c74b38 fixed dots;
wenzelm
parents: 1149
diff changeset
   219
    ==> when(p, %x. c(x), %y. d(y)) = when(q, %x. e(x), %y. f(y)) : C(p)"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   220
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   221
  PlusC_inl
1149
5750eba8820d removed \...\ inside strings
clasohm
parents: 283
diff changeset
   222
    "[| a: A;  !!x. x:A ==> c(x): C(inl(x));  
5750eba8820d removed \...\ inside strings
clasohm
parents: 283
diff changeset
   223
              !!y. y:B ==> d(y): C(inr(y)) |] 
3837
d7f033c74b38 fixed dots;
wenzelm
parents: 1149
diff changeset
   224
    ==> when(inl(a), %x. c(x), %y. d(y)) = c(a) : C(inl(a))"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   225
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   226
  PlusC_inr
1149
5750eba8820d removed \...\ inside strings
clasohm
parents: 283
diff changeset
   227
    "[| b: B;  !!x. x:A ==> c(x): C(inl(x));  
5750eba8820d removed \...\ inside strings
clasohm
parents: 283
diff changeset
   228
              !!y. y:B ==> d(y): C(inr(y)) |] 
3837
d7f033c74b38 fixed dots;
wenzelm
parents: 1149
diff changeset
   229
    ==> when(inr(b), %x. c(x), %y. d(y)) = d(b) : C(inr(b))"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   230
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   231
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   232
  (*The type Eq*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   233
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   234
  EqF    "[| A type;  a : A;  b : A |] ==> Eq(A,a,b) type"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   235
  EqFL "[| A=B;  a=c: A;  b=d : A |] ==> Eq(A,a,b) = Eq(B,c,d)"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   236
  EqI "a = b : A ==> eq : Eq(A,a,b)"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   237
  EqE "p : Eq(A,a,b) ==> a = b : A"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   238
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   239
  (*By equality of types, can prove C(p) from C(eq), an elimination rule*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   240
  EqC "p : Eq(A,a,b) ==> p = eq : Eq(A,a,b)"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   241
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   242
  (*The type F*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   243
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   244
  FF "F type"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   245
  FE "[| p: F;  C type |] ==> contr(p) : C"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   246
  FEL  "[| p = q : F;  C type |] ==> contr(p) = contr(q) : C"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   247
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   248
  (*The type T
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   249
     Martin-Lof's book (page 68) discusses elimination and computation.
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   250
     Elimination can be derived by computation and equality of types,
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   251
     but with an extra premise C(x) type x:T.
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   252
     Also computation can be derived from elimination. *)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   253
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   254
  TF "T type"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   255
  TI "tt : T"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   256
  TE "[| p : T;  c : C(tt) |] ==> c : C(p)"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   257
  TEL "[| p = q : T;  c = d : C(tt) |] ==> c = d : C(p)"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   258
  TC "p : T ==> p = tt : T"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   259
end
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   260
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   261
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   262
ML
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   263
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   264
val print_translation =
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   265
  [("Prod", dependent_tr' ("@PROD", "@-->")),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   266
   ("Sum", dependent_tr' ("@SUM", "@*"))];
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   267