src/HOL/Prod.thy
changeset 923 ff1574a81019
child 967 bfcb53497a99
equal deleted inserted replaced
922:196ca0973a6d 923:ff1574a81019
       
     1 (*  Title:      HOL/Prod.thy
       
     2     ID:         Prod.thy,v 1.5 1994/08/19 09:04:27 lcp Exp
       
     3     Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
       
     4     Copyright   1992  University of Cambridge
       
     5 
       
     6 Ordered Pairs and the Cartesian product type.
       
     7 The unit type.
       
     8 *)
       
     9 
       
    10 Prod = Fun +
       
    11 
       
    12 (** Products **)
       
    13 
       
    14 (* type definition *)
       
    15 
       
    16 consts
       
    17   Pair_Rep      :: "['a, 'b] => ['a, 'b] => bool"
       
    18 
       
    19 defs
       
    20   Pair_Rep_def  "Pair_Rep == (%a b. %x y. x=a & y=b)"
       
    21 
       
    22 subtype (Prod)
       
    23   ('a, 'b) "*"          (infixr 20)
       
    24     = "{f. ? a b. f = Pair_Rep (a::'a) (b::'b)}"
       
    25 
       
    26 
       
    27 (* abstract constants and syntax *)
       
    28 
       
    29 consts
       
    30   fst           :: "'a * 'b => 'a"
       
    31   snd           :: "'a * 'b => 'b"
       
    32   split         :: "[['a, 'b] => 'c, 'a * 'b] => 'c"
       
    33   prod_fun      :: "['a => 'b, 'c => 'd, 'a * 'c] => 'b * 'd"
       
    34   Pair          :: "['a, 'b] => 'a * 'b"
       
    35   Sigma         :: "['a set, 'a => 'b set] => ('a * 'b) set"
       
    36 
       
    37 syntax
       
    38   "@Tuple"      :: "args => 'a * 'b"            ("(1<_>)")
       
    39 
       
    40 translations
       
    41   "<x, y, z>"   == "<x, <y, z>>"
       
    42   "<x, y>"      == "Pair x y"
       
    43   "<x>"         => "x"
       
    44 
       
    45 defs
       
    46   Pair_def      "Pair a b == Abs_Prod(Pair_Rep a b)"
       
    47   fst_def       "fst(p) == @a. ? b. p = <a, b>"
       
    48   snd_def       "snd(p) == @b. ? a. p = <a, b>"
       
    49   split_def     "split c p == c (fst p) (snd p)"
       
    50   prod_fun_def  "prod_fun f g == split(%x y.<f(x), g(y)>)"
       
    51   Sigma_def     "Sigma A B == UN x:A. UN y:B(x). {<x, y>}"
       
    52 
       
    53 
       
    54 
       
    55 (** Unit **)
       
    56 
       
    57 subtype (Unit)
       
    58   unit = "{p. p = True}"
       
    59 
       
    60 consts
       
    61   Unity         :: "unit"                       ("<>")
       
    62 
       
    63 defs
       
    64   Unity_def     "Unity == Abs_Unit(True)"
       
    65 
       
    66 end