
nipkow@15737: (*  Title:      HOL/Library/Product_ord.thy
nipkow@15737:     ID:         $Id$
nipkow@15737:     Author:     Norbert Voelker
nipkow@15737: *)
nipkow@15737: 
wenzelm@17200: header {* Order on product types *}
nipkow@15737: 
nipkow@15737: theory Product_ord
nipkow@15737: imports Main
nipkow@15737: begin
nipkow@15737: 
haftmann@21458: instance "*" :: (ord, ord) ord
haftmann@22177:   prod_le_def: "(x \<le> y) \<equiv> (fst x < fst y) \<or> (fst x = fst y \<and> snd x \<le> snd y)"
haftmann@22177:   prod_less_def: "(x < y) \<equiv> (fst x < fst y) \<or> (fst x = fst y \<and> snd x < snd y)" ..
nipkow@15737: 
haftmann@22845: lemmas prod_ord_defs [code func del] = prod_less_def prod_le_def
nipkow@15737: 
haftmann@22177: lemma [code func]:
haftmann@22177:   "(x1\<Colon>'a\<Colon>{ord, eq}, y1) \<le> (x2, y2) \<longleftrightarrow> x1 < x2 \<or> x1 = x2 \<and> y1 \<le> y2"
haftmann@22177:   "(x1\<Colon>'a\<Colon>{ord, eq}, y1) < (x2, y2) \<longleftrightarrow> x1 < x2 \<or> x1 = x2 \<and> y1 < y2"
haftmann@22177:   unfolding prod_ord_defs by simp_all
haftmann@22177: 
haftmann@21458: lemma [code]:
haftmann@21458:   "(x1, y1) \<le> (x2, y2) \<longleftrightarrow> x1 < x2 \<or> x1 = x2 \<and> y1 \<le> y2"
haftmann@21458:   "(x1, y1) < (x2, y2) \<longleftrightarrow> x1 < x2 \<or> x1 = x2 \<and> y1 < y2"
haftmann@21458:   unfolding prod_ord_defs by simp_all
haftmann@21458: 
wenzelm@19736: instance * :: (order, order) order
wenzelm@19736:   by default (auto simp: prod_ord_defs intro: order_less_trans)
nipkow@15737: 
wenzelm@19736: instance * :: (linorder, linorder) linorder
wenzelm@19736:   by default (auto simp: prod_le_def)
nipkow@15737: 
haftmann@22483: instance * :: (linorder, linorder) distrib_lattice
haftmann@22483:   inf_prod_def: "inf \<equiv> min"
haftmann@22483:   sup_prod_def: "sup \<equiv> max"
haftmann@22483:   by intro_classes
haftmann@22483:     (auto simp add: inf_prod_def sup_prod_def min_max.sup_inf_distrib1)
haftmann@22483: 
wenzelm@19736: end




