Theory Product_ord

Up to index of Isabelle/HOL/ex

theory Product_ord
imports ATP_Linkup
begin

(*  Title:      HOL/Library/Product_ord.thy
    ID:         $Id: Product_ord.thy,v 1.13 2008/05/26 15:55:34 haftmann Exp $
    Author:     Norbert Voelker
*)

header {* Order on product types *}

theory Product_ord
imports ATP_Linkup
begin

instantiation "*" :: (ord, ord) ord
begin

definition
  prod_le_def [code func del]: "x ≤ y <-> fst x < fst y ∨ fst x = fst y ∧ snd x ≤ snd y"

definition
  prod_less_def [code func del]: "x < y <-> fst x < fst y ∨ fst x = fst y ∧ snd x < snd y"

instance ..

end

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

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_le_def prod_less_def by simp_all

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

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

instantiation * :: (linorder, linorder) distrib_lattice
begin

definition
  inf_prod_def: "(inf :: 'a × 'b => _ => _) = min"

definition
  sup_prod_def: "(sup :: 'a × 'b => _ => _) = max"

instance
  by intro_classes
    (auto simp add: inf_prod_def sup_prod_def min_max.sup_inf_distrib1)

end

end

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)