src/HOL/Library/Product_Order.thy
author wenzelm
Thu Jun 25 23:33:47 2015 +0200 (2015-06-25)
changeset 60580 7e741e22d7fc
parent 60500 903bb1495239
child 60679 ade12ef2773c
permissions -rw-r--r--
tuned proofs;
haftmann@51115
     1
(*  Title:      HOL/Library/Product_Order.thy
huffman@44006
     2
    Author:     Brian Huffman
huffman@44006
     3
*)
huffman@44006
     4
wenzelm@60500
     5
section \<open>Pointwise order on product types\<close>
huffman@44006
     6
haftmann@51115
     7
theory Product_Order
immler@54776
     8
imports Product_plus Conditionally_Complete_Lattices
huffman@44006
     9
begin
huffman@44006
    10
wenzelm@60500
    11
subsection \<open>Pointwise ordering\<close>
huffman@44006
    12
huffman@44006
    13
instantiation prod :: (ord, ord) ord
huffman@44006
    14
begin
huffman@44006
    15
huffman@44006
    16
definition
huffman@44006
    17
  "x \<le> y \<longleftrightarrow> fst x \<le> fst y \<and> snd x \<le> snd y"
huffman@44006
    18
huffman@44006
    19
definition
huffman@44006
    20
  "(x::'a \<times> 'b) < y \<longleftrightarrow> x \<le> y \<and> \<not> y \<le> x"
huffman@44006
    21
huffman@44006
    22
instance ..
huffman@44006
    23
huffman@44006
    24
end
huffman@44006
    25
huffman@44006
    26
lemma fst_mono: "x \<le> y \<Longrightarrow> fst x \<le> fst y"
huffman@44006
    27
  unfolding less_eq_prod_def by simp
huffman@44006
    28
huffman@44006
    29
lemma snd_mono: "x \<le> y \<Longrightarrow> snd x \<le> snd y"
huffman@44006
    30
  unfolding less_eq_prod_def by simp
huffman@44006
    31
huffman@44006
    32
lemma Pair_mono: "x \<le> x' \<Longrightarrow> y \<le> y' \<Longrightarrow> (x, y) \<le> (x', y')"
huffman@44006
    33
  unfolding less_eq_prod_def by simp
huffman@44006
    34
huffman@44006
    35
lemma Pair_le [simp]: "(a, b) \<le> (c, d) \<longleftrightarrow> a \<le> c \<and> b \<le> d"
huffman@44006
    36
  unfolding less_eq_prod_def by simp
huffman@44006
    37
huffman@44006
    38
instance prod :: (preorder, preorder) preorder
huffman@44006
    39
proof
huffman@44006
    40
  fix x y z :: "'a \<times> 'b"
huffman@44006
    41
  show "x < y \<longleftrightarrow> x \<le> y \<and> \<not> y \<le> x"
huffman@44006
    42
    by (rule less_prod_def)
huffman@44006
    43
  show "x \<le> x"
huffman@44006
    44
    unfolding less_eq_prod_def
huffman@44006
    45
    by fast
huffman@44006
    46
  assume "x \<le> y" and "y \<le> z" thus "x \<le> z"
huffman@44006
    47
    unfolding less_eq_prod_def
huffman@44006
    48
    by (fast elim: order_trans)
huffman@44006
    49
qed
huffman@44006
    50
huffman@44006
    51
instance prod :: (order, order) order
huffman@44006
    52
  by default auto
huffman@44006
    53
huffman@44006
    54
wenzelm@60500
    55
subsection \<open>Binary infimum and supremum\<close>
huffman@44006
    56
immler@54776
    57
instantiation prod :: (inf, inf) inf
huffman@44006
    58
begin
huffman@44006
    59
huffman@44006
    60
definition
huffman@44006
    61
  "inf x y = (inf (fst x) (fst y), inf (snd x) (snd y))"
huffman@44006
    62
huffman@44006
    63
lemma inf_Pair_Pair [simp]: "inf (a, b) (c, d) = (inf a c, inf b d)"
huffman@44006
    64
  unfolding inf_prod_def by simp
huffman@44006
    65
huffman@44006
    66
lemma fst_inf [simp]: "fst (inf x y) = inf (fst x) (fst y)"
huffman@44006
    67
  unfolding inf_prod_def by simp
huffman@44006
    68
huffman@44006
    69
lemma snd_inf [simp]: "snd (inf x y) = inf (snd x) (snd y)"
huffman@44006
    70
  unfolding inf_prod_def by simp
huffman@44006
    71
immler@54776
    72
instance proof qed
immler@54776
    73
end
immler@54776
    74
immler@54776
    75
instance prod :: (semilattice_inf, semilattice_inf) semilattice_inf
huffman@44006
    76
  by default auto
huffman@44006
    77
huffman@44006
    78
immler@54776
    79
instantiation prod :: (sup, sup) sup
huffman@44006
    80
begin
huffman@44006
    81
huffman@44006
    82
