src/HOL/Order_Relation.thy
changeset 28952 15a4b2cf8c34
parent 27487 c8a6ce181805
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/HOL/Order_Relation.thy	Wed Dec 03 15:58:44 2008 +0100
     1.3 @@ -0,0 +1,131 @@
     1.4 +(*  ID          : $Id$
     1.5 +    Author      : Tobias Nipkow
     1.6 +*)
     1.7 +
     1.8 +header {* Orders as Relations *}
     1.9 +
    1.10 +theory Order_Relation
    1.11 +imports Plain "~~/src/HOL/Hilbert_Choice" "~~/src/HOL/ATP_Linkup"
    1.12 +begin
    1.13 +
    1.14 +text{* This prelude could be moved to theory Relation: *}
    1.15 +
    1.16 +definition "irrefl r \<equiv> \<forall>x. (x,x) \<notin> r"
    1.17 +
    1.18 +definition "total_on A r \<equiv> \<forall>x\<in>A.\<forall>y\<in>A. x\<noteq>y \<longrightarrow> (x,y)\<in>r \<or> (y,x)\<in>r"
    1.19 +
    1.20 +abbreviation "total \<equiv> total_on UNIV"
    1.21 +
    1.22 +
    1.23 +lemma total_on_empty[simp]: "total_on {} r"
    1.24 +by(simp add:total_on_def)
    1.25 +
    1.26 +lemma refl_on_converse[simp]: "refl A (r^-1) = refl A r"
    1.27 +by(auto simp add:refl_def)
    1.28 +
    1.29 +lemma total_on_converse[simp]: "total_on A (r^-1) = total_on A r"
    1.30 +by (auto simp: total_on_def)
    1.31 +
    1.32 +lemma irrefl_diff_Id[simp]: "irrefl(r-Id)"
    1.33 +by(simp add:irrefl_def)
    1.34 +
    1.35 +declare [[simp_depth_limit = 2]]
    1.36 +lemma trans_diff_Id: " trans r \<Longrightarrow> antisym r \<Longrightarrow> trans (r-Id)"
    1.37 +by(simp add: antisym_def trans_def) blast
    1.38 +declare [[simp_depth_limit = 50]]
    1.39 +
    1.40 +lemma total_on_diff_Id[simp]: "total_on A (r-Id) = total_on A r"
    1.41 +by(simp add: total_on_def)
    1.42 +
    1.43 +
    1.44 +subsection{* Orders on a set *}
    1.45 +
    1.46 +definition "preorder_on A r \<equiv> refl A r \<and> trans r"
    1.47 +
    1.48 +definition "partial_order_on A r \<equiv> preorder_on A r \<and> antisym r"
    1.49 +
    1.50 +definition "linear_order_on A r \<equiv> partial_order_on A r \<and> total_on A r"
    1.51 +
    1.52 +definition "strict_linear_order_on A r \<equiv> trans r \<and> irrefl r \<and> total_on A r"
    1.53 +
    1.54 +definition "well_order_on A r \<equiv> linear_order_on A r \<and> wf(r - Id)"
    1.55 +
    1.56 +lemmas order_on_defs =
    1.57 +  preorder_on_def partial_order_on_def linear_order_on_def
    1.58 +  strict_linear_order_on_def well_order_on_def
    1.59 +
    1.60 +
    1.61 +lemma preorder_on_empty[simp]: "preorder_on {} {}"
    1.62 +by(simp add:preorder_on_def trans_def)
    1.63 +
    1.64 +lemma partial_order_on_empty[simp]: "partial_order_on {} {}"
    1.65 +by(simp add:partial_order_on_def)
    1.66 +
    1.67 +lemma lnear_order_on_empty[simp]: "linear_order_on {} {}"
    1.68 +by(simp add:linear_order_on_def)
    1.69 +
    1.70 +lemma well_order_on_empty[simp]: "well_order_on {} {}"
    1.71 +by(simp add:well_order_on_def)
    1.72 +
    1.73 +
    1.74 +lemma preorder_on_converse[simp]: "preorder_on A (r^-1) = preorder_on A r"
    1.75 +by (simp add:preorder_on_def)
    1.76 +
    1.77 +lemma partial_order_on_converse[simp]:
    1.78 +  "partial_order_on A (r^-1) = partial_order_on A r"
    1.79 +by (simp add: partial_order_on_def)
    1.80 +
    1.81 +lemma linear_order_on_converse[simp]:
    1.82 +  "linear_order_on A (r^-1) = linear_order_on A r"
    1.83 +by (simp add: linear_order_on_def)
    1.84 +
    1.85 +
    1.86 +lemma strict_linear_order_on_diff_Id:
    1.87 +  "linear_order_on A r \<Longrightarrow> strict_linear_order_on A (r-Id)"
    1.88 +by(simp add: order_on_defs trans_diff_Id)
    1.89 +
    1.90 +
    1.91 +subsection{* Orders on the field *}
    1.92 +
    1.93 +abbreviation "Refl r \<equiv> refl (Field r) r"
    1.94 +
    1.95 +abbreviation "Preorder r \<equiv> preorder_on (Field r) r"
    1.96 +
    1.97 +abbreviation "Partial_order r \<equiv> partial_order_on (Field r) r"
    1.98 +
    1.99 +abbreviation "Total r \<equiv> total_on (Field r) r"
   1.100 +
   1.101 +abbreviation "Linear_order r \<equiv> linear_order_on (Field r) r"
   1.102 +
   1.103 +abbreviation "Well_order r \<equiv> well_order_on (Field r) r"
   1.104 +
   1.105 +
   1.106 +lemma subset_Image_Image_iff:
   1.107 +  "\<lbrakk> Preorder r; A \<subseteq> Field r; B \<subseteq> Field r\<rbrakk> \<Longrightarrow>
   1.108 +   r `` A \<subseteq> r `` B \<longleftrightarrow> (\<forall>a\<in>A.\<exists>b\<in>B. (b,a):r)"
   1.109 +apply(auto simp add: subset_eq preorder_on_def refl_def Image_def)
   1.110 +apply metis
   1.111 +by(metis trans_def)
   1.112 +
   1.113 +lemma subset_Image1_Image1_iff:
   1.114 +  "\<lbrakk> Preorder r; a : Field r; b : Field r\<rbrakk> \<Longrightarrow> r `` {a} \<subseteq> r `` {b} \<longleftrightarrow> (b,a):r"
   1.115 +by(simp add:subset_Image_Image_iff)
   1.116 +
   1.117 +lemma Refl_antisym_eq_Image1_Image1_iff:
   1.118 +  "\<lbrakk>Refl r; antisym r; a:Field r; b:Field r\<rbrakk> \<Longrightarrow> r `` {a} = r `` {b} \<longleftrightarrow> a=b"
   1.119 +by(simp add: expand_set_eq antisym_def refl_def) metis
   1.120 +
   1.121 +lemma Partial_order_eq_Image1_Image1_iff:
   1.122 +  "\<lbrakk>Partial_order r; a:Field r; b:Field r\<rbrakk> \<Longrightarrow> r `` {a} = r `` {b} \<longleftrightarrow> a=b"
   1.123 +by(auto simp:order_on_defs Refl_antisym_eq_Image1_Image1_iff)
   1.124 +
   1.125 +
   1.126 +subsection{* Orders on a type *}
   1.127 +
   1.128 +abbreviation "strict_linear_order \<equiv> strict_linear_order_on UNIV"
   1.129 +
   1.130 +abbreviation "linear_order \<equiv> linear_order_on UNIV"
   1.131 +
   1.132 +abbreviation "well_order r \<equiv> well_order_on UNIV"
   1.133 +
   1.134 +end