src/HOL/Prod.thy
author wenzelm
Tue, 03 Oct 2000 01:14:52 +0200
changeset 10131 546686f0a6fb
parent 9360 82e8b18e6985
permissions -rw-r--r--
range declared as syntax;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     1
(*  Title:      HOL/Prod.thy
4570
c04027ccc86e fixed Id;
wenzelm
parents: 3947
diff changeset
     2
    ID:         $Id$
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     4
    Copyright   1992  University of Cambridge
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     5
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     6
Ordered Pairs and the Cartesian product type.
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     7
The unit type.
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     8
*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     9
1755
17001ecd546e Added additional parent theory equalities because some proofs in
berghofe
parents: 1674
diff changeset
    10
Prod = Fun + equalities +
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    11
2260
b59781f2b809 added symbols syntax;
wenzelm
parents: 1765
diff changeset
    12
b59781f2b809 added symbols syntax;
wenzelm
parents: 1765
diff changeset
    13
(** products **)
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    14
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    15
(* type definition *)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    16
1558
9c6ebfab4e05 added constdefs section
clasohm
parents: 1475
diff changeset
    17
constdefs
1370
7361ac9b024d removed quotes from types in consts and syntax sections
clasohm
parents: 1273
diff changeset
    18
  Pair_Rep      :: ['a, 'b] => ['a, 'b] => bool
1558
9c6ebfab4e05 added constdefs section
clasohm
parents: 1475
diff changeset
    19
  "Pair_Rep == (%a b. %x y. x=a & y=b)"
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    20
3947
eb707467f8c5 adapted to qualified names;
wenzelm
parents: 3842
diff changeset
    21
global
eb707467f8c5 adapted to qualified names;
wenzelm
parents: 3842
diff changeset
    22
1475
7f5a4cd08209 expanded tabs; renamed subtype to typedef;
clasohm
parents: 1454
diff changeset
    23
typedef (Prod)
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    24
  ('a, 'b) "*"          (infixr 20)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    25
    = "{f. ? a b. f = Pair_Rep (a::'a) (b::'b)}"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    26
2260
b59781f2b809 added symbols syntax;
wenzelm
parents: 1765
diff changeset
    27
syntax (symbols)
b59781f2b809 added symbols syntax;
wenzelm
parents: 1765
diff changeset
    28
  "*"           :: [type, type] => type         ("(_ \\<times>/ _)" [21, 20] 20)
b59781f2b809 added symbols syntax;
wenzelm
parents: 1765
diff changeset
    29
6340
7d5cbd5819a0 HTML output;
wenzelm
parents: 4875
diff changeset
    30
syntax (HTML output)
7d5cbd5819a0 HTML output;
wenzelm
parents: 4875
diff changeset
    31
  "*"           :: [type, type] => type         ("(_ \\<times>/ _)" [21, 20] 20)
7d5cbd5819a0 HTML output;
wenzelm
parents: 4875
diff changeset
    32
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    33
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    34
(* abstract constants and syntax *)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    35
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    36
consts
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    37
  fst           :: "'a * 'b => 'a"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    38
  snd           :: "'a * 'b => 'b"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    39
  split         :: "[['a, 'b] => 'c, 'a * 'b] => 'c"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    40
  prod_fun      :: "['a => 'b, 'c => 'd, 'a * 'c] => 'b * 'd"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    41
  Pair          :: "['a, 'b] => 'a * 'b"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    42
  Sigma         :: "['a set, 'a => 'b set] => ('a * 'b) set"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    43
2260
b59781f2b809 added symbols syntax;
wenzelm
parents: 1765
diff changeset
    44
b59781f2b809 added symbols syntax;
wenzelm
parents: 1765
diff changeset
    45
(* patterns -- extends pre-defined type "pttrn" used in abstractions *)
b59781f2b809 added symbols syntax;
wenzelm
parents: 1765
diff changeset
    46
4875
cb48549230ce nontermials;
wenzelm
parents: 4570
diff changeset
    47
nonterminals
9360
82e8b18e6985 more robust tuple syntax (still improper, though!);
wenzelm
parents: 9341
diff changeset
    48
  tuple_args patterns
1068
e0f2dffab506 HOL.thy:
nipkow
parents: 972
diff changeset
    49
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    50
syntax
9360
82e8b18e6985 more robust tuple syntax (still improper, though!);
wenzelm
parents: 9341
diff changeset
    51
  "_tuple"      :: "'a => tuple_args => 'a * 'b"        ("(1'(_,/ _'))")
82e8b18e6985 more robust tuple syntax (still improper, though!);
wenzelm
parents: 9341
diff changeset
    52
  "_tuple_arg"  :: "'a => tuple_args"                   ("_")
82e8b18e6985 more robust tuple syntax (still improper, though!);
wenzelm
parents: 9341
diff changeset
    53
  "_tuple_args" :: "'a => tuple_args => tuple_args"     ("_,/ _")
82e8b18e6985 more robust tuple syntax (still improper, though!);
wenzelm
parents: 9341
diff changeset
    54
  "_pattern"    :: [pttrn, patterns] => pttrn           ("'(_,/ _')")
82e8b18e6985 more robust tuple syntax (still improper, though!);
wenzelm
parents: 9341
diff changeset
    55
  ""            :: pttrn => patterns                    ("_")
82e8b18e6985 more robust tuple syntax (still improper, though!);
wenzelm
parents: 9341
diff changeset
    56
  "_patterns"   :: [pttrn, patterns] => patterns        ("_,/ _")
3692
9f9bcce140ce tuned pattern syntax;
wenzelm
parents: 2973
diff changeset
    57
  "@Sigma"      :: "[pttrn, 'a set, 'b set] => ('a * 'b) set"   ("(3SIGMA _:_./ _)" 10)
8703
816d8f6513be Times -> <*>
nipkow
parents: 6340
diff changeset
    58
  "@Times"      :: "['a set, 'a => 'b set] => ('a * 'b) set"    (infixr "<*>" 80)
1636
e18416e3e1d4 Introduced Times and SIGMA.
nipkow
parents: 1558
diff changeset
    59
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    60
translations
3842
b55686a7b22c fixed dots;
wenzelm
parents: 3692
diff changeset
    61
  "(x, y)"       == "Pair x y"
9360
82e8b18e6985 more robust tuple syntax (still improper, though!);
wenzelm
parents: 9341
diff changeset
    62
  "_tuple x (_tuple_args y z)" == "_tuple x (_tuple_arg (_tuple y z))"
3842
b55686a7b22c fixed dots;
wenzelm
parents: 3692
diff changeset
    63
  "%(x,y,zs).b"  == "split(%x (y,zs).b)"
b55686a7b22c fixed dots;
wenzelm
parents: 3692
diff changeset
    64
  "%(x,y).b"     == "split(%x y. b)"
2973
184c7cd8043d Added ability to have case expressions involving tuples. (via translation)
nipkow
parents: 2886
diff changeset
    65
  "_abs (Pair x y) t" => "%(x,y).t"
184c7cd8043d Added ability to have case expressions involving tuples. (via translation)
nipkow
parents: 2886
diff changeset
    66
  (* The last rule accommodates tuples in `case C ... (x,y) ... => ...'
184c7cd8043d Added ability to have case expressions involving tuples. (via translation)
nipkow
parents: 2886
diff changeset
    67
     The (x,y) is parsed as `Pair x y' because it is logic, not pttrn *)
2260
b59781f2b809 added symbols syntax;
wenzelm
parents: 1765
diff changeset
    68
3842
b55686a7b22c fixed dots;
wenzelm
parents: 3692
diff changeset
    69
  "SIGMA x:A. B" => "Sigma A (%x. B)"
8703
816d8f6513be Times -> <*>
nipkow
parents: 6340
diff changeset
    70
  "A <*> B"      => "Sigma A (_K B)"
1068
e0f2dffab506 HOL.thy:
nipkow
parents: 972
diff changeset
    71
2260
b59781f2b809 added symbols syntax;
wenzelm
parents: 1765
diff changeset
    72
syntax (symbols)
3692
9f9bcce140ce tuned pattern syntax;
wenzelm
parents: 2973
diff changeset
    73
  "@Sigma"      :: "[pttrn, 'a set, 'b set] => ('a * 'b) set"   ("(3\\<Sigma> _\\<in>_./ _)" 10)
2260
b59781f2b809 added symbols syntax;
wenzelm
parents: 1765
diff changeset
    74
  "@Times"      :: "['a set, 'a => 'b set] => ('a * 'b) set"    ("_ \\<times> _" [81, 80] 80)
b59781f2b809 added symbols syntax;
wenzelm
parents: 1765
diff changeset
    75
b59781f2b809 added symbols syntax;
wenzelm
parents: 1765
diff changeset
    76
b59781f2b809 added symbols syntax;
wenzelm
parents: 1765
diff changeset
    77
(* definitions *)
1636
e18416e3e1d4 Introduced Times and SIGMA.
nipkow
parents: 1558
diff changeset
    78
3947
eb707467f8c5 adapted to qualified names;
wenzelm
parents: 3842
diff changeset
    79
local
eb707467f8c5 adapted to qualified names;
wenzelm
parents: 3842
diff changeset
    80
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    81
defs
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    82
  Pair_def      "Pair a b == Abs_Prod(Pair_Rep a b)"
2393
651fce76c86c adaptions for symbol font
oheimb
parents: 2260
diff changeset
    83
  fst_def       "fst p == @a. ? b. p = (a, b)"
651fce76c86c adaptions for symbol font
oheimb
parents: 2260
diff changeset
    84
  snd_def       "snd p == @b. ? a. p = (a, b)"
1655
5be64540f275 Added a number of lemmas
nipkow
parents: 1636
diff changeset
    85
  split_def     "split == (%c p. c (fst p) (snd p))"
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 967
diff changeset
    86
  prod_fun_def  "prod_fun f g == split(%x y.(f(x), g(y)))"
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 967
diff changeset
    87
  Sigma_def     "Sigma A B == UN x:A. UN y:B(x). {(x, y)}"
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    88
2260
b59781f2b809 added symbols syntax;
wenzelm
parents: 1765
diff changeset
    89
b59781f2b809 added symbols syntax;
wenzelm
parents: 1765
diff changeset
    90
b59781f2b809 added symbols syntax;
wenzelm
parents: 1765
diff changeset
    91
(** unit **)
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    92
3947
eb707467f8c5 adapted to qualified names;
wenzelm
parents: 3842
diff changeset
    93
global
eb707467f8c5 adapted to qualified names;
wenzelm
parents: 3842
diff changeset
    94
2886
fd5645efa43d Now: unit = {True}
nipkow
parents: 2880
diff changeset
    95
typedef  unit = "{True}"
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    96
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    97
consts
1370
7361ac9b024d removed quotes from types in consts and syntax sections
clasohm
parents: 1273
diff changeset
    98
  "()"          :: unit                           ("'(')")
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    99
3947
eb707467f8c5 adapted to qualified names;
wenzelm
parents: 3842
diff changeset
   100
local
eb707467f8c5 adapted to qualified names;
wenzelm
parents: 3842
diff changeset
   101
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   102
defs
2880
a0fde30aa126 Removed (Unit) in Prod.
nipkow
parents: 2393
diff changeset
   103
  Unity_def     "() == Abs_unit True"
1273
6960ec882bca added 8bit pragmas
regensbu
parents: 1114
diff changeset
   104
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   105
end
1636
e18416e3e1d4 Introduced Times and SIGMA.
nipkow
parents: 1558
diff changeset
   106
e18416e3e1d4 Introduced Times and SIGMA.
nipkow
parents: 1558
diff changeset
   107
ML
e18416e3e1d4 Introduced Times and SIGMA.
nipkow
parents: 1558
diff changeset
   108
e18416e3e1d4 Introduced Times and SIGMA.
nipkow
parents: 1558
diff changeset
   109
val print_translation = [("Sigma", dependent_tr' ("@Sigma", "@Times"))];