src/HOL/Product_Type.thy
author wenzelm
Wed, 17 Oct 2001 20:24:03 +0200
changeset 11820 015a82d4ee96
parent 11777 b03c8a3fcc6d
child 11838 02d75712061d
permissions -rw-r--r--
proper proof of split_paired_all (presently unused);
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
11777
wenzelm
parents: 11602
diff changeset
     5
*)
10213
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
     6
11777
wenzelm
parents: 11602
diff changeset
     7
header {* Finite products (including unit) *}
10213
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
     8
11025
a70b796d9af8 converted to Isar therory, adding attributes complete_split and split_format
oheimb
parents: 10289
diff changeset
     9
theory Product_Type = Fun
11032
83f723e86dac added hidden internal_split constant;
wenzelm
parents: 11025
diff changeset
    10
files ("Product_Type_lemmas.ML") ("Tools/split_rule.ML"):
10213
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    11
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    12
11777
wenzelm
parents: 11602
diff changeset
    13
subsection {* Products *}
10213
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    14
11777
wenzelm
parents: 11602
diff changeset
    15
subsubsection {* Type definition *}
10213
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    16
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    17
constdefs
11025
a70b796d9af8 converted to Isar therory, adding attributes complete_split and split_format
oheimb
parents: 10289
diff changeset
    18
  Pair_Rep :: "['a, 'b] => ['a, 'b] => bool"
11032
83f723e86dac added hidden internal_split constant;
wenzelm
parents: 11025
diff changeset
    19
  "Pair_Rep == (%a b. %x y. x=a & y=b)"
10213
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)
11032
83f723e86dac added hidden internal_split constant;
wenzelm
parents: 11025
diff changeset
    25
    = "{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
    26
proof
a70b796d9af8 converted to Isar therory, adding attributes complete_split and split_format
oheimb
parents: 10289
diff changeset
    27
  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
    28
    by blast
a70b796d9af8 converted to Isar therory, adding attributes complete_split and split_format
oheimb
parents: 10289
diff changeset
    29
qed
10213
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    30
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    31
syntax (symbols)
11493
f3ff2549cdc8 added pair_imageI (also as intro rule)
oheimb
parents: 11451
diff changeset
    32
  "*"      :: "[type, type] => type"         ("(_ \<times>/ _)" [21, 20] 20)
10213
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    33
syntax (HTML output)
11493
f3ff2549cdc8 added pair_imageI (also as intro rule)
oheimb
parents: 11451
diff changeset
    34
  "*"      :: "[type, type] => type"         ("(_ \<times>/ _)" [21, 20] 20)
10213
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    35
11777
wenzelm
parents: 11602
diff changeset
    36
local
10213
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    37
11777
wenzelm
parents: 11602
diff changeset
    38
wenzelm
parents: 11602
diff changeset
    39
subsubsection {* Abstract constants and syntax *}
wenzelm
parents: 11602
diff changeset
    40
wenzelm
parents: 11602
diff changeset
    41
global
10213
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    42
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    43
consts
11025
a70b796d9af8 converted to Isar therory, adding attributes complete_split and split_format
oheimb
parents: 10289
diff changeset
    44
  fst      :: "'a * 'b => 'a"
a70b796d9af8 converted to Isar therory, adding attributes complete_split and split_format
oheimb
parents: 10289
diff changeset
    45
  snd      :: "'a * 'b => 'b"
a70b796d9af8 converted to Isar therory, adding attributes complete_split and split_format
oheimb
parents: 10289
diff changeset
    46
  split    :: "[['a, 'b] => 'c, 'a * 'b] => 'c"
a70b796d9af8 converted to Isar therory, adding attributes complete_split and split_format
oheimb
parents: 10289
diff changeset
    47
  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
    48
  Pair     :: "['a, 'b] => 'a * 'b"
a70b796d9af8 converted to Isar therory, adding attributes complete_split and split_format
oheimb
parents: 10289
diff changeset
    49
  Sigma    :: "['a set, 'a => 'b set] => ('a * 'b) set"
10213
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    50
11777
wenzelm
parents: 11602
diff changeset
    51
local
10213
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    52
11777
wenzelm
parents: 11602
diff changeset
    53
text {*
wenzelm
parents: 11602
diff changeset
    54
  Patterns -- extends pre-defined type @{typ pttrn} used in
wenzelm
parents: 11602
diff changeset
    55
  abstractions.
wenzelm
parents: 11602
diff changeset
    56
*}
10213
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    57
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    58
nonterminals
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    59
  tuple_args patterns
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    60
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    61
syntax
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    62
  "_tuple"      :: "'a => tuple_args => 'a * 'b"        ("(1'(_,/ _'))")
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    63
  "_tuple_arg"  :: "'a => tuple_args"                   ("_")
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    64
  "_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
    65
  "_pattern"    :: "[pttrn, patterns] => pttrn"         ("'(_,/ _')")