definition
huffman@44006
    83
  "sup x y = (sup (fst x) (fst y), sup (snd x) (snd y))"
huffman@44006
    84
huffman@44006
    85
lemma sup_Pair_Pair [simp]: "sup (a, b) (c, d) = (sup a c, sup b d)"
huffman@44006
    86
  unfolding sup_prod_def by simp
huffman@44006
    87
huffman@44006
    88
lemma fst_sup [simp]: "fst (sup x y) = sup (fst x) (fst y)"
huffman@44006
    89
  unfolding sup_prod_def by simp
huffman@44006
    90
huffman@44006
    91
lemma snd_sup [simp]: "snd (sup x y) = sup (snd x) (snd y)"
huffman@44006
    92
  unfolding sup_prod_def by simp
huffman@44006
    93
immler@54776
    94
instance proof qed
immler@54776
    95
end
immler@54776
    96
immler@54776
    97
instance prod :: (semilattice_sup, semilattice_sup) semilattice_sup
huffman@44006
    98
  by default auto
huffman@44006
    99
huffman@44006
   100
instance prod :: (lattice, lattice) lattice ..
huffman@44006
   101
huffman@44006
   102
instance prod :: (distrib_lattice, distrib_lattice) distrib_lattice
huffman@44006
   103
  by default (auto simp add: sup_inf_distrib1)
huffman@44006
   104
huffman@44006
   105
wenzelm@60500
   106
subsection \<open>Top and bottom elements\<close>
huffman@44006
   107
huffman@44006
   108
instantiation prod :: (top, top) top
huffman@44006
   109
begin
huffman@44006
   110
huffman@44006
   111
definition
huffman@44006
   112
  "top = (top, top)"
huffman@44006
   113
haftmann@52729
   114
instance ..
haftmann@52729
   115
haftmann@52729
   116
end
haftmann@52729
   117
huffman@44006
   118
lemma fst_top [simp]: "fst top = top"
huffman@44006
   119
  unfolding top_prod_def by simp
huffman@44006
   120
huffman@44006
   121
lemma snd_top [simp]: "snd top = top"
huffman@44006
   122
  unfolding top_prod_def by simp
huffman@44006
   123
huffman@44006
   124
lemma Pair_top_top: "(top, top) = top"
huffman@44006
   125
  unfolding top_prod_def by simp
huffman@44006
   126
haftmann@52729
   127
instance prod :: (order_top, order_top) order_top
huffman@44006
   128
  by default (auto simp add: top_prod_def)
huffman@44006
   129
huffman@44006
   130
instantiation prod :: (bot, bot) bot
huffman@44006
   131
begin
huffman@44006
   132
huffman@44006
   133
definition
huffman@44006
   134
  "bot = (bot, bot)"
huffman@44006
   135
haftmann@52729
   136
instance ..
haftmann@52729
   137
haftmann@52729
   138
end
haftmann@52729
   139
huffman@44006
   140
lemma fst_bot [simp]: "fst bot = bot"
huffman@44006
   141
  unfolding bot_prod_def by simp
huffman@44006
   142
huffman@44006
   143
lemma snd_bot [simp]: "snd bot = bot"
huffman@44006
   144
  unfolding bot_prod_def by simp
huffman@44006
   145
huffman@44006
   146
lemma Pair_bot_bot: "(bot, bot) = bot"
huffman@44006
   147
  unfolding bot_prod_def by simp
huffman@44006
   148
haftmann@52729
   149
instance prod :: (order_bot, order_bot) order_bot
huffman@44006
   150
  by default (auto simp add: bot_prod_def)
huffman@44006
   151
huffman@44006
   152
instance prod :: (bounded_lattice, bounded_lattice) bounded_lattice ..
huffman@44006
   153
huffman@44006
   154
instance prod :: (boolean_algebra, boolean_algebra) boolean_algebra
huffman@44006
   155
  by default (auto simp add: prod_eqI inf_compl_bot sup_compl_top diff_eq)
huffman@44006
   156
huffman@44006
   157
wenzelm@60500
   158
subsection \<open>Complete lattice operations\<close>
huffman@44006
   159
immler@54776
   160
instantiation prod :: (Inf, Inf) Inf
immler@54776
   161
begin
immler@54776
   162
immler@54776
   163
definition
immler@54776
   164
  "Inf A = (INF x:A. fst x, INF x:A. snd x)"
immler@54776
   165
immler@54776
   166
instance proof qed
immler@54776
   167
end
immler@54776
   168
immler@54776
   169
instantiation prod :: (Sup, Sup) Sup
huffman@44006
   170
begin
huffman@44006
   171
huffman@44006
   172
definition
huffman@44006
   173
  "Sup A = (SUP x:A. fst x, SUP x:A. snd x)"
huffman@44006
   174
immler@54776
   175
instance proof qed
immler@54776
   176
end
huffman@44006
   177
immler@54776
   178
instance prod :: (conditionally_complete_lattice, conditionally_complete_lattice)
immler@54776
   179
    conditionally_complete_lattice
