More defns and thms
authornipkow
Mon Mar 17 11:42:46 2008 +0100 (2008-03-17)
changeset 26295afc43168ed85
parent 26294 c5fe289de634
child 26296 988a103afbab
More defns and thms
src/HOL/Library/Order_Relation.thy
src/HOL/Library/Zorn.thy
     1.1 --- a/src/HOL/Library/Order_Relation.thy	Mon Mar 17 07:15:40 2008 +0100
     1.2 +++ b/src/HOL/Library/Order_Relation.thy	Mon Mar 17 11:42:46 2008 +0100
     1.3 @@ -1,7 +1,5 @@
     1.4  (*  ID          : $Id$
     1.5      Author      : Tobias Nipkow
     1.6 -
     1.7 -Orders as relations with implicit base set, their Field
     1.8  *)
     1.9  
    1.10  header {* Orders as Relations *}
    1.11 @@ -10,53 +8,106 @@
    1.12  imports ATP_Linkup Hilbert_Choice
    1.13  begin
    1.14  
    1.15 -definition "Refl r \<equiv> \<forall>x \<in> Field r. (x,x) \<in> r"
    1.16 -definition "Preorder r \<equiv> Refl r \<and> trans r"
    1.17 -definition "Partial_order r \<equiv> Preorder r \<and> antisym r"
    1.18 -definition "Total r \<equiv> \<forall>x\<in>Field r.\<forall>y\<in>Field r. x\<noteq>y \<longrightarrow> (x,y)\<in>r \<or> (y,x)\<in>r"
    1.19 -definition "Linear_order r \<equiv> Partial_order r \<and> Total r"
    1.20 -definition "Well_order r \<equiv> Linear_order r \<and> wf(r - Id)"
    1.21 +(* FIXME to Relation *)
    1.22 +
    1.23 +definition "refl_on A r \<equiv> \<forall>x\<in>A. (x,x) \<in> r"
    1.24 +
    1.25 +definition "irrefl r \<equiv> \<forall>x. (x,x) \<notin> r"
    1.26 +
    1.27 +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.28 +
    1.29 +abbreviation "total \<equiv> total_on UNIV"
    1.30 +
    1.31 +
    1.32 +lemma refl_on_empty[simp]: "refl_on {} r"
    1.33 +by(simp add:refl_on_def)
    1.34 +
    1.35 +lemma total_on_empty[simp]: "total_on {} r"
    1.36 +by(simp add:total_on_def)
    1.37 +
    1.38 +lemma refl_on_converse[simp]: "refl_on A (r^-1) = refl_on A r"
    1.39 +by(simp add:refl_on_def)
    1.40 +
    1.41 +lemma total_on_converse[simp]: "total_on A (r^-1) = total_on A r"
    1.42 +by (auto simp: total_on_def)
    1.43  
    1.44 -lemmas Order_defs =
    1.45 -  Preorder_def Partial_order_def Linear_order_def Well_order_def
    1.46 +lemma irrefl_diff_Id[simp]: "irrefl(r-Id)"
    1.47 +by(simp add:irrefl_def)
    1.48  
    1.49 -lemma Refl_empty[simp]: "Refl {}"
    1.50 -by(simp add:Refl_def)
    1.51 +declare [[simp_depth_limit = 2]]
    1.52 +lemma trans_diff_Id: " trans r \<Longrightarrow> antisym r \<Longrightarrow> trans (r-Id)"
    1.53 +by(simp add: antisym_def trans_def) blast
    1.54 +declare [[simp_depth_limit = 50]]
    1.55 +
    1.56 +lemma total_on_diff_Id[simp]: "total_on A (r-Id) = total_on A r"
    1.57 +by(simp add: total_on_def)
    1.58  
    1.59 -lemma Preorder_empty[simp]: "Preorder {}"
    1.60 -by(simp add:Preorder_def trans_def)
    1.61 +subsection{* Orders on a set *}
    1.62 +
    1.63 +definition "preorder_on A r \<equiv> refl_on A r \<and> trans r"
    1.64 +
    1.65 +definition "partial_order_on A r \<equiv> preorder_on A r \<and> antisym r"
    1.66  
    1.67 -lemma Partial_order_empty[simp]: "Partial_order {}"
    1.68 -by(simp add:Partial_order_def)
    1.69 +definition "linear_order_on A r \<equiv> partial_order_on A r \<and> total_on A r"
    1.70 +
    1.71 +definition "strict_linear_order_on A r \<equiv> trans r \<and> irrefl r \<and> total_on A r"
    1.72 +
    1.73 +definition "well_order_on A r \<equiv> linear_order_on A r \<and> wf(r - Id)"
    1.74  
    1.75 -lemma Total_empty[simp]: "Total {}"
    1.76 -by(simp add:Total_def)
    1.77 +lemmas order_on_defs =
    1.78 +  preorder_on_def partial_order_on_def linear_order_on_def
    1.79 +  strict_linear_order_on_def well_order_on_def
    1.80 +
    1.81  
    1.82 -lemma Linear_order_empty[simp]: "Linear_order {}"
    1.83 -by(simp add:Linear_order_def)
    1.84 +lemma preorder_on_empty[simp]: "preorder_on {} {}"
    1.85 +by(simp add:preorder_on_def trans_def)
    1.86 +
    1.87 +lemma partial_order_on_empty[simp]: "partial_order_on {} {}"
    1.88 +by(simp add:partial_order_on_def)
    1.89  
    1.90 -lemma Well_order_empty[simp]: "Well_order {}"
    1.91 -by(simp add:Well_order_def)
    1.92 +lemma lnear_order_on_empty[simp]: "linear_order_on {} {}"
    1.93 +by(simp add:linear_order_on_def)
    1.94 +
    1.95 +lemma well_order_on_empty[simp]: "well_order_on {} {}"
    1.96 +by(simp add:well_order_on_def)
    1.97 +
    1.98  
    1.99 -lemma Refl_converse[simp]: "Refl(r^-1) = Refl r"
   1.100 -by(simp add:Refl_def)
   1.101 +lemma preorder_on_converse[simp]: "preorder_on A (r^-1) = preorder_on A r"
   1.102 +by (simp add:preorder_on_def)
   1.103 +
   1.104 +lemma partial_order_on_converse[simp]:
   1.105 +  "partial_order_on A (r^-1) = partial_order_on A r"
   1.106 +by (simp add: partial_order_on_def)
   1.107  
   1.108 -lemma Preorder_converse[simp]: "Preorder (r^-1) = Preorder r"
   1.109 -by (simp add:Preorder_def)
   1.110 +lemma linear_order_on_converse[simp]:
   1.111 +  "linear_order_on A (r^-1) = linear_order_on A r"
   1.112 +by (simp add: linear_order_on_def)
   1.113 +
   1.114  
   1.115 -lemma Partial_order_converse[simp]: "Partial_order (r^-1) = Partial_order r"
   1.116 -by (simp add: Partial_order_def)
   1.117 +lemma strict_linear_order_on_diff_Id:
   1.118 +  "linear_order_on A r \<Longrightarrow> strict_linear_order_on A (r-Id)"
   1.119 +by(simp add: order_on_defs trans_diff_Id)
   1.120 +
   1.121 +
   1.122 +subsection{* Orders on the field *}
   1.123  
   1.124 -lemma Total_converse[simp]: "Total (r^-1) = Total r"
   1.125 -by (auto simp: Total_def)
   1.126 +abbreviation "Refl r \<equiv> refl_on (Field r) r"
   1.127 +
   1.128 +abbreviation "Preorder r \<equiv> preorder_on (Field r) r"
   1.129 +
   1.130 +abbreviation "Partial_order r \<equiv> partial_order_on (Field r) r"
   1.131  
   1.132 -lemma Linear_order_converse[simp]: "Linear_order (r^-1) = Linear_order r"
   1.133 -by (simp add: Linear_order_def)
   1.134 +abbreviation "Total r \<equiv> total_on (Field r) r"
   1.135 +
   1.136 +abbreviation "Linear_order r \<equiv> linear_order_on (Field r) r"
   1.137 +
   1.138 +abbreviation "Well_order r \<equiv> well_order_on (Field r) r"
   1.139 +
   1.140  
   1.141  lemma subset_Image_Image_iff:
   1.142    "\<lbrakk> Preorder r; A \<subseteq> Field r; B \<subseteq> Field r\<rbrakk> \<Longrightarrow>
   1.143     r `` A \<subseteq> r `` B \<longleftrightarrow> (\<forall>a\<in>A.\<exists>b\<in>B. (b,a):r)"
   1.144 -apply(auto simp add:subset_def Preorder_def Refl_def Image_def)
   1.145 +apply(auto simp add:subset_def preorder_on_def refl_on_def Image_def)
   1.146  apply metis
   1.147  by(metis trans_def)
   1.148  
   1.149 @@ -66,11 +117,19 @@
   1.150  
   1.151  lemma Refl_antisym_eq_Image1_Image1_iff:
   1.152    "\<lbrakk>Refl r; antisym r; a:Field r; b:Field r\<rbrakk> \<Longrightarrow> r `` {a} = r `` {b} \<longleftrightarrow> a=b"
   1.153 -by(simp add:Preorder_def expand_set_eq Partial_order_def antisym_def Refl_def)
   1.154 -  metis
   1.155 +by(simp add: expand_set_eq antisym_def refl_on_def) metis
   1.156  
   1.157  lemma Partial_order_eq_Image1_Image1_iff:
   1.158    "\<lbrakk>Partial_order r; a:Field r; b:Field r\<rbrakk> \<Longrightarrow> r `` {a} = r `` {b} \<longleftrightarrow> a=b"
   1.159 -by(auto simp:Preorder_def Partial_order_def Refl_antisym_eq_Image1_Image1_iff)
   1.160 +by(auto simp:order_on_defs Refl_antisym_eq_Image1_Image1_iff)
   1.161 +
   1.162 +
   1.163 +subsection{* Orders on a type *}
   1.164 +
   1.165 +abbreviation "strict_linear_order \<equiv> strict_linear_order_on UNIV"
   1.166 +
   1.167 +abbreviation "linear_order \<equiv> linear_order_on UNIV"
   1.168 +
   1.169 +abbreviation "well_order r \<equiv> well_order_on UNIV"
   1.170  
   1.171  end
     2.1 --- a/src/HOL/Library/Zorn.thy	Mon Mar 17 07:15:40 2008 +0100
     2.2 +++ b/src/HOL/Library/Zorn.thy	Mon Mar 17 11:42:46 2008 +0100
     2.3 @@ -279,7 +279,7 @@
     2.4  assumes po: "Partial_order r" and u: "\<forall>C\<in>Chain r. \<exists>u\<in>Field r. \<forall>a\<in>C. (a,u):r"
     2.5  shows "\<exists>m\<in>Field r. \<forall>a\<in>Field r. (m,a):r \<longrightarrow> a=m"
     2.6  proof-
     2.7 -  have "Preorder r" using po by(simp add:Partial_order_def)
     2.8 +  have "Preorder r" using po by(simp add:partial_order_on_def)
     2.9  --{* Mirror r in the set of subsets below (wrt r) elements of A*}
    2.10    let ?B = "%x. r^-1 `` {x}" let ?S = "?B ` Field r"
    2.11    have "\<forall>C \<in> chain ?S. EX U:?S. ALL A:C. A\<subseteq>U"
    2.12 @@ -301,7 +301,7 @@
    2.13        fix a B assume aB: "B:C" "a:B"
    2.14        with 1 obtain x where "x:Field r" "B = r^-1 `` {x}" by auto
    2.15        thus "(a,u) : r" using uA aB `Preorder r`
    2.16 -	by (auto simp add: Preorder_def Refl_def) (metis transD)
    2.17 +	by (auto simp add: preorder_on_def refl_on_def) (metis transD)
    2.18      qed
    2.19      thus "EX u:Field r. ?P u" using `u:Field r` by blast
    2.20    qed
    2.21 @@ -358,18 +358,18 @@
    2.22  lemma chain_subset_Total_Union:
    2.23  assumes "chain\<^bsub>\<subseteq>\<^esub> R" "\<forall>r\<in>R. Total r"
    2.24  shows "Total (\<Union>R)"
    2.25 -proof (simp add: Total_def Ball_def, auto del:disjCI)
    2.26 +proof (simp add: total_on_def Ball_def, auto del:disjCI)
    2.27    fix r s a b assume A: "r:R" "s:R" "a:Field r" "b:Field s" "a\<noteq>b"
    2.28    from `chain\<^bsub>\<subseteq>\<^esub> R` `r:R` `s:R` have "r\<subseteq>s \<or> s\<subseteq>r"
    2.29      by(simp add:chain_subset_def)
    2.30    thus "(\<exists>r\<in>R. (a,b) \<in> r) \<or> (\<exists>r\<in>R. (b,a) \<in> r)"
    2.31    proof
    2.32      assume "r\<subseteq>s" hence "(a,b):s \<or> (b,a):s" using assms(2) A
    2.33 -      by(simp add:Total_def)(metis mono_Field subsetD)
    2.34 +      by(simp add:total_on_def)(metis mono_Field subsetD)
    2.35      thus ?thesis using `s:R` by blast
    2.36    next
    2.37      assume "s\<subseteq>r" hence "(a,b):r \<or> (b,a):r" using assms(2) A
    2.38 -      by(simp add:Total_def)(metis mono_Field subsetD)
    2.39 +      by(simp add:total_on_def)(metis mono_Field subsetD)
    2.40      thus ?thesis using `r:R` by blast
    2.41    qed
    2.42  qed
    2.43 @@ -414,7 +414,7 @@
    2.44      by(simp add:Chain_def I_def) blast
    2.45    have FI: "Field I = ?WO" by(auto simp add:I_def init_seg_of_def Field_def)
    2.46    hence 0: "Partial_order I"
    2.47 -    by(auto simp add: Partial_order_def Preorder_def antisym_def antisym_init_seg_of Refl_def trans_def I_def)(metis trans_init_seg_of)
    2.48 +    by(auto simp: partial_order_on_def preorder_on_def antisym_def antisym_init_seg_of refl_on_def trans_def I_def elim!: trans_init_seg_of)
    2.49  -- {*I-chains have upper bounds in ?WO wrt I: their Union*}
    2.50    { fix R assume "R \<in> Chain I"
    2.51      hence Ris: "R \<in> Chain init_seg_of" using mono_Chain[OF I_init] by blast
    2.52 @@ -422,8 +422,8 @@
    2.53        by(auto simp:init_seg_of_def chain_subset_def Chain_def)
    2.54      have "\<forall>r\<in>R. Refl r" "\<forall>r\<in>R. trans r" "\<forall>r\<in>R. antisym r" "\<forall>r\<in>R. Total r"
    2.55           "\<forall>r\<in>R. wf(r-Id)"
    2.56 -      using Chain_wo[OF `R \<in> Chain I`] by(simp_all add:Order_defs)
    2.57 -    have "Refl (\<Union>R)" using `\<forall>r\<in>R. Refl r` by(auto simp:Refl_def)
    2.58 +      using Chain_wo[OF `R \<in> Chain I`] by(simp_all add:order_on_defs)
    2.59 +    have "Refl (\<Union>R)" using `\<forall>r\<in>R. Refl r` by(auto simp:refl_on_def)
    2.60      moreover have "trans (\<Union>R)"
    2.61        by(rule chain_subset_trans_Union[OF subch `\<forall>r\<in>R. trans r`])
    2.62      moreover have "antisym(\<Union>R)"
    2.63 @@ -436,7 +436,7 @@
    2.64        with `\<forall>r\<in>R. wf(r-Id)` wf_Union_wf_init_segs[OF Chain_inits_DiffI[OF Ris]]
    2.65        show ?thesis by (simp (no_asm_simp)) blast
    2.66      qed
    2.67 -    ultimately have "Well_order (\<Union>R)" by(simp add:Order_defs)
    2.68 +    ultimately have "Well_order (\<Union>R)" by(simp add:order_on_defs)
    2.69      moreover have "\<forall>r \<in> R. r initial_segment_of \<Union>R" using Ris
    2.70        by(simp add: Chain_init_seg_of_Union)
    2.71      ultimately have "\<Union>R : ?WO \<and> (\<forall>r\<in>R. (r,\<Union>R) : I)"
    2.72 @@ -455,26 +455,27 @@
    2.73      proof
    2.74        assume "m={}"
    2.75        moreover have "Well_order {(x,x)}"
    2.76 -	by(simp add:Order_defs Refl_def trans_def antisym_def Total_def Field_def Domain_def Range_def)
    2.77 +	by(simp add:order_on_defs refl_on_def trans_def antisym_def total_on_def Field_def Domain_def Range_def)
    2.78        ultimately show False using max
    2.79  	by (auto simp:I_def init_seg_of_def simp del:Field_insert)
    2.80      qed
    2.81      hence "Field m \<noteq> {}" by(auto simp:Field_def)
    2.82 -    moreover have "wf(m-Id)" using `Well_order m` by(simp add:Well_order_def)
    2.83 +    moreover have "wf(m-Id)" using `Well_order m`
    2.84 +      by(simp add:well_order_on_def)
    2.85  --{*The extension of m by x:*}
    2.86      let ?s = "{(a,x)|a. a : Field m}" let ?m = "insert (x,x) m Un ?s"
    2.87      have Fm: "Field ?m = insert x (Field m)"
    2.88        apply(simp add:Field_insert Field_Un)
    2.89        unfolding Field_def by auto
    2.90      have "Refl m" "trans m" "antisym m" "Total m" "wf(m-Id)"
    2.91 -      using `Well_order m` by(simp_all add:Order_defs)
    2.92 +      using `Well_order m` by(simp_all add:order_on_defs)
    2.93  --{*We show that the extension is a well-order*}
    2.94 -    have "Refl ?m" using `Refl m` Fm by(auto simp:Refl_def)
    2.95 +    have "Refl ?m" using `Refl m` Fm by(auto simp:refl_on_def)
    2.96      moreover have "trans ?m" using `trans m` `x \<notin> Field m`
    2.97        unfolding trans_def Field_def Domain_def Range_def by blast
    2.98      moreover have "antisym ?m" using `antisym m` `x \<notin> Field m`
    2.99        unfolding antisym_def Field_def Domain_def Range_def by blast
   2.100 -    moreover have "Total ?m" using `Total m` Fm by(auto simp: Total_def)
   2.101 +    moreover have "Total ?m" using `Total m` Fm by(auto simp: total_on_def)
   2.102      moreover have "wf(?m-Id)"
   2.103      proof-
   2.104        have "wf ?s" using `x \<notin> Field m`
   2.105 @@ -483,7 +484,7 @@
   2.106  	wf_subset[OF `wf ?s` Diff_subset]
   2.107  	by (fastsimp intro!: wf_Un simp add: Un_Diff Field_def)
   2.108      qed
   2.109 -    ultimately have "Well_order ?m" by(simp add:Order_defs)
   2.110 +    ultimately have "Well_order ?m" by(simp add:order_on_defs)
   2.111  --{*We show that the extension is above m*}
   2.112      moreover hence "(m,?m) : I" using `Well_order m` `x \<notin> Field m`
   2.113        by(fastsimp simp:I_def init_seg_of_def Field_def Domain_def Range_def)
   2.114 @@ -496,24 +497,24 @@
   2.115    ultimately show ?thesis by blast
   2.116  qed
   2.117  
   2.118 -corollary well_ordering_set: "\<exists>r::('a*'a)set. Well_order r \<and> Field r = A"
   2.119 +corollary well_order_on: "\<exists>r::('a*'a)set. well_order_on A r"
   2.120  proof -
   2.121    obtain r::"('a*'a)set" where wo: "Well_order r" and univ: "Field r = UNIV"
   2.122      using well_ordering[where 'a = "'a"] by blast
   2.123    let ?r = "{(x,y). x:A & y:A & (x,y):r}"
   2.124    have 1: "Field ?r = A" using wo univ
   2.125 -    by(fastsimp simp: Field_def Domain_def Range_def Order_defs Refl_def)
   2.126 +    by(fastsimp simp: Field_def Domain_def Range_def order_on_defs refl_on_def)
   2.127    have "Refl r" "trans r" "antisym r" "Total r" "wf(r-Id)"
   2.128 -    using `Well_order r` by(simp_all add:Order_defs)
   2.129 -  have "Refl ?r" using `Refl r` by(auto simp:Refl_def 1 univ)
   2.130 +    using `Well_order r` by(simp_all add:order_on_defs)
   2.131 +  have "Refl ?r" using `Refl r` by(auto simp:refl_on_def 1 univ)
   2.132    moreover have "trans ?r" using `trans r`
   2.133      unfolding trans_def by blast
   2.134    moreover have "antisym ?r" using `antisym r`
   2.135      unfolding antisym_def by blast
   2.136 -  moreover have "Total ?r" using `Total r` by(simp add:Total_def 1 univ)
   2.137 +  moreover have "Total ?r" using `Total r` by(simp add:total_on_def 1 univ)
   2.138    moreover have "wf(?r - Id)" by(rule wf_subset[OF `wf(r-Id)`]) blast
   2.139 -  ultimately have "Well_order ?r" by(simp add:Order_defs)
   2.140 -  with 1 show ?thesis by blast
   2.141 +  ultimately have "Well_order ?r" by(simp add:order_on_defs)
   2.142 +  with 1 show ?thesis by metis
   2.143  qed
   2.144  
   2.145  end