next up previous contents
Next: Inductive Sigma Up: The LEGO library Previous: Product Types

Sum Types

In the directory lib_sum there is a single file defining the sum type with constructors in1 and in2. Also defined is the case function (essentially the iterator for sum).

 ** Module lib_sum Imports lib_eq_basics
 $sum : (Type)->(Type)->Type(sum)
 $in1_exp : {A:Type}{B:Type}A->sum A B
 $in2_exp : {A:Type}{B:Type}B->sum A B
 $sum_elim :
    {A:Type}{B:Type}{C_sum:(sum A B)->Type}
    ({x2:A}C_sum (in1_exp A B x2))->({x1:B}C_sum (in2_exp A B x1))->
    {z:sum A B}C_sum z
[[A:Type][B:Type][C_sum:(sum A B)->Type]
 [f_in1_exp:{x2:A}C_sum (in1_exp A B x2)]
 [f_in2_exp:{x1:B}C_sum (in2_exp A B x1)][x2:A][x1:B]
    sum_elim A B C_sum f_in1_exp f_in2_exp (in1_exp A B x2)  ==>
    f_in1_exp x2
 || sum_elim A B C_sum f_in1_exp f_in2_exp (in2_exp A B x1)  ==>
    f_in2_exp x1]

  in1 = ... : {s|Type}{t|Type}s->sum s t
  in2 = ... : {s|Type}{t|Type}t->sum s t
  case = ... : {s|Type}{t|Type}{u|Type}(s->u)->(t->u)->(sum s t)->u
  sum_ind = ... :
    {s|Type}{t|Type}{P:(sum s t)->Prop}({x:s}P (in1 x))->
    ({y:t}P (in2 y))->{z:sum s t}P z
  is_in1 = ... : {s|Type}{t|Type}(sum s t)->Prop
  is_in2 = ... : {s|Type}{t|Type}(sum s t)->Prop
  in1_or_in2 = ... : {s|Type}{t|Type}{x:sum s t}or (is_in1 x) (is_in2 x)
  in1_not_in2 = ... : {s|Type}{t|Type}{x|s}not (is_in2 (in1|s|t x))
  in2_not_in1 = ... : {s|Type}{t|Type}{x|t}not (is_in1 (in2|s|t x))
  in1_inj = ... :
    {s|Type}{t|Type}{x,y:s}(Eq (in1|s|t x) (in1|s|t y))->Eq x y
  in2_inj = ... :
    {s|Type}{t|Type}{x,y:t}(Eq (in2|s|t x) (in2|s|t y))->Eq x y

Fri May 24 19:01:27 BST 1996