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