src/HOL/Prod.thy
author nipkow
Thu Apr 03 09:46:42 1997 +0200 (1997-04-03)
changeset 2880 a0fde30aa126
parent 2393 651fce76c86c
child 2886 fd5645efa43d
permissions -rw-r--r--
Removed (Unit) in Prod.
Added test for ancestor Nat in datatype.
     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 pttrns
    43 
    44 syntax
    45   "@Tuple"      :: "['a, args] => 'a * 'b"      ("(1'(_,/ _'))")
    46 
    47   "@pttrn"      :: [pttrn, pttrns] => pttrn     ("'(_,/_')")
    48   ""            :: pttrn => pttrns              ("_")
    49   "@pttrns"     :: [pttrn, pttrns] => pttrns    ("_,/_")
    50   "@Sigma"      :: "[idt, 'a set, 'b set] => ('a * 'b) set"     ("(3SIGMA _:_./ _)" 10)
    51   "@Times"      :: "['a set, 'a => 'b set] => ('a * 'b) set"    ("_ Times _" [81, 80] 80)
    52 
    53 translations
    54   "(x, y, z)"   == "(x, (y, z))"
    55   "(x, y)"      == "Pair x y"
    56 
    57   "%(x,y,zs).b" == "split(%x (y,zs).b)"
    58   "%(x,y).b"    == "split(%x y.b)"
    59 
    60   "SIGMA x:A.B" => "Sigma A (%x.B)"
    61   "A Times B"   => "Sigma A (_K B)"
    62 
    63 syntax (symbols)
    64   "@Sigma"      :: "[idt, 'a set, 'b set] => ('a * 'b) set"     ("(3\\<Sigma> _\\<in>_./ _)" 10)
    65   "@Times"      :: "['a set, 'a => 'b set] => ('a * 'b) set"    ("_ \\<times> _" [81, 80] 80)
    66 
    67 
    68 (* definitions *)
    69 
    70 defs
    71   Pair_def      "Pair a b == Abs_Prod(Pair_Rep a b)"
    72   fst_def       "fst p == @a. ? b. p = (a, b)"
    73   snd_def       "snd p == @b. ? a. p = (a, b)"
    74   split_def     "split == (%c p. c (fst p) (snd p))"
    75   prod_fun_def  "prod_fun f g == split(%x y.(f(x), g(y)))"
    76   Sigma_def     "Sigma A B == UN x:A. UN y:B(x). {(x, y)}"
    77 
    78 
    79 
    80 (** unit **)
    81 
    82 typedef  unit = "{p. p = True}"
    83 
    84 consts
    85   "()"          :: unit                           ("'(')")
    86 
    87 defs
    88   Unity_def     "() == Abs_unit True"
    89 
    90 end
    91 
    92 ML
    93 
    94 val print_translation = [("Sigma", dependent_tr' ("@Sigma", "@Times"))];