Theory Product_ord

Up to index of Isabelle/HOL/ex

theory Product_ord
imports Main
begin

(*  Title:      HOL/Library/Product_ord.thy
    ID:         $Id: Product_ord.thy,v 1.8 2007/05/06 19:50:20 haftmann Exp $
    Author:     Norbert Voelker
*)

header {* Order on product types *}

theory Product_ord
imports Main
begin

instance "*" :: (ord, ord) ord
  prod_le_def: "(x ≤ y) ≡ (fst x < fst y) ∨ (fst x = fst y ∧ snd x ≤ snd y)"
  prod_less_def: "(x < y) ≡ (fst x < fst y) ∨ (fst x = fst y ∧ snd x < snd y)" ..

lemmas prod_ord_defs [code func del] = prod_less_def prod_le_def

lemma [code func]:
  "(x1::'a::{ord, eq}, y1) ≤ (x2, y2) <-> x1 < x2 ∨ x1 = x2 ∧ y1 ≤ y2"
  "(x1::'a::{ord, eq}, y1) < (x2, y2) <-> x1 < x2 ∨ x1 = x2 ∧ y1 < y2"
  unfolding prod_ord_defs by simp_all

lemma [code]:
  "(x1, y1) ≤ (x2, y2) <-> x1 < x2 ∨ x1 = x2 ∧ y1 ≤ y2"
  "(x1, y1) < (x2, y2) <-> x1 < x2 ∨ x1 = x2 ∧ y1 < y2"
  unfolding prod_ord_defs by simp_all

instance * :: (order, order) order
  by default (auto simp: prod_ord_defs intro: order_less_trans)

instance * :: (linorder, linorder) linorder
  by default (auto simp: prod_le_def)

instance * :: (linorder, linorder) distrib_lattice
  inf_prod_def: "inf ≡ min"
  sup_prod_def: "sup ≡ max"
  by intro_classes
    (auto simp add: inf_prod_def sup_prod_def min_max.sup_inf_distrib1)

end

lemma prod_ord_defs:

  x < y == fst x < fst y ∨ fst x = fst y ∧ snd x < snd y
  x  y == fst x < fst y ∨ fst x = fst y ∧ snd x  snd y

lemma

  ((x1.0, y1.0)  (x2.0, y2.0)) = (x1.0 < x2.0x1.0 = x2.0y1.0  y2.0)
  ((x1.0, y1.0) < (x2.0, y2.0)) = (x1.0 < x2.0x1.0 = x2.0y1.0 < y2.0)

lemma

  ((x1.0, y1.0)  (x2.0, y2.0)) = (x1.0 < x2.0x1.0 = x2.0y1.0  y2.0)
  ((x1.0, y1.0) < (x2.0, y2.0)) = (x1.0 < x2.0x1.0 = x2.0y1.0 < y2.0)