src/HOL/Product_Type.thy
author oheimb
Thu Feb 01 20:51:48 2001 +0100 (2001-02-01)
changeset 11025 a70b796d9af8
parent 10289 475ea668c67d
child 11032 83f723e86dac
permissions -rw-r--r--
converted to Isar therory, adding attributes complete_split and split_format
nipkow@10213
     1
(*  Title:      HOL/Product_Type.thy
nipkow@10213
     2
    ID:         $Id$
nipkow@10213
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
nipkow@10213
     4
    Copyright   1992  University of Cambridge
nipkow@10213
     5
nipkow@10213
     6
Ordered Pairs and the Cartesian product type.
nipkow@10213
     7
The unit type.
nipkow@10213
     8
*)
nipkow@10213
     9
oheimb@11025
    10
theory Product_Type = Fun
oheimb@11025
    11
files 
oheimb@11025
    12
  ("Tools/split_rule.ML")
oheimb@11025
    13
  ("Product_Type_lemmas.ML")
oheimb@11025
    14
:
nipkow@10213
    15
nipkow@10213
    16
nipkow@10213
    17
(** products **)
nipkow@10213
    18
nipkow@10213
    19
(* type definition *)
nipkow@10213
    20
nipkow@10213
    21
constdefs
oheimb@11025
    22
  Pair_Rep :: "['a, 'b] => ['a, 'b] => bool"
oheimb@11025
    23
 "Pair_Rep == (%a b. %x y. x=a & y=b)"
nipkow@10213
    24
nipkow@10213
    25
global
nipkow@10213
    26
nipkow@10213
    27
typedef (Prod)
nipkow@10213
    28
  ('a, 'b) "*"          (infixr 20)
nipkow@10213
    29
    = "{f. ? a b. f = Pair_Rep (a::'a) (b::'b)}"
oheimb@11025
    30
proof
oheimb@11025
    31
  fix a b show "Pair_Rep a b : ?Prod"
oheimb@11025
    32
    by blast
oheimb@11025
    33
qed
nipkow@10213
    34
nipkow@10213
    35
syntax (symbols)
oheimb@11025
    36
  "*"      :: "[type, type] => type"         ("(_ \<times>/ _)" [21, 20] 20)
nipkow@10213
    37
syntax (HTML output)
oheimb@11025
    38
  "*"      :: "[type, type] => type"         ("(_ \<times>/ _)" [21, 20] 20)
nipkow@10213
    39
nipkow@10213
    40
nipkow@10213
    41
(* abstract constants and syntax *)
nipkow@10213
    42
nipkow@10213
    43
consts
oheimb@11025
    44
  fst      :: "'a * 'b => 'a"
oheimb@11025
    45
  snd      :: "'a * 'b => 'b"
oheimb@11025
    46
  split    :: "[['a, 'b] => 'c, 'a * 'b] => 'c"
oheimb@11025
    47
  prod_fun :: "['a => 'b, 'c => 'd, 'a * 'c] => 'b * 'd"
oheimb@11025
    48
  Pair     :: "['a, 'b] => 'a * 'b"
oheimb@11025
    49
  Sigma    :: "['a set, 'a => 'b set] => ('a * 'b) set"
nipkow@10213
    50
nipkow@10213
    51
nipkow@10213
    52
(* patterns -- extends pre-defined type "pttrn" used in abstractions *)
nipkow@10213
    53
nipkow@10213
    54
nonterminals
nipkow@10213
    55
  tuple_args patterns
nipkow@10213
    56
nipkow@10213
    57
syntax
nipkow@10213
    58
  "_tuple"      :: "'a => tuple_args => 'a * 'b"        ("(1'(_,/ _'))")
nipkow@10213
    59
  "_tuple_arg"  :: "'a => tuple_args"                   ("_")
nipkow@10213
    60
  "_tuple_args" :: "'a => tuple_args => tuple_args"     ("_,/ _")
oheimb@11025
    61
  "_pattern"    :: "[pttrn, patterns] => pttrn"         ("'(_,/ _')")
