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;
clasohm@923
     1
(*  Title:      HOL/Prod.thy
clasohm@923
     2
    ID:         Prod.thy,v 1.5 1994/08/19 09:04:27 lcp Exp
clasohm@923
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
clasohm@923
     4
    Copyright   1992  University of Cambridge
clasohm@923
     5
clasohm@923
     6
Ordered Pairs and the Cartesian product type.
clasohm@923
     7
The unit type.
clasohm@923
     8
*)
clasohm@923
     9
berghofe@1755
    10
Prod = Fun + equalities +
clasohm@923
    11
wenzelm@2260
    12
wenzelm@2260
    13
(** products **)
clasohm@923
    14
clasohm@923
    15
(* type definition *)
clasohm@923
    16
clasohm@1558
    17
constdefs
clasohm@1370
    18
  Pair_Rep      :: ['a, 'b] => ['a, 'b] => bool
clasohm@1558
    19
  "Pair_Rep == (%a b. %x y. x=a & y=b)"
clasohm@923
    20
wenzelm@3947
    21
global
wenzelm@3947
    22
clasohm@1475
    23
typedef (Prod)
clasohm@923
    24
  ('a, 'b) "*"          (infixr 20)
clasohm@923
    25
    = "{f. ? a b. f = Pair_Rep (a::'a) (b::'b)}"
clasohm@923
    26
wenzelm@2260
    27
syntax (symbols)
wenzelm@2260
    28
  "*"           :: [type, type] => type         ("(_ \\<times>/ _)" [21, 20] 20)
wenzelm@2260
    29
clasohm@923
    30
clasohm@923
    31
(* abstract constants and syntax *)
clasohm@923
    32
clasohm@923
    33
consts
clasohm@923
    34
  fst           :: "'a * 'b => 'a"
clasohm@923
    35
  snd           :: "'a * 'b => 'b"
clasohm@923
    36
  split         :: "[['a, 'b] => 'c, 'a * 'b] => 'c"
clasohm@923
    37
  prod_fun      :: "['a => 'b, 'c => 'd, 'a * 'c] => 'b * 'd"
clasohm@923
    38
  Pair          :: "['a, 'b] => 'a * 'b"
clasohm@923
    39
  Sigma         :: "['a set, 'a => 'b set] => ('a * 'b) set"
clasohm@923
    40
wenzelm@2260
    41
wenzelm@2260
    42
(* patterns -- extends pre-defined type "pttrn" used in abstractions *)
wenzelm@2260
    43
wenzelm@3692
    44
types patterns
nipkow@1068
    45
clasohm@923
    46
syntax
wenzelm@3692
    47
  "@Tuple"      :: "['a, args] => 'a * 'b"       ("(1'(_,/ _'))")
clasohm@923
    48
wenzelm@3692
    49
  "_pattern"    :: [pttrn, patterns] => pttrn    ("'(_,/_')")
wenzelm@3692
    50
  ""            :: pttrn => patterns             ("_")
wenzelm@3692
    51
  "_patterns"   :: [pttrn, patterns] => patterns ("_,/_")
nipkow@2973
    52
wenzelm@3692
    53
  "@Sigma"      :: "[pttrn, 'a set, 'b set] => ('a * 'b) set"   ("(3SIGMA _:_./ _)" 10)
wenzelm@2260
    54
  "@Times"      :: "['a set, 'a => 'b set] => ('a * 'b) set"    ("_ Times _" [81, 80] 80)
nipkow@1636
    55
clasohm@923
    56
translations
wenzelm@3842
    57
  "(x, y, z)"    == "(x, (y, z))"
wenzelm@3842
    58
  "(x, y)"       == "Pair x y"
clasohm@923
    59
wenzelm@3842
    60
  "%(x,y,zs).b"  == "split(%x (y,zs).b)"
wenzelm@3842
    61
  "%(x,y).b"     == "split(%x y. b)"
nipkow@2973
    62
  "_abs (Pair x y) t" => "%(x,y).t"
nipkow@2973
    63
  (* The last rule accommodates tuples in `case C ... (x,y) ... => ...'
nipkow@2973
    64
     The (x,y) is parsed as `Pair x y' because it is logic, not pttrn *)
wenzelm@2260
    65
wenzelm@3842
    66
  "SIGMA x:A. B" => "Sigma A (%x. B)"
wenzelm@3842
    67
  "A Times B"    => "Sigma A (_K B)"
nipkow@1068
    68
wenzelm@2260
    69
syntax (symbols)
wenzelm@3692
    70
  "@Sigma"      :: "[pttrn, 'a set, 'b set] => ('a * 'b) set"   ("(3\\<Sigma> _\\<in>_./ _)" 10)
wenzelm@2260
    71
  "@Times"      :: "['a set, 'a => 'b set] => ('a * 'b) set"    ("_ \\<times> _" [81, 80] 80)
wenzelm@2260
    72
wenzelm@2260
    73
wenzelm@2260
    74
(* definitions *)
nipkow@1636
    75
wenzelm@3947
    76
local
wenzelm@3947
    77
clasohm@923
    78
defs
clasohm@923
    79
  Pair_def      "Pair a b == Abs_Prod(Pair_Rep a b)"
oheimb@2393
    80
  fst_def       "fst p == @a. ? b. p = (a, b)"
oheimb@2393
    81
  snd_def       "snd p == @b. ? a. p = (a, b)"
nipkow@1655
    82
  split_def     "split == (%c p. c (fst p) (snd p))"
clasohm@972
    83
  prod_fun_def  "prod_fun f g == split(%x y.(f(x), g(y)))"
clasohm@972
    84
  Sigma_def     "Sigma A B == UN x:A. UN y:B(x). {(x, y)}"
clasohm@923
    85
wenzelm@2260
    86
wenzelm@2260
    87
wenzelm@2260
    88
(** unit **)
clasohm@923
    89
wenzelm@3947
    90
global
wenzelm@3947
    91
nipkow@2886
    92
typedef  unit = "{True}"
clasohm@923
    93
clasohm@923
    94
consts
clasohm@1370
    95
  "()"          :: unit                           ("'(')")
clasohm@923
    96
wenzelm@3947
    97
local
wenzelm@3947
    98
clasohm@923
    99
defs
nipkow@2880
   100
  Unity_def     "() == Abs_unit True"
regensbu@1273
   101
clasohm@923
   102
end
nipkow@1636
   103
nipkow@1636
   104
ML
nipkow@1636
   105
nipkow@1636
   106
val print_translation = [("Sigma", dependent_tr' ("@Sigma", "@Times"))];