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