src/HOL/Product_Type.thy
author wenzelm
Fri, 02 Feb 2001 22:18:10 +0100
changeset 11032 83f723e86dac
parent 11025 a70b796d9af8
child 11425 4988fd27d6e6
permissions -rw-r--r--
added hidden internal_split constant; tuned;
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
11025
a70b796d9af8 converted to Isar therory, adding attributes complete_split and split_format
oheimb
parents: 10289
diff changeset
    10
theory Product_Type = Fun
11032
83f723e86dac added hidden internal_split constant;
wenzelm
parents: 11025
diff changeset
    11
files ("Product_Type_lemmas.ML") ("Tools/split_rule.ML"):
10213
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    12
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    13
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    14
(** products **)
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    15
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    16
(* type definition *)
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    17
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    18
constdefs
11025
a70b796d9af8 converted to Isar therory, adding attributes complete_split and split_format
oheimb
parents: 10289
diff changeset
    19
  Pair_Rep :: "['a, 'b] => ['a, 'b] => bool"
11032
83f723e86dac added hidden internal_split constant;
wenzelm
parents: 11025
diff changeset
    20
  "Pair_Rep == (%a b. %x y. x=a & y=b)"
10213
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    21
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    22
global
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    23
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    24
typedef (Prod)
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    25
  ('a, 'b) "*"          (infixr 20)
11032
83f723e86dac added hidden internal_split constant;
wenzelm
parents: 11025
diff changeset
    26
    = "{f. EX a b. f = Pair_Rep (a::'a) (b::'b)}"
11025
a70b796d9af8 converted to Isar therory, adding attributes complete_split and split_format
oheimb
parents: 10289
diff changeset
    27
proof
a70b796d9af8 converted to Isar therory, adding attributes complete_split and split_format
oheimb
parents: 10289
diff changeset
    28
  fix a b show "Pair_Rep a b : ?Prod"
a70b796d9af8 converted to Isar therory, adding attributes complete_split and split_format
oheimb
parents: 10289
diff changeset
    29
    by blast
a70b796d9af8 converted to Isar therory, adding attributes complete_split and split_format
oheimb
parents: 10289
diff changeset
    30
qed
10213
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    31
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    32
syntax (symbols)
11025
a70b796d9af8 converted to Isar therory, adding attributes complete_split and split_format
oheimb
parents: 10289
diff changeset
    33
  "*"      :: "[type, type] => type"         ("(_ \<times>/ _)" [21, 20] 20)
10213
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    34
syntax (HTML output)
11025
a70b796d9af8 converted to Isar therory, adding attributes complete_split and split_format
oheimb
parents: 10289
diff changeset
    35
  "*"      :: "[type, type] => type"         ("(_ \<times>/ _)" [21, 20] 20)
10213
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    36
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    37
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    38
(* abstract constants and syntax *)
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    39
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    40
consts
11025
a70b796d9af8 converted to Isar therory, adding attributes complete_split and split_format
oheimb
parents: 10289
diff changeset
    41
  fst      :: "'a * 'b => 'a"
a70b796d9af8 converted to Isar therory, adding attributes complete_split and split_format
oheimb
parents: 10289
diff changeset
    42
  snd      :: "'a * 'b => 'b"
a70b796d9af8 converted to Isar therory, adding attributes complete_split and split_format
oheimb
parents: 10289
diff changeset
    43
  split    :: "[['a, 'b] => 'c, 'a * 'b] => 'c"
a70b796d9af8 converted to Isar therory, adding attributes complete_split and split_format
oheimb
parents: 10289
diff changeset
    44
  prod_fun :: "['a => 'b, 'c => 'd, 'a * 'c] => 'b * 'd"
a70b796d9af8 converted to Isar therory, adding attributes complete_split and split_format
oheimb
parents: 10289
diff changeset
    45
  Pair     :: "['a, 'b] => 'a * 'b"
a70b796d9af8 converted to Isar therory, adding attributes complete_split and split_format
oheimb
parents: 10289
diff changeset
    46
  Sigma    :: "['a set, 'a => 'b set] => ('a * 'b) set"
