Datasets:
AI4M
/

text
stringlengths
0
3.34M
lemma bounded_closure_image: "bounded (f ` closure S) \<Longrightarrow> bounded (f ` S)"
theory Dining_Cryptographers imports "HOL-Probability.Information" begin lemma image_ex1_eq: "inj_on f A \<Longrightarrow> (b \<in> f ` A) \<longleftrightarrow> (\<exists>!x \<in> A. b = f x)" by (unfold inj_on_def) blast lemma Ex1_eq: "\<exists>!x. P x \<Longrightarrow> P x \<Longrightarrow> P y \<Longrightarrow> x = y" by auto subsection \<open>Define the state space\<close> text \<open> We introduce the state space on which the algorithm operates. This contains: \begin{description} \item[n] The number of cryptographers on the table. \item[payer] Either one of the cryptographers or the NSA. \item[coin] The result of the coin flipping for each cryptographer. \item[inversion] The public result for each cryptographer, e.g. the sum of the coin flipping for the cryptographer, its right neighbour and the information if he paid or not. \end{description} The observables are the \emph{inversions} \<close> locale dining_cryptographers_space = fixes n :: nat assumes n_gt_3: "n \<ge> 3" begin definition "dining_cryptographers = ({None} \<union> Some ` {0..<n}) \<times> {xs :: bool list. length xs = n}" definition "payer dc = fst dc" definition coin :: "(nat option \<times> bool list) \<Rightarrow> nat \<Rightarrow> bool" where "coin dc c = snd dc ! (c mod n)" definition "inversion dc = map (\<lambda>c. (payer dc = Some c) \<noteq> (coin dc c \<noteq> coin dc (c + 1))) [0..<n]" definition "result dc = foldl (\<lambda> a b. a \<noteq> b) False (inversion dc)" lemma coin_n[simp]: "coin dc n = coin dc 0" unfolding coin_def by simp theorem correctness: assumes "dc \<in> dining_cryptographers" shows "result dc \<longleftrightarrow> (payer dc \<noteq> None)" proof - let ?XOR = "\<lambda>f l. foldl (\<noteq>) False (map f [0..<l])" have foldl_coin: "\<not> ?XOR (\<lambda>c. coin dc c \<noteq> coin dc (c + 1)) n" proof - define n' where "n' = n" \<comment> \<open>Need to hide n, as it is hidden in coin\<close> have "?XOR (\<lambda>c. coin dc c \<noteq> coin dc (c + 1)) n' = (coin dc 0 \<noteq> coin dc n')" by (induct n') auto thus ?thesis using \<open>n' \<equiv> n\<close> by simp qed from assms have "payer dc = None \<or> (\<exists>k<n. payer dc = Some k)" unfolding dining_cryptographers_def payer_def by auto thus ?thesis proof (rule disjE) assume "payer dc = None" thus ?thesis unfolding result_def inversion_def using foldl_coin by simp next assume "\<exists>k<n. payer dc = Some k" then obtain k where "k < n" and "payer dc = Some k" by auto define l where "l = n" \<comment> \<open>Need to hide n, as it is hidden in coin, payer etc.\<close> have "?XOR (\<lambda>c. (payer dc = Some c) \<noteq> (coin dc c \<noteq> coin dc (c + 1))) l = ((k < l) \<noteq> ?XOR (\<lambda>c. (coin dc c \<noteq> coin dc (c + 1))) l)" using \<open>payer dc = Some k\<close> by (induct l) auto thus ?thesis unfolding result_def inversion_def l_def using \<open>payer dc = Some k\<close> foldl_coin \<open>k < n\<close> by simp qed qed text \<open> We now restrict the state space for the dining cryptographers to the cases when one of the cryptographer pays. \<close> definition "dc_crypto = dining_cryptographers - {None}\<times>UNIV" lemma dc_crypto: "dc_crypto = Some ` {0..<n} \<times> {xs :: bool list. length xs = n}" unfolding dc_crypto_def dining_cryptographers_def by auto lemma image_payer_dc_crypto: "payer ` dc_crypto = Some ` {0..<n}" proof - have *: "{xs. length xs = n} \<noteq> {}" by (auto intro!: exI[of _ "replicate n undefined"]) show ?thesis unfolding payer_def [abs_def] dc_crypto fst_image_times if_not_P[OF *] .. qed lemma card_payer_and_inversion: assumes "xs \<in> inversion ` dc_crypto" and "i < n" shows "card {dc \<in> dc_crypto. payer dc = Some i \<and> inversion dc = xs} = 2" (is "card ?S = 2") proof - obtain ys j where xs_inv: "inversion (Some j, ys) = xs" and "j < n" and "(Some j, ys) \<in> dc_crypto" using assms(1) by (auto simp: dc_crypto) hence "length ys = n" by (simp add: dc_crypto) have [simp]: "length xs = n" using xs_inv[symmetric] by (simp add: inversion_def) { fix b have "inj_on (\<lambda>x. inversion (Some i, x)) {ys. ys ! 0 = b \<and> length ys = length xs}" proof (rule inj_onI) fix x y assume "x \<in> {ys. ys ! 0 = b \<and> length ys = length xs}" and "y \<in> {ys. ys ! 0 = b \<and> length ys = length xs}" and inv: "inversion (Some i, x) = inversion (Some i, y)" hence [simp]: "x ! 0 = y ! 0" "length y = n" "length x = n" using \<open>length xs = n\<close> by simp_all have *: "\<And>j. j < n \<Longrightarrow> (x ! j = x ! (Suc j mod n)) = (y ! j = y ! (Suc j mod n))" using inv unfolding inversion_def map_eq_conv payer_def coin_def by fastforce show "x = y" proof (rule nth_equalityI, simp) fix j assume "j < length x" hence "j < n" using \<open>length xs = n\<close> by simp thus "x ! j = y ! j" proof (induct j) case (Suc j) hence "j < n" by simp with Suc show ?case using *[OF \<open>j < n\<close>] by (cases "y ! j") simp_all qed simp qed qed } note inj_inv = this txt \<open> We now construct the possible inversions for \<^term>\<open>xs\<close> when the payer is \<^term>\<open>i\<close>. \<close> define zs where "zs = map (\<lambda>p. if p \<in> {min i j<..max i j} then \<not> ys ! p else ys ! p) [0..<n]" hence [simp]: "length zs = n" by simp hence [simp]: "0 < length zs" using n_gt_3 by simp have "\<And>l. l < max i j \<Longrightarrow> Suc l mod n = Suc l" using \<open>i < n\<close> \<open>j < n\<close> by auto { fix l assume "l < n" hence "(((l < min i j \<or> l = min i j) \<or> (min i j < l \<and> l < max i j)) \<or> l = max i j) \<or> max i j < l" by auto hence "((i = l) = (zs ! l = zs ! (Suc l mod n))) = ((j = l) = (ys ! l = ys ! (Suc l mod n)))" apply - proof ((erule disjE)+) assume "l < min i j" hence "l \<noteq> i" and "l \<noteq> j" and "zs ! l = ys ! l" and "zs ! (Suc l mod n) = ys ! (Suc l mod n)" using \<open>i < n\<close> \<open>j < n\<close> unfolding zs_def by auto thus ?thesis by simp next assume "l = min i j" show ?thesis proof (cases rule: linorder_cases) assume "i < j" hence "l = i" and "Suc l < n" and "i \<noteq> j" and "Suc l \<le> max i j" using \<open>l = min i j\<close> using \<open>j < n\<close> by auto hence "zs ! l = ys ! l" and "zs ! (Suc l mod n) = (\<not> ys ! (Suc l mod n))" using \<open>l = min i j\<close>[symmetric] by (simp_all add: zs_def) thus ?thesis using \<open>l = i\<close> \<open>i \<noteq> j\<close> by simp next assume "j < i" hence "l = j" and "Suc l < n" and "i \<noteq> j" and "Suc l \<le> max i j" using \<open>l = min i j\<close> using \<open>i < n\<close> by auto hence "zs ! l = ys ! l" and "zs ! (Suc l mod n) = (\<not> ys ! (Suc l mod n))" using \<open>l = min i j\<close>[symmetric] by (simp_all add: zs_def) thus ?thesis using \<open>l = j\<close> \<open>i \<noteq> j\<close> by simp next assume "i = j" hence "i = j" and "max i j = l" and "min i j = l" and "zs = ys" using \<open>l = min i j\<close> by (simp_all add: zs_def \<open>length ys = n\<close>[symmetric] map_nth) thus ?thesis by simp qed next assume "min i j < l \<and> l < max i j" hence "i \<noteq> l" and "j \<noteq> l" and "zs ! l = (\<not> ys ! l)" "zs ! (Suc l mod n) = (\<not> ys ! (Suc l mod n))" using \<open>i < n\<close> \<open>j < n\<close> by (auto simp: zs_def) thus ?thesis by simp next assume "l = max i j" show ?thesis proof (cases rule: linorder_cases) assume "i < j" hence "l = j" and "i \<noteq> j" using \<open>l = max i j\<close> using \<open>j < n\<close> by auto have "zs ! (Suc l mod n) = ys ! (Suc l mod n)" using \<open>j < n\<close> \<open>i < j\<close> \<open>l = j\<close> by (cases "Suc l = n") (auto simp add: zs_def) moreover have "zs ! l = (\<not> ys ! l)" using \<open>j < n\<close> \<open>i < j\<close> by (auto simp add: \<open>l = j\<close> zs_def) ultimately show ?thesis using \<open>l = j\<close> \<open>i \<noteq> j\<close> by simp next assume "j < i" hence "l = i" and "i \<noteq> j" using \<open>l = max i j\<close> by auto have "zs ! (Suc l mod n) = ys ! (Suc l mod n)" using \<open>i < n\<close> \<open>j < i\<close> \<open>l = i\<close> by (cases "Suc l = n") (auto simp add: zs_def) moreover have "zs ! l = (\<not> ys ! l)" using \<open>i < n\<close> \<open>j < i\<close> by (auto simp add: \<open>l = i\<close> zs_def) ultimately show ?thesis using \<open>l = i\<close> \<open>i \<noteq> j\<close> by auto next assume "i = j" hence "i = j" and "max i j = l" and "min i j = l" and "zs = ys" using \<open>l = max i j\<close> by (simp_all add: zs_def \<open>length ys = n\<close>[symmetric] map_nth) thus ?thesis by simp qed next assume "max i j < l" hence "j \<noteq> l" and "i \<noteq> l" by simp_all have "zs ! (Suc l mod n) = ys ! (Suc l mod n)" using \<open>l < n\<close> \<open>max i j < l\<close> by (cases "Suc l = n") (auto simp add: zs_def) moreover have "zs ! l = ys ! l" using \<open>l < n\<close> \<open>max i j < l\<close> by (auto simp add: zs_def) ultimately show ?thesis using \<open>j \<noteq> l\<close> \<open>i \<noteq> l\<close> by auto qed } hence zs: "inversion (Some i, zs) = xs" by (simp add: xs_inv[symmetric] inversion_def coin_def payer_def) moreover from zs have Not_zs: "inversion (Some i, (map Not zs)) = xs" by (simp add: xs_inv[symmetric] inversion_def coin_def payer_def) ultimately have "{dc \<in> dc_crypto. payer dc = Some i \<and> inversion dc = xs} = {(Some i, zs), (Some i, map Not zs)}" using \<open>i < n\<close> [[ hypsubst_thin = true ]] proof (safe, simp_all add:dc_crypto payer_def) fix b assume [simp]: "length b = n" and *: "inversion (Some i, b) = xs" and "b \<noteq> zs" show "b = map Not zs" proof (cases "b ! 0 = zs ! 0") case True hence zs: "zs \<in> {ys. ys ! 0 = b ! 0 \<and> length ys = length xs} \<and> xs = inversion (Some i, zs)" using zs by simp have b: "b \<in> {ys. ys ! 0 = b ! 0 \<and> length ys = length xs} \<and> xs = inversion (Some i, b)" using * by simp hence "b \<in> {ys. ys ! 0 = b ! 0 \<and> length ys = length xs}" .. with *[symmetric] have "xs \<in> (\<lambda>x. inversion (Some i, x)) ` {ys. ys ! 0 = b ! 0 \<and> length ys = length xs}" by (rule image_eqI) from this[unfolded image_ex1_eq[OF inj_inv]] b zs have "b = zs" by (rule Ex1_eq) thus ?thesis using \<open>b \<noteq> zs\<close> by simp next case False hence zs: "map Not zs \<in> {ys. ys ! 0 = b ! 0 \<and> length ys = length xs} \<and> xs = inversion (Some i, map Not zs)" using Not_zs by (simp add: nth_map[OF \<open>0 < length zs\<close>]) have b: "b \<in> {ys. ys ! 0 = b ! 0 \<and> length ys = length xs} \<and> xs = inversion (Some i, b)" using * by simp hence "b \<in> {ys. ys ! 0 = b ! 0 \<and> length ys = length xs}" .. with *[symmetric] have "xs \<in> (\<lambda>x. inversion (Some i, x)) ` {ys. ys ! 0 = b ! 0 \<and> length ys = length xs}" by (rule image_eqI) from this[unfolded image_ex1_eq[OF inj_inv]] b zs show "b = map Not zs" by (rule Ex1_eq) qed qed moreover have "zs \<noteq> map Not zs" using \<open>0 < length zs\<close> by (cases zs) simp_all ultimately show ?thesis by simp qed lemma finite_dc_crypto: "finite dc_crypto" using finite_lists_length_eq[where A="UNIV :: bool set"] unfolding dc_crypto by simp lemma card_inversion: assumes "xs \<in> inversion ` dc_crypto" shows "card {dc \<in> dc_crypto. inversion dc = xs} = 2 * n" proof - let ?set = "\<lambda>i. {dc \<in> dc_crypto. payer dc = Some i \<and> inversion dc = xs}" let ?sets = "{?set i | i. i < n}" have [simp]: "length xs = n" using assms by (auto simp: dc_crypto inversion_def [abs_def]) have "{dc \<in> dc_crypto. inversion dc = xs} = (\<Union>i < n. ?set i)" unfolding dc_crypto payer_def by auto also have "\<dots> = (\<Union>?sets)" by auto finally have eq_Union: "{dc \<in> dc_crypto. inversion dc = xs} = (\<Union>?sets)" by simp have card_double: "2 * card ?sets = card (\<Union>?sets)" proof (rule card_partition) show "finite ?sets" by simp { fix i assume "i < n" have "?set i \<subseteq> dc_crypto" by auto have "finite (?set i)" using finite_dc_crypto by auto } thus "finite (\<Union>?sets)" by auto next fix c assume "c \<in> ?sets" thus "card c = 2" using card_payer_and_inversion[OF assms] by auto next fix x y assume "x \<in> ?sets" and "y \<in> ?sets" "x \<noteq> y" then obtain i j where xy: "x = ?set i" "y = ?set j" by auto hence "i \<noteq> j" using \<open>x \<noteq> y\<close> by auto thus "x \<inter> y = {}" using xy by auto qed have sets: "?sets = ?set ` {..< n}" unfolding image_def by auto { fix i j :: nat assume asm: "i \<noteq> j" "i < n" "j < n" { assume iasm: "?set i = {}" have "card (?set i) = 2" using card_payer_and_inversion[OF assms \<open>i < n\<close>] by auto hence "False" using iasm by auto } then obtain c where ci: "c \<in> ?set i" by blast hence cj: "c \<notin> ?set j" using asm by auto { assume "?set i = ?set j" hence "False" using ci cj by auto } hence "?set i \<noteq> ?set j" by auto } hence "inj_on ?set {..< n}" unfolding inj_on_def by auto from card_image[OF this] have "card (?set ` {..< n}) = n" by auto hence "card ?sets = n" using sets by auto thus ?thesis using eq_Union card_double by auto qed lemma card_dc_crypto: "card dc_crypto = n * 2^n" unfolding dc_crypto using card_lists_length_eq[of "UNIV :: bool set"] by (simp add: card_cartesian_product card_image) lemma card_image_inversion: "card (inversion ` dc_crypto) = 2^(n - 1)" proof - let ?P = "{inversion -` {x} \<inter> dc_crypto |x. x \<in> inversion ` dc_crypto}" have "\<Union>?P = dc_crypto" by auto { fix a b assume *: "(a, b) \<in> dc_crypto" have inv_SOME: "inversion (SOME x. inversion x = inversion (a, b) \<and> x \<in> dc_crypto) = inversion (a, b)" apply (rule someI2) by (auto simp: *) } note inv_SOME = this { fix a b assume *: "(a, b) \<in> dc_crypto" have "(SOME x. inversion x = inversion (a, b) \<and> x \<in> dc_crypto) \<in> dc_crypto" by (rule someI2) (auto simp: *) } note SOME_inv_dc = this have "bij_betw (\<lambda>s. inversion (SOME x. x \<in> s \<and> x \<in> dc_crypto)) {inversion -` {x} \<inter> dc_crypto |x. x \<in> inversion ` dc_crypto} (inversion ` dc_crypto)" unfolding bij_betw_def by (auto intro!: inj_onI image_eqI simp: inv_SOME SOME_inv_dc) hence card_eq: "card {inversion -` {x} \<inter> dc_crypto |x. x \<in> inversion ` dc_crypto} = card (inversion ` dc_crypto)" by (rule bij_betw_same_card) have "(2*n) * card (inversion ` dc_crypto) = card (\<Union>?P)" unfolding card_eq[symmetric] proof (rule card_partition) have "\<Union>?P \<subseteq> dc_crypto" by auto thus "finite (\<Union>?P)" using finite_dc_crypto by (auto intro: finite_subset) have "?P = (\<lambda>x. inversion -` {x} \<inter> dc_crypto) ` (inversion ` dc_crypto)" by auto thus "finite ?P" using finite_dc_crypto by auto next fix c assume "c \<in> {inversion -` {x} \<inter> dc_crypto |x. x \<in> inversion ` dc_crypto}" then obtain x where "c = inversion -` {x} \<inter> dc_crypto" and x: "x \<in> inversion ` dc_crypto" by auto hence "c = {dc \<in> dc_crypto. inversion dc = x}" by auto thus "card c = 2 * n" using card_inversion[OF x] by simp next fix x y assume "x \<in> ?P" "y \<in> ?P" and "x \<noteq> y" then obtain i j where x: "x = inversion -` {i} \<inter> dc_crypto" and i: "i \<in> inversion ` dc_crypto" and y: "y = inversion -` {j} \<inter> dc_crypto" and j: "j \<in> inversion ` dc_crypto" by auto show "x \<inter> y = {}" using x y \<open>x \<noteq> y\<close> by auto qed hence "2 * card (inversion ` dc_crypto) = 2 ^ n" unfolding \<open>\<Union>?P = dc_crypto\<close> card_dc_crypto using n_gt_3 by auto thus ?thesis by (cases n) auto qed end sublocale dining_cryptographers_space \<subseteq> prob_space "uniform_count_measure dc_crypto" by (rule prob_space_uniform_count_measure[OF finite_dc_crypto]) (insert n_gt_3, auto simp: dc_crypto intro: exI[of _ "replicate n True"]) sublocale dining_cryptographers_space \<subseteq> information_space "uniform_count_measure dc_crypto" 2 by standard auto notation (in dining_cryptographers_space) mutual_information_Pow ("\<I>'( _ ; _ ')") notation (in dining_cryptographers_space) entropy_Pow ("\<H>'( _ ')") notation (in dining_cryptographers_space) conditional_entropy_Pow ("\<H>'( _ | _ ')") theorem (in dining_cryptographers_space) "\<I>( inversion ; payer ) = 0" proof (rule mutual_information_eq_0_simple) have n: "0 < n" using n_gt_3 by auto have card_image_inversion: "real (card (inversion ` dc_crypto)) = 2^n / 2" unfolding card_image_inversion using \<open>0 < n\<close> by (cases n) auto show inversion: "simple_distributed (uniform_count_measure dc_crypto) inversion (\<lambda>x. 2 / 2^n)" proof (rule simple_distributedI) show "simple_function (uniform_count_measure dc_crypto) inversion" using finite_dc_crypto by (auto simp: simple_function_def space_uniform_count_measure sets_uniform_count_measure) fix x assume "x \<in> inversion ` space (uniform_count_measure dc_crypto)" moreover have "inversion -` {x} \<inter> dc_crypto = {dc \<in> dc_crypto. inversion dc = x}" by auto ultimately show "2 / 2^n = prob (inversion -` {x} \<inter> space (uniform_count_measure dc_crypto))" using \<open>0 < n\<close> by (simp add: card_inversion card_dc_crypto finite_dc_crypto subset_eq space_uniform_count_measure measure_uniform_count_measure) qed simp show "simple_distributed (uniform_count_measure dc_crypto) payer (\<lambda>x. 1 / real n)" proof (rule simple_distributedI) show "simple_function (uniform_count_measure dc_crypto) payer" using finite_dc_crypto by (auto simp: simple_function_def space_uniform_count_measure sets_uniform_count_measure) fix z assume "z \<in> payer ` space (uniform_count_measure dc_crypto)" then have "payer -` {z} \<inter> dc_crypto = {z} \<times> {xs. length xs = n}" by (auto simp: dc_crypto payer_def space_uniform_count_measure cong del: image_cong_simp) hence "card (payer -` {z} \<inter> dc_crypto) = 2^n" using card_lists_length_eq[where A="UNIV::bool set"] by (simp add: card_cartesian_product_singleton) then show "1 / real n = prob (payer -` {z} \<inter> space (uniform_count_measure dc_crypto))" using finite_dc_crypto by (subst measure_uniform_count_measure) (auto simp add: card_dc_crypto space_uniform_count_measure) qed simp show "simple_distributed (uniform_count_measure dc_crypto) (\<lambda>x. (inversion x, payer x)) (\<lambda>x. 2 / (real n *2^n))" proof (rule simple_distributedI) show "simple_function (uniform_count_measure dc_crypto) (\<lambda>x. (inversion x, payer x))" using finite_dc_crypto by (auto simp: simple_function_def space_uniform_count_measure sets_uniform_count_measure) fix x assume "x \<in> (\<lambda>x. (inversion x, payer x)) ` space (uniform_count_measure dc_crypto)" then obtain i xs where x: "x = (inversion (Some i, xs), payer (Some i, xs))" and "i < n" "length xs = n" by (simp add: image_iff space_uniform_count_measure dc_crypto Bex_def) blast then have xs: "inversion (Some i, xs) \<in> inversion`dc_crypto" and i: "Some i \<in> Some ` {0..<n}" and x: "x = (inversion (Some i, xs), Some i)" by (simp_all add: payer_def dc_crypto) moreover define ys where "ys = inversion (Some i, xs)" ultimately have ys: "ys \<in> inversion`dc_crypto" and "Some i \<in> Some ` {0..<n}" "x = (ys, Some i)" by simp_all then have "(\<lambda>x. (inversion x, payer x)) -` {x} \<inter> space (uniform_count_measure dc_crypto) = {dc \<in> dc_crypto. payer dc = Some (the (Some i)) \<and> inversion dc = ys}" by (auto simp add: payer_def space_uniform_count_measure) then show "2 / (real n * 2 ^ n) = prob ((\<lambda>x. (inversion x, payer x)) -` {x} \<inter> space (uniform_count_measure dc_crypto))" using \<open>i < n\<close> ys by (simp add: measure_uniform_count_measure card_payer_and_inversion finite_dc_crypto subset_eq card_dc_crypto) qed simp show "\<forall>x\<in>space (uniform_count_measure dc_crypto). 2 / (real n * 2 ^ n) = 2 / 2 ^ n * (1 / real n) " by simp qed end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % File: Thesis_Introduction.tex % % Tex Master: Thesis.tex % % % % Author: Andre C. Marta % % Last modified : 2 Jul 2015 % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \chapter{Introduction} \label{chapter:introduction} \input{/home/guimas/Documents/Chapters/intro/Chapters/Introduction.tex}
State Before: α : Type u_1 β : Type u_2 inst✝ : Encodable β f : β → Set α hd : Pairwise (Disjoint on f) ⊢ Pairwise (Disjoint on fun i => ⋃ (b : β) (_ : b ∈ decode₂ β i), f b) State After: α : Type u_1 β : Type u_2 inst✝ : Encodable β f : β → Set α hd : Pairwise (Disjoint on f) i j : ℕ ij : i ≠ j ⊢ (Disjoint on fun i => ⋃ (b : β) (_ : b ∈ decode₂ β i), f b) i j Tactic: rintro i j ij State Before: α : Type u_1 β : Type u_2 inst✝ : Encodable β f : β → Set α hd : Pairwise (Disjoint on f) i j : ℕ ij : i ≠ j ⊢ (Disjoint on fun i => ⋃ (b : β) (_ : b ∈ decode₂ β i), f b) i j State After: α : Type u_1 β : Type u_2 inst✝ : Encodable β f : β → Set α hd : Pairwise (Disjoint on f) i j : ℕ ij : i ≠ j x : α ⊢ x ∈ (fun i => ⋃ (b : β) (_ : b ∈ decode₂ β i), f b) i → ¬x ∈ (fun i => ⋃ (b : β) (_ : b ∈ decode₂ β i), f b) j Tactic: refine' disjoint_left.mpr fun x => _ State Before: α : Type u_1 β : Type u_2 inst✝ : Encodable β f : β → Set α hd : Pairwise (Disjoint on f) i j : ℕ ij : i ≠ j x : α ⊢ x ∈ (fun i => ⋃ (b : β) (_ : b ∈ decode₂ β i), f b) i → ¬x ∈ (fun i => ⋃ (b : β) (_ : b ∈ decode₂ β i), f b) j State After: α : Type u_1 β : Type u_2 inst✝ : Encodable β f : β → Set α hd : Pairwise (Disjoint on f) i j : ℕ ij : i ≠ j x : α ⊢ ∀ (a : β), encode a = i → x ∈ f a → ∀ (b : β), encode b = j → ¬x ∈ f b Tactic: suffices ∀ a, encode a = i → x ∈ f a → ∀ b, encode b = j → x ∉ f b by simpa [decode₂_eq_some] State Before: α : Type u_1 β : Type u_2 inst✝ : Encodable β f : β → Set α hd : Pairwise (Disjoint on f) i j : ℕ ij : i ≠ j x : α ⊢ ∀ (a : β), encode a = i → x ∈ f a → ∀ (b : β), encode b = j → ¬x ∈ f b State After: α : Type u_1 β : Type u_2 inst✝ : Encodable β f : β → Set α hd : Pairwise (Disjoint on f) x : α a : β ha : x ∈ f a b : β ij : encode a ≠ encode b hb : x ∈ f b ⊢ False Tactic: rintro a rfl ha b rfl hb State Before: α : Type u_1 β : Type u_2 inst✝ : Encodable β f : β → Set α hd : Pairwise (Disjoint on f) x : α a : β ha : x ∈ f a b : β ij : encode a ≠ encode b hb : x ∈ f b ⊢ False State After: no goals Tactic: exact (hd (mt (congr_arg encode) ij)).le_bot ⟨ha, hb⟩ State Before: α : Type u_1 β : Type u_2 inst✝ : Encodable β f : β → Set α hd : Pairwise (Disjoint on f) i j : ℕ ij : i ≠ j x : α this : ∀ (a : β), encode a = i → x ∈ f a → ∀ (b : β), encode b = j → ¬x ∈ f b ⊢ x ∈ (fun i => ⋃ (b : β) (_ : b ∈ decode₂ β i), f b) i → ¬x ∈ (fun i => ⋃ (b : β) (_ : b ∈ decode₂ β i), f b) j State After: no goals Tactic: simpa [decode₂_eq_some]
Formal statement is: lemma to_fract_diff [simp]: "to_fract (x - y) = to_fract x - to_fract y" Informal statement is: The difference of two fractions is equal to the difference of their numerators divided by the product of their denominators.
/- Copyright (c) 2021 OpenAI. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kunhao Zheng, Stanislas Polu, David Renshaw, OpenAI GPT-f -/ import mathzoo.imports.miniF2F open_locale nat rat real big_operators topological_space theorem mathd_algebra_137 (x : ℕ) (h₀ : ↑x + (4:ℝ) / (100:ℝ) * ↑x = 598) : x = 575 := begin have h₁ : ↑x = (575:ℝ), linarith, assumption_mod_cast, end
lemmas tendsto_mult_left_zero = bounded_bilinear.tendsto_left_zero [OF bounded_bilinear_mult]
import data.nat.basic -- 1ª demostración example (n m : ℕ) (hn : n ≠ 0) (hm : n ≤ m) : m ≠ 0 := begin intro h, simp * at *, end -- 2ª demostración example (n m : ℕ) (hn : n ≠ 0) (hm : n ≤ m) : m ≠ 0 := λ h, by simp * at *
import function.bijection data.list.set data.fin open fin function namespace fin protected lemma le_refl {n} (a : fin n) : a ≤ a := fin.cases_on a (λ a _, nat.le_refl a) protected lemma le_trans {n} {a b c : fin n} : a ≤ b → b ≤ c → a ≤ c := fin.cases_on a (λ _ _, fin.cases_on b (λ _ _, fin.cases_on c (λ _ _, assume Hab Hbc, nat.le_trans Hab Hbc ) ) ) protected lemma le_antisymm {n}{a b : fin n} : a ≤ b → b ≤ a → a = b := fin.cases_on a (λ _ _, fin.cases_on b (λ _ _, assume Hab Hba, fin.eq_of_veq (nat.le_antisymm Hab Hba) ) ) instance {n} : decidable_linear_order (fin n) := { lt := fin.lt, le := fin.le, le_refl := fin.le_refl, le_trans := @fin.le_trans _, le_antisymm := @fin.le_antisymm _, le_iff_lt_or_eq := λ a b, fin.cases_on a (λ i _, fin.cases_on b (λ j _, iff.intro (assume H, or.elim (nat.lt_or_eq_of_le H) or.inl (assume Heq, or.inr (fin.eq_of_veq Heq))) (assume H, nat.le_of_lt_or_eq (or.imp id (begin intro heq, apply (fin.veq_of_eq heq) end) H)) ) ), lt_irrefl := λ a, fin.cases_on a (λ _ _, nat.lt_irrefl _ ), le_total := λ a b, fin.cases_on a (λ _ _, fin.cases_on b (λ _ _, nat.le_total)), decidable_lt := fin.decidable_lt, decidable_le := fin.decidable_le, decidable_eq := fin.decidable_eq _ } def swap {n} (k : fin (n+1)) : fin (n+1) → fin (n+1) := take i, if i = k then 0 else if i = 0 then k else i namespace swap variables {n : ℕ } {k : fin (n+1)} lemma idem : ∀ i, swap k (swap k i) = i := take i, if Hik : i = k then if Hkz : k = 0 then by simp [Hik, Hkz, swap] else begin simp_using_hs [swap], apply if_neg, intro H, apply Hkz, symmetry, assumption end else if Hiz : i = 0 then begin rw Hiz, simp [swap], apply if_pos, apply if_neg, intro H, apply Hik, rw Hiz, assumption end else by simp [swap]; cc lemma has_left_inverse : has_left_inverse (swap k) := ⟨ swap k, idem ⟩ lemma has_right_inverse : has_right_inverse (swap k) := ⟨ swap k, idem ⟩ lemma has_isomorphism : has_bijection(swap k) := ⟨ swap k, idem , idem ⟩ lemma injective : injective (swap k) := injective_of_has_left_inverse has_left_inverse lemma surjective : surjective (swap k) := surjective_of_has_right_inverse has_right_inverse instance : bijection (swap k) := ⟨ swap k, idem , idem ⟩ lemma k_eq_zero : swap k k = 0 := by simp [swap] lemma zero_eq_k : swap k 0 = k := if H : 0 = k then by simp_using_hs [swap] else by simp_using_hs [swap] lemma id_of_zero : swap 0 = @id (fin (n+1)) := begin apply funext, intro i, simp_using_hs [swap], cases (fin.decidable_eq _ i 0) with H H, repeat {simp_using_hs} end end swap lemma ne_zero_of_succ {n} : ∀ i : fin n, fin.succ i ≠ 0 := begin intros i, cases i, unfold fin.succ, intro H, apply (nat.succ_ne_zero val), apply (fin.veq_of_eq H), end lemma succ.injective {n} : injective (@fin.succ n) := begin intros fi fj H, cases fi with i ilt, cases fj with j jlt, simp [fin.succ] at H, apply fin.eq_of_veq, apply nat.succ.inj, simp, exact (fin.veq_of_eq H) end lemma pred.injective {n} {i j : fin (n + 1)} { ine0 : i ≠ 0} { jne0 : j ≠ 0} : fin.pred i ine0 = fin.pred j jne0 → i = j := begin cases i with ival ilt, cases j with jval jlt, simp [fin.pred], intro H, apply fin.eq_of_veq, simp, apply nat.pred_inj, { -- ival > 0 apply nat.pos_of_ne_zero, exact (fin.vne_of_ne ine0) }, { -- jval > 0 apply nat.pos_of_ne_zero, exact (fin.vne_of_ne jne0) }, { exact (fin.veq_of_eq H) } end /-- A proof of pigeonhole principle. -/ theorem not_injective_of_gt {m n} (f : fin m → fin n) : m > n → ¬ injective f := begin revert m, induction n with n iH, { intros m f H Hinj, cases (f ⟨0, H⟩ ) with val is_lt, exact (absurd is_lt (nat.not_lt_zero _)) }, { intros m f Hmn Hinj, pose pred_m := nat.pred m, assert Hm : m = nat.succ pred_m, { symmetry, apply nat.succ_pred_eq_of_pos, transitivity, exact Hmn, apply nat.zero_lt_succ }, revert f Hmn, rw Hm, intros f Hpmn Hinj, pose g := swap (f 0) ∘ f ∘ fin.succ, assert Hgnz : ∀ i, g i ≠ 0, { intros i Hgz, apply (ne_zero_of_succ i), apply Hinj, apply (@swap.injective _ (f 0)), rw swap.k_eq_zero, assumption }, pose h := λ i, fin.pred (g i) (Hgnz i), apply (iH h), { apply nat.le_of_succ_le_succ, apply Hpmn, }, { intros i₁ i₂ Heq, apply succ.injective, apply Hinj, apply swap.injective, apply pred.injective, assumption } } end def elems : ∀ n : ℕ, list (fin n) | 0 := [] | (n+1) := 0 :: list.map fin.succ (elems n) lemma succ_ne_zero {n} (i : fin n) : fin.succ i ≠ 0 := begin cases i, simp [fin.succ], apply fin.ne_of_vne, rw fin.val_zero, simp, apply nat.succ_ne_zero end /- lemma nodup_elems : ∀ n, list.nodup (elems n) | 0 := list.nodup_nil | (n+1) := list.nodup_cons (λ h, exists.elim (list.exists_of_mem_map h) (λ i hp, succ_ne_zero _ hp.right)) (list.nodup_map succ.injective (nodup_elems n)) -/ def mem_elems : ∀ {n} (i : fin n), i ∈ elems n | 0 ⟨_ , is_lt⟩ := absurd is_lt (nat.not_lt_zero _) | (n+1) ⟨0 , _⟩ := list.mem_cons_self _ _ | (n+1) ⟨i + 1, is_lt⟩ := list.mem_cons_of_mem _ (list.mem_map fin.succ (mem_elems ⟨i, nat.le_of_succ_le_succ is_lt⟩)) def {u} nth { α : Type u} : Π (l : list α), fin (list.length l) → α | [] ⟨_, is_lt⟩ := absurd is_lt (nat.not_lt_zero _) | (x :: xs) ⟨0, _⟩ := x | (_ :: xs) ⟨n+1, is_lt⟩ := nth xs ⟨n, nat.le_of_succ_le_succ is_lt⟩ lemma {u} mem_nth {α : Type u} : ∀ (l : list α) i, nth l i ∈ l | [] ⟨_, is_lt⟩ := absurd is_lt (nat.not_lt_zero _) | (x :: xs) ⟨0, _⟩ := list.mem_cons_self _ _ | (_ :: xs) ⟨i+1, is_lt⟩ := list.mem_cons_of_mem _ $ mem_nth xs ⟨i, nat.le_of_succ_le_succ is_lt⟩ def {u} left_index {α : Type u}[decidable_eq α]{a} : Π {l : list α}, a ∈ l → fin (list.length l) | [] h := absurd h (list.not_mem_nil _) | (x::xs) h := if H : a = x then (0 : fin ((list.length xs) + 1)) else fin.succ $ left_index $ or.resolve_left h H def {u} nth_left_index_left_inverse {α : Type u} [deq : decidable_eq α] {l : list α} {a} (h : a ∈ l) : nth l (left_index h) = a := begin induction l with x xs iH, { exact (absurd h (list.not_mem_nil _)) }, { unfold left_index, cases (deq a x) with Hne Heq, { rw dif_neg, assert Hmem : a ∈ xs, apply or.resolve_left, assumption, assumption, change nth (x :: xs) (fin.succ (left_index Hmem)) = a, assert Lem : ∀ a x (xs : list α)(H : a ∈ xs), nth (x :: xs) (fin.succ (left_index H)) = nth xs (left_index H), { intros a x xs H, generalize (left_index H) i, intro i, cases i, simp [fin.succ, nth], refl }, rw Lem, apply iH, assumption }, { rw dif_pos, rw Heq, refl, assumption } } end lemma {u} nth_ne_nth_of_nodup_of_lt {α : Type u} {l : list α} : Π {i j : fin (list.length l)}, list.nodup l → i < j → nth l i ≠ nth l j := begin induction l with x xs iH, { intro i, exact (absurd i.is_lt (nat.not_lt_zero _)) }, { intros i j Hdis Hlt Heq, cases i with i ilt, cases j with j jlt, assert Hj : j = nat.succ (nat.pred j), { symmetry, apply nat.succ_pred_eq_of_pos, apply nat.lt_of_le_of_lt, apply nat.zero_le, assumption }, revert jlt, rw Hj, intros jlt Hlt Heq, cases i with i, { simp [nth] at Heq, apply (list.not_mem_of_nodup_cons Hdis), rw Heq, apply mem_nth }, { simp [nth] at Heq, apply (@iH ⟨i, nat.lt_of_succ_lt_succ ilt⟩ ⟨nat.pred j, nat.lt_of_succ_lt_succ jlt⟩ ), apply list.nodup_of_nodup_cons, assumption, exact (nat.lt_of_succ_lt_succ Hlt), assumption } } end lemma {u} left_index_mem_nth_left_inverse_of_nodup {α : Type u}[decidable_eq α]{l : list α} : list.nodup l → ∀ i, left_index (mem_nth l i) = i := begin intros Hdis i, induction Hdis with x xs Hx dxs iH, { exact (absurd i.is_lt (nat.not_lt_zero _)) }, { cases i with i ilt, cases i with i, { change left_index (list.mem_cons_self x xs) = ⟨0, _⟩, simp [left_index], rw dif_pos, refl, refl }, { simp [left_index, mem_nth], rw dif_neg, assert Lem : ∀ {n}(i : fin n), (fin.succ i).val = nat.succ i.val, { intros n i, cases i, simp [fin.succ] }, apply fin.eq_of_veq, rw Lem, simp, apply (congr_arg nat.succ), pose j : fin (list.length xs) := ⟨i, nat.lt_of_succ_lt_succ ilt⟩, change (left_index (mem_nth xs j)).val = j.val, apply fin.veq_of_eq, apply iH, simp [nth], intro H, apply Hx, rw -H, apply mem_nth } } end lemma {u} injective_nth_of_nodup {α : Type u}{l : list α} : list.nodup l → injective (nth l) := assume Hdis, take i j, assume H, if Heq : i = j then Heq else if Hlt : i < j then absurd H (nth_ne_nth_of_nodup_of_lt Hdis Hlt) else have j < i, from or.resolve_left (lt_or_gt_of_ne Heq) Hlt, absurd (eq.symm H) (nth_ne_nth_of_nodup_of_lt Hdis this) lemma length_le_of_nodup_fin {n} {l : list (fin n)} : list.nodup l → list.length l ≤ n := begin intro Hdis, induction l with x xs iH, { exact (nat.zero_le _) }, { apply le_of_not_gt, unfold list.length, intro Hgt, pose f : fin (list.length xs + 1) → fin n := nth (x::xs), apply not_injective_of_gt f Hgt, intros i j Hf, cases (fin.decidable_eq _ i j) with Hne Heq, { assert Ho : i < j ∨ i > j, { cases i with i ilt, cases j with j jlt, change (i < j ∨ i > j), apply lt_or_gt_of_ne, apply (fin.vne_of_ne Hne) }, cases Ho with Hlt Hgt, { exact (absurd Hf (nth_ne_nth_of_nodup_of_lt Hdis Hlt)) }, { exact (absurd (eq.symm Hf) (nth_ne_nth_of_nodup_of_lt Hdis Hgt)) } }, { exact Heq } } end end fin
namespace prop_16 variables A B : Prop theorem prop_16 : ((¬ A → B) ∧ (¬ A → ¬ B)) → A := assume h1: (¬ A → B) ∧ (¬ A → ¬ B), have h2: ¬ A → B, from and.left h1, have h3: ¬ A → ¬ B, from and.right h1, show A, from (classical.by_contradiction (assume h4: ¬ A, have h5: B, from h2 h4, have h6: ¬ B, from h3 h4, show false, from h6 h5)) -- end namespace end prop_16
theory Proofs_no_setVarAny imports HandDryer_no_setVarAny VCTheoryLemmas_no_setVarAny Extra_no_setVarAny begin theorem proof_1_1: "VC1 inv1 s0" apply(simp only: VC1_def inv1_def R1_def extraInv_def waiting_def drying_def) by auto theorem proof_2_1: "VC1 inv2 s0" apply(simp only: VC1_def inv2_def R2_def extraInv_def waiting_def drying_def) by auto theorem proof_3_1: "VC1 inv3 s0" apply(simp only: VC1_def inv3_def R3_def extraInv_def waiting_def drying_def) by auto theorem proof_4_1: "VC1 inv4 s0" apply(simp only: VC1_def inv4_def R4_def extraInv_def waiting_def drying_def) by auto theorem proof_2_2: "VC2 inv2 s0 hands_value" apply(simp only: VC2_def inv2_def R2_def dryer_def) apply(rule impI; rule conjI) apply(auto) using extra2 by (auto simp add: VC2_def dryer_def) theorem proof_2_3: "VC3 inv2 s0 hands_value" apply(simp only: VC3_def inv2_def R2_def dryer_def) apply(rule impI; rule conjI) apply(auto) using extra3 by (auto simp add: VC3_def dryer_def) theorem proof_2_4: "VC4 inv2 s0 hands_value" apply(simp only: VC4_def R2_def dryer_def) by auto theorem proof_2_5: "VC5 inv2 s0 hands_value" apply(simp only: VC5_def inv2_def R2_def dryer_def) apply(rule impI; rule conjI) apply(auto) using extra5 by (auto simp add: VC5_def) theorem proof_2_6: "VC6 inv2 s0 hands_value" apply(simp only: VC6_def inv2_def R2_def dryer_def) apply(rule impI; rule conjI) apply(rule conjI) apply simp apply((rule allI)+) apply(rule impI) apply(simp split: if_splits) using substate_toEnvNum_id apply blast apply auto[1] using extra6 by (auto simp add: VC6_def) theorem proof_2_7: "VC7 inv2 s0 hands_value" apply(simp only: VC7_def inv2_def R2_def dryer_def) apply(rule impI; rule conjI) apply(auto) apply force using substate_toEnvNum_id apply blast using extra7 by (auto simp add: VC7_def) theorem proof_4_2: "VC2 inv4 s0 hands_value" apply(simp only: VC2_def inv4_def R4_def dryer_def) apply(rule impI; rule conjI) apply(auto) using extra2 by (auto simp add: VC2_def dryer_def) theorem proof_4_3: "VC3 inv4 s0 hands_value" apply(simp only: VC3_def inv4_def R4_def dryer_def) apply(rule impI; rule conjI) apply(auto) using extra3 by (auto simp add: VC3_def dryer_def) theorem proof_4_4: "VC4 inv4 s0 hands_value" apply(simp only: VC4_def R4_def dryer_def) by auto theorem proof_4_5: "VC5 inv4 s0 hands_value" apply(simp only: VC5_def inv4_def R4_def dryer_def) apply(rule impI; rule conjI) apply(auto) apply(force) using substate_toEnvNum_id apply(blast) using extra5 by (auto simp add: VC5_def) theorem proof_4_6: "VC6 inv4 s0 hands_value" apply(simp only: VC6_def inv4_def R4_def dryer_def) apply(rule impI; rule conjI) apply(auto) using extra6 by (auto simp add: VC6_def) theorem proof_4_7: "VC7 inv4 s0 hands_value" apply(simp only: VC7_def inv4_def R4_def dryer_def) apply(rule impI; rule conjI) apply(auto) using extra7 by (auto simp add: VC7_def) theorem proof_1_4: "VC4 inv1 s0 hands_value" apply(simp only: VC4_def R1_def dryer_def) by auto theorem proof_3_4: "VC4 inv3 s0 hands_value" apply(simp only: VC4_def R3_def dryer_def) by auto end
[GOAL] p : ℕ → Prop x : ℕ h : p x ⊢ WellFounded (Upto.GT p) [PROOFSTEP] suffices Upto.GT p = InvImage (· < ·) fun y : Nat.Upto p => x - y.val by rw [this] exact (measure _).wf [GOAL] p : ℕ → Prop x : ℕ h : p x this : Upto.GT p = InvImage (fun x x_1 => x < x_1) fun y => x - ↑y ⊢ WellFounded (Upto.GT p) [PROOFSTEP] rw [this] [GOAL] p : ℕ → Prop x : ℕ h : p x this : Upto.GT p = InvImage (fun x x_1 => x < x_1) fun y => x - ↑y ⊢ WellFounded (InvImage (fun x x_1 => x < x_1) fun y => x - ↑y) [PROOFSTEP] exact (measure _).wf [GOAL] p : ℕ → Prop x : ℕ h : p x ⊢ Upto.GT p = InvImage (fun x x_1 => x < x_1) fun y => x - ↑y [PROOFSTEP] ext ⟨a, ha⟩ ⟨b, _⟩ [GOAL] case h.mk.h.mk.a p : ℕ → Prop x : ℕ h : p x a : ℕ ha : ∀ (j : ℕ), j < a → ¬p j b : ℕ property✝ : ∀ (j : ℕ), j < b → ¬p j ⊢ Upto.GT p { val := a, property := ha } { val := b, property := property✝ } ↔ InvImage (fun x x_1 => x < x_1) (fun y => x - ↑y) { val := a, property := ha } { val := b, property := property✝ } [PROOFSTEP] dsimp [InvImage, Upto.GT] [GOAL] case h.mk.h.mk.a p : ℕ → Prop x : ℕ h : p x a : ℕ ha : ∀ (j : ℕ), j < a → ¬p j b : ℕ property✝ : ∀ (j : ℕ), j < b → ¬p j ⊢ a > b ↔ x - a < x - b [PROOFSTEP] rw [tsub_lt_tsub_iff_left_of_le (le_of_not_lt fun h' => ha _ h' h)] [GOAL] p : ℕ → Prop x : Upto p h : ¬p ↑x j : ℕ h' : j < Nat.succ ↑x ⊢ ¬p j [PROOFSTEP] rcases Nat.lt_succ_iff_lt_or_eq.1 h' with (h' | rfl) <;> [exact x.2 _ h'; exact h] [GOAL] p : ℕ → Prop x : Upto p h : ¬p ↑x j : ℕ h' : j < Nat.succ ↑x ⊢ ¬p j [PROOFSTEP] rcases Nat.lt_succ_iff_lt_or_eq.1 h' with (h' | rfl) [GOAL] case inl p : ℕ → Prop x : Upto p h : ¬p ↑x j : ℕ h'✝ : j < Nat.succ ↑x h' : j < ↑x ⊢ ¬p j [PROOFSTEP] exact x.2 _ h' [GOAL] case inr p : ℕ → Prop x : Upto p h : ¬p ↑x h' : ↑x < Nat.succ ↑x ⊢ ¬p ↑x [PROOFSTEP] exact h
Formal statement is: corollary fps_coeff_residues_bigo': fixes f :: "complex \<Rightarrow> complex" and r :: real assumes exp: "f has_fps_expansion F" assumes "open A" "connected A" "cball 0 r \<subseteq> A" "r > 0" assumes "f holomorphic_on A - S" "S \<subseteq> ball 0 r" "finite S" "0 \<notin> S" assumes "eventually (\<lambda>n. g n = -(\<Sum>z\<in>S. residue (\<lambda>z. f z / z ^ Suc n) z)) sequentially" (is "eventually (\<lambda>n. _ = -?g' n) _") shows "(\<lambda>n. fps_nth F n - g n) \<in> O(\<lambda>n. 1 / r ^ n)" (is "(\<lambda>n. ?c n - _) \<in> O(_)") Informal statement is: Suppose $f$ is a holomorphic function on a connected open set $A$ that contains the closed ball of radius $r$ centered at the origin. Suppose $f$ has a power series expansion about the origin. Suppose $S$ is a finite set of points in the open ball of radius $r$ centered at the origin, and $0 \notin S$. Then the coefficients of the power series expansion of $f$ are asymptotically equal to the sum of the residues of $f$ at the points in $S$.
(** We test memory usage of typeclass resification of let-binders to PHOAS *) Generalizable All Variables. Axiom Let_In : forall {A P} (v : A) (f : forall x : A, P x), P v. Fixpoint nested_lets (n : nat) (init : nat) : nat := match n with | O => init + init | S n => Let_In (init + init) (fun x => nested_lets n x) end. Inductive type := NAT. Inductive expr {var : type -> Type} : type -> Type := | Zero : expr NAT | Succ (n : expr NAT) : expr NAT | Plus (x y : expr NAT) : expr NAT | LetIn {A B} (x : expr A) (f : var A -> expr B) : expr B | Var {T} (v : var T) : expr T . Axiom P : forall {var t}, @expr var t -> Prop. Axiom p : forall var t e, @P var t e. Ltac solve_P := intros; apply p. Class type_reified_of (v : Type) (t : type) := dummyT : True. Typeclasses Opaque type_reified_of. Global Hint Mode type_reified_of ! - : typeclass_instances. Global Instance reify_nat : type_reified_of nat NAT := I. Class reified_of {var A B} (v : A) (e : @expr var B) := dummy : True. Typeclasses Opaque reified_of. Typeclasses Opaque Nat.add. Global Hint Mode reified_of - - - ! - : typeclass_instances. Global Instance reify_plus {var x ex y ey} {_:reified_of x ex} {_:reified_of y ey} : reified_of (x + y) (@Plus var ex ey) := I. Global Instance reify_LetIn {var A B tA tB x ex f ef} {_:reified_of x ex} {_:forall v ev, reified_of v (Var ev) -> reified_of (f v) (ef ev)} : reified_of (@Let_In A (fun _ => B) x f) (@LetIn var tA tB ex ef) := I. Global Instance reify_0 {var} : reified_of 0 (@Zero var) := I. Global Instance reify_S {var n en} {_:reified_of n en} : reified_of (S n) (@Succ var en) := I. Definition reify {var T T'} (v : T) {ev : @expr var T'} {_ : reified_of v ev} := ev. Ltac subst_evars := repeat match goal with | [ x := ?e |- _ ] => is_evar e; subst x end. Global Hint Extern 0 (reified_of _ _) => progress (cbv [nested_lets]; subst_evars) : typeclass_instances. Notation reified var' v := (match _ return _ with t => match _ : @expr var' t return _ with e => match _ : reified_of v e with _ => e end end end) (only parsing). Notation goal n := (forall var, P (reified var (nested_lets n 0))) (only parsing). Time Definition foo10 : goal 10. Time solve_P. Time Qed.
lemma upd_surj: "upd ` {..< n} = {..< n}"
parameters (eq : a -> a -> Bool) lookup : a -> List (a, b) -> Maybe b lookup x [] = Nothing lookup x ((k, v) :: ys) = if eq x k then Just v else lookup x ys data Dict : Type -> Type where MkDict : List (a, b) -> Dict b lookupK : a -> Dict b -> Maybe b lookupK k (MkDict xs) = lookup k xs testDict : Dict {a=Int} (==) String testDict = MkDict _ [(0, "foo"), (1, "bar")] parameters (y : ?) -- test that the type of 'y' can be inferred foo : (x : Int) -> x = y -> Int foo x@_ Refl = 42
section \<open>Return and their corresponding call nodes\<close> theory ReturnAndCallNodes imports CFG begin context CFG begin subsection \<open>Defining \<open>return_node\<close>\<close> definition return_node :: "'node \<Rightarrow> bool" where "return_node n \<equiv> \<exists>a a'. valid_edge a \<and> n = targetnode a \<and> valid_edge a' \<and> a \<in> get_return_edges a'" lemma return_node_determines_call_node: assumes "return_node n" shows "\<exists>!n'. \<exists>a a'. valid_edge a \<and> n' = sourcenode a \<and> valid_edge a' \<and> a' \<in> get_return_edges a \<and> n = targetnode a'" proof(rule ex_ex1I) from \<open>return_node n\<close> show "\<exists>n' a a'. valid_edge a \<and> n' = sourcenode a \<and> valid_edge a' \<and> a' \<in> get_return_edges a \<and> n = targetnode a'" by(simp add:return_node_def) blast next fix n' nx assume "\<exists>a a'. valid_edge a \<and> n' = sourcenode a \<and> valid_edge a' \<and> a' \<in> get_return_edges a \<and> n = targetnode a'" and "\<exists>a a'. valid_edge a \<and> nx = sourcenode a \<and> valid_edge a' \<and> a' \<in> get_return_edges a \<and> n = targetnode a'" then obtain a a' ax ax' where "valid_edge a" and "n' = sourcenode a" and "valid_edge a'" and "a' \<in> get_return_edges a" and "n = targetnode a'" and "valid_edge ax" and "nx = sourcenode ax" and "valid_edge ax'" and "ax' \<in> get_return_edges ax" and "n = targetnode ax'" by blast from \<open>valid_edge a\<close> \<open>a' \<in> get_return_edges a\<close> have "valid_edge a'" by(rule get_return_edges_valid) from \<open>valid_edge a\<close> \<open>a' \<in> get_return_edges a\<close> obtain a'' where intra_edge1:"valid_edge a''" "sourcenode a'' = sourcenode a" "targetnode a'' = targetnode a'" "kind a'' = (\<lambda>cf. False)\<^sub>\<surd>" by(fastforce dest:call_return_node_edge) from \<open>valid_edge ax\<close> \<open>ax' \<in> get_return_edges ax\<close> obtain ax'' where intra_edge2:"valid_edge ax''" "sourcenode ax'' = sourcenode ax" "targetnode ax'' = targetnode ax'" "kind ax'' = (\<lambda>cf. False)\<^sub>\<surd>" by(fastforce dest:call_return_node_edge) from \<open>valid_edge a\<close> \<open>a' \<in> get_return_edges a\<close> obtain Q r p fs where "kind a = Q:r\<hookrightarrow>\<^bsub>p\<^esub>fs" by(fastforce dest!:only_call_get_return_edges) with \<open>valid_edge a\<close> \<open>a' \<in> get_return_edges a\<close> obtain Q' p f' where "kind a' = Q'\<hookleftarrow>\<^bsub>p\<^esub>f'" by(fastforce dest!:call_return_edges) with \<open>valid_edge a'\<close> have "\<exists>!a''. valid_edge a'' \<and> targetnode a'' = targetnode a' \<and> intra_kind(kind a'')" by(rule return_only_one_intra_edge) with intra_edge1 intra_edge2 \<open>n = targetnode a'\<close> \<open>n = targetnode ax'\<close> have "a'' = ax''" by(fastforce simp:intra_kind_def) with \<open>sourcenode a'' = sourcenode a\<close> \<open>sourcenode ax'' = sourcenode ax\<close> \<open>n' = sourcenode a\<close> \<open>nx = sourcenode ax\<close> show "n' = nx" by simp qed lemma return_node_THE_call_node: "\<lbrakk>return_node n; valid_edge a; valid_edge a'; a' \<in> get_return_edges a; n = targetnode a'\<rbrakk> \<Longrightarrow> (THE n'. \<exists>a a'. valid_edge a \<and> n' = sourcenode a \<and> valid_edge a' \<and> a' \<in> get_return_edges a \<and> n = targetnode a') = sourcenode a" by(fastforce intro!:the1_equality return_node_determines_call_node) subsection \<open>Defining call nodes belonging to a certain \<open>return_node\<close>\<close> definition call_of_return_node :: "'node \<Rightarrow> 'node \<Rightarrow> bool" where "call_of_return_node n n' \<equiv> \<exists>a a'. return_node n \<and> valid_edge a \<and> n' = sourcenode a \<and> valid_edge a' \<and> a' \<in> get_return_edges a \<and> n = targetnode a'" lemma return_node_call_of_return_node: "return_node n \<Longrightarrow> \<exists>!n'. call_of_return_node n n'" by -(frule return_node_determines_call_node,unfold call_of_return_node_def,simp) lemma call_of_return_nodes_det [dest]: assumes "call_of_return_node n n'" and "call_of_return_node n n''" shows "n' = n''" proof - from \<open>call_of_return_node n n'\<close> have "return_node n" by(simp add:call_of_return_node_def) hence "\<exists>!n'. call_of_return_node n n'" by(rule return_node_call_of_return_node) with \<open>call_of_return_node n n'\<close> \<open>call_of_return_node n n''\<close> show ?thesis by auto qed lemma get_return_edges_call_of_return_nodes: "\<lbrakk>valid_call_list cs m; valid_return_list rs m; \<forall>i < length rs. rs!i \<in> get_return_edges (cs!i); length rs = length cs\<rbrakk> \<Longrightarrow> \<forall>i<length cs. call_of_return_node (targetnodes rs!i) (sourcenode (cs!i))" proof(induct cs arbitrary:m rs) case Nil thus ?case by fastforce next case (Cons c' cs') note IH = \<open>\<And>m rs. \<lbrakk>valid_call_list cs' m; valid_return_list rs m; \<forall>i<length rs. rs ! i \<in> get_return_edges (cs' ! i); length rs = length cs'\<rbrakk> \<Longrightarrow> \<forall>i<length cs'. call_of_return_node (targetnodes rs ! i) (sourcenode (cs'!i))\<close> from \<open>length rs = length (c' # cs')\<close> obtain r' rs' where "rs = r' # rs'" and "length rs' = length cs'" by(cases rs) auto with \<open>\<forall>i<length rs. rs ! i \<in> get_return_edges ((c' # cs') ! i)\<close> have "\<forall>i<length rs'. rs' ! i \<in> get_return_edges (cs' ! i)" and "r' \<in> get_return_edges c'" by auto from \<open>valid_call_list (c'#cs') m\<close> have "valid_edge c'" by(fastforce simp:valid_call_list_def) from this \<open>r' \<in> get_return_edges c'\<close> have "get_proc (sourcenode c') = get_proc (targetnode r')" by(rule get_proc_get_return_edge) from \<open>valid_call_list (c'#cs') m\<close> have "valid_call_list cs' (sourcenode c')" apply(clarsimp simp:valid_call_list_def) apply(hypsubst_thin) apply(erule_tac x="c'#cs'" in allE) apply clarsimp by(case_tac cs')(auto simp:sourcenodes_def) from \<open>valid_return_list rs m\<close> \<open>rs = r' # rs'\<close> \<open>get_proc (sourcenode c') = get_proc (targetnode r')\<close> have "valid_return_list rs' (sourcenode c')" apply(clarsimp simp:valid_return_list_def) apply(erule_tac x="r'#cs'" in allE) apply clarsimp by(case_tac cs')(auto simp:targetnodes_def) from IH[OF \<open>valid_call_list cs' (sourcenode c')\<close> \<open>valid_return_list rs' (sourcenode c')\<close> \<open>\<forall>i<length rs'. rs' ! i \<in> get_return_edges (cs' ! i)\<close> \<open>length rs' = length cs'\<close>] have all:"\<forall>i<length cs'. call_of_return_node (targetnodes rs' ! i) (sourcenode (cs' ! i))" . from \<open>valid_edge c'\<close> \<open>r' \<in> get_return_edges c'\<close> have "valid_edge r'" by(rule get_return_edges_valid) from \<open>valid_edge r'\<close> \<open>valid_edge c'\<close> \<open>r' \<in> get_return_edges c'\<close> have "return_node (targetnode r')" by(fastforce simp:return_node_def) with \<open>valid_edge c'\<close> \<open>r' \<in> get_return_edges c'\<close> \<open>valid_edge r'\<close> have "call_of_return_node (targetnode r') (sourcenode c')" by(simp add:call_of_return_node_def) blast with all \<open>rs = r' # rs'\<close> show ?case by auto(case_tac i,auto simp:targetnodes_def) qed end end
State Before: G : Type u_1 inst✝ : Group G H K : Subgroup G S T : Set G f : G ⧸ H → G hf : ∀ (q : G ⧸ H), ↑(f q) = q ⊢ Function.Injective (Set.restrict (Set.range f) Quotient.mk'') State After: case mk.intro.mk.intro G : Type u_1 inst✝ : Group G H K : Subgroup G S T : Set G f : G ⧸ H → G hf : ∀ (q : G ⧸ H), ↑(f q) = q q₁ q₂ : G ⧸ H h : Set.restrict (Set.range f) Quotient.mk'' { val := f q₁, property := (_ : ∃ y, f y = f q₁) } = Set.restrict (Set.range f) Quotient.mk'' { val := f q₂, property := (_ : ∃ y, f y = f q₂) } ⊢ { val := f q₁, property := (_ : ∃ y, f y = f q₁) } = { val := f q₂, property := (_ : ∃ y, f y = f q₂) } Tactic: rintro ⟨-, q₁, rfl⟩ ⟨-, q₂, rfl⟩ h State Before: case mk.intro.mk.intro G : Type u_1 inst✝ : Group G H K : Subgroup G S T : Set G f : G ⧸ H → G hf : ∀ (q : G ⧸ H), ↑(f q) = q q₁ q₂ : G ⧸ H h : Set.restrict (Set.range f) Quotient.mk'' { val := f q₁, property := (_ : ∃ y, f y = f q₁) } = Set.restrict (Set.range f) Quotient.mk'' { val := f q₂, property := (_ : ∃ y, f y = f q₂) } ⊢ { val := f q₁, property := (_ : ∃ y, f y = f q₁) } = { val := f q₂, property := (_ : ∃ y, f y = f q₂) } State After: no goals Tactic: exact Subtype.ext $ congr_arg f $ ((hf q₁).symm.trans h).trans (hf q₂)
Formal statement is: lemma order_degree: assumes p: "p \<noteq> 0" shows "order a p \<le> degree p" Informal statement is: If $p$ is a nonzero polynomial, then the order of $a$ modulo $p$ is at most the degree of $p$.
lemma simply_connected_eq_contractible_loop_any: fixes S :: "_::real_normed_vector set" shows "simply_connected S \<longleftrightarrow> (\<forall>p a. path p \<and> path_image p \<subseteq> S \<and> pathfinish p = pathstart p \<and> a \<in> S \<longrightarrow> homotopic_loops S p (linepath a a))" (is "?lhs = ?rhs")
Customised shoe boxes are a popular way to add an extra flavor of sophistication and appeal to your brand. At my box printing we offer numerous embellishing printing options such as embossing/degassing, foil stamping, metallic and spot UV printing for a box that is truly dazzling. We also print on a variety of materials, our customers can choose from a wide range of corrugated card, cardboard, paper and plastic.The printed artwork on the shoe box often incorporates brand imagery to create an impression, and marketing purpose. The packaging of the box can be die-cut in any shape or size and designed in a way to provide ease of construction, and yet an elegant appearance. At My Box Printing we can create and design custom printed shoe packaging boxes for your business or event, providing a cost effective, and an aesthetically pleasing end product. We provide a fast delivery, quality and price unmatched in Australia! Are you looking to re-brand your business or design an artwork for your box? At my box printing we have an expert design team that is able to watch packaging. intro: Customized shoe boxes are a popular way to add an extra flavor of sophistication and appeal to your brand.
[GOAL] α : Type u β : Type v X : Type u_1 inst✝ : LinearOrder β U : Filter (α × α) z : β D : α → α → β H : ∀ (s : Set (α × α)), s ∈ U ↔ ∃ ε, ε > z ∧ ∀ {a b : α}, D a b < ε → (a, b) ∈ s s : Set (α × α) ⊢ s ∈ U ↔ ∃ i, i > z ∧ {p | D p.fst p.snd < i} ⊆ s [PROOFSTEP] simp only [H, subset_def, Prod.forall, mem_setOf] [GOAL] α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x y z : α ⊢ edist x y ≤ edist z x + edist z y [PROOFSTEP] rw [edist_comm z] [GOAL] α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x y z : α ⊢ edist x y ≤ edist x z + edist z y [PROOFSTEP] apply edist_triangle [GOAL] α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x y z : α ⊢ edist x y ≤ edist x z + edist y z [PROOFSTEP] rw [edist_comm y] [GOAL] α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x y z : α ⊢ edist x y ≤ edist x z + edist z y [PROOFSTEP] apply edist_triangle [GOAL] α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x y z : α h : edist x y = 0 ⊢ edist x z = edist y z [PROOFSTEP] apply le_antisymm [GOAL] case a α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x y z : α h : edist x y = 0 ⊢ edist x z ≤ edist y z [PROOFSTEP] rw [← zero_add (edist y z), ← h] [GOAL] case a α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x y z : α h : edist x y = 0 ⊢ edist x z ≤ edist x y + edist y z [PROOFSTEP] apply edist_triangle [GOAL] case a α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x y z : α h : edist x y = 0 ⊢ edist y z ≤ edist x z [PROOFSTEP] rw [edist_comm] at h [GOAL] case a α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x y z : α h : edist y x = 0 ⊢ edist y z ≤ edist x z [PROOFSTEP] rw [← zero_add (edist x z), ← h] [GOAL] case a α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x y z : α h : edist y x = 0 ⊢ edist y z ≤ edist y x + edist x z [PROOFSTEP] apply edist_triangle [GOAL] α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x y z : α h : edist x y = 0 ⊢ edist z x = edist z y [PROOFSTEP] rw [edist_comm z x, edist_comm z y] [GOAL] α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x y z : α h : edist x y = 0 ⊢ edist x z = edist y z [PROOFSTEP] apply edist_congr_right h [GOAL] α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α f : ℕ → α m n : ℕ h : m ≤ n ⊢ edist (f m) (f n) ≤ ∑ i in Finset.Ico m n, edist (f i) (f (i + 1)) [PROOFSTEP] induction n, h using Nat.le_induction [GOAL] case base α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α f : ℕ → α m n : ℕ ⊢ edist (f m) (f m) ≤ ∑ i in Finset.Ico m m, edist (f i) (f (i + 1)) case succ α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α f : ℕ → α m n n✝ : ℕ hn✝ : m ≤ n✝ a✝ : edist (f m) (f n✝) ≤ ∑ i in Finset.Ico m n✝, edist (f i) (f (i + 1)) ⊢ edist (f m) (f (n✝ + 1)) ≤ ∑ i in Finset.Ico m (n✝ + 1), edist (f i) (f (i + 1)) [PROOFSTEP] case base => rw [Finset.Ico_self, Finset.sum_empty, edist_self] [GOAL] α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α f : ℕ → α m n : ℕ ⊢ edist (f m) (f m) ≤ ∑ i in Finset.Ico m m, edist (f i) (f (i + 1)) [PROOFSTEP] case base => rw [Finset.Ico_self, Finset.sum_empty, edist_self] [GOAL] α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α f : ℕ → α m n : ℕ ⊢ edist (f m) (f m) ≤ ∑ i in Finset.Ico m m, edist (f i) (f (i + 1)) [PROOFSTEP] rw [Finset.Ico_self, Finset.sum_empty, edist_self] [GOAL] case succ α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α f : ℕ → α m n n✝ : ℕ hn✝ : m ≤ n✝ a✝ : edist (f m) (f n✝) ≤ ∑ i in Finset.Ico m n✝, edist (f i) (f (i + 1)) ⊢ edist (f m) (f (n✝ + 1)) ≤ ∑ i in Finset.Ico m (n✝ + 1), edist (f i) (f (i + 1)) [PROOFSTEP] case succ n hle ihn => calc edist (f m) (f (n + 1)) ≤ edist (f m) (f n) + edist (f n) (f (n + 1)) := edist_triangle _ _ _ _ ≤ (∑ i in Finset.Ico m n, _) + _ := (add_le_add ihn le_rfl) _ = ∑ i in Finset.Ico m (n + 1), _ := by {rw [Nat.Ico_succ_right_eq_insert_Ico hle, Finset.sum_insert, add_comm]; simp } [GOAL] α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α f : ℕ → α m n✝ n : ℕ hle : m ≤ n ihn : edist (f m) (f n) ≤ ∑ i in Finset.Ico m n, edist (f i) (f (i + 1)) ⊢ edist (f m) (f (n + 1)) ≤ ∑ i in Finset.Ico m (n + 1), edist (f i) (f (i + 1)) [PROOFSTEP] case succ n hle ihn => calc edist (f m) (f (n + 1)) ≤ edist (f m) (f n) + edist (f n) (f (n + 1)) := edist_triangle _ _ _ _ ≤ (∑ i in Finset.Ico m n, _) + _ := (add_le_add ihn le_rfl) _ = ∑ i in Finset.Ico m (n + 1), _ := by {rw [Nat.Ico_succ_right_eq_insert_Ico hle, Finset.sum_insert, add_comm]; simp } [GOAL] α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α f : ℕ → α m n✝ n : ℕ hle : m ≤ n ihn : edist (f m) (f n) ≤ ∑ i in Finset.Ico m n, edist (f i) (f (i + 1)) ⊢ edist (f m) (f (n + 1)) ≤ ∑ i in Finset.Ico m (n + 1), edist (f i) (f (i + 1)) [PROOFSTEP] calc edist (f m) (f (n + 1)) ≤ edist (f m) (f n) + edist (f n) (f (n + 1)) := edist_triangle _ _ _ _ ≤ (∑ i in Finset.Ico m n, _) + _ := (add_le_add ihn le_rfl) _ = ∑ i in Finset.Ico m (n + 1), _ := by {rw [Nat.Ico_succ_right_eq_insert_Ico hle, Finset.sum_insert, add_comm]; simp } [GOAL] α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α f : ℕ → α m n✝ n : ℕ hle : m ≤ n ihn : edist (f m) (f n) ≤ ∑ i in Finset.Ico m n, edist (f i) (f (i + 1)) ⊢ ∑ i in Finset.Ico m n, edist (f i) (f (i + 1)) + edist (f n) (f (n + 1)) = ∑ i in Finset.Ico m (n + 1), edist (f i) (f (i + 1)) [PROOFSTEP] {rw [Nat.Ico_succ_right_eq_insert_Ico hle, Finset.sum_insert, add_comm]; simp } [GOAL] α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α f : ℕ → α m n✝ n : ℕ hle : m ≤ n ihn : edist (f m) (f n) ≤ ∑ i in Finset.Ico m n, edist (f i) (f (i + 1)) ⊢ ∑ i in Finset.Ico m n, edist (f i) (f (i + 1)) + edist (f n) (f (n + 1)) = ∑ i in Finset.Ico m (n + 1), edist (f i) (f (i + 1)) [PROOFSTEP] rw [Nat.Ico_succ_right_eq_insert_Ico hle, Finset.sum_insert, add_comm] [GOAL] α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α f : ℕ → α m n✝ n : ℕ hle : m ≤ n ihn : edist (f m) (f n) ≤ ∑ i in Finset.Ico m n, edist (f i) (f (i + 1)) ⊢ ¬n ∈ Finset.Ico m n [PROOFSTEP] simp [GOAL] α : Type u β✝ : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α β : Type u_2 p : β → Prop f : β → ℝ≥0∞ hf₀ : ∀ (x : β), p x → 0 < f x hf : ∀ (ε : ℝ≥0∞), 0 < ε → ∃ x, p x ∧ f x ≤ ε ⊢ HasBasis (𝓤 α) p fun x => {p | edist p.fst p.snd < f x} [PROOFSTEP] refine' ⟨fun s => uniformity_basis_edist.mem_iff.trans _⟩ [GOAL] α : Type u β✝ : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α β : Type u_2 p : β → Prop f : β → ℝ≥0∞ hf₀ : ∀ (x : β), p x → 0 < f x hf : ∀ (ε : ℝ≥0∞), 0 < ε → ∃ x, p x ∧ f x ≤ ε s : Set (α × α) ⊢ (∃ i, 0 < i ∧ {p | edist p.fst p.snd < i} ⊆ s) ↔ ∃ i, p i ∧ {p | edist p.fst p.snd < f i} ⊆ s [PROOFSTEP] constructor [GOAL] case mp α : Type u β✝ : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α β : Type u_2 p : β → Prop f : β → ℝ≥0∞ hf₀ : ∀ (x : β), p x → 0 < f x hf : ∀ (ε : ℝ≥0∞), 0 < ε → ∃ x, p x ∧ f x ≤ ε s : Set (α × α) ⊢ (∃ i, 0 < i ∧ {p | edist p.fst p.snd < i} ⊆ s) → ∃ i, p i ∧ {p | edist p.fst p.snd < f i} ⊆ s [PROOFSTEP] rintro ⟨ε, ε₀, hε⟩ [GOAL] case mp.intro.intro α : Type u β✝ : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α β : Type u_2 p : β → Prop f : β → ℝ≥0∞ hf₀ : ∀ (x : β), p x → 0 < f x hf : ∀ (ε : ℝ≥0∞), 0 < ε → ∃ x, p x ∧ f x ≤ ε s : Set (α × α) ε : ℝ≥0∞ ε₀ : 0 < ε hε : {p | edist p.fst p.snd < ε} ⊆ s ⊢ ∃ i, p i ∧ {p | edist p.fst p.snd < f i} ⊆ s [PROOFSTEP] rcases hf ε ε₀ with ⟨i, hi, H⟩ [GOAL] case mp.intro.intro.intro.intro α : Type u β✝ : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α β : Type u_2 p : β → Prop f : β → ℝ≥0∞ hf₀ : ∀ (x : β), p x → 0 < f x hf : ∀ (ε : ℝ≥0∞), 0 < ε → ∃ x, p x ∧ f x ≤ ε s : Set (α × α) ε : ℝ≥0∞ ε₀ : 0 < ε hε : {p | edist p.fst p.snd < ε} ⊆ s i : β hi : p i H : f i ≤ ε ⊢ ∃ i, p i ∧ {p | edist p.fst p.snd < f i} ⊆ s [PROOFSTEP] exact ⟨i, hi, fun x hx => hε <| lt_of_lt_of_le hx.out H⟩ [GOAL] case mpr α : Type u β✝ : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α β : Type u_2 p : β → Prop f : β → ℝ≥0∞ hf₀ : ∀ (x : β), p x → 0 < f x hf : ∀ (ε : ℝ≥0∞), 0 < ε → ∃ x, p x ∧ f x ≤ ε s : Set (α × α) ⊢ (∃ i, p i ∧ {p | edist p.fst p.snd < f i} ⊆ s) → ∃ i, 0 < i ∧ {p | edist p.fst p.snd < i} ⊆ s [PROOFSTEP] exact fun ⟨i, hi, H⟩ => ⟨f i, hf₀ i hi, H⟩ [GOAL] α : Type u β✝ : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α β : Type u_2 p : β → Prop f : β → ℝ≥0∞ hf₀ : ∀ (x : β), p x → 0 < f x hf : ∀ (ε : ℝ≥0∞), 0 < ε → ∃ x, p x ∧ f x ≤ ε ⊢ HasBasis (𝓤 α) p fun x => {p | edist p.fst p.snd ≤ f x} [PROOFSTEP] refine' ⟨fun s => uniformity_basis_edist.mem_iff.trans _⟩ [GOAL] α : Type u β✝ : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α β : Type u_2 p : β → Prop f : β → ℝ≥0∞ hf₀ : ∀ (x : β), p x → 0 < f x hf : ∀ (ε : ℝ≥0∞), 0 < ε → ∃ x, p x ∧ f x ≤ ε s : Set (α × α) ⊢ (∃ i, 0 < i ∧ {p | edist p.fst p.snd < i} ⊆ s) ↔ ∃ i, p i ∧ {p | edist p.fst p.snd ≤ f i} ⊆ s [PROOFSTEP] constructor [GOAL] case mp α : Type u β✝ : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α β : Type u_2 p : β → Prop f : β → ℝ≥0∞ hf₀ : ∀ (x : β), p x → 0 < f x hf : ∀ (ε : ℝ≥0∞), 0 < ε → ∃ x, p x ∧ f x ≤ ε s : Set (α × α) ⊢ (∃ i, 0 < i ∧ {p | edist p.fst p.snd < i} ⊆ s) → ∃ i, p i ∧ {p | edist p.fst p.snd ≤ f i} ⊆ s [PROOFSTEP] rintro ⟨ε, ε₀, hε⟩ [GOAL] case mp.intro.intro α : Type u β✝ : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α β : Type u_2 p : β → Prop f : β → ℝ≥0∞ hf₀ : ∀ (x : β), p x → 0 < f x hf : ∀ (ε : ℝ≥0∞), 0 < ε → ∃ x, p x ∧ f x ≤ ε s : Set (α × α) ε : ℝ≥0∞ ε₀ : 0 < ε hε : {p | edist p.fst p.snd < ε} ⊆ s ⊢ ∃ i, p i ∧ {p | edist p.fst p.snd ≤ f i} ⊆ s [PROOFSTEP] rcases exists_between ε₀ with ⟨ε', hε'⟩ [GOAL] case mp.intro.intro.intro α : Type u β✝ : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α β : Type u_2 p : β → Prop f : β → ℝ≥0∞ hf₀ : ∀ (x : β), p x → 0 < f x hf : ∀ (ε : ℝ≥0∞), 0 < ε → ∃ x, p x ∧ f x ≤ ε s : Set (α × α) ε : ℝ≥0∞ ε₀ : 0 < ε hε : {p | edist p.fst p.snd < ε} ⊆ s ε' : ℝ≥0∞ hε' : 0 < ε' ∧ ε' < ε ⊢ ∃ i, p i ∧ {p | edist p.fst p.snd ≤ f i} ⊆ s [PROOFSTEP] rcases hf ε' hε'.1 with ⟨i, hi, H⟩ [GOAL] case mp.intro.intro.intro.intro.intro α : Type u β✝ : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α β : Type u_2 p : β → Prop f : β → ℝ≥0∞ hf₀ : ∀ (x : β), p x → 0 < f x hf : ∀ (ε : ℝ≥0∞), 0 < ε → ∃ x, p x ∧ f x ≤ ε s : Set (α × α) ε : ℝ≥0∞ ε₀ : 0 < ε hε : {p | edist p.fst p.snd < ε} ⊆ s ε' : ℝ≥0∞ hε' : 0 < ε' ∧ ε' < ε i : β hi : p i H : f i ≤ ε' ⊢ ∃ i, p i ∧ {p | edist p.fst p.snd ≤ f i} ⊆ s [PROOFSTEP] exact ⟨i, hi, fun x hx => hε <| lt_of_le_of_lt (le_trans hx.out H) hε'.2⟩ [GOAL] case mpr α : Type u β✝ : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α β : Type u_2 p : β → Prop f : β → ℝ≥0∞ hf₀ : ∀ (x : β), p x → 0 < f x hf : ∀ (ε : ℝ≥0∞), 0 < ε → ∃ x, p x ∧ f x ≤ ε s : Set (α × α) ⊢ (∃ i, p i ∧ {p | edist p.fst p.snd ≤ f i} ⊆ s) → ∃ i, 0 < i ∧ {p | edist p.fst p.snd < i} ⊆ s [PROOFSTEP] exact fun ⟨i, hi, H⟩ => ⟨f i, hf₀ i hi, fun x hx => H (le_of_lt hx.out)⟩ [GOAL] α : Type u β : Type v X : Type u_1 inst✝¹ : PseudoEMetricSpace α inst✝ : PseudoEMetricSpace β f : α → β ⊢ (∀ (i' : ℝ≥0∞), 0 < i' → ∃ i, 0 < i ∧ Prod.map f f ⁻¹' {p | edist p.fst p.snd < i} ⊆ {p | edist p.fst p.snd < i'}) ↔ ∀ (δ : ℝ≥0∞), δ > 0 → ∃ ε, ε > 0 ∧ ∀ {a b : α}, edist (f a) (f b) < ε → edist a b < δ [PROOFSTEP] simp only [subset_def, Prod.forall] [GOAL] α : Type u β : Type v X : Type u_1 inst✝¹ : PseudoEMetricSpace α inst✝ : PseudoEMetricSpace β f : α → β ⊢ (∀ (i' : ℝ≥0∞), 0 < i' → ∃ i, 0 < i ∧ ∀ (a b : α), (a, b) ∈ Prod.map f f ⁻¹' {p | edist p.fst p.snd < i} → (a, b) ∈ {p | edist p.fst p.snd < i'}) ↔ ∀ (δ : ℝ≥0∞), δ > 0 → ∃ ε, ε > 0 ∧ ∀ {a b : α}, edist (f a) (f b) < ε → edist a b < δ [PROOFSTEP] rfl [GOAL] α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α f : Filter α ⊢ Cauchy f ↔ f ≠ ⊥ ∧ ∀ (ε : ℝ≥0∞), ε > 0 → ∃ t, t ∈ f ∧ ∀ (x : α), x ∈ t → ∀ (y : α), y ∈ t → edist x y < ε [PROOFSTEP] rw [← neBot_iff] [GOAL] α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α f : Filter α ⊢ Cauchy f ↔ NeBot f ∧ ∀ (ε : ℝ≥0∞), ε > 0 → ∃ t, t ∈ f ∧ ∀ (x : α), x ∈ t → ∀ (y : α), y ∈ t → edist x y < ε [PROOFSTEP] exact uniformity_basis_edist.cauchy_iff [GOAL] α : Type u β : Type v X : Type u_1 inst✝¹ : PseudoEMetricSpace α ι : Type u_2 inst✝ : TopologicalSpace β F : ι → β → α f : β → α p : Filter ι s : Set β ⊢ TendstoLocallyUniformlyOn F f p s ↔ ∀ (ε : ℝ≥0∞), ε > 0 → ∀ (x : β), x ∈ s → ∃ t, t ∈ 𝓝[s] x ∧ ∀ᶠ (n : ι) in p, ∀ (y : β), y ∈ t → edist (f y) (F n y) < ε [PROOFSTEP] refine' ⟨fun H ε hε => H _ (edist_mem_uniformity hε), fun H u hu x hx => _⟩ [GOAL] α : Type u β : Type v X : Type u_1 inst✝¹ : PseudoEMetricSpace α ι : Type u_2 inst✝ : TopologicalSpace β F : ι → β → α f : β → α p : Filter ι s : Set β H : ∀ (ε : ℝ≥0∞), ε > 0 → ∀ (x : β), x ∈ s → ∃ t, t ∈ 𝓝[s] x ∧ ∀ᶠ (n : ι) in p, ∀ (y : β), y ∈ t → edist (f y) (F n y) < ε u : Set (α × α) hu : u ∈ 𝓤 α x : β hx : x ∈ s ⊢ ∃ t, t ∈ 𝓝[s] x ∧ ∀ᶠ (n : ι) in p, ∀ (y : β), y ∈ t → (f y, F n y) ∈ u [PROOFSTEP] rcases mem_uniformity_edist.1 hu with ⟨ε, εpos, hε⟩ [GOAL] case intro.intro α : Type u β : Type v X : Type u_1 inst✝¹ : PseudoEMetricSpace α ι : Type u_2 inst✝ : TopologicalSpace β F : ι → β → α f : β → α p : Filter ι s : Set β H : ∀ (ε : ℝ≥0∞), ε > 0 → ∀ (x : β), x ∈ s → ∃ t, t ∈ 𝓝[s] x ∧ ∀ᶠ (n : ι) in p, ∀ (y : β), y ∈ t → edist (f y) (F n y) < ε u : Set (α × α) hu : u ∈ 𝓤 α x : β hx : x ∈ s ε : ℝ≥0∞ εpos : ε > 0 hε : ∀ {a b : α}, edist a b < ε → (a, b) ∈ u ⊢ ∃ t, t ∈ 𝓝[s] x ∧ ∀ᶠ (n : ι) in p, ∀ (y : β), y ∈ t → (f y, F n y) ∈ u [PROOFSTEP] rcases H ε εpos x hx with ⟨t, ht, Ht⟩ [GOAL] case intro.intro.intro.intro α : Type u β : Type v X : Type u_1 inst✝¹ : PseudoEMetricSpace α ι : Type u_2 inst✝ : TopologicalSpace β F : ι → β → α f : β → α p : Filter ι s : Set β H : ∀ (ε : ℝ≥0∞), ε > 0 → ∀ (x : β), x ∈ s → ∃ t, t ∈ 𝓝[s] x ∧ ∀ᶠ (n : ι) in p, ∀ (y : β), y ∈ t → edist (f y) (F n y) < ε u : Set (α × α) hu : u ∈ 𝓤 α x : β hx : x ∈ s ε : ℝ≥0∞ εpos : ε > 0 hε : ∀ {a b : α}, edist a b < ε → (a, b) ∈ u t : Set β ht : t ∈ 𝓝[s] x Ht : ∀ᶠ (n : ι) in p, ∀ (y : β), y ∈ t → edist (f y) (F n y) < ε ⊢ ∃ t, t ∈ 𝓝[s] x ∧ ∀ᶠ (n : ι) in p, ∀ (y : β), y ∈ t → (f y, F n y) ∈ u [PROOFSTEP] exact ⟨t, ht, Ht.mono fun n hs x hx => hε (hs x hx)⟩ [GOAL] α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α ι : Type u_2 F : ι → β → α f : β → α p : Filter ι s : Set β ⊢ TendstoUniformlyOn F f p s ↔ ∀ (ε : ℝ≥0∞), ε > 0 → ∀ᶠ (n : ι) in p, ∀ (x : β), x ∈ s → edist (f x) (F n x) < ε [PROOFSTEP] refine' ⟨fun H ε hε => H _ (edist_mem_uniformity hε), fun H u hu => _⟩ [GOAL] α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α ι : Type u_2 F : ι → β → α f : β → α p : Filter ι s : Set β H : ∀ (ε : ℝ≥0∞), ε > 0 → ∀ᶠ (n : ι) in p, ∀ (x : β), x ∈ s → edist (f x) (F n x) < ε u : Set (α × α) hu : u ∈ 𝓤 α ⊢ ∀ᶠ (n : ι) in p, ∀ (x : β), x ∈ s → (f x, F n x) ∈ u [PROOFSTEP] rcases mem_uniformity_edist.1 hu with ⟨ε, εpos, hε⟩ [GOAL] case intro.intro α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α ι : Type u_2 F : ι → β → α f : β → α p : Filter ι s : Set β H : ∀ (ε : ℝ≥0∞), ε > 0 → ∀ᶠ (n : ι) in p, ∀ (x : β), x ∈ s → edist (f x) (F n x) < ε u : Set (α × α) hu : u ∈ 𝓤 α ε : ℝ≥0∞ εpos : ε > 0 hε : ∀ {a b : α}, edist a b < ε → (a, b) ∈ u ⊢ ∀ᶠ (n : ι) in p, ∀ (x : β), x ∈ s → (f x, F n x) ∈ u [PROOFSTEP] exact (H ε εpos).mono fun n hs x hx => hε (hs x hx) [GOAL] α : Type u β : Type v X : Type u_1 inst✝¹ : PseudoEMetricSpace α ι : Type u_2 inst✝ : TopologicalSpace β F : ι → β → α f : β → α p : Filter ι ⊢ TendstoLocallyUniformly F f p ↔ ∀ (ε : ℝ≥0∞), ε > 0 → ∀ (x : β), ∃ t, t ∈ 𝓝 x ∧ ∀ᶠ (n : ι) in p, ∀ (y : β), y ∈ t → edist (f y) (F n y) < ε [PROOFSTEP] simp only [← tendstoLocallyUniformlyOn_univ, tendstoLocallyUniformlyOn_iff, mem_univ, forall_const, exists_prop, nhdsWithin_univ] [GOAL] α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α ι : Type u_2 F : ι → β → α f : β → α p : Filter ι ⊢ TendstoUniformly F f p ↔ ∀ (ε : ℝ≥0∞), ε > 0 → ∀ᶠ (n : ι) in p, ∀ (x : β), edist (f x) (F n x) < ε [PROOFSTEP] simp only [← tendstoUniformlyOn_univ, tendstoUniformlyOn_iff, mem_univ, forall_const] [GOAL] α : Type u β : Type v X : Type u_1 inst✝¹ : PseudoEMetricSpace α inst✝ : PseudoEMetricSpace β x : α × β ⊢ edist x x = 0 [PROOFSTEP] simp [GOAL] α : Type u β : Type v X : Type u_1 inst✝¹ : PseudoEMetricSpace α inst✝ : PseudoEMetricSpace β x y : α × β ⊢ edist x y = edist y x [PROOFSTEP] simp [edist_comm] [GOAL] α : Type u β : Type v X : Type u_1 inst✝¹ : PseudoEMetricSpace α inst✝ : PseudoEMetricSpace β ⊢ comap (fun p => (p.fst.fst, p.snd.fst)) (𝓤 α) ⊓ comap (fun p => (p.fst.snd, p.snd.snd)) (𝓤 β) = ⨅ (ε : ℝ≥0∞) (_ : ε > 0), 𝓟 {p | edist p.fst p.snd < ε} [PROOFSTEP] simp [PseudoEMetricSpace.uniformity_edist, ← iInf_inf_eq, setOf_and] [GOAL] α : Type u β : Type v X : Type u_1 inst✝² : PseudoEMetricSpace α π : β → Type u_2 inst✝¹ : Fintype β inst✝ : (b : β) → EDist (π b) f g : (b : β) → π b d : ℝ≥0∞ ⊢ (∀ (b : β), b ∈ Finset.univ → edist (f b) (g b) ≤ d) ↔ ∀ (b : β), edist (f b) (g b) ≤ d [PROOFSTEP] simp only [Finset.mem_univ, forall_const] [GOAL] α : Type u β : Type v X : Type u_1 inst✝² : PseudoEMetricSpace α π : β → Type u_2 inst✝¹ : Fintype β inst✝ : (b : β) → PseudoEMetricSpace (π b) f : (b : β) → π b ⊢ ∀ (b : β), b ∈ Finset.univ → edist (f b) (f b) ≤ ⊥ [PROOFSTEP] simp [GOAL] α : Type u β : Type v X : Type u_1 inst✝² : PseudoEMetricSpace α π : β → Type u_2 inst✝¹ : Fintype β inst✝ : (b : β) → PseudoEMetricSpace (π b) f g : (b : β) → π b ⊢ edist f g = edist g f [PROOFSTEP] simp [edist_pi_def, edist_comm] [GOAL] α : Type u β : Type v X : Type u_1 inst✝² : PseudoEMetricSpace α π : β → Type u_2 inst✝¹ : Fintype β inst✝ : (b : β) → PseudoEMetricSpace (π b) ⊢ 𝓤 ((b : β) → π b) = ⨅ (ε : ℝ≥0∞) (_ : ε > 0), 𝓟 {p | edist p.fst p.snd < ε} [PROOFSTEP] simp only [Pi.uniformity, PseudoEMetricSpace.uniformity_edist, comap_iInf, gt_iff_lt, preimage_setOf_eq, comap_principal, edist_pi_def] [GOAL] α : Type u β : Type v X : Type u_1 inst✝² : PseudoEMetricSpace α π : β → Type u_2 inst✝¹ : Fintype β inst✝ : (b : β) → PseudoEMetricSpace (π b) ⊢ ⨅ (i : β) (i_1 : ℝ≥0∞) (_ : 0 < i_1), 𝓟 {a | edist (Prod.fst a i) (Prod.snd a i) < i_1} = ⨅ (ε : ℝ≥0∞) (_ : 0 < ε), 𝓟 {p | (sup Finset.univ fun b => edist (Prod.fst p b) (Prod.snd p b)) < ε} [PROOFSTEP] rw [iInf_comm] [GOAL] α : Type u β : Type v X : Type u_1 inst✝² : PseudoEMetricSpace α π : β → Type u_2 inst✝¹ : Fintype β inst✝ : (b : β) → PseudoEMetricSpace (π b) ⊢ ⨅ (j : ℝ≥0∞) (i : β) (_ : 0 < j), 𝓟 {a | edist (Prod.fst a i) (Prod.snd a i) < j} = ⨅ (ε : ℝ≥0∞) (_ : 0 < ε), 𝓟 {p | (sup Finset.univ fun b => edist (Prod.fst p b) (Prod.snd p b)) < ε} [PROOFSTEP] congr [GOAL] case e_s α : Type u β : Type v X : Type u_1 inst✝² : PseudoEMetricSpace α π : β → Type u_2 inst✝¹ : Fintype β inst✝ : (b : β) → PseudoEMetricSpace (π b) ⊢ (fun j => ⨅ (i : β) (_ : 0 < j), 𝓟 {a | edist (Prod.fst a i) (Prod.snd a i) < j}) = fun ε => ⨅ (_ : 0 < ε), 𝓟 {p | (sup Finset.univ fun b => edist (Prod.fst p b) (Prod.snd p b)) < ε} [PROOFSTEP] funext ε [GOAL] case e_s.h α : Type u β : Type v X : Type u_1 inst✝² : PseudoEMetricSpace α π : β → Type u_2 inst✝¹ : Fintype β inst✝ : (b : β) → PseudoEMetricSpace (π b) ε : ℝ≥0∞ ⊢ ⨅ (i : β) (_ : 0 < ε), 𝓟 {a | edist (Prod.fst a i) (Prod.snd a i) < ε} = ⨅ (_ : 0 < ε), 𝓟 {p | (sup Finset.univ fun b => edist (Prod.fst p b) (Prod.snd p b)) < ε} [PROOFSTEP] rw [iInf_comm] [GOAL] case e_s.h α : Type u β : Type v X : Type u_1 inst✝² : PseudoEMetricSpace α π : β → Type u_2 inst✝¹ : Fintype β inst✝ : (b : β) → PseudoEMetricSpace (π b) ε : ℝ≥0∞ ⊢ ⨅ (_ : 0 < ε) (i : β), 𝓟 {a | edist (Prod.fst a i) (Prod.snd a i) < ε} = ⨅ (_ : 0 < ε), 𝓟 {p | (sup Finset.univ fun b => edist (Prod.fst p b) (Prod.snd p b)) < ε} [PROOFSTEP] congr [GOAL] case e_s.h.e_s α : Type u β : Type v X : Type u_1 inst✝² : PseudoEMetricSpace α π : β → Type u_2 inst✝¹ : Fintype β inst✝ : (b : β) → PseudoEMetricSpace (π b) ε : ℝ≥0∞ ⊢ (fun j => ⨅ (i : β), 𝓟 {a | edist (Prod.fst a i) (Prod.snd a i) < ε}) = fun x => 𝓟 {p | (sup Finset.univ fun b => edist (Prod.fst p b) (Prod.snd p b)) < ε} [PROOFSTEP] funext εpos [GOAL] case e_s.h.e_s.h α : Type u β : Type v X : Type u_1 inst✝² : PseudoEMetricSpace α π : β → Type u_2 inst✝¹ : Fintype β inst✝ : (b : β) → PseudoEMetricSpace (π b) ε : ℝ≥0∞ εpos : 0 < ε ⊢ ⨅ (i : β), 𝓟 {a | edist (Prod.fst a i) (Prod.snd a i) < ε} = 𝓟 {p | (sup Finset.univ fun b => edist (Prod.fst p b) (Prod.snd p b)) < ε} [PROOFSTEP] simp [setOf_forall, εpos] [GOAL] α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x y z : α ε ε₁ ε₂ : ℝ≥0∞ s t : Set α ⊢ y ∈ ball x ε ↔ edist x y < ε [PROOFSTEP] rw [edist_comm, mem_ball] [GOAL] α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x y z : α ε ε₁ ε₂ : ℝ≥0∞ s t : Set α ⊢ y ∈ closedBall x ε ↔ edist x y ≤ ε [PROOFSTEP] rw [edist_comm, mem_closedBall] [GOAL] α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x y z : α ε ε₁ ε₂ : ℝ≥0∞ s t : Set α h : 0 < ε ⊢ x ∈ ball x ε [PROOFSTEP] rwa [mem_ball, edist_self] [GOAL] α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x y z : α ε ε₁ ε₂ : ℝ≥0∞ s t : Set α ⊢ x ∈ closedBall x ε [PROOFSTEP] rw [mem_closedBall, edist_self] [GOAL] α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x y z : α ε ε₁ ε₂ : ℝ≥0∞ s t : Set α ⊢ 0 ≤ ε [PROOFSTEP] apply zero_le [GOAL] α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x y z : α ε ε₁ ε₂ : ℝ≥0∞ s t : Set α ⊢ x ∈ ball y ε ↔ y ∈ ball x ε [PROOFSTEP] rw [mem_ball', mem_ball] [GOAL] α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x y z : α ε ε₁ ε₂ : ℝ≥0∞ s t : Set α ⊢ x ∈ closedBall y ε ↔ y ∈ closedBall x ε [PROOFSTEP] rw [mem_closedBall', mem_closedBall] [GOAL] α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x y z : α ε ε₁ ε₂ : ℝ≥0∞ s t : Set α h : y ∈ ball x ε ⊢ ∃ ε', ε' > 0 ∧ ball y ε' ⊆ ball x ε [PROOFSTEP] have : 0 < ε - edist y x := by simpa using h [GOAL] α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x y z : α ε ε₁ ε₂ : ℝ≥0∞ s t : Set α h : y ∈ ball x ε ⊢ 0 < ε - edist y x [PROOFSTEP] simpa using h [GOAL] α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x y z : α ε ε₁ ε₂ : ℝ≥0∞ s t : Set α h : y ∈ ball x ε this : 0 < ε - edist y x ⊢ ∃ ε', ε' > 0 ∧ ball y ε' ⊆ ball x ε [PROOFSTEP] refine' ⟨ε - edist y x, this, ball_subset _ (ne_top_of_lt h)⟩ [GOAL] α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x y z : α ε ε₁ ε₂ : ℝ≥0∞ s t : Set α h : y ∈ ball x ε this : 0 < ε - edist y x ⊢ edist y x + (ε - edist y x) ≤ ε [PROOFSTEP] exact (add_tsub_cancel_of_le (mem_ball.mp h).le).le [GOAL] α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x✝ y z : α ε ε₁ ε₂ : ℝ≥0∞ s t : Set α x : α ⊢ edist x x < ⊤ [PROOFSTEP] rw [edist_self] [GOAL] α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x✝ y z : α ε ε₁ ε₂ : ℝ≥0∞ s t : Set α x : α ⊢ 0 < ⊤ [PROOFSTEP] exact ENNReal.coe_lt_top [GOAL] α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x y z : α ε ε₁ ε₂ : ℝ≥0∞ s t : Set α x✝ y✝ : α h : edist x✝ y✝ < ⊤ ⊢ edist y✝ x✝ < ⊤ [PROOFSTEP] rwa [edist_comm] [GOAL] α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x y z : α ε ε₁ ε₂ : ℝ≥0∞ s t : Set α ⊢ ball x 0 = ∅ [PROOFSTEP] rw [EMetric.ball_eq_empty_iff] [GOAL] α : Type u β : Type v X : Type u_1 inst✝¹ : PseudoEMetricSpace α x✝² y z : α ε✝ ε₁ ε₂ : ℝ≥0∞ s t✝ : Set α inst✝ : PseudoEMetricSpace β f : α → β t : Set β a : α b : β ε : ℝ≥0∞ x✝¹ : 0 < ε δ : ℝ≥0∞ x✝ : 0 < δ x : α ⊢ x ∈ ball a δ ∩ s → f x ∈ ball b ε ∩ t ↔ x ∈ s → edist x a < δ → f x ∈ t ∧ edist (f x) b < ε [PROOFSTEP] simp [GOAL] α : Type u β : Type v X : Type u_1 inst✝¹ : PseudoEMetricSpace α x✝² y z : α ε✝ ε₁ ε₂ : ℝ≥0∞ s t✝ : Set α inst✝ : PseudoEMetricSpace β f : α → β t : Set β a : α b : β ε : ℝ≥0∞ x✝¹ : 0 < ε δ : ℝ≥0∞ x✝ : 0 < δ x : α ⊢ edist x a < δ → x ∈ s → edist (f x) b < ε ∧ f x ∈ t ↔ x ∈ s → edist x a < δ → f x ∈ t ∧ edist (f x) b < ε [PROOFSTEP] tauto [GOAL] α : Type u β : Type v X : Type u_1 inst✝¹ : PseudoEMetricSpace α x y z : α ε ε₁ ε₂ : ℝ≥0∞ s t : Set α inst✝ : PseudoEMetricSpace β f : α → β a : α b : β ⊢ Tendsto f (𝓝[s] a) (𝓝 b) ↔ ∀ (ε : ℝ≥0∞), ε > 0 → ∃ δ, δ > 0 ∧ ∀ {x : α}, x ∈ s → edist x a < δ → edist (f x) b < ε [PROOFSTEP] rw [← nhdsWithin_univ b, tendsto_nhdsWithin_nhdsWithin] [GOAL] α : Type u β : Type v X : Type u_1 inst✝¹ : PseudoEMetricSpace α x y z : α ε ε₁ ε₂ : ℝ≥0∞ s t : Set α inst✝ : PseudoEMetricSpace β f : α → β a : α b : β ⊢ (∀ (ε : ℝ≥0∞), ε > 0 → ∃ δ, δ > 0 ∧ ∀ ⦃x : α⦄, x ∈ s → edist x a < δ → f x ∈ univ ∧ edist (f x) b < ε) ↔ ∀ (ε : ℝ≥0∞), ε > 0 → ∃ δ, δ > 0 ∧ ∀ {x : α}, x ∈ s → edist x a < δ → edist (f x) b < ε [PROOFSTEP] simp only [mem_univ, true_and_iff] [GOAL] α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x y z : α ε ε₁ ε₂ : ℝ≥0∞ s t : Set α ⊢ IsOpen s ↔ ∀ (x : α), x ∈ s → ∃ ε, ε > 0 ∧ ball x ε ⊆ s [PROOFSTEP] simp [isOpen_iff_nhds, mem_nhds_iff] [GOAL] α : Type u β : Type v X : Type u_1 inst✝¹ : PseudoEMetricSpace α x✝ y✝ z✝ : α ε ε₁ ε₂ : ℝ≥0∞ s t : Set α inst✝ : PseudoEMetricSpace β x : α y : β r : ℝ≥0∞ z : α × β ⊢ z ∈ ball x r ×ˢ ball y r ↔ z ∈ ball (x, y) r [PROOFSTEP] simp [Prod.edist_eq] [GOAL] α : Type u β : Type v X : Type u_1 inst✝¹ : PseudoEMetricSpace α x✝ y✝ z✝ : α ε ε₁ ε₂ : ℝ≥0∞ s t : Set α inst✝ : PseudoEMetricSpace β x : α y : β r : ℝ≥0∞ z : α × β ⊢ z ∈ closedBall x r ×ˢ closedBall y r ↔ z ∈ closedBall (x, y) r [PROOFSTEP] simp [Prod.edist_eq] [GOAL] α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x y z : α ε ε₁ ε₂ : ℝ≥0∞ s t : Set α ⊢ (∀ (i : ℝ≥0∞), 0 < i → ∃ y, y ∈ s ∧ y ∈ ball x i) ↔ ∀ (ε : ℝ≥0∞), ε > 0 → ∃ y, y ∈ s ∧ edist x y < ε [PROOFSTEP] simp only [mem_ball, edist_comm x] [GOAL] α : Type u β : Type v X : Type u_1 inst✝² : PseudoEMetricSpace α x y z : α ε ε₁ ε₂ : ℝ≥0∞ s t : Set α inst✝¹ : Nonempty β inst✝ : SemilatticeSup β u : β → α a : α ⊢ (∀ (ib : ℝ≥0∞), 0 < ib → ∃ ia, True ∧ ∀ (x : β), x ∈ Ici ia → u x ∈ ball a ib) ↔ ∀ (ε : ℝ≥0∞), ε > 0 → ∃ N, ∀ (n : β), n ≥ N → edist (u n) a < ε [PROOFSTEP] simp only [exists_prop, true_and_iff, mem_Ici, mem_ball] [GOAL] α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x y z : α ε ε₁ ε₂ : ℝ≥0∞ s t : Set α ⊢ Inseparable x y ↔ edist x y = 0 [PROOFSTEP] simp [inseparable_iff_mem_closure, mem_closure_iff, edist_comm, forall_lt_iff_le'] [GOAL] α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x y z : α ε ε₁ ε₂ : ℝ≥0∞ s✝ t s : Set α hs : ∀ (ε : ℝ≥0∞), ε > 0 → ∃ t, Set.Countable t ∧ s ⊆ ⋃ (x : α) (_ : x ∈ t), closedBall x ε ⊢ ∃ t, t ⊆ s ∧ Set.Countable t ∧ s ⊆ closure t [PROOFSTEP] rcases s.eq_empty_or_nonempty with (rfl | ⟨x₀, hx₀⟩) [GOAL] case inl α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x y z : α ε ε₁ ε₂ : ℝ≥0∞ s t : Set α hs : ∀ (ε : ℝ≥0∞), ε > 0 → ∃ t, Set.Countable t ∧ ∅ ⊆ ⋃ (x : α) (_ : x ∈ t), closedBall x ε ⊢ ∃ t, t ⊆ ∅ ∧ Set.Countable t ∧ ∅ ⊆ closure t [PROOFSTEP] exact ⟨∅, empty_subset _, countable_empty, empty_subset _⟩ [GOAL] case inr.intro α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x y z : α ε ε₁ ε₂ : ℝ≥0∞ s✝ t s : Set α hs : ∀ (ε : ℝ≥0∞), ε > 0 → ∃ t, Set.Countable t ∧ s ⊆ ⋃ (x : α) (_ : x ∈ t), closedBall x ε x₀ : α hx₀ : x₀ ∈ s ⊢ ∃ t, t ⊆ s ∧ Set.Countable t ∧ s ⊆ closure t [PROOFSTEP] choose! T hTc hsT using fun n : ℕ => hs n⁻¹ (by simp) [GOAL] α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x y z : α ε ε₁ ε₂ : ℝ≥0∞ s✝ t s : Set α hs : ∀ (ε : ℝ≥0∞), ε > 0 → ∃ t, Set.Countable t ∧ s ⊆ ⋃ (x : α) (_ : x ∈ t), closedBall x ε x₀ : α hx₀ : x₀ ∈ s n : ℕ ⊢ (↑n)⁻¹ > 0 [PROOFSTEP] simp [GOAL] case inr.intro α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x y z : α ε ε₁ ε₂ : ℝ≥0∞ s✝ t s : Set α hs : ∀ (ε : ℝ≥0∞), ε > 0 → ∃ t, Set.Countable t ∧ s ⊆ ⋃ (x : α) (_ : x ∈ t), closedBall x ε x₀ : α hx₀ : x₀ ∈ s T : ℕ → Set α hTc : ∀ (n : ℕ), Set.Countable (T n) hsT : ∀ (n : ℕ), s ⊆ ⋃ (x : α) (_ : x ∈ T n), closedBall x (↑n)⁻¹ ⊢ ∃ t, t ⊆ s ∧ Set.Countable t ∧ s ⊆ closure t [PROOFSTEP] have : ∀ r x, ∃ y ∈ s, closedBall x r ∩ s ⊆ closedBall y (r * 2) := fun r x => by rcases(closedBall x r ∩ s).eq_empty_or_nonempty with (he | ⟨y, hxy, hys⟩) · refine' ⟨x₀, hx₀, _⟩ rw [he] exact empty_subset _ · refine' ⟨y, hys, fun z hz => _⟩ calc edist z y ≤ edist z x + edist y x := edist_triangle_right _ _ _ _ ≤ r + r := (add_le_add hz.1 hxy) _ = r * 2 := (mul_two r).symm [GOAL] α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x✝ y z : α ε ε₁ ε₂ : ℝ≥0∞ s✝ t s : Set α hs : ∀ (ε : ℝ≥0∞), ε > 0 → ∃ t, Set.Countable t ∧ s ⊆ ⋃ (x : α) (_ : x ∈ t), closedBall x ε x₀ : α hx₀ : x₀ ∈ s T : ℕ → Set α hTc : ∀ (n : ℕ), Set.Countable (T n) hsT : ∀ (n : ℕ), s ⊆ ⋃ (x : α) (_ : x ∈ T n), closedBall x (↑n)⁻¹ r : ℝ≥0∞ x : α ⊢ ∃ y, y ∈ s ∧ closedBall x r ∩ s ⊆ closedBall y (r * 2) [PROOFSTEP] rcases(closedBall x r ∩ s).eq_empty_or_nonempty with (he | ⟨y, hxy, hys⟩) [GOAL] case inl α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x✝ y z : α ε ε₁ ε₂ : ℝ≥0∞ s✝ t s : Set α hs : ∀ (ε : ℝ≥0∞), ε > 0 → ∃ t, Set.Countable t ∧ s ⊆ ⋃ (x : α) (_ : x ∈ t), closedBall x ε x₀ : α hx₀ : x₀ ∈ s T : ℕ → Set α hTc : ∀ (n : ℕ), Set.Countable (T n) hsT : ∀ (n : ℕ), s ⊆ ⋃ (x : α) (_ : x ∈ T n), closedBall x (↑n)⁻¹ r : ℝ≥0∞ x : α he : closedBall x r ∩ s = ∅ ⊢ ∃ y, y ∈ s ∧ closedBall x r ∩ s ⊆ closedBall y (r * 2) [PROOFSTEP] refine' ⟨x₀, hx₀, _⟩ [GOAL] case inl α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x✝ y z : α ε ε₁ ε₂ : ℝ≥0∞ s✝ t s : Set α hs : ∀ (ε : ℝ≥0∞), ε > 0 → ∃ t, Set.Countable t ∧ s ⊆ ⋃ (x : α) (_ : x ∈ t), closedBall x ε x₀ : α hx₀ : x₀ ∈ s T : ℕ → Set α hTc : ∀ (n : ℕ), Set.Countable (T n) hsT : ∀ (n : ℕ), s ⊆ ⋃ (x : α) (_ : x ∈ T n), closedBall x (↑n)⁻¹ r : ℝ≥0∞ x : α he : closedBall x r ∩ s = ∅ ⊢ closedBall x r ∩ s ⊆ closedBall x₀ (r * 2) [PROOFSTEP] rw [he] [GOAL] case inl α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x✝ y z : α ε ε₁ ε₂ : ℝ≥0∞ s✝ t s : Set α hs : ∀ (ε : ℝ≥0∞), ε > 0 → ∃ t, Set.Countable t ∧ s ⊆ ⋃ (x : α) (_ : x ∈ t), closedBall x ε x₀ : α hx₀ : x₀ ∈ s T : ℕ → Set α hTc : ∀ (n : ℕ), Set.Countable (T n) hsT : ∀ (n : ℕ), s ⊆ ⋃ (x : α) (_ : x ∈ T n), closedBall x (↑n)⁻¹ r : ℝ≥0∞ x : α he : closedBall x r ∩ s = ∅ ⊢ ∅ ⊆ closedBall x₀ (r * 2) [PROOFSTEP] exact empty_subset _ [GOAL] case inr.intro.intro α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x✝ y✝ z : α ε ε₁ ε₂ : ℝ≥0∞ s✝ t s : Set α hs : ∀ (ε : ℝ≥0∞), ε > 0 → ∃ t, Set.Countable t ∧ s ⊆ ⋃ (x : α) (_ : x ∈ t), closedBall x ε x₀ : α hx₀ : x₀ ∈ s T : ℕ → Set α hTc : ∀ (n : ℕ), Set.Countable (T n) hsT : ∀ (n : ℕ), s ⊆ ⋃ (x : α) (_ : x ∈ T n), closedBall x (↑n)⁻¹ r : ℝ≥0∞ x y : α hxy : y ∈ closedBall x r hys : y ∈ s ⊢ ∃ y, y ∈ s ∧ closedBall x r ∩ s ⊆ closedBall y (r * 2) [PROOFSTEP] refine' ⟨y, hys, fun z hz => _⟩ [GOAL] case inr.intro.intro α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x✝ y✝ z✝ : α ε ε₁ ε₂ : ℝ≥0∞ s✝ t s : Set α hs : ∀ (ε : ℝ≥0∞), ε > 0 → ∃ t, Set.Countable t ∧ s ⊆ ⋃ (x : α) (_ : x ∈ t), closedBall x ε x₀ : α hx₀ : x₀ ∈ s T : ℕ → Set α hTc : ∀ (n : ℕ), Set.Countable (T n) hsT : ∀ (n : ℕ), s ⊆ ⋃ (x : α) (_ : x ∈ T n), closedBall x (↑n)⁻¹ r : ℝ≥0∞ x y : α hxy : y ∈ closedBall x r hys : y ∈ s z : α hz : z ∈ closedBall x r ∩ s ⊢ z ∈ closedBall y (r * 2) [PROOFSTEP] calc edist z y ≤ edist z x + edist y x := edist_triangle_right _ _ _ _ ≤ r + r := (add_le_add hz.1 hxy) _ = r * 2 := (mul_two r).symm [GOAL] case inr.intro α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x y z : α ε ε₁ ε₂ : ℝ≥0∞ s✝ t s : Set α hs : ∀ (ε : ℝ≥0∞), ε > 0 → ∃ t, Set.Countable t ∧ s ⊆ ⋃ (x : α) (_ : x ∈ t), closedBall x ε x₀ : α hx₀ : x₀ ∈ s T : ℕ → Set α hTc : ∀ (n : ℕ), Set.Countable (T n) hsT : ∀ (n : ℕ), s ⊆ ⋃ (x : α) (_ : x ∈ T n), closedBall x (↑n)⁻¹ this : ∀ (r : ℝ≥0∞) (x : α), ∃ y, y ∈ s ∧ closedBall x r ∩ s ⊆ closedBall y (r * 2) ⊢ ∃ t, t ⊆ s ∧ Set.Countable t ∧ s ⊆ closure t [PROOFSTEP] choose f hfs hf using this [GOAL] case inr.intro α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x y z : α ε ε₁ ε₂ : ℝ≥0∞ s✝ t s : Set α hs : ∀ (ε : ℝ≥0∞), ε > 0 → ∃ t, Set.Countable t ∧ s ⊆ ⋃ (x : α) (_ : x ∈ t), closedBall x ε x₀ : α hx₀ : x₀ ∈ s T : ℕ → Set α hTc : ∀ (n : ℕ), Set.Countable (T n) hsT : ∀ (n : ℕ), s ⊆ ⋃ (x : α) (_ : x ∈ T n), closedBall x (↑n)⁻¹ f : ℝ≥0∞ → α → α hfs : ∀ (r : ℝ≥0∞) (x : α), f r x ∈ s hf : ∀ (r : ℝ≥0∞) (x : α), closedBall x r ∩ s ⊆ closedBall (f r x) (r * 2) ⊢ ∃ t, t ⊆ s ∧ Set.Countable t ∧ s ⊆ closure t [PROOFSTEP] refine' ⟨⋃ n : ℕ, f n⁻¹ '' T n, iUnion_subset fun n => image_subset_iff.2 fun z _ => hfs _ _, countable_iUnion fun n => (hTc n).image _, _⟩ [GOAL] case inr.intro α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x y z : α ε ε₁ ε₂ : ℝ≥0∞ s✝ t s : Set α hs : ∀ (ε : ℝ≥0∞), ε > 0 → ∃ t, Set.Countable t ∧ s ⊆ ⋃ (x : α) (_ : x ∈ t), closedBall x ε x₀ : α hx₀ : x₀ ∈ s T : ℕ → Set α hTc : ∀ (n : ℕ), Set.Countable (T n) hsT : ∀ (n : ℕ), s ⊆ ⋃ (x : α) (_ : x ∈ T n), closedBall x (↑n)⁻¹ f : ℝ≥0∞ → α → α hfs : ∀ (r : ℝ≥0∞) (x : α), f r x ∈ s hf : ∀ (r : ℝ≥0∞) (x : α), closedBall x r ∩ s ⊆ closedBall (f r x) (r * 2) ⊢ s ⊆ closure (⋃ (n : ℕ), f (↑n)⁻¹ '' T n) [PROOFSTEP] refine' fun x hx => mem_closure_iff.2 fun ε ε0 => _ [GOAL] case inr.intro α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x✝ y z : α ε✝ ε₁ ε₂ : ℝ≥0∞ s✝ t s : Set α hs : ∀ (ε : ℝ≥0∞), ε > 0 → ∃ t, Set.Countable t ∧ s ⊆ ⋃ (x : α) (_ : x ∈ t), closedBall x ε x₀ : α hx₀ : x₀ ∈ s T : ℕ → Set α hTc : ∀ (n : ℕ), Set.Countable (T n) hsT : ∀ (n : ℕ), s ⊆ ⋃ (x : α) (_ : x ∈ T n), closedBall x (↑n)⁻¹ f : ℝ≥0∞ → α → α hfs : ∀ (r : ℝ≥0∞) (x : α), f r x ∈ s hf : ∀ (r : ℝ≥0∞) (x : α), closedBall x r ∩ s ⊆ closedBall (f r x) (r * 2) x : α hx : x ∈ s ε : ℝ≥0∞ ε0 : ε > 0 ⊢ ∃ y, y ∈ ⋃ (n : ℕ), f (↑n)⁻¹ '' T n ∧ edist x y < ε [PROOFSTEP] rcases ENNReal.exists_inv_nat_lt (ENNReal.half_pos ε0.lt.ne').ne' with ⟨n, hn⟩ [GOAL] case inr.intro.intro α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x✝ y z : α ε✝ ε₁ ε₂ : ℝ≥0∞ s✝ t s : Set α hs : ∀ (ε : ℝ≥0∞), ε > 0 → ∃ t, Set.Countable t ∧ s ⊆ ⋃ (x : α) (_ : x ∈ t), closedBall x ε x₀ : α hx₀ : x₀ ∈ s T : ℕ → Set α hTc : ∀ (n : ℕ), Set.Countable (T n) hsT : ∀ (n : ℕ), s ⊆ ⋃ (x : α) (_ : x ∈ T n), closedBall x (↑n)⁻¹ f : ℝ≥0∞ → α → α hfs : ∀ (r : ℝ≥0∞) (x : α), f r x ∈ s hf : ∀ (r : ℝ≥0∞) (x : α), closedBall x r ∩ s ⊆ closedBall (f r x) (r * 2) x : α hx : x ∈ s ε : ℝ≥0∞ ε0 : ε > 0 n : ℕ hn : (↑n)⁻¹ < ε / 2 ⊢ ∃ y, y ∈ ⋃ (n : ℕ), f (↑n)⁻¹ '' T n ∧ edist x y < ε [PROOFSTEP] rcases mem_iUnion₂.1 (hsT n hx) with ⟨y, hyn, hyx⟩ [GOAL] case inr.intro.intro.intro.intro α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x✝ y✝ z : α ε✝ ε₁ ε₂ : ℝ≥0∞ s✝ t s : Set α hs : ∀ (ε : ℝ≥0∞), ε > 0 → ∃ t, Set.Countable t ∧ s ⊆ ⋃ (x : α) (_ : x ∈ t), closedBall x ε x₀ : α hx₀ : x₀ ∈ s T : ℕ → Set α hTc : ∀ (n : ℕ), Set.Countable (T n) hsT : ∀ (n : ℕ), s ⊆ ⋃ (x : α) (_ : x ∈ T n), closedBall x (↑n)⁻¹ f : ℝ≥0∞ → α → α hfs : ∀ (r : ℝ≥0∞) (x : α), f r x ∈ s hf : ∀ (r : ℝ≥0∞) (x : α), closedBall x r ∩ s ⊆ closedBall (f r x) (r * 2) x : α hx : x ∈ s ε : ℝ≥0∞ ε0 : ε > 0 n : ℕ hn : (↑n)⁻¹ < ε / 2 y : α hyn : y ∈ T n hyx : x ∈ closedBall y (↑n)⁻¹ ⊢ ∃ y, y ∈ ⋃ (n : ℕ), f (↑n)⁻¹ '' T n ∧ edist x y < ε [PROOFSTEP] refine' ⟨f n⁻¹ y, mem_iUnion.2 ⟨n, mem_image_of_mem _ hyn⟩, _⟩ [GOAL] case inr.intro.intro.intro.intro α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x✝ y✝ z : α ε✝ ε₁ ε₂ : ℝ≥0∞ s✝ t s : Set α hs : ∀ (ε : ℝ≥0∞), ε > 0 → ∃ t, Set.Countable t ∧ s ⊆ ⋃ (x : α) (_ : x ∈ t), closedBall x ε x₀ : α hx₀ : x₀ ∈ s T : ℕ → Set α hTc : ∀ (n : ℕ), Set.Countable (T n) hsT : ∀ (n : ℕ), s ⊆ ⋃ (x : α) (_ : x ∈ T n), closedBall x (↑n)⁻¹ f : ℝ≥0∞ → α → α hfs : ∀ (r : ℝ≥0∞) (x : α), f r x ∈ s hf : ∀ (r : ℝ≥0∞) (x : α), closedBall x r ∩ s ⊆ closedBall (f r x) (r * 2) x : α hx : x ∈ s ε : ℝ≥0∞ ε0 : ε > 0 n : ℕ hn : (↑n)⁻¹ < ε / 2 y : α hyn : y ∈ T n hyx : x ∈ closedBall y (↑n)⁻¹ ⊢ edist x (f (↑n)⁻¹ y) < ε [PROOFSTEP] calc edist x (f n⁻¹ y) ≤ (n : ℝ≥0∞)⁻¹ * 2 := hf _ _ ⟨hyx, hx⟩ _ < ε := ENNReal.mul_lt_of_lt_div hn [GOAL] α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x y z : α ε ε₁ ε₂ : ℝ≥0∞ s✝ t s : Set α hs : IsSeparable s ⊢ SeparableSpace ↑s [PROOFSTEP] have : ∀ ε > 0, ∃ t : Set α, t.Countable ∧ s ⊆ ⋃ x ∈ t, closedBall x ε := fun ε ε0 => by rcases hs with ⟨t, htc, hst⟩ refine ⟨t, htc, hst.trans fun x hx => ?_⟩ rcases mem_closure_iff.1 hx ε ε0 with ⟨y, hyt, hxy⟩ exact mem_iUnion₂.2 ⟨y, hyt, mem_closedBall.2 hxy.le⟩ [GOAL] α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x y z : α ε✝ ε₁ ε₂ : ℝ≥0∞ s✝ t s : Set α hs : IsSeparable s ε : ℝ≥0∞ ε0 : ε > 0 ⊢ ∃ t, Set.Countable t ∧ s ⊆ ⋃ (x : α) (_ : x ∈ t), closedBall x ε [PROOFSTEP] rcases hs with ⟨t, htc, hst⟩ [GOAL] case intro.intro α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x y z : α ε✝ ε₁ ε₂ : ℝ≥0∞ s✝ t✝ s : Set α ε : ℝ≥0∞ ε0 : ε > 0 t : Set α htc : Set.Countable t hst : s ⊆ closure t ⊢ ∃ t, Set.Countable t ∧ s ⊆ ⋃ (x : α) (_ : x ∈ t), closedBall x ε [PROOFSTEP] refine ⟨t, htc, hst.trans fun x hx => ?_⟩ [GOAL] case intro.intro α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x✝ y z : α ε✝ ε₁ ε₂ : ℝ≥0∞ s✝ t✝ s : Set α ε : ℝ≥0∞ ε0 : ε > 0 t : Set α htc : Set.Countable t hst : s ⊆ closure t x : α hx : x ∈ closure t ⊢ x ∈ ⋃ (x : α) (_ : x ∈ t), closedBall x ε [PROOFSTEP] rcases mem_closure_iff.1 hx ε ε0 with ⟨y, hyt, hxy⟩ [GOAL] case intro.intro.intro.intro α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x✝ y✝ z : α ε✝ ε₁ ε₂ : ℝ≥0∞ s✝ t✝ s : Set α ε : ℝ≥0∞ ε0 : ε > 0 t : Set α htc : Set.Countable t hst : s ⊆ closure t x : α hx : x ∈ closure t y : α hyt : y ∈ t hxy : edist x y < ε ⊢ x ∈ ⋃ (x : α) (_ : x ∈ t), closedBall x ε [PROOFSTEP] exact mem_iUnion₂.2 ⟨y, hyt, mem_closedBall.2 hxy.le⟩ [GOAL] α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x y z : α ε ε₁ ε₂ : ℝ≥0∞ s✝ t s : Set α hs : IsSeparable s this : ∀ (ε : ℝ≥0∞), ε > 0 → ∃ t, Set.Countable t ∧ s ⊆ ⋃ (x : α) (_ : x ∈ t), closedBall x ε ⊢ SeparableSpace ↑s [PROOFSTEP] rcases subset_countable_closure_of_almost_dense_set _ this with ⟨t, hts, htc, hst⟩ [GOAL] case intro.intro.intro α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x y z : α ε ε₁ ε₂ : ℝ≥0∞ s✝ t✝ s : Set α hs : IsSeparable s this : ∀ (ε : ℝ≥0∞), ε > 0 → ∃ t, Set.Countable t ∧ s ⊆ ⋃ (x : α) (_ : x ∈ t), closedBall x ε t : Set α hts : t ⊆ s htc : Set.Countable t hst : s ⊆ closure t ⊢ SeparableSpace ↑s [PROOFSTEP] lift t to Set s using hts [GOAL] case intro.intro.intro.intro α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x y z : α ε ε₁ ε₂ : ℝ≥0∞ s✝ t✝ s : Set α hs : IsSeparable s this : ∀ (ε : ℝ≥0∞), ε > 0 → ∃ t, Set.Countable t ∧ s ⊆ ⋃ (x : α) (_ : x ∈ t), closedBall x ε t : Set ↑s htc : Set.Countable ((fun x x_1 => x '' x_1) Subtype.val t) hst : s ⊆ closure ((fun x x_1 => x '' x_1) Subtype.val t) ⊢ SeparableSpace ↑s [PROOFSTEP] refine ⟨⟨t, countable_of_injective_of_countable_image (Subtype.coe_injective.injOn _) htc, ?_⟩⟩ [GOAL] case intro.intro.intro.intro α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x y z : α ε ε₁ ε₂ : ℝ≥0∞ s✝ t✝ s : Set α hs : IsSeparable s this : ∀ (ε : ℝ≥0∞), ε > 0 → ∃ t, Set.Countable t ∧ s ⊆ ⋃ (x : α) (_ : x ∈ t), closedBall x ε t : Set ↑s htc : Set.Countable ((fun x x_1 => x '' x_1) Subtype.val t) hst : s ⊆ closure ((fun x x_1 => x '' x_1) Subtype.val t) ⊢ Dense t [PROOFSTEP] rwa [inducing_subtype_val.dense_iff, Subtype.forall] [GOAL] α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x y z : α ε ε₁ ε₂ : ℝ≥0∞ s✝ t s : Set α hs : IsCompact s ⊢ ∃ t, t ⊆ s ∧ Set.Countable t ∧ s ⊆ closure t [PROOFSTEP] refine' subset_countable_closure_of_almost_dense_set s fun ε hε => _ [GOAL] α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x y z : α ε✝ ε₁ ε₂ : ℝ≥0∞ s✝ t s : Set α hs : IsCompact s ε : ℝ≥0∞ hε : ε > 0 ⊢ ∃ t, Set.Countable t ∧ s ⊆ ⋃ (x : α) (_ : x ∈ t), closedBall x ε [PROOFSTEP] rcases totallyBounded_iff'.1 hs.totallyBounded ε hε with ⟨t, -, htf, hst⟩ [GOAL] case intro.intro.intro α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x y z : α ε✝ ε₁ ε₂ : ℝ≥0∞ s✝ t✝ s : Set α hs : IsCompact s ε : ℝ≥0∞ hε : ε > 0 t : Set α htf : Set.Finite t hst : s ⊆ ⋃ (y : α) (_ : y ∈ t), ball y ε ⊢ ∃ t, Set.Countable t ∧ s ⊆ ⋃ (x : α) (_ : x ∈ t), closedBall x ε [PROOFSTEP] exact ⟨t, htf.countable, hst.trans <| iUnion₂_mono fun _ _ => ball_subset_closedBall⟩ [GOAL] α : Type u β : Type v X : Type u_1 inst✝¹ : PseudoEMetricSpace α x y z : α ε ε₁ ε₂ : ℝ≥0∞ s t : Set α inst✝ : SigmaCompactSpace α ⊢ SecondCountableTopology α [PROOFSTEP] suffices SeparableSpace α by exact UniformSpace.secondCountable_of_separable α [GOAL] α : Type u β : Type v X : Type u_1 inst✝¹ : PseudoEMetricSpace α x y z : α ε ε₁ ε₂ : ℝ≥0∞ s t : Set α inst✝ : SigmaCompactSpace α this : SeparableSpace α ⊢ SecondCountableTopology α [PROOFSTEP] exact UniformSpace.secondCountable_of_separable α [GOAL] α : Type u β : Type v X : Type u_1 inst✝¹ : PseudoEMetricSpace α x y z : α ε ε₁ ε₂ : ℝ≥0∞ s t : Set α inst✝ : SigmaCompactSpace α ⊢ SeparableSpace α [PROOFSTEP] choose T _ hTc hsubT using fun n => subset_countable_closure_of_compact (isCompact_compactCovering α n) [GOAL] α : Type u β : Type v X : Type u_1 inst✝¹ : PseudoEMetricSpace α x y z : α ε ε₁ ε₂ : ℝ≥0∞ s t : Set α inst✝ : SigmaCompactSpace α T : ℕ → Set α h✝ : ∀ (n : ℕ), T n ⊆ compactCovering α n hTc : ∀ (n : ℕ), Set.Countable (T n) hsubT : ∀ (n : ℕ), compactCovering α n ⊆ closure (T n) ⊢ SeparableSpace α [PROOFSTEP] refine' ⟨⟨⋃ n, T n, countable_iUnion hTc, fun x => _⟩⟩ [GOAL] α : Type u β : Type v X : Type u_1 inst✝¹ : PseudoEMetricSpace α x✝ y z : α ε ε₁ ε₂ : ℝ≥0∞ s t : Set α inst✝ : SigmaCompactSpace α T : ℕ → Set α h✝ : ∀ (n : ℕ), T n ⊆ compactCovering α n hTc : ∀ (n : ℕ), Set.Countable (T n) hsubT : ∀ (n : ℕ), compactCovering α n ⊆ closure (T n) x : α ⊢ x ∈ closure (⋃ (n : ℕ), T n) [PROOFSTEP] rcases iUnion_eq_univ_iff.1 (iUnion_compactCovering α) x with ⟨n, hn⟩ [GOAL] case intro α : Type u β : Type v X : Type u_1 inst✝¹ : PseudoEMetricSpace α x✝ y z : α ε ε₁ ε₂ : ℝ≥0∞ s t : Set α inst✝ : SigmaCompactSpace α T : ℕ → Set α h✝ : ∀ (n : ℕ), T n ⊆ compactCovering α n hTc : ∀ (n : ℕ), Set.Countable (T n) hsubT : ∀ (n : ℕ), compactCovering α n ⊆ closure (T n) x : α n : ℕ hn : x ∈ compactCovering α n ⊢ x ∈ closure (⋃ (n : ℕ), T n) [PROOFSTEP] exact closure_mono (subset_iUnion _ n) (hsubT _ hn) [GOAL] α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x y z : α ε ε₁ ε₂ : ℝ≥0∞ s t : Set α hs : ∀ (ε : ℝ≥0∞), ε > 0 → ∃ t, Set.Countable t ∧ ⋃ (x : α) (_ : x ∈ t), closedBall x ε = univ ⊢ SecondCountableTopology α [PROOFSTEP] suffices SeparableSpace α from UniformSpace.secondCountable_of_separable α [GOAL] α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x y z : α ε ε₁ ε₂ : ℝ≥0∞ s t : Set α hs : ∀ (ε : ℝ≥0∞), ε > 0 → ∃ t, Set.Countable t ∧ ⋃ (x : α) (_ : x ∈ t), closedBall x ε = univ ⊢ SeparableSpace α [PROOFSTEP] have : ∀ ε > 0, ∃ t : Set α, Set.Countable t ∧ univ ⊆ ⋃ x ∈ t, closedBall x ε [GOAL] case this α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x y z : α ε ε₁ ε₂ : ℝ≥0∞ s t : Set α hs : ∀ (ε : ℝ≥0∞), ε > 0 → ∃ t, Set.Countable t ∧ ⋃ (x : α) (_ : x ∈ t), closedBall x ε = univ ⊢ ∀ (ε : ℝ≥0∞), ε > 0 → ∃ t, Set.Countable t ∧ univ ⊆ ⋃ (x : α) (_ : x ∈ t), closedBall x ε [PROOFSTEP] simpa only [univ_subset_iff] using hs [GOAL] α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x y z : α ε ε₁ ε₂ : ℝ≥0∞ s t : Set α hs : ∀ (ε : ℝ≥0∞), ε > 0 → ∃ t, Set.Countable t ∧ ⋃ (x : α) (_ : x ∈ t), closedBall x ε = univ this : ∀ (ε : ℝ≥0∞), ε > 0 → ∃ t, Set.Countable t ∧ univ ⊆ ⋃ (x : α) (_ : x ∈ t), closedBall x ε ⊢ SeparableSpace α [PROOFSTEP] rcases subset_countable_closure_of_almost_dense_set (univ : Set α) this with ⟨t, -, htc, ht⟩ [GOAL] case intro.intro.intro α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x y z : α ε ε₁ ε₂ : ℝ≥0∞ s t✝ : Set α hs : ∀ (ε : ℝ≥0∞), ε > 0 → ∃ t, Set.Countable t ∧ ⋃ (x : α) (_ : x ∈ t), closedBall x ε = univ this : ∀ (ε : ℝ≥0∞), ε > 0 → ∃ t, Set.Countable t ∧ univ ⊆ ⋃ (x : α) (_ : x ∈ t), closedBall x ε t : Set α htc : Set.Countable t ht : univ ⊆ closure t ⊢ SeparableSpace α [PROOFSTEP] exact ⟨⟨t, htc, fun x => ht (mem_univ x)⟩⟩ [GOAL] α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x y z : α ε ε₁ ε₂ : ℝ≥0∞ s t : Set α d : ℝ≥0∞ ⊢ diam s ≤ d ↔ ∀ (x : α), x ∈ s → ∀ (y : α), y ∈ s → edist x y ≤ d [PROOFSTEP] simp only [diam, iSup_le_iff] [GOAL] α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x y z : α ε ε₁ ε₂ : ℝ≥0∞ s✝ t : Set α d : ℝ≥0∞ f : β → α s : Set β ⊢ diam (f '' s) ≤ d ↔ ∀ (x : β), x ∈ s → ∀ (y : β), y ∈ s → edist (f x) (f y) ≤ d [PROOFSTEP] simp only [diam_le_iff, ball_image_iff] [GOAL] α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x y z : α ε ε₁ ε₂ : ℝ≥0∞ s✝ t : Set α ι : Type u_2 o : Option ι s : ι → Set α ⊢ diam (⋃ (i : ι) (_ : i ∈ o), s i) = ⨆ (i : ι) (_ : i ∈ o), diam (s i) [PROOFSTEP] cases o [GOAL] case none α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x y z : α ε ε₁ ε₂ : ℝ≥0∞ s✝ t : Set α ι : Type u_2 s : ι → Set α ⊢ diam (⋃ (i : ι) (_ : i ∈ none), s i) = ⨆ (i : ι) (_ : i ∈ none), diam (s i) [PROOFSTEP] simp [GOAL] case some α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x y z : α ε ε₁ ε₂ : ℝ≥0∞ s✝ t : Set α ι : Type u_2 s : ι → Set α val✝ : ι ⊢ diam (⋃ (i : ι) (_ : i ∈ Option.some val✝), s i) = ⨆ (i : ι) (_ : i ∈ Option.some val✝), diam (s i) [PROOFSTEP] simp [GOAL] α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x y z : α ε ε₁ ε₂ : ℝ≥0∞ s t : Set α d : ℝ≥0∞ ⊢ diam (insert x s) ≤ d ↔ max (⨆ (y : α) (_ : y ∈ s), edist x y) (diam s) ≤ d [PROOFSTEP] simp only [diam_le_iff, ball_insert_iff, edist_self, edist_comm x, max_le_iff, iSup_le_iff, zero_le, true_and_iff, forall_and, and_self_iff, ← and_assoc] [GOAL] α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x y z : α ε ε₁ ε₂ : ℝ≥0∞ s t : Set α ⊢ diam {x, y} = edist x y [PROOFSTEP] simp only [iSup_singleton, diam_insert, diam_singleton, ENNReal.max_zero_right] [GOAL] α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x y z : α ε ε₁ ε₂ : ℝ≥0∞ s t : Set α ⊢ diam {x, y, z} = max (max (edist x y) (edist x z)) (edist y z) [PROOFSTEP] simp only [diam_insert, iSup_insert, iSup_singleton, diam_singleton, ENNReal.max_zero_right, ENNReal.sup_eq_max] [GOAL] α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x y z : α ε ε₁ ε₂ : ℝ≥0∞ s t✝ t : Set α xs : x ∈ s yt : y ∈ t ⊢ diam (s ∪ t) ≤ diam s + edist x y + diam t [PROOFSTEP] have A : ∀ a ∈ s, ∀ b ∈ t, edist a b ≤ diam s + edist x y + diam t := fun a ha b hb => calc edist a b ≤ edist a x + edist x y + edist y b := edist_triangle4 _ _ _ _ _ ≤ diam s + edist x y + diam t := add_le_add (add_le_add (edist_le_diam_of_mem ha xs) le_rfl) (edist_le_diam_of_mem yt hb) [GOAL] α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x y z : α ε ε₁ ε₂ : ℝ≥0∞ s t✝ t : Set α xs : x ∈ s yt : y ∈ t A : ∀ (a : α), a ∈ s → ∀ (b : α), b ∈ t → edist a b ≤ diam s + edist x y + diam t ⊢ diam (s ∪ t) ≤ diam s + edist x y + diam t [PROOFSTEP] refine' diam_le fun a ha b hb => _ [GOAL] α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x y z : α ε ε₁ ε₂ : ℝ≥0∞ s t✝ t : Set α xs : x ∈ s yt : y ∈ t A : ∀ (a : α), a ∈ s → ∀ (b : α), b ∈ t → edist a b ≤ diam s + edist x y + diam t a : α ha : a ∈ s ∪ t b : α hb : b ∈ s ∪ t ⊢ edist a b ≤ diam s + edist x y + diam t [PROOFSTEP] cases' (mem_union _ _ _).1 ha with h'a h'a [GOAL] case inl α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x y z : α ε ε₁ ε₂ : ℝ≥0∞ s t✝ t : Set α xs : x ∈ s yt : y ∈ t A : ∀ (a : α), a ∈ s → ∀ (b : α), b ∈ t → edist a b ≤ diam s + edist x y + diam t a : α ha : a ∈ s ∪ t b : α hb : b ∈ s ∪ t h'a : a ∈ s ⊢ edist a b ≤ diam s + edist x y + diam t [PROOFSTEP] cases' (mem_union _ _ _).1 hb with h'b h'b [GOAL] case inr α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x y z : α ε ε₁ ε₂ : ℝ≥0∞ s t✝ t : Set α xs : x ∈ s yt : y ∈ t A : ∀ (a : α), a ∈ s → ∀ (b : α), b ∈ t → edist a b ≤ diam s + edist x y + diam t a : α ha : a ∈ s ∪ t b : α hb : b ∈ s ∪ t h'a : a ∈ t ⊢ edist a b ≤ diam s + edist x y + diam t [PROOFSTEP] cases' (mem_union _ _ _).1 hb with h'b h'b [GOAL] case inl.inl α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x y z : α ε ε₁ ε₂ : ℝ≥0∞ s t✝ t : Set α xs : x ∈ s yt : y ∈ t A : ∀ (a : α), a ∈ s → ∀ (b : α), b ∈ t → edist a b ≤ diam s + edist x y + diam t a : α ha : a ∈ s ∪ t b : α hb : b ∈ s ∪ t h'a : a ∈ s h'b : b ∈ s ⊢ edist a b ≤ diam s + edist x y + diam t [PROOFSTEP] calc edist a b ≤ diam s := edist_le_diam_of_mem h'a h'b _ ≤ diam s + (edist x y + diam t) := le_self_add _ = diam s + edist x y + diam t := (add_assoc _ _ _).symm [GOAL] case inl.inr α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x y z : α ε ε₁ ε₂ : ℝ≥0∞ s t✝ t : Set α xs : x ∈ s yt : y ∈ t A : ∀ (a : α), a ∈ s → ∀ (b : α), b ∈ t → edist a b ≤ diam s + edist x y + diam t a : α ha : a ∈ s ∪ t b : α hb : b ∈ s ∪ t h'a : a ∈ s h'b : b ∈ t ⊢ edist a b ≤ diam s + edist x y + diam t [PROOFSTEP] exact A a h'a b h'b [GOAL] case inr.inl α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x y z : α ε ε₁ ε₂ : ℝ≥0∞ s t✝ t : Set α xs : x ∈ s yt : y ∈ t A : ∀ (a : α), a ∈ s → ∀ (b : α), b ∈ t → edist a b ≤ diam s + edist x y + diam t a : α ha : a ∈ s ∪ t b : α hb : b ∈ s ∪ t h'a : a ∈ t h'b : b ∈ s ⊢ edist a b ≤ diam s + edist x y + diam t [PROOFSTEP] have Z := A b h'b a h'a [GOAL] case inr.inl α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x y z : α ε ε₁ ε₂ : ℝ≥0∞ s t✝ t : Set α xs : x ∈ s yt : y ∈ t A : ∀ (a : α), a ∈ s → ∀ (b : α), b ∈ t → edist a b ≤ diam s + edist x y + diam t a : α ha : a ∈ s ∪ t b : α hb : b ∈ s ∪ t h'a : a ∈ t h'b : b ∈ s Z : edist b a ≤ diam s + edist x y + diam t ⊢ edist a b ≤ diam s + edist x y + diam t [PROOFSTEP] rwa [edist_comm] at Z [GOAL] case inr.inr α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x y z : α ε ε₁ ε₂ : ℝ≥0∞ s t✝ t : Set α xs : x ∈ s yt : y ∈ t A : ∀ (a : α), a ∈ s → ∀ (b : α), b ∈ t → edist a b ≤ diam s + edist x y + diam t a : α ha : a ∈ s ∪ t b : α hb : b ∈ s ∪ t h'a : a ∈ t h'b : b ∈ t ⊢ edist a b ≤ diam s + edist x y + diam t [PROOFSTEP] calc edist a b ≤ diam t := edist_le_diam_of_mem h'a h'b _ ≤ diam s + edist x y + diam t := le_add_self [GOAL] α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x y z : α ε ε₁ ε₂ : ℝ≥0∞ s t✝ t : Set α h : Set.Nonempty (s ∩ t) ⊢ diam (s ∪ t) ≤ diam s + diam t [PROOFSTEP] let ⟨x, ⟨xs, xt⟩⟩ := h [GOAL] α : Type u β : Type v X : Type u_1 inst✝ : PseudoEMetricSpace α x✝ y z : α ε ε₁ ε₂ : ℝ≥0∞ s t✝ t : Set α h : Set.Nonempty (s ∩ t) x : α xs : x ∈ s xt : x ∈ t ⊢ diam (s ∪ t) ≤ diam s + diam t [PROOFSTEP] simpa using diam_union xs xt [GOAL] α : Type u β : Type v X : Type u_1 inst✝² : PseudoEMetricSpace α x y z : α ε ε₁ ε₂ : ℝ≥0∞ s✝ t : Set α π : β → Type u_2 inst✝¹ : Fintype β inst✝ : (b : β) → PseudoEMetricSpace (π b) s : (b : β) → Set (π b) c : ℝ≥0∞ h : ∀ (b : β), diam (s b) ≤ c ⊢ diam (Set.pi univ s) ≤ c [PROOFSTEP] refine diam_le fun x hx y hy => edist_pi_le_iff.mpr ?_ [GOAL] α : Type u β : Type v X : Type u_1 inst✝² : PseudoEMetricSpace α x✝ y✝ z : α ε ε₁ ε₂ : ℝ≥0∞ s✝ t : Set α π : β → Type u_2 inst✝¹ : Fintype β inst✝ : (b : β) → PseudoEMetricSpace (π b) s : (b : β) → Set (π b) c : ℝ≥0∞ h : ∀ (b : β), diam (s b) ≤ c x : (i : β) → π i hx : x ∈ Set.pi univ s y : (i : β) → π i hy : y ∈ Set.pi univ s ⊢ ∀ (b : β), edist (x b) (y b) ≤ c [PROOFSTEP] rw [mem_univ_pi] at hx hy [GOAL] α : Type u β : Type v X : Type u_1 inst✝² : PseudoEMetricSpace α x✝ y✝ z : α ε ε₁ ε₂ : ℝ≥0∞ s✝ t : Set α π : β → Type u_2 inst✝¹ : Fintype β inst✝ : (b : β) → PseudoEMetricSpace (π b) s : (b : β) → Set (π b) c : ℝ≥0∞ h : ∀ (b : β), diam (s b) ≤ c x : (i : β) → π i hx : ∀ (i : β), x i ∈ s i y : (i : β) → π i hy : ∀ (i : β), y i ∈ s i ⊢ ∀ (b : β), edist (x b) (y b) ≤ c [PROOFSTEP] exact fun b => diam_le_iff.1 (h b) (x b) (hx b) (y b) (hy b) [GOAL] α : Type u β : Type v X : Type u_1 inst✝¹ : PseudoEMetricSpace α γ : Type w inst✝ : EMetricSpace γ x y : γ ⊢ 0 < edist x y ↔ x ≠ y [PROOFSTEP] simp [← not_le] [GOAL] α : Type u β : Type v X : Type u_1 inst✝² : PseudoEMetricSpace α γ : Type w inst✝¹ : EMetricSpace γ inst✝ : EMetricSpace β f : γ → β ⊢ UniformEmbedding f ↔ (∀ (ε : ℝ≥0∞), ε > 0 → ∃ δ, δ > 0 ∧ ∀ {a b : γ}, edist a b < δ → edist (f a) (f b) < ε) ∧ ∀ (δ : ℝ≥0∞), δ > 0 → ∃ ε, ε > 0 ∧ ∀ {a b : γ}, edist (f a) (f b) < ε → edist a b < δ [PROOFSTEP] rw [uniformEmbedding_iff_uniformInducing, uniformInducing_iff, uniformContinuous_iff] [GOAL] α : Type u β : Type v X : Type u_1 inst✝¹ : PseudoEMetricSpace α γ : Type w inst✝ : EMetricSpace γ s : Set γ hs : IsCompact s ⊢ ∃ t, t ⊆ s ∧ Set.Countable t ∧ s = closure t [PROOFSTEP] rcases subset_countable_closure_of_compact hs with ⟨t, hts, htc, hsub⟩ [GOAL] case intro.intro.intro α : Type u β : Type v X : Type u_1 inst✝¹ : PseudoEMetricSpace α γ : Type w inst✝ : EMetricSpace γ s : Set γ hs : IsCompact s t : Set γ hts : t ⊆ s htc : Set.Countable t hsub : s ⊆ closure t ⊢ ∃ t, t ⊆ s ∧ Set.Countable t ∧ s = closure t [PROOFSTEP] exact ⟨t, hts, htc, hsub.antisymm (closure_minimal hts hs.isClosed)⟩ [GOAL] α : Type u β : Type v X : Type u_1 inst✝¹ : PseudoEMetricSpace α γ : Type w inst✝ : EMetricSpace γ s : Set γ ⊢ 0 < diam s ↔ Set.Nontrivial s [PROOFSTEP] simp only [pos_iff_ne_zero, Ne.def, diam_eq_zero_iff, Set.not_subsingleton_iff] [GOAL] α : Type u β : Type v X : Type u_1 inst✝¹ : PseudoEMetricSpace α γ : Type w inst✝ : EMetricSpace γ s : Set γ ⊢ 0 < diam s ↔ ∃ x, x ∈ s ∧ ∃ y, y ∈ s ∧ x ≠ y [PROOFSTEP] simp only [diam_pos_iff, Set.Nontrivial, exists_prop] [GOAL] α : Type u β : Type v X : Type u_1 inst✝² : PseudoEMetricSpace α γ : Type w inst✝¹ : EMetricSpace γ inst✝ : PseudoEMetricSpace X ε : ℝ≥0∞ x✝ : 0 < ε ⊢ (fun p => (Quotient.mk (UniformSpace.separationSetoid X) p.fst, Quotient.mk (UniformSpace.separationSetoid X) p.snd)) '' {p | edist p.fst p.snd < ε} = {p | edist p.fst p.snd < ε} [PROOFSTEP] ext ⟨⟨x⟩, ⟨y⟩⟩ [GOAL] case h.mk.mk.mk α : Type u β : Type v X : Type u_1 inst✝² : PseudoEMetricSpace α γ : Type w inst✝¹ : EMetricSpace γ inst✝ : PseudoEMetricSpace X ε : ℝ≥0∞ x✝ : 0 < ε fst✝ snd✝ : Quotient (UniformSpace.separationSetoid X) x y : X ⊢ (Quot.mk Setoid.r x, Quot.mk Setoid.r y) ∈ (fun p => (Quotient.mk (UniformSpace.separationSetoid X) p.fst, Quotient.mk (UniformSpace.separationSetoid X) p.snd)) '' {p | edist p.fst p.snd < ε} ↔ (Quot.mk Setoid.r x, Quot.mk Setoid.r y) ∈ {p | edist p.fst p.snd < ε} [PROOFSTEP] refine ⟨?_, fun h => ⟨(x, y), h, rfl⟩⟩ [GOAL] case h.mk.mk.mk α : Type u β : Type v X : Type u_1 inst✝² : PseudoEMetricSpace α γ : Type w inst✝¹ : EMetricSpace γ inst✝ : PseudoEMetricSpace X ε : ℝ≥0∞ x✝ : 0 < ε fst✝ snd✝ : Quotient (UniformSpace.separationSetoid X) x y : X ⊢ (Quot.mk Setoid.r x, Quot.mk Setoid.r y) ∈ (fun p => (Quotient.mk (UniformSpace.separationSetoid X) p.fst, Quotient.mk (UniformSpace.separationSetoid X) p.snd)) '' {p | edist p.fst p.snd < ε} → (Quot.mk Setoid.r x, Quot.mk Setoid.r y) ∈ {p | edist p.fst p.snd < ε} [PROOFSTEP] rintro ⟨⟨x', y'⟩, h', h⟩ [GOAL] case h.mk.mk.mk.intro.mk.intro α : Type u β : Type v X : Type u_1 inst✝² : PseudoEMetricSpace α γ : Type w inst✝¹ : EMetricSpace γ inst✝ : PseudoEMetricSpace X ε : ℝ≥0∞ x✝ : 0 < ε fst✝ snd✝ : Quotient (UniformSpace.separationSetoid X) x y x' y' : X h' : (x', y') ∈ {p | edist p.fst p.snd < ε} h : (fun p => (Quotient.mk (UniformSpace.separationSetoid X) p.fst, Quotient.mk (UniformSpace.separationSetoid X) p.snd)) (x', y') = (Quot.mk Setoid.r x, Quot.mk Setoid.r y) ⊢ (Quot.mk Setoid.r x, Quot.mk Setoid.r y) ∈ {p | edist p.fst p.snd < ε} [PROOFSTEP] simp only [Prod.ext_iff] at h [GOAL] case h.mk.mk.mk.intro.mk.intro α : Type u β : Type v X : Type u_1 inst✝² : PseudoEMetricSpace α γ : Type w inst✝¹ : EMetricSpace γ inst✝ : PseudoEMetricSpace X ε : ℝ≥0∞ x✝ : 0 < ε fst✝ snd✝ : Quotient (UniformSpace.separationSetoid X) x y x' y' : X h' : (x', y') ∈ {p | edist p.fst p.snd < ε} h : Quotient.mk (UniformSpace.separationSetoid X) x' = Quot.mk Setoid.r x ∧ Quotient.mk (UniformSpace.separationSetoid X) y' = Quot.mk Setoid.r y ⊢ (Quot.mk Setoid.r x, Quot.mk Setoid.r y) ∈ {p | edist p.fst p.snd < ε} [PROOFSTEP] rwa [← h.1, ← h.2]
universes u def id' {α : Sort u} (a : α) : α := a def Set (X : Type) := X → Prop namespace Set def mem {X : Type} (x : X) (s : Set X) := s x infix:50 " ∈ " => mem theorem ext {X : Type} (s₁ s₂ : Set X) (h : ∀ x : X, x ∈ s₁ ↔ x ∈ s₂) : s₁ = s₂ := by funext x exact propext <| h x @[inline] def asSubtype {X : Type} (Y : Set X) := Subtype (λ x => x ∈ Y) instance {X : Type} : CoeSort (Set X) Type where coe Y := Subtype (λ x => x ∈ Y) def img {X Y : Type} (f : X → Y) (P : Set X) : Set Y := λ y => ∃ x, x ∈ P ∧ y = f x def imgComp {X Y Z : Type} {f : X → Y} {g : Y → Z} {P : Set X} : img g (img f P) = img (g ∘ f) P := by funext z apply propext simp [img, Function.comp] exact ⟨ λ h => match h with | ⟨ y, ⟨ ⟨ x, ⟨ xIn, xImg ⟩ ⟩, yImg ⟩ ⟩ => ⟨ x, ⟨ xIn, xImg ▸ yImg ▸ rfl ⟩ ⟩, λ h => match h with | ⟨ x, ⟨ xIn, xImg ⟩ ⟩ => ⟨ (f x), ⟨ ⟨ x, ⟨ xIn, rfl ⟩ ⟩, xImg ⟩ ⟩ ⟩ def imgCongrFun {X Y : Type} {f g : X → Y} {P : Set X} (h : f = g) : img f P = img g P := by rw [h] end Set
(* Exercise 17 *) Require Import BenB. Variable D : Set. Variables P Q S T : D -> Prop. Variable R : D -> D -> Prop. Theorem exercise_017 : ~(exists x : D, forall y : D, (R y x -> ~ R x y) /\ (~ R x y -> R y x)). Proof. neg_i (1=1) a1. exi_e (exists x : D, forall y : D, (R y x -> ~ R x y) /\ (~ R x y -> R y x)) a a2. hyp a1. dis_e (R a a \/ ~R a a) a3 a3. LEM. neg_e (R a a). imp_e (R a a). con_e1 (~R a a -> R a a). all_e (forall y:D, (R y a -> ~ R a y) /\ (~ R a y -> R y a)) a. hyp a2. hyp a3. hyp a3. neg_e (R a a). hyp a3. imp_e (~R a a). con_e2 (R a a -> ~R a a). all_e (forall y : D, (R y a -> ~ R a y) /\ (~ R a y -> R y a)) a. hyp a2. hyp a3. lin_solve. Qed.
## Copyright (c) 2013 Miguel Bazdresch ## ## This file is distributed under the 2-clause BSD License. """ save(term, output, [termopts,] [font,] [size,] [linewidth,] [background,] [handle]) -> nothing Save current figure (or figure specified by `handle`) using the specified `term`. Optionally, the font, size, linewidth, and background may be specified as arguments. """ function save(; term::String, output::String, handle::Int = gnuplot_state.current, font = "", size = "", linewidth = 0, background = "", saveopts = config[:saveopts]) debug("term = $term, output = $output, saveopts = $saveopts", "save") # process arguments isempty(output) && throw(DomainError("Please specify an output filename.")) isempty(term) && throw(DomainError("Please specify a file format")) h = findfigure(handle) h == 0 && throw(DomainError(h, "requested figure does not exist.")) fig = gnuplot_state.figs[h] (term == "pdf" || term == :pdf) && (term = "pdfcairo") (term == "png" || term == :png) && (term = "pngcairo") (term == "eps" || term == :eps) && (term = "epscairo") # create print configuration pc = "set term $term " if isempty(saveopts) !isempty(font) && (pc *= "font '$font' ") !isempty(size) && (pc *= "size $size ") linewidth > 0 && (pc *= "linewidth $linewidth ") !isempty(background) && (pc *= "background '$background' ") else pc *= saveopts end # send gnuplot commands llplot(fig, printstring=(pc,output)) return nothing end
module HVX.Internal.TestUtil ( fpequalsApprox , pairsOf , positiveVectors , smallEvenPowersGreaterThanOne , smallNonIntPowersGreaterThanOne , smallVectors , vectors ) where import Control.Monad import Numeric.LinearAlgebra import Test.QuickCheck hiding ( (><) ) import HVX.Internal.Matrix import HVX.Internal.Util fpequalsApprox :: Double -> Double -> Bool fpequalsApprox a b | a == 0 && b == 0 = True | max (abs a) (abs b) < 1e-6 = True | otherwise = abs ( (a - b) / denom) < tolerance where denom = max (abs a) (abs b) tolerance = 5e-2 -- 5% tolerance is why we call it Approx. pairsOf :: Gen a -> Gen b -> Gen (a, b) pairsOf a b = do x <- a y <- b return (x, y) positiveVectors :: Gen Mat positiveVectors = do nonEmptyL <- arbitrary :: Gen (NonEmptyList Double) let l = getNonEmpty nonEmptyL return $ abs $ (length l><1) l smallEvenPowersGreaterThanOne :: Gen Double smallEvenPowersGreaterThanOne = liftM fromIntegral $ (arbitrary :: Gen Integer) `suchThat` \x -> x > 1 && x <= 20 && even x smallNonIntPowersGreaterThanOne :: Gen Double smallNonIntPowersGreaterThanOne = arbitrary `suchThat` \x -> x > 1 && x <= 20 && not (isInteger x) smallVectors :: Gen Mat smallVectors = do len <- choose (1, 100) l <- sequence [choose (-10, 10) | _ <- [1..len]] return $ (len><1) l vectors :: Gen Mat vectors = do nonEmptyL <- arbitrary :: Gen (NonEmptyList Double) let l = getNonEmpty nonEmptyL return $ (length l><1) l
lemma bounded_insert [simp]: "bounded (insert x S) \<longleftrightarrow> bounded S"
Proper discipline for children while being careful not to provoke them .
Formal statement is: lemma map_poly_id [simp]: "map_poly id p = p" Informal statement is: The identity function is the identity map on polynomials.
[STATEMENT] theorem Done_ZObis[simp]: "Done \<approx>01 Done" [PROOF STATE] proof (prove) goal (1 subgoal): 1. Done \<approx>01 Done [PROOF STEP] by simp
/- Copyright (c) 2018 Chris Hughes. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Chris Hughes ! This file was ported from Lean 3 source module ring_theory.adjoin.field ! leanprover-community/mathlib commit c4658a649d216f57e99621708b09dcb3dcccbd23 ! Please do not edit these lines, except to modify the commit id ! if you have ported upstream changes. -/ import Mathbin.Data.Polynomial.Splits import Mathbin.RingTheory.Adjoin.Basic import Mathbin.RingTheory.AdjoinRoot /-! # Adjoining elements to a field Some lemmas on the ring generating by adjoining an element to a field. ## Main statements * `lift_of_splits`: If `K` and `L` are field extensions of `F` and we have `s : finset K` such that the minimal polynomial of each `x ∈ s` splits in `L` then `algebra.adjoin F s` embeds in `L`. -/ noncomputable section open BigOperators Polynomial section Embeddings variable (F : Type _) [Field F] /-- If `p` is the minimal polynomial of `a` over `F` then `F[a] ≃ₐ[F] F[x]/(p)` -/ def AlgEquiv.adjoinSingletonEquivAdjoinRootMinpoly {R : Type _} [CommRing R] [Algebra F R] (x : R) : Algebra.adjoin F ({x} : Set R) ≃ₐ[F] AdjoinRoot (minpoly F x) := AlgEquiv.symm <| AlgEquiv.ofBijective (AlgHom.codRestrict (AdjoinRoot.liftHom _ x <| minpoly.aeval F x) _ fun p => AdjoinRoot.induction_on _ p fun p => (Algebra.adjoin_singleton_eq_range_aeval F x).symm ▸ (Polynomial.aeval _).mem_range.mpr ⟨p, rfl⟩) ⟨(AlgHom.injective_codRestrict _ _ _).2 <| (injective_iff_map_eq_zero _).2 fun p => AdjoinRoot.induction_on _ p fun p hp => Ideal.Quotient.eq_zero_iff_mem.2 <| Ideal.mem_span_singleton.2 <| minpoly.dvd F x hp, fun y => let ⟨p, hp⟩ := (SetLike.ext_iff.1 (Algebra.adjoin_singleton_eq_range_aeval F x) (y : R)).1 y.2 ⟨AdjoinRoot.mk _ p, Subtype.eq hp⟩⟩ #align alg_equiv.adjoin_singleton_equiv_adjoin_root_minpoly AlgEquiv.adjoinSingletonEquivAdjoinRootMinpoly open Finset /-- If `K` and `L` are field extensions of `F` and we have `s : finset K` such that the minimal polynomial of each `x ∈ s` splits in `L` then `algebra.adjoin F s` embeds in `L`. -/ theorem lift_of_splits {F K L : Type _} [Field F] [Field K] [Field L] [Algebra F K] [Algebra F L] (s : Finset K) : (∀ x ∈ s, IsIntegral F x ∧ Polynomial.Splits (algebraMap F L) (minpoly F x)) → Nonempty (Algebra.adjoin F (↑s : Set K) →ₐ[F] L) := by classical refine' Finset.induction_on s (fun H => _) fun a s has ih H => _ · rw [coe_empty, Algebra.adjoin_empty] exact ⟨(Algebra.ofId F L).comp (Algebra.botEquiv F K)⟩ rw [forall_mem_insert] at H rcases H with ⟨⟨H1, H2⟩, H3⟩ cases' ih H3 with f choose H3 H4 using H3 rw [coe_insert, Set.insert_eq, Set.union_comm, Algebra.adjoin_union_eq_adjoin_adjoin] letI := (f : Algebra.adjoin F (↑s : Set K) →+* L).toAlgebra haveI : FiniteDimensional F (Algebra.adjoin F (↑s : Set K)) := ((Submodule.fg_iff_finiteDimensional _).1 (fg_adjoin_of_finite s.finite_to_set H3)).of_subalgebra_toSubmodule letI := fieldOfFiniteDimensional F (Algebra.adjoin F (↑s : Set K)) have H5 : IsIntegral (Algebra.adjoin F (↑s : Set K)) a := isIntegral_of_isScalarTower H1 have H6 : (minpoly (Algebra.adjoin F (↑s : Set K)) a).Splits (algebraMap (Algebra.adjoin F (↑s : Set K)) L) := by refine' Polynomial.splits_of_splits_of_dvd _ (Polynomial.map_ne_zero <| minpoly.ne_zero H1 : Polynomial.map (algebraMap _ _) _ ≠ 0) ((Polynomial.splits_map_iff _ _).2 _) (minpoly.dvd _ _ _) · rw [← IsScalarTower.algebraMap_eq] exact H2 · rw [Polynomial.aeval_map_algebraMap, minpoly.aeval] obtain ⟨y, hy⟩ := Polynomial.exists_root_of_splits _ H6 (ne_of_lt (minpoly.degree_pos H5)).symm refine' ⟨Subalgebra.ofRestrictScalars _ _ _⟩ refine' (AdjoinRoot.liftHom (minpoly (Algebra.adjoin F (↑s : Set K)) a) y hy).comp _ exact AlgEquiv.adjoinSingletonEquivAdjoinRootMinpoly (Algebra.adjoin F (↑s : Set K)) a #align lift_of_splits lift_of_splits end Embeddings
||| Test if :typeat can report the type of variables in interface definitions ||| and implementations interface Nattable a where toNat : a -> Nat Nattable Bool where -- Create some variables just to test toNat True = let x = 0 in S x toNat False = let y = 0 in y
-- Jesper, 2019-09-12: The fix of #3541 introduced a regression: the -- index of the equality type is treated as a positive argument. data _≡_ (A : Set) : Set → Set where refl : A ≡ A postulate X : Set data D : Set where c : X ≡ D → D
Formal statement is: lemma polynomial_function_add [intro]: "\<lbrakk>polynomial_function f; polynomial_function g\<rbrakk> \<Longrightarrow> polynomial_function (\<lambda>x. f x + g x)" Informal statement is: If $f$ and $g$ are polynomial functions, then so is $f + g$.
lemma is_interval_cbox [simp]: "is_interval (cbox a (b::'a::euclidean_space))" (is ?th1) and is_interval_box [simp]: "is_interval (box a b)" (is ?th2)
module utilities contains subroutine check_fompi_status( actual, expected, filename, line, & rank ) implicit none integer, intent(in) :: actual integer, intent(in) :: expected character(50), intent(in) :: filename integer, intent(in) :: line integer, intent(in) :: rank if (actual .ne. expected) then write (*,*) "Error on rank ", rank, " in ", filename, " line ", & line, ": return code ", actual, " instead of ", expected STOP endif end subroutine check_fompi_status subroutine millisleep(milliseconds) ! inspired by IRO-bot (see http://stackoverflow.com/questions/6931846/sleep-in-fortran) ! for small waits, since it is using CPU time while waiting implicit none integer, intent(in) :: milliseconds integer, dimension(8) :: t integer :: ms1, ms2 ! Get start time: call date_and_time( values=t ) ms1 = ( t(5) * 3600 + t(6) *60 + t(7) ) * 1000+ t(8) do ! check time: call date_and_time(values=t) ms2 = ( t(5) * 3600 + t(6) * 60 + t(7) ) * 1000 + t(8) if ( ms2 - ms1 >= milliseconds ) exit enddo end subroutine millisleep end module utilities
/- Copyright (c) 2018 Simon Hudon. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Simon Hudon -/ import data.set.image import tactic.interactive open set variables {α β : Type} @[simp] lemma singleton_inter_singleton_eq_empty {x y : α} : ({x} ∩ {y} = (∅ : set α)) ↔ x ≠ y := by simp [singleton_inter_eq_empty] example {f : β → α} {x y : α} (h : x ≠ y) : f ⁻¹' {x} ∩ f ⁻¹' {y} = ∅ := begin have : {x} ∩ {y} = (∅ : set α) := by simpa using h, convert preimage_empty, rw [←preimage_inter,this], end example (P : Prop) (h : P) : P := by convert h
[GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 G✝ : SimpleGraph α H✝ : SimpleGraph β G : SimpleGraph α H : SimpleGraph β x y : α × β ⊢ (fun x y => Adj G x.fst y.fst ∧ x.snd = y.snd ∨ Adj H x.snd y.snd ∧ x.fst = y.fst) x y → (fun x y => Adj G x.fst y.fst ∧ x.snd = y.snd ∨ Adj H x.snd y.snd ∧ x.fst = y.fst) y x [PROOFSTEP] simp [and_comm, or_comm, eq_comm, adj_comm] [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 G✝ : SimpleGraph α H✝ : SimpleGraph β G : SimpleGraph α H : SimpleGraph β x : α × β ⊢ ¬(fun x y => Adj G x.fst y.fst ∧ x.snd = y.snd ∨ Adj H x.snd y.snd ∧ x.fst = y.fst) x x [PROOFSTEP] simp [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 G : SimpleGraph α H : SimpleGraph β a₁ : α b : β a₂ : α ⊢ Adj (G □ H) (a₁, b) (a₂, b) ↔ Adj G a₁ a₂ [PROOFSTEP] simp only [boxProd_adj, and_true, SimpleGraph.irrefl, false_and, or_false] [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 G : SimpleGraph α H : SimpleGraph β a : α b₁ b₂ : β ⊢ Adj (G □ H) (a, b₁) (a, b₂) ↔ Adj H b₁ b₂ [PROOFSTEP] simp only [boxProd_adj, SimpleGraph.irrefl, false_and, and_true, false_or] [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 G : SimpleGraph α H : SimpleGraph β x : α × β ⊢ neighborSet (G □ H) x = neighborSet G x.fst ×ˢ {x.snd} ∪ {x.fst} ×ˢ neighborSet H x.snd [PROOFSTEP] ext ⟨a', b'⟩ [GOAL] case h.mk α : Type u_1 β : Type u_2 γ : Type u_3 G : SimpleGraph α H : SimpleGraph β x : α × β a' : α b' : β ⊢ (a', b') ∈ neighborSet (G □ H) x ↔ (a', b') ∈ neighborSet G x.fst ×ˢ {x.snd} ∪ {x.fst} ×ˢ neighborSet H x.snd [PROOFSTEP] simp only [mem_neighborSet, Set.mem_union, boxProd_adj, Set.mem_prod, Set.mem_singleton_iff] [GOAL] case h.mk α : Type u_1 β : Type u_2 γ : Type u_3 G : SimpleGraph α H : SimpleGraph β x : α × β a' : α b' : β ⊢ Adj G x.fst a' ∧ x.snd = b' ∨ Adj H x.snd b' ∧ x.fst = a' ↔ Adj G x.fst a' ∧ b' = x.snd ∨ a' = x.fst ∧ Adj H x.snd b' [PROOFSTEP] simp only [eq_comm, and_comm] [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 G : SimpleGraph α H : SimpleGraph β I : SimpleGraph γ x y : (α × β) × γ ⊢ Adj (G □ (H □ I)) (↑(Equiv.prodAssoc α β γ) x) (↑(Equiv.prodAssoc α β γ) y) ↔ Adj (G □ H □ I) x y [PROOFSTEP] simp only [boxProd_adj, Equiv.prodAssoc_apply, or_and_right, or_assoc, Prod.ext_iff, and_assoc, @and_comm (x.fst.fst = _)] [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 G : SimpleGraph α H : SimpleGraph β b : β inst✝¹ : DecidableEq β inst✝ : DecidableRel G.Adj a₁ a₂ x z y : α h : Adj G x y w : Walk G y z ⊢ ofBoxProdLeft (Walk.boxProdLeft H b (cons' x y z h w)) = cons' x y z h w [PROOFSTEP] rw [Walk.boxProdLeft, map_cons, ofBoxProdLeft, Or.by_cases, dif_pos, ← Walk.boxProdLeft] [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 G : SimpleGraph α H : SimpleGraph β b : β inst✝¹ : DecidableEq β inst✝ : DecidableRel G.Adj a₁ a₂ x z y : α h : Adj G x y w : Walk G y z ⊢ cons (_ : Adj G (x, b).fst (↑(Embedding.toHom (boxProdLeft G H b)) y).fst) (ofBoxProdLeft (Walk.boxProdLeft H b w)) = cons' x y z h w case hc α : Type u_1 β : Type u_2 γ : Type u_3 G : SimpleGraph α H : SimpleGraph β b : β inst✝¹ : DecidableEq β inst✝ : DecidableRel G.Adj a₁ a₂ x z y : α h : Adj G x y w : Walk G y z ⊢ Adj G (x, b).fst (↑(Embedding.toHom (boxProdLeft G H b)) y).fst ∧ (x, b).snd = (↑(Embedding.toHom (boxProdLeft G H b)) y).snd case hc α : Type u_1 β : Type u_2 γ : Type u_3 G : SimpleGraph α H : SimpleGraph β b : β inst✝¹ : DecidableEq β inst✝ : DecidableRel G.Adj a₁ a₂ x z y : α h : Adj G x y w : Walk G y z ⊢ Adj G (x, b).fst (↑(Embedding.toHom (boxProdLeft G H b)) y).fst ∧ (x, b).snd = (↑(Embedding.toHom (boxProdLeft G H b)) y).snd [PROOFSTEP] simp [ofBoxProdLeft_boxProdLeft] [GOAL] case hc α : Type u_1 β : Type u_2 γ : Type u_3 G : SimpleGraph α H : SimpleGraph β b : β inst✝¹ : DecidableEq β inst✝ : DecidableRel G.Adj a₁ a₂ x z y : α h : Adj G x y w : Walk G y z ⊢ Adj G (x, b).fst (↑(Embedding.toHom (boxProdLeft G H b)) y).fst ∧ (x, b).snd = (↑(Embedding.toHom (boxProdLeft G H b)) y).snd case hc α : Type u_1 β : Type u_2 γ : Type u_3 G : SimpleGraph α H : SimpleGraph β b : β inst✝¹ : DecidableEq β inst✝ : DecidableRel G.Adj a₁ a₂ x z y : α h : Adj G x y w : Walk G y z ⊢ Adj G (x, b).fst (↑(Embedding.toHom (boxProdLeft G H b)) y).fst ∧ (x, b).snd = (↑(Embedding.toHom (boxProdLeft G H b)) y).snd [PROOFSTEP] exact ⟨h, rfl⟩ [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 G : SimpleGraph α H : SimpleGraph β a : α inst✝¹ : DecidableEq α inst✝ : DecidableRel G.Adj b₁ b₂ x z y : α h : Adj G x y w : Walk G y z ⊢ ofBoxProdRight (Walk.boxProdRight G a (cons' x y z h w)) = cons' x y z h w [PROOFSTEP] rw [Walk.boxProdRight, map_cons, ofBoxProdRight, Or.by_cases, dif_pos, ← Walk.boxProdRight] [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 G : SimpleGraph α H : SimpleGraph β a : α inst✝¹ : DecidableEq α inst✝ : DecidableRel G.Adj b₁ b₂ x z y : α h : Adj G x y w : Walk G y z ⊢ cons (_ : Adj G (a, x).snd (↑(Embedding.toHom (boxProdRight G G a)) y).snd) (ofBoxProdRight (Walk.boxProdRight G a w)) = cons' x y z h w case hc α : Type u_1 β : Type u_2 γ : Type u_3 G : SimpleGraph α H : SimpleGraph β a : α inst✝¹ : DecidableEq α inst✝ : DecidableRel G.Adj b₁ b₂ x z y : α h : Adj G x y w : Walk G y z ⊢ Adj G (a, x).snd (↑(Embedding.toHom (boxProdRight G G a)) y).snd ∧ (a, x).fst = (↑(Embedding.toHom (boxProdRight G G a)) y).fst case hc α : Type u_1 β : Type u_2 γ : Type u_3 G : SimpleGraph α H : SimpleGraph β a : α inst✝¹ : DecidableEq α inst✝ : DecidableRel G.Adj b₁ b₂ x z y : α h : Adj G x y w : Walk G y z ⊢ Adj G (a, x).snd (↑(Embedding.toHom (boxProdRight G G a)) y).snd ∧ (a, x).fst = (↑(Embedding.toHom (boxProdRight G G a)) y).fst [PROOFSTEP] simp [ofBoxProdLeft_boxProdRight] [GOAL] case hc α : Type u_1 β : Type u_2 γ : Type u_3 G : SimpleGraph α H : SimpleGraph β a : α inst✝¹ : DecidableEq α inst✝ : DecidableRel G.Adj b₁ b₂ x z y : α h : Adj G x y w : Walk G y z ⊢ Adj G (a, x).snd (↑(Embedding.toHom (boxProdRight G G a)) y).snd ∧ (a, x).fst = (↑(Embedding.toHom (boxProdRight G G a)) y).fst case hc α : Type u_1 β : Type u_2 γ : Type u_3 G : SimpleGraph α H : SimpleGraph β a : α inst✝¹ : DecidableEq α inst✝ : DecidableRel G.Adj b₁ b₂ x z y : α h : Adj G x y w : Walk G y z ⊢ Adj G (a, x).snd (↑(Embedding.toHom (boxProdRight G G a)) y).snd ∧ (a, x).fst = (↑(Embedding.toHom (boxProdRight G G a)) y).fst [PROOFSTEP] exact ⟨h, rfl⟩ [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 G : SimpleGraph α H : SimpleGraph β hG : Preconnected G hH : Preconnected H ⊢ Preconnected (G □ H) [PROOFSTEP] rintro x y [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 G : SimpleGraph α H : SimpleGraph β hG : Preconnected G hH : Preconnected H x y : α × β ⊢ Reachable (G □ H) x y [PROOFSTEP] obtain ⟨w₁⟩ := hG x.1 y.1 [GOAL] case intro α : Type u_1 β : Type u_2 γ : Type u_3 G : SimpleGraph α H : SimpleGraph β hG : Preconnected G hH : Preconnected H x y : α × β w₁ : Walk G x.fst y.fst ⊢ Reachable (G □ H) x y [PROOFSTEP] obtain ⟨w₂⟩ := hH x.2 y.2 [GOAL] case intro.intro α : Type u_1 β : Type u_2 γ : Type u_3 G : SimpleGraph α H : SimpleGraph β hG : Preconnected G hH : Preconnected H x y : α × β w₁ : Walk G x.fst y.fst w₂ : Walk H x.snd y.snd ⊢ Reachable (G □ H) x y [PROOFSTEP] rw [← @Prod.mk.eta _ _ x, ← @Prod.mk.eta _ _ y] [GOAL] case intro.intro α : Type u_1 β : Type u_2 γ : Type u_3 G : SimpleGraph α H : SimpleGraph β hG : Preconnected G hH : Preconnected H x y : α × β w₁ : Walk G x.fst y.fst w₂ : Walk H x.snd y.snd ⊢ Reachable (G □ H) (x.fst, x.snd) (y.fst, y.snd) [PROOFSTEP] exact ⟨(w₁.boxProdLeft _ _).append (w₂.boxProdRight _ _)⟩ [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 G : SimpleGraph α H : SimpleGraph β inst✝ : Nonempty β h : Preconnected (G □ H) ⊢ Preconnected G [PROOFSTEP] classical rintro a₁ a₂ obtain ⟨w⟩ := h (a₁, Classical.arbitrary _) (a₂, Classical.arbitrary _) exact ⟨w.ofBoxProdLeft⟩ [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 G : SimpleGraph α H : SimpleGraph β inst✝ : Nonempty β h : Preconnected (G □ H) ⊢ Preconnected G [PROOFSTEP] rintro a₁ a₂ [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 G : SimpleGraph α H : SimpleGraph β inst✝ : Nonempty β h : Preconnected (G □ H) a₁ a₂ : α ⊢ Reachable G a₁ a₂ [PROOFSTEP] obtain ⟨w⟩ := h (a₁, Classical.arbitrary _) (a₂, Classical.arbitrary _) [GOAL] case intro α : Type u_1 β : Type u_2 γ : Type u_3 G : SimpleGraph α H : SimpleGraph β inst✝ : Nonempty β h : Preconnected (G □ H) a₁ a₂ : α w : Walk (G □ H) (a₁, Classical.arbitrary β) (a₂, Classical.arbitrary β) ⊢ Reachable G a₁ a₂ [PROOFSTEP] exact ⟨w.ofBoxProdLeft⟩ [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 G : SimpleGraph α H : SimpleGraph β inst✝ : Nonempty α h : Preconnected (G □ H) ⊢ Preconnected H [PROOFSTEP] classical rintro b₁ b₂ obtain ⟨w⟩ := h (Classical.arbitrary _, b₁) (Classical.arbitrary _, b₂) exact ⟨w.ofBoxProdRight⟩ [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 G : SimpleGraph α H : SimpleGraph β inst✝ : Nonempty α h : Preconnected (G □ H) ⊢ Preconnected H [PROOFSTEP] rintro b₁ b₂ [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 G : SimpleGraph α H : SimpleGraph β inst✝ : Nonempty α h : Preconnected (G □ H) b₁ b₂ : β ⊢ Reachable H b₁ b₂ [PROOFSTEP] obtain ⟨w⟩ := h (Classical.arbitrary _, b₁) (Classical.arbitrary _, b₂) [GOAL] case intro α : Type u_1 β : Type u_2 γ : Type u_3 G : SimpleGraph α H : SimpleGraph β inst✝ : Nonempty α h : Preconnected (G □ H) b₁ b₂ : β w : Walk (G □ H) (Classical.arbitrary α, b₁) (Classical.arbitrary α, b₂) ⊢ Reachable H b₁ b₂ [PROOFSTEP] exact ⟨w.ofBoxProdRight⟩ [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 G : SimpleGraph α H : SimpleGraph β hG : Connected G hH : Connected H ⊢ Connected (G □ H) [PROOFSTEP] haveI := hG.nonempty [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 G : SimpleGraph α H : SimpleGraph β hG : Connected G hH : Connected H this : Nonempty α ⊢ Connected (G □ H) [PROOFSTEP] haveI := hH.nonempty [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 G : SimpleGraph α H : SimpleGraph β hG : Connected G hH : Connected H this✝ : Nonempty α this : Nonempty β ⊢ Connected (G □ H) [PROOFSTEP] exact ⟨hG.preconnected.boxProd hH.preconnected⟩ [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 G : SimpleGraph α H : SimpleGraph β h : Connected (G □ H) ⊢ Connected G [PROOFSTEP] haveI := (nonempty_prod.1 h.nonempty).1 [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 G : SimpleGraph α H : SimpleGraph β h : Connected (G □ H) this : Nonempty α ⊢ Connected G [PROOFSTEP] haveI := (nonempty_prod.1 h.nonempty).2 [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 G : SimpleGraph α H : SimpleGraph β h : Connected (G □ H) this✝ : Nonempty α this : Nonempty β ⊢ Connected G [PROOFSTEP] exact ⟨h.preconnected.ofBoxProdLeft⟩ [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 G : SimpleGraph α H : SimpleGraph β h : Connected (G □ H) ⊢ Connected H [PROOFSTEP] haveI := (nonempty_prod.1 h.nonempty).1 [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 G : SimpleGraph α H : SimpleGraph β h : Connected (G □ H) this : Nonempty α ⊢ Connected H [PROOFSTEP] haveI := (nonempty_prod.1 h.nonempty).2 [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 G : SimpleGraph α H : SimpleGraph β h : Connected (G □ H) this✝ : Nonempty α this : Nonempty β ⊢ Connected H [PROOFSTEP] exact ⟨h.preconnected.ofBoxProdRight⟩ [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 G : SimpleGraph α H : SimpleGraph β x : α × β inst✝¹ : Fintype ↑(neighborSet G x.fst) inst✝ : Fintype ↑(neighborSet H x.snd) y : α × β ⊢ y ∈ Finset.disjUnion (neighborFinset G x.fst ×ˢ {x.snd}) ({x.fst} ×ˢ neighborFinset H x.snd) (_ : Disjoint (neighborFinset G x.fst ×ˢ {x.snd}) ({x.fst} ×ˢ neighborFinset H x.snd)) ↔ ↑(Equiv.refl (α × β)) y ∈ neighborSet (G □ H) x [PROOFSTEP] simp_rw [Finset.mem_disjUnion, Finset.mem_product, Finset.mem_singleton, mem_neighborFinset, mem_neighborSet, Equiv.refl_apply, boxProd_adj] [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 G : SimpleGraph α H : SimpleGraph β x : α × β inst✝¹ : Fintype ↑(neighborSet G x.fst) inst✝ : Fintype ↑(neighborSet H x.snd) y : α × β ⊢ Adj G x.fst y.fst ∧ y.snd = x.snd ∨ y.fst = x.fst ∧ Adj H x.snd y.snd ↔ Adj G x.fst y.fst ∧ x.snd = y.snd ∨ Adj H x.snd y.snd ∧ x.fst = y.fst [PROOFSTEP] simp only [eq_comm, and_comm] [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 G : SimpleGraph α H : SimpleGraph β x : α × β inst✝² : Fintype ↑(neighborSet G x.fst) inst✝¹ : Fintype ↑(neighborSet H x.snd) inst✝ : Fintype ↑(neighborSet (G □ H) x) ⊢ neighborFinset (G □ H) x = Finset.disjUnion (neighborFinset G x.fst ×ˢ {x.snd}) ({x.fst} ×ˢ neighborFinset H x.snd) (_ : Disjoint (neighborFinset G x.fst ×ˢ {x.snd}) ({x.fst} ×ˢ neighborFinset H x.snd)) [PROOFSTEP] letI : Fintype ((G □ H).neighborSet x) := SimpleGraph.boxProdFintypeNeighborSet _ [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 G : SimpleGraph α H : SimpleGraph β x : α × β inst✝² : Fintype ↑(neighborSet G x.fst) inst✝¹ : Fintype ↑(neighborSet H x.snd) inst✝ : Fintype ↑(neighborSet (G □ H) x) this : Fintype ↑(neighborSet (G □ H) x) := boxProdFintypeNeighborSet x ⊢ neighborFinset (G □ H) x = Finset.disjUnion (neighborFinset G x.fst ×ˢ {x.snd}) ({x.fst} ×ˢ neighborFinset H x.snd) (_ : Disjoint (neighborFinset G x.fst ×ˢ {x.snd}) ({x.fst} ×ˢ neighborFinset H x.snd)) [PROOFSTEP] convert_to (G □ H).neighborFinset x = _ using 2 [GOAL] case convert_2 α : Type u_1 β : Type u_2 γ : Type u_3 G : SimpleGraph α H : SimpleGraph β x : α × β inst✝² : Fintype ↑(neighborSet G x.fst) inst✝¹ : Fintype ↑(neighborSet H x.snd) inst✝ : Fintype ↑(neighborSet (G □ H) x) this : Fintype ↑(neighborSet (G □ H) x) := boxProdFintypeNeighborSet x ⊢ neighborFinset (G □ H) x = Finset.disjUnion (neighborFinset G x.fst ×ˢ {x.snd}) ({x.fst} ×ˢ neighborFinset H x.snd) (_ : Disjoint (neighborFinset G x.fst ×ˢ {x.snd}) ({x.fst} ×ˢ neighborFinset H x.snd)) [PROOFSTEP] exact Eq.trans (Finset.map_map _ _ _) Finset.attach_map_val [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 G : SimpleGraph α H : SimpleGraph β x : α × β inst✝² : Fintype ↑(neighborSet G x.fst) inst✝¹ : Fintype ↑(neighborSet H x.snd) inst✝ : Fintype ↑(neighborSet (G □ H) x) ⊢ degree (G □ H) x = degree G x.fst + degree H x.snd [PROOFSTEP] rw [degree, degree, degree, boxProd_neighborFinset, Finset.card_disjUnion] [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 G : SimpleGraph α H : SimpleGraph β x : α × β inst✝² : Fintype ↑(neighborSet G x.fst) inst✝¹ : Fintype ↑(neighborSet H x.snd) inst✝ : Fintype ↑(neighborSet (G □ H) x) ⊢ Finset.card (neighborFinset G x.fst ×ˢ {x.snd}) + Finset.card ({x.fst} ×ˢ neighborFinset H x.snd) = Finset.card (neighborFinset G x.fst) + Finset.card (neighborFinset H x.snd) [PROOFSTEP] simp_rw [Finset.card_product, Finset.card_singleton, mul_one, one_mul]
def f (m n : ℕ) : ℕ := m + n + m example {m n : ℕ} (h : n = 1) (h' : 0 = m) : (f m n) = n := by simp [h, h'.symm, f]
function fun(a,*) fun = 0 end
theory Ex002 imports Main begin lemma "A \<Longrightarrow> B \<Longrightarrow> A" by assumption lemma "A \<Longrightarrow> B \<Longrightarrow> A" proof - assume A then show A by assumption (*then = from this*) qed lemma "A \<longrightarrow> B \<longrightarrow> A" proof - { assume A { assume B from \<open>A\<close> have A by assumption (*the brackets \<open> (\open) \<close> (\close) make it possible to reference a fact without giving it a name prior*) } hence "B \<longrightarrow> A" by (rule impI) (*hence = from this have*) } thus ?thesis .. qed (*thus = from this show*)(*?thesis refers to the lemma we want to proof*)(*the two dots mean "by rule", Isabelle often pics the right rule*)
using ADCME using PyCall using LinearAlgebra using PyPlot using Random using DelimitedFiles using SparseArrays Random.seed!(233) mpi_init() sp = sprand(10,10,0.3) SP = mpi_SparseTensor(sp) SPt = SP' sess = Session(); init(sess) Array(run(sess, SP))-Array(run(sess, SPt))'
setVtPars <- function(par, spect, fsc) { pks <- peaks(spect) pks$x <- fsc * pks$x fidx <- c(7,10,13,16,19,22,25,28) aidx <- fidx + 2 for (i in 1:length(pks$x)) { par[fidx[i]] <- pks$x[i] par[aidx[i]] <- pks$y[i] } par }
module Package.IpkgAst import public Lightyear import public Lightyear.Char import public Lightyear.Strings %default total %access public export ipkgPackage : String->String ipkgPackage x = "package " ++x {- <|> clause "main" (iName []) (\st v -> st { idris_main = Just v }) <|> clause "sourcedir" identifier (\st v -> st { sourcedir = v }) <|> clause "opts" pOptions (\st v -> st { idris_opts = v ++ idris_opts st }) <|> clause "pkgs" (commaSep (pPkgName <* someSpace)) (\st ps -> <|> clause "modules" (commaSep moduleName) (\st v -> st { modules = modules st ++ v }) <|> clause "libs" (commaSep identifier) (\st v -> st { libdeps = libdeps st ++ v }) <|> clause "objs" (commaSep identifier) (\st v -> st { objs = objs st ++ v }) <|> clause "makefile" (iName []) (\st v -> st { makefile = Just (show v) }) <|> clause "tests" (commaSep (iName [])) (\st v -> st { idris_tests = idris_tests st ++ v }) <|> clause "version" textUntilEol (\st v -> st { pkgversion = Just v }) <|> clause "readme" textUntilEol (\st v -> st { pkgreadme = Just v }) <|> clause "license" textUntilEol (\st v -> st { pkglicense = Just v }) <|> clause "homepage" textUntilEol (\st v -> st { pkghomepage = Just v }) <|> clause "sourceloc" textUntilEol (\st v -> st { pkgsourceloc = Just v }) <|> clause "bugtracker" textUntilEol (\st v -> st { pkgbugtracker = Just v }) <|> clause "brief" stringLiteral (\st v -> st { pkgbrief = Just v }) <|> clause "author" textUntilEol (\st v -> st { pkgauthor = Just v }) <|> clause "maintainer" textUntilEol (\st v -> st { pkgmaintainer = Just v })-} data Clause = Imain String | Isourcedir String | Ipkgs (List String) | Iopts String | Ideps (List String) -- | Ipkgs (List String) IpkgAst : Type IpkgAst = List Clause Clause2cmdStr : Clause -> String Clause2cmdStr x = "main" partial pNames : Parser String pNames = (many $ noneOf "," )>>= pure . pack partial pClause : String -> Parser Clause pClause x@"main" = do string x pure $ Imain x pClause x@"pkgs" = do string x spaces string "=" l<-pNames `sepBy` (string ",") pure $ Ipkgs l pClause x = pure $ Imain ""
// // file BasePPhoreSite.cc // David Cosgrove // AstraZeneca // 10th October 2006 // // Implementation of BasePPhoreSite. #include <algorithm> #include <numeric> #include <boost/bind.hpp> #include "stddefs.H" #include "BasePPhoreSite.H" #include "SinglePPhoreSite.H" // bad karma! #include "OverlayTrans.H" namespace DACLIB { void rotate_about_axis( const double axis[3] , const double angle , double vec[3] ); double angle_about_axis( const double axis[3] , const double vec1[3] , const double vec2[3] ); float torsion( const float *cds1 , const float *cds2 , const float *cds3 , const float *cds4 , bool degs ); } using namespace std; // ******************************************************************************* BasePPhoreSite::BasePPhoreSite() { reset_data(); } // ******************************************************************************* // tc and ts are the type code and type string respectively. BasePPhoreSite::BasePPhoreSite( const double cds[3] , const double dir[3] , int tc , const string &ts , const string &lbl , bool use_dir ) { label_ = lbl; num_dirs_ = use_dir ? 1 : 0; selected_ = false; type_code_ = tc; type_string_ = ts; cds_[0] = cds[0]; cds_[1] = cds[1]; cds_[2] = cds[2]; if( use_dir ) { dir_[0] = dir[0]; dir_[1] = dir[1]; dir_[2] = dir[2]; } else { dir_[0] = dir_[1] = dir_[2] = 0.0; } dir_moves_ = GtplDefs::NONE; num_virt_sites_ = 0; active_virt_site_ = -1; } // ******************************************************************************* BasePPhoreSite::~BasePPhoreSite() { } // **************************************************************************** void BasePPhoreSite::reset_data() { label_ = ""; num_dirs_ = 0; selected_ = false; type_code_ = -1; type_string_ = ""; cds_[0] = cds_[1] = cds_[2] = 0.0; dir_[0] = dir_[1] = dir_[2] = 0.0; dir_moves_ = GtplDefs::NONE; num_virt_sites_ = 0; active_virt_site_ = -1; } // **************************************************************************** void BasePPhoreSite::copy_data( const BasePPhoreSite &c ) { label_ = c.label_; type_code_ = c.type_code_; type_string_ = c.type_string_; cds_[0] = c.cds_[0]; cds_[1] = c.cds_[1]; cds_[2] = c.cds_[2]; num_dirs_ = c.num_dirs_; if( c.num_dirs_ ) { copy( c.dir_ , c.dir_ + num_dirs_ * 3 , dir_ ); copy( c.dir_types_ , c.dir_types_ + num_dirs_ , dir_types_ ); } selected_ = c.selected_; dir_moves_ = c.dir_moves_; twiddle_axis_[0] = c.twiddle_axis_[0]; twiddle_axis_[1] = c.twiddle_axis_[1]; twiddle_axis_[2] = c.twiddle_axis_[2]; num_virt_sites_ = c.num_virt_sites_; copy( c.virt_sites_ , c.virt_sites_ + 3 * num_virt_sites_ , virt_sites_ ); active_virt_site_ = c.active_virt_site_; } // **************************************************************************** void BasePPhoreSite::set_coords( const double *new_cds ) { cds_[0] = new_cds[0]; cds_[1] = new_cds[1]; cds_[2] = new_cds[2]; } // **************************************************************************** void BasePPhoreSite::set_coords( const float *new_cds ) { cds_[0] = new_cds[0]; cds_[1] = new_cds[1]; cds_[2] = new_cds[2]; } // **************************************************************************** int BasePPhoreSite::get_num_dirs( GtplDefs::DIRS_TYPE dirs_type ) const { int ret_num = 0; for( int i = 0 ; i < num_dirs_ ; ++i ) if( dirs_type == dir_types_[i] ) ++ret_num; return ret_num; } // **************************************************************************** const double *BasePPhoreSite::direction( int dir_num ) const { if( dir_num < 0 || dir_num >= num_dirs_ ) return 0; else return dir_ + 3 * dir_num; } // **************************************************************************** GtplDefs::DIRS_TYPE BasePPhoreSite::direction_type( int dir_num ) const { if( dir_num < 0 || dir_num >= num_dirs_ ) return GtplDefs::UNKNOWN; else return dir_types_[dir_num]; } // **************************************************************************** void BasePPhoreSite::set_direction( const double *new_dir , GtplDefs::DIRS_TYPE t , int dir_num ) { if( -1 == dir_num && num_dirs_ < 3 ) { dir_[3 * num_dirs_] = new_dir[0]; dir_[3 * num_dirs_ + 1] = new_dir[1]; dir_[3 * num_dirs_ + 2] = new_dir[2]; dir_types_[num_dirs_] = t; ++num_dirs_; } if( -1 != dir_num && dir_num < 3 ) { dir_[3 * dir_num] = new_dir[0]; dir_[3 * dir_num + 1] = new_dir[1]; dir_[3 * dir_num + 2] = new_dir[2]; dir_types_[dir_num] = t; } } // **************************************************************************** void BasePPhoreSite::set_direction( const float *new_dir , GtplDefs::DIRS_TYPE t , int dir_num ) { if( -1 == dir_num && num_dirs_ < 3 ) { dir_[3 * num_dirs_] = new_dir[0]; dir_[3 * num_dirs_ + 1] = new_dir[1]; dir_[3 * num_dirs_ + 2] = new_dir[2]; dir_types_[num_dirs_] = t; ++num_dirs_; } if( -1 != dir_num && dir_num < 3 ) { dir_[3 * dir_num] = new_dir[0]; dir_[3 * dir_num + 1] = new_dir[1]; dir_[3 * dir_num + 2] = new_dir[2]; dir_types_[dir_num] = t; } } // **************************************************************************** float BasePPhoreSite::square_distance( const double *cds ) const { return ( DACLIB::square( cds[0] - cds_[0] ) + DACLIB::square( cds[1] - cds_[1] ) + DACLIB::square( cds[2] - cds_[2] ) ); } // **************************************************************************** void BasePPhoreSite::translate( float x_trans , float y_trans , float z_trans ) { cds_[0] += x_trans; cds_[1] += y_trans; cds_[2] += z_trans; } // **************************************************************************** void BasePPhoreSite::rotate( const float rot[3][3] ) { float cds[3]; cds[0] = rot[0][0] * cds_[0] + rot[0][1] * cds_[1] + rot[0][2] * cds_[2]; cds[1] = rot[1][0] * cds_[0] + rot[1][1] * cds_[1] + rot[1][2] * cds_[2]; cds[2] = rot[2][0] * cds_[0] + rot[2][1] * cds_[1] + rot[2][2] * cds_[2]; cds_[0] = cds[0]; cds_[1] = cds[1]; cds_[2] = cds[2]; cds[0] = rot[0][0] * twiddle_axis_[0] + rot[0][1] * twiddle_axis_[1] + rot[0][2] * twiddle_axis_[2]; cds[1] = rot[1][0] * twiddle_axis_[0] + rot[1][1] * twiddle_axis_[1] + rot[1][2] * twiddle_axis_[2]; cds[2] = rot[2][0] * twiddle_axis_[0] + rot[2][1] * twiddle_axis_[1] + rot[2][2] * twiddle_axis_[2]; twiddle_axis_[0] = cds[0]; twiddle_axis_[1] = cds[1]; twiddle_axis_[2] = cds[2]; for( int i = 0 ; i < num_dirs_ ; ++i ) { cds[0] = rot[0][0] * dir_[3*i] + rot[0][1] * dir_[3*i+1] + rot[0][2] * dir_[3*i+2]; cds[1] = rot[1][0] * dir_[3*i] + rot[1][1] * dir_[3*i+1] + rot[1][2] * dir_[3*i+2]; cds[2] = rot[2][0] * dir_[3*i] + rot[2][1] * dir_[3*i+1] + rot[2][2] * dir_[3*i+2]; dir_[3*i] = cds[0]; dir_[3*i+1] = cds[1]; dir_[3*i+2] = cds[2]; } for( int i = 0 ; i < num_virt_sites_ ; ++i ) { cds[0] = rot[0][0] * virt_sites_[3*i] + rot[0][1] * virt_sites_[3*i+1] + rot[0][2] * virt_sites_[3*i+2]; cds[1] = rot[1][0] * virt_sites_[3*i] + rot[1][1] * virt_sites_[3*i+1] + rot[1][2] * virt_sites_[3*i+2]; cds[2] = rot[2][0] * virt_sites_[3*i] + rot[2][1] * virt_sites_[3*i+1] + rot[2][2] * virt_sites_[3*i+2]; virt_sites_[3*i] = cds[0]; virt_sites_[3*i+1] = cds[1]; virt_sites_[3*i+2] = cds[2]; } } // **************************************************************************** // find the order of directions in site that has the most of the given // type lined up with directions in this. Dir_order maps dirs_ vectors in // site onto dirs_ vectors in this. Returns the sum of the dot-products for // the order found. float BasePPhoreSite::best_dir_alignments( BasePPhoreSite &site , GtplDefs::DIRS_TYPE dirs_type , bool twiddle_if_poss , vector<int> &dir_order ) { // needs to be done with num_dirs_ >= site.num_dirs_ if( site.num_dirs_ > num_dirs_ ) { return site.best_dir_alignments( *this , dirs_type , twiddle_if_poss , dir_order ); } vector<int> combs; for( int i = 0 ; i < site.num_dirs_ ; ++i ) { combs.push_back( i ); } float best_dot = -1.0; dir_order = combs; do { #ifdef NOTYET cout << "Next comb : "; copy( combs.begin() , combs.end() , ostream_iterator<int>( cout , " " ) ); cout << " :: " << dirs_type << endl; #endif // line up on the first direction if appropriate if( twiddle_if_poss && site.get_twiddlable() ) { site.twiddle( dir_ , combs[0] ); } float cum_dot = 0.0F; for( int i = 0 ; i < site.num_dirs_ ; ++i ) { if( dir_types_[i] == dirs_type ) cum_dot = DACLIB::dot_product( dir_ + 3 * i , site.dir_ + 3 * combs[i] ); } if( cum_dot > best_dot ) { best_dot = cum_dot; dir_order = combs; } } while ( next_permutation( combs.begin() , combs.end() ) ); return best_dot; } // **************************************************************************** // put the direction vectors into the new order. void BasePPhoreSite::reorder_dirs( const vector<int> &new_order ) { double dirs2[9]; GtplDefs::DIRS_TYPE dt[3]; #ifdef NOTYET cout << "new orders : " << new_order.size() << " :: "; copy( new_order.begin() , new_order.end() , intOut ); cout << endl; cout << "num_dirs : " << num_dirs_ << " : " << get_num_dirs() << endl; #endif for( int i = 0 ; i < std::min( num_dirs_ , int( new_order.size() ) ) ; ++i ) { dirs2[3 * i] = dir_[3 * new_order[i]]; dirs2[3 * i + 1] = dir_[3 * new_order[i] + 1]; dirs2[3 * i + 2] = dir_[3 * new_order[i] + 2]; dt[i] = dir_types_[new_order[i]]; } for( int i = 0 ; i < get_num_dirs() ; ++i ) { dir_[3 * i] = dirs2[3 * i]; dir_[3 * i + 1] = dirs2[3 * i + 1]; dir_[3 * i + 2] = dirs2[3 * i + 2]; dir_types_[i] = dt[i]; } } // **************************************************************************** // twiddle the given direction to point along the given vector dir // if it's twiddlable leaving it unchanged if it isn't void BasePPhoreSite::twiddle( const double *dir , int dir_num ) { if( dir_moves_ != GtplDefs::FREE || dir_num < 0 || dir_num >= num_dirs_ ) { return; } double in_dir[3] = { dir[0] , dir[1] , dir[2] }; double this_dir[3] = { dir_[3 * dir_num] , dir_[3 * dir_num + 1] , dir_[3 * dir_num + 2] }; double angle = DACLIB::angle_about_axis( twiddle_axis_ , in_dir , this_dir ); DACLIB::rotate_about_axis( twiddle_axis_ , -angle , this_dir ); double angle_to_use = -angle; // sometimes the angle comes back with the wrong sign, for reasons which // I don't understand and haven't delved into deeply. If it's right, the // rotation will put the vectors with essentially a zero angle. If not, try // it the other way. double new_angle = DACLIB::angle_about_axis( twiddle_axis_ , in_dir , this_dir ); if( new_angle > 1.0e-6 ) { double othis_dir[3] = { dir_[3 * dir_num] , dir_[3 * dir_num + 1] , dir_[3 * dir_num + 2] }; DACLIB::rotate_about_axis( twiddle_axis_ , angle , this_dir ); double rnew_angle = DACLIB::angle_about_axis( twiddle_axis_ , in_dir , othis_dir ); if( rnew_angle < new_angle ) { angle_to_use = angle; } } for( int i = 0 ; i < num_dirs_ ; ++i ) { DACLIB::rotate_about_axis( twiddle_axis_ , angle_to_use , dir_ + 3 * i ); } } // **************************************************************************** // this one aligns all directions of given type as best as possible, and // rearranges the directions to match those in site. void BasePPhoreSite::twiddle( BasePPhoreSite &site , GtplDefs::DIRS_TYPE dirs ) { if( dir_moves_ != GtplDefs::FREE || !num_dirs_ || !site.num_dirs_ ) { return; } // needs to be done with num_dirs_ >= site.num_dirs_ if( site.num_dirs_ > num_dirs_ ) { site.twiddle( *this , dirs ); return; } vector<int> best_comb; best_dir_alignments( site , dirs , true , best_comb ); // make best_comb the directions site.twiddle( dir_ , best_comb[0] ); site.reorder_dirs( best_comb ); } // **************************************************************************** // flip directions by 180 void BasePPhoreSite::flip() { if( dir_moves_ != GtplDefs::FLIP ) return; for( int i = 0 ; i < num_dirs_ ; ++i ) DACLIB::rotate_about_axis( twiddle_axis_ , M_PI , dir_ + 3 * i ); } // **************************************************************************** // flip directions by 180 if the alignments between dirs_ of type dirs // gives a better score that way. void BasePPhoreSite::flip( BasePPhoreSite &site , GtplDefs::DIRS_TYPE dirs ) { if( dir_moves_ != GtplDefs::FLIP ) return; vector<int> score1_comb; float score1 = best_dir_alignments( site , dirs , false , score1_comb ); flip(); vector<int> score2_comb; float score2 = best_dir_alignments( site , dirs , false , score2_comb ); if( score1 > score2 ) { // put it back again site.reorder_dirs( score1_comb ); flip(); } else { site.reorder_dirs( score2_comb ); } } // **************************************************************************** void BasePPhoreSite::set_virt_sites( const double *vs, int num_vs ) { num_virt_sites_ = num_vs; copy( vs , vs + 3 * num_vs , virt_sites_ ); } // **************************************************************************** void BasePPhoreSite::write_to_stream( ostream &os ) const { os << label_ << endl << type_code_ << endl << type_string_ << endl << cds_[0] << " " << cds_[1] << " " << cds_[2] << endl << num_dirs_ << endl; for( int i = 0 ; i < num_dirs_ ; ++i ) os << dir_[3*i] << " " << dir_[3*i+1] << " " << dir_[3*i+2] << " " << dir_types_[i] << endl; os << dir_moves_ << endl; if( dir_moves_ != GtplDefs::NONE ) os << twiddle_axis_[0] << " " << twiddle_axis_[1] << " " << twiddle_axis_[2] << endl; } // **************************************************************************** void BasePPhoreSite::read_from_stream( istream &is ) { is >> label_ >> type_code_ >> type_string_ >> cds_[0] >> cds_[1] >> cds_[2] >> num_dirs_; for( int i = 0 ; i < num_dirs_ ; ++i ) { is >> dir_[3*i] >> dir_[3*i+1] >> dir_[3*i+2]; int j; is >> j; dir_types_[i] = (GtplDefs::DIRS_TYPE) j; } int i; is >> i; dir_moves_ = (GtplDefs::DIR_MOVES) i; if( dir_moves_ != GtplDefs::NONE ) is >> twiddle_axis_[0] >> twiddle_axis_[1] >> twiddle_axis_[2]; } // **************************************************************************** void BasePPhoreSite::brief_report( ostream &os ) const { os << "Site " << get_full_name() << " :: "; os << "(" << cds_[0] << " , " << cds_[1] << " , " << cds_[2] << ")"; for( int j = 0 , js = num_dirs_ ; j < js ; ++j ) { os << " (" << dir_[3 * j + 0] << " , " << dir_[3 * j + 1] << " , " << dir_[3 * j + 2] << ")"; } os << endl; } // **************************************************************************** void brief_report_sites( ostream &os , const vector<BasePPhoreSite *> &sites ) { for( unsigned int i = 0 ; i < sites.size() ; i++ ) { sites[i]->brief_report( os ); } } // **************************************************************************** // calculate the overlay transformation to move the given pairs of the second // vector of PPhoreSites onto the first, returning the RMS of the overlay, but // not moving the sites. float calc_overlay_trans( const vector<BasePPhoreSite *> &sites1 , const vector<BasePPhoreSite *> &sites2 , const vector<int> &pairs , OverlayTrans &overlay_trans , bool use_ring_norm_dirs , bool use_h_vec_dirs , bool use_lp_dirs ) { vector<float> cds1 , cds2; for( unsigned int i = 0 , is = pairs.size() ; i < is ; i += 2 ) { const double *sds1 = sites1[pairs[i]]->coords(); const double *sds2 = sites2[pairs[i+1]]->coords(); cds1.insert( cds1.end() , sds1 , sds1 + 3 ); cds2.insert( cds2.end() , sds2 , sds2 + 3 ); } if( use_ring_norm_dirs ) { add_ring_norm_dir_sites( sites1 , sites2 , pairs , cds1 , cds2 ); } if( use_h_vec_dirs ) { add_dir_sites( GtplDefs::H_VECTOR , sites1 , sites2 , pairs , cds1 , cds2 ); } if( use_lp_dirs ) { add_dir_sites( GtplDefs::LP_VECTOR , sites1 , sites2 , pairs , cds1 , cds2 ); } vector<float> cds1_cp( cds1 ) , cds2_cp( cds2 ); // OverlayTrans c'tor moves first coords onto 2nd. It centres the coords, so // changes the originals, hence the need for cds1_cp and cds2_cp. int num_cds = cds2.size() / 3; overlay_trans = OverlayTrans( &cds2[0] , &cds1[0] , num_cds ); // do the overlay so we can calculate the RMS. overlay_trans.overlay( num_cds , &cds2_cp[0] ); // don't want to calculate RMS on the extension points as well int num_sites = pairs.size() / 2; float rms = inner_product( cds1_cp.begin() , cds1_cp.begin() + 3 * num_sites , cds2_cp.begin() , 0.0F , plus<float>() , boost::bind( multiplies<float>() , boost::bind( minus<float>() , _1 , _2 ) , boost::bind( minus<float>() , _1 , _2 ) ) ); rms = sqrt( rms / float( num_cds ) ); return rms; } // ************************************************************************** void add_ring_norm_dir_sites( const vector<BasePPhoreSite *> &sites1 , const vector<BasePPhoreSite *> &sites2 , const vector<int> &pairs , vector<float> &cds1 , vector<float> &cds2 ) { float pcds1[3] , pcds2[3]; for( int i = 0 , is = pairs.size() ; i < is ; i += 2 ) { BasePPhoreSite *site1 = sites1[pairs[i]]; BasePPhoreSite *site2 = sites2[pairs[i+1]]; if( site1->get_num_dirs() && site2->get_num_dirs() ) { // find the end of the normal for each site const double *dir1 = 0 , *dir2 = 0; int site1_dir_num = -1; for( int j = 0 ; j < 3 ; ++j ) { if( GtplDefs::RING_NORMAL == site1->direction_type( j ) ) { dir1 = site1->direction( j ); site1_dir_num = j; break; } } if( !dir1 ) continue; int site2_dir_num = -1; for( int j = 0 ; j < 3 ; ++j ) { if( GtplDefs::RING_NORMAL == site2->direction_type( j ) ) { dir2 = site2->direction( j ); site2_dir_num = j; break; } } if( !dir2 ) continue; double cdir2[3] = { dir2[0] , dir2[1] , dir2[2] }; const double *sds1 = site1->coords(); const double *sds2 = site2->coords(); pcds1[0] = sds1[0] + dir1[0]; pcds1[1] = sds1[1] + dir1[1]; pcds1[2] = sds1[2] + dir1[2]; // depending on arbitrary factors, ring normals might be pointing in opposite // directions. This is why this only works on overlaid sites (not that // we're checking this anywhere). if( DACLIB::dot_product( site1->direction( site1_dir_num ) , site2->direction( site2_dir_num ) ) <= 0.0 ) { cdir2[0] *= -1.0; cdir2[1] *= -1.0; cdir2[2] *= -1.0; site2->set_direction( cdir2 , site1->direction_type( site1_dir_num ) , site2_dir_num ); } pcds2[0] = sds2[0] + cdir2[0]; pcds2[1] = sds2[1] + cdir2[1]; pcds2[2] = sds2[2] + cdir2[2]; cds1.insert( cds1.end() , pcds1 , pcds1 + 3 ); cds2.insert( cds2.end() , pcds2 , pcds2 + 3 ); } } } // ************************************************************************** // return the directions of the given type void get_site_dirs( GtplDefs::DIRS_TYPE dt , BasePPhoreSite &site , double dirs[9] , int &num_dirs ) { num_dirs = 0; for( int i = 0 , is = site.get_num_dirs() ; i < is ; ++i ) { if( dt == site.direction_type( i ) ) { dirs[num_dirs++] = site.direction( i )[0]; dirs[num_dirs++] = site.direction( i )[1]; dirs[num_dirs++] = site.direction( i )[2]; } } num_dirs /= 3; } // ************************************************************************** void add_site_coords( const double *cds , const double *dir , vector<float> &site_cds ) { site_cds.push_back( cds[0] + dir[0] ); site_cds.push_back( cds[1] + dir[1] ); site_cds.push_back( cds[2] + dir[2] ); } // ************************************************************************** // by convention, sites1 is fixed, sites2 is moving void add_dir_sites( GtplDefs::DIRS_TYPE dirs_type , const vector<BasePPhoreSite *> &sites1 , const vector<BasePPhoreSite *> &sites2 , const vector<int> &pairs , vector<float> &cds1 , vector<float> &cds2 ) { // this is all a bit complicated, as there may be more than one vector per site // and the site itself may be twiddlable or flippable double site1_dirs[9] , site2_dirs[9]; int nsd1 , nsd2; for( int i = 0 , is = pairs.size() ; i < is ; i += 2 ) { BasePPhoreSite *site1 , *site2; BasePPhoreSite *in_site1 = sites1[pairs[i]] , *in_site2 = sites2[pairs[i+1]]; bool made_site1( false ) , made_site2( false ); if( in_site1->get_twiddlable() || in_site1->get_flippable() ) { site1 = new SinglePPhoreSite; site1->set_flippable( in_site1->get_flippable() ); site1->set_twiddlable( in_site1->get_twiddlable() ); for( int j = 0 , js = in_site1->get_num_dirs() ; j < js ; ++j ) { site1->set_direction( in_site1->direction( j ) , in_site1->direction_type( j ) , -1 ); // -1 makes a new direction } site1->set_coords( in_site1->coords() ); site1->set_twiddle_axis( in_site1->twiddle_axis() ); made_site1 = true; } else { site1 = in_site1; } if( in_site2->get_twiddlable() || in_site2->get_flippable() ) { site2 = new SinglePPhoreSite; site2->set_flippable( in_site2->get_flippable() ); site2->set_twiddlable( in_site2->get_twiddlable() ); for( int j = 0 , js = in_site2->get_num_dirs() ; j < js ; ++j ) { site2->set_direction( in_site2->direction( j ) , in_site2->direction_type( j ) , -1 ); // -1 makes a new direction } site2->set_coords( in_site2->coords() ); site2->set_twiddle_axis( in_site2->twiddle_axis() ); made_site2 = true; } else { site2 = in_site2; } #ifdef NOTYET cout << "Site 1 " << site1->label() << " : " << site1->get_num_dirs() << " and " << "Site 2 " << site2->label() << " : " << site2->get_num_dirs() << endl; #endif get_site_dirs( dirs_type , *site1 , site1_dirs , nsd1 ); if( !nsd1 ) { if( made_site1 ) { delete site1; } if( made_site2 ) { delete site2; } continue; } get_site_dirs( dirs_type , *site2 , site2_dirs , nsd2 ); if( !nsd2 ) { if( made_site1 ) { delete site1; } if( made_site2 ) { delete site2; } continue; } if( site2->get_twiddlable() ) { site2->twiddle( *site1 , dirs_type ); } else if( site1->get_twiddlable() ) { site1->twiddle( *site2 , dirs_type ); } if( site2->get_flippable() ) { site2->flip( *site1 , dirs_type ); } else if( site1->get_flippable() ) { site1->flip( *site2 , dirs_type ); } // having twiddled and flipped one site, find the best combination of // site1_dirs and site2_dirs of the same type and add them to site // coords. This is because sometimes there can be more than one // dir of the same type that is neither flippable nor twiddlable // the first example seen being aniline NH2 for DONORS float best_dot = -1.0; int best1 = -1 , best2 = -1; for( int ii = 0 ; ii < nsd1 ; ++ii ) { if( dirs_type != site1->direction_type( ii ) ) { continue; } for( int j = 0 ; j < nsd2; ++j ) { if( dirs_type != site2->direction_type( j ) ) { continue; } float this_dot = DACLIB::dot_product( site1_dirs + 3 * ii , site2_dirs + 3 * j ); if( this_dot > best_dot ) { best1 = ii; best2 = j; best_dot = this_dot; } } } if( -1 != best1 && -1 != best2 ) { add_site_coords( site1->coords() , site1->direction( best1 ) , cds1 ); add_site_coords( site2->coords() , site2->direction( best2 ) , cds2 ); } if( made_site1 ) { delete site1; } if( made_site2 ) { delete site2; } } }
------------------------------------------------------------------------ -- A definition of the propositional truncation operator that does not -- use recursive higher inductive types ------------------------------------------------------------------------ -- The definition does use natural numbers. The code is based on van -- Doorn's "Constructing the Propositional Truncation using -- Non-recursive HITs". {-# OPTIONS --erased-cubical --safe #-} import Equality.Path as P module H-level.Truncation.Propositional.Non-recursive {e⁺} (eq : ∀ {a p} → P.Equality-with-paths a p e⁺) where private open module PD = P.Derived-definitions-and-properties eq hiding (elim) open import Prelude open import Colimit.Sequential eq as C using (Colimit) open import Equality.Decidable-UIP equality-with-J open import Equality.Path.Isomorphisms eq open import Equivalence equality-with-J as Eq using (_≃_) open import Function-universe equality-with-J as F open import H-level equality-with-J open import H-level.Closure equality-with-J import H-level.Truncation.Propositional eq as T open import H-level.Truncation.Propositional.Non-recursive.Erased eq as N using (∥_∥ᴱ) open import H-level.Truncation.Propositional.One-step eq as O using (∥_∥¹; ∥_∥¹-out-^; ∣_∣-out-^) private variable a p : Level A B : Type a P : A → Type p e x : A -- The propositional truncation operator. ∥_∥ : Type a → Type a ∥ A ∥ = Colimit ∥ A ∥¹-out-^ O.∣_∣ -- The point constructor. ∣_∣ : A → ∥ A ∥ ∣_∣ = C.∣_∣ -- The eliminator. record Elim {A : Type a} (P : ∥ A ∥ → Type p) : Type (a ⊔ p) where no-eta-equality field ∣∣ʳ : ∀ x → P ∣ x ∣ is-propositionʳ : ∀ x → Is-proposition (P x) open Elim public elim : Elim P → (x : ∥ A ∥) → P x elim {A = A} {P = P} e = C.elim λ where .C.Elim.∣∣ʳ {n = n} → helper n .C.Elim.∣∣≡∣∣ʳ _ → E.is-propositionʳ _ _ _ where module E = Elim e helper : ∀ n (x : ∥ A ∥¹-out-^ n) → P C.∣ x ∣ helper zero = E.∣∣ʳ helper (suc n) = O.elim λ where .O.Elim.∣∣ʳ x → subst P (sym (C.∣∣≡∣∣ x)) (helper n x) .O.Elim.∣∣-constantʳ _ _ → E.is-propositionʳ _ _ _ _ : elim e ∣ x ∣ ≡ e .∣∣ʳ x _ = refl _ -- The propositional truncation operator returns propositions. ∥∥-proposition : Is-proposition ∥ A ∥ ∥∥-proposition {A = A} = elim λ where .is-propositionʳ → Π≡-proposition ext .∣∣ʳ x → C.elim λ where .C.Elim.∣∣ʳ → lemma₁ _ x .C.Elim.∣∣≡∣∣ʳ {n = n} y → subst (∣ x ∣ ≡_) (C.∣∣≡∣∣ y) (lemma₁ (suc n) x O.∣ y ∣) ≡⟨ sym trans-subst ⟩ trans (lemma₁ (1 + n) x O.∣ y ∣) (C.∣∣≡∣∣ y) ≡⟨⟩ trans (trans (sym (trans (C.∣∣≡∣∣ (∣ x ∣-out-^ (1 + n))) (lemma₀ (1 + n) x))) (trans (cong C.∣_∣ (O.∣∣-constant (∣ x ∣-out-^ (1 + n)) O.∣ y ∣)) (C.∣∣≡∣∣ O.∣ y ∣))) (C.∣∣≡∣∣ y) ≡⟨ trans (cong (λ eq → trans (trans eq (trans (cong C.∣_∣ (O.∣∣-constant _ _)) (C.∣∣≡∣∣ _))) (C.∣∣≡∣∣ _)) $ sym-trans _ _) $ trans (trans-assoc _ _ _) $ trans (trans-assoc _ _ _) $ cong (trans (sym (lemma₀ (1 + n) _))) $ sym $ trans-assoc _ _ _ ⟩ trans (sym (lemma₀ (1 + n) x)) (trans (trans (sym (C.∣∣≡∣∣ (∣ x ∣-out-^ (1 + n)))) (trans (cong C.∣_∣ (O.∣∣-constant (∣ x ∣-out-^ (1 + n)) O.∣ y ∣)) (C.∣∣≡∣∣ O.∣ y ∣))) (C.∣∣≡∣∣ y)) ≡⟨ cong (λ eq → trans (sym (lemma₀ (1 + n) _)) (trans (trans (sym (C.∣∣≡∣∣ _)) eq) (C.∣∣≡∣∣ _))) $ sym $ lemma₂ _ _ _ _ _ ⟩ trans (sym (lemma₀ (1 + n) x)) (trans (trans (sym (C.∣∣≡∣∣ (∣ x ∣-out-^ (1 + n)))) (trans (C.∣∣≡∣∣ (∣ x ∣-out-^ (1 + n))) (cong C.∣_∣ (O.∣∣-constant _ _)))) (C.∣∣≡∣∣ y)) ≡⟨ cong (λ eq → trans (sym (lemma₀ (1 + n) _)) (trans eq (C.∣∣≡∣∣ _))) $ trans-sym-[trans] _ _ ⟩ trans (sym (lemma₀ (1 + n) x)) (trans (cong C.∣_∣ (O.∣∣-constant _ _)) (C.∣∣≡∣∣ y)) ≡⟨⟩ lemma₁ n x y ∎ where lemma₀ : ∀ n (x : A) → C.∣ ∣ x ∣-out-^ n ∣ ≡ ∣ x ∣ lemma₀ zero x = ∣ x ∣ ∎ lemma₀ (suc n) x = C.∣ O.∣ ∣ x ∣-out-^ n ∣ ∣ ≡⟨ C.∣∣≡∣∣ (∣ x ∣-out-^ n) ⟩ C.∣ ∣ x ∣-out-^ n ∣ ≡⟨ lemma₀ n x ⟩∎ ∣ x ∣ ∎ lemma₁ : ∀ n (x : A) (y : ∥ A ∥¹-out-^ n) → ∣ x ∣ ≡ C.∣ y ∣ lemma₁ n x y = ∣ x ∣ ≡⟨ sym (lemma₀ (suc n) x) ⟩ C.∣ ∣ x ∣-out-^ (suc n) ∣ ≡⟨⟩ C.∣ O.∣ ∣ x ∣-out-^ n ∣ ∣ ≡⟨ cong C.∣_∣ (O.∣∣-constant _ _) ⟩ C.∣ O.∣ y ∣ ∣ ≡⟨ C.∣∣≡∣∣ y ⟩∎ C.∣ y ∣ ∎ lemma₂ : ∀ n (x y : ∥ A ∥¹-out-^ n) (p : x ≡ y) (q : O.∣ x ∣ ≡ O.∣ y ∣) → trans (C.∣∣≡∣∣ {P = ∥ A ∥¹-out-^} x) (cong C.∣_∣ p) ≡ trans (cong C.∣_∣ q) (C.∣∣≡∣∣ y) lemma₂ n x y p q = trans (C.∣∣≡∣∣ x) (cong C.∣_∣ p) ≡⟨ PD.elim (λ {x y} p → trans (C.∣∣≡∣∣ x) (cong C.∣_∣ p) ≡ trans (cong C.∣_∣ (cong O.∣_∣ p)) (C.∣∣≡∣∣ y)) (λ x → trans (C.∣∣≡∣∣ x) (cong C.∣_∣ (refl _)) ≡⟨ cong (trans _) $ cong-refl _ ⟩ trans (C.∣∣≡∣∣ x) (refl _) ≡⟨ trans-reflʳ _ ⟩ C.∣∣≡∣∣ x ≡⟨ sym $ trans-reflˡ _ ⟩ trans (refl _) (C.∣∣≡∣∣ x) ≡⟨ cong (flip trans _) $ sym $ trans (cong (cong C.∣_∣) $ cong-refl _) $ cong-refl _ ⟩∎ trans (cong C.∣_∣ (cong O.∣_∣ (refl _))) (C.∣∣≡∣∣ x) ∎) p ⟩ trans (cong C.∣_∣ (cong O.∣_∣ p)) (C.∣∣≡∣∣ y) ≡⟨ cong (flip trans _) $ cong-preserves-Constant (λ u v → C.∣ u ∣ ≡⟨ sym (C.∣∣≡∣∣ u) ⟩ C.∣ O.∣ u ∣ ∣ ≡⟨ cong C.∣_∣ (O.∣∣-constant _ _) ⟩ C.∣ O.∣ v ∣ ∣ ≡⟨ C.∣∣≡∣∣ v ⟩∎ C.∣ v ∣ ∎) _ _ ⟩∎ trans (cong C.∣_∣ q) (C.∣∣≡∣∣ y) ∎ -- ∥_∥ is pointwise equivalent to T.∥_∥. ∥∥≃∥∥ : ∥ A ∥ ≃ T.∥ A ∥ ∥∥≃∥∥ = Eq.⇔→≃ ∥∥-proposition T.truncation-is-proposition (elim λ where .∣∣ʳ → T.∣_∣ .is-propositionʳ _ → T.truncation-is-proposition) (T.rec ∥∥-proposition ∣_∣) -- Functions from T.∥ A ∥ can be expressed as families of functions -- from ∥ A ∥¹-out-^ that satisfy a certain property. ∥∥→≃ : (T.∥ A ∥ → B) ≃ (∃ λ (f : ∀ n → ∥ A ∥¹-out-^ n → B) → ∀ n x → f (suc n) O.∣ x ∣ ≡ f n x) ∥∥→≃ {A = A} {B = B} = (T.∥ A ∥ → B) ↝⟨ →-cong ext (inverse ∥∥≃∥∥) F.id ⟩ (∥ A ∥ → B) ↝⟨ C.universal-property ⟩□ (∃ λ (f : ∀ n → ∥ A ∥¹-out-^ n → B) → ∀ n x → f (suc n) O.∣ x ∣ ≡ f n x) □ ------------------------------------------------------------------------ -- Some conversion functions -- ∥ A ∥ᴱ implies ∥ A ∥. ∥∥ᴱ→∥∥ : ∥ A ∥ᴱ → ∥ A ∥ ∥∥ᴱ→∥∥ = N.elim λ where .N.∣∣ʳ → ∣_∣ .N.is-propositionʳ _ → ∥∥-proposition -- In erased contexts ∥ A ∥ᴱ and ∥ A ∥ are equivalent. @0 ∥∥ᴱ≃∥∥ : ∥ A ∥ᴱ ≃ ∥ A ∥ ∥∥ᴱ≃∥∥ = Eq.↔→≃ ∥∥ᴱ→∥∥ (elim λ @0 where .∣∣ʳ → N.∣_∣ .is-propositionʳ _ → N.∥∥ᴱ-proposition) (elim λ @0 where .∣∣ʳ _ → refl _ .is-propositionʳ _ → mono₁ 1 ∥∥-proposition) (N.elim λ where .N.∣∣ʳ _ → refl _ .N.is-propositionʳ _ → mono₁ 1 N.∥∥ᴱ-proposition)
EW schwarz,1,Projekt //This line defines the kind of character to be created (EW=cube schwarz=black,1=size?,Projekt is not used) T(1,0,0) //relocaded to (x,y,z) T(1,0,0) //relocated to (x,y,z) EW schwarz,1,Projekt //This line defines the kind of character to be created (EW=cube schwarz=black,1=size?,Projekt is not used) S(2,2,2) //redefines size of edges to (x,y,z)
[STATEMENT] lemma Pos_fold [code_unfold]: "numeral Num.One = Pos Num.One" "numeral (Num.Bit0 k) = Pos (Num.Bit0 k)" "numeral (Num.Bit1 k) = Pos (Num.Bit1 k)" [PROOF STATE] proof (prove) goal (1 subgoal): 1. Numeral1 = Pos num.One &&& numeral (num.Bit0 k) = Pos (num.Bit0 k) &&& numeral (num.Bit1 k) = Pos (num.Bit1 k) [PROOF STEP] by simp_all
lemma Dynkin_system_trivial: shows "Dynkin_system A (Pow A)"
using Base.Test using Holidays @test 1 == 1
From Cofq.SystemC Require Import SystemCDefinitions. From Cofq.BaseExpressions Require Import Integers. From Cofq.Show Require Import ShowUtils. From Coq Require Import String List. Open Scope string_scope. Require Import QuickChick. Fixpoint showCType' (t : CType) := match t with | CProd ts => "CProd " ++ show (map showCType' ts) | CTForall n ts => "CTForall " ++ show n ++ " " ++ show (map showCType' ts) | CTVar x => "CTVar " ++ show x | CIntType => "CIntType" | CTExists t => "CTExists " ++ showCType' t end. Instance showCType : Show CType := {| show := showCType' |}. Fixpoint showCValue' {I} `{FInt I} `{Show I} (v : CValue) := match v with | CAnnotated rv t => "CAnnotated (" ++ showCRawValue' rv ++ ") (" ++ show t ++ ")" end with showCRawValue' {I} `{FInt I} `{Show I} (rv : CRawValue) := match rv with | CNum x => "CNum (" ++ show x ++ ")" | CVar x => "CVar (" ++ show x ++ ")" | CTuple x => "CTuple " ++ show (map showCValue' x) | CPack t1 rv t2 => "CPack (" ++ show t1 ++ ") (" ++ showCRawValue' rv ++ ") (" ++ show t2 ++ ")" | CTApp rv τ => "CTApp (" ++ showCRawValue' rv ++ ") (" ++ show τ ++ ")" end. Instance showCValue {I} `{FInt I} `{Show I} : Show CValue := {| show := showCValue' |}. Instance showCRawValue {I} `{FInt I} `{Show I} : Show CRawValue := {| show := showCRawValue' |}. Definition showCDeclaration' {I} `{FInt I} `{Show I} (d : CDeclaration) := match d with | CVal x => "CVal (" ++ show x ++ ")" | CProjN i v => "CProjN (" ++ show i ++ ") (" ++ show v ++ ")" | COp op v1 v2 => "COp " ++ show op ++ " (" ++ show v1 ++ ") (" ++ show v2 ++ ")" | CUnpack x => "CUnpack (" ++ show x ++ ")" end. Instance showCDeclaration {I} `{FInt I} `{Show I} : Show CDeclaration := {| show := showCDeclaration' |}. Fixpoint showCTerm' {I} `{FInt I} `{Show I} (term : CTerm) := match term with | CLet dec v => "CLet (" ++ show dec ++ ") (" ++ showCTerm' v ++ ")" | CApp f vs => "CApp (" ++ show f ++ ") " ++ show vs | CIf0 c e1 e2 => "CIf0 (" ++ show c ++ ") (" ++ showCTerm' e1 ++ ") (" ++ showCTerm' e2 ++ ")" | CHalt x τ => "CHalt (" ++ show x ++ ") (" ++ show τ ++ ")" end. Instance showCTerm {I} `{FInt I} `{Show I} : Show CTerm := {| show := showCTerm' |}.
[STATEMENT] lemma useful_tautologies_5[PLM]: "[(\<phi> \<^bold>\<rightarrow> \<psi>) \<^bold>\<rightarrow> (\<^bold>\<not>\<psi> \<^bold>\<rightarrow> \<^bold>\<not>\<phi>) in v]" [PROOF STATE] proof (prove) goal (1 subgoal): 1. [\<phi> \<^bold>\<rightarrow> \<psi> \<^bold>\<rightarrow> (\<^bold>\<not>\<psi> \<^bold>\<rightarrow> \<^bold>\<not>\<phi>) in v] [PROOF STEP] by (metis CP useful_tautologies_4 vdash_properties_10)
{-# LANGUAGE GADTs #-} {-# LANGUAGE FlexibleContexts #-} module HVX.Primitives -- TODO(mh): Currently primitives that should generate implicit constraints are -- unsupported. The should be supported shortily. (2014-06-04) ( apply , hadd , (+~) , hmul , (*~) , habs , neg , hlog , hexp , logsumexp , hmax , hmin , norm , berhu , huber , quadform , powBaseP0 , powBaseP01 , powBaseP1 , powBaseP1InfEven , powBaseP1InfNotInt ) where import Numeric.LinearAlgebra hiding (i) import Numeric.LinearAlgebra.LAPACK import HVX.Internal.DCP import HVX.Internal.Matrix import HVX.Internal.Primitives import HVX.Internal.Util apply :: (Vex vf, Mon mf, Vex ve, Mon me, Vex (ApplyVex vf mf ve me), Mon (ApplyMon mf me)) => Fun vf mf -> Expr ve me -> Expr (ApplyVex vf mf ve me) (ApplyMon mf me) apply = EFun hadd :: (Vex v1, Mon m1, Vex v2, Mon m2, Vex (AddVex v1 v2), Mon (AddMon m1 m2)) => Expr v1 m1 -> Expr v2 m2 -> Expr (AddVex v1 v2) (AddMon m1 m2) hadd = EAdd infixl 6 +~ (+~) :: (Vex v1, Mon m1, Vex v2, Mon m2, Vex (AddVex v1 v2), Mon (AddMon m1 m2)) => Expr v1 m1 -> Expr v2 m2 -> Expr (AddVex v1 v2) (AddMon m1 m2) (+~) = hadd -- Constructors that enforce DCP constraints. hmul :: (Vex v1, Mon m1, Vex (ApplyVex Affine Nonmon v1 m1), Mon (ApplyMon Nonmon m1)) => Expr Affine Const -> Expr v1 m1 -> Expr (ApplyVex Affine Nonmon v1 m1) (ApplyMon Nonmon m1) hmul (EConst a) e = apply (Mul a) e hmul _ _ = error "the left argument of a multiply must be a constant" infixl 7 *~ (*~) :: (Vex v1, Mon m1, Vex (ApplyVex Affine Nonmon v1 m1), Mon (ApplyMon Nonmon m1)) => Expr Affine Const -> Expr v1 m1 -> Expr (ApplyVex Affine Nonmon v1 m1) (ApplyMon Nonmon m1) (*~) (EConst a) e = apply (Mul a) e (*~) _ _ = error "the left argument of a multiply must be a constant" habs :: (Vex v1, Mon m1, Vex (ApplyVex Convex Nonmon v1 m1), Mon (ApplyMon Nonmon m1)) => Expr v1 m1 -> Expr (ApplyVex Convex Nonmon v1 m1) (ApplyMon Nonmon m1) habs = apply Abs neg :: (Vex v1, Mon m1, Vex (ApplyVex Affine Noninc v1 m1), Mon (ApplyMon Noninc m1)) => Expr v1 m1 -> Expr (ApplyVex Affine Noninc v1 m1) (ApplyMon Noninc m1) neg = apply Neg hlog :: (Vex v1, Mon m1, Vex (ApplyVex Concave Nondec v1 m1), Mon (ApplyMon Nondec m1)) => Expr v1 m1 -> Expr (ApplyVex Concave Nondec v1 m1) (ApplyMon Nondec m1) hlog = apply Log hexp :: (Vex v1, Mon m1, Vex (ApplyVex Convex Nondec v1 m1), Mon (ApplyMon Nondec m1)) => Expr v1 m1 -> Expr (ApplyVex Convex Nondec v1 m1) (ApplyMon Nondec m1) hexp = apply Exp logsumexp :: (Vex v1, Mon m1, Vex (ApplyVex Convex Nondec v1 m1), Mon (ApplyMon Nondec m1)) => Expr v1 m1 -> Expr (ApplyVex Convex Nondec v1 m1) (ApplyMon Nondec m1) logsumexp = apply LogSumExp hmax :: (Vex v1, Mon m1, Vex (ApplyVex Convex Nondec v1 m1), Mon (ApplyMon Nondec m1)) => Expr v1 m1 -> Expr (ApplyVex Convex Nondec v1 m1) (ApplyMon Nondec m1) hmax = apply Max hmin :: (Vex v1, Mon m1, Vex (ApplyVex Concave Nondec v1 m1), Mon (ApplyMon Nondec m1)) => Expr v1 m1 -> Expr (ApplyVex Concave Nondec v1 m1) (ApplyMon Nondec m1) hmin = apply Min norm :: (Vex v1, Mon m1, Vex (ApplyVex Convex Nonmon v1 m1), Mon (ApplyMon Nonmon m1)) => Double -> Expr v1 m1 -> Expr (ApplyVex Convex Nonmon v1 m1) (ApplyMon Nonmon m1) norm p | p == infinity = error "Internal: Infinity norm should become max . abs." | 1 <= p = apply (Norm p) | otherwise = error "Internal: Norm only supports p >= 1." berhu :: (Vex v1, Mon m1, Vex (ApplyVex Convex Nonmon v1 m1), Mon (ApplyMon Nonmon m1)) => Double -> Expr v1 m1 -> Expr (ApplyVex Convex Nonmon v1 m1) (ApplyMon Nonmon m1) berhu m | 0 < m = apply (Berhu m) | otherwise = error "Internal: Berhu only supports m >= 0." huber :: (Vex v1, Mon m1, Vex (ApplyVex Convex Nonmon v1 m1), Mon (ApplyMon Nonmon m1)) => Double -> Expr v1 m1 -> Expr (ApplyVex Convex Nonmon v1 m1) (ApplyMon Nonmon m1) huber m | 0 < m = apply (Huber m) | otherwise = error "Internal: Huber only supports m >= 0." quadform :: (Mon m1, Vex (ApplyVex Convex Nonmon Affine m1), Mon (ApplyMon Nonmon m1)) => Expr Affine Const -> Expr Affine m1 -> Expr (ApplyVex Convex Nonmon Affine m1) (ApplyMon Nonmon m1) quadform (EConst a) e | rows a == cols a && fpequalsMat a (trans a) && 0 <= maxElement (eigOnlyS a) = apply (Quadform a) e | otherwise = error "Matrices in quadratic forms must be positive semidefinite." quadform _ _ = error "The matrix sandwitched by the quadratic form must be constant." powBaseP0 :: (Vex v1, Mon m1, Vex (ApplyVex Affine Const v1 m1), Mon (ApplyMon Const m1)) => Double -> Expr v1 m1 -> Expr (ApplyVex Affine Const v1 m1) (ApplyMon Const m1) powBaseP0 p | p `fpequals` 0 = apply PowBaseP0 | otherwise = error "Internal: PowBaseP0 only supports p == 0." powBaseP01 :: (Vex v1, Mon m1, Vex (ApplyVex Concave Nondec v1 m1), Mon (ApplyMon Nondec m1)) => Double -> Expr v1 m1 -> Expr (ApplyVex Concave Nondec v1 m1) (ApplyMon Nondec m1) powBaseP01 p | 0 < p && p < 1 = apply (PowBaseP01 p) | otherwise = error "Internal: PowBaseP01 only supports 0 < p < 1." powBaseP1 :: (Vex v1, Mon m1, Vex (ApplyVex Affine Nondec v1 m1), Mon (ApplyMon Nondec m1)) => Double -> Expr v1 m1 -> Expr (ApplyVex Affine Nondec v1 m1) (ApplyMon Nondec m1) powBaseP1 p | p `fpequals` 1 = apply PowBaseP1 | otherwise = error "Internal: PowBaseP1 only supports p == 1." powBaseP1InfEven :: (Vex v1, Mon m1, Vex (ApplyVex Convex Nonmon v1 m1), Mon (ApplyMon Nonmon m1)) => Double -> Expr v1 m1 -> Expr (ApplyVex Convex Nonmon v1 m1) (ApplyMon Nonmon m1) powBaseP1InfEven p | 1 < p && isInteger p && even intP = apply (PowBaseP1InfEven intP) | otherwise = error "Internal: PowBaseP1InfEven only supports even p > 1." where intP = round p :: Integer powBaseP1InfNotInt :: (Vex v1, Mon m1, Vex (ApplyVex Convex Nondec v1 m1), Mon (ApplyMon Nondec m1)) => Double -> Expr v1 m1 -> Expr (ApplyVex Convex Nondec v1 m1) (ApplyMon Nondec m1) powBaseP1InfNotInt p | 1 < p && not (isInteger p) = apply (PowBaseP1InfNotInt p) | otherwise = error "Internal: PowBaseP1InfNotInt only supports non integral p > 1."
variable {f: Fin l} {f₀: Fin 0} (h: l = 0) (h': (h▸f) = f₀) example: l = 0 := by simp_all example (h'': l ≠ 0): False := by simp_all example: l = 0 := by simp[*] at * example (h'': l ≠ 0): False := by simp[*] at *
import data.real.basic theorem nat_real_le : ∀(x y : ℕ), x ≤ y → (↑x : ℝ) ≤ (↑y : ℝ) := sorry theorem ge_0_le_0 : ∀(x y : ℝ), x - y = x + (-y) := begin intros x y, linarith, end
/- Copyright (c) 2020 Sébastien Gouëzel. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Sébastien Gouëzel ! This file was ported from Lean 3 source module analysis.normed_space.multilinear ! leanprover-community/mathlib commit ce11c3c2a285bbe6937e26d9792fda4e51f3fe1a ! Please do not edit these lines, except to modify the commit id ! if you have ported upstream changes. -/ import Mathbin.Analysis.NormedSpace.OperatorNorm import Mathbin.Topology.Algebra.Module.Multilinear /-! # Operator norm on the space of continuous multilinear maps When `f` is a continuous multilinear map in finitely many variables, we define its norm `‖f‖` as the smallest number such that `‖f m‖ ≤ ‖f‖ * ∏ i, ‖m i‖` for all `m`. We show that it is indeed a norm, and prove its basic properties. ## Main results Let `f` be a multilinear map in finitely many variables. * `exists_bound_of_continuous` asserts that, if `f` is continuous, then there exists `C > 0` with `‖f m‖ ≤ C * ∏ i, ‖m i‖` for all `m`. * `continuous_of_bound`, conversely, asserts that this bound implies continuity. * `mk_continuous` constructs the associated continuous multilinear map. Let `f` be a continuous multilinear map in finitely many variables. * `‖f‖` is its norm, i.e., the smallest number such that `‖f m‖ ≤ ‖f‖ * ∏ i, ‖m i‖` for all `m`. * `le_op_norm f m` asserts the fundamental inequality `‖f m‖ ≤ ‖f‖ * ∏ i, ‖m i‖`. * `norm_image_sub_le f m₁ m₂` gives a control of the difference `f m₁ - f m₂` in terms of `‖f‖` and `‖m₁ - m₂‖`. We also register isomorphisms corresponding to currying or uncurrying variables, transforming a continuous multilinear function `f` in `n+1` variables into a continuous linear function taking values in continuous multilinear functions in `n` variables, and also into a continuous multilinear function in `n` variables taking values in continuous linear functions. These operations are called `f.curry_left` and `f.curry_right` respectively (with inverses `f.uncurry_left` and `f.uncurry_right`). They induce continuous linear equivalences between spaces of continuous multilinear functions in `n+1` variables and spaces of continuous linear functions into continuous multilinear functions in `n` variables (resp. continuous multilinear functions in `n` variables taking values in continuous linear functions), called respectively `continuous_multilinear_curry_left_equiv` and `continuous_multilinear_curry_right_equiv`. ## Implementation notes We mostly follow the API (and the proofs) of `operator_norm.lean`, with the additional complexity that we should deal with multilinear maps in several variables. The currying/uncurrying constructions are based on those in `multilinear.lean`. From the mathematical point of view, all the results follow from the results on operator norm in one variable, by applying them to one variable after the other through currying. However, this is only well defined when there is an order on the variables (for instance on `fin n`) although the final result is independent of the order. While everything could be done following this approach, it turns out that direct proofs are easier and more efficient. -/ noncomputable section open BigOperators NNReal open Finset Metric attribute [local instance] AddCommGroup.toAddCommMonoid NormedAddCommGroup.toAddCommGroup NormedSpace.toModule' /-! ### Type variables We use the following type variables in this file: * `𝕜` : a `nontrivially_normed_field`; * `ι`, `ι'` : finite index types with decidable equality; * `E`, `E₁` : families of normed vector spaces over `𝕜` indexed by `i : ι`; * `E'` : a family of normed vector spaces over `𝕜` indexed by `i' : ι'`; * `Ei` : a family of normed vector spaces over `𝕜` indexed by `i : fin (nat.succ n)`; * `G`, `G'` : normed vector spaces over `𝕜`. -/ universe u v v' wE wE₁ wE' wEi wG wG' variable {𝕜 : Type u} {ι : Type v} {ι' : Type v'} {n : ℕ} {E : ι → Type wE} {E₁ : ι → Type wE₁} {E' : ι' → Type wE'} {Ei : Fin n.succ → Type wEi} {G : Type wG} {G' : Type wG'} [Fintype ι] [Fintype ι'] [NontriviallyNormedField 𝕜] [∀ i, NormedAddCommGroup (E i)] [∀ i, NormedSpace 𝕜 (E i)] [∀ i, NormedAddCommGroup (E₁ i)] [∀ i, NormedSpace 𝕜 (E₁ i)] [∀ i, NormedAddCommGroup (E' i)] [∀ i, NormedSpace 𝕜 (E' i)] [∀ i, NormedAddCommGroup (Ei i)] [∀ i, NormedSpace 𝕜 (Ei i)] [NormedAddCommGroup G] [NormedSpace 𝕜 G] [NormedAddCommGroup G'] [NormedSpace 𝕜 G'] /-! ### Continuity properties of multilinear maps We relate continuity of multilinear maps to the inequality `‖f m‖ ≤ C * ∏ i, ‖m i‖`, in both directions. Along the way, we prove useful bounds on the difference `‖f m₁ - f m₂‖`. -/ namespace MultilinearMap variable (f : MultilinearMap 𝕜 E G) /-- If a multilinear map in finitely many variables on normed spaces satisfies the inequality `‖f m‖ ≤ C * ∏ i, ‖m i‖` on a shell `ε i / ‖c i‖ < ‖m i‖ < ε i` for some positive numbers `ε i` and elements `c i : 𝕜`, `1 < ‖c i‖`, then it satisfies this inequality for all `m`. -/ theorem bound_of_shell {ε : ι → ℝ} {C : ℝ} (hε : ∀ i, 0 < ε i) {c : ι → 𝕜} (hc : ∀ i, 1 < ‖c i‖) (hf : ∀ m : ∀ i, E i, (∀ i, ε i / ‖c i‖ ≤ ‖m i‖) → (∀ i, ‖m i‖ < ε i) → ‖f m‖ ≤ C * ∏ i, ‖m i‖) (m : ∀ i, E i) : ‖f m‖ ≤ C * ∏ i, ‖m i‖ := by rcases em (∃ i, m i = 0) with (⟨i, hi⟩ | hm) <;> [skip, push_neg at hm] · simp [f.map_coord_zero i hi, prod_eq_zero (mem_univ i), hi] choose δ hδ0 hδm_lt hle_δm hδinv using fun i => rescale_to_shell (hc i) (hε i) (hm i) have hδ0 : 0 < ∏ i, ‖δ i‖ := prod_pos fun i _ => norm_pos_iff.2 (hδ0 i) simpa [map_smul_univ, norm_smul, prod_mul_distrib, mul_left_comm C, mul_le_mul_left hδ0] using hf (fun i => δ i • m i) hle_δm hδm_lt #align multilinear_map.bound_of_shell MultilinearMap.bound_of_shell /-- If a multilinear map in finitely many variables on normed spaces is continuous, then it satisfies the inequality `‖f m‖ ≤ C * ∏ i, ‖m i‖`, for some `C` which can be chosen to be positive. -/ theorem exists_bound_of_continuous (hf : Continuous f) : ∃ C : ℝ, 0 < C ∧ ∀ m, ‖f m‖ ≤ C * ∏ i, ‖m i‖ := by cases isEmpty_or_nonempty ι · refine' ⟨‖f 0‖ + 1, add_pos_of_nonneg_of_pos (norm_nonneg _) zero_lt_one, fun m => _⟩ obtain rfl : m = 0 exact funext (IsEmpty.elim ‹_›) simp [univ_eq_empty, zero_le_one] obtain ⟨ε : ℝ, ε0 : 0 < ε, hε : ∀ m : ∀ i, E i, ‖m - 0‖ < ε → ‖f m - f 0‖ < 1⟩ := NormedAddCommGroup.tendsto_nhds_nhds.1 (hf.tendsto 0) 1 zero_lt_one simp only [sub_zero, f.map_zero] at hε rcases NormedField.exists_one_lt_norm 𝕜 with ⟨c, hc⟩ have : 0 < (‖c‖ / ε) ^ Fintype.card ι := pow_pos (div_pos (zero_lt_one.trans hc) ε0) _ refine' ⟨_, this, _⟩ refine' f.bound_of_shell (fun _ => ε0) (fun _ => hc) fun m hcm hm => _ refine' (hε m ((pi_norm_lt_iff ε0).2 hm)).le.trans _ rw [← div_le_iff' this, one_div, ← inv_pow, inv_div, Fintype.card, ← prod_const] exact prod_le_prod (fun _ _ => div_nonneg ε0.le (norm_nonneg _)) fun i _ => hcm i #align multilinear_map.exists_bound_of_continuous MultilinearMap.exists_bound_of_continuous /-- If `f` satisfies a boundedness property around `0`, one can deduce a bound on `f m₁ - f m₂` using the multilinearity. Here, we give a precise but hard to use version. See `norm_image_sub_le_of_bound` for a less precise but more usable version. The bound reads `‖f m - f m'‖ ≤ C * ‖m 1 - m' 1‖ * max ‖m 2‖ ‖m' 2‖ * max ‖m 3‖ ‖m' 3‖ * ... * max ‖m n‖ ‖m' n‖ + ...`, where the other terms in the sum are the same products where `1` is replaced by any `i`. -/ theorem norm_image_sub_le_of_bound' [DecidableEq ι] {C : ℝ} (hC : 0 ≤ C) (H : ∀ m, ‖f m‖ ≤ C * ∏ i, ‖m i‖) (m₁ m₂ : ∀ i, E i) : ‖f m₁ - f m₂‖ ≤ C * ∑ i, ∏ j, if j = i then ‖m₁ i - m₂ i‖ else max ‖m₁ j‖ ‖m₂ j‖ := by have A : ∀ s : Finset ι, ‖f m₁ - f (s.piecewise m₂ m₁)‖ ≤ C * ∑ i in s, ∏ j, if j = i then ‖m₁ i - m₂ i‖ else max ‖m₁ j‖ ‖m₂ j‖ := by refine' Finset.induction (by simp) _ intro i s his Hrec have I : ‖f (s.piecewise m₂ m₁) - f ((insert i s).piecewise m₂ m₁)‖ ≤ C * ∏ j, if j = i then ‖m₁ i - m₂ i‖ else max ‖m₁ j‖ ‖m₂ j‖ := by have A : (insert i s).piecewise m₂ m₁ = Function.update (s.piecewise m₂ m₁) i (m₂ i) := s.piecewise_insert _ _ _ have B : s.piecewise m₂ m₁ = Function.update (s.piecewise m₂ m₁) i (m₁ i) := by ext j by_cases h : j = i · rw [h] simp [his] · simp [h] rw [B, A, ← f.map_sub] apply le_trans (H _) (mul_le_mul_of_nonneg_left _ hC) refine' prod_le_prod (fun j hj => norm_nonneg _) fun j hj => _ by_cases h : j = i · rw [h] simp · by_cases h' : j ∈ s <;> simp [h', h, le_refl] calc ‖f m₁ - f ((insert i s).piecewise m₂ m₁)‖ ≤ ‖f m₁ - f (s.piecewise m₂ m₁)‖ + ‖f (s.piecewise m₂ m₁) - f ((insert i s).piecewise m₂ m₁)‖ := by rw [← dist_eq_norm, ← dist_eq_norm, ← dist_eq_norm] exact dist_triangle _ _ _ _ ≤ (C * ∑ i in s, ∏ j, if j = i then ‖m₁ i - m₂ i‖ else max ‖m₁ j‖ ‖m₂ j‖) + C * ∏ j, if j = i then ‖m₁ i - m₂ i‖ else max ‖m₁ j‖ ‖m₂ j‖ := (add_le_add Hrec I) _ = C * ∑ i in insert i s, ∏ j, if j = i then ‖m₁ i - m₂ i‖ else max ‖m₁ j‖ ‖m₂ j‖ := by simp [his, add_comm, left_distrib] convert A univ simp #align multilinear_map.norm_image_sub_le_of_bound' MultilinearMap.norm_image_sub_le_of_bound' /-- If `f` satisfies a boundedness property around `0`, one can deduce a bound on `f m₁ - f m₂` using the multilinearity. Here, we give a usable but not very precise version. See `norm_image_sub_le_of_bound'` for a more precise but less usable version. The bound is `‖f m - f m'‖ ≤ C * card ι * ‖m - m'‖ * (max ‖m‖ ‖m'‖) ^ (card ι - 1)`. -/ theorem norm_image_sub_le_of_bound {C : ℝ} (hC : 0 ≤ C) (H : ∀ m, ‖f m‖ ≤ C * ∏ i, ‖m i‖) (m₁ m₂ : ∀ i, E i) : ‖f m₁ - f m₂‖ ≤ C * Fintype.card ι * max ‖m₁‖ ‖m₂‖ ^ (Fintype.card ι - 1) * ‖m₁ - m₂‖ := by letI := Classical.decEq ι have A : ∀ i : ι, (∏ j, if j = i then ‖m₁ i - m₂ i‖ else max ‖m₁ j‖ ‖m₂ j‖) ≤ ‖m₁ - m₂‖ * max ‖m₁‖ ‖m₂‖ ^ (Fintype.card ι - 1) := by intro i calc (∏ j, if j = i then ‖m₁ i - m₂ i‖ else max ‖m₁ j‖ ‖m₂ j‖) ≤ ∏ j : ι, Function.update (fun j => max ‖m₁‖ ‖m₂‖) i ‖m₁ - m₂‖ j := by apply prod_le_prod · intro j hj by_cases h : j = i <;> simp [h, norm_nonneg] · intro j hj by_cases h : j = i · rw [h] simp exact norm_le_pi_norm (m₁ - m₂) i · simp [h, max_le_max, norm_le_pi_norm (_ : ∀ i, E i)] _ = ‖m₁ - m₂‖ * max ‖m₁‖ ‖m₂‖ ^ (Fintype.card ι - 1) := by rw [prod_update_of_mem (Finset.mem_univ _)] simp [card_univ_diff] calc ‖f m₁ - f m₂‖ ≤ C * ∑ i, ∏ j, if j = i then ‖m₁ i - m₂ i‖ else max ‖m₁ j‖ ‖m₂ j‖ := f.norm_image_sub_le_of_bound' hC H m₁ m₂ _ ≤ C * ∑ i, ‖m₁ - m₂‖ * max ‖m₁‖ ‖m₂‖ ^ (Fintype.card ι - 1) := (mul_le_mul_of_nonneg_left (sum_le_sum fun i hi => A i) hC) _ = C * Fintype.card ι * max ‖m₁‖ ‖m₂‖ ^ (Fintype.card ι - 1) * ‖m₁ - m₂‖ := by rw [sum_const, card_univ, nsmul_eq_mul] ring #align multilinear_map.norm_image_sub_le_of_bound MultilinearMap.norm_image_sub_le_of_bound /-- If a multilinear map satisfies an inequality `‖f m‖ ≤ C * ∏ i, ‖m i‖`, then it is continuous. -/ theorem continuous_of_bound (C : ℝ) (H : ∀ m, ‖f m‖ ≤ C * ∏ i, ‖m i‖) : Continuous f := by let D := max C 1 have D_pos : 0 ≤ D := le_trans zero_le_one (le_max_right _ _) replace H : ∀ m, ‖f m‖ ≤ D * ∏ i, ‖m i‖ · intro m apply le_trans (H m) (mul_le_mul_of_nonneg_right (le_max_left _ _) _) exact prod_nonneg fun (i : ι) hi => norm_nonneg (m i) refine' continuous_iff_continuousAt.2 fun m => _ refine' continuousAt_of_locally_lipschitz zero_lt_one (D * Fintype.card ι * (‖m‖ + 1) ^ (Fintype.card ι - 1)) fun m' h' => _ rw [dist_eq_norm, dist_eq_norm] have : 0 ≤ max ‖m'‖ ‖m‖ := by simp have : max ‖m'‖ ‖m‖ ≤ ‖m‖ + 1 := by simp [zero_le_one, norm_le_of_mem_closedBall (le_of_lt h'), -add_comm] calc ‖f m' - f m‖ ≤ D * Fintype.card ι * max ‖m'‖ ‖m‖ ^ (Fintype.card ι - 1) * ‖m' - m‖ := f.norm_image_sub_le_of_bound D_pos H m' m _ ≤ D * Fintype.card ι * (‖m‖ + 1) ^ (Fintype.card ι - 1) * ‖m' - m‖ := by apply_rules [mul_le_mul_of_nonneg_right, mul_le_mul_of_nonneg_left, mul_nonneg, norm_nonneg, Nat.cast_nonneg, pow_le_pow_of_le_left] #align multilinear_map.continuous_of_bound MultilinearMap.continuous_of_bound /-- Constructing a continuous multilinear map from a multilinear map satisfying a boundedness condition. -/ def mkContinuous (C : ℝ) (H : ∀ m, ‖f m‖ ≤ C * ∏ i, ‖m i‖) : ContinuousMultilinearMap 𝕜 E G := { f with cont := f.continuous_of_bound C H } #align multilinear_map.mk_continuous MultilinearMap.mkContinuous @[simp] theorem coe_mkContinuous (C : ℝ) (H : ∀ m, ‖f m‖ ≤ C * ∏ i, ‖m i‖) : ⇑(f.mkContinuous C H) = f := rfl #align multilinear_map.coe_mk_continuous MultilinearMap.coe_mkContinuous /-- Given a multilinear map in `n` variables, if one restricts it to `k` variables putting `z` on the other coordinates, then the resulting restricted function satisfies an inequality `‖f.restr v‖ ≤ C * ‖z‖^(n-k) * Π ‖v i‖` if the original function satisfies `‖f v‖ ≤ C * Π ‖v i‖`. -/ theorem restr_norm_le {k n : ℕ} (f : (MultilinearMap 𝕜 (fun i : Fin n => G) G' : _)) (s : Finset (Fin n)) (hk : s.card = k) (z : G) {C : ℝ} (H : ∀ m, ‖f m‖ ≤ C * ∏ i, ‖m i‖) (v : Fin k → G) : ‖f.restr s hk z v‖ ≤ C * ‖z‖ ^ (n - k) * ∏ i, ‖v i‖ := by rw [mul_right_comm, mul_assoc] convert H _ using 2 simp only [apply_dite norm, Fintype.prod_dite, prod_const ‖z‖, Finset.card_univ, Fintype.card_of_subtype (sᶜ) fun x => mem_compl, card_compl, Fintype.card_fin, hk, mk_coe, ← (s.order_iso_of_fin hk).symm.Bijective.prod_comp fun x => ‖v x‖] rfl #align multilinear_map.restr_norm_le MultilinearMap.restr_norm_le end MultilinearMap /-! ### Continuous multilinear maps We define the norm `‖f‖` of a continuous multilinear map `f` in finitely many variables as the smallest number such that `‖f m‖ ≤ ‖f‖ * ∏ i, ‖m i‖` for all `m`. We show that this defines a normed space structure on `continuous_multilinear_map 𝕜 E G`. -/ namespace ContinuousMultilinearMap variable (c : 𝕜) (f g : ContinuousMultilinearMap 𝕜 E G) (m : ∀ i, E i) theorem bound : ∃ C : ℝ, 0 < C ∧ ∀ m, ‖f m‖ ≤ C * ∏ i, ‖m i‖ := f.toMultilinearMap.exists_bound_of_continuous f.2 #align continuous_multilinear_map.bound ContinuousMultilinearMap.bound open Real /-- The operator norm of a continuous multilinear map is the inf of all its bounds. -/ def opNorm := infₛ { c | 0 ≤ (c : ℝ) ∧ ∀ m, ‖f m‖ ≤ c * ∏ i, ‖m i‖ } #align continuous_multilinear_map.op_norm ContinuousMultilinearMap.opNorm instance hasOpNorm : Norm (ContinuousMultilinearMap 𝕜 E G) := ⟨opNorm⟩ #align continuous_multilinear_map.has_op_norm ContinuousMultilinearMap.hasOpNorm /-- An alias of `continuous_multilinear_map.has_op_norm` with non-dependent types to help typeclass search. -/ instance hasOpNorm' : Norm (ContinuousMultilinearMap 𝕜 (fun i : ι => G) G') := ContinuousMultilinearMap.hasOpNorm #align continuous_multilinear_map.has_op_norm' ContinuousMultilinearMap.hasOpNorm' theorem norm_def : ‖f‖ = infₛ { c | 0 ≤ (c : ℝ) ∧ ∀ m, ‖f m‖ ≤ c * ∏ i, ‖m i‖ } := rfl #align continuous_multilinear_map.norm_def ContinuousMultilinearMap.norm_def -- So that invocations of `le_cInf` make sense: we show that the set of -- bounds is nonempty and bounded below. theorem bounds_nonempty {f : ContinuousMultilinearMap 𝕜 E G} : ∃ c, c ∈ { c | 0 ≤ c ∧ ∀ m, ‖f m‖ ≤ c * ∏ i, ‖m i‖ } := let ⟨M, hMp, hMb⟩ := f.bound ⟨M, le_of_lt hMp, hMb⟩ #align continuous_multilinear_map.bounds_nonempty ContinuousMultilinearMap.bounds_nonempty theorem bounds_bddBelow {f : ContinuousMultilinearMap 𝕜 E G} : BddBelow { c | 0 ≤ c ∧ ∀ m, ‖f m‖ ≤ c * ∏ i, ‖m i‖ } := ⟨0, fun _ ⟨hn, _⟩ => hn⟩ #align continuous_multilinear_map.bounds_bdd_below ContinuousMultilinearMap.bounds_bddBelow theorem op_norm_nonneg : 0 ≤ ‖f‖ := le_cinfₛ bounds_nonempty fun _ ⟨hx, _⟩ => hx #align continuous_multilinear_map.op_norm_nonneg ContinuousMultilinearMap.op_norm_nonneg /-- The fundamental property of the operator norm of a continuous multilinear map: `‖f m‖` is bounded by `‖f‖` times the product of the `‖m i‖`. -/ theorem le_op_norm : ‖f m‖ ≤ ‖f‖ * ∏ i, ‖m i‖ := by have A : 0 ≤ ∏ i, ‖m i‖ := prod_nonneg fun j hj => norm_nonneg _ cases' A.eq_or_lt with h hlt · rcases prod_eq_zero_iff.1 h.symm with ⟨i, _, hi⟩ rw [norm_eq_zero] at hi have : f m = 0 := f.map_coord_zero i hi rw [this, norm_zero] exact mul_nonneg (op_norm_nonneg f) A · rw [← div_le_iff hlt] apply le_cinfₛ bounds_nonempty rintro c ⟨_, hc⟩ rw [div_le_iff hlt] apply hc #align continuous_multilinear_map.le_op_norm ContinuousMultilinearMap.le_op_norm theorem le_of_op_norm_le {C : ℝ} (h : ‖f‖ ≤ C) : ‖f m‖ ≤ C * ∏ i, ‖m i‖ := (f.le_op_norm m).trans <| mul_le_mul_of_nonneg_right h (prod_nonneg fun i _ => norm_nonneg (m i)) #align continuous_multilinear_map.le_of_op_norm_le ContinuousMultilinearMap.le_of_op_norm_le theorem ratio_le_op_norm : (‖f m‖ / ∏ i, ‖m i‖) ≤ ‖f‖ := div_le_of_nonneg_of_le_mul (prod_nonneg fun i _ => norm_nonneg _) (op_norm_nonneg _) (f.le_op_norm m) #align continuous_multilinear_map.ratio_le_op_norm ContinuousMultilinearMap.ratio_le_op_norm /-- The image of the unit ball under a continuous multilinear map is bounded. -/ theorem unit_le_op_norm (h : ‖m‖ ≤ 1) : ‖f m‖ ≤ ‖f‖ := calc ‖f m‖ ≤ ‖f‖ * ∏ i, ‖m i‖ := f.le_op_norm m _ ≤ ‖f‖ * ∏ i : ι, 1 := (mul_le_mul_of_nonneg_left (prod_le_prod (fun i hi => norm_nonneg _) fun i hi => le_trans (norm_le_pi_norm (_ : ∀ i, E i) _) h) (op_norm_nonneg f)) _ = ‖f‖ := by simp #align continuous_multilinear_map.unit_le_op_norm ContinuousMultilinearMap.unit_le_op_norm /-- If one controls the norm of every `f x`, then one controls the norm of `f`. -/ theorem op_norm_le_bound {M : ℝ} (hMp : 0 ≤ M) (hM : ∀ m, ‖f m‖ ≤ M * ∏ i, ‖m i‖) : ‖f‖ ≤ M := cinfₛ_le bounds_bddBelow ⟨hMp, hM⟩ #align continuous_multilinear_map.op_norm_le_bound ContinuousMultilinearMap.op_norm_le_bound /-- The operator norm satisfies the triangle inequality. -/ theorem op_norm_add_le : ‖f + g‖ ≤ ‖f‖ + ‖g‖ := cinfₛ_le bounds_bddBelow ⟨add_nonneg (op_norm_nonneg _) (op_norm_nonneg _), fun x => by rw [add_mul] exact norm_add_le_of_le (le_op_norm _ _) (le_op_norm _ _)⟩ #align continuous_multilinear_map.op_norm_add_le ContinuousMultilinearMap.op_norm_add_le theorem op_norm_zero : ‖(0 : ContinuousMultilinearMap 𝕜 E G)‖ = 0 := (op_norm_nonneg _).antisymm' <| op_norm_le_bound 0 le_rfl fun m => by simp #align continuous_multilinear_map.op_norm_zero ContinuousMultilinearMap.op_norm_zero /-- A continuous linear map is zero iff its norm vanishes. -/ theorem op_norm_zero_iff : ‖f‖ = 0 ↔ f = 0 := ⟨fun h => by ext m simpa [h] using f.le_op_norm m, by rintro rfl exact op_norm_zero⟩ #align continuous_multilinear_map.op_norm_zero_iff ContinuousMultilinearMap.op_norm_zero_iff section variable {𝕜' : Type _} [NormedField 𝕜'] [NormedSpace 𝕜' G] [SMulCommClass 𝕜 𝕜' G] theorem op_norm_smul_le (c : 𝕜') : ‖c • f‖ ≤ ‖c‖ * ‖f‖ := (c • f).op_norm_le_bound (mul_nonneg (norm_nonneg _) (op_norm_nonneg _)) (by intro m erw [norm_smul, mul_assoc] exact mul_le_mul_of_nonneg_left (le_op_norm _ _) (norm_nonneg _)) #align continuous_multilinear_map.op_norm_smul_le ContinuousMultilinearMap.op_norm_smul_le theorem op_norm_neg : ‖-f‖ = ‖f‖ := by rw [norm_def] apply congr_arg ext simp #align continuous_multilinear_map.op_norm_neg ContinuousMultilinearMap.op_norm_neg /-- Continuous multilinear maps themselves form a normed space with respect to the operator norm. -/ instance normedAddCommGroup : NormedAddCommGroup (ContinuousMultilinearMap 𝕜 E G) := AddGroupNorm.toNormedAddCommGroup { toFun := norm map_zero' := op_norm_zero neg' := op_norm_neg add_le' := op_norm_add_le eq_zero_of_map_eq_zero' := fun f => f.op_norm_zero_iff.1 } #align continuous_multilinear_map.normed_add_comm_group ContinuousMultilinearMap.normedAddCommGroup /-- An alias of `continuous_multilinear_map.normed_add_comm_group` with non-dependent types to help typeclass search. -/ instance normedAddCommGroup' : NormedAddCommGroup (ContinuousMultilinearMap 𝕜 (fun i : ι => G) G') := ContinuousMultilinearMap.normedAddCommGroup #align continuous_multilinear_map.normed_add_comm_group' ContinuousMultilinearMap.normedAddCommGroup' instance normedSpace : NormedSpace 𝕜' (ContinuousMultilinearMap 𝕜 E G) := ⟨fun c f => f.op_norm_smul_le c⟩ #align continuous_multilinear_map.normed_space ContinuousMultilinearMap.normedSpace /-- An alias of `continuous_multilinear_map.normed_space` with non-dependent types to help typeclass search. -/ instance normedSpace' : NormedSpace 𝕜' (ContinuousMultilinearMap 𝕜 (fun i : ι => G') G) := ContinuousMultilinearMap.normedSpace #align continuous_multilinear_map.normed_space' ContinuousMultilinearMap.normedSpace' theorem le_op_norm_mul_prod_of_le {b : ι → ℝ} (hm : ∀ i, ‖m i‖ ≤ b i) : ‖f m‖ ≤ ‖f‖ * ∏ i, b i := (f.le_op_norm m).trans <| mul_le_mul_of_nonneg_left (prod_le_prod (fun _ _ => norm_nonneg _) fun i _ => hm i) (norm_nonneg f) #align continuous_multilinear_map.le_op_norm_mul_prod_of_le ContinuousMultilinearMap.le_op_norm_mul_prod_of_le theorem le_op_norm_mul_pow_card_of_le {b : ℝ} (hm : ∀ i, ‖m i‖ ≤ b) : ‖f m‖ ≤ ‖f‖ * b ^ Fintype.card ι := by simpa only [prod_const] using f.le_op_norm_mul_prod_of_le m hm #align continuous_multilinear_map.le_op_norm_mul_pow_card_of_le ContinuousMultilinearMap.le_op_norm_mul_pow_card_of_le theorem le_op_norm_mul_pow_of_le {Ei : Fin n → Type _} [∀ i, NormedAddCommGroup (Ei i)] [∀ i, NormedSpace 𝕜 (Ei i)] (f : ContinuousMultilinearMap 𝕜 Ei G) (m : ∀ i, Ei i) {b : ℝ} (hm : ‖m‖ ≤ b) : ‖f m‖ ≤ ‖f‖ * b ^ n := by simpa only [Fintype.card_fin] using f.le_op_norm_mul_pow_card_of_le m fun i => (norm_le_pi_norm m i).trans hm #align continuous_multilinear_map.le_op_norm_mul_pow_of_le ContinuousMultilinearMap.le_op_norm_mul_pow_of_le /-- The fundamental property of the operator norm of a continuous multilinear map: `‖f m‖` is bounded by `‖f‖` times the product of the `‖m i‖`, `nnnorm` version. -/ theorem le_op_nnnorm : ‖f m‖₊ ≤ ‖f‖₊ * ∏ i, ‖m i‖₊ := NNReal.coe_le_coe.1 <| by push_cast exact f.le_op_norm m #align continuous_multilinear_map.le_op_nnnorm ContinuousMultilinearMap.le_op_nnnorm theorem le_of_op_nnnorm_le {C : ℝ≥0} (h : ‖f‖₊ ≤ C) : ‖f m‖₊ ≤ C * ∏ i, ‖m i‖₊ := (f.le_op_nnnorm m).trans <| mul_le_mul' h le_rfl #align continuous_multilinear_map.le_of_op_nnnorm_le ContinuousMultilinearMap.le_of_op_nnnorm_le theorem op_norm_prod (f : ContinuousMultilinearMap 𝕜 E G) (g : ContinuousMultilinearMap 𝕜 E G') : ‖f.Prod g‖ = max ‖f‖ ‖g‖ := le_antisymm (op_norm_le_bound _ (norm_nonneg (f, g)) fun m => by have H : 0 ≤ ∏ i, ‖m i‖ := prod_nonneg fun _ _ => norm_nonneg _ simpa only [prod_apply, Prod.norm_def, max_mul_of_nonneg, H] using max_le_max (f.le_op_norm m) (g.le_op_norm m)) <| max_le (f.op_norm_le_bound (norm_nonneg _) fun m => (le_max_left _ _).trans ((f.Prod g).le_op_norm _)) (g.op_norm_le_bound (norm_nonneg _) fun m => (le_max_right _ _).trans ((f.Prod g).le_op_norm _)) #align continuous_multilinear_map.op_norm_prod ContinuousMultilinearMap.op_norm_prod theorem norm_pi {ι' : Type v'} [Fintype ι'] {E' : ι' → Type wE'} [∀ i', NormedAddCommGroup (E' i')] [∀ i', NormedSpace 𝕜 (E' i')] (f : ∀ i', ContinuousMultilinearMap 𝕜 E (E' i')) : ‖pi f‖ = ‖f‖ := by apply le_antisymm · refine' op_norm_le_bound _ (norm_nonneg f) fun m => _ dsimp rw [pi_norm_le_iff_of_nonneg] exacts[fun i => (f i).le_of_op_norm_le m (norm_le_pi_norm f i), mul_nonneg (norm_nonneg f) (prod_nonneg fun _ _ => norm_nonneg _)] · refine' (pi_norm_le_iff_of_nonneg (norm_nonneg _)).2 fun i => _ refine' op_norm_le_bound _ (norm_nonneg _) fun m => _ refine' le_trans _ ((pi f).le_op_norm m) convert norm_le_pi_norm (fun j => f j m) i #align continuous_multilinear_map.norm_pi ContinuousMultilinearMap.norm_pi section variable (𝕜 G) @[simp] theorem norm_ofSubsingleton [Subsingleton ι] [Nontrivial G] (i' : ι) : ‖ofSubsingleton 𝕜 G i'‖ = 1 := by apply le_antisymm · refine' op_norm_le_bound _ zero_le_one fun m => _ rw [Fintype.prod_subsingleton _ i', one_mul, of_subsingleton_apply] · obtain ⟨g, hg⟩ := exists_ne (0 : G) rw [← norm_ne_zero_iff] at hg have := (of_subsingleton 𝕜 G i').ratio_le_op_norm fun _ => g rwa [Fintype.prod_subsingleton _ i', of_subsingleton_apply, div_self hg] at this #align continuous_multilinear_map.norm_of_subsingleton ContinuousMultilinearMap.norm_ofSubsingleton @[simp] theorem nnnorm_ofSubsingleton [Subsingleton ι] [Nontrivial G] (i' : ι) : ‖ofSubsingleton 𝕜 G i'‖₊ = 1 := NNReal.eq <| norm_ofSubsingleton _ _ _ #align continuous_multilinear_map.nnnorm_of_subsingleton ContinuousMultilinearMap.nnnorm_ofSubsingleton variable {G} (E) @[simp] theorem norm_constOfIsEmpty [IsEmpty ι] (x : G) : ‖constOfIsEmpty 𝕜 E x‖ = ‖x‖ := by apply le_antisymm · refine' op_norm_le_bound _ (norm_nonneg _) fun x => _ rw [Fintype.prod_empty, mul_one, const_of_is_empty_apply] · simpa using (const_of_is_empty 𝕜 E x).le_op_norm 0 #align continuous_multilinear_map.norm_const_of_is_empty ContinuousMultilinearMap.norm_constOfIsEmpty @[simp] theorem nnnorm_constOfIsEmpty [IsEmpty ι] (x : G) : ‖constOfIsEmpty 𝕜 E x‖₊ = ‖x‖₊ := NNReal.eq <| norm_constOfIsEmpty _ _ _ #align continuous_multilinear_map.nnnorm_const_of_is_empty ContinuousMultilinearMap.nnnorm_constOfIsEmpty end section variable (𝕜 E E' G G') /-- `continuous_multilinear_map.prod` as a `linear_isometry_equiv`. -/ def prodL : ContinuousMultilinearMap 𝕜 E G × ContinuousMultilinearMap 𝕜 E G' ≃ₗᵢ[𝕜] ContinuousMultilinearMap 𝕜 E (G × G') where toFun f := f.1.Prod f.2 invFun f := ((ContinuousLinearMap.fst 𝕜 G G').compContinuousMultilinearMap f, (ContinuousLinearMap.snd 𝕜 G G').compContinuousMultilinearMap f) map_add' f g := rfl map_smul' c f := rfl left_inv f := by ext <;> rfl right_inv f := by ext <;> rfl norm_map' f := op_norm_prod f.1 f.2 #align continuous_multilinear_map.prodL ContinuousMultilinearMap.prodL /-- `continuous_multilinear_map.pi` as a `linear_isometry_equiv`. -/ def piₗᵢ {ι' : Type v'} [Fintype ι'] {E' : ι' → Type wE'} [∀ i', NormedAddCommGroup (E' i')] [∀ i', NormedSpace 𝕜 (E' i')] : @LinearIsometryEquiv 𝕜 𝕜 _ _ (RingHom.id 𝕜) _ _ _ (∀ i', ContinuousMultilinearMap 𝕜 E (E' i')) (ContinuousMultilinearMap 𝕜 E (∀ i, E' i)) _ _ (@Pi.module ι' _ 𝕜 _ _ fun i' => inferInstance) _ where toLinearEquiv :=-- note: `pi_linear_equiv` does not unify correctly here, presumably due to issues with dependent -- typeclass arguments. { piEquiv with map_add' := fun f g => rfl map_smul' := fun c f => rfl } norm_map' := norm_pi #align continuous_multilinear_map.piₗᵢ ContinuousMultilinearMap.piₗᵢ end end section RestrictScalars variable {𝕜' : Type _} [NontriviallyNormedField 𝕜'] [NormedAlgebra 𝕜' 𝕜] variable [NormedSpace 𝕜' G] [IsScalarTower 𝕜' 𝕜 G] variable [∀ i, NormedSpace 𝕜' (E i)] [∀ i, IsScalarTower 𝕜' 𝕜 (E i)] @[simp] theorem norm_restrictScalars : ‖f.restrictScalars 𝕜'‖ = ‖f‖ := by simp only [norm_def, coe_restrict_scalars] #align continuous_multilinear_map.norm_restrict_scalars ContinuousMultilinearMap.norm_restrictScalars variable (𝕜') /-- `continuous_multilinear_map.restrict_scalars` as a `continuous_multilinear_map`. -/ def restrictScalarsLinear : ContinuousMultilinearMap 𝕜 E G →L[𝕜'] ContinuousMultilinearMap 𝕜' E G := LinearMap.mkContinuous { toFun := restrictScalars 𝕜' map_add' := fun m₁ m₂ => rfl map_smul' := fun c m => rfl } 1 fun f => by simp #align continuous_multilinear_map.restrict_scalars_linear ContinuousMultilinearMap.restrictScalarsLinear variable {𝕜'} theorem continuous_restrictScalars : Continuous (restrictScalars 𝕜' : ContinuousMultilinearMap 𝕜 E G → ContinuousMultilinearMap 𝕜' E G) := (restrictScalarsLinear 𝕜').Continuous #align continuous_multilinear_map.continuous_restrict_scalars ContinuousMultilinearMap.continuous_restrictScalars end RestrictScalars /-- The difference `f m₁ - f m₂` is controlled in terms of `‖f‖` and `‖m₁ - m₂‖`, precise version. For a less precise but more usable version, see `norm_image_sub_le`. The bound reads `‖f m - f m'‖ ≤ ‖f‖ * ‖m 1 - m' 1‖ * max ‖m 2‖ ‖m' 2‖ * max ‖m 3‖ ‖m' 3‖ * ... * max ‖m n‖ ‖m' n‖ + ...`, where the other terms in the sum are the same products where `1` is replaced by any `i`.-/ theorem norm_image_sub_le' [DecidableEq ι] (m₁ m₂ : ∀ i, E i) : ‖f m₁ - f m₂‖ ≤ ‖f‖ * ∑ i, ∏ j, if j = i then ‖m₁ i - m₂ i‖ else max ‖m₁ j‖ ‖m₂ j‖ := f.toMultilinearMap.norm_image_sub_le_of_bound' (norm_nonneg _) f.le_op_norm _ _ #align continuous_multilinear_map.norm_image_sub_le' ContinuousMultilinearMap.norm_image_sub_le' /-- The difference `f m₁ - f m₂` is controlled in terms of `‖f‖` and `‖m₁ - m₂‖`, less precise version. For a more precise but less usable version, see `norm_image_sub_le'`. The bound is `‖f m - f m'‖ ≤ ‖f‖ * card ι * ‖m - m'‖ * (max ‖m‖ ‖m'‖) ^ (card ι - 1)`.-/ theorem norm_image_sub_le (m₁ m₂ : ∀ i, E i) : ‖f m₁ - f m₂‖ ≤ ‖f‖ * Fintype.card ι * max ‖m₁‖ ‖m₂‖ ^ (Fintype.card ι - 1) * ‖m₁ - m₂‖ := f.toMultilinearMap.norm_image_sub_le_of_bound (norm_nonneg _) f.le_op_norm _ _ #align continuous_multilinear_map.norm_image_sub_le ContinuousMultilinearMap.norm_image_sub_le /-- Applying a multilinear map to a vector is continuous in both coordinates. -/ theorem continuous_eval : Continuous fun p : ContinuousMultilinearMap 𝕜 E G × ∀ i, E i => p.1 p.2 := by apply continuous_iff_continuousAt.2 fun p => _ apply continuousAt_of_locally_lipschitz zero_lt_one ((‖p‖ + 1) * Fintype.card ι * (‖p‖ + 1) ^ (Fintype.card ι - 1) + ∏ i, ‖p.2 i‖) fun q hq => _ have : 0 ≤ max ‖q.2‖ ‖p.2‖ := by simp have : 0 ≤ ‖p‖ + 1 := zero_le_one.trans ((le_add_iff_nonneg_left 1).2 <| norm_nonneg p) have A : ‖q‖ ≤ ‖p‖ + 1 := norm_le_of_mem_closedBall hq.le have : max ‖q.2‖ ‖p.2‖ ≤ ‖p‖ + 1 := (max_le_max (norm_snd_le q) (norm_snd_le p)).trans (by simp [A, -add_comm, zero_le_one]) have : ∀ i : ι, i ∈ univ → 0 ≤ ‖p.2 i‖ := fun i hi => norm_nonneg _ calc dist (q.1 q.2) (p.1 p.2) ≤ dist (q.1 q.2) (q.1 p.2) + dist (q.1 p.2) (p.1 p.2) := dist_triangle _ _ _ _ = ‖q.1 q.2 - q.1 p.2‖ + ‖q.1 p.2 - p.1 p.2‖ := by rw [dist_eq_norm, dist_eq_norm] _ ≤ ‖q.1‖ * Fintype.card ι * max ‖q.2‖ ‖p.2‖ ^ (Fintype.card ι - 1) * ‖q.2 - p.2‖ + ‖q.1 - p.1‖ * ∏ i, ‖p.2 i‖ := (add_le_add (norm_image_sub_le _ _ _) ((q.1 - p.1).le_op_norm p.2)) _ ≤ (‖p‖ + 1) * Fintype.card ι * (‖p‖ + 1) ^ (Fintype.card ι - 1) * ‖q - p‖ + ‖q - p‖ * ∏ i, ‖p.2 i‖ := by apply_rules [add_le_add, mul_le_mul, le_refl, le_trans (norm_fst_le q) A, Nat.cast_nonneg, mul_nonneg, pow_le_pow_of_le_left, pow_nonneg, norm_snd_le (q - p), norm_nonneg, norm_fst_le (q - p), prod_nonneg] _ = ((‖p‖ + 1) * Fintype.card ι * (‖p‖ + 1) ^ (Fintype.card ι - 1) + ∏ i, ‖p.2 i‖) * dist q p := by rw [dist_eq_norm] ring #align continuous_multilinear_map.continuous_eval ContinuousMultilinearMap.continuous_eval theorem continuous_eval_left (m : ∀ i, E i) : Continuous fun p : ContinuousMultilinearMap 𝕜 E G => p m := continuous_eval.comp (continuous_id.prod_mk continuous_const) #align continuous_multilinear_map.continuous_eval_left ContinuousMultilinearMap.continuous_eval_left theorem hasSum_eval {α : Type _} {p : α → ContinuousMultilinearMap 𝕜 E G} {q : ContinuousMultilinearMap 𝕜 E G} (h : HasSum p q) (m : ∀ i, E i) : HasSum (fun a => p a m) (q m) := by dsimp [HasSum] at h⊢ convert((continuous_eval_left m).Tendsto _).comp h ext s simp #align continuous_multilinear_map.has_sum_eval ContinuousMultilinearMap.hasSum_eval theorem tsum_eval {α : Type _} {p : α → ContinuousMultilinearMap 𝕜 E G} (hp : Summable p) (m : ∀ i, E i) : (∑' a, p a) m = ∑' a, p a m := (hasSum_eval hp.HasSum m).tsum_eq.symm #align continuous_multilinear_map.tsum_eval ContinuousMultilinearMap.tsum_eval open Topology open Filter /-- If the target space is complete, the space of continuous multilinear maps with its norm is also complete. The proof is essentially the same as for the space of continuous linear maps (modulo the addition of `finset.prod` where needed. The duplication could be avoided by deducing the linear case from the multilinear case via a currying isomorphism. However, this would mess up imports, and it is more satisfactory to have the simplest case as a standalone proof. -/ instance [CompleteSpace G] : CompleteSpace (ContinuousMultilinearMap 𝕜 E G) := by have nonneg : ∀ v : ∀ i, E i, 0 ≤ ∏ i, ‖v i‖ := fun v => Finset.prod_nonneg fun i hi => norm_nonneg _ -- We show that every Cauchy sequence converges. refine' Metric.complete_of_cauchySeq_tendsto fun f hf => _ -- We now expand out the definition of a Cauchy sequence, rcases cauchySeq_iff_le_tendsto_0.1 hf with ⟨b, b0, b_bound, b_lim⟩ -- and establish that the evaluation at any point `v : Π i, E i` is Cauchy. have cau : ∀ v, CauchySeq fun n => f n v := by intro v apply cauchySeq_iff_le_tendsto_0.2 ⟨fun n => b n * ∏ i, ‖v i‖, fun n => _, _, _⟩ · exact mul_nonneg (b0 n) (nonneg v) · intro n m N hn hm rw [dist_eq_norm] apply le_trans ((f n - f m).le_op_norm v) _ exact mul_le_mul_of_nonneg_right (b_bound n m N hn hm) (nonneg v) · simpa using b_lim.mul tendsto_const_nhds -- We assemble the limits points of those Cauchy sequences -- (which exist as `G` is complete) -- into a function which we call `F`. choose F hF using fun v => cauchySeq_tendsto_of_complete (cau v) -- Next, we show that this `F` is multilinear, let Fmult : MultilinearMap 𝕜 E G := { toFun := F map_add' := fun _ v i x y => by skip have A := hF (Function.update v i (x + y)) have B := (hF (Function.update v i x)).add (hF (Function.update v i y)) simp at A B exact tendsto_nhds_unique A B map_smul' := fun _ v i c x => by skip have A := hF (Function.update v i (c • x)) have B := Filter.Tendsto.smul (@tendsto_const_nhds _ ℕ _ c _) (hF (Function.update v i x)) simp at A B exact tendsto_nhds_unique A B } -- and that `F` has norm at most `(b 0 + ‖f 0‖)`. have Fnorm : ∀ v, ‖F v‖ ≤ (b 0 + ‖f 0‖) * ∏ i, ‖v i‖ := by intro v have A : ∀ n, ‖f n v‖ ≤ (b 0 + ‖f 0‖) * ∏ i, ‖v i‖ := by intro n apply le_trans ((f n).le_op_norm _) _ apply mul_le_mul_of_nonneg_right _ (nonneg v) calc ‖f n‖ = ‖f n - f 0 + f 0‖ := by congr 1 abel _ ≤ ‖f n - f 0‖ + ‖f 0‖ := (norm_add_le _ _) _ ≤ b 0 + ‖f 0‖ := by apply add_le_add_right simpa [dist_eq_norm] using b_bound n 0 0 (zero_le _) (zero_le _) exact le_of_tendsto (hF v).norm (eventually_of_forall A) -- Thus `F` is continuous, and we propose that as the limit point of our original Cauchy sequence. let Fcont := Fmult.mk_continuous _ Fnorm use Fcont -- Our last task is to establish convergence to `F` in norm. have : ∀ n, ‖f n - Fcont‖ ≤ b n := by intro n apply op_norm_le_bound _ (b0 n) fun v => _ have A : ∀ᶠ m in at_top, ‖(f n - f m) v‖ ≤ b n * ∏ i, ‖v i‖ := by refine' eventually_at_top.2 ⟨n, fun m hm => _⟩ apply le_trans ((f n - f m).le_op_norm _) _ exact mul_le_mul_of_nonneg_right (b_bound n m n le_rfl hm) (nonneg v) have B : tendsto (fun m => ‖(f n - f m) v‖) at_top (𝓝 ‖(f n - Fcont) v‖) := tendsto.norm (tendsto_const_nhds.sub (hF v)) exact le_of_tendsto B A erw [tendsto_iff_norm_tendsto_zero] exact squeeze_zero (fun n => norm_nonneg _) this b_lim end ContinuousMultilinearMap /-- If a continuous multilinear map is constructed from a multilinear map via the constructor `mk_continuous`, then its norm is bounded by the bound given to the constructor if it is nonnegative. -/ theorem MultilinearMap.mkContinuous_norm_le (f : MultilinearMap 𝕜 E G) {C : ℝ} (hC : 0 ≤ C) (H : ∀ m, ‖f m‖ ≤ C * ∏ i, ‖m i‖) : ‖f.mkContinuous C H‖ ≤ C := ContinuousMultilinearMap.op_norm_le_bound _ hC fun m => H m #align multilinear_map.mk_continuous_norm_le MultilinearMap.mkContinuous_norm_le /-- If a continuous multilinear map is constructed from a multilinear map via the constructor `mk_continuous`, then its norm is bounded by the bound given to the constructor if it is nonnegative. -/ theorem MultilinearMap.mkContinuous_norm_le' (f : MultilinearMap 𝕜 E G) {C : ℝ} (H : ∀ m, ‖f m‖ ≤ C * ∏ i, ‖m i‖) : ‖f.mkContinuous C H‖ ≤ max C 0 := ContinuousMultilinearMap.op_norm_le_bound _ (le_max_right _ _) fun m => (H m).trans <| mul_le_mul_of_nonneg_right (le_max_left _ _) (prod_nonneg fun _ _ => norm_nonneg _) #align multilinear_map.mk_continuous_norm_le' MultilinearMap.mkContinuous_norm_le' namespace ContinuousMultilinearMap /-- Given a continuous multilinear map `f` on `n` variables (parameterized by `fin n`) and a subset `s` of `k` of these variables, one gets a new continuous multilinear map on `fin k` by varying these variables, and fixing the other ones equal to a given value `z`. It is denoted by `f.restr s hk z`, where `hk` is a proof that the cardinality of `s` is `k`. The implicit identification between `fin k` and `s` that we use is the canonical (increasing) bijection. -/ def restr {k n : ℕ} (f : (G[×n]→L[𝕜] G' : _)) (s : Finset (Fin n)) (hk : s.card = k) (z : G) : G[×k]→L[𝕜] G' := (f.toMultilinearMap.restr s hk z).mkContinuous (‖f‖ * ‖z‖ ^ (n - k)) fun v => MultilinearMap.restr_norm_le _ _ _ _ f.le_op_norm _ #align continuous_multilinear_map.restr ContinuousMultilinearMap.restr theorem norm_restr {k n : ℕ} (f : G[×n]→L[𝕜] G') (s : Finset (Fin n)) (hk : s.card = k) (z : G) : ‖f.restr s hk z‖ ≤ ‖f‖ * ‖z‖ ^ (n - k) := by apply MultilinearMap.mkContinuous_norm_le exact mul_nonneg (norm_nonneg _) (pow_nonneg (norm_nonneg _) _) #align continuous_multilinear_map.norm_restr ContinuousMultilinearMap.norm_restr section variable {𝕜 ι} {A : Type _} [NormedCommRing A] [NormedAlgebra 𝕜 A] @[simp] theorem norm_mkPiAlgebra_le [Nonempty ι] : ‖ContinuousMultilinearMap.mkPiAlgebra 𝕜 ι A‖ ≤ 1 := by have := fun f => @op_norm_le_bound 𝕜 ι (fun i => A) A _ _ _ _ _ _ f _ zero_le_one refine' this _ _ intro m simp only [ContinuousMultilinearMap.mkPiAlgebra_apply, one_mul] exact norm_prod_le' _ univ_nonempty _ #align continuous_multilinear_map.norm_mk_pi_algebra_le ContinuousMultilinearMap.norm_mkPiAlgebra_le theorem norm_mkPiAlgebra_of_empty [IsEmpty ι] : ‖ContinuousMultilinearMap.mkPiAlgebra 𝕜 ι A‖ = ‖(1 : A)‖ := by apply le_antisymm · have := fun f => @op_norm_le_bound 𝕜 ι (fun i => A) A _ _ _ _ _ _ f _ (norm_nonneg (1 : A)) refine' this _ _ simp · convert ratio_le_op_norm _ fun _ => (1 : A) simp [eq_empty_of_is_empty (univ : Finset ι)] #align continuous_multilinear_map.norm_mk_pi_algebra_of_empty ContinuousMultilinearMap.norm_mkPiAlgebra_of_empty @[simp] theorem norm_mkPiAlgebra [NormOneClass A] : ‖ContinuousMultilinearMap.mkPiAlgebra 𝕜 ι A‖ = 1 := by cases isEmpty_or_nonempty ι · simp [norm_mk_pi_algebra_of_empty] · refine' le_antisymm norm_mk_pi_algebra_le _ convert ratio_le_op_norm _ fun _ => 1 <;> [skip, infer_instance] simp #align continuous_multilinear_map.norm_mk_pi_algebra ContinuousMultilinearMap.norm_mkPiAlgebra end section variable {𝕜 n} {A : Type _} [NormedRing A] [NormedAlgebra 𝕜 A] theorem norm_mkPiAlgebraFin_succ_le : ‖ContinuousMultilinearMap.mkPiAlgebraFin 𝕜 n.succ A‖ ≤ 1 := by have := fun f => @op_norm_le_bound 𝕜 (Fin n.succ) (fun i => A) A _ _ _ _ _ _ f _ zero_le_one refine' this _ _ intro m simp only [ContinuousMultilinearMap.mkPiAlgebraFin_apply, one_mul, List.ofFn_eq_map, Fin.prod_univ_def, Multiset.coe_map, Multiset.coe_prod] refine' (List.norm_prod_le' _).trans_eq _ · rw [Ne.def, List.map_eq_nil, List.finRange_eq_nil] exact Nat.succ_ne_zero _ rw [List.map_map] #align continuous_multilinear_map.norm_mk_pi_algebra_fin_succ_le ContinuousMultilinearMap.norm_mkPiAlgebraFin_succ_le theorem norm_mkPiAlgebraFin_le_of_pos (hn : 0 < n) : ‖ContinuousMultilinearMap.mkPiAlgebraFin 𝕜 n A‖ ≤ 1 := by obtain ⟨n, rfl⟩ := Nat.exists_eq_succ_of_ne_zero hn.ne' exact norm_mk_pi_algebra_fin_succ_le #align continuous_multilinear_map.norm_mk_pi_algebra_fin_le_of_pos ContinuousMultilinearMap.norm_mkPiAlgebraFin_le_of_pos theorem norm_mkPiAlgebraFin_zero : ‖ContinuousMultilinearMap.mkPiAlgebraFin 𝕜 0 A‖ = ‖(1 : A)‖ := by refine' le_antisymm _ _ · have := fun f => @op_norm_le_bound 𝕜 (Fin 0) (fun i => A) A _ _ _ _ _ _ f _ (norm_nonneg (1 : A)) refine' this _ _ simp · convert ratio_le_op_norm _ fun _ => (1 : A) simp #align continuous_multilinear_map.norm_mk_pi_algebra_fin_zero ContinuousMultilinearMap.norm_mkPiAlgebraFin_zero @[simp] theorem norm_mkPiAlgebraFin [NormOneClass A] : ‖ContinuousMultilinearMap.mkPiAlgebraFin 𝕜 n A‖ = 1 := by cases n · simp [norm_mk_pi_algebra_fin_zero] · refine' le_antisymm norm_mk_pi_algebra_fin_succ_le _ convert ratio_le_op_norm _ fun _ => 1 <;> [skip, infer_instance] simp #align continuous_multilinear_map.norm_mk_pi_algebra_fin ContinuousMultilinearMap.norm_mkPiAlgebraFin end variable (𝕜 ι) /-- The canonical continuous multilinear map on `𝕜^ι`, associating to `m` the product of all the `m i` (multiplied by a fixed reference element `z` in the target module) -/ protected def mkPiField (z : G) : ContinuousMultilinearMap 𝕜 (fun i : ι => 𝕜) G := MultilinearMap.mkContinuous (MultilinearMap.mkPiRing 𝕜 ι z) ‖z‖ fun m => by simp only [MultilinearMap.mkPiRing_apply, norm_smul, norm_prod, mul_comm] #align continuous_multilinear_map.mk_pi_field ContinuousMultilinearMap.mkPiField variable {𝕜 ι} @[simp] theorem mkPiField_apply (z : G) (m : ι → 𝕜) : (ContinuousMultilinearMap.mkPiField 𝕜 ι z : (ι → 𝕜) → G) m = (∏ i, m i) • z := rfl #align continuous_multilinear_map.mk_pi_field_apply ContinuousMultilinearMap.mkPiField_apply theorem mkPiField_apply_one_eq_self (f : ContinuousMultilinearMap 𝕜 (fun i : ι => 𝕜) G) : ContinuousMultilinearMap.mkPiField 𝕜 ι (f fun i => 1) = f := toMultilinearMap_inj f.toMultilinearMap.mkPiRing_apply_one_eq_self #align continuous_multilinear_map.mk_pi_field_apply_one_eq_self ContinuousMultilinearMap.mkPiField_apply_one_eq_self @[simp] theorem norm_mkPiField (z : G) : ‖ContinuousMultilinearMap.mkPiField 𝕜 ι z‖ = ‖z‖ := (MultilinearMap.mkContinuous_norm_le _ (norm_nonneg z) _).antisymm <| by simpa using (ContinuousMultilinearMap.mkPiField 𝕜 ι z).le_op_norm fun _ => 1 #align continuous_multilinear_map.norm_mk_pi_field ContinuousMultilinearMap.norm_mkPiField theorem mkPiField_eq_iff {z₁ z₂ : G} : ContinuousMultilinearMap.mkPiField 𝕜 ι z₁ = ContinuousMultilinearMap.mkPiField 𝕜 ι z₂ ↔ z₁ = z₂ := by rw [← to_multilinear_map_inj.eq_iff] exact MultilinearMap.mkPiRing_eq_iff #align continuous_multilinear_map.mk_pi_field_eq_iff ContinuousMultilinearMap.mkPiField_eq_iff theorem mkPiField_zero : ContinuousMultilinearMap.mkPiField 𝕜 ι (0 : G) = 0 := by ext <;> rw [mk_pi_field_apply, smul_zero, ContinuousMultilinearMap.zero_apply] #align continuous_multilinear_map.mk_pi_field_zero ContinuousMultilinearMap.mkPiField_zero theorem mkPiField_eq_zero_iff (z : G) : ContinuousMultilinearMap.mkPiField 𝕜 ι z = 0 ↔ z = 0 := by rw [← mk_pi_field_zero, mk_pi_field_eq_iff] #align continuous_multilinear_map.mk_pi_field_eq_zero_iff ContinuousMultilinearMap.mkPiField_eq_zero_iff variable (𝕜 ι G) /-- Continuous multilinear maps on `𝕜^n` with values in `G` are in bijection with `G`, as such a continuous multilinear map is completely determined by its value on the constant vector made of ones. We register this bijection as a linear isometry in `continuous_multilinear_map.pi_field_equiv`. -/ protected def piFieldEquiv : G ≃ₗᵢ[𝕜] ContinuousMultilinearMap 𝕜 (fun i : ι => 𝕜) G where toFun z := ContinuousMultilinearMap.mkPiField 𝕜 ι z invFun f := f fun i => 1 map_add' z z' := by ext m simp [smul_add] map_smul' c z := by ext m simp [smul_smul, mul_comm] left_inv z := by simp right_inv f := f.mkPiField_apply_one_eq_self norm_map' := norm_mkPiField #align continuous_multilinear_map.pi_field_equiv ContinuousMultilinearMap.piFieldEquiv end ContinuousMultilinearMap namespace ContinuousLinearMap theorem norm_compContinuousMultilinearMap_le (g : G →L[𝕜] G') (f : ContinuousMultilinearMap 𝕜 E G) : ‖g.compContinuousMultilinearMap f‖ ≤ ‖g‖ * ‖f‖ := ContinuousMultilinearMap.op_norm_le_bound _ (mul_nonneg (norm_nonneg _) (norm_nonneg _)) fun m => calc ‖g (f m)‖ ≤ ‖g‖ * (‖f‖ * ∏ i, ‖m i‖) := g.le_op_norm_of_le <| f.le_op_norm _ _ = _ := (mul_assoc _ _ _).symm #align continuous_linear_map.norm_comp_continuous_multilinear_map_le ContinuousLinearMap.norm_compContinuousMultilinearMap_le variable (𝕜 E G G') /-- `continuous_linear_map.comp_continuous_multilinear_map` as a bundled continuous bilinear map. -/ def compContinuousMultilinearMapL : (G →L[𝕜] G') →L[𝕜] ContinuousMultilinearMap 𝕜 E G →L[𝕜] ContinuousMultilinearMap 𝕜 E G' := LinearMap.mkContinuous₂ (LinearMap.mk₂ 𝕜 compContinuousMultilinearMap (fun f₁ f₂ g => rfl) (fun c f g => rfl) (fun f g₁ g₂ => by ext1 apply f.map_add) fun c f g => by ext1 simp) 1 fun f g => by rw [one_mul] exact f.norm_comp_continuous_multilinear_map_le g #align continuous_linear_map.comp_continuous_multilinear_mapL ContinuousLinearMap.compContinuousMultilinearMapL variable {𝕜 G G'} /-- `continuous_linear_map.comp_continuous_multilinear_map` as a bundled continuous linear equiv. -/ def ContinuousLinearEquiv.compContinuousMultilinearMapL (g : G ≃L[𝕜] G') : ContinuousMultilinearMap 𝕜 E G ≃L[𝕜] ContinuousMultilinearMap 𝕜 E G' := { compContinuousMultilinearMapL 𝕜 _ _ _ g.toContinuousLinearMap with invFun := compContinuousMultilinearMapL 𝕜 _ _ _ g.symm.toContinuousLinearMap left_inv := by intro f ext1 m simp only [comp_continuous_multilinear_mapL, ContinuousLinearEquiv.coe_def_rev, to_linear_map_eq_coe, LinearMap.toFun_eq_coe, coe_coe, LinearMap.mkContinuous₂_apply, LinearMap.mk₂_apply, comp_continuous_multilinear_map_coe, ContinuousLinearEquiv.coe_coe, Function.comp_apply, ContinuousLinearEquiv.symm_apply_apply] right_inv := by intro f ext1 m simp only [comp_continuous_multilinear_mapL, ContinuousLinearEquiv.coe_def_rev, to_linear_map_eq_coe, LinearMap.mkContinuous₂_apply, LinearMap.mk₂_apply, LinearMap.toFun_eq_coe, coe_coe, comp_continuous_multilinear_map_coe, ContinuousLinearEquiv.coe_coe, Function.comp_apply, ContinuousLinearEquiv.apply_symm_apply] continuous_toFun := (compContinuousMultilinearMapL 𝕜 _ _ _ g.toContinuousLinearMap).Continuous continuous_invFun := (compContinuousMultilinearMapL 𝕜 _ _ _ g.symm.toContinuousLinearMap).Continuous } #align continuous_linear_equiv.comp_continuous_multilinear_mapL ContinuousLinearEquiv.compContinuousMultilinearMapL @[simp] theorem ContinuousLinearEquiv.compContinuousMultilinearMapL_symm (g : G ≃L[𝕜] G') : (g.compContinuousMultilinearMapL E).symm = g.symm.compContinuousMultilinearMapL E := rfl #align continuous_linear_equiv.comp_continuous_multilinear_mapL_symm ContinuousLinearEquiv.compContinuousMultilinearMapL_symm variable {E} @[simp] theorem ContinuousLinearEquiv.compContinuousMultilinearMapL_apply (g : G ≃L[𝕜] G') (f : ContinuousMultilinearMap 𝕜 E G) : g.compContinuousMultilinearMapL E f = (g : G →L[𝕜] G').compContinuousMultilinearMap f := rfl #align continuous_linear_equiv.comp_continuous_multilinear_mapL_apply ContinuousLinearEquiv.compContinuousMultilinearMapL_apply /-- Flip arguments in `f : G →L[𝕜] continuous_multilinear_map 𝕜 E G'` to get `continuous_multilinear_map 𝕜 E (G →L[𝕜] G')` -/ def flipMultilinear (f : G →L[𝕜] ContinuousMultilinearMap 𝕜 E G') : ContinuousMultilinearMap 𝕜 E (G →L[𝕜] G') := MultilinearMap.mkContinuous { toFun := fun m => LinearMap.mkContinuous { toFun := fun x => f x m map_add' := fun x y => by simp only [map_add, ContinuousMultilinearMap.add_apply] map_smul' := fun c x => by simp only [ContinuousMultilinearMap.smul_apply, map_smul, RingHom.id_apply] } (‖f‖ * ∏ i, ‖m i‖) fun x => by rw [mul_right_comm] exact (f x).le_of_op_norm_le _ (f.le_op_norm x) map_add' := fun _ m i x y => by ext1 simp only [add_apply, ContinuousMultilinearMap.map_add, LinearMap.coe_mk, LinearMap.mkContinuous_apply] map_smul' := fun _ m i c x => by ext1 simp only [coe_smul', ContinuousMultilinearMap.map_smul, LinearMap.coe_mk, LinearMap.mkContinuous_apply, Pi.smul_apply] } ‖f‖ fun m => LinearMap.mkContinuous_norm_le _ (mul_nonneg (norm_nonneg f) (prod_nonneg fun i hi => norm_nonneg (m i))) _ #align continuous_linear_map.flip_multilinear ContinuousLinearMap.flipMultilinear end ContinuousLinearMap theorem LinearIsometry.norm_compContinuousMultilinearMap (g : G →ₗᵢ[𝕜] G') (f : ContinuousMultilinearMap 𝕜 E G) : ‖g.toContinuousLinearMap.compContinuousMultilinearMap f‖ = ‖f‖ := by simp only [ContinuousLinearMap.compContinuousMultilinearMap_coe, LinearIsometry.coe_toContinuousLinearMap, LinearIsometry.norm_map, ContinuousMultilinearMap.norm_def] #align linear_isometry.norm_comp_continuous_multilinear_map LinearIsometry.norm_compContinuousMultilinearMap open ContinuousMultilinearMap namespace MultilinearMap /-- Given a map `f : G →ₗ[𝕜] multilinear_map 𝕜 E G'` and an estimate `H : ∀ x m, ‖f x m‖ ≤ C * ‖x‖ * ∏ i, ‖m i‖`, construct a continuous linear map from `G` to `continuous_multilinear_map 𝕜 E G'`. In order to lift, e.g., a map `f : (multilinear_map 𝕜 E G) →ₗ[𝕜] multilinear_map 𝕜 E' G'` to a map `(continuous_multilinear_map 𝕜 E G) →L[𝕜] continuous_multilinear_map 𝕜 E' G'`, one can apply this construction to `f.comp continuous_multilinear_map.to_multilinear_map_linear` which is a linear map from `continuous_multilinear_map 𝕜 E G` to `multilinear_map 𝕜 E' G'`. -/ def mkContinuousLinear (f : G →ₗ[𝕜] MultilinearMap 𝕜 E G') (C : ℝ) (H : ∀ x m, ‖f x m‖ ≤ C * ‖x‖ * ∏ i, ‖m i‖) : G →L[𝕜] ContinuousMultilinearMap 𝕜 E G' := LinearMap.mkContinuous { toFun := fun x => (f x).mkContinuous (C * ‖x‖) <| H x map_add' := fun x y => by ext1 simp only [_root_.map_add] rfl map_smul' := fun c x => by ext1 simp only [SMulHomClass.map_smul] rfl } (max C 0) fun x => ((f x).mkContinuous_norm_le' _).trans_eq <| by rw [max_mul_of_nonneg _ _ (norm_nonneg x), MulZeroClass.zero_mul] #align multilinear_map.mk_continuous_linear MultilinearMap.mkContinuousLinear theorem mkContinuousLinear_norm_le' (f : G →ₗ[𝕜] MultilinearMap 𝕜 E G') (C : ℝ) (H : ∀ x m, ‖f x m‖ ≤ C * ‖x‖ * ∏ i, ‖m i‖) : ‖mkContinuousLinear f C H‖ ≤ max C 0 := by dsimp only [mk_continuous_linear] exact LinearMap.mkContinuous_norm_le _ (le_max_right _ _) _ #align multilinear_map.mk_continuous_linear_norm_le' MultilinearMap.mkContinuousLinear_norm_le' theorem mkContinuousLinear_norm_le (f : G →ₗ[𝕜] MultilinearMap 𝕜 E G') {C : ℝ} (hC : 0 ≤ C) (H : ∀ x m, ‖f x m‖ ≤ C * ‖x‖ * ∏ i, ‖m i‖) : ‖mkContinuousLinear f C H‖ ≤ C := (mkContinuousLinear_norm_le' f C H).trans_eq (max_eq_left hC) #align multilinear_map.mk_continuous_linear_norm_le MultilinearMap.mkContinuousLinear_norm_le /-- Given a map `f : multilinear_map 𝕜 E (multilinear_map 𝕜 E' G)` and an estimate `H : ∀ m m', ‖f m m'‖ ≤ C * ∏ i, ‖m i‖ * ∏ i, ‖m' i‖`, upgrade all `multilinear_map`s in the type to `continuous_multilinear_map`s. -/ def mkContinuousMultilinear (f : MultilinearMap 𝕜 E (MultilinearMap 𝕜 E' G)) (C : ℝ) (H : ∀ m₁ m₂, ‖f m₁ m₂‖ ≤ (C * ∏ i, ‖m₁ i‖) * ∏ i, ‖m₂ i‖) : ContinuousMultilinearMap 𝕜 E (ContinuousMultilinearMap 𝕜 E' G) := mkContinuous { toFun := fun m => mkContinuous (f m) (C * ∏ i, ‖m i‖) <| H m map_add' := fun _ m i x y => by ext1 simp map_smul' := fun _ m i c x => by ext1 simp } (max C 0) fun m => ((f m).mkContinuous_norm_le' _).trans_eq <| by rw [max_mul_of_nonneg, MulZeroClass.zero_mul] exact prod_nonneg fun _ _ => norm_nonneg _ #align multilinear_map.mk_continuous_multilinear MultilinearMap.mkContinuousMultilinear @[simp] theorem mkContinuousMultilinear_apply (f : MultilinearMap 𝕜 E (MultilinearMap 𝕜 E' G)) {C : ℝ} (H : ∀ m₁ m₂, ‖f m₁ m₂‖ ≤ (C * ∏ i, ‖m₁ i‖) * ∏ i, ‖m₂ i‖) (m : ∀ i, E i) : ⇑(mkContinuousMultilinear f C H m) = f m := rfl #align multilinear_map.mk_continuous_multilinear_apply MultilinearMap.mkContinuousMultilinear_apply theorem mkContinuousMultilinear_norm_le' (f : MultilinearMap 𝕜 E (MultilinearMap 𝕜 E' G)) (C : ℝ) (H : ∀ m₁ m₂, ‖f m₁ m₂‖ ≤ (C * ∏ i, ‖m₁ i‖) * ∏ i, ‖m₂ i‖) : ‖mkContinuousMultilinear f C H‖ ≤ max C 0 := by dsimp only [mk_continuous_multilinear] exact mk_continuous_norm_le _ (le_max_right _ _) _ #align multilinear_map.mk_continuous_multilinear_norm_le' MultilinearMap.mkContinuousMultilinear_norm_le' theorem mkContinuousMultilinear_norm_le (f : MultilinearMap 𝕜 E (MultilinearMap 𝕜 E' G)) {C : ℝ} (hC : 0 ≤ C) (H : ∀ m₁ m₂, ‖f m₁ m₂‖ ≤ (C * ∏ i, ‖m₁ i‖) * ∏ i, ‖m₂ i‖) : ‖mkContinuousMultilinear f C H‖ ≤ C := (mkContinuousMultilinear_norm_le' f C H).trans_eq (max_eq_left hC) #align multilinear_map.mk_continuous_multilinear_norm_le MultilinearMap.mkContinuousMultilinear_norm_le end MultilinearMap namespace ContinuousMultilinearMap theorem norm_comp_continuous_linear_le (g : ContinuousMultilinearMap 𝕜 E₁ G) (f : ∀ i, E i →L[𝕜] E₁ i) : ‖g.compContinuousLinearMap f‖ ≤ ‖g‖ * ∏ i, ‖f i‖ := op_norm_le_bound _ (mul_nonneg (norm_nonneg _) <| prod_nonneg fun i hi => norm_nonneg _) fun m => calc ‖g fun i => f i (m i)‖ ≤ ‖g‖ * ∏ i, ‖f i (m i)‖ := g.le_op_norm _ _ ≤ ‖g‖ * ∏ i, ‖f i‖ * ‖m i‖ := (mul_le_mul_of_nonneg_left (prod_le_prod (fun _ _ => norm_nonneg _) fun i hi => (f i).le_op_norm (m i)) (norm_nonneg g)) _ = (‖g‖ * ∏ i, ‖f i‖) * ∏ i, ‖m i‖ := by rw [prod_mul_distrib, mul_assoc] #align continuous_multilinear_map.norm_comp_continuous_linear_le ContinuousMultilinearMap.norm_comp_continuous_linear_le theorem norm_comp_continuous_linearIsometry_le (g : ContinuousMultilinearMap 𝕜 E₁ G) (f : ∀ i, E i →ₗᵢ[𝕜] E₁ i) : ‖g.compContinuousLinearMap fun i => (f i).toContinuousLinearMap‖ ≤ ‖g‖ := by apply op_norm_le_bound _ (norm_nonneg _) fun m => _ apply (g.le_op_norm _).trans _ simp only [ContinuousLinearMap.toLinearMap_eq_coe, ContinuousLinearMap.coe_coe, LinearIsometry.coe_toContinuousLinearMap, LinearIsometry.norm_map] #align continuous_multilinear_map.norm_comp_continuous_linear_isometry_le ContinuousMultilinearMap.norm_comp_continuous_linearIsometry_le theorem norm_comp_continuous_linearIsometryEquiv (g : ContinuousMultilinearMap 𝕜 E₁ G) (f : ∀ i, E i ≃ₗᵢ[𝕜] E₁ i) : ‖g.compContinuousLinearMap fun i => (f i : E i →L[𝕜] E₁ i)‖ = ‖g‖ := by apply le_antisymm (g.norm_comp_continuous_linear_isometry_le fun i => (f i).toLinearIsometry) have : g = (g.comp_continuous_linear_map fun i => (f i : E i →L[𝕜] E₁ i)).compContinuousLinearMap fun i => ((f i).symm : E₁ i →L[𝕜] E i) := by ext1 m simp only [comp_continuous_linear_map_apply, LinearIsometryEquiv.coe_coe'', LinearIsometryEquiv.apply_symm_apply] conv_lhs => rw [this] apply (g.comp_continuous_linear_map fun i => (f i : E i →L[𝕜] E₁ i)).norm_comp_continuous_linearIsometry_le fun i => (f i).symm.toLinearIsometry #align continuous_multilinear_map.norm_comp_continuous_linear_isometry_equiv ContinuousMultilinearMap.norm_comp_continuous_linearIsometryEquiv /-- `continuous_multilinear_map.comp_continuous_linear_map` as a bundled continuous linear map. This implementation fixes `f : Π i, E i →L[𝕜] E₁ i`. TODO: Actually, the map is multilinear in `f` but an attempt to formalize this failed because of issues with class instances. -/ def compContinuousLinearMapL (f : ∀ i, E i →L[𝕜] E₁ i) : ContinuousMultilinearMap 𝕜 E₁ G →L[𝕜] ContinuousMultilinearMap 𝕜 E G := LinearMap.mkContinuous { toFun := fun g => g.compContinuousLinearMap f map_add' := fun g₁ g₂ => rfl map_smul' := fun c g => rfl } (∏ i, ‖f i‖) fun g => (norm_comp_continuous_linear_le _ _).trans_eq (mul_comm _ _) #align continuous_multilinear_map.comp_continuous_linear_mapL ContinuousMultilinearMap.compContinuousLinearMapL @[simp] theorem compContinuousLinearMapL_apply (g : ContinuousMultilinearMap 𝕜 E₁ G) (f : ∀ i, E i →L[𝕜] E₁ i) : compContinuousLinearMapL f g = g.compContinuousLinearMap f := rfl #align continuous_multilinear_map.comp_continuous_linear_mapL_apply ContinuousMultilinearMap.compContinuousLinearMapL_apply theorem norm_compContinuousLinearMapL_le (f : ∀ i, E i →L[𝕜] E₁ i) : ‖@compContinuousLinearMapL 𝕜 ι E E₁ G _ _ _ _ _ _ _ _ f‖ ≤ ∏ i, ‖f i‖ := LinearMap.mkContinuous_norm_le _ (prod_nonneg fun i _ => norm_nonneg _) _ #align continuous_multilinear_map.norm_comp_continuous_linear_mapL_le ContinuousMultilinearMap.norm_compContinuousLinearMapL_le variable (G) /-- `continuous_multilinear_map.comp_continuous_linear_map` as a bundled continuous linear equiv, given `f : Π i, E i ≃L[𝕜] E₁ i`. -/ def compContinuousLinearMapEquivL (f : ∀ i, E i ≃L[𝕜] E₁ i) : ContinuousMultilinearMap 𝕜 E₁ G ≃L[𝕜] ContinuousMultilinearMap 𝕜 E G := { compContinuousLinearMapL fun i => (f i : E i →L[𝕜] E₁ i) with invFun := compContinuousLinearMapL fun i => ((f i).symm : E₁ i →L[𝕜] E i) continuous_toFun := (compContinuousLinearMapL fun i => (f i : E i →L[𝕜] E₁ i)).Continuous continuous_invFun := (compContinuousLinearMapL fun i => ((f i).symm : E₁ i →L[𝕜] E i)).Continuous left_inv := by intro g ext1 m simp only [ContinuousLinearMap.toLinearMap_eq_coe, LinearMap.toFun_eq_coe, ContinuousLinearMap.coe_coe, comp_continuous_linear_mapL_apply, comp_continuous_linear_map_apply, ContinuousLinearEquiv.coe_coe, ContinuousLinearEquiv.apply_symm_apply] right_inv := by intro g ext1 m simp only [ContinuousLinearMap.toLinearMap_eq_coe, comp_continuous_linear_mapL_apply, LinearMap.toFun_eq_coe, ContinuousLinearMap.coe_coe, comp_continuous_linear_map_apply, ContinuousLinearEquiv.coe_coe, ContinuousLinearEquiv.symm_apply_apply] } #align continuous_multilinear_map.comp_continuous_linear_map_equivL ContinuousMultilinearMap.compContinuousLinearMapEquivL @[simp] theorem compContinuousLinearMapEquivL_symm (f : ∀ i, E i ≃L[𝕜] E₁ i) : (compContinuousLinearMapEquivL G f).symm = compContinuousLinearMapEquivL G fun i : ι => (f i).symm := rfl #align continuous_multilinear_map.comp_continuous_linear_map_equivL_symm ContinuousMultilinearMap.compContinuousLinearMapEquivL_symm variable {G} @[simp] theorem compContinuousLinearMapEquivL_apply (g : ContinuousMultilinearMap 𝕜 E₁ G) (f : ∀ i, E i ≃L[𝕜] E₁ i) : compContinuousLinearMapEquivL G f g = g.compContinuousLinearMap fun i => (f i : E i →L[𝕜] E₁ i) := rfl #align continuous_multilinear_map.comp_continuous_linear_map_equivL_apply ContinuousMultilinearMap.compContinuousLinearMapEquivL_apply end ContinuousMultilinearMap section Smul variable {R : Type _} [Semiring R] [Module R G] [SMulCommClass 𝕜 R G] [ContinuousConstSMul R G] instance : ContinuousConstSMul R (ContinuousMultilinearMap 𝕜 E G) := ⟨fun c => (ContinuousLinearMap.compContinuousMultilinearMapL 𝕜 _ G G (c • ContinuousLinearMap.id 𝕜 G)).2⟩ end Smul section Currying /-! ### Currying We associate to a continuous multilinear map in `n+1` variables (i.e., based on `fin n.succ`) two curried functions, named `f.curry_left` (which is a continuous linear map on `E 0` taking values in continuous multilinear maps in `n` variables) and `f.curry_right` (which is a continuous multilinear map in `n` variables taking values in continuous linear maps on `E (last n)`). The inverse operations are called `uncurry_left` and `uncurry_right`. We also register continuous linear equiv versions of these correspondences, in `continuous_multilinear_curry_left_equiv` and `continuous_multilinear_curry_right_equiv`. -/ open Fin Function theorem ContinuousLinearMap.norm_map_tail_le (f : Ei 0 →L[𝕜] ContinuousMultilinearMap 𝕜 (fun i : Fin n => Ei i.succ) G) (m : ∀ i, Ei i) : ‖f (m 0) (tail m)‖ ≤ ‖f‖ * ∏ i, ‖m i‖ := calc ‖f (m 0) (tail m)‖ ≤ ‖f (m 0)‖ * ∏ i, ‖(tail m) i‖ := (f (m 0)).le_op_norm _ _ ≤ ‖f‖ * ‖m 0‖ * ∏ i, ‖(tail m) i‖ := (mul_le_mul_of_nonneg_right (f.le_op_norm _) (prod_nonneg fun i hi => norm_nonneg _)) _ = ‖f‖ * (‖m 0‖ * ∏ i, ‖(tail m) i‖) := by ring _ = ‖f‖ * ∏ i, ‖m i‖ := by rw [prod_univ_succ] rfl #align continuous_linear_map.norm_map_tail_le ContinuousLinearMap.norm_map_tail_le theorem ContinuousMultilinearMap.norm_map_init_le (f : ContinuousMultilinearMap 𝕜 (fun i : Fin n => Ei i.cast_succ) (Ei (last n) →L[𝕜] G)) (m : ∀ i, Ei i) : ‖f (init m) (m (last n))‖ ≤ ‖f‖ * ∏ i, ‖m i‖ := calc ‖f (init m) (m (last n))‖ ≤ ‖f (init m)‖ * ‖m (last n)‖ := (f (init m)).le_op_norm _ _ ≤ (‖f‖ * ∏ i, ‖(init m) i‖) * ‖m (last n)‖ := (mul_le_mul_of_nonneg_right (f.le_op_norm _) (norm_nonneg _)) _ = ‖f‖ * ((∏ i, ‖(init m) i‖) * ‖m (last n)‖) := (mul_assoc _ _ _) _ = ‖f‖ * ∏ i, ‖m i‖ := by rw [prod_univ_cast_succ] rfl #align continuous_multilinear_map.norm_map_init_le ContinuousMultilinearMap.norm_map_init_le theorem ContinuousMultilinearMap.norm_map_cons_le (f : ContinuousMultilinearMap 𝕜 Ei G) (x : Ei 0) (m : ∀ i : Fin n, Ei i.succ) : ‖f (cons x m)‖ ≤ ‖f‖ * ‖x‖ * ∏ i, ‖m i‖ := calc ‖f (cons x m)‖ ≤ ‖f‖ * ∏ i, ‖cons x m i‖ := f.le_op_norm _ _ = ‖f‖ * ‖x‖ * ∏ i, ‖m i‖ := by rw [prod_univ_succ] simp [mul_assoc] #align continuous_multilinear_map.norm_map_cons_le ContinuousMultilinearMap.norm_map_cons_le theorem ContinuousMultilinearMap.norm_map_snoc_le (f : ContinuousMultilinearMap 𝕜 Ei G) (m : ∀ i : Fin n, Ei i.cast_succ) (x : Ei (last n)) : ‖f (snoc m x)‖ ≤ (‖f‖ * ∏ i, ‖m i‖) * ‖x‖ := calc ‖f (snoc m x)‖ ≤ ‖f‖ * ∏ i, ‖snoc m x i‖ := f.le_op_norm _ _ = (‖f‖ * ∏ i, ‖m i‖) * ‖x‖ := by rw [prod_univ_cast_succ] simp [mul_assoc] #align continuous_multilinear_map.norm_map_snoc_le ContinuousMultilinearMap.norm_map_snoc_le /-! #### Left currying -/ /-- Given a continuous linear map `f` from `E 0` to continuous multilinear maps on `n` variables, construct the corresponding continuous multilinear map on `n+1` variables obtained by concatenating the variables, given by `m ↦ f (m 0) (tail m)`-/ def ContinuousLinearMap.uncurryLeft (f : Ei 0 →L[𝕜] ContinuousMultilinearMap 𝕜 (fun i : Fin n => Ei i.succ) G) : ContinuousMultilinearMap 𝕜 Ei G := (@LinearMap.uncurryLeft 𝕜 n Ei G _ _ _ _ _ (ContinuousMultilinearMap.toMultilinearMapLinear.comp f.toLinearMap)).mkContinuous ‖f‖ fun m => ContinuousLinearMap.norm_map_tail_le f m #align continuous_linear_map.uncurry_left ContinuousLinearMap.uncurryLeft @[simp] theorem ContinuousLinearMap.uncurryLeft_apply (f : Ei 0 →L[𝕜] ContinuousMultilinearMap 𝕜 (fun i : Fin n => Ei i.succ) G) (m : ∀ i, Ei i) : f.uncurryLeft m = f (m 0) (tail m) := rfl #align continuous_linear_map.uncurry_left_apply ContinuousLinearMap.uncurryLeft_apply /-- Given a continuous multilinear map `f` in `n+1` variables, split the first variable to obtain a continuous linear map into continuous multilinear maps in `n` variables, given by `x ↦ (m ↦ f (cons x m))`. -/ def ContinuousMultilinearMap.curryLeft (f : ContinuousMultilinearMap 𝕜 Ei G) : Ei 0 →L[𝕜] ContinuousMultilinearMap 𝕜 (fun i : Fin n => Ei i.succ) G := LinearMap.mkContinuous { -- define a linear map into `n` continuous multilinear maps from an `n+1` continuous multilinear -- map toFun := fun x => (f.toMultilinearMap.curryLeft x).mkContinuous (‖f‖ * ‖x‖) (f.norm_map_cons_le x) map_add' := fun x y => by ext m exact f.cons_add m x y map_smul' := fun c x => by ext m exact f.cons_smul m c x }-- then register its continuity thanks to its boundedness properties. ‖f‖ fun x => MultilinearMap.mkContinuous_norm_le _ (mul_nonneg (norm_nonneg _) (norm_nonneg _)) _ #align continuous_multilinear_map.curry_left ContinuousMultilinearMap.curryLeft @[simp] theorem ContinuousMultilinearMap.curryLeft_apply (f : ContinuousMultilinearMap 𝕜 Ei G) (x : Ei 0) (m : ∀ i : Fin n, Ei i.succ) : f.curryLeft x m = f (cons x m) := rfl #align continuous_multilinear_map.curry_left_apply ContinuousMultilinearMap.curryLeft_apply @[simp] theorem ContinuousLinearMap.curry_uncurryLeft (f : Ei 0 →L[𝕜] ContinuousMultilinearMap 𝕜 (fun i : Fin n => Ei i.succ) G) : f.uncurryLeft.curryLeft = f := by ext (m x) simp only [tail_cons, ContinuousLinearMap.uncurryLeft_apply, ContinuousMultilinearMap.curryLeft_apply] rw [cons_zero] #align continuous_linear_map.curry_uncurry_left ContinuousLinearMap.curry_uncurryLeft @[simp] theorem ContinuousMultilinearMap.uncurry_curryLeft (f : ContinuousMultilinearMap 𝕜 Ei G) : f.curryLeft.uncurryLeft = f := ContinuousMultilinearMap.toMultilinearMap_inj <| f.toMultilinearMap.uncurry_curryLeft #align continuous_multilinear_map.uncurry_curry_left ContinuousMultilinearMap.uncurry_curryLeft variable (𝕜 Ei G) /-- The space of continuous multilinear maps on `Π(i : fin (n+1)), E i` is canonically isomorphic to the space of continuous linear maps from `E 0` to the space of continuous multilinear maps on `Π(i : fin n), E i.succ `, by separating the first variable. We register this isomorphism in `continuous_multilinear_curry_left_equiv 𝕜 E E₂`. The algebraic version (without topology) is given in `multilinear_curry_left_equiv 𝕜 E E₂`. The direct and inverse maps are given by `f.uncurry_left` and `f.curry_left`. Use these unless you need the full framework of linear isometric equivs. -/ def continuousMultilinearCurryLeftEquiv : (Ei 0 →L[𝕜] ContinuousMultilinearMap 𝕜 (fun i : Fin n => Ei i.succ) G) ≃ₗᵢ[𝕜] ContinuousMultilinearMap 𝕜 Ei G := LinearIsometryEquiv.ofBounds { toFun := ContinuousLinearMap.uncurryLeft map_add' := fun f₁ f₂ => by ext m rfl map_smul' := fun c f => by ext m rfl invFun := ContinuousMultilinearMap.curryLeft left_inv := ContinuousLinearMap.curry_uncurryLeft right_inv := ContinuousMultilinearMap.uncurry_curryLeft } (fun f => MultilinearMap.mkContinuous_norm_le _ (norm_nonneg f) _) fun f => LinearMap.mkContinuous_norm_le _ (norm_nonneg f) _ #align continuous_multilinear_curry_left_equiv continuousMultilinearCurryLeftEquiv variable {𝕜 Ei G} @[simp] theorem continuousMultilinearCurryLeftEquiv_apply (f : Ei 0 →L[𝕜] ContinuousMultilinearMap 𝕜 (fun i : Fin n => Ei i.succ) G) (v : ∀ i, Ei i) : continuousMultilinearCurryLeftEquiv 𝕜 Ei G f v = f (v 0) (tail v) := rfl #align continuous_multilinear_curry_left_equiv_apply continuousMultilinearCurryLeftEquiv_apply @[simp] theorem continuousMultilinearCurryLeftEquiv_symm_apply (f : ContinuousMultilinearMap 𝕜 Ei G) (x : Ei 0) (v : ∀ i : Fin n, Ei i.succ) : (continuousMultilinearCurryLeftEquiv 𝕜 Ei G).symm f x v = f (cons x v) := rfl #align continuous_multilinear_curry_left_equiv_symm_apply continuousMultilinearCurryLeftEquiv_symm_apply @[simp] theorem ContinuousMultilinearMap.curryLeft_norm (f : ContinuousMultilinearMap 𝕜 Ei G) : ‖f.curryLeft‖ = ‖f‖ := (continuousMultilinearCurryLeftEquiv 𝕜 Ei G).symm.norm_map f #align continuous_multilinear_map.curry_left_norm ContinuousMultilinearMap.curryLeft_norm @[simp] theorem ContinuousLinearMap.uncurryLeft_norm (f : Ei 0 →L[𝕜] ContinuousMultilinearMap 𝕜 (fun i : Fin n => Ei i.succ) G) : ‖f.uncurryLeft‖ = ‖f‖ := (continuousMultilinearCurryLeftEquiv 𝕜 Ei G).norm_map f #align continuous_linear_map.uncurry_left_norm ContinuousLinearMap.uncurryLeft_norm /-! #### Right currying -/ /-- Given a continuous linear map `f` from continuous multilinear maps on `n` variables to continuous linear maps on `E 0`, construct the corresponding continuous multilinear map on `n+1` variables obtained by concatenating the variables, given by `m ↦ f (init m) (m (last n))`. -/ def ContinuousMultilinearMap.uncurryRight (f : ContinuousMultilinearMap 𝕜 (fun i : Fin n => Ei i.cast_succ) (Ei (last n) →L[𝕜] G)) : ContinuousMultilinearMap 𝕜 Ei G := let f' : MultilinearMap 𝕜 (fun i : Fin n => Ei i.cast_succ) (Ei (last n) →ₗ[𝕜] G) := { toFun := fun m => (f m).toLinearMap map_add' := fun _ m i x y => by simp map_smul' := fun _ m i c x => by simp } (@MultilinearMap.uncurryRight 𝕜 n Ei G _ _ _ _ _ f').mkContinuous ‖f‖ fun m => f.norm_map_init_le m #align continuous_multilinear_map.uncurry_right ContinuousMultilinearMap.uncurryRight @[simp] theorem ContinuousMultilinearMap.uncurryRight_apply (f : ContinuousMultilinearMap 𝕜 (fun i : Fin n => Ei i.cast_succ) (Ei (last n) →L[𝕜] G)) (m : ∀ i, Ei i) : f.uncurryRight m = f (init m) (m (last n)) := rfl #align continuous_multilinear_map.uncurry_right_apply ContinuousMultilinearMap.uncurryRight_apply /-- Given a continuous multilinear map `f` in `n+1` variables, split the last variable to obtain a continuous multilinear map in `n` variables into continuous linear maps, given by `m ↦ (x ↦ f (snoc m x))`. -/ def ContinuousMultilinearMap.curryRight (f : ContinuousMultilinearMap 𝕜 Ei G) : ContinuousMultilinearMap 𝕜 (fun i : Fin n => Ei i.cast_succ) (Ei (last n) →L[𝕜] G) := let f' : MultilinearMap 𝕜 (fun i : Fin n => Ei i.cast_succ) (Ei (last n) →L[𝕜] G) := { toFun := fun m => (f.toMultilinearMap.curryRight m).mkContinuous (‖f‖ * ∏ i, ‖m i‖) fun x => f.norm_map_snoc_le m x map_add' := fun _ m i x y => by simp rfl map_smul' := fun _ m i c x => by simp rfl } f'.mkContinuous ‖f‖ fun m => LinearMap.mkContinuous_norm_le _ (mul_nonneg (norm_nonneg _) (prod_nonneg fun j hj => norm_nonneg _)) _ #align continuous_multilinear_map.curry_right ContinuousMultilinearMap.curryRight @[simp] theorem ContinuousMultilinearMap.curryRight_apply (f : ContinuousMultilinearMap 𝕜 Ei G) (m : ∀ i : Fin n, Ei i.cast_succ) (x : Ei (last n)) : f.curryRight m x = f (snoc m x) := rfl #align continuous_multilinear_map.curry_right_apply ContinuousMultilinearMap.curryRight_apply @[simp] theorem ContinuousMultilinearMap.curry_uncurryRight (f : ContinuousMultilinearMap 𝕜 (fun i : Fin n => Ei i.cast_succ) (Ei (last n) →L[𝕜] G)) : f.uncurryRight.curryRight = f := by ext (m x) simp only [snoc_last, ContinuousMultilinearMap.curryRight_apply, ContinuousMultilinearMap.uncurryRight_apply] rw [init_snoc] #align continuous_multilinear_map.curry_uncurry_right ContinuousMultilinearMap.curry_uncurryRight @[simp] theorem ContinuousMultilinearMap.uncurry_curryRight (f : ContinuousMultilinearMap 𝕜 Ei G) : f.curryRight.uncurryRight = f := by ext m simp #align continuous_multilinear_map.uncurry_curry_right ContinuousMultilinearMap.uncurry_curryRight variable (𝕜 Ei G) /-- The space of continuous multilinear maps on `Π(i : fin (n+1)), Ei i` is canonically isomorphic to the space of continuous multilinear maps on `Π(i : fin n), Ei i.cast_succ` with values in the space of continuous linear maps on `Ei (last n)`, by separating the last variable. We register this isomorphism as a continuous linear equiv in `continuous_multilinear_curry_right_equiv 𝕜 Ei G`. The algebraic version (without topology) is given in `multilinear_curry_right_equiv 𝕜 Ei G`. The direct and inverse maps are given by `f.uncurry_right` and `f.curry_right`. Use these unless you need the full framework of linear isometric equivs. -/ def continuousMultilinearCurryRightEquiv : ContinuousMultilinearMap 𝕜 (fun i : Fin n => Ei i.cast_succ) (Ei (last n) →L[𝕜] G) ≃ₗᵢ[𝕜] ContinuousMultilinearMap 𝕜 Ei G := LinearIsometryEquiv.ofBounds { toFun := ContinuousMultilinearMap.uncurryRight map_add' := fun f₁ f₂ => by ext m rfl map_smul' := fun c f => by ext m rfl invFun := ContinuousMultilinearMap.curryRight left_inv := ContinuousMultilinearMap.curry_uncurryRight right_inv := ContinuousMultilinearMap.uncurry_curryRight } (fun f => MultilinearMap.mkContinuous_norm_le _ (norm_nonneg f) _) fun f => MultilinearMap.mkContinuous_norm_le _ (norm_nonneg f) _ #align continuous_multilinear_curry_right_equiv continuousMultilinearCurryRightEquiv variable (n G') /-- The space of continuous multilinear maps on `Π(i : fin (n+1)), G` is canonically isomorphic to the space of continuous multilinear maps on `Π(i : fin n), G` with values in the space of continuous linear maps on `G`, by separating the last variable. We register this isomorphism as a continuous linear equiv in `continuous_multilinear_curry_right_equiv' 𝕜 n G G'`. For a version allowing dependent types, see `continuous_multilinear_curry_right_equiv`. When there are no dependent types, use the primed version as it helps Lean a lot for unification. The direct and inverse maps are given by `f.uncurry_right` and `f.curry_right`. Use these unless you need the full framework of linear isometric equivs. -/ def continuousMultilinearCurryRightEquiv' : (G[×n]→L[𝕜] G →L[𝕜] G') ≃ₗᵢ[𝕜] G[×n.succ]→L[𝕜] G' := continuousMultilinearCurryRightEquiv 𝕜 (fun i : Fin n.succ => G) G' #align continuous_multilinear_curry_right_equiv' continuousMultilinearCurryRightEquiv' variable {n 𝕜 G Ei G'} @[simp] theorem continuousMultilinearCurryRightEquiv_apply (f : ContinuousMultilinearMap 𝕜 (fun i : Fin n => Ei i.cast_succ) (Ei (last n) →L[𝕜] G)) (v : ∀ i, Ei i) : (continuousMultilinearCurryRightEquiv 𝕜 Ei G) f v = f (init v) (v (last n)) := rfl #align continuous_multilinear_curry_right_equiv_apply continuousMultilinearCurryRightEquiv_apply @[simp] theorem continuousMultilinearCurryRightEquiv_symm_apply (f : ContinuousMultilinearMap 𝕜 Ei G) (v : ∀ i : Fin n, Ei i.cast_succ) (x : Ei (last n)) : (continuousMultilinearCurryRightEquiv 𝕜 Ei G).symm f v x = f (snoc v x) := rfl #align continuous_multilinear_curry_right_equiv_symm_apply continuousMultilinearCurryRightEquiv_symm_apply @[simp] theorem continuous_multilinear_curry_right_equiv_apply' (f : G[×n]→L[𝕜] G →L[𝕜] G') (v : Fin (n + 1) → G) : continuousMultilinearCurryRightEquiv' 𝕜 n G G' f v = f (init v) (v (last n)) := rfl #align continuous_multilinear_curry_right_equiv_apply' continuous_multilinear_curry_right_equiv_apply' @[simp] theorem continuous_multilinear_curry_right_equiv_symm_apply' (f : G[×n.succ]→L[𝕜] G') (v : Fin n → G) (x : G) : (continuousMultilinearCurryRightEquiv' 𝕜 n G G').symm f v x = f (snoc v x) := rfl #align continuous_multilinear_curry_right_equiv_symm_apply' continuous_multilinear_curry_right_equiv_symm_apply' @[simp] theorem ContinuousMultilinearMap.curryRight_norm (f : ContinuousMultilinearMap 𝕜 Ei G) : ‖f.curryRight‖ = ‖f‖ := (continuousMultilinearCurryRightEquiv 𝕜 Ei G).symm.norm_map f #align continuous_multilinear_map.curry_right_norm ContinuousMultilinearMap.curryRight_norm @[simp] theorem ContinuousMultilinearMap.uncurryRight_norm (f : ContinuousMultilinearMap 𝕜 (fun i : Fin n => Ei i.cast_succ) (Ei (last n) →L[𝕜] G)) : ‖f.uncurryRight‖ = ‖f‖ := (continuousMultilinearCurryRightEquiv 𝕜 Ei G).norm_map f #align continuous_multilinear_map.uncurry_right_norm ContinuousMultilinearMap.uncurryRight_norm /-! #### Currying with `0` variables The space of multilinear maps with `0` variables is trivial: such a multilinear map is just an arbitrary constant (note that multilinear maps in `0` variables need not map `0` to `0`!). Therefore, the space of continuous multilinear maps on `(fin 0) → G` with values in `E₂` is isomorphic (and even isometric) to `E₂`. As this is the zeroth step in the construction of iterated derivatives, we register this isomorphism. -/ section variable {𝕜 G G'} /-- Associating to a continuous multilinear map in `0` variables the unique value it takes. -/ def ContinuousMultilinearMap.uncurry0 (f : ContinuousMultilinearMap 𝕜 (fun i : Fin 0 => G) G') : G' := f 0 #align continuous_multilinear_map.uncurry0 ContinuousMultilinearMap.uncurry0 variable (𝕜 G) /-- Associating to an element `x` of a vector space `E₂` the continuous multilinear map in `0` variables taking the (unique) value `x` -/ def ContinuousMultilinearMap.curry0 (x : G') : G[×0]→L[𝕜] G' := ContinuousMultilinearMap.constOfIsEmpty 𝕜 _ x #align continuous_multilinear_map.curry0 ContinuousMultilinearMap.curry0 variable {G} @[simp] theorem ContinuousMultilinearMap.curry0_apply (x : G') (m : Fin 0 → G) : ContinuousMultilinearMap.curry0 𝕜 G x m = x := rfl #align continuous_multilinear_map.curry0_apply ContinuousMultilinearMap.curry0_apply variable {𝕜} @[simp] theorem ContinuousMultilinearMap.uncurry0_apply (f : G[×0]→L[𝕜] G') : f.uncurry0 = f 0 := rfl #align continuous_multilinear_map.uncurry0_apply ContinuousMultilinearMap.uncurry0_apply @[simp] theorem ContinuousMultilinearMap.apply_zero_curry0 (f : G[×0]→L[𝕜] G') {x : Fin 0 → G} : ContinuousMultilinearMap.curry0 𝕜 G (f x) = f := by ext m simp [(Subsingleton.elim _ _ : x = m)] #align continuous_multilinear_map.apply_zero_curry0 ContinuousMultilinearMap.apply_zero_curry0 theorem ContinuousMultilinearMap.uncurry0_curry0 (f : G[×0]→L[𝕜] G') : ContinuousMultilinearMap.curry0 𝕜 G f.uncurry0 = f := by simp #align continuous_multilinear_map.uncurry0_curry0 ContinuousMultilinearMap.uncurry0_curry0 variable (𝕜 G) @[simp] theorem ContinuousMultilinearMap.curry0_uncurry0 (x : G') : (ContinuousMultilinearMap.curry0 𝕜 G x).uncurry0 = x := rfl #align continuous_multilinear_map.curry0_uncurry0 ContinuousMultilinearMap.curry0_uncurry0 @[simp] theorem ContinuousMultilinearMap.curry0_norm (x : G') : ‖ContinuousMultilinearMap.curry0 𝕜 G x‖ = ‖x‖ := norm_constOfIsEmpty _ _ _ #align continuous_multilinear_map.curry0_norm ContinuousMultilinearMap.curry0_norm variable {𝕜 G} @[simp] theorem ContinuousMultilinearMap.fin0_apply_norm (f : G[×0]→L[𝕜] G') {x : Fin 0 → G} : ‖f x‖ = ‖f‖ := by obtain rfl : x = 0 := Subsingleton.elim _ _ refine' le_antisymm (by simpa using f.le_op_norm 0) _ have : ‖ContinuousMultilinearMap.curry0 𝕜 G f.uncurry0‖ ≤ ‖f.uncurry0‖ := ContinuousMultilinearMap.op_norm_le_bound _ (norm_nonneg _) fun m => by simp [-ContinuousMultilinearMap.apply_zero_curry0] simpa #align continuous_multilinear_map.fin0_apply_norm ContinuousMultilinearMap.fin0_apply_norm theorem ContinuousMultilinearMap.uncurry0_norm (f : G[×0]→L[𝕜] G') : ‖f.uncurry0‖ = ‖f‖ := by simp #align continuous_multilinear_map.uncurry0_norm ContinuousMultilinearMap.uncurry0_norm variable (𝕜 G G') /-- The continuous linear isomorphism between elements of a normed space, and continuous multilinear maps in `0` variables with values in this normed space. The direct and inverse maps are `uncurry0` and `curry0`. Use these unless you need the full framework of linear isometric equivs. -/ def continuousMultilinearCurryFin0 : (G[×0]→L[𝕜] G') ≃ₗᵢ[𝕜] G' where toFun f := ContinuousMultilinearMap.uncurry0 f invFun f := ContinuousMultilinearMap.curry0 𝕜 G f map_add' f g := rfl map_smul' c f := rfl left_inv := ContinuousMultilinearMap.uncurry0_curry0 right_inv := ContinuousMultilinearMap.curry0_uncurry0 𝕜 G norm_map' := ContinuousMultilinearMap.uncurry0_norm #align continuous_multilinear_curry_fin0 continuousMultilinearCurryFin0 variable {𝕜 G G'} @[simp] theorem continuousMultilinearCurryFin0_apply (f : G[×0]→L[𝕜] G') : continuousMultilinearCurryFin0 𝕜 G G' f = f 0 := rfl #align continuous_multilinear_curry_fin0_apply continuousMultilinearCurryFin0_apply @[simp] theorem continuousMultilinearCurryFin0_symm_apply (x : G') (v : Fin 0 → G) : (continuousMultilinearCurryFin0 𝕜 G G').symm x v = x := rfl #align continuous_multilinear_curry_fin0_symm_apply continuousMultilinearCurryFin0_symm_apply end /-! #### With 1 variable -/ variable (𝕜 G G') /-- Continuous multilinear maps from `G^1` to `G'` are isomorphic with continuous linear maps from `G` to `G'`. -/ def continuousMultilinearCurryFin1 : (G[×1]→L[𝕜] G') ≃ₗᵢ[𝕜] G →L[𝕜] G' := (continuousMultilinearCurryRightEquiv 𝕜 (fun i : Fin 1 => G) G').symm.trans (continuousMultilinearCurryFin0 𝕜 G (G →L[𝕜] G')) #align continuous_multilinear_curry_fin1 continuousMultilinearCurryFin1 variable {𝕜 G G'} @[simp] theorem continuousMultilinearCurryFin1_apply (f : G[×1]→L[𝕜] G') (x : G) : continuousMultilinearCurryFin1 𝕜 G G' f x = f (Fin.snoc 0 x) := rfl #align continuous_multilinear_curry_fin1_apply continuousMultilinearCurryFin1_apply @[simp] theorem continuousMultilinearCurryFin1_symm_apply (f : G →L[𝕜] G') (v : Fin 1 → G) : (continuousMultilinearCurryFin1 𝕜 G G').symm f v = f (v 0) := rfl #align continuous_multilinear_curry_fin1_symm_apply continuousMultilinearCurryFin1_symm_apply namespace ContinuousMultilinearMap variable (𝕜 G G') /-- An equivalence of the index set defines a linear isometric equivalence between the spaces of multilinear maps. -/ def domDomCongr (σ : ι ≃ ι') : ContinuousMultilinearMap 𝕜 (fun _ : ι => G) G' ≃ₗᵢ[𝕜] ContinuousMultilinearMap 𝕜 (fun _ : ι' => G) G' := LinearIsometryEquiv.ofBounds { toFun := fun f => (MultilinearMap.domDomCongr σ f.toMultilinearMap).mkContinuous ‖f‖ fun m => (f.le_op_norm fun i => m (σ i)).trans_eq <| by rw [← σ.prod_comp] invFun := fun f => (MultilinearMap.domDomCongr σ.symm f.toMultilinearMap).mkContinuous ‖f‖ fun m => (f.le_op_norm fun i => m (σ.symm i)).trans_eq <| by rw [← σ.symm.prod_comp] left_inv := fun f => ext fun m => congr_arg f <| by simp only [σ.symm_apply_apply] right_inv := fun f => ext fun m => congr_arg f <| by simp only [σ.apply_symm_apply] map_add' := fun f g => rfl map_smul' := fun c f => rfl } (fun f => MultilinearMap.mkContinuous_norm_le _ (norm_nonneg f) _) fun f => MultilinearMap.mkContinuous_norm_le _ (norm_nonneg f) _ #align continuous_multilinear_map.dom_dom_congr ContinuousMultilinearMap.domDomCongr variable {𝕜 G G'} section /-- A continuous multilinear map with variables indexed by `ι ⊕ ι'` defines a continuous multilinear map with variables indexed by `ι` taking values in the space of continuous multilinear maps with variables indexed by `ι'`. -/ def currySum (f : ContinuousMultilinearMap 𝕜 (fun x : Sum ι ι' => G) G') : ContinuousMultilinearMap 𝕜 (fun x : ι => G) (ContinuousMultilinearMap 𝕜 (fun x : ι' => G) G') := MultilinearMap.mkContinuousMultilinear (MultilinearMap.currySum f.toMultilinearMap) ‖f‖ fun m m' => by simpa [Fintype.prod_sum_type, mul_assoc] using f.le_op_norm (Sum.elim m m') #align continuous_multilinear_map.curry_sum ContinuousMultilinearMap.currySum @[simp] theorem currySum_apply (f : ContinuousMultilinearMap 𝕜 (fun x : Sum ι ι' => G) G') (m : ι → G) (m' : ι' → G) : f.currySum m m' = f (Sum.elim m m') := rfl #align continuous_multilinear_map.curry_sum_apply ContinuousMultilinearMap.currySum_apply /-- A continuous multilinear map with variables indexed by `ι` taking values in the space of continuous multilinear maps with variables indexed by `ι'` defines a continuous multilinear map with variables indexed by `ι ⊕ ι'`. -/ def uncurrySum (f : ContinuousMultilinearMap 𝕜 (fun x : ι => G) (ContinuousMultilinearMap 𝕜 (fun x : ι' => G) G')) : ContinuousMultilinearMap 𝕜 (fun x : Sum ι ι' => G) G' := MultilinearMap.mkContinuous (toMultilinearMapLinear.compMultilinearMap f.toMultilinearMap).uncurrySum ‖f‖ fun m => by simpa [Fintype.prod_sum_type, mul_assoc] using (f (m ∘ Sum.inl)).le_of_op_norm_le (m ∘ Sum.inr) (f.le_op_norm _) #align continuous_multilinear_map.uncurry_sum ContinuousMultilinearMap.uncurrySum @[simp] theorem uncurrySum_apply (f : ContinuousMultilinearMap 𝕜 (fun x : ι => G) (ContinuousMultilinearMap 𝕜 (fun x : ι' => G) G')) (m : Sum ι ι' → G) : f.uncurrySum m = f (m ∘ Sum.inl) (m ∘ Sum.inr) := rfl #align continuous_multilinear_map.uncurry_sum_apply ContinuousMultilinearMap.uncurrySum_apply variable (𝕜 ι ι' G G') /-- Linear isometric equivalence between the space of continuous multilinear maps with variables indexed by `ι ⊕ ι'` and the space of continuous multilinear maps with variables indexed by `ι` taking values in the space of continuous multilinear maps with variables indexed by `ι'`. The forward and inverse functions are `continuous_multilinear_map.curry_sum` and `continuous_multilinear_map.uncurry_sum`. Use this definition only if you need some properties of `linear_isometry_equiv`. -/ def currySumEquiv : ContinuousMultilinearMap 𝕜 (fun x : Sum ι ι' => G) G' ≃ₗᵢ[𝕜] ContinuousMultilinearMap 𝕜 (fun x : ι => G) (ContinuousMultilinearMap 𝕜 (fun x : ι' => G) G') := LinearIsometryEquiv.ofBounds { toFun := currySum invFun := uncurrySum map_add' := fun f g => by ext rfl map_smul' := fun c f => by ext rfl left_inv := fun f => by ext m exact congr_arg f (Sum.elim_comp_inl_inr m) right_inv := fun f => by ext (m₁ m₂) change f _ _ = f _ _ rw [Sum.elim_comp_inl, Sum.elim_comp_inr] } (fun f => MultilinearMap.mkContinuousMultilinear_norm_le _ (norm_nonneg f) _) fun f => MultilinearMap.mkContinuous_norm_le _ (norm_nonneg f) _ #align continuous_multilinear_map.curry_sum_equiv ContinuousMultilinearMap.currySumEquiv end section variable (𝕜 G G') {k l : ℕ} {s : Finset (Fin n)} /-- If `s : finset (fin n)` is a finite set of cardinality `k` and its complement has cardinality `l`, then the space of continuous multilinear maps `G [×n]→L[𝕜] G'` of `n` variables is isomorphic to the space of continuous multilinear maps `G [×k]→L[𝕜] G [×l]→L[𝕜] G'` of `k` variables taking values in the space of continuous multilinear maps of `l` variables. -/ def curryFinFinset {k l n : ℕ} {s : Finset (Fin n)} (hk : s.card = k) (hl : sᶜ.card = l) : (G[×n]→L[𝕜] G') ≃ₗᵢ[𝕜] G[×k]→L[𝕜] G[×l]→L[𝕜] G' := (domDomCongr 𝕜 G G' (finSumEquivOfFinset hk hl).symm).trans (currySumEquiv 𝕜 (Fin k) (Fin l) G G') #align continuous_multilinear_map.curry_fin_finset ContinuousMultilinearMap.curryFinFinset variable {𝕜 G G'} @[simp] theorem curryFinFinset_apply (hk : s.card = k) (hl : sᶜ.card = l) (f : G[×n]→L[𝕜] G') (mk : Fin k → G) (ml : Fin l → G) : curryFinFinset 𝕜 G G' hk hl f mk ml = f fun i => Sum.elim mk ml ((finSumEquivOfFinset hk hl).symm i) := rfl #align continuous_multilinear_map.curry_fin_finset_apply ContinuousMultilinearMap.curryFinFinset_apply @[simp] theorem curryFinFinset_symm_apply (hk : s.card = k) (hl : sᶜ.card = l) (f : G[×k]→L[𝕜] G[×l]→L[𝕜] G') (m : Fin n → G) : (curryFinFinset 𝕜 G G' hk hl).symm f m = f (fun i => m <| finSumEquivOfFinset hk hl (Sum.inl i)) fun i => m <| finSumEquivOfFinset hk hl (Sum.inr i) := rfl #align continuous_multilinear_map.curry_fin_finset_symm_apply ContinuousMultilinearMap.curryFinFinset_symm_apply @[simp] theorem curryFinFinset_symm_apply_piecewise_const (hk : s.card = k) (hl : sᶜ.card = l) (f : G[×k]→L[𝕜] G[×l]→L[𝕜] G') (x y : G) : (curryFinFinset 𝕜 G G' hk hl).symm f (s.piecewise (fun _ => x) fun _ => y) = f (fun _ => x) fun _ => y := MultilinearMap.curryFinFinset_symm_apply_piecewise_const hk hl _ x y #align continuous_multilinear_map.curry_fin_finset_symm_apply_piecewise_const ContinuousMultilinearMap.curryFinFinset_symm_apply_piecewise_const @[simp] theorem curryFinFinset_symm_apply_const (hk : s.card = k) (hl : sᶜ.card = l) (f : G[×k]→L[𝕜] G[×l]→L[𝕜] G') (x : G) : ((curryFinFinset 𝕜 G G' hk hl).symm f fun _ => x) = f (fun _ => x) fun _ => x := rfl #align continuous_multilinear_map.curry_fin_finset_symm_apply_const ContinuousMultilinearMap.curryFinFinset_symm_apply_const @[simp] theorem curryFinFinset_apply_const (hk : s.card = k) (hl : sᶜ.card = l) (f : G[×n]→L[𝕜] G') (x y : G) : (curryFinFinset 𝕜 G G' hk hl f (fun _ => x) fun _ => y) = f (s.piecewise (fun _ => x) fun _ => y) := by refine' (curry_fin_finset_symm_apply_piecewise_const hk hl _ _ _).symm.trans _ -- `rw` fails rw [LinearIsometryEquiv.symm_apply_apply] #align continuous_multilinear_map.curry_fin_finset_apply_const ContinuousMultilinearMap.curryFinFinset_apply_const end end ContinuousMultilinearMap end Currying
[STATEMENT] lemma in_restricted_global_in_unrestricted_global [intro]: "r' \<in> RID\<^sub>G (s(r := None)) \<Longrightarrow> r' \<in> RID\<^sub>G s" "l \<in> LID\<^sub>G (s(r := None)) \<Longrightarrow> l \<in> LID\<^sub>G s" [PROOF STATE] proof (prove) goal (1 subgoal): 1. (r' \<in> RID\<^sub>G (s(r := None)) \<Longrightarrow> r' \<in> RID\<^sub>G s) &&& (l \<in> LID\<^sub>G (s(r := None)) \<Longrightarrow> l \<in> LID\<^sub>G s) [PROOF STEP] by (simp add: ID_restricted_global_subset_unrestricted rev_subsetD)+
lemma linear_componentwise_iff: "(linear f') \<longleftrightarrow> (\<forall>i\<in>Basis. linear (\<lambda>x. f' x \<bullet> i))"
p r o g r a m t c test for continued holleriths in call, data, and do statements c h a r a c t e r *(l e n = 6 ) a _ b ( 3 ) c h a r a c t e r * 6 2 c Comment ': : x c h a r a c t e r * 5 : : l , m , n , o , p , q d a *Comment ct a x /62HAbCdEfGhIjKlMnOpQrStUvWxYz1234567890aBcDeFgHiJkLmNoPqRsT auVwXyZ/ character *60::a data a/60H!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ccomment !!!!!/ print *,a d a t a l , m , n , o /5hHeLlo,5hwORLD,5hFrOm ,5hMaTT /, p !/5hwHy!?/ , q / 5hnO!!!/ p r i n t * , l , m , o , p , q p r i n t *,x d a t a a _ *b / 'Hello ' , 5 *HWorld , 1 h! / d a t a c / 5 H!!!!! / p r i n t * , a _ b ! comment 1 0 0 f o r m a t ( " Hello ", 5 HWorld, *2 h ! ) p r i n t 1 0 0 c a *l l s ( 1 h; ) p r i n t * , c e n d p r o g r a m t s u b r o u t i n e s ( c ) i n t e g e r c ( 1 ) p r *i n *t * , c e n d s u b r o u t i n e s
module Postulate where postulate f : {A : Set} → A → A g : {A : Set} → A → A h : {A : Set} → A → A h x = f x
reserve prefix `#` : 9999 -- #_ reserve infix ` >> ` : 1000 -- _ >> _ /- Useful Properties -/ namespace use universes u v /- Proofs from L∃∀N's library regarding negation, conjunction, and disjunction -/ lemma Not_Or {a b : Prop} : ¬ a → ¬ b → ¬ (a ∨ b) | hna hnb (or.inl ha) := absurd ha hna | hna hnb (or.inr hb) := absurd hb hnb lemma Not_Or_iff_And_Not (p q) [d₁ : decidable p] [d₂ : decidable q] : ¬ (p ∨ q) ↔ ¬ p ∧ ¬ q := iff.intro (λ h, match d₁ with | is_true h₁ := false.elim $ h (or.inl h₁) | is_false h₁ := match d₂ with | is_true h₂ := false.elim $ h (or.inr h₂) | is_false h₂ := ⟨h₁, h₂⟩ end end) (λ ⟨np, nq⟩ h, or.elim h np nq) /- Proving the distributive property of "IF-THEN-ELSE" -/ lemma ITE_Distribution {α : Type u}{β : Type v} {IF : Prop}{THEN ELSE : α} [decIF : decidable IF] : ∀(f : α → β), --------------------------- ( f (ite IF THEN ELSE) = ite IF (f THEN) (f ELSE) ) := begin with_cases { by_cases IFs : IF }, case pos { simp [IFs] }, case neg { simp [IFs] } end /- Useful properties regarding Products -/ lemma EQ_Prod_iff_EQ_and_EQ {α : Type u} {β : Type v} : ∀{a1 a2 : α}{b1 b2 : β}, --------------------------- ( (a1,b1) = (a2,b2) ) ↔ ( (a1 = a2) ∧ (b1 = b2) ) | a1 a2 b1 b2 := begin have case_to : ∀{a1 a2 : α}{b1 b2 : β}, (a1,b1) = (a2,b2) → (a1 = a2) ∧ (b1 = b2), from begin assume a1 a2 b1 b2 eq_prod, from prod.mk.inj eq_prod end, have case_from : ∀{a1 a2 : α}{b1 b2 : β}, (a1 = a2) ∧ (b1 = b2) → (a1,b1) = (a2,b2), from begin assume a1 a2 b1 b2 and_eq, simp [and_eq] end, from iff.intro case_to case_from end /- Useful properties regarding Lists -/ lemma Index_LT_Length_of_Mem {α : Type u} [eqα : decidable_eq α] : ∀{a : α}{l : list α}, ( a ∈ l ) → --------------------------- ( list.index_of a l < list.length l ) | a [] := begin assume a_mem, simp [has_mem.mem, list.mem] at a_mem, from false.elim a_mem end | a (HEAD::TAIL) := begin assume a_mem, simp [has_mem.mem, list.mem] at a_mem, simp [list.index_of, list.find_index, list.length], with_cases { by_cases a_eq_head : a = HEAD }, case pos { simp [a_eq_head], have one_le_succ, from nat.add_le_add_left (nat.zero_le (list.length TAIL)) 1, rewrite [nat.add_zero] at one_le_succ, from nat.lt_of_lt_of_le nat.zero_lt_one one_le_succ }, case neg { simp [a_eq_head] at ⊢ a_mem, rewrite [nat.succ_eq_add_one, add_comm], have loop, from Index_LT_Length_of_Mem a_mem, from nat.add_le_add_left loop 1 } end lemma Mem_Remove_of_Mem_of_Not_Mem {α : Type u} [eqα : decidable_eq α] : ∀{nth : α}{l1 l2 : list α}, ( nth ∉ l1 ) → ( nth ∈ l2 ) → --------------------------- ( ∀(a : α), a ∈ l1 → a ∈ l2 → a ∈ list.remove_nth l2 (list.index_of nth l2) ) | nth l1 [] := begin assume nth_not_l1 nth_mem_l2, simp [has_mem.mem, list.mem] at nth_mem_l2, from false.elim nth_mem_l2 end | nth l1 (HEAD2::TAIL2) := begin assume nth_not_l1 nth_mem_l2, simp [list.index_of, list.find_index], with_cases { by_cases nth_eq_head2 : nth = HEAD2 }, case pos { simp [nth_eq_head2] at ⊢ nth_not_l1, simp [list.index_of, list.find_index, list.remove_nth], have case_loop : ∀(a : α), a ∈ l1 → a ∈ (HEAD2::TAIL2) → a ∈ TAIL2, from begin assume loop loop_mem_l1 loop_mem_l2, simp [has_mem.mem, list.mem] at loop_mem_l2, cases loop_mem_l2 with loop_eq_head2 loop_mem_tail2, case or.inl { rewrite [loop_eq_head2] at loop_mem_l1, from absurd loop_mem_l1 nth_not_l1 }, case or.inr { from loop_mem_tail2 } end, from case_loop }, case neg { simp [nth_eq_head2] at ⊢ nth_mem_l2, simp [list.remove_nth], have case_loop : ∀(a : α), a ∈ l1 → a ∈ (HEAD2::TAIL2) → a = HEAD2 ∨ a ∈ list.remove_nth TAIL2 (list.find_index (eq nth) TAIL2), from begin assume loop loop_mem_l1 loop_mem_l2, simp [has_mem.mem, list.mem] at loop_mem_l2, cases loop_mem_l2 with loop_eq_head2 loop_mem_tail2, case or.inl { simp [loop_eq_head2] }, case or.inr { apply (or.intro_right), from Mem_Remove_of_Mem_of_Not_Mem nth_not_l1 nth_mem_l2 loop loop_mem_l1 loop_mem_tail2 } end, from case_loop } end lemma Subset_Self {α : Type u} : ∀(l : list α), --------------------------- ( ∀(a : α), ( a ∈ l ) → ( a ∈ l ) ) | l := begin have subset_self : ∀(a : α), a ∈ l → a ∈ l, from begin assume a a_mem_l, from a_mem_l end, from subset_self end /- Lemmata taken from L∃∀N's library about Lists -/ lemma EQ_NIL_of_Length_EQ_ZERO {α : Type u} : ∀{l : list α}, ( list.length l = 0 ) → --------------------------- ( l = [] ) | l := by from list.eq_nil_of_length_eq_zero lemma Mem_Append {α : Type u} : ∀{a : α}{l1 l2 : list α}, --------------------------- ( list.mem a (l1++l2) ) ↔ ( (list.mem a l1) ∨ (list.mem a l2) ) | a l1 l2 := by from list.mem_append lemma Length_Remove_Nth {α : Type u} : ∀{l : list α}{n : ℕ}, ( n < list.length l ) → --------------------------- ( list.length (list.remove_nth l n) = list.length l - 1 ) | l n := by from list.length_remove_nth l n /- Useful properties regarding Natural Numbers (Must be in Order) -/ lemma EQ_of_LT_ONE_of_GE : ∀{a b : ℕ}, ( a ≥ b ) → ( a < 1 + b ) → --------------------------------- ( a = b ) | 0 0 := begin assume a_ge_b a_lt_oneb, from refl 0 end | (a+1) 0 := begin assume a_ge_b a_lt_oneb, rewrite [add_comm] at a_lt_oneb, have zero_lt_a, from lt_of_add_lt_add_left a_lt_oneb, have not_zero_lt_a, from nat.not_lt_zero a, from absurd zero_lt_a not_zero_lt_a end | 0 (b+1) := begin assume a_ge_b a_lt_oneb, have zero_le_b, from nat.zero_le b, have b_le_oneb, from le_trans a_ge_b zero_le_b, rewrite [nat.add_one] at b_le_oneb, from absurd b_le_oneb (nat.not_succ_le_self b) end | (a+1) (b+1) := begin assume a_ge_b a_lt_oneb, have loop_ge : a ≥ b , from nat.le_of_succ_le_succ a_ge_b, rewrite [add_comm] at a_lt_oneb, have loop_lt, from lt_of_add_lt_add_left a_lt_oneb, rewrite [add_comm] at loop_lt, rewrite [EQ_of_LT_ONE_of_GE loop_ge loop_lt] end lemma LT_of_Mul_LT_of_Pos : ∀{a b c : ℕ}, ( 0 < a ) → ( a * b < c ) → --------------------------------- ( b < c ) | a 0 c := begin assume zero_lt_a ab_lt_c, simp [nat.mul_zero] at ⊢ ab_lt_c, from ab_lt_c end | a (b+1) c := begin assume zero_lt_a ab_lt_c, with_cases { by_cases a_eq_1 : 1 = a }, case pos { rewrite [←a_eq_1, nat.one_mul] at ab_lt_c, from ab_lt_c }, case neg { have one_le_a, from nat.le_of_lt_succ (nat.succ_lt_succ zero_lt_a), have one_lt_a, from nat.lt_of_le_and_ne one_le_a a_eq_1, have b_le_b, from nat.le_refl (b+1), have zero_lt_b, from lt_add_of_le_of_pos (nat.zero_le b) nat.zero_lt_one, have zero_le_a, from nat.zero_le a, --( 1 < a ) → ( (b+1) ≤ (b+1) ) → ( 0 < (b+1) ) → ( 0 ≤ a ) → ( 1 * (b+1) < a * (b+1) ) have b_lt_ab, from mul_lt_mul one_lt_a b_le_b zero_lt_b zero_le_a, rewrite [nat.one_mul] at b_lt_ab, from nat.lt_trans b_lt_ab ab_lt_c } end lemma LE_Mul_Left_of_Pos : ∀{a : ℕ}, ( 0 < a ) → --------------------------------- ( ∀(b : ℕ), b ≤ a * b ) | a := begin assume zero_lt_a b, induction b, case nat.zero { simp [mul_zero] }, case nat.succ { have one_le_a, from nat.le_of_lt_succ (nat.succ_lt_succ zero_lt_a), rewrite [nat.succ_eq_add_one, mul_comm a, add_comm, right_distrib, one_mul, mul_comm], from add_le_add one_le_a b_ih } end /- Useful properties regarding Natural Numbers -/ lemma Add_GE_Add : ∀{a b c d : ℕ}, ( a ≥ b ) → ( c ≥ d ) → --------------------------------- ( a + c ≥ b + d ) | a b c d := begin assume a_ge_b c_ge_d, from add_le_add a_ge_b c_ge_d end lemma EQ_or_SUCC_LE_iff_LE : ∀{a b : ℕ}, --------------------------- ( a ≤ b ) ↔ ( (a = b) ∨ (a+1 ≤ b) ) := begin have case_to : ∀{a b : ℕ}, a ≤ b → (a = b) ∨ (a+1 ≤ b), from begin assume a b le_a_b, from nat.eq_or_lt_of_le le_a_b end, have case_from : ∀{a b : ℕ}, (a = b) ∨ (a+1 ≤ b) → a ≤ b, from begin assume a b eq_or_succ_le_a_b, cases eq_or_succ_le_a_b with eq_a_b succ_le_a_b, case or.inl { simp [eq_a_b] }, case or.inr { from nat.le_of_succ_le succ_le_a_b } end, assume a b, from iff.intro case_to case_from end lemma EQ_PRED_of_SUCC_EQ : -- Notice that the other way does not hold true, since 0 ≠ 0 - 1 ∀{a b : ℕ}, ( a+1 = b ) → --------------------------- ( a = b-1 ) | a b := begin assume eq_succ_a_b, rewrite [←eq_succ_a_b, eq_comm], from nat.add_sub_cancel a 1 end lemma GE_Cancel_Right : ∀{a b c : ℕ}, ( a ≥ b + c ) → --------------------------------- ( a ≥ b ) | a b c := begin assume a_ge_bc, have bc_ge_b : b + c ≥ b, from begin have b_le_bc, from add_le_add_left (nat.zero_le c) b, rewrite [add_zero] at b_le_bc, from b_le_bc end, from ge_trans a_ge_bc bc_ge_b end lemma GE_iff_Not_LT : ∀{a b : ℕ}, --------------------------- ( a ≥ b ) ↔ ( ¬( a < b ) ) := begin have case_to : ∀{m n : ℕ}, ( m ≥ n ) → ( ¬( m < n ) ), from begin assume m n m_ge_n, from not_lt_of_ge m_ge_n end, have case_from : ∀{m n : ℕ}, ( ¬( m < n ) ) → ( m ≥ n ), from begin assume m n not_m_lt_n, have eq_or_lt, from nat.eq_or_lt_of_not_lt not_m_lt_n, cases eq_or_lt with m_eq_n m_lt_n, case or.inl { apply nat.le_of_eq, from (iff.elim_right eq_comm) m_eq_n }, case or.inr { apply nat.le_of_lt, from m_lt_n }, end, assume a b, from iff.intro case_to case_from end lemma LE_Add_Left : ∀{a b : ℕ}, ( a ≤ b ) → --------------------------------- ( ∀(c : ℕ), ( a ≤ c + b ) ) | a b := begin assume a_le_b c, from le_trans a_le_b (nat.le_add_left b c) end lemma LE_Add_Right : ∀{a b : ℕ}, ( a ≤ b ) → --------------------------------- ( ∀(c : ℕ), ( a ≤ b + c ) ) | a b := begin assume a_le_b c, from le_trans a_le_b (nat.le_add_right b c) end lemma LE_Mul_of_LE : ∀{a b : ℕ}, ∀(c : ℕ), ( a ≤ b ) → --------------------------- ( a * c ≤ b * c ) | a b 0 := begin assume a_le_b, simp [nat.mul_zero] end | a b (c+1) := begin assume a_le_b, rewrite [←mul_comm (c+1), right_distrib, nat.one_mul, mul_comm c], rewrite [←mul_comm (c+1), right_distrib, nat.one_mul, mul_comm c], have loop, from LE_Mul_of_LE c a_le_b, from add_le_add loop a_le_b end lemma LT_Add_Left : ∀{a b : ℕ}, ( a < b ) → --------------------------------- ( ∀(c : ℕ), ( a < c + b ) ) | a b := begin assume a_lt_b c, with_cases {by_cases c_eq_zero : c = 0 }, case pos { simp [c_eq_zero], from a_lt_b }, case neg { rewrite [eq_comm] at c_eq_zero, have c_pos, from lt_of_le_of_ne (nat.zero_le c) (c_eq_zero), from lt_add_of_pos_of_lt c_pos a_lt_b } end lemma LT_Add_Right : ∀{a b : ℕ}, ( a < b ) → --------------------------------- ( ∀(c : ℕ), ( a < b + c ) ) | a b := begin assume a_lt_b c, with_cases {by_cases c_eq_zero : c = 0 }, case pos { simp [c_eq_zero], from a_lt_b }, case neg { rewrite [eq_comm] at c_eq_zero, have c_pos, from lt_of_le_of_ne (nat.zero_le c) (c_eq_zero), from lt_add_of_lt_of_pos a_lt_b c_pos } end lemma LT_ZERO_iff_LE_ONE : ∀{a : ℕ}, --------------------------- ( 0 < a ) ↔ ( 1 ≤ a ) := begin have case_to : ∀{a : ℕ}, ( 0 < a ) → ( 1 ≤ a ), from begin assume a zero_lt_a, from nat.le_of_lt_succ (nat.succ_lt_succ zero_lt_a) end, have case_from : ∀{a : ℕ}, ( 1 ≤ a ) → ( 0 < a ), from begin assume a one_le_a, from nat.lt_of_lt_of_le nat.zero_lt_one one_le_a end, assume a, from iff.intro case_to case_from end lemma Not_EQ_of_SUCC_EQ_SUB : ∀{a b c : ℕ}, ( c+1 = a-b ) → --------------------------------- ¬ ( b = a ) | a b c := begin assume succ_eq_sub eq_a_b, rewrite [eq_a_b] at succ_eq_sub, rewrite [nat.sub_self] at succ_eq_sub, simp [nat.add_one_ne_zero] at succ_eq_sub, from succ_eq_sub end lemma Not_SUCC_LE_of_ZERO_EQ_SUB : ∀{a b : ℕ}, ( 0 = a-b ) → --------------------------------- ¬ ( b+1 ≤ a ) | a b := begin assume zero_eq_sub succ_le, rewrite [eq_comm] at zero_eq_sub, have le_a_b, from nat.le_of_sub_eq_zero zero_eq_sub, have le_succ_b_b, from nat.le_trans succ_le le_a_b, simp [nat.not_succ_le_self] at le_succ_b_b, from le_succ_b_b end lemma Sub_Add_Cancel : ∀{a b : ℕ}, ( b ≤ a ) → --------------------------------- ( a - b + b = a ) | a b := begin assume b_le_a, from nat.sub_add_cancel b_le_a end lemma ZERO_LT_Mul_iff_AND_ZERO_LT : ∀{a b : ℕ}, --------------------------------- ( 0 < a * b ) ↔ ( 0 < a ∧ 0 < b ) := begin have case_to : ∀{a b : ℕ}, ( 0 < a * b ) → ( 0 < a ∧ 0 < b ), from begin assume a b zero_lt_ab, with_cases {by_cases a_eq_zero : a = 0 }, case pos { rewrite [a_eq_zero, nat.zero_mul] at zero_lt_ab, from false.elim (nat.not_lt_zero 0 zero_lt_ab) }, case neg { with_cases {by_cases b_eq_zero : b = 0 }, case pos { rewrite [b_eq_zero, nat.mul_zero] at zero_lt_ab, from false.elim (nat.not_lt_zero 0 zero_lt_ab) }, case neg { have zero_le_a, from nat.lt_of_le_and_ne (nat.zero_le a), have zero_le_b, from nat.lt_of_le_and_ne (nat.zero_le b), rewrite [ne.def, eq_comm] at zero_le_a zero_le_b, from and.intro (zero_le_a a_eq_zero) (zero_le_b b_eq_zero) }, } end, have case_from : ∀{a b : ℕ}, ( 0 < a ∧ 0 < b ) → ( 0 < a * b ), from begin assume a b zero_lt_a_and_b, cases zero_lt_a_and_b with zero_lt_a zero_lt_b, have zero_lt_ab, from mul_lt_mul_of_pos_left zero_lt_b zero_lt_a, rewrite [nat.mul_zero] at zero_lt_ab, from zero_lt_ab end, assume a b, from iff.intro case_to case_from end lemma ZERO_LT_of_Not_EQ_ZERO : ∀{a : ℕ}, ¬ ( a = 0 ) → --------------------------------- ( 0 < a ) | 0 := begin assume not_refl_zero, from absurd (eq.refl 0) not_refl_zero end | (a+1) := begin assume not_succ_eq_zero, rewrite [add_comm], from nat.zero_lt_one_add a end /- Lemmata taken from L∃∀N's library about Natural Numbers -/ lemma Add_LE_Add : ∀{a b c d : ℕ}, ( a ≤ b ) → ( c ≤ d ) → --------------------------------- ( a + c ≤ b + d ) | a b c d := begin assume a_le_b c_le_d, from add_le_add a_le_b c_le_d end lemma Add_LT_Add_Left : ∀{a b : ℕ}, ( a < b ) → --------------------------------- ( ∀(c : ℕ), ( c + a < c + b ) ) | a b := begin assume a_lt_b c, from add_lt_add_left a_lt_b c end lemma Add_LT_Add_Right : ∀{a b : ℕ}, ( a < b ) → --------------------------------- ( ∀(c : ℕ), ( a + c < b + c ) ) | a b := begin assume a_lt_b c, from add_lt_add_right a_lt_b c end lemma Add_ZERO : ∀(a : ℕ), --------------------------------- ( a + 0 = a ) | a := by from add_zero a lemma EQ_Refl {α : Sort u} : ∀(a : α), --------------------------------- ( a = a ) | a := by from eq.refl a lemma LE_of_SUCC_LE : ∀{n m : ℕ}, ( nat.succ n ≤ m ) → --------------------------- ( n ≤ m ) | n m := by from nat.le_of_succ_le lemma LE_SUCC_of_LE : ∀{n m : ℕ}, ( n ≤ m ) → --------------------------- ( n ≤ nat.succ m ) | n m := by from nat.le_succ_of_le lemma LE_Refl : ∀(a : ℕ), --------------------------- ( a ≤ a ) | a := by from nat.le_refl a lemma LE_Trans : ∀{a b c : ℕ}, ( a ≤ b ) → ( b ≤ c ) → --------------------------- ( a ≤ c ) | a b c := by from nat.le_trans lemma LT_Irrefl : ∀{a : ℕ}, --------------------------------- ¬ ( a < a ) | a := by from lt_irrefl a lemma LT_of_LT_of_LE : ∀{n m k : ℕ}, ( n < m ) → ( m ≤ k ) → --------------------------- ( n < k ) | n m k := by from nat.lt_of_lt_of_le lemma LT_of_LE_of_LT : ∀{n m k : ℕ}, ( n ≤ m ) → ( m < k ) → --------------------------- ( n < k ) | n m k := by from nat.lt_of_le_of_lt lemma Mul_Assoc : ∀{a b c : ℕ}, --------------------------- ( a * b * c = a * (b * c) ) | a b c := by from mul_assoc a b c lemma Mul_ZERO : ∀{a : ℕ}, --------------------------- ( a * 0 = 0 ) | a := by from nat.mul_zero a lemma Not_LT_ZERO : ∀{a : ℕ}, --------------------------- ¬ ( a < 0 ) | a := by from nat.not_lt_zero a lemma Not_SUCC_LE_Self : ∀{a : ℕ}, --------------------------- ¬ ( nat.succ a ≤ a ) | a := by from nat.not_succ_le_self a lemma ONE_Mul : ∀(a : ℕ), --------------------------- ( 1 * a = a ) | a := by from nat.one_mul a lemma Right_Distrib : ∀{a b c : ℕ}, --------------------------------- ( (a + b) * c = a * c + b * c ) | a b c := by from right_distrib a b c lemma SUCC_EQ_Add_ONE : ∀{a : ℕ}, --------------------------- ( nat.succ a = a + 1 ) | a := by from nat.succ_eq_add_one a lemma SUCC_Mul : ∀{n m : ℕ}, --------------------------- ( (nat.succ n) * m = n * m + m ) | n m := by from nat.succ_mul n m lemma ZERO_LE : ∀(a : ℕ), --------------------------------- ( 0 ≤ a ) | a := by from nat.zero_le a lemma ZERO_LT_ONE_Add : ∀(a : ℕ), --------------------------------- ( 0 < 1 + a ) | a := by from nat.zero_lt_one_add a lemma ZERO_LT_ONE : --------------------------------- 0 < (1:nat) := by from nat.zero_lt_one end use /- Auxiliary Definitions -/ namespace aux universes u v /- Methods for determining the size of nested lists -/ -- The order of the following definitions is important class has_size (α : Type u) := (size : α → ℕ) instance is_default_size (α : Type u) : has_size α := ⟨ (λx, 1) ⟩ -- First the size method checks if it has been given a list, if not it goes to its default case def size {α : Type u} [hcα : has_size α] : α → ℕ := has_size.size def list_size {α : Type u} [hcα : has_size α] : list α → ℕ | [] := 0 | (h::l) := size h + list_size l -- Writing [hcα : has_size α] means that α ay have either is_list_size or is_default_size -- If [hcα : has_size α] is omitted, than α must have is_default_size instance is_list_size (α : Type u) [hcα : has_size α] : has_size (list α) := ⟨list_size⟩ /- Properties about list size -/ lemma Deafault_Size_EQ_Length {α : Type} : ∀{l : list α}, --------------------------- ( list_size l = list.length l ) | [] := by simp [list.length, list_size] | (HEAD::TAIL) := begin simp [list.length, list_size], simp [size, has_size.size], rewrite [Deafault_Size_EQ_Length] end lemma ZERO_LT_Length_of_LT_Size {α : Type} [hcα : has_size α] : ∀{l : list α}{num : ℕ}, ( num < list_size l ) → --------------------------- ( 0 < list.length l ) | [] num := begin assume num_lt_size, simp [list_size] at num_lt_size, from absurd num_lt_size use.Not_LT_ZERO end | (HEAD::TAIL) num := begin assume num_lt_size, simp [list.length], from use.ZERO_LT_ONE_Add (list.length TAIL) end /- Combinatory theorem about nested lists -/ theorem Main_Combinatory_Nested {α : Type} [hsα : has_size α] : ∀{num : ℕ}{ll : list (list α)}, ( (list.length ll) * num < list_size ll ) → --------------------------------- ( ∃(l : list α), l ∈ ll ∧ num < list_size l ) | num [] := begin assume mul_lt_ll, simp [list_size] at mul_lt_ll, from false.elim (use.Not_LT_ZERO mul_lt_ll) end | num (HEAD::TAIL) := begin assume mul_lt_ll, simp [list_size] at mul_lt_ll, with_cases { by_cases num_lt_head : num < size HEAD }, case pos { --If HEAD is big apply exists.intro HEAD, simp [has_mem.mem, list.mem], from num_lt_head }, case neg { --If HEAD isn't big with_cases { by_cases mul_lt_tail : (list.length TAIL) * num < list_size TAIL }, case pos { --If TAIL is big have main_combinatory, from Main_Combinatory_Nested mul_lt_tail, cases main_combinatory with la main_combinatory, cases main_combinatory with mem_la_tail num_lt_la, apply exists.intro la, simp [has_mem.mem, list.mem] at ⊢ mem_la_tail, simp [mem_la_tail], from num_lt_la }, case neg { --If TAIL isn't big rewrite [use.Right_Distrib, use.ONE_Mul, add_comm] at mul_lt_ll, rewrite [←use.GE_iff_Not_LT] at num_lt_head, rewrite [←use.GE_iff_Not_LT] at mul_lt_tail, have not_mul_lt_ll, from use.Add_GE_Add mul_lt_tail num_lt_head, rewrite [use.GE_iff_Not_LT] at not_mul_lt_ll, from absurd mul_lt_ll not_mul_lt_ll } } end /- Methods for counting the number diferent elements in a list -/ def list_set {α : Type u} [eqα : decidable_eq α] : list α → list α | [] := [] | (HEAD::TAIL) := if HEAD ∈ TAIL then list_set TAIL else HEAD :: list_set TAIL def list_filter {α : Type u} [eqα : decidable_eq α] : α → list α → list α | _ [] := [] | a (HEAD::TAIL) := if a = HEAD then HEAD :: list_filter a TAIL else list_filter a TAIL def list_delete {α : Type u} [eqα : decidable_eq α] : α → list α → list α | _ [] := [] | a (HEAD::TAIL) := if a = HEAD then list_delete a TAIL else HEAD :: list_delete a TAIL /- Properties about list set, filter, and delete -/ lemma Length_Set_LE_Length_of_Subset {α : Type u} [eqα : decidable_eq α] : ∀{l1 l2 : list α}, ( ∀(a : α), ( a ∈ l1 ) → ( a ∈ l2 ) ) → --------------------------- ( list.length (list_set l1) ≤ list.length l2 ) | [] l2 := begin assume case_mem, simp [list_set], from use.ZERO_LE (list.length l2) end | (HEAD1::TAIL1) l2 := begin assume case_mem, have head1_mem_l2 : HEAD1 ∈ l2, from begin apply (case_mem HEAD1), simp [has_mem.mem, list.mem] end, have case_mem_tail1 : ∀ (a : α), a ∈ TAIL1 → a ∈ l2, from begin assume loop loop_mem_tail1, simp [has_mem.mem, list.mem] at case_mem, apply (case_mem loop), simp [has_mem.mem, list.mem] at loop_mem_tail1, simp [loop_mem_tail1] end, simp [list_set], with_cases { by_cases head1_mem_tail1 : HEAD1 ∈ TAIL1 }, -- case pos { simp [head1_mem_tail1], from Length_Set_LE_Length_of_Subset case_mem_tail1 }, case neg { simp [head1_mem_tail1], have case_loop : ∀ (a : α), a ∈ TAIL1 → a ∈ list.remove_nth l2 (list.index_of HEAD1 l2), from begin assume loop loop_mem_tail1, have loop_mem_l2, from case_mem_tail1 loop loop_mem_tail1, have case_remove, from use.Mem_Remove_of_Mem_of_Not_Mem head1_mem_tail1 head1_mem_l2, from case_remove loop loop_mem_tail1 loop_mem_l2 end, have loop, from Length_Set_LE_Length_of_Subset case_loop, have case_index, from use.Index_LT_Length_of_Mem head1_mem_l2, rewrite [use.Length_Remove_Nth case_index] at loop, have one_le_l2, from use.LT_of_LE_of_LT (use.ZERO_LE (list.index_of HEAD1 l2)) case_index, rewrite [use.LT_ZERO_iff_LE_ONE] at one_le_l2, rewrite [add_comm, ←use.Sub_Add_Cancel one_le_l2], from use.Add_LE_Add loop (use.LE_Refl 1) } end lemma Mem_of_Mem_Delete {α : Type u} [eqα : decidable_eq α] : ∀{a1 a2 : α}{l : list α}, ( a1 ∈ (list_delete a2 l) ) → --------------------------- ( a1 ∈ l ) | a1 a2 [] := begin assume a1_mem_del, simp [list_delete, has_mem.mem, list.mem] at a1_mem_del, from false.elim a1_mem_del end | a1 a2 (HEAD::TAIL) := begin assume a1_mem_del, simp [list_delete, has_mem.mem, list.mem] at ⊢ a1_mem_del, with_cases { by_cases a2_eq_head : a2 = HEAD }, case pos { -- If HEAD = a2 simp [a2_eq_head] at a1_mem_del, have loop, from Mem_of_Mem_Delete a1_mem_del, simp [has_mem.mem, list.mem] at ⊢ loop, simp [loop] }, case neg { -- If HEAD ≠ a2 simp [a2_eq_head, list.mem] at a1_mem_del, cases a1_mem_del with a1_eq_head a1_mem_del, case or.inl { simp [a1_eq_head] }, case or.inr { have loop, from Mem_of_Mem_Delete a1_mem_del, simp [has_mem.mem, list.mem] at ⊢ loop, simp [loop] } } end lemma Size_Filter_Delete {α : Type u} [eqα : decidable_eq α] : ∀(a : α)(l : list α), --------------------------- ( list_size (list_filter a (list_delete a l)) = 0 ) | a [] := by simp [list_delete, list_filter, list_size] | a (HEAD::TAIL) := begin with_cases { by_cases a_eq_head : a = HEAD }, case pos { -- If a = HEAD simp [a_eq_head, list_delete], from Size_Filter_Delete HEAD TAIL }, case neg { -- If a ≠ HEAD simp [a_eq_head, list_delete, list_filter], from Size_Filter_Delete a TAIL } end lemma Size_Delete_LE_Size {α : Type u} [eqα : decidable_eq α] : ∀(a1 a2 : α)(l : list α), --------------------------- ( list_size (list_filter a1 (list_delete a2 l)) ≤ list_size (list_filter a1 l) ) | a1 a2 [] := by simp [list_delete, list_filter] | a1 a2 (HEAD::TAIL) := begin simp [list_delete], with_cases { by_cases a2_eq_head : a2 = HEAD }, case pos { -- If a2 = HEAD simp [a2_eq_head, list_filter], with_cases { by_cases a1_eq_head : a1 = HEAD }, case pos { -- If a1 = HEAD simp [a1_eq_head, list_size], from use.LE_Add_Left (Size_Delete_LE_Size HEAD HEAD TAIL) (size HEAD) }, case neg { -- If a1 ≠ HEAD simp [a1_eq_head, list_size], from Size_Delete_LE_Size a1 HEAD TAIL } }, case neg { -- If a2 ≠ HEAD simp [a2_eq_head, list_filter], with_cases { by_cases a1_eq_head : a1 = HEAD }, case pos { -- If a1 = HEAD simp [a1_eq_head, list_size], from use.Add_LE_Add (use.LE_Refl (size HEAD)) (Size_Delete_LE_Size HEAD a2 TAIL) }, case neg { -- If a1 ≠ HEAD simp [a1_eq_head, list_size], from Size_Delete_LE_Size a1 a2 TAIL } } end lemma Size_Filter_Delete_EQ_Size {α : Type u} [eqα : decidable_eq α] : ∀(a : α)(l : list α), --------------------------- ( list_size (list_filter a l) + list_size (list_delete a l) = list_size l ) | a [] := by simp [list_delete, list_filter, list_size] | a (HEAD::TAIL) := begin simp [list_filter, list_delete], with_cases { by_cases a_eq_head : a = HEAD }, case pos { -- If a = HEAD simp [a_eq_head, list_size], have loop, from Size_Filter_Delete_EQ_Size HEAD TAIL, rewrite [add_comm] at loop, rewrite [loop, add_comm] }, case neg { -- If a ≠ HEAD simp [a_eq_head, list_size], have loop, from Size_Filter_Delete_EQ_Size a TAIL, rewrite [add_comm] at loop, rewrite [loop, add_comm] } end /- Properties about list set, filter, and delete (Must be left in order) -/ lemma Case_Not_Mem_Del {α : Type u} [eqα : decidable_eq α] : ∀{a1 a2 : α}{l : list α}, ( a2 ≠ a1 ) → ( a1 ∉ l ) → --------------------------- ( a1 ∉ list_delete a2 l ) | a1 a2 [] := by simp [list_delete] | a1 a2 (HEAD::TAIL) := begin assume a1_ne_a2 a1_not_mem, simp [has_mem.mem, list.mem] at a1_not_mem, rewrite [use.Not_Or_iff_And_Not] at a1_not_mem, cases a1_not_mem with a1_ne_head a1_not_mem_tail, -- with_cases { by_cases a2_eq_head : a2 = HEAD }, case pos { -- If a2 = HEAD simp [a2_eq_head, list_delete] at ⊢ a1_ne_a2, rewrite [eq_comm] at a1_ne_head, from Case_Not_Mem_Del a1_ne_head a1_not_mem_tail }, case neg { -- If a2 ≠ HEAD simp [a2_eq_head, list_delete], from use.Not_Or a1_ne_head (Case_Not_Mem_Del a1_ne_a2 a1_not_mem_tail) } end lemma Case_Mem_Del {α : Type u} [eqα : decidable_eq α] : ∀{a1 a2 : α}{l : list α}, ( a2 ≠ a1 ) → ( a1 ∈ l ) → --------------------------- ( a1 ∈ list_delete a2 l ) | a1 a2 [] := by simp [list_delete] | a1 a2 (HEAD::TAIL) := begin assume a1_ne_a2 a1_mem, simp [has_mem.mem, list.mem] at a1_mem, -- with_cases { by_cases a2_eq_head : a2 = HEAD }, case pos { -- If a2 = HEAD simp [a2_eq_head, list_delete] at ⊢ a1_ne_a2, cases a1_mem with a1_eq_head a1_mem_tail, case or.inl { rewrite [eq_comm] at a1_eq_head, from absurd a1_eq_head a1_ne_a2 }, case or.inr { from Case_Mem_Del a1_ne_a2 a1_mem_tail } }, case neg { -- If a2 ≠ HEAD simp [a2_eq_head, list_delete], cases a1_mem with a1_eq_head a1_mem_tail, case or.inl { simp [a1_eq_head] }, case or.inr { simp [Case_Mem_Del a1_ne_a2 a1_mem_tail] } } end lemma Lenght_EQ_Lenght_Set_Delete {α : Type u} [eqα : decidable_eq α] : ∀(a : α)(l : list α), --------------------------- ( list.length (list_set (a::l)) = 1 + list.length (list_set (list_delete a l)) ) | a [] := by simp [list_delete, list_set] | a (HEAD::TAIL) := begin have loop_head, from Lenght_EQ_Lenght_Set_Delete HEAD TAIL, have loop_a, from Lenght_EQ_Lenght_Set_Delete a TAIL, simp [list_delete] at ⊢ loop_head loop_a, with_cases { by_cases a_eq_head : a = HEAD }, case pos { -- If a = HEAD simp [a_eq_head, list_set] at ⊢ loop_head, with_cases { by_cases head_mem_tail : HEAD ∈ TAIL }, case pos { -- If HEAD ∈ TAIL simp [head_mem_tail, list.length] at ⊢ loop_head, from loop_head }, case neg { -- If HEAD ∉ TAIL simp [head_mem_tail, list.length] at ⊢ loop_head, from loop_head } }, case neg { -- If a ≠ HEAD simp [a_eq_head, list_set] at ⊢ loop_a, with_cases { by_cases a_mem_tail : a ∈ TAIL }, case pos { -- If a ∈ TAIL simp [a_mem_tail, list.length] at ⊢ loop_a, with_cases { by_cases head_mem_tail : HEAD ∈ TAIL }, case pos { -- If HEAD ∈ TAIL simp [head_mem_tail, list.length] at ⊢ loop_a, simp [Case_Mem_Del a_eq_head head_mem_tail], from loop_a }, case neg { -- If HEAD ∉ TAIL simp [head_mem_tail, list.length] at ⊢ loop_a, simp [Case_Not_Mem_Del a_eq_head head_mem_tail], simp [loop_a] } }, case neg { -- If a ∉ TAIL simp [a_mem_tail, list.length] at ⊢ loop_a, with_cases { by_cases head_mem_tail : HEAD ∈ TAIL }, case pos { -- If HEAD ∈ TAIL simp [head_mem_tail, list.length] at ⊢ loop_a, simp [Case_Mem_Del a_eq_head head_mem_tail], from loop_a }, case neg { -- If HEAD ∉ TAIL simp [head_mem_tail, list.length] at ⊢ loop_a, simp [Case_Not_Mem_Del a_eq_head head_mem_tail], simp [loop_a] } } } end /- Combinatory theorem about lists (Filter) -/ theorem Main_Combinatory_Filter {α : Type} [eqα : decidable_eq α] : ∀(num : ℕ)(l : list α), ( list.length (list_set l) * num < list_size l ) → --------------------------------- ( ∃(a : α), a ∈ l ∧ num < list_size (list_filter a l) ) | num [] := begin assume mul_lt_l, simp [list_size] at mul_lt_l, from false.elim (use.Not_LT_ZERO mul_lt_l) end | num (HEAD::TAIL) := begin assume mul_lt_l, with_cases { by_cases num_lt_head : num < 1 + list_size (list_filter HEAD TAIL) }, case pos { -- If list_filter HEAD (HEAD::TAIL) is big apply exists.intro HEAD, simp [list_filter, list_size, has_mem.mem, list.mem, size, has_size.size], from num_lt_head }, case neg { -- If list_filter HEAD (HEAD::TAIL) isn't big with_cases { by_cases mul_lt_del : list.length (list_set (list_delete HEAD TAIL)) * num < list_size (list_delete HEAD TAIL) }, case pos { -- If list_delete HEAD (HEAD::TAIL) is big have main_combinatory : ∃(a : α), a ∈ list_delete HEAD TAIL ∧ num < list_size (list_filter a (list_delete HEAD TAIL)), from Main_Combinatory_Filter num (list_delete HEAD TAIL) mul_lt_del, -- sorry, cases main_combinatory with a main_combinatory, cases main_combinatory with a_mem_del num_lt_a, apply exists.intro a, simp [has_mem.mem, list.mem] at ⊢ a_mem_del, simp [a_mem_del, list_filter], with_cases { by_cases a_eq_head : a = HEAD }, case pos { -- If a = HEAD rewrite [a_eq_head] at num_lt_a a_mem_del, rewrite [Size_Filter_Delete HEAD TAIL] at num_lt_a, from absurd num_lt_a use.Not_LT_ZERO }, case neg { -- If a ≠ HEAD simp [a_eq_head], have a_mem_tail, from Mem_of_Mem_Delete a_mem_del, simp [has_mem.mem] at a_mem_tail, simp [a_mem_tail], from use.LT_of_LT_of_LE num_lt_a (Size_Delete_LE_Size a HEAD TAIL) } }, case neg { --If list_delete HEAD (HEAD::TAIL) isn't big rewrite [Lenght_EQ_Lenght_Set_Delete, use.Right_Distrib] at mul_lt_l, simp [list_delete, list_size, size, has_size.size] at mul_lt_l, rewrite [←use.GE_iff_Not_LT] at mul_lt_del, rewrite [←use.GE_iff_Not_LT] at num_lt_head, have mul_ge_l, from use.Add_GE_Add num_lt_head mul_lt_del, rewrite [add_assoc, Size_Filter_Delete_EQ_Size] at mul_ge_l, rewrite [use.GE_iff_Not_LT] at mul_ge_l, -- This proof is the same as Main_Combinatory_Nested from absurd mul_lt_l mul_ge_l } } end using_well_founded -- So that the recursion is explicitly done over the list-type { rel_tac := λ _ _, `[exact ⟨_, measure_wf (λ t, list.sizeof t.snd)⟩] } -- L∃∀N gives us a warning that the recursion at Main_Combinatory_Filter is not well-founded: -- @has_well_founded.r (Σ' (num : ℕ), list α) -- (@has_well_founded.mk (Σ' (num : ℕ), list α) -- (@measure (Σ' (num : ℕ), list α) -- (λ (t : Σ' (num : ℕ), list α), -- @list.sizeof α (default_has_sizeof α) (@psigma.snd ℕ (λ (num : ℕ), list α) t))) -- _) -- The nested exception message contains the failure state for the decreasing tactic: -- ⊢ list.sizeof (list_delete HEAD TAIL) < 1 + list.sizeof TAIL -- However, we show this target is true for all type-instances -- Proving that, despite the warning, the recursion used in Main_Combinatory_Filter is well-founded lemma Well_Founded_Delete {α : Type u} [eqα : decidable_eq α] : ∀(head : α)(tail : list α), --------------------------------- ( list.sizeof (list_delete head tail) < 1 + list.sizeof tail ) | head [] := begin simp [list_delete], simp [list.sizeof], have del_lt_sizeof, from use.Add_LT_Add_Left use.ZERO_LT_ONE 1, rewrite [use.Add_ZERO] at del_lt_sizeof, from del_lt_sizeof end | head (HEAD::TAIL) := begin simp [list_delete], with_cases { by_cases eq_head : head = HEAD }, case pos { -- If head = HEAD simp [eq_head], simp [list.sizeof], have loop_0, from Well_Founded_Delete HEAD TAIL, have loop_1, from use.LT_Add_Right loop_0 (sizeof HEAD), rewrite [add_assoc] at loop_1, from use.LT_Add_Left loop_1 1 }, case neg { -- If head ≠ HEAD simp [eq_head], simp [list.sizeof], have loop_0, from Well_Founded_Delete head TAIL, have loop_1, from use.Add_LT_Add_Right loop_0 (sizeof HEAD), rewrite [add_assoc, add_comm] at loop_1, from use.Add_LT_Add_Left loop_1 1 } end end aux /- Type Definitions and Properties -/ namespace types /- Inductive Types: Formula -/ inductive formula | atom (SBL : ℕ) : formula | implication (ANT CON : formula) : formula export formula (atom implication) notation #SBL := formula.atom SBL notation ANT >> CON := formula.implication ANT CON /- Inductive Types: Proof-Graph -/ inductive node_option | leaf : node_option | node : node_option export node_option (leaf node) inductive tree -- Top Formulas and Hypotheses | leaf (LVL : ℕ) (FML : formula) : tree -- Nodes resulting from →Introduction | u_tree (LVL : ℕ) (FML : formula) (UNI : tree) : tree -- Nodes resulting from →Elimination | lr_tree (LVL : ℕ) (FML : formula) (MNR MJR : tree) : tree export tree (leaf u_tree lr_tree) inductive branch -- The First Node of the Branch (Always a leaf when a Proof-Branch) | leaf (BRC : branch) (OPT : node_option) (LVL : ℕ) (FML : formula) : branch -- Nodes resulting from →Introduction | u_branch (BRC : branch) (OPT : node_option) (LVL : ℕ) (FML : formula) : branch -- Nodes resulting from →Elimination, connected to their Minor Premise | l_branch (BRC : branch) (OPT : node_option) (LVL : ℕ) (FML : formula) : branch -- Nodes resulting from →Elimination, connected to their Major Premise | r_branch (BRC : branch) (OPT : node_option) (LVL : ℕ) (FML : formula) : branch -- Pointer to the Ending of the Branch (Always the Root of the Proof-Tree before Pruning) | root : branch export branch (leaf u_branch l_branch r_branch root) /- Instances of Decidability (Equality): Formula -/ instance formula.decidable_eq : ∀(f1 f2 : formula), --------------------------------- decidable (f1 = f2) -- ATOM: | (atom SBL1) (atom SBL2) := begin simp [eq.decidable], from @nat.decidable_eq SBL1 SBL2 end | (atom _) (implication _ _) := begin simp [eq.decidable], from is_false not_false end -- IMPLICATION: | (implication _ _) (atom _) := begin simp [eq.decidable], from is_false not_false end | (implication ANT1 CON1) (implication ANT2 CON2) := begin simp [eq.decidable], from @and.decidable (ANT1 = ANT2) (CON1 = CON2) (@formula.decidable_eq ANT1 ANT2) (@formula.decidable_eq CON1 CON2) end /- Instances of Decidability (Equality): Proof-Graph -/ instance node_option.decidable_eq : ∀(opt1 opt2 : node_option), --------------------------------- decidable (opt1 = opt2) -- LEAF: | leaf leaf := begin simp [eq.decidable], from is_true trivial end | leaf node := begin simp [eq.decidable], from is_false not_false end -- NODE: | node leaf := begin simp [eq.decidable], from is_false not_false end | node node := begin simp [eq.decidable], from is_true trivial end instance tree.decidable_eq : ∀(t1 t2 : tree), --------------------------------- decidable (t1 = t2) -- LEAF: | (leaf LVL1 FML1) (leaf LVL2 FML2) := begin simp [eq.decidable], from @and.decidable (LVL1 = LVL2) (FML1 = FML2) (@nat.decidable_eq LVL1 LVL2) (@formula.decidable_eq FML1 FML2) end | (leaf _ _) (u_tree _ _ _) := begin simp [eq.decidable], from is_false not_false end | (leaf _ _) (lr_tree _ _ _ _) := begin simp [eq.decidable], from is_false not_false end -- U_Tree: | (u_tree _ _ UNI1) (leaf _ _) := begin simp [eq.decidable], from is_false not_false end | (u_tree LVL1 FML1 UNI1) (u_tree LVL2 FML2 UNI2) := begin simp [eq.decidable], have dec_and1, from @and.decidable (FML1 = FML2) (UNI1 = UNI2) (@formula.decidable_eq FML1 FML2) (@tree.decidable_eq UNI1 UNI2), from @and.decidable (LVL1 = LVL2) (FML1 = FML2 ∧ UNI1 = UNI2) (@nat.decidable_eq LVL1 LVL2) dec_and1 end | (u_tree _ _ _) (lr_tree _ _ _ _) := begin simp [eq.decidable], from is_false not_false end -- LR_Tree: | (lr_tree _ _ MNR1 MJR1) (leaf _ _) := begin simp [eq.decidable], from is_false not_false end | (lr_tree _ _ MNR1 MJR1) (u_tree _ _ _) := begin simp [eq.decidable], from is_false not_false end | (lr_tree LVL1 FML1 MNR1 MJR1) (lr_tree LVL2 FML2 MNR2 MJR2) := begin simp [eq.decidable], have dec_and1, from @and.decidable (MNR1 = MNR2) (MJR1 = MJR2) (@tree.decidable_eq MNR1 MNR2) (@tree.decidable_eq MJR1 MJR2), have dec_and2, from @and.decidable (FML1 = FML2) (MNR1 = MNR2 ∧ MJR1 = MJR2) (@formula.decidable_eq FML1 FML2) dec_and1, from @and.decidable (LVL1 = LVL2) (FML1 = FML2 ∧ MNR1 = MNR2 ∧ MJR1 = MJR2) (@nat.decidable_eq LVL1 LVL2) dec_and2 end instance branch.decidable_eq : ∀(p1 p2 : branch), --------------------------------- decidable (p1 = p2) -- LEAF: | (leaf BRC1 OPT1 LVL1 FML1) (leaf BRC2 OPT2 LVL2 FML2) := begin simp [eq.decidable], have dec_and1, from @and.decidable (LVL1 = LVL2) (FML1 = FML2) (@nat.decidable_eq LVL1 LVL2) (@formula.decidable_eq FML1 FML2), have dec_and2, from @and.decidable (OPT1 = OPT2) (LVL1 = LVL2 ∧ FML1 = FML2) (@node_option.decidable_eq OPT1 OPT2) dec_and1, from @and.decidable (BRC1 = BRC2) (OPT1 = OPT2 ∧ LVL1 = LVL2 ∧ FML1 = FML2) (@branch.decidable_eq BRC1 BRC2) dec_and2 end | (leaf _ _ _ _) (u_branch _ _ _ _) := begin simp [eq.decidable], from is_false not_false end | (leaf _ _ _ _) (l_branch _ _ _ _) := begin simp [eq.decidable], from is_false not_false end | (leaf _ _ _ _) (r_branch _ _ _ _) := begin simp [eq.decidable], from is_false not_false end | (leaf _ _ _ _) root := begin simp [eq.decidable], from is_false not_false end -- U_Path: | (u_branch _ _ _ _) (leaf _ _ _ _) := begin simp [eq.decidable], from is_false not_false end | (u_branch BRC1 OPT1 LVL1 FML1) (u_branch BRC2 OPT2 LVL2 FML2) := begin simp [eq.decidable], have dec_and1, from @and.decidable (LVL1 = LVL2) (FML1 = FML2) (@nat.decidable_eq LVL1 LVL2) (@formula.decidable_eq FML1 FML2), have dec_and2, from @and.decidable (OPT1 = OPT2) (LVL1 = LVL2 ∧ FML1 = FML2) (@node_option.decidable_eq OPT1 OPT2) dec_and1, from @and.decidable (BRC1 = BRC2) (OPT1 = OPT2 ∧ LVL1 = LVL2 ∧ FML1 = FML2) (@branch.decidable_eq BRC1 BRC2) dec_and2 end | (u_branch _ _ _ _) (l_branch _ _ _ _) := begin simp [eq.decidable], from is_false not_false end | (u_branch _ _ _ _) (r_branch _ _ _ _) := begin simp [eq.decidable], from is_false not_false end | (u_branch _ _ _ _) root := begin simp [eq.decidable], from is_false not_false end -- L_Path: | (l_branch _ _ _ _) (leaf _ _ _ _) := begin simp [eq.decidable], from is_false not_false end | (l_branch _ _ _ _) (u_branch _ _ _ _) := begin simp [eq.decidable], from is_false not_false end | (l_branch BRC1 OPT1 LVL1 FML1) (l_branch BRC2 OPT2 LVL2 FML2) := begin simp [eq.decidable], have dec_and1, from @and.decidable (LVL1 = LVL2) (FML1 = FML2) (@nat.decidable_eq LVL1 LVL2) (@formula.decidable_eq FML1 FML2), have dec_and2, from @and.decidable (OPT1 = OPT2) (LVL1 = LVL2 ∧ FML1 = FML2) (@node_option.decidable_eq OPT1 OPT2) dec_and1, from @and.decidable (BRC1 = BRC2) (OPT1 = OPT2 ∧ LVL1 = LVL2 ∧ FML1 = FML2) (@branch.decidable_eq BRC1 BRC2) dec_and2 end | (l_branch _ _ _ _) (r_branch _ _ _ _) := begin simp [eq.decidable], from is_false not_false end | (l_branch _ _ _ _) root := begin simp [eq.decidable], from is_false not_false end -- R_Path: | (r_branch _ _ _ _) (leaf _ _ _ _) := begin simp [eq.decidable], from is_false not_false end | (r_branch _ _ _ _) (u_branch _ _ _ _) := begin simp [eq.decidable], from is_false not_false end | (r_branch _ _ _ _) (l_branch _ _ _ _) := begin simp [eq.decidable], from is_false not_false end | (r_branch BRC1 OPT1 LVL1 FML1) (r_branch BRC2 OPT2 LVL2 FML2) := begin simp [eq.decidable], have dec_and1, from @and.decidable (LVL1 = LVL2) (FML1 = FML2) (@nat.decidable_eq LVL1 LVL2) (@formula.decidable_eq FML1 FML2), have dec_and2, from @and.decidable (OPT1 = OPT2) (LVL1 = LVL2 ∧ FML1 = FML2) (@node_option.decidable_eq OPT1 OPT2) dec_and1, from @and.decidable (BRC1 = BRC2) (OPT1 = OPT2 ∧ LVL1 = LVL2 ∧ FML1 = FML2) (@branch.decidable_eq BRC1 BRC2) dec_and2 end | (r_branch _ _ _ _) root := begin simp [eq.decidable], from is_false not_false end -- ROOT: | root (leaf _ _ _ _) := begin simp [eq.decidable], from is_false not_false end | root (u_branch _ _ _ _) := begin simp [eq.decidable], from is_false not_false end | root (l_branch _ _ _ _) := begin simp [eq.decidable], from is_false not_false end | root (r_branch _ _ _ _) := begin simp [eq.decidable], from is_false not_false end | root root := begin simp [eq.decidable], from is_true trivial end /- Get Methods: Formula -/ def is_atomic : formula → Prop | (atom _) := true | (implication _ _) := false instance formula.is_atomic : ∀(f : formula), --------------------------------- decidable (is_atomic f) | (atom _) := begin simp [is_atomic], from is_true trivial end | (implication _ _) := begin simp [is_atomic], from is_false not_false end def not_atomic : formula → Prop | (atom _) := false | (implication _ _) := true instance formula.not_atomic : ∀(f : formula), --------------------------------- decidable (not_atomic f) | (atom _) := begin simp [not_atomic], from is_false not_false end | (implication _ _) := begin simp [not_atomic], from is_true trivial end def get_antecedent : formula → formula | (atom SBL) := #0 -- NULL | (implication ANT _) := ANT def get_consequent : formula → formula | (atom SBL) := #0 -- NULL | (implication _ CON) := CON /- Get Methods: Proof-Graph -/ def not_root : branch → Prop | (leaf _ _ _ _) := true | (u_branch _ _ _ _) := true | (l_branch _ _ _ _) := true | (r_branch _ _ _ _) := true | root := false instance branch.not_root : ∀(b : branch), --------------------------------- decidable (not_root b) | (leaf _ _ _ _) := begin simp [not_root], from is_true trivial end | (u_branch _ _ _ _) := begin simp [not_root], from is_true trivial end | (l_branch _ _ _ _) := begin simp [not_root], from is_true trivial end | (r_branch _ _ _ _) := begin simp [not_root], from is_true trivial end | root := begin simp [not_root], from is_false not_false end def get_option : branch → node_option | (leaf _ OPT _ _) := OPT | (u_branch _ OPT _ _) := OPT | (l_branch _ OPT _ _) := OPT | (r_branch _ OPT _ _) := OPT | root := node -- NULL def get_level : branch → ℕ | (leaf _ _ LVL _) := LVL | (u_branch _ _ LVL _) := LVL | (l_branch _ _ LVL _) := LVL | (r_branch _ _ LVL _) := LVL | root := 0 -- NULL def get_formula : branch → formula | (leaf _ _ _ FML) := FML | (u_branch _ _ _ FML) := FML | (l_branch _ _ _ FML) := FML | (r_branch _ _ _ FML) := FML | root := #0 -- NULL /- Numbber of Levels and Formulas -/ def list_levels : tree → list (ℕ) | (leaf LVL _) := [LVL] | (u_tree LVL _ UNI) := if LVL ∈ list_levels UNI then list_levels UNI else [LVL] ++ list_levels UNI | (lr_tree LVL _ MNR MJR) := if LVL ∈ (list_levels MNR ∩ list_levels MJR) then (list_levels MNR ∩ list_levels MJR) else [LVL] ++ (list_levels MNR ∩ list_levels MJR) def list_formulas : tree → list (formula) | (leaf _ FML) := [FML] | (u_tree _ FML UNI) := if FML ∈ list_formulas UNI then list_formulas UNI else [FML] ++ list_formulas UNI | (lr_tree _ FML MNR MJR) := if FML ∈ (list_formulas MNR ∩ list_formulas MJR) then (list_formulas MNR ∩ list_formulas MJR) else [FML] ++ (list_formulas MNR ∩ list_formulas MJR) def count_levels : tree → ℕ | t := list.length (list_levels t) def count_formulas : tree → ℕ | t := list.length (list_formulas t) /- For this proof, trees are viewed as lists of nodes(which are also trees) -/ -- The lists are arranged in an orderly fashion, splitting the tree by types of node, levels, and formulas -- The lists return a branch from the original tree's root to a node given by the by type/level/formula def loop_tree_option_level_formula : branch → tree → node_option → ℕ → formula → list (branch) -- Matched node_option with the type of tree constructor | BRC (leaf LVL FML) leaf lvl fml := if LVL=lvl ∧ FML=fml then [leaf BRC leaf LVL FML] else [] | BRC (u_tree LVL FML UNI) node lvl fml := if LVL=lvl ∧ FML=fml then [leaf BRC node LVL FML] else loop_tree_option_level_formula (u_branch BRC node LVL FML) UNI node lvl fml | BRC (lr_tree LVL FML MNR MJR) node lvl fml := if LVL=lvl ∧ FML=fml then [leaf BRC node LVL FML] else loop_tree_option_level_formula (l_branch BRC node LVL FML) MNR node lvl fml ++ loop_tree_option_level_formula (r_branch BRC node LVL FML) MJR node lvl fml -- Mismatched node_option with the type of tree constructor | BRC (leaf LVL FML) node lvl fml := [] | BRC (u_tree LVL FML UNI) leaf lvl fml := loop_tree_option_level_formula (u_branch BRC node LVL FML) UNI leaf lvl fml | BRC (lr_tree LVL FML MNR MJR) leaf lvl fml := loop_tree_option_level_formula (l_branch BRC node LVL FML) MNR leaf lvl fml ++ loop_tree_option_level_formula (r_branch BRC node LVL FML) MJR leaf lvl fml -- Returns all the nodes in the tree, with a given constructor, at a given level, and with a specific formula def list_tree_option_level_formula : tree → node_option → ℕ → formula → list (branch) | t opt lvl fml := loop_tree_option_level_formula root t opt lvl fml -- Returns all the nodes in the tree, with a given constructor, and at a given level def loop_tree_option_level : tree → node_option → ℕ → list (formula) → list (list (branch)) | t opt lvl [] := [] | t opt lvl (HEAD::TAIL) := [list_tree_option_level_formula t opt lvl HEAD] ++ loop_tree_option_level t opt lvl TAIL def list_tree_option_level : tree → node_option → ℕ → list (list (branch)) | t opt lvl := loop_tree_option_level t opt lvl (list_formulas t) -- Returns all the nodes in the tree, with a given constructor def loop_tree_option :tree → node_option → list (ℕ) → list (list (list (branch))) | t opt [] := [] | t opt (HEAD::TAIL) := [list_tree_option_level t opt HEAD] ++ loop_tree_option t opt TAIL def list_tree_option : tree → node_option → list (list (list (branch))) | t opt := loop_tree_option t opt (list_levels t) -- Returns all the nodes in the tree def list_tree : tree → list (list (list (list (branch)))) | t := [list_tree_option t leaf] ++ [list_tree_option t node] /- Prooving the correctness of the list_tree_option_level_formula method -/ lemma Loop_Level_Formula_Option : ∀(mem b : branch)(t : tree)(opt : node_option)(lvl : ℕ)(fml : formula), ( mem ∈ loop_tree_option_level_formula b t opt lvl fml ) → --------------------------- ( (get_option mem = opt) ∧ (get_level mem = lvl) ∧ (get_formula mem = fml) ) -- When mem and opt match | mem BRC (leaf LVL FML) leaf lvl fml := begin assume mem_node, -- Simplifying ∈ at the condition(mem_node) simp [loop_tree_option_level_formula] at mem_node, simp [has_mem.mem] at mem_node, simp [use.ITE_Distribution (list.mem mem)] at mem_node, simp [list.mem] at mem_node, -- Cases over (LVL=lvl ∧ FML=fml) with_cases { by_cases and_eq : (LVL=lvl ∧ FML=fml) }, case pos { simp [and_eq] at mem_node, simp [mem_node, get_option, get_level, get_formula] }, -- The case where ¬(LVL=lvl ∧ FML=fml) is impossible, since b ∉ [] case neg { simp [and_eq] at mem_node, from false.elim mem_node } end | mem BRC (u_tree LVL FML UNI) node lvl fml := begin assume mem_node, -- Simplifying ∈ at the condition(mem_node) simp [loop_tree_option_level_formula] at mem_node, simp [has_mem.mem] at mem_node, simp [use.ITE_Distribution (list.mem mem)] at mem_node, simp [list.mem] at mem_node, -- Cases over (LVL=lvl ∧ FML=fml) with_cases { by_cases and_eq : (LVL=lvl ∧ FML=fml) }, case pos { simp [and_eq] at mem_node, simp [mem_node, get_option, get_level, get_formula] }, -- The case where ¬(LVL=lvl ∧ FML=fml) continues up the single child case neg { simp [and_eq] at mem_node, from Loop_Level_Formula_Option mem (u_branch BRC node LVL FML) UNI node lvl fml mem_node } end | mem BRC (lr_tree LVL FML MNR MJR) node lvl fml := begin assume mem_node, -- Simplifying ∈ at the condition(mem_node) simp [loop_tree_option_level_formula] at mem_node, simp [has_mem.mem] at mem_node, simp [use.ITE_Distribution (list.mem mem)] at mem_node, simp [list.mem] at mem_node, -- Cases over (LVL=lvl ∧ FML=fml) with_cases { by_cases and_eq : (LVL=lvl ∧ FML=fml) }, case pos { simp [and_eq] at mem_node, simp [mem_node, get_option, get_level, get_formula] }, -- The case where ¬(LVL=lvl ∧ FML=fml) continues up both children case neg { simp [and_eq] at mem_node, -- Using the relation between append[++] and or[∨] regarding item membership over lists rewrite [use.Mem_Append] at mem_node, cases mem_node with mem_node mem_node, case or.inl { from Loop_Level_Formula_Option mem (l_branch BRC node LVL FML) MNR node lvl fml mem_node }, case or.inr { from Loop_Level_Formula_Option mem (r_branch BRC node LVL FML) MJR node lvl fml mem_node } } end -- When mem and opt don't match | mem BRC (leaf LVL FML) node lvl fml := by simp [loop_tree_option_level_formula] | mem BRC (u_tree LVL FML UNI) leaf lvl fml := begin assume mem_node, simp [loop_tree_option_level_formula] at mem_node, from Loop_Level_Formula_Option mem (u_branch BRC node LVL FML) UNI leaf lvl fml mem_node end | mem BRC (lr_tree LVL FML MNR MJR) leaf lvl fml := begin simp [loop_tree_option_level_formula], assume mem_node, cases mem_node, case or.inl { from Loop_Level_Formula_Option mem (l_branch BRC node LVL FML) MNR leaf lvl fml mem_node }, case or.inr { from Loop_Level_Formula_Option mem (r_branch BRC node LVL FML) MJR leaf lvl fml mem_node } end lemma From_Level_Formula_Option : ∀(mem : branch)(t : tree)(opt : node_option)(lvl : ℕ)(fml : formula), ( mem ∈ list_tree_option_level_formula t opt lvl fml ) → --------------------------- ( (get_option mem = opt) ∧ (get_level mem = lvl) ∧ (get_formula mem = fml) ) | mem t opt lvl fml := begin assume mem_node, simp [list_tree_option_level_formula] at mem_node, from Loop_Level_Formula_Option mem root t opt lvl fml mem_node end end types export types.formula (atom implication) export types.node_option (leaf node) export types.tree (leaf u_tree lr_tree) export types.branch (leaf u_branch l_branch r_branch root) /- Proof: Leaf Redundancy -/ namespace p_leaf /- Restrictions Regarding Proof-Trees -/ -- Trees must be finite, meaning that every node must have a path ending on a leaf def is_finite : types.tree → Prop | t := ∀(lvl : ℕ), --------------------------- ( aux.list_size (types.list_tree_option_level t node lvl) ≤ aux.list_size (types.list_tree_option t leaf) ) lemma Case_Option : ∀(t : types.tree), ∀(lll : list (list (list (types.branch)))), ( lll ∈ (types.list_tree t ) ) → --------------------------- ( ∃(opt : types.node_option), lll = types.list_tree_option t opt ) | t lll := begin assume or_eq, simp [types.list_tree] at or_eq, -- ∨-Elimination cases or_eq with eq_leaf eq_node, case or.inl { from exists.intro leaf eq_leaf }, case or.inr { from exists.intro node eq_node } end lemma Length_Tree : ∀(t : types.tree), --------------------------- ( 2 = list.length (types.list_tree t) ) | t := by simp [types.list_tree] lemma Tree_to_Option : ∀(t : types.tree), ∀{num : ℕ}, ( 2 * num < aux.list_size (types.list_tree t) ) → --------------------------- ( ∃(opt : types.node_option), num < aux.list_size (types.list_tree_option t opt) ) | t n := begin assume big_tree, -- Combinatory Property rewrite [Length_Tree t] at big_tree, have main_combinatory, from aux.Main_Combinatory_Nested big_tree, cases main_combinatory with list_opt main_combinatory, cases main_combinatory with list_mem main_combinatory, -- Substitution have case_opt, from Case_Option t list_opt list_mem, cases case_opt with opt case_opt, rewrite [case_opt] at main_combinatory, -- ∃-Introduction from exists.intro opt main_combinatory end lemma Case_Level : ∀(t : types.tree)(opt : types.node_option)(loop : list (ℕ)), ∀(ll : list (list (types.branch))), ( ll ∈ types.loop_tree_option t opt loop ) → --------------------------- ( ∃(lvl : ℕ), lvl ∈ loop ∧ ll = types.list_tree_option_level t opt lvl ) | t opt [] ll := by simp [types.loop_tree_option] | t opt (HEAD::TAIL) ll := begin simp [types.loop_tree_option], assume or_eq_mem, cases or_eq_mem with eq_head list_mem, case or.inl { apply exists.intro HEAD, simp [use.EQ_Refl HEAD], from eq_head }, case or.inr { have case_inductive, from Case_Level t opt TAIL ll list_mem, cases case_inductive with lvl case_inductive, apply exists.intro lvl, cases case_inductive with mem_lvl eq_lllt, simp [mem_lvl], from eq_lllt } end lemma Length_Tree_Option : ∀(t : types.tree)(opt : types.node_option), --------------------------- ( types.count_levels t = list.length (types.list_tree_option t opt) ) | t opt := begin simp [types.list_tree_option, types.count_levels], induction (types.list_levels t), case list.nil { simp [types.loop_tree_option] }, case list.cons { simp [types.loop_tree_option, ih] } end lemma Option_to_Level : ∀(t : types.tree)(opt : types.node_option), ∀{num : ℕ}, ( (types.count_levels t) * num < aux.list_size (types.list_tree_option t opt) ) → --------------------------- ( ∃(lvl : ℕ), lvl ∈ types.list_levels t ∧ num < aux.list_size (types.list_tree_option_level t opt lvl) ) | t opt num := begin assume big_option, -- Combinatory Property rewrite [Length_Tree_Option t opt] at big_option, have main_combinatory, from aux.Main_Combinatory_Nested big_option, cases main_combinatory with list_lvl main_combinatory, cases main_combinatory with list_mem main_combinatory, -- Substitution have case_level, from Case_Level t opt (types.list_levels t) list_lvl list_mem, cases case_level with lvl case_level, cases case_level with mem_lvl case_level, rewrite [case_level] at main_combinatory, -- ∃-Introduction and ∧-Introduction apply exists.intro lvl, from and.intro mem_lvl main_combinatory end lemma Case_Formula : ∀(t : types.tree)(opt : types.node_option)(lvl : ℕ)(loop : list (types.formula)), ∀(l : list (types.branch)), ( l ∈ types.loop_tree_option_level t opt lvl loop ) → --------------------------- ( ∃(fml : types.formula), fml ∈ loop ∧ l = types.list_tree_option_level_formula t opt lvl fml ) | t opt lvl [] ll := by simp [types.loop_tree_option_level] | t opt lvl (HEAD::TAIL) ll := begin simp [types.loop_tree_option_level], assume or_eq_mem, cases or_eq_mem with eq_head list_mem, case or.inl { apply exists.intro HEAD, simp [use.EQ_Refl HEAD], from eq_head }, case or.inr { have case_inductive, from Case_Formula t opt lvl TAIL ll list_mem, cases case_inductive with fml case_inductive, apply exists.intro fml, cases case_inductive with mem_fml eq_llt, simp [mem_fml], from eq_llt } end lemma Length_Tree_Option_Level: ∀(t : types.tree)(opt : types.node_option)(lvl : ℕ), --------------------------- ( types.count_formulas t = list.length (types.list_tree_option_level t opt lvl) ) | t opt lvl := begin simp [types.list_tree_option_level, types.count_formulas], induction (types.list_formulas t), case list.nil { simp [types.loop_tree_option_level] }, case list.cons { simp [types.loop_tree_option_level, ih] } end lemma Level_to_Formula : ∀(t : types.tree)(opt : types.node_option)(lvl : ℕ), ∀{num : ℕ}, ( (types.count_formulas t) * num < aux.list_size (types.list_tree_option_level t opt lvl) ) → --------------------------- ( ∃(fml : types.formula), fml ∈ types.list_formulas t ∧ num < aux.list_size (types.list_tree_option_level_formula t opt lvl fml) ) | t opt lvl num := begin assume big_option_level, -- Combinatory Property rewrite [Length_Tree_Option_Level t opt lvl] at big_option_level, have main_combinatory, from aux.Main_Combinatory_Nested big_option_level, cases main_combinatory with list_fml main_combinatory, cases main_combinatory with list_mem main_combinatory, -- Substitution have case_fml, from Case_Formula t opt lvl (types.list_formulas t) list_fml list_mem, cases case_fml with fml case_fml, cases case_fml with mem_fml case_fml, rewrite [case_fml] at main_combinatory, -- ∃-Introduction and ∧-Introduction apply exists.intro fml, from and.intro mem_fml main_combinatory end lemma Option_to_Leaf : ∀(t : types.tree)(opt : types.node_option), ∀{num : ℕ}, ( is_finite t ) → ( (types.count_levels t) * num < aux.list_size (types.list_tree_option t opt) ) → --------------------------- ( num < aux.list_size (types.list_tree_option t leaf) ) | t leaf num := begin assume finite big_option, have levels_pos, from aux.ZERO_LT_Length_of_LT_Size big_option, rewrite [←Length_Tree_Option t leaf] at levels_pos, have le_mul, from use.LE_Mul_Left_of_Pos levels_pos num, from use.LT_of_LE_of_LT le_mul big_option end | t node num := begin assume finite big_option, have big_lrnode_level, from Option_to_Level t node big_option, cases big_lrnode_level with lvl big_lrnode_level, cases big_lrnode_level with mem_lvl big_lrnode, from use.LT_of_LT_of_LE big_lrnode (finite lvl) end theorem Main_Theorem_Leaves : ∀(t : types.tree)(mul num : ℕ), ( is_finite t ) → ( mul = (2 * (types.count_levels t * (types.count_levels t * (types.count_formulas t * (types.count_formulas t * num))))) ) → ( mul < aux.list_size (types.list_tree t) ) → --------------------------- ( ∃(lvl : ℕ)(fml : types.formula), lvl ∈ types.list_levels t ∧ fml ∈ types.list_formulas t ∧ (types.count_formulas t) * num < aux.list_size (types.list_tree_option_level_formula t leaf lvl fml) ) | t mul num := begin assume finite mul_constant big_tree, rewrite [mul_constant] at big_tree, -- Find a redundant type-constructor within the tree: have big_option, from Tree_to_Option t big_tree, cases big_option with opt big_option, -- Since the tree is finite, there must be a redundant number of leaves within the tree: have big_leaf, from Option_to_Leaf t opt finite big_option, -- Find a redundant level within the repeating leaf-constructor: have big_leaf_level, from Option_to_Level t leaf big_leaf, cases big_leaf_level with lvl big_leaf_level, cases big_leaf_level with mem_lvl big_leaf_level, apply exists.intro lvl, simp [mem_lvl], -- Find a redundant formula within the repeating leaf-constructor/level: have big_leaf_level_formula, from Level_to_Formula t leaf lvl big_leaf_level, cases big_leaf_level_formula with fml big_leaf_level_formula, cases big_leaf_level_formula with mem_fml big_leaf_level_formula, apply exists.intro fml, simp [mem_fml], from big_leaf_level_formula end end p_leaf /- Proof: Leaf Redundancy Implies Proof-Branch Redundancy -/ namespace p_branch /- Methods Regarding Proof-Branchs (Prop) -/ -- Proofs and Derivations in Natural Deduction can be seen as Proof-Trees -- Proofs have no open formulas, while Derivations may have open formulas -- In a Normal Proof-Tree, every Leaf is part of a Proof-Branch -- A Proof-Branch can be obtained by pruning the Branch which connects its Leaf to the proof's conclusion -- This pruning is done top-down, from the Leaf to either the minor premise of an →ELIMINATION or the proof's conclusion -- Along the pruning, if a visited node in the unpruned Branch is the result of an: -- →ELIMINATION from its major premise: visited node = CON; visited premise = _ >> CON; the Proof-Branch continues -- →ELIMINATION from its minor premise: visited node = some formula; the Proof-Branch ends at the visited premise -- →INTRODUCTION: -- In a Normal Proof-Tree, an →INTRODUCTION can only be followed by an: -- →INTRODUCTION: visited node = _ >> CON; visited premise = CON; the Proof-Branch continues -- →ELIMINATION from its minor premise: visited node = some formula; the Proof-Branch ends at the visited premise -- The proof's conclusion: the Proof-Branch ends at the proof's conclusion -- But no matter where this →INTRODUCTION sequence ends, the formula where it ends determines the sequence -- Every Proof-Branch of a Normal Proof-Tree is either: -- Composed of an →ELIMINATION (from its major premise) part followed by an →INTRODUCTION part -- Composed of an →ELIMINATION (from its major premise) only -- Composed of an →INTRODUCTION only -- A Leaf that is the minor premise of an →ELIMINATION -- In an Atomicaly Expanded Normal Proof-Tree: -- If there is an →ELIMINATION part, it ends in a atomic formula -- If there is an →INTRODUCTION part, it begins in a atomic formula -- That is to say, in an Atomicaly Expanded Normal Proof-Tree: -- The Proof-Branch's Leaf determines completely the →ELIMINATION part -- The Proof-Branch's Ending Formula completely determines the →INTRODUCTION part -- Loops over the →INTRODUCTION part def loop_check_intro : ℕ → types.formula → types.branch → Prop | lvl1 fml1 (u_branch BRC OPT LVL0 FML0) := ( OPT = node ) ∧ ( lvl1 = LVL0+1 ) ∧ ( types.not_atomic FML0 ∧ types.get_consequent FML0 = fml1 ) ∧ loop_check_intro LVL0 FML0 BRC | lvl1 fml1 (l_branch BRC OPT LVL0 FML0) := ( OPT = node ) ∧ ( lvl1 = LVL0+1 ) | lvl1 fml1 root := ( lvl1 = 1 ) | _ _ _ := false -- Loops over the →ELIMINATION part and verifies if the minimal formula is atomic def loop_check_elim : ℕ → types.formula → types.branch → Prop | lvl1 fml1 (u_branch BRC OPT LVL0 FML0) := ( OPT = node ) ∧ ( lvl1 = LVL0+1 ) ∧ ( types.is_atomic fml1 ∧ types.not_atomic FML0 ∧ types.get_consequent FML0 = fml1 ) ∧ loop_check_intro LVL0 FML0 BRC | lvl1 fml1 (l_branch BRC OPT LVL0 FML0) := ( OPT = node ) ∧ ( lvl1 = LVL0+1 ) ∧ ( types.is_atomic fml1 ) | lvl1 fml1 (r_branch BRC OPT LVL0 FML0) := ( OPT = node ) ∧ ( lvl1 = LVL0+1 ) ∧ ( types.not_atomic fml1 ∧ types.get_consequent fml1 = FML0 ) ∧ loop_check_elim LVL0 FML0 BRC | lvl1 fml1 root := ( lvl1 = 1 ) ∧ ( types.is_atomic fml1 ) | _ _ _ := false -- Verifies the type of branch (→ELIMINATION→INTRODUCTION; →ELIMINATION; →INTRODUCTION; Leaf) def check_leaf : ℕ → types.formula → types.branch → Prop | lvl1 fml1 (u_branch BRC OPT LVL0 FML0) := ( OPT = node ) ∧ ( lvl1 = LVL0+1 ) ∧ ( types.is_atomic fml1 ∧ types.not_atomic FML0 ∧ types.get_consequent FML0 = fml1 ) ∧ loop_check_intro LVL0 FML0 BRC | lvl1 fml1 (l_branch BRC OPT LVL0 FML0) := ( OPT = node ) ∧ ( lvl1 = LVL0+1 ) | lvl1 fml1 (r_branch BRC OPT LVL0 FML0) := ( OPT = node ) ∧ ( lvl1 = LVL0+1 ) ∧ ( types.not_atomic fml1 ∧ types.get_consequent fml1 = FML0 ) ∧ loop_check_elim LVL0 FML0 BRC | _ _ _ := false -- To check if a regular Branch, ending at the Proof-Tree's conclusion, can be pruned into a Proof-Branch def check_proof_branch : types.branch → Prop | (leaf BRC leaf LVL0 FML0) := check_leaf LVL0 FML0 BRC | _ := false -- Using check_proof_branch as an if-clause demands a proof of decidability for each method instance types.branch.loop_check_intro : ∀(lvl1 : ℕ)(fml1 : types.formula)(b : types.branch), --------------------------------- decidable (loop_check_intro lvl1 fml1 b) | _ _ (leaf _ _ _ _) := begin simp [loop_check_intro], from is_false not_false end | lvl1 fml1 (u_branch BRC OPT LVL0 FML0) := begin simp [loop_check_intro], have dec_and1, from @and.decidable (types.not_atomic FML0) (types.get_consequent FML0 = fml1) (@types.formula.not_atomic FML0) (@types.formula.decidable_eq (types.get_consequent FML0) fml1), have dec_and2, from @and.decidable (types.not_atomic FML0 ∧ types.get_consequent FML0 = fml1) (loop_check_intro LVL0 FML0 BRC) dec_and1 (@types.branch.loop_check_intro LVL0 FML0 BRC), have dec_and3, from @and.decidable (lvl1 = LVL0+1) ((types.not_atomic FML0 ∧ types.get_consequent FML0 = fml1) ∧ loop_check_intro LVL0 FML0 BRC) (@nat.decidable_eq lvl1 (LVL0+1)) dec_and2, from @and.decidable (OPT = node) (lvl1 = LVL0+1 ∧ (types.not_atomic FML0 ∧ types.get_consequent FML0 = fml1) ∧ loop_check_intro LVL0 FML0 BRC) (@types.node_option.decidable_eq OPT node) dec_and3 end | lvl1 fml1 (l_branch BRC OPT LVL0 FML0) := begin simp [loop_check_intro], from @and.decidable (OPT = node) (lvl1 = LVL0 + 1) (@types.node_option.decidable_eq OPT node) (@nat.decidable_eq lvl1 (LVL0+1)) end | _ _ (r_branch _ _ _ _) := begin simp [loop_check_intro], from is_false not_false end | lvl1 fml1 root := begin simp [loop_check_intro], from @nat.decidable_eq lvl1 1 end instance types.branch.loop_check_elim : ∀(lvl1 : ℕ)(fml1 : types.formula)(b : types.branch), --------------------------------- decidable (loop_check_elim lvl1 fml1 b) | _ _ (leaf _ _ _ _) := begin simp [loop_check_elim], from is_false not_false end | lvl1 fml1 (u_branch BRC OPT LVL0 FML0) := begin simp [loop_check_elim], have dec_and1, from @and.decidable (types.not_atomic FML0) (types.get_consequent FML0 = fml1) (@types.formula.not_atomic FML0) (@types.formula.decidable_eq (types.get_consequent FML0) fml1), have dec_and2, from @and.decidable (types.is_atomic fml1) (types.not_atomic FML0 ∧ types.get_consequent FML0 = fml1) (@types.formula.is_atomic fml1) dec_and1, have dec_and3, from @and.decidable (types.is_atomic fml1 ∧ types.not_atomic FML0 ∧ types.get_consequent FML0 = fml1) (loop_check_intro LVL0 FML0 BRC) dec_and2 (@types.branch.loop_check_intro LVL0 FML0 BRC), have dec_and4, from @and.decidable (lvl1 = LVL0+1) ((types.is_atomic fml1 ∧ types.not_atomic FML0 ∧ types.get_consequent FML0 = fml1) ∧ loop_check_intro LVL0 FML0 BRC) (@nat.decidable_eq lvl1 (LVL0+1)) dec_and3, from @and.decidable (OPT = node) (lvl1 = LVL0+1 ∧ (types.is_atomic fml1 ∧ types.not_atomic FML0 ∧ types.get_consequent FML0 = fml1) ∧ loop_check_intro LVL0 FML0 BRC) (@types.node_option.decidable_eq OPT node) dec_and4 end | lvl1 fml1 (l_branch BRC OPT LVL0 FML0) := begin simp [loop_check_elim], have dec_and1, from @and.decidable (lvl1 = LVL0 + 1) (types.is_atomic fml1) (@nat.decidable_eq lvl1 (LVL0+1)) (@types.formula.is_atomic fml1), from @and.decidable (OPT = node) (lvl1 = LVL0 + 1 ∧ types.is_atomic fml1) (@types.node_option.decidable_eq OPT node) dec_and1 end | lvl1 fml1 (r_branch BRC OPT LVL0 FML0) := begin simp [loop_check_elim], have dec_and1, from @and.decidable (types.not_atomic fml1) (types.get_consequent fml1 = FML0) (@types.formula.not_atomic fml1) (@types.formula.decidable_eq (types.get_consequent fml1) FML0), have dec_and2, from @and.decidable (types.not_atomic fml1 ∧ types.get_consequent fml1 = FML0) (loop_check_elim LVL0 FML0 BRC) dec_and1 (@types.branch.loop_check_elim LVL0 FML0 BRC), have dec_and3, from @and.decidable (lvl1 = LVL0+1) ((types.not_atomic fml1 ∧ types.get_consequent fml1 = FML0) ∧ loop_check_elim LVL0 FML0 BRC) (@nat.decidable_eq lvl1 (LVL0+1)) dec_and2, from @and.decidable (OPT = node) (lvl1 = LVL0+1 ∧ (types.not_atomic fml1 ∧ types.get_consequent fml1 = FML0) ∧ loop_check_elim LVL0 FML0 BRC) (@types.node_option.decidable_eq OPT node) dec_and3 end | lvl1 fml1 root := begin simp [loop_check_elim], from @and.decidable (lvl1 = 1) (types.is_atomic fml1) (@nat.decidable_eq lvl1 1) (@types.formula.is_atomic fml1) end instance types.branch.check_leaf : ∀(lvl1 : ℕ)(fml1 : types.formula)(b : types.branch), --------------------------------- decidable (check_leaf lvl1 fml1 b) | _ _ (leaf _ _ _ _) := begin simp [check_leaf], from is_false not_false end | lvl1 fml1 (u_branch BRC OPT LVL0 FML0) := begin simp [check_leaf], have dec_and1, from @and.decidable (types.not_atomic FML0) (types.get_consequent FML0 = fml1) (@types.formula.not_atomic FML0) (@types.formula.decidable_eq (types.get_consequent FML0) fml1), have dec_and2, from @and.decidable (types.is_atomic fml1) (types.not_atomic FML0 ∧ types.get_consequent FML0 = fml1) (@types.formula.is_atomic fml1) dec_and1, have dec_and3, from @and.decidable (types.is_atomic fml1 ∧ types.not_atomic FML0 ∧ types.get_consequent FML0 = fml1) (loop_check_intro LVL0 FML0 BRC) dec_and2 (@types.branch.loop_check_intro LVL0 FML0 BRC), have dec_and4, from @and.decidable (lvl1 = LVL0+1) ((types.is_atomic fml1 ∧ types.not_atomic FML0 ∧ types.get_consequent FML0 = fml1) ∧ loop_check_intro LVL0 FML0 BRC) (@nat.decidable_eq lvl1 (LVL0+1)) dec_and3, from @and.decidable (OPT = node) (lvl1 = LVL0+1 ∧ (types.is_atomic fml1 ∧ types.not_atomic FML0 ∧ types.get_consequent FML0 = fml1) ∧ loop_check_intro LVL0 FML0 BRC) (@types.node_option.decidable_eq OPT node) dec_and4 end | lvl1 fml1 (l_branch BRC OPT LVL0 FML0) := begin simp [check_leaf], from @and.decidable (OPT = node) (lvl1 = LVL0 + 1) (@types.node_option.decidable_eq OPT node) (@nat.decidable_eq lvl1 (LVL0+1)) end | lvl1 fml1 (r_branch BRC OPT LVL0 FML0) := begin simp [check_leaf], have dec_and1, from @and.decidable (types.not_atomic fml1) (types.get_consequent fml1 = FML0) (@types.formula.not_atomic fml1) (@types.formula.decidable_eq (types.get_consequent fml1) FML0), have dec_and2, from @and.decidable (types.not_atomic fml1 ∧ types.get_consequent fml1 = FML0) (loop_check_elim LVL0 FML0 BRC) dec_and1 (@types.branch.loop_check_elim LVL0 FML0 BRC), have dec_and3, from @and.decidable (lvl1 = LVL0+1) ((types.not_atomic fml1 ∧ types.get_consequent fml1 = FML0) ∧ loop_check_elim LVL0 FML0 BRC) (@nat.decidable_eq lvl1 (LVL0+1)) dec_and2, from @and.decidable (OPT = node) (lvl1 = LVL0+1 ∧ (types.not_atomic fml1 ∧ types.get_consequent fml1 = FML0) ∧ loop_check_elim LVL0 FML0 BRC) (@types.node_option.decidable_eq OPT node) dec_and3 end | _ _ root := begin simp [check_leaf], from is_false not_false end instance types.branch.check_proof_branch : ∀(b : types.branch), --------------------------------- decidable (check_proof_branch b) | (leaf BRC leaf LVL0 FML0) := begin simp [check_proof_branch], from @types.branch.check_leaf LVL0 FML0 BRC end | (leaf _ node _ _) := begin simp [check_proof_branch], from is_false not_false end | (u_branch _ _ _ _) := begin simp [check_proof_branch], from is_false not_false end | (l_branch _ _ _ _) := begin simp [check_proof_branch], from is_false not_false end | (r_branch _ _ _ _) := begin simp [check_proof_branch], from is_false not_false end | root := begin simp [check_proof_branch], from is_false not_false end /- Methods Regarding Proof-Branchs (Formulas) -/ -- Finally, the pruning, per se def loop_prune_intro : ℕ → types.formula → types.branch → types.formula | lvl1 fml1 (u_branch BRC OPT LVL0 FML0) := if loop_check_intro lvl1 fml1 (u_branch BRC OPT LVL0 FML0) then loop_prune_intro LVL0 FML0 BRC else #0 --false | lvl1 fml1 (l_branch BRC OPT LVL0 FML0) := if loop_check_intro lvl1 fml1 (l_branch BRC OPT LVL0 FML0) then fml1 else #0 --false | lvl1 fml1 root := if loop_check_intro lvl1 fml1 root then fml1 else #0 --false | _ _ _ := #0 --false def loop_prune_elim : ℕ → types.formula → types.branch → types.formula | lvl1 fml1 (u_branch BRC OPT LVL0 FML0) := if loop_check_elim lvl1 fml1 (u_branch BRC OPT LVL0 FML0) then loop_prune_intro LVL0 FML0 BRC else #0 --false | lvl1 fml1 (l_branch BRC OPT LVL0 FML0) := if loop_check_elim lvl1 fml1 (l_branch BRC OPT LVL0 FML0) then fml1 else #0 --false | lvl1 fml1 (r_branch BRC OPT LVL0 FML0) := if loop_check_elim lvl1 fml1 (r_branch BRC OPT LVL0 FML0) then loop_prune_elim LVL0 FML0 BRC else #0 --false | lvl1 fml1 root := if loop_check_elim lvl1 fml1 root then fml1 else #0 --false | _ _ _ := #0 --false def prune_leaf : ℕ → types.formula → types.branch → types.formula | lvl1 fml1 (u_branch BRC OPT LVL0 FML0) := if check_leaf lvl1 fml1 (u_branch BRC OPT LVL0 FML0) then loop_prune_intro LVL0 FML0 BRC else #0 --false | lvl1 fml1 (l_branch BRC OPT LVL0 FML0) := if check_leaf lvl1 fml1 (l_branch BRC OPT LVL0 FML0) then fml1 else #0 --false | lvl1 fml1 (r_branch BRC OPT LVL0 FML0) := if check_leaf lvl1 fml1 (r_branch BRC OPT LVL0 FML0) then loop_prune_elim LVL0 FML0 BRC else #0 --false | _ _ _ := #0 --false def prune_proof_branch : types.branch → types.formula | (leaf BRC leaf LVL0 FML0) := prune_leaf LVL0 FML0 BRC | _ := #0 --false def prune_branch : types.branch → (types.formula) | (leaf BRC leaf LVL FML) := #0 | _ := #0 --false -- Defining a method to prune all the branches in a list of branches def prune_list_branch : list (types.branch) → list (types.formula) | [] := [] | (HEAD::TAIL) := if check_proof_branch HEAD then [prune_branch HEAD] ++ prune_list_branch TAIL else prune_list_branch TAIL -- def list_proof_branch_root : types.tree → types.node_option → ℕ → types.formula→ types.formula → list (types.formula) | t opt lvl1 fml1 fml0 := aux.list_filter fml0 (prune_list_branch (types.list_tree_option_level_formula t leaf lvl1 fml1)) /- Restrictions Regarding Proof-Branchs -/ -- In a Normal Proof-Tree, every Leaf is part of a Proof-Branch def is_normal_check : types.tree → Prop | t := ∀(lvl1 : ℕ)(fml1 : types.formula)(b : types.branch), ( b ∈ (types.list_tree_option_level_formula t leaf lvl1 fml1) ) → --------------------------- ( check_proof_branch b ) def is_normal_mem : types.tree → Prop | t := ∀(lvl1 : ℕ)(fml1 fml0 : types.formula), ( fml0 ∈ prune_list_branch (types.list_tree_option_level_formula t leaf lvl1 fml1) ) → --------------------------- ( fml0 ∈ types.list_formulas t ) lemma Case_Size : ∀{t : types.tree}{lvl1 : ℕ}{fml1 : types.formula}, ∀{l : list (types.branch)}, ( is_normal_check t ) → ( ∀(b : types.branch), b ∈ l → b ∈ types.list_tree_option_level_formula t leaf lvl1 fml1 ) → --------------------------- ( aux.list_size l = aux.list_size (prune_list_branch l) ) | t lvl1 fml1 [] := begin assume normal_check subset, simp [prune_list_branch, aux.list_size] end | t lvl1 fml1 (HEAD::TAIL) := begin assume normal_check subset, have head_mem : HEAD ∈ types.list_tree_option_level_formula t leaf lvl1 fml1, from begin apply (subset HEAD), simp [has_mem.mem, list.mem] end, have tail_subset : ∀(b : types.branch), b ∈ TAIL → b ∈ types.list_tree_option_level_formula t leaf lvl1 fml1, from begin assume loop loop_mem_tail, apply (subset loop), simp [has_mem.mem, list.mem] at ⊢ loop_mem_tail, simp [loop_mem_tail] end, simp [prune_list_branch], rewrite [use.ITE_Distribution (aux.list_size)], simp [aux.list_size, aux.size, aux.has_size.size], have check_head, from normal_check lvl1 fml1 HEAD head_mem, simp [implies, has_mem.mem, list.mem] at check_head, simp [check_head], rewrite [Case_Size normal_check tail_subset] end lemma Normal_Size : ∀(t : types.tree)(lvl1 : ℕ)(fml1 : types.formula), ( is_normal_check t ) → --------------------------- ( aux.list_size (types.list_tree_option_level_formula t leaf lvl1 fml1) = aux.list_size (prune_list_branch (types.list_tree_option_level_formula t leaf lvl1 fml1)) ) | t lvl1 fml1 := begin assume normal_check, from Case_Size normal_check (use.Subset_Self (types.list_tree_option_level_formula t leaf lvl1 fml1)) end lemma Case_Set : ∀(t : types.tree)(lvl1 : ℕ)(fml1 : types.formula)(n : ℕ), ( is_normal_mem t ) → --------------------------- ( list.length (aux.list_set (prune_list_branch (types.list_tree_option_level_formula t leaf lvl1 fml1))) * n ≤ list.length (types.list_formulas t) * n ) | t lvl1 fml1 n := begin assume normal_mem, have set_le_formulas, from aux.Length_Set_LE_Length_of_Subset (normal_mem lvl1 fml1), from use.LE_Mul_of_LE n set_le_formulas end theorem Main_Theorem_Branchs : ∀(t : types.tree)(lvl1 : ℕ)(fml1 : types.formula)(num : ℕ), ( is_normal_check t ) → ( is_normal_mem t ) → ( (types.count_formulas t) * num < aux.list_size (types.list_tree_option_level_formula t leaf lvl1 fml1) ) → --------------------------- ( ∃(fml0 : types.formula), fml0 ∈ prune_list_branch (types.list_tree_option_level_formula t leaf lvl1 fml1) ∧ num < aux.list_size (list_proof_branch_root t leaf lvl1 fml1 fml0) ) | t lvl1 fml1 num := begin assume normal_check normal_mem big_leaf_level_formula, simp [list_proof_branch_root, aux.list_size] at ⊢ big_leaf_level_formula, simp [types.count_formulas, mul_assoc] at big_leaf_level_formula, rewrite [Normal_Size t lvl1 fml1 normal_check] at big_leaf_level_formula, -- have main_combinatory, from aux.Main_Combinatory_Filter num (prune_list_branch (types.list_tree_option_level_formula t leaf lvl1 fml1)), -- have case_set, from Case_Set t lvl1 fml1 num normal_mem, have big_branch, from main_combinatory (use.LT_of_LE_of_LT case_set big_leaf_level_formula), cases big_branch with fml0 big_branch, cases big_branch with mem_fml0 big_branch, apply exists.intro fml0, simp [mem_fml0], from big_branch end end p_branch /- Proof: Theorem of Proof-Branch Redundancy -/ theorem Proof_Branch_Redundancy : ∀(t : types.tree)(mul num : ℕ), ( p_leaf.is_finite t ) → ( p_branch.is_normal_check t ) → ( p_branch.is_normal_mem t ) → ( mul = (2 * (types.count_levels t * (types.count_levels t * (types.count_formulas t * (types.count_formulas t * num))))) ) → ( mul < aux.list_size (types.list_tree t) ) → --------------------------- ( ∃(lvl1 : ℕ)(fml1 fml0 : types.formula), lvl1 ∈ types.list_levels t ∧ fml1 ∈ types.list_formulas t ∧ fml0 ∈ p_branch.prune_list_branch (types.list_tree_option_level_formula t leaf lvl1 fml1) ∧ num < aux.list_size (p_branch.list_proof_branch_root t leaf lvl1 fml1 fml0) ) | t mul num := begin assume finite normal_check normal_mem mul_constant big_tree, -- Find a repeating leaf-constructor/level/formula: have big_leaf_level_formula, from p_leaf.Main_Theorem_Leaves t mul num finite mul_constant big_tree, cases big_leaf_level_formula with lvl1 big_leaf_level_formula, cases big_leaf_level_formula with fml1 big_leaf_level_formula, cases big_leaf_level_formula with mem_lvl1 big_leaf_level_formula, cases big_leaf_level_formula with mem_fml1 big_leaf_level_formula, apply exists.intro lvl1, simp [mem_lvl1], apply exists.intro fml1, simp [mem_fml1], -- Find a redundant proof-branch from the repeating leaf-constructor/level/formula: have big_branch, from p_branch.Main_Theorem_Branchs t lvl1 fml1 num normal_check normal_mem big_leaf_level_formula, cases big_branch with fml0 big_branch, cases big_branch with mem_fml0 big_branch, apply exists.intro fml0, simp [mem_fml0], from big_branch end
# Copyright: Robert P Herbig, 2011 # Interpreter at http://ideone.com/ rows <- 3 cols <- 6 start <- matrix( c(0,1,2,3,4,5, 6,7,8,9,10,11, 12,13,14,15,16,17), nrow=rows, ncol=cols, byrow=TRUE ) print(start) end <- start for(i in 1:rows) { for(j in 1:cols) { if(start[i,j]==0) { end[i,] <- 0 end[,j] <- 0 } } } print(end)
-- WARNING: This file was generated automatically by Vehicle -- and should not be modified manually! -- Metadata -- - Agda version: 2.6.2 -- - AISEC version: 0.1.0.1 -- - Time generated: ??? open import Data.Unit module MyTestModule where e1 : let x = ⊤ in x e1 = checkProperty record { databasePath = DATABASE_PATH ; propertyUUID = ???? }
theory Simulation (*TODO: rename, das ist nur fuer AllgemeinesGesetz*) imports Gesetz Handlung AllgemeinesGesetz begin section\<open>Simulation\<close> text\<open>Gegeben eine handelnde Person und eine Maxime, wir wollen simulieren was für ein allgemeines Gesetz abgeleitet werden könnte.\<close> datatype ('person, 'welt, 'a, 'b) simulation_constants = SimConsts \<open>'person\<close> \<comment> \<open>handelnde Person\<close> \<open>('person, 'welt) maxime\<close> \<open>('welt, 'a, 'b) allgemeines_gesetz_ableiten\<close> (*moeglich :: H.Handlung world -> Bool, -- brauch ich das oder geht das mit typen?*) text\<open>...\<close> (*<*) text\<open>Simulate one \<^typ>\<open>('person, 'welt) handlungsabsicht\<close> once:\<close> fun simulate_handlungsabsicht :: \<open>('person, 'welt, 'a, 'b) simulation_constants \<Rightarrow> ('person, 'welt) handlungsabsicht \<Rightarrow> 'welt \<Rightarrow> (nat, 'a, 'b) gesetz \<Rightarrow> ('welt \<times> (nat, 'a, 'b) gesetz)\<close> where \<open>simulate_handlungsabsicht (SimConsts person maxime aga) ha welt g = (let (sollensanordnung, g') = moarlisch_gesetz_ableiten person welt maxime ha aga g in let w' = (if sollensanordnung = Erlaubnis then nachher (handeln person welt ha) else welt ) in (w', g') )\<close> lemma \<open>simulate_handlungsabsicht (SimConsts () (Maxime (\<lambda>_ _. True)) (\<lambda>h s. Rechtsnorm (Tatbestand h) (Rechtsfolge ''count''))) (Handlungsabsicht (\<lambda>p w. Some (w+1))) (32::int) (Gesetz {})= (33, Gesetz {(\<section> (Suc 0), Rechtsnorm (Tatbestand (Handlung 32 33)) (Rechtsfolge ''count''))})\<close> by eval text\<open>Funktion begrenzt oft anwenden bis sich die Welt nicht mehr ändert. Parameter \<^item> Funktion \<^item> Maximale Anzahl Iterationen (Simulationen) \<^item> Initialwelt \<^item> Initialgesetz \<close> fun converge :: \<open>('welt \<Rightarrow> 'gesetz \<Rightarrow> ('welt \<times> 'gesetz)) \<Rightarrow> nat \<Rightarrow> 'welt \<Rightarrow> 'gesetz \<Rightarrow> ('welt \<times> 'gesetz)\<close> where \<open>converge _ 0 w g = (w, g)\<close> | \<open>converge f (Suc its) w g = (let (w', g') = f w g in if w = w' then (w, g') else converge f its w' g')\<close> text\<open>Example: Count 32..42, where \<^term>\<open>32::int\<close> is the initial world and we do \<^term>\<open>10::nat\<close> iterations.\<close> lemma \<open>converge (\<lambda>w g. (w+1, w#g)) 10 (32::int) ([]) = (42, [41, 40, 39, 38, 37, 36, 35, 34, 33, 32])\<close> by eval text\<open>simulate one \<^typ>\<open>('person, 'welt) handlungsabsicht\<close> a few times\<close> definition simulateOne :: \<open>('person, 'welt, 'a, 'b) simulation_constants \<Rightarrow> nat \<Rightarrow> ('person, 'welt) handlungsabsicht \<Rightarrow> 'welt \<Rightarrow> (nat, 'a, 'b) gesetz \<Rightarrow> (nat, 'a, 'b) gesetz\<close> where \<open>simulateOne simconsts i ha w g \<equiv> let (welt, gesetz) = converge (simulate_handlungsabsicht simconsts ha) i w g in gesetz\<close> (*>*) text\<open>... Die Funktion \<^const>\<open>simulateOne\<close> nimmt eine Konfiguration \<^typ>\<open>('person, 'welt, 'a, 'b) simulation_constants\<close>, eine Anzahl an Iterationen die durchgeführt werden sollen, eine Handlung, eine Initialwelt, ein Initialgesetz, und gibt das daraus resultierende Gesetz nach so vielen Iterationen zurück. Beispiel: Wir nehmen die mir-ist-alles-egal Maxime. Wir leiten ein allgemeines Gesetz ab indem wir einfach nur die Handlung wörtlich ins Gesetz übernehmen. Wir machen \<^term>\<open>10\<close> Iterationen. Die Welt ist nur eine Zahl und die initiale Welt sei \<^term>\<open>32\<close>. Die Handlung ist es diese Zahl um Eins zu erhöhen, Das Ergebnis der Simulation ist dann, dass wir einfach von \<^term>\<open>32\<close> bis \<^term>\<open>42\<close> zählen.\<close> lemma \<open>simulateOne (SimConsts () (Maxime (\<lambda>_ _. True)) (\<lambda>h s. Rechtsnorm (Tatbestand h) (Rechtsfolge ''count''))) 10 (Handlungsabsicht (\<lambda>p n. Some (Suc n))) 32 (Gesetz {}) = Gesetz {(\<section> 10, Rechtsnorm (Tatbestand (Handlung 41 42)) (Rechtsfolge ''count'')), (\<section> 9, Rechtsnorm (Tatbestand (Handlung 40 41)) (Rechtsfolge ''count'')), (\<section> 8, Rechtsnorm (Tatbestand (Handlung 39 40)) (Rechtsfolge ''count'')), (\<section> 7, Rechtsnorm (Tatbestand (Handlung 38 39)) (Rechtsfolge ''count'')), (\<section> 6, Rechtsnorm (Tatbestand (Handlung 37 38)) (Rechtsfolge ''count'')), (\<section> 5, Rechtsnorm (Tatbestand (Handlung 36 37)) (Rechtsfolge ''count'')), (\<section> 4, Rechtsnorm (Tatbestand (Handlung 35 36)) (Rechtsfolge ''count'')), (\<section> 3, Rechtsnorm (Tatbestand (Handlung 34 35)) (Rechtsfolge ''count'')), (\<section> 2, Rechtsnorm (Tatbestand (Handlung 33 34)) (Rechtsfolge ''count'')), (\<section> 1, Rechtsnorm (Tatbestand (Handlung 32 33)) (Rechtsfolge ''count''))}\<close> by eval text\<open>Eine Iteration der Simulation liefert genau einen Paragraphen im Gesetz:\<close> lemma \<open>\<exists>tb rf. simulateOne (SimConsts person maxime gesetz_ableiten) 1 handlungsabsicht initialwelt (Gesetz {}) = Gesetz {(\<section> 1, Rechtsnorm (Tatbestand tb) (Rechtsfolge rf))}\<close> apply(simp add: simulateOne_def moarlisch_gesetz_ableiten_def) apply(case_tac \<open>maxime\<close>, simp) apply(simp add: moralisch_unfold max_paragraph_def) apply(intro conjI impI) by(metis rechtsfolge.exhaust rechtsnorm.exhaust tatbestand.exhaust)+ end
/- Copyright (c) 2020 Robert Y. Lewis. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Robert Y. Lewis Ported by: Scott Morrison -/ import Std.Tactic.Simpa import Std.Tactic.Lint.Basic import Mathlib.Algebra.Order.Ring.Defs import Mathlib.Algebra.Order.Monoid.Lemmas import Mathlib.Init.Data.Int.Order import Mathlib.Algebra.Order.ZeroLEOne import Mathlib.Algebra.GroupPower.Order /-! # Lemmas for `linarith`. Those in the `Linarith` namespace should stay here. Those outside the `Linarith` namespace may be deleted as they are ported to mathlib4. -/ namespace Linarith theorem lt_irrefl {α : Type u} [Preorder α] {a : α} : ¬a < a := _root_.lt_irrefl a theorem eq_of_eq_of_eq {α} [OrderedSemiring α] {a b : α} (ha : a = 0) (hb : b = 0) : a + b = 0 := by simp [*] theorem lt_of_eq_of_lt {α} [OrderedSemiring α] {a b : α} (ha : a = 0) (hb : b < 0) : a + b < 0 := by simp [*] theorem le_of_le_of_eq {α} [OrderedSemiring α] {a b : α} (ha : a ≤ 0) (hb : b = 0) : a + b ≤ 0 := by simp [*] theorem lt_of_lt_of_eq {α} [OrderedSemiring α] {a b : α} (ha : a < 0) (hb : b = 0) : a + b < 0 := by simp [*] theorem mul_neg {α} [StrictOrderedRing α] {a b : α} (ha : a < 0) (hb : 0 < b) : b * a < 0 := have : (-b)*a > 0 := mul_pos_of_neg_of_neg (neg_neg_of_pos hb) ha neg_of_neg_pos (by simpa) theorem mul_nonpos {α} [OrderedRing α] {a b : α} (ha : a ≤ 0) (hb : 0 < b) : b * a ≤ 0 := have : (-b)*a ≥ 0 := mul_nonneg_of_nonpos_of_nonpos (le_of_lt (neg_neg_of_pos hb)) ha by simpa -- used alongside `mul_neg` and `mul_nonpos`, so has the same argument pattern for uniformity @[nolint unusedArguments] theorem mul_eq {α} [OrderedSemiring α] {a b : α} (ha : a = 0) (_ : 0 < b) : b * a = 0 := by simp [*] lemma eq_of_not_lt_of_not_gt {α} [LinearOrder α] (a b : α) (h1 : ¬ a < b) (h2 : ¬ b < a) : a = b := le_antisymm (le_of_not_gt h2) (le_of_not_gt h1) -- used in the `nlinarith` normalization steps. The `_` argument is for uniformity. @[nolint unusedArguments] lemma mul_zero_eq {α} {R : α → α → Prop} [Semiring α] {a b : α} (_ : R a 0) (h : b = 0) : a * b = 0 := by simp [h] -- used in the `nlinarith` normalization steps. The `_` argument is for uniformity. @[nolint unusedArguments] lemma zero_mul_eq {α} {R : α → α → Prop} [Semiring α] {a b : α} (h : a = 0) (_ : R b 0) : a * b = 0 := by simp [h] end Linarith section open Function -- These lemmas can be removed when their originals are ported. theorem lt_zero_of_zero_gt [Zero α] [LT α] {a : α} (h : 0 > a) : a < 0 := h theorem le_zero_of_zero_ge [Zero α] [LE α] {a : α} (h : 0 ≥ a) : a ≤ 0 := h
-- The ATP roles must to have at least an argument -- This error is detected by Syntax.Translation.ConcreteToAbstract. module ATPMissingArgument where {-# ATP axiom #-}
import category_theory.category.default import game.world1.level3 universes v u -- The order in this declaration matters: v often needs to be explicitly specified while u often can be omitted namespace category_theory variables (C : Type u) [category.{v} C] /- # Category world ## Level 5: More tactic reviews -/ /-blah blah -/ /- Lemma If $$f : X ⟶ Y$$ and $$g : X ⟶ Y$$ are morphisms such that $$f = g$$, then $$f ≫ h = g ≫ h$$. -/ lemma id_of_comp_left_id' (X : C) (f : X ⟶ X) (w : ∀ {Y : C} (g : X ⟶ Y), f ≫ g = g) : f = 𝟙 X := begin apply eq_of_comp_left_eq'', intros Z h, rw category.id_comp h, apply w, end end category_theory
Require Import Setoid. Theorem not_not_not : forall P, ~~~P <-> ~P. Proof. split. intros. unfold not in *. intro. apply H. intros. apply H1. apply H0. unfold not. intros. apply (H0 H). Qed. Theorem wierd : forall P, ~(~P /\ ~~P). Proof. intros P H. destruct H as [A B]. apply (B A). Qed. Theorem www : forall P Q, ~(~P /\ ~Q) <-> ~~(~~P \/ ~~Q). Proof. intros. split. intro And. unfold not in *. intro Or. apply And. split; intro aPQ; apply Or; [left | right]; intro nPQ; apply (nPQ aPQ). intro Or. intro And. unfold not in *. apply Or. intro Or0. destruct Or0 as [Or1 | Or1]; apply Or1; apply And. Qed. Theorem wierder : forall P, ~~(~P \/ ~~P). Proof. intros P. unfold not at 1 2 4 5. rewrite <- not_not_not in |- *. apply www. unfold not. intro And. destruct And as [nnP nP]. apply (nnP nP). Qed. Theorem PP : forall P, ((~P)->~~P)->~~P. Proof. intros. unfold not in *. intro. apply (H H0 H0). Qed. Theorem PPP : forall P, (P \/ ~P) -> ((~P)->P)->P. Proof. intros. case H. intro. apply H1. exact H0. Qed.
/- Copyright (c) 2020 Anne Baanen. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Anne Baanen -/ import ring_theory.polynomial.scale_roots import ring_theory.localization /-! # Rational root theorem and integral root theorem This file contains the rational root theorem and integral root theorem. The rational root theorem for a unique factorization domain `A` with localization `S`, states that the roots of `p : polynomial A` in `A`'s field of fractions are of the form `x / y` with `x y : A`, `x ∣ p.coeff 0` and `y ∣ p.leading_coeff`. The corollary is the integral root theorem `is_integer_of_is_root_of_monic`: if `p` is monic, its roots must be integers. Finally, we use this to show unique factorization domains are integrally closed. ## References * https://en.wikipedia.org/wiki/Rational_root_theorem -/ section scale_roots variables {A K R S : Type*} [integral_domain A] [field K] [comm_ring R] [comm_ring S] variables {M : submonoid A} {f : localization_map M S} {g : fraction_map A K} open finsupp polynomial lemma scale_roots_aeval_eq_zero_of_aeval_mk'_eq_zero {p : polynomial A} {r : A} {s : M} (hr : @aeval A f.codomain _ _ _ (f.mk' r s) p = 0) : @aeval A f.codomain _ _ _ (f.to_map r) (scale_roots p s) = 0 := begin convert scale_roots_eval₂_eq_zero f.to_map hr, rw aeval_def, congr, apply (f.mk'_spec' r s).symm end lemma num_is_root_scale_roots_of_aeval_eq_zero [unique_factorization_monoid A] (g : fraction_map A K) {p : polynomial A} {x : g.codomain} (hr : aeval x p = 0) : is_root (scale_roots p (g.denom x)) (g.num x) := begin apply is_root_of_eval₂_map_eq_zero g.injective, refine scale_roots_aeval_eq_zero_of_aeval_mk'_eq_zero _, rw g.mk'_num_denom, exact hr end end scale_roots section rational_root_theorem variables {A K : Type*} [integral_domain A] [unique_factorization_monoid A] [field K] variables {f : fraction_map A K} open polynomial unique_factorization_monoid /-- Rational root theorem part 1: if `r : f.codomain` is a root of a polynomial over the ufd `A`, then the numerator of `r` divides the constant coefficient -/ theorem num_dvd_of_is_root {p : polynomial A} {r : f.codomain} (hr : aeval r p = 0) : f.num r ∣ p.coeff 0 := begin suffices : f.num r ∣ (scale_roots p (f.denom r)).coeff 0, { simp only [coeff_scale_roots, nat.sub_zero] at this, haveI := classical.prop_decidable, by_cases hr : f.num r = 0, { obtain ⟨u, hu⟩ := (f.is_unit_denom_of_num_eq_zero hr).pow p.nat_degree, rw ←hu at this, exact units.dvd_mul_right.mp this }, { refine dvd_of_dvd_mul_left_of_no_prime_factors hr _ this, intros q dvd_num dvd_denom_pow hq, apply hq.not_unit, exact f.num_denom_reduced r dvd_num (hq.dvd_of_dvd_pow dvd_denom_pow) } }, convert dvd_term_of_is_root_of_dvd_terms 0 (num_is_root_scale_roots_of_aeval_eq_zero f hr) _, { rw [pow_zero, mul_one] }, intros j hj, apply dvd_mul_of_dvd_right, convert pow_dvd_pow (f.num r) (nat.succ_le_of_lt (bot_lt_iff_ne_bot.mpr hj)), exact (pow_one _).symm end /-- Rational root theorem part 2: if `r : f.codomain` is a root of a polynomial over the ufd `A`, then the denominator of `r` divides the leading coefficient -/ theorem denom_dvd_of_is_root {p : polynomial A} {r : f.codomain} (hr : aeval r p = 0) : (f.denom r : A) ∣ p.leading_coeff := begin suffices : (f.denom r : A) ∣ p.leading_coeff * f.num r ^ p.nat_degree, { refine dvd_of_dvd_mul_left_of_no_prime_factors (mem_non_zero_divisors_iff_ne_zero.mp (f.denom r).2) _ this, intros q dvd_denom dvd_num_pow hq, apply hq.not_unit, exact f.num_denom_reduced r (hq.dvd_of_dvd_pow dvd_num_pow) dvd_denom }, rw ←coeff_scale_roots_nat_degree, apply dvd_term_of_is_root_of_dvd_terms _ (num_is_root_scale_roots_of_aeval_eq_zero f hr), intros j hj, by_cases h : j < p.nat_degree, { rw coeff_scale_roots, refine dvd_mul_of_dvd_left (dvd_mul_of_dvd_right _ _) _, convert pow_dvd_pow _ (nat.succ_le_iff.mpr (nat.lt_sub_left_of_add_lt _)), { exact (pow_one _).symm }, simpa using h }, rw [←nat_degree_scale_roots p (f.denom r)] at *, rw [coeff_eq_zero_of_nat_degree_lt (lt_of_le_of_ne (le_of_not_gt h) hj.symm), zero_mul], exact dvd_zero _ end /-- Integral root theorem: if `r : f.codomain` is a root of a monic polynomial over the ufd `A`, then `r` is an integer -/ theorem is_integer_of_is_root_of_monic {p : polynomial A} (hp : monic p) {r : f.codomain} (hr : aeval r p = 0) : f.is_integer r := f.is_integer_of_is_unit_denom (is_unit_of_dvd_one _ (hp ▸ denom_dvd_of_is_root hr)) namespace unique_factorization_monoid lemma integer_of_integral {x : f.codomain} : is_integral A x → f.is_integer x := λ ⟨p, hp, hx⟩, is_integer_of_is_root_of_monic hp hx lemma integrally_closed : integral_closure A f.codomain = ⊥ := eq_bot_iff.mpr (λ x hx, algebra.mem_bot.mpr (integer_of_integral hx)) end unique_factorization_monoid end rational_root_theorem
import category_theory.abelian.projective import for_mathlib.homological_complex_shift import tactic.linarith import algebra.homology.quasi_iso import algebra.homology.homotopy import for_mathlib.abelian_category . open category_theory category_theory.limits open_locale zero_object section zero_object variables {V : Type*} [category V] [has_zero_morphisms V] noncomputable lemma split_epi_of_is_zero {X Y : V} (f : X ⟶ Y) (h : is_zero Y) : split_epi f := ⟨0, by simp [is_zero_iff_id_eq_zero.mp h]⟩ lemma epi_of_is_zero {X Y : V} (f : X ⟶ Y) (h : is_zero Y) : epi f := @@split_epi.epi _ (split_epi_of_is_zero f h) noncomputable lemma split_mono_of_is_zero {X Y : V} (f : X ⟶ Y) (h : is_zero X) : split_mono f := ⟨0, by simp [is_zero_iff_id_eq_zero.mp h]⟩ lemma mono_of_is_zero_object {X Y : V} (f : X ⟶ Y) (h : is_zero X) : mono f := @@split_mono.mono _ (split_mono_of_is_zero f h) lemma is_iso_of_is_zero {X Y : V} (f : X ⟶ Y) (h₁ : is_zero X) (h₂ : is_zero Y) : is_iso f := begin use 0, rw [is_zero_iff_id_eq_zero.mp h₁, is_zero_iff_id_eq_zero.mp h₂], split; simp end end zero_object variables {V : Type*} [category V] [abelian V] [enough_projectives V] (X : cochain_complex V ℤ) variables (a : ℤ) (H : ∀ i (h : a ≤ i), is_zero (X.X i)) lemma comp_eq_to_hom_heq_iff {C : Type*} [category C] {X X' Y Y' Y'' : C} (f : X ⟶ Y) (f' : X' ⟶ Y') (e : Y = Y'') : f ≫ eq_to_hom e == f' ↔ f == f' := by { subst e, erw category.comp_id } lemma eq_to_hom_comp_heq_iff {C : Type*} [category C] {X X' Y Y' X'' : C} (f : X ⟶ Y) (f' : X' ⟶ Y') (e : X'' = X) : eq_to_hom e ≫ f == f' ↔ f == f' := by { subst e, erw category.id_comp } lemma heq_eq_to_hom_comp_iff {C : Type*} [category C] {X X' Y Y' X'' : C} (f : X ⟶ Y) (f' : X' ⟶ Y') (e : X'' = X') : f == eq_to_hom e ≫ f' ↔ f == f' := by { subst e, erw category.id_comp } lemma heq_comp_eq_to_hom_iff {C : Type*} [category C] {X X' Y Y' Y'' : C} (f : X ⟶ Y) (f' : X' ⟶ Y') (e : Y' = Y'') : f == f' ≫ eq_to_hom e ↔ f == f' := by { subst e, erw category.comp_id } include H namespace category_theory.projective noncomputable def replacement_aux : Π n : ℕ, Σ f : arrow V, (f.left ⟶ X.X (a-n)) | 0 := ⟨⟨0, 0, 0⟩, 0⟩ | (n+1) := ⟨⟨over (pullback (X.d (a-n-1) (a-n)) (kernel.ι (replacement_aux n).1.hom ≫ (replacement_aux n).2)), (replacement_aux n).1.left, π _ ≫ pullback.snd ≫ kernel.ι _⟩, π _ ≫ pullback.fst ≫ (X.X_eq_to_iso (by { norm_num, exact sub_sub _ _ _ })).hom⟩ . lemma replacement_aux_right_eq (n : ℕ) : (replacement_aux X a H (n + 1)).1.right = (replacement_aux X a H n).1.left := by { delta replacement_aux, exact rfl } lemma replacement_aux_hom_eq (n : ℕ) : (replacement_aux X a H (n + 1)).1.hom = eq_to_hom (by { delta replacement_aux, exact rfl }) ≫ π (pullback (X.d (a-n-1) (a-n)) (kernel.ι (replacement_aux X a H n).1.hom ≫ (replacement_aux X a H n).2)) ≫ pullback.snd ≫ kernel.ι (replacement_aux X a H n).1.hom ≫ eq_to_hom (by { delta replacement_aux, exact rfl }) := by { delta replacement_aux, erw [category.id_comp, category.comp_id], exact rfl } . lemma replacement_aux_snd_comm (n : ℕ) : (replacement_aux X a H (n + 1)).1.hom ≫ eq_to_hom (replacement_aux_right_eq X a H n) ≫ (replacement_aux X a H n).2 = (replacement_aux X a H (n + 1)).2 ≫ X.d _ _ := begin rw replacement_aux_hom_eq, simp only [category.id_comp, eq_to_hom_refl, category.assoc, eq_to_hom_trans_assoc], delta replacement_aux, rw [eq_to_hom_refl, category.id_comp, ← pullback.condition], erw [category.assoc, category.assoc, homological_complex.X_eq_to_iso_d], end noncomputable def replacement : cochain_complex V ℤ := { X := λ i, if a < i then 0 else (replacement_aux X a H ((a - i).nat_abs + 1)).1.right, d := λ i j, if h₁ : i + 1 = j then if h₂ : j > a then 0 else eq_to_hom (begin rw [if_neg, replacement_aux_right_eq, functor.id_obj], subst h₁, suffices : (a - i).nat_abs = (a - (i + 1)).nat_abs + 1, { rw this }, apply int.coe_nat_inj, norm_num [← int.abs_eq_nat_abs], rw [abs_eq_self.mpr _, abs_eq_self.mpr _], all_goals { linarith } end) ≫ (replacement_aux X a H ((a - j).nat_abs + 1)).fst.hom ≫ eq_to_hom (dif_neg h₂).symm else 0, shape' := λ _ _ e, dif_neg e, d_comp_d' := begin rintros i j k (rfl : i+1 = j) (rfl : i+1+1 = k), simp only [dif_pos, dif_ctx_congr], by_cases h : i + 1 + 1 > a, { rw [dif_pos h, comp_zero] }, rw [dif_neg h, dif_neg], rw [← category.assoc, ← category.assoc, ← is_iso.eq_comp_inv], simp only [category.assoc, eq_to_hom_trans_assoc], rw [← is_iso.eq_inv_comp, zero_comp, comp_zero, replacement_aux_hom_eq], simp only [category.assoc, eq_to_hom_trans_assoc], iterate 3 { convert comp_zero }, suffices : (a - (i + 1)).nat_abs = (a - (i + 1 + 1)).nat_abs + 1, { convert kernel.condition _; try { rw this }, apply (eq_to_hom_comp_heq_iff _ _ _).mpr, congr; rw this }, apply int.coe_nat_inj, norm_num [← int.abs_eq_nat_abs], rw [abs_eq_self.mpr _, abs_eq_self.mpr _], all_goals { linarith } end } noncomputable def replacement.hom : replacement X a H ⟶ X := { f := λ i, if h : a < i then 0 else eq_to_hom (if_neg h) ≫ eq_to_hom (by rw replacement_aux_right_eq) ≫ (replacement_aux X a H ((a - i).nat_abs)).snd ≫ (X.X_eq_to_iso (by { rw [← int.abs_eq_nat_abs, sub_eq_iff_eq_add, ← sub_eq_iff_eq_add', eq_comm, abs_eq_self], linarith })).hom, comm' := begin rintros i j (rfl : i+1 = j), split_ifs with h', { rw [zero_comp, comp_zero] }, { exfalso, linarith }, { rw comp_zero, apply (H _ (le_of_lt h)).eq_of_tgt }, { dsimp only [replacement], rw [dif_pos rfl, dif_neg h], simp only [← category.assoc, eq_to_hom_trans_assoc], rw [← is_iso.comp_inv_eq], simp only [homological_complex.X_d_eq_to_iso, homological_complex.X_eq_to_iso_inv, category.assoc, homological_complex.X_eq_to_iso_d, eq_to_hom_trans, is_iso.iso.inv_hom], rw [← is_iso.inv_comp_eq, inv_eq_to_hom, eq_to_hom_trans_assoc], refine eq.trans _ (replacement_aux_snd_comm X a H _).symm, suffices : (a - (i + 1)).nat_abs + 1 = (a - i).nat_abs, { rw ← heq_iff_eq, apply (eq_to_hom_comp_heq_iff _ _ _).mpr, rw this }, apply int.coe_nat_inj, norm_num [← int.abs_eq_nat_abs], rw [abs_eq_self.mpr _, abs_eq_self.mpr _], all_goals { linarith } } end } omit H variables {V} {A B C : V} (f : A ⟶ B) (g : B ⟶ C) (w : f ≫ g = 0) variables {A' B' C' : V} {f' : A' ⟶ B'} {g' : B' ⟶ C'} (w' : f' ≫ g' = 0) variables (α : arrow.mk f ⟶ arrow.mk f') (β : arrow.mk g ⟶ arrow.mk g') variables (p : α.right = β.left) instance : epi (homology.π f g w) := by { delta homology.π, apply_instance } instance : strong_epi (factor_thru_image f) := strong_epi_factor_thru_image_of_strong_epi_mono_factorisation $ classical.choice $ has_strong_epi_mono_factorisations.has_fac f instance : epi (factor_thru_image f ≫ (image_subobject_iso f).inv) := epi_comp _ _ instance : mono (homology.ι f g w) := by { delta homology.ι, apply_instance } @[simp, reassoc] lemma π_cokernel_iso_of_eq {f₁ f₂ : A ⟶ B} (e : f₁ = f₂) : cokernel.π f₁ ≫ (cokernel_iso_of_eq e).hom = cokernel.π f₂ := by { subst e, erw has_colimit.iso_of_nat_iso_ι_hom, exact category.id_comp _ } @[simp, reassoc] lemma homology.π_iso_cokernel_lift_hom : homology.π f g w ≫ (homology_iso_cokernel_lift f g w).hom = (kernel_subobject_iso _).hom ≫ cokernel.π _ := begin simp only [limits.cokernel_epi_comp_inv, iso.symm_hom, homology_iso_cokernel_lift, iso.trans_hom], erw homology.π_desc_assoc, simp only [cokernel.π_desc_assoc, category.assoc, iso.cancel_iso_hom_left, π_cokernel_iso_of_eq], end @[simp, reassoc] lemma homology.π'_ι : homology.π' f g w ≫ homology.ι f g w = kernel.ι g ≫ cokernel.π f := by { delta homology.π' homology.ι homology_iso_kernel_desc, simp } @[simp, reassoc] lemma homology.π_ι : homology.π f g w ≫ homology.ι f g w = (kernel_subobject _).arrow ≫ cokernel.π _ := by rw [← homology.π'_eq_π, category.assoc, homology.π'_ι, kernel_subobject_arrow_assoc] open_locale pseudoelement open category_theory.abelian lemma mono_homology_map_of_pseudoelement (H : ∀ (x : B) (y : A') (h₁ : g x = 0) (h₂ : f' y = α.right x), ∃ z : A, f z = x) : mono (homology.map w w' α β p) := begin apply pseudoelement.mono_of_zero_of_map_zero, intros x e, obtain ⟨x', rfl⟩ := pseudoelement.pseudo_surjective_of_epi (homology.π f g w) x, rw [← pseudoelement.comp_apply, homology.π_map, pseudoelement.comp_apply] at e, obtain ⟨y, hy⟩ := (@pseudoelement.pseudo_exact_of_exact _ _ _ _ _ _ _ (homology.π f' g' w') (exact_cokernel _)).2 _ e, obtain ⟨y', rfl⟩ := pseudoelement.pseudo_surjective_of_epi (factor_thru_image f' ≫ (image_subobject_iso _).inv) y, obtain ⟨z, e'⟩ := H ((kernel_subobject g).arrow x') y' (by rw [← pseudoelement.comp_apply, kernel_subobject_arrow_comp, pseudoelement.zero_apply]) (by simpa [← pseudoelement.comp_apply, p] using congr_arg (kernel_subobject g').arrow hy), have : f = (factor_thru_image f ≫ (image_subobject_iso _).inv ≫ image_to_kernel f g w) ≫ (kernel_subobject g).arrow := by simp, rw [this, pseudoelement.comp_apply] at e', have := pseudoelement.pseudo_injective_of_mono _ e', subst this, simp [← pseudoelement.comp_apply] end . lemma mono_homology_map_of_epi_pullback_lift (H : epi (pullback.lift _ _ (show α.left ≫ f' = (kernel.lift g f w) ≫ kernel.ι _ ≫ α.right, by simp))) : mono (homology.map w w' α β p) := begin apply mono_homology_map_of_pseudoelement, intros x y e₁ e₂, obtain ⟨x', rfl⟩ := (@pseudoelement.pseudo_exact_of_exact _ _ _ _ _ _ _ _ exact_kernel_ι).2 x e₁, rw ← pseudoelement.comp_apply at e₂, obtain ⟨z, rfl, rfl⟩ := pseudoelement.pseudo_pullback e₂, obtain ⟨z', rfl⟩ := @@pseudoelement.pseudo_surjective_of_epi _ _ _ H z, use z', simp [← pseudoelement.comp_apply] end . lemma epi_homology_map_of_pseudoelement (H : ∀ (x : B') (h : g' x = 0), ∃ (y : B), g y = 0 ∧ (cokernel.π f') (α.right y) = cokernel.π f' x) : epi (homology.map w w' α β p) := begin apply pseudoelement.epi_of_pseudo_surjective, intro x, obtain ⟨x', rfl⟩ := pseudoelement.pseudo_surjective_of_epi (homology.π f' g' w') x, obtain ⟨y, e₁, e₂⟩ := H ((kernel_subobject g').arrow x') (by rw [← pseudoelement.comp_apply, kernel_subobject_arrow_comp, pseudoelement.zero_apply]), obtain ⟨y', rfl⟩ := (@pseudoelement.pseudo_exact_of_exact _ _ _ _ _ _ _ _ exact_kernel_subobject_arrow).2 y e₁, use homology.π f g w y', apply pseudoelement.pseudo_injective_of_mono (homology.ι f' g' w'), simpa [← pseudoelement.comp_apply, p] using e₂, end local attribute [instance] epi_comp mono_comp noncomputable def pullback_comp_mono_iso {X Y Z Z' : V} (f : X ⟶ Z) (g : Y ⟶ Z) (h : Z ⟶ Z') [mono h] : pullback (f ≫ h) (g ≫ h) ≅ pullback f g := limit.iso_limit_cone ⟨_, pullback_is_pullback_of_comp_mono f g h⟩ @[simp, reassoc] lemma pullback_comp_mono_iso_fst {X Y Z Z' : V} (f : X ⟶ Z) (g : Y ⟶ Z) (h : Z ⟶ Z') [mono h] : (pullback_comp_mono_iso f g h).hom ≫ pullback.fst = pullback.fst := limit.iso_limit_cone_hom_π _ walking_cospan.left lemma kernel_ι_replacement_aux_eq_zero (i : ℕ) : kernel.ι (replacement_aux X a H i).fst.hom ≫ (replacement_aux X a H i).snd ≫ X.d (a - i) (a - i + 1) = 0 := begin cases i, { dsimp [replacement_aux], simp }, { have : a - i.succ + 1 = a - i, { norm_num [sub_add] }, rw [this, ← replacement_aux_snd_comm, kernel.condition_assoc, zero_comp] } end instance replacement_kernel_map_epi (i : ℕ) : epi (kernel.lift (X.d (a - i) (a - i + 1)) (kernel.ι (replacement_aux X a H i).fst.hom ≫ (replacement_aux X a H i).snd) (by rw [category.assoc, kernel_ι_replacement_aux_eq_zero])) := begin cases i, { apply epi_of_is_zero, refine is_zero_of_mono (kernel.ι _) _, { apply H, simp }, }, { apply pseudoelement.epi_of_pseudo_surjective, intro x, obtain ⟨y, h₁, h₂⟩ := @pseudoelement.pseudo_pullback _ _ _ _ _ _ _ (X.d (a - i - 1) (a - i)) (kernel.ι (replacement_aux X a H i).fst.hom ≫ (replacement_aux X a H i).snd) ((X.X_eq_to_iso (by norm_num [sub_sub])).hom (kernel.ι (X.d _ _) x)) 0 _, swap, { simp only [← pseudoelement.comp_apply, category.assoc, homological_complex.X_eq_to_iso_d, pseudoelement.apply_zero], convert pseudoelement.zero_apply _ _, have : a - ↑i = a - ↑(i + 1) + 1 := by norm_num [← sub_sub], convert kernel.condition _ }, obtain ⟨z, rfl⟩ := pseudoelement.pseudo_surjective_of_epi (projective.π _) y, apply_fun kernel.ι (replacement_aux X a H i).fst.hom at h₂, simp only [← pseudoelement.comp_apply, category.assoc, pseudoelement.apply_zero] at h₂, obtain ⟨w, rfl⟩ := (@pseudoelement.pseudo_exact_of_exact _ _ _ _ _ _ _ _ exact_kernel_ι).2 z h₂, dsimp [replacement_aux], use w, simp only [← pseudoelement.comp_apply] at h₁, apply pseudoelement.pseudo_injective_of_mono (kernel.ι (X.d (a - ↑(i + 1)) (a - ↑(i + 1) + 1)) ≫ (homological_complex.X_eq_to_iso X _).hom), refine eq.trans _ h₁, simp only [← pseudoelement.comp_apply, category.assoc], congr' 1, refine (kernel.lift_ι_assoc _ _ _ _).trans _, simpa, apply_instance } end instance (i : ℕ) : epi (replacement_aux X a H i).snd := begin cases i; dsimp [replacement_aux], { apply epi_of_is_zero, apply H, simp }, { apply_with epi_comp { instances := ff }, { apply_instance }, apply_with epi_comp { instances := ff }, swap, { apply_instance }, let e : pullback (X.d (a - i - 1) (a - i)) (kernel.ι (replacement_aux X a H i).fst.hom ≫ (replacement_aux X a H i).snd) ≅ pullback (kernel.lift (X.d (a - i) (a - i + 1)) _ _) (kernel.lift _ _ _), { refine pullback.congr_hom (kernel.lift_ι _ _ (X.d_comp_d _ _ _)).symm (kernel.lift_ι _ _ _).symm ≪≫ pullback_comp_mono_iso _ _ (kernel.ι _), rw [category.assoc, kernel_ι_replacement_aux_eq_zero] }, have : e.hom ≫ pullback.fst = pullback.fst, { simp }, refine (eq_iff_iff.mp (congr_arg epi this)).mp _, apply_instance }, end noncomputable def homology_functor_obj_iso (X) (i : ℤ) : (homology_functor V (complex_shape.up ℤ) i).obj X ≅ homology _ _ (X.d_comp_d (i-1) i (i+1)) := homology.map_iso _ _ (arrow.iso_mk (X.X_prev_iso (sub_add_cancel _ _)) (iso.refl _) (by { dsimp, simp [← X.d_to_eq] })) (arrow.iso_mk (iso.refl _) (X.X_next_iso rfl) (by { dsimp, simp })) (by { dsimp, simp}) lemma homology_functor_map_iso {X Y : cochain_complex V ℤ} (f : X ⟶ Y) (i : ℤ) : (homology_functor V (complex_shape.up ℤ) i).map f = (homology_functor_obj_iso X i).hom ≫ homology.map _ _ (arrow.hom_mk (f.comm _ _)) (arrow.hom_mk (f.comm _ _)) rfl ≫ (homology_functor_obj_iso Y i).inv := begin delta homology_functor_obj_iso homology.map_iso, simp only [homology_functor_map, homology.map_comp], congr; ext; dsimp, { rw homological_complex.hom.prev_eq, }, { simp only [category.comp_id, category.id_comp] }, { simp only [category.comp_id, category.id_comp] }, { rw homological_complex.hom.next_eq, }, end lemma mono_homology_functor_of_pseudoelement (i : ℤ) {X Y : cochain_complex V ℤ} (f : X ⟶ Y) (H : ∀ (x : X.X i) (y : Y.X (i - 1)), X.d i (i + 1) x = 0 → Y.d (i - 1) i y = f.f i x → (∃ (z : X.X (i - 1)), X.d (i - 1) i z = x)) : mono ((homology_functor V (complex_shape.up ℤ) i).map f) := begin haveI := mono_homology_map_of_pseudoelement _ _ (X.d_comp_d (i-1) i (i+1)) (Y.d_comp_d (i-1) i (i+1)) (arrow.hom_mk (f.comm _ _)) (arrow.hom_mk (f.comm _ _)) rfl H, rw homology_functor_map_iso, apply_instance end local attribute [instance] pseudoelement.setoid lemma pseudoelement.id_apply {X : V} (x : X) : @@coe_fn _ pseudoelement.hom_to_fun (𝟙 X) x = x := begin apply quot.induction_on x, intro a, change ⟦over.mk _⟧ = ⟦a⟧, erw category.comp_id, rcases a with ⟨_, ⟨⟨⟩⟩, _⟩, congr, end lemma replacement_aux_comp_eq_zero (i : ℕ) : (replacement_aux X a H (i+1)).fst.hom ≫ eq_to_hom (by { dsimp [replacement_aux], refl }) ≫ (replacement_aux X a H i).fst.hom = 0 := begin dsimp [replacement_aux], simp only [category.assoc, category.id_comp], refine (category.assoc _ _ _).symm.trans (eq.trans _ comp_zero), swap 3, congr' 1, exact kernel.condition (replacement_aux X a H i).fst.hom, end noncomputable def replacement_homology_map (i : ℕ) : homology _ _ ((category.assoc _ _ _).trans (replacement_aux_comp_eq_zero X a H (i+1))) ⟶ homology _ _ (X.d_comp_d (a-(i+1 : ℕ) - 1) (a-(i+1 : ℕ)) (a-i)) := begin refine homology.map _ _ _ (arrow.hom_mk (replacement_aux_snd_comm X a H i).symm) _, { have := (replacement_aux_snd_comm X a H (i+1)).symm.trans (category.assoc _ _ _).symm, have hai : a - ↑(i + 2) = a - ↑(i + 1) - 1, { push_cast, ring }, rw [← X.X_eq_to_iso_d hai, ← category.assoc] at this, exact arrow.hom_mk this, }, { apply_instance }, { refl } end instance (i : ℕ) : mono (replacement_homology_map X a H i) := begin apply mono_homology_map_of_epi_pullback_lift, dsimp [replacement_aux], convert projective.π_epi _, apply pullback.hom_ext, { simpa only [category.comp_id, category.assoc, arrow.hom_mk_left, X.X_eq_to_iso_trans, X.X_eq_to_iso_refl, pullback.lift_fst] }, { refine (cancel_mono (kernel.ι _)).mp _, simp only [category.comp_id, category.assoc, arrow.hom_mk_left, kernel.lift_ι, X.X_eq_to_iso_trans, pullback.lift_snd, X.X_eq_to_iso_refl], simp_rw ← category.assoc, exact category.comp_id _ }, end . lemma comp_left_epi_iff {V : Type*} [category V] {X Y Z : V} (f : X ⟶ Y) (g : Y ⟶ Z) [epi f] : epi (f ≫ g) ↔ epi g := ⟨λ h, @@epi_of_epi _ _ _ h, λ h, @@epi_comp _ _ _ _ h⟩ lemma comp_right_epi_iff {V : Type*} [category V] {X Y Z : V} (f : X ⟶ Y) (g : Y ⟶ Z) [is_iso g] : epi (f ≫ g) ↔ epi f := ⟨λ h, by simpa using @@epi_comp _ (f ≫ g) h (inv g) _, λ h, @@epi_comp _ _ h _ _⟩ instance replacement_kernel_map_epi' (i : ℕ) : epi (kernel.lift (X.d (a - (i + 1)) (a - i)) (kernel.ι (replacement_aux X a H (i + 1)).fst.hom ≫ (replacement_aux X a H (i + 1)).snd) (by { rw category.assoc, convert kernel_ι_replacement_aux_eq_zero X a H _; norm_num [sub_add] })) := begin convert projective.replacement_kernel_map_epi X a H _; norm_num [sub_add] end instance (i : ℕ) : epi (replacement_homology_map X a H i) := begin apply_with (epi_of_epi (homology.π _ _ _)) { instances := ff }, erw homology.π_map, apply_with epi_comp { instances := ff }, swap, { apply_instance }, rw [← comp_left_epi_iff (kernel_subobject_iso _).inv, ← comp_right_epi_iff _ (kernel_subobject_iso _).hom], convert projective.replacement_kernel_map_epi' X a H _ using 1, refine (cancel_mono (kernel.ι _)).mp _, simp only [kernel_subobject_arrow'_assoc, category.assoc, kernel_subobject_map_arrow, kernel_subobject_arrow, arrow.hom_mk_left], erw kernel.lift_ι, apply_instance end instance (i : ℕ) : is_iso (replacement_homology_map X a H i) := is_iso_of_mono_of_epi _ lemma replacement_aux_eq_of_eq (i j : ℕ) (e : i + 1 = j) : (replacement_aux X a H j).1.right = (replacement_aux X a H i).1.left := begin subst e, dsimp [replacement_aux], refl end lemma replacement_aux_fst_hom_congr (i j : ℕ) (e : i = j) : (replacement_aux X a H i).1.hom == (replacement_aux X a H j).1.hom := by { subst e } lemma replacement_aux_snd_congr (i j : ℕ) (e : i = j) : (replacement_aux X a H i).2 == (replacement_aux X a H j).2 := by { subst e } lemma replacement_homology_eq (i : ℕ) : homology _ _ ((replacement X a H).d_comp_d (a - ↑(i + 1) - 1) (a - ↑(i + 1)) (a - i)) = homology _ _ (replacement_homology_map._proof_4 X a H i) := begin dsimp only [replacement], have e₁ : a - (↑i + 1) - 1 + 1 = a - (↑i + 1) := by norm_num [sub_add], have e₂ : a - (↑i + 1) + 1 = a - ↑i := by norm_num [sub_add], have e₃ : ¬ a < a - (↑i + 1) - 1 := by { simp only [tsub_le_iff_right, not_lt], linarith }, have e₄ : ¬a - (↑i + 1) > a := by { simp only [gt_iff_lt, tsub_le_iff_right, not_lt], linarith }, have e₅ : ¬a - i > a := by { simp only [gt_iff_lt, tsub_le_iff_right, not_lt], linarith }, have e₆ : (a - (a - (↑i + 1))).nat_abs = i + 1, { rw [← sub_add, sub_self, zero_add], exact int.nat_abs_of_nat_core _ }, have e₇ : (a - (a - (↑i + 1) - 1)).nat_abs = i + 1 + 1, { rw [sub_sub, ← sub_add, sub_self, zero_add], exact int.nat_abs_of_nat_core _ }, have e₈ : (a - (a - i)).nat_abs = i := by norm_num, simp only [nat.cast_add, nat.cast_one, sub_add_cancel, eq_self_iff_true, gt_iff_lt, dif_pos, not_lt, sub_le_self_iff, nat.cast_nonneg, dif_neg, eq_to_hom_refl, category.comp_id], simp only [dif_pos e₁, dif_pos e₂, dif_neg e₄, dif_neg e₅], congr' 1, { erw if_neg e₃, apply replacement_aux_eq_of_eq, erw e₇ }, { erw if_neg e₄, apply replacement_aux_eq_of_eq, erw e₆ }, { erw if_neg e₅, { congr, { ext, congr, exact e₈ }, { exact e₈ } } }, { erw [eq_to_hom_comp_heq_iff, comp_eq_to_hom_heq_iff, e₆] }, { erw [eq_to_hom_comp_heq_iff, comp_eq_to_hom_heq_iff, e₈] }, end lemma replacement_hom_homology_iso (i : ℕ) : homology.map ((replacement X a H).d_comp_d _ _ _) (X.d_comp_d _ _ _) (arrow.hom_mk ((replacement.hom X a H).comm _ _)) (arrow.hom_mk ((replacement.hom X a H).comm _ _)) rfl = (eq_to_hom (replacement_homology_eq X a H i)) ≫ replacement_homology_map X a H i := begin rw [← heq_iff_eq, heq_eq_to_hom_comp_iff], delta replacement_homology_map, dsimp [replacement], congr' 3, any_goals { rw if_neg, apply replacement_aux_eq_of_eq, { norm_num [← sub_add], exact (int.nat_abs_of_nat_core _).symm }, { simp only [gt_iff_lt, tsub_le_iff_right, not_lt], linarith } }, any_goals { rw if_neg, dsimp [replacement_aux], congr, { ext, congr, norm_num }, { norm_num }, { simp only [gt_iff_lt, tsub_le_iff_right, not_lt], linarith } }, any_goals { rw category.comp_id }, any_goals { rw heq_eq_to_hom_comp_iff}, any_goals { delta homological_complex.X_eq_to_iso, erw heq_comp_eq_to_hom_iff }, any_goals { dsimp [replacement.hom], rw [dif_neg, eq_to_hom_comp_heq_iff, eq_to_hom_comp_heq_iff], erw comp_eq_to_hom_heq_iff, { apply replacement_aux_snd_congr, refine eq.trans _ (int.nat_abs_of_nat_core _), congr' 1, norm_num [sub_sub, sub_add] }, { simp only [gt_iff_lt, tsub_le_iff_right, not_lt], linarith } }, all_goals { rw [dif_pos, dif_neg, eq_to_hom_comp_heq_iff, comp_eq_to_hom_heq_iff], apply replacement_aux_fst_hom_congr, { congr' 1, refine eq.trans _ (int.nat_abs_of_nat_core _), congr' 1, norm_num [sub_sub, sub_add] }, { simp only [gt_iff_lt, tsub_le_iff_right, not_lt], linarith }, { norm_num [sub_sub, sub_add] } }, end . lemma homology_functor_map_iso' {X Y : cochain_complex V ℤ} (f : X ⟶ Y) (i j k : ℤ) (e₁ : i + 1 = j) (e₂ : j + 1 = k) : (homology_functor V (complex_shape.up ℤ) j).map f = (homology_functor_obj_iso X _).hom ≫ (eq_to_hom $ by { have e₁ : i = j - 1 := by simp [← e₁], substs e₁ e₂ }) ≫ homology.map (X.d_comp_d i j k) (Y.d_comp_d i j k) (arrow.hom_mk (f.comm i j)) (arrow.hom_mk (f.comm j k)) rfl ≫ (eq_to_hom $ by { have e₁ : i = j - 1 := by simp [← e₁], substs e₁ e₂ }) ≫ (homology_functor_obj_iso Y _).inv := begin have e₁ : i = j - 1 := by simp [← e₁], substs e₁ e₂, erw [category.id_comp, category.id_comp], rw homology_functor_map_iso end include H lemma homology_is_zero_of_bounded (i : ℤ) (e : a ≤ i) : is_zero ((homology_functor V (complex_shape.up ℤ) i).obj X) := begin apply is_zero_of_mono (homology_iso_cokernel_image_to_kernel' _ _ _).hom, apply is_zero_of_epi (cokernel.π _), apply is_zero_of_mono (kernel.ι _), apply H i e, all_goals { apply_instance } end omit H lemma replacement_is_projective (i : ℤ) : projective ((replacement X a H).X i) := begin dsimp [replacement], split_ifs, { apply_instance }, { dsimp [replacement_aux], induction (a - i).nat_abs; dsimp [replacement_aux]; apply_instance } end instance (i : ℤ) : epi ((replacement.hom X a H).f i) := begin dsimp [replacement.hom], split_ifs, { apply epi_of_is_zero, apply H, exact le_of_lt h }, { apply_instance } end lemma replacement_is_bounded : ∀ i (h : a ≤ i), is_zero ((replacement X a H).X i) := begin intros i h, dsimp [replacement], split_ifs, { exact is_zero_zero _ }, { have : a = i := by linarith, subst this, rw [sub_self, int.nat_abs_zero], dsimp [replacement_aux], exact is_zero_zero _ } end instance : quasi_iso (replacement.hom X a H) := begin constructor, intro i, rw ← sub_add_cancel i a, induction (i - a) with i i, { apply is_iso_of_is_zero, exact homology_is_zero_of_bounded _ a (replacement_is_bounded X a H) _ (by simp), exact homology_is_zero_of_bounded _ a H _ (by simp) }, { rw (show (-[1+ i] + a) = (a - ↑(i + 1)), by { rw [add_comm], refl }), rw homology_functor_map_iso' _ (a - ↑(i + 1) - 1) (a - ↑(i + 1)) (a - i), { rw replacement_hom_homology_iso X a H i, apply_instance }, { norm_num }, { norm_num [sub_add] }, apply_instance } end . @[simps] def _root_.cochain_complex.as_nat_chain_complex (X : cochain_complex V ℤ) (a : ℤ) : chain_complex V ℕ := { X := λ i, X.X (a - i), d := λ i j, X.d _ _, shape' := λ i j r, by { refine X.shape _ _ (λ e, r _), dsimp at e ⊢, apply int.coe_nat_inj, push_cast, linarith }, d_comp_d' := λ i j k _ _, X.d_comp_d _ _ _ } @[simps] def _root_.cochain_complex.to_nat_chain_complex (a : ℤ) : cochain_complex V ℤ ⥤ chain_complex V ℕ := { obj := λ X, X.as_nat_chain_complex a, map := λ X Y f, { f := λ i, f.f _ } } lemma is_zero_iff_iso_zero (X : V) : is_zero X ↔ nonempty (X ≅ 0) := ⟨λ e, ⟨e.iso_zero⟩, λ ⟨e⟩, is_zero_of_iso_of_zero (is_zero_zero _) e.symm⟩ lemma preadditive.exact_iff_homology_is_zero {X Y Z : V} (f : X ⟶ Y) (g : Y ⟶ Z) : exact f g ↔ ∃ w, is_zero (homology f g w) := begin rw preadditive.exact_iff_homology_zero, simp_rw is_zero_iff_iso_zero, end noncomputable def null_homotopic_of_projective_to_acyclic_aux {X Y : cochain_complex V ℤ} (f : X ⟶ Y) (a : ℤ) (h₁ : ∀ i, projective (X.X i)) (h₂ : ∀ i, a ≤ i → is_zero (X.X i)) (h₃ : ∀ i, is_zero ((homology_functor _ _ i).obj Y)) : homotopy ((cochain_complex.to_nat_chain_complex a).map f) 0 := begin have h₄ : ∀ i, a ≤ i → f.f i = 0, { intros i e, apply (h₂ i e).eq_of_src }, fapply homotopy.mk_inductive _ 0, { dsimp, rw zero_comp, apply h₄, push_cast, linarith }, all_goals { dsimp }, { have := f.comm (a - (0 + 1)) a, rw [h₄ _ (le_of_eq rfl), comp_zero] at this, refine projective.factor_thru (kernel.lift _ _ this) _, exact kernel.lift _ _ (Y.d_comp_d _ _ _), { apply_with kernel.lift.epi { instances := ff }, rw preadditive.exact_iff_homology_is_zero, refine ⟨Y.d_comp_d _ _ _, is_zero_of_iso_of_zero (h₃ (a - (0 + 1))) (homology_iso _ _ _ _ _ _)⟩, all_goals { dsimp, abel } } }, { rw comp_zero, conv_rhs { rw [zero_add] }, slice_rhs 2 3 { erw ← kernel.lift_ι _ _ (Y.d_comp_d (a - (0 + 1 + 1)) (a - (0 + 1)) a) }, erw [← category.assoc, projective.factor_thru_comp, kernel.lift_ι], refl }, { rintros n ⟨g₁, g₂, e⟩, dsimp only, have : X.d (a - (n + 1 + 1)) (a - (n + 1)) ≫ (f.f (a - (↑n + 1)) - g₂ ≫ Y.d (a - (↑n + 1 + 1)) (a - (↑n + 1))) = 0, { rw ← sub_eq_iff_eq_add at e, erw [e, X.d_comp_d_assoc, zero_comp] }, rw [preadditive.comp_sub, ← f.comm, ← category.assoc, ← preadditive.sub_comp] at this, fsplit, { refine projective.factor_thru (kernel.lift _ _ this) _, exact kernel.lift _ _ (Y.d_comp_d _ _ _), apply_with kernel.lift.epi { instances := ff }, rw preadditive.exact_iff_homology_is_zero, refine ⟨Y.d_comp_d _ _ _, is_zero_of_iso_of_zero (h₃ _) (homology_iso _ _ _ _ _ _)⟩, all_goals { dsimp, push_cast, abel } }, { rw ← sub_eq_iff_eq_add', slice_rhs 2 3 { erw ← kernel.lift_ι (Y.d (a-(n+1+1)) (a-(n+1))) _ (Y.d_comp_d _ _ _) }, erw [← category.assoc, projective.factor_thru_comp, kernel.lift_ι], refl } } end noncomputable def null_homotopic_of_projective_to_acyclic {X Y : cochain_complex V ℤ} (f : X ⟶ Y) (a : ℤ) (h₁ : ∀ i, projective (X.X i)) (h₂ : ∀ i, a ≤ i → is_zero (X.X i)) (h₃ : ∀ i, is_zero ((homology_functor _ _ i).obj Y)) : homotopy f 0 := { hom := λ i j, if h : i ≤ a ∧ j ≤ a then begin refine (X.X_eq_to_iso _).hom ≫ (null_homotopic_of_projective_to_acyclic_aux f a h₁ h₂ h₃).hom (a - i).nat_abs (a - j).nat_abs ≫ (Y.X_eq_to_iso _).hom, swap, symmetry, all_goals { rw [← int.abs_eq_nat_abs, eq_sub_iff_add_eq, ← eq_sub_iff_add_eq', abs_eq_self], cases h, rwa sub_nonneg } end else 0, zero' := begin intros i j e, split_ifs, { cases h, rw [(null_homotopic_of_projective_to_acyclic_aux f a h₁ h₂ h₃).zero, zero_comp, comp_zero], intro e', apply e, dsimp at e' ⊢, apply_fun (coe : ℕ → ℤ) at e', rw [int.coe_nat_add, ← int.abs_eq_nat_abs, ← int.abs_eq_nat_abs, abs_eq_self.mpr _, abs_eq_self.mpr _, int.coe_nat_one, sub_add, sub_right_inj] at e', rw [← e', sub_add_cancel], all_goals { rwa sub_nonneg } }, { refl } end, comm := begin intros i, rw [d_next_eq _ (show (complex_shape.up ℤ).rel i (i+1), from rfl), prev_d_eq _ (show (complex_shape.up ℤ).rel (i-1) i, from sub_add_cancel _ _)], have e₁ : i + 1 ≤ a ∧ i ≤ a ↔ i + 1 ≤ a := by { rw and_iff_left_iff_imp, intro e, linarith }, have e₂ : i ≤ a ∧ i ≤ a + 1 ↔ i ≤ a := by { rw and_iff_left_iff_imp, intro e, linarith }, simp only [tsub_le_iff_right, homological_complex.zero_f_apply, add_zero, e₁, e₂], by_cases H₁ : a ≤ i, { apply (h₂ _ H₁).eq_of_src, }, replace H₁ : i + 1 ≤ a, { linarith only [H₁] }, have H₂ : i ≤ a, { linarith only [H₁] }, rw [dif_pos H₁, dif_pos H₂], have e : a - (a - i).nat_abs = i, { rw [← int.abs_eq_nat_abs, abs_eq_self.mpr _, ← sub_add, sub_self, zero_add], rwa sub_nonneg }, rw [← cancel_mono (Y.X_eq_to_iso e.symm).hom, ← cancel_epi (X.X_eq_to_iso e).hom], have := (null_homotopic_of_projective_to_acyclic_aux f a h₁ h₂ h₃).comm (a - i).nat_abs, dsimp [from_next, to_prev] at this ⊢, simp only [homological_complex.X_d_eq_to_iso_assoc, category.comp_id, add_zero, homological_complex.X_d_eq_to_iso, category.id_comp, homological_complex.X_eq_to_iso_d_assoc, homological_complex.X_eq_to_iso_trans_assoc, preadditive.comp_add, category.assoc, homological_complex.X_eq_to_iso_d, homological_complex.X_eq_to_iso_trans, homological_complex.X_eq_to_iso_f_assoc, homological_complex.X_eq_to_iso_refl, preadditive.add_comp] at this ⊢, rw this, clear this, delta homological_complex.d_from homological_complex.d_to cochain_complex.as_nat_chain_complex, dsimp only, have aux₁ : (complex_shape.down ℕ).next (a - i).nat_abs = (a - (i + 1)).nat_abs, { apply complex_shape.next_eq', show (a - (i + 1)).nat_abs + 1 = (a - i).nat_abs, zify, rw [← int.abs_eq_nat_abs, abs_eq_self.mpr _, ← int.abs_eq_nat_abs, abs_eq_self.mpr _], { ring }, all_goals { linarith only [H₁, H₂] }, }, have aux₂ : (complex_shape.down ℕ).prev (a - i).nat_abs = (a - (i - 1)).nat_abs, { apply complex_shape.prev_eq', show (a - i).nat_abs + 1 = (a - (i - 1)).nat_abs, zify, rw [← int.abs_eq_nat_abs, abs_eq_self.mpr _, ← int.abs_eq_nat_abs, abs_eq_self.mpr _], { ring }, all_goals { linarith only [H₁, H₂] }, }, rw [← aux₁, ← aux₂], end } end category_theory.projective
[STATEMENT] lemma compact_Icc[simp, intro]: "compact {a .. b::real}" [PROOF STATE] proof (prove) goal (1 subgoal): 1. compact {a..b} [PROOF STEP] proof (cases "a \<le> b", rule compactI) [PROOF STATE] proof (state) goal (2 subgoals): 1. \<And>C. \<lbrakk>a \<le> b; \<forall>t\<in>C. open t; {a..b} \<subseteq> \<Union> C\<rbrakk> \<Longrightarrow> \<exists>C'\<subseteq>C. finite C' \<and> {a..b} \<subseteq> \<Union> C' 2. \<not> a \<le> b \<Longrightarrow> compact {a..b} [PROOF STEP] fix C [PROOF STATE] proof (state) goal (2 subgoals): 1. \<And>C. \<lbrakk>a \<le> b; \<forall>t\<in>C. open t; {a..b} \<subseteq> \<Union> C\<rbrakk> \<Longrightarrow> \<exists>C'\<subseteq>C. finite C' \<and> {a..b} \<subseteq> \<Union> C' 2. \<not> a \<le> b \<Longrightarrow> compact {a..b} [PROOF STEP] assume C: "a \<le> b" "\<forall>t\<in>C. open t" "{a..b} \<subseteq> \<Union>C" [PROOF STATE] proof (state) this: a \<le> b \<forall>t\<in>C. open t {a..b} \<subseteq> \<Union> C goal (2 subgoals): 1. \<And>C. \<lbrakk>a \<le> b; \<forall>t\<in>C. open t; {a..b} \<subseteq> \<Union> C\<rbrakk> \<Longrightarrow> \<exists>C'\<subseteq>C. finite C' \<and> {a..b} \<subseteq> \<Union> C' 2. \<not> a \<le> b \<Longrightarrow> compact {a..b} [PROOF STEP] define T where "T = {a .. b}" [PROOF STATE] proof (state) this: T = {a..b} goal (2 subgoals): 1. \<And>C. \<lbrakk>a \<le> b; \<forall>t\<in>C. open t; {a..b} \<subseteq> \<Union> C\<rbrakk> \<Longrightarrow> \<exists>C'\<subseteq>C. finite C' \<and> {a..b} \<subseteq> \<Union> C' 2. \<not> a \<le> b \<Longrightarrow> compact {a..b} [PROOF STEP] from C(1,3) [PROOF STATE] proof (chain) picking this: a \<le> b {a..b} \<subseteq> \<Union> C [PROOF STEP] show "\<exists>C'\<subseteq>C. finite C' \<and> {a..b} \<subseteq> \<Union>C'" [PROOF STATE] proof (prove) using this: a \<le> b {a..b} \<subseteq> \<Union> C goal (1 subgoal): 1. \<exists>C'\<subseteq>C. finite C' \<and> {a..b} \<subseteq> \<Union> C' [PROOF STEP] proof (induct rule: Bolzano) [PROOF STATE] proof (state) goal (2 subgoals): 1. \<And>a b c. \<lbrakk>{a..b} \<subseteq> \<Union> C \<Longrightarrow> \<exists>C'\<subseteq>C. finite C' \<and> {a..b} \<subseteq> \<Union> C'; {b..c} \<subseteq> \<Union> C \<Longrightarrow> \<exists>C'\<subseteq>C. finite C' \<and> {b..c} \<subseteq> \<Union> C'; a \<le> b; b \<le> c; {a..c} \<subseteq> \<Union> C\<rbrakk> \<Longrightarrow> \<exists>C'\<subseteq>C. finite C' \<and> {a..c} \<subseteq> \<Union> C' 2. \<And>x. \<lbrakk>a \<le> x; x \<le> b\<rbrakk> \<Longrightarrow> \<exists>d>0. \<forall>a b. a \<le> x \<and> x \<le> b \<and> b - a < d \<longrightarrow> {a..b} \<subseteq> \<Union> C \<longrightarrow> (\<exists>C'\<subseteq>C. finite C' \<and> {a..b} \<subseteq> \<Union> C') [PROOF STEP] case (trans a b c) [PROOF STATE] proof (state) this: {a..b} \<subseteq> \<Union> C \<Longrightarrow> \<exists>C'\<subseteq>C. finite C' \<and> {a..b} \<subseteq> \<Union> C' {b..c} \<subseteq> \<Union> C \<Longrightarrow> \<exists>C'\<subseteq>C. finite C' \<and> {b..c} \<subseteq> \<Union> C' a \<le> b b \<le> c {a..c} \<subseteq> \<Union> C goal (2 subgoals): 1. \<And>a b c. \<lbrakk>{a..b} \<subseteq> \<Union> C \<Longrightarrow> \<exists>C'\<subseteq>C. finite C' \<and> {a..b} \<subseteq> \<Union> C'; {b..c} \<subseteq> \<Union> C \<Longrightarrow> \<exists>C'\<subseteq>C. finite C' \<and> {b..c} \<subseteq> \<Union> C'; a \<le> b; b \<le> c; {a..c} \<subseteq> \<Union> C\<rbrakk> \<Longrightarrow> \<exists>C'\<subseteq>C. finite C' \<and> {a..c} \<subseteq> \<Union> C' 2. \<And>x. \<lbrakk>a \<le> x; x \<le> b\<rbrakk> \<Longrightarrow> \<exists>d>0. \<forall>a b. a \<le> x \<and> x \<le> b \<and> b - a < d \<longrightarrow> {a..b} \<subseteq> \<Union> C \<longrightarrow> (\<exists>C'\<subseteq>C. finite C' \<and> {a..b} \<subseteq> \<Union> C') [PROOF STEP] then [PROOF STATE] proof (chain) picking this: {a..b} \<subseteq> \<Union> C \<Longrightarrow> \<exists>C'\<subseteq>C. finite C' \<and> {a..b} \<subseteq> \<Union> C' {b..c} \<subseteq> \<Union> C \<Longrightarrow> \<exists>C'\<subseteq>C. finite C' \<and> {b..c} \<subseteq> \<Union> C' a \<le> b b \<le> c {a..c} \<subseteq> \<Union> C [PROOF STEP] have *: "{a..c} = {a..b} \<union> {b..c}" [PROOF STATE] proof (prove) using this: {a..b} \<subseteq> \<Union> C \<Longrightarrow> \<exists>C'\<subseteq>C. finite C' \<and> {a..b} \<subseteq> \<Union> C' {b..c} \<subseteq> \<Union> C \<Longrightarrow> \<exists>C'\<subseteq>C. finite C' \<and> {b..c} \<subseteq> \<Union> C' a \<le> b b \<le> c {a..c} \<subseteq> \<Union> C goal (1 subgoal): 1. {a..c} = {a..b} \<union> {b..c} [PROOF STEP] by auto [PROOF STATE] proof (state) this: {a..c} = {a..b} \<union> {b..c} goal (2 subgoals): 1. \<And>a b c. \<lbrakk>{a..b} \<subseteq> \<Union> C \<Longrightarrow> \<exists>C'\<subseteq>C. finite C' \<and> {a..b} \<subseteq> \<Union> C'; {b..c} \<subseteq> \<Union> C \<Longrightarrow> \<exists>C'\<subseteq>C. finite C' \<and> {b..c} \<subseteq> \<Union> C'; a \<le> b; b \<le> c; {a..c} \<subseteq> \<Union> C\<rbrakk> \<Longrightarrow> \<exists>C'\<subseteq>C. finite C' \<and> {a..c} \<subseteq> \<Union> C' 2. \<And>x. \<lbrakk>a \<le> x; x \<le> b\<rbrakk> \<Longrightarrow> \<exists>d>0. \<forall>a b. a \<le> x \<and> x \<le> b \<and> b - a < d \<longrightarrow> {a..b} \<subseteq> \<Union> C \<longrightarrow> (\<exists>C'\<subseteq>C. finite C' \<and> {a..b} \<subseteq> \<Union> C') [PROOF STEP] with trans [PROOF STATE] proof (chain) picking this: {a..b} \<subseteq> \<Union> C \<Longrightarrow> \<exists>C'\<subseteq>C. finite C' \<and> {a..b} \<subseteq> \<Union> C' {b..c} \<subseteq> \<Union> C \<Longrightarrow> \<exists>C'\<subseteq>C. finite C' \<and> {b..c} \<subseteq> \<Union> C' a \<le> b b \<le> c {a..c} \<subseteq> \<Union> C {a..c} = {a..b} \<union> {b..c} [PROOF STEP] obtain C1 C2 where "C1\<subseteq>C" "finite C1" "{a..b} \<subseteq> \<Union>C1" "C2\<subseteq>C" "finite C2" "{b..c} \<subseteq> \<Union>C2" [PROOF STATE] proof (prove) using this: {a..b} \<subseteq> \<Union> C \<Longrightarrow> \<exists>C'\<subseteq>C. finite C' \<and> {a..b} \<subseteq> \<Union> C' {b..c} \<subseteq> \<Union> C \<Longrightarrow> \<exists>C'\<subseteq>C. finite C' \<and> {b..c} \<subseteq> \<Union> C' a \<le> b b \<le> c {a..c} \<subseteq> \<Union> C {a..c} = {a..b} \<union> {b..c} goal (1 subgoal): 1. (\<And>C1 C2. \<lbrakk>C1 \<subseteq> C; finite C1; {a..b} \<subseteq> \<Union> C1; C2 \<subseteq> C; finite C2; {b..c} \<subseteq> \<Union> C2\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis [PROOF STEP] by auto [PROOF STATE] proof (state) this: C1 \<subseteq> C finite C1 {a..b} \<subseteq> \<Union> C1 C2 \<subseteq> C finite C2 {b..c} \<subseteq> \<Union> C2 goal (2 subgoals): 1. \<And>a b c. \<lbrakk>{a..b} \<subseteq> \<Union> C \<Longrightarrow> \<exists>C'\<subseteq>C. finite C' \<and> {a..b} \<subseteq> \<Union> C'; {b..c} \<subseteq> \<Union> C \<Longrightarrow> \<exists>C'\<subseteq>C. finite C' \<and> {b..c} \<subseteq> \<Union> C'; a \<le> b; b \<le> c; {a..c} \<subseteq> \<Union> C\<rbrakk> \<Longrightarrow> \<exists>C'\<subseteq>C. finite C' \<and> {a..c} \<subseteq> \<Union> C' 2. \<And>x. \<lbrakk>a \<le> x; x \<le> b\<rbrakk> \<Longrightarrow> \<exists>d>0. \<forall>a b. a \<le> x \<and> x \<le> b \<and> b - a < d \<longrightarrow> {a..b} \<subseteq> \<Union> C \<longrightarrow> (\<exists>C'\<subseteq>C. finite C' \<and> {a..b} \<subseteq> \<Union> C') [PROOF STEP] with trans [PROOF STATE] proof (chain) picking this: {a..b} \<subseteq> \<Union> C \<Longrightarrow> \<exists>C'\<subseteq>C. finite C' \<and> {a..b} \<subseteq> \<Union> C' {b..c} \<subseteq> \<Union> C \<Longrightarrow> \<exists>C'\<subseteq>C. finite C' \<and> {b..c} \<subseteq> \<Union> C' a \<le> b b \<le> c {a..c} \<subseteq> \<Union> C C1 \<subseteq> C finite C1 {a..b} \<subseteq> \<Union> C1 C2 \<subseteq> C finite C2 {b..c} \<subseteq> \<Union> C2 [PROOF STEP] show ?case [PROOF STATE] proof (prove) using this: {a..b} \<subseteq> \<Union> C \<Longrightarrow> \<exists>C'\<subseteq>C. finite C' \<and> {a..b} \<subseteq> \<Union> C' {b..c} \<subseteq> \<Union> C \<Longrightarrow> \<exists>C'\<subseteq>C. finite C' \<and> {b..c} \<subseteq> \<Union> C' a \<le> b b \<le> c {a..c} \<subseteq> \<Union> C C1 \<subseteq> C finite C1 {a..b} \<subseteq> \<Union> C1 C2 \<subseteq> C finite C2 {b..c} \<subseteq> \<Union> C2 goal (1 subgoal): 1. \<exists>C'\<subseteq>C. finite C' \<and> {a..c} \<subseteq> \<Union> C' [PROOF STEP] unfolding * [PROOF STATE] proof (prove) using this: {a..b} \<subseteq> \<Union> C \<Longrightarrow> \<exists>C'\<subseteq>C. finite C' \<and> {a..b} \<subseteq> \<Union> C' {b..c} \<subseteq> \<Union> C \<Longrightarrow> \<exists>C'\<subseteq>C. finite C' \<and> {b..c} \<subseteq> \<Union> C' a \<le> b b \<le> c {a..b} \<union> {b..c} \<subseteq> \<Union> C C1 \<subseteq> C finite C1 {a..b} \<subseteq> \<Union> C1 C2 \<subseteq> C finite C2 {b..c} \<subseteq> \<Union> C2 goal (1 subgoal): 1. \<exists>C'\<subseteq>C. finite C' \<and> {a..b} \<union> {b..c} \<subseteq> \<Union> C' [PROOF STEP] by (intro exI[of _ "C1 \<union> C2"]) auto [PROOF STATE] proof (state) this: \<exists>C'\<subseteq>C. finite C' \<and> {a..c} \<subseteq> \<Union> C' goal (1 subgoal): 1. \<And>x. \<lbrakk>a \<le> x; x \<le> b\<rbrakk> \<Longrightarrow> \<exists>d>0. \<forall>a b. a \<le> x \<and> x \<le> b \<and> b - a < d \<longrightarrow> {a..b} \<subseteq> \<Union> C \<longrightarrow> (\<exists>C'\<subseteq>C. finite C' \<and> {a..b} \<subseteq> \<Union> C') [PROOF STEP] next [PROOF STATE] proof (state) goal (1 subgoal): 1. \<And>x. \<lbrakk>a \<le> x; x \<le> b\<rbrakk> \<Longrightarrow> \<exists>d>0. \<forall>a b. a \<le> x \<and> x \<le> b \<and> b - a < d \<longrightarrow> {a..b} \<subseteq> \<Union> C \<longrightarrow> (\<exists>C'\<subseteq>C. finite C' \<and> {a..b} \<subseteq> \<Union> C') [PROOF STEP] case (local x) [PROOF STATE] proof (state) this: a \<le> x x \<le> b goal (1 subgoal): 1. \<And>x. \<lbrakk>a \<le> x; x \<le> b\<rbrakk> \<Longrightarrow> \<exists>d>0. \<forall>a b. a \<le> x \<and> x \<le> b \<and> b - a < d \<longrightarrow> {a..b} \<subseteq> \<Union> C \<longrightarrow> (\<exists>C'\<subseteq>C. finite C' \<and> {a..b} \<subseteq> \<Union> C') [PROOF STEP] with C [PROOF STATE] proof (chain) picking this: a \<le> b \<forall>t\<in>C. open t {a..b} \<subseteq> \<Union> C a \<le> x x \<le> b [PROOF STEP] have "x \<in> \<Union>C" [PROOF STATE] proof (prove) using this: a \<le> b \<forall>t\<in>C. open t {a..b} \<subseteq> \<Union> C a \<le> x x \<le> b goal (1 subgoal): 1. x \<in> \<Union> C [PROOF STEP] by auto [PROOF STATE] proof (state) this: x \<in> \<Union> C goal (1 subgoal): 1. \<And>x. \<lbrakk>a \<le> x; x \<le> b\<rbrakk> \<Longrightarrow> \<exists>d>0. \<forall>a b. a \<le> x \<and> x \<le> b \<and> b - a < d \<longrightarrow> {a..b} \<subseteq> \<Union> C \<longrightarrow> (\<exists>C'\<subseteq>C. finite C' \<and> {a..b} \<subseteq> \<Union> C') [PROOF STEP] with C(2) [PROOF STATE] proof (chain) picking this: \<forall>t\<in>C. open t x \<in> \<Union> C [PROOF STEP] obtain c where "x \<in> c" "open c" "c \<in> C" [PROOF STATE] proof (prove) using this: \<forall>t\<in>C. open t x \<in> \<Union> C goal (1 subgoal): 1. (\<And>c. \<lbrakk>x \<in> c; open c; c \<in> C\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis [PROOF STEP] by auto [PROOF STATE] proof (state) this: x \<in> c open c c \<in> C goal (1 subgoal): 1. \<And>x. \<lbrakk>a \<le> x; x \<le> b\<rbrakk> \<Longrightarrow> \<exists>d>0. \<forall>a b. a \<le> x \<and> x \<le> b \<and> b - a < d \<longrightarrow> {a..b} \<subseteq> \<Union> C \<longrightarrow> (\<exists>C'\<subseteq>C. finite C' \<and> {a..b} \<subseteq> \<Union> C') [PROOF STEP] then [PROOF STATE] proof (chain) picking this: x \<in> c open c c \<in> C [PROOF STEP] obtain e where "0 < e" "{x - e <..< x + e} \<subseteq> c" [PROOF STATE] proof (prove) using this: x \<in> c open c c \<in> C goal (1 subgoal): 1. (\<And>e. \<lbrakk>0 < e; {x - e<..<x + e} \<subseteq> c\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis [PROOF STEP] by (auto simp: open_dist dist_real_def subset_eq Ball_def abs_less_iff) [PROOF STATE] proof (state) this: 0 < e {x - e<..<x + e} \<subseteq> c goal (1 subgoal): 1. \<And>x. \<lbrakk>a \<le> x; x \<le> b\<rbrakk> \<Longrightarrow> \<exists>d>0. \<forall>a b. a \<le> x \<and> x \<le> b \<and> b - a < d \<longrightarrow> {a..b} \<subseteq> \<Union> C \<longrightarrow> (\<exists>C'\<subseteq>C. finite C' \<and> {a..b} \<subseteq> \<Union> C') [PROOF STEP] with \<open>c \<in> C\<close> [PROOF STATE] proof (chain) picking this: c \<in> C 0 < e {x - e<..<x + e} \<subseteq> c [PROOF STEP] show ?case [PROOF STATE] proof (prove) using this: c \<in> C 0 < e {x - e<..<x + e} \<subseteq> c goal (1 subgoal): 1. \<exists>d>0. \<forall>a b. a \<le> x \<and> x \<le> b \<and> b - a < d \<longrightarrow> {a..b} \<subseteq> \<Union> C \<longrightarrow> (\<exists>C'\<subseteq>C. finite C' \<and> {a..b} \<subseteq> \<Union> C') [PROOF STEP] by (safe intro!: exI[of _ "e/2"] exI[of _ "{c}"]) auto [PROOF STATE] proof (state) this: \<exists>d>0. \<forall>a b. a \<le> x \<and> x \<le> b \<and> b - a < d \<longrightarrow> {a..b} \<subseteq> \<Union> C \<longrightarrow> (\<exists>C'\<subseteq>C. finite C' \<and> {a..b} \<subseteq> \<Union> C') goal: No subgoals! [PROOF STEP] qed [PROOF STATE] proof (state) this: \<exists>C'\<subseteq>C. finite C' \<and> {a..b} \<subseteq> \<Union> C' goal (1 subgoal): 1. \<not> a \<le> b \<Longrightarrow> compact {a..b} [PROOF STEP] qed simp
------------------------------------------------------------------------ -- The Agda standard library -- -- A definition for the permutation relation using setoid equality ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.List.Relation.Binary.Permutation.Homogeneous where open import Data.List.Base using (List; _∷_) open import Data.List.Relation.Binary.Pointwise as Pointwise using (Pointwise) open import Level using (Level; _⊔_) open import Relation.Binary private variable a r s : Level A : Set a data Permutation {A : Set a} (R : Rel A r) : Rel (List A) (a ⊔ r) where refl : ∀ {xs ys} → Pointwise R xs ys → Permutation R xs ys prep : ∀ {xs ys x y} (eq : R x y) → Permutation R xs ys → Permutation R (x ∷ xs) (y ∷ ys) swap : ∀ {xs ys x y x' y'} (eq₁ : R x x') (eq₂ : R y y') → Permutation R xs ys → Permutation R (x ∷ y ∷ xs) (y' ∷ x' ∷ ys) trans : ∀ {xs ys zs} → Permutation R xs ys → Permutation R ys zs → Permutation R xs zs ------------------------------------------------------------------------ -- The Permutation relation is an equivalence module _ {R : Rel A r} where sym : Symmetric R → Symmetric (Permutation R) sym R-sym (refl xs∼ys) = refl (Pointwise.symmetric R-sym xs∼ys) sym R-sym (prep x∼x' xs↭ys) = prep (R-sym x∼x') (sym R-sym xs↭ys) sym R-sym (swap x∼x' y∼y' xs↭ys) = swap (R-sym y∼y') (R-sym x∼x') (sym R-sym xs↭ys) sym R-sym (trans xs↭ys ys↭zs) = trans (sym R-sym ys↭zs) (sym R-sym xs↭ys) isEquivalence : Reflexive R → Symmetric R → IsEquivalence (Permutation R) isEquivalence R-refl R-sym = record { refl = refl (Pointwise.refl R-refl) ; sym = sym R-sym ; trans = trans } setoid : Reflexive R → Symmetric R → Setoid _ _ setoid R-refl R-sym = record { isEquivalence = isEquivalence R-refl R-sym } map : ∀ {R : Rel A r} {S : Rel A s} → (R ⇒ S) → (Permutation R ⇒ Permutation S) map R⇒S (refl xs∼ys) = refl (Pointwise.map R⇒S xs∼ys) map R⇒S (prep e xs∼ys) = prep (R⇒S e) (map R⇒S xs∼ys) map R⇒S (swap e₁ e₂ xs∼ys) = swap (R⇒S e₁) (R⇒S e₂) (map R⇒S xs∼ys) map R⇒S (trans xs∼ys ys∼zs) = trans (map R⇒S xs∼ys) (map R⇒S ys∼zs)
#include <boost_adaptbx/tests/tst_optional_copy.h> #include <vector> #include <iostream> #include <cstdio> struct empty {}; int main(int argc, char* argv[]) { unsigned long n_iter = 1; if (argc == 2) { std::sscanf(argv[1], "%lu", &n_iter); } for(unsigned long i_iter=0;i_iter==0||i_iter<n_iter;) { { using tbxx::optional_copy; optional_copy<int> oc_int; TBXX_ASSERT(!oc_int); oc_int = 1; TBXX_ASSERT(oc_int); TBXX_ASSERT(*oc_int == 1); } { using tbxx::optional_copy; optional_copy<empty> oc_empty; TBXX_ASSERT(!oc_empty); oc_empty = empty(); TBXX_ASSERT(oc_empty); } { std::size_t n = 1; std::vector<int> v1(n, 1); std::vector<int> v4(n, 4); using boost_adaptbx::tst_optional_copy::exercise; exercise(v1, v4, /*value_is_shared*/ false); } if (n_iter != 0) i_iter++; } std::cout << "OK\n"; return 0; }
function kern = rbfard2KernParamInit(kern) % RBFARD2KERNPARAMINIT RBFARD2 kernel parameter initialisation. % The automatic relevance determination version of the radial basis % function kernel (RBFARD2) is a very smooth non-linear kernel and is a % popular choice for generic use. % % k(x_i, x_j) = sigma2 * exp(-1/2 *(x_i - x_j)'*A*(x_i - x_j)) % % The parameters are sigma2, the process variance (kern.variance), the % diagonal matrix of input scales (kern.inputScales, constrained to be % positive). % % SEEALSO : rbfKernParamInit % % FORMAT % DESC initialises the automatic relevance determination radial basis function % kernel structure with some default parameters. % ARG kern : the kernel structure which requires initialisation. % RETURN kern : the kernel structure with the default parameters placed in. % % SEEALSO : kernCreate, kernParamInit % % COPYRIGHT : Neil D. Lawrence, 2004, 2005, 2006 % % COPYRIGHT : Michalis K. Titsias, 2009 % KERN % This parameter is restricted positive. kern.variance = 1; kern.inputScales = 0.999*ones(1, kern.inputDimension); kern.nParams = 1 + kern.inputDimension; kern.transforms(1).index = [1:kern.nParams]; kern.transforms(1).type = optimiDefaultConstraint('positive'); kern.isStationary = true;
[STATEMENT] theorem E19: "\<turnstile> \<diamond>\<box>F \<longrightarrow> \<box>\<diamond>\<box>F" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<turnstile> \<diamond>\<box>F \<longrightarrow> \<box>\<diamond>\<box>F [PROOF STEP] proof - [PROOF STATE] proof (state) goal (1 subgoal): 1. \<turnstile> \<diamond>\<box>F \<longrightarrow> \<box>\<diamond>\<box>F [PROOF STEP] have "\<turnstile> (\<box>F \<and> \<not>\<box>F) = #False" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<turnstile> (\<box>F \<and> \<not> \<box>F) = #False [PROOF STEP] by auto [PROOF STATE] proof (state) this: \<turnstile> (\<box>F \<and> \<not> \<box>F) = #False goal (1 subgoal): 1. \<turnstile> \<diamond>\<box>F \<longrightarrow> \<box>\<diamond>\<box>F [PROOF STEP] hence "\<turnstile> \<diamond>\<box>(\<box>F \<and> \<not>\<box>F) = \<diamond>\<box>#False" [PROOF STATE] proof (prove) using this: \<turnstile> (\<box>F \<and> \<not> \<box>F) = #False goal (1 subgoal): 1. \<turnstile> \<diamond>\<box>(\<box>F \<and> \<not> \<box>F) = \<diamond>\<box>#False [PROOF STEP] by (rule E22[OF MM1]) [PROOF STATE] proof (state) this: \<turnstile> \<diamond>\<box>(\<box>F \<and> \<not> \<box>F) = \<diamond>\<box>#False goal (1 subgoal): 1. \<turnstile> \<diamond>\<box>F \<longrightarrow> \<box>\<diamond>\<box>F [PROOF STEP] thus ?thesis [PROOF STATE] proof (prove) using this: \<turnstile> \<diamond>\<box>(\<box>F \<and> \<not> \<box>F) = \<diamond>\<box>#False goal (1 subgoal): 1. \<turnstile> \<diamond>\<box>F \<longrightarrow> \<box>\<diamond>\<box>F [PROOF STEP] unfolding STL6[int_rewrite] [PROOF STATE] proof (prove) using this: \<turnstile> (\<diamond>\<box>\<box>F \<and> \<diamond>\<box>\<not> \<box>F) = \<diamond>\<box>#False goal (1 subgoal): 1. \<turnstile> \<diamond>\<box>F \<longrightarrow> \<box>\<diamond>\<box>F [PROOF STEP] by (auto simp: eventually_def) [PROOF STATE] proof (state) this: \<turnstile> \<diamond>\<box>F \<longrightarrow> \<box>\<diamond>\<box>F goal: No subgoals! [PROOF STEP] qed
t0 = (0,) t1 = (1, 4, 3) # finding elements println(t0[1]) # 0 println(t1[end]) # 3 println(t1[2:3]) # (4, 3) # unpacking a, b, c = t1 print("a=$a, b=$b, c=$c") #=============================# # NOTES: Tuple are immutable # #=============================#
\atsp \begin{frame}{\ft{Obtaining Information About Parameters}} \section{Group 1: Obtaining Information About Parameters} \pdfpageheight 30cm \begin{annotatedFigure}{0pt}{0pt} {\includegraphics[scale=1.5]{texs/about.png}} \pgfdeclareverticalshading{myshading}{100bp}{color(0bp)=(yellow!60); %color(30bp)=(yellow!10); %color(70bp)=(green!10); color(100bp)=(green!10)} \node [text width=13cm,inner sep=14pt,align=justify,%fill=logoCyan!20, %draw=logoBlue, %draw opacity=0.5, line width=1mm, fill opacity=0.9, draw=green!40!black,shading=myshading, shading angle=125] at (0.58,0.76){\annfont\textbf{Context menus also allow users to obtain information and explanations about individual parts of the data set, such as individual statistical parameters. In this screenshot, the user has right-clicked on a data column (Flow) and has chosen a context menu action which shows, via a dialog box, a precis of the quantities represented in that column and their significance for the data set as a whole.}}; \annotatedFigureBox{0.2,0.12}{0.812,0.645}{1}{0.81,0.645}% \end{annotatedFigure} \end{frame}
\documentclass{memoir} \usepackage{notestemplate} %\logo{~/School-Work/Auxiliary-Files/resources/png/logo.png} %\institute{Rice University} %\faculty{Faculty of Whatever Sciences} %\department{Department of Mathematics} %\title{Class Notes} %\subtitle{Based on MATH xxx} %\author{\textit{Author}\\Gabriel \textsc{Gress}} %\supervisor{Linus \textsc{Torvalds}} %\context{Well, I was bored...} %\date{\today} \begin{document} % \maketitle % Notes taken on 05/10/21 Now we apply this theorem to finite fields. Consider \(\mathbb{F}_{p^{n}}\), the splitting field of \(x^{p^{n}}-x\). This is Galois over \(\mathbb{F}_p\). Thus we have \(\left| \textrm{Aut}(\mathbb{F}_{p^{n}} / \mathbb{F}_p )\right| = [ \mathbb{F}_{p^{n}}: \mathbb{F}_p ] = n \). This gives us \(\textrm{Gal}(\mathbb{F}_{p^{n}} / \mathbb{F}_p ) = \Z / n\Z\) and the Galois group consists solely of the Frobenius endomorphism.\\ One can see then that all subfields \(\mathbb{F}_p\subset E\subset \mathbb{F}_{p^{n}}\) have the form \(E \cong \mathbb{F}_{p^{d}}\) for some \(d\mid n\). Of course, this means that \(E / F\) is necessarily Galois as well! \section{Applications of Galois Theory} \label{sec:applications_of_galois_theory} \begin{prop} The irreducible polynomial \(x^{4}+1 \in \Z[x]\) is reducible over \(\mathbb{F}_p\) for any prime \(p\). \end{prop} \begin{proof} One can check this directly for \(p=2\). If \(p>2\), then observe that \(p \cong 1,3,5\) or \(7 \mod 8\), and hence \(p^2 \cong 1 \mod 8\). Therefore we have that \(x^{8}-1 \mid x^{p^2-1}-1\) over \(\mathbb{F}_p\).\\ Of course, \(x^{4}+1 \mid x^{8}-1\) and so any root of \(x^{4}+1\) is a root of \(x^{p^2}-x\) and hence are elements of the field \(\mathbb{F}_{p^2}\). Since \([\mathbb{F}_{p^2}:\mathbb{F}_p] = 2\), the degree of the extension is no more than 2. Of course, if \(x^{4}+1\) were irreducible over \(\mathbb{F}_p\), then it would necessarily be 4, and hence it must be reducible. \end{proof} \begin{prop} \begin{align*} x^{p^{n}}-x = \prod_{d\mid n} \left\{ \text{irreducible polynomial in \(\mathbb{F}_p[x]\) of degree \(d\)} \right\} \end{align*} \end{prop} We can use this recursively as \(n\) increases. \end{document}
/- Lemma 10.16.6. Let R be a ring. Let f∈R. The map R→Rf induces via the functoriality of Spec a homeomorphism Spec(Rf)⟶D(f)⊂Spec(R). The inverse is given by 𝔭↦𝔭⋅Rf. Proof. This is a special case of Lemma 10.16.5 (=tag 00E3) -/ import analysis.topology.topological_space analysis.topology.continuity tag00E2 localization import Kenny_comm_alg.Zariski import mathlib_someday.topology universes u /-- tag 00E4 -/ -- note: this should be in mathlib as a structure lemma lemma_standard_open (R : Type u) [comm_ring R] (f : R) : let φ := Zariski.induced $ localization.of_comm_ring R (powers f) in topological_space.open_immersion' φ ∧ φ '' set.univ = Spec.D'(f) := ⟨⟨Zariski.induced.continuous _, λ x y hxy, subtype.eq $ set.ext $ λ z, quotient.induction_on z $ λ ⟨r, s, hs⟩, ⟨λ hr, have h1 : _ := localization.mul_denom R _ r s hs, have h2 : localization.of_comm_ring R (powers f) r ∈ x.val, from eq.rec (@@is_ideal.mul_right _ x.2.1.1 hr) h1, have h3 : r ∈ (Zariski.induced (localization.of_comm_ring R (powers f)) y).1, from eq.rec h2 hxy, have h4 : localization.of_comm_ring R (powers f) r ∈ y.val, from h3, have h5 : _ := localization.mul_inv_denom R _ r s hs, eq.rec (@@is_ideal.mul_right _ y.2.1.1 h4) h5, λ hr, have h1 : _ := localization.mul_denom R _ r s hs, have h2 : localization.of_comm_ring R (powers f) r ∈ y.val, from eq.rec (@@is_ideal.mul_right _ y.2.1.1 hr) h1, have h3 : r ∈ (Zariski.induced (localization.of_comm_ring R (powers f)) x).1, from eq.rec h2 hxy.symm, have h4 : localization.of_comm_ring R (powers f) r ∈ x.val, from h3, have h5 : _ := localization.mul_inv_denom R _ r s hs, eq.rec (@@is_ideal.mul_right _ x.2.1.1 h4) h5⟩, λ S hs, let ⟨F, hsf⟩ := hs in let F' := {fr | ∃ (r) (s ∈ powers f), fr = f * r ∧ ⟦(⟨r, s, H⟩ : R × powers f)⟧ ∈ F} in ⟨F', set.ext $ λ z, ⟨λ hz ⟨x, hxs, hnz⟩, have h1 : x ∈ Spec.V F, from λ g, quotient.induction_on g $ λ ⟨r, s, hsg⟩ hg, have h2 : f * r ∈ F', from ⟨r, s, hsg, rfl, hg⟩, have h3 : _, from hz h2, have h4 : f * s ∈ powers f, from let ⟨n, hfns⟩ := hsg in ⟨nat.succ n, by rw ← hfns; refl⟩, have h5 : ⟦((r, ⟨s, hsg⟩) : R × powers f)⟧ = ⟦(f * r, ⟨f * s, h4⟩)⟧, from quotient.sound ⟨1, is_submonoid.one_mem _, by simp [mul_left_comm, mul_assoc]⟩, begin rw h5, rw ← localization.mul_inv_denom, rw ← hnz at h3, exact @@is_ideal.mul_right _ x.2.1.1 h3 end, by rw hsf at h1; exact h1 hxs, λ hz g ⟨r, s, hsg, hgfr, hrs⟩, classical.by_contradiction $ λ hngz, have h1 : f ∉ z.1, by intro hn; apply hngz; rw hgfr; exact @@is_ideal.mul_right _ z.2.1.1 hn, let z' : set (localization.loc R (powers f)) := {f | quotient.lift_on f (λ g, g.1 ∈ z.1) $ begin intros f1 f4 h2, rcases f1 with ⟨f1, f2, f3⟩, rcases f4 with ⟨f4, f5, f6⟩, rcases h2 with ⟨h2, h3, h4⟩, simp [-sub_eq_add_neg, sub_mul, sub_eq_zero] at h4 ⊢, apply propext, show f1 ∈ z.val ↔ f4 ∈ z.val, split, { intro h5, have h6 : f5 * f1 * h2 ∈ z.val, { apply @@is_ideal.mul_right _ z.2.1.1, exact @@is_ideal.mul_left _ z.2.1.1 h5 }, rw ← h4 at h6, cases @@is_prime_ideal.mem_or_mem_of_mul_mem _ z.2 h6 with h7 h7, cases @@is_prime_ideal.mem_or_mem_of_mul_mem _ z.2 h7 with h8 h8, { exfalso, apply h1, cases f3 with f7 f8, apply @@is_prime_ideal.mem_of_pow_mem _ z.2, rw ← f8 at h8, exact h8 }, { exact h8 }, { exfalso, apply h1, cases h3 with f7 f8, apply @@is_prime_ideal.mem_of_pow_mem _ z.2, rw ← f8 at h7, exact h7 } }, { intro h5, have h6 : f2 * f4 * h2 ∈ z.val, { apply @@is_ideal.mul_right _ z.2.1.1, exact @@is_ideal.mul_left _ z.2.1.1 h5 }, rw h4 at h6, cases @@is_prime_ideal.mem_or_mem_of_mul_mem _ z.2 h6 with h7 h7, cases @@is_prime_ideal.mem_or_mem_of_mul_mem _ z.2 h7 with h8 h8, { exfalso, apply h1, cases f6 with f7 f8, apply @@is_prime_ideal.mem_of_pow_mem _ z.2, rw ← f8 at h8, exact h8 }, { exact h8 }, { exfalso, apply h1, cases h3 with f7 f8, apply @@is_prime_ideal.mem_of_pow_mem _ z.2, rw ← f8 at h7, exact h7 } } end} in have h2 : is_prime_ideal z', from { zero_ := by simp [localization.zero_frac]; exact @@is_ideal.zero _ _ z.2.1.1, add_ := λ f1 f2, quotient.induction_on₂ f1 f2 $ λ ⟨r1, s1, hs1⟩ ⟨r2, s2, hs2⟩ hg1 hg2, by simp [localization.mk_eq, localization.add_frac] at hg1 hg2 ⊢; exact @@is_ideal.add _ z.2.1.1 (@@is_ideal.mul_left _ z.2.1.1 hg2) (@@is_ideal.mul_left _ z.2.1.1 hg1), smul := λ c x, quotient.induction_on₂ c x $ λ ⟨r1, s1, hs1⟩ ⟨r2, s2, hs2⟩ hg2, by simp [localization.mk_eq, localization.mul_frac] at hg2 ⊢; exact @@is_ideal.mul_left _ z.2.1.1 hg2, ne_univ := λ h2, h1 $ by rw set.eq_univ_iff_forall at h2; exact h2 (localization.of_comm_ring _ _ f), mem_or_mem_of_mul_mem := λ f1 f2, quotient.induction_on₂ f1 f2 $ λ ⟨r1, s1, hs1⟩ ⟨r2, s2, hs2⟩ hg2, by simp [localization.mk_eq, localization.mul_frac] at hg2 ⊢; exact @@is_prime_ideal.mem_or_mem_of_mul_mem _ z.2 hg2 }, have h3 : (⟨z', h2⟩ : X (localization.loc R (powers f))) ∉ Spec.V F, from λ h3, hngz $ by rw hgfr; exact @@is_ideal.mul_left _ z.2.1.1 (h3 hrs), hz ⟨⟨z', h2⟩, by rw hsf at h3; exact classical.by_contradiction h3, begin apply subtype.eq, apply set.ext, intro r1, simp [Zariski.induced, localization.of_comm_ring] end⟩⟩⟩⟩, set.ext $ λ x, ⟨λ ⟨y, _, hyx⟩ hfx, have h1 : localization.of_comm_ring R (powers f) f ∈ y.val, by rwa ← hyx at hfx, @@is_prime_ideal.one_not_mem _ y.1 y.2 $ begin rw ← @localization.div_self _ _ (powers f) _ f ⟨1, by simp⟩, unfold localization.mk, rw ← localization.mul_inv_denom _ (powers f), exact @@is_ideal.mul_right _ y.2.1.1 h1 end, λ hx, let y : set (localization.loc R (powers f)) := {f | quotient.lift_on f (λ g, g.1 ∈ x.1) $ begin intros f1 f4 h2, rcases f1 with ⟨f1, f2, f3⟩, rcases f4 with ⟨f4, f5, f6⟩, rcases h2 with ⟨h2, h3, h4⟩, simp [-sub_eq_add_neg, sub_mul, sub_eq_zero] at h4 ⊢, apply propext, show f1 ∈ x.val ↔ f4 ∈ x.val, split, { intro h5, have h6 : f5 * f1 * h2 ∈ x.val, { apply @@is_ideal.mul_right _ x.2.1.1, exact @@is_ideal.mul_left _ x.2.1.1 h5 }, rw ← h4 at h6, cases @@is_prime_ideal.mem_or_mem_of_mul_mem _ x.2 h6 with h7 h7, cases @@is_prime_ideal.mem_or_mem_of_mul_mem _ x.2 h7 with h8 h8, { exfalso, apply hx, cases f3 with f7 f8, apply @@is_prime_ideal.mem_of_pow_mem _ x.2, rw ← f8 at h8, exact h8 }, { exact h8 }, { exfalso, apply hx, cases h3 with f7 f8, apply @@is_prime_ideal.mem_of_pow_mem _ x.2, rw ← f8 at h7, exact h7 } }, { intro h5, have h6 : f2 * f4 * h2 ∈ x.val, { apply @@is_ideal.mul_right _ x.2.1.1, exact @@is_ideal.mul_left _ x.2.1.1 h5 }, rw h4 at h6, cases @@is_prime_ideal.mem_or_mem_of_mul_mem _ x.2 h6 with h7 h7, cases @@is_prime_ideal.mem_or_mem_of_mul_mem _ x.2 h7 with h8 h8, { exfalso, apply hx, cases f6 with f7 f8, apply @@is_prime_ideal.mem_of_pow_mem _ x.2, rw ← f8 at h8, exact h8 }, { exact h8 }, { exfalso, apply hx, cases h3 with f7 f8, apply @@is_prime_ideal.mem_of_pow_mem _ x.2, rw ← f8 at h7, exact h7 } } end} in have h2 : is_prime_ideal y, from { zero_ := by simp [localization.zero_frac]; exact @@is_ideal.zero _ _ x.2.1.1, add_ := λ f1 f2, quotient.induction_on₂ f1 f2 $ λ ⟨r1, s1, hs1⟩ ⟨r2, s2, hs2⟩ hg1 hg2, by simp [localization.mk_eq, localization.add_frac] at hg1 hg2 ⊢; exact @@is_ideal.add _ x.2.1.1 (@@is_ideal.mul_left _ x.2.1.1 hg2) (@@is_ideal.mul_left _ x.2.1.1 hg1), smul := λ c z, quotient.induction_on₂ c z $ λ ⟨r1, s1, hs1⟩ ⟨r2, s2, hs2⟩ hg2, by simp [localization.mk_eq, localization.mul_frac] at hg2 ⊢; exact @@is_ideal.mul_left _ x.2.1.1 hg2, ne_univ := λ h2, hx $ by rw set.eq_univ_iff_forall at h2; exact h2 (localization.of_comm_ring _ _ f), mem_or_mem_of_mul_mem := λ f1 f2, quotient.induction_on₂ f1 f2 $ λ ⟨r1, s1, hs1⟩ ⟨r2, s2, hs2⟩ hg2, by simp [localization.mk_eq, localization.mul_frac] at hg2 ⊢; exact @@is_prime_ideal.mem_or_mem_of_mul_mem _ x.2 hg2 }, ⟨⟨y, h2⟩, trivial, subtype.eq $ set.ext $ λ r1, by simp [Zariski.induced, localization.of_comm_ring]⟩⟩⟩
[STATEMENT] lemma Sup_image_eadd2: "Y \<noteq> {} \<Longrightarrow> Sup ((\<lambda>y :: enat. x + y) ` Y) = x + Sup Y" [PROOF STATE] proof (prove) goal (1 subgoal): 1. Y \<noteq> {} \<Longrightarrow> \<Squnion> ((+) x ` Y) = x + \<Squnion> Y [PROOF STEP] by(simp add: Sup_image_eadd1 add.commute)
[STATEMENT] lemma netgmap_netmask_subnets' [elim]: assumes "netgmap sr s1 = netmask (net_tree_ips n1) (\<sigma>, snd (netgmap sr s1))" and "netgmap sr s2 = netmask (net_tree_ips n2) (\<sigma>, snd (netgmap sr s2))" and "s = SubnetS s1 s2" shows "netgmap sr s = netmask (net_tree_ips (n1 \<parallel> n2)) (\<sigma>, snd (netgmap sr s))" [PROOF STATE] proof (prove) goal (1 subgoal): 1. netgmap sr s = netmask (net_tree_ips (n1 \<parallel> n2)) (\<sigma>, snd (netgmap sr s)) [PROOF STEP] by (simp only: assms(3)) (rule prod_eqI [OF netgmap_netmask_subnets [OF assms(1-2)]], simp)
using Distributions using LinearAlgebra using Random # Define the DGP function simulate_sample(N0, N1) dy1 = Weibull(2, 1); dy2 = Weibull(2, 1.3); dy = MixtureModel([Weibull(2, 0.5), Weibull(2, 1.5)], [0.5, 0.5]) X0 = [ones(N0) rand([0, 1], N0, 4) rand(N0)] X1 = kron([ones(2, 4) [1, 0] [0, 0]], ones(N1)) λ0 = @. exp(-1.0 + 1.0 * X0[:, end - 1] + 1.0 * X0[:, end]) y0 = λ0 .* rand(dy, N0) y1 = LinRange(0, 6, N1) |> collect |> x -> repeat(x, 2) c0 = rand(Exponential(10), N0) z0 = deepcopy(y0) return dy1, dy2, z0, c0, y0, X0, y1, X1 end # Not run Random.seed!(1); N0, N1 = 500, 0; dy1, dy2, z0, c0, y0, X0, y1, X1 = simulate_sample(N0, N1); println(mean(z0 .> c0)) println(maximum(z0)) println(mean(z0))
Darkling I listen ; and , for many a time
\<^marker>\<open>creator "Bohua Zhan"\<close> \<^marker>\<open>contributor "Kevin Kappelmann"\<close> theory Auto2_HOTG_Setup imports HOTG.Bounded_Quantifiers begin paragraph \<open>Summary\<close> text \<open>Extra theorems in logic used by auto2. Adapted from \<open>Auto2_HOL/HOL/HOL_Base.thy\<close>.\<close> lemma to_contra_form: "Trueprop A \<equiv> (\<not>A \<Longrightarrow> False)" by (rule equal_intr_rule) auto lemma to_contra_form': "Trueprop (\<not>A) \<equiv> (A \<Longrightarrow> False)" by (rule equal_intr_rule) auto lemma contra_triv: "\<not>A \<Longrightarrow> A \<Longrightarrow> False" by simp lemma or_intro1: "\<not> (P \<or> Q) \<Longrightarrow> \<not> P" by simp lemma or_intro2: "\<not> (P \<or> Q) \<Longrightarrow> \<not> Q" by simp lemma or_cancel1: "\<not>Q \<Longrightarrow> (P \<or> Q) = P" by auto lemma or_cancel2: "\<not>P \<Longrightarrow> (P \<or> Q) = Q" by auto lemma exE': "(\<And>x. P x \<Longrightarrow> Q) \<Longrightarrow> \<exists>x. P x \<Longrightarrow> Q" by auto lemma nn_create: "A \<Longrightarrow> \<not>\<not>A" by auto lemma iffD: "A \<longleftrightarrow> B \<Longrightarrow> (A \<longrightarrow> B) \<and> (B \<longrightarrow> A)" by auto lemma obj_sym: "Trueprop (t = s) \<equiv> Trueprop (s = t)" by (rule equal_intr_rule) auto lemma to_meta_eq: "Trueprop (t = s) \<equiv> (t \<equiv> s)" by (rule equal_intr_rule) auto lemma inv_backward: "A \<longleftrightarrow> B \<Longrightarrow> \<not>A \<Longrightarrow> \<not>B" by auto lemma backward_conv: "(A \<Longrightarrow> B) \<equiv> (\<not>B \<Longrightarrow> \<not>A)" by (rule equal_intr_rule) auto lemma backward1_conv: "(A \<Longrightarrow> B \<Longrightarrow> C) \<equiv> (\<not>C \<Longrightarrow> B \<Longrightarrow> \<not>A)" by (rule equal_intr_rule) auto lemma backward2_conv: "(A \<Longrightarrow> B \<Longrightarrow> C) \<equiv> (\<not>C \<Longrightarrow> A \<Longrightarrow> \<not>B)" by (rule equal_intr_rule) auto lemma resolve_conv: "(A \<Longrightarrow> B) \<equiv> (\<not>B \<Longrightarrow> A \<Longrightarrow> False)" by (rule equal_intr_rule) auto text \<open>Quantifiers: swapping out of ALL or EX.\<close> lemma swap_ex_conj: "(P \<and> (\<exists>x. Q x)) \<longleftrightarrow> (\<exists>x. P \<and> Q x)" by auto lemma swap_all_disj: "(P \<or> (\<forall>x. Q x)) \<longleftrightarrow> (\<forall>x. P \<or> Q x)" by auto text \<open>Use these instead of original versions to keep names in abstractions.\<close> lemma bex_def': "(\<exists>x \<in> S. P x) \<longleftrightarrow> (\<exists>x. x \<in> S \<and> P x)" by auto lemma ball_def': "(\<forall>x \<in> S. P x) \<longleftrightarrow> (\<forall>x. x \<in> S \<longrightarrow> P x)" by auto text \<open>Taking conjunction of assumptions.\<close> lemma atomize_conjL: "(A \<Longrightarrow> B \<Longrightarrow> PROP C) \<equiv> (A \<and> B \<Longrightarrow> PROP C)" by (rule equal_intr_rule) auto end
import os import sys import numpy as np import pandas as pd import argparse import random import config def create_validation_folds(args): """Create validation file with folds and write out to validate_meta.csv """ # Arguments & parameters dataset_dir = args.dataset_dir workspace = args.workspace labels = config.labels random_state = np.random.RandomState(1234) folds_num = 4 # Paths csv_path = os.path.join(dataset_dir, 'train.csv') # Read csv df = pd.DataFrame(pd.read_csv(csv_path)) indexes = np.arange(len(df)) random_state.shuffle(indexes) audios_num = len(df) audios_num_per_fold = int(audios_num // folds_num) # Create folds folds = np.zeros(audios_num, dtype=np.int32) for n in range(audios_num): folds[indexes[n]] = (n % folds_num) + 1 df_ex = df df_ex['fold'] = folds # Write out validation csv out_path = os.path.join(workspace, 'validate_meta.csv') df_ex.to_csv(out_path) print("Write out to {}".format(out_path)) if __name__ == '__main__': parser = argparse.ArgumentParser(description='') parser.add_argument('--dataset_dir') parser.add_argument('--workspace') args = parser.parse_args() create_validation_folds(args)
theory Proc1 imports "../SPARK" begin spark_open "loop_invariant/proc1" spark_vc procedure_proc1_5 by (simp add: ring_distribs pull_mods) spark_vc procedure_proc1_8 by (simp add: ring_distribs pull_mods) spark_end lemma pow_2_32_simp: "4294967296 = (2::int)^32" by simp end
module Oscar.Class.Transitivity where open import Oscar.Level open import Oscar.Relation record Transitivity {a} {A : Set a} {ℓ} (_≤_ : A → A → Set ℓ) : Set (a ⊔ ℓ) where field transitivity : ∀ {x y} → x ≤ y → ∀ {z} → y ⟨ _≤ z ⟩→ x open Transitivity ⦃ … ⦄ public
-- WARNING: This file was generated automatically by Vehicle -- and should not be modified manually! -- Metadata -- - Agda version: 2.6.2 -- - AISEC version: 0.1.0.1 -- - Time generated: ??? {-# OPTIONS --allow-exec #-} open import Vehicle open import Vehicle.Data.Tensor open import Data.Product open import Data.Integer as ℤ using (ℤ) open import Data.Rational as ℚ using (ℚ) open import Data.List open import Relation.Binary.PropositionalEquality module reachability-temp-output where postulate f : Tensor ℚ (2 ∷ []) → Tensor ℚ (1 ∷ []) abstract reachable : ∃ λ (x : Tensor ℚ (2 ∷ [])) → f x ≡ ℤ.+ 0 ℚ./ 1 ∷ [] reachable = checkSpecification record { proofCache = "/home/matthew/Code/AISEC/vehicle/proofcache.vclp" }
data InfIO: Type where Do: IO a -> (a -> Inf InfIO) -> InfIO (>>=) : IO a -> (a -> Inf InfIO) -> InfIO (>>=) = Do data Fuel = Dry | More (Lazy Fuel) forever: Fuel forever = More forever tank: Nat -> Fuel tank Z = Dry tank (S k) = More (tank k) printLoop: String -> InfIO printLoop msg = do putStrLn msg printLoop msg run: InfIO -> IO() run (Do action cont) = do res <- action run (cont res) runFuel: Fuel -> InfIO -> IO() runFuel Dry y = putStrLn "Out of fuel" runFuel (More fuel) (Do action cont) = do res <- action runFuel fuel (cont res)
partial bar : (n : Nat) -> (m : Nat) -> n = m -> Nat bar (S m) (S m) (Refl {x = S m}) = m data Baz : Int -> Type where AddThings : (x : Int) -> (y : Int) -> Baz (x + y) addBaz : (x : Int) -> Baz x -> Int addBaz (x + y) (AddThings x y) = x + y -- Not allowed in Idris 2, we use unification rather than matching! -- addBaz2 : (x : Int) -> Baz x -> Int -- addBaz2 (_ + _) (AddThings x y) = x + y -- Also not allowed in Idris 2! -- addBaz3 : (x : Int) -> Baz x -> Int -- addBaz3 (x + y) (AddThings _ _) = x + y
[STATEMENT] lemma isometry_on_id [simp]: "isometry_on A (\<lambda>x. x)" "isometry_on A id" [PROOF STATE] proof (prove) goal (1 subgoal): 1. isometry_on A (\<lambda>x. x) &&& isometry_on A id [PROOF STEP] unfolding isometry_on_def [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<forall>x\<in>A. \<forall>y\<in>A. dist x y = dist x y &&& \<forall>x\<in>A. \<forall>y\<in>A. dist (id x) (id y) = dist x y [PROOF STEP] by auto
-- This document shows how to encode GADTs using `IFix`. {-# OPTIONS --type-in-type #-} module ScottVec where -- The kind of church-encoded type-level natural numbers. Nat = (Set -> Set) -> Set -> Set zero : Nat zero = λ f z -> z suc : Nat -> Nat suc = λ n f z -> f (n f z) plus : Nat -> Nat -> Nat plus = λ n m f z -> n f (m f z) -- Our old friend. {-# NO_POSITIVITY_CHECK #-} record IFix {I : Set} (F : (I -> Set) -> I -> Set) (i : I) : Set where constructor wrap field unwrap : F (IFix F) i open IFix -- Scott-encoded vectors (a vector is a list with statically-known length). -- As usually the pattern vector of a Scott-encoded data type encodes pattern-matching. VecF : Set -> (Nat -> Set) -> Nat -> Set VecF = λ A Rec n -> (R : Nat -> Set) -- The type of the result depends on the vector's length. -> (∀ p -> A -> Rec p -> R (suc p)) -- The encoded `cons` constructor. -> R zero -- The encoded `nil` constructor. -> R n Vec : Set -> Nat -> Set Vec = λ (A : Set) -> IFix (VecF A) nil : ∀ A -> Vec A zero nil = λ A -> wrap λ R f z -> z cons : ∀ A n -> A -> Vec A n -> Vec A (suc n) cons = λ A n x xs -> wrap λ R f z -> f n x xs open import Data.Empty open import Data.Unit.Base open import Data.Nat.Base using (ℕ; _+_) -- Type-safe `head`. head : ∀ A n -> Vec A (suc n) -> A head A n xs = unwrap xs (λ p -> p (λ _ -> A) ⊤) -- `p (λ _ -> A) ⊤` returns `A` when `p` is `suc p'` for some `p'` -- and `⊤` when `p` is `zero` (λ p x xs' -> x) -- In the `cons` case `suc p (λ _ -> A) ⊤` reduces to `A`, -- hence we return the list element of type `A`. tt -- In the `nil` case `zero (λ _ -> A) ⊤` reduces to `⊤`, -- hence we return the only value of that type. {- Note [Type-safe `tail`] It's not obvious if type-safe `tail` can be implemented with this setup. This is because even though `Vec` is Scott-encoded, the type-level natural are Church-encoded (obviously we could have Scott-encoded type-level naturals in Agda just as well, but not in Zerepoch Core), which makes `pred` hard, which makes `tail` non-trivial. I did try using Scott-encoded naturals in Agda, that makes `tail` even more straightforward than `head`: tail : ∀ A n -> Vec A (suc n) -> Vec A n tail A n xs = unwrap xs (λ p -> ((B : ℕ -> Set) -> B (pred p) -> B n) -> Vec A n) (λ p x xs' coe -> coe (Vec A) xs') (λ coe -> coe (Vec A) (nil A)) (λ B x -> x) -} -- Here we pattern-match on `xs` and if it's non-empty, i.e. of type `Vec ℕ (suc p)` for some `p`, -- then we also get access to a coercion function that allows us to coerce the second list from -- `Vec ℕ n` to the same `Vec ℕ (suc p)` and call the type-safe `head` over it. -- Note that we don't even need to encode the `n ~ suc p` and `n ~ zero` equality constraints in -- the definition of `vecF` and can recover coercions along those constraints by adding the -- `Vec ℕ n -> Vec ℕ p` argument to the motive. sumHeadsOr0 : ∀ n -> Vec ℕ n -> Vec ℕ n -> ℕ sumHeadsOr0 n xs ys = unwrap xs (λ p -> (Vec ℕ n -> Vec ℕ p) -> ℕ) (λ p i _ coe -> i + head ℕ p (coe ys)) (λ _ -> 0) (λ x -> x)
/** * * @file qwrapper_ztrtri.c * * PLASMA core_blas quark wrapper * PLASMA is a software package provided by Univ. of Tennessee, * Univ. of California Berkeley and Univ. of Colorado Denver * * @version 2.6.0 * @author Julien Langou * @author Henricus Bouwmeester * @author Mathieu Faverge * @date 2010-11-15 * @precisions normal z -> c d s * **/ #include <lapacke.h> #include "common.h" /***************************************************************************//** * **/ void QUARK_CORE_ztrtri(Quark *quark, Quark_Task_Flags *task_flags, PLASMA_enum uplo, PLASMA_enum diag, int n, int nb, PLASMA_Complex64_t *A, int lda, PLASMA_sequence *sequence, PLASMA_request *request, int iinfo) { QUARK_Insert_Task( quark, CORE_ztrtri_quark, task_flags, sizeof(PLASMA_enum), &uplo, VALUE, sizeof(PLASMA_enum), &diag, VALUE, sizeof(int), &n, VALUE, sizeof(PLASMA_Complex64_t)*nb*nb, A, INOUT, sizeof(int), &lda, VALUE, sizeof(PLASMA_sequence*), &sequence, VALUE, sizeof(PLASMA_request*), &request, VALUE, sizeof(int), &iinfo, VALUE, 0); } /***************************************************************************//** * **/ #if defined(PLASMA_HAVE_WEAK) #pragma weak CORE_ztrtri_quark = PCORE_ztrtri_quark #define CORE_ztrtri_quark PCORE_ztrtri_quark #endif void CORE_ztrtri_quark(Quark *quark) { PLASMA_enum uplo; PLASMA_enum diag; int N; PLASMA_Complex64_t *A; int LDA; PLASMA_sequence *sequence; PLASMA_request *request; int iinfo; int info; quark_unpack_args_8(quark, uplo, diag, N, A, LDA, sequence, request, iinfo); info = LAPACKE_ztrtri_work( LAPACK_COL_MAJOR, lapack_const(uplo), lapack_const(diag), N, A, LDA); if ((sequence->status == PLASMA_SUCCESS) && (info > 0)) plasma_sequence_flush(quark, sequence, request, iinfo + info); }
[GOAL] M : Type u_1 inst✝⁴ : Nonempty M inst✝³ : Semigroup M inst✝² : TopologicalSpace M inst✝¹ : CompactSpace M inst✝ : T2Space M continuous_mul_left : ∀ (r : M), Continuous fun x => x * r ⊢ ∃ m, m * m = m [PROOFSTEP] let S : Set (Set M) := {N | IsClosed N ∧ N.Nonempty ∧ ∀ (m) (_ : m ∈ N) (m') (_ : m' ∈ N), m * m' ∈ N} [GOAL] M : Type u_1 inst✝⁴ : Nonempty M inst✝³ : Semigroup M inst✝² : TopologicalSpace M inst✝¹ : CompactSpace M inst✝ : T2Space M continuous_mul_left : ∀ (r : M), Continuous fun x => x * r S : Set (Set M) := {N | IsClosed N ∧ Set.Nonempty N ∧ ∀ (m : M), m ∈ N → ∀ (m' : M), m' ∈ N → m * m' ∈ N} ⊢ ∃ m, m * m = m [PROOFSTEP] obtain ⟨N, ⟨N_closed, ⟨m, hm⟩, N_mul⟩, N_minimal⟩ : ∃ N ∈ S, ∀ N' ∈ S, N' ⊆ N → N' = N [GOAL] M : Type u_1 inst✝⁴ : Nonempty M inst✝³ : Semigroup M inst✝² : TopologicalSpace M inst✝¹ : CompactSpace M inst✝ : T2Space M continuous_mul_left : ∀ (r : M), Continuous fun x => x * r S : Set (Set M) := {N | IsClosed N ∧ Set.Nonempty N ∧ ∀ (m : M), m ∈ N → ∀ (m' : M), m' ∈ N → m * m' ∈ N} ⊢ ∃ N, N ∈ S ∧ ∀ (N' : Set M), N' ∈ S → N' ⊆ N → N' = N case intro.intro.intro.intro.intro M : Type u_1 inst✝⁴ : Nonempty M inst✝³ : Semigroup M inst✝² : TopologicalSpace M inst✝¹ : CompactSpace M inst✝ : T2Space M continuous_mul_left : ∀ (r : M), Continuous fun x => x * r S : Set (Set M) := {N | IsClosed N ∧ Set.Nonempty N ∧ ∀ (m : M), m ∈ N → ∀ (m' : M), m' ∈ N → m * m' ∈ N} N : Set M N_minimal : ∀ (N' : Set M), N' ∈ S → N' ⊆ N → N' = N N_closed : IsClosed N N_mul : ∀ (m : M), m ∈ N → ∀ (m' : M), m' ∈ N → m * m' ∈ N m : M hm : m ∈ N ⊢ ∃ m, m * m = m [PROOFSTEP] rotate_left -- Porting note: restore to `rsuffices` [GOAL] case intro.intro.intro.intro.intro M : Type u_1 inst✝⁴ : Nonempty M inst✝³ : Semigroup M inst✝² : TopologicalSpace M inst✝¹ : CompactSpace M inst✝ : T2Space M continuous_mul_left : ∀ (r : M), Continuous fun x => x * r S : Set (Set M) := {N | IsClosed N ∧ Set.Nonempty N ∧ ∀ (m : M), m ∈ N → ∀ (m' : M), m' ∈ N → m * m' ∈ N} N : Set M N_minimal : ∀ (N' : Set M), N' ∈ S → N' ⊆ N → N' = N N_closed : IsClosed N N_mul : ∀ (m : M), m ∈ N → ∀ (m' : M), m' ∈ N → m * m' ∈ N m : M hm : m ∈ N ⊢ ∃ m, m * m = m [PROOFSTEP] use m [GOAL] case h M : Type u_1 inst✝⁴ : Nonempty M inst✝³ : Semigroup M inst✝² : TopologicalSpace M inst✝¹ : CompactSpace M inst✝ : T2Space M continuous_mul_left : ∀ (r : M), Continuous fun x => x * r S : Set (Set M) := {N | IsClosed N ∧ Set.Nonempty N ∧ ∀ (m : M), m ∈ N → ∀ (m' : M), m' ∈ N → m * m' ∈ N} N : Set M N_minimal : ∀ (N' : Set M), N' ∈ S → N' ⊆ N → N' = N N_closed : IsClosed N N_mul : ∀ (m : M), m ∈ N → ∀ (m' : M), m' ∈ N → m * m' ∈ N m : M hm : m ∈ N ⊢ m * m = m [PROOFSTEP] have scaling_eq_self : (· * m) '' N = N := by apply N_minimal · refine' ⟨(continuous_mul_left m).isClosedMap _ N_closed, ⟨_, ⟨m, hm, rfl⟩⟩, _⟩ rintro _ ⟨m'', hm'', rfl⟩ _ ⟨m', hm', rfl⟩ refine' ⟨m'' * m * m', N_mul _ (N_mul _ hm'' _ hm) _ hm', mul_assoc _ _ _⟩ · rintro _ ⟨m', hm', rfl⟩ exact N_mul _ hm' _ hm [GOAL] M : Type u_1 inst✝⁴ : Nonempty M inst✝³ : Semigroup M inst✝² : TopologicalSpace M inst✝¹ : CompactSpace M inst✝ : T2Space M continuous_mul_left : ∀ (r : M), Continuous fun x => x * r S : Set (Set M) := {N | IsClosed N ∧ Set.Nonempty N ∧ ∀ (m : M), m ∈ N → ∀ (m' : M), m' ∈ N → m * m' ∈ N} N : Set M N_minimal : ∀ (N' : Set M), N' ∈ S → N' ⊆ N → N' = N N_closed : IsClosed N N_mul : ∀ (m : M), m ∈ N → ∀ (m' : M), m' ∈ N → m * m' ∈ N m : M hm : m ∈ N ⊢ (fun x => x * m) '' N = N [PROOFSTEP] apply N_minimal [GOAL] case a M : Type u_1 inst✝⁴ : Nonempty M inst✝³ : Semigroup M inst✝² : TopologicalSpace M inst✝¹ : CompactSpace M inst✝ : T2Space M continuous_mul_left : ∀ (r : M), Continuous fun x => x * r S : Set (Set M) := {N | IsClosed N ∧ Set.Nonempty N ∧ ∀ (m : M), m ∈ N → ∀ (m' : M), m' ∈ N → m * m' ∈ N} N : Set M N_minimal : ∀ (N' : Set M), N' ∈ S → N' ⊆ N → N' = N N_closed : IsClosed N N_mul : ∀ (m : M), m ∈ N → ∀ (m' : M), m' ∈ N → m * m' ∈ N m : M hm : m ∈ N ⊢ (fun x => x * m) '' N ∈ S [PROOFSTEP] refine' ⟨(continuous_mul_left m).isClosedMap _ N_closed, ⟨_, ⟨m, hm, rfl⟩⟩, _⟩ [GOAL] case a M : Type u_1 inst✝⁴ : Nonempty M inst✝³ : Semigroup M inst✝² : TopologicalSpace M inst✝¹ : CompactSpace M inst✝ : T2Space M continuous_mul_left : ∀ (r : M), Continuous fun x => x * r S : Set (Set M) := {N | IsClosed N ∧ Set.Nonempty N ∧ ∀ (m : M), m ∈ N → ∀ (m' : M), m' ∈ N → m * m' ∈ N} N : Set M N_minimal : ∀ (N' : Set M), N' ∈ S → N' ⊆ N → N' = N N_closed : IsClosed N N_mul : ∀ (m : M), m ∈ N → ∀ (m' : M), m' ∈ N → m * m' ∈ N m : M hm : m ∈ N ⊢ ∀ (m_1 : M), m_1 ∈ (fun x => x * m) '' N → ∀ (m' : M), m' ∈ (fun x => x * m) '' N → m_1 * m' ∈ (fun x => x * m) '' N [PROOFSTEP] rintro _ ⟨m'', hm'', rfl⟩ _ ⟨m', hm', rfl⟩ [GOAL] case a.intro.intro.intro.intro M : Type u_1 inst✝⁴ : Nonempty M inst✝³ : Semigroup M inst✝² : TopologicalSpace M inst✝¹ : CompactSpace M inst✝ : T2Space M continuous_mul_left : ∀ (r : M), Continuous fun x => x * r S : Set (Set M) := {N | IsClosed N ∧ Set.Nonempty N ∧ ∀ (m : M), m ∈ N → ∀ (m' : M), m' ∈ N → m * m' ∈ N} N : Set M N_minimal : ∀ (N' : Set M), N' ∈ S → N' ⊆ N → N' = N N_closed : IsClosed N N_mul : ∀ (m : M), m ∈ N → ∀ (m' : M), m' ∈ N → m * m' ∈ N m : M hm : m ∈ N m'' : M hm'' : m'' ∈ N m' : M hm' : m' ∈ N ⊢ (fun x => x * m) m'' * (fun x => x * m) m' ∈ (fun x => x * m) '' N [PROOFSTEP] refine' ⟨m'' * m * m', N_mul _ (N_mul _ hm'' _ hm) _ hm', mul_assoc _ _ _⟩ [GOAL] case a M : Type u_1 inst✝⁴ : Nonempty M inst✝³ : Semigroup M inst✝² : TopologicalSpace M inst✝¹ : CompactSpace M inst✝ : T2Space M continuous_mul_left : ∀ (r : M), Continuous fun x => x * r S : Set (Set M) := {N | IsClosed N ∧ Set.Nonempty N ∧ ∀ (m : M), m ∈ N → ∀ (m' : M), m' ∈ N → m * m' ∈ N} N : Set M N_minimal : ∀ (N' : Set M), N' ∈ S → N' ⊆ N → N' = N N_closed : IsClosed N N_mul : ∀ (m : M), m ∈ N → ∀ (m' : M), m' ∈ N → m * m' ∈ N m : M hm : m ∈ N ⊢ (fun x => x * m) '' N ⊆ N [PROOFSTEP] rintro _ ⟨m', hm', rfl⟩ [GOAL] case a.intro.intro M : Type u_1 inst✝⁴ : Nonempty M inst✝³ : Semigroup M inst✝² : TopologicalSpace M inst✝¹ : CompactSpace M inst✝ : T2Space M continuous_mul_left : ∀ (r : M), Continuous fun x => x * r S : Set (Set M) := {N | IsClosed N ∧ Set.Nonempty N ∧ ∀ (m : M), m ∈ N → ∀ (m' : M), m' ∈ N → m * m' ∈ N} N : Set M N_minimal : ∀ (N' : Set M), N' ∈ S → N' ⊆ N → N' = N N_closed : IsClosed N N_mul : ∀ (m : M), m ∈ N → ∀ (m' : M), m' ∈ N → m * m' ∈ N m : M hm : m ∈ N m' : M hm' : m' ∈ N ⊢ (fun x => x * m) m' ∈ N [PROOFSTEP] exact N_mul _ hm' _ hm [GOAL] case h M : Type u_1 inst✝⁴ : Nonempty M inst✝³ : Semigroup M inst✝² : TopologicalSpace M inst✝¹ : CompactSpace M inst✝ : T2Space M continuous_mul_left : ∀ (r : M), Continuous fun x => x * r S : Set (Set M) := {N | IsClosed N ∧ Set.Nonempty N ∧ ∀ (m : M), m ∈ N → ∀ (m' : M), m' ∈ N → m * m' ∈ N} N : Set M N_minimal : ∀ (N' : Set M), N' ∈ S → N' ⊆ N → N' = N N_closed : IsClosed N N_mul : ∀ (m : M), m ∈ N → ∀ (m' : M), m' ∈ N → m * m' ∈ N m : M hm : m ∈ N scaling_eq_self : (fun x => x * m) '' N = N ⊢ m * m = m [PROOFSTEP] have absorbing_eq_self : N ∩ {m' | m' * m = m} = N := by apply N_minimal · refine' ⟨N_closed.inter ((T1Space.t1 m).preimage (continuous_mul_left m)), _, _⟩ · rwa [← scaling_eq_self] at hm · rintro m'' ⟨mem'', eq'' : _ = m⟩ m' ⟨mem', eq' : _ = m⟩ refine' ⟨N_mul _ mem'' _ mem', _⟩ rw [Set.mem_setOf_eq, mul_assoc, eq', eq''] apply Set.inter_subset_left [GOAL] M : Type u_1 inst✝⁴ : Nonempty M inst✝³ : Semigroup M inst✝² : TopologicalSpace M inst✝¹ : CompactSpace M inst✝ : T2Space M continuous_mul_left : ∀ (r : M), Continuous fun x => x * r S : Set (Set M) := {N | IsClosed N ∧ Set.Nonempty N ∧ ∀ (m : M), m ∈ N → ∀ (m' : M), m' ∈ N → m * m' ∈ N} N : Set M N_minimal : ∀ (N' : Set M), N' ∈ S → N' ⊆ N → N' = N N_closed : IsClosed N N_mul : ∀ (m : M), m ∈ N → ∀ (m' : M), m' ∈ N → m * m' ∈ N m : M hm : m ∈ N scaling_eq_self : (fun x => x * m) '' N = N ⊢ N ∩ {m' | m' * m = m} = N [PROOFSTEP] apply N_minimal [GOAL] case a M : Type u_1 inst✝⁴ : Nonempty M inst✝³ : Semigroup M inst✝² : TopologicalSpace M inst✝¹ : CompactSpace M inst✝ : T2Space M continuous_mul_left : ∀ (r : M), Continuous fun x => x * r S : Set (Set M) := {N | IsClosed N ∧ Set.Nonempty N ∧ ∀ (m : M), m ∈ N → ∀ (m' : M), m' ∈ N → m * m' ∈ N} N : Set M N_minimal : ∀ (N' : Set M), N' ∈ S → N' ⊆ N → N' = N N_closed : IsClosed N N_mul : ∀ (m : M), m ∈ N → ∀ (m' : M), m' ∈ N → m * m' ∈ N m : M hm : m ∈ N scaling_eq_self : (fun x => x * m) '' N = N ⊢ N ∩ {m' | m' * m = m} ∈ S [PROOFSTEP] refine' ⟨N_closed.inter ((T1Space.t1 m).preimage (continuous_mul_left m)), _, _⟩ [GOAL] case a.refine'_1 M : Type u_1 inst✝⁴ : Nonempty M inst✝³ : Semigroup M inst✝² : TopologicalSpace M inst✝¹ : CompactSpace M inst✝ : T2Space M continuous_mul_left : ∀ (r : M), Continuous fun x => x * r S : Set (Set M) := {N | IsClosed N ∧ Set.Nonempty N ∧ ∀ (m : M), m ∈ N → ∀ (m' : M), m' ∈ N → m * m' ∈ N} N : Set M N_minimal : ∀ (N' : Set M), N' ∈ S → N' ⊆ N → N' = N N_closed : IsClosed N N_mul : ∀ (m : M), m ∈ N → ∀ (m' : M), m' ∈ N → m * m' ∈ N m : M hm : m ∈ N scaling_eq_self : (fun x => x * m) '' N = N ⊢ Set.Nonempty (N ∩ {m' | m' * m = m}) [PROOFSTEP] rwa [← scaling_eq_self] at hm [GOAL] case a.refine'_2 M : Type u_1 inst✝⁴ : Nonempty M inst✝³ : Semigroup M inst✝² : TopologicalSpace M inst✝¹ : CompactSpace M inst✝ : T2Space M continuous_mul_left : ∀ (r : M), Continuous fun x => x * r S : Set (Set M) := {N | IsClosed N ∧ Set.Nonempty N ∧ ∀ (m : M), m ∈ N → ∀ (m' : M), m' ∈ N → m * m' ∈ N} N : Set M N_minimal : ∀ (N' : Set M), N' ∈ S → N' ⊆ N → N' = N N_closed : IsClosed N N_mul : ∀ (m : M), m ∈ N → ∀ (m' : M), m' ∈ N → m * m' ∈ N m : M hm : m ∈ N scaling_eq_self : (fun x => x * m) '' N = N ⊢ ∀ (m_1 : M), m_1 ∈ N ∩ {m' | m' * m = m} → ∀ (m' : M), m' ∈ N ∩ {m' | m' * m = m} → m_1 * m' ∈ N ∩ {m' | m' * m = m} [PROOFSTEP] rintro m'' ⟨mem'', eq'' : _ = m⟩ m' ⟨mem', eq' : _ = m⟩ [GOAL] case a.refine'_2.intro.intro M : Type u_1 inst✝⁴ : Nonempty M inst✝³ : Semigroup M inst✝² : TopologicalSpace M inst✝¹ : CompactSpace M inst✝ : T2Space M continuous_mul_left : ∀ (r : M), Continuous fun x => x * r S : Set (Set M) := {N | IsClosed N ∧ Set.Nonempty N ∧ ∀ (m : M), m ∈ N → ∀ (m' : M), m' ∈ N → m * m' ∈ N} N : Set M N_minimal : ∀ (N' : Set M), N' ∈ S → N' ⊆ N → N' = N N_closed : IsClosed N N_mul : ∀ (m : M), m ∈ N → ∀ (m' : M), m' ∈ N → m * m' ∈ N m : M hm : m ∈ N scaling_eq_self : (fun x => x * m) '' N = N m'' : M mem'' : m'' ∈ N eq'' : m'' * m = m m' : M mem' : m' ∈ N eq' : m' * m = m ⊢ m'' * m' ∈ N ∩ {m' | m' * m = m} [PROOFSTEP] refine' ⟨N_mul _ mem'' _ mem', _⟩ [GOAL] case a.refine'_2.intro.intro M : Type u_1 inst✝⁴ : Nonempty M inst✝³ : Semigroup M inst✝² : TopologicalSpace M inst✝¹ : CompactSpace M inst✝ : T2Space M continuous_mul_left : ∀ (r : M), Continuous fun x => x * r S : Set (Set M) := {N | IsClosed N ∧ Set.Nonempty N ∧ ∀ (m : M), m ∈ N → ∀ (m' : M), m' ∈ N → m * m' ∈ N} N : Set M N_minimal : ∀ (N' : Set M), N' ∈ S → N' ⊆ N → N' = N N_closed : IsClosed N N_mul : ∀ (m : M), m ∈ N → ∀ (m' : M), m' ∈ N → m * m' ∈ N m : M hm : m ∈ N scaling_eq_self : (fun x => x * m) '' N = N m'' : M mem'' : m'' ∈ N eq'' : m'' * m = m m' : M mem' : m' ∈ N eq' : m' * m = m ⊢ m'' * m' ∈ {m' | m' * m = m} [PROOFSTEP] rw [Set.mem_setOf_eq, mul_assoc, eq', eq''] [GOAL] case a M : Type u_1 inst✝⁴ : Nonempty M inst✝³ : Semigroup M inst✝² : TopologicalSpace M inst✝¹ : CompactSpace M inst✝ : T2Space M continuous_mul_left : ∀ (r : M), Continuous fun x => x * r S : Set (Set M) := {N | IsClosed N ∧ Set.Nonempty N ∧ ∀ (m : M), m ∈ N → ∀ (m' : M), m' ∈ N → m * m' ∈ N} N : Set M N_minimal : ∀ (N' : Set M), N' ∈ S → N' ⊆ N → N' = N N_closed : IsClosed N N_mul : ∀ (m : M), m ∈ N → ∀ (m' : M), m' ∈ N → m * m' ∈ N m : M hm : m ∈ N scaling_eq_self : (fun x => x * m) '' N = N ⊢ N ∩ {m' | m' * m = m} ⊆ N [PROOFSTEP] apply Set.inter_subset_left [GOAL] case h M : Type u_1 inst✝⁴ : Nonempty M inst✝³ : Semigroup M inst✝² : TopologicalSpace M inst✝¹ : CompactSpace M inst✝ : T2Space M continuous_mul_left : ∀ (r : M), Continuous fun x => x * r S : Set (Set M) := {N | IsClosed N ∧ Set.Nonempty N ∧ ∀ (m : M), m ∈ N → ∀ (m' : M), m' ∈ N → m * m' ∈ N} N : Set M N_minimal : ∀ (N' : Set M), N' ∈ S → N' ⊆ N → N' = N N_closed : IsClosed N N_mul : ∀ (m : M), m ∈ N → ∀ (m' : M), m' ∈ N → m * m' ∈ N m : M hm : m ∈ N scaling_eq_self : (fun x => x * m) '' N = N absorbing_eq_self : N ∩ {m' | m' * m = m} = N ⊢ m * m = m [PROOFSTEP] rw [← absorbing_eq_self] at hm [GOAL] case h M : Type u_1 inst✝⁴ : Nonempty M inst✝³ : Semigroup M inst✝² : TopologicalSpace M inst✝¹ : CompactSpace M inst✝ : T2Space M continuous_mul_left : ∀ (r : M), Continuous fun x => x * r S : Set (Set M) := {N | IsClosed N ∧ Set.Nonempty N ∧ ∀ (m : M), m ∈ N → ∀ (m' : M), m' ∈ N → m * m' ∈ N} N : Set M N_minimal : ∀ (N' : Set M), N' ∈ S → N' ⊆ N → N' = N N_closed : IsClosed N N_mul : ∀ (m : M), m ∈ N → ∀ (m' : M), m' ∈ N → m * m' ∈ N m : M hm : m ∈ N ∩ {m' | m' * m = m} scaling_eq_self : (fun x => x * m) '' N = N absorbing_eq_self : N ∩ {m' | m' * m = m} = N ⊢ m * m = m [PROOFSTEP] exact hm.2 [GOAL] M : Type u_1 inst✝⁴ : Nonempty M inst✝³ : Semigroup M inst✝² : TopologicalSpace M inst✝¹ : CompactSpace M inst✝ : T2Space M continuous_mul_left : ∀ (r : M), Continuous fun x => x * r S : Set (Set M) := {N | IsClosed N ∧ Set.Nonempty N ∧ ∀ (m : M), m ∈ N → ∀ (m' : M), m' ∈ N → m * m' ∈ N} ⊢ ∃ N, N ∈ S ∧ ∀ (N' : Set M), N' ∈ S → N' ⊆ N → N' = N [PROOFSTEP] refine' zorn_superset _ fun c hcs hc => _ [GOAL] M : Type u_1 inst✝⁴ : Nonempty M inst✝³ : Semigroup M inst✝² : TopologicalSpace M inst✝¹ : CompactSpace M inst✝ : T2Space M continuous_mul_left : ∀ (r : M), Continuous fun x => x * r S : Set (Set M) := {N | IsClosed N ∧ Set.Nonempty N ∧ ∀ (m : M), m ∈ N → ∀ (m' : M), m' ∈ N → m * m' ∈ N} c : Set (Set M) hcs : c ⊆ S hc : IsChain (fun x x_1 => x ⊆ x_1) c ⊢ ∃ lb, lb ∈ S ∧ ∀ (s : Set M), s ∈ c → lb ⊆ s [PROOFSTEP] refine' ⟨⋂₀ c, ⟨isClosed_sInter fun t ht => (hcs ht).1, _, fun m hm m' hm' => _⟩, fun s hs => Set.sInter_subset_of_mem hs⟩ [GOAL] case refine'_1 M : Type u_1 inst✝⁴ : Nonempty M inst✝³ : Semigroup M inst✝² : TopologicalSpace M inst✝¹ : CompactSpace M inst✝ : T2Space M continuous_mul_left : ∀ (r : M), Continuous fun x => x * r S : Set (Set M) := {N | IsClosed N ∧ Set.Nonempty N ∧ ∀ (m : M), m ∈ N → ∀ (m' : M), m' ∈ N → m * m' ∈ N} c : Set (Set M) hcs : c ⊆ S hc : IsChain (fun x x_1 => x ⊆ x_1) c ⊢ Set.Nonempty (⋂₀ c) [PROOFSTEP] obtain rfl | hcnemp := c.eq_empty_or_nonempty [GOAL] case refine'_1.inl M : Type u_1 inst✝⁴ : Nonempty M inst✝³ : Semigroup M inst✝² : TopologicalSpace M inst✝¹ : CompactSpace M inst✝ : T2Space M continuous_mul_left : ∀ (r : M), Continuous fun x => x * r S : Set (Set M) := {N | IsClosed N ∧ Set.Nonempty N ∧ ∀ (m : M), m ∈ N → ∀ (m' : M), m' ∈ N → m * m' ∈ N} hcs : ∅ ⊆ S hc : IsChain (fun x x_1 => x ⊆ x_1) ∅ ⊢ Set.Nonempty (⋂₀ ∅) [PROOFSTEP] rw [Set.sInter_empty] [GOAL] case refine'_1.inl M : Type u_1 inst✝⁴ : Nonempty M inst✝³ : Semigroup M inst✝² : TopologicalSpace M inst✝¹ : CompactSpace M inst✝ : T2Space M continuous_mul_left : ∀ (r : M), Continuous fun x => x * r S : Set (Set M) := {N | IsClosed N ∧ Set.Nonempty N ∧ ∀ (m : M), m ∈ N → ∀ (m' : M), m' ∈ N → m * m' ∈ N} hcs : ∅ ⊆ S hc : IsChain (fun x x_1 => x ⊆ x_1) ∅ ⊢ Set.Nonempty Set.univ [PROOFSTEP] apply Set.univ_nonempty [GOAL] case refine'_1.inr M : Type u_1 inst✝⁴ : Nonempty M inst✝³ : Semigroup M inst✝² : TopologicalSpace M inst✝¹ : CompactSpace M inst✝ : T2Space M continuous_mul_left : ∀ (r : M), Continuous fun x => x * r S : Set (Set M) := {N | IsClosed N ∧ Set.Nonempty N ∧ ∀ (m : M), m ∈ N → ∀ (m' : M), m' ∈ N → m * m' ∈ N} c : Set (Set M) hcs : c ⊆ S hc : IsChain (fun x x_1 => x ⊆ x_1) c hcnemp : Set.Nonempty c ⊢ Set.Nonempty (⋂₀ c) [PROOFSTEP] convert @IsCompact.nonempty_iInter_of_directed_nonempty_compact_closed _ _ _ hcnemp.coe_sort ((↑) : c → Set M) ?_ ?_ ?_ ?_ [GOAL] case h.e'_2 M : Type u_1 inst✝⁴ : Nonempty M inst✝³ : Semigroup M inst✝² : TopologicalSpace M inst✝¹ : CompactSpace M inst✝ : T2Space M continuous_mul_left : ∀ (r : M), Continuous fun x => x * r S : Set (Set M) := {N | IsClosed N ∧ Set.Nonempty N ∧ ∀ (m : M), m ∈ N → ∀ (m' : M), m' ∈ N → m * m' ∈ N} c : Set (Set M) hcs : c ⊆ S hc : IsChain (fun x x_1 => x ⊆ x_1) c hcnemp : Set.Nonempty c ⊢ ⋂₀ c = ⋂ (i : ↑c), ↑i [PROOFSTEP] exact Set.sInter_eq_iInter [GOAL] case refine'_1.inr.convert_1 M : Type u_1 inst✝⁴ : Nonempty M inst✝³ : Semigroup M inst✝² : TopologicalSpace M inst✝¹ : CompactSpace M inst✝ : T2Space M continuous_mul_left : ∀ (r : M), Continuous fun x => x * r S : Set (Set M) := {N | IsClosed N ∧ Set.Nonempty N ∧ ∀ (m : M), m ∈ N → ∀ (m' : M), m' ∈ N → m * m' ∈ N} c : Set (Set M) hcs : c ⊆ S hc : IsChain (fun x x_1 => x ⊆ x_1) c hcnemp : Set.Nonempty c ⊢ Directed (fun x x_1 => x ⊇ x_1) Subtype.val [PROOFSTEP] refine' DirectedOn.directed_val (IsChain.directedOn hc.symm) [GOAL] case refine'_1.inr.convert_2 M : Type u_1 inst✝⁴ : Nonempty M inst✝³ : Semigroup M inst✝² : TopologicalSpace M inst✝¹ : CompactSpace M inst✝ : T2Space M continuous_mul_left : ∀ (r : M), Continuous fun x => x * r S : Set (Set M) := {N | IsClosed N ∧ Set.Nonempty N ∧ ∀ (m : M), m ∈ N → ∀ (m' : M), m' ∈ N → m * m' ∈ N} c : Set (Set M) hcs : c ⊆ S hc : IsChain (fun x x_1 => x ⊆ x_1) c hcnemp : Set.Nonempty c ⊢ ∀ (i : ↑c), Set.Nonempty ↑i case refine'_1.inr.convert_3 M : Type u_1 inst✝⁴ : Nonempty M inst✝³ : Semigroup M inst✝² : TopologicalSpace M inst✝¹ : CompactSpace M inst✝ : T2Space M continuous_mul_left : ∀ (r : M), Continuous fun x => x * r S : Set (Set M) := {N | IsClosed N ∧ Set.Nonempty N ∧ ∀ (m : M), m ∈ N → ∀ (m' : M), m' ∈ N → m * m' ∈ N} c : Set (Set M) hcs : c ⊆ S hc : IsChain (fun x x_1 => x ⊆ x_1) c hcnemp : Set.Nonempty c ⊢ ∀ (i : ↑c), IsCompact ↑i case refine'_1.inr.convert_4 M : Type u_1 inst✝⁴ : Nonempty M inst✝³ : Semigroup M inst✝² : TopologicalSpace M inst✝¹ : CompactSpace M inst✝ : T2Space M continuous_mul_left : ∀ (r : M), Continuous fun x => x * r S : Set (Set M) := {N | IsClosed N ∧ Set.Nonempty N ∧ ∀ (m : M), m ∈ N → ∀ (m' : M), m' ∈ N → m * m' ∈ N} c : Set (Set M) hcs : c ⊆ S hc : IsChain (fun x x_1 => x ⊆ x_1) c hcnemp : Set.Nonempty c ⊢ ∀ (i : ↑c), IsClosed ↑i [PROOFSTEP] exacts [fun i => (hcs i.prop).2.1, fun i => (hcs i.prop).1.isCompact, fun i => (hcs i.prop).1] [GOAL] case refine'_2 M : Type u_1 inst✝⁴ : Nonempty M inst✝³ : Semigroup M inst✝² : TopologicalSpace M inst✝¹ : CompactSpace M inst✝ : T2Space M continuous_mul_left : ∀ (r : M), Continuous fun x => x * r S : Set (Set M) := {N | IsClosed N ∧ Set.Nonempty N ∧ ∀ (m : M), m ∈ N → ∀ (m' : M), m' ∈ N → m * m' ∈ N} c : Set (Set M) hcs : c ⊆ S hc : IsChain (fun x x_1 => x ⊆ x_1) c m : M hm : m ∈ ⋂₀ c m' : M hm' : m' ∈ ⋂₀ c ⊢ m * m' ∈ ⋂₀ c [PROOFSTEP] rw [Set.mem_sInter] [GOAL] case refine'_2 M : Type u_1 inst✝⁴ : Nonempty M inst✝³ : Semigroup M inst✝² : TopologicalSpace M inst✝¹ : CompactSpace M inst✝ : T2Space M continuous_mul_left : ∀ (r : M), Continuous fun x => x * r S : Set (Set M) := {N | IsClosed N ∧ Set.Nonempty N ∧ ∀ (m : M), m ∈ N → ∀ (m' : M), m' ∈ N → m * m' ∈ N} c : Set (Set M) hcs : c ⊆ S hc : IsChain (fun x x_1 => x ⊆ x_1) c m : M hm : m ∈ ⋂₀ c m' : M hm' : m' ∈ ⋂₀ c ⊢ ∀ (t : Set M), t ∈ c → m * m' ∈ t [PROOFSTEP] exact fun t ht => (hcs ht).2.2 m (Set.mem_sInter.mp hm t ht) m' (Set.mem_sInter.mp hm' t ht) [GOAL] M : Type u_1 inst✝² : Semigroup M inst✝¹ : TopologicalSpace M inst✝ : T2Space M continuous_mul_left : ∀ (r : M), Continuous fun x => x * r s : Set M snemp : Set.Nonempty s s_compact : IsCompact s s_add : ∀ (x : M), x ∈ s → ∀ (y : M), y ∈ s → x * y ∈ s ⊢ ∃ m, m ∈ s ∧ m * m = m [PROOFSTEP] let M' := { m // m ∈ s } [GOAL] M : Type u_1 inst✝² : Semigroup M inst✝¹ : TopologicalSpace M inst✝ : T2Space M continuous_mul_left : ∀ (r : M), Continuous fun x => x * r s : Set M snemp : Set.Nonempty s s_compact : IsCompact s s_add : ∀ (x : M), x ∈ s → ∀ (y : M), y ∈ s → x * y ∈ s M' : Type u_1 := { m // m ∈ s } ⊢ ∃ m, m ∈ s ∧ m * m = m [PROOFSTEP] letI : Semigroup M' := { mul := fun p q => ⟨p.1 * q.1, s_add _ p.2 _ q.2⟩ mul_assoc := fun p q r => Subtype.eq (mul_assoc _ _ _) } [GOAL] M : Type u_1 inst✝² : Semigroup M inst✝¹ : TopologicalSpace M inst✝ : T2Space M continuous_mul_left : ∀ (r : M), Continuous fun x => x * r s : Set M snemp : Set.Nonempty s s_compact : IsCompact s s_add : ∀ (x : M), x ∈ s → ∀ (y : M), y ∈ s → x * y ∈ s M' : Type u_1 := { m // m ∈ s } this : Semigroup M' := Semigroup.mk (_ : ∀ (p q r : M'), p * q * r = p * (q * r)) ⊢ ∃ m, m ∈ s ∧ m * m = m [PROOFSTEP] haveI : CompactSpace M' := isCompact_iff_compactSpace.mp s_compact [GOAL] M : Type u_1 inst✝² : Semigroup M inst✝¹ : TopologicalSpace M inst✝ : T2Space M continuous_mul_left : ∀ (r : M), Continuous fun x => x * r s : Set M snemp : Set.Nonempty s s_compact : IsCompact s s_add : ∀ (x : M), x ∈ s → ∀ (y : M), y ∈ s → x * y ∈ s M' : Type u_1 := { m // m ∈ s } this✝ : Semigroup M' := Semigroup.mk (_ : ∀ (p q r : M'), p * q * r = p * (q * r)) this : CompactSpace M' ⊢ ∃ m, m ∈ s ∧ m * m = m [PROOFSTEP] haveI : Nonempty M' := nonempty_subtype.mpr snemp [GOAL] M : Type u_1 inst✝² : Semigroup M inst✝¹ : TopologicalSpace M inst✝ : T2Space M continuous_mul_left : ∀ (r : M), Continuous fun x => x * r s : Set M snemp : Set.Nonempty s s_compact : IsCompact s s_add : ∀ (x : M), x ∈ s → ∀ (y : M), y ∈ s → x * y ∈ s M' : Type u_1 := { m // m ∈ s } this✝¹ : Semigroup M' := Semigroup.mk (_ : ∀ (p q r : M'), p * q * r = p * (q * r)) this✝ : CompactSpace M' this : Nonempty M' ⊢ ∃ m, m ∈ s ∧ m * m = m [PROOFSTEP] have : ∀ p : M', Continuous (· * p) := fun p => ((continuous_mul_left p.1).comp continuous_subtype_val).subtype_mk _ [GOAL] M : Type u_1 inst✝² : Semigroup M inst✝¹ : TopologicalSpace M inst✝ : T2Space M continuous_mul_left : ∀ (r : M), Continuous fun x => x * r s : Set M snemp : Set.Nonempty s s_compact : IsCompact s s_add : ∀ (x : M), x ∈ s → ∀ (y : M), y ∈ s → x * y ∈ s M' : Type u_1 := { m // m ∈ s } this✝² : Semigroup M' := Semigroup.mk (_ : ∀ (p q r : M'), p * q * r = p * (q * r)) this✝¹ : CompactSpace M' this✝ : Nonempty M' this : ∀ (p : M'), Continuous fun x => x * p ⊢ ∃ m, m ∈ s ∧ m * m = m [PROOFSTEP] obtain ⟨⟨m, hm⟩, idem⟩ := exists_idempotent_of_compact_t2_of_continuous_mul_left this [GOAL] case intro.mk M : Type u_1 inst✝² : Semigroup M inst✝¹ : TopologicalSpace M inst✝ : T2Space M continuous_mul_left : ∀ (r : M), Continuous fun x => x * r s : Set M snemp : Set.Nonempty s s_compact : IsCompact s s_add : ∀ (x : M), x ∈ s → ∀ (y : M), y ∈ s → x * y ∈ s M' : Type u_1 := { m // m ∈ s } this✝² : Semigroup M' := Semigroup.mk (_ : ∀ (p q r : M'), p * q * r = p * (q * r)) this✝¹ : CompactSpace M' this✝ : Nonempty M' this : ∀ (p : M'), Continuous fun x => x * p m : M hm : m ∈ s idem : { val := m, property := hm } * { val := m, property := hm } = { val := m, property := hm } ⊢ ∃ m, m ∈ s ∧ m * m = m [PROOFSTEP] exact ⟨m, hm, Subtype.ext_iff.mp idem⟩
State Before: C : Type u₁ inst✝ : Category C Z X Y P : C f : Z ⟶ X g : Z ⟶ Y inl : X ⟶ P inr : Y ⟶ P c : PushoutCocone f g h : IsColimit c ⊢ PushoutCocone.inl c ≫ (Iso.refl c.pt).hom = PushoutCocone.inl (PushoutCocone.mk (PushoutCocone.inl c) (PushoutCocone.inr c) (_ : f ≫ PushoutCocone.inl c = g ≫ PushoutCocone.inr c)) State After: no goals Tactic: aesop_cat State Before: C : Type u₁ inst✝ : Category C Z X Y P : C f : Z ⟶ X g : Z ⟶ Y inl : X ⟶ P inr : Y ⟶ P c : PushoutCocone f g h : IsColimit c ⊢ PushoutCocone.inr c ≫ (Iso.refl c.pt).hom = PushoutCocone.inr (PushoutCocone.mk (PushoutCocone.inl c) (PushoutCocone.inr c) (_ : f ≫ PushoutCocone.inl c = g ≫ PushoutCocone.inr c)) State After: no goals Tactic: aesop_cat
import tactic #check dvd_mul_right -- BEGIN example {m n k : ℕ} (h : m ∣ n ∨ m ∣ k) : m ∣ n * k := begin rcases h with ⟨a, rfl⟩ | ⟨b, rfl⟩, /- rfl expects the hypothesis to be h : a = b, and calls on the hypothesis, which has the effect of replacing b with a everywhere or vice versa. -/ { rw mul_assoc, apply dvd_mul_right }, rw mul_comm, rw mul_assoc, apply dvd_mul_right, end /- Using the cases tactic -/ example {m n k : ℕ} (h : m ∣ n ∨ m ∣ k) : m ∣ n * k := begin cases h with hmn hmk, cases hmn with a ha, rw ha, rw mul_assoc, apply dvd_mul_right, cases hmk with b hb, rw hb, rw mul_comm, rw mul_assoc, apply dvd_mul_right, end -- END
While serving as an administrator for Hangzhou , the poet Su Shi ( 1037 – 1101 ) had a large pedestrian causeway built across the West Lake , which still bears his name : Sudi ( <unk> ) . In 1221 , the Taoist traveler Qiu Changchun visited Genghis Khan in Samarkand , describing various Chinese bridges encountered on the way there through the Tian Shan Mountains , east of Yining . The historian Joseph Needham quotes him as saying :
#define BOOST_TEST_MODULE "Cuttle Parser Tests" #define BOOST_TEST_DYN_LINK #include <boost/test/unit_test.hpp>
------------------------------------------------------------------------ -- The Agda standard library -- -- Natural numbers defined in terms of Data.Star ------------------------------------------------------------------------ module Data.Star.Nat where open import Data.Star open import Data.Unit open import Function open import Relation.Binary open import Relation.Binary.Simple -- Natural numbers. ℕ : Set ℕ = Star Always tt tt -- Zero and successor. zero : ℕ zero = ε suc : ℕ → ℕ suc = _◅_ _ -- The length of a star-list. length : ∀ {i t} {I : Set i} {T : Rel I t} {i j} → Star T i j → ℕ length = gmap (const _) (const _) -- Arithmetic. infixl 7 _*_ infixl 6 _+_ _∸_ _+_ : ℕ → ℕ → ℕ _+_ = _◅◅_ _*_ : ℕ → ℕ → ℕ _*_ m = const m ⋆ _∸_ : ℕ → ℕ → ℕ m ∸ ε = m ε ∸ (_ ◅ n) = zero (_ ◅ m) ∸ (_ ◅ n) = m ∸ n -- Some constants. 0# = zero 1# = suc 0# 2# = suc 1# 3# = suc 2# 4# = suc 3# 5# = suc 4#
(* * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *) Require Import ZArith. Require Import String. Require Import List. Require Import Utils. Require Import DataSystem. Require Import CAMPRuntime. Require Import CAMPRuleRuntime. Require Import TrivialModel. Require CompilerRuntime. Require Import CompLang. Require Import CompDriver. Require Import CompilerModel. Require CAMPSystem. Require Import TcNRAEnv. Require Import TCAMPtocNRAEnv. Local Open Scope Z_scope. Local Open Scope string. Import ListNotations. Definition CPRModel := ("MainEntity", "Entity") :: nil. Instance CPRModel_relation : brand_relation := mkBrand_relation CPRModel (eq_refl _) (eq_refl _). Module TR := TrivialRuntime. (* This module encodes the examples in sample-rules.txt *) Section CompilerUntypedTest. Local Open Scope camp_scope. Local Open Scope string. (* This was copy/pastes from sample-rules (with [] added in at the top level *) Definition makeMainEntity (db:Z) (id:string) (i:Z) := class (singleton "MainEntity") (drec [("doubleAttribute",dconst db); ("intAttribute", dconst i); ("id",dconst id) ]). Definition MainEntity (inp:Z*string*Z) := makeMainEntity (fst (fst inp)) (snd (fst inp)) (snd inp). Example exampleWM : list data := [makeMainEntity 120 "string1" 1; makeMainEntity 50 "string2" 2; makeMainEntity 125 "string3" 3; makeMainEntity 50 "string4" 4]. (* Example1: Aggregate, counts customers with age 32 *) (* rule r1 { when { total-attribute: aggregate { e:MainEntity(doubleAttribute == 50); } do { count {e}; } } then { System.out.println("total-attribute: " + total-attribute); } } rule Example1 { when { cs: aggregate { c:MainEntity( age == 32 ); } do { count {c.name}; } } then { System.out.println("MainEntitys with age 32: " + cs); } } *) Example Example1' := ("total-attribute" IS AGGREGATE (rule_when ("e" INSTANCEOF (singleton "MainEntity") WHERE ("doubleAttribute" !#-> … ≐ ‵50))) DO OpCount OVER (withVar "e" …) FLATTEN 0). Example Example1 := rule_global ("total-attribute" IS AGGREGATE (rule_when ("e" INSTANCEOF (singleton "MainEntity") WHERE ("doubleAttribute" !#-> … ≐ ‵50))) DO OpCount OVER (withVar "e" …) FLATTEN 0) ;; rule_return (‵"MainEntitys with doubleAttribute 50: " +s+ toString (lookup "total-attribute")). Example Example1_result := eval_camp_rule nil Example1 exampleWM. Example Example1_expected := map dconst ["MainEntitys with doubleAttribute 50: 2"]. Definition camp5 : camp := Eval vm_compute in Example1'. Definition algopt5 : nraenv_core := camp_to_nraenv_core Example1'. Definition rcamp5 : camp_rule := Eval vm_compute in Example1. Definition ralgopt5 : nraenv := camp_rule_to_nraenv_optim Example1. Definition rnnrc5 : nnrc := camp_rule_to_nnrc_optim Example1. Definition inp1 : (list (string*data)) := (("WORLD", dcoll exampleWM)::nil). Definition inp2 : data := dunit. End CompilerUntypedTest. Section CompilerBrandModelTest. Program Definition MainEntityDataType := Rec Open (("doubleAttribute", Nat) :: ("id", String) :: ("intAttribute", Nat) :: nil) _. Program Definition EntityType : rtype := Rec Open [] _. Definition CPTModelTypes := [("Entity", EntityType); ("MainEntity", MainEntityDataType) ]. Definition CPTModel := @mkBrand_context _ CPRModel_relation CPTModelTypes (eq_refl _). Instance CPModel : brand_model := mkBrand_model CPRModel_relation CPTModel (eq_refl _) (eq_refl _). End CompilerBrandModelTest. Module MyBrandModel <: CompilerBrandModel(TrivialForeignType). Definition compiler_brand_model := CPModel. End MyBrandModel. Module TM := TrivialModel(MyBrandModel). Section CompilerTypedTest. Existing Instance CPModel. (* Eval compute in (interp Example1' inp1 inp2). *) Lemma makeMainEntity_typed db id i: (normalize_data brand_relation_brands (makeMainEntity db id i)) ▹ (Brand (singleton "MainEntity")). Proof. simpl. apply (@dtbrand' _ _ _ CPModel). - qeauto. - rewrite (@canon_brands_singleton (@brand_model_relation _ CPModel)). rewrite brands_type_singleton. simpl. apply (@dtrec_full _ _ _ CPModel). apply Forall2_cons; simpl. split; [reflexivity|constructor]. apply Forall2_cons; simpl. split; [reflexivity|constructor]. apply Forall2_cons; simpl. split; [reflexivity|constructor]. apply Forall2_nil; simpl. - rewrite (@canon_brands_singleton (@brand_model_relation _ CPModel)). reflexivity. Qed. (* We don't have a typing rule for ⊤ ... Lemma makeMainEntity_typedAll db id i: (normalize_data (makeMainEntity db id i)) ▹ (Rec AllEntityType AllEntity_pf). Proof. unfold hasType. apply dtrec. apply Forall2_cons; simpl. - split; try reflexivity. (* Type ⊤ here *) - apply Forall2_cons; simpl. split; [reflexivity|apply dtstring]. apply Forall2_nil; simpl. Qed. *) Definition tout1 := Rec Closed (("total-attribute", Nat)::nil) eq_refl. Definition tinp1 := (("WORLD", Coll (Brand (singleton "MainEntity")))::nil). (* This is collapsed using econstructor, but not sure how systematic that would be... -JS *) Lemma Example1'_wt τ : TCAMP.camp_type tinp1 nil Example1' τ tout1. Proof. econstructor; qeauto. econstructor; qeauto. econstructor; qeauto. econstructor; qeauto. econstructor; qeauto. econstructor; qeauto. econstructor; qeauto. econstructor; qeauto. econstructor; qeauto. econstructor; qeauto. econstructor; qeauto. econstructor; qeauto. econstructor; qeauto. econstructor; qeauto. econstructor; qeauto. econstructor; qeauto. econstructor; qeauto. econstructor; qeauto. econstructor; qeauto. econstructor; qeauto. econstructor; qeauto. econstructor; qeauto. econstructor; qeauto. econstructor; qeauto. econstructor; qeauto. rewrite brands_type_singleton. simpl. repeat econstructor; qeauto. repeat econstructor; qeauto. repeat econstructor; qeauto. repeat econstructor; qeauto. repeat econstructor; qeauto. repeat econstructor; qeauto. repeat econstructor; qeauto. repeat econstructor; qeauto. repeat econstructor; qeauto. repeat econstructor; qeauto. Unshelve. qeauto. qeauto. qeauto. qeauto. qeauto. Qed. (* Require Import TcNRAEnvInfer. Definition tout1infer : option rtype₀ := match infer_nraenv_core_type alg5 (Rec tinp1 eq_refl) Unit with | None => None | Some x => Some (proj1_sig x) end. *) (* Eval compute in tout1infer. Eval compute in (proj1_sig tout1). *) Lemma alg5_wt τ : algopt5 ▷ τ >=> Coll tout1 ⊣ tinp1;(Rec Closed nil eq_refl). Proof. unfold algopt5, camp_to_nraenv_core. unfold CAMPtocNRAEnv.camp_to_nraenv_core_top. unfold CAMPtocNRAEnv.nraenv_core_of_camp. econstructor; qeauto. econstructor; qeauto. 2: { apply (@nraenv_core_of_camp_type_preserve). apply Example1'_wt. } repeat econstructor; qeauto. Unshelve. qeauto. Qed. End CompilerTypedTest.