immler@54776
   180
  by default (force simp: less_eq_prod_def Inf_prod_def Sup_prod_def bdd_below_def bdd_above_def
haftmann@56166
   181
    INF_def SUP_def simp del: Inf_image_eq Sup_image_eq intro!: cInf_lower cSup_upper cInf_greatest cSup_least)+
immler@54776
   182
immler@54776
   183
instance prod :: (complete_lattice, complete_lattice) complete_lattice
huffman@44006
   184
  by default (simp_all add: less_eq_prod_def Inf_prod_def Sup_prod_def
haftmann@52729
   185
    INF_lower SUP_upper le_INF_iff SUP_le_iff bot_prod_def top_prod_def)
huffman@44006
   186
huffman@44006
   187
lemma fst_Sup: "fst (Sup A) = (SUP x:A. fst x)"
huffman@44006
   188
  unfolding Sup_prod_def by simp
huffman@44006
   189
huffman@44006
   190
lemma snd_Sup: "snd (Sup A) = (SUP x:A. snd x)"
huffman@44006
   191
  unfolding Sup_prod_def by simp
huffman@44006
   192
huffman@44006
   193
lemma fst_Inf: "fst (Inf A) = (INF x:A. fst x)"
huffman@44006
   194
  unfolding Inf_prod_def by simp
huffman@44006
   195
huffman@44006
   196
lemma snd_Inf: "snd (Inf A) = (INF x:A. snd x)"
huffman@44006
   197
  unfolding Inf_prod_def by simp
huffman@44006
   198
huffman@44006
   199
lemma fst_SUP: "fst (SUP x:A. f x) = (SUP x:A. fst (f x))"
haftmann@56166
   200
  using fst_Sup [of "f ` A", symmetric] by (simp add: comp_def)
huffman@44006
   201
huffman@44006
   202
lemma snd_SUP: "snd (SUP x:A. f x) = (SUP x:A. snd (f x))"
haftmann@56166
   203
  using snd_Sup [of "f ` A", symmetric] by (simp add: comp_def)
huffman@44006
   204
huffman@44006
   205
lemma fst_INF: "fst (INF x:A. f x) = (INF x:A. fst (f x))"
haftmann@56166
   206
  using fst_Inf [of "f ` A", symmetric] by (simp add: comp_def)
huffman@44006
   207
huffman@44006
   208
lemma snd_INF: "snd (INF x:A. f x) = (INF x:A. snd (f x))"
haftmann@56166
   209
  using snd_Inf [of "f ` A", symmetric] by (simp add: comp_def)
huffman@44006
   210
huffman@44006
   211
lemma SUP_Pair: "(SUP x:A. (f x, g x)) = (SUP x:A. f x, SUP x:A. g x)"
haftmann@56166
   212
  unfolding SUP_def Sup_prod_def by (simp add: comp_def)
huffman@44006
   213
huffman@44006
   214
lemma INF_Pair: "(INF x:A. (f x, g x)) = (INF x:A. f x, INF x:A. g x)"
haftmann@56166
   215
  unfolding INF_def Inf_prod_def by (simp add: comp_def)
huffman@44006
   216
nipkow@50535
   217
wenzelm@60500
   218
text \<open>Alternative formulations for set infima and suprema over the product
wenzelm@60500
   219
of two complete lattices:\<close>
nipkow@50535
   220
haftmann@56212
   221
lemma INF_prod_alt_def:
haftmann@56218
   222
  "INFIMUM A f = (INFIMUM A (fst o f), INFIMUM A (snd o f))"
haftmann@56166
   223
  unfolding INF_def Inf_prod_def by simp
nipkow@50535
   224
haftmann@56212
   225
lemma SUP_prod_alt_def:
haftmann@56218
   226
  "SUPREMUM A f = (SUPREMUM A (fst o f), SUPREMUM A (snd o f))"
haftmann@56166
   227
  unfolding SUP_def Sup_prod_def by simp
nipkow@50535
   228
nipkow@50535
   229
wenzelm@60500
   230
subsection \<open>Complete distributive lattices\<close>
nipkow@50535
   231
nipkow@50573
   232
(* Contribution: Alessandro Coglio *)
nipkow@50535
   233
nipkow@50535
   234
instance prod ::
nipkow@50535
   235
  (complete_distrib_lattice, complete_distrib_lattice) complete_distrib_lattice
wenzelm@60580
   236
proof (default, goals)
wenzelm@60580
   237
  case 1
wenzelm@60580
   238
  then show ?case
haftmann@56212
   239
    by (auto simp: sup_prod_def Inf_prod_def INF_prod_alt_def sup_Inf sup_INF comp_def)
nipkow@50535
   240
next
wenzelm@60580
   241
  case 2
wenzelm@60580
   242
  then show ?case
haftmann@56212
   243
    by (auto simp: inf_prod_def Sup_prod_def SUP_prod_alt_def inf_Sup inf_SUP comp_def)
nipkow@50535
   244
qed
nipkow@50535
   245
haftmann@51115
   246
end
nipkow@50535
   247