src/HOL/Library/Ramsey.thy
changeset 71083 ce92360f0692
parent 69661 a03a63b81f44
child 71259 09aee7f5b447
equal deleted inserted replaced
71060:295609359b58 71083:ce92360f0692
   159   where "part r s Y f \<longleftrightarrow> (\<forall>X. X \<subseteq> Y \<and> finite X \<and> card X = r \<longrightarrow> f X < s)"
   159   where "part r s Y f \<longleftrightarrow> (\<forall>X. X \<subseteq> Y \<and> finite X \<and> card X = r \<longrightarrow> f X < s)"
   160 
   160 
   161 text \<open>For induction, we decrease the value of \<^term>\<open>r\<close> in partitions.\<close>
   161 text \<open>For induction, we decrease the value of \<^term>\<open>r\<close> in partitions.\<close>
   162 lemma part_Suc_imp_part:
   162 lemma part_Suc_imp_part:
   163   "\<lbrakk>infinite Y; part (Suc r) s Y f; y \<in> Y\<rbrakk> \<Longrightarrow> part r s (Y - {y}) (\<lambda>u. f (insert y u))"
   163   "\<lbrakk>infinite Y; part (Suc r) s Y f; y \<in> Y\<rbrakk> \<Longrightarrow> part r s (Y - {y}) (\<lambda>u. f (insert y u))"
   164   apply (simp add: part_def)
   164   by (simp add: part_def subset_Diff_insert)
   165   apply clarify
       
   166   apply (drule_tac x="insert y X" in spec)
       
   167   apply force
       
   168   done
       
   169 
   165 
   170 lemma part_subset: "part r s YY f \<Longrightarrow> Y \<subseteq> YY \<Longrightarrow> part r s Y f"
   166 lemma part_subset: "part r s YY f \<Longrightarrow> Y \<subseteq> YY \<Longrightarrow> part r s Y f"
   171   unfolding part_def by blast
   167   unfolding part_def by blast
   172 
   168 
   173 
   169 
   354   by (simp add: transition_idx_def doubleton_eq_iff conj_disj_distribR cong: conj_cong) (erule LeastI)
   350   by (simp add: transition_idx_def doubleton_eq_iff conj_disj_distribR cong: conj_cong) (erule LeastI)
   355 
   351 
   356 text \<open>To be equal to the union of some well-founded relations is equivalent
   352 text \<open>To be equal to the union of some well-founded relations is equivalent
   357   to being the subset of such a union.\<close>
   353   to being the subset of such a union.\<close>
   358 lemma disj_wf: "disj_wf r \<longleftrightarrow> (\<exists>T. \<exists>n::nat. (\<forall>i<n. wf(T i)) \<and> r \<subseteq> (\<Union>i<n. T i))"
   354 lemma disj_wf: "disj_wf r \<longleftrightarrow> (\<exists>T. \<exists>n::nat. (\<forall>i<n. wf(T i)) \<and> r \<subseteq> (\<Union>i<n. T i))"
   359   apply (auto simp add: disj_wf_def)
   355 proof -
   360   apply (rule_tac x="\<lambda>i. T i Int r" in exI)
   356   have *: "\<And>T n. \<lbrakk>\<forall>i<n. wf (T i); r \<subseteq> \<Union> (T ` {..<n})\<rbrakk>
   361   apply (rule_tac x=n in exI)
   357            \<Longrightarrow> (\<forall>i<n. wf (T i \<inter> r)) \<and> r = (\<Union>i<n. T i \<inter> r)"
   362   apply (force simp add: wf_Int1)
   358     by (force simp add: wf_Int1)
   363   done
   359   show ?thesis
       
   360     unfolding disj_wf_def by auto (metis "*")
       
   361 qed
   364 
   362 
   365 theorem trans_disj_wf_implies_wf:
   363 theorem trans_disj_wf_implies_wf:
   366   assumes "trans r"
   364   assumes "trans r"
   367     and "disj_wf r"
   365     and "disj_wf r"
   368   shows "wf r"
   366   shows "wf r"
   382       with \<open>trans r\<close> show ?case
   380       with \<open>trans r\<close> show ?case
   383         unfolding trans_def by blast
   381         unfolding trans_def by blast
   384     qed
   382     qed
   385     then show ?thesis by (auto simp add: r)
   383     then show ?thesis by (auto simp add: r)
   386   qed
   384   qed
   387   have trless: "i \<noteq> j \<Longrightarrow> transition_idx s T {i, j} < n" for i j
   385   have "i < j \<Longrightarrow> transition_idx s T {i, j} < n" for i j
   388     apply (auto simp add: linorder_neq_iff)
   386     using s_in_T transition_idx_less by blast
   389      apply (blast dest: s_in_T transition_idx_less)
   387   then have trless: "i \<noteq> j \<Longrightarrow> transition_idx s T {i, j} < n" for i j
   390     apply (subst insert_commute)
   388     by (metis doubleton_eq_iff less_linear)
   391     apply (blast dest: s_in_T transition_idx_less)
       
   392     done
       
   393   have "\<exists>K k. K \<subseteq> UNIV \<and> infinite K \<and> k < n \<and>
   389   have "\<exists>K k. K \<subseteq> UNIV \<and> infinite K \<and> k < n \<and>
   394       (\<forall>i\<in>K. \<forall>j\<in>K. i \<noteq> j \<longrightarrow> transition_idx s T {i, j} = k)"
   390       (\<forall>i\<in>K. \<forall>j\<in>K. i \<noteq> j \<longrightarrow> transition_idx s T {i, j} = k)"
   395     by (rule Ramsey2) (auto intro: trless infinite_UNIV_nat)
   391     by (rule Ramsey2) (auto intro: trless infinite_UNIV_nat)
   396   then obtain K and k where infK: "infinite K" and "k < n"
   392   then obtain K and k where infK: "infinite K" and "k < n"
   397     and allk: "\<forall>i\<in>K. \<forall>j\<in>K. i \<noteq> j \<longrightarrow> transition_idx s T {i, j} = k"
   393     and allk: "\<forall>i\<in>K. \<forall>j\<in>K. i \<noteq> j \<longrightarrow> transition_idx s T {i, j} = k"
   405     with ij have k: "k = transition_idx s T {?i, ?j}" by (simp add: allk)
   401     with ij have k: "k = transition_idx s T {?i, ?j}" by (simp add: allk)
   406     from s_in_T [OF ij] obtain k' where "(s ?j, s ?i) \<in> T k'" "k'<n" by blast
   402     from s_in_T [OF ij] obtain k' where "(s ?j, s ?i) \<in> T k'" "k'<n" by blast
   407     then show "(s ?j, s ?i) \<in> T k" by (simp add: k transition_idx_in ij)
   403     then show "(s ?j, s ?i) \<in> T k" by (simp add: k transition_idx_in ij)
   408   qed
   404   qed
   409   then have "\<not> wf (T k)"
   405   then have "\<not> wf (T k)"
   410     unfolding wf_iff_no_infinite_down_chain by fast
   406     by (meson wf_iff_no_infinite_down_chain)
   411   with wfT \<open>k < n\<close> show False by blast
   407   with wfT \<open>k < n\<close> show False by blast
   412 qed
   408 qed
   413 
   409 
   414 end
   410 end