src/HOL/Prod.thy
author wenzelm
Thu Mar 11 13:20:35 1999 +0100 (1999-03-11)
changeset 6349 f7750d816c21
parent 6340 7d5cbd5819a0
child 8703 816d8f6513be
permissions -rw-r--r--
removed foo_build_completed -- now handled by session management (via usedir);
clasohm@923
     1
(*  Title:      HOL/Prod.thy
wenzelm@4570
     2
    ID:         $Id$
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
wenzelm@6340
    30
syntax (HTML output)
wenzelm@6340
    31
  "*"           :: [type, type] => type         ("(_ \\<times>/ _)" [21, 20] 20)
wenzelm@6340
    32
clasohm@923
    33
clasohm@923
    34
(* abstract constants and syntax *)
clasohm@923
    35
clasohm@923
    36
consts
clasohm@923
    37
  fst           :: "'a * 'b => 'a"
clasohm@923
    38
  snd           :: "'a * 'b => 'b"
clasohm@923
    39
  split         :: "[['a, 'b] => 'c, 'a * 'b] => 'c"
clasohm@923
    40
  prod_fun      :: "['a => 'b, 'c => 'd, 'a * 'c] => 'b * 'd"
clasohm@923
    41
  Pair          :: "['a, 'b] => 'a * 'b"
clasohm@923
    42
  Sigma         :: "['a set, 'a => 'b set] => ('a * 'b) set"
clasohm@923
    43
wenzelm@2260
    44
wenzelm@2260
    45
(* patterns -- extends pre-defined type "pttrn" used in abstractions *)
wenzelm@2260
    46
wenzelm@4875
    47
nonterminals
wenzelm@4875
    48
  patterns
nipkow@1068
    49
clasohm@923
    50
syntax
wenzelm@3692
    51
  "@Tuple"      :: "['a, args] => 'a * 'b"       ("(1'(_,/ _'))")
clasohm@923
    52
wenzelm@3692
    53
  "_pattern"    :: [pttrn, patterns] => pttrn    ("'(_,/_')")
wenzelm@3692
    54
  ""            :: pttrn => patterns             ("_")
wenzelm@3692
    55
  "_patterns"   :: [pttrn, patterns] => patterns ("_,/_")
nipkow@2973
    56
wenzelm@3692
    57
  "@Sigma"      :: "[pttrn, 'a set, 'b set] => ('a * 'b) set"   ("(3SIGMA _:_./ _)" 10)
wenzelm@2260
    58
  "@Times"      :: "['a set, 'a => 'b set] => ('a * 'b) set"    ("_ Times _" [81, 80] 80)
nipkow@1636
    59
clasohm@923
    60
translations
wenzelm@3842
    61
  "(x, y, z)"    == "(x, (y, z))"
wenzelm@3842
    62
  "(x, y)"       == "Pair x y"
clasohm@923
    63
wenzelm@3842
    64
  "%(x,y,zs).b"  == "split(%x (y,zs).b)"
wenzelm@3842
    65
  "%(x,y).b"     == "split(%x y. b)"
nipkow@2973
    66
  "_abs (Pair x y) t" => "%(x,y).t"
nipkow@2973
    67
  (* The last rule accommodates tuples in `case C ... (x,y) ... => ...'
nipkow@2973
    68
     The (x,y) is parsed as `Pair x y' because it is logic, not pttrn *)
wenzelm@2260
    69
wenzelm@3842
    70
  "SIGMA x:A. B" => "Sigma A (%x. B)"
wenzelm@3842
    71
  "A Times B"    => "Sigma A (_K B)"
nipkow@1068
    72
wenzelm@2260
    73
syntax (symbols)
wenzelm@3692
    74
  "@Sigma"      :: "[pttrn, 'a set, 'b set] => ('a * 'b) set"   ("(3\\<Sigma> _\\<in>_./ _)" 10)
wenzelm@2260
    75
  "@Times"      :: "['a set, 'a => 'b set] => ('a * 'b) set"    ("_ \\<times> _" [81, 80] 80)
wenzelm@2260
    76
wenzelm@2260
    77
wenzelm@2260
    78
(* definitions *)
nipkow@1636
    79
wenzelm@3947
    80
local
wenzelm@3947
    81
clasohm@923
    82
defs
clasohm@923
    83
  Pair_def      "Pair a b == Abs_Prod(Pair_Rep a b)"
oheimb@2393
    84
  fst_def       "fst p == @a. ? b. p = (a, b)"
oheimb@2393
    85
  snd_def       "snd p == @b. ? a. p = (a, b)"
nipkow@1655
    86
  split_def     "split == (%c p. c (fst p) (snd p))"
clasohm@972
    87
  prod_fun_def  "prod_fun f g == split(%x y.(f(x), g(y)))"
clasohm@972
    88
  Sigma_def     "Sigma A B == UN x:A. UN y:B(x). {(x, y)}"
clasohm@923
    89
wenzelm@2260
    90
wenzelm@2260
    91
wenzelm@2260
    92
(** unit **)
clasohm@923
    93
wenzelm@3947
    94
global
wenzelm@3947
    95
nipkow@2886
    96
typedef  unit = "{True}"
clasohm@923
    97
clasohm@923
    98
consts
clasohm@1370
    99
  "()"          :: unit                           ("'(')")
clasohm@923
   100
wenzelm@3947
   101
local
wenzelm@3947
   102
clasohm@923
   103
defs
nipkow@2880
   104
  Unity_def     "() == Abs_unit True"
regensbu@1273
   105
clasohm@923
   106
end
nipkow@1636
   107
nipkow@1636
   108
ML
nipkow@1636
   109
nipkow@1636
   110
val print_translation = [("Sigma", dependent_tr' ("@Sigma", "@Times"))];