src/HOL/Prod.thy
author wenzelm
Mon Oct 20 11:25:39 1997 +0200 (1997-10-20)
changeset 3947 eb707467f8c5
parent 3842 b55686a7b22c
child 4570 c04027ccc86e
permissions -rw-r--r--
adapted to qualified names;
     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 + equalities +
    11 
    12 
    13 (** products **)
    14 
    15 (* type definition *)
    16 
    17 constdefs
    18   Pair_Rep      :: ['a, 'b] => ['a, 'b] => bool
    19   "Pair_Rep == (%a b. %x y. x=a & y=b)"
    20 
    21 global
    22 
    23 typedef (Prod)
    24   ('a, 'b) "*"          (infixr 20)
    25     = "{f. ? a b. f = Pair_Rep (a::'a) (b::'b)}"
    26 
    27 syntax (symbols)
    28   "*"           :: [type, type] => type         ("(_ \\<times>/ _)" [21, 20] 20)
    29 
    30 
    31 (* abstract constants and syntax *)
    32 
    33 consts
    34   fst           :: "'a * 'b => 'a"
    35   snd           :: "'a * 'b => 'b"
    36   split         :: "[['a, 'b] => 'c, 'a * 'b] => 'c"
    37   prod_fun      :: "['a => 'b, 'c => 'd, 'a * 'c] => 'b * 'd"
    38   Pair          :: "['a, 'b] => 'a * 'b"
    39   Sigma         :: "['a set, 'a => 'b set] => ('a * 'b) set"
    40 
    41 
    42 (* patterns -- extends pre-defined type "pttrn" used in abstractions *)
    43 
    44 types patterns
    45 
    46 syntax
    47   "@Tuple"      :: "['a, args] => 'a * 'b"       ("(1'(_,/ _'))")
    48 
    49   "_pattern"    :: [pttrn, patterns] => pttrn    ("'(_,/_')")
    50   ""            :: pttrn => patterns             ("_")
    51   "_patterns"   :: [pttrn, patterns] => patterns ("_,/_")
    52 
    53   "@Sigma"      :: "[pttrn, 'a set, 'b set] => ('a * 'b) set"   ("(3SIGMA _:_./ _)" 10)
    54   "@Times"      :: "['a set, 'a => 'b set] => ('a * 'b) set"    ("_ Times _" [81, 80] 80)
    55 
    56 translations
    57   "(x, y, z)"    == "(x, (y, z))"
    58   "(x, y)"       == "Pair x y"
    59 
    60   "%(x,y,zs).b"  == "split(%x (y,zs).b)"
    61   "%(x,y).b"     == "split(%x y. b)"
    62   "_abs (Pair x y) t" => "%(x,y).t"
    63   (* The last rule accommodates tuples in `case C ... (x,y) ... => ...'
    64      The (x,y) is parsed as `Pair x y' because it is logic, not pttrn *)
    65 
    66   "SIGMA x:A. B" => "Sigma A (%x. B)"
    67   "A Times B"    => "Sigma A (_K B)"
    68 
    69 syntax (symbols)
    70   "@Sigma"      :: "[pttrn, 'a set, 'b set] => ('a * 'b) set"   ("(3\\<Sigma> _\\<in>_./ _)" 10)
    71   "@Times"      :: "['a set, 'a => 'b set] => ('a * 'b) set"    ("_ \\<times> _" [81, 80] 80)
    72 
    73 
    74 (* definitions *)
    75 
    76 local
    77 
    78 defs
    79   Pair_def      "Pair a b == Abs_Prod(Pair_Rep a b)"
    80   fst_def       "fst p == @a. ? b. p = (a, b)"
    81   snd_def       "snd p == @b. ? a. p = (a, b)"
    82   split_def     "split == (%c p. c (fst p) (snd p))"
    83   prod_fun_def  "prod_fun f g == split(%x y.(f(x), g(y)))"
    84   Sigma_def     "Sigma A B == UN x:A. UN y:B(x). {(x, y)}"
    85 
    86 
    87 
    88 (** unit **)
    89 
    90 global
    91 
    92 typedef  unit = "{True}"
    93 
    94 consts
    95   "()"          :: unit                           ("'(')")
    96 
    97 local
    98 
    99 defs
   100   Unity_def     "() == Abs_unit True"
   101 
   102 end
   103 
   104 ML
   105 
   106 val print_translation = [("Sigma", dependent_tr' ("@Sigma", "@Times"))];