src/HOL/Library/Product_ord.thy
author haftmann
Wed May 06 09:08:47 2009 +0200 (2009-05-06)
changeset 31040 996ae76c9eda
parent 30738 0842e906300c
child 37678 0040bafffdef
permissions -rw-r--r--
compatible with preorder; bot and top instances
     1 (*  Title:      HOL/Library/Product_ord.thy
     2     Author:     Norbert Voelker
     3 *)
     4 
     5 header {* Order on product types *}
     6 
     7 theory Product_ord
     8 imports Main
     9 begin
    10 
    11 instantiation "*" :: (ord, ord) ord
    12 begin
    13 
    14 definition
    15   prod_le_def [code del]: "x \<le> y \<longleftrightarrow> fst x < fst y \<or> fst x \<le> fst y \<and> snd x \<le> snd y"
    16 
    17 definition
    18   prod_less_def [code del]: "x < y \<longleftrightarrow> fst x < fst y \<or> fst x \<le> fst y \<and> snd x < snd y"
    19 
    20 instance ..
    21 
    22 end
    23 
    24 lemma [code]:
    25   "(x1\<Colon>'a\<Colon>{ord, eq}, y1) \<le> (x2, y2) \<longleftrightarrow> x1 < x2 \<or> x1 \<le> x2 \<and> y1 \<le> y2"
    26   "(x1\<Colon>'a\<Colon>{ord, eq}, y1) < (x2, y2) \<longleftrightarrow> x1 < x2 \<or> x1 \<le> x2 \<and> y1 < y2"
    27   unfolding prod_le_def prod_less_def by simp_all
    28 
    29 instance * :: (preorder, preorder) preorder proof
    30 qed (auto simp: prod_le_def prod_less_def less_le_not_le intro: order_trans)
    31 
    32 instance * :: (order, order) order proof
    33 qed (auto simp add: prod_le_def)
    34 
    35 instance * :: (linorder, linorder) linorder proof
    36 qed (auto simp: prod_le_def)
    37 
    38 instantiation * :: (linorder, linorder) distrib_lattice
    39 begin
    40 
    41 definition
    42   inf_prod_def: "(inf \<Colon> 'a \<times> 'b \<Rightarrow> _ \<Rightarrow> _) = min"
    43 
    44 definition
    45   sup_prod_def: "(sup \<Colon> 'a \<times> 'b \<Rightarrow> _ \<Rightarrow> _) = max"
    46 
    47 instance proof
    48 qed (auto simp add: inf_prod_def sup_prod_def min_max.sup_inf_distrib1)
    49 
    50 end
    51 
    52 instantiation * :: (bot, bot) bot
    53 begin
    54 
    55 definition
    56   bot_prod_def: "bot = (bot, bot)"
    57 
    58 instance proof
    59 qed (auto simp add: bot_prod_def prod_le_def)
    60 
    61 end
    62 
    63 instantiation * :: (top, top) top
    64 begin
    65 
    66 definition
    67   top_prod_def: "top = (top, top)"
    68 
    69 instance proof
    70 qed (auto simp add: top_prod_def prod_le_def)
    71 
    72 end
    73 
    74 end