diff --git a/thys/Szemeredi_Regularity/Szemeredi.thy b/thys/Szemeredi_Regularity/Szemeredi.thy --- a/thys/Szemeredi_Regularity/Szemeredi.thy +++ b/thys/Szemeredi_Regularity/Szemeredi.thy @@ -1,1235 +1,1080 @@ section \Szemerédi's Regularity Lemma\ theory Szemeredi imports Complex_Main "HOL-Library.Disjoint_Sets" "Girth_Chromatic.Ugraphs" begin +thm card_vimage_inj +lemma card_vimage_inj_on_le: + assumes "inj_on f D" "finite A" + shows "card (f-`A \ D) \ card A" + by (meson assms card_inj_on_le image_subset_iff_subset_vimage inf_le1 inf_le2 inj_on_subset) + + text\We formalise Szemerédi's Regularity Lemma, which is a major result in the study of large graphs (extremal graph theory). We follow Yufei Zhao's notes ``Graph Theory and Additive Combinatorics'' (MIT) \<^url>\https://ocw.mit.edu/courses/mathematics/18-217-graph-theory-and-additive-combinatorics-fall-2019/lecture-notes/MIT18_217F19_ch3.pdf\ and W.T. Gowers's notes ``Topics in Combinatorics'' (University of Cambridge, Lent 2004, Chapter 3) \<^url>\https://www.dpmms.cam.ac.uk/~par31/notes/tic.pdf\. We also refer to a third source, also by Zhao and also entitled ``Graph Theory and Additive Combinatorics'': \<^url>\https://yufeizhao.com/gtac/gtac17.pdf\.\ subsection \Miscellaneous\ text \A technical lemma used below in @{text \energy_graph_partition_half\}\ lemma sum_products_le: fixes a :: "'a \ 'b::linordered_idom" assumes "\i. i \ I \ a i \ 0" shows "(\i\I. a i * b i)\<^sup>2 \ (\i\I. a i) * (\i\I. a i * (b i)\<^sup>2)" using assms proof (induction I rule: infinite_finite_induct) case (insert j I) then have "(\i\insert j I. a i * b i)\<^sup>2 \ (a j * b j)\<^sup>2 + 2 * a j * b j * (\i\I. a i * b i) + (\i\I. a i) * (\i\I. a i * (b i)\<^sup>2)" using insert by (simp add: algebra_simps power2_eq_square) also have "\ \ a j * (a j * (b j)\<^sup>2) + (a j * (sum a I * (b j)\<^sup>2 + (\i\I. a i * (b i)\<^sup>2)) + sum a I * (\i\I. a i * (b i)\<^sup>2))" proof - have "0 \ (\i\I. a i * (b i - b j)\<^sup>2)" by (simp add: insert.prems sum_nonneg) then have "2 * b j * (\i\I. a i * b i) \ (sum a I * (b j)\<^sup>2) + (\i\I. a i * (b i)\<^sup>2)" by (simp add: power2_eq_square algebra_simps sum_subtractf sum.distrib sum_distrib_left) then show ?thesis by (simp add: insert.prems power2_eq_square mult.commute mult.left_commute mult_left_mono) qed finally show ?case by (simp add: insert algebra_simps) qed auto subsubsection \Partitions indexed by integers\ -definition finite_graph_partition :: "[uvert set, nat \ uvert set, nat] \ bool" - where "finite_graph_partition V P n \ partition_on V (P ` {.. disjoint_family_on P {..Equivalent, simpler characterisation\ -lemma finite_graph_partition_eq: "finite_graph_partition V P n \ partition_on V (P ` {.. inj_on P {.. disjoint_family_on P {.. bool" + where "finite_graph_partition V P n \ partition_on V P \ finite P \ card P = n" lemma finite_graph_partition_0 [iff]: - "finite_graph_partition V P 0 \ V={}" - by (auto simp: finite_graph_partition_eq partition_on_def) + "finite_graph_partition V P 0 \ V = {} \ P = {}" + by (auto simp: finite_graph_partition_def partition_on_def) + +lemma finite_graph_partition_empty [iff]: + "finite_graph_partition {} P n \ P = {} \ n = 0" + by (auto simp: finite_graph_partition_def partition_on_def) lemma finite_graph_partition_equals: - "finite_graph_partition V P n \ (\i (\P) = V" by (meson finite_graph_partition_def partition_on_def) lemma finite_graph_partition_subset: - "\finite_graph_partition V P n; i \ P i \ V" + "\finite_graph_partition V P n; X \ P\ \ X \ V" using finite_graph_partition_equals by blast -lemma finite_graph_partition_nonempty: - "\finite_graph_partition V P n; i \ P i \ {}" - by (metis finite_graph_partition_def image_eqI lessThan_iff partition_on_def) - -lemma trivial_graph_partition: - assumes "finite_graph_partition V P 1" shows "P 0 = V" - using finite_graph_partition_equals [OF assms] by auto - lemma trivial_graph_partition_exists: assumes "V \ {}" - shows "finite_graph_partition V (\i. V) (Suc 0)" - using assms by (simp add: lessThan_Suc finite_graph_partition_eq partition_on_def) + shows "finite_graph_partition V {V} (Suc 0)" + by (simp add: assms finite_graph_partition_def partition_on_space) lemma finite_graph_partition_finite: - assumes "finite_graph_partition V P k" "finite V" "i P" + shows "finite X" + by (meson assms finite_graph_partition_subset infinite_super) lemma finite_graph_partition_le: - assumes "finite_graph_partition V P k" "finite V" "i card V" - by (metis (mono_tags, lifting) UN_I assms card_mono finite_graph_partition_equals lessThan_iff subsetI) + assumes "finite_graph_partition V P k" "finite V" "X \ P" + shows "card X \ card V" + by (meson assms card_mono finite_graph_partition_subset) lemma finite_graph_partition_gt0: - assumes "finite_graph_partition V P k" "finite V" "i 0" - by (metis assms card_gt_0_iff finite_graph_partition_def finite_graph_partition_finite imageI lessThan_iff partition_on_def) + assumes "finite_graph_partition V P k" "finite V" "X \ P" + shows "card X > 0" + by (metis assms card_0_eq finite_graph_partition_def finite_graph_partition_finite gr_zeroI partition_on_def) lemma card_finite_graph_partition: assumes "finite_graph_partition V P k" "finite V" - shows "(\ii = card (\ (P ` {.. = card V" - using assms finite_graph_partition_equals by blast - finally show ?thesis . -qed + shows "(\X\P. card X) = card V" + by (metis assms finite_graph_partition_def finite_graph_partition_finite product_partition) lemma finite_graph_partition_obtain: assumes "finite_graph_partition V P k" "x \ V" - obtains i where "i < k" and "x \ P i" + obtains X where "X \ P" and "x \ X" using assms finite_graph_partition_equals by force -text \Partitions into two parts\ -fun binary_partition :: "['a set, 'a set, nat] \ 'a set" - where "binary_partition A B 0 = A" - | "binary_partition A B (Suc 0) = B-A" - -lemma binary_partition2_eq [simp]: "binary_partition A B ` {..<2} = {A,B-A}" - by (auto simp add: numeral_2_eq_2 lessThan_Suc) - -lemma inj_binary_partition: - "B \ {} \ inj_on (binary_partition A B) {..<2}" - by (auto simp: numeral_2_eq_2 lessThan_Suc) - -lemma disjoint_family_binary_partition: "disjoint_family_on (binary_partition A B) {..<2}" - by (auto simp: numeral_2_eq_2 lessThan_Suc disjoint_family_on_def) - -lemma finite_graph_partition_binary_partition: - assumes "A \ B" "A \ {}" - shows "finite_graph_partition B (binary_partition A B) 2" - unfolding finite_graph_partition_def partition_on_def binary_partition2_eq - using assms - by (force simp add: disjnt_iff pairwise_insert disjoint_family_binary_partition) - subsubsection \Tools to combine the refinements of the partition @{term "P i"} for each @{term i}\ text \These are needed to retain the ``intuitive'' idea of partitions as indexed by integers.\ -lemma less_sum_nat_iff: - fixes b::nat and k::nat - shows "b < (\i (\ji b \ b < (\ii (\!j. j (\i b \ b < (\i nat) \ nat \ nat \ nat" - where "part a k b \ (THE j. j (\i b \ b < (\ii (let j = part a k b in j < k \ (\i < j. a i) \ b \ b < (\i < j. a i) + a j)" - (is "?lhs = ?rhs") -proof - assume ?lhs - then show ?rhs - unfolding less_sum_nat_iff_uniq part_def by (metis (no_types, lifting) theI') -qed (auto simp: less_sum_nat_iff Let_def) - -lemma part_Suc: "part a (Suc k) b = (if sum a {.. b \ b < sum a {..: "\j. \sum a {.. sum a {.. \ j = i" - by (meson \d < a i\ leD le_add1 less_sum_nat_iff nat_add_left_cancel_less not_less_iff_gr_or_eq) - show ?thesis - unfolding part_def - using assms - by (intro the_equality) (auto simp: \
) -qed - -lemma sum_layers_less: - fixes d::nat and k::nat - shows "\i < k; d < a i\ \ sum a {..Edges\ text \All edges between two sets of vertices, @{term X} and @{term Y}, in a graph, @{term G}\ definition all_edges_between :: "nat set \ nat set \ nat set \ nat set set \ (nat \ nat) set" where "all_edges_between X Y G \ {(x,y). x\X \ y\Y \ {x,y} \ uedges G}" lemma all_edges_between_subset: "all_edges_between X Y G \ X\Y" by (auto simp: all_edges_between_def) lemma max_all_edges_between: assumes "finite X" "finite Y" shows "card (all_edges_between X Y G) \ card X * card Y" by (metis assms card_mono finite_SigmaI all_edges_between_subset card_cartesian_product) lemma all_edges_between_empty [simp]: "all_edges_between {} Z G = {}" "all_edges_between Z {} G = {}" by (auto simp: all_edges_between_def) lemma all_edges_between_disjnt1: assumes "disjnt X Y" shows "disjnt (all_edges_between X Z G) (all_edges_between Y Z G)" using assms by (auto simp: all_edges_between_def disjnt_iff) lemma all_edges_between_disjnt2: assumes "disjnt Y Z" shows "disjnt (all_edges_between X Y G) (all_edges_between X Z G)" using assms by (auto simp: all_edges_between_def disjnt_iff) lemma all_edges_between_Un1: "all_edges_between (X \ Y) Z G = all_edges_between X Z G \ all_edges_between Y Z G" by (auto simp: all_edges_between_def) lemma all_edges_between_Un2: "all_edges_between X (Y \ Z) G = all_edges_between X Y G \ all_edges_between X Z G" by (auto simp: all_edges_between_def) lemma finite_all_edges_between: assumes "finite X" "finite Y" shows "finite (all_edges_between X Y G)" by (meson all_edges_between_subset assms finite_cartesian_product finite_subset) subsection \Edge Density and Regular Pairs\ text \The edge density between two sets of vertices, @{term X} and @{term Y}, in @{term G}. Authors disagree on whether the sets are assumed to be disjoint!. Quite a few authors assume disjointness, e.g. Malliaris and Shelah \<^url>\https://www.jstor.org/stable/23813167\ For the following definitions, see pages 49--50 in Zhao's notes.\ definition "edge_density X Y G \ card(all_edges_between X Y G) / (card X * card Y)" lemma edge_density_ge0: "edge_density X Y G \ 0" by (auto simp: edge_density_def) -lemma edge_density_le1: "edge_density X Y G \ 1" -proof (cases "finite X \ finite Y") - case True - then show ?thesis - using of_nat_mono [OF max_all_edges_between, of X Y] - by (fastforce simp add: edge_density_def divide_simps) -qed (auto simp: edge_density_def) +lemma edge_density_le1: + assumes "finite X" "finite Y" + shows "edge_density X Y G \ 1" + using of_nat_mono [OF max_all_edges_between [OF assms]] + by (fastforce simp add: edge_density_def divide_simps) lemma all_edges_between_swap: "all_edges_between X Y G = (\(x,y). (y,x)) ` (all_edges_between Y X G)" unfolding all_edges_between_def by (auto simp add: insert_commute image_iff split: prod.split) lemma card_all_edges_between_commute: "card (all_edges_between X Y G) = card (all_edges_between Y X G)" proof - have "inj_on (\(x, y). (y, x)) A" for A :: "(nat*nat)set" by (auto simp: inj_on_def) then show ?thesis by (simp add: all_edges_between_swap [of X Y] card_image) qed lemma edge_density_commute: "edge_density X Y G = edge_density Y X G" by (simp add: edge_density_def card_all_edges_between_commute mult.commute) text \$\epsilon$-regular pairs, for two sets of vertices. Again, authors disagree on whether the sets need to be disjoint, though it seems that overlapping sets cause double-counting. Authors also disagree about whether or not to use the strict subset relation here. The proofs below are easier if it is strict but later proofs require the non-strict version. The two definitions can be proved to be equivalent under fairly mild conditions, but even those conditions turn out to be onerous.\ definition regular_pair:: "uvert set \ uvert set \ ugraph \ real \ bool" where "regular_pair X Y G \ \ \A B. A \ X \ B \ Y \ (card A \ \ * card X) \ (card B \ \ * card Y) \ \edge_density A B G - edge_density X Y G\ \ \" for \::real lemma regular_pair_commute: "regular_pair X Y G \ \ regular_pair Y X G \" by (metis edge_density_commute regular_pair_def) abbreviation "irregular_pair X Y G \ \ \ regular_pair X Y G \" lemma irregular_pair_E: fixes \::real assumes "irregular_pair X Y G \" obtains A B where "A \ X \ B \ Y \ (card A \ \ * card X) \ (card B \ \ * card Y)" "\edge_density A B G - edge_density X Y G\ > \" using assms by (auto simp: not_le regular_pair_def) lemma irregular_pair_I: fixes \::real assumes "A \ X" "B \ Y" "(card A \ \ * card X)" "(card B \ \ * card Y)" "\edge_density A B G - edge_density X Y G\ > \" shows "irregular_pair X Y G \" using assms by (auto simp: not_le regular_pair_def) lemma edge_density_Un: assumes "disjnt X1 X2" "finite X1" "finite X2" "finite Y" shows "edge_density (X1 \ X2) Y G = (edge_density X1 Y G * card X1 + edge_density X2 Y G * card X2) / (card X1 + card X2)" using assms unfolding edge_density_def by (simp add: all_edges_between_disjnt1 all_edges_between_Un1 finite_all_edges_between card_Un_disjnt divide_simps) lemma edge_density_partition: - assumes U: "finite_graph_partition U P n" "finite U" and "finite W" - shows "edge_density U W G = (\ii (P ` {.. (P ` {.. (P ` {..ii (\i \ (P ` {.. = (edge_density (P n) W G * card (P n) - + edge_density (\ (P ` {.. (P ` {.. (P ` {.. (P ` {..finite W\ finU in auto) - also have "\ = (edge_density (P n) W G * card (P n) - + edge_density (\ (P ` {..ii = (\iiX\P. edge_density X W G * card X) / card U" +proof - + have "finite P" + using assms finite_graph_partition_def by blast + then show ?thesis + using U + proof (induction P arbitrary: n U) + case empty + then show ?case + by (simp add: edge_density_def finite_graph_partition_def partition_on_def) + next + case (insert X P) + then have "n > 0" + by (metis finite_graph_partition_0 gr_zeroI insert_not_empty) + with insert.prems insert.hyps + have UX: "finite_graph_partition (U-X) P (n-1)" + by (auto simp: finite_graph_partition_def partition_on_def disjnt_iff pairwise_insert) + then have finU: "finite (\P)" + using finite_graph_partition_equals insert by auto + then have sumXP: "card U = card X + card (\P)" + by (metis UX card_finite_graph_partition finite_graph_partition_equals insert.hyps insert.prems sum.insert) + have FUX: "finite (U - X)" + by (simp add: insert.prems) + have XUP: "X \ (\P) = U" + using finite_graph_partition_equals insert.prems(2) by auto + then have "edge_density U W G = edge_density (X \ \P) W G" + by auto + also have "\ = (edge_density X W G * card X + edge_density (\P) W G * card (\P)) + / (card X + card (\P))" + proof (rule edge_density_Un) + show "disjnt X (\P)" + using UX disjnt_iff finite_graph_partition_equals by auto + show "finite X" + using XUP \finite U\ by blast + qed (use \finite W\ finU in auto) + also have "\ = (edge_density X W G * card X + edge_density (U-X) W G * card (\P)) + / card U" + using UX card_finite_graph_partition finite_graph_partition_equals insert.prems(1) insert.prems(2) sumXP by auto + also have "\ = (\Y \ insert X P. edge_density Y W G * card Y) / card U" + using UX insert.prems insert.hyps + apply (simp add: insert.IH [OF FUX UX] divide_simps algebra_simps finite_graph_partition_equals) + by (metis (no_types, lifting) Diff_eq_empty_iff finite_graph_partition_empty sum.empty) + finally show ?case . + qed qed text\Let @{term P}, @{term Q} be partitions of a set of vertices @{term V}. Then @{term P} refines @{term Q} if for all @{term \A \ P\} there is @{term \B \ Q\} such that @{term \A \ B\}.\ -definition finite_graph_refines :: "[uvert set, nat \ uvert set, nat, nat \ uvert set, nat] \ bool" - where "finite_graph_refines V P n Q m \ - finite_graph_partition V P n \ finite_graph_partition V Q m \ (\ij Q j)" - text \For the sake of generality, and following Zhao's Online Lecture \<^url>\https://www.youtube.com/watch?v=vcsxCFSLyP8&t=16s\ we do not impose disjointness: we do not include @{term "i\j"} below.\ -definition irregular_set:: "[real, ugraph, nat \ uvert set, nat] \ (nat\nat) set" - where "irregular_set \ \\::real. \G P k. {(i,j)|i j. i j irregular_pair (P i) (P j) G \}" +definition irregular_set:: "[real, ugraph, uvert set set] \ (uvert set \ uvert set) set" + where "irregular_set \ \\::real. \G P. {(R,S)|R S. R\P \ S\P \ irregular_pair R S G \}" text\A regular partition may contain a few irregular pairs as long as their total size is bounded as follows.\ -definition regular_partition:: "[real, ugraph, nat \ uvert set, nat] \ bool" +definition regular_partition:: "[real, ugraph, uvert set set] \ bool" where - "regular_partition \ \\::real. \G P k. - finite_graph_partition (uverts G) P k \ - (\(i,j) \ irregular_set \ G P k. card (P i) * card (P j)) \ \ * (card (uverts G))\<^sup>2" + "regular_partition \ \\::real. \G P . + partition_on (uverts G) P \ + (\(R,S) \ irregular_set \ G P. card R * card S) \ \ * (card (uverts G))\<^sup>2" -lemma irregular_set_subset: "irregular_set \ G P k \ {.. {.. G P \ P \ P" by (auto simp: irregular_set_def) -lemma irregular_set_swap: "(i,j) \ irregular_set \ G P k \ (j,i) \ irregular_set \ G P k" +lemma irregular_set_swap: "(i,j) \ irregular_set \ G P \ (j,i) \ irregular_set \ G P" by (auto simp add: irregular_set_def regular_pair_commute) -lemma finite_graph_refines_refines: - assumes "finite_graph_refines V Y n X m" - shows "refines V (Y ` {.. G P k)" -proof - - have "irregular_set \ G P k \ {0.. {0.. finite (irregular_set \ G P)" + by (metis finite_SigmaI finite_subset irregular_set_subset) subsection \Energy of a Graph\ text \Definition 3.7 (Energy), written @{term "q(\,\)"}\ definition energy_graph_subsets:: "[uvert set, uvert set, ugraph] \ real" where "energy_graph_subsets \ \ G \ card \ * card \ * (edge_density \ \ G)\<^sup>2 / (card (uverts G))\<^sup>2" text \Definition for partitions\ definition energy_graph_partitions_subsets - :: "[ugraph, nat \ uvert set, nat, nat \ uvert set, nat] \ real" - where "energy_graph_partitions_subsets G U k W l \ - \ij real" + where "energy_graph_partitions_subsets G U W \ + \R\U.\S\W. energy_graph_subsets R S G" -lemma energy_graph_subsets_0 [simp]: "energy_graph_subsets {} B G = 0" "energy_graph_subsets A {} G = 0" +lemma energy_graph_subsets_0 [simp]: + "energy_graph_subsets {} B G = 0" "energy_graph_subsets A {} G = 0" by (auto simp: energy_graph_subsets_def) lemma energy_graph_subsets_ge0 [simp]: "energy_graph_subsets \ \ G \ 0" by (auto simp: energy_graph_subsets_def) lemma energy_graph_partitions_subsets_ge0 [simp]: - "energy_graph_partitions_subsets G U k W l \ 0" + "energy_graph_partitions_subsets G U W \ 0" by (auto simp: sum_nonneg energy_graph_partitions_subsets_def) lemma energy_graph_subsets_commute: "energy_graph_subsets \ \ G = energy_graph_subsets \ \ G" by (simp add: energy_graph_subsets_def edge_density_commute) lemma energy_graph_partitions_subsets_commute: - "energy_graph_partitions_subsets G W l U k = energy_graph_partitions_subsets G U k W l" - by (simp add: energy_graph_partitions_subsets_def energy_graph_subsets_commute sum.swap [where A="{..Definition 3.7 (Energy of a Partition), or following Gowers, mean square density: a version of energy for a single partition of the vertex set. \ -abbreviation mean_square_density :: "[ugraph, nat \ uvert set, nat] \ real" - where "mean_square_density G U k \ energy_graph_partitions_subsets G U k U k" +abbreviation mean_square_density :: "[ugraph, uvert set set] \ real" + where "mean_square_density G U \ energy_graph_partitions_subsets G U U" lemma mean_square_density: - "mean_square_density G U k \ - (\ij2) - / (card (uverts G))\<^sup>2" + "mean_square_density G U \ + (\R\U. \S\U. card R * card S * (edge_density R S G)\<^sup>2) / (card (uverts G))\<^sup>2" by (simp add: energy_graph_partitions_subsets_def energy_graph_subsets_def sum_divide_distrib) text\Observation: the energy is between 0 and 1 because the edge density is bounded above by 1.\ lemma sum_partition_le: assumes "finite_graph_partition V P k" "finite V" - shows "(\ij (real(card V))\<^sup>2" - using assms -proof (induction k arbitrary: V) - case (Suc k) - then have [simp]: "V \ P k = P k" - using finite_graph_partition_equals by fastforce - have [simp]: "finite (P i)" if "i\k" for i - using Suc.prems finite_graph_partition_finite that by force - have C: "card (P i) \ card V" if "i\k" for i - using Suc.prems finite_graph_partition_le le_imp_less_Suc that by presburger - have D [simp]: "(\j (P ` {..ij (real (card (V - P k)))\<^sup>2" - by (simp add: finite_graph_partition_def lessThan_Suc partition_on_insert disjoint_family_on_insert comm_monoid_add_class.sum.distrib) - have "(\ijij \ real (card (P k) * card (P k)) + - 2 * (card V - card (P k)) * card (P k) + (real (card (V - P k)))\<^sup>2" - using * by linarith - also have "\ \ (real (card V))\<^sup>2" - by (simp add: of_nat_diff C card_Diff_subset_Int algebra_simps power2_eq_square) - finally show ?case . -qed auto + shows "(\R\P. \S\P. real (card R * card S)) \ (real(card V))\<^sup>2" +proof - + have "finite P" + using assms finite_graph_partition_def by blast + then show ?thesis + using assms + proof (induction P arbitrary: V k) + case (insert X P) + have [simp]: "finite Y" if "Y \ insert X P" for Y + by (meson finite_graph_partition_finite insert.prems that) + have C: "card Y \ card V" if"Y \ insert X P" for Y + by (meson finite_graph_partition_le insert.prems that) + have D [simp]: "(\Y\P. real (card Y)) = real (card V) - real (card X)" + by (smt (verit) card_finite_graph_partition insert.hyps insert.prems of_nat_sum sum.cong sum.insert) + have "disjnt X (\P)" + using insert.prems insert.hyps + by (auto simp add: finite_graph_partition_def disjnt_iff pairwise_insert partition_on_def) + with insert have *: "(\R\P. \S\P. real (card R * card S)) \ (real (card (V - X)))\<^sup>2" + unfolding finite_graph_partition_def + by (simp add: lessThan_Suc partition_on_insert disjoint_family_on_insert sum.distrib) + have [simp]: "V \X = X" + using finite_graph_partition_equals insert.prems by blast + have "(\R \ insert X P. \S \ insert X P. real (card R * card S)) + = real (card X * card X) + 2 * (card V - card X) * card X + + (\R\P. \S\P. real (card R * card S))" + using \X \ P\ \finite P\ + by (simp add: C of_nat_diff sum.distrib algebra_simps flip: sum_distrib_right) + also have "\ \ real (card X * card X) + 2 * (card V - card X) * card X + (real (card (V - X)))\<^sup>2" + using * by linarith + also have "\ \ (real (card V))\<^sup>2" + by (simp add: of_nat_diff C card_Diff_subset_Int algebra_simps power2_eq_square) + finally show ?case . + qed auto +qed lemma mean_square_density_bounded: assumes "finite_graph_partition (uverts G) P k" "finite (uverts G)" - shows "mean_square_density G P k \ 1" + shows "mean_square_density G P \ 1" proof- - have \
: "edge_density (P i) (P j) G \ 1" for i j + have \
: "edge_density R S G \ 1" for R S using assms of_nat_mono [OF max_all_edges_between] - by (smt (verit, best) card.infinite divide_eq_0_iff edge_density_def edge_density_le1 mult_eq_0_iff of_nat_0) - have "(\ij2) - \ (\ijR\P. \S\P. real (card R * card S) * (edge_density R S G)\<^sup>2) + \ (\R\P. \S\P. real (card R * card S))" by (intro sum_mono mult_right_le_one_le) (auto simp: abs_square_le_1 edge_density_ge0 \
) also have "\ \ (real(card (uverts G)))\<^sup>2" - using sum_partition_le using assms by presburger + using sum_partition_le assms by blast finally show ?thesis by (simp add: mean_square_density divide_simps) qed subsection \Partitioning and Energy\ text\Zhao's Lemma 3.8 and Gowers's remark after Lemma 11. Further partitioning of subsets of the vertex set cannot make the energy decrease. We follow Gowers's proof, which avoids the use of probability.\ lemma energy_graph_partition_half: assumes fin: "finite \" "finite \" and U: "finite_graph_partition \ U n" - shows "card \ * (edge_density \ \ G)\<^sup>2 \ (\i G)\<^sup>2)" + shows "card \ * (edge_density \ \ G)\<^sup>2 \ (\R\U. card R * (edge_density R \ G)\<^sup>2)" proof - - have "card \ * (edge_density \ \ G)\<^sup>2 = (\i \ G)\<^sup>2)" + have \
: "(\R\U. card R * edge_density R \ G)\<^sup>2 + \ (sum card U) * (\R\U. card R * (edge_density R \ G)\<^sup>2)" + by (simp add: sum_products_le) + have "card \ * (edge_density \ \ G)\<^sup>2 = (\R\U. card R * (edge_density \ \ G)\<^sup>2)" by (metis \finite \\ U sum_distrib_right card_finite_graph_partition of_nat_sum) - also have "\ = edge_density \ \ G * (\i \ G * card (U i))" + also have "\ = edge_density \ \ G * (\R\U. edge_density \ \ G * card R)" by (simp add: sum_distrib_left power2_eq_square mult_ac) - also have "\ = (\i G * real (card (U i))) * edge_density \ \ G" + also have "\ = (\R\U. edge_density R \ G * real (card R)) * edge_density \ \ G" proof - - have "edge_density \ \ G * (\n G * card (U n)) - = edge_density \ \ G * (edge_density \ \ G * (\n \ G * (\R\U. edge_density R \ G * card R) + = edge_density \ \ G * (edge_density \ \ G * (\R\U. card R))" + using assms card_finite_graph_partition by (auto simp: edge_density_partition [OF _ U]) then show ?thesis by (simp add: mult.commute sum_distrib_left) qed - also have "\ = (\i G) * edge_density \ \ G" + also have "\ = (\R\U. card R * edge_density R \ G) * edge_density \ \ G" by (simp add: sum_distrib_left mult_ac) - also have "\ = (\i G)\<^sup>2 / (\i \ (\i G)\<^sup>2)" - apply (clarsimp simp add: mult_ac divide_simps simp flip: of_nat_sum) - by (simp add: sum_products_le) + also have "\ = (\R\U. card R * edge_density R \ G)\<^sup>2 / card \" + using assms + by (simp add: edge_density_partition [OF _ U] mult_ac flip: power2_eq_square) + also have "\ \ (\R\U. card R * (edge_density R \ G)\<^sup>2)" + using \
U card_finite_graph_partition fin by (force simp add: mult_ac divide_simps simp flip: of_nat_sum) finally show ?thesis . qed proposition energy_graph_partition_increase: assumes fin: "finite \" "finite \" and U: "finite_graph_partition \ U k" and V: "finite_graph_partition \ W l" - shows "energy_graph_partitions_subsets G U k W l \ energy_graph_subsets \ \ G" + shows "energy_graph_partitions_subsets G U W \ energy_graph_subsets \ \ G" proof - have "(card \ * card \) * (edge_density \ \ G)\<^sup>2 = card \ * (card \ * (edge_density \ \ G)\<^sup>2)" using fin by (simp add: mult_ac) - also have "\ \ card \ * (\i G)\<^sup>2)" + also have "\ \ card \ * (\R\U. card R * (edge_density R \ G)\<^sup>2)" by (intro mult_left_mono energy_graph_partition_half fin) (use assms in auto) - also have "\ = (\i * (edge_density \ (U i) G)\<^sup>2))" + also have "\ = (\R\U. card R * (card \ * (edge_density \ R G)\<^sup>2))" by (simp add: sum_distrib_left edge_density_commute mult_ac) - also have "\ \ (\ij2))" + also have "\ \ (\R\U. card R * (\S\W. card S * (edge_density S R G)\<^sup>2))" proof (intro mult_left_mono energy_graph_partition_half sum_mono fin) - show "finite (U i)" if "i \ {.. U" for R using that U fin finite_graph_partition_finite by blast qed (use assms in auto) - also have "\ \ (\ij2)" + also have "\ \ (\R\U. \S\W. (card R * card S) * (edge_density R S G)\<^sup>2)" by (simp add: sum_distrib_left edge_density_commute mult_ac) finally have "(card \ * card \) * (edge_density \ \ G)\<^sup>2 - \ (\ij2)" . + \ (\R\U. \S\W. (card R * card S) * (edge_density R S G)\<^sup>2)" . then show ?thesis unfolding energy_graph_partitions_subsets_def energy_graph_subsets_def by (simp add: divide_simps flip: sum_divide_distrib) qed -lemma partition_imp_finite_graph_partition: - "\partition_on A P; finite P\ \ finite_graph_partition A (from_nat_into P) (card P)" - by (metis bij_betw_def bij_betw_from_nat_into_finite finite_graph_partition_eq) - text \The following is the fully general version of Gowers's Lemma 11 and Zhao's Lemma 3.9. Further partitioning of subsets of the vertex set cannot make the energy decrease. Note that @{term V} should be @{term "uverts G"} even though this more general version holds.\ lemma energy_graph_partitions_subsets_increase_half: - assumes ref: "finite_graph_refines V Y n X m" and "finite V" - and finU: "\i. i < k \ card (U i) > 0" - shows "energy_graph_partitions_subsets G X m U k \ energy_graph_partitions_subsets G Y n U k" + assumes ref: "refines V Y X" and "finite V" and part_VX: "partition_on V X" + and U: "{} \ U" "finite (\U)" + shows "energy_graph_partitions_subsets G X U \ energy_graph_partitions_subsets G Y U" (is "?lhs \ ?rhs") proof - - have "\F. partition_on (X i) F \ F = Y ` {j. j Y j \ X i}" if "ii. i partition_on (X i) (F i) \ F i = Y ` {j. j Y j \ X i}" + have "\F. partition_on R F \ F = {S\Y. S \ R}" if "R\X" for R + using ref refines_obtains_subset that by blast + then obtain F where F: "\R. R \ X \ partition_on R (F R) \ F R = {S\Y. S \ R}" by fastforce - have finite_X: "finite (X i)" if "ifinite V\ finite_graph_partition_finite finite_graph_refines_def ref that by auto - have finite_F: "finite (F i)" if "i X" for R + by (metis Union_upper assms(2) part_VX finite_subset partition_on_def that) + then have finite_F: "finite (F R)" if "R \ X" for R using that by (simp add: F) - have Fi_eq: "F i = from_nat_into (F i) ` {.. {}" if "iiU\F i. f U) = (\i real" + have dFX: "disjoint (F ` X)" + using part_VX unfolding finite_graph_partition_def partition_def + by (smt (verit, best) F Int_subset_iff Union_upper disjnt_iff disjointD pairwise_imageI partition_on_def subset_empty) + have F_ne: "F R \ {}" if "R \ X" for R + by (metis F Sup_empty part_VX partition_on_def that) + have F_sums_Y: "(\R\X. \U\F R. f U) = (\S\Y. f S)" for f :: "nat set \ real" proof - - have Yn_eq: "Y ` {..ii. {Y i}) {..ii = (sum \ sum) f (F ` {.. = (\iU\F i. f U)" + have Yn_eq: "Y = (\R \ X. F R)" + using ref by (force simp add: refines_def dest: F) + then have "(\S\Y. f S) = sum f (\R \ X. F R)" + by blast + also have "\ = (sum \ sum) f (F ` X)" + by (smt (verit, best) dFX disjnt_def finite_F image_iff pairwiseD sum.Union_disjoint) + also have "\ = (\R \ X. \U\F R. f U)" unfolding comp_apply by (metis injF sum.reindex_cong) finally show ?thesis by simp qed - have "?lhs = (\ijR \ X. \T\U. energy_graph_subsets R T G)" by (simp add: energy_graph_partitions_subsets_def) - also have "\ \ (\ijx. U j) 1)" + also have "\ \ (\R\X. \T\U. energy_graph_partitions_subsets G (F R) {T})" proof - - have "finite_graph_partition (X i) (from_nat_into (F i)) (card (F i))" - if "i < m" "j < k" for i j - using partition_imp_finite_graph_partition that F by fastforce - moreover have "finite_graph_partition (U j) (\x. U j) (Suc 0)" - if "i < m" "j < k" for i j - using that by (metis card.empty finU less_not_refl trivial_graph_partition_exists) + have "finite_graph_partition R (F R) (card (F R))" + if "R \ X" for R + by (meson F finite_F finite_graph_partition_def that) + moreover have "finite_graph_partition T {T} (Suc 0)" + if "T \ U" for T + using U by (metis that trivial_graph_partition_exists) + moreover have "finite T" if "T \ U" for T + using U by (meson Sup_upper infinite_super that) ultimately show ?thesis - by (intro sum_mono energy_graph_partition_increase; simp add: finU card_ge_0_finite finite_X) + using finite_X by (intro sum_mono energy_graph_partition_increase) auto qed - also have "\ = (\irj = (\iv\F i. \j = (\R \ X. \D \ F R. \T\U. energy_graph_subsets D T G)" + by (simp add: energy_graph_partitions_subsets_def sum.swap [where B = "U"]) also have "\ = ?rhs" by (simp add: energy_graph_partitions_subsets_def F_sums_Y) finally show ?thesis . qed proposition energy_graph_partitions_subsets_increase: - assumes refX: "finite_graph_refines V Y n X m" and refU: "finite_graph_refines V' W l U k" - and "finite V" "finite V'" - shows "energy_graph_partitions_subsets G X m U k \ energy_graph_partitions_subsets G Y n W l" + assumes refX: "refines V Y X" and refU: "refines V' W U" + and "finite V" "finite V'" + shows "energy_graph_partitions_subsets G X U \ energy_graph_partitions_subsets G Y W" (is "?lhs \ ?rhs") proof - - have finU: "\i. i < k \ card (U i) > 0" and finY: "\i. i < n \ card (Y i) > 0" - using finite_graph_partition_gt0 finite_graph_refines_def assms by auto - have "?lhs \ energy_graph_partitions_subsets G Y n U k" - using assms energy_graph_partitions_subsets_increase_half finU refX by blast - also have "\ = energy_graph_partitions_subsets G U k Y n" + obtain U: "finite (\U)" "{} \ U" + using assms unfolding refines_def partition_on_def by presburger + obtain Y: "finite (\Y)" "{} \ Y" + using assms unfolding refines_def partition_on_def by presburger + have "?lhs \ energy_graph_partitions_subsets G Y U" + using assms energy_graph_partitions_subsets_increase_half U assms + using refines_def by blast + also have "\ = energy_graph_partitions_subsets G U Y" by (meson energy_graph_partitions_subsets_commute) - also have "\ \ energy_graph_partitions_subsets G W l Y n" - using assms energy_graph_partitions_subsets_increase_half finY refU by blast + also have "\ \ energy_graph_partitions_subsets G W Y" + using Y \finite V'\ energy_graph_partitions_subsets_increase_half refU refines_def by blast also have "\ = ?rhs" by (simp add: energy_graph_partitions_subsets_commute) finally show ?thesis . qed text \The original version of Gowers's Lemma 11 and Zhao's Lemma 3.9 is not general enough to be used for anything.\ corollary mean_square_density_increase: - assumes "finite_graph_refines V Y n X m" "finite V" - shows "mean_square_density G X m \ mean_square_density G Y n" + assumes "refines V Y X" "finite V" + shows "mean_square_density G X \ mean_square_density G Y" using assms energy_graph_partitions_subsets_increase by presburger text\The Energy Boost Lemma (Lemma 3.10 in Zhao's notes) says that an irregular partition increases the energy substantially. We assume that @{term "\ \ uverts G"} and @{term "\ \ uverts G"} are not irregular, as witnessed by their subsets @{term"U1 \ \"} and @{term"W1 \ \"}. The proof follows Lemma 12 of Gowers. \ -definition "bla X Y \ if X \ Y then {X,Y-X} else {Y}" - -lemma card_bla: "card (bla X Y) \ 2" - by (simp add: bla_def card_insert_if) - -lemma sum_bla: "\X \ Y; f{} = 0\ \ sum f (bla X Y) = f X + f (Y-X)" - by (force simp add: bla_def sum.insert_if) - -definition bla_partition :: "['a set, 'a set, nat] \ 'a set" - where "bla_partition A B \ if A \ B then binary_partition A B else (\i. A)" - -definition "bla_idx A B \ if A \ B then 2 else Suc 0" - -lemma bla_partition2_eq [simp]: - "bla_partition A B ` {.. B then {A,B-A} else {A})" - by (auto simp add: bla_partition_def bla_idx_def) +definition "P2 X Y \ if X \ Y then {X,Y-X} else {Y}" -lemma inj_bla_partition: - "B \ {} \ inj_on (bla_partition A B) {.. 2" + by (simp add: P2_def card_insert_if) -lemma finite_graph_partition_bla_partition: +lemma sum_P2: "\X \ Y; f{} = 0\ \ sum f (P2 X Y) = f X + f (Y-X)" + by (force simp add: P2_def sum.insert_if) + +lemma partition_P2: assumes "A \ B" "A \ {}" - shows "finite_graph_partition B (bla_partition A B) (bla_idx A B)" - using assms trivial_graph_partition_exists - by (auto simp add: bla_idx_def bla_partition_def finite_graph_partition_binary_partition) - -lemma bla_sum_expand: "A\B \ (\U\bla A B. f U) = (\i::real and \ \ G defines "alpha \ edge_density \ \ G" defines "u \ \X Y. edge_density X Y G - alpha" assumes "finite \" "finite \" and "U1 \ \" "W1 \ \" "\ > 0" and U1: "card U1 \ \ * card \" and W1: "card W1 \ \ * card \" and gt: "\u U1 W1\ > \" - shows "(\A \ bla U1 \. \B \ bla W1 \. energy_graph_subsets A B G) + shows "(\A \ P2 U1 \. \B \ P2 W1 \. energy_graph_subsets A B G) \ energy_graph_subsets \ \ G + \^4 * (card \ * card \) / (card (uverts G))\<^sup>2" (is "?lhs \ ?rhs") proof - - define UF where "UF \ bla U1 \" - define WF where "WF \ bla W1 \" + define UF where "UF \ P2 U1 \" + define WF where "WF \ P2 W1 \" obtain [simp]: "finite \" "finite \" using assms by (meson finite_subset) obtain 1: "card U1 > 0" "card W1 > 0" using gt \\ > 0\ U1 W1 by (force simp: u_def alpha_def edge_density_def mult_le_0_iff zero_less_mult_iff) then obtain 0: "card \ > 0" "card \ > 0" using assms by fastforce then obtain 1: "card U1 > 0" "card W1 > 0" by (smt (verit) U1 W1 \\ > 0\ of_nat_0_less_iff zero_less_mult_iff) then obtain [simp]: "finite U1" "finite W1" by (meson card_ge_0_finite) + obtain [simp]: "W1 \ \ - W1" "U1 \ \ - U1" + by (metis DiffD2 1 all_not_in_conv card.empty less_irrefl) have 2 [simp]: "card x > 0" if "x \ UF" for x - using "1"(1) assms that by (auto simp: UF_def bla_def split: if_split_asm) + using "1"(1) assms that by (auto simp: UF_def P2_def split: if_split_asm) have 3 [simp]: "card x > 0" if "x \ WF" for x - using "1"(2) assms that by (auto simp: WF_def bla_def split: if_split_asm) + using "1"(2) assms that by (auto simp: WF_def P2_def split: if_split_asm) have cardUW: "card \ = card U1 + card(\ - U1)" "card \ = card W1 + card(\ - W1)" using 0 1 \U1 \ \\ \W1 \ \\ by (metis card_eq_0_iff card_Diff_subset card_mono le_add_diff_inverse less_le)+ - - have [simp]: "W1 \ \ - W1" - by (metis "1"(2) Diff_cancel Diff_idemp card.empty less_le) - have [simp]: "U1 \ \ - U1" - by (metis "1"(1) Diff_cancel Diff_idemp card.empty less_nat_zero_code) - have "\ = (\ - U1) \ U1" "disjnt (\ - U1) U1" using \U1 \ \\ by (force simp: disjnt_iff)+ then have CU: "card (all_edges_between \ Z G) = card (all_edges_between (\ - U1) Z G) + card (all_edges_between U1 Z G)" if "finite Z" for Z by (metis \finite U1\ all_edges_between_Un1 all_edges_between_disjnt1 \finite \\ card_Un_disjnt finite_Diff finite_all_edges_between that) have "\ = (\ - W1) \ W1" "disjnt (\ - W1) W1" using \W1 \ \\ by (force simp: disjnt_iff)+ then have CW: "card (all_edges_between Z \ G) = card (all_edges_between Z (\ - W1) G) + card (all_edges_between Z W1 G)" if "finite Z" for Z by (metis \finite W1\ all_edges_between_Un2 all_edges_between_disjnt2 \finite \\ card_Un_disjnt finite_Diff2 finite_all_edges_between that) have *: "(\i\UF. \j\WF. real (card (all_edges_between i j G))) = card (all_edges_between \ \ G)" - by (simp add: UF_def WF_def cardUW CU CW sum_bla \U1 \ \\ \W1 \ \\) + by (simp add: UF_def WF_def cardUW CU CW sum_P2 \U1 \ \\ \W1 \ \\) have **: "real (card \) * real (card \) = (\i\UF. \j\WF. card i * card j)" - by (simp add: UF_def WF_def cardUW sum_bla \U1 \ \\ \W1 \ \\ algebra_simps) + by (simp add: UF_def WF_def cardUW sum_P2 \U1 \ \\ \W1 \ \\ algebra_simps) let ?S = "\i\UF. \j\WF. (card i * card j) / (card \ * card \) * (edge_density i j G)\<^sup>2" have \
: "2 * (\i\UF. \j\WF. (card i * card j) / (card \ * card \) * (edge_density i j G)) = alpha + alpha * (\i\UF. \j\WF. (card i * card j) / (card \ * card \))" unfolding alpha_def - by (simp add: * ** edge_density_def divide_simps sum_bla \U1 \ \\ \W1 \ \\ flip: sum_divide_distrib) + by (simp add: * ** edge_density_def divide_simps sum_P2 \U1 \ \\ \W1 \ \\ flip: sum_divide_distrib) have "\ * \ \ u U1 W1 * u U1 W1" by (metis abs_ge_zero abs_mult_self_eq \\ > 0\ gt less_le mult_mono) then have "(\*\)*(\*\) \ (card U1 * card W1) / (card \ * card \) * (u U1 W1)\<^sup>2" using 0 mult_mono [OF U1 W1] \\ > 0\ apply (simp add: divide_simps eval_nat_numeral) by (smt (verit, del_insts) mult.assoc mult.commute mult_mono' of_nat_0_le_iff zero_le_mult_iff) also have "\ \ (\i\UF. \j\WF. (card i * card j) / (card \ * card \) * (u i j)\<^sup>2)" - by (simp add: UF_def WF_def sum_bla \U1 \ \\ \W1 \ \\) + by (simp add: UF_def WF_def sum_P2 \U1 \ \\ \W1 \ \\) also have "\ = ?S - 2 * alpha * (\i\UF. \j\WF. (card i * card j) / (card \ * card \) * edge_density i j G) + alpha\<^sup>2 * (\i\UF. \j\WF. (card i * card j) / (card \ * card \))" by (simp add: u_def power2_diff mult_ac ring_distribs divide_simps sum_distrib_left sum_distrib_right sum_subtractf sum.distrib flip: sum_divide_distrib) also have "\ = ?S - alpha\<^sup>2" using \
by (simp add: power2_eq_square algebra_simps) finally have 12: "alpha\<^sup>2 + \^4 \ ?S" by (simp add: eval_nat_numeral) have "?rhs = (alpha\<^sup>2 + \^4) * (card \ * card \ / (card (uverts G))\<^sup>2)" unfolding alpha_def energy_graph_subsets_def by (simp add: ring_distribs divide_simps power2_eq_square) also have "\ \ ?S * (card \ * card \ / (card (uverts G))\<^sup>2)" by (rule mult_right_mono [OF 12]) auto also have "\ = ?lhs" using 0 unfolding energy_graph_subsets_def UF_def WF_def - by (auto simp add: algebra_simps sum_bla \U1 \ \\ \W1 \ \\ ) + by (auto simp add: algebra_simps sum_P2 \U1 \ \\ \W1 \ \\ ) finally show ?thesis . qed subsection \Towards Zhao's Lemma 3.11\ text\Lemma 3.11 says that we can always find a refinement that increases the energy by a certain amount.\ text \A necessary lemma for the tower of exponentials in the result. Angeliki's proof\ lemma le_tower_2: "k * (2 ^ Suc k) \ 2^(2^k)" proof (induction k rule: less_induct) case (less k) show ?case proof (cases "k \ Suc (Suc 0)") case False define j where "j = k - Suc 0" have kj: "k = Suc j" using False j_def by force have "(3::nat) \ 2 ^ j" by (metis kj False Suc_leI less_trans_Suc less_exp not_less numeral_3_eq_3) then have \
: "(2^j + 3) \ (2::nat) ^ k" by (simp add: kj) have "k * (2 ^ Suc k) \ 6 * j * 2^j" using False by (simp add: kj) also have "\ \ 6 * 2^(2^j)" using kj less.IH by force also have "\ < 8 * 2^(2^j)" by simp also have "\ = 2^(2^j + 3)" by (simp add: power_add) also have "\ \ 2^2^k" using \
by (metis One_nat_def less_2_cases_iff power_increasing_iff) finally show ?thesis by simp qed (auto simp: le_Suc_eq) qed text \Zhao's actual Lemma 3.11. However, the bound $m \le k 2 ^{k+1}$ comes from a different source by Zhao: ``Graph Theory and Additive Combinatorics'', \<^url>\https://yufeizhao.com/gtac/gtac17.pdf\. Zhao's original version, and Gowers', both have incorrect bounds.\ proposition exists_refinement: - assumes "finite_graph_partition (uverts G) P k" and "finite (uverts G)" - and irreg: "\ regular_partition \ G P k" and "\ > 0" - obtains Q m where "finite_graph_refines (uverts G) Q m P k" - "mean_square_density G Q m \ mean_square_density G P k + \^5" - "\i. i card {j. j Q j \ P i} \ 2 ^ Suc k" - "m \ k * 2 ^ Suc k" + assumes fgp: "finite_graph_partition (uverts G) P k" and "finite (uverts G)" + and irreg: "\ regular_partition \ G P" and "\ > 0" + obtains Q where "refines (uverts G) Q P" + "mean_square_density G Q \ mean_square_density G P + \^5" + "\R. R\P \ card {S\Q. S \ R} \ 2 ^ Suc k" + "card Q \ k * 2 ^ Suc k" proof - - define sum_pp where "sum_pp \ (\(i,j) \ irregular_set \ G P k. card (P i) * card (P j))" - have "k \ 0" - using assms unfolding regular_partition_def irregular_set_def - by (intro notI) auto - then have G_nonempty: "0 < card (uverts G)" - by (metis assms(1) assms(2) finite_graph_partition_gt0 finite_graph_partition_le gr_zeroI leD) - have part_GP: "partition_on (uverts G) (P ` {.. {}" if "i (\(R,S) \ irregular_set \ G P. card R * card S)" + have cardP: "card P = k" + using fgp finite_graph_partition_def by force + then have "k \ 0" + using assms unfolding regular_partition_def irregular_set_def finite_graph_partition_def by fastforce + with assms have G_nonempty: "0 < card (uverts G)" + by (metis card_gt_0_iff finite_graph_partition_empty) + have part_GP: "partition_on (uverts G) P" + using fgp finite_graph_partition_def by blast + then have finP: "finite R" "R \ {}" if "R\P" for R + using assms that partition_onD3 finite_graph_partition_finite by blast+ have spp: "sum_pp > \ * (card (uverts G))\<^sup>2" - using assms by (metis not_le regular_partition_def sum_pp_def) + by (metis irreg not_le part_GP regular_partition_def sum_pp_def) then have sum_irreg_pos: "sum_pp > 0" using \\ > 0\ G_nonempty less_asym by fastforce - have "\X\P i. - \Y\P j. - \ * card (P i) \ card X \ - \ * card (P j) \ card Y \ - \edge_density X Y G - edge_density (P i) (P j) G\ > \" - if "(i,j) \ irregular_set \ G P k" for i j - using that assms(1) finite_graph_partition_subset by (simp add: irregular_set_def regular_pair_def not_le) + have "\X\R. \Y\S. \ * card R \ card X \ \ * card S \ card Y \ + \edge_density X Y G - edge_density R S G\ > \" + if "(R,S) \ irregular_set \ G P" for R S + using that fgp finite_graph_partition_subset by (simp add: irregular_set_def regular_pair_def not_le) then obtain X0 Y0 - where XY0_psub_P: "\i j. \(i,j) \ irregular_set \ G P k\ \ X0 i j \ P i \ Y0 i j \ P j" + where XY0_psub_P: "\R S. \(R,S) \ irregular_set \ G P\ \ X0 R S \ R \ Y0 R S \ S" and XY0_eps: - "\i j. \(i,j) \ irregular_set \ G P k\ - \ \ * card (P i) \ card (X0 i j) \ - \ * card (P j) \ card (Y0 i j) \ - \edge_density (X0 i j) (Y0 i j) G - edge_density (P i) (P j) G\ > \" + "\R S. (R,S) \ irregular_set \ G P + \ \ * card R \ card (X0 R S) \ \ * card S \ card (Y0 R S) \ + \edge_density (X0 R S) (Y0 R S) G - edge_density R S G\ > \" by metis - - define X where "X \ \i j. if j>i then Y0 j i else X0 i j" - define Y where "Y \ \i j. if j>i then X0 j i else Y0 i j" - - have XY_psub_P: "\i j. \(i,j) \ irregular_set \ G P k\ \ X i j \ P i \ Y i j \ P j" + obtain iP where iP: "bij_betw iP P {.. \R S. if iP R < iP S then Y0 S R else X0 R S" + define Y where "Y \ \R S. if iP R < iP S then X0 S R else Y0 R S" + have XY_psub_P: "\R S. \(R,S) \ irregular_set \ G P\ \ X R S \ R \ Y R S \ S" using XY0_psub_P by (force simp: X_def Y_def irregular_set_swap) have XY_eps: - "\i j. \(i,j) \ irregular_set \ G P k\ - \ \ * card (P i) \ card (X i j) \ - \ * card (P j) \ card (Y i j) \ - \edge_density (X i j) (Y i j) G - edge_density (P i) (P j) G\ > \" + "\R S. (R,S) \ irregular_set \ G P + \ \ * card R \ card (X R S) \ \ * card S \ card (Y R S) \ + \edge_density (X R S) (Y R S) G - edge_density R S G\ > \" using XY0_eps by (force simp: X_def Y_def edge_density_commute irregular_set_swap) - have cardP: "card (P i) > 0" if "i {}" "Y i j \ {}" if "(i,j) \ irregular_set \ G P k" for i j - using XY_eps [OF that] that \\ > 0\ cardP [of i] cardP [of j] + have card_elem_P: "card R > 0" if "R\P" for R + by (metis card_eq_0_iff finP neq0_conv that) + have XY_nonempty: "X R S \ {}" "Y R S \ {}" if "(R,S) \ irregular_set \ G P" for R S + using XY_eps [OF that] that \\ > 0\ card_elem_P [of R] card_elem_P [of S] by (auto simp: irregular_set_def mult_le_0_iff) text\By the assumption that our partition is irregular, there are many irregular pairs. For each irregular pair, find pairs of subsets that witness irregularity.\ - define XP where "XP i \ ((\j. bla (X i j) (P i)) ` {j. (i,j) \ irregular_set \ G P k})" for i - define YP where "YP j \ ((\i. bla (Y i j) (P j)) ` {i. (i,j) \ irregular_set \ G P k})" for j + define XP where "XP R \ ((\S. P2 (X R S) R) ` {S. (R,S) \ irregular_set \ G P})" for R + define YP where "YP S \ ((\R. P2 (Y R S) S) ` {R. (R,S) \ irregular_set \ G P})" for S text \include degenerate partition to ensure it works whether or not there's an irregular pair\ - define PP where "PP \ \i. insert {P i} (XP i \ YP i)" - have finPP: "finite (PP i)" for i - unfolding PP_def XP_def YP_def - by (auto simp: inj_def intro!: finite_inverse_image finite_irregular_set) - have inPP_fin: "P \ PP i \ finite P" for P i - by (auto simp: PP_def XP_def YP_def bla_def) - have fin_cf: "finite (common_refinement (PP i))" for i - by (simp add: finPP finite_common_refinement inPP_fin) - - have part_cr: "partition_on (P i) (common_refinement (PP i))" if "i < k" for i - proof (intro partition_on_common_refinement partition_onI) - show "\\. \ \ PP i \ {} \ \" - using that XY_nonempty XY_psub_P finP(2) by (fastforce simp add: PP_def XP_def YP_def bla_def) - qed (auto simp: disjnt_iff PP_def XP_def YP_def bla_def dest: XY_psub_P) + define PP where "PP \ \R. insert {R} (XP R \ YP R)" + define QS where "QS R \ common_refinement (PP R)" for R + define r where "r R \ card (QS R)" for R + have "finite P" + using fgp finite_graph_partition_def by blast + then have finPP: "finite (PP R)" for R + by (simp add: PP_def XP_def YP_def irregular_set_def) + have inPP_fin: "P \ PP R \ finite P" for P R + by (auto simp: PP_def XP_def YP_def P2_def) + have finite_QS: "finite (QS R)" for R + by (simp add: QS_def finPP finite_common_refinement inPP_fin) - define QS where "QS i \ from_nat_into (common_refinement (PP i))" for i - define r where "r i \ card (common_refinement (PP i))" for i - have to_nat_on_cr: - "\x i. \x \ common_refinement (PP i); i < k\ - \ to_nat_on (common_refinement (PP i)) x < r i" - by (metis bij_betw_apply fin_cf lessThan_iff r_def to_nat_on_finite) - have QSr_eq: "QS i ` {.. {}" if "i P i" if "i < k" "q < r i" for i q - using part_cr [of i] QSr_eq that - unfolding partition_on_def by blast - then have QS_inject: "i = i'" - if "QS i q = QS i' q'" "i P" for R + unfolding QS_def + proof (intro partition_on_common_refinement partition_onI) + show "\\. \ \ PP R \ {} \ \" + using that XY_nonempty XY_psub_P finP(2) + by (fastforce simp add: PP_def XP_def YP_def P2_def) + qed (auto simp: disjnt_iff PP_def XP_def YP_def P2_def dest: XY_psub_P) - define sumr where "sumr \ \j. (\i sumr k" - define Q where "Q \ \d. QS (part r k d) (d - sumr (part r k d))" - have QS_Q: "QS j q = Q (sumr j + q)" if "ji ?rhs" - using QSr_eq r_def - apply (simp add: image_subset_iff Ball_def Bex_def QS_def Q_def m_def) - by (metis sumr_def add.right_neutral card.empty from_nat_into leD part) - show "?rhs \ ?lhs" - using QS_Q m_def sum_layers_less sumr_def by fastforce - qed - have Qm_eq: "Q ` {..iP" for R + by (simp add: finite_QS finite_graph_partition_def part_QS r_def that) + then have fin_SQ [simp]: "finite (QS R)" if "R\P" for R + using QS_def finite_QS by force + have QS_ne: "{} \ QS R" if "R\P" for R + using QS_def part_QS partition_onD3 that by blast + have QS_subset_P: "q \ QS R \ q \ R" if "R\P" for R q + by (meson finite_graph_partition_subset part_P_QS that) + then have QS_inject: "R = R'" + if "R\P" "R'\P" "q \ QS R" "q \ QS R'" for R R' q + by (metis UnionI disjnt_iff equals0I pairwiseD part_GP part_QS partition_on_def that) + define Q where "Q \ (\R\P. QS R)" + define m where "m \ \R\P. r R" show thesis proof - show ref_QP: "finite_graph_refines (uverts G) Q m P k" - unfolding finite_graph_refines_def - proof (intro conjI strip) - show "finite_graph_partition (uverts G) Q m" - unfolding finite_graph_partition_eq + show ref_QP: "refines (uverts G) Q P" + unfolding refines_def + proof (intro conjI strip part_GP) + fix X + assume "X \ Q" + then show "\Y\P. X \ Y" + by (metis QS_subset_P Q_def UN_iff) + next + show "partition_on (uverts G) Q" proof (intro conjI partition_onI) - have "\ (Q ` {..i (common_refinement (PP i)))" - by (auto simp add: Qm_eq) - also have "\ = uverts G" - using part_cr finite_graph_partition_equals assms(1) - by (force simp: partition_on_def) - finally show "\ (Q ` {.. Q ` {.. Q ` {.. q" for p q + show "\Q = uverts G" + proof + show "\Q \ uverts G" + using QS_subset_P Q_def fgp finite_graph_partition_equals by fastforce + show "uverts G \ \Q" + by (metis Q_def Sup_least UN_upper Union_mono part_GP part_QS partition_onD1) + qed + show "disjnt p q" if "p \ Q" and "q \ Q" and "p \ q" for p q proof - from that - obtain i j where "i common_refinement (PP i)" and j: "q \ common_refinement (PP j)" - by (auto simp add: Qm_eq) + obtain R S where "R\P" "S\P" + and *: "p \ QS R" "q \ QS S" + by (auto simp: Q_def QS_def) show ?thesis - proof (cases "i=j") + proof (cases "R=S") case True then show ?thesis - using part_cr [of i] - by (metis \j < k\ i j pairwise_def partition_on_def \p \ q\) + using part_QS [of R] + by (metis \R \ P\ * pairwiseD partition_on_def \p \ q\) next case False - have "p \ P i \ q \ P j" - by (metis Union_upper \i < k\ \j < k\ i j part_cr partition_onD1) then show ?thesis - using False \i < k\ \j < k\ part_GP disjfam_P - by (fastforce simp add: disjoint_family_on_def disjnt_iff) + by (metis Union_upper \R \ P\ \S \ P\ disjnt_iff * in_mono pairwiseD part_GP part_QS partition_onD1 partition_onD2) qed qed - show "{} \ Q ` {.. Q" + using QS_ne Q_def by blast qed - fix i - assume "i < m" - have "part r k i < k" "(\i < part r k i. r i) \ i \ i < (\i < part r k i. r i) + r (part r k i)" - by (metis \i < m\ m_def part sumr_def)+ - then have "QS (part r k i) (i - sum r {.. P (part r k i)" - by (simp add: QS_subset_P less_diff_conv2) - then show "\j P j" - unfolding Q_def sumr_def using \part r k i < k\ by blast - qed (use assms in auto) - - have inj_Q: "inj_on Q {.. (\(i,j) \ irregular_set \ G P k. \^4 * (card (P i) * card (P j)) / (card (uverts G))\<^sup>2)" - { fix i j - assume ij: "(i,j) \ irregular_set \ G P k" - then have "i^4 * (card (P i) * card (P j)) / (card (uverts G))\<^sup>2 - \ (\A \ bla (X i j) (P i). \B \ bla (Y i j) (P j). energy_graph_subsets A B G)" - using XY_psub_P [OF ij] XY_eps [OF ij] assms - by (intro energy_boost \i < k\ \j < k\ finP \\>0\) auto - also have "\ = (\ab = energy_graph_partitions_subsets G (bla_partition (X i j) (P i)) (bla_idx (X i j) (P i)) (bla_partition (Y i j) (P j)) (bla_idx (Y i j) (P j))" + qed + have disj_QSP: "disjoint_family_on QS P" + unfolding disjoint_family_on_def by (metis Int_emptyI QS_inject) + let ?PP = "P \ P" + let ?REG = "?PP - irregular_set \ G P" + define sum_eps where "sum_eps \ (\(R,S) \ irregular_set \ G P. \^4 * (card R * card S) / (card (uverts G))\<^sup>2)" + have A: "energy_graph_subsets R S G + \^4 * (card R * card S) / (card (uverts G))\<^sup>2 + \ energy_graph_partitions_subsets G (P2 (X R S) R) (P2 (Y R S) S)" + (is "?L \ ?R") + if *: "(R,S) \ irregular_set \ G P" for R S + proof - + have "R\P" "S\P" + using * by (auto simp: irregular_set_def) + have "?L \ (\A \ P2 (X R S) R. \B \ P2 (Y R S) S. energy_graph_subsets A B G)" + using XY_psub_P [OF *] XY_eps [OF *] assms + by (intro energy_boost \R \ P\ \S \ P\ finP \\>0\) auto + also have "\ \ ?R" by (simp add: energy_graph_partitions_subsets_def) - finally have "energy_graph_subsets (P i) (P j) G + \^4 * (card (P i) * card (P j)) / (card (uverts G))\<^sup>2 - \ energy_graph_partitions_subsets G (bla_partition (X i j) (P i)) (bla_idx (X i j) (P i)) (bla_partition (Y i j) (P j)) (bla_idx (Y i j) (P j))" . - } note A = this - { fix i j - assume ij: "(i,j) \ irregular_set \ G P k" - then have "i X i j \ P i \ X i j = P i" "\ Y i j \ P j \ Y i j = P j" - using XY_psub_P ij by blast+ - have XPX: "bla (X i j) (P i) \ PP i" - using ij by (simp add: PP_def XP_def) - have I: "finite_graph_partition (P i) (QS i) (r i)" - by (simp add: QSr_eq \i < k\ finite_graph_partition_eq inj_QS part_cr) - moreover have "\qb bla_partition (X i j) (P i) b" - using common_refinement_exists [OF _ XPX] - apply (clarsimp simp add: bla_def bla_idx_def bla_partition_def QS_subset_P \i < k\) - apply (simp add: QS_def r_def numeral_2_eq_2) - by (metis binary_partition.simps card.empty empty_iff from_nat_into insert_iff lessI less_nat_zero_code psubsetI zero_less_Suc) - ultimately have ref_XP: "finite_graph_refines (P i) (QS i) (r i) (bla_partition (X i j) (P i)) (bla_idx (X i j) (P i))" - unfolding finite_graph_refines_def - using XY_nonempty(1) XY_psub_P finite_graph_partition_binary_partition ij - by (simp add: finite_graph_partition_bla_partition) - have YPY: "bla (Y i j) (P j) \ PP j" - using ij by (simp add: PP_def YP_def) - have J: "finite_graph_partition (P j) (QS j) (r j)" - by (simp add: QSr_eq \j < k\ finite_graph_partition_eq inj_QS part_cr) - moreover have "\qb bla_partition (Y i j) (P j) b" - using common_refinement_exists [OF _ YPY] - apply (clarsimp simp add: bla_def bla_idx_def bla_partition_def QS_subset_P \j < k\) - apply (simp add: QS_def r_def numeral_2_eq_2) - by (metis binary_partition.simps card.empty empty_iff from_nat_into insert_iff lessI less_nat_zero_code psubsetI zero_less_Suc) - ultimately have ref_YP: "finite_graph_refines (P j) (QS j) (r j) (bla_partition (Y i j) (P j)) (bla_idx (Y i j) (P j))" - unfolding finite_graph_refines_def - using XY_nonempty(2) XY_psub_P finite_graph_partition_binary_partition ij - by (simp add: finite_graph_partition_bla_partition) - have "energy_graph_partitions_subsets G (bla_partition (X i j) (P i)) (bla_idx (X i j) (P i)) (bla_partition (Y i j) (P j)) (bla_idx (Y i j) (P j)) - \ energy_graph_partitions_subsets G (QS i) (r i) (QS j) (r j)" - using \i < k\ \j < k\ + finally show ?thesis . + qed + have B: "energy_graph_partitions_subsets G (P2 (X R S) R) (P2 (Y R S) S) + \ energy_graph_partitions_subsets G (QS R) (QS S)" + if "(R,S) \ irregular_set \ G P" for R S + proof - + have "R\P" "S\P" using that by (auto simp: irregular_set_def) + have [simp]: "\ X R S \ R \ X R S = R" "\ Y R S \ S \ Y R S = S" + using XY_psub_P that by blast+ + have XPX: "P2 (X R S) R \ PP R" + using that by (simp add: PP_def XP_def) + have I: "partition_on R (QS R)" + using QS_def \R \ P\ part_QS by force + moreover have "\q \ QS R. \b \ P2 (X R S) R. q \ b" + using common_refinement_exists [OF _ XPX] by (simp add: QS_def) + ultimately have ref_XP: "refines R (QS R) (P2 (X R S) R)" + by (simp add: refines_def XY_nonempty XY_psub_P that partition_P2) + have YPY: "P2 (Y R S) S \ PP S" + using that by (simp add: PP_def YP_def) + have J: "partition_on S (QS S)" + using QS_def \S \ P\ part_QS by force + moreover have "\q \ QS S. \b \ P2 (Y R S) S. q \ b" + using common_refinement_exists [OF _ YPY] by (simp add: QS_def) + ultimately have ref_YP: "refines S (QS S) (P2 (Y R S) S)" + by (simp add: XY_nonempty XY_psub_P that partition_P2 refines_def) + show ?thesis + using \R \ P\ \S \ P\ by (simp add: finP energy_graph_partitions_subsets_increase [OF ref_XP ref_YP]) - } note B = this - have df_QS: "disjoint_family_on (\i. QS i ` {..^5 \ mean_square_density G P k + sum_eps" + qed + have "mean_square_density G P + \^5 \ mean_square_density G P + sum_eps" proof - have "\^5 = (\ * (card (uverts G))\<^sup>2) * (\^4 / (card (uverts G))\<^sup>2)" using G_nonempty by (simp add: field_simps eval_nat_numeral) also have "\ \ sum_pp * (sum_eps / sum_pp)" proof (rule mult_mono) show "\^4 / real ((card (uverts G))\<^sup>2) \ sum_eps / sum_pp" using sum_irreg_pos sum_eps_def sum_pp_def by (auto simp add: case_prod_unfold sum.neutral simp flip: sum_distrib_left sum_divide_distrib of_nat_sum of_nat_mult) qed (use spp sum_nonneg in auto) also have "\ \ sum_eps" by (simp add: sum_irreg_pos) finally show ?thesis by simp qed - also have "\ = (\(i,j)\?REG. energy_graph_subsets (P i) (P j) G) - + (\(i,j)\irregular_set \ G P k. energy_graph_subsets (P i) (P j) G) + sum_eps" - by (simp add: energy_graph_partitions_subsets_def sum.cartesian_product irregular_set_subset sum.subset_diff) - also have "\ \ (\(i,j) \ ?REG. energy_graph_subsets (P i) (P j) G) - + (\(i,j) \ irregular_set \ G P k. energy_graph_partitions_subsets G (bla_partition (X i j) (P i)) (bla_idx (X i j) (P i)) (bla_partition (Y i j) (P j)) (bla_idx (Y i j) (P j)))" - using A unfolding sum_eps_def case_prod_unfold - by (force intro: sum_mono simp flip: energy_graph_partitions_subsets_def sum.distrib) - also have "\ \ (\(i,j) \ ?REG. energy_graph_partitions_subsets G (QS i) (r i) (QS j) (r j)) - + (\(i,j) \ irregular_set \ G P k. energy_graph_partitions_subsets G (bla_partition (X i j) (P i)) (bla_idx (X i j) (P i)) (bla_partition (Y i j) (P j)) (bla_idx (Y i j) (P j)))" - by(auto simp: part_P_QS finP intro!: sum_mono energy_graph_partition_increase) - also have "\ \ (\(i,j) \ ?REG. energy_graph_partitions_subsets G (QS i) (r i) (QS j) (r j)) - + (\(i,j) \ irregular_set \ G P k. energy_graph_partitions_subsets G (QS i) (r i) (QS j) (r j))" + also have "\ = (\(i,j)\?REG. energy_graph_subsets i j G) + + (\(i,j)\irregular_set \ G P. energy_graph_subsets i j G) + sum_eps" + by (simp add: \finite P\ energy_graph_partitions_subsets_def sum.cartesian_product irregular_set_subset sum.subset_diff) + also have "\ \ (\(i,j) \ ?REG. energy_graph_subsets i j G) + + (\(i,j) \ irregular_set \ G P. energy_graph_partitions_subsets G (P2 (X i j) i) (P2 (Y i j) j))" + using A unfolding sum_eps_def case_prod_unfold + by (force intro: sum_mono simp flip: sum.distrib) + also have "\ \ (\(i,j) \ ?REG. energy_graph_partitions_subsets G (QS i) (QS j)) + + (\(i,j) \ irregular_set \ G P. energy_graph_partitions_subsets G (P2 (X i j) i) (P2 (Y i j) j))" + by (auto simp: finP intro!: part_P_QS sum_mono energy_graph_partition_increase) + also have "\ \ (\(i,j) \ ?REG. energy_graph_partitions_subsets G (QS i) (QS j)) + + (\(i,j) \ irregular_set \ G P. energy_graph_partitions_subsets G (QS i) (QS j))" using B proof (intro sum_mono add_mono ordered_comm_monoid_add_class.sum_mono2) qed (auto split: prod.split) - also have "\ = (\(i,j) \ ?KK. energy_graph_partitions_subsets G (QS i) (r i) (QS j) (r j))" - by (metis (no_types, lifting) finite_SigmaI finite_lessThan irregular_set_subset sum.subset_diff) - also have "\ = (\ij = (\(i,j) \ ?PP. energy_graph_partitions_subsets G (QS i) (QS j))" + by (metis (no_types, lifting) \finite P\ finite_SigmaI irregular_set_subset sum.subset_diff) + also have "\ = (\i\P. \j\P. energy_graph_partitions_subsets G (QS i) (QS j))" by (simp flip: sum.cartesian_product) - also have "\ = (\A \ Q ` {..B \ Q ` {.. = (\ij = mean_square_density G Q m" + also have "\ = (\A \ Q. \B \ Q. energy_graph_subsets A B G)" + unfolding energy_graph_partitions_subsets_def Q_def + by (simp add: disj_QSP \finite P\ sum.UNION_disjoint_family sum.swap [of _ "P" "QS _"]) + also have "\ = mean_square_density G Q" by (simp add: mean_square_density energy_graph_subsets_def sum_divide_distrib) - finally show "mean_square_density G P k + \ ^ 5 \ mean_square_density G Q m" . + finally show "mean_square_density G P + \ ^ 5 \ mean_square_density G Q" . - let ?QinP = "\i. {j. j < m \ Q j \ P i}" - show card_QP: "card (?QinP i) \ 2 ^ Suc k" - if "i < k" for i + define QinP where "QinP \ \i. {j\Q. j \ i}" + show card_QP: "card (QinP i) \ 2 ^ Suc k" + if "i \ P" for i proof - - have card_cr: "card (common_refinement (PP i)) \ 2 ^ Suc k" + have less_cardP: "iP i < k" + using iP bij_betwE that by blast + have card_cr: "card (QS i) \ 2 ^ Suc k" proof - - have "card (common_refinement (PP i)) \ prod card (PP i)" - by (intro card_common_refinement finPP inPP_fin) + have "card (QS i) \ prod card (PP i)" + by (simp add: QS_def card_common_refinement finPP inPP_fin) also have "\ = prod card (XP i \ YP i)" using finPP by (simp add: PP_def prod.insert_if) also have "\ \ 2 ^ Suc k" proof (rule prod_le_power) - define XS where "XS \ (\l. bla (X0 i l) (P i)) ` {..i}" - define YS where "YS \ (\l. bla (Y0 l i) (P i)) ` {i.. Suc i" "card YS \ k-i" - unfolding XS_def YS_def using card_image_le by force+ - with that have k': "card XS + card YS \ Suc k" + define XS where "XS \ (\R \ {R\P. iP R \ iP i}. {P2 (X0 i R) i})" + define YS where "YS \ (\R \ {R\P. iP R \ iP i}. {P2 (Y0 R i) i})" + have 1: "{R \ P. iP R \ iP i} \ iP -` {..iP i} \ P" + by auto + have "card XS \ card {R \ P. iP R \ iP i}" + by (force simp add: XS_def \finite P\ intro: order_trans [OF card_UN_le]) + also have "\ \ card (iP -` {..iP i} \ P)" + using 1 by (simp add: \finite P\ card_mono) + also have "\ \ Suc (iP i)" + by (metis card_vimage_inj_on_le bij_betw_def card_atMost finite_atMost iP) + finally have cXS: "card XS \ Suc (iP i)" . + have 2: "{R \ P. iP R \ iP i} \ iP -` {iP i.. P" + by clarsimp (meson bij_betw_apply iP lessThan_iff nat_less_le) + have "card YS \ card {R \ P. iP R \ iP i}" + by (force simp add: YS_def \finite P\ intro: order_trans [OF card_UN_le]) + also have "\ \ card (iP -` {iP i.. P)" + using 2 by (simp add: \finite P\ card_mono) + also have "\ \ card {iP i.. k - iP i" + by simp + with less_cardP cXS have k': "card XS + card YS \ Suc k" by linarith have finXYS: "finite (XS \ YS)" - by (simp add: XS_def YS_def) + unfolding XS_def YS_def using \finite P\ by (auto intro: finite_vimageI) have "XP i \ YP i \ XS \ YS" - by (auto simp: XP_def YP_def X_def Y_def XS_def YS_def irregular_set_def) + apply (simp add: XP_def X_def YP_def Y_def XS_def YS_def irregular_set_def image_def subset_iff) + by (metis insert_iff linear not_le) then have "card (XP i \ YP i) \ card XS + card YS" by (meson card_Un_le card_mono finXYS order_trans) then show "card (XP i \ YP i) \ Suc k" using k' le_trans by blast fix x assume "x \ XP i \ YP i" then show "0 \ card x \ card x \ 2" - using XP_def YP_def card_bla by force + using XP_def YP_def card_P2 by force qed auto finally show ?thesis . qed - have "i' = i" if "QS i' q \ P i" "i'i < k\ inf.bounded_iff lessThan_iff subset_empty that) - then have "?QinP i \ {sumr i..< sumr (Suc i)}" - by (clarsimp simp: Q_def sumr_def m_def) (metis add_less_cancel_left le_add_diff_inverse part) - then have "card (?QinP i) \ card {sumr i..< sumr (Suc i)}" - by (meson card_mono finite_atLeastLessThan) + have "i' = i" if "q \ i" "i'\P" "q \ QS i'" for i' q + by (metis QS_ne QS_subset_P \i \ P\ disjnt_iff equals0I pairwiseD part_GP partition_on_def subset_eq that) + then have "QinP i \ QS i" + by (auto simp: QinP_def Q_def) + then have "card (QinP i) \ card (QS i)" + by (simp add: card_mono that) also have "\ \ 2 ^ Suc k" - using card_cr by (simp add: sumr_def r_def) + using QS_def card_cr by presburger finally show ?thesis . qed - have "m = card {j. j < m}" - by simp - also have "\ \ card (\i (QS ` P))" + unfolding Q_def .. + also have "\ \ card (\i\P. QinP i)" proof (rule card_mono) - show "{j. j < m} \ (\i \ (\i \ (\i k * 2 ^ Suc k" - by simp + show "(\ (QS ` P)) \ (\i\P. QinP i)" + using ref_QP QS_subset_P Q_def QinP_def by blast + show "finite (\i\P. QinP i)" + by (simp add: Q_def QinP_def \finite P\) + qed + also have "\ \ (\i\P. card (QinP i))" + using card_UN_le \finite P\ by blast + also have "\ \ (\i\P. 2 ^ Suc k)" + using card_QP sum_mono by force + finally show "card Q \ k * 2 ^ Suc k" + by (simp add: cardP) qed qed subsection \The Regularity Proof Itself\ text\Szemerédi's Regularity Lemma is Theorem 3.5 in Zhao's notes.\ text\We start with a trivial partition (one part). If it is already $\epsilon$-regular, we are done. If not, we refine it by applying lemma @{thm[source]"exists_refinement"} above, which increases the energy. We can repeat this step, but it cannot increase forever: by @{thm [source] mean_square_density_bounded} it cannot exceed~1. This defines an algorithm that must stop after at most $\epsilon^{-5}$ steps, resulting in an $\epsilon$-regular partition.\ theorem Szemeredi_Regularity_Lemma: assumes "\ > 0" - obtains M where "\G. card (uverts G) > 0 \ \P k. regular_partition \ G P k \ k \ M" + obtains M where "\G. card (uverts G) > 0 \ \P. regular_partition \ G P \ card P \ M" proof fix G assume "card (uverts G) > 0" then obtain finG: "finite (uverts G)" and nonempty: "uverts G \ {}" by (simp add: card_gt_0_iff) - define \ where "\ \ \Q m P k. finite_graph_refines (uverts G) Q m P k \ - mean_square_density G Q m \ mean_square_density G P k + \^5 \ - m \ k * 2 ^ Suc k" - define nxt where "nxt \ \(P,k). if regular_partition \ G P k then (P,k) else SOME (Q,m). \ Q m P k" - define iter where "iter \ \i. (nxt ^^ i) ((\u. uverts G, Suc 0))" + define \ where "\ \ \Q P. refines (uverts G) Q P \ + mean_square_density G Q \ mean_square_density G P + \^5 \ + card Q \ card P * 2 ^ Suc (card P)" + define nxt where "nxt \ \P. if regular_partition \ G P then P else SOME Q. \ Q P" + define iter where "iter \ \i. (nxt ^^ i) {uverts G}" define last where "last \ Suc (nat\1 / \ ^ 5\)" have iter_Suc [simp]: "iter (Suc i) = nxt (iter i)" for i by (simp add: iter_def) - have \: "\ Q m P k" - if Pk: "finite_graph_partition (uverts G) P k" and irreg: "\ regular_partition \ G P k" - and "(Q,m) = nxt (P,k)" for P k Q m - using that exists_refinement [OF Pk finG irreg assms] irreg - apply (simp add: nxt_def \_def) - by (metis (mono_tags, lifting) case_prod_conv someI) - have iter_finite_graph_partition: "case iter i of (P,k) \ finite_graph_partition (uverts G) P k" for i + have \: "\ (nxt P) P" + if Pk: "partition_on (uverts G) P" and irreg: "\ regular_partition \ G P" for P + proof - + have "finite_graph_partition (uverts G) P (card P)" + by (meson Pk finG finite_elements finite_graph_partition_def) + then show ?thesis + using that exists_refinement [OF _ finG irreg assms] irreg Pk + apply (simp only: nxt_def if_False) + by (metis (no_types, lifting) \_def someI) + qed + have partition_on: "partition_on (uverts G) (iter i)" for i proof (induction i) case 0 then show ?case - by (simp add: iter_def nonempty trivial_graph_partition_exists) + by (simp add: iter_def nonempty trivial_graph_partition_exists partition_on_space) next case (Suc i) with \ show ?case - apply (simp add: nxt_def \_def split: prod.split) - by (metis (no_types, lifting) case_prodD finite_graph_refines_def) + by (metis \_def iter_Suc nxt_def refines_def) qed - have False if irreg: "\i. i\last \ (case iter i of (P,k) \ \ regular_partition \ G P k)" + have False if irreg: "\i. i\last \ \ regular_partition \ G (iter i)" proof - - have \_loop: "\ Q m P k" if "nxt (P,k) = (Q,m)" "iter i = (P,k)" "i\last" for i Q m P k - by (metis \ case_prod_conv irreg iter_finite_graph_partition that) - have iter_grow: "(case iter i of (Q,m) \ mean_square_density G Q m) \ i * \^5" if "i\last" for i + have \_loop: "\ (nxt (iter i)) (iter i)" if "i\last" for i + using \ irreg partition_on that by blast + have iter_grow: "mean_square_density G (iter i) \ i * \^5" if "i\last" for i using that proof (induction i) case (Suc i) then show ?case - by (auto simp add: algebra_simps \_def split: prod.split prod.split_asm dest: \_loop) + by (clarsimp simp: algebra_simps) (smt (verit, best) Suc_leD \_def \_loop) qed (auto simp: iter_def) - have "last * \^5 \ (case iter last of (Q,m) \ mean_square_density G Q m)" + have "last * \^5 \ mean_square_density G (iter last)" by (simp add: iter_grow) also have "\ \ 1" - by (metis (no_types, lifting) finG case_prod_beta iter_finite_graph_partition mean_square_density_bounded) + by (meson finG finite_elements finite_graph_partition_def mean_square_density_bounded partition_on) finally have "real last * \ ^ 5 \ 1" . with assms show False unfolding last_def by (meson lessI natceiling_lessD not_less pos_divide_less_eq zero_less_power) qed - then obtain i where "i \ last" and "case iter i of (P,k) \ regular_partition \ G P k" + then obtain i where "i \ last" and "regular_partition \ G (iter i)" by force - then have reglar: "case iter (i + d) of (P,k) \ regular_partition \ G P k" for d - by (induction d) (auto simp add: nxt_def split: prod.split prod.split_asm) + then have reglar: "regular_partition \ G (iter (i + d))" for d + by (induction d) (auto simp add: nxt_def) define tower where "tower \ \k. (power(2::nat) ^^ k) 2" have [simp]: "tower (Suc k) = 2 ^ tower k" for k by (simp add: tower_def) - have iter_tower: "(case iter i of (Q,m) \ m) \ tower (2*i)" for i + have iter_tower: "card (iter i) \ tower (2*i)" for i proof (induction i) - case 0 - then show ?case - by (auto simp: iter_def tower_def) - next case (Suc i) - then obtain Q m P k where Qm: "nxt (P,k) = (Q,m)" "iter i = (P,k)" and kle: "k \ tower (2 * i)" - by (metis case_prod_conv surj_pair) - then have *: "m \ k * 2 ^ Suc k" - using iter_finite_graph_partition [of i] \ - by (smt (verit, ccfv_SIG) Suc_leD \_def case_prod_conv le_eq_less_or_eq mult_le_mono2 nxt_def - power2_eq_square power2_nat_le_imp_le prod.simps(1) self_le_ge2_pow) + then have Qm: "card (iter i) \ tower (2 * i)" + by simp + then have *: "card (nxt (iter i)) \ card (iter i) * 2 ^ Suc (card (iter i))" + using \ by (simp add: \_def nxt_def partition_on) also have "\ \ 2 ^ 2 ^ tower (2 * i)" - by (metis (full_types) One_nat_def le_tower_2 lessI numeral_2_eq_2 order.trans power_increasing_iff kle) + by (metis One_nat_def Suc.IH le_tower_2 lessI numeral_2_eq_2 order.trans power_increasing_iff) finally show ?case by (simp add: Qm) - qed - then show "\P k. regular_partition \ G P k \ k \ tower(2 * last)" - using reglar \i \ last\ by (metis case_prod_beta nat_le_iff_add) + qed (auto simp: iter_def tower_def) + then show "\P. regular_partition \ G P \ card P \ tower(2 * last)" + by (metis \i \ last\ nat_le_iff_add reglar) qed text \The actual value of the bound is visible above: a tower of exponentials of height $2(1 + \epsilon^{-5})$.\ end