10213
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    47
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    48
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    49
(* patterns -- extends pre-defined type "pttrn" used in abstractions *)
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    50
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    51
nonterminals
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    52
  tuple_args patterns
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    53
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    54
syntax
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    55
  "_tuple"      :: "'a => tuple_args => 'a * 'b"        ("(1'(_,/ _'))")
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    56
  "_tuple_arg"  :: "'a => tuple_args"                   ("_")
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    57
  "_tuple_args" :: "'a => tuple_args => tuple_args"     ("_,/ _")
11025
a70b796d9af8 converted to Isar therory, adding attributes complete_split and split_format
oheimb
parents: 10289
diff changeset
    58
  "_pattern"    :: "[pttrn, patterns] => pttrn"         ("'(_,/ _')")
a70b796d9af8 converted to Isar therory, adding attributes complete_split and split_format
oheimb
parents: 10289
diff changeset
    59
  ""            :: "pttrn => patterns"                  ("_")
a70b796d9af8 converted to Isar therory, adding attributes complete_split and split_format
oheimb
parents: 10289
diff changeset
    60
  "_patterns"   :: "[pttrn, patterns] => patterns"      ("_,/ _")
a70b796d9af8 converted to Isar therory, adding attributes complete_split and split_format
oheimb
parents: 10289
diff changeset
    61
  "@Sigma" ::"[pttrn, 'a set, 'b set] => ('a * 'b) set" ("(3SIGMA _:_./ _)" 10)
a70b796d9af8 converted to Isar therory, adding attributes complete_split and split_format
oheimb
parents: 10289
diff changeset
    62
  "@Times" ::"['a set,  'a => 'b set] => ('a * 'b) set" (infixr "<*>" 80)
