Theory Order_Relation

Up to index of Isabelle/HOL/Valuation

theory Order_Relation
imports ATP_Linkup
begin

(*  ID          : $Id: Order_Relation.thy,v 1.4 2008/05/07 08:57:47 berghofe Exp $
    Author      : Tobias Nipkow
*)

header {* Orders as Relations *}

theory Order_Relation
imports ATP_Linkup Hilbert_Choice
begin

text{* This prelude could be moved to theory Relation: *}

definition "irrefl r ≡ ∀x. (x,x) ∉ r"

definition "total_on A r ≡ ∀x∈A.∀y∈A. x≠y --> (x,y)∈r ∨ (y,x)∈r"

abbreviation "total ≡ total_on UNIV"


lemma total_on_empty[simp]: "total_on {} r"
by(simp add:total_on_def)

lemma refl_on_converse[simp]: "refl A (r^-1) = refl A r"
by(auto simp add:refl_def)

lemma total_on_converse[simp]: "total_on A (r^-1) = total_on A r"
by (auto simp: total_on_def)

lemma irrefl_diff_Id[simp]: "irrefl(r-Id)"
by(simp add:irrefl_def)

declare [[simp_depth_limit = 2]]
lemma trans_diff_Id: " trans r ==> antisym r ==> trans (r-Id)"
by(simp add: antisym_def trans_def) blast
declare [[simp_depth_limit = 50]]

lemma total_on_diff_Id[simp]: "total_on A (r-Id) = total_on A r"
by(simp add: total_on_def)


subsection{* Orders on a set *}

definition "preorder_on A r ≡ refl A r ∧ trans r"

definition "partial_order_on A r ≡ preorder_on A r ∧ antisym r"

definition "linear_order_on A r ≡ partial_order_on A r ∧ total_on A r"

definition "strict_linear_order_on A r ≡ trans r ∧ irrefl r ∧ total_on A r"

definition "well_order_on A r ≡ linear_order_on A r ∧ wf(r - Id)"

lemmas order_on_defs =
  preorder_on_def partial_order_on_def linear_order_on_def
  strict_linear_order_on_def well_order_on_def


lemma preorder_on_empty[simp]: "preorder_on {} {}"
by(simp add:preorder_on_def trans_def)

lemma partial_order_on_empty[simp]: "partial_order_on {} {}"
by(simp add:partial_order_on_def)

lemma lnear_order_on_empty[simp]: "linear_order_on {} {}"
by(simp add:linear_order_on_def)

lemma well_order_on_empty[simp]: "well_order_on {} {}"
by(simp add:well_order_on_def)


lemma preorder_on_converse[simp]: "preorder_on A (r^-1) = preorder_on A r"
by (simp add:preorder_on_def)

lemma partial_order_on_converse[simp]:
  "partial_order_on A (r^-1) = partial_order_on A r"
by (simp add: partial_order_on_def)

lemma linear_order_on_converse[simp]:
  "linear_order_on A (r^-1) = linear_order_on A r"
by (simp add: linear_order_on_def)


lemma strict_linear_order_on_diff_Id:
  "linear_order_on A r ==> strict_linear_order_on A (r-Id)"
by(simp add: order_on_defs trans_diff_Id)


subsection{* Orders on the field *}

abbreviation "Refl r ≡ refl (Field r) r"

abbreviation "Preorder r ≡ preorder_on (Field r) r"

abbreviation "Partial_order r ≡ partial_order_on (Field r) r"

abbreviation "Total r ≡ total_on (Field r) r"

abbreviation "Linear_order r ≡ linear_order_on (Field r) r"

abbreviation "Well_order r ≡ well_order_on (Field r) r"


lemma subset_Image_Image_iff:
  "[| Preorder r; A ⊆ Field r; B ⊆ Field r|] ==>
   r `` A ⊆ r `` B <-> (∀a∈A.∃b∈B. (b,a):r)"
apply(auto simp add: subset_eq preorder_on_def refl_def Image_def)
apply metis
by(metis trans_def)

lemma subset_Image1_Image1_iff:
  "[| Preorder r; a : Field r; b : Field r|] ==> r `` {a} ⊆ r `` {b} <-> (b,a):r"
by(simp add:subset_Image_Image_iff)

lemma Refl_antisym_eq_Image1_Image1_iff:
  "[|Refl r; antisym r; a:Field r; b:Field r|] ==> r `` {a} = r `` {b} <-> a=b"
by(simp add: expand_set_eq antisym_def refl_def) metis

lemma Partial_order_eq_Image1_Image1_iff:
  "[|Partial_order r; a:Field r; b:Field r|] ==> r `` {a} = r `` {b} <-> a=b"
by(auto simp:order_on_defs Refl_antisym_eq_Image1_Image1_iff)


subsection{* Orders on a type *}

abbreviation "strict_linear_order ≡ strict_linear_order_on UNIV"

abbreviation "linear_order ≡ linear_order_on UNIV"

abbreviation "well_order r ≡ well_order_on UNIV"

end

lemma total_on_empty:

  total_on {} r

lemma refl_on_converse:

  refl A (r^-1) = refl A r

lemma total_on_converse:

  total_on A (r^-1) = total_on A r

lemma irrefl_diff_Id:

  irrefl (r - Id)

lemma trans_diff_Id:

  [| trans r; antisym r |] ==> trans (r - Id)

lemma total_on_diff_Id:

  total_on A (r - Id) = total_on A r

Orders on a set

lemma order_on_defs:

  preorder_on A r == refl A rtrans r
  partial_order_on A r == preorder_on A rantisym r
  linear_order_on A r == partial_order_on A rtotal_on A r
  strict_linear_order_on A r == trans rirrefl rtotal_on A r
  well_order_on A r == linear_order_on A r ∧ wf (r - Id)

lemma preorder_on_empty:

  preorder_on {} {}

lemma partial_order_on_empty:

  partial_order_on {} {}

lemma lnear_order_on_empty:

  linear_order_on {} {}

lemma well_order_on_empty:

  well_order_on {} {}

lemma preorder_on_converse:

  preorder_on A (r^-1) = preorder_on A r

lemma partial_order_on_converse:

  partial_order_on A (r^-1) = partial_order_on A r

lemma linear_order_on_converse:

  linear_order_on A (r^-1) = linear_order_on A r

lemma strict_linear_order_on_diff_Id:

  linear_order_on A r ==> strict_linear_order_on A (r - Id)

Orders on the field

lemma subset_Image_Image_iff:

  [| Preorder r; A  Field r; B  Field r |]
  ==> (r `` A  r `` B) = (∀aA. ∃bB. (b, a) ∈ r)

lemma subset_Image1_Image1_iff:

  [| Preorder r; aField r; bField r |]
  ==> (r `` {a}  r `` {b}) = ((b, a) ∈ r)

lemma Refl_antisym_eq_Image1_Image1_iff:

  [| Refl r; antisym r; aField r; bField r |]
  ==> (r `` {a} = r `` {b}) = (a = b)

lemma Partial_order_eq_Image1_Image1_iff:

  [| Partial_order r; aField r; bField r |]
  ==> (r `` {a} = r `` {b}) = (a = b)

Orders on a type