a70b796d9af8 converted to Isar therory, adding attributes complete_split and split_format
oheimb
parents: 10289
diff changeset
    66
  ""            :: "pttrn => patterns"                  ("_")
a70b796d9af8 converted to Isar therory, adding attributes complete_split and split_format
oheimb
parents: 10289
diff changeset
    67
  "_patterns"   :: "[pttrn, patterns] => patterns"      ("_,/ _")
a70b796d9af8 converted to Isar therory, adding attributes complete_split and split_format
oheimb
parents: 10289
diff changeset
    68
  "@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
    69
  "@Times" ::"['a set,  'a => 'b set] => ('a * 'b) set" (infixr "<*>" 80)
10213
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    70
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    71
translations
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    72
  "(x, y)"       == "Pair x y"
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    73
  "_tuple x (_tuple_args y z)" == "_tuple x (_tuple_arg (_tuple y z))"
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    74
  "%(x,y,zs).b"  == "split(%x (y,zs).b)"
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    75
  "%(x,y).b"     == "split(%x y. b)"
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    76
  "_abs (Pair x y) t" => "%(x,y).t"
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    77
  (* The last rule accommodates tuples in `case C ... (x,y) ... => ...'
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    78
     The (x,y) is parsed as `Pair x y' because it is logic, not pttrn *)
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    79
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    80
  "SIGMA x:A. B" => "Sigma A (%x. B)"
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    81
  "A <*> B"      => "Sigma A (_K B)"
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    82
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    83
syntax (symbols)
11493
f3ff2549cdc8 added pair_imageI (also as intro rule)
oheimb
parents: 11451
diff changeset
    84
  "@Sigma" :: "[pttrn, 'a set, 'b set] => ('a * 'b) set"  ("(3\<Sigma> _\<in>_./ _)"   10)
f3ff2549cdc8 added pair_imageI (also as intro rule)
oheimb
parents: 11451
diff changeset
    85
  "@Times" :: "['a set,  'a => 'b set] => ('a * 'b) set"  ("_ \<times> _" [81, 80] 80)
11025
a70b796d9af8 converted to Isar therory, adding attributes complete_split and split_format
oheimb
parents: 10289
diff changeset
    86
11032
83f723e86dac added hidden internal_split constant;
wenzelm
parents: 11025
diff changeset
    87
print_translation {* [("Sigma", dependent_tr' ("@Sigma", "@Times"))] *}
10213
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    88
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    89
11777
wenzelm
parents: 11602
diff changeset
    90
subsubsection {* Definitions *}
10213
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    91
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    92
defs
11025
a70b796d9af8 converted to Isar therory, adding attributes complete_split and split_format
oheimb
parents: 10289
diff changeset
    93
  Pair_def:     "Pair a b == Abs_Prod(Pair_Rep a b)"
11451
8abfb4f7bd02 partial restructuring to reduce dependence on Axiom of Choice
paulson
parents: 11425
diff changeset
    94
  fst_def:      "fst p == THE a. EX b. p = (a, b)"
8abfb4f7bd02 partial restructuring to reduce dependence on Axiom of Choice
paulson
parents: 11425
diff changeset
    95
  snd_def:      "snd p == THE b. EX a. p = (a, b)"
11025
a70b796d9af8 converted to Isar therory, adding attributes complete_split and split_format
oheimb
parents: 10289
diff changeset
    96
  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
    97
  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
    98
  Sigma_def:    "Sigma A B == UN x:A. UN y:B(x). {(x, y)}"
10213
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    99
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   100
11777
wenzelm
parents: 11602
diff changeset
   101
subsection {* Unit *}
10213
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   102
11032
83f723e86dac added hidden internal_split constant;
wenzelm
parents: 11025
diff changeset
   103
typedef unit = "{True}"
11025
a70b796d9af8 converted to Isar therory, adding attributes complete_split and split_format
oheimb
parents: 10289
diff changeset
   104
proof
a70b796d9af8 converted to Isar therory, adding attributes complete_split and split_format
oheimb
parents: 10289
diff changeset
   105
  show "True : ?unit"
a70b796d9af8 converted to Isar therory, adding attributes complete_split and split_format
oheimb
parents: 10289
diff changeset
   106
    by blast
a70b796d9af8 converted to Isar therory, adding attributes complete_split and split_format
oheimb
parents: 10289
diff changeset
   107
qed
10213
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   108
11602
bf6700f4c010 renamed "()" to Unity, made local;
wenzelm
parents: 11493
diff changeset
   109
constdefs
bf6700f4c010 renamed "()" to Unity, made local;
wenzelm
parents: 11493
diff changeset
   110
  Unity :: unit    ("'(')")
bf6700f4c010 renamed "()" to Unity, made local;
wenzelm
parents: 11493
diff changeset
   111
  "() == Abs_unit True"
11025
a70b796d9af8 converted to Isar therory, adding attributes complete_split and split_format
oheimb
parents: 10289
diff changeset
   112
11032
83f723e86dac added hidden internal_split constant;
wenzelm
parents: 11025
diff changeset
   113
11777
wenzelm
parents: 11602
diff changeset
   114
subsection {* Lemmas and tool setup *}
11032
83f723e86dac added hidden internal_split constant;
wenzelm
parents: 11025
diff changeset
   115
11025
a70b796d9af8 converted to Isar therory, adding attributes complete_split and split_format
oheimb
parents: 10289
diff changeset
   116
use "Product_Type_lemmas.ML"
a70b796d9af8 converted to Isar therory, adding attributes complete_split and split_format
oheimb
parents: 10289
diff changeset
   117
11820
015a82d4ee96 proper proof of split_paired_all (presently unused);
wenzelm
parents: 11777
diff changeset
   118
lemma (*split_paired_all:*) "(!!x. PROP P x) == (!!a b. PROP P (a, b))"   (* FIXME unused *)
015a82d4ee96 proper proof of split_paired_all (presently unused);
wenzelm
parents: 11777
diff changeset
   119
proof
015a82d4ee96 proper proof of split_paired_all (presently unused);
wenzelm
parents: 11777
diff changeset
   120
  fix a b
015a82d4ee96 proper proof of split_paired_all (presently unused);
wenzelm
parents: 11777
diff changeset
   121
  assume "!!x. PROP P x"
015a82d4ee96 proper proof of split_paired_all (presently unused);
wenzelm
parents: 11777
diff changeset
   122
  thus "PROP P (a, b)" .
015a82d4ee96 proper proof of split_paired_all (presently unused);
wenzelm
parents: 11777
diff changeset
   123
next
015a82d4ee96 proper proof of split_paired_all (presently unused);
wenzelm
parents: 11777
diff changeset
   124
  fix x
015a82d4ee96 proper proof of split_paired_all (presently unused);
wenzelm
parents: 11777
diff changeset
   125
  assume "!!a b. PROP P (a, b)"
015a82d4ee96 proper proof of split_paired_all (presently unused);
wenzelm
parents: 11777
diff changeset
   126
  hence "PROP P (fst x, snd x)" .
015a82d4ee96 proper proof of split_paired_all (presently unused);
wenzelm
parents: 11777
diff changeset
   127
  thus "PROP P x" by simp
015a82d4ee96 proper proof of split_paired_all (presently unused);
wenzelm
parents: 11777
diff changeset
   128
qed
015a82d4ee96 proper proof of split_paired_all (presently unused);
wenzelm
parents: 11777
diff changeset
   129
11493
f3ff2549cdc8 added pair_imageI (also as intro rule)
oheimb
parents: 11451
diff changeset
   130
lemma pair_imageI [intro]: "(a, b) : A ==> f a b : (%(a, b). f a b) ` A"
11777
wenzelm
parents: 11602
diff changeset
   131
  apply (rule_tac x = "(a, b)" in image_eqI)
wenzelm
parents: 11602
diff changeset
   132
   apply auto
wenzelm
parents: 11602
diff changeset
   133
  done
wenzelm
parents: 11602
diff changeset
   134
11493
f3ff2549cdc8 added pair_imageI (also as intro rule)
oheimb
parents: 11451
diff changeset
   135
11032
83f723e86dac added hidden internal_split constant;
wenzelm
parents: 11025
diff changeset
   136
constdefs
11425
wenzelm
parents: 11032
diff changeset
   137
  internal_split :: "('a => 'b => 'c) => 'a * 'b => 'c"
11032
83f723e86dac added hidden internal_split constant;
wenzelm
parents: 11025
diff changeset
   138
  "internal_split == split"
83f723e86dac added hidden internal_split constant;
wenzelm
parents: 11025
diff changeset
   139
83f723e86dac added hidden internal_split constant;
wenzelm
parents: 11025
diff changeset
   140
lemma internal_split_conv: "internal_split c (a, b) = c a b"
83f723e86dac added hidden internal_split constant;
wenzelm
parents: 11025
diff changeset
   141
  by (simp only: internal_split_def split_conv)
83f723e86dac added hidden internal_split constant;
wenzelm
parents: 11025
diff changeset
   142
83f723e86dac added hidden internal_split constant;
wenzelm
parents: 11025
diff changeset
   143
hide const internal_split
83f723e86dac added hidden internal_split constant;
wenzelm
parents: 11025
diff changeset
   144
11025
a70b796d9af8 converted to Isar therory, adding attributes complete_split and split_format
oheimb
parents: 10289
diff changeset
   145
use "Tools/split_rule.ML"
11032
83f723e86dac added hidden internal_split constant;
wenzelm
parents: 11025
diff changeset
   146
setup SplitRule.setup
10213
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   147
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   148
end