src/HOL/Product_Type.thy
author nipkow
Fri, 24 Nov 2000 16:49:27 +0100
changeset 10519 ade64af4c57c
parent 10289 475ea668c67d
child 11025 a70b796d9af8
permissions -rw-r--r--
hide many names from Datatype_Universe.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10213
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
     1
(*  Title:      HOL/Product_Type.thy
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
     2
    ID:         $Id$
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
     4
    Copyright   1992  University of Cambridge
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
     5
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
     6
Ordered Pairs and the Cartesian product type.
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
     7
The unit type.
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
     8
*)
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
     9
10289
475ea668c67d tuned deps;
wenzelm
parents: 10213
diff changeset
    10
Product_Type = Fun +
10213
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    11
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    12
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    13
(** products **)
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    14
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    15
(* type definition *)
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    16
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    17
constdefs
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    18
  Pair_Rep      :: ['a, 'b] => ['a, 'b] => bool
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    19
  "Pair_Rep == (%a b. %x y. x=a & y=b)"
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    20
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    21
global
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    22
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    23
typedef (Prod)
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    24
  ('a, 'b) "*"          (infixr 20)
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    25
    = "{f. ? a b. f = Pair_Rep (a::'a) (b::'b)}"
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    26
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    27
syntax (symbols)
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    28
  "*"           :: [type, type] => type         ("(_ \\<times>/ _)" [21, 20] 20)
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    29
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    30
syntax (HTML output)
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    31
  "*"           :: [type, type] => type         ("(_ \\<times>/ _)" [21, 20] 20)
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    32
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    33
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    34
(* abstract constants and syntax *)
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    35
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    36
consts
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    37
  fst           :: "'a * 'b => 'a"
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    38
  snd           :: "'a * 'b => 'b"
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    39
  split         :: "[['a, 'b] => 'c, 'a * 'b] => 'c"
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    40
  prod_fun      :: "['a => 'b, 'c => 'd, 'a * 'c] => 'b * 'd"
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    41
  Pair          :: "['a, 'b] => 'a * 'b"
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    42
  Sigma         :: "['a set, 'a => 'b set] => ('a * 'b) set"
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    43
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    44
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    45
(* patterns -- extends pre-defined type "pttrn" used in abstractions *)
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    46
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    47
nonterminals
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    48
  tuple_args patterns
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    49
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    50
syntax
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    51
  "_tuple"      :: "'a => tuple_args => 'a * 'b"        ("(1'(_,/ _'))")
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    52
  "_tuple_arg"  :: "'a => tuple_args"                   ("_")
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    53
  "_tuple_args" :: "'a => tuple_args => tuple_args"     ("_,/ _")
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    54
  "_pattern"    :: [pttrn, patterns] => pttrn           ("'(_,/ _')")
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    55
  ""            :: pttrn => patterns                    ("_")
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    56
  "_patterns"   :: [pttrn, patterns] => patterns        ("_,/ _")
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    57
  "@Sigma"      :: "[pttrn, 'a set, 'b set] => ('a * 'b) set"   ("(3SIGMA _:_./ _)" 10)
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    58
  "@Times"      :: "['a set, 'a => 'b set] => ('a * 'b) set"    (infixr "<*>" 80)
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    59
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    60
translations
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    61
  "(x, y)"       == "Pair x y"
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    62
  "_tuple x (_tuple_args y z)" == "_tuple x (_tuple_arg (_tuple y z))"
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    63
  "%(x,y,zs).b"  == "split(%x (y,zs).b)"
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    64
  "%(x,y).b"     == "split(%x y. b)"
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    65
  "_abs (Pair x y) t" => "%(x,y).t"
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    66
  (* The last rule accommodates tuples in `case C ... (x,y) ... => ...'
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    67
     The (x,y) is parsed as `Pair x y' because it is logic, not pttrn *)
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    68
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    69
  "SIGMA x:A. B" => "Sigma A (%x. B)"
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    70
  "A <*> B"      => "Sigma A (_K B)"
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    71
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    72
syntax (symbols)
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    73
  "@Sigma"      :: "[pttrn, 'a set, 'b set] => ('a * 'b) set"   ("(3\\<Sigma> _\\<in>_./ _)" 10)
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    74
  "@Times"      :: "['a set, 'a => 'b set] => ('a * 'b) set"    ("_ \\<times> _" [81, 80] 80)
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    75
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    76
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    77
(* definitions *)
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    78
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    79
local
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    80
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    81
defs
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    82
  Pair_def      "Pair a b == Abs_Prod(Pair_Rep a b)"
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    83
  fst_def       "fst p == @a. ? b. p = (a, b)"
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    84
  snd_def       "snd p == @b. ? a. p = (a, b)"
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    85
  split_def     "split == (%c p. c (fst p) (snd p))"
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    86
  prod_fun_def  "prod_fun f g == split(%x y.(f(x), g(y)))"
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    87
  Sigma_def     "Sigma A B == UN x:A. UN y:B(x). {(x, y)}"
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    88
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    89
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    90
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    91
(** unit **)
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    92
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    93
global
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    94
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    95
typedef  unit = "{True}"
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    96
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    97
consts
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    98
  "()"          :: unit                           ("'(')")
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    99
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   100
local
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   101
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   102
defs
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   103
  Unity_def     "() == Abs_unit True"
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   104
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   105
end
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   106
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   107
ML
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   108
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   109
val print_translation = [("Sigma", dependent_tr' ("@Sigma", "@Times"))];