oheimb@11025
    62
  ""            :: "pttrn => patterns"                  ("_")
oheimb@11025
    63
  "_patterns"   :: "[pttrn, patterns] => patterns"      ("_,/ _")
oheimb@11025
    64
  "@Sigma" ::"[pttrn, 'a set, 'b set] => ('a * 'b) set" ("(3SIGMA _:_./ _)" 10)
oheimb@11025
    65
  "@Times" ::"['a set,  'a => 'b set] => ('a * 'b) set" (infixr "<*>" 80)
nipkow@10213
    66
nipkow@10213
    67
translations
nipkow@10213
    68
  "(x, y)"       == "Pair x y"
nipkow@10213
    69
  "_tuple x (_tuple_args y z)" == "_tuple x (_tuple_arg (_tuple y z))"
nipkow@10213
    70
  "%(x,y,zs).b"  == "split(%x (y,zs).b)"
nipkow@10213
    71
  "%(x,y).b"     == "split(%x y. b)"
nipkow@10213
    72
  "_abs (Pair x y) t" => "%(x,y).t"
nipkow@10213
    73
  (* The last rule accommodates tuples in `case C ... (x,y) ... => ...'
nipkow@10213
    74
     The (x,y) is parsed as `Pair x y' because it is logic, not pttrn *)
nipkow@10213
    75
nipkow@10213
    76
  "SIGMA x:A. B" => "Sigma A (%x. B)"
nipkow@10213
    77
  "A <*> B"      => "Sigma A (_K B)"
nipkow@10213
    78
nipkow@10213
    79
syntax (symbols)
oheimb@11025
    80
  "@Sigma" :: "[pttrn, 'a set, 'b set] => ('a * 'b) set"  ("(3\<Sigma> _\<in>_./ _)"   10)
oheimb@11025
    81
  "@Times" :: "['a set,  'a => 'b set] => ('a * 'b) set"  ("_ \<times> _" [81, 80] 80)
oheimb@11025
    82
oheimb@11025
    83
print_translation {* [("Sigma", dependent_tr' ("@Sigma", "@Times"))]; *}
nipkow@10213
    84
nipkow@10213
    85
nipkow@10213
    86
(* definitions *)
nipkow@10213
    87
nipkow@10213
    88
local
nipkow@10213
    89
nipkow@10213
    90
defs
oheimb@11025
    91
  Pair_def:     "Pair a b == Abs_Prod(Pair_Rep a b)"
oheimb@11025
    92
  fst_def:      "fst p == @a. ? b. p = (a, b)"
oheimb@11025
    93
  snd_def:      "snd p == @b. ? a. p = (a, b)"
oheimb@11025
    94
  split_def:    "split == (%c p. c (fst p) (snd p))"
oheimb@11025
    95
  prod_fun_def: "prod_fun f g == split(%x y.(f(x), g(y)))"
oheimb@11025
    96
  Sigma_def:    "Sigma A B == UN x:A. UN y:B(x). {(x, y)}"
nipkow@10213
    97
nipkow@10213
    98
nipkow@10213
    99
nipkow@10213
   100
(** unit **)
nipkow@10213
   101
nipkow@10213
   102
global
nipkow@10213
   103
oheimb@11025
   104
typedef  unit = "{True}" 
oheimb@11025
   105
proof
oheimb@11025
   106
  show "True : ?unit"
oheimb@11025
   107
    by blast
oheimb@11025
   108
qed
nipkow@10213
   109
nipkow@10213
   110
consts
nipkow@10213
   111
  "()"          :: unit                           ("'(')")
nipkow@10213
   112
nipkow@10213
   113
local
nipkow@10213
   114
nipkow@10213
   115
defs
oheimb@11025
   116
  Unity_def:    "() == Abs_unit True"
oheimb@11025
   117
oheimb@11025
   118
use "Product_Type_lemmas.ML"
oheimb@11025
   119
oheimb@11025
   120
use "Tools/split_rule.ML"
oheimb@11025
   121
setup split_attributes
nipkow@10213
   122
nipkow@10213
   123
end