1 (* Title: Product_Lattice.thy
5 header {* Lattice operations on product types *}
8 imports "~~/src/HOL/Library/Product_plus"
11 subsection {* Pointwise ordering *}
13 instantiation prod :: (ord, ord) ord
17 "x \<le> y \<longleftrightarrow> fst x \<le> fst y \<and> snd x \<le> snd y"
20 "(x::'a \<times> 'b) < y \<longleftrightarrow> x \<le> y \<and> \<not> y \<le> x"
26 lemma fst_mono: "x \<le> y \<Longrightarrow> fst x \<le> fst y"
27 unfolding less_eq_prod_def by simp
29 lemma snd_mono: "x \<le> y \<Longrightarrow> snd x \<le> snd y"
30 unfolding less_eq_prod_def by simp
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
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
38 instance prod :: (preorder, preorder) preorder
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)
44 unfolding less_eq_prod_def
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)
51 instance prod :: (order, order) order
55 subsection {* Binary infimum and supremum *}
57 instantiation prod :: (semilattice_inf, semilattice_inf) semilattice_inf
61 "inf x y = (inf (fst x) (fst y), inf (snd x) (snd y))"
63 lemma inf_Pair_Pair [simp]: "inf (a, b) (c, d) = (inf a c, inf b d)"
64 unfolding inf_prod_def by simp
66 lemma fst_inf [simp]: "fst (inf x y) = inf (fst x) (fst y)"
67 unfolding inf_prod_def by simp
69 lemma snd_inf [simp]: "snd (inf x y) = inf (snd x) (snd y)"
70 unfolding inf_prod_def by simp
77 instantiation prod :: (semilattice_sup, semilattice_sup) semilattice_sup
81 "sup x y = (sup (fst x) (fst y), sup (snd x) (snd y))"
83 lemma sup_Pair_Pair [simp]: "sup (a, b) (c, d) = (sup a c, sup b d)"
84 unfolding sup_prod_def by simp
86 lemma fst_sup [simp]: "fst (sup x y) = sup (fst x) (fst y)"
87 unfolding sup_prod_def by simp
89 lemma snd_sup [simp]: "snd (sup x y) = sup (snd x) (snd y)"
90 unfolding sup_prod_def by simp
97 instance prod :: (lattice, lattice) lattice ..
99 instance prod :: (distrib_lattice, distrib_lattice) distrib_lattice
100 by default (auto simp add: sup_inf_distrib1)
103 subsection {* Top and bottom elements *}
105 instantiation prod :: (top, top) top
111 lemma fst_top [simp]: "fst top = top"
112 unfolding top_prod_def by simp
114 lemma snd_top [simp]: "snd top = top"
115 unfolding top_prod_def by simp
117 lemma Pair_top_top: "(top, top) = top"
118 unfolding top_prod_def by simp
121 by default (auto simp add: top_prod_def)
125 instantiation prod :: (bot, bot) bot
131 lemma fst_bot [simp]: "fst bot = bot"
132 unfolding bot_prod_def by simp
134 lemma snd_bot [simp]: "snd bot = bot"
135 unfolding bot_prod_def by simp
137 lemma Pair_bot_bot: "(bot, bot) = bot"
138 unfolding bot_prod_def by simp
141 by default (auto simp add: bot_prod_def)
145 instance prod :: (bounded_lattice, bounded_lattice) bounded_lattice ..
147 instance prod :: (boolean_algebra, boolean_algebra) boolean_algebra
148 by default (auto simp add: prod_eqI inf_compl_bot sup_compl_top diff_eq)
151 subsection {* Complete lattice operations *}
153 instantiation prod :: (complete_lattice, complete_lattice) complete_lattice
157 "Sup A = (SUP x:A. fst x, SUP x:A. snd x)"
160 "Inf A = (INF x:A. fst x, INF x:A. snd x)"
163 by default (simp_all add: less_eq_prod_def Inf_prod_def Sup_prod_def
164 INF_leI le_SUPI le_INF_iff SUP_le_iff)
168 lemma fst_Sup: "fst (Sup A) = (SUP x:A. fst x)"
169 unfolding Sup_prod_def by simp
171 lemma snd_Sup: "snd (Sup A) = (SUP x:A. snd x)"
172 unfolding Sup_prod_def by simp
174 lemma fst_Inf: "fst (Inf A) = (INF x:A. fst x)"
175 unfolding Inf_prod_def by simp
177 lemma snd_Inf: "snd (Inf A) = (INF x:A. snd x)"
178 unfolding Inf_prod_def by simp
180 lemma fst_SUP: "fst (SUP x:A. f x) = (SUP x:A. fst (f x))"
181 by (simp add: SUPR_def fst_Sup image_image)
183 lemma snd_SUP: "snd (SUP x:A. f x) = (SUP x:A. snd (f x))"
184 by (simp add: SUPR_def snd_Sup image_image)
186 lemma fst_INF: "fst (INF x:A. f x) = (INF x:A. fst (f x))"
187 by (simp add: INFI_def fst_Inf image_image)
189 lemma snd_INF: "snd (INF x:A. f x) = (INF x:A. snd (f x))"
190 by (simp add: INFI_def snd_Inf image_image)
192 lemma SUP_Pair: "(SUP x:A. (f x, g x)) = (SUP x:A. f x, SUP x:A. g x)"
193 by (simp add: SUPR_def Sup_prod_def image_image)
195 lemma INF_Pair: "(INF x:A. (f x, g x)) = (INF x:A. f x, INF x:A. g x)"
196 by (simp add: INFI_def Inf_prod_def image_image)