Moved Order_Relation into Library and moved some of it into Relation.
authornipkow
Wed Feb 11 10:51:07 2009 +0100 (2009-02-11)
changeset 2985933bff35f1335
parent 29856 984191be0357
child 29860 f735e4027656
Moved Order_Relation into Library and moved some of it into Relation.
src/HOL/IsaMakefile
src/HOL/Library/Order_Relation.thy
src/HOL/Order_Relation.thy
src/HOL/Relation.thy
     1.1 --- a/src/HOL/IsaMakefile	Tue Feb 10 17:53:51 2009 -0800
     1.2 +++ b/src/HOL/IsaMakefile	Wed Feb 11 10:51:07 2009 +0100
     1.3 @@ -285,7 +285,6 @@
     1.4    Taylor.thy \
     1.5    Transcendental.thy \
     1.6    GCD.thy \
     1.7 -  Order_Relation.thy \
     1.8    Parity.thy \
     1.9    Lubs.thy \
    1.10    Polynomial.thy \
    1.11 @@ -322,7 +321,7 @@
    1.12    Library/Multiset.thy Library/Permutation.thy	\
    1.13    Library/Primes.thy Library/Pocklington.thy Library/Quotient.thy	\
    1.14    Library/Quicksort.thy Library/Nat_Infinity.thy Library/Word.thy	\
    1.15 -  Library/README.html Library/Continuity.thy				\
    1.16 +  Library/README.html Library/Continuity.thy Library/Order_Relation.thy \
    1.17    Library/Nested_Environment.thy Library/Ramsey.thy Library/Zorn.thy	\
    1.18    Library/Library/ROOT.ML Library/Library/document/root.tex		\
    1.19    Library/Library/document/root.bib Library/While_Combinator.thy	\
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/src/HOL/Library/Order_Relation.thy	Wed Feb 11 10:51:07 2009 +0100
     2.3 @@ -0,0 +1,101 @@
     2.4 +(*  ID          : $Id$
     2.5 +    Author      : Tobias Nipkow
     2.6 +*)
     2.7 +
     2.8 +header {* Orders as Relations *}
     2.9 +
    2.10 +theory Order_Relation
    2.11 +imports Main
    2.12 +begin
    2.13 +
    2.14 +subsection{* Orders on a set *}
    2.15 +
    2.16 +definition "preorder_on A r \<equiv> refl A r \<and> trans r"
    2.17 +
    2.18 +definition "partial_order_on A r \<equiv> preorder_on A r \<and> antisym r"
    2.19 +
    2.20 +definition "linear_order_on A r \<equiv> partial_order_on A r \<and> total_on A r"
    2.21 +
    2.22 +definition "strict_linear_order_on A r \<equiv> trans r \<and> irrefl r \<and> total_on A r"
    2.23 +
    2.24 +definition "well_order_on A r \<equiv> linear_order_on A r \<and> wf(r - Id)"
    2.25 +
    2.26 +lemmas order_on_defs =
    2.27 +  preorder_on_def partial_order_on_def linear_order_on_def
    2.28 +  strict_linear_order_on_def well_order_on_def
    2.29 +
    2.30 +
    2.31 +lemma preorder_on_empty[simp]: "preorder_on {} {}"
    2.32 +by(simp add:preorder_on_def trans_def)
    2.33 +
    2.34 +lemma partial_order_on_empty[simp]: "partial_order_on {} {}"
    2.35 +by(simp add:partial_order_on_def)
    2.36 +
    2.37 +lemma lnear_order_on_empty[simp]: "linear_order_on {} {}"
    2.38 +by(simp add:linear_order_on_def)
    2.39 +
    2.40 +lemma well_order_on_empty[simp]: "well_order_on {} {}"
    2.41 +by(simp add:well_order_on_def)
    2.42 +
    2.43 +
    2.44 +lemma preorder_on_converse[simp]: "preorder_on A (r^-1) = preorder_on A r"
    2.45 +by (simp add:preorder_on_def)
    2.46 +
    2.47 +lemma partial_order_on_converse[simp]:
    2.48 +  "partial_order_on A (r^-1) = partial_order_on A r"
    2.49 +by (simp add: partial_order_on_def)
    2.50 +
    2.51 +lemma linear_order_on_converse[simp]:
    2.52 +  "linear_order_on A (r^-1) = linear_order_on A r"
    2.53 +by (simp add: linear_order_on_def)
    2.54 +
    2.55 +
    2.56 +lemma strict_linear_order_on_diff_Id:
    2.57 +  "linear_order_on A r \<Longrightarrow> strict_linear_order_on A (r-Id)"
    2.58 +by(simp add: order_on_defs trans_diff_Id)
    2.59 +
    2.60 +
    2.61 +subsection{* Orders on the field *}
    2.62 +
    2.63 +abbreviation "Refl r \<equiv> refl (Field r) r"
    2.64 +
    2.65 +abbreviation "Preorder r \<equiv> preorder_on (Field r) r"
    2.66 +
    2.67 +abbreviation "Partial_order r \<equiv> partial_order_on (Field r) r"
    2.68 +
    2.69 +abbreviation "Total r \<equiv> total_on (Field r) r"
    2.70 +
    2.71 +abbreviation "Linear_order r \<equiv> linear_order_on (Field r) r"
    2.72 +
    2.73 +abbreviation "Well_order r \<equiv> well_order_on (Field r) r"
    2.74 +
    2.75 +
    2.76 +lemma subset_Image_Image_iff:
    2.77 +  "\<lbrakk> Preorder r; A \<subseteq> Field r; B \<subseteq> Field r\<rbrakk> \<Longrightarrow>
    2.78 +   r `` A \<subseteq> r `` B \<longleftrightarrow> (\<forall>a\<in>A.\<exists>b\<in>B. (b,a):r)"
    2.79 +apply(auto simp add: subset_eq preorder_on_def refl_def Image_def)
    2.80 +apply metis
    2.81 +by(metis trans_def)
    2.82 +
    2.83 +lemma subset_Image1_Image1_iff:
    2.84 +  "\<lbrakk> Preorder r; a : Field r; b : Field r\<rbrakk> \<Longrightarrow> r `` {a} \<subseteq> r `` {b} \<longleftrightarrow> (b,a):r"
    2.85 +by(simp add:subset_Image_Image_iff)
    2.86 +
    2.87 +lemma Refl_antisym_eq_Image1_Image1_iff:
    2.88 +  "\<lbrakk>Refl r; antisym r; a:Field r; b:Field r\<rbrakk> \<Longrightarrow> r `` {a} = r `` {b} \<longleftrightarrow> a=b"
    2.89 +by(simp add: expand_set_eq antisym_def refl_def) metis
    2.90 +
    2.91 +lemma Partial_order_eq_Image1_Image1_iff:
    2.92 +  "\<lbrakk>Partial_order r; a:Field r; b:Field r\<rbrakk> \<Longrightarrow> r `` {a} = r `` {b} \<longleftrightarrow> a=b"
    2.93 +by(auto simp:order_on_defs Refl_antisym_eq_Image1_Image1_iff)
    2.94 +
    2.95 +
    2.96 +subsection{* Orders on a type *}
    2.97 +
    2.98 +abbreviation "strict_linear_order \<equiv> strict_linear_order_on UNIV"
    2.99 +
   2.100 +abbreviation "linear_order \<equiv> linear_order_on UNIV"
   2.101 +
   2.102 +abbreviation "well_order r \<equiv> well_order_on UNIV"
   2.103 +
   2.104 +end
     3.1 --- a/src/HOL/Order_Relation.thy	Tue Feb 10 17:53:51 2009 -0800
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,131 +0,0 @@
     3.4 -(*  ID          : $Id$
     3.5 -    Author      : Tobias Nipkow
     3.6 -*)
     3.7 -
     3.8 -header {* Orders as Relations *}
     3.9 -
    3.10 -theory Order_Relation
    3.11 -imports Plain "~~/src/HOL/Hilbert_Choice" "~~/src/HOL/ATP_Linkup"
    3.12 -begin
    3.13 -
    3.14 -text{* This prelude could be moved to theory Relation: *}
    3.15 -
    3.16 -definition "irrefl r \<equiv> \<forall>x. (x,x) \<notin> r"
    3.17 -
    3.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"
    3.19 -
    3.20 -abbreviation "total \<equiv> total_on UNIV"
    3.21 -
    3.22 -
    3.23 -lemma total_on_empty[simp]: "total_on {} r"
    3.24 -by(simp add:total_on_def)
    3.25 -
    3.26 -lemma refl_on_converse[simp]: "refl A (r^-1) = refl A r"
    3.27 -by(auto simp add:refl_def)
    3.28 -
    3.29 -lemma total_on_converse[simp]: "total_on A (r^-1) = total_on A r"
    3.30 -by (auto simp: total_on_def)
    3.31 -
    3.32 -lemma irrefl_diff_Id[simp]: "irrefl(r-Id)"
    3.33 -by(simp add:irrefl_def)
    3.34 -
    3.35 -declare [[simp_depth_limit = 2]]
    3.36 -lemma trans_diff_Id: " trans r \<Longrightarrow> antisym r \<Longrightarrow> trans (r-Id)"
    3.37 -by(simp add: antisym_def trans_def) blast
    3.38 -declare [[simp_depth_limit = 50]]
    3.39 -
    3.40 -lemma total_on_diff_Id[simp]: "total_on A (r-Id) = total_on A r"
    3.41 -by(simp add: total_on_def)
    3.42 -
    3.43 -
    3.44 -subsection{* Orders on a set *}
    3.45 -
    3.46 -definition "preorder_on A r \<equiv> refl A r \<and> trans r"
    3.47 -
    3.48 -definition "partial_order_on A r \<equiv> preorder_on A r \<and> antisym r"
    3.49 -
    3.50 -definition "linear_order_on A r \<equiv> partial_order_on A r \<and> total_on A r"
    3.51 -
    3.52 -definition "strict_linear_order_on A r \<equiv> trans r \<and> irrefl r \<and> total_on A r"
    3.53 -
    3.54 -definition "well_order_on A r \<equiv> linear_order_on A r \<and> wf(r - Id)"
    3.55 -
    3.56 -lemmas order_on_defs =
    3.57 -  preorder_on_def partial_order_on_def linear_order_on_def
    3.58 -  strict_linear_order_on_def well_order_on_def
    3.59 -
    3.60 -
    3.61 -lemma preorder_on_empty[simp]: "preorder_on {} {}"
    3.62 -by(simp add:preorder_on_def trans_def)
    3.63 -
    3.64 -lemma partial_order_on_empty[simp]: "partial_order_on {} {}"
    3.65 -by(simp add:partial_order_on_def)
    3.66 -
    3.67 -lemma lnear_order_on_empty[simp]: "linear_order_on {} {}"
    3.68 -by(simp add:linear_order_on_def)
    3.69 -
    3.70 -lemma well_order_on_empty[simp]: "well_order_on {} {}"
    3.71 -by(simp add:well_order_on_def)
    3.72 -
    3.73 -
    3.74 -lemma preorder_on_converse[simp]: "preorder_on A (r^-1) = preorder_on A r"
    3.75 -by (simp add:preorder_on_def)
    3.76 -
    3.77 -lemma partial_order_on_converse[simp]:
    3.78 -  "partial_order_on A (r^-1) = partial_order_on A r"
    3.79 -by (simp add: partial_order_on_def)
    3.80 -
    3.81 -lemma linear_order_on_converse[simp]:
    3.82 -  "linear_order_on A (r^-1) = linear_order_on A r"
    3.83 -by (simp add: linear_order_on_def)
    3.84 -
    3.85 -
    3.86 -lemma strict_linear_order_on_diff_Id:
    3.87 -  "linear_order_on A r \<Longrightarrow> strict_linear_order_on A (r-Id)"
    3.88 -by(simp add: order_on_defs trans_diff_Id)
    3.89 -
    3.90 -
    3.91 -subsection{* Orders on the field *}
    3.92 -
    3.93 -abbreviation "Refl r \<equiv> refl (Field r) r"
    3.94 -
    3.95 -abbreviation "Preorder r \<equiv> preorder_on (Field r) r"
    3.96 -
    3.97 -abbreviation "Partial_order r \<equiv> partial_order_on (Field r) r"
    3.98 -
    3.99 -abbreviation "Total r \<equiv> total_on (Field r) r"
   3.100 -
   3.101 -abbreviation "Linear_order r \<equiv> linear_order_on (Field r) r"
   3.102 -
   3.103 -abbreviation "Well_order r \<equiv> well_order_on (Field r) r"
   3.104 -
   3.105 -
   3.106 -lemma subset_Image_Image_iff:
   3.107 -  "\<lbrakk> Preorder r; A \<subseteq> Field r; B \<subseteq> Field r\<rbrakk> \<Longrightarrow>
   3.108 -   r `` A \<subseteq> r `` B \<longleftrightarrow> (\<forall>a\<in>A.\<exists>b\<in>B. (b,a):r)"
   3.109 -apply(auto simp add: subset_eq preorder_on_def refl_def Image_def)
   3.110 -apply metis
   3.111 -by(metis trans_def)
   3.112 -
   3.113 -lemma subset_Image1_Image1_iff:
   3.114 -  "\<lbrakk> Preorder r; a : Field r; b : Field r\<rbrakk> \<Longrightarrow> r `` {a} \<subseteq> r `` {b} \<longleftrightarrow> (b,a):r"
   3.115 -by(simp add:subset_Image_Image_iff)
   3.116 -
   3.117 -lemma Refl_antisym_eq_Image1_Image1_iff:
   3.118 -  "\<lbrakk>Refl r; antisym r; a:Field r; b:Field r\<rbrakk> \<Longrightarrow> r `` {a} = r `` {b} \<longleftrightarrow> a=b"
   3.119 -by(simp add: expand_set_eq antisym_def refl_def) metis
   3.120 -
   3.121 -lemma Partial_order_eq_Image1_Image1_iff:
   3.122 -  "\<lbrakk>Partial_order r; a:Field r; b:Field r\<rbrakk> \<Longrightarrow> r `` {a} = r `` {b} \<longleftrightarrow> a=b"
   3.123 -by(auto simp:order_on_defs Refl_antisym_eq_Image1_Image1_iff)
   3.124 -
   3.125 -
   3.126 -subsection{* Orders on a type *}
   3.127 -
   3.128 -abbreviation "strict_linear_order \<equiv> strict_linear_order_on UNIV"
   3.129 -
   3.130 -abbreviation "linear_order \<equiv> linear_order_on UNIV"
   3.131 -
   3.132 -abbreviation "well_order r \<equiv> well_order_on UNIV"
   3.133 -
   3.134 -end
     4.1 --- a/src/HOL/Relation.thy	Tue Feb 10 17:53:51 2009 -0800
     4.2 +++ b/src/HOL/Relation.thy	Wed Feb 11 10:51:07 2009 +0100
     4.3 @@ -70,6 +70,16 @@
     4.4    "trans r == (ALL x y z. (x,y):r --> (y,z):r --> (x,z):r)"
     4.5  
     4.6  definition
     4.7 +irrefl :: "('a * 'a) set => bool" where
     4.8 +"irrefl r \<equiv> \<forall>x. (x,x) \<notin> r"
     4.9 +
    4.10 +definition
    4.11 +total_on :: "'a set => ('a * 'a) set => bool" where
    4.12 +"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"
    4.13 +
    4.14 +abbreviation "total \<equiv> total_on UNIV"
    4.15 +
    4.16 +definition
    4.17    single_valued :: "('a * 'b) set => bool" where
    4.18    "single_valued r == ALL x y. (x,y):r --> (ALL z. (x,z):r --> y=z)"
    4.19  
    4.20 @@ -268,6 +278,21 @@
    4.21  lemma trans_diag [simp]: "trans (diag A)"
    4.22  by (fast intro: transI elim: transD)
    4.23  
    4.24 +lemma trans_diff_Id: " trans r \<Longrightarrow> antisym r \<Longrightarrow> trans (r-Id)"
    4.25 +unfolding antisym_def trans_def by blast
    4.26 +
    4.27 +subsection {* Irreflexivity *}
    4.28 +
    4.29 +lemma irrefl_diff_Id[simp]: "irrefl(r-Id)"
    4.30 +by(simp add:irrefl_def)
    4.31 +
    4.32 +subsection {* Totality *}
    4.33 +
    4.34 +lemma total_on_empty[simp]: "total_on {} r"
    4.35 +by(simp add:total_on_def)
    4.36 +
    4.37 +lemma total_on_diff_Id[simp]: "total_on A (r-Id) = total_on A r"
    4.38 +by(simp add: total_on_def)
    4.39  
    4.40  subsection {* Converse *}
    4.41  
    4.42 @@ -330,6 +355,9 @@
    4.43  lemma sym_Int_converse: "sym (r \<inter> r^-1)"
    4.44  by (unfold sym_def) blast
    4.45  
    4.46 +lemma total_on_converse[simp]: "total_on A (r^-1) = total_on A r"
    4.47 +by (auto simp: total_on_def)
    4.48 +
    4.49  
    4.50  subsection {* Domain *}
    4.51