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