src/HOL/Library/Product_ord.thy
author haftmann
Thu Nov 29 17:08:26 2007 +0100 (2007-11-29)
changeset 25502 9200b36280c0
parent 22845 5f9138bcb3d7
child 25571 c9e39eafc7a0
permissions -rw-r--r--
instance command as rudimentary class target
nipkow@15737
     1
(*  Title:      HOL/Library/Product_ord.thy
nipkow@15737
     2
    ID:         $Id$
nipkow@15737
     3
    Author:     Norbert Voelker
nipkow@15737
     4
*)
nipkow@15737
     5
wenzelm@17200
     6
header {* Order on product types *}
nipkow@15737
     7
nipkow@15737
     8
theory Product_ord
nipkow@15737
     9
imports Main
nipkow@15737
    10
begin
nipkow@15737
    11
haftmann@21458
    12
instance "*" :: (ord, ord) ord
haftmann@25502
    13
  prod_le_def [code func del]: "x \<le> y \<longleftrightarrow> fst x < fst y \<or> fst x = fst y \<and> snd x \<le> snd y"
haftmann@25502
    14
  prod_less_def [code func del]: "x < y \<longleftrightarrow> fst x < fst y \<or> fst x = fst y \<and> snd x < snd y" ..
nipkow@15737
    15
haftmann@22177
    16
lemma [code func]:
haftmann@22177
    17
  "(x1\<Colon>'a\<Colon>{ord, eq}, y1) \<le> (x2, y2) \<longleftrightarrow> x1 < x2 \<or> x1 = x2 \<and> y1 \<le> y2"
haftmann@22177
    18
  "(x1\<Colon>'a\<Colon>{ord, eq}, y1) < (x2, y2) \<longleftrightarrow> x1 < x2 \<or> x1 = x2 \<and> y1 < y2"
haftmann@25502
    19
  unfolding prod_le_def prod_less_def by simp_all
haftmann@22177
    20
haftmann@21458
    21
lemma [code]:
haftmann@21458
    22
  "(x1, y1) \<le> (x2, y2) \<longleftrightarrow> x1 < x2 \<or> x1 = x2 \<and> y1 \<le> y2"
haftmann@21458
    23
  "(x1, y1) < (x2, y2) \<longleftrightarrow> x1 < x2 \<or> x1 = x2 \<and> y1 < y2"
haftmann@25502
    24
  unfolding prod_le_def prod_less_def by simp_all
haftmann@21458
    25
wenzelm@19736
    26
instance * :: (order, order) order
haftmann@25502
    27
  by default (auto simp: prod_le_def prod_less_def intro: order_less_trans)
nipkow@15737
    28
wenzelm@19736
    29
instance * :: (linorder, linorder) linorder
wenzelm@19736
    30
  by default (auto simp: prod_le_def)
nipkow@15737
    31
haftmann@22483
    32
instance * :: (linorder, linorder) distrib_lattice
haftmann@25502
    33
  inf_prod_def: "(inf \<Colon> 'a \<times> 'b \<Rightarrow> _ \<Rightarrow> _) = min"
haftmann@25502
    34
  sup_prod_def: "(sup \<Colon> 'a \<times> 'b \<Rightarrow> _ \<Rightarrow> _) = max"
haftmann@22483
    35
  by intro_classes
haftmann@22483
    36
    (auto simp add: inf_prod_def sup_prod_def min_max.sup_inf_distrib1)
haftmann@22483
    37
wenzelm@19736
    38
end