10213
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    63
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    64
translations
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    65
  "(x, y)"       == "Pair x y"
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    66
  "_tuple x (_tuple_args y z)" == "_tuple x (_tuple_arg (_tuple y z))"
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    67
  "%(x,y,zs).b"  == "split(%x (y,zs).b)"
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    68
  "%(x,y).b"     == "split(%x y. b)"
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    69
  "_abs (Pair x y) t" => "%(x,y).t"
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    70
  (* The last rule accommodates tuples in `case C ... (x,y) ... => ...'
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    71
     The (x,y) is parsed as `Pair x y' because it is logic, not pttrn *)
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    72
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    73
  "SIGMA x:A. B" => "Sigma A (%x. B)"
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    74
  "A <*> B"      => "Sigma A (_K B)"
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    75
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    76
syntax (symbols)
11025
a70b796d9af8 converted to Isar therory, adding attributes complete_split and split_format
oheimb
parents: 10289
diff changeset
    77
  "@Sigma" :: "[pttrn, 'a set, 'b set] => ('a * 'b) set"  ("(3\<Sigma> _\<in>_./ _)"   10)
a70b796d9af8 converted to Isar therory, adding attributes complete_split and split_format
oheimb
parents: 10289
diff changeset
    78
  "@Times" :: "['a set,  'a => 'b set] => ('a * 'b) set"  ("_ \<times> _" [81, 80] 80)
a70b796d9af8 converted to Isar therory, adding attributes complete_split and split_format
oheimb
parents: 10289
diff changeset
    79
11032
83f723e86dac added hidden internal_split constant;
wenzelm
parents: 11025
diff changeset
    80
print_translation {* [("Sigma", dependent_tr' ("@Sigma", "@Times"))] *}
10213
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    81
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    82
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    83
(* definitions *)
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    84
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    85
local
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    86
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    87
defs
11025
a70b796d9af8 converted to Isar therory, adding attributes complete_split and split_format
oheimb
parents: 10289
diff changeset
    88
  Pair_def:     "Pair a b == Abs_Prod(Pair_Rep a b)"
11032
83f723e86dac added hidden internal_split constant;
wenzelm
parents: 11025
diff changeset
    89
  fst_def:      "fst p == SOME a. EX b. p = (a, b)"
83f723e86dac added hidden internal_split constant;
wenzelm
parents: 11025
diff changeset
    90
  snd_def:      "snd p == SOME b. EX a. p = (a, b)"
11025
a70b796d9af8 converted to Isar therory, adding attributes complete_split and split_format
oheimb
parents: 10289
diff changeset
    91
  split_def:    "split == (%c p. c (fst p) (snd p))"
a70b796d9af8 converted to Isar therory, adding attributes complete_split and split_format
oheimb
parents: 10289
diff changeset
    92
  prod_fun_def: "prod_fun f g == split(%x y.(f(x), g(y)))"
a70b796d9af8 converted to Isar therory, adding attributes complete_split and split_format
oheimb
parents: 10289
diff changeset
    93
  Sigma_def:    "Sigma A B == UN x:A. UN y:B(x). {(x, y)}"
10213
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    94
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    95
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    96
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    97
(** unit **)
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    98
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    99
global
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   100
11032
83f723e86dac added hidden internal_split constant;
wenzelm
parents: 11025
diff changeset
   101
typedef unit = "{True}"
11025
a70b796d9af8 converted to Isar therory, adding attributes complete_split and split_format
oheimb
parents: 10289
diff changeset
   102
proof
a70b796d9af8 converted to Isar therory, adding attributes complete_split and split_format
oheimb
parents: 10289
diff changeset
   103
  show "True : ?unit"
a70b796d9af8 converted to Isar therory, adding attributes complete_split and split_format
oheimb
parents: 10289
diff changeset
   104
    by blast
a70b796d9af8 converted to Isar therory, adding attributes complete_split and split_format
oheimb
parents: 10289
diff changeset
   105
qed
10213
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   106
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   107
consts
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   108
  "()"          :: unit                           ("'(')")
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   109
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   110
local
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   111
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   112
defs
11025
a70b796d9af8 converted to Isar therory, adding attributes complete_split and split_format
oheimb
parents: 10289
diff changeset
   113
  Unity_def:    "() == Abs_unit True"
a70b796d9af8 converted to Isar therory, adding attributes complete_split and split_format
oheimb
parents: 10289
diff changeset
   114
11032
83f723e86dac added hidden internal_split constant;
wenzelm
parents: 11025
diff changeset
   115
83f723e86dac added hidden internal_split constant;
wenzelm
parents: 11025
diff changeset
   116
83f723e86dac added hidden internal_split constant;
wenzelm
parents: 11025
diff changeset
   117
(** lemmas and tool setup **)
83f723e86dac added hidden internal_split constant;
wenzelm
parents: 11025
diff changeset
   118
11025
a70b796d9af8 converted to Isar therory, adding attributes complete_split and split_format
oheimb
parents: 10289
diff changeset
   119
use "Product_Type_lemmas.ML"
a70b796d9af8 converted to Isar therory, adding attributes complete_split and split_format
oheimb
parents: 10289
diff changeset
   120
11032
83f723e86dac added hidden internal_split constant;
wenzelm
parents: 11025
diff changeset
   121
constdefs
83f723e86dac added hidden internal_split constant;
wenzelm
parents: 11025
diff changeset
   122
  internal_split :: "('a \<Rightarrow> 'b => 'c) => 'a * 'b => 'c"
83f723e86dac added hidden internal_split constant;
wenzelm
parents: 11025
diff changeset
   123
  "internal_split == split"
83f723e86dac added hidden internal_split constant;
wenzelm
parents: 11025
diff changeset
   124
83f723e86dac added hidden internal_split constant;
wenzelm
parents: 11025
diff changeset
   125
lemma internal_split_conv: "internal_split c (a, b) = c a b"
83f723e86dac added hidden internal_split constant;
wenzelm
parents: 11025
diff changeset
   126
  by (simp only: internal_split_def split_conv)
83f723e86dac added hidden internal_split constant;
wenzelm
parents: 11025
diff changeset
   127
83f723e86dac added hidden internal_split constant;
wenzelm
parents: 11025
diff changeset
   128
hide const internal_split
83f723e86dac added hidden internal_split constant;
wenzelm
parents: 11025
diff changeset
   129
11025
a70b796d9af8 converted to Isar therory, adding attributes complete_split and split_format
oheimb
parents: 10289
diff changeset
   130
use "Tools/split_rule.ML"
11032
83f723e86dac added hidden internal_split constant;
wenzelm
parents: 11025
diff changeset
   131
setup SplitRule.setup
10213
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   132
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   133
end