src/HOL/Library/Product_ord.thy
author haftmann
Sun May 06 21:50:17 2007 +0200 (2007-05-06)
changeset 22845 5f9138bcb3d7
parent 22744 5cbe966d67a2
child 25502 9200b36280c0
permissions -rw-r--r--
changed code generator invocation syntax
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@22177
    13
  prod_le_def: "(x \<le> y) \<equiv> (fst x < fst y) \<or> (fst x = fst y \<and> snd x \<le> snd y)"
haftmann@22177
    14
  prod_less_def: "(x < y) \<equiv> (fst x < fst y) \<or> (fst x = fst y \<and> snd x < snd y)" ..
nipkow@15737
    15
haftmann@22845
    16
lemmas prod_ord_defs [code func del] = prod_less_def prod_le_def
nipkow@15737
    17
haftmann@22177
    18
lemma [code func]:
haftmann@22177
    19
  "(x1\<Colon>'a\<Colon>{ord, eq}, y1) \<le> (x2, y2) \<longleftrightarrow> x1 < x2 \<or> x1 = x2 \<and> y1 \<le> y2"
haftmann@22177
    20
  "(x1\<Colon>'a\<Colon>{ord, eq}, y1) < (x2, y2) \<longleftrightarrow> x1 < x2 \<or> x1 = x2 \<and> y1 < y2"
haftmann@22177
    21
  unfolding prod_ord_defs by simp_all
haftmann@22177
    22
haftmann@21458
    23
lemma [code]:
haftmann@21458
    24
  "(x1, y1) \<le> (x2, y2) \<longleftrightarrow> x1 < x2 \<or> x1 = x2 \<and> y1 \<le> y2"
haftmann@21458
    25
  "(x1, y1) < (x2, y2) \<longleftrightarrow> x1 < x2 \<or> x1 = x2 \<and> y1 < y2"
haftmann@21458
    26
  unfolding prod_ord_defs by simp_all
haftmann@21458
    27
wenzelm@19736
    28
instance * :: (order, order) order
wenzelm@19736
    29
  by default (auto simp: prod_ord_defs intro: order_less_trans)
nipkow@15737
    30
wenzelm@19736
    31
instance * :: (linorder, linorder) linorder
wenzelm@19736
    32
  by default (auto simp: prod_le_def)
nipkow@15737
    33
haftmann@22483
    34
instance * :: (linorder, linorder) distrib_lattice
haftmann@22483
    35
  inf_prod_def: "inf \<equiv> min"
haftmann@22483
    36
  sup_prod_def: "sup \<equiv> max"
haftmann@22483
    37
  by intro_classes
haftmann@22483
    38
    (auto simp add: inf_prod_def sup_prod_def min_max.sup_inf_distrib1)
haftmann@22483
    39
wenzelm@19736
    40
end