Datasets:
AI4M
/

text
stringlengths
0
3.34M
library(ggplot2) csvData <- read.csv("2014-03-08_household_income.csv", stringsAsFactors=FALSE) csvData <- csvData[1:42,] csvData$Income <- factor(csvData$Income, levels=csvData$Income, ordered=TRUE) csvData$Number<-as.numeric(csvData$Number) cbPalette <- c("#999999", "#E69F00", "#56B4E9", "#009E73", "#F0E442", "#0072B2", "#D55E00", "#CC79A7") myFill <- rep(cbPalette[1], 42) myFill[13] <- cbPalette[2] myFill[15] <- cbPalette[3] myFill <- factor(myFill) ggplot(data = csvData, aes(x = Income,y = Number), height=200, width=800) + geom_bar(stat="identity", xlab="Income", color="white", fill=myFill) + theme(axis.text.x=element_text(angle=60, hjust=1)) ggsave("household_income.png", width=8, height=5)
theory Tables_nat imports Tables_real begin declare le_of_int_ceiling[simp] (* MOVE *) (* Final version with l :: nat in fully localized form, no duplication *) locale TableInv = Table0 f1 f2 f1' f2' e c for f1 f2 f1' f2' e c :: real + fixes l0 :: nat assumes l0f2e: "l0 \<ge> 1/(f2 * (e-1))" assumes l0f1c: "l0 \<ge> 1/(f1 * (c-1))" assumes l0f2f1e: "l0 \<ge> f1/(f2 - f1*e)" assumes l0f2f1c: "l0 \<ge> f2/(f2 - f1*c)" begin lemma l0_gr0[arith]: "l0 > 0" proof - have "0 < 1/(f2*(e-1))" by(simp) also note l0f2e finally show ?thesis by simp qed lemma f1_l0: assumes "l0 \<le> l/c" shows "f1*(l/c) \<le> f1*l - 1" proof - have "1 = f1*((c-1)/c)*(c*(1/(f1*(c-1))))" using f1'_le_f2' f2'_less_f2 by(simp add: field_simps) also note l0f1c also have l': "c*l0 \<le> l" using assms(1) by(simp add: field_simps) finally show ?thesis by(simp add: divide_le_cancel) (simp add: field_simps) qed fun nxt :: "op\<^sub>t\<^sub>b \<Rightarrow> nat*nat \<Rightarrow> nat*nat" where "nxt Ins (n,l) = (n+1, if n+1 \<le> f2*l then l else nat\<lceil>e*l\<rceil>)" | "nxt Del (n,l) = (n-1, if f1*l \<le> real(n-1) then l else if l0 \<le> \<lfloor>l/c\<rfloor> then nat\<lfloor>l/c\<rfloor> else l)" fun t :: "op\<^sub>t\<^sub>b \<Rightarrow> nat*nat \<Rightarrow> real" where "t Ins (n,l) = (if n+1 \<le> f2*l then 1 else n+1)" | "t Del (n,l) = (if f1*l \<le> real(n-1) then 1 else if l0 \<le> \<lfloor>l/c\<rfloor> then n else 1)" fun invar :: "nat * nat \<Rightarrow> bool" where "invar(n,l) = (l \<ge> l0 \<and> (\<lfloor>l/c\<rfloor> \<ge> l0 \<longrightarrow> f1*l \<le> n) \<and> n \<le> f2*l)" lemma invar_init: "invar (0,l0)" by (auto simp: le_floor_iff field_simps) lemma invar_pres: assumes "invar s" shows "invar(nxt f s)" proof - obtain n l where [simp]: "s = (n,l)" by fastforce from assms have "l0 \<le> l" and "n \<le> f2*l" by auto show ?thesis proof (cases f) case [simp]: Ins show ?thesis proof cases assume "n+1 \<le> f2*l" thus ?thesis using assms by (auto) next assume 0: "\<not> n+1 \<le> f2*l" have f1: "f1 * \<lceil>e*l\<rceil> \<le> n+1" proof - have "\<lceil>e*l\<rceil> \<le> e*l + 1" by linarith hence "f1 * \<lceil>e*l\<rceil> \<le> f1 * (e*l + 1)" by simp also have "\<dots> \<le> f2*l" proof - have "f1 \<le> (f2 - f1*e)*l0" using l0f2f1e f1f2e by(simp add: field_simps) also note \<open>l0 \<le> l\<close> finally show ?thesis using f1f2e[simplified field_simps] by (simp add:ac_simps mult_left_mono) (simp add:algebra_simps) qed finally show ?thesis using 0 by linarith qed have "n+1 \<le> f2*e*l" proof - have "n+1 \<le> f2*l+1" using \<open>n \<le> f2*l\<close> by linarith also have "1 = f2*(e-1)*(1/(f2*(e-1)))" by(simp) also note l0f2e also note \<open>l0 \<le> l\<close> finally show ?thesis by simp (simp add: algebra_simps) qed also have "f2*e*l \<le> f2*\<lceil>e*l\<rceil>" by simp finally have f2: "n+1 \<le> f2*\<lceil>e*l\<rceil>" . have "l < e*l" using \<open>l0 \<le> l\<close> by simp hence "l0 \<le> e*l" using \<open>l0\<le>l\<close> by linarith with 0 f1 f2 show ?thesis by (auto simp add: field_simps) linarith qed next case [simp]: Del show ?thesis proof cases assume "f1*l \<le> real n - 1" thus ?thesis using assms by(auto) next assume 0: "\<not> f1*l \<le> real n - 1" show ?thesis proof cases assume "n=0" thus ?thesis using 0 assms by(simp add: field_simps) next assume "n \<noteq> 0" show ?thesis proof cases assume l: "l0 \<le> \<lfloor>l/c\<rfloor>" hence l': "l0 \<le> l/c" by linarith have "f1 * \<lfloor>l/c\<rfloor> \<le> f1*(l/c)" by(simp del: times_divide_eq_right) hence f1: "f1*\<lfloor>l/c\<rfloor> \<le> n-1" using l' f1_l0[OF l'] assms \<open>n \<noteq> 0\<close> by(simp add: le_floor_iff) have "n-1 \<le> f2 * \<lfloor>l/c\<rfloor>" proof - have "n-1 < f1*l" using 0 \<open>n \<noteq> 0\<close> by linarith also have "f1*l \<le> f2*(l/c) - f2" proof - have "(f2 - f1*c)*l0 \<ge> f2" using l0f2f1c f1cf2 by(simp add: field_simps) with mult_left_mono[OF \<open>l0 \<le> l/c\<close>, of "f2-f1*c"] f1cf2 have "(f2 - f1*c)*(l/c) \<ge> f2" by linarith thus ?thesis by(simp add: field_simps) qed also have "\<dots> \<le> f2*\<lfloor>l/c\<rfloor>" proof - have "l/c - 1 \<le> \<lfloor>l/c\<rfloor>" by linarith from mult_left_mono[OF this, of f2] show ?thesis by(simp add: algebra_simps) qed finally show ?thesis using 0 \<open>n \<noteq> 0\<close> by linarith qed with l 0 f1 \<open>n \<noteq> 0\<close> show ?thesis by (auto) next assume "\<not> l0 \<le> \<lfloor>l/c\<rfloor>" with 0 assms show ?thesis by (auto simp add: field_simps) qed qed qed qed qed end locale Table1 = TableInv + assumes f2f2': "l0 \<ge> 1/(f2 - f2')" assumes f1'f1: "l0 \<ge> 1/((f1' - f1)*c)" begin definition "ai = f2/(f2-f2')" definition "ad = f1/(f1'-f1)" lemma aigr0[arith]: "ai > 1" using f2'_less_f2 by(simp add: ai_def field_simps) lemma adgr0[arith]: "ad > 0" using f1_less_f1' by(simp add: ad_def field_simps) lemma f1'ad[arith]: "f1'*ad > 0" by simp lemma f2'ai[arith]: "f2'*ai > 0" by simp fun \<Phi> :: "nat * nat \<Rightarrow> real" where "\<Phi> (n,l) = (if n \<ge> f2'*l then ai*(n - f2'*l) else if n \<le> f1'*l \<and> l0 \<le> \<lfloor>l/c\<rfloor> then ad*(f1'*l - n) else 0)" lemma Phi_Psi: "\<Phi> (n,l) = \<Psi> (l0 \<le> \<lfloor>l/c\<rfloor>) ai ad (f1'*l) (f2'*l) n" by(simp) abbreviation "U \<equiv> \<lambda>f _. case f of Ins \<Rightarrow> ai+1 + f1'*ad | Del \<Rightarrow> ad+1 + f2'*ai" interpretation tb: Amortized where init = "(0,l0)" and nxt = nxt and inv = invar and t = t and \<Phi> = \<Phi> and U = U proof (standard, goal_cases) case 1 show ?case by (fact invar_init) next case 2 thus ?case by(fact invar_pres) next case (3 s) thus ?case by(cases s)(simp split: if_splits) next case 4 show ?case by(auto simp: field_simps mult_le_0_iff le_floor_iff) next case (5 s f) obtain n l where [simp]: "s = (n,l)" by fastforce show ?case proof (cases f) case [simp]: Ins show ?thesis (is "?A \<le> _") proof cases assume "n+1 \<le> f2*l" hence "?A \<le> ai+1" by(simp del: \<Phi>.simps \<Psi>.simps add: Phi_Psi Psi_diff_Ins) thus ?thesis by simp next assume [arith]: "\<not> n+1 \<le> f2*l" have [arith]: "l \<ge> l0" "n \<le> f2*l" using 5 by auto have "(f2 - f2')*l \<ge> 1" using mult_mono[OF order_refl, of l0 l "f2-f2'"] f2'_less_f2 f2f2' by (simp add: field_simps) hence "n \<ge> f2'*l" by(simp add: algebra_simps) hence Phi: "\<Phi> s = ai * (n - f2'*l)" by simp have [simp]: "real (nat \<lceil>e*l\<rceil>) = real_of_int \<lceil>e*l\<rceil>" by (simp add: order.order_iff_strict) have "?A \<le> n - ai*(f2 - f2')*l + ai + 1 + f1'*ad" (is "_ \<le> ?R") proof cases assume f2': "n+1 < f2'*\<lceil>e*l\<rceil>" show ?thesis proof cases assume "n+1 \<le> f1'*\<lceil>e*l\<rceil>" hence "?A \<le> n+1 + ad*(f1'*\<lceil>e*l\<rceil>-(n+1)) - ai*(n - f2'*l)" using Phi f2' by (simp add: ) also have "f1'*\<lceil>e*l\<rceil> - (n+1) \<le> f1'" proof - have "f1'*\<lceil>e*l\<rceil> \<le> f1'*(e*l + 1)" by(simp) also have "\<dots> = f1'*e*l + f1'" by(simp add: algebra_simps) also have "f1'*e*l \<le> f2*l" using f1'ef2 by(simp) finally show ?thesis by linarith qed also have "n+1+ad*f1'-ai*(n-f2'*l) = n+ai*(-real(n+1)+f2'*l)+ai+f1'*ad+1" by(simp add: algebra_simps) also have "-real(n+1) \<le> -f2*l" by linarith finally show ?thesis by(simp add: algebra_simps) (* f1'*ad *) next assume "\<not> n+1 \<le> f1'*\<lceil>e*l\<rceil>" hence "?A = n+1 - ai*(n - f2'*l)" using Phi f2' by (simp) also have "n+1-ai*(n-f2'*l) = n+ai*(-real(n+1)+f2'*l)+ai+1" by(simp add: algebra_simps) also have "-real(n+1) \<le> -f2*l" by linarith also have "n+ai*(-f2*l+f2'*l)+ai+1 \<le> ?R" by(simp add: algebra_simps) finally show ?thesis by(simp) qed next assume "\<not> n+1 < f2'*\<lceil>e*l\<rceil>" hence "?A = n + ai*(-f2'*\<lceil>e*l\<rceil> + f2'*l) + ai+1" using Phi by(simp add: algebra_simps) also have "-f2'*\<lceil>e*l\<rceil> \<le> -f2'*e*l" by(simp) also have "-f2'*e \<le> -f2" using f2_le_f2'e by linarith also have "n+ai*(-f2*l+f2'*l)+ai+1 \<le> ?R" by(simp add: algebra_simps) finally show ?thesis by(simp) qed also have "\<dots> = n - f2*l + ai+f1'*ad+1" using f2'_less_f2 by(simp add: ai_def) finally show ?thesis by simp qed next case [simp]: Del have [arith]: "l \<ge> l0" using 5 by simp show ?thesis proof cases assume "n=0" with 5 show ?thesis by(simp add: mult_le_0_iff field_simps) next assume [arith]: "n\<noteq>0" show ?thesis (is "?A \<le> _") proof cases assume "real n - 1 \<ge> f1*l \<or> \<lfloor>l/c\<rfloor> < l0" hence "?A \<le> ad+1" using f1'_le_f2' by(auto simp del: \<Phi>.simps \<Psi>.simps simp add: Phi_Psi Psi_diff_Del) thus ?thesis by simp next assume "\<not> (real n - 1 \<ge> f1*l \<or> \<lfloor>l/c\<rfloor> < l0)" hence n: "real n - 1 < f1*l" and lc': "\<lfloor>l/c\<rfloor> \<ge> l0" and lc: "l/c \<ge> l0" by linarith+ have "f1'*l \<le> f2'*l" using f1'_le_f2' by simp have "(f1' - f1)*l \<ge> 1" using mult_mono[OF order_refl, of l0 "l/c" "f1'-f1"] lc f1_less_f1' f1'f1 by (simp add: field_simps) hence "n < f1'*l" using n by(simp add: algebra_simps) hence Phi: "\<Phi> s = ad*(f1'*l - n)" apply(simp) using \<open>f1'*l \<le> f2'*l\<close> lc by linarith have "?A \<le> n - ad*(f1' - f1)*l + ad + f2'*ai" (is "_ \<le> ?R + _") proof cases assume f2': "n-1 < f2'*\<lfloor>l/c\<rfloor>" show ?thesis proof cases assume "n-1 < f1'*\<lfloor>l/c\<rfloor> \<and> \<lfloor>\<lfloor>l/c\<rfloor>/c\<rfloor> \<ge> l0" hence "\<Phi> (nxt f s) = ad*(f1'*\<lfloor>l/c\<rfloor> - (n-1))" using f2' n lc' by(auto) hence "?A = n + ad*(f1'*\<lfloor>l/c\<rfloor> - (n-1)) - (ad*(f1'*l - n))" using Phi n lc' by (simp add: algebra_simps) also have "\<lfloor>l/c\<rfloor> \<le> l/c" by(simp) also have "n+ad*(f1'*(l/c)-(n-1))-(ad*(f1'*l-n)) = n+ad*(f1'/c-f1')*l+ad" by(simp add: algebra_simps) also note f1'c_le_f1 finally have "?A \<le> ?R" by(simp add: algebra_simps) thus ?thesis by linarith next assume "\<not>(n-1 < f1'*\<lfloor>l/c\<rfloor> \<and> \<lfloor>\<lfloor>l/c\<rfloor>/c\<rfloor> \<ge> l0)" hence "\<Phi> (nxt f s) = 0" using f2' n lc' by(auto) hence "?A = n + ad*(n - f1'*l)" using Phi n lc' by (simp add: algebra_simps) also have "\<dots> = n + ad*(n-1 - f1'*l) + ad" by(simp add: algebra_simps) also have "n-1 \<le> f1*l" using n by linarith finally have "?A \<le> ?R" by (simp add: algebra_simps) thus ?thesis by linarith qed next assume f2': "\<not> n-1 < f2'*\<lfloor>l/c\<rfloor>" hence "?A = n + ai*(n-1-f2'*\<lfloor>l/c\<rfloor>) - ad*(f1'*l - n)" using Phi n lc' by (simp) also have "n-1-f2'*\<lfloor>l/c\<rfloor> \<le> f2'" proof - have "f1*l \<le> f2'*(l/c)" using f1f2'c by(simp add: field_simps) hence "n-1 < f2'*(l/c)" using n by linarith also have "l/c \<le> \<lfloor>l/c\<rfloor> + 1" by linarith finally show ?thesis by(fastforce simp: algebra_simps) qed also have "n+ai*f2'-ad*(f1'*l-n) = n + ad*(n-1 - f1'*l) + ad + f2'*ai" by(simp add: algebra_simps) also have "n-1 \<le> f1*l" using n by linarith finally show ?thesis by(simp add: algebra_simps) qed also have "\<dots> = n - f1*l + ad + f2'*ai" using f1_less_f1' by(simp add: ad_def) finally show ?thesis using n by simp qed qed qed qed end locale Table2_f1f2'' = TableInv + fixes f1'' f2'' :: real locale Table2 = Table2_f1f2'' + assumes f2f2'': "(f2 - f2'')*l0 \<ge> 1" assumes f1''f1: "(f1'' - f1)*c*l0 \<ge> 1" assumes f1_less_f1'': "f1 < f1''" assumes f1''_less_f1': "f1'' < f1'" assumes f2'_less_f2'': "f2' < f2''" assumes f2''_less_f2: "f2'' < f2" assumes f1''_f1': "l \<ge> real l0 \<Longrightarrow> f1'' * (l+1) \<le> f1'*l" assumes f2'_f2'': "l \<ge> real l0 \<Longrightarrow> f2' * l \<le> f2'' * (l-1)" begin definition "ai = f2 / (f2 - f2'')" definition "ad = f1 / (f1'' - f1)" lemma f1''_gr0[arith]: "f1'' > 0" using f1_less_f1'' f1 by linarith lemma f2''_gr0[arith]: "f2'' > 0" using f2' f2'_less_f2'' by linarith lemma aigr0[arith]: "ai > 0" using f2''_less_f2 by(simp add: ai_def field_simps) lemma adgr0[arith]: "ad > 0" using f1_less_f1'' by(simp add: ad_def field_simps) fun \<Phi> :: "nat * nat \<Rightarrow> real" where "\<Phi>(n,l) = (if n \<ge> f2''*l then ai*(n - f2''*l) else if n \<le> f1''*l \<and> l0 \<le> \<lfloor>l/c\<rfloor> then ad*(f1''*l - n) else 0)" lemma Phi_Psi: "\<Phi> (n,l) = \<Psi> (l0 \<le> \<lfloor>l/c\<rfloor>) ai ad (f1''*l) (f2''*l) n" by(simp) abbreviation "U \<equiv> \<lambda>f _. case f of Ins \<Rightarrow> ai+1 | Del \<Rightarrow> ad+1" interpretation tb: Amortized where init = "(0,l0)" and nxt = nxt and inv = invar and t = t and \<Phi> = \<Phi> and U = U proof (standard, goal_cases) case 1 show ?case by (fact invar_init) next case 2 thus ?case by(fact invar_pres) next case (3 s) thus ?case by(cases s)(simp split: if_splits) next case 4 show ?case by(auto simp: field_simps mult_le_0_iff le_floor_iff) next case (5 s f) obtain n l where [simp]: "s = (n,l)" by fastforce show ?case proof (cases f) case [simp]: Ins show ?thesis (is "?L \<le> _") proof cases assume "n+1 \<le> f2*l" thus ?thesis by(simp del: \<Phi>.simps \<Psi>.simps add: Phi_Psi Psi_diff_Ins) next assume [arith]: "\<not> n+1 \<le> f2*l" have [arith]: "l \<ge> l0" "n \<le> f2*l" using 5 by auto have "l0 \<le> e*l" using \<open>l0 \<le> l\<close> e1 mult_mono[of 1 e l0 l] by simp have "(f2 - f2'')*l \<ge> 1" using mult_mono[OF order_refl, of l0 l "f2-f2''"] f2''_less_f2 f2f2'' by (simp add: algebra_simps) hence "n \<ge> f2''*l" by(simp add: algebra_simps) hence Phi: "\<Phi> s = ai * (n - f2''*l)" by simp have [simp]: "real (nat \<lceil>e*l\<rceil>) = real_of_int \<lceil>e*l\<rceil>" by (simp add: order.order_iff_strict) have "?L \<le> n - ai*(f2 - f2'')*l + ai + 1" (is "_ \<le> ?R") proof cases assume f2'': "n+1 < f2''*\<lceil>e*l\<rceil>" have "f1''*\<lceil>e*l\<rceil> \<le> f1''*(e*l + 1)" by(simp) also note f1''_f1'[OF \<open>l0 \<le> e*l\<close>] also have "f1'*(e*l) \<le> f2*l" using f1'ef2 by(simp) also have "f2*l \<le> n+1" by linarith finally have "?L \<le> n+1 - ai*(n - f2''*l)" using Phi f2'' by (simp) also have "n+1-ai*(n-f2''*l) = n+ai*(-real(n+1)+f2''*l)+ai+1" by(simp add: algebra_simps) also have "-real(n+1) \<le> -f2*l" by linarith finally show ?thesis by(simp add: algebra_simps) next assume "\<not> n+1 < f2''*\<lceil>e*l\<rceil>" hence "?L = n + ai*(-f2''*\<lceil>e*l\<rceil> + f2''*l) + ai+1" using Phi by(simp add: algebra_simps) also have "-f2''*\<lceil>e*l\<rceil> \<le> -f2''*e*l" by(simp) also have "-f2''*e \<le> -f2'*e" using f2'_less_f2'' by(simp) also have "-f2'*e \<le> -f2" using f2_le_f2'e by(simp) also have "n+ai*(-f2*l+f2''*l)+ai+1 \<le> ?R" by(simp add: algebra_simps) finally show ?thesis by(simp) qed also have "\<dots> = n - f2*l + ai+1" using f2''_less_f2 by(simp add: ai_def) finally show ?thesis by simp qed next case [simp]: Del have [arith]: "l \<ge> l0" using 5 by simp show ?thesis proof cases assume "n=0" with 5 show ?thesis by(simp add: mult_le_0_iff field_simps) next assume [arith]: "n\<noteq>0" show ?thesis (is "?A \<le> _") proof cases assume "real n - 1 \<ge> f1*l \<or> \<lfloor>l/c\<rfloor> < l0" thus ?thesis using f1''_less_f1' f1'_le_f2' f2'_less_f2'' by(auto simp del: \<Phi>.simps \<Psi>.simps simp add: Phi_Psi Psi_diff_Del) next assume "\<not> (real n - 1 \<ge> f1*l \<or> \<lfloor>l/c\<rfloor> < l0)" hence n: "real n - 1 < f1*l" and lc': "\<lfloor>l/c\<rfloor> \<ge> l0" and lc: "l/c \<ge> l0" by linarith+ have "f1''*l \<le> f2''*l" using f1''_less_f1' f1'_le_f2' f2'_less_f2'' by simp have "(f1'' - f1)*l \<ge> 1" using mult_mono[OF order_refl, of l0 "l/c" "f1''-f1"] lc f1_less_f1'' f1''f1 by (simp add: field_simps) hence "n < f1''*l" using n by(simp add: algebra_simps) hence Phi: "\<Phi> s = ad*(f1''*l - n)" apply(simp) using \<open>f1''*l \<le> f2''*l\<close> lc by linarith have f2': "n-1 < f2''*\<lfloor>l/c\<rfloor>" proof - have "n-1 < f1*l" using n by linarith also have "f1*l \<le> f2'*(l/c)" using f1f2'c by(auto simp: field_simps) also note f2'_f2''[OF \<open>l/c\<ge>l0\<close>] also have "f2''*(l/c - 1) \<le> f2''*\<lfloor>l/c\<rfloor>" by simp finally show ?thesis by(simp) qed have "?A \<le> n - ad*(f1'' - f1)*l + ad" proof cases assume "n-1 < f1''*\<lfloor>l/c\<rfloor> \<and> \<lfloor>\<lfloor>l/c\<rfloor>/c\<rfloor> \<ge> l0" hence "\<Phi> (nxt f s) = ad*(f1''*\<lfloor>l/c\<rfloor> - (n-1))" using f2' n lc' by(auto) hence "?A = n + ad*(f1''*\<lfloor>l/c\<rfloor> - (n-1)) - (ad*(f1''*l - n))" using Phi n lc' by (simp add: algebra_simps) also have "\<lfloor>l/c\<rfloor> \<le> l/c" by(simp) also have "n+ad*(f1''*(l/c)-(n-1))-(ad*(f1''*l-n)) = n+ad*(f1''/c-f1'')*l+ad" by(simp add: algebra_simps) also have "f1''/c \<le> f1'/c" using f1''_less_f1' by(simp add: field_simps) also note f1'c_le_f1 finally show ?thesis by(simp add: algebra_simps) next assume "\<not>(n-1 < f1''*\<lfloor>l/c\<rfloor> \<and> \<lfloor>\<lfloor>l/c\<rfloor>/c\<rfloor> \<ge> l0)" hence "\<Phi> (nxt f s) = 0" using f2' n lc' by(auto) hence "?A = n + ad*(n - f1''*l)" using Phi n lc' by (simp add: algebra_simps) also have "\<dots> = n + ad*(n-1 - f1''*l) + ad" by(simp add: algebra_simps) also have "n-1 \<le> f1*l" using n by linarith finally show ?thesis by (simp add: algebra_simps) qed also have "\<dots> = n - f1*l + ad" using f1_less_f1'' by(simp add: ad_def) finally show ?thesis using n by simp qed qed qed qed end locale Table3 = Table2_f1f2'' + assumes f1''_def: "f1'' = (f1'::real)*l0/(l0+1)" assumes f2''_def: "f2'' = (f2'::real)*l0/(l0-1)" (* they imply (f2 - f2'')*l0 \<ge> 1 and (f1 - f1'')*l0*c \<ge> 1 *) assumes l0_f2f2': "l0 \<ge> (f2+1)/(f2-f2')" assumes l0_f1f1': "l0 \<ge> (f1'*c+1)/((f1'-f1)*c)" (* they imply f1<f1'' and f2'<f2'' and l0 > 1 *) assumes l0_f1_f1': "l0 > f1/((f1'-f1))" assumes l0_f2_f2': "l0 > f2/(f2-f2')" begin lemma l0_gr1: "l0 > 1" proof - have "f2/(f2-f2') \<ge> 1" using f2'_less_f2 by(simp add: field_simps) thus ?thesis using l0_f2_f2' f2'_less_f2 by linarith qed lemma f1''_less_f1': "f1'' < f1'" by(simp add: f1''_def field_simps) lemma f1_less_f1'': "f1 < f1''" proof - have "1 + l0 > 0" by (simp add: add_pos_pos) hence "f1''> f1 \<longleftrightarrow> l0 > f1/((f1'-f1))" using f1_less_f1' by(simp add: f1''_def field_simps) also have "\<dots> \<longleftrightarrow> True" using l0_f1_f1' by blast finally show ?thesis by blast qed lemma f2'_less_f2'': "f2' < f2''" using l0_gr1 by(simp add: f2''_def field_simps) lemma f2''_less_f2: "f2'' < f2" proof - have "f2''< f2 \<longleftrightarrow> l0 > f2/(f2-f2')" using f2'_less_f2 l0_gr1 by(simp add: f2''_def field_simps) also have "\<dots> \<longleftrightarrow> True" using l0_f2_f2' by blast finally show ?thesis by blast qed (* This is the real constraint we want, not l0_f2f2', but it involves f2'', which depends on l0 *) lemma f2f2'': "(f2 - f2'')*l0 \<ge> 1" proof - have "(f2 - f2'')*(l0-1) \<ge> 1" using l0_gr1 l0_f2f2' f2'_less_f2 by(simp add: f2''_def algebra_simps del: of_nat_diff) (simp add: field_simps) thus ?thesis using f2''_less_f2 by (simp add: algebra_simps) qed (* This is the real constraint we want, not l0_f1f1', but it involves f1'', which depends on l0 *) lemma f1''f1: "(f1'' - f1)*c*l0 \<ge> 1" proof - have "1 \<le> (f1' - f1)*c*l0 - f1'*c" using l0_f1f1' f1_less_f1' by(simp add: field_simps) also have "\<dots> = (f1'*((l0-1)/l0) - f1)*c*l0" by(simp add: field_simps) also have "(l0-1)/l0 \<le> l0/(l0+1)" by(simp add: field_simps) also have "f1'*(l0/(l0+1)) = f1'*l0/(l0+1)" by(simp add: algebra_simps) also note f1''_def[symmetric] finally show ?thesis by(simp) qed lemma f1''_f1': assumes "l \<ge> real l0" shows "f1''*(l+1) \<le> f1' * l" proof - have "f1''*(l+1) = f1'*(l0/(l0+1))*(l+1)" by(simp add: f1''_def field_simps) also have "l0/(l0+1) \<le> l/(l+1)" using assms by(simp add: field_simps) finally show ?thesis using \<open>l0 \<le> l\<close> by(simp) qed lemma f2'_f2'': assumes "l \<ge> real l0" shows "f2' * l \<le> f2'' * (l-1)" proof - have "f2' * l = f2' * l + f2'*((l0-1)/(l0-1) - 1)" using l0_gr1 by simp also have "(l0-1)/(l0-1) \<le> (l-1)/(l0-1)" using \<open>l\<ge>l0\<close> by(simp) also have "f2'*l + f2'*((l-1)/(l0-1) - 1) = f2''*(l-1)" using l0_gr1 by(simp add: f2''_def field_simps) finally show ?thesis by simp qed sublocale Table2 proof qed (fact f1_less_f1'' f1''_less_f1' f2'_less_f2'' f2''_less_f2 f1''f1 f2f2'' f1''_f1' f2'_f2'')+ end end
! *****************************COPYRIGHT******************************* ! (C) Crown copyright Met Office. All rights reserved. ! For further details please refer to the file COPYRIGHT.txt ! which you should have received as part of this distribution. ! *****************************COPYRIGHT******************************* ! ! This file is part of the UM Shared Library project. ! ! The UM Shared Library is free software: you can redistribute it ! and/or modify it under the terms of the Modified BSD License, as ! published by the Open Source Initiative. ! ! The UM Shared Library is distributed in the hope that it will be ! useful, but WITHOUT ANY WARRANTY; without even the implied warranty ! of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! Modified BSD License for more details. ! ! You should have received a copy of the Modified BSD License ! along with the UM Shared Library. ! If not, see <http://opensource.org/licenses/BSD-3-Clause>. ! !******************************************************************************* ! ! ! Description : A module containing constants/parameters for ! Relative Molecular Mass ! MODULE f_shum_rel_mol_mass_mod USE, INTRINSIC :: ISO_C_BINDING, ONLY: & C_DOUBLE IMPLICIT NONE PRIVATE PUBLIC :: shum_rmm_s_const, shum_rmm_h2o2_const, & shum_rmm_o3_const, shum_rmm_air_const, & shum_rmm_w_const !------------------------------------------------------------------------------! ! We're going to use the types from the ISO_C_BINDING module, since although ! ! the REALs aren't 100% guaranteed to correspond to the sizes we want to ! ! enforce, they should be good enough on the majority of systems. ! ! ! ! Additional protection for the case that FLOAT/DOUBLE do not conform to the ! ! sizes we expect is provided via the "precision_bomb" macro-file ! !------------------------------------------------------------------------------! INTEGER, PARAMETER :: real64 = C_DOUBLE !------------------------------------------------------------------------------! ! Relative Molecular Mass (kg/mole) REAL(KIND=real64), PARAMETER :: shum_rmm_s_const = 3.20e-2_real64 ! S REAL(KIND=real64), PARAMETER :: shum_rmm_h2o2_const = 3.40e-2_real64 ! H2O2 REAL(KIND=real64), PARAMETER :: shum_rmm_o3_const = 4.8e-2_real64 ! O3 REAL(KIND=real64), PARAMETER :: shum_rmm_air_const = 2.896e-2_real64 ! dry air REAL(KIND=real64), PARAMETER :: shum_rmm_w_const = 1.8e-2_real64 ! water END MODULE f_shum_rel_mol_mass_mod
[STATEMENT] lemma image_Un_conv: "f ` (\<Union>p\<in>dom \<Gamma>. \<Union>Z. {x p Z}) = (\<Union>p\<in>dom \<Gamma>. \<Union>Z. {f (x p Z)})" [PROOF STATE] proof (prove) goal (1 subgoal): 1. f ` (\<Union>p\<in>dom \<Gamma>. \<Union>Z. {x p Z}) = (\<Union>p\<in>dom \<Gamma>. \<Union>Z. {f (x p Z)}) [PROOF STEP] by (auto iff: not_None_eq)
# # Partitions # #md # [![](https://img.shields.io/badge/show-nbviewer-579ACA.svg)](@__NBVIEWER_ROOT_URL__/generated/sketches/Partitions.ipynb) # # Partitions are a categorical construction that we derive from sets and functions. # Given a set A, you can think of all of the ways to partition A into parts. # These ways of partitioning are isomorphic to equivalence relations R ⊆ A × A. # The first step is our Catlab imports using Core: GeneratedFunctionStub using Test using Catlab, Catlab.Theories, Catlab.CategoricalAlgebra, Catlab.CategoricalAlgebra.FinSets import Catlab.Theories: compose using DataStructures using PrettyTables PrettyTables.pretty_table(f::FinFunction, name::Symbol=:f) = pretty_table(OrderedDict(:x=>1:dom(f).set, Symbol("$(name)(x)")=>collect(f))) using LaTeXStrings Quiversty = L""" % contents of quiver.sty % `tikz-cd` is necessary to draw commutative diagrams. \RequirePackage{tikz-cd} % `amssymb` is necessary for `\lrcorner` and `\ulcorner`. \RequirePackage{amssymb} % `calc` is necessary to draw curved arrows. \usetikzlibrary{calc} % `pathmorphing` is necessary to draw squiggly arrows. \usetikzlibrary{decorations.pathmorphing} % A TikZ style for curved arrows of a fixed height, due to AndréC. \tikzset{curve/.style={settings={#1},to path={(\tikztostart) .. controls ($(\tikztostart)!\pv{pos}!(\tikztotarget)!\pv{height}!270:(\tikztotarget)$) and ($(\tikztostart)!1-\pv{pos}!(\tikztotarget)!\pv{height}!270:(\tikztotarget)$) .. (\tikztotarget)\tikztonodes}}, settings/.code={\tikzset{quiver/.cd,#1} \def\pv##1{\pgfkeysvalueof{/tikz/quiver/##1}}}, quiver/.cd,pos/.initial=0.35,height/.initial=0} % TikZ arrowhead/tail styles. \tikzset{tail reversed/.code={\pgfsetarrowsstart{tikzcd to}}} \tikzset{2tail/.code={\pgfsetarrowsstart{Implies[reversed]}}} \tikzset{2tail reversed/.code={\pgfsetarrowsstart{Implies}}} % TikZ arrow styles. \tikzset{no body/.style={/tikz/dash pattern=on 0 off 1mm}} """; # ## FinSet: the category of Finite Sets # In FinSet the objects are sets n = {1...n} and the morphisms are functions between finite sets. # You can wrap a plain old Int into a finite set with the FinSet(n::Int) function. These sets will # serve as the domain and codomains of our functions. n = FinSet(3) m = FinSet(4) # once you have some sets, you can define functions between them. A FinFunction from n to m, f:n→m, can be specified as # an array of length n with elements from m. f = FinFunction([2,4,3], n, m) pretty_table(f) # ## Surjective maps # In order to use a map to represent a partition, we have to make sure that it is surjective. # Given a FinFunction, we can compute the preimage of any element in its codomain. preimage(f, 2) preimage(f, 1) # If the preimage is empty, then there is no element in the domain that maps to that element of the codomain. # This gives us a definition of surjective functions by asserting that all the preimages are nonempty. # Julia note: !p is the predicate x ↦ ¬p(x), f.(A) applies f to all of the elements in A. is_surjective(f::FinFunction) = all((!isempty).(preimage(f,i) for i in codom(f))) is_surjective(f) # Our function f, wasn't surjective so it can't be used to induce a partition via its preimages. # Let's try again, g = FinFunction([1,2,3,3], m, n) pretty_table(g, :g) is_surjective(g) # # Refinements of a Partition # When defining partitions classically as A = ∪ₚ Aₚ with p ≠ r ⟹ Aₚ ≠ Aᵣ, # it is not immediately obvious how to define comparisons between partitions. # With the "a partition of A is a surjective map out of A" definition, the comparisons # are obvious. The composition of surjective maps is surjective, so we can define # the refinement order in terms of a diagram in Set. # # You can see a graphical definition in [quiver](https://q.uiver.app/?q=WzAsMyxbMCwwLCJBIl0sWzMsMCwiUSJdLFszLDIsIlAiXSxbMSwyLCJoIiwwLHsic3R5bGUiOnsiaGVhZCI6eyJuYW1lIjoiZXBpIn19fV0sWzAsMSwiZiIsMCx7InN0eWxlIjp7ImhlYWQiOnsibmFtZSI6ImVwaSJ9fX1dLFswLDIsImciLDIseyJzdHlsZSI6eyJoZWFkIjp7Im5hbWUiOiJlcGkifX19XV0=) using TikzCDs triangle = L""" A &&& Q \\ \\ &&& P \arrow["h", two heads, from=1-4, to=3-4] \arrow["f", two heads, from=1-1, to=1-4] \arrow["g"', two heads, from=1-1, to=3-4] """; TikzCD(triangle, preamble=Quiversty) # Let's take a look at an example: A = FinSet(4) Q = FinSet(3) P = FinSet(2) f = FinFunction([1,2,3,3], A, Q) g = FinFunction([1,1,2,2], A, P) h = FinFunction([1,1,2], Q, P) @test_throws ErrorException compose(g,h) #Catlab checks the domains match pretty_table(compose(f,h), Symbol("(f⋅h)")) compose(f,h) == g # This triangle commutes, so f is a refinement of g equivalently g is coarser than f. h′ = FinFunction([1,1], P, FinSet(1)) pretty_table(f⋅h⋅h′, Symbol("f⋅h⋅h′")) # ### Properties of refinements # We can show that refinement gives us a preorder on partitions directly from the # nice properties of surjective maps. # 1. Reflexive: Any partition is a refinement of itself. # 2. Transitive: If f ≤ g ≤ h as partitions, then f ≤ h # You can read these directly off the definition of refinements as a commutative # triangle in the category of (Set, Surjections). # You can edit this diagram in [quiver](https://q.uiver.app/?q=WzAsNCxbMCwwLCJBIl0sWzMsMCwiUSJdLFszLDIsIlAiXSxbMyw0LCJRXlxccHJpbWUiXSxbMSwyLCJoIl0sWzAsMSwiZiIsMCx7InN0eWxlIjp7ImhlYWQiOnsibmFtZSI6ImVwaSJ9fX1dLFswLDIsImciLDIseyJzdHlsZSI6eyJoZWFkIjp7Im5hbWUiOiJlcGkifX19XSxbMiwzLCJoXlxccHJpbWUiXSxbMCwzLCJmXFxjZG90IGhcXGNkb3QgaF5cXHByaW1lID0gZ1xcY2RvdCBoXlxccHJpbWUiLDIseyJzdHlsZSI6eyJoZWFkIjp7Im5hbWUiOiJlcGkifX19XV0=) refinement = L""" A &&& Q \\ \\ &&& P \\ \\ &&& {Q^\prime} \arrow["h", from=1-4, to=3-4] \arrow["f", two heads, from=1-1, to=1-4] \arrow["g"', two heads, from=1-1, to=3-4] \arrow["{h^\prime}", from=3-4, to=5-4] \arrow["{f\cdot h\cdot h^\prime = g\cdot h^\prime}"', two heads, from=1-1, to=5-4] """; TikzCD(refinement, preamble=Quiversty)
You've noticed something that's at once obvious and subtle about astrology: opposite signs have a lot in common, and astrologers will work with these similarities. And it's very common that people with a strong sign placement will draw a lot of the opposite sign into their lives. However, you were also reading Pisces birthday reports during a time when the ruler of Virgo was retrograde in its opposite sign, Pisces. So that was providing plenty of room for overlapping themes, since in many respects Pisces and Virgo have been fully merged for a few months. However, these two signs can seem strikingly similar, even to the oddest details, until you get far enough below the surface to see that Pisces really is Pisces and Virgo really is Virgo.
A polynomial is either zero, or positive, or negative.
function [a,ass] = bipartiteMatchingIntProg(dst, nmatches) % BIPARTITEMATCHINGINTPROG Use binary integer programming (linear objective) to solve for optimal linear assignment % function a = bipartiteMatchingIntProg(dst) % a(i) = best matching column for row i % % This gives the same result as bipartiteMatchingHungarian. % % function a = bibpartiteMatchingIntProg(dst, nmatches) % only matches the specified number (must be <= min(size(dst))). % This can be used to allow outliers in both source and target. % % For details, see Marciel & Costeira, "A global solution to sparse correspondence % problems", PAMI 25(2), 2003 if nargin < 2, nmatches = []; end [p1 p2] = size(dst); p1orig = p1; p2orig = p2; dstorig = dst; if isempty(nmatches) % no outliers allowed (modulo size difference) % ensure matrix is square m = max(dst(:)); if p1<p2 dst = [dst; m*ones(p2-p1, p2)]; elseif p1>p2 dst = [dst m*ones(p1, p1-p2)]; end end [p1 p2] = size(dst); c = dst(:); % vectorize cost matrix % row-sum: ensure each column sums to 1 A2 = kron(eye(p2), ones(1,p1)); b2 = ones(p2,1); % col-sum: ensure each row sums to 1 A3 = kron(ones(1,p2), eye(p1)); b3 = ones(p1,1); if isempty(nmatches) % enforce doubly stochastic A = [A2; A3]; b = [b2; b3]; Aineq = zeros(1, p1*p2); bineq = 0; else nmatches = min([nmatches, p1, p2]); Aineq = [A2; A3]; bineq = [b2; b3]; % row and col sums <= 1 A = ones(1,p1*p2); b = nmatches; % total num matches = b (otherwise get degenerate soln) end ass = bintprog(c, Aineq, bineq, A, b); ass = reshape(ass, p1, p2); a = zeros(1, p1orig); for i=1:p1orig ndx = find(ass(i,:)==1); if ~isempty(ndx) & (ndx <= p2orig) a(i) = ndx; end end
-- 2010-10-05 Andreas module TerminationRecordPatternCoerce where data Empty : Set where record Unit : Set where constructor unit data Bool : Set where true false : Bool T : Bool -> Set T true = Unit T false = Empty data _==_ {A : Set}(a : A) : A -> Set where refl : a == a subst : forall {A a b} -> a == b -> {P : A -> Set} -> P a -> P b subst refl x = x -- Thorsten suggests on the Agda list thread "Coinductive families" -- to encode lists as records record List (A : Set) : Set where constructor list field isCons : Bool head : T isCons -> A tail : T isCons -> List A open List public -- However, we have to be careful to preserve termination -- in the presence of a lie postulate lie : {b : Bool} -> T b -- if the record constructor list was counted as structural increase -- this function would not be rejected f : {A : Set} -> (b : Bool) -> (l : List A) -> b == isCons l -> Unit f .false (list false h t) refl = unit f .true (list true h t) refl = f (isCons tl) tl refl where tl : List _ tl = t unit {- dot patterns inside of record patterns not supported! f true (list .true h t) refl = f (isCons tl) tl refl where tl : List _ tl = t unit -} -- however, it is almost like the following f' : {A : Set} -> (b : Bool) -> (l : List A) -> b == isCons l -> Unit f' false l p = unit f' true (list b' h t) p = f' (isCons tl) tl refl where tl : List _ tl = t (subst p {T} unit)
The Lebesgue measure on the real line is sigma-finite.
module Main import System import Task import Helpers %default total -- Tests ----------------------------------------------------------------------- -- -- NOTE: Tasks ending in `'` need user input -- -- Helpers -- edit : Int -> Task (PRIM INT) edit = pure --FIXME: due to some namespacing problem... del : Nat -> List a -> List a del = Helpers.delete rep : Nat -> a -> List a -> List a rep = Helpers.replace -- Basics -- fourtytwo : Task (PRIM INT) fourtytwo = pure 42 hello : Task (PRIM STRING) hello = pure "Hello" inc : Int -> Task (PRIM INT) inc x = pure (x + 1) add : Int -> Int -> Task (PRIM INT) add x y = pure (x + y) append : String -> String -> Task (PRIM STRING) append x y = pure (x ++ y) -- Steps -- pureStep : Task (PRIM INT) pureStep = do x <- fourtytwo inc x pureStep' : Task (PRIM INT) pureStep' = "Hello" # ( fourtytwo >>? \x => inc x ) pureStep'' : Task (PRIM INT) pureStep'' = ("Hello" # fourtytwo) >>? \x => inc x oneStep : Task (PRIM INT) oneStep = do x <- edit 0 inc x oneStep' : Task (PRIM INT) oneStep' = edit 0 >>? \x => inc x twoSteps : Task (PRIM INT) twoSteps = do x <- edit 1 y <- edit 2 add x y twoSteps' : Task (PRIM INT) twoSteps' = edit 1 >>? \x => edit 2 >>? \y => add x y -- Parallel -- parallel : Task (PAIR (PRIM INT) (PRIM STRING)) parallel = "Give an integer" # ask (PRIM INT) <&> hello parallelStep : Task (PRIM STRING) parallelStep = do ( n, m ) <- parallel pure (unwords $ replicate (cast n) m) parallelStep' : Task (PRIM STRING) parallelStep' = parallel >>? \( n, m ) => pure (unwords $ replicate (cast n) m) -- Normalisation -- -- -- FIXME: should these automatically simplify? pair : Task (PAIR (PRIM INT) (PRIM INT)) pair = pure 3 <&> pure 8 inner : Task (PRIM INT) inner = do ( x, y ) <- pair add x y inner' : Task (PRIM INT) inner' = pair >>? \( x, y ) => add x y -- Shared Data -- partial editList : Task (PAIR (PRIM UNIT) (LIST (PRIM INT))) editList = do l <- ref (LIST (PRIM INT)) [] start l <&> watch l where delete : Loc (LIST (PRIM INT)) -> Nat -> Task (PRIM UNIT) delete l i = modify (LIST (PRIM INT)) l (del i) replace : Loc (LIST (PRIM INT)) -> Nat -> Task (PRIM UNIT) replace l i = "Give a new value" # ask (PRIM INT) >>? \x => modify (LIST (PRIM INT)) l (rep i x) change : Loc (LIST (PRIM INT)) -> Task (PRIM UNIT) change l = --NOTE: `deref` should be before the external step, -- otherwise we'll end up an a state where we show an editor with the list when the user entered an improper index. -- Compare this with iTasks though: -- `deref` should be before the external step because you cannot specify the `deref` inside the step list! deref (LIST (PRIM INT)) l >>= \xs => "Give an index" # ask (PRIM INT) >>? \n => let i = the Nat (cast n) in if i < List.length xs then "Delete" # delete l i <?> "Replace" # replace l i else fail prepend : Loc (LIST (PRIM INT)) -> Task (PRIM UNIT) prepend l = "Give a new value to prepend" # ask (PRIM INT) >>? \x => modify (LIST (PRIM INT)) l ((::) x) clear : Loc (LIST (PRIM INT)) -> Task (PRIM UNIT) clear l = modify (LIST (PRIM INT)) l (const []) quit : Task (PRIM UNIT) quit = pure () mutual partial repeat : Loc (LIST (PRIM INT)) -> Task (PRIM UNIT) repeat l = do "Prepend" # prepend l <?> "Clear" # clear l <?> "Change" # change l start l partial start : Loc (LIST (PRIM INT)) -> Task (PRIM UNIT) start l = "Edit" # repeat l <?> "Quit" # quit update1 : Loc (PRIM INT) -> Task (PRIM INT) update1 l = do n <- ask (PRIM INT) assign (PRIM INT) l n m <- ask (PRIM INT) modify (PRIM INT) l ((+) m) edit !(deref (PRIM INT) l) update2 : Loc (PRIM INT) -> Task (PRIM UNIT) update2 l = deref (PRIM INT) l >>= \x => edit (x + 1) >>? \y => assign (PRIM INT) l y >>= \() => deref (PRIM INT) l >>= \u => edit (u + 2) >>? \v => assign (PRIM INT) l v inspect : Show (typeOf a) => (Loc (PRIM INT) -> Task a) -> Task (PAIR a (PRIM INT)) inspect f = do l <- ref (PRIM INT) 0 f l <&> watch l -- inspect : Show (typeOf a) => Show (typeOf b) => (Loc b -> Task a) -> Task (PAIR a (PRIM b)) -- inspect {b} f = do -- l <- init b -- f l <&> watch l doubleShared : Task (PAIR (PRIM UNIT) (PRIM INT)) doubleShared = do l <- ref (PRIM INT) 0 m <- ref (PRIM INT) 0 let t1 = do x <- the (Task (PRIM INT)) $ watch m if x >= 10 then edit (x * 2) else fail let t2 = do y <- the (Task (PRIM INT)) $ watch l if y >= 5 then assign (PRIM INT) m 12 else fail t2 <&> t1 -- Choices -- pick1 : Task (PRIM INT) pick1 = fail <|> edit 0 pick2 : Task (PRIM INT) pick2 = edit 1 <|> edit 2 pick3 : Task (PRIM INT) pick3 = pick2 <|> edit 3 pick1' : Task (PRIM INT) pick1' = "Fail" # fail <?> "Cont" # edit 0 pick2' : Task (PRIM INT) pick2' = "Pick one of two" # ("First" # edit 1 <?> "Second" # edit 2) pick3' : Task (PRIM INT) pick3' = "Pick one of three" # (pick2' <?> "Third" # edit 3) -- Guards -- auto : Task (PRIM STRING) auto = do x <- ask (PRIM INT) if x >= 10 then pure "large" else fail actions : Task (PRIM INT) actions = ask (PRIM INT) >>? \x => pick3 actions' : Task (PRIM INT) actions' = ask (PRIM INT) >>? \x => pick3' guards : Task (PRIM STRING) guards = do x <- ask (PRIM INT) "Large" # (if x >= 10 then pure "large" else fail) <?> "VeryLarge" # (if x >= 100 then pure "very large" else fail) guards' : Task (PRIM STRING) guards' = do ask (PRIM INT) >>? \x => ("Large" # (if x >= 10 then pure "large" else fail) <?> "VeryLarge" # (if x >= 100 then pure "very large" else fail)) partial -- due to `mod` on `0` branch : Task (PRIM STRING) branch = edit 1 >>? \x => if x `mod` 3 == 0 then pure "multiple of 3" else if x `mod` 5 == 0 then pure "multiple of 5" else fail -- Empty edit -- empties : Task (PRIM INT) empties = do ( x, y ) <- ask (PRIM INT) <&> ask (PRIM INT) pure (x + y) -- Running --------------------------------------------------------------------- %default covering get : IO Input get = do putStr ">> " input <- getLine case input of "quit" => System.exit 0 _ => case Task.Input.parse (words input) of Right event => do pure event Left msg => do putStrLn msg get loop : Show (typeOf a) => Task a -> IO () loop task = do putStrLn !(Task.ui task) putStrLn $ "Possibilities: " ++ show !(Task.inputs task) event <- get loop !(Task.run task event) run : Show (typeOf a) => Task a -> IO () run task = loop !(Task.initialise task) main : IO () main = run empties
Oh I wish I were dead! There are so many people in the world who through no fault of their own go without the basic things in life. Food, shelter, love, income, family and in some cases even a country. Such hardship and suffering exists both at home and abroad. One thing they do all have is hope. Hope is omnipresent and deep within all of us. It reminds us we are alive and there is still a chance that things will get better. We cling to it as if our life depends on it because without hope there is nothing. We have all experienced some form of despair at low times and we can feel very alone. It made me realize how just simple gestures from those we know, and also from strangers, can make such a difference to our lives and ease some of the suffering. A kind thought costs us nothing neither does spending a little of our time with someone who is lonely. Sharing some food could be the difference between going to bed hungry or not for a desperate person. If we can be anything in this life, shouldn’t we be kind?
[STATEMENT] lemma distincts_distinct_set: assumes "distincts xss" shows "distinct (map set xss)" [PROOF STATE] proof (prove) goal (1 subgoal): 1. distinct (map set xss) [PROOF STEP] using assms [PROOF STATE] proof (prove) using this: distincts xss goal (1 subgoal): 1. distinct (map set xss) [PROOF STEP] by (auto simp: distinct_map distincts_distinct distincts_inj_on_set)
theory Collecting_ITP imports "~~/src/Tools/Permanent_Interpretation" Complete_Lattice_ix "ACom_ITP" begin subsection "Collecting Semantics of Commands" subsubsection "Annotated commands as a complete lattice" (* Orderings could also be lifted generically (thus subsuming the instantiation for preord and order), but then less_eq_acom would need to become a definition, eg less_eq_acom = lift2 less_eq, and then proofs would need to unfold this defn first. *) instantiation acom :: (order) order begin fun less_eq_acom :: "('a::order)acom \<Rightarrow> 'a acom \<Rightarrow> bool" where "(SKIP {S}) \<le> (SKIP {S'}) = (S \<le> S')" | "(x ::= e {S}) \<le> (x' ::= e' {S'}) = (x=x' \<and> e=e' \<and> S \<le> S')" | "(c1;;c2) \<le> (c1';;c2') = (c1 \<le> c1' \<and> c2 \<le> c2')" | "(IF b THEN c1 ELSE c2 {S}) \<le> (IF b' THEN c1' ELSE c2' {S'}) = (b=b' \<and> c1 \<le> c1' \<and> c2 \<le> c2' \<and> S \<le> S')" | "({Inv} WHILE b DO c {P}) \<le> ({Inv'} WHILE b' DO c' {P'}) = (b=b' \<and> c \<le> c' \<and> Inv \<le> Inv' \<and> P \<le> P')" | "less_eq_acom _ _ = False" lemma SKIP_le: "SKIP {S} \<le> c \<longleftrightarrow> (\<exists>S'. c = SKIP {S'} \<and> S \<le> S')" by (cases c) auto lemma Assign_le: "x ::= e {S} \<le> c \<longleftrightarrow> (\<exists>S'. c = x ::= e {S'} \<and> S \<le> S')" by (cases c) auto lemma Seq_le: "c1;;c2 \<le> c \<longleftrightarrow> (\<exists>c1' c2'. c = c1';;c2' \<and> c1 \<le> c1' \<and> c2 \<le> c2')" by (cases c) auto lemma If_le: "IF b THEN c1 ELSE c2 {S} \<le> c \<longleftrightarrow> (\<exists>c1' c2' S'. c= IF b THEN c1' ELSE c2' {S'} \<and> c1 \<le> c1' \<and> c2 \<le> c2' \<and> S \<le> S')" by (cases c) auto lemma While_le: "{Inv} WHILE b DO c {P} \<le> w \<longleftrightarrow> (\<exists>Inv' c' P'. w = {Inv'} WHILE b DO c' {P'} \<and> c \<le> c' \<and> Inv \<le> Inv' \<and> P \<le> P')" by (cases w) auto definition less_acom :: "'a acom \<Rightarrow> 'a acom \<Rightarrow> bool" where "less_acom x y = (x \<le> y \<and> \<not> y \<le> x)" instance proof case goal1 show ?case by(simp add: less_acom_def) next case goal2 thus ?case by (induct x) auto next case goal3 thus ?case apply(induct x y arbitrary: z rule: less_eq_acom.induct) apply (auto intro: le_trans simp: SKIP_le Assign_le Seq_le If_le While_le) done next case goal4 thus ?case apply(induct x y rule: less_eq_acom.induct) apply (auto intro: le_antisym) done qed end fun sub\<^sub>1 :: "'a acom \<Rightarrow> 'a acom" where "sub\<^sub>1(c1;;c2) = c1" | "sub\<^sub>1(IF b THEN c1 ELSE c2 {S}) = c1" | "sub\<^sub>1({I} WHILE b DO c {P}) = c" fun sub\<^sub>2 :: "'a acom \<Rightarrow> 'a acom" where "sub\<^sub>2(c1;;c2) = c2" | "sub\<^sub>2(IF b THEN c1 ELSE c2 {S}) = c2" fun invar :: "'a acom \<Rightarrow> 'a" where "invar({I} WHILE b DO c {P}) = I" fun lift :: "('a set \<Rightarrow> 'b) \<Rightarrow> com \<Rightarrow> 'a acom set \<Rightarrow> 'b acom" where "lift F com.SKIP M = (SKIP {F (post ` M)})" | "lift F (x ::= a) M = (x ::= a {F (post ` M)})" | "lift F (c1;;c2) M = lift F c1 (sub\<^sub>1 ` M);; lift F c2 (sub\<^sub>2 ` M)" | "lift F (IF b THEN c1 ELSE c2) M = IF b THEN lift F c1 (sub\<^sub>1 ` M) ELSE lift F c2 (sub\<^sub>2 ` M) {F (post ` M)}" | "lift F (WHILE b DO c) M = {F (invar ` M)} WHILE b DO lift F c (sub\<^sub>1 ` M) {F (post ` M)}" permanent_interpretation Complete_Lattice_ix "%c. {c'. strip c' = c}" "lift Inter" proof case goal1 have "a:A \<Longrightarrow> lift Inter (strip a) A \<le> a" proof(induction a arbitrary: A) case Seq from Seq.prems show ?case by(force intro!: Seq.IH) next case If from If.prems show ?case by(force intro!: If.IH) next case While from While.prems show ?case by(force intro!: While.IH) qed force+ with goal1 show ?case by auto next case goal2 thus ?case proof(induction b arbitrary: i A) case SKIP thus ?case by (force simp:SKIP_le) next case Assign thus ?case by (force simp:Assign_le) next case Seq from Seq.prems show ?case by (force intro!: Seq.IH simp:Seq_le) next case If from If.prems show ?case by (force simp: If_le intro!: If.IH) next case While from While.prems show ?case by(fastforce simp: While_le intro: While.IH) qed next case goal3 have "strip(lift Inter i A) = i" proof(induction i arbitrary: A) case Seq from Seq.prems show ?case by (fastforce simp: strip_eq_Seq subset_iff intro!: Seq.IH) next case If from If.prems show ?case by (fastforce intro!: If.IH simp: strip_eq_If) next case While from While.prems show ?case by(fastforce intro: While.IH simp: strip_eq_While) qed auto thus ?case by auto qed lemma le_post: "c \<le> d \<Longrightarrow> post c \<le> post d" by(induction c d rule: less_eq_acom.induct) auto subsubsection "Collecting semantics" fun step :: "state set \<Rightarrow> state set acom \<Rightarrow> state set acom" where "step S (SKIP {P}) = (SKIP {S})" | "step S (x ::= e {P}) = (x ::= e {{s'. EX s:S. s' = s(x := aval e s)}})" | "step S (c1;; c2) = step S c1;; step (post c1) c2" | "step S (IF b THEN c1 ELSE c2 {P}) = IF b THEN step {s:S. bval b s} c1 ELSE step {s:S. \<not> bval b s} c2 {post c1 \<union> post c2}" | "step S ({Inv} WHILE b DO c {P}) = {S \<union> post c} WHILE b DO (step {s:Inv. bval b s} c) {{s:Inv. \<not> bval b s}}" definition CS :: "com \<Rightarrow> state set acom" where "CS c = lfp (step UNIV) c" lemma mono2_step: "c1 \<le> c2 \<Longrightarrow> S1 \<subseteq> S2 \<Longrightarrow> step S1 c1 \<le> step S2 c2" proof(induction c1 c2 arbitrary: S1 S2 rule: less_eq_acom.induct) case 2 thus ?case by fastforce next case 3 thus ?case by(simp add: le_post) next case 4 thus ?case by(simp add: subset_iff)(metis le_post set_mp)+ next case 5 thus ?case by(simp add: subset_iff) (metis le_post set_mp) qed auto lemma mono_step: "mono (step S)" by(blast intro: monoI mono2_step) lemma strip_step: "strip(step S c) = strip c" by (induction c arbitrary: S) auto lemma lfp_cs_unfold: "lfp (step S) c = step S (lfp (step S) c)" apply(rule lfp_unfold[OF _ mono_step]) apply(simp add: strip_step) done lemma CS_unfold: "CS c = step UNIV (CS c)" by (metis CS_def lfp_cs_unfold) lemma strip_CS[simp]: "strip(CS c) = c" by(simp add: CS_def index_lfp[simplified]) end
%EDGELIST Return list of edge pixels for region % % EG = EDGELIST(IM, SEED) is a list of edge pixels (Nx2) of a region in the % image IM starting at edge coordinate SEED=[X,Y]. The edgelist has one row per % edge point coordinate (x,y). % % EG = EDGELIST(IM, SEED, DIRECTION) as above, but the direction of edge % following is specified. DIRECTION == 0 (default) means clockwise, non % zero is counter-clockwise. Note that direction is with respect to y-axis % upward, in matrix coordinate frame, not image frame. % % [EG,D] = EDGELIST(IM, SEED, DIRECTION) as above but also returns a vector % of edge segment directions which have values 1 to 8 representing W SW S SE E % NW N NW respectively. % % Notes:: % - Coordinates are given assuming the matrix is an image, so the indices are % always in the form (x,y) or (column,row). % - IM is a binary image where 0 is assumed to be background, non-zero % is an object. % - SEED must be a point on the edge of the region. % - The seed point is always the first element of the returned edgelist. % - 8-direction chain coding can give incorrect results when used with % blobs founds using 4-way connectivty. % % Reference:: % - METHODS TO ESTIMATE AREAS AND PERIMETERS OF BLOB-LIKE OBJECTS: A COMPARISON % Luren Yang, Fritz Albregtsen, Tor Lgnnestad and Per Grgttum % IAPR Workshop on Machine Vision Applications Dec. 13-15, 1994, Kawasaki % % See also ILABEL. % Copyright (C) 1993-2014, by Peter I. Corke % % This file is part of The Robotics Toolbox for MATLAB (RTB). % % RTB is free software: you can redistribute it and/or modify % it under the terms of the GNU Lesser General Public License as published by % the Free Software Foundation, either version 3 of the License, or % (at your option) any later version. % % RTB is distributed in the hope that it will be useful, % but WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % GNU Lesser General Public License for more details. % % You should have received a copy of the GNU Leser General Public License % along with RTB. If not, see <http://www.gnu.org/licenses/>. % % http://www.petercorke.com function [e,d] = edgelist(im, P, direction) % deal with direction argument if nargin == 2 direction = 0; end if direction == 0 neighbours = [1:8]; % neigbours in clockwise direction else neighbours = [8:-1:1]; % neigbours in counter-clockwise direction end P = P(:)'; P0 = P; % make a note of where we started pix0 = im(P(2), P(1)); % color of pixel we start at % find an adjacent point outside the blob Q = adjacent_point(im, P, pix0); if isempty(Q) error('no neighbour outside the blob'); end e = P; % initialize the edge list dir = []; % initialize the direction list % these are directions of 8-neighbours in a clockwise direction dirs = [-1 0; -1 1; 0 1; 1 1; 1 0; 1 -1; 0 -1; -1 -1]; while 1 % find which direction is Q dQ = Q - P; for kq=1:8 if all(dQ == dirs(kq,:)) break; end end % now test for directions relative to Q for j=neighbours % get index of neighbour's direction in range [1,8] k = j + kq; if k > 8 k = k - 8; end dir = [dir; k]; % compute coordinate of the k'th neighbour Nk = P + dirs(k,:); try if im(Nk(2), Nk(1)) == pix0 % if this neighbour is in the blob it is the next edge pixel P = Nk; break; end end Q = Nk; % the (k-1)th neighbour end % check if we are back where we started if all(P == P0) break; end % keep going, add P to the edgelist e = [e; P]; end if nargout > 1 d = dir; end end function P = adjacent_point(im, seed, pix0) % find an adjacent point not in the region dirs = [1 0; 0 1; -1 0; 0 -1]; for d=dirs' P = [seed(1)+d(1), seed(2)+d(2)]; try if im(P(2), P(1)) ~= pix0 return; end catch % if we get an exception then by definition P is outside the region, % since it's off the edge of the image return; end end P = []; end
module PLFI.Part1.Naturals -- https://plfa.gihub.io/Naturals data Vect : Nat -> (t : Type) -> Type where Nil : Vect 0 t (::) : (x : t) -> Vect n t -> Vect (1 + n) t replicate : Nat -> t -> List t replicateV : (n : Nat) -> t -> Vect n t replicateV 0 x = [] replicateV (S k) x = x :: replicateV k x %hide (+) %hide (*) -- %default total -- data N0 = Zero | Suc N0 {- ----------- Zero Zero : N m : N ----------- Suc Suc m : N -} public export data N : Type where -- Base case Zero : -------- N -- Inductive case Suc : (m : N) -> ---------- N export Num N where (*) = ?m1 (+) = ?a1 fromInteger n with (compare n 0) fromInteger n | LT = Zero fromInteger n | EQ = Zero fromInteger n | GT = Suc (assert_total (fromInteger (n-1))) ex1 : N ex1 = Suc (Suc (Suc (Suc (Suc (Suc (Suc Zero)))))) test : N test = (-7) total public export (+) : N -> N -> N Zero + m = m (Suc n) + m = Suc (n + m) export addEquation1 : {n : N} -> (Zero + n) = n -- Refl : Equal x x addEquation1 = Refl export addEquation2 : (Suc m) + n = Suc (m + n) addEquation2 = Refl total public export (*) : N -> N -> N Zero * n = Zero (Suc m) * n = n + (m * n) -- N -> Zero * ? = Zero multEquation0 : {n : N} -> Zero * n = Zero -- test :: Maybe (Maybe Int) -- test : Maybe $ Maybe Int -- test : (n : Nat) -> let m = n + n in Vect m Int export multEquation1 : Zero * n = Zero multEquation1 = Refl export multEquation2 : (Suc m) * n = n + (m * n) multEquation2 = Refl infixr 8 ^ -- Exercise: recommended total export (^) : N -> N -> N m ^ Zero = Suc Zero m ^ (Suc n) = m * (m ^ n) -- m ^ 0 = 1 -- m ^ (1 + n) = m * (m ^ n) export expEquation1 : m ^ Zero = Suc Zero expEquation1 = Refl export expEquation2 : m ^ (Suc n) = m * (m ^ n) expEquation2 = Refl -- monus infixl 6 -* total export (-*) : N -> N -> N m -* Zero = m Zero -* (Suc n) = Zero (Suc m) -* (Suc n) = m -* n -- Exercise: strech public export data Bin : Type where E : Bin O : Bin -> Bin I : Bin -> Bin -- 1101 is encoded as -- IOIIE this needs to be read reversed: -- EIIOI export inc : Bin -> Bin export to : N -> Bin export from : Bin -> N
module Types4Crib where open import Basics public _<=_ : Nat -> Nat -> Set ze <= y = One su x <= ze = Zero su x <= su y = x <= y cmp : (x y : Nat) -> (x <= y) + (y <= x) cmp ze y = inl <> cmp (su x) ze = inr <> cmp (su x) (su y) = cmp x y data Bnd : Set where bot : Bnd # : Nat -> Bnd top : Bnd _<B=_ : Bnd -> Bnd -> Set bot <B= _ = One # x <B= # y = x <= y _ <B= top = One _ <B= _ = Zero data T23 (l u : Bnd) : Nat -> Set where leaf : (lu : l <B= u) -> T23 l u ze node2 : forall {h} x (tlx : T23 l (# x) h)(txu : T23 (# x) u h) -> T23 l u (su h) node3 : forall {h} x y (tlx : T23 l (# x) h)(txy : T23 (# x) (# y) h)(tyu : T23 (# y) u h) -> T23 l u (su h) data Intv (l u : Bnd) : Set where intv : (x : Nat)(lx : l <B= # x)(xu : # x <B= u) -> Intv l u TooBig : Bnd -> Bnd -> Nat -> Set TooBig l u h = Sg Nat \ x -> T23 l (# x) h * T23 (# x) u h insert : forall {h l u} -> Intv l u -> T23 l u h -> TooBig l u h + T23 l u h insert (intv x lx xu) (leaf lu) = inl (x , (leaf lx , leaf xu)) insert (intv x lx xu) (node2 y tly tyu) with cmp x y insert (intv x lx xu) (node2 y tly tyu) | inl xy with insert (intv x lx xy) tly insert (intv x lx xu) (node2 y tly tyu) | inl xy | inl (z , tlz , tzu) = inr (node3 z y tlz tzu tyu) insert (intv x lx xu) (node2 y tly tyu) | inl xy | inr tly' = inr (node2 y tly' tyu) insert (intv x lx xu) (node2 y tly tyu) | inr yx with insert (intv x yx xu) tyu insert (intv x lx xu) (node2 y tly tyu) | inr yx | inl (v , tyv , tvu) = inr (node3 y v tly tyv tvu) insert (intv x lx xu) (node2 y tly tyu) | inr yx | inr tyv' = inr (node2 y tly tyv') insert (intv x lx xu) (node3 y z tly tyz tzu) with cmp x y insert (intv x lx xu) (node3 y z tly tyz tzu) | inl xy with insert (intv x lx xy) tly insert (intv x lx xu) (node3 y z tly tyz tzu) | inl xy | inl (v , tlv , tvy) = inl (y , node2 v tlv tvy , node2 z tyz tzu) insert (intv x lx xu) (node3 y z tly tyz tzu) | inl xy | inr tly' = inr (node3 y z tly' tyz tzu) insert (intv x lx xu) (node3 y z tly tyz tzu) | inr yx with cmp x z insert (intv x lx xu) (node3 y z tly tyz tzu) | inr yx | inl xz with insert (intv x yx xz) tyz insert (intv x lx xu) (node3 y z tly tyz tzu) | inr yx | inl xz | inl (v , tyv , tvz) = inl (v , node2 y tly tyv , node2 z tvz tzu) insert (intv x lx xu) (node3 y z tly tyz tzu) | inr yx | inl xz | inr tyz' = inr (node3 y z tly tyz' tzu) insert (intv x lx xu) (node3 y z tly tyz tzu) | inr yx | inr zx with insert (intv x zx xu) tzu insert (intv x lx xu) (node3 y z tly tyz tzu) | inr yx | inr zx | inl (v , tzv , tvu) = inl (z , node2 y tly tyz , node2 v tzv tvu) insert (intv x lx xu) (node3 y z tly tyz tzu) | inr yx | inr zx | inr tzu' = inr (node3 y z tly tyz tzu')
% !TEX root = ../zeth-protocol-specification.tex \section{Encryption of the notes}\label{implementation:encryption} In this section we give some remarks concerning the implementation of the \zeth{} encryption scheme, described in \cref{instantiation:enc}. As noted, there are several details in the specification of the underlying primitives which can impact security if not carefully implemented. The following list is by no means exhaustive but includes several details noted during development of the proof-of-concept system. \begin{itemize} \item Private keys for \curve{25519} \MUST{} be randomly generated as $32$ bytes where the first byte is a multiple of $8$, and the last byte takes a value between $64$ and $127$ (inclusive). Further details are given in~\cite{bernstein2006curve25519}, including an example algorithm for generation. Implementations \MUST{} take care to ensure that their code, or any external libraries they rely upon, correctly perform this step. \item A similar observation holds for \polymac{1305} in which the $r$ component of the \mac{} key $(r, s)$ \MUST{} be \emph{clamped} in a specific way (see~\cref{instantiation:enc:enc-sch}). This step is also essential and \MUST{} be performed. \item In the implementation of the \chacha{} stream cipher, correct use of the \emph{key}, \emph{counter} and \emph{nonce} \MUST{} be ensured in order to adhere to the standard and guarantee the appropriate security properties. \end{itemize} During the proof-of-concept implementation it was not obvious that the cryptography library\footnote{\url{https://cryptography.io/en/latest/}} adhered to the specifications with respect to the above points. In particular, it was not clear whether key clamping was performed at generation time and/or when performing operations. Moreover, the interface to the \chacha{} cipher accepted a different set of input parameters (namely \emph{key} and \emph{nonce} with no \emph{counter}). This left some ambiguity about the responsibility for clamping, and whether the \chacha{} block data would be updated as described in the specification. Details of how this was resolved are given in the proof-of-concept encryption code, which may prove a useful reference for implementers\footnote{see~\url{https://github.com/clearmatics/zeth/blob/v0.4/client/zeth/encryption.py}}.
Require Import Extensionality. (** Implementation of the List monad transformer in Coq. *) Set Implicit Arguments. (** We use Mersenne induction to ensure that even if T may not be positive, that does not impede the writing of such a type. *) Inductive listT (T : Type -> Type) A := | NodeT : forall S, (S -> nodeT T A) -> T S -> listT T A with nodeT (T : Type -> Type) A := | Nil : nodeT T A | Cons : A -> listT T A -> nodeT T A. Arguments Nil [_ _]. Fixpoint map {T A B} (f : A -> B) (l : listT T A) : listT T B with map_node {T A B} (f : A -> B) (n : nodeT T A) : nodeT T B. Proof. + destruct l as [S k n]; exists S. - intros s. apply (map_node T A B f (k s)). - exact n. + destruct n as [|x l]. - apply Nil. - apply Cons; [exact (f x)|]. apply (map _ _ _ f l). Defined. (* Fixpoint map {R T A B} (f : A -> B) (l : listT R T A) : listT R T B with map_node {R T A B} (f : A -> B) (n : nodeT R T A) : nodeT R T B. Proof. + destruct l as [S k n]; exists S. - intros s; destruct (k s) as [r|N]. { left; exact r. } { right; apply (map_node _ _ A B f N). } - exact n. + destruct n as [|x l]. - apply Nil. - apply Cons; [exact (f x)|]. apply (map _ _ _ _ f l). Defined.*) Section Ops. Context (T : Type -> Type). Variable lift : forall {A}, A -> T A. Variable bind : forall {A B}, (A -> T B) -> (T A -> T B). Fixpoint fold_right {A B} (f : B -> A -> T A) (accu : T A) (l : listT T B) : T A with fold_right_node {A B} (f : B -> A -> T A) (accu : T A) (n : nodeT T B) : T A. Proof. + destruct l as [S k s]. apply (@bind S); [clear s|exact s]. intros s; apply (fold_right_node _ _ f accu (k s)). + destruct n as [|x l]. - exact accu. - pose (ans := fold_right _ _ f accu l). refine (bind _ ans); clear ans accu; intros accu. apply (f x accu). Defined. (* Definition collapse {A} (m : T (listT T A)) : listT T A. Proof. exists (T unit). exists (nodeT T A); [intros n; exact n|]. refine (bind _ m). intros [S k s]. refine (bind _ s); clear s; intros s. apply lift, (k s). Defined. *) Fixpoint app {A} (l1 l2 : listT T A) {struct l1} : listT T A with app_node {A} (n1 : nodeT T A) (l2 : listT T A) {struct n1} : listT T A. Proof. + destruct l1 as [S k s]. apply app_node. apply (app_node _ (k s) l2). + destruct n1 as [|x l1]. (* Fixpoint fold_right {A B} (f : B -> A -> T A) (accu : T A) (l : listT R T B) : T (R + A) with fold_right_node {A B} (f : B -> A -> T A) (accu : T A) (n : nodeT R T B) : T (R + A). Proof. + destruct l as [S k s]. apply (@bind S); [clear s|exact s]. intros s; destruct (k s) as [r|n]. - apply lift; exact (inl r). - apply (fold_right_node _ _ f accu n). + destruct n as [|x l]. - exact (bind (fun x => lift (inr x)) accu). - pose (ans := fold_right _ _ f accu l). refine (bind _ ans); clear ans accu; intros [r|accu]. { apply lift, inl, r. } { refine (bind _ (f x accu)); intros ans; apply lift, inr, ans. } Defined.*) (*Definition collapse {A} (m : T (listT T A)) : listT T A. Proof. exists (PnodeT False T A); [exact inr|]. refine (bind _ m). intros [S k s]. refine (bind _ s); clear s; intros s. destruct (k s) as [[]|n]; apply lift, n. Defined. *) Definition nil {A} : (listT T A) := NodeT (fun _ => inr Nil) (lift tt). Definition cons {A} (x : A) (l : listT T A) := NodeT (fun _ => inr (Cons x l)) (lift tt). Lemma toto : forall A B (f : A -> B) l, lift (map f l) ≅ fold_right (fun x accu => lift (cons (f x) accu)) (lift nil) l. Proof. intros A B f [S k s] Hext; simpl. End Ops.
// Copyright 2005 The Trustees of Indiana University. // Use, modification and distribution is subject to the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // Authors: Douglas Gregor // Andrew Lumsdaine // This is a configuration file for the Python bindings to the // Parallel BGL. Any settings that would usually be reserved for users // (e.g., which process group to use) but should be fixed for a Python // module will be contained here. #include <boost/parallel/mpi/bsp_process_group.hpp> namespace boost { namespace graph { namespace distributed {namespace python { typedef boost::parallel::mpi::bsp_process_group process_group_type; } } } } // end namespace boost::graph::distributed::python
(** CoLoR, a Coq library on rewriting and termination. See the COPYRIGHTS and LICENSE files. - Adam Koprowski, 2004-09-06 - William Delobel, 2005-10-07 This file provides some basic results concerning relations that were missing in the standard library. *) Set Implicit Arguments. Require Import RelUtil LogicUtil Max Arith Setoid Morphisms Basics. (***********************************************************************) (** strict order *) Section StrictOrder. Variables (A : Type) (R : relation A). Record strict_order : Prop := { sord_trans : transitive R; sord_irrefl : irreflexive R }. Variable so : strict_order. Lemma so_not_symmetric : forall a b, R a b -> R b a -> False. Proof. unfold not; intros a b Rab Rba. exact (sord_irrefl so (sord_trans so Rab Rba)). Qed. Variables (eq : relation A) (Req_compat : Proper (eq ==> eq ==> impl) R) (eq_Equivalence : Equivalence eq). Existing Instance eq_Equivalence. Existing Instance Req_compat. Lemma so_strict : forall x y, eq x y -> ~R x y. Proof. intros x y xy. rewrite xy. apply sord_irrefl. hyp. Qed. End StrictOrder. (***********************************************************************) (** module types for setoids with decidable equality *) Module Type SetA. Parameter A : Type. End SetA. Module Type Eqset. Parameter A : Type. Parameter eqA : relation A. Notation "X =A= Y" := (eqA X Y) (at level 70). Declare Instance eqA_Equivalence : Equivalence eqA. Hint Resolve (Seq_refl A eqA eqA_Equivalence) : sets. Hint Resolve (Seq_trans A eqA eqA_Equivalence) : sets. Hint Resolve (Seq_sym A eqA eqA_Equivalence) : sets. End Eqset. Module Type Eqset_dec. Declare Module Export Eq : Eqset. Parameter eqA_dec : forall x y, {x =A= y} + {~x =A= y}. End Eqset_dec. Module Eqset_def (A : SetA) <: Eqset. Definition A := A.A. Definition eqA := eq (A:=A). Instance eqA_Equivalence : Equivalence eqA. Proof. unfold eqA. class. Qed. Hint Resolve (Seq_refl A eqA eqA_Equivalence) : sets. Hint Resolve (Seq_trans A eqA eqA_Equivalence) : sets. Hint Resolve (Seq_sym A eqA eqA_Equivalence) : sets. End Eqset_def. (***********************************************************************) (** module types for ordered setoids *) Section Eqset_def_gtA_eqA_compat. Variables (A : Type) (gtA : relation A). Instance Eqset_def_gtA_eqA_compat : Proper (eq ==> eq ==> impl) gtA. Proof. intros x x' x_x' y y' y_y' x_y. rewrite <- x_x', <- y_y'; trivial. Qed. End Eqset_def_gtA_eqA_compat. Module Type Ord. Parameter A : Type. Declare Module Export S : Eqset with Definition A := A. Parameter gtA : relation A. Notation "X >A Y" := (gtA X Y) (at level 70). Declare Instance gtA_eqA_compat : Proper (eqA ==> eqA ==> impl) gtA. Hint Resolve gtA_eqA_compat : sets. End Ord. Module OrdLemmas (Export P : Ord). Definition ltA := transp gtA. Definition geA x y := ~ ltA x y. Definition leA x y := ~ gtA x y. Definition AccA := Acc ltA. Notation "X <A Y" := (ltA X Y) (at level 70). Notation "X >=A Y" := (geA X Y) (at level 70). Notation "X <=A Y" := (leA X Y) (at level 70). Hint Unfold ltA geA leA AccA : sets. (*REMOVE?*) Instance gtA_morph : Proper (eqA ==> eqA ==> iff) gtA. Proof. intros a b ab c d cd. split; apply gtA_eqA_compat; (hyp||sym;hyp). Qed. (*REMOVE?*) Instance ltA_morph : Proper (eqA ==> eqA ==> iff) ltA. Proof. intros a b ab c d cd. split; apply gtA_eqA_compat; (hyp||sym;hyp). Qed. Instance AccA_morph : Proper (eqA ==> iff) AccA. Proof. intros a b eq_ab. split. intro acc_a. inversion acc_a. constructor. intros. apply H. rewrite eq_ab. hyp. intros acc_b. inversion acc_b. constructor. intros. apply H. rewrite <- eq_ab. hyp. Qed. End OrdLemmas. Module Type Poset. Parameter A : Type. Declare Module Export O : Ord with Definition A := A. Parameter gtA_so : strict_order gtA. Hint Resolve (sord_trans gtA_so) : sets. Hint Resolve (sord_irrefl gtA_so) : sets. Hint Resolve (so_not_symmetric gtA_so) : sets. Hint Resolve (so_strict gtA_so gtA_eqA_compat eqA_Equivalence) : sets. End Poset. Module nat_ord <: Ord. Module natSet <: SetA. Definition A := nat. Definition eqA_dec := eq_nat_dec. End natSet. Module S := Eqset_def natSet. Definition A := nat. Definition gtA := gt. Instance gtA_eqA_compat : Proper (eq ==> eq ==> impl) gt. Proof. fo. Qed. End nat_ord. (***********************************************************************) (** specification *) Section Specif. Inductive sigPS2 (A : Type) (P : A -> Prop) (Q : A -> Set) : Type := existPS2 : forall x, P x -> Q x -> sigPS2 (A:=A) P Q. Notation "{ x : A # P & Q }" := (sigPS2 (fun x : A => P) (fun x : A => Q)) : type_scope. Variables (A : Type) (P Q : A -> Prop). Definition proj1_sig2 (e: sig2 P Q) := match e with | exist2 _ _ a p q => a end. End Specif. (***********************************************************************) (** tactics *) Ltac rewrite_lr term := apply (proj1 term). Ltac rewrite_rl term := apply (proj2 term). Ltac try_solve := simpl in *; try (intros; solve [ contr | discr | auto with terms | tauto | congruence ]).
.fp \np tR .lg 0
SUBROUTINE sprsax(sa,ija,x,b,n) INTEGER n,ija(*) REAL b(n),sa(*),x(n) INTEGER i,k if (ija(1).ne.n+2) pause 'mismatched vector and matrix in sprsax' do 12 i=1,n b(i)=sa(i)*x(i) do 11 k=ija(i),ija(i+1)-1 b(i)=b(i)+sa(k)*x(ija(k)) 11 continue 12 continue return END
[STATEMENT] lemma substitute_above_arg: "t \<sqsubseteq> substitute f T t" [PROOF STATE] proof (prove) goal (1 subgoal): 1. t \<sqsubseteq> substitute f T t [PROOF STEP] using substitute_contains_arg[folded below_set_def, unfolded paths_mono_iff] [PROOF STATE] proof (prove) using this: ?t \<sqsubseteq> substitute ?f ?T ?t goal (1 subgoal): 1. t \<sqsubseteq> substitute f T t [PROOF STEP] .
[GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F h : HasFTaylorSeriesUpToOn n f p s x : E hx : x ∈ s ⊢ p x 0 = ↑(LinearIsometryEquiv.symm (continuousMultilinearCurryFin0 𝕜 E F)) (f x) [PROOFSTEP] rw [← h.zero_eq x hx] [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F h : HasFTaylorSeriesUpToOn n f p s x : E hx : x ∈ s ⊢ p x 0 = ↑(LinearIsometryEquiv.symm (continuousMultilinearCurryFin0 𝕜 E F)) (ContinuousMultilinearMap.uncurry0 (p x 0)) [PROOFSTEP] exact (p x 0).uncurry0_curry0.symm [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F h : HasFTaylorSeriesUpToOn n f p s h₁ : ∀ (x : E), x ∈ s → f₁ x = f x ⊢ HasFTaylorSeriesUpToOn n f₁ p s [PROOFSTEP] refine' ⟨fun x hx => _, h.fderivWithin, h.cont⟩ [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F h : HasFTaylorSeriesUpToOn n f p s h₁ : ∀ (x : E), x ∈ s → f₁ x = f x x : E hx : x ∈ s ⊢ ContinuousMultilinearMap.uncurry0 (p x 0) = f₁ x [PROOFSTEP] rw [h₁ x hx] [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F h : HasFTaylorSeriesUpToOn n f p s h₁ : ∀ (x : E), x ∈ s → f₁ x = f x x : E hx : x ∈ s ⊢ ContinuousMultilinearMap.uncurry0 (p x 0) = f x [PROOFSTEP] exact h.zero_eq x hx [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F h : HasFTaylorSeriesUpToOn n f p s ⊢ ContinuousOn f s [PROOFSTEP] have := (h.cont 0 bot_le).congr fun x hx => (h.zero_eq' hx).symm [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F h : HasFTaylorSeriesUpToOn n f p s this : ContinuousOn (fun x => ↑(LinearIsometryEquiv.symm (continuousMultilinearCurryFin0 𝕜 E F)) (f x)) s ⊢ ContinuousOn f s [PROOFSTEP] rwa [← (continuousMultilinearCurryFin0 𝕜 E F).symm.comp_continuousOn_iff] [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F ⊢ HasFTaylorSeriesUpToOn 0 f p s ↔ ContinuousOn f s ∧ ∀ (x : E), x ∈ s → ContinuousMultilinearMap.uncurry0 (p x 0) = f x [PROOFSTEP] refine ⟨fun H => ⟨H.continuousOn, H.zero_eq⟩, fun H => ⟨H.2, fun m hm => False.elim (not_le.2 hm bot_le), fun m hm ↦ ?_⟩⟩ [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m✝ n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F H : ContinuousOn f s ∧ ∀ (x : E), x ∈ s → ContinuousMultilinearMap.uncurry0 (p x 0) = f x m : ℕ hm : ↑m ≤ 0 ⊢ ContinuousOn (fun x => p x m) s [PROOFSTEP] obtain rfl : m = 0 := by exact_mod_cast hm.antisymm (zero_le _) [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m✝ n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F H : ContinuousOn f s ∧ ∀ (x : E), x ∈ s → ContinuousMultilinearMap.uncurry0 (p x 0) = f x m : ℕ hm : ↑m ≤ 0 ⊢ m = 0 [PROOFSTEP] exact_mod_cast hm.antisymm (zero_le _) [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F H : ContinuousOn f s ∧ ∀ (x : E), x ∈ s → ContinuousMultilinearMap.uncurry0 (p x 0) = f x hm : ↑0 ≤ 0 ⊢ ContinuousOn (fun x => p x 0) s [PROOFSTEP] have : EqOn (p · 0) ((continuousMultilinearCurryFin0 𝕜 E F).symm ∘ f) s := fun x hx ↦ (continuousMultilinearCurryFin0 𝕜 E F).eq_symm_apply.2 (H.2 x hx) [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F H : ContinuousOn f s ∧ ∀ (x : E), x ∈ s → ContinuousMultilinearMap.uncurry0 (p x 0) = f x hm : ↑0 ≤ 0 this : EqOn (fun x => p x 0) (↑(LinearIsometryEquiv.symm (continuousMultilinearCurryFin0 𝕜 E F)) ∘ f) s ⊢ ContinuousOn (fun x => p x 0) s [PROOFSTEP] rw [continuousOn_congr this, LinearIsometryEquiv.comp_continuousOn_iff] [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F H : ContinuousOn f s ∧ ∀ (x : E), x ∈ s → ContinuousMultilinearMap.uncurry0 (p x 0) = f x hm : ↑0 ≤ 0 this : EqOn (fun x => p x 0) (↑(LinearIsometryEquiv.symm (continuousMultilinearCurryFin0 𝕜 E F)) ∘ f) s ⊢ ContinuousOn f s [PROOFSTEP] exact H.1 [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F ⊢ HasFTaylorSeriesUpToOn ⊤ f p s ↔ ∀ (n : ℕ), HasFTaylorSeriesUpToOn (↑n) f p s [PROOFSTEP] constructor [GOAL] case mp 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F ⊢ HasFTaylorSeriesUpToOn ⊤ f p s → ∀ (n : ℕ), HasFTaylorSeriesUpToOn (↑n) f p s [PROOFSTEP] intro H n [GOAL] case mp 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F H : HasFTaylorSeriesUpToOn ⊤ f p s n : ℕ ⊢ HasFTaylorSeriesUpToOn (↑n) f p s [PROOFSTEP] exact H.of_le le_top [GOAL] case mpr 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F ⊢ (∀ (n : ℕ), HasFTaylorSeriesUpToOn (↑n) f p s) → HasFTaylorSeriesUpToOn ⊤ f p s [PROOFSTEP] intro H [GOAL] case mpr 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F H : ∀ (n : ℕ), HasFTaylorSeriesUpToOn (↑n) f p s ⊢ HasFTaylorSeriesUpToOn ⊤ f p s [PROOFSTEP] constructor [GOAL] case mpr.zero_eq 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F H : ∀ (n : ℕ), HasFTaylorSeriesUpToOn (↑n) f p s ⊢ ∀ (x : E), x ∈ s → ContinuousMultilinearMap.uncurry0 (p x 0) = f x [PROOFSTEP] exact (H 0).zero_eq [GOAL] case mpr.fderivWithin 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F H : ∀ (n : ℕ), HasFTaylorSeriesUpToOn (↑n) f p s ⊢ ∀ (m : ℕ), ↑m < ⊤ → ∀ (x : E), x ∈ s → HasFDerivWithinAt (fun x => p x m) (ContinuousMultilinearMap.curryLeft (p x (Nat.succ m))) s x [PROOFSTEP] intro m _ [GOAL] case mpr.fderivWithin 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m✝ n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F H : ∀ (n : ℕ), HasFTaylorSeriesUpToOn (↑n) f p s m : ℕ a✝ : ↑m < ⊤ ⊢ ∀ (x : E), x ∈ s → HasFDerivWithinAt (fun x => p x m) (ContinuousMultilinearMap.curryLeft (p x (Nat.succ m))) s x [PROOFSTEP] apply (H m.succ).fderivWithin m (WithTop.coe_lt_coe.2 (lt_add_one m)) [GOAL] case mpr.cont 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F H : ∀ (n : ℕ), HasFTaylorSeriesUpToOn (↑n) f p s ⊢ ∀ (m : ℕ), ↑m ≤ ⊤ → ContinuousOn (fun x => p x m) s [PROOFSTEP] intro m _ [GOAL] case mpr.cont 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m✝ n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F H : ∀ (n : ℕ), HasFTaylorSeriesUpToOn (↑n) f p s m : ℕ a✝ : ↑m ≤ ⊤ ⊢ ContinuousOn (fun x => p x m) s [PROOFSTEP] apply (H m).cont m le_rfl [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F h : HasFTaylorSeriesUpToOn n f p s hn : 1 ≤ n hx : x ∈ s ⊢ HasFDerivWithinAt f (↑(continuousMultilinearCurryFin1 𝕜 E F) (p x 1)) s x [PROOFSTEP] have A : ∀ y ∈ s, f y = (continuousMultilinearCurryFin0 𝕜 E F) (p y 0) := fun y hy ↦ (h.zero_eq y hy).symm [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F h : HasFTaylorSeriesUpToOn n f p s hn : 1 ≤ n hx : x ∈ s A : ∀ (y : E), y ∈ s → f y = ↑(continuousMultilinearCurryFin0 𝕜 E F) (p y 0) ⊢ HasFDerivWithinAt f (↑(continuousMultilinearCurryFin1 𝕜 E F) (p x 1)) s x [PROOFSTEP] suffices H : HasFDerivWithinAt (continuousMultilinearCurryFin0 𝕜 E F ∘ (p · 0)) (continuousMultilinearCurryFin1 𝕜 E F (p x 1)) s x [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F h : HasFTaylorSeriesUpToOn n f p s hn : 1 ≤ n hx : x ∈ s A : ∀ (y : E), y ∈ s → f y = ↑(continuousMultilinearCurryFin0 𝕜 E F) (p y 0) H : HasFDerivWithinAt (↑(continuousMultilinearCurryFin0 𝕜 E F) ∘ fun x => p x 0) (↑(continuousMultilinearCurryFin1 𝕜 E F) (p x 1)) s x ⊢ HasFDerivWithinAt f (↑(continuousMultilinearCurryFin1 𝕜 E F) (p x 1)) s x [PROOFSTEP] exact H.congr A (A x hx) [GOAL] case H 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F h : HasFTaylorSeriesUpToOn n f p s hn : 1 ≤ n hx : x ∈ s A : ∀ (y : E), y ∈ s → f y = ↑(continuousMultilinearCurryFin0 𝕜 E F) (p y 0) ⊢ HasFDerivWithinAt (↑(continuousMultilinearCurryFin0 𝕜 E F) ∘ fun x => p x 0) (↑(continuousMultilinearCurryFin1 𝕜 E F) (p x 1)) s x [PROOFSTEP] rw [LinearIsometryEquiv.comp_hasFDerivWithinAt_iff'] [GOAL] case H 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F h : HasFTaylorSeriesUpToOn n f p s hn : 1 ≤ n hx : x ∈ s A : ∀ (y : E), y ∈ s → f y = ↑(continuousMultilinearCurryFin0 𝕜 E F) (p y 0) ⊢ HasFDerivWithinAt (fun x => p x 0) (ContinuousLinearMap.comp (↑(ContinuousLinearEquiv.mk (LinearIsometryEquiv.symm (continuousMultilinearCurryFin0 𝕜 E F)).toLinearEquiv)) (↑(continuousMultilinearCurryFin1 𝕜 E F) (p x 1))) s x [PROOFSTEP] have : ((0 : ℕ) : ℕ∞) < n := zero_lt_one.trans_le hn [GOAL] case H 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F h : HasFTaylorSeriesUpToOn n f p s hn : 1 ≤ n hx : x ∈ s A : ∀ (y : E), y ∈ s → f y = ↑(continuousMultilinearCurryFin0 𝕜 E F) (p y 0) this : ↑0 < n ⊢ HasFDerivWithinAt (fun x => p x 0) (ContinuousLinearMap.comp (↑(ContinuousLinearEquiv.mk (LinearIsometryEquiv.symm (continuousMultilinearCurryFin0 𝕜 E F)).toLinearEquiv)) (↑(continuousMultilinearCurryFin1 𝕜 E F) (p x 1))) s x [PROOFSTEP] convert h.fderivWithin _ this x hx [GOAL] case h.e'_10.h.h 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F h : HasFTaylorSeriesUpToOn n f p s hn : 1 ≤ n hx : x ∈ s A : ∀ (y : E), y ∈ s → f y = ↑(continuousMultilinearCurryFin0 𝕜 E F) (p y 0) this : ↑0 < n e_7✝ : ContinuousMultilinearMap.normedAddCommGroup' = ContinuousMultilinearMap.normedAddCommGroup ⊢ ContinuousLinearMap.comp (↑(ContinuousLinearEquiv.mk (LinearIsometryEquiv.symm (continuousMultilinearCurryFin0 𝕜 E F)).toLinearEquiv)) (↑(continuousMultilinearCurryFin1 𝕜 E F) (p x 1)) = ContinuousMultilinearMap.curryLeft (p x (Nat.succ 0)) [PROOFSTEP] ext y v [GOAL] case h.e'_10.h.h.h.H 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F h : HasFTaylorSeriesUpToOn n f p s hn : 1 ≤ n hx : x ∈ s A : ∀ (y : E), y ∈ s → f y = ↑(continuousMultilinearCurryFin0 𝕜 E F) (p y 0) this : ↑0 < n e_7✝ : ContinuousMultilinearMap.normedAddCommGroup' = ContinuousMultilinearMap.normedAddCommGroup y : E v : Fin 0 → E ⊢ ↑(↑(ContinuousLinearMap.comp (↑(ContinuousLinearEquiv.mk (LinearIsometryEquiv.symm (continuousMultilinearCurryFin0 𝕜 E F)).toLinearEquiv)) (↑(continuousMultilinearCurryFin1 𝕜 E F) (p x 1))) y) v = ↑(↑(ContinuousMultilinearMap.curryLeft (p x (Nat.succ 0))) y) v [PROOFSTEP] change (p x 1) (snoc 0 y) = (p x 1) (cons y v) [GOAL] case h.e'_10.h.h.h.H 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F h : HasFTaylorSeriesUpToOn n f p s hn : 1 ≤ n hx : x ∈ s A : ∀ (y : E), y ∈ s → f y = ↑(continuousMultilinearCurryFin0 𝕜 E F) (p y 0) this : ↑0 < n e_7✝ : ContinuousMultilinearMap.normedAddCommGroup' = ContinuousMultilinearMap.normedAddCommGroup y : E v : Fin 0 → E ⊢ ↑(p x 1) (snoc 0 y) = ↑(p x 1) (cons y v) [PROOFSTEP] congr with i [GOAL] case h.e'_10.h.h.h.H.h.e_6.h.h 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F h : HasFTaylorSeriesUpToOn n f p s hn : 1 ≤ n hx : x ∈ s A : ∀ (y : E), y ∈ s → f y = ↑(continuousMultilinearCurryFin0 𝕜 E F) (p y 0) this : ↑0 < n e_7✝ : ContinuousMultilinearMap.normedAddCommGroup' = ContinuousMultilinearMap.normedAddCommGroup y : E v : Fin 0 → E i : Fin (0 + 1) ⊢ snoc 0 y i = cons y v i [PROOFSTEP] rw [Unique.eq_default (α := Fin 1) i] [GOAL] case h.e'_10.h.h.h.H.h.e_6.h.h 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F h : HasFTaylorSeriesUpToOn n f p s hn : 1 ≤ n hx : x ∈ s A : ∀ (y : E), y ∈ s → f y = ↑(continuousMultilinearCurryFin0 𝕜 E F) (p y 0) this : ↑0 < n e_7✝ : ContinuousMultilinearMap.normedAddCommGroup' = ContinuousMultilinearMap.normedAddCommGroup y : E v : Fin 0 → E i : Fin (0 + 1) ⊢ snoc 0 y default = cons y v default [PROOFSTEP] rfl [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ ⊢ HasFTaylorSeriesUpToOn (↑n + 1) f p s ↔ HasFTaylorSeriesUpToOn (↑n) f p s ∧ (∀ (x : E), x ∈ s → HasFDerivWithinAt (fun y => p y n) (ContinuousMultilinearMap.curryLeft (p x (Nat.succ n))) s x) ∧ ContinuousOn (fun x => p x (n + 1)) s [PROOFSTEP] constructor [GOAL] case mp 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ ⊢ HasFTaylorSeriesUpToOn (↑n + 1) f p s → HasFTaylorSeriesUpToOn (↑n) f p s ∧ (∀ (x : E), x ∈ s → HasFDerivWithinAt (fun y => p y n) (ContinuousMultilinearMap.curryLeft (p x (Nat.succ n))) s x) ∧ ContinuousOn (fun x => p x (n + 1)) s [PROOFSTEP] exact fun h ↦ ⟨h.of_le (WithTop.coe_le_coe.2 (Nat.le_succ n)), h.fderivWithin _ (WithTop.coe_lt_coe.2 (lt_add_one n)), h.cont (n + 1) le_rfl⟩ [GOAL] case mpr 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ ⊢ HasFTaylorSeriesUpToOn (↑n) f p s ∧ (∀ (x : E), x ∈ s → HasFDerivWithinAt (fun y => p y n) (ContinuousMultilinearMap.curryLeft (p x (Nat.succ n))) s x) ∧ ContinuousOn (fun x => p x (n + 1)) s → HasFTaylorSeriesUpToOn (↑n + 1) f p s [PROOFSTEP] intro h [GOAL] case mpr 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ h : HasFTaylorSeriesUpToOn (↑n) f p s ∧ (∀ (x : E), x ∈ s → HasFDerivWithinAt (fun y => p y n) (ContinuousMultilinearMap.curryLeft (p x (Nat.succ n))) s x) ∧ ContinuousOn (fun x => p x (n + 1)) s ⊢ HasFTaylorSeriesUpToOn (↑n + 1) f p s [PROOFSTEP] constructor [GOAL] case mpr.zero_eq 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ h : HasFTaylorSeriesUpToOn (↑n) f p s ∧ (∀ (x : E), x ∈ s → HasFDerivWithinAt (fun y => p y n) (ContinuousMultilinearMap.curryLeft (p x (Nat.succ n))) s x) ∧ ContinuousOn (fun x => p x (n + 1)) s ⊢ ∀ (x : E), x ∈ s → ContinuousMultilinearMap.uncurry0 (p x 0) = f x [PROOFSTEP] exact h.1.zero_eq [GOAL] case mpr.fderivWithin 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ h : HasFTaylorSeriesUpToOn (↑n) f p s ∧ (∀ (x : E), x ∈ s → HasFDerivWithinAt (fun y => p y n) (ContinuousMultilinearMap.curryLeft (p x (Nat.succ n))) s x) ∧ ContinuousOn (fun x => p x (n + 1)) s ⊢ ∀ (m : ℕ), ↑m < ↑n + 1 → ∀ (x : E), x ∈ s → HasFDerivWithinAt (fun x => p x m) (ContinuousMultilinearMap.curryLeft (p x (Nat.succ m))) s x [PROOFSTEP] intro m hm [GOAL] case mpr.fderivWithin 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m✝ n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ h : HasFTaylorSeriesUpToOn (↑n) f p s ∧ (∀ (x : E), x ∈ s → HasFDerivWithinAt (fun y => p y n) (ContinuousMultilinearMap.curryLeft (p x (Nat.succ n))) s x) ∧ ContinuousOn (fun x => p x (n + 1)) s m : ℕ hm : ↑m < ↑n + 1 ⊢ ∀ (x : E), x ∈ s → HasFDerivWithinAt (fun x => p x m) (ContinuousMultilinearMap.curryLeft (p x (Nat.succ m))) s x [PROOFSTEP] by_cases h' : m < n [GOAL] case pos 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m✝ n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ h : HasFTaylorSeriesUpToOn (↑n) f p s ∧ (∀ (x : E), x ∈ s → HasFDerivWithinAt (fun y => p y n) (ContinuousMultilinearMap.curryLeft (p x (Nat.succ n))) s x) ∧ ContinuousOn (fun x => p x (n + 1)) s m : ℕ hm : ↑m < ↑n + 1 h' : m < n ⊢ ∀ (x : E), x ∈ s → HasFDerivWithinAt (fun x => p x m) (ContinuousMultilinearMap.curryLeft (p x (Nat.succ m))) s x [PROOFSTEP] exact h.1.fderivWithin m (WithTop.coe_lt_coe.2 h') [GOAL] case neg 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m✝ n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ h : HasFTaylorSeriesUpToOn (↑n) f p s ∧ (∀ (x : E), x ∈ s → HasFDerivWithinAt (fun y => p y n) (ContinuousMultilinearMap.curryLeft (p x (Nat.succ n))) s x) ∧ ContinuousOn (fun x => p x (n + 1)) s m : ℕ hm : ↑m < ↑n + 1 h' : ¬m < n ⊢ ∀ (x : E), x ∈ s → HasFDerivWithinAt (fun x => p x m) (ContinuousMultilinearMap.curryLeft (p x (Nat.succ m))) s x [PROOFSTEP] have : m = n := Nat.eq_of_lt_succ_of_not_lt (WithTop.coe_lt_coe.1 hm) h' [GOAL] case neg 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m✝ n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ h : HasFTaylorSeriesUpToOn (↑n) f p s ∧ (∀ (x : E), x ∈ s → HasFDerivWithinAt (fun y => p y n) (ContinuousMultilinearMap.curryLeft (p x (Nat.succ n))) s x) ∧ ContinuousOn (fun x => p x (n + 1)) s m : ℕ hm : ↑m < ↑n + 1 h' : ¬m < n this : m = n ⊢ ∀ (x : E), x ∈ s → HasFDerivWithinAt (fun x => p x m) (ContinuousMultilinearMap.curryLeft (p x (Nat.succ m))) s x [PROOFSTEP] rw [this] [GOAL] case neg 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m✝ n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ h : HasFTaylorSeriesUpToOn (↑n) f p s ∧ (∀ (x : E), x ∈ s → HasFDerivWithinAt (fun y => p y n) (ContinuousMultilinearMap.curryLeft (p x (Nat.succ n))) s x) ∧ ContinuousOn (fun x => p x (n + 1)) s m : ℕ hm : ↑m < ↑n + 1 h' : ¬m < n this : m = n ⊢ ∀ (x : E), x ∈ s → HasFDerivWithinAt (fun x => p x n) (ContinuousMultilinearMap.curryLeft (p x (Nat.succ n))) s x [PROOFSTEP] exact h.2.1 [GOAL] case mpr.cont 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ h : HasFTaylorSeriesUpToOn (↑n) f p s ∧ (∀ (x : E), x ∈ s → HasFDerivWithinAt (fun y => p y n) (ContinuousMultilinearMap.curryLeft (p x (Nat.succ n))) s x) ∧ ContinuousOn (fun x => p x (n + 1)) s ⊢ ∀ (m : ℕ), ↑m ≤ ↑n + 1 → ContinuousOn (fun x => p x m) s [PROOFSTEP] intro m hm [GOAL] case mpr.cont 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m✝ n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ h : HasFTaylorSeriesUpToOn (↑n) f p s ∧ (∀ (x : E), x ∈ s → HasFDerivWithinAt (fun y => p y n) (ContinuousMultilinearMap.curryLeft (p x (Nat.succ n))) s x) ∧ ContinuousOn (fun x => p x (n + 1)) s m : ℕ hm : ↑m ≤ ↑n + 1 ⊢ ContinuousOn (fun x => p x m) s [PROOFSTEP] by_cases h' : m ≤ n [GOAL] case pos 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m✝ n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ h : HasFTaylorSeriesUpToOn (↑n) f p s ∧ (∀ (x : E), x ∈ s → HasFDerivWithinAt (fun y => p y n) (ContinuousMultilinearMap.curryLeft (p x (Nat.succ n))) s x) ∧ ContinuousOn (fun x => p x (n + 1)) s m : ℕ hm : ↑m ≤ ↑n + 1 h' : m ≤ n ⊢ ContinuousOn (fun x => p x m) s [PROOFSTEP] apply h.1.cont m (WithTop.coe_le_coe.2 h') [GOAL] case neg 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m✝ n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ h : HasFTaylorSeriesUpToOn (↑n) f p s ∧ (∀ (x : E), x ∈ s → HasFDerivWithinAt (fun y => p y n) (ContinuousMultilinearMap.curryLeft (p x (Nat.succ n))) s x) ∧ ContinuousOn (fun x => p x (n + 1)) s m : ℕ hm : ↑m ≤ ↑n + 1 h' : ¬m ≤ n ⊢ ContinuousOn (fun x => p x m) s [PROOFSTEP] have : m = n + 1 := le_antisymm (WithTop.coe_le_coe.1 hm) (not_le.1 h') [GOAL] case neg 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m✝ n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ h : HasFTaylorSeriesUpToOn (↑n) f p s ∧ (∀ (x : E), x ∈ s → HasFDerivWithinAt (fun y => p y n) (ContinuousMultilinearMap.curryLeft (p x (Nat.succ n))) s x) ∧ ContinuousOn (fun x => p x (n + 1)) s m : ℕ hm : ↑m ≤ ↑n + 1 h' : ¬m ≤ n this : m = n + 1 ⊢ ContinuousOn (fun x => p x m) s [PROOFSTEP] rw [this] [GOAL] case neg 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m✝ n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ h : HasFTaylorSeriesUpToOn (↑n) f p s ∧ (∀ (x : E), x ∈ s → HasFDerivWithinAt (fun y => p y n) (ContinuousMultilinearMap.curryLeft (p x (Nat.succ n))) s x) ∧ ContinuousOn (fun x => p x (n + 1)) s m : ℕ hm : ↑m ≤ ↑n + 1 h' : ¬m ≤ n this : m = n + 1 ⊢ ContinuousOn (fun x => p x (n + 1)) s [PROOFSTEP] exact h.2.2 [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ H : HasFTaylorSeriesUpToOn (↑(n + 1)) f p s ⊢ HasFTaylorSeriesUpToOn (↑n) (fun x => ↑(continuousMultilinearCurryFin1 𝕜 E F) (p x 1)) (fun x => FormalMultilinearSeries.shift (p x)) s [PROOFSTEP] constructor [GOAL] case zero_eq 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ H : HasFTaylorSeriesUpToOn (↑(n + 1)) f p s ⊢ ∀ (x : E), x ∈ s → ContinuousMultilinearMap.uncurry0 (FormalMultilinearSeries.shift (p x) 0) = ↑(continuousMultilinearCurryFin1 𝕜 E F) (p x 1) [PROOFSTEP] intro x _ [GOAL] case zero_eq 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ H : HasFTaylorSeriesUpToOn (↑(n + 1)) f p s x : E a✝ : x ∈ s ⊢ ContinuousMultilinearMap.uncurry0 (FormalMultilinearSeries.shift (p x) 0) = ↑(continuousMultilinearCurryFin1 𝕜 E F) (p x 1) [PROOFSTEP] rfl [GOAL] case fderivWithin 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ H : HasFTaylorSeriesUpToOn (↑(n + 1)) f p s ⊢ ∀ (m : ℕ), ↑m < ↑n → ∀ (x : E), x ∈ s → HasFDerivWithinAt (fun x => FormalMultilinearSeries.shift (p x) m) (ContinuousMultilinearMap.curryLeft (FormalMultilinearSeries.shift (p x) (Nat.succ m))) s x [PROOFSTEP] intro m (hm : (m : ℕ∞) < n) x (hx : x ∈ s) [GOAL] case fderivWithin 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝ n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ H : HasFTaylorSeriesUpToOn (↑(n + 1)) f p s m : ℕ hm : ↑m < ↑n x : E hx : x ∈ s ⊢ HasFDerivWithinAt (fun x => FormalMultilinearSeries.shift (p x) m) (ContinuousMultilinearMap.curryLeft (FormalMultilinearSeries.shift (p x) (Nat.succ m))) s x [PROOFSTEP] have A : (m.succ : ℕ∞) < n.succ [GOAL] case A 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝ n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ H : HasFTaylorSeriesUpToOn (↑(n + 1)) f p s m : ℕ hm : ↑m < ↑n x : E hx : x ∈ s ⊢ ↑(Nat.succ m) < ↑(Nat.succ n) [PROOFSTEP] rw [Nat.cast_lt] at hm ⊢ [GOAL] case A 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝ n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ H : HasFTaylorSeriesUpToOn (↑(n + 1)) f p s m : ℕ hm : m < n x : E hx : x ∈ s ⊢ Nat.succ m < Nat.succ n [PROOFSTEP] exact Nat.succ_lt_succ hm [GOAL] case fderivWithin 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝ n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ H : HasFTaylorSeriesUpToOn (↑(n + 1)) f p s m : ℕ hm : ↑m < ↑n x : E hx : x ∈ s A : ↑(Nat.succ m) < ↑(Nat.succ n) ⊢ HasFDerivWithinAt (fun x => FormalMultilinearSeries.shift (p x) m) (ContinuousMultilinearMap.curryLeft (FormalMultilinearSeries.shift (p x) (Nat.succ m))) s x [PROOFSTEP] change HasFDerivWithinAt ((continuousMultilinearCurryRightEquiv' 𝕜 m E F).symm ∘ (p · m.succ)) (p x m.succ.succ).curryRight.curryLeft s x [GOAL] case fderivWithin 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝ n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ H : HasFTaylorSeriesUpToOn (↑(n + 1)) f p s m : ℕ hm : ↑m < ↑n x : E hx : x ∈ s A : ↑(Nat.succ m) < ↑(Nat.succ n) ⊢ HasFDerivWithinAt (↑(LinearIsometryEquiv.symm (continuousMultilinearCurryRightEquiv' 𝕜 m E F)) ∘ fun x => p x (Nat.succ m)) (ContinuousMultilinearMap.curryLeft (ContinuousMultilinearMap.curryRight (p x (Nat.succ (Nat.succ m))))) s x [PROOFSTEP] rw [((continuousMultilinearCurryRightEquiv' 𝕜 m E F).symm).comp_hasFDerivWithinAt_iff'] [GOAL] case fderivWithin 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝ n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ H : HasFTaylorSeriesUpToOn (↑(n + 1)) f p s m : ℕ hm : ↑m < ↑n x : E hx : x ∈ s A : ↑(Nat.succ m) < ↑(Nat.succ n) ⊢ HasFDerivWithinAt (fun x => p x (Nat.succ m)) (ContinuousLinearMap.comp (↑(ContinuousLinearEquiv.mk (LinearIsometryEquiv.symm (LinearIsometryEquiv.symm (continuousMultilinearCurryRightEquiv' 𝕜 m E F))).toLinearEquiv)) (ContinuousMultilinearMap.curryLeft (ContinuousMultilinearMap.curryRight (p x (Nat.succ (Nat.succ m)))))) s x [PROOFSTEP] convert H.fderivWithin _ A x hx [GOAL] case h.e'_10.h.h 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝ n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ H : HasFTaylorSeriesUpToOn (↑(n + 1)) f p s m : ℕ hm : ↑m < ↑n x : E hx : x ∈ s A : ↑(Nat.succ m) < ↑(Nat.succ n) e_7✝ : ContinuousMultilinearMap.normedAddCommGroup' = ContinuousMultilinearMap.normedAddCommGroup ⊢ ContinuousLinearMap.comp (↑(ContinuousLinearEquiv.mk (LinearIsometryEquiv.symm (LinearIsometryEquiv.symm (continuousMultilinearCurryRightEquiv' 𝕜 m E F))).toLinearEquiv)) (ContinuousMultilinearMap.curryLeft (ContinuousMultilinearMap.curryRight (p x (Nat.succ (Nat.succ m))))) = ContinuousMultilinearMap.curryLeft (p x (Nat.succ (Nat.succ m))) [PROOFSTEP] ext y v [GOAL] case h.e'_10.h.h.h.H 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝ n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ H : HasFTaylorSeriesUpToOn (↑(n + 1)) f p s m : ℕ hm : ↑m < ↑n x : E hx : x ∈ s A : ↑(Nat.succ m) < ↑(Nat.succ n) e_7✝ : ContinuousMultilinearMap.normedAddCommGroup' = ContinuousMultilinearMap.normedAddCommGroup y : E v : Fin (Nat.succ m) → E ⊢ ↑(↑(ContinuousLinearMap.comp (↑(ContinuousLinearEquiv.mk (LinearIsometryEquiv.symm (LinearIsometryEquiv.symm (continuousMultilinearCurryRightEquiv' 𝕜 m E F))).toLinearEquiv)) (ContinuousMultilinearMap.curryLeft (ContinuousMultilinearMap.curryRight (p x (Nat.succ (Nat.succ m)))))) y) v = ↑(↑(ContinuousMultilinearMap.curryLeft (p x (Nat.succ (Nat.succ m)))) y) v [PROOFSTEP] change p x (m + 2) (snoc (cons y (init v)) (v (last _))) = p x (m + 2) (cons y v) [GOAL] case h.e'_10.h.h.h.H 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝ n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ H : HasFTaylorSeriesUpToOn (↑(n + 1)) f p s m : ℕ hm : ↑m < ↑n x : E hx : x ∈ s A : ↑(Nat.succ m) < ↑(Nat.succ n) e_7✝ : ContinuousMultilinearMap.normedAddCommGroup' = ContinuousMultilinearMap.normedAddCommGroup y : E v : Fin (Nat.succ m) → E ⊢ ↑(p x (m + 2)) (snoc (cons y (init v)) (v (last m))) = ↑(p x (m + 2)) (cons y v) [PROOFSTEP] rw [← cons_snoc_eq_snoc_cons, snoc_init_self] [GOAL] case cont 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ H : HasFTaylorSeriesUpToOn (↑(n + 1)) f p s ⊢ ∀ (m : ℕ), ↑m ≤ ↑n → ContinuousOn (fun x => FormalMultilinearSeries.shift (p x) m) s [PROOFSTEP] intro m (hm : (m : ℕ∞) ≤ n) [GOAL] case cont 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m✝ n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ H : HasFTaylorSeriesUpToOn (↑(n + 1)) f p s m : ℕ hm : ↑m ≤ ↑n ⊢ ContinuousOn (fun x => FormalMultilinearSeries.shift (p x) m) s [PROOFSTEP] suffices A : ContinuousOn (p · (m + 1)) s [GOAL] case cont 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m✝ n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ H : HasFTaylorSeriesUpToOn (↑(n + 1)) f p s m : ℕ hm : ↑m ≤ ↑n A : ContinuousOn (fun x => p x (m + 1)) s ⊢ ContinuousOn (fun x => FormalMultilinearSeries.shift (p x) m) s [PROOFSTEP] exact ((continuousMultilinearCurryRightEquiv' 𝕜 m E F).symm).continuous.comp_continuousOn A [GOAL] case A 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m✝ n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ H : HasFTaylorSeriesUpToOn (↑(n + 1)) f p s m : ℕ hm : ↑m ≤ ↑n ⊢ ContinuousOn (fun x => p x (m + 1)) s [PROOFSTEP] refine H.cont _ ?_ [GOAL] case A 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m✝ n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ H : HasFTaylorSeriesUpToOn (↑(n + 1)) f p s m : ℕ hm : ↑m ≤ ↑n ⊢ ↑(m + 1) ≤ ↑(n + 1) [PROOFSTEP] rw [Nat.cast_le] at hm ⊢ [GOAL] case A 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m✝ n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ H : HasFTaylorSeriesUpToOn (↑(n + 1)) f p s m : ℕ hm : m ≤ n ⊢ m + 1 ≤ n + 1 [PROOFSTEP] exact Nat.succ_le_succ hm [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ ⊢ HasFTaylorSeriesUpToOn (↑(n + 1)) f p s ↔ (∀ (x : E), x ∈ s → ContinuousMultilinearMap.uncurry0 (p x 0) = f x) ∧ (∀ (x : E), x ∈ s → HasFDerivWithinAt (fun y => p y 0) (ContinuousMultilinearMap.curryLeft (p x 1)) s x) ∧ HasFTaylorSeriesUpToOn (↑n) (fun x => ↑(continuousMultilinearCurryFin1 𝕜 E F) (p x 1)) (fun x => FormalMultilinearSeries.shift (p x)) s [PROOFSTEP] constructor [GOAL] case mp 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ ⊢ HasFTaylorSeriesUpToOn (↑(n + 1)) f p s → (∀ (x : E), x ∈ s → ContinuousMultilinearMap.uncurry0 (p x 0) = f x) ∧ (∀ (x : E), x ∈ s → HasFDerivWithinAt (fun y => p y 0) (ContinuousMultilinearMap.curryLeft (p x 1)) s x) ∧ HasFTaylorSeriesUpToOn (↑n) (fun x => ↑(continuousMultilinearCurryFin1 𝕜 E F) (p x 1)) (fun x => FormalMultilinearSeries.shift (p x)) s [PROOFSTEP] intro H [GOAL] case mp 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ H : HasFTaylorSeriesUpToOn (↑(n + 1)) f p s ⊢ (∀ (x : E), x ∈ s → ContinuousMultilinearMap.uncurry0 (p x 0) = f x) ∧ (∀ (x : E), x ∈ s → HasFDerivWithinAt (fun y => p y 0) (ContinuousMultilinearMap.curryLeft (p x 1)) s x) ∧ HasFTaylorSeriesUpToOn (↑n) (fun x => ↑(continuousMultilinearCurryFin1 𝕜 E F) (p x 1)) (fun x => FormalMultilinearSeries.shift (p x)) s [PROOFSTEP] refine' ⟨H.zero_eq, H.fderivWithin 0 (Nat.cast_lt.2 (Nat.succ_pos n)), _⟩ [GOAL] case mp 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ H : HasFTaylorSeriesUpToOn (↑(n + 1)) f p s ⊢ HasFTaylorSeriesUpToOn (↑n) (fun x => ↑(continuousMultilinearCurryFin1 𝕜 E F) (p x 1)) (fun x => FormalMultilinearSeries.shift (p x)) s [PROOFSTEP] exact H.shift_of_succ [GOAL] case mpr 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ ⊢ (∀ (x : E), x ∈ s → ContinuousMultilinearMap.uncurry0 (p x 0) = f x) ∧ (∀ (x : E), x ∈ s → HasFDerivWithinAt (fun y => p y 0) (ContinuousMultilinearMap.curryLeft (p x 1)) s x) ∧ HasFTaylorSeriesUpToOn (↑n) (fun x => ↑(continuousMultilinearCurryFin1 𝕜 E F) (p x 1)) (fun x => FormalMultilinearSeries.shift (p x)) s → HasFTaylorSeriesUpToOn (↑(n + 1)) f p s [PROOFSTEP] rintro ⟨Hzero_eq, Hfderiv_zero, Htaylor⟩ [GOAL] case mpr.intro.intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ Hzero_eq : ∀ (x : E), x ∈ s → ContinuousMultilinearMap.uncurry0 (p x 0) = f x Hfderiv_zero : ∀ (x : E), x ∈ s → HasFDerivWithinAt (fun y => p y 0) (ContinuousMultilinearMap.curryLeft (p x 1)) s x Htaylor : HasFTaylorSeriesUpToOn (↑n) (fun x => ↑(continuousMultilinearCurryFin1 𝕜 E F) (p x 1)) (fun x => FormalMultilinearSeries.shift (p x)) s ⊢ HasFTaylorSeriesUpToOn (↑(n + 1)) f p s [PROOFSTEP] constructor [GOAL] case mpr.intro.intro.zero_eq 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ Hzero_eq : ∀ (x : E), x ∈ s → ContinuousMultilinearMap.uncurry0 (p x 0) = f x Hfderiv_zero : ∀ (x : E), x ∈ s → HasFDerivWithinAt (fun y => p y 0) (ContinuousMultilinearMap.curryLeft (p x 1)) s x Htaylor : HasFTaylorSeriesUpToOn (↑n) (fun x => ↑(continuousMultilinearCurryFin1 𝕜 E F) (p x 1)) (fun x => FormalMultilinearSeries.shift (p x)) s ⊢ ∀ (x : E), x ∈ s → ContinuousMultilinearMap.uncurry0 (p x 0) = f x [PROOFSTEP] exact Hzero_eq [GOAL] case mpr.intro.intro.fderivWithin 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ Hzero_eq : ∀ (x : E), x ∈ s → ContinuousMultilinearMap.uncurry0 (p x 0) = f x Hfderiv_zero : ∀ (x : E), x ∈ s → HasFDerivWithinAt (fun y => p y 0) (ContinuousMultilinearMap.curryLeft (p x 1)) s x Htaylor : HasFTaylorSeriesUpToOn (↑n) (fun x => ↑(continuousMultilinearCurryFin1 𝕜 E F) (p x 1)) (fun x => FormalMultilinearSeries.shift (p x)) s ⊢ ∀ (m : ℕ), ↑m < ↑(n + 1) → ∀ (x : E), x ∈ s → HasFDerivWithinAt (fun x => p x m) (ContinuousMultilinearMap.curryLeft (p x (Nat.succ m))) s x [PROOFSTEP] intro m (hm : (m : ℕ∞) < n.succ) x (hx : x ∈ s) [GOAL] case mpr.intro.intro.fderivWithin 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝ n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ Hzero_eq : ∀ (x : E), x ∈ s → ContinuousMultilinearMap.uncurry0 (p x 0) = f x Hfderiv_zero : ∀ (x : E), x ∈ s → HasFDerivWithinAt (fun y => p y 0) (ContinuousMultilinearMap.curryLeft (p x 1)) s x Htaylor : HasFTaylorSeriesUpToOn (↑n) (fun x => ↑(continuousMultilinearCurryFin1 𝕜 E F) (p x 1)) (fun x => FormalMultilinearSeries.shift (p x)) s m : ℕ hm : ↑m < ↑(Nat.succ n) x : E hx : x ∈ s ⊢ HasFDerivWithinAt (fun x => p x m) (ContinuousMultilinearMap.curryLeft (p x (Nat.succ m))) s x [PROOFSTEP] cases' m with m [GOAL] case mpr.intro.intro.fderivWithin.zero 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ Hzero_eq : ∀ (x : E), x ∈ s → ContinuousMultilinearMap.uncurry0 (p x 0) = f x Hfderiv_zero : ∀ (x : E), x ∈ s → HasFDerivWithinAt (fun y => p y 0) (ContinuousMultilinearMap.curryLeft (p x 1)) s x Htaylor : HasFTaylorSeriesUpToOn (↑n) (fun x => ↑(continuousMultilinearCurryFin1 𝕜 E F) (p x 1)) (fun x => FormalMultilinearSeries.shift (p x)) s x : E hx : x ∈ s hm : ↑Nat.zero < ↑(Nat.succ n) ⊢ HasFDerivWithinAt (fun x => p x Nat.zero) (ContinuousMultilinearMap.curryLeft (p x (Nat.succ Nat.zero))) s x [PROOFSTEP] exact Hfderiv_zero x hx [GOAL] case mpr.intro.intro.fderivWithin.succ 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝ n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ Hzero_eq : ∀ (x : E), x ∈ s → ContinuousMultilinearMap.uncurry0 (p x 0) = f x Hfderiv_zero : ∀ (x : E), x ∈ s → HasFDerivWithinAt (fun y => p y 0) (ContinuousMultilinearMap.curryLeft (p x 1)) s x Htaylor : HasFTaylorSeriesUpToOn (↑n) (fun x => ↑(continuousMultilinearCurryFin1 𝕜 E F) (p x 1)) (fun x => FormalMultilinearSeries.shift (p x)) s x : E hx : x ∈ s m : ℕ hm : ↑(Nat.succ m) < ↑(Nat.succ n) ⊢ HasFDerivWithinAt (fun x => p x (Nat.succ m)) (ContinuousMultilinearMap.curryLeft (p x (Nat.succ (Nat.succ m)))) s x [PROOFSTEP] have A : (m : ℕ∞) < n := by rw [Nat.cast_lt] at hm ⊢ exact Nat.lt_of_succ_lt_succ hm [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝ n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ Hzero_eq : ∀ (x : E), x ∈ s → ContinuousMultilinearMap.uncurry0 (p x 0) = f x Hfderiv_zero : ∀ (x : E), x ∈ s → HasFDerivWithinAt (fun y => p y 0) (ContinuousMultilinearMap.curryLeft (p x 1)) s x Htaylor : HasFTaylorSeriesUpToOn (↑n) (fun x => ↑(continuousMultilinearCurryFin1 𝕜 E F) (p x 1)) (fun x => FormalMultilinearSeries.shift (p x)) s x : E hx : x ∈ s m : ℕ hm : ↑(Nat.succ m) < ↑(Nat.succ n) ⊢ ↑m < ↑n [PROOFSTEP] rw [Nat.cast_lt] at hm ⊢ [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝ n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ Hzero_eq : ∀ (x : E), x ∈ s → ContinuousMultilinearMap.uncurry0 (p x 0) = f x Hfderiv_zero : ∀ (x : E), x ∈ s → HasFDerivWithinAt (fun y => p y 0) (ContinuousMultilinearMap.curryLeft (p x 1)) s x Htaylor : HasFTaylorSeriesUpToOn (↑n) (fun x => ↑(continuousMultilinearCurryFin1 𝕜 E F) (p x 1)) (fun x => FormalMultilinearSeries.shift (p x)) s x : E hx : x ∈ s m : ℕ hm : Nat.succ m < Nat.succ n ⊢ m < n [PROOFSTEP] exact Nat.lt_of_succ_lt_succ hm [GOAL] case mpr.intro.intro.fderivWithin.succ 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝ n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ Hzero_eq : ∀ (x : E), x ∈ s → ContinuousMultilinearMap.uncurry0 (p x 0) = f x Hfderiv_zero : ∀ (x : E), x ∈ s → HasFDerivWithinAt (fun y => p y 0) (ContinuousMultilinearMap.curryLeft (p x 1)) s x Htaylor : HasFTaylorSeriesUpToOn (↑n) (fun x => ↑(continuousMultilinearCurryFin1 𝕜 E F) (p x 1)) (fun x => FormalMultilinearSeries.shift (p x)) s x : E hx : x ∈ s m : ℕ hm : ↑(Nat.succ m) < ↑(Nat.succ n) A : ↑m < ↑n ⊢ HasFDerivWithinAt (fun x => p x (Nat.succ m)) (ContinuousMultilinearMap.curryLeft (p x (Nat.succ (Nat.succ m)))) s x [PROOFSTEP] have : HasFDerivWithinAt ((continuousMultilinearCurryRightEquiv' 𝕜 m E F).symm ∘ (p · m.succ)) ((p x).shift m.succ).curryLeft s x := Htaylor.fderivWithin _ A x hx [GOAL] case mpr.intro.intro.fderivWithin.succ 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝ n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ Hzero_eq : ∀ (x : E), x ∈ s → ContinuousMultilinearMap.uncurry0 (p x 0) = f x Hfderiv_zero : ∀ (x : E), x ∈ s → HasFDerivWithinAt (fun y => p y 0) (ContinuousMultilinearMap.curryLeft (p x 1)) s x Htaylor : HasFTaylorSeriesUpToOn (↑n) (fun x => ↑(continuousMultilinearCurryFin1 𝕜 E F) (p x 1)) (fun x => FormalMultilinearSeries.shift (p x)) s x : E hx : x ∈ s m : ℕ hm : ↑(Nat.succ m) < ↑(Nat.succ n) A : ↑m < ↑n this : HasFDerivWithinAt (↑(LinearIsometryEquiv.symm (continuousMultilinearCurryRightEquiv' 𝕜 m E F)) ∘ fun x => p x (Nat.succ m)) (ContinuousMultilinearMap.curryLeft (FormalMultilinearSeries.shift (p x) (Nat.succ m))) s x ⊢ HasFDerivWithinAt (fun x => p x (Nat.succ m)) (ContinuousMultilinearMap.curryLeft (p x (Nat.succ (Nat.succ m)))) s x [PROOFSTEP] rw [LinearIsometryEquiv.comp_hasFDerivWithinAt_iff'] at this [GOAL] case mpr.intro.intro.fderivWithin.succ 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝ n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ Hzero_eq : ∀ (x : E), x ∈ s → ContinuousMultilinearMap.uncurry0 (p x 0) = f x Hfderiv_zero : ∀ (x : E), x ∈ s → HasFDerivWithinAt (fun y => p y 0) (ContinuousMultilinearMap.curryLeft (p x 1)) s x Htaylor : HasFTaylorSeriesUpToOn (↑n) (fun x => ↑(continuousMultilinearCurryFin1 𝕜 E F) (p x 1)) (fun x => FormalMultilinearSeries.shift (p x)) s x : E hx : x ∈ s m : ℕ hm : ↑(Nat.succ m) < ↑(Nat.succ n) A : ↑m < ↑n this : HasFDerivWithinAt (fun x => p x (Nat.succ m)) (ContinuousLinearMap.comp (↑(ContinuousLinearEquiv.mk (LinearIsometryEquiv.symm (LinearIsometryEquiv.symm (continuousMultilinearCurryRightEquiv' 𝕜 m E F))).toLinearEquiv)) (ContinuousMultilinearMap.curryLeft (FormalMultilinearSeries.shift (p x) (Nat.succ m)))) s x ⊢ HasFDerivWithinAt (fun x => p x (Nat.succ m)) (ContinuousMultilinearMap.curryLeft (p x (Nat.succ (Nat.succ m)))) s x [PROOFSTEP] convert this [GOAL] case h.e'_10.h.h 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝ n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ Hzero_eq : ∀ (x : E), x ∈ s → ContinuousMultilinearMap.uncurry0 (p x 0) = f x Hfderiv_zero : ∀ (x : E), x ∈ s → HasFDerivWithinAt (fun y => p y 0) (ContinuousMultilinearMap.curryLeft (p x 1)) s x Htaylor : HasFTaylorSeriesUpToOn (↑n) (fun x => ↑(continuousMultilinearCurryFin1 𝕜 E F) (p x 1)) (fun x => FormalMultilinearSeries.shift (p x)) s x : E hx : x ∈ s m : ℕ hm : ↑(Nat.succ m) < ↑(Nat.succ n) A : ↑m < ↑n this : HasFDerivWithinAt (fun x => p x (Nat.succ m)) (ContinuousLinearMap.comp (↑(ContinuousLinearEquiv.mk (LinearIsometryEquiv.symm (LinearIsometryEquiv.symm (continuousMultilinearCurryRightEquiv' 𝕜 m E F))).toLinearEquiv)) (ContinuousMultilinearMap.curryLeft (FormalMultilinearSeries.shift (p x) (Nat.succ m)))) s x e_7✝ : ContinuousMultilinearMap.normedAddCommGroup = ContinuousMultilinearMap.normedAddCommGroup' ⊢ ContinuousMultilinearMap.curryLeft (p x (Nat.succ (Nat.succ m))) = ContinuousLinearMap.comp (↑(ContinuousLinearEquiv.mk (LinearIsometryEquiv.symm (LinearIsometryEquiv.symm (continuousMultilinearCurryRightEquiv' 𝕜 m E F))).toLinearEquiv)) (ContinuousMultilinearMap.curryLeft (FormalMultilinearSeries.shift (p x) (Nat.succ m))) [PROOFSTEP] ext y v [GOAL] case h.e'_10.h.h.h.H 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝ n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ Hzero_eq : ∀ (x : E), x ∈ s → ContinuousMultilinearMap.uncurry0 (p x 0) = f x Hfderiv_zero : ∀ (x : E), x ∈ s → HasFDerivWithinAt (fun y => p y 0) (ContinuousMultilinearMap.curryLeft (p x 1)) s x Htaylor : HasFTaylorSeriesUpToOn (↑n) (fun x => ↑(continuousMultilinearCurryFin1 𝕜 E F) (p x 1)) (fun x => FormalMultilinearSeries.shift (p x)) s x : E hx : x ∈ s m : ℕ hm : ↑(Nat.succ m) < ↑(Nat.succ n) A : ↑m < ↑n this : HasFDerivWithinAt (fun x => p x (Nat.succ m)) (ContinuousLinearMap.comp (↑(ContinuousLinearEquiv.mk (LinearIsometryEquiv.symm (LinearIsometryEquiv.symm (continuousMultilinearCurryRightEquiv' 𝕜 m E F))).toLinearEquiv)) (ContinuousMultilinearMap.curryLeft (FormalMultilinearSeries.shift (p x) (Nat.succ m)))) s x e_7✝ : ContinuousMultilinearMap.normedAddCommGroup = ContinuousMultilinearMap.normedAddCommGroup' y : E v : Fin (Nat.succ m) → E ⊢ ↑(↑(ContinuousMultilinearMap.curryLeft (p x (Nat.succ (Nat.succ m)))) y) v = ↑(↑(ContinuousLinearMap.comp (↑(ContinuousLinearEquiv.mk (LinearIsometryEquiv.symm (LinearIsometryEquiv.symm (continuousMultilinearCurryRightEquiv' 𝕜 m E F))).toLinearEquiv)) (ContinuousMultilinearMap.curryLeft (FormalMultilinearSeries.shift (p x) (Nat.succ m)))) y) v [PROOFSTEP] change (p x (Nat.succ (Nat.succ m))) (cons y v) = (p x m.succ.succ) (snoc (cons y (init v)) (v (last _))) [GOAL] case h.e'_10.h.h.h.H 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝ n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ Hzero_eq : ∀ (x : E), x ∈ s → ContinuousMultilinearMap.uncurry0 (p x 0) = f x Hfderiv_zero : ∀ (x : E), x ∈ s → HasFDerivWithinAt (fun y => p y 0) (ContinuousMultilinearMap.curryLeft (p x 1)) s x Htaylor : HasFTaylorSeriesUpToOn (↑n) (fun x => ↑(continuousMultilinearCurryFin1 𝕜 E F) (p x 1)) (fun x => FormalMultilinearSeries.shift (p x)) s x : E hx : x ∈ s m : ℕ hm : ↑(Nat.succ m) < ↑(Nat.succ n) A : ↑m < ↑n this : HasFDerivWithinAt (fun x => p x (Nat.succ m)) (ContinuousLinearMap.comp (↑(ContinuousLinearEquiv.mk (LinearIsometryEquiv.symm (LinearIsometryEquiv.symm (continuousMultilinearCurryRightEquiv' 𝕜 m E F))).toLinearEquiv)) (ContinuousMultilinearMap.curryLeft (FormalMultilinearSeries.shift (p x) (Nat.succ m)))) s x e_7✝ : ContinuousMultilinearMap.normedAddCommGroup = ContinuousMultilinearMap.normedAddCommGroup' y : E v : Fin (Nat.succ m) → E ⊢ ↑(p x (Nat.succ (Nat.succ m))) (cons y v) = ↑(p x (Nat.succ (Nat.succ m))) (snoc (cons y (init v)) (v (last m))) [PROOFSTEP] rw [← cons_snoc_eq_snoc_cons, snoc_init_self] [GOAL] case mpr.intro.intro.cont 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ Hzero_eq : ∀ (x : E), x ∈ s → ContinuousMultilinearMap.uncurry0 (p x 0) = f x Hfderiv_zero : ∀ (x : E), x ∈ s → HasFDerivWithinAt (fun y => p y 0) (ContinuousMultilinearMap.curryLeft (p x 1)) s x Htaylor : HasFTaylorSeriesUpToOn (↑n) (fun x => ↑(continuousMultilinearCurryFin1 𝕜 E F) (p x 1)) (fun x => FormalMultilinearSeries.shift (p x)) s ⊢ ∀ (m : ℕ), ↑m ≤ ↑(n + 1) → ContinuousOn (fun x => p x m) s [PROOFSTEP] intro m (hm : (m : ℕ∞) ≤ n.succ) [GOAL] case mpr.intro.intro.cont 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m✝ n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ Hzero_eq : ∀ (x : E), x ∈ s → ContinuousMultilinearMap.uncurry0 (p x 0) = f x Hfderiv_zero : ∀ (x : E), x ∈ s → HasFDerivWithinAt (fun y => p y 0) (ContinuousMultilinearMap.curryLeft (p x 1)) s x Htaylor : HasFTaylorSeriesUpToOn (↑n) (fun x => ↑(continuousMultilinearCurryFin1 𝕜 E F) (p x 1)) (fun x => FormalMultilinearSeries.shift (p x)) s m : ℕ hm : ↑m ≤ ↑(Nat.succ n) ⊢ ContinuousOn (fun x => p x m) s [PROOFSTEP] cases' m with m [GOAL] case mpr.intro.intro.cont.zero 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ Hzero_eq : ∀ (x : E), x ∈ s → ContinuousMultilinearMap.uncurry0 (p x 0) = f x Hfderiv_zero : ∀ (x : E), x ∈ s → HasFDerivWithinAt (fun y => p y 0) (ContinuousMultilinearMap.curryLeft (p x 1)) s x Htaylor : HasFTaylorSeriesUpToOn (↑n) (fun x => ↑(continuousMultilinearCurryFin1 𝕜 E F) (p x 1)) (fun x => FormalMultilinearSeries.shift (p x)) s hm : ↑Nat.zero ≤ ↑(Nat.succ n) ⊢ ContinuousOn (fun x => p x Nat.zero) s [PROOFSTEP] have : DifferentiableOn 𝕜 (fun x => p x 0) s := fun x hx => (Hfderiv_zero x hx).differentiableWithinAt [GOAL] case mpr.intro.intro.cont.zero 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ Hzero_eq : ∀ (x : E), x ∈ s → ContinuousMultilinearMap.uncurry0 (p x 0) = f x Hfderiv_zero : ∀ (x : E), x ∈ s → HasFDerivWithinAt (fun y => p y 0) (ContinuousMultilinearMap.curryLeft (p x 1)) s x Htaylor : HasFTaylorSeriesUpToOn (↑n) (fun x => ↑(continuousMultilinearCurryFin1 𝕜 E F) (p x 1)) (fun x => FormalMultilinearSeries.shift (p x)) s hm : ↑Nat.zero ≤ ↑(Nat.succ n) this : DifferentiableOn 𝕜 (fun x => p x 0) s ⊢ ContinuousOn (fun x => p x Nat.zero) s [PROOFSTEP] exact this.continuousOn [GOAL] case mpr.intro.intro.cont.succ 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m✝ n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ Hzero_eq : ∀ (x : E), x ∈ s → ContinuousMultilinearMap.uncurry0 (p x 0) = f x Hfderiv_zero : ∀ (x : E), x ∈ s → HasFDerivWithinAt (fun y => p y 0) (ContinuousMultilinearMap.curryLeft (p x 1)) s x Htaylor : HasFTaylorSeriesUpToOn (↑n) (fun x => ↑(continuousMultilinearCurryFin1 𝕜 E F) (p x 1)) (fun x => FormalMultilinearSeries.shift (p x)) s m : ℕ hm : ↑(Nat.succ m) ≤ ↑(Nat.succ n) ⊢ ContinuousOn (fun x => p x (Nat.succ m)) s [PROOFSTEP] refine (continuousMultilinearCurryRightEquiv' 𝕜 m E F).symm.comp_continuousOn_iff.mp ?_ [GOAL] case mpr.intro.intro.cont.succ 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m✝ n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ Hzero_eq : ∀ (x : E), x ∈ s → ContinuousMultilinearMap.uncurry0 (p x 0) = f x Hfderiv_zero : ∀ (x : E), x ∈ s → HasFDerivWithinAt (fun y => p y 0) (ContinuousMultilinearMap.curryLeft (p x 1)) s x Htaylor : HasFTaylorSeriesUpToOn (↑n) (fun x => ↑(continuousMultilinearCurryFin1 𝕜 E F) (p x 1)) (fun x => FormalMultilinearSeries.shift (p x)) s m : ℕ hm : ↑(Nat.succ m) ≤ ↑(Nat.succ n) ⊢ ContinuousOn (↑(LinearIsometryEquiv.symm (continuousMultilinearCurryRightEquiv' 𝕜 m E F)) ∘ fun x => p x (Nat.succ m)) s [PROOFSTEP] refine Htaylor.cont _ ?_ [GOAL] case mpr.intro.intro.cont.succ 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m✝ n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ Hzero_eq : ∀ (x : E), x ∈ s → ContinuousMultilinearMap.uncurry0 (p x 0) = f x Hfderiv_zero : ∀ (x : E), x ∈ s → HasFDerivWithinAt (fun y => p y 0) (ContinuousMultilinearMap.curryLeft (p x 1)) s x Htaylor : HasFTaylorSeriesUpToOn (↑n) (fun x => ↑(continuousMultilinearCurryFin1 𝕜 E F) (p x 1)) (fun x => FormalMultilinearSeries.shift (p x)) s m : ℕ hm : ↑(Nat.succ m) ≤ ↑(Nat.succ n) ⊢ ↑m ≤ ↑n [PROOFSTEP] rw [Nat.cast_le] at hm ⊢ [GOAL] case mpr.intro.intro.cont.succ 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m✝ n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ Hzero_eq : ∀ (x : E), x ∈ s → ContinuousMultilinearMap.uncurry0 (p x 0) = f x Hfderiv_zero : ∀ (x : E), x ∈ s → HasFDerivWithinAt (fun y => p y 0) (ContinuousMultilinearMap.curryLeft (p x 1)) s x Htaylor : HasFTaylorSeriesUpToOn (↑n) (fun x => ↑(continuousMultilinearCurryFin1 𝕜 E F) (p x 1)) (fun x => FormalMultilinearSeries.shift (p x)) s m : ℕ hm : Nat.succ m ≤ Nat.succ n ⊢ m ≤ n [PROOFSTEP] exact Nat.lt_succ_iff.mp hm [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F ⊢ (∀ (m : ℕ), ↑m ≤ ⊤ → ContDiffWithinAt 𝕜 (↑m) f s x) ↔ ∀ (n : ℕ), ContDiffWithinAt 𝕜 (↑n) f s x [PROOFSTEP] simp only [forall_prop_of_true, le_top] [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F h : ContDiffWithinAt 𝕜 n f s x ⊢ ContinuousWithinAt f s x [PROOFSTEP] rcases h 0 bot_le with ⟨u, hu, p, H⟩ [GOAL] case intro.intro.intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p✝ : E → FormalMultilinearSeries 𝕜 E F h : ContDiffWithinAt 𝕜 n f s x u : Set E hu : u ∈ 𝓝[insert x s] x p : E → FormalMultilinearSeries 𝕜 E F H : HasFTaylorSeriesUpToOn (↑0) f p u ⊢ ContinuousWithinAt f s x [PROOFSTEP] rw [mem_nhdsWithin_insert] at hu [GOAL] case intro.intro.intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p✝ : E → FormalMultilinearSeries 𝕜 E F h : ContDiffWithinAt 𝕜 n f s x u : Set E hu : x ∈ u ∧ u ∈ 𝓝[s] x p : E → FormalMultilinearSeries 𝕜 E F H : HasFTaylorSeriesUpToOn (↑0) f p u ⊢ ContinuousWithinAt f s x [PROOFSTEP] exact (H.continuousOn.continuousWithinAt hu.1).mono_of_mem hu.2 [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t✝ u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F h : ContDiffWithinAt 𝕜 n f s x t : Set E hst : s ∈ 𝓝[t] x ⊢ ContDiffWithinAt 𝕜 n f t x [PROOFSTEP] intro m hm [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t✝ u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m✝ n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F h : ContDiffWithinAt 𝕜 n f s x t : Set E hst : s ∈ 𝓝[t] x m : ℕ hm : ↑m ≤ n ⊢ ∃ u, u ∈ 𝓝[insert x t] x ∧ ∃ p, HasFTaylorSeriesUpToOn (↑m) f p u [PROOFSTEP] rcases h m hm with ⟨u, hu, p, H⟩ [GOAL] case intro.intro.intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t✝ u✝ : Set E f f₁ : E → F g : F → G x x₀ : E c : F m✝ n : ℕ∞ p✝ : E → FormalMultilinearSeries 𝕜 E F h : ContDiffWithinAt 𝕜 n f s x t : Set E hst : s ∈ 𝓝[t] x m : ℕ hm : ↑m ≤ n u : Set E hu : u ∈ 𝓝[insert x s] x p : E → FormalMultilinearSeries 𝕜 E F H : HasFTaylorSeriesUpToOn (↑m) f p u ⊢ ∃ u, u ∈ 𝓝[insert x t] x ∧ ∃ p, HasFTaylorSeriesUpToOn (↑m) f p u [PROOFSTEP] exact ⟨u, nhdsWithin_le_of_mem (insert_mem_nhdsWithin_insert hst) hu, p, H⟩ [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F ⊢ ContDiffWithinAt 𝕜 n f (insert x s) x ↔ ContDiffWithinAt 𝕜 n f s x [PROOFSTEP] simp_rw [ContDiffWithinAt, insert_idem] [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F y : E ⊢ ContDiffWithinAt 𝕜 n f (insert y s) x ↔ ContDiffWithinAt 𝕜 n f s x [PROOFSTEP] rcases eq_or_ne x y with (rfl | h) [GOAL] case inl 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F ⊢ ContDiffWithinAt 𝕜 n f (insert x s) x ↔ ContDiffWithinAt 𝕜 n f s x [PROOFSTEP] exact contDiffWithinAt_insert_self [GOAL] case inr 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F y : E h : x ≠ y ⊢ ContDiffWithinAt 𝕜 n f (insert y s) x ↔ ContDiffWithinAt 𝕜 n f s x [PROOFSTEP] simp_rw [ContDiffWithinAt, insert_comm x y, nhdsWithin_insert_of_ne h] [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F h : ContDiffWithinAt 𝕜 n f s x hn : 1 ≤ n ⊢ DifferentiableWithinAt 𝕜 f (insert x s) x [PROOFSTEP] rcases h 1 hn with ⟨u, hu, p, H⟩ [GOAL] case intro.intro.intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p✝ : E → FormalMultilinearSeries 𝕜 E F h : ContDiffWithinAt 𝕜 n f s x hn : 1 ≤ n u : Set E hu : u ∈ 𝓝[insert x s] x p : E → FormalMultilinearSeries 𝕜 E F H : HasFTaylorSeriesUpToOn (↑1) f p u ⊢ DifferentiableWithinAt 𝕜 f (insert x s) x [PROOFSTEP] rcases mem_nhdsWithin.1 hu with ⟨t, t_open, xt, tu⟩ [GOAL] case intro.intro.intro.intro.intro.intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t✝ u✝ : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p✝ : E → FormalMultilinearSeries 𝕜 E F h : ContDiffWithinAt 𝕜 n f s x hn : 1 ≤ n u : Set E hu : u ∈ 𝓝[insert x s] x p : E → FormalMultilinearSeries 𝕜 E F H : HasFTaylorSeriesUpToOn (↑1) f p u t : Set E t_open : IsOpen t xt : x ∈ t tu : t ∩ insert x s ⊆ u ⊢ DifferentiableWithinAt 𝕜 f (insert x s) x [PROOFSTEP] rw [inter_comm] at tu [GOAL] case intro.intro.intro.intro.intro.intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t✝ u✝ : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p✝ : E → FormalMultilinearSeries 𝕜 E F h : ContDiffWithinAt 𝕜 n f s x hn : 1 ≤ n u : Set E hu : u ∈ 𝓝[insert x s] x p : E → FormalMultilinearSeries 𝕜 E F H : HasFTaylorSeriesUpToOn (↑1) f p u t : Set E t_open : IsOpen t xt : x ∈ t tu : insert x s ∩ t ⊆ u ⊢ DifferentiableWithinAt 𝕜 f (insert x s) x [PROOFSTEP] have := ((H.mono tu).differentiableOn le_rfl) x ⟨mem_insert x s, xt⟩ [GOAL] case intro.intro.intro.intro.intro.intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t✝ u✝ : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p✝ : E → FormalMultilinearSeries 𝕜 E F h : ContDiffWithinAt 𝕜 n f s x hn : 1 ≤ n u : Set E hu : u ∈ 𝓝[insert x s] x p : E → FormalMultilinearSeries 𝕜 E F H : HasFTaylorSeriesUpToOn (↑1) f p u t : Set E t_open : IsOpen t xt : x ∈ t tu : insert x s ∩ t ⊆ u this : DifferentiableWithinAt 𝕜 f (insert x s ∩ t) x ⊢ DifferentiableWithinAt 𝕜 f (insert x s) x [PROOFSTEP] exact (differentiableWithinAt_inter (IsOpen.mem_nhds t_open xt)).1 this [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ ⊢ ContDiffWithinAt 𝕜 (↑(n + 1)) f s x ↔ ∃ u, u ∈ 𝓝[insert x s] x ∧ ∃ f', (∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) u x) ∧ ContDiffWithinAt 𝕜 (↑n) f' u x [PROOFSTEP] constructor [GOAL] case mp 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ ⊢ ContDiffWithinAt 𝕜 (↑(n + 1)) f s x → ∃ u, u ∈ 𝓝[insert x s] x ∧ ∃ f', (∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) u x) ∧ ContDiffWithinAt 𝕜 (↑n) f' u x [PROOFSTEP] intro h [GOAL] case mp 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ h : ContDiffWithinAt 𝕜 (↑(n + 1)) f s x ⊢ ∃ u, u ∈ 𝓝[insert x s] x ∧ ∃ f', (∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) u x) ∧ ContDiffWithinAt 𝕜 (↑n) f' u x [PROOFSTEP] rcases h n.succ le_rfl with ⟨u, hu, p, Hp⟩ [GOAL] case mp.intro.intro.intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p✝ : E → FormalMultilinearSeries 𝕜 E F n : ℕ h : ContDiffWithinAt 𝕜 (↑(n + 1)) f s x u : Set E hu : u ∈ 𝓝[insert x s] x p : E → FormalMultilinearSeries 𝕜 E F Hp : HasFTaylorSeriesUpToOn (↑(Nat.succ n)) f p u ⊢ ∃ u, u ∈ 𝓝[insert x s] x ∧ ∃ f', (∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) u x) ∧ ContDiffWithinAt 𝕜 (↑n) f' u x [PROOFSTEP] refine' ⟨u, hu, fun y => (continuousMultilinearCurryFin1 𝕜 E F) (p y 1), fun y hy => Hp.hasFDerivWithinAt (WithTop.coe_le_coe.2 (Nat.le_add_left 1 n)) hy, _⟩ [GOAL] case mp.intro.intro.intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p✝ : E → FormalMultilinearSeries 𝕜 E F n : ℕ h : ContDiffWithinAt 𝕜 (↑(n + 1)) f s x u : Set E hu : u ∈ 𝓝[insert x s] x p : E → FormalMultilinearSeries 𝕜 E F Hp : HasFTaylorSeriesUpToOn (↑(Nat.succ n)) f p u ⊢ ContDiffWithinAt 𝕜 (↑n) (fun y => ↑(continuousMultilinearCurryFin1 𝕜 E F) (p y 1)) u x [PROOFSTEP] intro m hm [GOAL] case mp.intro.intro.intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x x₀ : E c : F m✝ n✝ : ℕ∞ p✝ : E → FormalMultilinearSeries 𝕜 E F n : ℕ h : ContDiffWithinAt 𝕜 (↑(n + 1)) f s x u : Set E hu : u ∈ 𝓝[insert x s] x p : E → FormalMultilinearSeries 𝕜 E F Hp : HasFTaylorSeriesUpToOn (↑(Nat.succ n)) f p u m : ℕ hm : ↑m ≤ ↑n ⊢ ∃ u_1, u_1 ∈ 𝓝[insert x u] x ∧ ∃ p_1, HasFTaylorSeriesUpToOn (↑m) (fun y => ↑(continuousMultilinearCurryFin1 𝕜 E F) (p y 1)) p_1 u_1 [PROOFSTEP] refine' ⟨u, _, fun y : E => (p y).shift, _⟩ [GOAL] case mp.intro.intro.intro.refine'_1 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x x₀ : E c : F m✝ n✝ : ℕ∞ p✝ : E → FormalMultilinearSeries 𝕜 E F n : ℕ h : ContDiffWithinAt 𝕜 (↑(n + 1)) f s x u : Set E hu : u ∈ 𝓝[insert x s] x p : E → FormalMultilinearSeries 𝕜 E F Hp : HasFTaylorSeriesUpToOn (↑(Nat.succ n)) f p u m : ℕ hm : ↑m ≤ ↑n ⊢ u ∈ 𝓝[insert x u] x [PROOFSTEP] convert @self_mem_nhdsWithin _ _ x u [GOAL] case h.e'_5.h.e'_4 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x x₀ : E c : F m✝ n✝ : ℕ∞ p✝ : E → FormalMultilinearSeries 𝕜 E F n : ℕ h : ContDiffWithinAt 𝕜 (↑(n + 1)) f s x u : Set E hu : u ∈ 𝓝[insert x s] x p : E → FormalMultilinearSeries 𝕜 E F Hp : HasFTaylorSeriesUpToOn (↑(Nat.succ n)) f p u m : ℕ hm : ↑m ≤ ↑n ⊢ insert x u = u [PROOFSTEP] have : x ∈ insert x s := by simp [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x x₀ : E c : F m✝ n✝ : ℕ∞ p✝ : E → FormalMultilinearSeries 𝕜 E F n : ℕ h : ContDiffWithinAt 𝕜 (↑(n + 1)) f s x u : Set E hu : u ∈ 𝓝[insert x s] x p : E → FormalMultilinearSeries 𝕜 E F Hp : HasFTaylorSeriesUpToOn (↑(Nat.succ n)) f p u m : ℕ hm : ↑m ≤ ↑n ⊢ x ∈ insert x s [PROOFSTEP] simp [GOAL] case h.e'_5.h.e'_4 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x x₀ : E c : F m✝ n✝ : ℕ∞ p✝ : E → FormalMultilinearSeries 𝕜 E F n : ℕ h : ContDiffWithinAt 𝕜 (↑(n + 1)) f s x u : Set E hu : u ∈ 𝓝[insert x s] x p : E → FormalMultilinearSeries 𝕜 E F Hp : HasFTaylorSeriesUpToOn (↑(Nat.succ n)) f p u m : ℕ hm : ↑m ≤ ↑n this : x ∈ insert x s ⊢ insert x u = u [PROOFSTEP] exact insert_eq_of_mem (mem_of_mem_nhdsWithin this hu) [GOAL] case mp.intro.intro.intro.refine'_2 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x x₀ : E c : F m✝ n✝ : ℕ∞ p✝ : E → FormalMultilinearSeries 𝕜 E F n : ℕ h : ContDiffWithinAt 𝕜 (↑(n + 1)) f s x u : Set E hu : u ∈ 𝓝[insert x s] x p : E → FormalMultilinearSeries 𝕜 E F Hp : HasFTaylorSeriesUpToOn (↑(Nat.succ n)) f p u m : ℕ hm : ↑m ≤ ↑n ⊢ HasFTaylorSeriesUpToOn (↑m) (fun y => ↑(continuousMultilinearCurryFin1 𝕜 E F) (p y 1)) (fun y => FormalMultilinearSeries.shift (p y)) u [PROOFSTEP] rw [hasFTaylorSeriesUpToOn_succ_iff_right] at Hp [GOAL] case mp.intro.intro.intro.refine'_2 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x x₀ : E c : F m✝ n✝ : ℕ∞ p✝ : E → FormalMultilinearSeries 𝕜 E F n : ℕ h : ContDiffWithinAt 𝕜 (↑(n + 1)) f s x u : Set E hu : u ∈ 𝓝[insert x s] x p : E → FormalMultilinearSeries 𝕜 E F Hp : (∀ (x : E), x ∈ u → ContinuousMultilinearMap.uncurry0 (p x 0) = f x) ∧ (∀ (x : E), x ∈ u → HasFDerivWithinAt (fun y => p y 0) (ContinuousMultilinearMap.curryLeft (p x 1)) u x) ∧ HasFTaylorSeriesUpToOn (↑n) (fun x => ↑(continuousMultilinearCurryFin1 𝕜 E F) (p x 1)) (fun x => FormalMultilinearSeries.shift (p x)) u m : ℕ hm : ↑m ≤ ↑n ⊢ HasFTaylorSeriesUpToOn (↑m) (fun y => ↑(continuousMultilinearCurryFin1 𝕜 E F) (p y 1)) (fun y => FormalMultilinearSeries.shift (p y)) u [PROOFSTEP] exact Hp.2.2.of_le hm [GOAL] case mpr 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ ⊢ (∃ u, u ∈ 𝓝[insert x s] x ∧ ∃ f', (∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) u x) ∧ ContDiffWithinAt 𝕜 (↑n) f' u x) → ContDiffWithinAt 𝕜 (↑(n + 1)) f s x [PROOFSTEP] rintro ⟨u, hu, f', f'_eq_deriv, Hf'⟩ [GOAL] case mpr.intro.intro.intro.intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ u : Set E hu : u ∈ 𝓝[insert x s] x f' : E → E →L[𝕜] F f'_eq_deriv : ∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) u x Hf' : ContDiffWithinAt 𝕜 (↑n) f' u x ⊢ ContDiffWithinAt 𝕜 (↑(n + 1)) f s x [PROOFSTEP] rw [contDiffWithinAt_nat] [GOAL] case mpr.intro.intro.intro.intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ u : Set E hu : u ∈ 𝓝[insert x s] x f' : E → E →L[𝕜] F f'_eq_deriv : ∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) u x Hf' : ContDiffWithinAt 𝕜 (↑n) f' u x ⊢ ∃ u, u ∈ 𝓝[insert x s] x ∧ ∃ p, HasFTaylorSeriesUpToOn (↑(n + 1)) f p u [PROOFSTEP] rcases Hf' n le_rfl with ⟨v, hv, p', Hp'⟩ [GOAL] case mpr.intro.intro.intro.intro.intro.intro.intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ u : Set E hu : u ∈ 𝓝[insert x s] x f' : E → E →L[𝕜] F f'_eq_deriv : ∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) u x Hf' : ContDiffWithinAt 𝕜 (↑n) f' u x v : Set E hv : v ∈ 𝓝[insert x u] x p' : E → FormalMultilinearSeries 𝕜 E (E →L[𝕜] F) Hp' : HasFTaylorSeriesUpToOn (↑n) f' p' v ⊢ ∃ u, u ∈ 𝓝[insert x s] x ∧ ∃ p, HasFTaylorSeriesUpToOn (↑(n + 1)) f p u [PROOFSTEP] refine' ⟨v ∩ u, _, fun x => (p' x).unshift (f x), _⟩ [GOAL] case mpr.intro.intro.intro.intro.intro.intro.intro.refine'_1 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ u : Set E hu : u ∈ 𝓝[insert x s] x f' : E → E →L[𝕜] F f'_eq_deriv : ∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) u x Hf' : ContDiffWithinAt 𝕜 (↑n) f' u x v : Set E hv : v ∈ 𝓝[insert x u] x p' : E → FormalMultilinearSeries 𝕜 E (E →L[𝕜] F) Hp' : HasFTaylorSeriesUpToOn (↑n) f' p' v ⊢ v ∩ u ∈ 𝓝[insert x s] x [PROOFSTEP] apply Filter.inter_mem _ hu [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ u : Set E hu : u ∈ 𝓝[insert x s] x f' : E → E →L[𝕜] F f'_eq_deriv : ∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) u x Hf' : ContDiffWithinAt 𝕜 (↑n) f' u x v : Set E hv : v ∈ 𝓝[insert x u] x p' : E → FormalMultilinearSeries 𝕜 E (E →L[𝕜] F) Hp' : HasFTaylorSeriesUpToOn (↑n) f' p' v ⊢ v ∈ 𝓝[insert x s] x [PROOFSTEP] apply nhdsWithin_le_of_mem hu [GOAL] case a 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ u : Set E hu : u ∈ 𝓝[insert x s] x f' : E → E →L[𝕜] F f'_eq_deriv : ∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) u x Hf' : ContDiffWithinAt 𝕜 (↑n) f' u x v : Set E hv : v ∈ 𝓝[insert x u] x p' : E → FormalMultilinearSeries 𝕜 E (E →L[𝕜] F) Hp' : HasFTaylorSeriesUpToOn (↑n) f' p' v ⊢ v ∈ 𝓝[u] x [PROOFSTEP] exact nhdsWithin_mono _ (subset_insert x u) hv [GOAL] case mpr.intro.intro.intro.intro.intro.intro.intro.refine'_2 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ u : Set E hu : u ∈ 𝓝[insert x s] x f' : E → E →L[𝕜] F f'_eq_deriv : ∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) u x Hf' : ContDiffWithinAt 𝕜 (↑n) f' u x v : Set E hv : v ∈ 𝓝[insert x u] x p' : E → FormalMultilinearSeries 𝕜 E (E →L[𝕜] F) Hp' : HasFTaylorSeriesUpToOn (↑n) f' p' v ⊢ HasFTaylorSeriesUpToOn (↑(n + 1)) f (fun x => FormalMultilinearSeries.unshift (p' x) (f x)) (v ∩ u) [PROOFSTEP] rw [hasFTaylorSeriesUpToOn_succ_iff_right] [GOAL] case mpr.intro.intro.intro.intro.intro.intro.intro.refine'_2 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ u : Set E hu : u ∈ 𝓝[insert x s] x f' : E → E →L[𝕜] F f'_eq_deriv : ∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) u x Hf' : ContDiffWithinAt 𝕜 (↑n) f' u x v : Set E hv : v ∈ 𝓝[insert x u] x p' : E → FormalMultilinearSeries 𝕜 E (E →L[𝕜] F) Hp' : HasFTaylorSeriesUpToOn (↑n) f' p' v ⊢ (∀ (x : E), x ∈ v ∩ u → ContinuousMultilinearMap.uncurry0 (FormalMultilinearSeries.unshift (p' x) (f x) 0) = f x) ∧ (∀ (x : E), x ∈ v ∩ u → HasFDerivWithinAt (fun y => FormalMultilinearSeries.unshift (p' y) (f y) 0) (ContinuousMultilinearMap.curryLeft (FormalMultilinearSeries.unshift (p' x) (f x) 1)) (v ∩ u) x) ∧ HasFTaylorSeriesUpToOn (↑n) (fun x => ↑(continuousMultilinearCurryFin1 𝕜 E F) (FormalMultilinearSeries.unshift (p' x) (f x) 1)) (fun x => FormalMultilinearSeries.shift (FormalMultilinearSeries.unshift (p' x) (f x))) (v ∩ u) [PROOFSTEP] refine' ⟨fun y _ => rfl, fun y hy => _, _⟩ [GOAL] case mpr.intro.intro.intro.intro.intro.intro.intro.refine'_2.refine'_1 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ u : Set E hu : u ∈ 𝓝[insert x s] x f' : E → E →L[𝕜] F f'_eq_deriv : ∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) u x Hf' : ContDiffWithinAt 𝕜 (↑n) f' u x v : Set E hv : v ∈ 𝓝[insert x u] x p' : E → FormalMultilinearSeries 𝕜 E (E →L[𝕜] F) Hp' : HasFTaylorSeriesUpToOn (↑n) f' p' v y : E hy : y ∈ v ∩ u ⊢ HasFDerivWithinAt (fun y => FormalMultilinearSeries.unshift (p' y) (f y) 0) (ContinuousMultilinearMap.curryLeft (FormalMultilinearSeries.unshift (p' y) (f y) 1)) (v ∩ u) y [PROOFSTEP] change HasFDerivWithinAt (fun z => (continuousMultilinearCurryFin0 𝕜 E F).symm (f z)) (FormalMultilinearSeries.unshift (p' y) (f y) 1).curryLeft (v ∩ u) y [GOAL] case mpr.intro.intro.intro.intro.intro.intro.intro.refine'_2.refine'_1 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ u : Set E hu : u ∈ 𝓝[insert x s] x f' : E → E →L[𝕜] F f'_eq_deriv : ∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) u x Hf' : ContDiffWithinAt 𝕜 (↑n) f' u x v : Set E hv : v ∈ 𝓝[insert x u] x p' : E → FormalMultilinearSeries 𝕜 E (E →L[𝕜] F) Hp' : HasFTaylorSeriesUpToOn (↑n) f' p' v y : E hy : y ∈ v ∩ u ⊢ HasFDerivWithinAt (fun z => ↑(LinearIsometryEquiv.symm (continuousMultilinearCurryFin0 𝕜 E F)) (f z)) (ContinuousMultilinearMap.curryLeft (FormalMultilinearSeries.unshift (p' y) (f y) 1)) (v ∩ u) y [PROOFSTEP] erw [LinearIsometryEquiv.comp_hasFDerivWithinAt_iff'] [GOAL] case mpr.intro.intro.intro.intro.intro.intro.intro.refine'_2.refine'_1 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ u : Set E hu : u ∈ 𝓝[insert x s] x f' : E → E →L[𝕜] F f'_eq_deriv : ∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) u x Hf' : ContDiffWithinAt 𝕜 (↑n) f' u x v : Set E hv : v ∈ 𝓝[insert x u] x p' : E → FormalMultilinearSeries 𝕜 E (E →L[𝕜] F) Hp' : HasFTaylorSeriesUpToOn (↑n) f' p' v y : E hy : y ∈ v ∩ u ⊢ HasFDerivWithinAt (fun z => f z) (ContinuousLinearMap.comp (↑(ContinuousLinearEquiv.mk (LinearIsometryEquiv.symm (LinearIsometryEquiv.symm (continuousMultilinearCurryFin0 𝕜 E F))).toLinearEquiv)) (ContinuousMultilinearMap.curryLeft (FormalMultilinearSeries.unshift (p' y) (f y) 1))) (v ∩ u) y [PROOFSTEP] convert (f'_eq_deriv y hy.2).mono (inter_subset_right v u) [GOAL] case h.e'_10 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ u : Set E hu : u ∈ 𝓝[insert x s] x f' : E → E →L[𝕜] F f'_eq_deriv : ∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) u x Hf' : ContDiffWithinAt 𝕜 (↑n) f' u x v : Set E hv : v ∈ 𝓝[insert x u] x p' : E → FormalMultilinearSeries 𝕜 E (E →L[𝕜] F) Hp' : HasFTaylorSeriesUpToOn (↑n) f' p' v y : E hy : y ∈ v ∩ u ⊢ ContinuousLinearMap.comp (↑(ContinuousLinearEquiv.mk (LinearIsometryEquiv.symm (LinearIsometryEquiv.symm (continuousMultilinearCurryFin0 𝕜 E F))).toLinearEquiv)) (ContinuousMultilinearMap.curryLeft (FormalMultilinearSeries.unshift (p' y) (f y) 1)) = f' y [PROOFSTEP] rw [← Hp'.zero_eq y hy.1] [GOAL] case h.e'_10 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ u : Set E hu : u ∈ 𝓝[insert x s] x f' : E → E →L[𝕜] F f'_eq_deriv : ∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) u x Hf' : ContDiffWithinAt 𝕜 (↑n) f' u x v : Set E hv : v ∈ 𝓝[insert x u] x p' : E → FormalMultilinearSeries 𝕜 E (E →L[𝕜] F) Hp' : HasFTaylorSeriesUpToOn (↑n) f' p' v y : E hy : y ∈ v ∩ u ⊢ ContinuousLinearMap.comp (↑(ContinuousLinearEquiv.mk (LinearIsometryEquiv.symm (LinearIsometryEquiv.symm (continuousMultilinearCurryFin0 𝕜 E F))).toLinearEquiv)) (ContinuousMultilinearMap.curryLeft (FormalMultilinearSeries.unshift (p' y) (f y) 1)) = ContinuousMultilinearMap.uncurry0 (p' y 0) [PROOFSTEP] ext z [GOAL] case h.e'_10.h 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ u : Set E hu : u ∈ 𝓝[insert x s] x f' : E → E →L[𝕜] F f'_eq_deriv : ∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) u x Hf' : ContDiffWithinAt 𝕜 (↑n) f' u x v : Set E hv : v ∈ 𝓝[insert x u] x p' : E → FormalMultilinearSeries 𝕜 E (E →L[𝕜] F) Hp' : HasFTaylorSeriesUpToOn (↑n) f' p' v y : E hy : y ∈ v ∩ u z : E ⊢ ↑(ContinuousLinearMap.comp (↑(ContinuousLinearEquiv.mk (LinearIsometryEquiv.symm (LinearIsometryEquiv.symm (continuousMultilinearCurryFin0 𝕜 E F))).toLinearEquiv)) (ContinuousMultilinearMap.curryLeft (FormalMultilinearSeries.unshift (p' y) (f y) 1))) z = ↑(ContinuousMultilinearMap.uncurry0 (p' y 0)) z [PROOFSTEP] change ((p' y 0) (init (@cons 0 (fun _ => E) z 0))) (@cons 0 (fun _ => E) z 0 (last 0)) = ((p' y 0) 0) z [GOAL] case h.e'_10.h 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ u : Set E hu : u ∈ 𝓝[insert x s] x f' : E → E →L[𝕜] F f'_eq_deriv : ∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) u x Hf' : ContDiffWithinAt 𝕜 (↑n) f' u x v : Set E hv : v ∈ 𝓝[insert x u] x p' : E → FormalMultilinearSeries 𝕜 E (E →L[𝕜] F) Hp' : HasFTaylorSeriesUpToOn (↑n) f' p' v y : E hy : y ∈ v ∩ u z : E ⊢ ↑(↑(p' y 0) (init (cons z 0))) (cons z 0 (last 0)) = ↑(↑(p' y 0) 0) z [PROOFSTEP] congr [GOAL] case h.e'_10.h.e_a.h.e_6.h 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ u : Set E hu : u ∈ 𝓝[insert x s] x f' : E → E →L[𝕜] F f'_eq_deriv : ∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) u x Hf' : ContDiffWithinAt 𝕜 (↑n) f' u x v : Set E hv : v ∈ 𝓝[insert x u] x p' : E → FormalMultilinearSeries 𝕜 E (E →L[𝕜] F) Hp' : HasFTaylorSeriesUpToOn (↑n) f' p' v y : E hy : y ∈ v ∩ u z : E ⊢ init (cons z 0) = 0 [PROOFSTEP] norm_num [GOAL] case mpr.intro.intro.intro.intro.intro.intro.intro.refine'_2.refine'_2 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ u : Set E hu : u ∈ 𝓝[insert x s] x f' : E → E →L[𝕜] F f'_eq_deriv : ∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) u x Hf' : ContDiffWithinAt 𝕜 (↑n) f' u x v : Set E hv : v ∈ 𝓝[insert x u] x p' : E → FormalMultilinearSeries 𝕜 E (E →L[𝕜] F) Hp' : HasFTaylorSeriesUpToOn (↑n) f' p' v ⊢ HasFTaylorSeriesUpToOn (↑n) (fun x => ↑(continuousMultilinearCurryFin1 𝕜 E F) (FormalMultilinearSeries.unshift (p' x) (f x) 1)) (fun x => FormalMultilinearSeries.shift (FormalMultilinearSeries.unshift (p' x) (f x))) (v ∩ u) [PROOFSTEP] convert (Hp'.mono (inter_subset_left v u)).congr fun x hx => Hp'.zero_eq x hx.1 using 1 [GOAL] case h.e'_10 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ u : Set E hu : u ∈ 𝓝[insert x s] x f' : E → E →L[𝕜] F f'_eq_deriv : ∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) u x Hf' : ContDiffWithinAt 𝕜 (↑n) f' u x v : Set E hv : v ∈ 𝓝[insert x u] x p' : E → FormalMultilinearSeries 𝕜 E (E →L[𝕜] F) Hp' : HasFTaylorSeriesUpToOn (↑n) f' p' v ⊢ (fun x => ↑(continuousMultilinearCurryFin1 𝕜 E F) (FormalMultilinearSeries.unshift (p' x) (f x) 1)) = fun x => ContinuousMultilinearMap.uncurry0 (p' x 0) [PROOFSTEP] ext x y [GOAL] case h.e'_10.h.h 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ u : Set E hu : u ∈ 𝓝[insert x✝ s] x✝ f' : E → E →L[𝕜] F f'_eq_deriv : ∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) u x Hf' : ContDiffWithinAt 𝕜 (↑n) f' u x✝ v : Set E hv : v ∈ 𝓝[insert x✝ u] x✝ p' : E → FormalMultilinearSeries 𝕜 E (E →L[𝕜] F) Hp' : HasFTaylorSeriesUpToOn (↑n) f' p' v x y : E ⊢ ↑(↑(continuousMultilinearCurryFin1 𝕜 E F) (FormalMultilinearSeries.unshift (p' x) (f x) 1)) y = ↑(ContinuousMultilinearMap.uncurry0 (p' x 0)) y [PROOFSTEP] change p' x 0 (init (@snoc 0 (fun _ : Fin 1 => E) 0 y)) y = p' x 0 0 y [GOAL] case h.e'_10.h.h 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ u : Set E hu : u ∈ 𝓝[insert x✝ s] x✝ f' : E → E →L[𝕜] F f'_eq_deriv : ∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) u x Hf' : ContDiffWithinAt 𝕜 (↑n) f' u x✝ v : Set E hv : v ∈ 𝓝[insert x✝ u] x✝ p' : E → FormalMultilinearSeries 𝕜 E (E →L[𝕜] F) Hp' : HasFTaylorSeriesUpToOn (↑n) f' p' v x y : E ⊢ ↑(↑(p' x 0) (init (snoc 0 y))) y = ↑(↑(p' x 0) 0) y [PROOFSTEP] rw [init_snoc] [GOAL] case h.e'_11 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ u : Set E hu : u ∈ 𝓝[insert x s] x f' : E → E →L[𝕜] F f'_eq_deriv : ∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) u x Hf' : ContDiffWithinAt 𝕜 (↑n) f' u x v : Set E hv : v ∈ 𝓝[insert x u] x p' : E → FormalMultilinearSeries 𝕜 E (E →L[𝕜] F) Hp' : HasFTaylorSeriesUpToOn (↑n) f' p' v ⊢ (fun x => FormalMultilinearSeries.shift (FormalMultilinearSeries.unshift (p' x) (f x))) = p' [PROOFSTEP] ext x k v y [GOAL] case h.e'_11.h.h.H.h 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ u : Set E hu : u ∈ 𝓝[insert x✝ s] x✝ f' : E → E →L[𝕜] F f'_eq_deriv : ∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) u x Hf' : ContDiffWithinAt 𝕜 (↑n) f' u x✝ v✝ : Set E hv : v✝ ∈ 𝓝[insert x✝ u] x✝ p' : E → FormalMultilinearSeries 𝕜 E (E →L[𝕜] F) Hp' : HasFTaylorSeriesUpToOn (↑n) f' p' v✝ x : E k : ℕ v : Fin k → E y : E ⊢ ↑(↑(FormalMultilinearSeries.shift (FormalMultilinearSeries.unshift (p' x) (f x)) k) v) y = ↑(↑(p' x k) v) y [PROOFSTEP] change p' x k (init (@snoc k (fun _ : Fin k.succ => E) v y)) (@snoc k (fun _ : Fin k.succ => E) v y (last k)) = p' x k v y [GOAL] case h.e'_11.h.h.H.h 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ u : Set E hu : u ∈ 𝓝[insert x✝ s] x✝ f' : E → E →L[𝕜] F f'_eq_deriv : ∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) u x Hf' : ContDiffWithinAt 𝕜 (↑n) f' u x✝ v✝ : Set E hv : v✝ ∈ 𝓝[insert x✝ u] x✝ p' : E → FormalMultilinearSeries 𝕜 E (E →L[𝕜] F) Hp' : HasFTaylorSeriesUpToOn (↑n) f' p' v✝ x : E k : ℕ v : Fin k → E y : E ⊢ ↑(↑(p' x k) (init (snoc v y))) (snoc v y (last k)) = ↑(↑(p' x k) v) y [PROOFSTEP] rw [snoc_last, init_snoc] [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ ⊢ ContDiffWithinAt 𝕜 (↑(n + 1)) f s x ↔ ∃ u, u ∈ 𝓝[insert x s] x ∧ u ⊆ insert x s ∧ ∃ f', (∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) s x) ∧ ContDiffWithinAt 𝕜 (↑n) f' s x [PROOFSTEP] refine' ⟨fun hf => _, _⟩ [GOAL] case refine'_1 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ hf : ContDiffWithinAt 𝕜 (↑(n + 1)) f s x ⊢ ∃ u, u ∈ 𝓝[insert x s] x ∧ u ⊆ insert x s ∧ ∃ f', (∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) s x) ∧ ContDiffWithinAt 𝕜 (↑n) f' s x [PROOFSTEP] obtain ⟨u, hu, f', huf', hf'⟩ := contDiffWithinAt_succ_iff_hasFDerivWithinAt.mp hf [GOAL] case refine'_1.intro.intro.intro.intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ hf : ContDiffWithinAt 𝕜 (↑(n + 1)) f s x u : Set E hu : u ∈ 𝓝[insert x s] x f' : E → E →L[𝕜] F huf' : ∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) u x hf' : ContDiffWithinAt 𝕜 (↑n) f' u x ⊢ ∃ u, u ∈ 𝓝[insert x s] x ∧ u ⊆ insert x s ∧ ∃ f', (∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) s x) ∧ ContDiffWithinAt 𝕜 (↑n) f' s x [PROOFSTEP] obtain ⟨w, hw, hxw, hwu⟩ := mem_nhdsWithin.mp hu [GOAL] case refine'_1.intro.intro.intro.intro.intro.intro.intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ hf : ContDiffWithinAt 𝕜 (↑(n + 1)) f s x u : Set E hu : u ∈ 𝓝[insert x s] x f' : E → E →L[𝕜] F huf' : ∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) u x hf' : ContDiffWithinAt 𝕜 (↑n) f' u x w : Set E hw : IsOpen w hxw : x ∈ w hwu : w ∩ insert x s ⊆ u ⊢ ∃ u, u ∈ 𝓝[insert x s] x ∧ u ⊆ insert x s ∧ ∃ f', (∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) s x) ∧ ContDiffWithinAt 𝕜 (↑n) f' s x [PROOFSTEP] rw [inter_comm] at hwu [GOAL] case refine'_1.intro.intro.intro.intro.intro.intro.intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ hf : ContDiffWithinAt 𝕜 (↑(n + 1)) f s x u : Set E hu : u ∈ 𝓝[insert x s] x f' : E → E →L[𝕜] F huf' : ∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) u x hf' : ContDiffWithinAt 𝕜 (↑n) f' u x w : Set E hw : IsOpen w hxw : x ∈ w hwu : insert x s ∩ w ⊆ u ⊢ ∃ u, u ∈ 𝓝[insert x s] x ∧ u ⊆ insert x s ∧ ∃ f', (∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) s x) ∧ ContDiffWithinAt 𝕜 (↑n) f' s x [PROOFSTEP] refine' ⟨insert x s ∩ w, inter_mem_nhdsWithin _ (hw.mem_nhds hxw), inter_subset_left _ _, f', fun y hy => _, _⟩ [GOAL] case refine'_1.intro.intro.intro.intro.intro.intro.intro.refine'_1 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ hf : ContDiffWithinAt 𝕜 (↑(n + 1)) f s x u : Set E hu : u ∈ 𝓝[insert x s] x f' : E → E →L[𝕜] F huf' : ∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) u x hf' : ContDiffWithinAt 𝕜 (↑n) f' u x w : Set E hw : IsOpen w hxw : x ∈ w hwu : insert x s ∩ w ⊆ u y : E hy : y ∈ insert x s ∩ w ⊢ HasFDerivWithinAt f (f' y) s y [PROOFSTEP] refine' ((huf' y <| hwu hy).mono hwu).mono_of_mem _ [GOAL] case refine'_1.intro.intro.intro.intro.intro.intro.intro.refine'_1 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ hf : ContDiffWithinAt 𝕜 (↑(n + 1)) f s x u : Set E hu : u ∈ 𝓝[insert x s] x f' : E → E →L[𝕜] F huf' : ∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) u x hf' : ContDiffWithinAt 𝕜 (↑n) f' u x w : Set E hw : IsOpen w hxw : x ∈ w hwu : insert x s ∩ w ⊆ u y : E hy : y ∈ insert x s ∩ w ⊢ insert x s ∩ w ∈ 𝓝[s] y [PROOFSTEP] refine' mem_of_superset _ (inter_subset_inter_left _ (subset_insert _ _)) [GOAL] case refine'_1.intro.intro.intro.intro.intro.intro.intro.refine'_1 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ hf : ContDiffWithinAt 𝕜 (↑(n + 1)) f s x u : Set E hu : u ∈ 𝓝[insert x s] x f' : E → E →L[𝕜] F huf' : ∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) u x hf' : ContDiffWithinAt 𝕜 (↑n) f' u x w : Set E hw : IsOpen w hxw : x ∈ w hwu : insert x s ∩ w ⊆ u y : E hy : y ∈ insert x s ∩ w ⊢ s ∩ w ∈ 𝓝[s] y [PROOFSTEP] refine' inter_mem_nhdsWithin _ (hw.mem_nhds hy.2) [GOAL] case refine'_1.intro.intro.intro.intro.intro.intro.intro.refine'_2 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ hf : ContDiffWithinAt 𝕜 (↑(n + 1)) f s x u : Set E hu : u ∈ 𝓝[insert x s] x f' : E → E →L[𝕜] F huf' : ∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) u x hf' : ContDiffWithinAt 𝕜 (↑n) f' u x w : Set E hw : IsOpen w hxw : x ∈ w hwu : insert x s ∩ w ⊆ u ⊢ ContDiffWithinAt 𝕜 (↑n) f' s x [PROOFSTEP] exact hf'.mono_of_mem (nhdsWithin_mono _ (subset_insert _ _) hu) [GOAL] case refine'_2 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ ⊢ (∃ u, u ∈ 𝓝[insert x s] x ∧ u ⊆ insert x s ∧ ∃ f', (∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) s x) ∧ ContDiffWithinAt 𝕜 (↑n) f' s x) → ContDiffWithinAt 𝕜 (↑(n + 1)) f s x [PROOFSTEP] rw [← contDiffWithinAt_insert, contDiffWithinAt_succ_iff_hasFDerivWithinAt, insert_eq_of_mem (mem_insert _ _)] [GOAL] case refine'_2 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ ⊢ (∃ u, u ∈ 𝓝[insert x s] x ∧ u ⊆ insert x s ∧ ∃ f', (∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) s x) ∧ ContDiffWithinAt 𝕜 (↑n) f' s x) → ∃ u, u ∈ 𝓝[insert x s] x ∧ ∃ f', (∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) u x) ∧ ContDiffWithinAt 𝕜 (↑n) f' u x [PROOFSTEP] rintro ⟨u, hu, hus, f', huf', hf'⟩ [GOAL] case refine'_2.intro.intro.intro.intro.intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ u : Set E hu : u ∈ 𝓝[insert x s] x hus : u ⊆ insert x s f' : E → E →L[𝕜] F huf' : ∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) s x hf' : ContDiffWithinAt 𝕜 (↑n) f' s x ⊢ ∃ u, u ∈ 𝓝[insert x s] x ∧ ∃ f', (∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) u x) ∧ ContDiffWithinAt 𝕜 (↑n) f' u x [PROOFSTEP] refine' ⟨u, hu, f', fun y hy => (huf' y hy).insert'.mono hus, hf'.insert.mono hus⟩ [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p f' : E → FormalMultilinearSeries 𝕜 E F hf : HasFTaylorSeriesUpToOn n f f' s ⊢ ContDiffOn 𝕜 n f s [PROOFSTEP] intro x hx m hm [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝ n : ℕ∞ p f' : E → FormalMultilinearSeries 𝕜 E F hf : HasFTaylorSeriesUpToOn n f f' s x : E hx : x ∈ s m : ℕ hm : ↑m ≤ n ⊢ ∃ u, u ∈ 𝓝[insert x s] x ∧ ∃ p, HasFTaylorSeriesUpToOn (↑m) f p u [PROOFSTEP] use s [GOAL] case h 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝ n : ℕ∞ p f' : E → FormalMultilinearSeries 𝕜 E F hf : HasFTaylorSeriesUpToOn n f f' s x : E hx : x ∈ s m : ℕ hm : ↑m ≤ n ⊢ s ∈ 𝓝[insert x s] x ∧ ∃ p, HasFTaylorSeriesUpToOn (↑m) f p s [PROOFSTEP] simp only [Set.insert_eq_of_mem hx, self_mem_nhdsWithin, true_and_iff] [GOAL] case h 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝ n : ℕ∞ p f' : E → FormalMultilinearSeries 𝕜 E F hf : HasFTaylorSeriesUpToOn n f f' s x : E hx : x ∈ s m : ℕ hm : ↑m ≤ n ⊢ ∃ p, HasFTaylorSeriesUpToOn (↑m) f p s [PROOFSTEP] exact ⟨f', hf.of_le hm⟩ [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m✝ n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F m : ℕ hm : ↑m ≤ n h : ContDiffWithinAt 𝕜 n f s x ⊢ ∃ u, IsOpen u ∧ x ∈ u ∧ ContDiffOn 𝕜 (↑m) f (insert x s ∩ u) [PROOFSTEP] rcases h m hm with ⟨t, ht, p, hp⟩ [GOAL] case intro.intro.intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t✝ u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m✝ n : ℕ∞ p✝ : E → FormalMultilinearSeries 𝕜 E F m : ℕ hm : ↑m ≤ n h : ContDiffWithinAt 𝕜 n f s x t : Set E ht : t ∈ 𝓝[insert x s] x p : E → FormalMultilinearSeries 𝕜 E F hp : HasFTaylorSeriesUpToOn (↑m) f p t ⊢ ∃ u, IsOpen u ∧ x ∈ u ∧ ContDiffOn 𝕜 (↑m) f (insert x s ∩ u) [PROOFSTEP] rcases mem_nhdsWithin.1 ht with ⟨u, huo, hxu, hut⟩ [GOAL] case intro.intro.intro.intro.intro.intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t✝ u✝ : Set E f f₁ : E → F g : F → G x x₀ : E c : F m✝ n : ℕ∞ p✝ : E → FormalMultilinearSeries 𝕜 E F m : ℕ hm : ↑m ≤ n h : ContDiffWithinAt 𝕜 n f s x t : Set E ht : t ∈ 𝓝[insert x s] x p : E → FormalMultilinearSeries 𝕜 E F hp : HasFTaylorSeriesUpToOn (↑m) f p t u : Set E huo : IsOpen u hxu : x ∈ u hut : u ∩ insert x s ⊆ t ⊢ ∃ u, IsOpen u ∧ x ∈ u ∧ ContDiffOn 𝕜 (↑m) f (insert x s ∩ u) [PROOFSTEP] rw [inter_comm] at hut [GOAL] case intro.intro.intro.intro.intro.intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t✝ u✝ : Set E f f₁ : E → F g : F → G x x₀ : E c : F m✝ n : ℕ∞ p✝ : E → FormalMultilinearSeries 𝕜 E F m : ℕ hm : ↑m ≤ n h : ContDiffWithinAt 𝕜 n f s x t : Set E ht : t ∈ 𝓝[insert x s] x p : E → FormalMultilinearSeries 𝕜 E F hp : HasFTaylorSeriesUpToOn (↑m) f p t u : Set E huo : IsOpen u hxu : x ∈ u hut : insert x s ∩ u ⊆ t ⊢ ∃ u, IsOpen u ∧ x ∈ u ∧ ContDiffOn 𝕜 (↑m) f (insert x s ∩ u) [PROOFSTEP] exact ⟨u, huo, hxu, (hp.mono hut).contDiffOn⟩ [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ h : ContDiffWithinAt 𝕜 (↑n) f s x ⊢ ∀ᶠ (y : E) in 𝓝[insert x s] x, ContDiffWithinAt 𝕜 (↑n) f s y [PROOFSTEP] rcases h.contDiffOn le_rfl with ⟨u, hu, _, hd⟩ [GOAL] case intro.intro.intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ h : ContDiffWithinAt 𝕜 (↑n) f s x u : Set E hu : u ∈ 𝓝[insert x s] x left✝ : u ⊆ insert x s hd : ContDiffOn 𝕜 (↑n) f u ⊢ ∀ᶠ (y : E) in 𝓝[insert x s] x, ContDiffWithinAt 𝕜 (↑n) f s y [PROOFSTEP] have : ∀ᶠ y : E in 𝓝[insert x s] x, u ∈ 𝓝[insert x s] y ∧ y ∈ u := (eventually_nhdsWithin_nhdsWithin.2 hu).and hu [GOAL] case intro.intro.intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ h : ContDiffWithinAt 𝕜 (↑n) f s x u : Set E hu : u ∈ 𝓝[insert x s] x left✝ : u ⊆ insert x s hd : ContDiffOn 𝕜 (↑n) f u this : ∀ᶠ (y : E) in 𝓝[insert x s] x, u ∈ 𝓝[insert x s] y ∧ y ∈ u ⊢ ∀ᶠ (y : E) in 𝓝[insert x s] x, ContDiffWithinAt 𝕜 (↑n) f s y [PROOFSTEP] refine' this.mono fun y hy => (hd y hy.2).mono_of_mem _ [GOAL] case intro.intro.intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ h : ContDiffWithinAt 𝕜 (↑n) f s x u : Set E hu : u ∈ 𝓝[insert x s] x left✝ : u ⊆ insert x s hd : ContDiffOn 𝕜 (↑n) f u this : ∀ᶠ (y : E) in 𝓝[insert x s] x, u ∈ 𝓝[insert x s] y ∧ y ∈ u y : E hy : u ∈ 𝓝[insert x s] y ∧ y ∈ u ⊢ u ∈ 𝓝[s] y [PROOFSTEP] exact nhdsWithin_mono y (subset_insert _ _) hy.1 [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F ⊢ (∀ (m : ℕ), ↑m ≤ ⊤ → ContDiffOn 𝕜 (↑m) f s) ↔ ∀ (n : ℕ), ContDiffOn 𝕜 (↑n) f s [PROOFSTEP] simp only [le_top, forall_prop_of_true] [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F ⊢ (∀ (n : ℕ∞), ContDiffOn 𝕜 n f s) ↔ ∀ (n : ℕ), ContDiffOn 𝕜 (↑n) f s [PROOFSTEP] refine' ⟨fun H n => H n, _⟩ [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F ⊢ (∀ (n : ℕ), ContDiffOn 𝕜 (↑n) f s) → ∀ (n : ℕ∞), ContDiffOn 𝕜 n f s [PROOFSTEP] rintro H (_ | n) [GOAL] case none 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F H : ∀ (n : ℕ), ContDiffOn 𝕜 (↑n) f s ⊢ ContDiffOn 𝕜 none f s case some 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F H : ∀ (n : ℕ), ContDiffOn 𝕜 (↑n) f s n : ℕ ⊢ ContDiffOn 𝕜 (some n) f s [PROOFSTEP] exacts [contDiffOn_top.2 H, H n] [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F h : ∀ (x : E), x ∈ s → ∃ u, IsOpen u ∧ x ∈ u ∧ ContDiffOn 𝕜 n f (s ∩ u) ⊢ ContDiffOn 𝕜 n f s [PROOFSTEP] intro x xs [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F h : ∀ (x : E), x ∈ s → ∃ u, IsOpen u ∧ x ∈ u ∧ ContDiffOn 𝕜 n f (s ∩ u) x : E xs : x ∈ s ⊢ ContDiffWithinAt 𝕜 n f s x [PROOFSTEP] rcases h x xs with ⟨u, u_open, xu, hu⟩ [GOAL] case intro.intro.intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F h : ∀ (x : E), x ∈ s → ∃ u, IsOpen u ∧ x ∈ u ∧ ContDiffOn 𝕜 n f (s ∩ u) x : E xs : x ∈ s u : Set E u_open : IsOpen u xu : x ∈ u hu : ContDiffOn 𝕜 n f (s ∩ u) ⊢ ContDiffWithinAt 𝕜 n f s x [PROOFSTEP] apply (contDiffWithinAt_inter _).1 (hu x ⟨xs, xu⟩) [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F h : ∀ (x : E), x ∈ s → ∃ u, IsOpen u ∧ x ∈ u ∧ ContDiffOn 𝕜 n f (s ∩ u) x : E xs : x ∈ s u : Set E u_open : IsOpen u xu : x ∈ u hu : ContDiffOn 𝕜 n f (s ∩ u) ⊢ u ∈ 𝓝 x [PROOFSTEP] exact IsOpen.mem_nhds u_open xu [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ ⊢ ContDiffOn 𝕜 (↑(n + 1)) f s ↔ ∀ (x : E), x ∈ s → ∃ u, u ∈ 𝓝[insert x s] x ∧ ∃ f', (∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) u x) ∧ ContDiffOn 𝕜 (↑n) f' u [PROOFSTEP] constructor [GOAL] case mp 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ ⊢ ContDiffOn 𝕜 (↑(n + 1)) f s → ∀ (x : E), x ∈ s → ∃ u, u ∈ 𝓝[insert x s] x ∧ ∃ f', (∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) u x) ∧ ContDiffOn 𝕜 (↑n) f' u [PROOFSTEP] intro h x hx [GOAL] case mp 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ h : ContDiffOn 𝕜 (↑(n + 1)) f s x : E hx : x ∈ s ⊢ ∃ u, u ∈ 𝓝[insert x s] x ∧ ∃ f', (∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) u x) ∧ ContDiffOn 𝕜 (↑n) f' u [PROOFSTEP] rcases(h x hx) n.succ le_rfl with ⟨u, hu, p, Hp⟩ [GOAL] case mp.intro.intro.intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m n✝ : ℕ∞ p✝ : E → FormalMultilinearSeries 𝕜 E F n : ℕ h : ContDiffOn 𝕜 (↑(n + 1)) f s x : E hx : x ∈ s u : Set E hu : u ∈ 𝓝[insert x s] x p : E → FormalMultilinearSeries 𝕜 E F Hp : HasFTaylorSeriesUpToOn (↑(Nat.succ n)) f p u ⊢ ∃ u, u ∈ 𝓝[insert x s] x ∧ ∃ f', (∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) u x) ∧ ContDiffOn 𝕜 (↑n) f' u [PROOFSTEP] refine' ⟨u, hu, fun y => (continuousMultilinearCurryFin1 𝕜 E F) (p y 1), fun y hy => Hp.hasFDerivWithinAt (WithTop.coe_le_coe.2 (Nat.le_add_left 1 n)) hy, _⟩ [GOAL] case mp.intro.intro.intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m n✝ : ℕ∞ p✝ : E → FormalMultilinearSeries 𝕜 E F n : ℕ h : ContDiffOn 𝕜 (↑(n + 1)) f s x : E hx : x ∈ s u : Set E hu : u ∈ 𝓝[insert x s] x p : E → FormalMultilinearSeries 𝕜 E F Hp : HasFTaylorSeriesUpToOn (↑(Nat.succ n)) f p u ⊢ ContDiffOn 𝕜 (↑n) (fun y => ↑(continuousMultilinearCurryFin1 𝕜 E F) (p y 1)) u [PROOFSTEP] rw [hasFTaylorSeriesUpToOn_succ_iff_right] at Hp [GOAL] case mp.intro.intro.intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m n✝ : ℕ∞ p✝ : E → FormalMultilinearSeries 𝕜 E F n : ℕ h : ContDiffOn 𝕜 (↑(n + 1)) f s x : E hx : x ∈ s u : Set E hu : u ∈ 𝓝[insert x s] x p : E → FormalMultilinearSeries 𝕜 E F Hp : (∀ (x : E), x ∈ u → ContinuousMultilinearMap.uncurry0 (p x 0) = f x) ∧ (∀ (x : E), x ∈ u → HasFDerivWithinAt (fun y => p y 0) (ContinuousMultilinearMap.curryLeft (p x 1)) u x) ∧ HasFTaylorSeriesUpToOn (↑n) (fun x => ↑(continuousMultilinearCurryFin1 𝕜 E F) (p x 1)) (fun x => FormalMultilinearSeries.shift (p x)) u ⊢ ContDiffOn 𝕜 (↑n) (fun y => ↑(continuousMultilinearCurryFin1 𝕜 E F) (p y 1)) u [PROOFSTEP] intro z hz m hm [GOAL] case mp.intro.intro.intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝ n✝ : ℕ∞ p✝ : E → FormalMultilinearSeries 𝕜 E F n : ℕ h : ContDiffOn 𝕜 (↑(n + 1)) f s x : E hx : x ∈ s u : Set E hu : u ∈ 𝓝[insert x s] x p : E → FormalMultilinearSeries 𝕜 E F Hp : (∀ (x : E), x ∈ u → ContinuousMultilinearMap.uncurry0 (p x 0) = f x) ∧ (∀ (x : E), x ∈ u → HasFDerivWithinAt (fun y => p y 0) (ContinuousMultilinearMap.curryLeft (p x 1)) u x) ∧ HasFTaylorSeriesUpToOn (↑n) (fun x => ↑(continuousMultilinearCurryFin1 𝕜 E F) (p x 1)) (fun x => FormalMultilinearSeries.shift (p x)) u z : E hz : z ∈ u m : ℕ hm : ↑m ≤ ↑n ⊢ ∃ u_1, u_1 ∈ 𝓝[insert z u] z ∧ ∃ p_1, HasFTaylorSeriesUpToOn (↑m) (fun y => ↑(continuousMultilinearCurryFin1 𝕜 E F) (p y 1)) p_1 u_1 [PROOFSTEP] refine' ⟨u, _, fun x : E => (p x).shift, Hp.2.2.of_le hm⟩ -- Porting note: without the explicit arguments `convert` can not determine the type. [GOAL] case mp.intro.intro.intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝ n✝ : ℕ∞ p✝ : E → FormalMultilinearSeries 𝕜 E F n : ℕ h : ContDiffOn 𝕜 (↑(n + 1)) f s x : E hx : x ∈ s u : Set E hu : u ∈ 𝓝[insert x s] x p : E → FormalMultilinearSeries 𝕜 E F Hp : (∀ (x : E), x ∈ u → ContinuousMultilinearMap.uncurry0 (p x 0) = f x) ∧ (∀ (x : E), x ∈ u → HasFDerivWithinAt (fun y => p y 0) (ContinuousMultilinearMap.curryLeft (p x 1)) u x) ∧ HasFTaylorSeriesUpToOn (↑n) (fun x => ↑(continuousMultilinearCurryFin1 𝕜 E F) (p x 1)) (fun x => FormalMultilinearSeries.shift (p x)) u z : E hz : z ∈ u m : ℕ hm : ↑m ≤ ↑n ⊢ u ∈ 𝓝[insert z u] z [PROOFSTEP] convert @self_mem_nhdsWithin _ _ z u [GOAL] case h.e'_5.h.e'_4 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝ n✝ : ℕ∞ p✝ : E → FormalMultilinearSeries 𝕜 E F n : ℕ h : ContDiffOn 𝕜 (↑(n + 1)) f s x : E hx : x ∈ s u : Set E hu : u ∈ 𝓝[insert x s] x p : E → FormalMultilinearSeries 𝕜 E F Hp : (∀ (x : E), x ∈ u → ContinuousMultilinearMap.uncurry0 (p x 0) = f x) ∧ (∀ (x : E), x ∈ u → HasFDerivWithinAt (fun y => p y 0) (ContinuousMultilinearMap.curryLeft (p x 1)) u x) ∧ HasFTaylorSeriesUpToOn (↑n) (fun x => ↑(continuousMultilinearCurryFin1 𝕜 E F) (p x 1)) (fun x => FormalMultilinearSeries.shift (p x)) u z : E hz : z ∈ u m : ℕ hm : ↑m ≤ ↑n ⊢ insert z u = u [PROOFSTEP] exact insert_eq_of_mem hz [GOAL] case mpr 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ ⊢ (∀ (x : E), x ∈ s → ∃ u, u ∈ 𝓝[insert x s] x ∧ ∃ f', (∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) u x) ∧ ContDiffOn 𝕜 (↑n) f' u) → ContDiffOn 𝕜 (↑(n + 1)) f s [PROOFSTEP] intro h x hx [GOAL] case mpr 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ h : ∀ (x : E), x ∈ s → ∃ u, u ∈ 𝓝[insert x s] x ∧ ∃ f', (∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) u x) ∧ ContDiffOn 𝕜 (↑n) f' u x : E hx : x ∈ s ⊢ ContDiffWithinAt 𝕜 (↑(n + 1)) f s x [PROOFSTEP] rw [contDiffWithinAt_succ_iff_hasFDerivWithinAt] [GOAL] case mpr 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ h : ∀ (x : E), x ∈ s → ∃ u, u ∈ 𝓝[insert x s] x ∧ ∃ f', (∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) u x) ∧ ContDiffOn 𝕜 (↑n) f' u x : E hx : x ∈ s ⊢ ∃ u, u ∈ 𝓝[insert x s] x ∧ ∃ f', (∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) u x) ∧ ContDiffWithinAt 𝕜 (↑n) f' u x [PROOFSTEP] rcases h x hx with ⟨u, u_nhbd, f', hu, hf'⟩ [GOAL] case mpr.intro.intro.intro.intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ h : ∀ (x : E), x ∈ s → ∃ u, u ∈ 𝓝[insert x s] x ∧ ∃ f', (∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) u x) ∧ ContDiffOn 𝕜 (↑n) f' u x : E hx : x ∈ s u : Set E u_nhbd : u ∈ 𝓝[insert x s] x f' : E → E →L[𝕜] F hu : ∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) u x hf' : ContDiffOn 𝕜 (↑n) f' u ⊢ ∃ u, u ∈ 𝓝[insert x s] x ∧ ∃ f', (∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) u x) ∧ ContDiffWithinAt 𝕜 (↑n) f' u x [PROOFSTEP] have : x ∈ u := mem_of_mem_nhdsWithin (mem_insert _ _) u_nhbd [GOAL] case mpr.intro.intro.intro.intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ h : ∀ (x : E), x ∈ s → ∃ u, u ∈ 𝓝[insert x s] x ∧ ∃ f', (∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) u x) ∧ ContDiffOn 𝕜 (↑n) f' u x : E hx : x ∈ s u : Set E u_nhbd : u ∈ 𝓝[insert x s] x f' : E → E →L[𝕜] F hu : ∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) u x hf' : ContDiffOn 𝕜 (↑n) f' u this : x ∈ u ⊢ ∃ u, u ∈ 𝓝[insert x s] x ∧ ∃ f', (∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) u x) ∧ ContDiffWithinAt 𝕜 (↑n) f' u x [PROOFSTEP] exact ⟨u, u_nhbd, f', hu, hf' x this⟩ [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F ⊢ ‖iteratedFDerivWithin 𝕜 0 f s x‖ = ‖f x‖ [PROOFSTEP] rw [iteratedFDerivWithin_zero_eq_comp, comp_apply, LinearIsometryEquiv.norm_map] [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s✝ s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F s : Set E n : ℕ ⊢ fderivWithin 𝕜 (iteratedFDerivWithin 𝕜 n f s) s = ↑(LinearIsometryEquiv.symm (continuousMultilinearCurryLeftEquiv 𝕜 (fun x => E) F)) ∘ iteratedFDerivWithin 𝕜 (n + 1) f s [PROOFSTEP] rw [iteratedFDerivWithin_succ_eq_comp_left] [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s✝ s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F s : Set E n : ℕ ⊢ fderivWithin 𝕜 (iteratedFDerivWithin 𝕜 n f s) s = ↑(LinearIsometryEquiv.symm (continuousMultilinearCurryLeftEquiv 𝕜 (fun x => E) F)) ∘ ↑(continuousMultilinearCurryLeftEquiv 𝕜 (fun x => E) F) ∘ fderivWithin 𝕜 (iteratedFDerivWithin 𝕜 n f s) s [PROOFSTEP] ext1 x [GOAL] case h 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s✝ s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F s : Set E n : ℕ x : E ⊢ fderivWithin 𝕜 (iteratedFDerivWithin 𝕜 n f s) s x = (↑(LinearIsometryEquiv.symm (continuousMultilinearCurryLeftEquiv 𝕜 (fun x => E) F)) ∘ ↑(continuousMultilinearCurryLeftEquiv 𝕜 (fun x => E) F) ∘ fderivWithin 𝕜 (iteratedFDerivWithin 𝕜 n f s) s) x [PROOFSTEP] simp only [Function.comp_apply, LinearIsometryEquiv.symm_apply_apply] [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ ⊢ ‖fderivWithin 𝕜 (iteratedFDerivWithin 𝕜 n f s) s x‖ = ‖iteratedFDerivWithin 𝕜 (n + 1) f s x‖ [PROOFSTEP] rw [iteratedFDerivWithin_succ_eq_comp_left, comp_apply, LinearIsometryEquiv.norm_map] [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m✝ n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ hs : UniqueDiffOn 𝕜 s hx : x ∈ s m : Fin (n + 1) → E ⊢ ↑(iteratedFDerivWithin 𝕜 (n + 1) f s x) m = ↑(↑(iteratedFDerivWithin 𝕜 n (fun y => fderivWithin 𝕜 f s y) s x) (init m)) (m (last n)) [PROOFSTEP] induction' n with n IH generalizing x [GOAL] case zero 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝¹ n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ hs : UniqueDiffOn 𝕜 s hx✝ : x✝ ∈ s m✝ : Fin (n + 1) → E x : E hx : x ∈ s m : Fin (Nat.zero + 1) → E ⊢ ↑(iteratedFDerivWithin 𝕜 (Nat.zero + 1) f s x) m = ↑(↑(iteratedFDerivWithin 𝕜 Nat.zero (fun y => fderivWithin 𝕜 f s y) s x) (init m)) (m (last Nat.zero)) [PROOFSTEP] rw [iteratedFDerivWithin_succ_eq_comp_left, iteratedFDerivWithin_zero_eq_comp, iteratedFDerivWithin_zero_apply, Function.comp_apply, LinearIsometryEquiv.comp_fderivWithin _ (hs x hx)] [GOAL] case zero 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝¹ n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ hs : UniqueDiffOn 𝕜 s hx✝ : x✝ ∈ s m✝ : Fin (n + 1) → E x : E hx : x ∈ s m : Fin (Nat.zero + 1) → E ⊢ ↑(↑(continuousMultilinearCurryLeftEquiv 𝕜 (fun x => E) F) (ContinuousLinearMap.comp (↑(ContinuousLinearEquiv.mk (LinearIsometryEquiv.symm (continuousMultilinearCurryFin0 𝕜 E F)).toLinearEquiv)) (fderivWithin 𝕜 f s x))) m = ↑(fderivWithin 𝕜 f s x) (m (last Nat.zero)) [PROOFSTEP] rfl [GOAL] case succ 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝¹ n✝¹ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n✝ : ℕ hs : UniqueDiffOn 𝕜 s hx✝ : x✝ ∈ s m✝ : Fin (n✝ + 1) → E n : ℕ IH : ∀ {x : E}, x ∈ s → ∀ (m : Fin (n + 1) → E), ↑(iteratedFDerivWithin 𝕜 (n + 1) f s x) m = ↑(↑(iteratedFDerivWithin 𝕜 n (fun y => fderivWithin 𝕜 f s y) s x) (init m)) (m (last n)) x : E hx : x ∈ s m : Fin (Nat.succ n + 1) → E ⊢ ↑(iteratedFDerivWithin 𝕜 (Nat.succ n + 1) f s x) m = ↑(↑(iteratedFDerivWithin 𝕜 (Nat.succ n) (fun y => fderivWithin 𝕜 f s y) s x) (init m)) (m (last (Nat.succ n))) [PROOFSTEP] let I := continuousMultilinearCurryRightEquiv' 𝕜 n E F [GOAL] case succ 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝¹ n✝¹ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n✝ : ℕ hs : UniqueDiffOn 𝕜 s hx✝ : x✝ ∈ s m✝ : Fin (n✝ + 1) → E n : ℕ IH : ∀ {x : E}, x ∈ s → ∀ (m : Fin (n + 1) → E), ↑(iteratedFDerivWithin 𝕜 (n + 1) f s x) m = ↑(↑(iteratedFDerivWithin 𝕜 n (fun y => fderivWithin 𝕜 f s y) s x) (init m)) (m (last n)) x : E hx : x ∈ s m : Fin (Nat.succ n + 1) → E I : ContinuousMultilinearMap 𝕜 (fun i => E) (E →L[𝕜] F) ≃ₗᵢ[𝕜] ContinuousMultilinearMap 𝕜 (fun i => E) F := continuousMultilinearCurryRightEquiv' 𝕜 n E F ⊢ ↑(iteratedFDerivWithin 𝕜 (Nat.succ n + 1) f s x) m = ↑(↑(iteratedFDerivWithin 𝕜 (Nat.succ n) (fun y => fderivWithin 𝕜 f s y) s x) (init m)) (m (last (Nat.succ n))) [PROOFSTEP] have A : ∀ y ∈ s, iteratedFDerivWithin 𝕜 n.succ f s y = (I ∘ iteratedFDerivWithin 𝕜 n (fun y => fderivWithin 𝕜 f s y) s) y := fun y hy ↦ by ext m rw [@IH y hy m] rfl [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝¹ n✝¹ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n✝ : ℕ hs : UniqueDiffOn 𝕜 s hx✝ : x✝ ∈ s m✝ : Fin (n✝ + 1) → E n : ℕ IH : ∀ {x : E}, x ∈ s → ∀ (m : Fin (n + 1) → E), ↑(iteratedFDerivWithin 𝕜 (n + 1) f s x) m = ↑(↑(iteratedFDerivWithin 𝕜 n (fun y => fderivWithin 𝕜 f s y) s x) (init m)) (m (last n)) x : E hx : x ∈ s m : Fin (Nat.succ n + 1) → E I : ContinuousMultilinearMap 𝕜 (fun i => E) (E →L[𝕜] F) ≃ₗᵢ[𝕜] ContinuousMultilinearMap 𝕜 (fun i => E) F := continuousMultilinearCurryRightEquiv' 𝕜 n E F y : E hy : y ∈ s ⊢ iteratedFDerivWithin 𝕜 (Nat.succ n) f s y = (↑I ∘ iteratedFDerivWithin 𝕜 n (fun y => fderivWithin 𝕜 f s y) s) y [PROOFSTEP] ext m [GOAL] case H 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝² n✝¹ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n✝ : ℕ hs : UniqueDiffOn 𝕜 s hx✝ : x✝ ∈ s m✝¹ : Fin (n✝ + 1) → E n : ℕ IH : ∀ {x : E}, x ∈ s → ∀ (m : Fin (n + 1) → E), ↑(iteratedFDerivWithin 𝕜 (n + 1) f s x) m = ↑(↑(iteratedFDerivWithin 𝕜 n (fun y => fderivWithin 𝕜 f s y) s x) (init m)) (m (last n)) x : E hx : x ∈ s m✝ : Fin (Nat.succ n + 1) → E I : ContinuousMultilinearMap 𝕜 (fun i => E) (E →L[𝕜] F) ≃ₗᵢ[𝕜] ContinuousMultilinearMap 𝕜 (fun i => E) F := continuousMultilinearCurryRightEquiv' 𝕜 n E F y : E hy : y ∈ s m : Fin (Nat.succ n) → E ⊢ ↑(iteratedFDerivWithin 𝕜 (Nat.succ n) f s y) m = ↑((↑I ∘ iteratedFDerivWithin 𝕜 n (fun y => fderivWithin 𝕜 f s y) s) y) m [PROOFSTEP] rw [@IH y hy m] [GOAL] case H 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝² n✝¹ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n✝ : ℕ hs : UniqueDiffOn 𝕜 s hx✝ : x✝ ∈ s m✝¹ : Fin (n✝ + 1) → E n : ℕ IH : ∀ {x : E}, x ∈ s → ∀ (m : Fin (n + 1) → E), ↑(iteratedFDerivWithin 𝕜 (n + 1) f s x) m = ↑(↑(iteratedFDerivWithin 𝕜 n (fun y => fderivWithin 𝕜 f s y) s x) (init m)) (m (last n)) x : E hx : x ∈ s m✝ : Fin (Nat.succ n + 1) → E I : ContinuousMultilinearMap 𝕜 (fun i => E) (E →L[𝕜] F) ≃ₗᵢ[𝕜] ContinuousMultilinearMap 𝕜 (fun i => E) F := continuousMultilinearCurryRightEquiv' 𝕜 n E F y : E hy : y ∈ s m : Fin (Nat.succ n) → E ⊢ ↑(↑(iteratedFDerivWithin 𝕜 n (fun y => fderivWithin 𝕜 f s y) s y) (init m)) (m (last n)) = ↑((↑I ∘ iteratedFDerivWithin 𝕜 n (fun y => fderivWithin 𝕜 f s y) s) y) m [PROOFSTEP] rfl [GOAL] case succ 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝¹ n✝¹ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n✝ : ℕ hs : UniqueDiffOn 𝕜 s hx✝ : x✝ ∈ s m✝ : Fin (n✝ + 1) → E n : ℕ IH : ∀ {x : E}, x ∈ s → ∀ (m : Fin (n + 1) → E), ↑(iteratedFDerivWithin 𝕜 (n + 1) f s x) m = ↑(↑(iteratedFDerivWithin 𝕜 n (fun y => fderivWithin 𝕜 f s y) s x) (init m)) (m (last n)) x : E hx : x ∈ s m : Fin (Nat.succ n + 1) → E I : ContinuousMultilinearMap 𝕜 (fun i => E) (E →L[𝕜] F) ≃ₗᵢ[𝕜] ContinuousMultilinearMap 𝕜 (fun i => E) F := continuousMultilinearCurryRightEquiv' 𝕜 n E F A : ∀ (y : E), y ∈ s → iteratedFDerivWithin 𝕜 (Nat.succ n) f s y = (↑I ∘ iteratedFDerivWithin 𝕜 n (fun y => fderivWithin 𝕜 f s y) s) y ⊢ ↑(iteratedFDerivWithin 𝕜 (Nat.succ n + 1) f s x) m = ↑(↑(iteratedFDerivWithin 𝕜 (Nat.succ n) (fun y => fderivWithin 𝕜 f s y) s x) (init m)) (m (last (Nat.succ n))) [PROOFSTEP] calc (iteratedFDerivWithin 𝕜 (n + 2) f s x : (Fin (n + 2) → E) → F) m = (fderivWithin 𝕜 (iteratedFDerivWithin 𝕜 n.succ f s) s x : E → E[×n + 1]→L[𝕜] F) (m 0) (tail m) := rfl _ = (fderivWithin 𝕜 (I ∘ iteratedFDerivWithin 𝕜 n (fderivWithin 𝕜 f s) s) s x : E → E[×n + 1]→L[𝕜] F) (m 0) (tail m) := by rw [fderivWithin_congr A (A x hx)] _ = (I ∘ fderivWithin 𝕜 (iteratedFDerivWithin 𝕜 n (fderivWithin 𝕜 f s) s) s x : E → E[×n + 1]→L[𝕜] F) (m 0) (tail m) := by simp only [LinearIsometryEquiv.comp_fderivWithin _ (hs x hx)]; rfl _ = (fderivWithin 𝕜 (iteratedFDerivWithin 𝕜 n (fun y => fderivWithin 𝕜 f s y) s) s x : E → E[×n]→L[𝕜] E →L[𝕜] F) (m 0) (init (tail m)) ((tail m) (last n)) := rfl _ = iteratedFDerivWithin 𝕜 (Nat.succ n) (fun y => fderivWithin 𝕜 f s y) s x (init m) (m (last (n + 1))) := by rw [iteratedFDerivWithin_succ_apply_left, tail_init_eq_init_tail] rfl [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝¹ n✝¹ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n✝ : ℕ hs : UniqueDiffOn 𝕜 s hx✝ : x✝ ∈ s m✝ : Fin (n✝ + 1) → E n : ℕ IH : ∀ {x : E}, x ∈ s → ∀ (m : Fin (n + 1) → E), ↑(iteratedFDerivWithin 𝕜 (n + 1) f s x) m = ↑(↑(iteratedFDerivWithin 𝕜 n (fun y => fderivWithin 𝕜 f s y) s x) (init m)) (m (last n)) x : E hx : x ∈ s m : Fin (Nat.succ n + 1) → E I : ContinuousMultilinearMap 𝕜 (fun i => E) (E →L[𝕜] F) ≃ₗᵢ[𝕜] ContinuousMultilinearMap 𝕜 (fun i => E) F := continuousMultilinearCurryRightEquiv' 𝕜 n E F A : ∀ (y : E), y ∈ s → iteratedFDerivWithin 𝕜 (Nat.succ n) f s y = (↑I ∘ iteratedFDerivWithin 𝕜 n (fun y => fderivWithin 𝕜 f s y) s) y ⊢ ↑(↑(fderivWithin 𝕜 (iteratedFDerivWithin 𝕜 (Nat.succ n) f s) s x) (m 0)) (tail m) = ↑(↑(fderivWithin 𝕜 (↑I ∘ iteratedFDerivWithin 𝕜 n (fderivWithin 𝕜 f s) s) s x) (m 0)) (tail m) [PROOFSTEP] rw [fderivWithin_congr A (A x hx)] [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝¹ n✝¹ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n✝ : ℕ hs : UniqueDiffOn 𝕜 s hx✝ : x✝ ∈ s m✝ : Fin (n✝ + 1) → E n : ℕ IH : ∀ {x : E}, x ∈ s → ∀ (m : Fin (n + 1) → E), ↑(iteratedFDerivWithin 𝕜 (n + 1) f s x) m = ↑(↑(iteratedFDerivWithin 𝕜 n (fun y => fderivWithin 𝕜 f s y) s x) (init m)) (m (last n)) x : E hx : x ∈ s m : Fin (Nat.succ n + 1) → E I : ContinuousMultilinearMap 𝕜 (fun i => E) (E →L[𝕜] F) ≃ₗᵢ[𝕜] ContinuousMultilinearMap 𝕜 (fun i => E) F := continuousMultilinearCurryRightEquiv' 𝕜 n E F A : ∀ (y : E), y ∈ s → iteratedFDerivWithin 𝕜 (Nat.succ n) f s y = (↑I ∘ iteratedFDerivWithin 𝕜 n (fun y => fderivWithin 𝕜 f s y) s) y ⊢ ↑(↑(fderivWithin 𝕜 (↑I ∘ iteratedFDerivWithin 𝕜 n (fderivWithin 𝕜 f s) s) s x) (m 0)) (tail m) = ↑((↑I ∘ ↑(fderivWithin 𝕜 (iteratedFDerivWithin 𝕜 n (fderivWithin 𝕜 f s) s) s x)) (m 0)) (tail m) [PROOFSTEP] simp only [LinearIsometryEquiv.comp_fderivWithin _ (hs x hx)] [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝¹ n✝¹ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n✝ : ℕ hs : UniqueDiffOn 𝕜 s hx✝ : x✝ ∈ s m✝ : Fin (n✝ + 1) → E n : ℕ IH : ∀ {x : E}, x ∈ s → ∀ (m : Fin (n + 1) → E), ↑(iteratedFDerivWithin 𝕜 (n + 1) f s x) m = ↑(↑(iteratedFDerivWithin 𝕜 n (fun y => fderivWithin 𝕜 f s y) s x) (init m)) (m (last n)) x : E hx : x ∈ s m : Fin (Nat.succ n + 1) → E I : ContinuousMultilinearMap 𝕜 (fun i => E) (E →L[𝕜] F) ≃ₗᵢ[𝕜] ContinuousMultilinearMap 𝕜 (fun i => E) F := continuousMultilinearCurryRightEquiv' 𝕜 n E F A : ∀ (y : E), y ∈ s → iteratedFDerivWithin 𝕜 (Nat.succ n) f s y = (↑I ∘ iteratedFDerivWithin 𝕜 n (fun y => fderivWithin 𝕜 f s y) s) y ⊢ ↑(↑(ContinuousLinearMap.comp (↑(ContinuousLinearEquiv.mk (continuousMultilinearCurryRightEquiv' 𝕜 n E F).toLinearEquiv)) (fderivWithin 𝕜 (iteratedFDerivWithin 𝕜 n (fderivWithin 𝕜 f s) s) s x)) (m 0)) (tail m) = ↑((↑(continuousMultilinearCurryRightEquiv' 𝕜 n E F) ∘ ↑(fderivWithin 𝕜 (iteratedFDerivWithin 𝕜 n (fderivWithin 𝕜 f s) s) s x)) (m 0)) (tail m) [PROOFSTEP] rfl [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝¹ n✝¹ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n✝ : ℕ hs : UniqueDiffOn 𝕜 s hx✝ : x✝ ∈ s m✝ : Fin (n✝ + 1) → E n : ℕ IH : ∀ {x : E}, x ∈ s → ∀ (m : Fin (n + 1) → E), ↑(iteratedFDerivWithin 𝕜 (n + 1) f s x) m = ↑(↑(iteratedFDerivWithin 𝕜 n (fun y => fderivWithin 𝕜 f s y) s x) (init m)) (m (last n)) x : E hx : x ∈ s m : Fin (Nat.succ n + 1) → E I : ContinuousMultilinearMap 𝕜 (fun i => E) (E →L[𝕜] F) ≃ₗᵢ[𝕜] ContinuousMultilinearMap 𝕜 (fun i => E) F := continuousMultilinearCurryRightEquiv' 𝕜 n E F A : ∀ (y : E), y ∈ s → iteratedFDerivWithin 𝕜 (Nat.succ n) f s y = (↑I ∘ iteratedFDerivWithin 𝕜 n (fun y => fderivWithin 𝕜 f s y) s) y ⊢ ↑(↑(↑(fderivWithin 𝕜 (iteratedFDerivWithin 𝕜 n (fun y => fderivWithin 𝕜 f s y) s) s x) (m 0)) (init (tail m))) (tail m (last n)) = ↑(↑(iteratedFDerivWithin 𝕜 (Nat.succ n) (fun y => fderivWithin 𝕜 f s y) s x) (init m)) (m (last (n + 1))) [PROOFSTEP] rw [iteratedFDerivWithin_succ_apply_left, tail_init_eq_init_tail] [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝¹ n✝¹ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n✝ : ℕ hs : UniqueDiffOn 𝕜 s hx✝ : x✝ ∈ s m✝ : Fin (n✝ + 1) → E n : ℕ IH : ∀ {x : E}, x ∈ s → ∀ (m : Fin (n + 1) → E), ↑(iteratedFDerivWithin 𝕜 (n + 1) f s x) m = ↑(↑(iteratedFDerivWithin 𝕜 n (fun y => fderivWithin 𝕜 f s y) s x) (init m)) (m (last n)) x : E hx : x ∈ s m : Fin (Nat.succ n + 1) → E I : ContinuousMultilinearMap 𝕜 (fun i => E) (E →L[𝕜] F) ≃ₗᵢ[𝕜] ContinuousMultilinearMap 𝕜 (fun i => E) F := continuousMultilinearCurryRightEquiv' 𝕜 n E F A : ∀ (y : E), y ∈ s → iteratedFDerivWithin 𝕜 (Nat.succ n) f s y = (↑I ∘ iteratedFDerivWithin 𝕜 n (fun y => fderivWithin 𝕜 f s y) s) y ⊢ ↑(↑(↑(fderivWithin 𝕜 (iteratedFDerivWithin 𝕜 n (fun y => fderivWithin 𝕜 f s y) s) s x) (m 0)) (init (tail m))) (tail m (last n)) = ↑(↑(↑(fderivWithin 𝕜 (iteratedFDerivWithin 𝕜 n (fun y => fderivWithin 𝕜 f s y) s) s x) (init m 0)) (init (tail m))) (m (last (n + 1))) [PROOFSTEP] rfl [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ hs : UniqueDiffOn 𝕜 s hx : x ∈ s ⊢ iteratedFDerivWithin 𝕜 (n + 1) f s x = (↑(continuousMultilinearCurryRightEquiv' 𝕜 n E F) ∘ iteratedFDerivWithin 𝕜 n (fun y => fderivWithin 𝕜 f s y) s) x [PROOFSTEP] ext m [GOAL] case H 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m✝ n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ hs : UniqueDiffOn 𝕜 s hx : x ∈ s m : Fin (n + 1) → E ⊢ ↑(iteratedFDerivWithin 𝕜 (n + 1) f s x) m = ↑((↑(continuousMultilinearCurryRightEquiv' 𝕜 n E F) ∘ iteratedFDerivWithin 𝕜 n (fun y => fderivWithin 𝕜 f s y) s) x) m [PROOFSTEP] rw [iteratedFDerivWithin_succ_apply_right hs hx] [GOAL] case H 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m✝ n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ hs : UniqueDiffOn 𝕜 s hx : x ∈ s m : Fin (n + 1) → E ⊢ ↑(↑(iteratedFDerivWithin 𝕜 n (fun y => fderivWithin 𝕜 f s y) s x) (init m)) (m (last n)) = ↑((↑(continuousMultilinearCurryRightEquiv' 𝕜 n E F) ∘ iteratedFDerivWithin 𝕜 n (fun y => fderivWithin 𝕜 f s y) s) x) m [PROOFSTEP] rfl [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ hs : UniqueDiffOn 𝕜 s hx : x ∈ s ⊢ ‖iteratedFDerivWithin 𝕜 n (fderivWithin 𝕜 f s) s x‖ = ‖iteratedFDerivWithin 𝕜 (n + 1) f s x‖ [PROOFSTEP] rw [iteratedFDerivWithin_succ_eq_comp_right hs hx, comp_apply, LinearIsometryEquiv.norm_map] [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m✝ n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F h : UniqueDiffWithinAt 𝕜 s x m : Fin 1 → E ⊢ ↑(iteratedFDerivWithin 𝕜 1 f s x) m = ↑(fderivWithin 𝕜 f s x) (m 0) [PROOFSTEP] simp only [iteratedFDerivWithin_succ_apply_left, iteratedFDerivWithin_zero_eq_comp, (continuousMultilinearCurryFin0 𝕜 E F).symm.comp_fderivWithin h] [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m✝ n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F h : UniqueDiffWithinAt 𝕜 s x m : Fin 1 → E ⊢ ↑(↑(ContinuousLinearMap.comp (↑(ContinuousLinearEquiv.mk (LinearIsometryEquiv.symm (continuousMultilinearCurryFin0 𝕜 E F)).toLinearEquiv)) (fderivWithin 𝕜 f s x)) (m 0)) (tail m) = ↑(fderivWithin 𝕜 f s x) (m 0) [PROOFSTEP] rfl [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F h : f₁ =ᶠ[𝓝[s] x] f ht : t ⊆ s n : ℕ ⊢ iteratedFDerivWithin 𝕜 n f₁ t =ᶠ[𝓝[s] x] iteratedFDerivWithin 𝕜 n f t [PROOFSTEP] induction' n with n ihn [GOAL] case zero 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F h : f₁ =ᶠ[𝓝[s] x] f ht : t ⊆ s ⊢ iteratedFDerivWithin 𝕜 Nat.zero f₁ t =ᶠ[𝓝[s] x] iteratedFDerivWithin 𝕜 Nat.zero f t [PROOFSTEP] exact h.mono fun y hy => FunLike.ext _ _ fun _ => hy [GOAL] case succ 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F h : f₁ =ᶠ[𝓝[s] x] f ht : t ⊆ s n : ℕ ihn : iteratedFDerivWithin 𝕜 n f₁ t =ᶠ[𝓝[s] x] iteratedFDerivWithin 𝕜 n f t ⊢ iteratedFDerivWithin 𝕜 (Nat.succ n) f₁ t =ᶠ[𝓝[s] x] iteratedFDerivWithin 𝕜 (Nat.succ n) f t [PROOFSTEP] have : fderivWithin 𝕜 _ t =ᶠ[𝓝[s] x] fderivWithin 𝕜 _ t := ihn.fderiv_within' ht [GOAL] case succ 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F h : f₁ =ᶠ[𝓝[s] x] f ht : t ⊆ s n : ℕ ihn : iteratedFDerivWithin 𝕜 n f₁ t =ᶠ[𝓝[s] x] iteratedFDerivWithin 𝕜 n f t this : fderivWithin 𝕜 (iteratedFDerivWithin 𝕜 n f₁ t) t =ᶠ[𝓝[s] x] fderivWithin 𝕜 (iteratedFDerivWithin 𝕜 n f t) t ⊢ iteratedFDerivWithin 𝕜 (Nat.succ n) f₁ t =ᶠ[𝓝[s] x] iteratedFDerivWithin 𝕜 (Nat.succ n) f t [PROOFSTEP] apply this.mono [GOAL] case succ 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F h : f₁ =ᶠ[𝓝[s] x] f ht : t ⊆ s n : ℕ ihn : iteratedFDerivWithin 𝕜 n f₁ t =ᶠ[𝓝[s] x] iteratedFDerivWithin 𝕜 n f t this : fderivWithin 𝕜 (iteratedFDerivWithin 𝕜 n f₁ t) t =ᶠ[𝓝[s] x] fderivWithin 𝕜 (iteratedFDerivWithin 𝕜 n f t) t ⊢ ∀ (x : E), fderivWithin 𝕜 (iteratedFDerivWithin 𝕜 n f₁ t) t x = fderivWithin 𝕜 (iteratedFDerivWithin 𝕜 n f t) t x → iteratedFDerivWithin 𝕜 (Nat.succ n) f₁ t x = iteratedFDerivWithin 𝕜 (Nat.succ n) f t x [PROOFSTEP] intro y hy [GOAL] case succ 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F h : f₁ =ᶠ[𝓝[s] x] f ht : t ⊆ s n : ℕ ihn : iteratedFDerivWithin 𝕜 n f₁ t =ᶠ[𝓝[s] x] iteratedFDerivWithin 𝕜 n f t this : fderivWithin 𝕜 (iteratedFDerivWithin 𝕜 n f₁ t) t =ᶠ[𝓝[s] x] fderivWithin 𝕜 (iteratedFDerivWithin 𝕜 n f t) t y : E hy : fderivWithin 𝕜 (iteratedFDerivWithin 𝕜 n f₁ t) t y = fderivWithin 𝕜 (iteratedFDerivWithin 𝕜 n f t) t y ⊢ iteratedFDerivWithin 𝕜 (Nat.succ n) f₁ t y = iteratedFDerivWithin 𝕜 (Nat.succ n) f t y [PROOFSTEP] simp only [iteratedFDerivWithin_succ_eq_comp_left, hy, (· ∘ ·)] [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F h : f₁ =ᶠ[𝓝[s] x] f hx : f₁ x = f x n : ℕ ⊢ f₁ =ᶠ[𝓝[insert x s] x] f [PROOFSTEP] simpa [EventuallyEq, hx] [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F y : E h : s =ᶠ[𝓝[{y}ᶜ] x] t n : ℕ ⊢ iteratedFDerivWithin 𝕜 n f s =ᶠ[𝓝 x] iteratedFDerivWithin 𝕜 n f t [PROOFSTEP] induction' n with n ihn generalizing x [GOAL] case zero 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F y : E h✝ : s =ᶠ[𝓝[{y}ᶜ] x✝] t x : E h : s =ᶠ[𝓝[{y}ᶜ] x] t ⊢ iteratedFDerivWithin 𝕜 Nat.zero f s =ᶠ[𝓝 x] iteratedFDerivWithin 𝕜 Nat.zero f t [PROOFSTEP] rfl [GOAL] case succ 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F y : E h✝ : s =ᶠ[𝓝[{y}ᶜ] x✝] t n : ℕ ihn : ∀ {x : E}, s =ᶠ[𝓝[{y}ᶜ] x] t → iteratedFDerivWithin 𝕜 n f s =ᶠ[𝓝 x] iteratedFDerivWithin 𝕜 n f t x : E h : s =ᶠ[𝓝[{y}ᶜ] x] t ⊢ iteratedFDerivWithin 𝕜 (Nat.succ n) f s =ᶠ[𝓝 x] iteratedFDerivWithin 𝕜 (Nat.succ n) f t [PROOFSTEP] refine' (eventually_nhds_nhdsWithin.2 h).mono fun y hy => _ [GOAL] case succ 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F y✝ : E h✝ : s =ᶠ[𝓝[{y✝}ᶜ] x✝] t n : ℕ ihn : ∀ {x : E}, s =ᶠ[𝓝[{y✝}ᶜ] x] t → iteratedFDerivWithin 𝕜 n f s =ᶠ[𝓝 x] iteratedFDerivWithin 𝕜 n f t x : E h : s =ᶠ[𝓝[{y✝}ᶜ] x] t y : E hy : ∀ᶠ (x : E) in 𝓝[{y✝}ᶜ] y, s x = t x ⊢ iteratedFDerivWithin 𝕜 (Nat.succ n) f s y = iteratedFDerivWithin 𝕜 (Nat.succ n) f t y [PROOFSTEP] simp only [iteratedFDerivWithin_succ_eq_comp_left, (· ∘ ·)] [GOAL] case succ 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F y✝ : E h✝ : s =ᶠ[𝓝[{y✝}ᶜ] x✝] t n : ℕ ihn : ∀ {x : E}, s =ᶠ[𝓝[{y✝}ᶜ] x] t → iteratedFDerivWithin 𝕜 n f s =ᶠ[𝓝 x] iteratedFDerivWithin 𝕜 n f t x : E h : s =ᶠ[𝓝[{y✝}ᶜ] x] t y : E hy : ∀ᶠ (x : E) in 𝓝[{y✝}ᶜ] y, s x = t x ⊢ ↑(continuousMultilinearCurryLeftEquiv 𝕜 (fun x => E) F) (fderivWithin 𝕜 (iteratedFDerivWithin 𝕜 n f s) s y) = ↑(continuousMultilinearCurryLeftEquiv 𝕜 (fun x => E) F) (fderivWithin 𝕜 (iteratedFDerivWithin 𝕜 n f t) t y) [PROOFSTEP] rw [(ihn hy).fderivWithin_eq_nhds, fderivWithin_congr_set' _ hy] [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F ⊢ ContDiffOn 𝕜 0 f s ↔ ContinuousOn f s [PROOFSTEP] refine' ⟨fun H => H.continuousOn, fun H => _⟩ [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F H : ContinuousOn f s ⊢ ContDiffOn 𝕜 0 f s [PROOFSTEP] intro x hx m hm [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝ n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F H : ContinuousOn f s x : E hx : x ∈ s m : ℕ hm : ↑m ≤ 0 ⊢ ∃ u, u ∈ 𝓝[insert x s] x ∧ ∃ p, HasFTaylorSeriesUpToOn (↑m) f p u [PROOFSTEP] have : (m : ℕ∞) = 0 := le_antisymm hm bot_le [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝ n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F H : ContinuousOn f s x : E hx : x ∈ s m : ℕ hm : ↑m ≤ 0 this : ↑m = 0 ⊢ ∃ u, u ∈ 𝓝[insert x s] x ∧ ∃ p, HasFTaylorSeriesUpToOn (↑m) f p u [PROOFSTEP] rw [this] [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝ n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F H : ContinuousOn f s x : E hx : x ∈ s m : ℕ hm : ↑m ≤ 0 this : ↑m = 0 ⊢ ∃ u, u ∈ 𝓝[insert x s] x ∧ ∃ p, HasFTaylorSeriesUpToOn 0 f p u [PROOFSTEP] refine' ⟨insert x s, self_mem_nhdsWithin, ftaylorSeriesWithin 𝕜 f s, _⟩ [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝ n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F H : ContinuousOn f s x : E hx : x ∈ s m : ℕ hm : ↑m ≤ 0 this : ↑m = 0 ⊢ HasFTaylorSeriesUpToOn 0 f (ftaylorSeriesWithin 𝕜 f s) (insert x s) [PROOFSTEP] rw [hasFTaylorSeriesUpToOn_zero_iff] [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝ n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F H : ContinuousOn f s x : E hx : x ∈ s m : ℕ hm : ↑m ≤ 0 this : ↑m = 0 ⊢ ContinuousOn f (insert x s) ∧ ∀ (x_1 : E), x_1 ∈ insert x s → ContinuousMultilinearMap.uncurry0 (ftaylorSeriesWithin 𝕜 f s x_1 0) = f x_1 [PROOFSTEP] exact ⟨by rwa [insert_eq_of_mem hx], fun x _ => by simp [ftaylorSeriesWithin]⟩ [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝ n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F H : ContinuousOn f s x : E hx : x ∈ s m : ℕ hm : ↑m ≤ 0 this : ↑m = 0 ⊢ ContinuousOn f (insert x s) [PROOFSTEP] rwa [insert_eq_of_mem hx] [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝² x₀ : E c : F m✝ n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F H : ContinuousOn f s x✝¹ : E hx : x✝¹ ∈ s m : ℕ hm : ↑m ≤ 0 this : ↑m = 0 x : E x✝ : x ∈ insert x✝¹ s ⊢ ContinuousMultilinearMap.uncurry0 (ftaylorSeriesWithin 𝕜 f s x 0) = f x [PROOFSTEP] simp [ftaylorSeriesWithin] [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F hx : x ∈ s ⊢ ContDiffWithinAt 𝕜 0 f s x ↔ ∃ u, u ∈ 𝓝[s] x ∧ ContinuousOn f (s ∩ u) [PROOFSTEP] constructor [GOAL] case mp 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F hx : x ∈ s ⊢ ContDiffWithinAt 𝕜 0 f s x → ∃ u, u ∈ 𝓝[s] x ∧ ContinuousOn f (s ∩ u) [PROOFSTEP] intro h [GOAL] case mp 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F hx : x ∈ s h : ContDiffWithinAt 𝕜 0 f s x ⊢ ∃ u, u ∈ 𝓝[s] x ∧ ContinuousOn f (s ∩ u) [PROOFSTEP] obtain ⟨u, H, p, hp⟩ := h 0 le_rfl [GOAL] case mp.intro.intro.intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p✝ : E → FormalMultilinearSeries 𝕜 E F hx : x ∈ s h : ContDiffWithinAt 𝕜 0 f s x u : Set E H : u ∈ 𝓝[insert x s] x p : E → FormalMultilinearSeries 𝕜 E F hp : HasFTaylorSeriesUpToOn (↑0) f p u ⊢ ∃ u, u ∈ 𝓝[s] x ∧ ContinuousOn f (s ∩ u) [PROOFSTEP] refine' ⟨u, _, _⟩ [GOAL] case mp.intro.intro.intro.refine'_1 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p✝ : E → FormalMultilinearSeries 𝕜 E F hx : x ∈ s h : ContDiffWithinAt 𝕜 0 f s x u : Set E H : u ∈ 𝓝[insert x s] x p : E → FormalMultilinearSeries 𝕜 E F hp : HasFTaylorSeriesUpToOn (↑0) f p u ⊢ u ∈ 𝓝[s] x [PROOFSTEP] simpa [hx] using H [GOAL] case mp.intro.intro.intro.refine'_2 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p✝ : E → FormalMultilinearSeries 𝕜 E F hx : x ∈ s h : ContDiffWithinAt 𝕜 0 f s x u : Set E H : u ∈ 𝓝[insert x s] x p : E → FormalMultilinearSeries 𝕜 E F hp : HasFTaylorSeriesUpToOn (↑0) f p u ⊢ ContinuousOn f (s ∩ u) [PROOFSTEP] simp only [Nat.cast_zero, hasFTaylorSeriesUpToOn_zero_iff] at hp [GOAL] case mp.intro.intro.intro.refine'_2 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p✝ : E → FormalMultilinearSeries 𝕜 E F hx : x ∈ s h : ContDiffWithinAt 𝕜 0 f s x u : Set E H : u ∈ 𝓝[insert x s] x p : E → FormalMultilinearSeries 𝕜 E F hp : ContinuousOn f u ∧ ∀ (x : E), x ∈ u → ContinuousMultilinearMap.uncurry0 (p x 0) = f x ⊢ ContinuousOn f (s ∩ u) [PROOFSTEP] exact hp.1.mono (inter_subset_right s u) [GOAL] case mpr 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F hx : x ∈ s ⊢ (∃ u, u ∈ 𝓝[s] x ∧ ContinuousOn f (s ∩ u)) → ContDiffWithinAt 𝕜 0 f s x [PROOFSTEP] rintro ⟨u, H, hu⟩ [GOAL] case mpr.intro.intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F hx : x ∈ s u : Set E H : u ∈ 𝓝[s] x hu : ContinuousOn f (s ∩ u) ⊢ ContDiffWithinAt 𝕜 0 f s x [PROOFSTEP] rw [← contDiffWithinAt_inter' H] [GOAL] case mpr.intro.intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F hx : x ∈ s u : Set E H : u ∈ 𝓝[s] x hu : ContinuousOn f (s ∩ u) ⊢ ContDiffWithinAt 𝕜 0 f (s ∩ u) x [PROOFSTEP] have h' : x ∈ s ∩ u := ⟨hx, mem_of_mem_nhdsWithin hx H⟩ [GOAL] case mpr.intro.intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F hx : x ∈ s u : Set E H : u ∈ 𝓝[s] x hu : ContinuousOn f (s ∩ u) h' : x ∈ s ∩ u ⊢ ContDiffWithinAt 𝕜 0 f (s ∩ u) x [PROOFSTEP] exact (contDiffOn_zero.mpr hu).contDiffWithinAt h' [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m✝ n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F h : HasFTaylorSeriesUpToOn n f p s m : ℕ hmn : ↑m ≤ n hs : UniqueDiffOn 𝕜 s hx : x ∈ s ⊢ p x m = iteratedFDerivWithin 𝕜 m f s x [PROOFSTEP] induction' m with m IH generalizing x [GOAL] case zero 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝ n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F h : HasFTaylorSeriesUpToOn n f p s m : ℕ hmn✝ : ↑m ≤ n hs : UniqueDiffOn 𝕜 s hx✝ : x✝ ∈ s x : E hmn : ↑Nat.zero ≤ n hx : x ∈ s ⊢ p x Nat.zero = iteratedFDerivWithin 𝕜 Nat.zero f s x [PROOFSTEP] rw [Nat.zero_eq, h.zero_eq' hx, iteratedFDerivWithin_zero_eq_comp] [GOAL] case zero 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝ n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F h : HasFTaylorSeriesUpToOn n f p s m : ℕ hmn✝ : ↑m ≤ n hs : UniqueDiffOn 𝕜 s hx✝ : x✝ ∈ s x : E hmn : ↑Nat.zero ≤ n hx : x ∈ s ⊢ ↑(LinearIsometryEquiv.symm (continuousMultilinearCurryFin0 𝕜 E F)) (f x) = (↑(LinearIsometryEquiv.symm (continuousMultilinearCurryFin0 𝕜 E F)) ∘ f) x [PROOFSTEP] rfl [GOAL] case succ 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝¹ n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F h : HasFTaylorSeriesUpToOn n f p s m✝ : ℕ hmn✝ : ↑m✝ ≤ n hs : UniqueDiffOn 𝕜 s hx✝ : x✝ ∈ s m : ℕ IH : ∀ {x : E}, ↑m ≤ n → x ∈ s → p x m = iteratedFDerivWithin 𝕜 m f s x x : E hmn : ↑(Nat.succ m) ≤ n hx : x ∈ s ⊢ p x (Nat.succ m) = iteratedFDerivWithin 𝕜 (Nat.succ m) f s x [PROOFSTEP] have A : (m : ℕ∞) < n := lt_of_lt_of_le (WithTop.coe_lt_coe.2 (lt_add_one m)) hmn [GOAL] case succ 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝¹ n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F h : HasFTaylorSeriesUpToOn n f p s m✝ : ℕ hmn✝ : ↑m✝ ≤ n hs : UniqueDiffOn 𝕜 s hx✝ : x✝ ∈ s m : ℕ IH : ∀ {x : E}, ↑m ≤ n → x ∈ s → p x m = iteratedFDerivWithin 𝕜 m f s x x : E hmn : ↑(Nat.succ m) ≤ n hx : x ∈ s A : ↑m < n ⊢ p x (Nat.succ m) = iteratedFDerivWithin 𝕜 (Nat.succ m) f s x [PROOFSTEP] have : HasFDerivWithinAt (fun y : E => iteratedFDerivWithin 𝕜 m f s y) (ContinuousMultilinearMap.curryLeft (p x (Nat.succ m))) s x := (h.fderivWithin m A x hx).congr (fun y hy => (IH (le_of_lt A) hy).symm) (IH (le_of_lt A) hx).symm [GOAL] case succ 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝¹ n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F h : HasFTaylorSeriesUpToOn n f p s m✝ : ℕ hmn✝ : ↑m✝ ≤ n hs : UniqueDiffOn 𝕜 s hx✝ : x✝ ∈ s m : ℕ IH : ∀ {x : E}, ↑m ≤ n → x ∈ s → p x m = iteratedFDerivWithin 𝕜 m f s x x : E hmn : ↑(Nat.succ m) ≤ n hx : x ∈ s A : ↑m < n this : HasFDerivWithinAt (fun y => iteratedFDerivWithin 𝕜 m f s y) (ContinuousMultilinearMap.curryLeft (p x (Nat.succ m))) s x ⊢ p x (Nat.succ m) = iteratedFDerivWithin 𝕜 (Nat.succ m) f s x [PROOFSTEP] rw [iteratedFDerivWithin_succ_eq_comp_left, Function.comp_apply, this.fderivWithin (hs x hx)] [GOAL] case succ 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝¹ n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F h : HasFTaylorSeriesUpToOn n f p s m✝ : ℕ hmn✝ : ↑m✝ ≤ n hs : UniqueDiffOn 𝕜 s hx✝ : x✝ ∈ s m : ℕ IH : ∀ {x : E}, ↑m ≤ n → x ∈ s → p x m = iteratedFDerivWithin 𝕜 m f s x x : E hmn : ↑(Nat.succ m) ≤ n hx : x ∈ s A : ↑m < n this : HasFDerivWithinAt (fun y => iteratedFDerivWithin 𝕜 m f s y) (ContinuousMultilinearMap.curryLeft (p x (Nat.succ m))) s x ⊢ p x (Nat.succ m) = ↑(continuousMultilinearCurryLeftEquiv 𝕜 (fun x => E) F) (ContinuousMultilinearMap.curryLeft (p x (Nat.succ m))) [PROOFSTEP] exact (ContinuousMultilinearMap.uncurry_curryLeft _).symm [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F h : ContDiffOn 𝕜 n f s hs : UniqueDiffOn 𝕜 s ⊢ HasFTaylorSeriesUpToOn n f (ftaylorSeriesWithin 𝕜 f s) s [PROOFSTEP] constructor [GOAL] case zero_eq 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F h : ContDiffOn 𝕜 n f s hs : UniqueDiffOn 𝕜 s ⊢ ∀ (x : E), x ∈ s → ContinuousMultilinearMap.uncurry0 (ftaylorSeriesWithin 𝕜 f s x 0) = f x [PROOFSTEP] intro x _ [GOAL] case zero_eq 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F h : ContDiffOn 𝕜 n f s hs : UniqueDiffOn 𝕜 s x : E a✝ : x ∈ s ⊢ ContinuousMultilinearMap.uncurry0 (ftaylorSeriesWithin 𝕜 f s x 0) = f x [PROOFSTEP] simp only [ftaylorSeriesWithin, ContinuousMultilinearMap.uncurry0_apply, iteratedFDerivWithin_zero_apply] [GOAL] case fderivWithin 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F h : ContDiffOn 𝕜 n f s hs : UniqueDiffOn 𝕜 s ⊢ ∀ (m : ℕ), ↑m < n → ∀ (x : E), x ∈ s → HasFDerivWithinAt (fun x => ftaylorSeriesWithin 𝕜 f s x m) (ContinuousMultilinearMap.curryLeft (ftaylorSeriesWithin 𝕜 f s x (Nat.succ m))) s x [PROOFSTEP] intro m hm x hx [GOAL] case fderivWithin 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝ n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F h : ContDiffOn 𝕜 n f s hs : UniqueDiffOn 𝕜 s m : ℕ hm : ↑m < n x : E hx : x ∈ s ⊢ HasFDerivWithinAt (fun x => ftaylorSeriesWithin 𝕜 f s x m) (ContinuousMultilinearMap.curryLeft (ftaylorSeriesWithin 𝕜 f s x (Nat.succ m))) s x [PROOFSTEP] rcases(h x hx) m.succ (ENat.add_one_le_of_lt hm) with ⟨u, hu, p, Hp⟩ [GOAL] case fderivWithin.intro.intro.intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝ n : ℕ∞ p✝ : E → FormalMultilinearSeries 𝕜 E F h : ContDiffOn 𝕜 n f s hs : UniqueDiffOn 𝕜 s m : ℕ hm : ↑m < n x : E hx : x ∈ s u : Set E hu : u ∈ 𝓝[insert x s] x p : E → FormalMultilinearSeries 𝕜 E F Hp : HasFTaylorSeriesUpToOn (↑(Nat.succ m)) f p u ⊢ HasFDerivWithinAt (fun x => ftaylorSeriesWithin 𝕜 f s x m) (ContinuousMultilinearMap.curryLeft (ftaylorSeriesWithin 𝕜 f s x (Nat.succ m))) s x [PROOFSTEP] rw [insert_eq_of_mem hx] at hu [GOAL] case fderivWithin.intro.intro.intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝ n : ℕ∞ p✝ : E → FormalMultilinearSeries 𝕜 E F h : ContDiffOn 𝕜 n f s hs : UniqueDiffOn 𝕜 s m : ℕ hm : ↑m < n x : E hx : x ∈ s u : Set E hu : u ∈ 𝓝[s] x p : E → FormalMultilinearSeries 𝕜 E F Hp : HasFTaylorSeriesUpToOn (↑(Nat.succ m)) f p u ⊢ HasFDerivWithinAt (fun x => ftaylorSeriesWithin 𝕜 f s x m) (ContinuousMultilinearMap.curryLeft (ftaylorSeriesWithin 𝕜 f s x (Nat.succ m))) s x [PROOFSTEP] rcases mem_nhdsWithin.1 hu with ⟨o, o_open, xo, ho⟩ [GOAL] case fderivWithin.intro.intro.intro.intro.intro.intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝ n : ℕ∞ p✝ : E → FormalMultilinearSeries 𝕜 E F h : ContDiffOn 𝕜 n f s hs : UniqueDiffOn 𝕜 s m : ℕ hm : ↑m < n x : E hx : x ∈ s u : Set E hu : u ∈ 𝓝[s] x p : E → FormalMultilinearSeries 𝕜 E F Hp : HasFTaylorSeriesUpToOn (↑(Nat.succ m)) f p u o : Set E o_open : IsOpen o xo : x ∈ o ho : o ∩ s ⊆ u ⊢ HasFDerivWithinAt (fun x => ftaylorSeriesWithin 𝕜 f s x m) (ContinuousMultilinearMap.curryLeft (ftaylorSeriesWithin 𝕜 f s x (Nat.succ m))) s x [PROOFSTEP] rw [inter_comm] at ho [GOAL] case fderivWithin.intro.intro.intro.intro.intro.intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝ n : ℕ∞ p✝ : E → FormalMultilinearSeries 𝕜 E F h : ContDiffOn 𝕜 n f s hs : UniqueDiffOn 𝕜 s m : ℕ hm : ↑m < n x : E hx : x ∈ s u : Set E hu : u ∈ 𝓝[s] x p : E → FormalMultilinearSeries 𝕜 E F Hp : HasFTaylorSeriesUpToOn (↑(Nat.succ m)) f p u o : Set E o_open : IsOpen o xo : x ∈ o ho : s ∩ o ⊆ u ⊢ HasFDerivWithinAt (fun x => ftaylorSeriesWithin 𝕜 f s x m) (ContinuousMultilinearMap.curryLeft (ftaylorSeriesWithin 𝕜 f s x (Nat.succ m))) s x [PROOFSTEP] have : p x m.succ = ftaylorSeriesWithin 𝕜 f s x m.succ := by change p x m.succ = iteratedFDerivWithin 𝕜 m.succ f s x rw [← iteratedFDerivWithin_inter_open o_open xo] exact (Hp.mono ho).eq_ftaylor_series_of_uniqueDiffOn le_rfl (hs.inter o_open) ⟨hx, xo⟩ [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝ n : ℕ∞ p✝ : E → FormalMultilinearSeries 𝕜 E F h : ContDiffOn 𝕜 n f s hs : UniqueDiffOn 𝕜 s m : ℕ hm : ↑m < n x : E hx : x ∈ s u : Set E hu : u ∈ 𝓝[s] x p : E → FormalMultilinearSeries 𝕜 E F Hp : HasFTaylorSeriesUpToOn (↑(Nat.succ m)) f p u o : Set E o_open : IsOpen o xo : x ∈ o ho : s ∩ o ⊆ u ⊢ p x (Nat.succ m) = ftaylorSeriesWithin 𝕜 f s x (Nat.succ m) [PROOFSTEP] change p x m.succ = iteratedFDerivWithin 𝕜 m.succ f s x [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝ n : ℕ∞ p✝ : E → FormalMultilinearSeries 𝕜 E F h : ContDiffOn 𝕜 n f s hs : UniqueDiffOn 𝕜 s m : ℕ hm : ↑m < n x : E hx : x ∈ s u : Set E hu : u ∈ 𝓝[s] x p : E → FormalMultilinearSeries 𝕜 E F Hp : HasFTaylorSeriesUpToOn (↑(Nat.succ m)) f p u o : Set E o_open : IsOpen o xo : x ∈ o ho : s ∩ o ⊆ u ⊢ p x (Nat.succ m) = iteratedFDerivWithin 𝕜 (Nat.succ m) f s x [PROOFSTEP] rw [← iteratedFDerivWithin_inter_open o_open xo] [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝ n : ℕ∞ p✝ : E → FormalMultilinearSeries 𝕜 E F h : ContDiffOn 𝕜 n f s hs : UniqueDiffOn 𝕜 s m : ℕ hm : ↑m < n x : E hx : x ∈ s u : Set E hu : u ∈ 𝓝[s] x p : E → FormalMultilinearSeries 𝕜 E F Hp : HasFTaylorSeriesUpToOn (↑(Nat.succ m)) f p u o : Set E o_open : IsOpen o xo : x ∈ o ho : s ∩ o ⊆ u ⊢ p x (Nat.succ m) = iteratedFDerivWithin 𝕜 (Nat.succ m) f (s ∩ o) x [PROOFSTEP] exact (Hp.mono ho).eq_ftaylor_series_of_uniqueDiffOn le_rfl (hs.inter o_open) ⟨hx, xo⟩ [GOAL] case fderivWithin.intro.intro.intro.intro.intro.intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝ n : ℕ∞ p✝ : E → FormalMultilinearSeries 𝕜 E F h : ContDiffOn 𝕜 n f s hs : UniqueDiffOn 𝕜 s m : ℕ hm : ↑m < n x : E hx : x ∈ s u : Set E hu : u ∈ 𝓝[s] x p : E → FormalMultilinearSeries 𝕜 E F Hp : HasFTaylorSeriesUpToOn (↑(Nat.succ m)) f p u o : Set E o_open : IsOpen o xo : x ∈ o ho : s ∩ o ⊆ u this : p x (Nat.succ m) = ftaylorSeriesWithin 𝕜 f s x (Nat.succ m) ⊢ HasFDerivWithinAt (fun x => ftaylorSeriesWithin 𝕜 f s x m) (ContinuousMultilinearMap.curryLeft (ftaylorSeriesWithin 𝕜 f s x (Nat.succ m))) s x [PROOFSTEP] rw [← this, ← hasFDerivWithinAt_inter (IsOpen.mem_nhds o_open xo)] [GOAL] case fderivWithin.intro.intro.intro.intro.intro.intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝ n : ℕ∞ p✝ : E → FormalMultilinearSeries 𝕜 E F h : ContDiffOn 𝕜 n f s hs : UniqueDiffOn 𝕜 s m : ℕ hm : ↑m < n x : E hx : x ∈ s u : Set E hu : u ∈ 𝓝[s] x p : E → FormalMultilinearSeries 𝕜 E F Hp : HasFTaylorSeriesUpToOn (↑(Nat.succ m)) f p u o : Set E o_open : IsOpen o xo : x ∈ o ho : s ∩ o ⊆ u this : p x (Nat.succ m) = ftaylorSeriesWithin 𝕜 f s x (Nat.succ m) ⊢ HasFDerivWithinAt (fun x => ftaylorSeriesWithin 𝕜 f s x m) (ContinuousMultilinearMap.curryLeft (p x (Nat.succ m))) (s ∩ o) x [PROOFSTEP] have A : ∀ y ∈ s ∩ o, p y m = ftaylorSeriesWithin 𝕜 f s y m := by rintro y ⟨hy, yo⟩ change p y m = iteratedFDerivWithin 𝕜 m f s y rw [← iteratedFDerivWithin_inter_open o_open yo] exact (Hp.mono ho).eq_ftaylor_series_of_uniqueDiffOn (WithTop.coe_le_coe.2 (Nat.le_succ m)) (hs.inter o_open) ⟨hy, yo⟩ [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝ n : ℕ∞ p✝ : E → FormalMultilinearSeries 𝕜 E F h : ContDiffOn 𝕜 n f s hs : UniqueDiffOn 𝕜 s m : ℕ hm : ↑m < n x : E hx : x ∈ s u : Set E hu : u ∈ 𝓝[s] x p : E → FormalMultilinearSeries 𝕜 E F Hp : HasFTaylorSeriesUpToOn (↑(Nat.succ m)) f p u o : Set E o_open : IsOpen o xo : x ∈ o ho : s ∩ o ⊆ u this : p x (Nat.succ m) = ftaylorSeriesWithin 𝕜 f s x (Nat.succ m) ⊢ ∀ (y : E), y ∈ s ∩ o → p y m = ftaylorSeriesWithin 𝕜 f s y m [PROOFSTEP] rintro y ⟨hy, yo⟩ [GOAL] case intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝ n : ℕ∞ p✝ : E → FormalMultilinearSeries 𝕜 E F h : ContDiffOn 𝕜 n f s hs : UniqueDiffOn 𝕜 s m : ℕ hm : ↑m < n x : E hx : x ∈ s u : Set E hu : u ∈ 𝓝[s] x p : E → FormalMultilinearSeries 𝕜 E F Hp : HasFTaylorSeriesUpToOn (↑(Nat.succ m)) f p u o : Set E o_open : IsOpen o xo : x ∈ o ho : s ∩ o ⊆ u this : p x (Nat.succ m) = ftaylorSeriesWithin 𝕜 f s x (Nat.succ m) y : E hy : y ∈ s yo : y ∈ o ⊢ p y m = ftaylorSeriesWithin 𝕜 f s y m [PROOFSTEP] change p y m = iteratedFDerivWithin 𝕜 m f s y [GOAL] case intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝ n : ℕ∞ p✝ : E → FormalMultilinearSeries 𝕜 E F h : ContDiffOn 𝕜 n f s hs : UniqueDiffOn 𝕜 s m : ℕ hm : ↑m < n x : E hx : x ∈ s u : Set E hu : u ∈ 𝓝[s] x p : E → FormalMultilinearSeries 𝕜 E F Hp : HasFTaylorSeriesUpToOn (↑(Nat.succ m)) f p u o : Set E o_open : IsOpen o xo : x ∈ o ho : s ∩ o ⊆ u this : p x (Nat.succ m) = ftaylorSeriesWithin 𝕜 f s x (Nat.succ m) y : E hy : y ∈ s yo : y ∈ o ⊢ p y m = iteratedFDerivWithin 𝕜 m f s y [PROOFSTEP] rw [← iteratedFDerivWithin_inter_open o_open yo] [GOAL] case intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝ n : ℕ∞ p✝ : E → FormalMultilinearSeries 𝕜 E F h : ContDiffOn 𝕜 n f s hs : UniqueDiffOn 𝕜 s m : ℕ hm : ↑m < n x : E hx : x ∈ s u : Set E hu : u ∈ 𝓝[s] x p : E → FormalMultilinearSeries 𝕜 E F Hp : HasFTaylorSeriesUpToOn (↑(Nat.succ m)) f p u o : Set E o_open : IsOpen o xo : x ∈ o ho : s ∩ o ⊆ u this : p x (Nat.succ m) = ftaylorSeriesWithin 𝕜 f s x (Nat.succ m) y : E hy : y ∈ s yo : y ∈ o ⊢ p y m = iteratedFDerivWithin 𝕜 m f (s ∩ o) y [PROOFSTEP] exact (Hp.mono ho).eq_ftaylor_series_of_uniqueDiffOn (WithTop.coe_le_coe.2 (Nat.le_succ m)) (hs.inter o_open) ⟨hy, yo⟩ [GOAL] case fderivWithin.intro.intro.intro.intro.intro.intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝ n : ℕ∞ p✝ : E → FormalMultilinearSeries 𝕜 E F h : ContDiffOn 𝕜 n f s hs : UniqueDiffOn 𝕜 s m : ℕ hm : ↑m < n x : E hx : x ∈ s u : Set E hu : u ∈ 𝓝[s] x p : E → FormalMultilinearSeries 𝕜 E F Hp : HasFTaylorSeriesUpToOn (↑(Nat.succ m)) f p u o : Set E o_open : IsOpen o xo : x ∈ o ho : s ∩ o ⊆ u this : p x (Nat.succ m) = ftaylorSeriesWithin 𝕜 f s x (Nat.succ m) A : ∀ (y : E), y ∈ s ∩ o → p y m = ftaylorSeriesWithin 𝕜 f s y m ⊢ HasFDerivWithinAt (fun x => ftaylorSeriesWithin 𝕜 f s x m) (ContinuousMultilinearMap.curryLeft (p x (Nat.succ m))) (s ∩ o) x [PROOFSTEP] exact ((Hp.mono ho).fderivWithin m (WithTop.coe_lt_coe.2 (lt_add_one m)) x ⟨hx, xo⟩).congr (fun y hy => (A y hy).symm) (A x ⟨hx, xo⟩).symm [GOAL] case cont 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F h : ContDiffOn 𝕜 n f s hs : UniqueDiffOn 𝕜 s ⊢ ∀ (m : ℕ), ↑m ≤ n → ContinuousOn (fun x => ftaylorSeriesWithin 𝕜 f s x m) s [PROOFSTEP] intro m hm [GOAL] case cont 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m✝ n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F h : ContDiffOn 𝕜 n f s hs : UniqueDiffOn 𝕜 s m : ℕ hm : ↑m ≤ n ⊢ ContinuousOn (fun x => ftaylorSeriesWithin 𝕜 f s x m) s [PROOFSTEP] apply continuousOn_of_locally_continuousOn [GOAL] case cont.h 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m✝ n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F h : ContDiffOn 𝕜 n f s hs : UniqueDiffOn 𝕜 s m : ℕ hm : ↑m ≤ n ⊢ ∀ (x : E), x ∈ s → ∃ t, IsOpen t ∧ x ∈ t ∧ ContinuousOn (fun x => ftaylorSeriesWithin 𝕜 f s x m) (s ∩ t) [PROOFSTEP] intro x hx [GOAL] case cont.h 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝ n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F h : ContDiffOn 𝕜 n f s hs : UniqueDiffOn 𝕜 s m : ℕ hm : ↑m ≤ n x : E hx : x ∈ s ⊢ ∃ t, IsOpen t ∧ x ∈ t ∧ ContinuousOn (fun x => ftaylorSeriesWithin 𝕜 f s x m) (s ∩ t) [PROOFSTEP] rcases h x hx m hm with ⟨u, hu, p, Hp⟩ [GOAL] case cont.h.intro.intro.intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝ n : ℕ∞ p✝ : E → FormalMultilinearSeries 𝕜 E F h : ContDiffOn 𝕜 n f s hs : UniqueDiffOn 𝕜 s m : ℕ hm : ↑m ≤ n x : E hx : x ∈ s u : Set E hu : u ∈ 𝓝[insert x s] x p : E → FormalMultilinearSeries 𝕜 E F Hp : HasFTaylorSeriesUpToOn (↑m) f p u ⊢ ∃ t, IsOpen t ∧ x ∈ t ∧ ContinuousOn (fun x => ftaylorSeriesWithin 𝕜 f s x m) (s ∩ t) [PROOFSTEP] rcases mem_nhdsWithin.1 hu with ⟨o, o_open, xo, ho⟩ [GOAL] case cont.h.intro.intro.intro.intro.intro.intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝ n : ℕ∞ p✝ : E → FormalMultilinearSeries 𝕜 E F h : ContDiffOn 𝕜 n f s hs : UniqueDiffOn 𝕜 s m : ℕ hm : ↑m ≤ n x : E hx : x ∈ s u : Set E hu : u ∈ 𝓝[insert x s] x p : E → FormalMultilinearSeries 𝕜 E F Hp : HasFTaylorSeriesUpToOn (↑m) f p u o : Set E o_open : IsOpen o xo : x ∈ o ho : o ∩ insert x s ⊆ u ⊢ ∃ t, IsOpen t ∧ x ∈ t ∧ ContinuousOn (fun x => ftaylorSeriesWithin 𝕜 f s x m) (s ∩ t) [PROOFSTEP] rw [insert_eq_of_mem hx] at ho [GOAL] case cont.h.intro.intro.intro.intro.intro.intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝ n : ℕ∞ p✝ : E → FormalMultilinearSeries 𝕜 E F h : ContDiffOn 𝕜 n f s hs : UniqueDiffOn 𝕜 s m : ℕ hm : ↑m ≤ n x : E hx : x ∈ s u : Set E hu : u ∈ 𝓝[insert x s] x p : E → FormalMultilinearSeries 𝕜 E F Hp : HasFTaylorSeriesUpToOn (↑m) f p u o : Set E o_open : IsOpen o xo : x ∈ o ho : o ∩ s ⊆ u ⊢ ∃ t, IsOpen t ∧ x ∈ t ∧ ContinuousOn (fun x => ftaylorSeriesWithin 𝕜 f s x m) (s ∩ t) [PROOFSTEP] rw [inter_comm] at ho [GOAL] case cont.h.intro.intro.intro.intro.intro.intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝ n : ℕ∞ p✝ : E → FormalMultilinearSeries 𝕜 E F h : ContDiffOn 𝕜 n f s hs : UniqueDiffOn 𝕜 s m : ℕ hm : ↑m ≤ n x : E hx : x ∈ s u : Set E hu : u ∈ 𝓝[insert x s] x p : E → FormalMultilinearSeries 𝕜 E F Hp : HasFTaylorSeriesUpToOn (↑m) f p u o : Set E o_open : IsOpen o xo : x ∈ o ho : s ∩ o ⊆ u ⊢ ∃ t, IsOpen t ∧ x ∈ t ∧ ContinuousOn (fun x => ftaylorSeriesWithin 𝕜 f s x m) (s ∩ t) [PROOFSTEP] refine' ⟨o, o_open, xo, _⟩ [GOAL] case cont.h.intro.intro.intro.intro.intro.intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝ n : ℕ∞ p✝ : E → FormalMultilinearSeries 𝕜 E F h : ContDiffOn 𝕜 n f s hs : UniqueDiffOn 𝕜 s m : ℕ hm : ↑m ≤ n x : E hx : x ∈ s u : Set E hu : u ∈ 𝓝[insert x s] x p : E → FormalMultilinearSeries 𝕜 E F Hp : HasFTaylorSeriesUpToOn (↑m) f p u o : Set E o_open : IsOpen o xo : x ∈ o ho : s ∩ o ⊆ u ⊢ ContinuousOn (fun x => ftaylorSeriesWithin 𝕜 f s x m) (s ∩ o) [PROOFSTEP] have A : ∀ y ∈ s ∩ o, p y m = ftaylorSeriesWithin 𝕜 f s y m := by rintro y ⟨hy, yo⟩ change p y m = iteratedFDerivWithin 𝕜 m f s y rw [← iteratedFDerivWithin_inter_open o_open yo] exact (Hp.mono ho).eq_ftaylor_series_of_uniqueDiffOn le_rfl (hs.inter o_open) ⟨hy, yo⟩ [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝ n : ℕ∞ p✝ : E → FormalMultilinearSeries 𝕜 E F h : ContDiffOn 𝕜 n f s hs : UniqueDiffOn 𝕜 s m : ℕ hm : ↑m ≤ n x : E hx : x ∈ s u : Set E hu : u ∈ 𝓝[insert x s] x p : E → FormalMultilinearSeries 𝕜 E F Hp : HasFTaylorSeriesUpToOn (↑m) f p u o : Set E o_open : IsOpen o xo : x ∈ o ho : s ∩ o ⊆ u ⊢ ∀ (y : E), y ∈ s ∩ o → p y m = ftaylorSeriesWithin 𝕜 f s y m [PROOFSTEP] rintro y ⟨hy, yo⟩ [GOAL] case intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝ n : ℕ∞ p✝ : E → FormalMultilinearSeries 𝕜 E F h : ContDiffOn 𝕜 n f s hs : UniqueDiffOn 𝕜 s m : ℕ hm : ↑m ≤ n x : E hx : x ∈ s u : Set E hu : u ∈ 𝓝[insert x s] x p : E → FormalMultilinearSeries 𝕜 E F Hp : HasFTaylorSeriesUpToOn (↑m) f p u o : Set E o_open : IsOpen o xo : x ∈ o ho : s ∩ o ⊆ u y : E hy : y ∈ s yo : y ∈ o ⊢ p y m = ftaylorSeriesWithin 𝕜 f s y m [PROOFSTEP] change p y m = iteratedFDerivWithin 𝕜 m f s y [GOAL] case intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝ n : ℕ∞ p✝ : E → FormalMultilinearSeries 𝕜 E F h : ContDiffOn 𝕜 n f s hs : UniqueDiffOn 𝕜 s m : ℕ hm : ↑m ≤ n x : E hx : x ∈ s u : Set E hu : u ∈ 𝓝[insert x s] x p : E → FormalMultilinearSeries 𝕜 E F Hp : HasFTaylorSeriesUpToOn (↑m) f p u o : Set E o_open : IsOpen o xo : x ∈ o ho : s ∩ o ⊆ u y : E hy : y ∈ s yo : y ∈ o ⊢ p y m = iteratedFDerivWithin 𝕜 m f s y [PROOFSTEP] rw [← iteratedFDerivWithin_inter_open o_open yo] [GOAL] case intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝ n : ℕ∞ p✝ : E → FormalMultilinearSeries 𝕜 E F h : ContDiffOn 𝕜 n f s hs : UniqueDiffOn 𝕜 s m : ℕ hm : ↑m ≤ n x : E hx : x ∈ s u : Set E hu : u ∈ 𝓝[insert x s] x p : E → FormalMultilinearSeries 𝕜 E F Hp : HasFTaylorSeriesUpToOn (↑m) f p u o : Set E o_open : IsOpen o xo : x ∈ o ho : s ∩ o ⊆ u y : E hy : y ∈ s yo : y ∈ o ⊢ p y m = iteratedFDerivWithin 𝕜 m f (s ∩ o) y [PROOFSTEP] exact (Hp.mono ho).eq_ftaylor_series_of_uniqueDiffOn le_rfl (hs.inter o_open) ⟨hy, yo⟩ [GOAL] case cont.h.intro.intro.intro.intro.intro.intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝ n : ℕ∞ p✝ : E → FormalMultilinearSeries 𝕜 E F h : ContDiffOn 𝕜 n f s hs : UniqueDiffOn 𝕜 s m : ℕ hm : ↑m ≤ n x : E hx : x ∈ s u : Set E hu : u ∈ 𝓝[insert x s] x p : E → FormalMultilinearSeries 𝕜 E F Hp : HasFTaylorSeriesUpToOn (↑m) f p u o : Set E o_open : IsOpen o xo : x ∈ o ho : s ∩ o ⊆ u A : ∀ (y : E), y ∈ s ∩ o → p y m = ftaylorSeriesWithin 𝕜 f s y m ⊢ ContinuousOn (fun x => ftaylorSeriesWithin 𝕜 f s x m) (s ∩ o) [PROOFSTEP] exact ((Hp.mono ho).cont m le_rfl).congr fun y hy => (A y hy).symm [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F Hcont : ∀ (m : ℕ), ↑m ≤ n → ContinuousOn (fun x => iteratedFDerivWithin 𝕜 m f s x) s Hdiff : ∀ (m : ℕ), ↑m < n → DifferentiableOn 𝕜 (fun x => iteratedFDerivWithin 𝕜 m f s x) s ⊢ ContDiffOn 𝕜 n f s [PROOFSTEP] intro x hx m hm [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝ n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F Hcont : ∀ (m : ℕ), ↑m ≤ n → ContinuousOn (fun x => iteratedFDerivWithin 𝕜 m f s x) s Hdiff : ∀ (m : ℕ), ↑m < n → DifferentiableOn 𝕜 (fun x => iteratedFDerivWithin 𝕜 m f s x) s x : E hx : x ∈ s m : ℕ hm : ↑m ≤ n ⊢ ∃ u, u ∈ 𝓝[insert x s] x ∧ ∃ p, HasFTaylorSeriesUpToOn (↑m) f p u [PROOFSTEP] rw [insert_eq_of_mem hx] [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝ n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F Hcont : ∀ (m : ℕ), ↑m ≤ n → ContinuousOn (fun x => iteratedFDerivWithin 𝕜 m f s x) s Hdiff : ∀ (m : ℕ), ↑m < n → DifferentiableOn 𝕜 (fun x => iteratedFDerivWithin 𝕜 m f s x) s x : E hx : x ∈ s m : ℕ hm : ↑m ≤ n ⊢ ∃ u, u ∈ 𝓝[s] x ∧ ∃ p, HasFTaylorSeriesUpToOn (↑m) f p u [PROOFSTEP] refine' ⟨s, self_mem_nhdsWithin, ftaylorSeriesWithin 𝕜 f s, _⟩ [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝ n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F Hcont : ∀ (m : ℕ), ↑m ≤ n → ContinuousOn (fun x => iteratedFDerivWithin 𝕜 m f s x) s Hdiff : ∀ (m : ℕ), ↑m < n → DifferentiableOn 𝕜 (fun x => iteratedFDerivWithin 𝕜 m f s x) s x : E hx : x ∈ s m : ℕ hm : ↑m ≤ n ⊢ HasFTaylorSeriesUpToOn (↑m) f (ftaylorSeriesWithin 𝕜 f s) s [PROOFSTEP] constructor [GOAL] case zero_eq 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝ n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F Hcont : ∀ (m : ℕ), ↑m ≤ n → ContinuousOn (fun x => iteratedFDerivWithin 𝕜 m f s x) s Hdiff : ∀ (m : ℕ), ↑m < n → DifferentiableOn 𝕜 (fun x => iteratedFDerivWithin 𝕜 m f s x) s x : E hx : x ∈ s m : ℕ hm : ↑m ≤ n ⊢ ∀ (x : E), x ∈ s → ContinuousMultilinearMap.uncurry0 (ftaylorSeriesWithin 𝕜 f s x 0) = f x [PROOFSTEP] intro y _ [GOAL] case zero_eq 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝ n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F Hcont : ∀ (m : ℕ), ↑m ≤ n → ContinuousOn (fun x => iteratedFDerivWithin 𝕜 m f s x) s Hdiff : ∀ (m : ℕ), ↑m < n → DifferentiableOn 𝕜 (fun x => iteratedFDerivWithin 𝕜 m f s x) s x : E hx : x ∈ s m : ℕ hm : ↑m ≤ n y : E a✝ : y ∈ s ⊢ ContinuousMultilinearMap.uncurry0 (ftaylorSeriesWithin 𝕜 f s y 0) = f y [PROOFSTEP] simp only [ftaylorSeriesWithin, ContinuousMultilinearMap.uncurry0_apply, iteratedFDerivWithin_zero_apply] [GOAL] case fderivWithin 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝ n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F Hcont : ∀ (m : ℕ), ↑m ≤ n → ContinuousOn (fun x => iteratedFDerivWithin 𝕜 m f s x) s Hdiff : ∀ (m : ℕ), ↑m < n → DifferentiableOn 𝕜 (fun x => iteratedFDerivWithin 𝕜 m f s x) s x : E hx : x ∈ s m : ℕ hm : ↑m ≤ n ⊢ ∀ (m_1 : ℕ), ↑m_1 < ↑m → ∀ (x : E), x ∈ s → HasFDerivWithinAt (fun x => ftaylorSeriesWithin 𝕜 f s x m_1) (ContinuousMultilinearMap.curryLeft (ftaylorSeriesWithin 𝕜 f s x (Nat.succ m_1))) s x [PROOFSTEP] intro k hk y hy [GOAL] case fderivWithin 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝ n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F Hcont : ∀ (m : ℕ), ↑m ≤ n → ContinuousOn (fun x => iteratedFDerivWithin 𝕜 m f s x) s Hdiff : ∀ (m : ℕ), ↑m < n → DifferentiableOn 𝕜 (fun x => iteratedFDerivWithin 𝕜 m f s x) s x : E hx : x ∈ s m : ℕ hm : ↑m ≤ n k : ℕ hk : ↑k < ↑m y : E hy : y ∈ s ⊢ HasFDerivWithinAt (fun x => ftaylorSeriesWithin 𝕜 f s x k) (ContinuousMultilinearMap.curryLeft (ftaylorSeriesWithin 𝕜 f s y (Nat.succ k))) s y [PROOFSTEP] convert (Hdiff k (lt_of_lt_of_le hk hm) y hy).hasFDerivWithinAt [GOAL] case cont 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝ n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F Hcont : ∀ (m : ℕ), ↑m ≤ n → ContinuousOn (fun x => iteratedFDerivWithin 𝕜 m f s x) s Hdiff : ∀ (m : ℕ), ↑m < n → DifferentiableOn 𝕜 (fun x => iteratedFDerivWithin 𝕜 m f s x) s x : E hx : x ∈ s m : ℕ hm : ↑m ≤ n ⊢ ∀ (m_1 : ℕ), ↑m_1 ≤ ↑m → ContinuousOn (fun x => ftaylorSeriesWithin 𝕜 f s x m_1) s [PROOFSTEP] intro k hk [GOAL] case cont 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝ n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F Hcont : ∀ (m : ℕ), ↑m ≤ n → ContinuousOn (fun x => iteratedFDerivWithin 𝕜 m f s x) s Hdiff : ∀ (m : ℕ), ↑m < n → DifferentiableOn 𝕜 (fun x => iteratedFDerivWithin 𝕜 m f s x) s x : E hx : x ∈ s m : ℕ hm : ↑m ≤ n k : ℕ hk : ↑k ≤ ↑m ⊢ ContinuousOn (fun x => ftaylorSeriesWithin 𝕜 f s x k) s [PROOFSTEP] exact Hcont k (le_trans hk hm) [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m✝ n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F m : ℕ h : ContDiffWithinAt 𝕜 n f s x hmn : ↑m < n hs : UniqueDiffOn 𝕜 (insert x s) ⊢ DifferentiableWithinAt 𝕜 (iteratedFDerivWithin 𝕜 m f s) s x [PROOFSTEP] rcases h.contDiffOn' (ENat.add_one_le_of_lt hmn) with ⟨u, uo, xu, hu⟩ [GOAL] case intro.intro.intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x x₀ : E c : F m✝ n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F m : ℕ h : ContDiffWithinAt 𝕜 n f s x hmn : ↑m < n hs : UniqueDiffOn 𝕜 (insert x s) u : Set E uo : IsOpen u xu : x ∈ u hu : ContDiffOn 𝕜 (↑(Add.add (↑m) 1)) f (insert x s ∩ u) ⊢ DifferentiableWithinAt 𝕜 (iteratedFDerivWithin 𝕜 m f s) s x [PROOFSTEP] set t := insert x s ∩ u [GOAL] case intro.intro.intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t✝ u✝ : Set E f f₁ : E → F g : F → G x x₀ : E c : F m✝ n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F m : ℕ h : ContDiffWithinAt 𝕜 n f s x hmn : ↑m < n hs : UniqueDiffOn 𝕜 (insert x s) u : Set E uo : IsOpen u xu : x ∈ u t : Set E := insert x s ∩ u hu : ContDiffOn 𝕜 (↑(Add.add (↑m) 1)) f t ⊢ DifferentiableWithinAt 𝕜 (iteratedFDerivWithin 𝕜 m f s) s x [PROOFSTEP] have A : t =ᶠ[𝓝[≠] x] s := by simp only [set_eventuallyEq_iff_inf_principal, ← nhdsWithin_inter'] rw [← inter_assoc, nhdsWithin_inter_of_mem', ← diff_eq_compl_inter, insert_diff_of_mem, diff_eq_compl_inter] exacts [rfl, mem_nhdsWithin_of_mem_nhds (uo.mem_nhds xu)] [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t✝ u✝ : Set E f f₁ : E → F g : F → G x x₀ : E c : F m✝ n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F m : ℕ h : ContDiffWithinAt 𝕜 n f s x hmn : ↑m < n hs : UniqueDiffOn 𝕜 (insert x s) u : Set E uo : IsOpen u xu : x ∈ u t : Set E := insert x s ∩ u hu : ContDiffOn 𝕜 (↑(Add.add (↑m) 1)) f t ⊢ t =ᶠ[𝓝[{x}ᶜ] x] s [PROOFSTEP] simp only [set_eventuallyEq_iff_inf_principal, ← nhdsWithin_inter'] [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t✝ u✝ : Set E f f₁ : E → F g : F → G x x₀ : E c : F m✝ n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F m : ℕ h : ContDiffWithinAt 𝕜 n f s x hmn : ↑m < n hs : UniqueDiffOn 𝕜 (insert x s) u : Set E uo : IsOpen u xu : x ∈ u t : Set E := insert x s ∩ u hu : ContDiffOn 𝕜 (↑(Add.add (↑m) 1)) f t ⊢ 𝓝[{x}ᶜ ∩ (insert x s ∩ u)] x = 𝓝[{x}ᶜ ∩ s] x [PROOFSTEP] rw [← inter_assoc, nhdsWithin_inter_of_mem', ← diff_eq_compl_inter, insert_diff_of_mem, diff_eq_compl_inter] [GOAL] case h 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t✝ u✝ : Set E f f₁ : E → F g : F → G x x₀ : E c : F m✝ n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F m : ℕ h : ContDiffWithinAt 𝕜 n f s x hmn : ↑m < n hs : UniqueDiffOn 𝕜 (insert x s) u : Set E uo : IsOpen u xu : x ∈ u t : Set E := insert x s ∩ u hu : ContDiffOn 𝕜 (↑(Add.add (↑m) 1)) f t ⊢ x ∈ {x} 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t✝ u✝ : Set E f f₁ : E → F g : F → G x x₀ : E c : F m✝ n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F m : ℕ h : ContDiffWithinAt 𝕜 n f s x hmn : ↑m < n hs : UniqueDiffOn 𝕜 (insert x s) u : Set E uo : IsOpen u xu : x ∈ u t : Set E := insert x s ∩ u hu : ContDiffOn 𝕜 (↑(Add.add (↑m) 1)) f t ⊢ u ∈ 𝓝[{x}ᶜ ∩ insert x s] x [PROOFSTEP] exacts [rfl, mem_nhdsWithin_of_mem_nhds (uo.mem_nhds xu)] [GOAL] case intro.intro.intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t✝ u✝ : Set E f f₁ : E → F g : F → G x x₀ : E c : F m✝ n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F m : ℕ h : ContDiffWithinAt 𝕜 n f s x hmn : ↑m < n hs : UniqueDiffOn 𝕜 (insert x s) u : Set E uo : IsOpen u xu : x ∈ u t : Set E := insert x s ∩ u hu : ContDiffOn 𝕜 (↑(Add.add (↑m) 1)) f t A : t =ᶠ[𝓝[{x}ᶜ] x] s ⊢ DifferentiableWithinAt 𝕜 (iteratedFDerivWithin 𝕜 m f s) s x [PROOFSTEP] have B : iteratedFDerivWithin 𝕜 m f s =ᶠ[𝓝 x] iteratedFDerivWithin 𝕜 m f t := iteratedFDerivWithin_eventually_congr_set' _ A.symm _ [GOAL] case intro.intro.intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t✝ u✝ : Set E f f₁ : E → F g : F → G x x₀ : E c : F m✝ n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F m : ℕ h : ContDiffWithinAt 𝕜 n f s x hmn : ↑m < n hs : UniqueDiffOn 𝕜 (insert x s) u : Set E uo : IsOpen u xu : x ∈ u t : Set E := insert x s ∩ u hu : ContDiffOn 𝕜 (↑(Add.add (↑m) 1)) f t A : t =ᶠ[𝓝[{x}ᶜ] x] s B : iteratedFDerivWithin 𝕜 m f s =ᶠ[𝓝 x] iteratedFDerivWithin 𝕜 m f t ⊢ DifferentiableWithinAt 𝕜 (iteratedFDerivWithin 𝕜 m f s) s x [PROOFSTEP] have C : DifferentiableWithinAt 𝕜 (iteratedFDerivWithin 𝕜 m f t) t x := hu.differentiableOn_iteratedFDerivWithin (Nat.cast_lt.2 m.lt_succ_self) (hs.inter uo) x ⟨mem_insert _ _, xu⟩ [GOAL] case intro.intro.intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t✝ u✝ : Set E f f₁ : E → F g : F → G x x₀ : E c : F m✝ n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F m : ℕ h : ContDiffWithinAt 𝕜 n f s x hmn : ↑m < n hs : UniqueDiffOn 𝕜 (insert x s) u : Set E uo : IsOpen u xu : x ∈ u t : Set E := insert x s ∩ u hu : ContDiffOn 𝕜 (↑(Add.add (↑m) 1)) f t A : t =ᶠ[𝓝[{x}ᶜ] x] s B : iteratedFDerivWithin 𝕜 m f s =ᶠ[𝓝 x] iteratedFDerivWithin 𝕜 m f t C : DifferentiableWithinAt 𝕜 (iteratedFDerivWithin 𝕜 m f t) t x ⊢ DifferentiableWithinAt 𝕜 (iteratedFDerivWithin 𝕜 m f s) s x [PROOFSTEP] rw [differentiableWithinAt_congr_set' _ A] at C [GOAL] case intro.intro.intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t✝ u✝ : Set E f f₁ : E → F g : F → G x x₀ : E c : F m✝ n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F m : ℕ h : ContDiffWithinAt 𝕜 n f s x hmn : ↑m < n hs : UniqueDiffOn 𝕜 (insert x s) u : Set E uo : IsOpen u xu : x ∈ u t : Set E := insert x s ∩ u hu : ContDiffOn 𝕜 (↑(Add.add (↑m) 1)) f t A : t =ᶠ[𝓝[{x}ᶜ] x] s B : iteratedFDerivWithin 𝕜 m f s =ᶠ[𝓝 x] iteratedFDerivWithin 𝕜 m f t C : DifferentiableWithinAt 𝕜 (iteratedFDerivWithin 𝕜 m f t) s x ⊢ DifferentiableWithinAt 𝕜 (iteratedFDerivWithin 𝕜 m f s) s x [PROOFSTEP] exact C.congr_of_eventuallyEq (B.filter_mono inf_le_left) B.self_of_nhds [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ hf : DifferentiableOn 𝕜 f s h : ContDiffOn 𝕜 (↑n) (fun y => fderivWithin 𝕜 f s y) s ⊢ ContDiffOn 𝕜 (↑(n + 1)) f s [PROOFSTEP] intro x hx [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ hf : DifferentiableOn 𝕜 f s h : ContDiffOn 𝕜 (↑n) (fun y => fderivWithin 𝕜 f s y) s x : E hx : x ∈ s ⊢ ContDiffWithinAt 𝕜 (↑(n + 1)) f s x [PROOFSTEP] rw [contDiffWithinAt_succ_iff_hasFDerivWithinAt, insert_eq_of_mem hx] [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ hf : DifferentiableOn 𝕜 f s h : ContDiffOn 𝕜 (↑n) (fun y => fderivWithin 𝕜 f s y) s x : E hx : x ∈ s ⊢ ∃ u, u ∈ 𝓝[s] x ∧ ∃ f', (∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) u x) ∧ ContDiffWithinAt 𝕜 (↑n) f' u x [PROOFSTEP] exact ⟨s, self_mem_nhdsWithin, fderivWithin 𝕜 f s, fun y hy => (hf y hy).hasFDerivWithinAt, h x hx⟩ [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ hs : UniqueDiffOn 𝕜 s ⊢ ContDiffOn 𝕜 (↑(n + 1)) f s ↔ DifferentiableOn 𝕜 f s ∧ ContDiffOn 𝕜 (↑n) (fun y => fderivWithin 𝕜 f s y) s [PROOFSTEP] refine' ⟨fun H => _, fun h => contDiffOn_succ_of_fderivWithin h.1 h.2⟩ [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ hs : UniqueDiffOn 𝕜 s H : ContDiffOn 𝕜 (↑(n + 1)) f s ⊢ DifferentiableOn 𝕜 f s ∧ ContDiffOn 𝕜 (↑n) (fun y => fderivWithin 𝕜 f s y) s [PROOFSTEP] refine' ⟨H.differentiableOn (WithTop.coe_le_coe.2 (Nat.le_add_left 1 n)), fun x hx => _⟩ [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ hs : UniqueDiffOn 𝕜 s H : ContDiffOn 𝕜 (↑(n + 1)) f s x : E hx : x ∈ s ⊢ ContDiffWithinAt 𝕜 (↑n) (fun y => fderivWithin 𝕜 f s y) s x [PROOFSTEP] rcases contDiffWithinAt_succ_iff_hasFDerivWithinAt.1 (H x hx) with ⟨u, hu, f', hff', hf'⟩ [GOAL] case intro.intro.intro.intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ hs : UniqueDiffOn 𝕜 s H : ContDiffOn 𝕜 (↑(n + 1)) f s x : E hx : x ∈ s u : Set E hu : u ∈ 𝓝[insert x s] x f' : E → E →L[𝕜] F hff' : ∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) u x hf' : ContDiffWithinAt 𝕜 (↑n) f' u x ⊢ ContDiffWithinAt 𝕜 (↑n) (fun y => fderivWithin 𝕜 f s y) s x [PROOFSTEP] rcases mem_nhdsWithin.1 hu with ⟨o, o_open, xo, ho⟩ [GOAL] case intro.intro.intro.intro.intro.intro.intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ hs : UniqueDiffOn 𝕜 s H : ContDiffOn 𝕜 (↑(n + 1)) f s x : E hx : x ∈ s u : Set E hu : u ∈ 𝓝[insert x s] x f' : E → E →L[𝕜] F hff' : ∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) u x hf' : ContDiffWithinAt 𝕜 (↑n) f' u x o : Set E o_open : IsOpen o xo : x ∈ o ho : o ∩ insert x s ⊆ u ⊢ ContDiffWithinAt 𝕜 (↑n) (fun y => fderivWithin 𝕜 f s y) s x [PROOFSTEP] rw [inter_comm, insert_eq_of_mem hx] at ho [GOAL] case intro.intro.intro.intro.intro.intro.intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ hs : UniqueDiffOn 𝕜 s H : ContDiffOn 𝕜 (↑(n + 1)) f s x : E hx : x ∈ s u : Set E hu : u ∈ 𝓝[insert x s] x f' : E → E →L[𝕜] F hff' : ∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) u x hf' : ContDiffWithinAt 𝕜 (↑n) f' u x o : Set E o_open : IsOpen o xo : x ∈ o ho : s ∩ o ⊆ u ⊢ ContDiffWithinAt 𝕜 (↑n) (fun y => fderivWithin 𝕜 f s y) s x [PROOFSTEP] have := hf'.mono ho [GOAL] case intro.intro.intro.intro.intro.intro.intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ hs : UniqueDiffOn 𝕜 s H : ContDiffOn 𝕜 (↑(n + 1)) f s x : E hx : x ∈ s u : Set E hu : u ∈ 𝓝[insert x s] x f' : E → E →L[𝕜] F hff' : ∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) u x hf' : ContDiffWithinAt 𝕜 (↑n) f' u x o : Set E o_open : IsOpen o xo : x ∈ o ho : s ∩ o ⊆ u this : ContDiffWithinAt 𝕜 (↑n) f' (s ∩ o) x ⊢ ContDiffWithinAt 𝕜 (↑n) (fun y => fderivWithin 𝕜 f s y) s x [PROOFSTEP] rw [contDiffWithinAt_inter' (mem_nhdsWithin_of_mem_nhds (IsOpen.mem_nhds o_open xo))] at this [GOAL] case intro.intro.intro.intro.intro.intro.intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ hs : UniqueDiffOn 𝕜 s H : ContDiffOn 𝕜 (↑(n + 1)) f s x : E hx : x ∈ s u : Set E hu : u ∈ 𝓝[insert x s] x f' : E → E →L[𝕜] F hff' : ∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) u x hf' : ContDiffWithinAt 𝕜 (↑n) f' u x o : Set E o_open : IsOpen o xo : x ∈ o ho : s ∩ o ⊆ u this : ContDiffWithinAt 𝕜 (↑n) f' s x ⊢ ContDiffWithinAt 𝕜 (↑n) (fun y => fderivWithin 𝕜 f s y) s x [PROOFSTEP] apply this.congr_of_eventually_eq' _ hx [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ hs : UniqueDiffOn 𝕜 s H : ContDiffOn 𝕜 (↑(n + 1)) f s x : E hx : x ∈ s u : Set E hu : u ∈ 𝓝[insert x s] x f' : E → E →L[𝕜] F hff' : ∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) u x hf' : ContDiffWithinAt 𝕜 (↑n) f' u x o : Set E o_open : IsOpen o xo : x ∈ o ho : s ∩ o ⊆ u this : ContDiffWithinAt 𝕜 (↑n) f' s x ⊢ (fun y => fderivWithin 𝕜 f s y) =ᶠ[𝓝[s] x] f' [PROOFSTEP] have : o ∩ s ∈ 𝓝[s] x := mem_nhdsWithin.2 ⟨o, o_open, xo, Subset.refl _⟩ [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ hs : UniqueDiffOn 𝕜 s H : ContDiffOn 𝕜 (↑(n + 1)) f s x : E hx : x ∈ s u : Set E hu : u ∈ 𝓝[insert x s] x f' : E → E →L[𝕜] F hff' : ∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) u x hf' : ContDiffWithinAt 𝕜 (↑n) f' u x o : Set E o_open : IsOpen o xo : x ∈ o ho : s ∩ o ⊆ u this✝ : ContDiffWithinAt 𝕜 (↑n) f' s x this : o ∩ s ∈ 𝓝[s] x ⊢ (fun y => fderivWithin 𝕜 f s y) =ᶠ[𝓝[s] x] f' [PROOFSTEP] rw [inter_comm] at this [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ hs : UniqueDiffOn 𝕜 s H : ContDiffOn 𝕜 (↑(n + 1)) f s x : E hx : x ∈ s u : Set E hu : u ∈ 𝓝[insert x s] x f' : E → E →L[𝕜] F hff' : ∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) u x hf' : ContDiffWithinAt 𝕜 (↑n) f' u x o : Set E o_open : IsOpen o xo : x ∈ o ho : s ∩ o ⊆ u this✝ : ContDiffWithinAt 𝕜 (↑n) f' s x this : s ∩ o ∈ 𝓝[s] x ⊢ (fun y => fderivWithin 𝕜 f s y) =ᶠ[𝓝[s] x] f' [PROOFSTEP] refine Filter.eventuallyEq_of_mem this fun y hy => ?_ [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ hs : UniqueDiffOn 𝕜 s H : ContDiffOn 𝕜 (↑(n + 1)) f s x : E hx : x ∈ s u : Set E hu : u ∈ 𝓝[insert x s] x f' : E → E →L[𝕜] F hff' : ∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) u x hf' : ContDiffWithinAt 𝕜 (↑n) f' u x o : Set E o_open : IsOpen o xo : x ∈ o ho : s ∩ o ⊆ u this✝ : ContDiffWithinAt 𝕜 (↑n) f' s x this : s ∩ o ∈ 𝓝[s] x y : E hy : y ∈ s ∩ o ⊢ fderivWithin 𝕜 f s y = f' y [PROOFSTEP] have A : fderivWithin 𝕜 f (s ∩ o) y = f' y := ((hff' y (ho hy)).mono ho).fderivWithin (hs.inter o_open y hy) [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ hs : UniqueDiffOn 𝕜 s H : ContDiffOn 𝕜 (↑(n + 1)) f s x : E hx : x ∈ s u : Set E hu : u ∈ 𝓝[insert x s] x f' : E → E →L[𝕜] F hff' : ∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) u x hf' : ContDiffWithinAt 𝕜 (↑n) f' u x o : Set E o_open : IsOpen o xo : x ∈ o ho : s ∩ o ⊆ u this✝ : ContDiffWithinAt 𝕜 (↑n) f' s x this : s ∩ o ∈ 𝓝[s] x y : E hy : y ∈ s ∩ o A : fderivWithin 𝕜 f (s ∩ o) y = f' y ⊢ fderivWithin 𝕜 f s y = f' y [PROOFSTEP] rwa [fderivWithin_inter (o_open.mem_nhds hy.2)] at A [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ hs : UniqueDiffOn 𝕜 s ⊢ ContDiffOn 𝕜 (↑(n + 1)) f s ↔ ∃ f', ContDiffOn 𝕜 (↑n) f' s ∧ ∀ (x : E), x ∈ s → HasFDerivWithinAt f (f' x) s x [PROOFSTEP] rw [contDiffOn_succ_iff_fderivWithin hs] [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ hs : UniqueDiffOn 𝕜 s ⊢ DifferentiableOn 𝕜 f s ∧ ContDiffOn 𝕜 (↑n) (fun y => fderivWithin 𝕜 f s y) s ↔ ∃ f', ContDiffOn 𝕜 (↑n) f' s ∧ ∀ (x : E), x ∈ s → HasFDerivWithinAt f (f' x) s x [PROOFSTEP] refine' ⟨fun h => ⟨fderivWithin 𝕜 f s, h.2, fun x hx => (h.1 x hx).hasFDerivWithinAt⟩, fun h => _⟩ [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ hs : UniqueDiffOn 𝕜 s h : ∃ f', ContDiffOn 𝕜 (↑n) f' s ∧ ∀ (x : E), x ∈ s → HasFDerivWithinAt f (f' x) s x ⊢ DifferentiableOn 𝕜 f s ∧ ContDiffOn 𝕜 (↑n) (fun y => fderivWithin 𝕜 f s y) s [PROOFSTEP] rcases h with ⟨f', h1, h2⟩ [GOAL] case intro.intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ hs : UniqueDiffOn 𝕜 s f' : E → E →L[𝕜] F h1 : ContDiffOn 𝕜 (↑n) f' s h2 : ∀ (x : E), x ∈ s → HasFDerivWithinAt f (f' x) s x ⊢ DifferentiableOn 𝕜 f s ∧ ContDiffOn 𝕜 (↑n) (fun y => fderivWithin 𝕜 f s y) s [PROOFSTEP] refine' ⟨fun x hx => (h2 x hx).differentiableWithinAt, fun x hx => _⟩ [GOAL] case intro.intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ hs : UniqueDiffOn 𝕜 s f' : E → E →L[𝕜] F h1 : ContDiffOn 𝕜 (↑n) f' s h2 : ∀ (x : E), x ∈ s → HasFDerivWithinAt f (f' x) s x x : E hx : x ∈ s ⊢ ContDiffWithinAt 𝕜 (↑n) (fun y => fderivWithin 𝕜 f s y) s x [PROOFSTEP] exact (h1 x hx).congr' (fun y hy => (h2 y hy).fderivWithin (hs y hy)) hx [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ hs : IsOpen s ⊢ ContDiffOn 𝕜 (↑(n + 1)) f s ↔ DifferentiableOn 𝕜 f s ∧ ContDiffOn 𝕜 (↑n) (fun y => fderiv 𝕜 f y) s [PROOFSTEP] rw [contDiffOn_succ_iff_fderivWithin hs.uniqueDiffOn] [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ hs : IsOpen s ⊢ DifferentiableOn 𝕜 f s ∧ ContDiffOn 𝕜 (↑n) (fun y => fderivWithin 𝕜 f s y) s ↔ DifferentiableOn 𝕜 f s ∧ ContDiffOn 𝕜 (↑n) (fun y => fderiv 𝕜 f y) s [PROOFSTEP] exact Iff.rfl.and (contDiffOn_congr fun x hx ↦ fderivWithin_of_open hs hx) [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F hs : UniqueDiffOn 𝕜 s ⊢ ContDiffOn 𝕜 ⊤ f s ↔ DifferentiableOn 𝕜 f s ∧ ContDiffOn 𝕜 ⊤ (fun y => fderivWithin 𝕜 f s y) s [PROOFSTEP] constructor [GOAL] case mp 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F hs : UniqueDiffOn 𝕜 s ⊢ ContDiffOn 𝕜 ⊤ f s → DifferentiableOn 𝕜 f s ∧ ContDiffOn 𝕜 ⊤ (fun y => fderivWithin 𝕜 f s y) s [PROOFSTEP] intro h [GOAL] case mp 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F hs : UniqueDiffOn 𝕜 s h : ContDiffOn 𝕜 ⊤ f s ⊢ DifferentiableOn 𝕜 f s ∧ ContDiffOn 𝕜 ⊤ (fun y => fderivWithin 𝕜 f s y) s [PROOFSTEP] refine' ⟨h.differentiableOn le_top, _⟩ [GOAL] case mp 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F hs : UniqueDiffOn 𝕜 s h : ContDiffOn 𝕜 ⊤ f s ⊢ ContDiffOn 𝕜 ⊤ (fun y => fderivWithin 𝕜 f s y) s [PROOFSTEP] refine' contDiffOn_top.2 fun n => ((contDiffOn_succ_iff_fderivWithin hs).1 _).2 [GOAL] case mp 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F hs : UniqueDiffOn 𝕜 s h : ContDiffOn 𝕜 ⊤ f s n : ℕ ⊢ ContDiffOn 𝕜 (↑(n + 1)) f s [PROOFSTEP] exact h.of_le le_top [GOAL] case mpr 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F hs : UniqueDiffOn 𝕜 s ⊢ DifferentiableOn 𝕜 f s ∧ ContDiffOn 𝕜 ⊤ (fun y => fderivWithin 𝕜 f s y) s → ContDiffOn 𝕜 ⊤ f s [PROOFSTEP] intro h [GOAL] case mpr 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F hs : UniqueDiffOn 𝕜 s h : DifferentiableOn 𝕜 f s ∧ ContDiffOn 𝕜 ⊤ (fun y => fderivWithin 𝕜 f s y) s ⊢ ContDiffOn 𝕜 ⊤ f s [PROOFSTEP] refine' contDiffOn_top.2 fun n => _ [GOAL] case mpr 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F hs : UniqueDiffOn 𝕜 s h : DifferentiableOn 𝕜 f s ∧ ContDiffOn 𝕜 ⊤ (fun y => fderivWithin 𝕜 f s y) s n : ℕ ⊢ ContDiffOn 𝕜 (↑n) f s [PROOFSTEP] have A : (n : ℕ∞) ≤ ∞ := le_top [GOAL] case mpr 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F hs : UniqueDiffOn 𝕜 s h : DifferentiableOn 𝕜 f s ∧ ContDiffOn 𝕜 ⊤ (fun y => fderivWithin 𝕜 f s y) s n : ℕ A : ↑n ≤ ⊤ ⊢ ContDiffOn 𝕜 (↑n) f s [PROOFSTEP] apply ((contDiffOn_succ_iff_fderivWithin hs).2 ⟨h.1, h.2.of_le A⟩).of_le [GOAL] case mpr 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F hs : UniqueDiffOn 𝕜 s h : DifferentiableOn 𝕜 f s ∧ ContDiffOn 𝕜 ⊤ (fun y => fderivWithin 𝕜 f s y) s n : ℕ A : ↑n ≤ ⊤ ⊢ ↑n ≤ ↑(n + 1) [PROOFSTEP] exact WithTop.coe_le_coe.2 (Nat.le_succ n) [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F hs : IsOpen s ⊢ ContDiffOn 𝕜 ⊤ f s ↔ DifferentiableOn 𝕜 f s ∧ ContDiffOn 𝕜 ⊤ (fun y => fderiv 𝕜 f y) s [PROOFSTEP] rw [contDiffOn_top_iff_fderivWithin hs.uniqueDiffOn] [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F hs : IsOpen s ⊢ DifferentiableOn 𝕜 f s ∧ ContDiffOn 𝕜 ⊤ (fun y => fderivWithin 𝕜 f s y) s ↔ DifferentiableOn 𝕜 f s ∧ ContDiffOn 𝕜 ⊤ (fun y => fderiv 𝕜 f y) s [PROOFSTEP] exact Iff.rfl.and <| contDiffOn_congr fun x hx ↦ fderivWithin_of_open hs hx [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F hf : ContDiffOn 𝕜 n f s hs : UniqueDiffOn 𝕜 s hmn : m + 1 ≤ n ⊢ ContDiffOn 𝕜 m (fun y => fderivWithin 𝕜 f s y) s [PROOFSTEP] cases' m with m [GOAL] case none 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F hf : ContDiffOn 𝕜 n f s hs : UniqueDiffOn 𝕜 s hmn : none + 1 ≤ n ⊢ ContDiffOn 𝕜 none (fun y => fderivWithin 𝕜 f s y) s [PROOFSTEP] change ∞ + 1 ≤ n at hmn [GOAL] case none 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F hf : ContDiffOn 𝕜 n f s hs : UniqueDiffOn 𝕜 s hmn : ⊤ + 1 ≤ n ⊢ ContDiffOn 𝕜 none (fun y => fderivWithin 𝕜 f s y) s [PROOFSTEP] have : n = ∞ := by simpa using hmn [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F hf : ContDiffOn 𝕜 n f s hs : UniqueDiffOn 𝕜 s hmn : ⊤ + 1 ≤ n ⊢ n = ⊤ [PROOFSTEP] simpa using hmn [GOAL] case none 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F hf : ContDiffOn 𝕜 n f s hs : UniqueDiffOn 𝕜 s hmn : ⊤ + 1 ≤ n this : n = ⊤ ⊢ ContDiffOn 𝕜 none (fun y => fderivWithin 𝕜 f s y) s [PROOFSTEP] rw [this] at hf [GOAL] case none 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F hf : ContDiffOn 𝕜 ⊤ f s hs : UniqueDiffOn 𝕜 s hmn : ⊤ + 1 ≤ n this : n = ⊤ ⊢ ContDiffOn 𝕜 none (fun y => fderivWithin 𝕜 f s y) s [PROOFSTEP] exact ((contDiffOn_top_iff_fderivWithin hs).1 hf).2 [GOAL] case some 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F hf : ContDiffOn 𝕜 n f s hs : UniqueDiffOn 𝕜 s m : ℕ hmn : some m + 1 ≤ n ⊢ ContDiffOn 𝕜 (some m) (fun y => fderivWithin 𝕜 f s y) s [PROOFSTEP] change (m.succ : ℕ∞) ≤ n at hmn [GOAL] case some 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F hf : ContDiffOn 𝕜 n f s hs : UniqueDiffOn 𝕜 s m : ℕ hmn : ↑(Nat.succ m) ≤ n ⊢ ContDiffOn 𝕜 (some m) (fun y => fderivWithin 𝕜 f s y) s [PROOFSTEP] exact ((contDiffOn_succ_iff_fderivWithin hs).1 (hf.of_le hmn)).2 [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F h : HasFTaylorSeriesUpTo n f p x : E ⊢ p x 0 = ↑(LinearIsometryEquiv.symm (continuousMultilinearCurryFin0 𝕜 E F)) (f x) [PROOFSTEP] rw [← h.zero_eq x] [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F h : HasFTaylorSeriesUpTo n f p x : E ⊢ p x 0 = ↑(LinearIsometryEquiv.symm (continuousMultilinearCurryFin0 𝕜 E F)) (ContinuousMultilinearMap.uncurry0 (p x 0)) [PROOFSTEP] exact (p x 0).uncurry0_curry0.symm [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F ⊢ HasFTaylorSeriesUpToOn n f p univ ↔ HasFTaylorSeriesUpTo n f p [PROOFSTEP] constructor [GOAL] case mp 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F ⊢ HasFTaylorSeriesUpToOn n f p univ → HasFTaylorSeriesUpTo n f p [PROOFSTEP] intro H [GOAL] case mp 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F H : HasFTaylorSeriesUpToOn n f p univ ⊢ HasFTaylorSeriesUpTo n f p [PROOFSTEP] constructor [GOAL] case mp.zero_eq 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F H : HasFTaylorSeriesUpToOn n f p univ ⊢ ∀ (x : E), ContinuousMultilinearMap.uncurry0 (p x 0) = f x [PROOFSTEP] exact fun x => H.zero_eq x (mem_univ x) [GOAL] case mp.fderiv 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F H : HasFTaylorSeriesUpToOn n f p univ ⊢ ∀ (m : ℕ), ↑m < n → ∀ (x : E), HasFDerivAt (fun y => p y m) (ContinuousMultilinearMap.curryLeft (p x (Nat.succ m))) x [PROOFSTEP] intro m hm x [GOAL] case mp.fderiv 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝ n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F H : HasFTaylorSeriesUpToOn n f p univ m : ℕ hm : ↑m < n x : E ⊢ HasFDerivAt (fun y => p y m) (ContinuousMultilinearMap.curryLeft (p x (Nat.succ m))) x [PROOFSTEP] rw [← hasFDerivWithinAt_univ] [GOAL] case mp.fderiv 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝ n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F H : HasFTaylorSeriesUpToOn n f p univ m : ℕ hm : ↑m < n x : E ⊢ HasFDerivWithinAt (fun y => p y m) (ContinuousMultilinearMap.curryLeft (p x (Nat.succ m))) univ x [PROOFSTEP] exact H.fderivWithin m hm x (mem_univ x) [GOAL] case mp.cont 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F H : HasFTaylorSeriesUpToOn n f p univ ⊢ ∀ (m : ℕ), ↑m ≤ n → Continuous fun x => p x m [PROOFSTEP] intro m hm [GOAL] case mp.cont 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m✝ n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F H : HasFTaylorSeriesUpToOn n f p univ m : ℕ hm : ↑m ≤ n ⊢ Continuous fun x => p x m [PROOFSTEP] rw [continuous_iff_continuousOn_univ] [GOAL] case mp.cont 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m✝ n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F H : HasFTaylorSeriesUpToOn n f p univ m : ℕ hm : ↑m ≤ n ⊢ ContinuousOn (fun x => p x m) univ [PROOFSTEP] exact H.cont m hm [GOAL] case mpr 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F ⊢ HasFTaylorSeriesUpTo n f p → HasFTaylorSeriesUpToOn n f p univ [PROOFSTEP] intro H [GOAL] case mpr 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F H : HasFTaylorSeriesUpTo n f p ⊢ HasFTaylorSeriesUpToOn n f p univ [PROOFSTEP] constructor [GOAL] case mpr.zero_eq 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F H : HasFTaylorSeriesUpTo n f p ⊢ ∀ (x : E), x ∈ univ → ContinuousMultilinearMap.uncurry0 (p x 0) = f x [PROOFSTEP] exact fun x _ => H.zero_eq x [GOAL] case mpr.fderivWithin 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F H : HasFTaylorSeriesUpTo n f p ⊢ ∀ (m : ℕ), ↑m < n → ∀ (x : E), x ∈ univ → HasFDerivWithinAt (fun x => p x m) (ContinuousMultilinearMap.curryLeft (p x (Nat.succ m))) univ x [PROOFSTEP] intro m hm x _ [GOAL] case mpr.fderivWithin 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝ n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F H : HasFTaylorSeriesUpTo n f p m : ℕ hm : ↑m < n x : E a✝ : x ∈ univ ⊢ HasFDerivWithinAt (fun x => p x m) (ContinuousMultilinearMap.curryLeft (p x (Nat.succ m))) univ x [PROOFSTEP] rw [hasFDerivWithinAt_univ] [GOAL] case mpr.fderivWithin 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝ n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F H : HasFTaylorSeriesUpTo n f p m : ℕ hm : ↑m < n x : E a✝ : x ∈ univ ⊢ HasFDerivAt (fun x => p x m) (ContinuousMultilinearMap.curryLeft (p x (Nat.succ m))) x [PROOFSTEP] exact H.fderiv m hm x [GOAL] case mpr.cont 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F H : HasFTaylorSeriesUpTo n f p ⊢ ∀ (m : ℕ), ↑m ≤ n → ContinuousOn (fun x => p x m) univ [PROOFSTEP] intro m hm [GOAL] case mpr.cont 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m✝ n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F H : HasFTaylorSeriesUpTo n f p m : ℕ hm : ↑m ≤ n ⊢ ContinuousOn (fun x => p x m) univ [PROOFSTEP] rw [← continuous_iff_continuousOn_univ] [GOAL] case mpr.cont 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m✝ n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F H : HasFTaylorSeriesUpTo n f p m : ℕ hm : ↑m ≤ n ⊢ Continuous fun x => p x m [PROOFSTEP] exact H.cont m hm [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F h : HasFTaylorSeriesUpTo n f p hmn : m ≤ n ⊢ HasFTaylorSeriesUpTo m f p [PROOFSTEP] rw [← hasFTaylorSeriesUpToOn_univ_iff] at h ⊢ [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F h : HasFTaylorSeriesUpToOn n f p univ hmn : m ≤ n ⊢ HasFTaylorSeriesUpToOn m f p univ [PROOFSTEP] exact h.of_le hmn [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F h : HasFTaylorSeriesUpTo n f p ⊢ Continuous f [PROOFSTEP] rw [← hasFTaylorSeriesUpToOn_univ_iff] at h [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F h : HasFTaylorSeriesUpToOn n f p univ ⊢ Continuous f [PROOFSTEP] rw [continuous_iff_continuousOn_univ] [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F h : HasFTaylorSeriesUpToOn n f p univ ⊢ ContinuousOn f univ [PROOFSTEP] exact h.continuousOn [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F ⊢ HasFTaylorSeriesUpTo 0 f p ↔ Continuous f ∧ ∀ (x : E), ContinuousMultilinearMap.uncurry0 (p x 0) = f x [PROOFSTEP] simp [hasFTaylorSeriesUpToOn_univ_iff.symm, continuous_iff_continuousOn_univ, hasFTaylorSeriesUpToOn_zero_iff] [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F ⊢ HasFTaylorSeriesUpTo ⊤ f p ↔ ∀ (n : ℕ), HasFTaylorSeriesUpTo (↑n) f p [PROOFSTEP] simp only [← hasFTaylorSeriesUpToOn_univ_iff, hasFTaylorSeriesUpToOn_top_iff] [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F ⊢ HasFTaylorSeriesUpTo ⊤ f p ↔ (∀ (x : E), ContinuousMultilinearMap.uncurry0 (p x 0) = f x) ∧ ∀ (m : ℕ) (x : E), HasFDerivAt (fun y => p y m) (ContinuousMultilinearMap.curryLeft (p x (Nat.succ m))) x [PROOFSTEP] simp only [← hasFTaylorSeriesUpToOn_univ_iff, hasFTaylorSeriesUpToOn_top_iff', mem_univ, forall_true_left, hasFDerivWithinAt_univ] [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F h : HasFTaylorSeriesUpTo n f p hn : 1 ≤ n x : E ⊢ HasFDerivAt f (↑(continuousMultilinearCurryFin1 𝕜 E F) (p x 1)) x [PROOFSTEP] rw [← hasFDerivWithinAt_univ] [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F h : HasFTaylorSeriesUpTo n f p hn : 1 ≤ n x : E ⊢ HasFDerivWithinAt f (↑(continuousMultilinearCurryFin1 𝕜 E F) (p x 1)) univ x [PROOFSTEP] exact (hasFTaylorSeriesUpToOn_univ_iff.2 h).hasFDerivWithinAt hn (mem_univ _) [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ ⊢ HasFTaylorSeriesUpTo (↑(n + 1)) f p ↔ (∀ (x : E), ContinuousMultilinearMap.uncurry0 (p x 0) = f x) ∧ (∀ (x : E), HasFDerivAt (fun y => p y 0) (ContinuousMultilinearMap.curryLeft (p x 1)) x) ∧ HasFTaylorSeriesUpTo (↑n) (fun x => ↑(continuousMultilinearCurryFin1 𝕜 E F) (p x 1)) fun x => FormalMultilinearSeries.shift (p x) [PROOFSTEP] simp only [hasFTaylorSeriesUpToOn_succ_iff_right, ← hasFTaylorSeriesUpToOn_univ_iff, mem_univ, forall_true_left, hasFDerivWithinAt_univ] [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F ⊢ ContDiffAt 𝕜 ⊤ f x ↔ ∀ (n : ℕ), ContDiffAt 𝕜 (↑n) f x [PROOFSTEP] simp [← contDiffWithinAt_univ, contDiffWithinAt_top] [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F h : ContDiffWithinAt 𝕜 n f s x hx : s ∈ 𝓝 x ⊢ ContDiffAt 𝕜 n f x [PROOFSTEP] rwa [ContDiffAt, ← contDiffWithinAt_inter hx, univ_inter] [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F h : ContDiffAt 𝕜 n f x hg : f₁ =ᶠ[𝓝 x] f ⊢ f₁ =ᶠ[𝓝[univ] x] f [PROOFSTEP] rwa [nhdsWithin_univ] [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F h : ContDiffAt 𝕜 n f x ⊢ ContinuousAt f x [PROOFSTEP] simpa [continuousWithinAt_univ] using h.continuousWithinAt [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F h : ContDiffAt 𝕜 n f x hn : 1 ≤ n ⊢ DifferentiableAt 𝕜 f x [PROOFSTEP] simpa [hn, differentiableWithinAt_univ] using h.differentiableWithinAt [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ ⊢ ContDiffAt 𝕜 (↑(n + 1)) f x ↔ ∃ f', (∃ u, u ∈ 𝓝 x ∧ ∀ (x : E), x ∈ u → HasFDerivAt f (f' x) x) ∧ ContDiffAt 𝕜 (↑n) f' x [PROOFSTEP] rw [← contDiffWithinAt_univ, contDiffWithinAt_succ_iff_hasFDerivWithinAt] [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ ⊢ (∃ u, u ∈ 𝓝[insert x univ] x ∧ ∃ f', (∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) u x) ∧ ContDiffWithinAt 𝕜 (↑n) f' u x) ↔ ∃ f', (∃ u, u ∈ 𝓝 x ∧ ∀ (x : E), x ∈ u → HasFDerivAt f (f' x) x) ∧ ContDiffAt 𝕜 (↑n) f' x [PROOFSTEP] simp only [nhdsWithin_univ, exists_prop, mem_univ, insert_eq_of_mem] [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ ⊢ (∃ u, u ∈ 𝓝 x ∧ ∃ f', (∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) u x) ∧ ContDiffWithinAt 𝕜 (↑n) f' u x) ↔ ∃ f', (∃ u, u ∈ 𝓝 x ∧ ∀ (x : E), x ∈ u → HasFDerivAt f (f' x) x) ∧ ContDiffAt 𝕜 (↑n) f' x [PROOFSTEP] constructor [GOAL] case mp 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ ⊢ (∃ u, u ∈ 𝓝 x ∧ ∃ f', (∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) u x) ∧ ContDiffWithinAt 𝕜 (↑n) f' u x) → ∃ f', (∃ u, u ∈ 𝓝 x ∧ ∀ (x : E), x ∈ u → HasFDerivAt f (f' x) x) ∧ ContDiffAt 𝕜 (↑n) f' x [PROOFSTEP] rintro ⟨u, H, f', h_fderiv, h_cont_diff⟩ [GOAL] case mp.intro.intro.intro.intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ u : Set E H : u ∈ 𝓝 x f' : E → E →L[𝕜] F h_fderiv : ∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) u x h_cont_diff : ContDiffWithinAt 𝕜 (↑n) f' u x ⊢ ∃ f', (∃ u, u ∈ 𝓝 x ∧ ∀ (x : E), x ∈ u → HasFDerivAt f (f' x) x) ∧ ContDiffAt 𝕜 (↑n) f' x [PROOFSTEP] rcases mem_nhds_iff.mp H with ⟨t, htu, ht, hxt⟩ [GOAL] case mp.intro.intro.intro.intro.intro.intro.intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t✝ u✝ : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ u : Set E H : u ∈ 𝓝 x f' : E → E →L[𝕜] F h_fderiv : ∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) u x h_cont_diff : ContDiffWithinAt 𝕜 (↑n) f' u x t : Set E htu : t ⊆ u ht : IsOpen t hxt : x ∈ t ⊢ ∃ f', (∃ u, u ∈ 𝓝 x ∧ ∀ (x : E), x ∈ u → HasFDerivAt f (f' x) x) ∧ ContDiffAt 𝕜 (↑n) f' x [PROOFSTEP] refine' ⟨f', ⟨t, _⟩, h_cont_diff.contDiffAt H⟩ [GOAL] case mp.intro.intro.intro.intro.intro.intro.intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t✝ u✝ : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ u : Set E H : u ∈ 𝓝 x f' : E → E →L[𝕜] F h_fderiv : ∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) u x h_cont_diff : ContDiffWithinAt 𝕜 (↑n) f' u x t : Set E htu : t ⊆ u ht : IsOpen t hxt : x ∈ t ⊢ t ∈ 𝓝 x ∧ ∀ (x : E), x ∈ t → HasFDerivAt f (f' x) x [PROOFSTEP] refine' ⟨mem_nhds_iff.mpr ⟨t, Subset.rfl, ht, hxt⟩, _⟩ [GOAL] case mp.intro.intro.intro.intro.intro.intro.intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t✝ u✝ : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ u : Set E H : u ∈ 𝓝 x f' : E → E →L[𝕜] F h_fderiv : ∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) u x h_cont_diff : ContDiffWithinAt 𝕜 (↑n) f' u x t : Set E htu : t ⊆ u ht : IsOpen t hxt : x ∈ t ⊢ ∀ (x : E), x ∈ t → HasFDerivAt f (f' x) x [PROOFSTEP] intro y hyt [GOAL] case mp.intro.intro.intro.intro.intro.intro.intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t✝ u✝ : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ u : Set E H : u ∈ 𝓝 x f' : E → E →L[𝕜] F h_fderiv : ∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) u x h_cont_diff : ContDiffWithinAt 𝕜 (↑n) f' u x t : Set E htu : t ⊆ u ht : IsOpen t hxt : x ∈ t y : E hyt : y ∈ t ⊢ HasFDerivAt f (f' y) y [PROOFSTEP] refine' (h_fderiv y (htu hyt)).hasFDerivAt _ [GOAL] case mp.intro.intro.intro.intro.intro.intro.intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t✝ u✝ : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ u : Set E H : u ∈ 𝓝 x f' : E → E →L[𝕜] F h_fderiv : ∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) u x h_cont_diff : ContDiffWithinAt 𝕜 (↑n) f' u x t : Set E htu : t ⊆ u ht : IsOpen t hxt : x ∈ t y : E hyt : y ∈ t ⊢ u ∈ 𝓝 y [PROOFSTEP] exact mem_nhds_iff.mpr ⟨t, htu, ht, hyt⟩ [GOAL] case mpr 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ ⊢ (∃ f', (∃ u, u ∈ 𝓝 x ∧ ∀ (x : E), x ∈ u → HasFDerivAt f (f' x) x) ∧ ContDiffAt 𝕜 (↑n) f' x) → ∃ u, u ∈ 𝓝 x ∧ ∃ f', (∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) u x) ∧ ContDiffWithinAt 𝕜 (↑n) f' u x [PROOFSTEP] rintro ⟨f', ⟨u, H, h_fderiv⟩, h_cont_diff⟩ [GOAL] case mpr.intro.intro.intro.intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ f' : E → E →L[𝕜] F h_cont_diff : ContDiffAt 𝕜 (↑n) f' x u : Set E H : u ∈ 𝓝 x h_fderiv : ∀ (x : E), x ∈ u → HasFDerivAt f (f' x) x ⊢ ∃ u, u ∈ 𝓝 x ∧ ∃ f', (∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) u x) ∧ ContDiffWithinAt 𝕜 (↑n) f' u x [PROOFSTEP] refine' ⟨u, H, f', _, h_cont_diff.contDiffWithinAt⟩ [GOAL] case mpr.intro.intro.intro.intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ f' : E → E →L[𝕜] F h_cont_diff : ContDiffAt 𝕜 (↑n) f' x u : Set E H : u ∈ 𝓝 x h_fderiv : ∀ (x : E), x ∈ u → HasFDerivAt f (f' x) x ⊢ ∀ (x : E), x ∈ u → HasFDerivWithinAt f (f' x) u x [PROOFSTEP] intro x hxu [GOAL] case mpr.intro.intro.intro.intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ f' : E → E →L[𝕜] F h_cont_diff : ContDiffAt 𝕜 (↑n) f' x✝ u : Set E H : u ∈ 𝓝 x✝ h_fderiv : ∀ (x : E), x ∈ u → HasFDerivAt f (f' x) x x : E hxu : x ∈ u ⊢ HasFDerivWithinAt f (f' x) u x [PROOFSTEP] exact (h_fderiv x hxu).hasFDerivWithinAt [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ h : ContDiffAt 𝕜 (↑n) f x ⊢ ∀ᶠ (y : E) in 𝓝 x, ContDiffAt 𝕜 (↑n) f y [PROOFSTEP] simpa [nhdsWithin_univ] using ContDiffWithinAt.eventually h [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F ⊢ ContDiffOn 𝕜 n f univ ↔ ContDiff 𝕜 n f [PROOFSTEP] constructor [GOAL] case mp 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F ⊢ ContDiffOn 𝕜 n f univ → ContDiff 𝕜 n f [PROOFSTEP] intro H [GOAL] case mp 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F H : ContDiffOn 𝕜 n f univ ⊢ ContDiff 𝕜 n f [PROOFSTEP] use ftaylorSeriesWithin 𝕜 f univ [GOAL] case h 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F H : ContDiffOn 𝕜 n f univ ⊢ HasFTaylorSeriesUpTo n f (ftaylorSeriesWithin 𝕜 f univ) [PROOFSTEP] rw [← hasFTaylorSeriesUpToOn_univ_iff] [GOAL] case h 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F H : ContDiffOn 𝕜 n f univ ⊢ HasFTaylorSeriesUpToOn n f (ftaylorSeriesWithin 𝕜 f univ) univ [PROOFSTEP] exact H.ftaylorSeriesWithin uniqueDiffOn_univ [GOAL] case mpr 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F ⊢ ContDiff 𝕜 n f → ContDiffOn 𝕜 n f univ [PROOFSTEP] rintro ⟨p, hp⟩ x _ m hm [GOAL] case mpr.intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝ n : ℕ∞ p✝ : E → FormalMultilinearSeries 𝕜 E F p : E → FormalMultilinearSeries 𝕜 E F hp : HasFTaylorSeriesUpTo n f p x : E a✝ : x ∈ univ m : ℕ hm : ↑m ≤ n ⊢ ∃ u, u ∈ 𝓝[insert x univ] x ∧ ∃ p, HasFTaylorSeriesUpToOn (↑m) f p u [PROOFSTEP] exact ⟨univ, Filter.univ_sets _, p, (hp.hasFTaylorSeriesUpToOn univ).of_le hm⟩ [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F ⊢ ContDiff 𝕜 n f ↔ ∀ (x : E), ContDiffAt 𝕜 n f x [PROOFSTEP] simp [← contDiffOn_univ, ContDiffOn, ContDiffAt] [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F ⊢ ContDiff 𝕜 ⊤ f ↔ ∀ (n : ℕ), ContDiff 𝕜 (↑n) f [PROOFSTEP] simp [contDiffOn_univ.symm, contDiffOn_top] [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F ⊢ (∀ (n : ℕ∞), ContDiff 𝕜 n f) ↔ ∀ (n : ℕ), ContDiff 𝕜 (↑n) f [PROOFSTEP] simp only [← contDiffOn_univ, contDiffOn_all_iff_nat] [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F ⊢ ContDiff 𝕜 0 f ↔ Continuous f [PROOFSTEP] rw [← contDiffOn_univ, continuous_iff_continuousOn_univ] [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F ⊢ ContDiffOn 𝕜 0 f univ ↔ ContinuousOn f univ [PROOFSTEP] exact contDiffOn_zero [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F ⊢ ContDiffAt 𝕜 0 f x ↔ ∃ u, u ∈ 𝓝 x ∧ ContinuousOn f u [PROOFSTEP] rw [← contDiffWithinAt_univ] [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F ⊢ ContDiffWithinAt 𝕜 0 f univ x ↔ ∃ u, u ∈ 𝓝 x ∧ ContinuousOn f u [PROOFSTEP] simp [contDiffWithinAt_zero, nhdsWithin_univ] [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F ⊢ ContDiffAt 𝕜 1 f x ↔ ∃ f' u, u ∈ 𝓝 x ∧ ContinuousOn f' u ∧ ∀ (x : E), x ∈ u → HasFDerivAt f (f' x) x [PROOFSTEP] simp_rw [show (1 : ℕ∞) = (0 + 1 : ℕ) from (zero_add 1).symm, contDiffAt_succ_iff_hasFDerivAt, show ((0 : ℕ) : ℕ∞) = 0 from rfl, contDiffAt_zero, exists_mem_and_iff antitone_bforall antitone_continuousOn, and_comm] [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F ⊢ ContDiff 𝕜 n f ↔ ∀ (m : ℕ), ↑m ≤ n → ContDiff 𝕜 (↑m) f [PROOFSTEP] simp_rw [← contDiffOn_univ] [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F ⊢ ContDiffOn 𝕜 n f univ ↔ ∀ (m : ℕ), ↑m ≤ n → ContDiffOn 𝕜 (↑m) f univ [PROOFSTEP] exact contDiffOn_iff_forall_nat_le [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ ⊢ ContDiff 𝕜 (↑(n + 1)) f ↔ ∃ f', ContDiff 𝕜 (↑n) f' ∧ ∀ (x : E), HasFDerivAt f (f' x) x [PROOFSTEP] simp only [← contDiffOn_univ, ← hasFDerivWithinAt_univ, contDiffOn_succ_iff_has_fderiv_within uniqueDiffOn_univ, Set.mem_univ, forall_true_left] [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F ⊢ ‖iteratedFDeriv 𝕜 0 f x‖ = ‖f x‖ [PROOFSTEP] rw [iteratedFDeriv_zero_eq_comp, comp_apply, LinearIsometryEquiv.norm_map] [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ ⊢ fderiv 𝕜 (iteratedFDeriv 𝕜 n f) = ↑(LinearIsometryEquiv.symm (continuousMultilinearCurryLeftEquiv 𝕜 (fun x => E) F)) ∘ iteratedFDeriv 𝕜 (n + 1) f [PROOFSTEP] rw [iteratedFDeriv_succ_eq_comp_left] [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ ⊢ fderiv 𝕜 (iteratedFDeriv 𝕜 n f) = ↑(LinearIsometryEquiv.symm (continuousMultilinearCurryLeftEquiv 𝕜 (fun x => E) F)) ∘ ↑(continuousMultilinearCurryLeftEquiv 𝕜 (fun x => E) F) ∘ fderiv 𝕜 (iteratedFDeriv 𝕜 n f) [PROOFSTEP] ext1 x [GOAL] case h 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ x : E ⊢ fderiv 𝕜 (iteratedFDeriv 𝕜 n f) x = (↑(LinearIsometryEquiv.symm (continuousMultilinearCurryLeftEquiv 𝕜 (fun x => E) F)) ∘ ↑(continuousMultilinearCurryLeftEquiv 𝕜 (fun x => E) F) ∘ fderiv 𝕜 (iteratedFDeriv 𝕜 n f)) x [PROOFSTEP] simp only [Function.comp_apply, LinearIsometryEquiv.symm_apply_apply] [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ ⊢ tsupport (iteratedFDeriv 𝕜 n f) ⊆ tsupport f [PROOFSTEP] induction' n with n IH [GOAL] case zero 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F ⊢ tsupport (iteratedFDeriv 𝕜 Nat.zero f) ⊆ tsupport f [PROOFSTEP] rw [iteratedFDeriv_zero_eq_comp] [GOAL] case zero 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F ⊢ tsupport (↑(LinearIsometryEquiv.symm (continuousMultilinearCurryFin0 𝕜 E F)) ∘ f) ⊆ tsupport f [PROOFSTEP] exact closure_minimal ((support_comp_subset (LinearIsometryEquiv.map_zero _) _).trans subset_closure) isClosed_closure [GOAL] case succ 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ IH : tsupport (iteratedFDeriv 𝕜 n f) ⊆ tsupport f ⊢ tsupport (iteratedFDeriv 𝕜 (Nat.succ n) f) ⊆ tsupport f [PROOFSTEP] rw [iteratedFDeriv_succ_eq_comp_left] [GOAL] case succ 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ IH : tsupport (iteratedFDeriv 𝕜 n f) ⊆ tsupport f ⊢ tsupport (↑(continuousMultilinearCurryLeftEquiv 𝕜 (fun x => E) F) ∘ fderiv 𝕜 (iteratedFDeriv 𝕜 n f)) ⊆ tsupport f [PROOFSTEP] exact closure_minimal ((support_comp_subset (LinearIsometryEquiv.map_zero _) _).trans ((support_fderiv_subset 𝕜).trans IH)) isClosed_closure [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ ⊢ ‖fderiv 𝕜 (iteratedFDeriv 𝕜 n f) x‖ = ‖iteratedFDeriv 𝕜 (n + 1) f x‖ [PROOFSTEP] rw [iteratedFDeriv_succ_eq_comp_left, comp_apply, LinearIsometryEquiv.norm_map] [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ ⊢ iteratedFDerivWithin 𝕜 n f univ = iteratedFDeriv 𝕜 n f [PROOFSTEP] induction' n with n IH [GOAL] case zero 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F ⊢ iteratedFDerivWithin 𝕜 Nat.zero f univ = iteratedFDeriv 𝕜 Nat.zero f [PROOFSTEP] ext x [GOAL] case zero.h.H 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝¹ x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F x : E x✝ : Fin Nat.zero → E ⊢ ↑(iteratedFDerivWithin 𝕜 Nat.zero f univ x) x✝ = ↑(iteratedFDeriv 𝕜 Nat.zero f x) x✝ [PROOFSTEP] simp [GOAL] case succ 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ IH : iteratedFDerivWithin 𝕜 n f univ = iteratedFDeriv 𝕜 n f ⊢ iteratedFDerivWithin 𝕜 (Nat.succ n) f univ = iteratedFDeriv 𝕜 (Nat.succ n) f [PROOFSTEP] ext x m [GOAL] case succ.h.H 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m✝ n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ IH : iteratedFDerivWithin 𝕜 n f univ = iteratedFDeriv 𝕜 n f x : E m : Fin (Nat.succ n) → E ⊢ ↑(iteratedFDerivWithin 𝕜 (Nat.succ n) f univ x) m = ↑(iteratedFDeriv 𝕜 (Nat.succ n) f x) m [PROOFSTEP] rw [iteratedFDeriv_succ_apply_left, iteratedFDerivWithin_succ_apply_left, IH, fderivWithin_univ] [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ hs : IsOpen s ⊢ EqOn (iteratedFDerivWithin 𝕜 n f s) (iteratedFDeriv 𝕜 n f) s [PROOFSTEP] induction' n with n IH [GOAL] case zero 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F hs : IsOpen s ⊢ EqOn (iteratedFDerivWithin 𝕜 Nat.zero f s) (iteratedFDeriv 𝕜 Nat.zero f) s [PROOFSTEP] intro x _ [GOAL] case zero 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F hs : IsOpen s x : E a✝ : x ∈ s ⊢ iteratedFDerivWithin 𝕜 Nat.zero f s x = iteratedFDeriv 𝕜 Nat.zero f x [PROOFSTEP] ext1 [GOAL] case zero.H 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝¹ x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F hs : IsOpen s x : E a✝ : x ∈ s x✝ : Fin Nat.zero → E ⊢ ↑(iteratedFDerivWithin 𝕜 Nat.zero f s x) x✝ = ↑(iteratedFDeriv 𝕜 Nat.zero f x) x✝ [PROOFSTEP] simp only [Nat.zero_eq, iteratedFDerivWithin_zero_apply, iteratedFDeriv_zero_apply] [GOAL] case succ 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F hs : IsOpen s n : ℕ IH : EqOn (iteratedFDerivWithin 𝕜 n f s) (iteratedFDeriv 𝕜 n f) s ⊢ EqOn (iteratedFDerivWithin 𝕜 (Nat.succ n) f s) (iteratedFDeriv 𝕜 (Nat.succ n) f) s [PROOFSTEP] intro x hx [GOAL] case succ 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F hs : IsOpen s n : ℕ IH : EqOn (iteratedFDerivWithin 𝕜 n f s) (iteratedFDeriv 𝕜 n f) s x : E hx : x ∈ s ⊢ iteratedFDerivWithin 𝕜 (Nat.succ n) f s x = iteratedFDeriv 𝕜 (Nat.succ n) f x [PROOFSTEP] rw [iteratedFDeriv_succ_eq_comp_left, iteratedFDerivWithin_succ_eq_comp_left] [GOAL] case succ 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F hs : IsOpen s n : ℕ IH : EqOn (iteratedFDerivWithin 𝕜 n f s) (iteratedFDeriv 𝕜 n f) s x : E hx : x ∈ s ⊢ (↑(continuousMultilinearCurryLeftEquiv 𝕜 (fun x => E) F) ∘ fderivWithin 𝕜 (iteratedFDerivWithin 𝕜 n f s) s) x = (↑(continuousMultilinearCurryLeftEquiv 𝕜 (fun x => E) F) ∘ fderiv 𝕜 (iteratedFDeriv 𝕜 n f)) x [PROOFSTEP] dsimp [GOAL] case succ 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F hs : IsOpen s n : ℕ IH : EqOn (iteratedFDerivWithin 𝕜 n f s) (iteratedFDeriv 𝕜 n f) s x : E hx : x ∈ s ⊢ ↑(continuousMultilinearCurryLeftEquiv 𝕜 (fun x => E) F) (fderivWithin 𝕜 (iteratedFDerivWithin 𝕜 n f s) s x) = ↑(continuousMultilinearCurryLeftEquiv 𝕜 (fun x => E) F) (fderiv 𝕜 (iteratedFDeriv 𝕜 n f) x) [PROOFSTEP] congr 1 [GOAL] case succ.h.e_6.h 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F hs : IsOpen s n : ℕ IH : EqOn (iteratedFDerivWithin 𝕜 n f s) (iteratedFDeriv 𝕜 n f) s x : E hx : x ∈ s ⊢ fderivWithin 𝕜 (iteratedFDerivWithin 𝕜 n f s) s x = fderiv 𝕜 (iteratedFDeriv 𝕜 n f) x [PROOFSTEP] rw [fderivWithin_of_open hs hx] [GOAL] case succ.h.e_6.h 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F hs : IsOpen s n : ℕ IH : EqOn (iteratedFDerivWithin 𝕜 n f s) (iteratedFDeriv 𝕜 n f) s x : E hx : x ∈ s ⊢ fderiv 𝕜 (iteratedFDerivWithin 𝕜 n f s) x = fderiv 𝕜 (iteratedFDeriv 𝕜 n f) x [PROOFSTEP] apply Filter.EventuallyEq.fderiv_eq [GOAL] case succ.h.e_6.h.h 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F hs : IsOpen s n : ℕ IH : EqOn (iteratedFDerivWithin 𝕜 n f s) (iteratedFDeriv 𝕜 n f) s x : E hx : x ∈ s ⊢ iteratedFDerivWithin 𝕜 n f s =ᶠ[𝓝 x] iteratedFDeriv 𝕜 n f [PROOFSTEP] filter_upwards [hs.mem_nhds hx] [GOAL] case h 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F hs : IsOpen s n : ℕ IH : EqOn (iteratedFDerivWithin 𝕜 n f s) (iteratedFDeriv 𝕜 n f) s x : E hx : x ∈ s ⊢ ∀ (a : E), a ∈ s → iteratedFDerivWithin 𝕜 n f s a = iteratedFDeriv 𝕜 n f a [PROOFSTEP] exact IH [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F ⊢ ftaylorSeriesWithin 𝕜 f univ = ftaylorSeries 𝕜 f [PROOFSTEP] ext1 x [GOAL] case h 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F x : E ⊢ ftaylorSeriesWithin 𝕜 f univ x = ftaylorSeries 𝕜 f x [PROOFSTEP] ext1 n [GOAL] case h.h 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F x : E n : ℕ ⊢ ftaylorSeriesWithin 𝕜 f univ x n = ftaylorSeries 𝕜 f x n [PROOFSTEP] change iteratedFDerivWithin 𝕜 n f univ x = iteratedFDeriv 𝕜 n f x [GOAL] case h.h 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F x : E n : ℕ ⊢ iteratedFDerivWithin 𝕜 n f univ x = iteratedFDeriv 𝕜 n f x [PROOFSTEP] rw [iteratedFDerivWithin_univ] [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m✝ n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ m : Fin (n + 1) → E ⊢ ↑(iteratedFDeriv 𝕜 (n + 1) f x) m = ↑(↑(iteratedFDeriv 𝕜 n (fun y => fderiv 𝕜 f y) x) (init m)) (m (last n)) [PROOFSTEP] rw [← iteratedFDerivWithin_univ, ← iteratedFDerivWithin_univ, ← fderivWithin_univ] [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m✝ n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ m : Fin (n + 1) → E ⊢ ↑(iteratedFDerivWithin 𝕜 (n + 1) f univ x) m = ↑(↑(iteratedFDerivWithin 𝕜 n (fun y => fderivWithin 𝕜 f univ y) univ x) (init m)) (m (last n)) [PROOFSTEP] exact iteratedFDerivWithin_succ_apply_right uniqueDiffOn_univ (mem_univ _) _ [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ ⊢ iteratedFDeriv 𝕜 (n + 1) f x = (↑(continuousMultilinearCurryRightEquiv' 𝕜 n E F) ∘ iteratedFDeriv 𝕜 n fun y => fderiv 𝕜 f y) x [PROOFSTEP] ext m [GOAL] case H 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m✝ n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ m : Fin (n + 1) → E ⊢ ↑(iteratedFDeriv 𝕜 (n + 1) f x) m = ↑((↑(continuousMultilinearCurryRightEquiv' 𝕜 n E F) ∘ iteratedFDeriv 𝕜 n fun y => fderiv 𝕜 f y) x) m [PROOFSTEP] rw [iteratedFDeriv_succ_apply_right] [GOAL] case H 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m✝ n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ m : Fin (n + 1) → E ⊢ ↑(↑(iteratedFDeriv 𝕜 n (fun y => fderiv 𝕜 f y) x) (init m)) (m (last n)) = ↑((↑(continuousMultilinearCurryRightEquiv' 𝕜 n E F) ∘ iteratedFDeriv 𝕜 n fun y => fderiv 𝕜 f y) x) m [PROOFSTEP] rfl [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ ⊢ ‖iteratedFDeriv 𝕜 n (fderiv 𝕜 f) x‖ = ‖iteratedFDeriv 𝕜 (n + 1) f x‖ [PROOFSTEP] rw [iteratedFDeriv_succ_eq_comp_right, comp_apply, LinearIsometryEquiv.norm_map] [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m✝ n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F m : Fin 1 → E ⊢ ↑(iteratedFDeriv 𝕜 1 f x) m = ↑(fderiv 𝕜 f x) (m 0) [PROOFSTEP] rw [iteratedFDeriv_succ_apply_right, iteratedFDeriv_zero_apply] [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m✝ n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F m : Fin 1 → E ⊢ ↑(fderiv 𝕜 f x) (m (last 0)) = ↑(fderiv 𝕜 f x) (m 0) [PROOFSTEP] rfl [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F ⊢ ContDiff 𝕜 n f ↔ HasFTaylorSeriesUpTo n f (ftaylorSeries 𝕜 f) [PROOFSTEP] constructor [GOAL] case mp 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F ⊢ ContDiff 𝕜 n f → HasFTaylorSeriesUpTo n f (ftaylorSeries 𝕜 f) [PROOFSTEP] rw [← contDiffOn_univ, ← hasFTaylorSeriesUpToOn_univ_iff, ← ftaylorSeriesWithin_univ] [GOAL] case mp 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F ⊢ ContDiffOn 𝕜 n f univ → HasFTaylorSeriesUpToOn n f (ftaylorSeriesWithin 𝕜 f univ) univ [PROOFSTEP] exact fun h => ContDiffOn.ftaylorSeriesWithin h uniqueDiffOn_univ [GOAL] case mpr 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F ⊢ HasFTaylorSeriesUpTo n f (ftaylorSeries 𝕜 f) → ContDiff 𝕜 n f [PROOFSTEP] intro h [GOAL] case mpr 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F h : HasFTaylorSeriesUpTo n f (ftaylorSeries 𝕜 f) ⊢ ContDiff 𝕜 n f [PROOFSTEP] exact ⟨ftaylorSeries 𝕜 f, h⟩ [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F ⊢ ContDiff 𝕜 n f ↔ (∀ (m : ℕ), ↑m ≤ n → Continuous fun x => iteratedFDeriv 𝕜 m f x) ∧ ∀ (m : ℕ), ↑m < n → Differentiable 𝕜 fun x => iteratedFDeriv 𝕜 m f x [PROOFSTEP] simp [contDiffOn_univ.symm, continuous_iff_continuousOn_univ, differentiableOn_univ.symm, iteratedFDerivWithin_univ, contDiffOn_iff_continuousOn_differentiableOn uniqueDiffOn_univ] [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n✝ : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F n : ℕ ⊢ ContDiff 𝕜 (↑(n + 1)) f ↔ Differentiable 𝕜 f ∧ ContDiff 𝕜 ↑n fun y => fderiv 𝕜 f y [PROOFSTEP] simp only [← contDiffOn_univ, ← differentiableOn_univ, ← fderivWithin_univ, contDiffOn_succ_iff_fderivWithin uniqueDiffOn_univ] [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F ⊢ ContDiff 𝕜 ⊤ f ↔ Differentiable 𝕜 f ∧ ContDiff 𝕜 ⊤ fun y => fderiv 𝕜 f y [PROOFSTEP] simp only [← contDiffOn_univ, ← differentiableOn_univ, ← fderivWithin_univ] [GOAL] 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F ⊢ ContDiffOn 𝕜 ⊤ f univ ↔ DifferentiableOn 𝕜 f univ ∧ ContDiffOn 𝕜 ⊤ (fun y => fderivWithin 𝕜 f univ y) univ [PROOFSTEP] rw [contDiffOn_top_iff_fderivWithin uniqueDiffOn_univ]
[STATEMENT] lemma assertion_neg_assert: "x \<in> assertion \<longleftrightarrow> x = neg_assert (neg_assert x)" [PROOF STATE] proof (prove) goal (1 subgoal): 1. (x \<in> assertion) = (x = neg_assert (neg_assert x)) [PROOF STEP] by (metis neg_assertion uminus_uminus)
program decl_all integer a integer :: b, c = -10 real :: d = -99.34 logical :: e = .true. real :: arr(10,-1:100), f integer, DIMENSION(1:10,-1:100, -1:10) :: g end program decl_all
// --------------------------------------------------------------------------------- // <copyright company="Microsoft"> // Copyright (c) Microsoft Corporation. All rights reserved. // </copyright> // --------------------------------------------------------------------------------- // // To use: // ./vspec-to-dtdl /home/ashbeitz/repos/Vehicle-DataModel-Tools/third-party/vehicle_signal_specification/src/vehicle_signal_specification/spec/VehicleSignalSpecification.vspec // #include <iostream> #include <string> #include <vector> #include <boost/program_options.hpp> #include "vspec-definition.h" #include "vspec-parser.h" #include "dtdl-definition.h" #include "dtdl-composer.h" #include "vspec-to-dtdl-converter.h" using namespace boost; using namespace microsoft::automotive::data; int main(int argc, char *argv[]) { try { program_options::options_description options("Allowed options"); options.add_options() ("help", "produce help message") ("vspec-file", program_options::value<std::string>(), "location of the root vspec file") ; program_options::positional_options_description positions; positions.add("vspec-file", -1); program_options::variables_map vm; program_options::store(program_options::command_line_parser(argc, argv).options(options).positional(positions).run(), vm); program_options::notify(vm); if (vm.count("help")) { std::cout << options << "\n"; return 0; } std::string vspecFilePath; if (vm.count("vspec-file")) { vspecFilePath = vm["vspec-file"].as<std::string>(); std::cout << "vspec-file was set to " << vspecFilePath << "\n"; } else { std::cout << "vspec-file was not set.\n"; } vspec::Definition vspecDefinition; VspecParser vspecParser; vspecParser.Parse(vspecFilePath, vspecDefinition); dtdl::Definition dtdlDefinition; VspecToDtdlConverter vspecToDtdlConverter; vspecToDtdlConverter.Convert(vspecDefinition, dtdlDefinition); DtdlComposer dtdlComposer; dtdlComposer.Compose(dtdlDefinition); } catch (const VspecParserException& pe) { std::cerr << pe.what() << '\n'; return 1; } catch (std::exception& e) { std::cerr << "error: " << e.what() << "\n"; return 1; } catch (...) { std::cerr << "Exception of unknown type!\n"; return 1; } return 0; }
(** * 6.822 Formal Reasoning About Programs, Spring 2020 - Pset 12 *) (* Author: * Samuel Gruetter ([email protected]) *) (* SETUP: Starting in the spring20 folder, do these commands: git pull git submodule update cd ./frap make lib make -f Makefile.coq MessagesAndRefinement.vo cd ../pset12_MessagePassing/ make *) Require Import Frap.Frap. Require Import Frap.MessagesAndRefinement. (* We suggest that you start by reading Chapter 19 in the FRAP book. For this pset, you will need to understand everything in that chapter up to and including Theorem 19.2 ("If p1 <| p2, then every trace generated by p1 is also generated by p2"). Also study the code in MessagesAndRefinement.v, because this pset depends on that code. *) (* Delete this line if you don't like bullet points and errors like "Expected a single focused goal but 2 goals are focused." *) Set Default Goal Selector "!". Arguments Nat.modulo: simpl never. (* In this pset, we will define a small key-value store server. To simplify, it only accepts GET requests: *) Inductive request := | GET (client_id key : nat). Definition get_key (req : request) : nat := match req with | GET _ key => key end. (* There are two possible responses for a GET request: *) Inductive response := | FOUND (client_id key value : nat) | NOT_FOUND (client_id key : nat). (* Given a key-value store (modeled as an fmap), a source channel, and an output channel, here's how we handle one request: *) Definition request_handler (store : fmap nat nat) (source output : channel) : proc := ??source(req: request); match req with | GET client_id key => match store $? key with | Some v => !!output(FOUND client_id key v); Done | None => !!output(NOT_FOUND client_id key); Done end end. (* Key-value stores might become very large, so that they don't fit on one single server's disk. Therefore, we split the store into two shards: One for all even keys, and one for all odd keys. Here's a predicate asserting that a full_store is split correctly into an even_store and an odd_store: *) Definition split_store (full_store even_store odd_store : fmap nat nat) : Prop := (forall k, k mod 2 = 0 -> even_store $? k = full_store $? k) /\ (forall k, k mod 2 = 0 -> odd_store $? k = None) /\ (forall k, k mod 2 <> 0 -> even_store $? k = None) /\ (forall k, k mod 2 <> 0 -> odd_store $? k = full_store $? k). (* The goal of this pset is to define a distributed key-value-store system implementation that does not need to save the full store anywhere, and only needs full_store to specify its correctness. *) (* We use two intermediate channels forward_even and forward_odd, and add a request_dispatcher to forward requests to these channels: *) Definition request_dispatcher (input forward_even forward_odd : channel) : proc := ??input(req: request); if get_key req mod 2 ==n 0 then !!forward_even(req); Done else !!forward_odd(req); Done. (* Our balanced request handler creates two intermediate channels and then combines the request dispatcher with two request handlers, one for even keys and one for odd keys: *) Definition balanced_handler (even_store odd_store : fmap nat nat) (input output : channel) : proc := New[input; output](forward_even); New[input; output; forward_even](forward_odd); request_dispatcher input forward_even forward_odd || request_handler even_store forward_even output || request_handler odd_store forward_odd output. (* Here's the correctness property that we want to hold for our balanced_handler: Each I/O trace generated by balanced_handler should also be a trace generated by one single request_handler which uses the full_store. *) Definition correctness: Prop := forall full_store even_store odd_store input output, split_store full_store even_store odd_store -> input <> output -> forall trace, couldGenerate (balanced_handler even_store odd_store input output) trace -> couldGenerate (request_handler full_store input output) trace. (* We suggest that you start by testing your understanding by answering the following questions. They are graded as follows: If you complete all the Coq proofs, you will get full score, no matter what you write in the answers to these questions. On the other hand, if you can't finish the Coq proofs, you can get up to 40 points for answering these questions, plus points for partial Coq proofs. Question 1) For each of the following processes, briefly describe what they do: a) !!ch(v); k b) ??ch(x: T); k c) pr1 || pr2 d) Dup pr e) Done f) New[ch1; ch2; ch3](ch4); k g) Block ch; k Question 2) Is the "refines" relation symmetric? That is, if "pr1 <| pr2", does that imply "pr2 <| pr1"? Question 3) Which of "||" and ";" binds stronger? In other words, does "pr1 || pr2 ; pr3" equal "pr1 || (pr2 ; pr3)" or "(pr1 || pr2) ; pr3"? Hint: Here's how you could solve this question for nats and "+" vs "*": Goal forall (a b c: nat), a + b * c = 0. Proof. simplify. Set Printing All. prints "(Init.Nat.add a (Init.Nat.mul b c))", so it's clear that "*" binds stronger. Question 4) Draw a diagram of the balanced request handler and the channels it uses Question 5) In order to prove refinements, we need to provide a simulation relation R of type "proc -> proc -> Prop", and prove the three conditions defined by "simulates". If we just pick "fun pr1 pr2 => True" for R, which of these three conditions can/cannot be proven? And what if we pick "fun pr1 pr2 => False"? Question 6) The specification (addN 2 input output) in MessagesAndRefinement.v performs the following steps: 1) It starts as (??input(n : nat); !!output(n + 2); Done) where it reads an input n 2) and then becomes (!!output(n + 2); Done) where it outputs (n + 2) 3) and then becomes Done Write down the same kind of explanation of steps for the implementation (add2_once input output): You should get steps numbered from 1) to 5). Question 7) In order to prove that the specification (addN 2 input output) can simulate the implementation (add2_once input output), we have to show that each implementation state has a corresponding specification state. Do so by filling out the following table: Impl | Spec state | state ------+------ 1 | 2 | 3 | 4 | 5 | Question 8) If you completed the above table, you've actually just created a paper proof of add2_once_refines_addN. Now study the Coq proof add2_once_refines_addN, and look at the three subgoals opened after the call to first_order. Where do they come from, and what does each of them ask you to prove? *) (* Now you should be ready to start proving correctness! NOTE: You MUST use refinement ("_ <| _") and "simulates" to earn full credit on this pset. Hint: You should follow the same approach as add2_once_refines_addN and define a relation similar to R_add2, with the following signature, where we use "fs", "es", and "os" as abbreviations for full_store, even_store, and odd_store: *) Inductive R (fs es os : fmap nat nat) (input output : channel) : proc -> proc -> Prop := (* FILL IN HERE *) . (* One more hint: You can use the "lists" tactic to prove any "NoDup" goals/contradictions. *) (* And another hint: Here's some tactic which you might find handy in your proofs. Feel free to use and/or adapt it! *) Ltac head e := match e with | ?e _ => head e | _ => e end. Ltac head_constructor e := let e := eval cbv beta delta in e in (* this is quite agressive... *) let h := head e in is_constructor h. Ltac t_step := match goal with | |- _ => solve [propositional] | H : ?a = ?b |- _ => head_constructor a; head_constructor b; progress invert H (* the previous case can loop because repeat invert can loop, propositional earlier prunes the cases where this occurs in our proof *) | H : R _ _ _ _ _ _ _ |- _ => invert H | H:lstep ?c _ _ |- _ => head_constructor c; (apply invert_Recv in H; try subst) || invert H | H:lstepSilent ?c _ |- _ => head_constructor c; invert H | r : request |- _ => cases r | H : True |- _ => clear H | _ => progress (cbn [notUse Channel get_key] in *; simplify) | |- _ /\ _ => split | _ => solve [equality] end. Ltac t := repeat t_step. Theorem balanced_handler_correct : correctness. Proof. Admitted. (* OPTIONAL exercise (ungraded, very short): Another important property of refinment is that any subpart of a larger program can be replaced with a refined version of it, yielding a refined version of the larger program. You can try it out by wrapping our one-shot server in Dup and using the "impl <| spec" fact you proved as a part of the last theorem to show "Dup impl <| Dup spec". This should be trivial once you have found the appropariate lemma from frap and factored out the appropriate refinement claim from the last proof. *) Lemma multicorrectness : forall full_store even_store odd_store input output, split_store full_store even_store odd_store -> input <> output -> forall trace, couldGenerate (Dup (balanced_handler even_store odd_store input output)) trace -> couldGenerate (Dup (request_handler full_store input output)) trace. Proof. Admitted.
%% contour2logic % Below is a demonstration of the features of the |contour2logic| function %% clear; close all; clc; %% Syntax % |[varargout]=contour2logic(M,v,Vcs);| %% Description % This function converts contours to a logic or labelled data. The logics % represent wether voxels are in, on, or outside the contour. % % The input consists of: %% % % * A 3D image |M| (or alternatively the size of M). % * The |vozelSize| a 1x3 vector specifying the size of the voxels in the % row, column, and slice direction. % * A cell array |Vcs| containing one or more contours per slice. If the % image has n slices then Vcs should be an nx1 cell array, i.e. contours % are defined for each slice. %% Examples % %% Import image data for this demo defaultFolder = fileparts(fileparts(mfilename('fullpath'))); %Set main folder pathNameImageData=fullfile(defaultFolder,'data','DICOM','0001_human_calf'); loadNameImageData=fullfile(pathNameImageData,'IMDAT','IMDAT.mat'); IMDAT_struct=load(loadNameImageData); %The image data structure G = IMDAT_struct.G; %Geometric/spatial information v=G.v; %The voxel size M= IMDAT_struct.type_1; %The image data %% contourName='imseg_calf_tibia'; pathName=fullfile(defaultFolder,'data','imseg'); %Folder name for contours %% Compute levelset loadName=fullfile(pathName,contourName); load(loadName); %Load segmentation structure Vcs=saveStruct.ContourSet; %Access the contour data [logicIn,logicOn,N]=contour2logic(M,v,Vcs); %% % Visualize logic image and contours together %Visualize logic image sv3(logicIn,v); %Open slice viewer for levelset %Visualize contours optionStruct.Color='r'; plotContours({Vcs},optionStruct); %Plot contours %Add colorbar labels [~,hc]=icolorbar; hc.TickLabels={'Out','In'}; drawnow; %% % Visualize labelled image and contours together %Visualize label image vizStruct.colormap=viridis(3); %Set colormap for levelset visualization hf2=sv3(N,v,vizStruct); %Open slice viewer for levelset %Visualize contours optionStruct.Color='r'; plotContours({Vcs},optionStruct); %Plot contours %Add colorbar labels [~,hc]=icolorbar; hc.TickLabels={'Out','On','In'}; drawnow; %% % % <<gibbVerySmall.gif>> % % _*GIBBON*_ % <www.gibboncode.org> % % _Kevin Mattheus Moerman_, <[email protected]> %% % _*GIBBON footer text*_ % % License: <https://github.com/gibbonCode/GIBBON/blob/master/LICENSE> % % GIBBON: The Geometry and Image-based Bioengineering add-On. A toolbox for % image segmentation, image-based modeling, meshing, and finite element % analysis. % % Copyright (C) 2006-2022 Kevin Mattheus Moerman and the GIBBON contributors % % This program is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by % the Free Software Foundation, either version 3 of the License, or % (at your option) any later version. % % This program is distributed in the hope that it will be useful, % but WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % GNU General Public License for more details. % % You should have received a copy of the GNU General Public License % along with this program. If not, see <http://www.gnu.org/licenses/>.
(* Title: HOL/Auth/n_g2kAbsAfter_lemma_on_inv__48.thy Author: Yongjian Li and Kaiqiang Duan, State Key Lab of Computer Science, Institute of Software, Chinese Academy of Sciences Copyright 2016 State Key Lab of Computer Science, Institute of Software, Chinese Academy of Sciences *) header{*The n_g2kAbsAfter Protocol Case Study*} theory n_g2kAbsAfter_lemma_on_inv__48 imports n_g2kAbsAfter_base begin section{*All lemmas on causal relation between inv__48 and some rule r*} lemma n_n_RecvReq_i1Vsinv__48: assumes a1: "(r=n_n_RecvReq_i1 )" and a2: "(f=inv__48 )" shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s") proof - have "?P3 s" apply (cut_tac a1 a2 , simp, rule_tac x="(neg (andForm (andForm (andForm (andForm (eqn (IVar (Ident ''ExGntd'')) (Const true)) (neg (eqn (IVar (Field (Ident ''ACache_1'') ''State'')) (Const E)))) (eqn (IVar (Field (Ident ''AChan2_1'') ''Cmd'')) (Const Empty))) (eqn (IVar (Ident ''AShrSet_1'')) (Const true))) (eqn (IVar (Ident ''CurCmd'')) (Const Empty))))" in exI, auto) done then show "invHoldForRule s f r (invariants N)" by auto qed lemma n_n_RecvInvAck_i1Vsinv__48: assumes a1: "(r=n_n_RecvInvAck_i1 )" and a2: "(f=inv__48 )" shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s") proof - have "((formEval (eqn (IVar (Ident ''ExGntd'')) (Const true)) s))\<or>((formEval (neg (eqn (IVar (Ident ''ExGntd'')) (Const true))) s))" by auto moreover { assume c1: "((formEval (eqn (IVar (Ident ''ExGntd'')) (Const true)) s))" have "?P1 s" proof(cut_tac a1 a2 c1, auto) qed then have "invHoldForRule s f r (invariants N)" by auto } moreover { assume c1: "((formEval (neg (eqn (IVar (Ident ''ExGntd'')) (Const true))) s))" have "?P2 s" proof(cut_tac a1 a2 c1, auto) qed then have "invHoldForRule s f r (invariants N)" by auto } ultimately show "invHoldForRule s f r (invariants N)" by satx qed lemma n_n_SendGntE_i1Vsinv__48: assumes a1: "(r=n_n_SendGntE_i1 )" and a2: "(f=inv__48 )" shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s") proof - have "?P3 s" apply (cut_tac a1 a2 , simp, rule_tac x="(neg (andForm (eqn (IVar (Ident ''AShrSet_1'')) (Const false)) (eqn (IVar (Ident ''AInvSet_1'')) (Const true))))" in exI, auto) done then show "invHoldForRule s f r (invariants N)" by auto qed lemma n_n_ARecvReq_i1Vsinv__48: assumes a1: "(r=n_n_ARecvReq_i1 )" and a2: "(f=inv__48 )" shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s") proof - have "?P3 s" apply (cut_tac a1 a2 , simp, rule_tac x="(neg (andForm (andForm (andForm (andForm (eqn (IVar (Ident ''ExGntd'')) (Const true)) (neg (eqn (IVar (Field (Ident ''ACache_1'') ''State'')) (Const E)))) (eqn (IVar (Field (Ident ''AChan2_1'') ''Cmd'')) (Const Empty))) (eqn (IVar (Ident ''AShrSet_1'')) (Const true))) (eqn (IVar (Ident ''CurCmd'')) (Const Empty))))" in exI, auto) done then show "invHoldForRule s f r (invariants N)" by auto qed lemma n_n_ASendInvE_i1Vsinv__48: assumes a1: "(r=n_n_ASendInvE_i1 )" and a2: "(f=inv__48 )" shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s") proof - have "?P1 s" proof(cut_tac a1 a2 , auto) qed then show "invHoldForRule s f r (invariants N)" by auto qed lemma n_n_ASendInvS_i1Vsinv__48: assumes a1: "(r=n_n_ASendInvS_i1 )" and a2: "(f=inv__48 )" shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s") proof - have "?P1 s" proof(cut_tac a1 a2 , auto) qed then show "invHoldForRule s f r (invariants N)" by auto qed lemma n_n_ASendInvAck_i1Vsinv__48: assumes a1: "(r=n_n_ASendInvAck_i1 )" and a2: "(f=inv__48 )" shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s") proof - have "?P3 s" apply (cut_tac a1 a2 , simp, rule_tac x="(neg (andForm (eqn (IVar (Ident ''AInvSet_1'')) (Const true)) (eqn (IVar (Field (Ident ''AChan2_1'') ''Cmd'')) (Const Inv))))" in exI, auto) done then show "invHoldForRule s f r (invariants N)" by auto qed lemma n_n_ARecvInvAck_i1Vsinv__48: assumes a1: "(r=n_n_ARecvInvAck_i1 )" and a2: "(f=inv__48 )" shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s") proof - have "((formEval (eqn (IVar (Ident ''ExGntd'')) (Const true)) s))\<or>((formEval (neg (eqn (IVar (Ident ''ExGntd'')) (Const true))) s))" by auto moreover { assume c1: "((formEval (eqn (IVar (Ident ''ExGntd'')) (Const true)) s))" have "?P1 s" proof(cut_tac a1 a2 c1, auto) qed then have "invHoldForRule s f r (invariants N)" by auto } moreover { assume c1: "((formEval (neg (eqn (IVar (Ident ''ExGntd'')) (Const true))) s))" have "?P2 s" proof(cut_tac a1 a2 c1, auto) qed then have "invHoldForRule s f r (invariants N)" by auto } ultimately show "invHoldForRule s f r (invariants N)" by satx qed lemma n_n_ASendGntS_i1Vsinv__48: assumes a1: "(r=n_n_ASendGntS_i1 )" and a2: "(f=inv__48 )" shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s") proof - have "?P1 s" proof(cut_tac a1 a2 , auto) qed then show "invHoldForRule s f r (invariants N)" by auto qed lemma n_n_ASendGntE_i1Vsinv__48: assumes a1: "(r=n_n_ASendGntE_i1 )" and a2: "(f=inv__48 )" shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s") proof - have "?P1 s" proof(cut_tac a1 a2 , auto) qed then show "invHoldForRule s f r (invariants N)" by auto qed lemma n_n_ARecvGntS_i1Vsinv__48: assumes a1: "(r=n_n_ARecvGntS_i1 )" and a2: "(f=inv__48 )" shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s") proof - have "?P3 s" apply (cut_tac a1 a2 , simp, rule_tac x="(neg (andForm (eqn (IVar (Ident ''ExGntd'')) (Const true)) (eqn (IVar (Field (Ident ''AChan2_1'') ''Cmd'')) (Const GntS))))" in exI, auto) done then show "invHoldForRule s f r (invariants N)" by auto qed lemma n_n_ARecvGntE_i1Vsinv__48: assumes a1: "(r=n_n_ARecvGntE_i1 )" and a2: "(f=inv__48 )" shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s") proof - have "?P1 s" proof(cut_tac a1 a2 , auto) qed then show "invHoldForRule s f r (invariants N)" by auto qed lemma n_n_SendInvS_i1Vsinv__48: assumes a1: "r=n_n_SendInvS_i1 " and a2: "(f=inv__48 )" shows "invHoldForRule s f r (invariants N)" apply (rule noEffectOnRule, cut_tac a1 a2, auto) done lemma n_n_SendReqEI_i1Vsinv__48: assumes a1: "r=n_n_SendReqEI_i1 " and a2: "(f=inv__48 )" shows "invHoldForRule s f r (invariants N)" apply (rule noEffectOnRule, cut_tac a1 a2, auto) done lemma n_n_ASendReqEI_i1Vsinv__48: assumes a1: "r=n_n_ASendReqEI_i1 " and a2: "(f=inv__48 )" shows "invHoldForRule s f r (invariants N)" apply (rule noEffectOnRule, cut_tac a1 a2, auto) done lemma n_n_ASendReqIS_j1Vsinv__48: assumes a1: "r=n_n_ASendReqIS_j1 " and a2: "(f=inv__48 )" shows "invHoldForRule s f r (invariants N)" apply (rule noEffectOnRule, cut_tac a1 a2, auto) done lemma n_n_ASendReqES_i1Vsinv__48: assumes a1: "r=n_n_ASendReqES_i1 " and a2: "(f=inv__48 )" shows "invHoldForRule s f r (invariants N)" apply (rule noEffectOnRule, cut_tac a1 a2, auto) done lemma n_n_SendGntS_i1Vsinv__48: assumes a1: "r=n_n_SendGntS_i1 " and a2: "(f=inv__48 )" shows "invHoldForRule s f r (invariants N)" apply (rule noEffectOnRule, cut_tac a1 a2, auto) done lemma n_n_SendReqES_i1Vsinv__48: assumes a1: "r=n_n_SendReqES_i1 " and a2: "(f=inv__48 )" shows "invHoldForRule s f r (invariants N)" apply (rule noEffectOnRule, cut_tac a1 a2, auto) done lemma n_n_SendInvE_i1Vsinv__48: assumes a1: "r=n_n_SendInvE_i1 " and a2: "(f=inv__48 )" shows "invHoldForRule s f r (invariants N)" apply (rule noEffectOnRule, cut_tac a1 a2, auto) done lemma n_n_ASendReqSE_j1Vsinv__48: assumes a1: "r=n_n_ASendReqSE_j1 " and a2: "(f=inv__48 )" shows "invHoldForRule s f r (invariants N)" apply (rule noEffectOnRule, cut_tac a1 a2, auto) done lemma n_n_RecvGntS_i1Vsinv__48: assumes a1: "r=n_n_RecvGntS_i1 " and a2: "(f=inv__48 )" shows "invHoldForRule s f r (invariants N)" apply (rule noEffectOnRule, cut_tac a1 a2, auto) done lemma n_n_SendReqEE_i1Vsinv__48: assumes a1: "r=n_n_SendReqEE_i1 " and a2: "(f=inv__48 )" shows "invHoldForRule s f r (invariants N)" apply (rule noEffectOnRule, cut_tac a1 a2, auto) done lemma n_n_RecvGntE_i1Vsinv__48: assumes a1: "r=n_n_RecvGntE_i1 " and a2: "(f=inv__48 )" shows "invHoldForRule s f r (invariants N)" apply (rule noEffectOnRule, cut_tac a1 a2, auto) done lemma n_n_Store_i1Vsinv__48: assumes a1: "\<exists> d. d\<le>N\<and>r=n_n_Store_i1 d" and a2: "(f=inv__48 )" shows "invHoldForRule s f r (invariants N)" apply (rule noEffectOnRule, cut_tac a1 a2, auto) done lemma n_n_AStore_i1Vsinv__48: assumes a1: "\<exists> d. d\<le>N\<and>r=n_n_AStore_i1 d" and a2: "(f=inv__48 )" shows "invHoldForRule s f r (invariants N)" apply (rule noEffectOnRule, cut_tac a1 a2, auto) done lemma n_n_SendReqS_j1Vsinv__48: assumes a1: "r=n_n_SendReqS_j1 " and a2: "(f=inv__48 )" shows "invHoldForRule s f r (invariants N)" apply (rule noEffectOnRule, cut_tac a1 a2, auto) done lemma n_n_SendInvAck_i1Vsinv__48: assumes a1: "r=n_n_SendInvAck_i1 " and a2: "(f=inv__48 )" shows "invHoldForRule s f r (invariants N)" apply (rule noEffectOnRule, cut_tac a1 a2, auto) done end
cc ------------ dpmjet3.4 - authors: S.Roesler, R.Engel, J.Ranft ------- cc -------- phojet1.12-40 - authors: S.Roesler, R.Engel, J.Ranft ------- cc - oct'13 ------- cc ----------- pythia-6.4 - authors: Torbjorn Sjostrand, Lund'10 ------- cc --------------------------------------------------------------------- cc converted for use with FLUKA ------- cc - oct'13 ------- C...PYALPS C...Gives the value of alpha_strong. DOUBLE PRECISION FUNCTION PYALPS(Q2) C...Double precision and integer declarations. IMPLICIT DOUBLE PRECISION(A-H, O-Z) IMPLICIT INTEGER(I-N) C...Commonblocks. include 'inc/pydat1' include 'inc/pydat2' C...Coefficients for second-order threshold matching. C...From W.J. Marciano, Phys. Rev. D29 (1984) 580. DIMENSION STEPDN(6),STEPUP(6) c DATA STEPDN/0D0,0D0,(2D0*107D0/2025D0),(2D0*963D0/14375D0), c &(2D0*321D0/3703D0),0D0/ c DATA STEPUP/0D0,0D0,0D0,(-2D0*107D0/1875D0), c &(-2D0*963D0/13225D0),(-2D0*321D0/3381D0)/ DATA STEPDN/0D0,0D0,0.10568D0,0.13398D0,0.17337D0,0D0/ DATA STEPUP/0D0,0D0,0D0,-0.11413D0,-0.14563D0,-0.18988D0/ C...Constant alpha_strong trivial. Pick artificial Lambda. IF(MSTU(111).LE.0) THEN PYALPS=PARU(111) MSTU(118)=MSTU(112) PARU(117)=0.2D0 IF(Q2.GT.0.04D0) PARU(117)=SQRT(Q2)*EXP(-6D0*PARU(1)/ & ((33D0-2D0*MSTU(112))*PARU(111))) PARU(118)=PARU(111) RETURN ENDIF C...Find effective Q2, number of flavours and Lambda. Q2EFF=Q2 IF(MSTU(115).GE.2) Q2EFF=MAX(Q2,PARU(114)) NF=MSTU(112) ALAM2=PARU(112)**2 100 IF(NF.GT.MAX(3,MSTU(113))) THEN Q2THR=PARU(113)*PMAS(NF,1)**2 IF(Q2EFF.LT.Q2THR) THEN NF=NF-1 Q2RAT=Q2THR/ALAM2 ALAM2=ALAM2*Q2RAT**(2D0/(33D0-2D0*NF)) IF(MSTU(111).EQ.2) ALAM2=ALAM2*LOG(Q2RAT)**STEPDN(NF) GOTO 100 ENDIF ENDIF 110 IF(NF.LT.MIN(6,MSTU(114))) THEN Q2THR=PARU(113)*PMAS(NF+1,1)**2 IF(Q2EFF.GT.Q2THR) THEN NF=NF+1 Q2RAT=Q2THR/ALAM2 ALAM2=ALAM2*Q2RAT**(-2D0/(33D0-2D0*NF)) IF(MSTU(111).EQ.2) ALAM2=ALAM2*LOG(Q2RAT)**STEPUP(NF) GOTO 110 ENDIF ENDIF IF(MSTU(115).EQ.1) Q2EFF=Q2EFF+ALAM2 PARU(117)=SQRT(ALAM2) C...Evaluate first or second order alpha_strong. B0=(33D0-2D0*NF)/6D0 ALGQ=LOG(MAX(1.0001D0,Q2EFF/ALAM2)) IF(MSTU(111).EQ.1) THEN PYALPS=MIN(PARU(115),PARU(2)/(B0*ALGQ)) ELSE B1=(153D0-19D0*NF)/6D0 PYALPS=MIN(PARU(115),PARU(2)/(B0*ALGQ)*(1D0-B1*LOG(ALGQ)/ & (B0**2*ALGQ))) ENDIF MSTU(118)=NF PARU(118)=PYALPS RETURN END
#include <gsl/gsl_odeiv2.h> #include "func.h" #include "make_grid.h" int make_grid (struct param params, double r, double r1, double y[]) { int status; int *fake_jac; /* The integrator RK8PD (Runge-Kutta Prince-Dormand) doesn't need the * jacobian (some more sophisticated integrators do) so make this a * null pointer. The linker will complain that the pointer type is * incompatable since it doesn't point to a function with a bunch of * arguments, but the pointer won't be used anyway so it doesn't * matter. */ fake_jac = 0; gsl_odeiv2_system sys = { func, fake_jac, 2, &params }; gsl_odeiv2_driver *d = gsl_odeiv2_driver_alloc_y_new (&sys, gsl_odeiv2_step_rk8pd, 1.0e+0, 1.0e-8, 1.0e-8); status = gsl_odeiv2_driver_apply (d, &r, r1, y); gsl_odeiv2_driver_free (d); return 0; }
% ********************************************************************** % Author: Ajahn Chah % Translator: % Title: Knowing the World % First published: Everything is Teaching Us % Comment: % Copyright: Permission granted by Wat Pah Nanachat to reprint for free distribution % ********************************************************************** % Notes on the text: % A large section of this Dhamma talk has previously been published under the title `Seeking the Source' % ********************************************************************** \chapterFootnote{\textit{Note}: This talk has been published elsewhere under the title: `\textit{Seeking the Source}'} \chapter{Knowing the World} \index[general]{world!knowing the} \index[general]{mind objects} \index[general]{mindfulness} \dropcaps{A}{ll things just as they are} display the truth. But we have biases and preferences about how we want them to be. \pali{\glsdisp{lokavidu}{Lokavid\=u}} means knowing the world clearly. The world is these phenomena (\pali{\glsdisp{sabhava}{sabh\=ava}}) abiding as they are. To sum it up simply, the world is \textit{arom}.\footnote{\textit{Arom}: (\textit{Thai}) All states (or objects) of mind, whether happy or unhappy, internal or external.} That's an easy way to put it. The world is \textit{arom}. If we say `world', that's pretty vast. `\textit{Arom} are the world' is a lot simpler. The world is \textit{arom}. Being deluded by the world is being deluded by \textit{arom}; being deluded by \textit{arom} is being deluded by the world. \pali{Lokavid\=u}, knowing the world clearly: however the world is, that's what we should know. It exists according to its conditions. So we should have full, present awareness of it. \index[general]{formations} Similarly, we should know \pali{\glsdisp{sankhara}{sa\.nkh\=ara}} for what they are; develop wisdom that knows \pali{sa\.nkh\=ar\=a}. Whatever the truth of \pali{sa\.nkh\=ar\=a} is, however they really are, that's the truth we should know. That's called wisdom that accepts and knows without obstacles. We need to develop a mind that has tranquillity together with wisdom in control of things. We talk about \glsdisp{sila}{s\={\i}la,} \glsdisp{samadhi}{sam\=adhi,} \glsdisp{panna}{pa\~n\~n\=a,} and about \glsdisp{samatha}{samatha} meditation and \glsdisp{vipassana}{vipassan\=a} meditation. But they are really all the same matter. They are the same, but we divide them into different categories and get confused. I've often made a simple analogy about it -- there are things to compare it to -- which can make it easier to contemplate and understand. \index[similes]{a growing mango!aspects of practice} A little mango later becomes a large, ripe mango. Is the little mango the same piece of fruit as the large one? From the time it's just a bud flowering on the tree, it's the same one mango. As it grows into a small mango and then gets bigger and bigger, almost ripe, then finally ripe, it's only undergoing change. \index[general]{morality!effects of} \index[similes]{still water!concentration} The aspects of practice we talk about are the same. S\={\i}la simply means giving up wrongdoing. A person without \textit{s\={\i}la} is in a hot condition. Giving up wrongdoing and evil ways, brings coolness, preventing harm or ill effects. The blessing that comes from this freedom from harmful effects is a tranquil mind -- that is sam\=adhi. When the mind is in sam\=adhi, clean and pure, it will see many things. It's like water that is still and undisturbed. You can see your face in it. You can see things further away reflected as well. You can see the roof of the building over there. If a bird alights on the roof you can see it. These factors are really all one, just like the one mango. The tiny fruit is that same one mango. The growing fruit is the same mango. The ripe fruit is the same mango. From green to yellow, it's the same mango; it's undergoing change, and that's why we see difference. \index[general]{practice!vs. study} \index[general]{M\=ara} Having this kind of simple understanding can put us at ease. Doubts will diminish. If instead we are relying on texts and seeking detailed explanations, we are likely to end up in confusion. So we have to watch our own minds. `\glsdisp{bhikkhu}{Bhikkhus!} You should be watching over your minds. Those who watch over their minds shall escape the snares of \glsdisp{mara}{M\=ara.'} Both M\=ara and his snares. And it depends on our own investigation. \index[general]{questions!restraint in asking} My way of practice was a little strange. After I ordained and started to practise, I had a lot of doubts and questions. But I didn't like to ask anyone about them very much. Even when I met Ajahn Mun, I didn't ask him many questions. I wanted to ask, but I didn't. I sat and listened to his teaching. I had questions, but I didn't ask. Asking someone else is like borrowing someone else's knife to cut something. We never come to have our own knife. That's the way I felt. So I didn't ask many questions of others. If I stayed with a teacher for a year or two, I'd listen to his discourses and try to work things out for myself. I would seek my own answers. I was different from other disciples, but I was able to develop wisdom; this way made me resourceful and clever. I didn't become heedless, rather I contemplated things until I could see for myself, increasing my understanding and removing my doubts. \index[general]{doubt!contemplate} My advice is to not let yourself get wrapped up in doubts and questions. Let them go and directly contemplate whatever you are experiencing. Don't make a big deal out of any physical pleasure or pain you experience. When you sit in meditation and start to feel tired or uncomfortable, adjust your position. Endure as much as you can, and then move. Don't overdo it. Develop a lot of mindfulness -- that's the point. Do your walking and sitting meditation as much as you can; the aim is to be developing mindfulness as much as you can, knowing things fully. That's enough. \index[general]{sense contact} Please take my words to contemplate. Whatever form of practice you're doing, when objects of mind arise, whether internally or externally, those are called \textit{arom}. The one who is aware of the \textit{arom} is called \ldots{} well, whatever you want to call it is OK; you can call it `mind'. The \textit{arom} is one thing, and the \glsdisp{one-who-knows}{one who knows} the \textit{arom} is another. It's like the eye and the objects it sees. The eye isn't the objects, and the objects aren't the eye. The ear hears sounds, but the ear isn't the sound and the sound isn't the ear. When there is contact between the two, then things happen. All states of mind, happy or unhappy, are called \textit{arom}. Whatever they may be, never mind -- we should constantly be reminding ourselves that `this is uncertain'. \index[general]{uncertainty} People don't consider very much, that `this is uncertain'. Just this is the vital factor that will bring about wisdom. It's really important. In order to cease our coming and going and come to rest, we only need to say, `this is uncertain.' Sometimes we may be distraught over something to the point that tears are flowing; this is something not certain. When moods of desire or aversion come to us, we should just remind ourselves of this one thing. Whether standing, walking, sitting, or lying down, whatever appears is uncertain. Can't you do this? Keep it up no matter what happens. Give it a try. You don't need a lot -- just this will work. This is something that brings wisdom. The way I practise meditation is not very complicated -- just this. This is what it all comes down to: `it's uncertain.' Everything meets at this point. Don't keep track of the various instances of mental experience. When you sit, there may be various conditions of mind appearing, seeing and knowing all manner of things, experiencing different states. Don't be keeping track of them\footnote{literally `count'} and don't get wrapped up in them. You only need to remind yourself that they're uncertain. That's enough. That's easy to do. It's simple. Then you can stop. Knowledge will come, but then don't make too much out of that or get attached to it. \index[general]{investigation!not thinking} Real investigation, investigation in the correct way, doesn't involve thinking. As soon as something contacts the eye, ear, nose, tongue, or body, it immediately takes place of its own. You don't have to pick up anything to look at -- things just present themselves and investigation happens of its own. We talk about \pali{\glsdisp{vitakka}{vitakka,}} `initial thought'. It means raising something up. \pali{\glsdisp{vicara}{Vic\=ara}} is `discursive thought'. It's investigation, seeing the planes of existence (\pali{bh\=umi}) that appear. \index[general]{impermanence!and the way of the Buddha} In the final analysis, the way of the Buddha flourishes through impermanence. It is always timely and relevant, whether in the time of the Buddha, in other times past, in the present age, or in the future. At all times, it is impermanence that rules. This is something you should meditate on. The true and correct words of the sages will not lack mention of impermanence. This is the truth. If there is no mention of impermanence, it is not the speech of the wise. It is not the speech of the Buddha or the \glsdisp{ariya}{ariyas;} it's called speech that does not accept the truth of existence. \index[general]{intoxication!mind} \index[general]{releasing phenomena} \looseness=1 All things have need of a way of release. Contemplation is not a matter of holding on and sticking to things. It's a matter of releasing. A mind that can't release phenomena is in a state of intoxication. In practice, it's important not to be intoxicated. When practice really seems to be good, don't be intoxicated by that good. If you're intoxicated by it, it becomes something harmful, and your practice is no longer correct. We do our best, but it's important not to become drunk on our efforts, otherwise we are out of harmony with Dhamma. This is the Buddha's advice. Even the good is not something to get intoxicated by. Be aware of this when it happens. \index[general]{will-power!in practice} A dam needs a sluiceway so that the water can run off. It's the same for us in practice. Using willpower to push ourselves and control the mind is something we can do at times, but don't get drunk on it. We want to be teaching the mind, not merely controlling it, so that it becomes aware. Too much forcing will make you crazy. What's vital is to keep on increasing awareness and sensitivity. Our path is like this. There are many points for comparison. We could talk about construction work and bring it back to the way of training the mind. \index[general]{practice!vs. study} \index[general]{Truth} There is a lot of benefit to be had from practising meditation, from watching over your mind. This is the first and foremost thing. The teachings you can study in the scriptures and commentaries are true and valuable, but they are secondary. They are people's explanations of the truth. But there is actual truth that surpasses the words. Sometimes the expositions that are derived seem uneven or are not so accessible, and with the passing of time they can become confusing. But the actual truth they are based on remains the same and isn't affected by what anyone says or does. It is the original, natural state of things that does not change or deteriorate. The explanations people compose are secondary or tertiary, one or two steps removed, and though they can be good and beneficial and flourish for some time, they are subject to deterioration.\footnote{Because they are still in the realm of concepts.} \index[general]{Truth} It's like the way that as population keeps increasing, troubles increase along with it. That's quite natural. The more people there are, the more issues there will be to deal with. Then leaders and teachers will try to show us the right way to live, to do good and solve problems. That can be valid and necessary, but it's still not the same as the reality those good ideas are based on. The true Dhamma that is the essence of all good has no way to decline or deteriorate, because it is immutable. It is the source, the \pali{\glsdisp{sacca-dhamma}{saccadhamma,}} existing as it is. All the followers of the Buddha's way who practise the Dhamma must strive to realize this. Then they may find different means to illustrate it. Over time, the explanations lose their potency, but the source remains the same. \index[general]{attachment!views and knowledge} \index[general]{knowledge!attachment to} So the Buddha taught to focus your attention and investigate. Practitioners in search of the truth, do not be attached to your views and knowledge. Don't be attached to the knowledge of others. Don't be attached to anyone's knowledge. Rather, develop special knowledge; allow the \pali{saccadhamma} to be revealed in full measure. In training the mind, investigating the \pali{saccadhamma}, our own minds are where it can be seen. When there is doubt about anything, we should pay attention to our thoughts and feelings, our mental processes. This is what we should know. The rest is all superficial. \index[general]{fear!settling} \index[general]{nimittas} In practising Dhamma, we will meet with many sorts of experiences, such as fear. What will we rely on then? When the mind is wrapped up in fear, it can't find anything to rely on. This is something I've gone through; the deluded mind stuck in fear, unable to find a safe place anywhere. So where can this be settled? It gets settled right at that place where it appears. Wherever it arises, that is where it ceases. Wherever the mind has fear, it can end fear right there. Putting it simply: when the mind is completely full of fear, it has nowhere else to go, and it can stop right there. The place of no fear is there in the place of fear. Whatever states the mind undergoes, if it experiences \pali{\glsdisp{nimitta}{nimitta,}} visions, or knowledge in meditation, for example, it doesn't matter -- we are taught to focus awareness on this mind in the present. That is the standard. Don't chase after external phenomena. All the things we contemplate come to conclusion at the source, the place where they arise. This is where the causes are. This is important. Feeling fear is a good example, since it's easy to see; if we let ourselves experience it until it has nowhere to go, then we will have no more fear, because it will be exhausted. It loses its power, so we don't feel fear anymore. Not feeling fear means it has become empty. We accept whatever comes our way, and it loses its power over us. This is what the Buddha wanted us to place our trust in; he wanted us not to be attached to our own views, not to be attached to others' views. This is really important. We are aiming at the knowledge that comes from realization of the truth, so we don't want to get stuck in attachment to our own or others' views and opinions. But when we have our ideas or interact with others, watching them contact the mind can be illuminating. Knowledge can be born in those things that we have and experience. \index[general]{mind!analysing} \index[general]{investigation!wrong vs. right} \index[general]{khandhas!correct attitude towards} In watching the mind and cultivating meditation, there can be many points of wrong understanding or deviation. Some people focus on conditions of mind and want to analyse them excessively, so their minds are always active. Or maybe we examine the five \pali{\glsdisp{khandha}{khandh\=a,}} or we go into further detail with the \glsdisp{thirty-two-parts}{thirty-two parts of the body;} there are many such classifications that are taught for contemplation. So we ponder and we analyse. Looking at the five \pali{khandh\=a} doesn't seem to get us to any conclusion, so we might go into the thirty-two parts, always analysing and investigating. But the way I see it, our attitude towards these five \pali{khandh\=a}, these heaps that we see right here, should be one of weariness and disenchantment, because they don't follow our wishes. I think that's probably enough. If they survive, we shouldn't be overly joyful to the point of forgetting ourselves. If they break up, we shouldn't be overly dejected by that. Recognizing this much should be enough. We don't have to tear apart the skin, the flesh, and the bones. This is something I've often talked about. Some people have to analyse like that, even if they are looking at a tree. Students in particular want to know what merit and demerit are, what form they have, what they look like. I explain to them that these things have no form. Merit is in our having correct understanding, correct attitude. But they want to know everything so clearly in such great detail. So I've used the example of a tree. The students will look at a tree, and they want to know all about the parts of the tree. Well, a tree has roots, it has leaves. It lives because of the roots. The students have to know, how many roots does it have? Major roots, minor roots, branches, leaves, they want to know all the details and numbers. Then they will feel they have clear knowledge about the tree. But the Buddha said that a person who wants such knowledge is actually pretty stupid. These things aren't necessary to know. Just knowing that there are roots and leaves is sufficient. Do you want to count all the leaves on a tree? If you look at one leaf, you should be able to get the picture. \index[general]{s\=ama\~n\~nalakkha\d{n}a} It's the same with people. If we know ourselves, then we understand all people in the universe without having to go and observe them. The Buddha wanted us to look at ourselves. As we are, so are others. We are all \pali{\glsdisp{samannalakkhana}{s\=ama\~n\~na\-lakkha\d{n}a,}} all being of the same characteristics. All \pali{sa\.nkh\=ar\=a} are like this. \index[general]{insight!samatha and vipassan\=a} So we practise sam\=adhi to be able to give up the defilements, to give birth to knowledge and vision and let go of the five \pali{khandh\=a}. Sometimes people talk about samatha. Sometimes they talk about vipassan\=a. I feel this can become confusing. Those who practise sam\=adhi will praise sam\=adhi. But, it is just for making the mind tranquil so it can know those things we have been talking about. \index[general]{meditation!methods of} Then there are those who will say, `I don't need to practise sam\=adhi so much. This plate will break one day in the future. Isn't that good enough? That will work, won't it? I'm not very skilled in sam\=adhi, but I already know that the plate must break someday. Yes, I take good care of it, because I'm afraid it will break, but I know that such is its future, and when it does break, I won't be suffering over that. Isn't my view correct? I don't need to practise a lot of sam\=adhi, because I already have this understanding. You practise sam\=adhi only for developing this understanding. After training your mind through sitting, you came to this view. I don't sit much, but I am already confident that this is the way of phenomena.' \index[general]{mind!under our command} This is a question for us practitioners. There are many factions of teachers promoting their different methods of meditation. It can get confusing. But the real point of it all is to be able to recognize the truth, seeing things as they really are and being free of doubt. As I see it, once we have correct knowledge, the mind comes under our command. What is this command about? The command is in \pali{anicca}, knowing that everything is impermanent. Everything stops here when we see clearly, and it becomes the cause for us to let go. Then we let things be, according to their nature. If nothing is occurring, we abide in equanimity, and if something comes up, we contemplate: does it cause us to have suffering? Do we hold onto it with grasping attachment? Is there anything there? This is what supports and sustains our practice. If we practise and get to this point, I think every one of us will realize genuine peace. Whether we are undertaking vipassan\=a meditation or samatha meditation, just this is what it's really about. But these days, it seems to me that when Buddhists talk about these things according to the traditional explanations, it becomes vague and mixed up. But the truth (\pali{saccadhamma}) isn't vague or mixed up. It remains as it is. So I feel it's better to seek out the source, looking at the way things originate in the mind. There's not a lot to this. \index[general]{Truth!recognising} Birth, ageing, illness, and death: it's brief, but it's a universal truth. So see it clearly and acknowledge these facts. If you acknowledge them, you will be able to let go. Gain, rank, praise, happiness, and their opposites -- you can let them go, because you recognize them for what they are. If we reach this place of `recognizing truth', we will be uncomplicated, undemanding people, content with simple food, dwelling, and other requisites for life, easy to speak to and unassuming in our actions. Without difficulty or trouble, we will live at ease. One who meditates and realizes a tranquil mind will be like this. \index[general]{practice!like the Buddha and his disciples} At present we are trying to practise in the way of the Buddha and his disciples. Those beings had achieved awakening, yet they still maintained their practice as long as they were living. They acted for the benefit of themselves and for the benefit of others, yet even after they had accomplished all that they could, they still kept up their practice, seeking their own and others' well-being in various ways. I think we should take them as the model for our practice. It means not becoming complacent -- that was their deeply ingrained nature. They never slackened their efforts. Effort was their way, their natural habit. Such is the character of the sages, of genuine practitioners. \index[similes]{rich and poor!effort and practice} We can compare it to rich people and poor people. The rich are especially hard-working, much more so than the poor. And the less effort poor people make, the less chance they have of becoming rich. The rich have knowledge and experience of a lot of things, so they maintain the habit of diligence in all they do. \index[general]{practice!all postures} If we want to take a break or get some rest, we will find rest in the practice itself. Once we've practised to get to the goal, know the goal, and be the goal, then when we are active, there's no way to incur loss or be harmed. When we are sitting still, there is no way we can be harmed. In all situations, nothing can affect us. Practice has matured to fulfilment and we have reached the destination. Maybe today we don't have a chance to sit and practise sam\=adhi, but we are OK. Sam\=adhi doesn't mean only sitting. There can be sam\=adhi in all postures. If we are really practising in all postures, we will enjoy sam\=adhi thus. There won't be anything that can interfere. Such words as `I'm not in a clear state of mind now, so I can't practise' will not be heard. We won't have such ideas; we will never feel that way. Our practice is well developed and complete -- this is how it should be. When we are free of doubt and perplexity, we stop at this point and contemplate. \index[general]{fetters!first three} You can look into this: self-view, sceptical doubt, superstitious attachment to rites and rituals. The first step is to get free of these. The mind needs to get free of whatever sort of knowledge you gain. What are they like now? To what extent do we still have them? We are the only ones who can know this; we have to know for ourselves. Who else can know better than we? If we are stuck in attachment to self-view, doubt, superstition here, have doubt here, are still groping here, then there is the conception of self here. But now we can only think, if there is no self, then who is it that takes interest and practises? \index[general]{nibb\=ana!definition} All these things go together. If we come to know them through practice and make an end of them, we live in an ordinary way. Just like the Buddha and the ariyas. They lived just like worldly beings (\pali{\glsdisp{puthujjana}{puthujjana}}). They used the same language as worldly beings. Their everyday existence wasn't really different. They used many of the same conventions. Where they differed was that they didn't create suffering for themselves with their minds. They had no suffering. This is the crucial point; they went beyond suffering, extinguishing suffering. \glsdisp{nibbana}{Nibb\=ana} means `extinguishing'. Extinguishing suffering, extinguishing heat and torment, extinguishing doubt and anxiety. \index[general]{doubt} There's no need to be in doubt about the practice. Whenever there is doubt about something, don't have doubt about the doubt -- look directly at it and crush it like that. In the beginning, we train to pacify the mind. This can be difficult to do. You have to find a meditation that suits your own temperament. That will make it easier to gain tranquillity. But in truth, the Buddha wanted us to return to ourselves, to take responsibility and look at ourselves. \index[general]{birth!in present} \index[general]{becoming!description} Anger is hot. Pleasure, the extreme of indulgence is too cool. The extreme of self-torment is hot. We want neither hot nor cold. Know hot and cold. Know all things that appear. Do they cause us to suffer? Do we form attachment to them? The teaching that birth is suffering doesn't only mean dying from this life and taking rebirth in the next life. That's so far away. The suffering of birth happens right now. It's said that becoming is the cause of birth. What is this `becoming'? Anything that we attach to and put meaning on is becoming. Whenever we see anything as self or other or belonging to ourselves, without wise discernment to know it as only a convention, that is all becoming. Whenever we hold on to something as `us' or `ours', and it then undergoes change, the mind is shaken by that. It is shaken with a positive or negative reaction. That sense of self experiencing happiness or unhappiness is birth. When there is birth, it brings suffering along with it. Ageing is suffering, illness is suffering, death is suffering. \index[general]{becoming!description} \index[general]{birth!description} Right now, do we have becoming? Are we aware of this becoming? For example, take the trees in the monastery. The abbot of the monastery can take birth as a worm in every tree in the monastery if he isn't aware of himself, if he feels that it is really `his' monastery. This grasping at `my' monastery with `my' orchard and `my' trees is the worm that latches on there. If there are thousands of trees, he will become a worm thousands of times. This is becoming. When the trees are cut or meet with any harm, the worms are affected; the mind is shaken and takes birth with all this anxiety. Then there is the suffering of birth, the suffering of ageing, and so forth. Are you aware of the way this happens? Well, those objects in our homes or our orchards are still a little far away. Let's look right at ourselves sitting here. We are composed of the five aggregates and the four elements. These \pali{sa\.nkh\=ar\=a} are designated as a self. Do you see these \pali{sa\.nkh\=ar\=a} and these suppositions as they really are? If you don't see the truth of them, there is becoming, being gladdened or depressed over the five \pali{khandh\=a}, and we take birth, with all the resultant sufferings. This rebirth happens right now, in the present. This glass isn't broken now, and we are happy about it now. But if this glass breaks right now, we are upset right now. This is how it happens, being upset or being happy without any wisdom in control. One only meets with ruination. You don't need to look far away to understand this. When you focus your attention here, you can know whether or not there is becoming. Then, when it is happening, are you aware of it? Are you aware of convention and supposition? Do you understand them? It's the grasping attachment that is the vital point, whether or not we are really believing in the designations of me and mine. This grasping is the worm, and it is what causes birth. \index[general]{attachment!description} \index[general]{contact} \index[general]{six senses} Where is this attachment? Grasping onto form, feeling, perception, thoughts, and consciousness, we attach to happiness and unhappiness, and we become obscured and take birth. It happens when we have contact through the senses. The eyes see forms, and it happens in the present. This is what the Buddha wanted us to look at, to recognize becoming and birth as they occur through our senses. If we know the inner senses and the external objects, we can let go, internally and externally. This can be seen in the present. It's not something that happens when we die from this life. It's the eye seeing forms right now, the ear hearing sounds right now, the nose smelling aromas right now, the tongue tasting flavours right now. Are you taking birth with them? Be aware and recognize birth right as it happens. This way is better. To do this requires having wisdom to steadily apply mindfulness and clear comprehension. Then you can be aware of yourself and know when you are undergoing becoming and birth. You won't need to ask a fortune-teller. \index[general]{superstition} \index[general]{divination} I have a Dhamma friend in central Thailand. In the old days we practised together, but we went our separate ways long ago. Recently I saw him. He practises the \glsdisp{foundations-of-mindfulness}{foundations of mindfulness,} reciting the \pali{\glsdisp{sutta}{sutta}} and giving discourses on it. But he hadn't resolved his doubts yet. He prostrated to me and said, `Oh, Ajahn, I'm so happy to see you!' I asked him why. He told me he had gone to some shrine where people go for divinations. He held the Buddha statue and said, `If I have already attained the state of purity, may I be able to raise up this statue. If I have not yet attained the state of purity, may I not be able to raise it up.' And then he was able to raise it up, which made him very delighted. Just this little act, which has no real basis in anything, meant so much to him and made him think he was pure. So he had it engraved on a stone to say, `I raised up the Buddha statue and have thus attained the state of purity.' \index[general]{intention} \index[general]{knowing!for oneself} \index[general]{Truth} Practitioners of the Dhamma shouldn't be like that. He didn't see himself at all. He was only looking outside and seeing external objects made of stone and cement. He didn't see the intentions and movements in his own mind in the present moment. When our meditation is looking there, we won't have doubts. So the way I see it, our practice may be good, but there's no one who can vouch for us. Like this chapel we are sitting in. It was built by someone with a fourth-grade education. He did a great job, but he has no brand name. He can't provide the guarantee or vouch for himself, showing qualifications like an architect who has the full training and education, but still he does it well. The \pali{saccadhamma} is like this. Even though we haven't studied much and don't know the detailed explanations, we can recognize suffering, we can recognize what brings suffering, and we can let go of it. We don't need to investigate the explanations or anything else. We just look at our minds, look at these matters. \index[general]{doubt} \index[general]{not-self} Don't make your practice confusing. Don't create a bunch of doubts for yourself. When you do have doubt, control it by seeing it as merely what it is, and let go. Really, there is nothing. We create the sense that there is something, but really there's nothing -- there is \pali{\glsdisp{anatta}{anatt\=a.}} Our doubtful minds think there is something, and then there's \pali{\glsdisp{atta}{att\=a.}} Then meditation becomes difficult because we think we have to get something and become something. Are you going to practise meditation to get or be something? Is that the correct way? It's only \pali{\glsdisp{tanha}{ta\d{n}h\=a}} that gets involved in having and becoming. There's no end in sight if you practise like that. \index[general]{cessation} Here, we are talking about cessation, extinguishing. We are talking about everything extinguished, ceasing because of knowledge, not in a state of indifferent ignorance. If we can practise like this and vouch for our own experience, then never mind what anyone else says. \index[similes]{upstairs and downstairs!middle way} \index[general]{space} \index[general]{becoming!definition} \looseness=1 So please don't get lost in doubts about the practice. Don't get attached to your own views. Don't get attached to others' views. Staying in this middle place, wisdom can be born, correctly and to full measure. I've often made the simple analogy of comparing grasping to the place we live. For example, there is the roof and the floor, the upper and lower storeys. If someone goes upstairs, he knows he is up there. If he comes downstairs, he knows he is downstairs, standing on the floor. This is all we can recognize. We can sense where we are, either upstairs or downstairs. But the space in the middle we aren't aware of, because there's no way to identify or measure it -- it's just space. We don't comprehend the space in between. But it remains as it is, whether or not anyone descends from upstairs or not. The \pali{saccadhamma} is like that, not going anywhere, not changing. When we say `no becoming', that is the middle space, not marked or identified by anything. It can't be described. For example, these days, the youngsters who are interested in Dhamma want to know about Nibb\=ana. What's it like? But if we tell them about a place without becoming, they don't want to go. They back off. We tell them that this place is cessation, it is peace, but they want to know how they will live, what they will eat and enjoy there. So there's no end to it. The real questions for those who want to know the truth, are questions about how to practise. \index[general]{\=aj\={\i}vaka} \index[general]{Buddha, the!meets wanderer upon enlightenment} There was an \pali{\glsdisp{ajivaka}{\=aj\={\i}vaka}} who met the Buddha. He asked, `Who is your teacher?' The Buddha replied, `I was enlightened through my own efforts. I have no teacher.' But his reply was incomprehensible to that wanderer. It was too direct. Their minds were in different places. Even if the wanderer asked all day and all night, there was nothing about it he could understand. The enlightened mind is unmoving and thus can not be recognized. We can develop wisdom and remove our doubts only through practice, nothing else. \index[general]{practice!in accordance with Dhamma} So should we not listen to the Dhamma? We should, but then we should put the knowledge we gain into practice. But this doesn't mean that we're following a person who teaches us; we follow the experience and awareness that arise as we put the teaching into practice. For instance, we feel, `I really like this thing. I like doing things this way!' But the Dhamma doesn't allow such liking and attachment. If we are really committed to the Dhamma, then we let go of that object of attraction when we see that it is contrary to Dhamma. This is what the knowledge is for. A lot of talk -- you're probably tired by now. Do you have any questions? Well, you probably do; you should have awareness in letting go. Things flow by and you let them go, but not in a dull, indifferent manner, without seeing what is happening. There has to be mindfulness. All the things I've been saying are pointing to having mindfulness protecting you at all times. It means practising with wisdom, not with delusion. Then we will gain true knowledge as wisdom becomes bold and keeps increasing.
%!TEX root = ../thesis.tex %******************************************************************************* %*********************************** First Chapter ***************************** %******************************************************************************* \chapter{An example of data-driven science} %Title of the First Chapter \label{chap:intro_stat} \ifpdf \graphicspath{{Chapter1/Figs/Raster/}{Chapter1/Figs/PDF/}{Chapter1/Figs/}} \else \graphicspath{{Chapter1/Figs/Vector/}{Chapter1/Figs/}} \fi \victor{This is a example of comment} \cecile{This is a example of comment} \isabelle{This is a example of comment} \david{This is a example of comment} \topic{This is a example of topic} \content{This is a example of content} \topic{Simulations combined with machine learning make possible to extract knowledge even in highly complex and stochastic process like High Energy Physics} \content{Objective : Improving the precision of parameter estimation in a special case of the inverse problem in the presence of systematic effect.} The first section (\autoref{sec:inverse_problem_at_lhc}) of this chapter describes the system and specific features of the analysis. Then \autoref{sec:inference_through_simulation} provides methods to conduct the analysis in an ideal setup. Finally the last parts of the analysis pipeline handling known biases and uncertainties are given in \autoref{sec:systematic_effects}. \autoref{sec:summary} is gathering it all and emphasizes the part of the pipeline this work focus on. \section{Inverse problem at LHC} % (fold) \label{sec:inverse_problem_at_lhc} % section inverse_problem_at_lhc (end) \topic{C'est très complexe mais on a pas besoin de toute cette complexité pour saisir le problème.} \subsection{The system} % (fold) \label{sub:the_system} The system producing the data studied in this analysis is the famous Large Hadron Collider (LHC). Without getting into the details, a particle collider is a machine accelerating small bricks of matter, protons in this case, in opposite direction to smash them against each others. The resulting collision produces high energy particles whose properties are captured by the various measurement apparatus which, for simplicity, can be reduced to a giant camera. \victor{FIGURE : Utiliser des images + jolies} \begin{figure}[htb] \centering \includegraphics[width=0.8\linewidth]{particle_collider_0} \caption{Very simple particle collider} \label{fig:particle_collider_0} \end{figure} These collisions can be classified into 2 kinds : \begin{itemize} \item the \emph{soft collisions} when the protons "missed" each other and does not produce high energy particles \item the \emph{hard collisions} when the protons smashed on each other and produces many particles \end{itemize} \begin{figure}[htb] \centering \begin{subfigure}[t]{0.49\linewidth} \includegraphics[width=\linewidth]{particle_collider_soft} \caption{soft collision} \label{fig:soft_collision} \end{subfigure}% \hfill \begin{subfigure}[t]{0.49\linewidth} \includegraphics[width=\linewidth]{particle_collider_hard} \caption{hard collision} \label{fig:hard_collision} \end{subfigure} \caption{soft collision (left) and hard collision (right)} \label{fig:collision} \end{figure} The hard collisions, usually named \emph{event} in the High Energy Physics (HEP) community, are way rarer than the soft one. The process creating the high energy particles is fundamentally stochastic. Meaning that the nature and properties (eg. kinematics) of the process producing particles are not fully predictable but follow probability distributions whose shapes and properties are deterministics. \cecile{Good, to be developed} The vast majority of the processes are already well known. To produce (very) rare therefore interesting processes the accelerator must produce a collosal number of collisions. The LHC is an international collaboration, involving thousands of people and housing many HEP experiments. The one that motivates this work is a study of a specific process ($H \to \tau \tau$). Basically an event produced a Higgs boson which desintegrated into 2 $\tau$ particles. \cecile{this is not the place for this detail} Each event following this process is defined as a \emph{signal} event versus the \emph{background} events that gather all the other processes. The objective is to measure the frequency, or probability, of this event to occur. \cecile{Qualitatively, yes} Leading to a counting experiment of the number of signals $s$ and the number of backgrounds $b$ to estimate the quantity of interest $f = \frac{s}{s + b}$. \cecile{NO. There is no such a thing a "The" quantity of interest. Just for memory, depending on the goal, it may be for instance $s/\sqrt{b}$ (discovery). And for measurement, it is NOT $s/(s+b)$. It might be $s/\sqrt{s+b}$, or the more complicated formula that was in our paperfigures. Because they make physical sense: $s/\sqrt{b}$ the significance of the hypothesis test; $s/\sqrt{s+b}$ is the inverse of the normalized standard deviation (coefficient of variance) of the measurement when no systematics. } From this frequency and the setup of the experiment (luminosity, etc) it is possible to compute the \emph{cross-section} (or branch factor ?) of the $H \to \tau \tau$ process which is the final goal of the study. \victor{Link between cross-section, branch factor, luminosity ?} \cecile{This is probably essentiel. It help explaining the Poisson model (ie $\mu s + b$ vs $s+b$ see detailed comment later} In many interesting cases, including ours, the nature of the event (signal / background) are not among the possible measurements that can be made. Counting signals and backgrounds requires extra work which is described in this chapter. The first step is to provide a very accurate description of the various steps in the experiment \ie the model. \subsection{The model} % (fold) \label{sub:the_model} The Standard Model \needcite (SM) is the theory describing quantum physics including particle collisions and productions. The counting experiment final objective is to improve our knowledge of one of the free parameter of the SM. In other words we are fitting the SM parameters to the data of the experiment. Let $x$ be the observables \ie the data collected by the apparatus for a single event and $p(x)$ its probability density. The LHC produces a large quantity of events while ensuring that the conditions are the same for all events. Hence we can assume that the full dataset $D$ contains $N$ independant and identically distributed (iid) events $D = \{x_i\}_{i=1}^N$. Going from the fundamental parameters to the observables is very complex and not in the direct interest of this study. The full process can be summaried into four major steps : \begin{enumerate} \item The collision between particles \item The particle production from the collision \item The journey of the created particles to the apparatus (particle desintegrations into other particles, interactions between produced particles, etc) \item Reaction of the measurement apparatus to the particles going through it. \end{enumerate} Each of these steps requires special care from the community to be accurately modeled. \victor{TODO : Maybe a few numbers to show how much it is complicated (nb poeple working on it, time required, nb of paper, etc)} Although modeling what happens between the particle production and the apparatus response is possible it is by definition impossible to get data about what really happened. Leading to the necessity to infer what happened before the measurements. \victor{TODO : Quelques mots sur le tracking, l'inférence des features} The vast majority of the intermediate quantities are latent or hidden variables, noted $z$. One of this latent variable was already mentioned previously : the \emph{label} of the event indicating the nature of the process, in our case if it is a \emph{signal} or a \emph{background} event. \victor{L'objectif est de donner un apperçu de la complexité de la chose. Sans entrer + que ça dans les détails...} \victor{TODO : Donner un aperçu de la complexité de chaque étape en 1 ou 2 phrases.} In this study the parameter of interest, noted $\mu$, is a fundamental parameter intervening at the particle collision stage (ie step 1). \begin{figure}[htb] \centering \includegraphics[width=0.8\linewidth]{KyleAll} \caption{Added by Cecile. The generative process (only left side is relevant for the referencing discussion.} \label{fig:genproc} \end{figure} Finally gathering all the ingredients the generative model can be splited in 3 stages : \begin{equation} \label{eq:model_simple} p(x, \mu, z) = p(x|z) p(z | \mu) p(\mu) \end{equation} In other words the fundamental parameter $\mu$ shapes the distribution of the latent variable $z$. And the data distribution depends on the latent variable $z$. \cecile{This is a formally correct way to formalize the notion of fundamental parameters. However, the technical conclusion is that $x$ is conditionally independent of $\mu$ given $z$, that is $p(x|z, \mu) = p(x|z)$. This "sounds strange". And in fact is \textbf{not true}. As you say after, the parameters of the apparatus (which are part of $z$) are not determined by $\mu$ at all. And more importantly, the nuisance parameters are not determined by $\mu$. Figure \ref{fig:genproc} shows that. Thus, what is exactly the point of this formula? Besides, it is contradictory with formula \ref{eq:intractable_integral}. See the discussion after that equation . The problem is a confusion between \textbf{parameters} and\textbf{ latent variables}} $p(\mu)$ is the prior knowledge, it contains all the belief of the community. Of course the belief of the community is only based on results of previous experiments or non-informative if there is no previous experiments. Note : we assume here that $\mu$ is the only fundamental parameter for simplicity. In a more realistic model, like the standard model, there are more fundamental parameters. To these fundamental parameters one should also take into account the parameters intervening in the apparatus response modeling. Additionally some required model simplifications introduce again some parameters, etc. How to take care of these additional parameters is the subject of \autoref{sec:systematic_effects}. The true value of $\mu$, assuming that the model is perfectly describing Nature's behaviour, is noted $\mu^\star$ as opposed to $\hmu$ the estimated value from the data. Of course the objective is to build an estimator $\hmu$ whose value is as close as possible to the true value $\mu^\star$. \subsection{Classic parameter estimation} % (fold) \label{sub:classic_parameter_estimation} \topic{Bayesian inference gives access to the full posterior distribution} Assuming that the model provides a likelihood $p(x | \mu)$ the Bayes theorem indicates how to access the posterior pobability. \begin{equation} p(\mu | x) = \frac{p(x|\mu) p(\mu)}{p(x)} = \frac{p(x|\mu) p(\mu)}{\int_\mu p(x|\mu) p(\mu)} \end{equation} The prior $p(\mu)$ contains all the current knowledge about the parameter. If no knowledge is available a non informative prior is chosen, usually a uniform distribution over the domain of $\mu$. The inference is then straitforward. Computing $p(\mu | x)$ for the possible values of $\mu$ \ie where the prior probability is not zero. The integral on the denominator can either be computed by hand or approximated with Monte Carlo. Often the full posterior is not required and only the most probable value of the parameter is infered. When no prior knowledge on the parameter of interest is available maximum a posteriori and maximum likelihood estimators are strickly equivalent. \begin{align} \label{eq:map_mle_1} \hmu &= \argmax_\mu p(\mu | x) \\ \label{eq:map_mle_2} &= \argmax_\mu \frac{p(x|\mu) p(\mu)}{p(x)} \\ \label{eq:map_mle_3} &= \argmax_\mu p(x|\mu) p(\mu) \\ \label{eq:map_mle_4} &= \argmax_\mu p(x|\mu)\\ \end{align} \autoref{eq:map_mle_1} $ \to$ \autoref{eq:map_mle_2} Bayes theorem ; \autoref{eq:map_mle_2} $ \to$ \autoref{eq:map_mle_3} $p(x)$ does not depends on $\mu$ ; \autoref{eq:map_mle_3} $ \to$ \autoref{eq:map_mle_4} $p(x)$ non-informative prior. \victor{TODO : trop de étails. Mettre ça dans l'appendix B avec les preuves.} Solving this maximization usually involves either analytical computing of the formulas or a numerical optimization process (eg. gradient ascent, coordinate ascent). See \autoref{sub:poisson_count_process} for an example. %\end{document} \subsection{Inverse problem} % (fold) \label{sub:inverse_problem} \topic{These methods don't scale to high dimensions} Unfortunately the likelihood provided by the model is not tracktable. The process leading from the collisions to the obvervables involves numerous latent variables $z_1, ..., z_n$ where $n=10^6$. Making the marginal likelihood intraclable because of high dimensional integrals. \begin{equation} \label{eq:intractable_integral} p(x|\mu) = \int_{z_1} \int_{z_2} ... \int_{z_n} p(x|\mu, z_1, z_2, ..., z_n) p(z_1) p(z_2) ... p(z_n) \end{equation} \cecile{This is not coherent with equation \ref{eq:model_simple}, as follows. \\ The integrand in the right hand side of \ref{eq:intractable_integral} is $p(x|\mu,z)p(z)$ \\ Using \ref{eq:model_simple}, which says that $p(x|\mu,z) = p(x|z)$, one gets the integrand is \\ $p(x|z)p(z)$ \\ which is obviously $p(x)$. And this does not make sense. } \cecile{Overall, there is a confusion between \textbf{parameters} (external) and \textbf{latent states} of the simulator. There are not "millions" of parameters, but there are millions of latent states. However, considering latent states is quite \textbf{specialized} to the "mining gold" approach, which augments the simulator to read and use them. In fact it explicitly computes (by computer, not closed form) the likelihood.} %\end{document} \cecile{follow up: the presentation of simulation from the point of view of latent variables is very good in the Mining gold paper. For reference, I copy it here, with a few stylistic changes. \\ We consider a scientific simulator that implements a stochastic generative process that proceeds through a series of latent states $z_i$ and finally to an output $x$. The latent space structure $Z$ can involve discrete and continuous components and is derived from the control flow of the (differentiable or non-differentiable) simulation code. Based on the mechanistic model implemented by the simulator, each latent state is sampled from a conditional probability density $z_i \sim p_i(z_i |\mu, z_{<i})$ %\end{document} and the final output is sampled from $x \sim p_x(x | \mu, z)$. The likelihood is then given by \\ $p(x|\mu) = \int dz p(x,z|\mu) = \int dz p(x|\mu,z)p(z|\mu)$ and the trick is that $p(z|\mu) = \prod{p_i(z_i |\mu, z_{<i})}$ can actually be computed by instrumenting the simulator. \\ Often the likelihood is intractable exactly because the latent space $Z$ is enormous and it is unfeasible to explicitly calculate this integral. In real-world scientific simulators, the trajectory for a single observation can involve many millions of latent variables. } \victor{What do we know about numerical stability of high dimensional integral ?} \content{Maybe a "simple" example that shows how often in real life this setting may happen} Moreover sometimes simplifications needs to be made in order to build the model \needcite making the computed likelihood only an approximation of the true likelihood. Some other times exact computable formulas or programs simply do not exist \needcite. \content{Approximation requiered to build some part of LHC simulation as an example} However building a simulator working only in forward mode, \ie allowing to sample from $p(x|\mu)$, is easier and possible in cour case. The objective is then to infer causal parameters from observations hence reversing the forward process which goes from causal parameters to observations. This is more generaly known as the \emph{inverse problem}. There is no general solution yet to this problem altough it occures often in experimental science. \begin{figure}[htb] \centering \includegraphics[width=0.8\linewidth]{inverse_problem} \caption{The inverse problem objective is to go from the observables to the causal parameter of the model embeded by the simulator} \label{fig:inverse_problem} \end{figure} \subsection{Special case of inverse problem} % (fold) \label{sub:special_case_of_inverse_problem} Although no general solution to the inverse problem exist yet it is possible to use the characteritics of the setup to get around the problem. Events are classified into two categories : signals and backgrounds. The distribution of events can be rewritten as : \begin{equation} p(x) = p(x|S) p(S) + p(x|B) p(B) \end{equation} The objective is to infer the probability of an event to be a signal ie $p(S)$ while $p(x|S)$ and $p(x|B)$ are intracktable. Since we are working with very rare events the value of $p(S)$ is very small. To avoid numerical stability issues it is more convenient to deal with a \emph{deviation} from a nominal value. \begin{equation} \label{eq:mu_definition} p(S) = \mu p_{SM}(S) \end{equation} where $p_{SM}(S)$ is the probability of an event to be a signal according to current knowledge \ie the Standard Model. The parameter of interest $\mu$ is measuring the deviation of the data from the SM. If the data are in perfect agreement with the SM then $\mu=1$. The next section makes use of this setup to tackle the inference. \section{Inference through simulation} % (fold) \label{sec:inference_through_simulation} \victor{Or "Inference with/using simulations" ?} \topic{Simulations/models are useful to explain data (therefore understand the undelying process that generated the data)} \content{Dans un monde simple tout est "facile"} \content{Introduire le problème d'extraction d'un coefficient de mélange(lié à cross-section)} This section show three independant ways to solve this specific case of inverse problem. \autoref{sub:hand_crafted_dimension_reduction} gives a general solution assuming domain knowledge allow to put all relevant information in a low dimension space. \autoref{sub:count_estimation} is using a classifier score as a proxy for maximum likelihood estimation. The remaining sections (\autoref{sub:poisson_count_process}, \autoref{sub:binned_poisson_count_process}, \autoref{sub:simulator_as_estimator}) describe the retained analysis pipeline. The reasons to retain the last one is given in \autoref{sec:systematic_effects}. \subsection{Hand crafted dimension reduction} % (fold) \label{sub:hand_crafted_dimension_reduction} \victor{Brouillon} Since the likelihood cannot be computed directly one solution is to sample many events and apply density estimation methods. Examples : histograms, kernel density estimation. Tackling the inverse problem with density estimation is subject to the curse of dimensionality. Restricting the observables to only one or two dimensions requires those dimension to carry all or most the information about the estimated parameter. The first idea to achieve such constraint is to use domain knowledge. Basically ask the theorists to find one or two computable quantities from the possible measurement allowing to infer the parameter. \victor{TODO : Fouiller les années 80 à la recherche d'exemple} \victor{Discard the less relevant ones (feature selection). Pas sûr que ça soit vraiment utilisé. Demander à David.} The second possibility is to use machine learning to reduce the dimension of the data. \victor{Parzen windows to estimated density to get a likelihood. Maybe beats curse of dimension.} Parzen windows can estimate densities ! So we can use it on the simulated data to define the likelihood function. \victor{Mot clé : "méthode des coupures" (cécile) comme méthode à la main pour trouver une région riche en signal} \victor{TODO : quelques remarques sur les limitations de ces methodes} \subsection{Count estimation} % (fold) \label{sub:count_estimation} This section borrows many results from \cite{Neal:2007zz}. The stochastic phenomenon of interest here displays the following generative process : \begin{equation} \label{eq:mixture_model} p(x|\eta) = \eta p(x|S) + (1-\eta) p(x|B) \end{equation} where $x$ is the set of observable features of the studied event gathered in a vector. Events are split into 2 classes : the signals $S$ and the backgrounds $B$. Note that $S$ and $B$ are one of the numerous latent variable $z_i$ in \autoref{eq:intractable_integral}. $\eta$ is the mixture coefficient between signals and backgrounds. As stated in \autoref{sub:special_case_of_inverse_problem} $\eta$ can be seen as the probability for an event to be a signal $p(S)$. It naturally follows that $1-\eta$ is the probability for an event to be a background $p(B)=1-p(S)$. \autoref{eq:mixture_model} can be re-written as \begin{equation} p(x) = p(S)p(x|S) + p(B)p(x|B) \end{equation} As previously explained \autoref{sub:inverse_problem} the likelihoods $p(x|S)$ and $p(x|B)$ are intractable because they involves high dimension integrals. However building a simulator working only in forward mode allowing to sample from $p(x|\eta)$ is possible. This allow us to build a training dataset to feed some machine learning algorithm later. Measurements are made from a large bunch of independent and identically distributed events $D=\{x_i\}_{i=1}^N$. \begin{align} p(D|\eta) =& \prod_{i=1}^N \eta p(x|S) + (1-\eta) p(x|B) \\ =& \prod_{i=1}^N p(x|B) \left [(1-\eta) + \eta \frac{p(x|S)}{p(x|B)} \right ]\\ =& \underbrace{\left[ \prod_{i=1}^N p(x|B) \right ]}_{h(x)} \times \underbrace{\left [\prod_{i=1}^N (1-\eta) + \eta \frac{p(x|S)}{p(x|B)} \right ]}_{g_\eta(T(x))} \label{eq:Fisher-Neyman} \end{align} with $T(x) = \frac{p(x|S)}{p(x|B)} $ The Fisher-Neyman factorization theorem \needcite states that $T(x)$ is a sufficient summary statistic to obtain $\eta$ The maximum likelihood estimator, noted $\hat \mu$, is commonly used to estimate the parameter of interest. This is a reasonable choice when we do not have prior knowledge as in this example. \begin{equation} \hat \eta = \argmax_\eta p(\eta | D) \end{equation} It is more convenient (numerical stability) to express the result as a deviation from the prediction of the Standard Model. The deviation is defined as : \begin{equation} \mu = \frac{p(S)}{p_{SM}(S)} = \frac{\eta}{p_{SM}(S)} \end{equation} $p_{SM}(S)$ is the expected probability to get a signal following the Standard Model. Recovering the frequency $\eta$ from $\mu$ is trivially done with $\eta = \mu p_{SM}(S)$. The estimator is now : \begin{align} \hmu =& \argmax_\mu p(D | \mu) \\ =& \argmax_\mu \prod_{i=1}^N g_\mu(T(x)) \\ \end{align} $T(x)$ can be obtained using a classifier $c$ trained to separate signals and backgrounds. A Bayes optimal classifier output gives : \begin{equation} c(x) = \frac{n_s p(x|S)}{(1-n_s) p(x|B) + n_s p(x|S)} \end{equation} where $n_s$ is the fraction of signals used in the training dataset. \begin{equation} T(x) = \frac{c(x)}{(1-c(x))} \frac{(1-n_s)}{n_s} \end{equation} Note that $c$ is also a sufficient summary statistic \begin{equation} g_\eta(T(x)) = 1 - \mu p_{SM}(S) + \mu p_{SM}(S) \times \frac{c(x)}{(1-c(x))} \frac{(1-n_s)}{n_s} = f_\mu(c(x)) \end{equation} \content{Limitation : what happens if the classifier is not (Bayes) optimal ? Can we detect it ?} \content{Physicists also uses the Neyman-Pearson theorem on statistical test to justify maximum likelihood estimator usage. Should I include it here ?} \victor{TODO : C'est ici que je devrais parler des travaux de Kyle Cranmer et al sur Calibrated classifier ! \cite{Cranmer2015}} \victor{TODO : quelques remarques sur les limitations de cette methode} \subsection{Poisson count process} % (fold) \label{sub:poisson_count_process} Here is derived the standard method to solve the problem. The modeling of events is replaced by a model at a dataset level which is tractable. The system allows 2 kind of collisions : soft and hard collisions. The hard collisions are very rare compared to the soft collisions. The hard collision are splitted into 2 categories the signal events and the background events. The number of signals is $s$ and the number of backgrounds is $b$. The data can be modeled by counting iid Bernoulli rare process which is well approximated by a Poisson distribution \needcite when the number of samples is large. \victor{FIGURE : Ajouter un petit dessin type arbre de probabilité.} The total number of events $n$ is the sum of signal events and background events. \begin{equation} n = s + b \end{equation} The number of signal events is following a Poisson distribution of parameter $\mu \gamma$. \begin{equation} s \sim Poisson(\mu \gamma) \end{equation} $\gamma$ is the expected number of signals according to current knowledge ie the SM. $\mu$ is the parameter of interest, it is the deviation from the SM. According to \autoref{eq:mu_definition} $\gamma = p_{SM}(S)$. Decomposing the expectancy of the number of signals is mainly here for numerical stability ($\gamma$ is of the order $10^-6$\needcite). The number of background events is following a Poisson distribution of parameter $\beta$. \begin{equation} b \sim Poisson(\beta) \end{equation} Since the sum of Poisson random variables is also Poisson distributed \needcite (cf wikipedia) : \begin{equation} n \sim Poisson(\mu \gamma + \beta) \end{equation} Giving the likelihood : \begin{equation} P(n| \mu) = \frac{(\mu \gamma +\beta)^n }{n!} e^{-(\mu \gamma +\beta)} \end{equation} A tractable likelihood is now available ! This allow to use more classic parameter estimation like maximum likelihood. \begin{equation} \hat \mu = \argmax_\mu p(n|\mu) = \argmax_\mu Poisson(n|\mu) \end{equation} This one can be done by hand. Assuming that we know $\gamma$ and $\beta$. \begin{equation} \frac{\partial \log p(n|\mu)}{\partial \mu} = \gamma \frac{n}{\mu\gamma + \beta} - \gamma \end{equation} \begin{equation} \frac{\partial \log p(n|\mu)}{\partial \mu} = 0 \iff \mu = \frac{n-\beta}{\gamma} \end{equation} Note $\EE[n] = \mu\gamma + \beta$ and $\max Poisson = \EE[Poisson]$ so maybe there is a simpler way to find this ? \subsection{Binned Poisson count process} % (fold) \label{sub:binned_poisson_count_process} \cecile{First, let us avoid "bins", and speak of "zones" (I was confused with binning the scores). Second, I do not understand the setting at all. a) Because this is not consistent with the basic process in physics analysis, which I assume to be reasonable. Whatever method (classification or old-style "cut method"), a region of the event space is selected, and the number of events tagged as signals $n$ is by definition the size of this region. Thus they do not define something like the $n_i$. And b) because the goals and the results are not clearly stated. Finally, I agree that the question "why a classifier is good" makes sense, but has no relation with binning as far as I understand this section. In fact, the question makes a lot of sense, because your mammouths want to get rid of the simple signal/background classifier, so first explaining what the simple method achieves is very necessary.} \cecile {Point a).In the basic ("non binned") setting described in the previous section, $n$ is the \textbf{observed} number of signals. I consider the case of classification. For each event $x$,the classifier computes a score (let's call it $q(x)$), and the final classification is obtained by $q(x)$ being above/below a threshold $\theta$. The "region" selected for obtaining $n$ is the set of events above the threshold $\theta$. In the old-style "cut" method, the region is defined by hand. } \cecile{b) interpretation 1. Assuming the space is partitioned into zones, maybe what you suggest is to run the classifier (for the classifier method, or whatever signal selection procedure) separately in each zone. Then for each zone, you get the region inside the zone which volume would be the $n_i$. My objections are as follows. \\ 1) At this level of physics-related generality, I think this is not the process in physics analysis, which wants to select \textbf{one and only one} (signal-rich) region. \\ 2) Just to be complete, let us examine if this procedure is good for reducing the variance. \\ Let $n_i$ be the number of selected signals in each region. In this setting, if I understand well, you look for the total number of signals $n = \sum n_i$. Assuming (as you do) these are Poisson independent variables, the variance of the estimator does not directly depend on the zoning. Proof : $n$ is also Poisson, with parameter the sum of the partial parameters: $$\sum_i \mu \gamma_i + \beta_i = \mu \gamma + \beta$$ Thus your estimator of $\mu$ would be as before $\frac{n-\beta}{\gamma}$, but with $\gamma$ and $\beta$ evaluated over the whole data (which might be a worse estimator than in the normal procedure). Then $$\VV(\mu) = \frac{\VV(n)}{\gamma^2} = \frac{\mu \gamma + \beta}{\gamma^2}.$$ The last quantity does not depend on the zoning (looking for "small zones"), but on the performances of the classifier in each zone, totalized. } \cecile {b) interpretation 2. Using this paragraph and appendix C.3, I understand that you want to prove that "\emph{a classifier is a good choice}". A good choice for what procedure is the issue. How would you define the number of signals ($n_1$ and $n_2$) in the above-threshold zone (predicted positive) and the below threshold region (predicted negative)? } %\cecile{I essentially disagree with your claim "\emph{Intuitively knowing not only the total number of events but the number of events in each chunk of the data space contains more information hence should improve the inference.}" Because the estimator will be very poor in signal-poor zones, which are dominating. We are back to finding a signal-rich zone, and restrict to it.} The previous section gives a simple way to derive a maximum likelihood estimator. This section show how to improve this estimator using binning. The Poisson approximation is allowed because of the small probability of a event to occur and the large number of samples that the LHC can produce. Cutting the data space into regions does not break these assumptions as long as the regions contains enough samples. Intuitively knowing not only the total number of events but the number of events in each chunk of the data space contains more information hence should improve the inference. Let $O$ be the full data space and $K$ regions $\{\Omega_i\}_{i=1}^K$ such that they do not overlap $\forall i\neq j, \Omega_i \cap \Omega_j = \varnothing $ and that their union cover the full space $\bigcup_{i=1}^K \Omega_i = O$. Those regions are most commonly called \emph{bins} (or histogram bins) as the counting events in regions often rely on building a histogram. There is an infinite number of ways to cut the space into bins. \victor{FIGURE : Dessin de 2 manières de couper l'espace en région} Our objective with the binning is to improve the estimation, especially reduce the variance of our estimator. First let's see how binning improves the variance. We compare the two likelihood functions $L_0$ without binning and $L_K$ with $K$ bins \begin{equation} L_0 = \frac{(\mu \gamma + \beta)^n }{n!} e^{-(\mu \gamma + \beta)} \end{equation} with $n = \sum_{i=1}^K n_i $, $\gamma = \sum_{i=1}^K \gamma_i $ and $\beta = \sum_{i=1}^K \beta_i $. \begin{equation} L_K = \prod_{i=1}^M \frac{(\mu \gamma_i + \beta_i)^{n_i} }{n_i!} e^{-(\mu \gamma_i + \beta_i)} \end{equation} $L_0 > L_K$ and $\left (\frac{\partial^2 \log L_0}{\partial \mu^2}\right )^{-1} > \left (\frac{\partial^2 \log L_K}{\partial \mu^2}\right )^{-1}$. See \autoref{sec:proof} for details of the proof. According to the Cramer-Rao bound : \begin{equation} \VV(\hmu) \geq \left (\EE \left [ \frac{\partial^2 \log L_K}{\partial \mu^2}\right ] \right )^{-1} \end{equation} If the bound is tight the binned likelihood $L_K$ leads to a estimator with lower variance. If the bound is not tight well it is still probably better. The choice of the bin shape remains to be decided. \begin{equation} \left (\EE \left [ \frac{\partial^2 \log L_K}{\partial \mu^2}\right ] \right )^{-1} = \left ( \EE \left [ \sum_{i=1}^K n_i \frac{\gamma_i^2}{(\mu \gamma_i + \beta_i)^2} \right ] \right )^{-1} = \left ( \sum_{i=1}^K \EE [n_i] \frac{\gamma_i^2}{\EE[n_i]^2} \right )^{-1} \end{equation} Choosing carefully the bins $\Omega_i$ to make this quantity as small as possible requires to have some bins with high purity of signals. \victor{I need to prove that ! See \autoref{sec:proof} for details} To improve inference a classifier is used to create at least one region as rich in signals as possible. As seen in \autoref{sub:count_estimation} a Bayes optimal classifier decision function is a sufficient summary statistic adding to the interest of using a classifier. \subsection{Simulator as estimator} % (fold) \label{sub:simulator_as_estimator} This section deals with the estimation of $\gamma_i$ and $\beta_i$ using the simulator. \victor{Brouillon} The current knowledge about the mixture of signal and backgrounds events $\gamma$ and $\beta$ is trivial to extract from the model. But if the data space is binned in a non-trivial way, e.g. with a histogram on the score of a classifier, the valus of $\gamma_i$ and $\beta_i$ requires to be estimated. Basically $\gamma_i = \EE [s_i]$ and $\beta_i = \EE [b_i]$ which can be estimated by Monte Carlo. Running the simulation to produce many signal events and putting them through the same computation used to measure $n_i$ will give an estimate of $\EE [s_i]$. The same can be done for $\EE [b_i]$ by producing background events. \victor{PAPER : trouver les papiers de référence pour ce processus.} \section{Systematic effects} % (fold) \label{sec:systematic_effects} \topic{Systematic effects make inference more complex by introducing nuisance parameters} The parameter of interest is not the only causal parameter in real life experiments. Many other parameters are required to explain the observed data. Here is described the methods to take into account those additional parameters and their impact on inference. \subsection{Definition} % (fold) \label{sub:definition} Real life data modeling often requires several parameters to be fully described. On the other hand only one or a few of these parameters are the object of one study. This leads to asign parameters into two classes : the parameter of interest and the nuisance parameters. Nuisance parameters can appear from : \begin{itemize} \item apparatus imperfections \item theory flaws \item fundamental parameter uncertainties \item etc \end{itemize} Here is an example to Bob wants to estimate the efficiency of its hotplate by measuring the time required to heat 1L of water in a saucepan to boiling temperature. Each time Bob need boiling water to cook he will run this little experiment. Bob measured the temperature of the water and the air and the air pressure and know the electric power of his hotplate. Unfortunatelly Bob is using tap water and cannot measure the amount of impurities in the water which have a influence on the boiling temperature. The impurities concentration in the water is now a nuisance parameter of the problem (fundamental uncertainty). Moreover the thermometer is a cheap one and may be biased toward lower or upper temperature introducing another nuisance parameter (apparatus imperfection). Finally to simplify the computation Bob assumed that the heat produced by the hotplate would be mostly transmitted to the water. Although this approximation is too strong Bob will take it into account with a simplified formulas involving an additionnal nuisance parameter (theory flaws). \content{FIGURE : Schéma inverse problem with nuisance parameters} In the remaining of this manuscript the nuisance parameters are all gathered into a vector $\alpha$. \subsection{Impact on likelihood} % (fold) \label{sub:impact_on_likelihood} \victor{Brouillon pour le moment} The likelihood now depends on several parameters : \begin{equation} p(D | \mu, \alpha) = \prod_{i=1}^N p(x | \mu, \alpha) = \prod_{i=1}^N \mu p_{SM}(S) p(x | \mu, \alpha, S) + (1-\mu p_{SM}(S)) p(x | \mu, \alpha, S) \end{equation} First, the introduction of nuisance parameters $\alpha$ in \autoref{eq:Fisher-Neyman} makes it impossible to use the Fisher-Neyman theorem. \begin{equation} p(D|\mu, \alpha) = \underbrace{\left[ \prod_{i=1}^N p(x|B, \alpha) \right ]}_{h_\alpha(x)} \times \underbrace{\left [\prod_{i=1}^N (1-\mu p_{SM}(S)) + \mu p_{SM}(S) \frac{p(x|S, \alpha)}{p(x|B, \alpha)} \right ]}_{g_\mu(T_\alpha(x))} \end{equation} Now $h_\alpha(x)$ does not depends only in $x$. One could argue that although the classifier score may not be a sufficient summary statistic anymore it is likely to still contains most of the information about the parameter of interest. The use of classifier score is a very good approximated proxy to the likelihood function in practice. Moreover \cite{Cranmer2015} shows that if the classifier score is a monotone function of the likelihood it is a sufficient statistic. \victor{TODO : vérifier les termes exact du théorème de Cranmer} Second, the poisson count likelihood (see \autoref{sub:poisson_count_process}) has to be updated with the introduction of the nuisance parameter $\alpha$. The expected number of signal $\gamma$ and backgrounds $\beta$ now depends on $\alpha$. \begin{equation} p(n| \mu, \alpha) = \frac{(\mu \gamma(\alpha) +\beta(\alpha))^n }{n!} e^{-(\mu \gamma(\alpha) +\beta(\alpha))} \end{equation} Which makes it impossible to use closed formulas since these dependencies are not known exactly or intractable. Moreover taking nuisance parameter into account can introduce local maxima in the likelihood function. \victor{TODO : C'est là que j'attaque les papiers avec linéarisation de l'impact du paramètre de nuisance} \subsection{Calibration experiment} % (fold) \label{sub:calibration_experiment} $\alpha$ is generally known to a certain extent thanks to other measurements is controlled region where the signal has low probability of appearing or even no influence at all making these measurement independent from $\mu$ (\autoref{eq:calib_integration_1} $\to$ \autoref{eq:calib_integration_2}). These measurements $D_{calib}$ very often constrains the values of $\alpha$ with a gaussian distribution (\autoref{eq:calib_integration_2} $\to$ \autoref{eq:calib_integration_3}). \begin{align} \label{eq:calib_integration_1} p(n, D_{calib} | \mu, \alpha) &= p(n | \mu, \alpha) \times p(D_{calib} | \mu, \alpha) \\ \label{eq:calib_integration_2} p(n, D_{calib} | \mu, \alpha) &= p(n | \mu, \alpha) \times p(D_{calib} | \alpha) \\ \label{eq:calib_integration_3} p(n, D_{calib} | \mu, \alpha) &= Poisson(n | \mu \gamma(\alpha) +\beta(\alpha)) \times \mathcal N(D_{calib} | \alpha) \end{align} Of course this can be extended to the binned poisson likelihood. \begin{equation} p(n_1, .., n_K, D_{calib} | \mu, \alpha) = \mathcal N(D_{calib} | \alpha) \times \prod_{i=1}^K Poisson(n_i | \mu \gamma_i(\alpha) +\beta_i(\alpha)) \end{equation} \subsection{Recipes to reduce systematic uncertainties} % (fold) \label{sub:recipes_to_reduce_systematic_unceratinties} \victor{Brouillon} Petite listes des choses faisables pour réduire les biais systématiques. Example : Calibrant interne en chimie (mesure supplémentaire dont la valeur attendu est connu). Calibrant externe (échantillon dont la valeur attendu est connu). \subsection{Improving the likelihood} % (fold) \label{sub:improving_the_likelihood} \victor{Brouillon} Without systematics the Poisson likelihood contains most if not all the information about the parameter of our model. With systematics one or several parameters $\alpha$ are included. The maximum likelihood is not only depending of $\mu$ but also of $\alpha$ \begin{equation} \hat \mu, \hat \alpha = \argmax_{\mu, \alpha} L(\mu, \alpha) \end{equation} The Poisson likelihood may not enough in this case. The data is reduced to a few number $D \to n_1, n_2, ..., n_K$. It was build to find $\mu$ not $\alpha$. This is enough for the inference of $\mu$ without systematics as seen previously. But most of the information about $\alpha$ is lost. This does not feel like the likelihood is capturing all the connections between the data and the parameters. Here is proposed a quick and dirty way to improve the inference by taking into account the nuisance parameter. The idea is to use a \emph{blind regressor} (see \autoref{sub:handle_nuisance_parameter}) to produce an additional approximated likelihood. It can be seen as using a neural network to both produce additional summary statistics. The blind regressor is trained to approximate $p(\alpha | D)$ with a gaussian distribution. Sauf que ça produit un posterior ! PAS une likelihood .... Du coup le nom \textbf{Improved likelihood} est assez bof... \begin{equation} L(\mu, \alpha) : \mu, \alpha \to \underbrace{\prod_{i=1}^K Poisson(n_i | \mu \gamma_i(\alpha) + \beta_i(\alpha))}_{\text{Binned Poisson Likelihood}} \times \underbrace{\mathcal N(\alpha | NN(D))}_{\text{Not Prior Calibration}} \end{equation} Versus : \begin{equation} L(\mu, \alpha) : \mu, \alpha \to \underbrace{\prod_{i=1}^K Poisson(n_i | \mu \gamma_i(\alpha) + \beta_i(\alpha))}_{\text{Binned Poisson Likelihood}} \times \underbrace{\mathcal N(\alpha | Prior)}_{\text{Prior Calibration}} \end{equation} \subsection{Variance estimations} % (fold) \label{sub:variance_estimations} \victor{Brouillon} For now the concerns were mostly focused the inference of the parameter. But this is only half the answer. In science every estimation must comes with its uncertainty. The other half of the answer is the measurement of the uncertainty of parameter of interest's estimator. \victor{Uncertainty = Variance or confidence interval or credible interval ? Je dois dire lequel pourquoi ici je traite la variance. Et ajouter qu'on a toujours pas de définition claire de systematic uncertainty dans la littérature...} The origin of the variance of our estimator can be divided into 2 parts. The one comming mostly from the lack of data is called \emph{statistical variance} and the other origniates from the sensitivity of the inference to nuisance parameter and is named \emph{systematic variance}. Reminder of the variance definition : \begin{equation} \VV(Y) = \EE[(Y - \EE[Y])^2] = \EE(Y^2) - [\EE(Y)]^2 \end{equation} Law of total variance \needcite : \begin{eqnarray} \label{eq:total_variance_law} \VV[Y] =& \EE_X \left (\VV[Y|X] \right ) &+ \VV_X \left (\EE[Y|X]\right ) \\ \VV[Y] =& \EE_X \left (\VV[Y|X] \right ) &+ \EE_X \left ( (\EE [Y|X] - \EE[Y])^2\right ) \end{eqnarray} Substituing with our problem the estimator $Y = \hmu$ and the nuisance parameter $X = \alpha$ : \begin{equation} \label{eq:stat_and_syst_variance_definition} \mathbb{V}[\hmu] = \underbrace{\mathbb{E}_{\alpha \sim p(\alpha)} \left (\mathbb{V}[\hmu | \alpha] \right )}_{V_{stat}} + \underbrace{\mathbb{E}_{\alpha \sim p(\alpha)} \left ( (\mathbb{E} [\hmu | \alpha] - \mathbb{E}[\hmu])^2\right )}_{V_{syst}} \end{equation} The variance of our estimator is splitted into : the average of the variances of our estimator (assuming $\alpha$ is known) and the deviation from the average estimator induced by the nuisance parameter. \victor{Voilà c'est bien joli, mais il reste des zones d'ombre. c'est quoi $p(\alpha)$ ? et c'est quoi $\hmu | \alpha$ ?} Is the following correct ? \begin{align} \hmu | \alpha &= \argmax_{\mu, \alpha} p(Data | \mu, \alpha) | \alpha \\ &= \argmax_{\mu} p(Data , \alpha | \mu) \end{align} Obviously $p(\alpha)$ is a prior distribution. If the likelihood already includes calibration then it simply should represent the community's belief (without data) on the nuisance parameters. \subsection{Profiled likelihood} % (fold) \label{sub:profiled_likelihood} \topic{The current way of measuring the variance of our estimation to include systematics is "profiled likelihood"} \content{Explain how profiled likelihood works and why is works} \content{Introduce Fisher information matrix and Cramer Rao bound (since we will use it later for INFERNO)} References : \begin{itemize} \item \url{https://arxiv.org/abs/physics/0403059} \item \url{https://arxiv.org/abs/1007.1727} \item \url{https://arxiv.org/abs/physics/0408039} coverage study of marginalization of nuisance params \end{itemize} \victor{Papier de référence pour la construction d'interval de confiance en HEP = \url{https://arxiv.org/pdf/physics/9711021.pdf} G. J. Feldman and R. D. Cousins, Phys. Rev. D 57, 3873 (1998) ?} Il s'agit de produire $\mu$ et de l'encadrer. Version simple : Monte Carlo pour avoir $p(x)$ et chercher le maximum. Puis pour l'encadrement on navigue autour du maximum pour obtenir à droite et à gauche la valeure qui corespond à l'encadrement. On veut un interval de confiance à X\%. On va faire des petits calculs + petites approximations pour mesurer la valeur de $\mu + \smu$ et de $\mu - \smu$. \content{Faire un petit example à la main end-to-end. Ou pas car ça pique ! cf chap 9 section 6 du livre de Glen} \content{Lister clairement les approximations faites pour obtenir cet intervalle de confiance. + citer les papiers qui ont challengé ces approximations } \section{Summary} % (fold) \label{sec:summary} \subsection{Workflow} % (fold) \label{sub:workflow} \victor{Brouillon} In practice the data go through many processes like trigger selection, tracking, event reconstructions, etc. Computing hand crafted features to reduce the dimensionality from $\RR^{100,000}$ to $\RR^{40}$ then using machine learning to reduce to $\RR$. Although machine learning is slowly becoming part of these steps \needcite. All the domain knowledge is concentrated in the simulator and the hand crafted data processing. To keep it simple we assume here that the simulator produces high level features $x \in \RR^d$ from the model parameters $\mu$ and $\alpha$. The trigger and other intermediate steps only reduces the data space or the amount of expected signal a priori $p_{SM}(S)$. The complete workflow consist of a negative log likelihood minimization according to the model parameter. Recall the binned likelihood with calibration : \begin{equation} L(\mu, \alpha) =\mathcal N (\alpha) \times \prod_{i=1}^K Poisson(n_i | \mu \gamma_i(\alpha) + \beta_i(\alpha) ) \end{equation} Asuming that the bins are defined as a histogram on the score of a classifier $c : x \to c(x)$. That the experiment provides a dataset of events $D^\star$. And the simulator $G$ provides data for Monte Carlo estimation with signal events only $D_S$ and background only $D_B$. Those dataset are using some value for $\mu$ and $\alpha$. The number of events in a bin is \begin{equation} n_i = \sum_{x \in D^\star} \mathbbm{1} [c(x)\in \Omega_i] \end{equation} Computing the expected number of backgrounds and signals can be done with Monte Carlo. \begin{equation} \gamma_i(\alpha) = \EE[s_i|\alpha] \end{equation} \begin{equation} \beta_i(\alpha) = \EE[b_i|\alpha] \end{equation} where \begin{equation} s_i | \alpha = \sum_{x \in D_S(\alpha)} \mathbbm{1} [c(x)\in \Omega_i] \end{equation} \begin{equation} b_i | \alpha = \sum_{x \in D_B(\alpha)} \mathbbm{1} [c(x)\in \Omega_i] \end{equation} In practice the Monte Carlo simulation is a very fine grid with importance sampling. \victor{Now is the time to make formulas even more complex with weights ?} Does it mean that a single weighted dataset is enough to estimate expected value ? \begin{equation} \gamma_i(\alpha) = \EE[s_i | \alpha] = \sum_{x \in D_S(\alpha)} w_x \mathbbm{1} [c(x)\in \Omega_i] \end{equation} \begin{equation} \beta_i(\alpha) = \EE[b_i | \alpha] = \sum_{x \in D_S(\alpha)} w_x \mathbbm{1} [c(x)\in \Omega_i] \end{equation} \victor{Brouillon d'algo} \begin{algorithm}[H] inputs $D$, $\mu$ and $\alpha$ \; $D_S \gets G(\alpha)$ \; $D_B \gets G(\alpha)$ \; $\gamma_i = \sum_{x \in D_S(\alpha, \mu)} w_x \mathbbm{1} [c(x)\in \Omega_i] $ \; $\beta_i = \sum_{x \in D_B(\alpha, \mu)} w_x \mathbbm{1} [c(x)\in \Omega_i] $ \; $n_i = \sum_{x \in D^\star} \mathbbm{1} [c(x)\in \Omega_i]$ \; $L = \mathcal N (\alpha) \times \prod_{i=1}^K Poisson(n_i | \mu \gamma_i(\alpha) + \beta_i(\alpha) )$ \; \caption{Computing the likelihood} \end{algorithm} \victor{Maintenant je remarque que j'ai pas mentionné les \emph{summary statistics} .... techniquement $n, s, b$ sont des summary statistics. Où est-ce que je vais mettre ça ?} \begin{figure}[htb] \centering \includegraphics[width=0.5\linewidth]{workflow} \caption{The workflow of maximum likelihood inference using an optimizer} \label{fig:workflow} \end{figure} \subsection{Looking for better} % (fold) \label{sub:looking_for_better} \topic{This document is about going further than the "simple" classifier method} \content{Annonce de la suite / du plan du manuscrit} The dependency of $\gamma$ and $\beta$ to the nuisance parameter $\alpha$ is the origin of the systematic variance. The objective of this work is to find a way to reduce the systematic variance. The first way is to train a classifier whose score is less influenced by $\alpha$ \autoref{chap:sota}. The second way is to rework the pipeline into a more direct approach to inference \autoref{chap:direct_approach}. Then all methods are compared using 2 toy problems and 1 reworked real dataset to measure their performances \autoref{chap:benchmark}. Finnally the performances are described and analysed in \autoref{chap:xp}. \autoref{chap:conclusion} gives insight for future work, discuss calibration and ...
/// @file spsc/queue_ut.cpp /// @brief Contains queue unit tests /// @copyright Licensed under the MIT License /// @author Rostislav Ostapenko ([email protected]) /// @date 6-Apr-2014 #define NOMINMAX #include <algorithm> #include <atomic> #include <iostream> #include <iomanip> #include <limits> #include <memory> #include <numeric> #include <thread> #include <type_traits> #include <boost/predef.h> #define BOOST_ENABLE_ASSERT_HANDLER #define BOOST_TEST_MODULE xcon_spsc_queue_test #include "boost_test.hpp" #include "ut_utils.hpp" #include "high_res_clock.hpp" #include "queue.hpp" namespace xcon { namespace spsc { namespace queue_ut { //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Basic Functionality Test /// Tests shared queue basic functionality, no threads envolved BOOST_AUTO_TEST_CASE(test_queue_basics) { typedef std::unique_ptr<int> smart_ptr; // Check ctor throwing BOOST_CHECK_THROW(queue<int>(0u), std::length_error); const size_t max_size = std::numeric_limits<size_t>::max(); BOOST_CHECK_THROW((queue<int>(max_size)), std::length_error); #if BOOST_ARCH_X86_64 const size_t max_size_bad_alloc = 10000000000u; #else const size_t max_size_bad_alloc = 1000000000u; #endif BOOST_CHECK_THROW((queue<int>(max_size_bad_alloc)), std::bad_alloc); // Check enqueue NULL throwing BOOST_CHECK_THROW(queue<int>(1).enqueue(nullptr), std::invalid_argument); BOOST_CHECK_THROW(queue<int>(1).enqueue(nullptr, 1), std::invalid_argument); // Basic enqueue/dequeue { queue<int> q(1); BOOST_CHECK_EQUAL(q.count(), 0u); invariants_checker::check(q); auto p1 = new int(42); q.enqueue(p1); BOOST_CHECK_EQUAL(q.count(), 1u); invariants_checker::check(q); smart_ptr p2(q.dequeue()); BOOST_CHECK_EQUAL(q.count(), 0u); BOOST_CHECK_EQUAL(p1, p2.get()); invariants_checker::check(q); } // Enqueue/dequeue sequence { const int vals[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; const auto count = std::extent<decltype(vals)>::value; queue<int> q(count); for(auto i : vals) { q.enqueue(new int(i)); invariants_checker::check(q); } BOOST_CHECK_EQUAL(q.count(), count); invariants_checker::check(q); for(auto i = 0u; i < count; ++i) { smart_ptr p(q.dequeue()); BOOST_CHECK_EQUAL(*p, vals[i]); invariants_checker::check(q); } BOOST_CHECK_EQUAL(q.count(), 0u); invariants_checker::check(q); } // Queue cleanup on destruction const auto delete_count = 10u; { queue<delete_counter> q(delete_count); for(auto i = 0u; i < delete_count; ++i) { q.enqueue(new delete_counter()); } BOOST_CHECK_EQUAL(q.count(), delete_count); invariants_checker::check(q); delete_counter::count() = 0; } BOOST_CHECK_EQUAL(delete_counter::count(), delete_count); } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // High Load Test const auto high_load_item_count = 100500; /// Producer for checking high load work void high_load_producer(queue<int>& queue, std::atomic<bool>& producer_waits, barrier& wait_barrier) { for(auto i = 0; i < high_load_item_count; ++i) { queue.enqueue(new int(i)); // Make a "spontaneous" check inside a loop if(i != 0 && i % 7531 == 0) { producer_waits = true; invariants_checker::check(queue, &wait_barrier); } } } // Consumer for checking high load work void high_load_consumer(queue<int>& queue, std::atomic<bool>& producer_waits, barrier& wait_barrier) { for(auto i = 0; i < high_load_item_count; ++i) { std::unique_ptr<int> p(queue.dequeue()); BOOST_CHECK_EQUAL(*p, i); if(producer_waits) { producer_waits = false; invariants_checker::check(queue, &wait_barrier); } } } /// Tests shared queue under high load with producer and consumer threads BOOST_AUTO_TEST_CASE(test_queue_high_load) { const auto queue_size = 100u; queue<int> q(queue_size); std::atomic<bool> producer_waits; barrier wait_barrier(2); // Start producer first std::thread producer(high_load_producer, std::ref(q), std::ref(producer_waits), std::ref(wait_barrier)); // Give him a chance to fill the queue // TODO: delays aren't reliable, used for simplicity only. // Replace with correct synchronization! std::this_thread::sleep_for(std::chrono::milliseconds(100)); BOOST_CHECK_EQUAL(q.count(), queue_size); // Start consumer std::thread consumer(high_load_consumer, std::ref(q), std::ref(producer_waits), std::ref(wait_barrier)); // Wait while both producer and consumer are finished producer.join(); consumer.join(); BOOST_CHECK_EQUAL(q.count(), 0u); invariants_checker::check(q); } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Low Latency Empty Queue Test using clock = std_ex::high_resolution_clock; using time_point = std_ex::high_resolution_clock::time_point; /// Producer for checking low latency empty queue void low_latency_producer(queue<int>& queue, time_point& time_point) { BOOST_CHECK_EQUAL(queue.count(), 0u); auto p = new int(42); time_point = clock::now(); queue.enqueue(p); } /// Consumer for checking low latency empty queue void low_latency_consumer(queue<int>& queue, time_point& end_point, time_point& start_point) { BOOST_CHECK_EQUAL(queue.count(), 0u); start_point = clock::now(); const auto p = queue.dequeue(); end_point = clock::now(); delete p; } /// Runs Empty Queue Low Latency test once double run_queue_low_latency_test() { queue<int> q(1); // Start consumer first on empty queue, it will block and wait for producer. time_point consumer_start_point; time_point end_point; std::thread consumer(low_latency_consumer, std::ref(q), std::ref(end_point), std::ref(consumer_start_point)); // TODO: delays aren't reliable, used for simplicity only. // Replace with correct synchronization! std::this_thread::sleep_for(std::chrono::milliseconds(10)); // Start producer then time_point producer_start_point; std::thread producer(low_latency_producer, std::ref(q), std::ref(producer_start_point)); // Wait while both producer and consumer are finished. consumer.join(); producer.join(); BOOST_CHECK(consumer_start_point < producer_start_point); BOOST_CHECK_EQUAL(q.count(), 0u); invariants_checker::check(q); const std::chrono::duration<double, std::micro> period(end_point - producer_start_point); return period.count(); } /// Tests shared queue empty queue low latency metric with producer and consumer threads /// running them several times. Outputs to stdout min. max, median and average /// latency time in microsecs. BOOST_AUTO_TEST_CASE(test_queue_low_latency) { const auto maxRuns = 1000; std::vector<double> latency; latency.reserve(maxRuns); for(auto i = 0; i < maxRuns; ++i) { latency.push_back(run_queue_low_latency_test()); } if(latency.empty()) { BOOST_FAIL("No latencies recorded"); } std::sort(latency.begin(), latency.end()); std::cout << std::fixed << std::setprecision(2) << std::endl; std::cout << "Empty queue latency (min): " << latency.front() << " microseconds" << std::endl; const auto median = latency.size() / 2; const bool oddSize = latency.size() % 2 != 0; std::cout << "Empty queue latency (med): " << (oddSize ? latency[median] : (latency[median] + latency[median - 1]) / 2) << " microseconds" << std::endl; if(latency.size() > 2) { const auto avg = std::accumulate(latency.begin() + 1, latency.end() - 1, 0.0) / (latency.size() - 2); std::cout << "Empty queue latency (avg): " << avg << " microseconds" << std::endl; } std::cout << "Empty queue latency (max): " << latency.back() << " microseconds" << std::endl; } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Blocking Enqueue/Dequeue Timeout Expiration Test /// Tests shared queue timeout expiration BOOST_AUTO_TEST_CASE(test_queue_timeout_expiration) { using namespace std::chrono; const auto max_timeout = 1000; queue<int> q(1); // Test dequeueing with timeout for(auto i = 1; i <= max_timeout; i *= 10) { const auto start_point = clock::now(); const auto p = q.dequeue(i); const auto end_point = clock::now(); const auto timeout = duration_cast<milliseconds>(end_point - start_point); // Sometimes actual timeout can be a bit greater, ~1ms BOOST_CHECK(timeout.count() >= i); BOOST_CHECK(timeout.count() < i + 1); BOOST_CHECK(p == nullptr); invariants_checker::check(q); } BOOST_CHECK(q.enqueue(new int(66), 100)); std::unique_ptr<int> p(new int(42)); // Test enqueueing with timeout for(auto i = 1; i <= max_timeout; i *= 10) { const auto start_point = clock::now(); const auto res = q.enqueue(p.get(), i); const auto end_point = clock::now(); const auto timeout = duration_cast<milliseconds>(end_point - start_point); // Sometimes actual timeout can be a bit greater, ~1ms BOOST_CHECK(timeout.count() >= i); BOOST_CHECK(timeout.count() <= i + 1); BOOST_CHECK(*p == 42); BOOST_CHECK(!res); invariants_checker::check(q); } } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Reentrance Throwing Test /// Tests shared queue throwing on reentrance BOOST_AUTO_TEST_CASE(test_queue_reentrance) { queue<int> q(1); // Test dequeue reentrance // Start consumer 1 on empty queue, it would block std::thread consumer1([&](){ delete q.dequeue(); }); // Ensure consumer 1 is running and blocking // TODO: delays aren't reliable, used for simplicity only. // Replace with correct synchronization! std::this_thread::sleep_for(std::chrono::milliseconds(10)); // Start consumer 2 on empty queue, it would throw std::thread consumer2([&](){ BOOST_CHECK_THROW(q.dequeue(), std::runtime_error); }); // Ensure consumer 2 is running and throwing // TODO: delays aren't reliable, used for simplicity only. // Replace with correct synchronization! std::this_thread::sleep_for(std::chrono::milliseconds(10)); // Release consumer 1 thread q.enqueue(new int(42)); consumer1.join(); consumer2.join(); BOOST_CHECK_EQUAL(q.count(), 0u); invariants_checker::check(q); // Test enqueue reentrance q.enqueue(new int(66)); // Start producer 1 on full queue, it would block std::thread producer1([&](){ q.enqueue(new int(42)); }); // Ensure producer 1 is running and blocking // TODO: delays aren't reliable, used for simplicity only. // Replace with correct synchronization! std::this_thread::sleep_for(std::chrono::milliseconds(10)); // Start producer 2 on full queue, it would throw std::thread producer2( [&]() { std::unique_ptr<int> p(new int(42)); BOOST_CHECK_THROW(q.enqueue(p.get()), std::runtime_error); }); // Ensure producer 2 is running and throwing // TODO: delays aren't reliable, used for simplicity only. // Replace with correct synchronization! std::this_thread::sleep_for(std::chrono::milliseconds(10)); // Release producer 1 thread delete q.dequeue(); producer1.join(); producer2.join(); BOOST_CHECK_EQUAL(q.count(), 1u); invariants_checker::check(q); } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Throughput (ops/sec) Measuring Test static int dummy_obj = 42; // Dummy struct that will not envolve dynamic memory allocation. struct dummy_type { int dummy; void* operator new(size_t) { return &dummy_obj; } void operator delete(void*) { } }; /// Producer for checking throughput void throughput_producer(queue<dummy_type>& queue, std::atomic<bool>& stop, size_t& opCount, time_point& start, time_point& end) { start = clock::now(); for(;;) { queue.enqueue(new dummy_type()); ++opCount; if(opCount % 1000 == 0 && stop) { break; } } end = clock::now(); } // Consumer for checking throughput void throughput_consumer(queue<dummy_type>& queue, std::atomic<bool>& stop, size_t& opCount, time_point& start, time_point& end) { start = clock::now(); for(;;) { queue.dequeue(); ++opCount; if(opCount % 1000 == 0 && stop) { break; } } end = clock::now(); } /// Tests shared queue throughput BOOST_AUTO_TEST_CASE(test_queue_throughput) { using namespace std::chrono; queue<dummy_type> q(1000); std::atomic<bool> stop; size_t enq_count = 0; size_t deq_count = 0; time_point producer_start; time_point producer_end; time_point consumer_start; time_point consumer_end; // Start producer std::thread producer(throughput_producer, std::ref(q), std::ref(stop), std::ref(enq_count), std::ref(producer_start), std::ref(producer_end)); // Start consumer std::thread consumer(throughput_consumer, std::ref(q), std::ref(stop), std::ref(deq_count), std::ref(consumer_start), std::ref(consumer_end)); // TODO: delays aren't reliable, used for simplicity only. // Replace with correct synchronization! std::this_thread::sleep_for(std::chrono::seconds(1)); stop = true; // Wait while both producer and consumer are finished. producer.join(); consumer.join(); const std::chrono::duration<double, std::milli> prod_time(producer_end - producer_start); const std::chrono::duration<double, std::milli> cons_time(consumer_end - consumer_start); const auto in_throughput = double(enq_count) / prod_time.count() * 1000.0; const auto out_throughput = double(deq_count) / cons_time.count() * 1000.0; invariants_checker::check(q); std::cout << std::fixed << std::setprecision(2) << std::endl; std::cout << "Queue input throughput: " << in_throughput << " ops/sec" << std::endl; std::cout << "Queue output throughput: " << out_throughput << " ops/sec" << std::endl; } } // namespace queue_ut } // namespace spsc } // namespace xcon
-- Andreas, 2020-09-26, issue #4946. -- More liberal type signatures for constructors of sized types. -- {-# OPTIONS -v tc.polarity:20 #-} open import Agda.Builtin.Size variable i : Size A : Set data T : Size → Set → Set where c : A → T i A → T (↑ i) A -- The type of the constructor c is elaborated to -- -- c : {A : Set} {i : Set} → A → T i A → T (↑ i) A -- -- Thus, the size argument i is not the first. -- Nevertheless, Agda recognize the first argument of T -- as covariant. test : T i A → T ∞ A test x = x -- Should pass.
import Data.Vect import Data.Fin -- %default total -- WHY NOT ? -- Possible types data Ty = TyInt | TyBool | TyFun Ty Ty -- Types interpreted in idris interpTy : Ty -> Type interpTy TyInt = Integer interpTy TyBool = Bool interpTy (TyFun A T) = interpTy A -> interpTy T using (G:Vect n Ty) -- the context data Expr : Vect n Ty -> Ty -> Type -- local vars Type -> Expr Type -- Representation of expressions data HasType : (i : Fin n) -> Vect n Ty -> Ty -> Type where Stop : HasType FZ (t :: G) t Pop : HasType k G t -> HasType (FS k) (u :: G) t data Expr : Vect n Ty -> Ty -> Type where Var : HasType i G t -> Expr G t Val : (x : Integer) -> Expr G TyInt Lam : Expr (a :: G) t -> Expr G (TyFun a t) App : Expr G (TyFun a t) -> Expr G a -> Expr G t Op : (interpTy a -> interpTy b -> interpTy c) -> Expr G a -> Expr G b -> Expr G c If : Expr G TyBool -> Lazy (Expr G a) -> Lazy (Expr G a) -> Expr G a data Env : Vect n Ty -> Type where Nil : Env Nil (::) : interpTy a -> Env G -> Env (a :: G) lookup : HasType i G t -> Env G -> interpTy t lookup Stop (x :: xs) = x lookup (Pop k) (x :: xs) = lookup k xs interp : Env G -> Expr G t -> interpTy t interp env (Var i) = lookup i env interp env (Val x) = x interp env (Lam sc) = \x => interp (x :: env) sc interp env (App f s) = interp env f (interp env s) interp env (Op op x y) = op (interp env x) (interp env y) interp env (If x t e) = if interp env x then interp env t else interp env e add : Expr G (TyFun TyInt (TyFun TyInt TyInt)) add = Lam (Lam (Op (+) (Var Stop) (Var (Pop Stop)))) fact : Expr G (TyFun TyInt TyInt) fact = Lam (If (Op (==) (Var Stop) (Val 0)) (Val 1) (Op (*) (App fact (Op (-) (Var Stop) (Val 1))) (Var Stop))) partial main : IO () main = do putStr "Enter a number: " x <- getLine printLn (interp [] fact (cast x))
#ifndef NETKET_COMMON_TYPES_HPP #define NETKET_COMMON_TYPES_HPP /** * This header contains standard type aliases to be used throughout the NetKet * codebase. */ #include <complex> #include <cstddef> #include <Eigen/Core> namespace netket { using Index = std::ptrdiff_t; using Complex = std::complex<double>; using VectorXd = Eigen::VectorXd; using VectorXcd = Eigen::VectorXcd; template <class T> using Matrix = Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>; using MatrixXd = Matrix<double>; using MatrixXcd = Matrix<Complex>; template <class T> using RowMatrix = Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>; using RowMatrixXd = RowMatrix<double>; using RowMatrixXcd = RowMatrix<Complex>; } // namespace netket #endif // NETKET_COMMON_TYPES_HPP
This entry was posted on Sunday, February 11th, 2018 at 9:00 pm and is filed under Festivals, Information. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.
/- Copyright (c) 2018 Mario Carneiro. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mario Carneiro Evaluate expressions in the language of (semi-)rings. Based on http://www.cs.ru.nl/~freek/courses/tt-2014/read/10.1.1.61.3041.pdf . -/ import algebra.group_power tactic.norm_num import tactic.converter.interactive namespace tactic namespace ring def horner {α} [comm_semiring α] (a x : α) (n : ℕ) (b : α) := a * x ^ n + b meta structure cache := (α : expr) (univ : level) (comm_semiring_inst : expr) meta def mk_cache (e : expr) : tactic cache := do α ← infer_type e, c ← mk_app ``comm_semiring [α] >>= mk_instance, u ← mk_meta_univ, infer_type α >>= unify (expr.sort (level.succ u)), u ← get_univ_assignment u, return ⟨α, u, c⟩ meta def cache.cs_app (c : cache) (n : name) : list expr → expr := (@expr.const tt n [c.univ] c.α c.comm_semiring_inst).mk_app meta def cache.mk_app (c : cache) (n inst : name) (l : list expr) : tactic expr := do m ← mk_instance ((expr.const inst [c.univ] : expr) c.α), return $ (@expr.const tt n [c.univ] c.α m).mk_app l meta inductive horner_expr : Type | const (e : expr) : horner_expr | xadd (e : expr) (a : horner_expr) (x : expr) (n : expr × ℕ) (b : horner_expr) : horner_expr meta def horner_expr.e : horner_expr → expr | (horner_expr.const e) := e | (horner_expr.xadd e _ _ _ _) := e meta instance : has_coe horner_expr expr := ⟨horner_expr.e⟩ meta def horner_expr.xadd' (c : cache) (a : horner_expr) (x : expr) (n : expr × ℕ) (b : horner_expr): horner_expr := horner_expr.xadd (c.cs_app ``horner [a, x, n.1, b]) a x n b open horner_expr meta def horner_expr.to_string : horner_expr → string | (const e) := to_string e | (xadd e a x (_, n) b) := "(" ++ a.to_string ++ ") * (" ++ to_string x ++ ")^" ++ to_string n ++ " + " ++ b.to_string meta def horner_expr.pp : horner_expr → tactic format | (const e) := pp e | (xadd e a x (_, n) b) := do pa ← a.pp, pb ← b.pp, px ← pp x, return $ "(" ++ pa ++ ") * (" ++ px ++ ")^" ++ to_string n ++ " + " ++ pb meta instance : has_to_tactic_format horner_expr := ⟨horner_expr.pp⟩ meta def horner_expr.refl_conv (e : horner_expr) : tactic (horner_expr × expr) := do p ← mk_eq_refl e, return (e, p) theorem zero_horner {α} [comm_semiring α] (x n b) : @horner α _ 0 x n b = b := by simp [horner] theorem horner_horner {α} [comm_semiring α] (a₁ x n₁ n₂ b n') (h : n₁ + n₂ = n') : @horner α _ (horner a₁ x n₁ 0) x n₂ b = horner a₁ x n' b := by simp [h.symm, horner, pow_add, mul_assoc] meta def eval_horner (c : cache) : horner_expr → expr → expr × ℕ → horner_expr → tactic (horner_expr × expr) | ha@(const a) x n b := if a.to_nat = some 0 then return (b, c.cs_app ``zero_horner [x, n.1, b]) else (xadd' c ha x n b).refl_conv | ha@(xadd a a₁ x₁ n₁ b₁) x n b := if x₁ = x ∧ b₁.e.to_nat = some 0 then do (n', h) ← mk_app ``has_add.add [n₁.1, n.1] >>= norm_num, return (xadd' c a₁ x (n', n₁.2 + n.2) b, c.cs_app ``horner_horner [a₁, x, n₁.1, n.1, b, n', h]) else (xadd' c ha x n b).refl_conv theorem const_add_horner {α} [comm_semiring α] (k a x n b b') (h : k + b = b') : k + @horner α _ a x n b = horner a x n b' := by simp [h.symm, horner] theorem horner_add_const {α} [comm_semiring α] (a x n b k b') (h : b + k = b') : @horner α _ a x n b + k = horner a x n b' := by simp [h.symm, horner] theorem horner_add_horner_lt {α} [comm_semiring α] (a₁ x n₁ b₁ a₂ n₂ b₂ k a' b') (h₁ : n₁ + k = n₂) (h₂ : (a₁ + horner a₂ x k 0 : α) = a') (h₃ : b₁ + b₂ = b') : @horner α _ a₁ x n₁ b₁ + horner a₂ x n₂ b₂ = horner a' x n₁ b' := by simp [h₂.symm, h₃.symm, h₁.symm, horner, pow_add, mul_add, mul_comm, mul_left_comm] theorem horner_add_horner_gt {α} [comm_semiring α] (a₁ x n₁ b₁ a₂ n₂ b₂ k a' b') (h₁ : n₂ + k = n₁) (h₂ : (horner a₁ x k 0 + a₂ : α) = a') (h₃ : b₁ + b₂ = b') : @horner α _ a₁ x n₁ b₁ + horner a₂ x n₂ b₂ = horner a' x n₂ b' := by simp [h₂.symm, h₃.symm, h₁.symm, horner, pow_add, mul_add, mul_comm, mul_left_comm] theorem horner_add_horner_eq {α} [comm_semiring α] (a₁ x n b₁ a₂ b₂ a' b' t) (h₁ : a₁ + a₂ = a') (h₂ : b₁ + b₂ = b') (h₃ : horner a' x n b' = t) : @horner α _ a₁ x n b₁ + horner a₂ x n b₂ = t := by simp [h₃.symm, h₂.symm, h₁.symm, horner, add_mul, mul_comm] meta def eval_add (c : cache) : horner_expr → horner_expr → tactic (horner_expr × expr) | (const e₁) (const e₂) := do (e, p) ← mk_app ``has_add.add [e₁, e₂] >>= norm_num, return (const e, p) | he₁@(const e₁) he₂@(xadd e₂ a x n b) := if e₁.to_nat = some 0 then do p ← mk_app ``zero_add [e₂], return (he₂, p) else do (b', h) ← eval_add he₁ b, return (xadd' c a x n b', c.cs_app ``const_add_horner [e₁, a, x, n.1, b, b', h]) | he₁@(xadd e₁ a x n b) he₂@(const e₂) := if e₂.to_nat = some 0 then do p ← mk_app ``add_zero [e₁], return (he₁, p) else do (b', h) ← eval_add b he₂, return (xadd' c a x n b', c.cs_app ``horner_add_const [a, x, n.1, b, e₂, b', h]) | he₁@(xadd e₁ a₁ x₁ n₁ b₁) he₂@(xadd e₂ a₂ x₂ n₂ b₂) := if expr.lex_lt x₁ x₂ then do (b', h) ← eval_add b₁ he₂, return (xadd' c a₁ x₁ n₁ b', c.cs_app ``horner_add_const [a₁, x₁, n₁.1, b₁, e₂, b', h]) else if x₁ ≠ x₂ then do (b', h) ← eval_add he₁ b₂, return (xadd' c a₂ x₂ n₂ b', c.cs_app ``const_add_horner [e₁, a₂, x₂, n₂.1, b₂, b', h]) else if n₁.2 < n₂.2 then do let k := n₂.2 - n₁.2, ek ← expr.of_nat (expr.const `nat []) k, (_, h₁) ← mk_app ``has_add.add [n₁.1, ek] >>= norm_num, α0 ← expr.of_nat c.α 0, (a', h₂) ← eval_add a₁ (xadd' c a₂ x₁ (ek, k) (const α0)), (b', h₃) ← eval_add b₁ b₂, return (xadd' c a' x₁ n₁ b', c.cs_app ``horner_add_horner_lt [a₁, x₁, n₁.1, b₁, a₂, n₂.1, b₂, ek, a', b', h₁, h₂, h₃]) else if n₁ ≠ n₂ then do let k := n₁.2 - n₂.2, ek ← expr.of_nat (expr.const `nat []) k, (_, h₁) ← mk_app ``has_add.add [n₂.1, ek] >>= norm_num, α0 ← expr.of_nat c.α 0, (a', h₂) ← eval_add (xadd' c a₁ x₁ (ek, k) (const α0)) a₂, (b', h₃) ← eval_add b₁ b₂, return (xadd' c a' x₁ n₂ b', c.cs_app ``horner_add_horner_gt [a₁, x₁, n₁.1, b₁, a₂, n₂.1, b₂, ek, a', b', h₁, h₂, h₃]) else do (a', h₁) ← eval_add a₁ a₂, (b', h₂) ← eval_add b₁ b₂, (t, h₃) ← eval_horner c a' x₁ n₁ b', return (t, c.cs_app ``horner_add_horner_eq [a₁, x₁, n₁.1, b₁, a₂, b₂, a', b', t, h₁, h₂, h₃]) theorem horner_neg {α} [comm_ring α] (a x n b a' b') (h₁ : -a = a') (h₂ : -b = b') : -@horner α _ a x n b = horner a' x n b' := by simp [h₂.symm, h₁.symm, horner] meta def eval_neg (c : cache) : horner_expr → tactic (horner_expr × expr) | (const e) := do (e', p) ← mk_app ``has_neg.neg [e] >>= norm_num, return (const e', p) | (xadd e a x n b) := do (a', h₁) ← eval_neg a, (b', h₂) ← eval_neg b, p ← c.mk_app ``horner_neg ``comm_ring [a, x, n.1, b, a', b', h₁, h₂], return (xadd' c a' x n b', p) theorem horner_const_mul {α} [comm_semiring α] (c a x n b a' b') (h₁ : c * a = a') (h₂ : c * b = b') : c * @horner α _ a x n b = horner a' x n b' := by simp [h₂.symm, h₁.symm, horner, mul_add, mul_assoc] theorem horner_mul_const {α} [comm_semiring α] (a x n b c a' b') (h₁ : a * c = a') (h₂ : b * c = b') : @horner α _ a x n b * c = horner a' x n b' := by simp [h₂.symm, h₁.symm, horner, add_mul, mul_right_comm] meta def eval_const_mul (c : cache) (k : expr) : horner_expr → tactic (horner_expr × expr) | (const e) := do (e', p) ← mk_app ``has_mul.mul [k, e] >>= norm_num, return (const e', p) | (xadd e a x n b) := do (a', h₁) ← eval_const_mul a, (b', h₂) ← eval_const_mul b, return (xadd' c a' x n b', c.cs_app ``horner_const_mul [k, a, x, n.1, b, a', b', h₁, h₂]) theorem horner_mul_horner_zero {α} [comm_semiring α] (a₁ x n₁ b₁ a₂ n₂ aa t) (h₁ : @horner α _ a₁ x n₁ b₁ * a₂ = aa) (h₂ : horner aa x n₂ 0 = t) : horner a₁ x n₁ b₁ * horner a₂ x n₂ 0 = t := by rw [← h₂, ← h₁]; simp [horner, mul_add, mul_comm, mul_left_comm, mul_assoc] theorem horner_mul_horner {α} [comm_semiring α] (a₁ x n₁ b₁ a₂ n₂ b₂ aa haa ab bb t) (h₁ : @horner α _ a₁ x n₁ b₁ * a₂ = aa) (h₂ : horner aa x n₂ 0 = haa) (h₃ : a₁ * b₂ = ab) (h₄ : b₁ * b₂ = bb) (H : haa + horner ab x n₁ bb = t) : horner a₁ x n₁ b₁ * horner a₂ x n₂ b₂ = t := by rw [← H, ← h₂, ← h₁, ← h₃, ← h₄]; simp [horner, mul_add, mul_comm, mul_left_comm, mul_assoc] meta def eval_mul (c : cache) : horner_expr → horner_expr → tactic (horner_expr × expr) | (const e₁) (const e₂) := do (e', p) ← mk_app ``has_mul.mul [e₁, e₂] >>= norm_num, return (const e', p) | (const e₁) e₂ := match e₁.to_nat with | (some 0) := do α0 ← expr.of_nat c.α 0, p ← mk_app ``zero_mul [e₂], return (const α0, p) | (some 1) := do p ← mk_app ``one_mul [e₂], return (e₂, p) | _ := eval_const_mul c e₁ e₂ end | e₁ he₂@(const e₂) := do p₁ ← mk_app ``mul_comm [e₁, e₂], (e', p₂) ← eval_mul he₂ e₁, p ← mk_eq_trans p₁ p₂, return (e', p) | he₁@(xadd e₁ a₁ x₁ n₁ b₁) he₂@(xadd e₂ a₂ x₂ n₂ b₂) := if expr.lex_lt x₁ x₂ then do (a', h₁) ← eval_mul a₁ he₂, (b', h₂) ← eval_mul b₁ he₂, return (xadd' c a' x₁ n₁ b', c.cs_app ``horner_mul_const [a₁, x₁, n₁.1, b₁, e₂, a', b', h₁, h₂]) else if x₁ ≠ x₂ then do (a', h₁) ← eval_mul he₁ a₂, (b', h₂) ← eval_mul he₁ b₂, return (xadd' c a' x₂ n₂ b', c.cs_app ``horner_const_mul [e₁, a₂, x₂, n₂.1, b₂, a', b', h₁, h₂]) else do (aa, h₁) ← eval_mul he₁ a₂, α0 ← expr.of_nat c.α 0, (haa, h₂) ← eval_horner c aa x₁ n₂ (const α0), if b₂.e.to_nat = some 0 then return (haa, c.cs_app ``horner_mul_horner_zero [a₁, x₁, n₁.1, b₁, a₂, n₂.1, aa, haa, h₁, h₂]) else do (ab, h₃) ← eval_mul a₁ b₂, (bb, h₄) ← eval_mul b₁ b₂, (t, H) ← eval_add c haa (xadd' c ab x₁ n₁ bb), return (t, c.cs_app ``horner_mul_horner [a₁, x₁, n₁.1, b₁, a₂, n₂.1, b₂, aa, haa, ab, bb, t, h₁, h₂, h₃, h₄, H]) theorem horner_pow {α} [comm_semiring α] (a x n m n' a') (h₁ : n * m = n') (h₂ : a ^ m = a') : @horner α _ a x n 0 ^ m = horner a' x n' 0 := by simp [h₁.symm, h₂.symm, horner, mul_pow, pow_mul] meta def eval_pow (c : cache) : horner_expr → expr × ℕ → tactic (horner_expr × expr) | e (_, 0) := do α1 ← expr.of_nat c.α 1, p ← mk_app ``pow_zero [e], return (const α1, p) | e (_, 1) := do p ← mk_app ``pow_one [e], return (e, p) | (const e) (e₂, m) := do (e', p) ← mk_app ``monoid.pow [e, e₂] >>= norm_num.derive, return (const e', p) | he@(xadd e a x n b) m := let N : expr := expr.const `nat [] in match b.e.to_nat with | some 0 := do (n', h₁) ← mk_app ``has_mul.mul [n.1, m.1] >>= norm_num, (a', h₂) ← eval_pow a m, α0 ← expr.of_nat c.α 0, return (xadd' c a' x (n', n.2 * m.2) (const α0), c.cs_app ``horner_pow [a, x, n.1, m.1, n', a', h₁, h₂]) | _ := do e₂ ← expr.of_nat N (m.2-1), l ← mk_app ``monoid.pow [e, e₂], (tl, hl) ← eval_pow he (e₂, m.2-1), (t, p₂) ← eval_mul c tl he, hr ← mk_eq_refl e, p₂ ← c.mk_app ``norm_num.subst_into_prod ``has_mul [l, e, tl, e, t, hl, hr, p₂], p₁ ← mk_app ``pow_succ' [e, e₂], p ← mk_eq_trans p₁ p₂, return (t, p) end theorem horner_atom {α} [comm_semiring α] (x : α) : x = horner 1 x 1 0 := by simp [horner] meta def eval_atom (c : cache) (e : expr) : tactic (horner_expr × expr) := do α0 ← expr.of_nat c.α 0, α1 ← expr.of_nat c.α 1, n1 ← expr.of_nat (expr.const `nat []) 1, return (xadd' c (const α1) e (n1, 1) (const α0), c.cs_app ``horner_atom [e]) lemma subst_into_pow {α} [monoid α] (l r tl tr t) (prl : (l : α) = tl) (prr : (r : ℕ) = tr) (prt : tl ^ tr = t) : l ^ r = t := by simp [prl, prr, prt] lemma unfold_sub {α} [add_group α] (a b c : α) (h : a + -b = c) : a - b = c := h lemma unfold_div {α} [division_ring α] (a b c : α) (h : a * b⁻¹ = c) : a / b = c := h meta def eval (c : cache) : expr → tactic (horner_expr × expr) | `(%%e₁ + %%e₂) := do (e₁', p₁) ← eval e₁, (e₂', p₂) ← eval e₂, (e', p') ← eval_add c e₁' e₂', p ← c.mk_app ``norm_num.subst_into_sum ``has_add [e₁, e₂, e₁', e₂', e', p₁, p₂, p'], return (e', p) | `(%%e₁ - %%e₂) := do e₂' ← mk_app ``has_neg.neg [e₂], e ← mk_app ``has_add.add [e₁, e₂'], (e', p) ← eval e, p' ← c.mk_app ``unfold_sub ``add_group [e₁, e₂, e', p], return (e', p') | `(- %%e) := do (e₁, p₁) ← eval e, (e₂, p₂) ← eval_neg c e₁, p ← c.mk_app ``norm_num.subst_into_neg ``has_neg [e, e₁, e₂, p₁, p₂], return (e₂, p) | `(%%e₁ * %%e₂) := do (e₁', p₁) ← eval e₁, (e₂', p₂) ← eval e₂, (e', p') ← eval_mul c e₁' e₂', p ← c.mk_app ``norm_num.subst_into_prod ``has_mul [e₁, e₂, e₁', e₂', e', p₁, p₂, p'], return (e', p) | e@`(has_inv.inv %%_) := (do (e', p) ← norm_num.derive e, e'.to_rat, return (const e', p)) <|> eval_atom c e | `(%%e₁ / %%e₂) := do e₂' ← mk_app ``has_inv.inv [e₂], e ← mk_app ``has_mul.mul [e₁, e₂'], (e', p) ← eval e, p' ← c.mk_app ``unfold_div ``division_ring [e₁, e₂, e', p], return (e', p') | e@`(@has_pow.pow _ _ %%P %%e₁ %%e₂) := do (e₂', p₂) ← eval e₂, match e₂'.e.to_nat, P with | some k, `(monoid.has_pow) := do (e₁', p₁) ← eval e₁, (e', p') ← eval_pow c e₁' (e₂, k), p ← c.mk_app ``subst_into_pow ``monoid [e₁, e₂, e₁', e₂', e', p₁, p₂, p'], return (e', p) | some k, `(nat.has_pow) := do (e₁', p₁) ← eval e₁, (e', p') ← eval_pow c e₁' (e₂, k), p₃ ← c.mk_app ``subst_into_pow ``monoid [e₁, e₂, e₁', e₂', e', p₁, p₂, p'], p₄ ← mk_app ``nat.pow_eq_pow [e₁, e₂] >>= mk_eq_symm, p ← mk_eq_trans p₄ p₃, return (e', p) | _, _ := eval_atom c e end | e := match e.to_nat with | some n := (const e).refl_conv | none := eval_atom c e end meta def eval' (c : cache) (e : expr) : tactic (expr × expr) := do (e', p) ← eval c e, return (e', p) theorem horner_def' {α} [comm_semiring α] (a x n b) : @horner α _ a x n b = x ^ n * a + b := by simp [horner, mul_comm] theorem mul_assoc_rev {α} [semigroup α] (a b c : α) : a * (b * c) = a * b * c := by simp [mul_assoc] theorem pow_add_rev {α} [monoid α] (a b : α) (m n : ℕ) : a ^ m * a ^ n = a ^ (m + n) := by simp [pow_add] theorem pow_add_rev_right {α} [monoid α] (a b : α) (m n : ℕ) : b * a ^ m * a ^ n = b * a ^ (m + n) := by simp [pow_add, mul_assoc] theorem add_neg_eq_sub {α} [add_group α] (a b : α) : a + -b = a - b := rfl @[derive has_reflect] inductive normalize_mode | raw | SOP | horner meta def normalize (mode := normalize_mode.horner) (e : expr) : tactic (expr × expr) := do pow_lemma ← simp_lemmas.mk.add_simp ``pow_one, let lemmas := match mode with | normalize_mode.SOP := [``horner_def', ``add_zero, ``mul_one, ``mul_add, ``mul_sub, ``mul_assoc_rev, ``pow_add_rev, ``pow_add_rev_right, ``mul_neg_eq_neg_mul_symm, ``add_neg_eq_sub] | normalize_mode.horner := [``horner.equations._eqn_1, ``add_zero, ``one_mul, ``pow_one, ``neg_mul_eq_neg_mul_symm, ``add_neg_eq_sub] | _ := [] end, lemmas ← lemmas.mfoldl simp_lemmas.add_simp simp_lemmas.mk, (_, e', pr) ← ext_simplify_core () {} simp_lemmas.mk (λ _, failed) (λ _ _ _ _ e, do c ← mk_cache e, (new_e, pr) ← match mode with | normalize_mode.raw := eval' c | normalize_mode.horner := trans_conv (eval' c) (simplify lemmas []) | normalize_mode.SOP := trans_conv (eval' c) $ trans_conv (simplify lemmas []) $ simp_bottom_up' (λ e, norm_num e <|> pow_lemma.rewrite e) end e, guard (¬ new_e =ₐ e), return ((), new_e, some pr, ff)) (λ _ _ _ _ _, failed) `eq e, return (e', pr) end ring namespace interactive open interactive interactive.types lean.parser open tactic.ring local postfix `?`:9001 := optional /-- Tactic for solving equations in the language of rings. This version of `ring` fails if the target is not an equality that is provable by the axioms of commutative (semi)rings. -/ meta def ring1 : tactic unit := do `(%%e₁ = %%e₂) ← target, c ← mk_cache e₁, (e₁', p₁) ← eval c e₁, (e₂', p₂) ← eval c e₂, is_def_eq e₁' e₂', p ← mk_eq_symm p₂ >>= mk_eq_trans p₁, tactic.exact p meta def ring.mode : lean.parser ring.normalize_mode := with_desc "(SOP|raw|horner)?" $ do mode ← ident?, match mode with | none := return ring.normalize_mode.horner | some `horner := return ring.normalize_mode.horner | some `SOP := return ring.normalize_mode.SOP | some `raw := return ring.normalize_mode.raw | _ := failed end /-- Tactic for solving equations in the language of rings. Attempts to prove the goal outright if there is no `at` specifier and the target is an equality, but if this fails it falls back to rewriting all ring expressions into a normal form. When writing a normal form, `ring SOP` will use sum-of-products form instead of horner form. -/ meta def ring (SOP : parse ring.mode) (loc : parse location) : tactic unit := match loc with | interactive.loc.ns [none] := ring1 | _ := failed end <|> do ns ← loc.get_locals, tt ← tactic.replace_at (normalize SOP) ns loc.include_goal | fail "ring failed to simplify", when loc.include_goal $ try tactic.reflexivity end interactive end tactic namespace conv.interactive open conv interactive open tactic tactic.interactive (ring.mode ring1) open tactic.ring (normalize) meta def ring (SOP : parse ring.mode) : conv unit := discharge_eq_lhs ring1 <|> replace_lhs (normalize SOP) <|> fail "ring failed to simplify" end conv.interactive
# What is the % odorant vapor in the air stream, as a function of odorant properties, jar dimensions, and air flow rate? A cynlindrical jar with cross-sectional area $A$ and height $h$ contains a volume $V_{sol}$ of odorant solution (diluted in a solvent with zero vapor pressure), and the remaining volume, above the solution, is called $V_{head}$. The flow rate of air into the jar, in mol/s, is $r_{air,in}$. The gas flow out of the jar consists of the air component $r_{air, out}$ and the odorant component $r_{odor, out}$, also in mol/s. The interface between the solution and the jar headspace has odorant molecules leaving with rate $r_{evap}$ and molecules condensing at rate $r_{condense}$, also in mol/s. Therefore, the amount of odorant $n_o$ (in moles) in the jar headspace evolves according to: \begin{equation} \tag{1}\frac{dn_{odor}}{dt} = r_{evap} - r_{condense} - r_{odor, out} \end{equation} And the amount of air $n_{air}$ in the jar headspace evolves according to: \begin{equation} \tag{2}\frac{dn_{air}}{dt} = r_{air,in} - r_{air, out} \end{equation} Assuming that mixing with odorant vapor in the jar is instantaneous. Then the ratio of odorant efflux out of the jar to air efflux out of the jar is equal to the ratio of odor to air in the headspace of the jar at that moment. \begin{equation} \tag{3}\frac{n_{odor}}{n_{air}} = \frac{r_{odor,out}}{r_{air, out}} \end{equation} If evaporation is slow compared to the flow rate, we can assume that: \begin{equation} \tag{4}r_{air,in} = r_{air,out} + r_{odor, out} \end{equation} Combining equations 3 and 4 gives: $$r_{odor,out} = r_{air,out}\frac{n_{odor}}{n_{air}} = (r_{air,in} - r_{odor, out})\frac{n_{odor}}{n_{air}}$$ $$r_{odor,out}(1+\frac{n_{odor}}{n_{air}}) = r_{air,in}\frac{n_{odor}}{n_{air}}$$ \begin{equation} \tag{5}r_{odor,out} = \frac{r_{air,in}n_{odor}}{n_{air}+n_{odor}} \end{equation} And lastly, if both odorant and air are ideal gases, and air flow does not substantially change pressure in the jar, then the combined air and gas molecules fill the headspace at room temperature and ambient pressure according to: \begin{equation} \tag{6}n_{odor} + n_{air} = \frac{P_{room}V_{head}}{RT_{room}} \sim \frac{V_{head}}{22.4 Liters} \end{equation} Substituting (6) into (5) gives: \begin{equation} \tag{7}r_{odor, out} = \frac{r_{air,in}n_{odor}RT_{room}}{P_{room}V_{head}} \end{equation} The evaporation rate is assumed to be indepedent of time, depending (through a function $F_{evap}$ obtained empirically and described later) only upon the partial pressure $P^*_o$ of the liquid odorant, and the surface area $A$ of the liquid-vapor interface, where the partial pressure is equal to the mole fraction $f_o$ of the odorant in the liquid times its intrinsic vapor pressure $P_o$ (at this temperature), according to Raoult's law. \begin{equation} \tag{8}r_{evap} = F_{evap}(P^*_{odor})A \end{equation} \begin{equation} \tag{9}P^*_{odor} = P_{odor}f_{odor} \end{equation} Meanwhile, the condensation rate depends upon the molar concentration C_o of odorant vapor in the headspace and the headspace volume according to a constant $k_{condense}$: \begin{equation} \tag{10}r_{condense} = k_{condense}AC_{odor} \end{equation} \begin{equation} \tag{11}C_{odor} = n_{odor}/V_{head} \end{equation} Substituting (7-11) back into equation (1) gives a first order, linear differential equation in $n_{odor}$: $$\frac{dn_{odor}}{dt} = F_{evap}(P_{odor},f_{odor})A - \frac{k_{condense}An_{odor}}{V_{head}} - \frac{r_{air,in}n_{odor}RT_{room}}{P_{room}V_{head}}$$ \begin{equation} \tag{12}\frac{dn_{odor}}{dt} = F_{evap}(P_{odor},f_{odor})A - n_{odor}(\frac{1}{V_{head}}(k_{condense}A + \frac{r_{air,in}RT_{room}}{P_{room}})) \end{equation} We can define: \begin{equation} \tag{13}u = \frac{1}{V_{head}}(k_{condense}A + \frac{r_{air,in}RT_{room}}{P_{room}}) \end{equation} and if the headspace volume changes very slowly, we can assume that this is independent of time. The integrating factor is: \begin{equation} e^{\int{u}dt} = e^{ut}\tag{14} \end{equation} The canonical solution to (12) is thus: \begin{equation} \tag{15}n_{odor}(t) = e^{-ut}(\int{e^{ut}F_{evap}(P_{odor},f_{odor})Adt} + constant) \end{equation} Integrating gives: \begin{equation} n_{odor}(t) = \frac{F_{evap}(P_{odor},f_{odor})A}{u} + constant*e^{-ut}\tag{16} \end{equation} At steady state flow ($t = \infty$), the number of odorant molecules in the headspace is proportional to the evaporation function $F_{evap}$, which depends on the vapor pressure of the odorant, its mole fraction in solution, and the surface area of the liquid-vapor interface). The number of odorant molecules in the headspace is inversely proportional to $u$, which includes a weighted sum of the condensation rate constant and the air inflow rate. \begin{equation} \tag{17} n_{odor}(t=\infty) = \frac{F_{evap}(P_{odor},f_{odor})A}{u} \end{equation} At the starting time ($t=0$), we will assume that the jar is already in equilibrium, and the number of odorant molecules in the headspace is determined by the odorant's partial pressure: \begin{equation} \tag{18} n_{odor}(t=0) = \frac{P_{odor}f_{odor}V_{head}}{RT_{room}} = \frac{F_{evap}(P_{odor},f_{odor})A}{u} + constant \end{equation} So the constant is equal to: \begin{equation} \tag{19} constant = \frac{P_{odor}f_{odor}V_{head}}{RT_{room}} - \frac{F_{evap}(P_{odor},f_{odor})A}{u} \end{equation} Substituting back into (16) gives: \begin{equation} n_{odor}(t) = \frac{F_{evap}(P_{odor},f_{odor})A}{u} + (\frac{P_{odor}f_{odor}V_{head}}{RT_{room}} - \frac{F_{evap}(P_{odor},f_{odor})A}{u})*e^{-ut}\tag{20} \end{equation} And substituting (13) into (20) gives: \begin{equation} n_{odor}(t) = \frac{V_{head}F_{evap}(P_{odor},f_{odor})A}{(k_{condense}A + \frac{r_{air,in}RT_{room}}{P_{room}})} + (\frac{P_{odor}f_{odor}V_{head}}{RT_{room}} - \frac{V_{head}F_{evap}(P_{odor},f_{odor})A}{(k_{condense}A + \frac{r_{air,in}RT_{room}}{P_{room}})})*e^{-(\frac{1}{V_{head}}(k_{condense}A + \frac{r_{air,in}RT_{room}}{P_{room}}))t}\tag{21} \end{equation} Subsituting (21) into (5) gives: \begin{equation} \frac{r_{odor,out}}{r_{air,in}} = \frac{\frac{V_{head}F_{evap}(P_{odor},f_{odor})A}{(k_{condense}A + \frac{r_{air,in}RT_{room}}{P_{room}})} + (\frac{P_{odor}f_{odor}V_{head}}{RT_{room}} - \frac{V_{head}F_{evap}(P_{odor},f_{odor})A}{(k_{condense}A + \frac{r_{air,in}RT_{room}}{P_{room}})})*e^{-(\frac{1}{V_{head}}(k_{condense}A + \frac{r_{air,in}RT_{room}}{P_{room}}))t}}{\frac{P_{room}V_{head}}{RT_{room}}} \end{equation} \begin{equation} \tag{22} \frac{r_{odor,out}}{r_{air,in}} = \frac{F_{evap}(P_{odor},f_{odor})}{(\frac{k_{condense}P_{room}}{RT_{room}} + \frac{r_{air,in}}{A})} + (\frac{P_{odor}f_{odor}}{P_{room}} - \frac{F_{evap}(P_{odor},f_{odor})}{(\frac{k_{condense}P_{room}}{RT_{room}} + \frac{r_{air,in}}{A})})*e^{-(\frac{1}{V_{head}}(k_{condense}A + \frac{r_{air,in}RT_{room}}{P_{room}}))t} \end{equation} The evaporation rate $F_{evap}$ depends on $P_{odor}$, $f_{odor}$, and $A$. According to *Mackay, D., & van Wesenbeeck, I. (2014). Correlation of Chemical Evaporation Rate with Vapor Pressure. Environmental Science & Technology, 48(17), 10259–10263. doi:10.1021/es5029074* the pure odorant evaporation rate per unit area has the empirical form: \begin{equation} \tag{23} F^*_{evap}(P_{odor}) = e^{1.0243 ln(\frac{P_{odor}}{P_{unity}} - 15.08)} * F_{unity} \end{equation} where $P_{unity} = 1 Pa$ and $F_{unity}= 1\frac{mol}{m^2s}$ Assuming linear dependence on mole fraction in solution: \begin{equation} \tag{25} F_{evap}(P_{odor},f_{odor}) = F^*_{evap}(P_{odor})f_{odor} = f_{odor}e^{1.0243 ln(\frac{P_{odor}}{P_{unity}} - 15.08)} * F_{unity} \end{equation} At equilibrium, the condensation rate is equal to the evaporation rate, resulting in a $n_{odor}(t=0)$ given by the partial pressure $P^*_{odor} = P_{odor}f_{odor}$. Setting (8) and (10) equal and subsituting (18) gives: \begin{equation} F_{evap}(P_{odor},f_{odor})A = k_{condense}A\frac{n_{odor}(t=0)}{V_{head}} \end{equation} \begin{equation} \tag{26} F^*_{evap}(P_{odor})f_{odor}A = k_{condense}A\frac{P_{odor}f_{odor}V_{head}}{V_{head}RT_{room}} \end{equation} \begin{equation} \tag{27} k_{condense} = \frac{RT_{room}F^*_{evap}(P_{odor})}{P_{odor}} \end{equation} Substituting (25) and (26) into (22) gives: \begin{equation} \frac{r_{odor,out}}{r_{air,in}}(t) = \frac{F^*_{evap}(P_{odor})f_{odor}}{(\frac{\frac{RT_{room}F^*_{evap}(P_{odor})}{P_{odor}}P_{room}}{RT_{room}} + \frac{r_{air,in}}{A})} + (\frac{P_{odor}f_{odor}}{P_{room}} - \frac{F^*_{evap}(P_{odor})f_{odor}}{(\frac{\frac{RT_{room}F^*_{evap}(P_{odor})}{P_{odor}}P_{room}}{RT_{room}} + \frac{r_{air,in}}{A})})e^{-(\frac{1}{V_{head}}(\frac{RT_{room}F^*_{evap}(P_{odor})}{P_{odor}}A + \frac{r_{air,in}RT_{room}}{P_{room}}))t} \end{equation} \begin{equation} \frac{r_{odor,out}}{r_{air,in}}(t) = f_{odor}(\frac{F^*_{evap}(P_{odor})}{(\frac{F^*_{evap}(P_{odor})}{P_{odor}}P_{room} + \frac{r_{air,in}}{A})} + (\frac{P_{odor}}{P_{room}} - \frac{F^*_{evap}(P_{odor})}{(\frac{F^*_{evap}(P_{odor})}{P_{odor}}P_{room} + \frac{r_{air,in}}{A})})e^{-(\frac{RT_{room}}{V_{head}}(\frac{F^*_{evap}(P_{odor})}{P_{odor}}A + \frac{r_{air,in}}{P_{room}}))t}) \end{equation} \begin{equation} \tag{28} \frac{r_{odor,out}}{r_{air,in}}(t) = f_{odor}(\frac{1}{(\frac{P_{room}}{P_{odor}} + \frac{r_{air,in}}{AF^*_{evap}(P_{odor})})} + (\frac{P_{odor}}{P_{room}} - \frac{1}{(\frac{P_{room}}{P_{odor}} + \frac{r_{air,in}}{AF^*_{evap}(P_{odor})})})e^{-(\frac{RT_{room}}{V_{head}}(\frac{F^*_{evap}(P_{odor})}{P_{odor}}A + \frac{r_{air,in}}{P_{room}}))t}) \end{equation} This equation, describing the molar fraction of odorant in the air stream, has the functional form:<br><br> \begin{equation} \tag{29} \frac{r_{odor,out}}{r_{air,in}}(t) = f_{odor}(a + (b-a)e^{-ct}) \end{equation} <br>where $f_{odor}$ is the mole fraction of the odorant in solution, $f_{odor}a$ describes the steady-state fraction in the exiting vapor at $t=0$, $f_{odor}b$ describes the steady-state fraction in the exiting vapor at $t=\infty$, and $\frac{1}{c}$ is the time constant. In the vapor pressure regime of most odorants (0.1 - 10 mm Hg), the ratio $\frac{F^*_{evap}(P_{odor})}{P_{odor}}$ does not differ more than $\sim5\%$ from $k_{evap} \sim3.2*10^{-7} \frac{mol}{m^2sPa}$, i.e. $F^*_{evap}$ is linear in $P_{odor}$. This means that the time constant $\frac{1}{c}$ is largely independent of the odorant in question. Plugging in numbers: ```python %matplotlib inline import numpy as np import matplotlib.pyplot as plt import seaborn as sns import quantities as pq from quantities.constants.statisticalmechanics import R from IPython.display import Markdown sns.set(font_scale=1.5) ``` ```python jar_diameter = 6 * pq.cm jar_height = 5 * pq.cm height_filled = 1*pq.cm A = np.pi * (jar_diameter / 2)**2 V_head = A * (jar_height - height_filled) f_odor = 0.001 # A 0.1% solution P_room = 1*pq.atm # 1 atmosphere P_odor = 10.5 * pq.mmHg # Hexanal vapor pressure T_room = (22 + 273.15)*pq.Kelvin r_air_in = (1.0*pq.L/pq.min)*P_room/(R*T_room) # 1 L/min convered to mol/s def F_star_evap(vp): # Units of Pascals vp = vp.rescale(pq.Pa) # Strip units for logarithm vp /= vp.units # Evaporation rate er = np.exp(1.0243*np.log(vp) - 15.08) if isinstance(er, np.ndarray): er[vp==0] = 0 # Attach units er *= pq.mol / (pq.m**2 * pq.s) return er t = np.linspace(0,5,1000) * pq.s # 1000 ms # Use the form: # ratio = f_odor*(a + (b - a)exp(-ct)) a = (1/(P_room/P_odor + r_air_in/(A*F_star_evap(P_odor)))).rescale(pq.dimensionless) b = (P_odor/P_room).rescale(pq.dimensionless) c = ((R*T_room/V_head)*(A*F_star_evap(P_odor)/P_odor + r_air_in/P_room)).rescale(1/pq.s) ratio = f_odor*(a + (b - a)*np.exp(-c*t)) Markdown(r"a = %.3g<br>b= %.3g<br>c = %.3g($s^{-1}$)" % (a, b, c)) ``` a = 0.0017<br>b= 0.0138<br>c = 0.168($s^{-1}$) Here is the decay curve for the fraction of odorant (by mole) in the vapor leaving the jar over time: ```python plt.plot(t, ratio) plt.xlabel('Time (s)') plt.ylabel('Volume fraction odorant\nin air stream') plt.ylim(0, ratio.max()*1.1); ``` ```python vps = (np.logspace(-1,1,100) * pq.mmHg).rescale(pq.Pa) ers = np.zeros(vps.shape) for i, vp in enumerate(vps): ers[i] = F_star_evap(vp) plt.scatter(vps, ers/vps) plt.xscale('log') plt.ylim(3e-7,3.5e-7) plt.xlabel(r'Vapor pressure ($Pa$)') plt.ylabel(r'Evaporation rate ($\frac{mol}{m^2s}$)'); ``` ```python r_air_ins_volume = np.logspace(-4,2,100)*pq.L/pq.min r_air_ins_mole = (r_air_ins_volume*P_room/(R*T_room)).rescale(pq.mol/pq.s) k_evap = 3.2e-7*pq.mol/(pq.m**2*pq.s*pq.Pa) cs = ((R*T_room/V_head)*(A*k_evap + r_air_ins_mole/P_room)).rescale(1/pq.s) plt.scatter(r_air_ins_volume, 1/cs) plt.xlabel(r'Air flow rate ($\frac{L}{min}$)') plt.ylabel(r'Odorant depletion time constant ($s$)') plt.xscale('log') plt.yscale('log') plt.xlim(1e-4,1e2) plt.ylim(1e-2,1e2); ``` Using the linear form of $F^*_{evap}$, the dependence on $P_{odor}$ of the ratio between the initial and steady-state odorant enrichments disappears: \begin{equation} \tag{30} \frac{b}{a} = \frac{\frac{P_{odor}}{P_{room}}}{\frac{1}{(\frac{P_{room}}{P_{odor}} + \frac{r_{air,in}}{AF^*_{evap}(P_{odor})})}} = \frac{\frac{P_{odor}}{P_{room}}}{\frac{1}{(\frac{P_{room}}{P_{odor}} + \frac{r_{air,in}}{Ak_{evap}P_{odor}})}} = \frac{P_{room}+\frac{r_{air,in}}{Ak_{evap}}}{P_{room}} = 1+\frac{r_{air,in}}{Ak_{evap}P_{room}} \end{equation} The only way to keep this fraction close to 1 is to have a low air-flow rate $r_{air,in}$ or a large solution-vapor interface surface area $A$, i.e. a wide jar. ```python b_a_ratios = 1 + (r_air_ins_mole/(A*k_evap*P_room)).rescale(pq.dimensionless) plt.scatter(r_air_ins_volume, b_a_ratios) plt.xlabel(r'Air flow rate ($\frac{L}{min}$)') plt.ylabel(r'Odorant enrichment ratio $\frac{initial}{steadystate}$') plt.xscale('log') plt.yscale('log') plt.xlim(1e-4,1e2) plt.ylim(0.9,1e3); ``` In the interval between stimuli, if air flow through the jar is turned off, the odorant concentration increases again towards its intitial concentration. Here we assume that the pressure change inside the sealed jar due to the odorant realizing its partial pressure is small.<br><br> \begin{equation} \tag{31} \frac{dn_{odor}}{dt} = r_{evap} - r_{condense} = f_{odor}F*_{evap}(P_{odor})A - \frac{RT_{room}F^*_{evap}(P_{odor})An_{odor}}{P_{odor}V_{head}} \end{equation} We can define: \begin{equation} \tag{32}u^* = \frac{RT_{room}F^*_{evap}(P_{odor})A}{P_{odor}V_{head}} \end{equation} with a solution just like (21), except without the term for air influx:<br><br> \begin{equation} \tag{32} n_{odor}(t) = \frac{V_{head}F_{evap}(P_{odor},f_{odor})A}{k_{condense}A} + (\frac{P_{odor}f_{odor}V_{head}}{RT_{room}} - \frac{V_{head}F_{evap}(P_{odor},f_{odor})A}{k_{condense}A})*e^{-(\frac{1}{V_{head}}(k_{condense}A))t} \end{equation} \begin{equation} n_{odor}(t) = e^{-ut}(\int{e^{ut}f_{odor}F^*_{evap}(P_{odor})Adt} + constant) \end{equation} \begin{equation} n_{odor}(t) = \frac{f_{odor}F^*_{evap}(P_{odor})A}{u} + constant*e^{-ut} \end{equation} <br> \begin{equation} n_{odor}(t) = \frac{f_{odor}F^*_{evap}(P_{odor})A}{\frac{RT_{room}F^*_{evap}(P_{odor})A}{P_{odor}V_{head}}} + constant*e^{-ut} \end{equation} <br> \begin{equation} \tag{33}n_{odor}(t) = \frac{f_{odor}P_{odor}V_{head}}{RT_{room}} + constant*e^{-\frac{RT_{room}F^*_{evap}(P_{odor})A}{P_{odor}V_{head}}t} \end{equation} The value of the constant term depends on how depleted the odorant in the headspace is before the airflow is turned off. Without less of generality we can simply define it as: \begin{equation} \tag{34} constant = n_{odor}(t=0) - \frac{f_{odor}P_{odor}V_{head}}{RT_{room}} \end{equation} giving us: \begin{equation} \tag{35}n_{odor}(t) = \frac{f_{odor}P_{odor}V_{head}}{RT_{room}} + (n_{odor}(t=0) - \frac{f_{odor}P_{odor}V_{head}}{RT_{room}})*e^{-\frac{RT_{room}F^*_{evap}(P_{odor})A}{P_{odor}V_{head}}t} \end{equation} Therefore, a scenario of a stimulus of duration $T_on$ followed by an interval of duration $T_off$ exhibits the following behavior: The quantity of odorant in the jar headspace is initially $\frac{f_{odor}P_{odor}V_{head}}{RT_{room}}$, which follows trivially from Raoult's law and the ideal gas law. Once the air flow is turned on, it declines by a factor of $\frac{b}{a} = 1+\frac{r_{air,in}}{Ak_{evap}P_{room}}$ with inverse time constant $c = \frac{RT_{room}}{V_{head}}(\frac{F^*_{evap}(P_{odor})}{P_{odor}}A + \frac{r_{air,in}}{P_{room}})) \sim \frac{RT_{room}}{V_{head}}(k_{evap}A + \frac{r_{air,in}}{P_{room}}))$. When the air is turned off, it returns to its initial value with inverse time constant $c = \frac{RT_{room}F^*_{evap}(P_{odor})A}{P_{odor}V_{head}} \sim \frac{RT_{room}k_{evap}A}{V_{head}}$. ```python dt = 0.001 T_on = 2 T_off = 8 n_cycles = 10 t = np.arange(0,(T_on+T_off)*n_cycles,dt) * pq.s t_on = int(T_on / dt) t_off = int(T_off / dt) ratios = np.zeros(t.shape) # Use the form: # ratio = f_odor*(a + (b - a)exp(-ct)) a = (1/(P_room/P_odor + r_air_in/(A*F_star_evap(P_odor)))).rescale(pq.dimensionless) b = (P_odor/P_room).rescale(pq.dimensionless) c_decay = ((R*T_room/V_head)*(A*F_star_evap(P_odor)/P_odor + r_air_in/P_room)).rescale(1/pq.s) c_recover = ((R*T_room/V_head)*(A*F_star_evap(P_odor)/P_odor)).rescale(1/pq.s) ratios[0:t_on] = f_odor*(a + (b - a)*np.exp(-c_decay*t[:t_on])) ratios[t_on:t_on+t_off] = f_odor*(b + (ratios[t_on-1]/f_odor - b)*np.exp(-c_recover*t[:t_off])) for cycle in range(1,n_cycles): ratios[cycle*t_on+cycle*t_off:(cycle+1)*t_on+cycle*t_off] = f_odor*(a + (ratios[cycle*t_on+cycle*t_off-1]/f_odor - a)*np.exp(-c_decay*t[:t_on])) ratios[(cycle+1)*t_on+cycle*t_off:(cycle+1)*t_on+(cycle+1)*t_off] = f_odor*(b + (ratios[(cycle+1)*t_on+cycle*t_off-1]/f_odor - b)*np.exp(-c_recover*t[:t_off])) ``` Repeated stimuli (with on time T_on and off time T_off will have an odorant mole fraction in the vapor that changes as follows): ```python plt.plot(t, ratios) plt.xlabel('Time ($s$)') plt.ylabel('Mole fraction of odorant\nin headspace vapor'); plt.ylim(0, ratios[0]*1.1); ``` ```python print("Depletion time constant is %.3g s" % (1/c_decay)) print("Recovery time constant is %.3g s" % (1/c_recover)) ``` Depletion time constant is 5.95 s Recovery time constant is 48.4 s
x <- 1:100 ifelse(x %% 15 == 0, 'FizzBuzz', ifelse(x %% 5 == 0, 'Buzz', ifelse(x %% 3 == 0, 'Fizz', x)))
A function $f$ is continuous on the closure of a set $S$ if and only if for every sequence $x_n$ in $S$ that converges to a point $a$ in the closure of $S$, the sequence $f(x_n)$ converges to $f(a)$.
C ********************************************************* C * * C * TEST NUMBER: 04.02.05.03/11 * C * TEST TITLE : Edge bundle index * C * * C * PHIGS Validation Tests, produced by NIST * C * * C ********************************************************* COMMON /GLOBNU/ CTLHND, ERRSIG, ERRFIL, IERRCT, UNERR, 1 TESTCT, IFLERR, PASSSW, ERRSW, MAXLIN, 2 CONID, MEMUN, WKID, WTYPE, GLBLUN, INDLUN, 3 DUMINT, DUMRL INTEGER CTLHND, ERRSIG, ERRFIL, IERRCT, UNERR, 1 TESTCT, IFLERR, PASSSW, ERRSW, MAXLIN, 2 CONID, MEMUN, WKID, WTYPE, GLBLUN, INDLUN, 3 DUMINT(20), ERRIND REAL DUMRL(20) COMMON /GLOBCH/ PIDENT, GLBERR, TSTMSG, FUNCID, 1 DUMCH CHARACTER PIDENT*40, GLBERR*60, TSTMSG*900, FUNCID*80, 1 DUMCH(20)*20 COMMON /DIALOG/ DOUTYP, DINTYP, DSTDNR, DSTRID, PSTRID, DTCLIM, 1 SCRMOD, DTXCI, SPECWT, 2 DSIZE, EFRAC, DYXRAT, SYXRAT, MTRPDC, WCPDC, QVIS INTEGER DOUTYP, DINTYP, DSTDNR, DSTRID, PSTRID, DTCLIM, 1 SCRMOD, DTXCI, SPECWT REAL DSIZE, EFRAC, DYXRAT, SYXRAT, MTRPDC, WCPDC, QVIS C aspect source INTEGER PBUNDL, PINDIV PARAMETER (PBUNDL = 0, PINDIV = 1) C interior style INTEGER PHOLLO, PSOLID, PPATTR, PHATCH, PISEMP PARAMETER (PHOLLO=0, PSOLID=1, PPATTR=2, PHATCH=3, PISEMP=4) C off/on switch for edge flag and error handling mode INTEGER POFF, PON PARAMETER (POFF = 0, PON = 1) C colour model INTEGER PRGB, PCIE, PHSV, PHLS PARAMETER (PRGB = 1, PCIE = 2, PHSV = 3, PHLS = 4) C aspect identifier INTEGER PLN, PLWSC, PPLCI, PMK, PMKSC PARAMETER (PLN = 0, PLWSC= 1, PPLCI= 2, PMK = 3, PMKSC= 4) INTEGER PPMCI, PTXFN, PTXPR, PCHXP, PCHSP PARAMETER (PPMCI= 5, PTXFN= 6, PTXPR= 7, PCHXP= 8, PCHSP= 9) INTEGER PTXCI, PIS, PISI, PICI, PEDFG PARAMETER (PTXCI=10, PIS =11, PISI =12, PICI =13, PEDFG=14) INTEGER MAXET, PICSTR, TXCI, IX, NPTS(1), RNDINT INTEGER NUMET, LAET(10), ALTET, SWITCH, SZBT, NUMBUN INTEGER BUNDIS(10), BUNDIF, EXPLCT, BUNEL, UNDF(3), PERM(10) INTEGER IDUM1, IDUM2, IDUM3, IDUM4, IDUM5, IDUM6, IDUM7 REAL XA(41), YA(41), YLOC, YINCR, RAD, CENTX, CENTY, PI REAL RDUM1, RDUM2, RDUM3 CALL INITGL ('04.02.05.03/11') C open PHIGS CALL XPOPPH (ERRFIL, MEMUN) C set-up of workstation and dialogue area PICSTR = 101 TXCI = 1 CALL SETDLG (PICSTR, 801,TXCI) CALL PSCMD (WKID, PRGB) CALL POPST (PICSTR) C by convention, view #1 is for picture CALL PSVWI (1) C use bundled attributes CALL SETASF (PBUNDL) C set interior style attribute ASFs to INDIVIDUAL C set interior style = EMPTY, interior color index = 1 CALL PSIASF (PIS, PINDIV) CALL PSIASF (PICI, PINDIV) CALL PSIS (PISEMP) CALL PSICI (1) C szbt = maximum size of edge bundle table CALL PQWKSL (SPECWT, ERRIND, IDUM1, IDUM2, IDUM3, IDUM4, 1 SZBT, IDUM5, IDUM6, IDUM7) CALL CHKINQ ('pqwksl', ERRIND) C numet = number of available edgetypes C laet = list of available edgetypes CALL PQEDF (SPECWT, 0, ERRIND, NUMET, IDUM1, IDUM2, RDUM1, RDUM2, 1 RDUM3, IDUM3) CALL CHKINQ ('pqedf', ERRIND) C ten is more than enough - limit to list size MAXET = MIN (10, ABS(NUMET)) DO 50 IX=1, MAXET CALL PQEDF (SPECWT, IX, ERRIND, IDUM1, LAET(IX), IDUM2, RDUM1, 1 RDUM2, RDUM3, IDUM3) CALL CHKINQ ('pqedf', ERRIND) 50 CONTINUE C sort laet CALL SRTIAR (MAXET, LAET) C *** *** *** edge index *** *** *** C mark start of edge bundles CALL PLB (1) CALL SETMSG ('3 4 5 6', 'A defined edge index should cause ' // 1 'the addressed entry in the bundle table to be ' // 2 'used when rendering a edge.') C numbun = number of bundles to be displayed = min(8, szbt) NUMBUN = MIN (8, SZBT) C initialize all of bundis DO 60 IX = 1, NUMBUN CALL PSEDR (WKID, IX, PON, 1, 1.0, 1) BUNDIS(IX) = IX 60 CONTINUE C altet = alternative edgetype C switch = switch edge flag ON or OFF IF (MAXET .GT. 1) THEN ALTET = LAET(2) SWITCH = PON ELSE ALTET = LAET(1) SWITCH = POFF ENDIF C bundif = randomly selected bundle from BUNDIS BUNDIF = RNDINT (1, NUMBUN) C set edge represent bundif CALL PSEDR (WKID, BUNDIF, SWITCH, ALTET, 2.0, 2) C Display and label triangles with edges for each bundle in bundis CALL DRBUED (NUMBUN, BUNDIS) C mark end of edgetype CALL PLB (2) CALL DCHPFV ('DEFINED EDGE INDICES: which triangle is ' // 1 'different?', NUMBUN, BUNDIF) C clear out last display from structure CALL PSEP (1) CALL PDELLB (1,2) CALL SETMSG ('3 4 5 7', 'An undefined edge index should cause ' // 1 'bundle number 1 in the edge bundle table to be ' // 2 'used when rendering an edge.') C set index #1 in bundle table CALL PSEDR (WKID, 1, PON, ALTET, 2.0, 2) C u1,u2,u3 = 3 undefined, positive indices UNDF(1) = SZBT + 1 UNDF(2) = SZBT + 10 UNDF(3) = SZBT + 90 C explct = number of explicit edges EXPLCT = RNDINT (0, 4) NUMBUN = EXPLCT + 3 CALL RNPERM (NUMBUN, PERM) C draw star with bundle index 1 RAD = 0.15 CENTX = .5 CENTY = .75 PI = 3.14159265 DO 400 IX = 1, 5 YA(IX) = CENTY + RAD * COS((4*PI*IX)/5) XA(IX) = CENTX + RAD * SIN((4*PI*IX)/5) 400 CONTINUE CALL PSEDI (1) NPTS(1) = 5 CALL PFAS (1,NPTS, XA, YA) C display interleaved: YLOC = 0.5 YINCR = 0.5/8 XA(1) = 0.3 XA(2) = 0.3 XA(3) = 0.7 NPTS(1) = 3 DO 500 IX = 1, NUMBUN BUNEL = PERM(IX) IF (BUNEL .LE. 3) THEN CALL PSEDI (UNDF(BUNEL)) ELSE CALL PSEDI (1) ENDIF YA(1) = YLOC - 0.25*YINCR YA(2) = YLOC + 0.25*YINCR YA(3) = YLOC - 0.25*YINCR CALL PFAS (1, NPTS, XA, YA) YLOC = YLOC - YINCR 500 CONTINUE CALL DCHPFV ('UNDEFINED EDGE INDICES: How many of the ' // 1 'triangles have the same edge attributes as ' // 2 'the star?', 12, NUMBUN) 666 CONTINUE C wrap it up. CALL ENDIT END
Micro Air® can provide the solution for all types of combustible dust such as wood, coal, carbon, plastic, food processing, metals etc. Micro Air's factory-trained network of Engineered Systems Distributors can assess your needs and design safety and compliance into your collection system. Find great deals on eBay for micro air grinder. Shop with confidence. Skip to main content. eBay: Shop by category. ... AIR MICRO GRINDER 56000 RPM TOOLS HIGH SPEED TOOL KIT PENCIL TYPE DIE GRINDER. Brand New. $19.89. Buy It Now. Free Shipping. Neiko Air Micro Die Grinder Kit. Brand New. $39.17. Air Micro Grinder. GISON Machinery Co.,Ltd. specializes in Manufacture, Supply and Export Air Grinder, Air Grinders (Pneumatic Grinder), with a factory in Taiwan for more than 40 years. Micro air grinder,high speed air micro grinder,chamfer tool air grinder,US $ 198 - 830 / Piece, Japan, TRUSCO, New.Source from KANAZAWAKIKO CO.,LTD on Alibaba.com. ... Find Listings of air micro grinder manufacturers and Suppliers from Chinese Wholesalers and Global Distributors at B2BFreezone.com » Learn More. suppliers micro grinder expert . suppliers micro grinder expert 500 di indonesia. vertical cement mill design . distributor micro air grinder di jakarta . ix352013 2.0L GL IV_ . sigaretta di prodotti. OEM/ODM . Inflatable Air Football. Electric . فیبر نوری حفاظت جعبه کابل، شکاف جعبه توزیع، پیرایش . Pencil Type Micro Air Die Grinder features a variable speed throttle control. Hanperal 16PCS Air Micro Die Grinder Kit, Mini Pencil Polishing Rotary Cutting Tool Set. by Hanperal. $25.55 $ 25 55 Prime. FREE Shipping on eligible orders. Only 2 left in stock - order soon. 4 out of 5 stars 1. Kingsfang(Xiamen)Import&Export Co., Ltd. Join our email list to receive the latest Mini news, updates, and more. And don't worry, we won't share your information with anyone else. Being the market leader we are actively devoted towards providing well tested Micro Die Grinder.Ideal for grinding and finishing of metal molds, aluminum die and other products, this die grinder is provided in different specifications as per the ever-evolving needs of the clients. AIR MICRO GRINDER 56000 RPM TOOLS HIGH SPEED TOOL KIT PENCIL TYPE DIE GRINDER. Brand New. $19.89. Buy It Now. Free Shipping. SPONSORED. 54,000 Rpm Air Micro Grinder Pencil Type Micro Grinder 1/8" Die Grinder 60" Hose. ... Air Micro Die Grinder Kit + 100 PC ROTARY POLISH ACCESSORY KIT POLISHER ENGRAVER See more like this.
Formal statement is: lemma Bseq_iff2: "Bseq X \<longleftrightarrow> (\<exists>k > 0. \<exists>x. \<forall>n. norm (X n + - x) \<le> k)" Informal statement is: A sequence $X$ is bounded if and only if there exists a constant $k > 0$ and a point $x$ such that $|X_n - x| \leq k$ for all $n$.
<unk> → p + + e − + ν
(* Author: Lukas Bulwahn <lukas.bulwahn-at-gmail.com> *) section \<open>Definition of Equivalence Classes\<close> theory Equiv_Relations_on_Functions imports Preliminaries Twelvefold_Way_Core begin subsection \<open>Permutation on the Domain\<close> definition domain_permutation where "domain_permutation A B = {(f, f') \<in> (A \<rightarrow>\<^sub>E B) \<times> (A \<rightarrow>\<^sub>E B). \<exists>p. p permutes A \<and> (\<forall>x \<in> A. f x = f' (p x))}" lemma equiv_domain_permutation: "equiv (A \<rightarrow>\<^sub>E B) (domain_permutation A B)" proof (rule equivI) show "refl_on (A \<rightarrow>\<^sub>E B) (domain_permutation A B)" proof (rule refl_onI) show "domain_permutation A B \<subseteq> (A \<rightarrow>\<^sub>E B) \<times> (A \<rightarrow>\<^sub>E B)" unfolding domain_permutation_def by auto next fix f assume "f \<in> A \<rightarrow>\<^sub>E B" from this show "(f, f) \<in> domain_permutation A B" using permutes_id unfolding domain_permutation_def by fastforce qed next show "sym (domain_permutation A B)" proof (rule symI) fix f f' assume "(f, f') \<in> domain_permutation A B" from this obtain p where "p permutes A" and "\<forall>x\<in>A. f x = f' (p x)" unfolding domain_permutation_def by auto from \<open>(f, f') \<in> domain_permutation A B\<close> have "f \<in> A \<rightarrow>\<^sub>E B" "f' \<in> A \<rightarrow>\<^sub>E B" unfolding domain_permutation_def by auto moreover from \<open>p permutes A\<close> have "inv p permutes A" by (simp add: permutes_inv) moreover from \<open>p permutes A\<close> \<open>\<forall>x\<in>A. f x = f' (p x)\<close> have "\<forall>x\<in>A. f' x = f (inv p x)" using permutes_in_image permutes_inverses(1) by (metis (mono_tags, hide_lams)) ultimately show "(f', f) \<in> domain_permutation A B" unfolding domain_permutation_def by auto qed next show "trans (domain_permutation A B)" proof (rule transI) fix f f' f'' assume "(f, f') \<in> domain_permutation A B" "(f', f'') \<in> domain_permutation A B" from \<open>(f, f') \<in> _\<close> obtain p where "p permutes A" and "\<forall>x\<in>A. f x = f' (p x)" unfolding domain_permutation_def by auto from \<open>(f', f'') \<in> _\<close> obtain p' where "p' permutes A" and "\<forall>x\<in>A. f' x = f'' (p' x)" unfolding domain_permutation_def by auto from \<open>(f, f') \<in> domain_permutation A B\<close> have "f \<in> A \<rightarrow>\<^sub>E B" unfolding domain_permutation_def by auto moreover from \<open>(f', f'') \<in> domain_permutation A B\<close> have "f'' \<in> A \<rightarrow>\<^sub>E B" unfolding domain_permutation_def by auto moreover from \<open>p permutes A\<close> \<open>p' permutes A\<close> have "(p' \<circ> p) permutes A" by (simp add: permutes_compose) moreover have "\<forall>x\<in>A. f x = f'' ((p' \<circ> p) x)" using \<open>\<forall>x\<in>A. f x = f' (p x)\<close> \<open>\<forall>x\<in>A. f' x = f'' (p' x)\<close> \<open>p permutes A\<close> by (simp add: permutes_in_image) ultimately show "(f, f'') \<in> domain_permutation A B" unfolding domain_permutation_def by auto qed qed subsubsection \<open>Respecting Functions\<close> lemma inj_on_respects_domain_permutation: "(\<lambda>f. inj_on f A) respects domain_permutation A B" proof (rule congruentI) fix f f' assume "(f, f') \<in> domain_permutation A B" from this obtain p where p: "p permutes A" "\<forall>x\<in>A. f x = f' (p x)" unfolding domain_permutation_def by auto have inv_p: "\<forall>x\<in>A. f' x = f (inv p x)" using p by (metis permutes_inverses(1) permutes_not_in) show "inj_on f A \<longleftrightarrow> inj_on f' A" proof assume "inj_on f A" show "inj_on f' A" proof (rule inj_onI) fix a a' assume "a \<in> A" "a' \<in> A" "f' a = f' a'" from this \<open>p permutes A\<close> have "inv p a \<in> A" "inv p a' \<in> A" by (simp add: permutes_in_image permutes_inv)+ have "f (inv p a) = f (inv p a')" using \<open>f' a = f' a'\<close> \<open>a \<in> A\<close> \<open>a' \<in> A\<close> inv_p by auto from \<open>inj_on f A\<close> this \<open>inv p a \<in> A\<close> \<open>inv p a' \<in> A\<close> have "inv p a = inv p a'" using inj_on_contraD by fastforce from this show "a = a'" by (metis \<open>p permutes A\<close> permutes_inverses(1)) qed next assume "inj_on f' A" from this p show "inj_on f A" unfolding inj_on_def by (metis inj_on_contraD permutes_in_image permutes_inj_on) qed qed lemma image_respects_domain_permutation: "(\<lambda>f. f ` A) respects (domain_permutation A B)" proof (rule congruentI) fix f f' assume "(f, f') \<in> domain_permutation A B" from this obtain p where p: "p permutes A" and f_eq: "\<forall>x\<in>A. f x = f' (p x)" unfolding domain_permutation_def by auto show "f ` A = f' ` A" proof from p f_eq show "f ` A \<subseteq> f' ` A" by (auto simp add: permutes_in_image) next from \<open>p permutes A\<close> \<open>\<forall>x\<in>A. f x = f' (p x)\<close> have "\<forall>x\<in>A. f' x = f (inv p x)" using permutes_in_image permutes_inverses(1) by (metis (mono_tags, hide_lams)) from this show "f' ` A \<subseteq> f ` A" using \<open>p permutes A\<close> by (auto simp add: permutes_inv permutes_in_image) qed qed lemma surjective_respects_domain_permutation: "(\<lambda>f. f ` A = B) respects domain_permutation A B" by (metis image_respects_domain_permutation congruentD congruentI) lemma bij_betw_respects_domain_permutation: "(\<lambda>f. bij_betw f A B) respects domain_permutation A B" proof (rule congruentI) fix f f' assume "(f, f') \<in> domain_permutation A B" from this obtain p where "p permutes A" and "\<forall>x\<in>A. f x = f' (p x)" unfolding domain_permutation_def by auto have "bij_betw f A B \<longleftrightarrow> bij_betw (f' o p) A B" using \<open>\<forall>x\<in>A. f x = f' (p x)\<close> by (metis (mono_tags, hide_lams) bij_betw_cong comp_apply) also have "... \<longleftrightarrow> bij_betw f' A B" using \<open>p permutes A\<close> by (auto intro!: bij_betw_comp_iff[symmetric] permutes_imp_bij) finally show "bij_betw f A B \<longleftrightarrow> bij_betw f' A B" . qed lemma image_mset_respects_domain_permutation: shows "(\<lambda>f. image_mset f (mset_set A)) respects (domain_permutation A B)" proof (rule congruentI) fix f f' assume "(f, f') \<in> domain_permutation A B" from this obtain p where "p permutes A" and "\<forall>x\<in>A. f x = f' (p x)" unfolding domain_permutation_def by auto from this show "image_mset f (mset_set A) = image_mset f' (mset_set A)" using permutes_implies_image_mset_eq by fastforce qed subsection \<open>Permutation on the Range\<close> definition range_permutation where "range_permutation A B = {(f, f') \<in> (A \<rightarrow>\<^sub>E B) \<times> (A \<rightarrow>\<^sub>E B). \<exists>p. p permutes B \<and> (\<forall>x \<in> A. f x = p (f' x))}" lemma equiv_range_permutation: "equiv (A \<rightarrow>\<^sub>E B) (range_permutation A B)" proof (rule equivI) show "refl_on (A \<rightarrow>\<^sub>E B) (range_permutation A B)" proof (rule refl_onI) show "range_permutation A B \<subseteq> (A \<rightarrow>\<^sub>E B) \<times> (A \<rightarrow>\<^sub>E B)" unfolding range_permutation_def by auto next fix f assume "f \<in> A \<rightarrow>\<^sub>E B" from this show "(f, f) \<in> range_permutation A B" using permutes_id unfolding range_permutation_def by fastforce qed next show "sym (range_permutation A B)" proof (rule symI) fix f f' assume "(f, f') \<in> range_permutation A B" from this obtain p where "p permutes B" and "\<forall>x\<in>A. f x = p (f' x)" unfolding range_permutation_def by auto from \<open>(f, f') \<in> range_permutation A B\<close> have "f \<in> A \<rightarrow>\<^sub>E B" "f' \<in> A \<rightarrow>\<^sub>E B" unfolding range_permutation_def by auto moreover from \<open>p permutes B\<close> have "inv p permutes B" by (simp add: permutes_inv) moreover from \<open>p permutes B\<close> \<open>\<forall>x\<in>A. f x = p (f' x)\<close> have "\<forall>x\<in>A. f' x = inv p (f x)" by (simp add: permutes_inverses(2)) ultimately show "(f', f) \<in> range_permutation A B" unfolding range_permutation_def by auto qed next show "trans (range_permutation A B)" proof (rule transI) fix f f' f'' assume "(f, f') \<in> range_permutation A B" "(f', f'') \<in> range_permutation A B" from \<open>(f, f') \<in> _\<close> obtain p where "p permutes B" and "\<forall>x\<in>A. f x = p (f' x)" unfolding range_permutation_def by auto from \<open>(f', f'') \<in> _\<close> obtain p' where "p' permutes B" and "\<forall>x\<in>A. f' x = p' (f'' x)" unfolding range_permutation_def by auto from \<open>(f, f') \<in> range_permutation A B\<close> have "f \<in> A \<rightarrow>\<^sub>E B" unfolding range_permutation_def by auto moreover from \<open>(f', f'') \<in> range_permutation A B\<close> have "f'' \<in> A \<rightarrow>\<^sub>E B" unfolding range_permutation_def by auto moreover from \<open>p permutes B\<close> \<open>p' permutes B\<close> have "(p \<circ> p') permutes B" by (simp add: permutes_compose) moreover have "\<forall>x\<in>A. f x = (p \<circ> p') (f'' x)" using \<open>\<forall>x\<in>A. f x = p (f' x)\<close> \<open>\<forall>x\<in>A. f' x = p' (f'' x)\<close> by auto ultimately show "(f, f'') \<in> range_permutation A B" unfolding range_permutation_def by auto qed qed subsubsection \<open>Respecting Functions\<close> lemma inj_on_respects_range_permutation: "(\<lambda>f. inj_on f A) respects range_permutation A B" proof (rule congruentI) fix f f' assume "(f, f') \<in> range_permutation A B" from this obtain p where p: "p permutes B" "\<forall>x\<in>A. f x = p (f' x)" unfolding range_permutation_def by auto have inv_p: "\<forall>x\<in>A. f' x = inv p (f x)" using p by (simp add: permutes_inverses(2)) show "inj_on f A \<longleftrightarrow> inj_on f' A" proof assume "inj_on f A" from this p show "inj_on f' A" unfolding inj_on_def by auto next assume "inj_on f' A" from this inv_p show "inj_on f A" unfolding inj_on_def by auto qed qed lemma surj_on_respects_range_permutation: "(\<lambda>f. f ` A = B) respects range_permutation A B" proof (rule congruentI) fix f f' assume a: "(f, f') \<in> range_permutation A B" from this have "f \<in> A \<rightarrow>\<^sub>E B" "f' \<in> A \<rightarrow>\<^sub>E B" unfolding range_permutation_def by auto from a obtain p where p: "p permutes B" "\<forall>x\<in>A. f x = p (f' x)" unfolding range_permutation_def by auto have 1: "f ` A = (\<lambda>x. p (f' x)) ` A" using p by (meson image_cong) have 2: "inv p ` ((\<lambda>x. p (f' x)) ` A) = f' ` A" using p by (simp add: image_image image_inv_f_f permutes_inj) show "(f ` A = B) = (f' ` A = B)" proof assume "f ` A = B" from this 1 2 show "f' ` A = B" using p by (simp add: permutes_image permutes_inv) next assume "f' ` A = B" from this 1 2 show "f ` A = B" using p by (metis image_image permutes_image) qed qed lemma bij_betw_respects_range_permutation: "(\<lambda>f. bij_betw f A B) respects range_permutation A B" proof (rule congruentI) fix f f' assume "(f, f') \<in> range_permutation A B" from this obtain p where "p permutes B" and "\<forall>x\<in>A. f x = p (f' x)" and "f' \<in> A \<rightarrow>\<^sub>E B" unfolding range_permutation_def by auto have "bij_betw f A B \<longleftrightarrow> bij_betw (p o f') A B" using \<open>\<forall>x\<in>A. f x = p (f' x)\<close> by (metis (mono_tags, hide_lams) bij_betw_cong comp_apply) also have "... \<longleftrightarrow> bij_betw f' A B" using \<open>f' \<in> A \<rightarrow>\<^sub>E B\<close> \<open>p permutes B\<close> by (auto intro!: bij_betw_comp_iff2[symmetric] permutes_imp_bij) finally show "bij_betw f A B \<longleftrightarrow> bij_betw f' A B" . qed lemma domain_partitions_respects_range_permutation: "(\<lambda>f. (\<lambda>b. {x \<in> A. f x = b}) ` B - {{}}) respects range_permutation A B" proof (rule congruentI) fix f f' assume "(f, f') \<in> range_permutation A B" from this obtain p where p: "p permutes B" "\<forall>x \<in> A. f x = p (f' x)" unfolding range_permutation_def by blast have "{} \<in> (\<lambda>b. {x \<in> A. f' x = b}) ` B \<longleftrightarrow> \<not> (\<forall>b \<in> B. \<exists>x \<in> A. f' x = b)" by auto also have "(\<forall>b \<in> B. \<exists>x \<in> A. f' x = b) \<longleftrightarrow> (\<forall>b \<in> B. \<exists>x \<in> A. p (f' x) = b)" proof assume "\<forall>b\<in>B. \<exists>x\<in>A. f' x = b" from this show "\<forall>b\<in>B. \<exists>x\<in>A. p (f' x) = b" using \<open>p permutes B\<close> unfolding permutes_def by metis next assume "\<forall>b\<in>B. \<exists>x\<in>A. p (f' x) = b" from this show "\<forall>b\<in>B. \<exists>x\<in>A. f' x = b" using \<open>p permutes B\<close> by (metis bij_betwE permutes_imp_bij permutes_inverses(2)) qed also have "\<not> (\<forall>b\<in>B. \<exists>x\<in>A. p (f' x) = b) \<longleftrightarrow> {} \<in> (\<lambda>b. {x \<in> A. p (f' x) = b}) ` B" by auto finally have "{} \<in> (\<lambda>b. {x \<in> A. f' x = b}) ` B \<longleftrightarrow> {} \<in> (\<lambda>b. {x \<in> A. p (f' x) = b}) ` B" . moreover have "(\<lambda>b. {x \<in> A. f' x = b}) ` B = (\<lambda>b. {x \<in> A. p (f' x) = b}) ` B" using \<open>p permutes B\<close> permutes_implies_inv_image_on_eq by blast ultimately have "(\<lambda>b. {x \<in> A. f' x = b}) ` B - {{}} = (\<lambda>b. {x \<in> A. p (f' x) = b}) ` B - {{}}" by auto also have "\<dots> = (\<lambda>b. {x \<in> A. f x = b}) ` B - {{}}" using \<open>\<forall>x \<in> A. f x = p (f' x)\<close> Collect_cong image_cong by auto finally show "(\<lambda>b. {x \<in> A. f x = b}) ` B - {{}} = (\<lambda>b. {x \<in> A. f' x = b}) ` B - {{}}" .. qed subsection \<open>Permutation on the Domain and the Range\<close> definition domain_and_range_permutation where "domain_and_range_permutation A B = {(f, f') \<in> (A \<rightarrow>\<^sub>E B) \<times> (A \<rightarrow>\<^sub>E B). \<exists>p\<^sub>A p\<^sub>B. p\<^sub>A permutes A \<and> p\<^sub>B permutes B \<and> (\<forall>x \<in> A. f x = p\<^sub>B (f' (p\<^sub>A x)))}" lemma equiv_domain_and_range_permutation: "equiv (A \<rightarrow>\<^sub>E B) (domain_and_range_permutation A B)" proof (rule equivI) show "refl_on (A \<rightarrow>\<^sub>E B) (domain_and_range_permutation A B)" proof (rule refl_onI) show "domain_and_range_permutation A B \<subseteq> (A \<rightarrow>\<^sub>E B) \<times> (A \<rightarrow>\<^sub>E B)" unfolding domain_and_range_permutation_def by auto next fix f assume "f \<in> A \<rightarrow>\<^sub>E B" from this show "(f, f) \<in> domain_and_range_permutation A B" using permutes_id[of A] permutes_id[of B] unfolding domain_and_range_permutation_def by fastforce qed next show "sym (domain_and_range_permutation A B)" proof (rule symI) fix f f' assume "(f, f') \<in> domain_and_range_permutation A B" from this obtain p\<^sub>A p\<^sub>B where "p\<^sub>A permutes A" "p\<^sub>B permutes B" and "\<forall>x\<in>A. f x = p\<^sub>B (f' (p\<^sub>A x))" unfolding domain_and_range_permutation_def by auto from \<open>(f, f') \<in> domain_and_range_permutation A B\<close> have f: "f \<in> A \<rightarrow>\<^sub>E B" "f' \<in> A \<rightarrow>\<^sub>E B" unfolding domain_and_range_permutation_def by auto moreover from \<open>p\<^sub>A permutes A\<close> \<open>p\<^sub>B permutes B\<close> have "inv p\<^sub>A permutes A" "inv p\<^sub>B permutes B" by (auto simp add: permutes_inv) moreover from \<open>\<forall>x\<in>A. f x = p\<^sub>B (f' (p\<^sub>A x))\<close> have "\<forall>x\<in>A. f' x = inv p\<^sub>B (f (inv p\<^sub>A x))" using \<open>p\<^sub>A permutes A\<close> \<open>p\<^sub>B permutes B\<close> \<open>inv p\<^sub>A permutes A\<close> \<open>inv p\<^sub>B permutes B\<close> by (metis (no_types, lifting) bij_betwE bij_inv_eq_iff permutes_bij permutes_imp_bij) ultimately show "(f', f) \<in> domain_and_range_permutation A B" unfolding domain_and_range_permutation_def by auto qed next show "trans (domain_and_range_permutation A B)" proof (rule transI) fix f f' f'' assume "(f, f') \<in> domain_and_range_permutation A B" assume "(f', f'') \<in> domain_and_range_permutation A B" from \<open>(f, f') \<in> _\<close> obtain p\<^sub>A p\<^sub>B where "p\<^sub>A permutes A" "p\<^sub>B permutes B" and "\<forall>x\<in>A. f x = p\<^sub>B (f' (p\<^sub>A x))" unfolding domain_and_range_permutation_def by auto from \<open>(f', f'') \<in> _\<close> obtain p'\<^sub>A p'\<^sub>B where "p'\<^sub>A permutes A" "p'\<^sub>B permutes B" and "\<forall>x\<in>A. f' x = p'\<^sub>B (f'' (p'\<^sub>A x))" unfolding domain_and_range_permutation_def by auto from \<open>(f, f') \<in> domain_and_range_permutation A B\<close> have "f \<in> A \<rightarrow>\<^sub>E B" unfolding domain_and_range_permutation_def by auto moreover from \<open>(f', f'') \<in> domain_and_range_permutation A B\<close> have "f'' \<in> A \<rightarrow>\<^sub>E B" unfolding domain_and_range_permutation_def by auto moreover from \<open>p\<^sub>A permutes A\<close> \<open>p'\<^sub>A permutes A\<close> have "(p'\<^sub>A \<circ> p\<^sub>A) permutes A" by (simp add: permutes_compose) moreover from \<open>p\<^sub>B permutes B\<close> \<open>p'\<^sub>B permutes B\<close> have "(p\<^sub>B \<circ> p'\<^sub>B) permutes B" by (simp add: permutes_compose) moreover have "\<forall>x\<in>A. f x = (p\<^sub>B \<circ> p'\<^sub>B) (f'' ((p'\<^sub>A \<circ> p\<^sub>A) x))" using \<open>\<forall>x\<in>A. f' x = p'\<^sub>B (f'' (p'\<^sub>A x))\<close> \<open>\<forall>x\<in>A. f x = p\<^sub>B (f' (p\<^sub>A x))\<close> \<open>p\<^sub>A permutes A\<close> by (simp add: permutes_in_image) ultimately show "(f, f'') \<in> domain_and_range_permutation A B" unfolding domain_and_range_permutation_def by fastforce qed qed subsubsection \<open>Respecting Functions\<close> lemma inj_on_respects_domain_and_range_permutation: "(\<lambda>f. inj_on f A) respects domain_and_range_permutation A B" proof (rule congruentI) fix f f' assume "(f, f') \<in> domain_and_range_permutation A B" from this obtain p\<^sub>A p\<^sub>B where "p\<^sub>A permutes A" "p\<^sub>B permutes B" and "\<forall>x\<in>A. f x = p\<^sub>B (f' (p\<^sub>A x))" unfolding domain_and_range_permutation_def by auto from \<open>(f, f') \<in> domain_and_range_permutation A B\<close> have "f' ` A \<subseteq> B" unfolding domain_and_range_permutation_def by auto from \<open>p\<^sub>A permutes A\<close> have "p\<^sub>A ` A = A" by (auto simp add: permutes_image) from \<open>p\<^sub>A permutes A\<close> have "inj_on p\<^sub>A A" using bij_betw_imp_inj_on permutes_imp_bij by blast from \<open>p\<^sub>B permutes B\<close> have "inj_on p\<^sub>B B" using bij_betw_imp_inj_on permutes_imp_bij by blast show "inj_on f A \<longleftrightarrow> inj_on f' A" proof - have "inj_on f A \<longleftrightarrow> inj_on (\<lambda>x. p\<^sub>B (f' (p\<^sub>A x))) A" using \<open>\<forall>x\<in>A. f x = p\<^sub>B (f' (p\<^sub>A x))\<close> inj_on_cong comp_apply by fastforce have "inj_on f A \<longleftrightarrow> inj_on (p\<^sub>B o f' o p\<^sub>A) A" by (simp add: \<open>\<forall>x\<in>A. f x = p\<^sub>B (f' (p\<^sub>A x))\<close> inj_on_def) also have "inj_on (p\<^sub>B o f' o p\<^sub>A) A \<longleftrightarrow> inj_on (p\<^sub>B o f') A" using \<open>inj_on p\<^sub>A A\<close> \<open>p\<^sub>A ` A = A\<close> by (auto dest: inj_on_imageI intro: comp_inj_on) also have "inj_on (p\<^sub>B o f') A \<longleftrightarrow> inj_on f' A" using \<open>inj_on p\<^sub>B B\<close> \<open>f' ` A \<subseteq> B\<close> by (auto dest: inj_on_imageI2 intro: comp_inj_on subset_inj_on) finally show ?thesis . qed qed lemma surjective_respects_domain_and_range_permutation: "(\<lambda>f. f ` A = B) respects domain_and_range_permutation A B" proof (rule congruentI) fix f f' assume "(f, f') \<in> domain_and_range_permutation A B" from this obtain p\<^sub>A p\<^sub>B where permutes: "p\<^sub>A permutes A" "p\<^sub>B permutes B" and "\<forall>x\<in>A. f x = p\<^sub>B (f' (p\<^sub>A x))" unfolding domain_and_range_permutation_def by auto from permutes have "p\<^sub>A ` A = A" "p\<^sub>B ` B = B" by (auto simp add: permutes_image) from \<open>p\<^sub>B permutes B\<close> have "inj p\<^sub>B" by (simp add: permutes_inj) show "(f ` A = B) \<longleftrightarrow> (f' ` A = B)" proof - have "f ` A = B \<longleftrightarrow> (\<lambda>x. p\<^sub>B (f' (p\<^sub>A x))) ` A = B" using \<open>\<forall>x\<in>A. f x = p\<^sub>B (f' (p\<^sub>A x))\<close> by (metis (mono_tags, lifting) image_cong) also have "(\<lambda>x. p\<^sub>B (f' (p\<^sub>A x))) ` A = B \<longleftrightarrow> (\<lambda>x. p\<^sub>B (f' x)) ` A = B" using \<open>p\<^sub>A ` A = A\<close> by (metis image_image) also have "(\<lambda>x. p\<^sub>B (f' x)) ` A = B \<longleftrightarrow> (f' ` A = B)" using \<open>p\<^sub>B ` B = B\<close> \<open>inj p\<^sub>B\<close> by (metis image_image image_inv_f_f) finally show ?thesis . qed qed lemma bij_betw_respects_domain_and_range_permutation: "(\<lambda>f. bij_betw f A B) respects domain_and_range_permutation A B" proof (rule congruentI) fix f f' assume "(f, f') \<in> domain_and_range_permutation A B" from this obtain p\<^sub>A p\<^sub>B where "p\<^sub>A permutes A" "p\<^sub>B permutes B" and "\<forall>x\<in>A. f x = p\<^sub>B (f' (p\<^sub>A x))" and "f' \<in> A \<rightarrow>\<^sub>E B" unfolding domain_and_range_permutation_def by auto have "bij_betw f A B \<longleftrightarrow> bij_betw (p\<^sub>B o f' o p\<^sub>A) A B" using \<open>\<forall>x\<in>A. f x = p\<^sub>B (f' (p\<^sub>A x))\<close> bij_betw_congI by fastforce also have "... \<longleftrightarrow> bij_betw (p\<^sub>B o f') A B" using \<open>p\<^sub>A permutes A\<close> by (auto intro!: bij_betw_comp_iff[symmetric] permutes_imp_bij) also have "... \<longleftrightarrow> bij_betw f' A B" using \<open>f' \<in> A \<rightarrow>\<^sub>E B\<close> \<open>p\<^sub>B permutes B\<close> by (auto intro!: bij_betw_comp_iff2[symmetric] permutes_imp_bij) finally show "bij_betw f A B \<longleftrightarrow> bij_betw f' A B" . qed lemma count_image_mset': "count (image_mset f A) x = sum (count A) {x' \<in> set_mset A. f x' = x}" proof - have "count (image_mset f A) x = sum (count A) (f -` {x} \<inter> set_mset A)" unfolding count_image_mset .. also have "\<dots> = sum (count A) {x' \<in> set_mset A. f x' = x}" proof - have "(f -` {x} \<inter> set_mset A) = {x' \<in> set_mset A. f x' = x}" by blast from this show ?thesis by simp qed finally show ?thesis . qed lemma multiset_of_partition_cards_respects_domain_and_range_permutation: assumes "finite B" shows "(\<lambda>f. image_mset (\<lambda>X. card X) (mset_set (((\<lambda>b. {x \<in> A. f x = b})) ` B - {{}}))) respects domain_and_range_permutation A B" proof (rule congruentI) fix f f' assume "(f, f') \<in> domain_and_range_permutation A B" from this obtain p\<^sub>A p\<^sub>B where "p\<^sub>A permutes A" "p\<^sub>B permutes B" "\<forall>x\<in>A. f x = p\<^sub>B (f' (p\<^sub>A x))" unfolding domain_and_range_permutation_def by auto have "(\<lambda>b. {x \<in> A. f x = b}) ` B = (\<lambda>b. {x \<in> A. p\<^sub>B (f' (p\<^sub>A x)) = b}) ` B" using \<open>\<forall>x\<in>A. f x = p\<^sub>B (f' (p\<^sub>A x))\<close> by auto from this have "image_mset card (mset_set ((\<lambda>b. {x \<in> A. f x = b}) ` B - {{}})) = image_mset card (mset_set ((\<lambda>b. {x \<in> A. p\<^sub>B (f' (p\<^sub>A x)) = b}) ` B - {{}}))" by simp also have "image_mset card (mset_set ((\<lambda>b. {x \<in> A. p\<^sub>B (f' (p\<^sub>A x)) = b}) ` B - {{}})) = image_mset card (mset_set ((\<lambda>b. {x \<in> A. f' (p\<^sub>A x) = b}) ` B - {{}}))" using permutes_implies_inv_image_on_eq[OF \<open>p\<^sub>B permutes B\<close>, of A] by metis also have "image_mset card (mset_set ((\<lambda>b. {x \<in> A. f' (p\<^sub>A x) = b}) ` B - {{}})) = image_mset card (mset_set ((\<lambda>b. {x \<in> A. f' x = b}) ` B - {{}}))" proof (rule multiset_eqI) fix n have "bij_betw (\<lambda>X. p\<^sub>A ` X) {X \<in> (\<lambda>b. {x \<in> A. f' (p\<^sub>A x) = b}) ` B - {{}}. card X = n} {X \<in> (\<lambda>b. {x \<in> A. f' x = b}) ` B - {{}}. card X = n}" proof (rule bij_betw_byWitness) show "\<forall>X\<in>{X \<in> (\<lambda>b. {x \<in> A. f' (p\<^sub>A x) = b}) ` B - {{}}. card X = n}. inv p\<^sub>A ` p\<^sub>A ` X = X" by (meson \<open>p\<^sub>A permutes A\<close> image_inv_f_f permutes_inj) show "\<forall>X\<in>{X \<in> (\<lambda>b. {x \<in> A. f' x = b}) ` B - {{}}. card X = n}. p\<^sub>A ` inv p\<^sub>A ` X = X" by (meson \<open>p\<^sub>A permutes A\<close> image_f_inv_f permutes_surj) show "(\<lambda>X. p\<^sub>A ` X) ` {X \<in> (\<lambda>b. {x \<in> A. f' (p\<^sub>A x) = b}) ` B - {{}}. card X = n} \<subseteq> {X \<in> (\<lambda>b. {x \<in> A. f' x = b}) ` B - {{}}. card X = n}" proof - have "card (p\<^sub>A ` {x \<in> A. f' (p\<^sub>A x) = b}) = card {x \<in> A. f' (p\<^sub>A x) = b}" for b proof - have "inj_on p\<^sub>A {x \<in> A. f' (p\<^sub>A x) = b}" by (metis (no_types, lifting) \<open>p\<^sub>A permutes A\<close> injD inj_onI permutes_inj) from this show ?thesis by (simp add: card_image) qed moreover have "p\<^sub>A ` {x \<in> A. f' (p\<^sub>A x) = b} = {x \<in> A. f' x = b}" for b proof show "p\<^sub>A ` {x \<in> A. f' (p\<^sub>A x) = b} \<subseteq> {x \<in> A. f' x = b}" by (auto simp add: \<open>p\<^sub>A permutes A\<close> permutes_in_image) show "{x \<in> A. f' x = b} \<subseteq> p\<^sub>A ` {x \<in> A. f' (p\<^sub>A x) = b}" proof fix x assume "x \<in> {x \<in> A. f' x = b}" moreover have "p\<^sub>A (inv p\<^sub>A x) = x" using \<open>p\<^sub>A permutes A\<close> permutes_inverses(1) by fastforce moreover from \<open>x \<in> {x \<in> A. f' x = b}\<close> have "inv p\<^sub>A x \<in> A" by (simp add: \<open>p\<^sub>A permutes A\<close> permutes_in_image permutes_inv) ultimately show "x \<in> p\<^sub>A ` {x \<in> A. f' (p\<^sub>A x) = b}" by (auto intro: image_eqI[where x="inv p\<^sub>A x"]) qed qed ultimately show ?thesis by auto qed show "(\<lambda>X. inv p\<^sub>A ` X) ` {X \<in> (\<lambda>b. {x \<in> A. f' x = b}) ` B - {{}}. card X = n} \<subseteq> {X \<in> (\<lambda>b. {x \<in> A. f' (p\<^sub>A x) = b}) ` B - {{}}. card X = n}" proof - have "card (inv p\<^sub>A ` {x \<in> A. f' x = b}) = card {x \<in> A. f' x = b}" for b proof - have "inj_on (inv p\<^sub>A) {x \<in> A. f' x = b}" by (metis (no_types, lifting) \<open>p\<^sub>A permutes A\<close> injD inj_onI permutes_surj surj_imp_inj_inv) from this show ?thesis by (simp add: card_image) qed moreover have "inv p\<^sub>A ` {x \<in> A. f' x = b} = {x \<in> A. f' (p\<^sub>A x) = b}" for b proof show "inv p\<^sub>A ` {x \<in> A. f' x = b} \<subseteq> {x \<in> A. f' (p\<^sub>A x) = b}" using \<open>p\<^sub>A permutes A\<close> by (auto simp add: permutes_in_image permutes_inv permutes_inverses(1)) show "{x \<in> A. f' (p\<^sub>A x) = b} \<subseteq> inv p\<^sub>A ` {x \<in> A. f' x = b}" proof fix x assume "x \<in> {x \<in> A. f' (p\<^sub>A x) = b}" moreover have "inv p\<^sub>A (p\<^sub>A x) = x" by (meson \<open>p\<^sub>A permutes A\<close> permutes_inverses(2)) moreover from \<open>x \<in> {x \<in> A. f' (p\<^sub>A x) = b}\<close> have "p\<^sub>A x \<in> A" by (simp add: \<open>p\<^sub>A permutes A\<close> permutes_in_image) ultimately show "x \<in> inv p\<^sub>A ` {x \<in> A. f' x = b}" by (auto intro: image_eqI[where x="p\<^sub>A x"]) qed qed ultimately show ?thesis by auto qed qed from this have "card {x' \<in> (\<lambda>b. {x \<in> A. f' (p\<^sub>A x) = b}) ` B - {{}}. card x' = n} = card {x' \<in> (\<lambda>b. {x \<in> A. f' x = b}) ` B - {{}}. card x' = n}" by (rule bij_betw_same_card) from this show "count (image_mset card (mset_set ((\<lambda>b. {x \<in> A. f' (p\<^sub>A x) = b}) ` B - {{}}))) n = count (image_mset card (mset_set ((\<lambda>b. {x \<in> A. f' x = b}) ` B - {{}}))) n" using \<open>finite B\<close> by (simp add: count_image_mset') qed finally show "image_mset card (mset_set ((\<lambda>b. {x \<in> A. f x = b}) ` B - {{}})) = image_mset card (mset_set ((\<lambda>b. {x \<in> A. f' x = b}) ` B - {{}}))" . qed end
%% 2019 NeuroFedora contributors %% packages %% % support for coloured text \usepackage{xcolor} \definecolor{FedoraBlue}{cmyk}{1.0,0.46,0.0,0.0} \definecolor{FedoraDarkBlue}{cmyk}{1.0,0.57,0.0,0.38} \definecolor{FriendsMagenta}{cmyk}{0.0,0.8,0.4,0.0} \definecolor{FeaturesOrange}{cmyk}{0.0,0.5,1.0,0.0} \definecolor{FirstGreen}{cmyk}{0.5,0.0,1.0,0.0} \definecolor{FreedomPurple}{cmyk}{0.57,0.46,0.0,0.0} % IPA \usepackage{tipa} \usepackage[scale=2]{ccicons} \usepackage{amssymb} \usepackage{tikz} \usetikzlibrary{arrows.meta, arrows, positioning} \usepackage{jneurosci} \usepackage{subfig} \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} \usepackage[style=verbose,backend=biber,autocite=footnote]{biblatex} \addbibresource{masterbib.bib} % Use opensans \usepackage[default,osfigures,scale=0.95]{opensans} % for strike through \usepackage[normalem]{ulem} % links, urls, refs \usepackage{hyperref} \hypersetup{colorlinks,linkcolor=FreedomPurple,urlcolor=FreedomPurple} % graphics \usepackage{graphicx} % algorithm \usepackage{algorithmic} \usepackage{textcomp} \usepackage{wrapfig} \usepackage{textgreek} \usepackage{euler} \usepackage{ccicons} \usepackage{pdfpages} % \usepackage{minted} % beamer theme \usetheme[numbering=fraction]{metropolis} \usefonttheme[onlymath]{serif} \setbeamerfont{footnote}{size=\tiny} \setbeamerfont{caption}{size=\tiny} \setbeamercolor{alerted text}{fg=FeaturesOrange} \setbeamercolor{progress bar}{fg=FriendsMagenta} \setbeamercolor{title separator}{fg=FriendsMagenta} \setbeamercolor{frametitle}{bg=FedoraDarkBlue} \renewcommand{\figurename}{} % Not needed in metropolis, but in general footnote citation fixes: https://tex.stackexchange.com/questions/44217/how-can-i-stop-footcite-from-hijacking-my-beamer-columns % how to use multiple references to the same footnote: https://tex.stackexchange.com/questions/27763/beamer-multiple-references-to-the-same-footnote %% title %% \title[Journal club]{Standards and Tools in Neuroscience} \subtitle{A summary of the Open Source Brain workshop, September 2019} \author{Ankur Sinha\\Ph.D. candidate: UH Biocomputation Group, UK,\\Volunteer: Fedora Project.} \date[]{} %% document begins %% \begin{document} % title frame %% \begin{frame} \titlepage{} \end{frame} %% 3 slides for 5 minutes, so 30 slides for 45 minutes. \section{The problem statement} \begin{frame}[c]{Neuroscience is complex, and massive} \begin{figure}[h] \centering \only<1>{\input{images/Neuroscience-cycle}}% \only<2>{\input{images/Neuroscience-cycle-complex}} \note[item]{A simplified diagram. Actually a lot more complex} \end{figure} \note[item]{It is so massive that you can speak to another neuroscientist and not understand a word of what they say---we specialise} \note[item]{We won't even discuss dissemination to a non scientific audience today---a completely different problem.} \end{frame} \begin{frame}[c]{Free/Open Neuroscience} Free/Open science:\\Scientific material should be easily, openly \alert{accessible to all}. \end{frame} { \setbeamercolor{background canvas}{bg=} \includepdf[pages={22,4,5}]{./2019-OSB-slides/OSB_introduction_Final_Angus.pdf} } \section{Standards: the common tongue} { \setbeamercolor{background canvas}{bg=} \includepdf[pages={1,4,15,27,29}]{./2019-OSB-slides/2019_09_09_opensourcebrain_nwbn_overview.pdf} \includepdf[pages={1,5,7}]{./2019-OSB-slides/NWBExplorerOSBMeeting2019.pdf} \includepdf[pages={1,7,15,25,32,33}]{./2019-OSB-slides/MultiscaleNetworksNeuroML_Sardinia19.pdf} \includepdf[pages={1,2,7,8,9,10,11,13}]{./2019-OSB-slides/BorisMarin_Sardinia2019.pdf} } \begin{frame}[c]{Netpyne workflow} \begin{figure}[h] \centering \includegraphics[width=\linewidth]{images/netpyne.png} \end{figure} \end{frame} \begin{frame}[c]{Netpyne GUI} \begin{figure}[h] \centering \includegraphics[width=\linewidth]{images/netpyne-gui.png} \end{figure} \end{frame} { \setbeamercolor{background canvas}{bg=} \includepdf[pages={1,2,3,4,25,26}]{./2019-OSB-slides/2019-09-OSB_YazanBilleh_v2.pdf}%chktex 8 \includepdf[pages={1,3,7,8,9,23,29}]{./2019-OSB-slides/OSB_2019_yann.pdf} } \section{NeuroFedora: marketing pitch} \begin{frame}[c]{Liaison between developers and users} \begin{figure}[h] \begin{center} \begin{tikzpicture}[scale=1, transform shape] \fill[fill=FedoraBlue, text=white, rounded corners] (0, 0) rectangle ++(8, 1) node[pos=0.5] (A){Developers (upstream)}; \fill[fill=FeaturesOrange, text=white, rounded corners] (0, -2) rectangle ++(8, 1) node[pos=0.5] (B){Distributions: Fedora/Debian \ldots}; \draw [FriendsMagenta, very thick, ->] (2, 0) -- node [midway, right, text centered] {code} node [midway, left, text centered] {support} ++(0, -1) ; \draw [FriendsMagenta, very thick, ->] (6, -1) -- node [midway, right, text centered] {code} node [midway, left, text centered] {feedback} ++(0, 1) ; \fill[fill=FirstGreen, text=white, rounded corners] (0, -4) rectangle ++(8, 1) node[pos=0.5] (B){End users (downstream)}; \draw [FriendsMagenta, very thick, ->] (2, -2) -- node [midway, right, text centered] {binaries} node [midway, left, text centered] {support} ++(0, -1) ; \draw [FriendsMagenta, very thick, ->] (6, -3) -- node [midway, right, text centered] {feedback} ++(0, 1) ; \end{tikzpicture} \end{center} \end{figure} \end{frame} \begin{frame}[c]{Search: \enquote{NeuroFedora}} \begin{columns} \begin{column}{0.3\textwidth} \begin{figure}[h] \centering \includegraphics[width=\linewidth]{images/NeuroFedoraBadge.png} \end{figure} \end{column} \begin{column}{0.8\textwidth} \textcolor{FeaturesOrange}{\enquote{Live} ISO now ready to download (demo)}\\ \textcolor{FedoraBlue}{Mailing list:\ [email protected]}\\ \textcolor{FirstGreen}{IRC:\ \#fedora-neuro on Freenode}\\ \textcolor{FeaturesOrange}{Telegram:\ t.me/NeuroFedora}\\ \textcolor{FriendsMagenta}{Documentation\ neuro.fedoraproject.org}\\ \textcolor{FirstGreen}{Blog:\ neuroblog.fedoraproject.org}\\ \textcolor{FeaturesOrange}{Pagure.io (FOSS Git forge):\ neuro-sig/NeuroFedora} \end{column} \end{columns} \end{frame} \begin{frame}[c]{License} \begin{center} \ccbysa{}\\ \vspace{0.5cm} This presentation is made available under a \href{https://creativecommons.org/licenses/by-sa/4.0/}{Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license}.\\ \end{center} \end{frame} \end{document}
module Basic.Compiler.CorrectFrom where open import Basic.AST open import Basic.BigStep open import Basic.Compiler.Code open import Basic.Compiler.SplitCode open import Utils.NatOrdLemmas open import Utils.Decidable open import Utils.Monoid open import Data.Fin using (Fin; #_) open import Data.Vec hiding (_∷ʳ_; _++_; [_]; _∈_; foldr) open import Data.Nat open import Data.Nat.Properties.Simple open import Data.Nat.Properties open import Data.Empty open import Data.Bool renaming (not to notBool; if_then_else_ to ifBool_then_else) open import Data.List hiding ([_]) open import Data.List.Properties open import Relation.Binary.PropositionalEquality open import Function open import Data.Product open import Relation.Nullary open import Relation.Nullary.Decidable import Level as L open import Algebra private module LM {a A} = Algebra.Monoid (Data.List.monoid {a} A) open import Relation.Unary open import Induction.Nat open import Induction.WellFounded {- Lemma 3.22 This proof caused me considerable headache. First I started to prove it by strctural recursion on the to-be-compiled statement, but then Agda complained that it was not structurally recursive. And indeed it isn't. In the "while-true" case, we start with a program derivation of the type: ⟨ 𝓒⟦ S ⟧ˢ ++ LOOP 𝓒⟦ b ⟧ᵉ 𝓒⟦ S ⟧ˢ ∷ [] , [] , s ⟩▷*⟨ [] , e , s' ⟩ And a statement with the following form: while b do S Then we split this derivation into two parts: ⟨ 𝓒⟦ S ⟧ˢ , [] , s ⟩▷*⟨ [] , e'' , s'' ⟩ ⟨ LOOP 𝓒⟦ b ⟧ᵉ 𝓒⟦ S ⟧ˢ ∷ [] , e'' , s'' ⟩▷*⟨ [] , e , s' ⟩ But now if we recurse on the second derivation, the corresponding statement will be again "while b do S". Thus Agda will not be able to prove termination. So I had to use well-founded induction. It is a standard library machinery that allows us to do induction on a well-ordered set. Here's an introduction to how it works: http://blog.ezyang.com/2010/06/well-founded-recursion-in-agda/ We usually prefer to not use well-founded recursion, because it demands us proofs of decreasing order even on cases where recursion is otherwise evidently structural, and it also makes certain proofs rather difficult. -} -- Well-foundedness lemmas ------------------------------------------------------------ {- We do well-founded recursion on the length of derivation sequences. But we also have to prove that splitting a derivation sequence will never produce empty sequences, or else the lenghts will not be strictly decreasing. To show this, we have to show that - compilation into abstract machine code never outputs an empty list of instructions - computation sequences starting with a non-empty instruction list are never empty -} ∷ʳ-nonempty : ∀ {a}{A : Set a}(xs : List A) x → xs ∷ʳ x ≢ [] ∷ʳ-nonempty [] x () ∷ʳ-nonempty (x ∷ xs) x₁ () ++-xs-empty : ∀ {a}{A : Set a}(xs : List A) {ys} → xs <> ys ≡ [] → xs ≡ [] ++-xs-empty [] p = refl ++-xs-empty (x ∷ xs) () {- Compiled statement are non-empty -} 𝓒ˢ-nonempty : ∀ {n}(S : St n) → 𝓒⟦ S ⟧ˢ ≢ [] 𝓒ˢ-nonempty (x := x₁) = ∷ʳ-nonempty 𝓒⟦ x₁ ⟧ᵉ (STORE x) 𝓒ˢ-nonempty (S , S₁) = 𝓒ˢ-nonempty S ∘ ++-xs-empty 𝓒⟦ S ⟧ˢ 𝓒ˢ-nonempty (if x then S else S₁) = ∷ʳ-nonempty 𝓒⟦ x ⟧ᵉ (BRANCH 𝓒⟦ S ⟧ˢ 𝓒⟦ S₁ ⟧ˢ) 𝓒ˢ-nonempty (while x do S) () 𝓒ˢ-nonempty skip () {- Compiled expressions are non-empty -} 𝓒-Exp-nonempty : ∀ {n t} (e : Exp n t) → 𝓒⟦ e ⟧ᵉ ≢ [] 𝓒-Exp-nonempty (add e e₁) = ∷ʳ-nonempty (𝓒⟦ e₁ ⟧ᵉ <> 𝓒⟦ e ⟧ᵉ) ADD 𝓒-Exp-nonempty (mul e e₁) = ∷ʳ-nonempty (𝓒⟦ e₁ ⟧ᵉ <> 𝓒⟦ e ⟧ᵉ) MUL 𝓒-Exp-nonempty (sub e e₁) = ∷ʳ-nonempty (𝓒⟦ e₁ ⟧ᵉ <> 𝓒⟦ e ⟧ᵉ) SUB 𝓒-Exp-nonempty (eq e e₁) = ∷ʳ-nonempty (𝓒⟦ e₁ ⟧ᵉ <> 𝓒⟦ e ⟧ᵉ) EQ 𝓒-Exp-nonempty (lte e e₁) = ∷ʳ-nonempty (𝓒⟦ e₁ ⟧ᵉ <> 𝓒⟦ e ⟧ᵉ) LTE 𝓒-Exp-nonempty (lt e e₁) = ∷ʳ-nonempty (𝓒⟦ e₁ ⟧ᵉ <> 𝓒⟦ e ⟧ᵉ) LT 𝓒-Exp-nonempty (Exp.and e e₁) = ∷ʳ-nonempty (𝓒⟦ e₁ ⟧ᵉ <> 𝓒⟦ e ⟧ᵉ) AND 𝓒-Exp-nonempty (not e) = ∷ʳ-nonempty 𝓒⟦ e ⟧ᵉ NOT 𝓒-Exp-nonempty (lit x) () 𝓒-Exp-nonempty (var x) () 𝓒-Exp-nonempty tt () 𝓒-Exp-nonempty ff () {-Computations sequences for non-empty code are non-zero length -} ▷*-S-nonempty : ∀ {n S}{s s' : State n}{e e'} (p : ⟨ 𝓒⟦ S ⟧ˢ , e , s ⟩▷*⟨ [] , e' , s' ⟩) → ▷*-length p ≢ 0 ▷*-S-nonempty{_}{S} p x with 𝓒ˢ-nonempty S | 𝓒⟦ S ⟧ˢ | inspect 𝓒⟦_⟧ˢ S ▷*-S-nonempty done x | ¬empty | [] | [ remember ] = ¬empty remember ▷*-S-nonempty (() ∷ p) x₁ | ¬empty | [] | [ remember ] ▷*-S-nonempty (x₁ ∷ p) () | ¬empty | x ∷ cs | [ remember ] {- misc ordering lemmas -} a<′a+sb : ∀ a b → b ≢ 0 → a <′ a + b a<′a+sb a zero x = ⊥-elim (x refl) a<′a+sb a (suc b) x rewrite +-comm a (suc b) = ≤⇒≤′ $ a<sb+a a b a<′b+sa : ∀ a b → a <′ b + suc a a<′b+sa a zero = ≤′-refl a<′b+sa a (suc b) = ≤′-step (a<′b+sa a b) ≤′-weaken-l : ∀ {a b} c → a ≤′ b → a ≤′ c + b ≤′-weaken-l zero p = p ≤′-weaken-l (suc c) p = ≤′-step (≤′-weaken-l c p) -- Correctness ------------------------------------------------------------ {- This is a shorthand for the actual type of the theorem. We use this because otherwise we'd have to write out the type three times in the following code. -} 𝓒-correct-from-Ty : {_ : ℕ} → ℕ → Set 𝓒-correct-from-Ty {n} size = ∀ {S : St n} {e s s'} → (p : ⟨ 𝓒⟦ S ⟧ˢ , [] , s ⟩▷*⟨ [] , e , s' ⟩) → size ≡ ▷*-length p → ⟨ S , s ⟩⟱ s' × e ≡ [] 𝓒-correct-from : ∀ {n} size → 𝓒-correct-from-Ty {n} size 𝓒-correct-from {n} = <-rec _ go where {- Note: we use ▷*-deterministic quite a few times below. We separately use ▷*-split to split the sequence and 𝓒-Exp to establish the contents of the stack after evaluating an expression, but these remain separate facts until we use determinism to prove that the first split sequence and 𝓒-Exp's resulting sequence are the same. We see 𝓒-Exp , ▷*-split and ▷*-deterministic chained together several times below. This is admittedly pretty ugly and it would be better to factor out this pattern and possibly include all the relevant information in the output of ▷*-split. -} {- "go" is the helper function for well-founded recursion. "<-rec" can be viewed as a sort of a fixpoint operator that demands a proof that the argument strictly decreases on every recursion. "size" is the size argument, and we recurse via the "recurse" argument. -} go : ∀ size → (∀ y → y <′ size → 𝓒-correct-from-Ty {n} y) → 𝓒-correct-from-Ty {n} size -- Assignment go size recurse {x := exp}{e}{s} p sizeEq with ▷*-split 𝓒⟦ exp ⟧ᵉ p | 𝓒-Exp-nat {e = []}{s = s} exp go size recurse {.x := exp} p sizeEq | s₁ , ._ , p1 , STORE x ∷ () ∷ p2 , eqn | exp' go size recurse {.x := exp} p sizeEq | s₁ , ._ , p1 , STORE x ∷ done , eqn | exp' with ▷*-deterministic p1 exp' ... | _ , eqe , eqs rewrite eqs with ∷-injective eqe ... | eq-cond , e≡[] rewrite nat-inj eq-cond = ass , e≡[] -- Skip go size recurse {skip} (NOOP ∷ done) sizeEq = skip , refl go size recurse {skip} (NOOP ∷ () ∷ p) sizeEq -- Sequencing go size recurse {S , S₁} p sizeEq with ▷*-split 𝓒⟦ S ⟧ˢ p ... | s'' , e'' , p1 , p2 , size+eq rewrite sizeEq | sym size+eq with recurse _ (a<′a+sb _ _ (▷*-S-nonempty {S = S₁} p2)) {S} p1 refl ... | p1' , e''≡[] rewrite e''≡[] | +-comm (▷*-length p1) (▷*-length p2) with recurse _ (a<′a+sb _ _ (▷*-S-nonempty {S = S} p1)) {S₁} p2 refl ... | p2' , e≡[] = (p1' , p2') , e≡[] -- If then else go size recurse {if b then S else S₁} {e}{s}{s'} p sizeEq with ▷*-split 𝓒⟦ b ⟧ᵉ p | 𝓒-Exp-bool {e = []}{s = s} b ... | s'' , ._ , p1 , BRANCH ∷ p2 , size+eq | b' with ▷*-deterministic p1 b' ... | _ , eqe , eqs rewrite eqs with ∷-injective eqe ... | eq-cond , e'≡[] rewrite bool-inj eq-cond | e'≡[] | proj₂ LM.identity (ifBool ⟦ b ⟧ᵉ s then 𝓒⟦ S ⟧ˢ else 𝓒⟦ S₁ ⟧ˢ) | sizeEq | sym size+eq with ⟦ b ⟧ᵉ s | inspect ⟦ b ⟧ᵉ s ... | true | [ condTrue ] = (if-true (≡true→T condTrue) (proj₁ rest)) , proj₂ rest where rest : ⟨ S , s ⟩⟱ s' × e ≡ [] rest = recurse (▷*-length p2) (a<′b+sa (▷*-length p2) (▷*-length p1)) p2 refl ... | false | [ condFalse ] = (if-false (≡false→F condFalse) (proj₁ rest)) , proj₂ rest where rest : ⟨ S₁ , s ⟩⟱ s' × e ≡ [] rest = recurse (▷*-length p2) (a<′b+sa (▷*-length p2) (▷*-length p1)) p2 refl -- While go size recurse {while b do S}{e}{s}{s'} (LOOP ∷ p) sizeEq with 𝓒-Exp-bool {e = []}{s = s} b | ▷*-split 𝓒⟦ b ⟧ᵉ p ... | b' | s'' , ._ , p1 , BRANCH ∷ p2 , size+eq with ▷*-deterministic p1 b' ... | _ , eqe , eqs rewrite eqs with ∷-injective eqe ... | eq-cond , e'≡[] rewrite bool-inj eq-cond | e'≡[] | proj₂ LM.identity (ifBool ⟦ b ⟧ᵉ s then 𝓒⟦ S ⟧ˢ ++ LOOP 𝓒⟦ b ⟧ᵉ 𝓒⟦ S ⟧ˢ ∷ [] else (NOOP ∷ [])) | sym size+eq | sizeEq with ⟦ b ⟧ᵉ s | inspect ⟦ b ⟧ᵉ s {- Here we the proofs are a bit messed up by the two recursive calls with hideous hand-crafted proofs of size decrease. This is the sort of thing where Coq's solvers and tactics for arithmetic are really handy. Unfortunately we don't yet have those things in Agda, although there is some infrastructure already in place that could be used to create more automatization (like typeclasses and goal reflection) -} -- while-true ... | true | [ condTrue ] = 𝓒-while-true condTrue p2 refl where 𝓒-while-true : ∀ {s s' : State n}{b e S} → ⟦ b ⟧ᵉ s ≡ true → (p3 : ⟨ 𝓒⟦ S ⟧ˢ ++ LOOP 𝓒⟦ b ⟧ᵉ 𝓒⟦ S ⟧ˢ ∷ [] , [] , s ⟩▷*⟨ [] , e , s' ⟩) → (▷*-length p3 ≡ ▷*-length p2) → (⟨ while b do S , s ⟩⟱ s') × e ≡ [] 𝓒-while-true {s}{s'}{b}{e}{S} condTrue p3 ≡len with ▷*-split 𝓒⟦ S ⟧ˢ p3 ... | s'' , e'' , p1_new , p2_new , size+eq rewrite sym size+eq with recurse (▷*-length p1_new) (≤′-step (subst (λ x → suc (▷*-length p1_new) ≤′ ▷*-length p1 + suc x) ≡len (≤′-weaken-l (▷*-length p1) (≤′-step (a<′a+sb (▷*-length p1_new) (▷*-length p2_new) (▷*-S-nonempty {S = while b do S} p2_new)))))) {S} p1_new refl ... | p1' , e''≡[] rewrite e''≡[] with recurse (▷*-length p2_new) (≤′-step (subst (λ x → suc (▷*-length p2_new) ≤′ ▷*-length p1 + suc x) ≡len (≤′-weaken-l (▷*-length p1) (≤′-step ( subst (λ x → ▷*-length p2_new <′ x) (+-comm (▷*-length p2_new) (▷*-length p1_new)) (a<′a+sb (▷*-length p2_new) (▷*-length p1_new) (▷*-S-nonempty {S = S} p1_new))))))) {while b do S} p2_new refl ... | p2' , e≡[] = (while-true (≡true→T condTrue) p1' p2') , e≡[] -- while-false ... | false | [ condFalse ] = 𝓒-while-false condFalse p2 where 𝓒-while-false : ∀ {n}{s s' : State n}{e b S} → ⟦ b ⟧ᵉ s ≡ false → ⟨ NOOP ∷ [] , [] , s ⟩▷*⟨ [] , e , s' ⟩ → (⟨ while b do S , s ⟩⟱ s' × e ≡ []) 𝓒-while-false f (NOOP ∷ done) = (while-false (≡false→F f)) , refl 𝓒-while-false f (NOOP ∷ () ∷ p)
import Lightyear import Lightyear.Strings import Network.Socket import Prelude.Strings import System import System.Concurrency.Process import Data.Vect import HydraBot.Types import HydraBot.NetworkUtils ||| Check news/updates ||| @w A writer process id ||| @c A list of channels ||| @d Delay between checks, in seconds ||| @l A list of news loaders ||| @o A list of previous versions news' : (w: ProcID Message) -> (c: List String) -> (d: Int) -> (l: Vect n (String, IO (Maybe String))) -> (o: Vect n (Maybe String)) -> Process Message () news' writer channels delay loaders old = do Lift $ usleep $ delay * 1000000 new <- traverse check $ zip loaders old news' writer channels delay loaders new where check : ((String, IO (Maybe String)), Maybe String) -> Process Message (Maybe String) check ((name, load), o) = do n <- Lift load case (n, n == o) of (Just n', False) => do if (o /= Nothing) -- don't write right after [re]start then traverse (\x => send writer (cmsg x (name ++ ": " ++ n'))) channels else pure [] pure (Just n') (Nothing, False) => do Lift . putStrLn $ "Failed to retrieve: " ++ name pure o (_, _) => pure o ||| Check news/updates ||| @w A writer process id ||| @c A list of channels ||| @d Delay between checks, in seconds ||| @l A list of news loaders news : (w: ProcID Message) -> (c: List String) -> (d: Int) -> (l: Vect n (String, IO (Maybe String))) -> Process Message () news w c d l = news' w c d l (map (const Nothing) l) skipTill : String -> Parser String skipTill s = string s <|>| ((satisfy $ const True) *> (skipTill s)) tillChar : Char -> Parser String tillChar c = pack <$> many (satisfy $ (/= c)) ||| XKCD scraper xkcd : IO (Maybe String) xkcd = scrape "23.235.37.67" 80 req "</feed>" url where req = "GET /atom.xml HTTP/1.0\r\nHost: xkcd.com\r\n" url : Parser String url = do skipTill "<entry><title>" title <- tillChar '<' skipTill "<link href=\"" url <- tillChar '"' pure $ url ++ " (" ++ title ++ ")" ||| Invisible Bread scraper IB : IO (Maybe String) IB = scrape "104.28.24.25" 80 req "<link rel=\"shortcut" url where req = "GET / HTTP/1.0\r\nHost: invisiblebread.com\r\n" url : Parser String url = do skipTill "<meta property=\"og:url\" content=\"" url <- tillChar '"' pure url comics : Vect 2 (String, IO (Maybe String)) comics = [("XKCD", xkcd), ("Invisible Bread", IB)]
# 深度学习"圣经" | 第二章 线性代数 >深度学习领域圣经,英文原版的三位作者 Ian Goodfellow、Yoshua Bengio 和 Aaron Courville 本人仅对中文版深度学习书中,提炼笔记,添加个人理解,该笔记仅作为个人深度学习知识的学习、总结、复习使用。若有错误,还望批评指教。----ZJ 中文版 2017-09-04 版 pdf (PDF 阅读器打开 55) 第二章内容:中文版 P27 -,英文版 P31 - --- ## Chapter 2 Linear Algebra ### 2.1 标量、向量、矩阵和张量 学习线性代数,会涉及以下几类数学概念: - 标量(scalar):一个标量就是一个单独的数。 - 向量(vector):一个向量是一列数。 - $$ x=\begin{bmatrix} x_1\\ x_2\\\vdots\\x_n \end{bmatrix}.\tag{2.1}$$ - 矩阵(matrix):矩阵是一个二维数组,其中的每一个元素被两个索引(而非一个)所确定。 ### 2.2 矩阵和向量相乘 - 逐元乘积 (element-wise product): 两个矩阵的标准乘积不是指两个矩阵中对应元素的乘积。不过,那样的矩阵操作确实是存在的,被称为元素对应乘积(element-wise product)或者Hadamard 乘积(Hadamard product),记为 A ⊙ B。 - 点积(dot product): 两个相同维数的向量 x 和 y 的点积(dot product)可看作是矩阵乘积 $x^⊤y$。 矩阵乘积运算有许多有用的性质,从而使矩阵的数学分析更加方便。比如,矩阵乘积服从分配律: 两个向量的点积(dot product)满足交换律: 两个向量点积的结果是标量,标量转置是自身的事实 ### 2.3 单位矩阵和逆矩阵 单位矩阵(identity matrix):任意向量和单位矩阵相乘,都不会改变。 我们将保持 $n$ 维向量不变的单位矩阵记作 $I_{n}$。 形式上,$I_{n}\in R^{n\times n}$, \begin{equation} \forall x \in R^{n}, I_{n} x = x. \end{equation} 矩阵$A$的矩阵逆记作$A^{-1}$,其定义的矩阵满足如下条件 \begin{equation} A^{-1}A = I_{n}. \end{equation} \begin{gather} Ax=b A^{-1}Ax = A^{-1}b I_{n} x=A^{-1}b x=A^{-1}b. \end{gather} ### 2.4 线性相关和生成子空间 \begin{equation} A x = \sum_i x_i A_{:,i}. \end{equation} 线性组合(linear combination) \begin{equation} \sum_i c_i v^{(i)}. \end{equation} 一组向量的生成子空间(span)是原始向量线性组合后所能抵达的点的集合。 确定$Ax=b$是否有解相当于确定向量$b$是否在$A$列向量的生成子空间中。 这个特殊的生成子空间被称为$A$的列空间或者$A$的值域。 P61 (pdf)有点晕,找个相关视频看看 这种冗余被称为线性相关(linear dependence)。如果一组向量中的任意一个向量都不能表示成其他向量的线性组合,那么这组向量称为线性无关(linearly independent)。 这意味着该矩阵必须是一个方阵(square),即 m = n,并且所有列 向量都是线性无关的。一个列向量线性相关的方阵被称为奇异的(singular)。 ### 2.5 范数 **$L^p$ 范数:** 有时我们需要衡量一个向量的大小。在机器学习中,我们经常使用被称为 范数(norm)的函数衡量向量大小。形式上,$L^p$ 范数定义如下 $$||x||_p = (\sum_{i}|x_{i}|^p)^{\frac{1}{p}}\tag{2.30} $$ 其中 $p ∈\mathbb{R},p ≥ 1$。 范数(包括 $L^p$ 范数)是将向量映射到非负值的函数。 直观上来说,向量 $x$ 的范数衡量从原点到点 $x$ 的距离。 更严格地说,范数是满足下列性质的任意函数: - $f(x) = 0 \Rightarrow x = \mathbf{0}$ - $f(x + y) \leq f(x) + f(y)$ (三角不等式) - $\forall \alpha \in \mathbb{R}$, $f(\alpha x) = \alpha f(x)$ **$L^2$ 范数:** 当$p=2$时,$L^2$范数被称为欧几里得范数。 它表示从原点出发到向量 $x$ 确定的点的欧几里得距离。 $L^2$范数在机器学习中出现地十分频繁,经常简化表示为$||x||$,略去了下标$2$。 平方$L^2$范数也经常用来衡量向量的大小,可以简单地通过点积 $x^Tx$计算。 平方$L^2$范数在数学和计算上都比$L^2$范数本身更方便。 例如,平方$L^2$范数对$x$中每个元素的导数只取决于对应的元素,而$L^2$范数对每个元素的导数却和整个向量相关。 但是在很多情况下,平方$L^2$范数也可能不受欢迎,因为它在原点附近增长得十分缓慢。 **$L^1$ 范数:** 在某些机器学习应用中,区分恰好是零的元素和非零但值很小的元素是很重要的。 在这些情况下,我们转而使用在各个位置斜率相同,同时保持简单的数学形式的函数:$L^1$范数。 $L^1$范数可以简化如下: $$\lVert{x}_1\rVert = \sum_i |x_i|.\tag{2.31}$$ 当机器学习问题中零和非零元素之间的差异非常重要时,通常会使用 $L^1$ 范数。 每当$x$中某个元素从 $0$ 增加 $\epsilon$,对应的$L^1$范数也会增加 $\epsilon$。 **$L^0$ 范数:** 有时候我们会统计向量中非零元素的个数来衡量向量的大小。 有些作者将这种函数称为”$L^0$范数”,但是这个术语在数学意义上是不对的。 向量的非零元素的数目不是范数,因为对向量缩放$\alpha$倍不会改变该向量非零元素的数目。 **$L^1$范数经常作为表示非零元素数目的替代函数。** **$L^\infty$范数:** 另外一个经常在机器学习中出现的范数是$L^\infty$范数,也被称为\,最大范数(max norm)。 这个范数表示向量中具有最大幅值的元素的绝对值: $$ \lVert{x}_1\rVert _\infty = \max_i |x_i|.\tag{2.32}$$ **衡量矩阵的大小:** 有时候我们可能也希望衡量矩阵的大小。 在深度学习中,最常见的做法是使用 Frobenius 范数(Frobenius norm), $$\lVert A \rVert_F= \sqrt{\sum_{i,j} A_{i,j}^2}, $$ 其类似于向量的$L^2$范数。 **两个向量的点积(dot product)可以用范数**来表示。 具体地, $$ x^{\mathrm{T}}y =\lVert{x}\rVert_2\lVert{Y}\rVert_2 \cos \theta\tag{2.34}$$ 其中 $\theta$ 表示 $x$ 和 $y$ 之间的夹角。 ### 2.6 特殊类型的矩阵和向量 对角矩阵(diagonal matrix):只在主对角线上含有非零元素,其他位置都是零。 我们用 diag(v) 表示一个对角元素由向量 v 中元素给定的对角方阵。 计算乘法 diag(v)x,我们只需要将 x 中的每个元素$x_i$放大$v_i$ 倍。换言之,diag(v)x = v ⊙ x。 对称(symmetric)矩阵是转置和自己相等的矩阵: $A = A ^⊤ .$ 单位向量(unit vector)是具有单位范数(unit norm)的向量: $||x||_2 = 1.\tag{2.36}$ 正交(orthogonal): 如果 $x^⊤ y = 0$,那么向量 x 和向量 y 互相正交(orthogonal)。如果两个向量都有非零范数,那么这两个向量之间的夹角是 90 度。 标准正交(orthonormal): 在 R n 中,至多有 n 个范数非零向量互相正交。如果这些向量不仅互相正交,并且范数都为 1,那么我们称它们是标准正交(orthonormal)。 正交矩阵(orthogonal matrix)是指行向量和列向量是分别标准正交的方阵: \begin{equation} A^\top A=AA^\top=I. \end{equation} ### 2.7 特征分解 知乎:[如何理解矩阵特征值?](https://www.zhihu.com/question/21874816)https://www.zhihu.com/question/21874816 许多数学对象可以通过将它们分解成多个组成部分或者找到它们的一些属性而更好地理解,这些属性是通用的,而不是由我们选择表示它们的方式产生的。 整数可以分解为质因数。 12 = 2 × 2 × 3 正如我们可以通过分解质因数来发现整数的一些内在性质,我们也可以通过分解矩阵来发现矩阵表示成数组元素时不明显的函数性质。 特征分解(eigendecomposition)是使用最广的矩阵分解之一,即我们将矩阵分解成一组**特征向量和特征值。** 方阵 A 的**特征向量**(eigenvector)是指与 A 相乘后相当于对该向量进行缩放的非零向量 $v$: $$Av = λv.$$ - 标量 λ 被称为这个特征向量对应的特征值(eigenvalue) 假设矩阵$A$有$n$个线性无关的特征向量${v^{(1)}, \dots, v^{(n)}}$,对应着特征值${\lambda_1, \dots , \lambda_n }$。 我们将特征向量连接成一个矩阵,使得每一列是一个特征向量:$V=[v^{(1)}, \dots, v^{(n)}]$. 类似地,我们也可以将特征值连接成一个向量$lambda = [\lambda_1, \dots , \lambda_n]^\top$。 因此$A$的特征分解可以记作 \begin{equation} A = V \text{diag}\lambda V^{-1}. \end{equation} 然而,我们也常常希望将矩阵分解(decompose)成特征值和特征向 量。这样可以帮助我们分析矩阵的特定性质,就像质因数分解有助于我们理解整数。 **实对称矩阵都可以分解成实特征向量和实特征值:** P66 找个视频看看 $$A = QΛQ^ ⊤$$ . (2.41) ### 2.8 奇异值分解 知乎:[奇异值的物理意义是什么?](https://www.zhihu.com/question/22237507)https://www.zhihu.com/question/22237507 另一种分解矩阵的方法,被称为奇异值分解(singular value decomposition, SVD),将矩阵分解为奇异向量(singular vector)和奇异值(singular value)。 特征分解: $$A = Vdiag(λ)V^{−1}$$ . 奇异值分解是类似的,只不过这回我们将矩阵 A 分解成三个矩阵的乘积: $$A = UDV^⊤$$ . 假设 A 是一个 m×n 的矩阵,那么 U 是一个 m×m 的矩阵,D 是一个 m×n的矩阵,V 是一个 n × n 矩阵。 矩阵 U 和 V 都定义为正交矩阵,而矩阵 D 定义为对角矩阵。注意,矩阵 D 不一定是方阵。 ### 2.9 Moore-Penrose 伪逆 CSDN:[Moore-Penrose广义逆矩阵](http://blog.csdn.net/theonegis/article/details/50964746) Moore-Penrose 伪逆(Moore-Penrose pseudoinverse)使我们在这类问题上取得了一定的进展。矩阵 A 的伪逆定义为: ### 2.10 迹运算 迹运算返回的是矩阵对角元素的和: ### 2.11 行列式 知乎:[行列式的本质是什么?](https://www.zhihu.com/question/36966326/answer/70687817) 行列式就是线性变换的放大率! 行列式,记作 det(A),是一个将方阵 A 映射到实数的函数。行列式等于矩阵特征值的乘积。行列式的绝对值可以用来衡量矩阵参与矩阵乘法后空间扩大或者缩小了多少。如果行列式是 0,那么空间至少沿着某一维完全收缩了,使其失去了所有的体积。如果行列式是 1,那么这个转换保持空间体积不变。 ### 2.12 实例:主成分分析 PCA 知乎:[PCA的数学原理(转)](https://zhuanlan.zhihu.com/p/21580949) [主成分分析PCA算法:为什么去均值以后的高维矩阵乘以其协方差矩阵的特征向量矩阵就是“投影”?](https://www.zhihu.com/question/30094611/answer/275172932)https://www.zhihu.com/question/30094611/answer/275172932 主成分分析(principal components analysis, PCA)是一个简单的机器学习算法,可以通过基础的线性代数知识推导。
from __future__ import print_function import os import sys import numpy as np from urllib import urlopen import yaml from cStringIO import StringIO from PIL import Image train_ratio = 0.8 minsize = 256 def save_product_image(path, i, j, url): # Set path and filename filename = "%02d_%02d.jpg" % (i, j) dest = path + filename # Includes start of filename try: # Download image f = StringIO(urlopen(url).read()) img = Image.open(f) # Resize file to appropriate dimensions ratio = float(img.size[0])/float(img.size[1]) \ if img.size[0]>img.size[1] \ else float(img.size[1])/float(img.size[0]) size = int(minsize * ratio) img.thumbnail((size, size), Image.ANTIALIAS) # Save file img.save(dest) except Exception as e: print("Exception raised for [%d, %d, %d, %s]" % (index, i, j, url)) if __name__=="__main__": with open('paths.yaml', 'r') as f: paths = yaml.load(f) train_img_dir = paths['train_img_dir'] val_img_dir = paths['val_img_dir'] urls = np.load("image_urls.npy") val_index_start = int(train_ratio * int(urls[-1][0])) count = 0 for index, i, j, url in urls: index, i, j = int(index), int(i), int(j) # Create folder for the group of colour variants DIR = train_img_dir if index<val_index_start else val_img_dir superpath = DIR + str("%05d" % int(index/1500)) + "/" path = superpath + str("%04d" % int(index%1500)) + "/" # This is the path for each group of colour variants if not os.path.exists(path): os.makedirs(path) save_product_image(path, i, j, url) count += 1 if count%10==0: sys.stdout.write("Downloaded %d images\r" % count) sys.stdout.flush()
Require Import Crypto.Arithmetic.PrimeFieldTheorems. Require Import Crypto.Specific.solinas64_2e192m2e64m1_4limbs.Synthesis. (* TODO : change this to field once field isomorphism happens *) Definition carry : { carry : feBW_loose -> feBW_tight | forall a, phiBW_tight (carry a) = (phiBW_loose a) }. Proof. Set Ltac Profiling. Time synthesize_carry (). Show Ltac Profile. Time Defined. Print Assumptions carry.
module Relation.Ternary.Separation.Monad where open import Level open import Data.Product open import Function using (_∘_; case_of_) open import Relation.Unary open import Relation.Unary.PredicateTransformer hiding (_⊔_) open import Relation.Binary.PropositionalEquality open import Relation.Ternary.Separation open import Relation.Ternary.Separation.Morphisms module Monads {a b} {A : Set a} {B : Set b} {{r}} {u} {{as : IsUnitalSep {C = A} r u}} {{rb : RawSep B}} {{jm : Morphism A B}} {{bs : IsUnitalSep rb (Morphism.j jm u)}} where open Morphism jm RawMonad : ∀ {i} (I : Set i) → (ℓ : Level) → Set _ RawMonad I ℓ = (i j : I) → PT A B ℓ ℓ {- strong indexed monads on predicates over PRSAs, relative to the functor induced by the PRSA morphism j -} record Monad {i} (I : Set i) ℓ (M : RawMonad I ℓ) : Set (a ⊔ b ⊔ suc ℓ ⊔ i) where field return : ∀ {P i₁} → ∀[ P ⇒ⱼ M i₁ i₁ P ] bind : ∀ {P i₁ i₂ i₃ Q} → ∀[ (P ─✴ⱼ M i₂ i₃ Q) ⇒ (M i₁ i₂ P ─✴ M i₁ i₃ Q) ] _=<<_ : ∀ {P Q i₁ i₂ i₃} → ∀[ P ⇒ⱼ M i₂ i₃ Q ] → ∀[ M i₁ i₂ P ⇒ M i₁ i₃ Q ] f =<< mp = app (bind (wand λ where px σ → case ⊎-id⁻ˡ σ of λ where refl → f px)) mp ⊎-idˡ _>>=_ : ∀ {Φ} {P Q i₁ i₂ i₃} → M i₁ i₂ P Φ → ∀[ P ⇒ⱼ M i₂ i₃ Q ] → M i₁ i₃ Q Φ mp >>= f = f =<< mp mapM′ : ∀ {P Q i₁ i₂} → ∀[ (P ─✴ Q) ⇒ⱼ (M i₁ i₂ P ─✴ M i₁ i₂ Q) ] mapM′ f = bind (wand λ where px σ → case j-⊎⁻ σ of λ where (_ , refl , σ') → return (app f px σ')) mapM : ∀ {Φ} {P Q i₁ i₂} → M i₁ i₂ P Φ → ∀[ P ⇒ Q ] → M i₁ i₂ Q Φ mapM mp f = mp >>= (return ∘ f) open Monad ⦃...⦄ public -- having the internal bind is enough to get strength module _ {i} {I : Set i} {i₁ i₂} {P} {M} {{ _ : Monad I a M }} where str : ∀ {Q : Pred A a} → M i₁ i₂ P Φ₁ → Φ₁ ⊎ j Φ₂ ≣ Φ → Q Φ₂ → M i₁ i₂ (P ✴ Q) Φ str mp σ qx = app (bind (wand λ where px σ' → case j-⊎⁻ σ' of λ where (_ , refl , σ'') → return (px ×⟨ ⊎-comm σ'' ⟩ qx)) ) mp (⊎-comm σ) typed-str : ∀ {Φ₁ Φ₂ Φ} (Q) → M i₁ i₂ P Φ₁ → Φ₁ ⊎ j Φ₂ ≣ Φ → Q Φ₂ → M i₁ i₂ (P ✴ Q) Φ typed-str Q mp σ qx = str {Q = Q} mp σ qx syntax str mp σ qx = mp &⟨ σ ⟩ qx syntax typed-str Q mp σ qx = mp &⟨ Q ∥ σ ⟩ qx _&_ : ∀ {Q} → M i₁ i₂ P ε → ∀[ Q ⇒ⱼ M i₁ i₂ (P ✴ Q) ] mp & q = mp &⟨ ⊎-idˡ ⟩ q
If $f$ is holomorphic on a neighborhood of $z$ and $f$ has a pole at $z$, then there exists a positive real number $r$ such that $f$ is holomorphic on the open ball of radius $r$ centered at $z$ and $f$ has a zero of order $n$ at $z$, where $n$ is the order of the pole of $f$ at $z$.
If $f$ is holomorphic on a punctured neighborhood of $z$, then the contour integral of $f$ around a circle of radius $r$ centered at $z$ is $2\pi i$ times the residue of $f$ at $z$.
State Before: α : Type u_2 β : Type u_1 γ : Type ?u.11263 δ : Type ?u.11266 a : α s t : Multiset α f g : α → Multiset β ⊢ bind (s + t) f = bind s f + bind t f State After: no goals Tactic: simp [bind]
[STATEMENT] lemma diff_union_single_conv2: "a \<in># J \<Longrightarrow> J + I - {#a#} = (J - {#a#}) + I" [PROOF STATE] proof (prove) goal (1 subgoal): 1. a \<in># J \<Longrightarrow> J + I - {#a#} = J - {#a#} + I [PROOF STEP] by simp
%kkimportasc 'Import ASCII Data File to Data Segment' % This MatLab function was automatically generated by a converter (KhorosToMatLab) from the Khoros kimportasc.pane file % % Parameters: % InputFile: i1 'ASCII Input File', required: 'ASCII input data file containing new data segment' % InputFile: i2 'Data Object Input', optional: 'data object input to insert the new segment into' % Integer: so 'Start Offset ', default: 0: 'starting point in ASCII input file to start importing at' % Integer: sf 'Skip Factor ', default: 0: 'number of points in ASCII file to skip between reads' % Integer: nr 'Number of Reads ', default: 1: 'number of points in ASCII file to read between skips' % Integer: dim 'Segment Dimension ', default: 5: 'dimension of the segment' % OutputFile: o 'Output Object', required: 'output data object' % Integer: wsize 'WIDTH ', default: 1: 'size of width dimension in index specified' % Integer: hsize 'HEIGHT ', default: 1: 'size of height dimension in index specified' % Integer: dsize 'DEPTH ', default: 1: 'size of depth dimension in index specified' % Integer: tsize 'TIME ', default: 1: 'size of time dimension in index specified' % Integer: esize 'ELEMENTS ', default: 1: 'size of elements dimension in index specified' % % Example: o = kkimportasc({i1, i2}, {'i1','';'i2','';'so',0;'sf',0;'nr',1;'dim',5;'o','';'wsize',1;'hsize',1;'dsize',1;'tsize',1;'esize',1}) % % Khoros helpfile follows below: % % PROGRAM % kimportasc - Import ASCII Data File to Data Segment % % DESCRIPTION % This routine will import an ASCII data file and insert it into a % specified data object. The new segment will be inserted into this % data object. If a source object was specified, then all of its data % segments and the global object attributes will be copied to the % destination. If no source object was specified, then the resulting % output object will contain only the imported segment. % There are four attributes of the new segment that can be specified: % dimension, index order, size and data type. The number of indices % and sizes specified must be equal to the dimension. % The parameter dimension must be greater than 0 and and less than or % equal to 5. % The segment size is an optional argument specified by five different % size variables: 'wsize', 'hsize', 'dsize', 'tsize', and 'esize'. Each size % variable must be >= to 1. Note that although the size variables are % optional, if no size variables are specified, the output will be of % size 1. % The index order is also specified by five different variables: % 'windex', 'hindex', 'dindex', 'tindex', and 'eindex'. The value for each % index variable must be unique and range from 1 to 5. Note that the index % order dictates how data is stored and retrieved. For example if the % index order is specified as windex 1, hindex 2, dindex 3, tindex 4, % eindex 5 then data will be accessed along width first, followed by height, % depth, time, and elements. If, however the index order is specified as % eindex 1, windex 2, hindex 3, dindex 4, tindex 5 then data will be accessed % along elements first, followed by width, height, depth, and time. % The start offset specifies the point in the ASCII data from which to % start importing in the data into the specified segment. All points before % the start offset are ignored. % The skip factor specifies the number of points to skip in the ASCII data % between reads. % The number of reads specifies the number of points to read before skipping. % For example, if the number of reads is 2 and the skip factor is 3, two % values will be read, three will be skipped, followed by two more reads, % three skips, etc. until all the data has been read. % If the segment_name is one of the Polymorphic segments, the correct % dimensionality must be provided : % % Segment Name Dimension % --------------------------------------------------- % KDA_SEGMENT_VALUE 5 % KDA_SEGMENT_MAP 5 % KDA_SEGMENT_MASK 5 % KDA_SEGMENT_LOCATION 4 % KDA_SEGMENT_TIME 1 % % When importing ASCII data to either the value, map, or mask segment, all % five size variables (wsize, hsize, dsize, tsize, and esize) may be specified % since these segments are five dimensional. Likewise, a five dimensional % index order may be provided. % When importing ASCII data to the locations segment, only four size variables % (wsize, hsize, dsize, and esize) may be specified since the location segment % is four dimensional. Likewise only a four dimensional index order (windex, % hindex, dindex, eindex) may be provided. % When importing ASCII data to the time segment, only one size variable % (tsize) may be specified since the location segment is one dimensional. % Likewise only a one dimensional index order (tindex) may be provided. % Complex values in ASCII are represented by number pairs, surrounded % by parenthesis and separated by a comma. These numbered pairs correspond % to the real and imaginary values respectively. For example, (8, 3) represents % the complex number 8+3i. % % % % EXAMPLES % Consider a simple ASCII input file which looks as follows: % % file: "ascii_data" % 1 2 3 4 % 1 2 3 4 % 1 2 3 4 % 1 2 3 4 % 1 2 3 4 % % This data can be imported into the 'value' segment in any number of ways which % is illustrated in the following four examples. % .I % Value Segment Example 1 % % kimportasc -i1 ascii_data -o output -wsize 2 -hsize 5 -dsize 1 -tsize 1 -esize 1 -so 0 -sf 1 -nr 1 -windex 1 -hindex 2 -dindex 3 -tindex 4 -eindex 5 -segment value -type 6 % This will import the above ASCII data into the value segment of a polymorphic % data object such that the size is "2x5x1x1x1", index order is "w,h,d,t,e", % and data type is integer. The output from kimportasc would conceptually % look as follows: % % 1 3 % 1 3 % 1 3 % 1 3 % 1 3 % % .I % Value Segment Example 2 % % kimportasc -i1 ascii_data -o output -wsize 1 -hsize 5 -dsize 1 -tsize 1 -esize 1 -so 1 -sf 3 -nr 1 -windex 1 -hindex 2 -dindex 3 -tindex 4 -eindex 5 -segment value -type 4 % This will import the above ASCII data into the value segment of a polymorphic % data object such that the size is "1x5x1x1x1", index order is "w,h,d,t,e", % and data type is short. The output from kimportasc would conceptually % look as follows: % % 2 % 2 % 2 % 2 % 2 % % .I % Value Segment Example 3 % % kimportasc -i1 ascii_data -o output -wsize 3 -hsize 5 -dsize 1 -tsize 1 -esize 1 -so 1 -sf 1 -nr 3 -windex 1 -hindex 2 -dindex 3 -tindex 4 -eindex 5 -segment value -type 10 % This will import the above ASCII data into the value segment of a polymorphic % data object such that the size is "3x5x1x1x1", index order is "w,h,d,t,e", % and data type is float. The output from kimportasc would conceptually % look as follows: % % 2 3 4 % 2 3 4 % 2 3 4 % 2 3 4 % 2 3 4 % % .I % Value Segment Example 4 % % kimportasc -i1 ascii_data -o output -wsize 5 -hsize 4 -dsize 1 -tsize 1 -esize % 1 -so 0 -sf 0 -nr 20 -segment value -type 8 % This will import the above ASCII data into the value segment of a polymorphic % data object such that the size is "4x5x1x1x1", index order is "w,h,d,t,e", % and data type is long. The output from kimportasc would conceptually look % as follows: % % 1 2 3 4 1 % 2 3 4 1 2 % 3 4 1 2 3 % 4 1 2 3 4 % % The same input data can be imported into the 'map' segment which is % illustrated in the following example. % .I % Map Segment Example % % kimportasc -i1 ascii_data -i2 data_without_map -o output -wsize 4 -hsize 5 -dsize 1 -tsize 1 -esize 1 -so 0 -sf 0 -nr 1 -windex 1 -hindex 2 -dindex 3 -tindex 4 -eindex 5 -segment map -type 6 % This will import the above ASCII data into the map segment of the polymorphic % data object specified by the input file "data_without_map" such that the size % of the map is "4x5x1x1x1", index order is "mw,mh,md,mt,me", and data type is % integer, where "mw,mh,md,mt,me" coorespond to map width, map height, map depth, % map time, and map elements respectively. The map segment output from % kimportasc would conceptually look like the input ASCII data. % % 1 2 3 4 % 1 2 3 4 % 1 2 3 4 % 1 2 3 4 % 1 2 3 4 % % .I % Mask Segment Example % The following input data can be imported into the 'mask' segment which is % illustrated in the following example. % % file: "map_ascii_data" % 1 0 0 1 % 0 0 1 0 % 1 1 0 0 % 1 1 1 1 % 1 0 1 0 % % % kimportasc -i1 map_ascii_data -i2 data_without_mask -o output -wsize 4 -hsize 5 -dsize 1 -tsize 1 -esize 1 -so 0 -sf 0 -nr 1 -windex 1 -hindex 2 -dindex 3 -tindex 4 -eindex 5 -segment mask -type 6 % This will import the above ASCII data into the mask segment of the polymorphic % data object specified by the input file "data_without_mask" such that the size % of the mask is "4x5x1x1x1", index order is "w,h,d,t,e" and data type is % integer. The mask segment output from kimportasc would conceptually look % like the ASCII input. % .I % Time Segment Example % The following input data can be imported into the 'time' segment which is % illustrated in the following example. % % file: "time_ascii_data" % 1 5 10 15 19 36 40 52 % % % kimportasc -i1 time_ascii_data -i2 data_with_time_series -o output -tsize 8 -so 0 -sf 0 -nr 1 -tindex 1 -segment time -type 6 -dim 1 % This will import the above ASCII data into the time segment of the polymorphic % data object specified by the input file "data_with_time_series" such that the % size of the explicit time segment is "8", index order is "t", and data type is % integer. The time segment output from kimportasc would conceptually look % like the ASCII input. % .I % Location Segment Example % The following input data can be imported into the 'location'segment which % is illustrated in the following example. % % file: "location_ascii_data" % 1 3 5 7 % 9 11 13 15 % 17 19 21 23 % 25 27 29 31 % 33 35 37 39 % % % kimportasc -i1 location_ascii_data -i2 data_without_locations -o output -wsize 4 -hsize 5 -dsize 1 -esize 1 -so 0 -sf 0 -nr 1 -windex 1 -hindex 2 -dindex 3 -eindex 4 -segment location -type 6 -dim 4 % This will import the above ASCII data into the location segment of the % polymorphic data object specified by the input file "data_without_locations" % such that the size of the explicit location segment is "4x5x1x1", index % order is "w,h,d,e", and data type is integer. The location segment output % from kimportasc would conceptually look like the ASCII input. % % "SEE ALSO" % kasc2val, kasc2mask, kasc2loc, kasc2time, kasc2map % % RESTRICTIONS % If no size variables are specified (wsize, hsize, dsize, tsize, or esize), % the output data object will be of size 1. % % REFERENCES % % COPYRIGHT % Copyright (C) 1993 - 1997, Khoral Research, Inc. ("KRI") All rights reserved. % function varargout = kkimportasc(varargin) if nargin ==0 Inputs={};arglist={'',''}; elseif nargin ==1 Inputs=varargin{1};arglist={'',''}; elseif nargin ==2 Inputs=varargin{1}; arglist=varargin{2}; else error('Usage: [out1,..] = kkimportasc(Inputs,arglist).'); end if size(arglist,2)~=2 error('arglist must be of form {''ParameterTag1'',value1;''ParameterTag2'',value2}') end narglist={'i1', '__input';'i2', '__input';'so', 0;'sf', 0;'nr', 1;'dim', 5;'o', '__output';'wsize', 1;'hsize', 1;'dsize', 1;'tsize', 1;'esize', 1}; maxval={0,1,1,1,2,2,0,2,2,2,2,2}; minval={0,1,1,1,2,2,0,2,2,2,2,2}; istoggle=[0,1,1,1,1,1,0,1,1,1,1,1]; was_set=istoggle * 0; paramtype={'InputFile','InputFile','Integer','Integer','Integer','Integer','OutputFile','Integer','Integer','Integer','Integer','Integer'}; % identify the input arrays and assign them to the arguments as stated by the user if ~iscell(Inputs) Inputs = {Inputs}; end NumReqOutputs=1; nextinput=1; nextoutput=1; for ii=1:size(arglist,1) wasmatched=0; for jj=1:size(narglist,1) if strcmp(arglist{ii,1},narglist{jj,1}) % a given argument was matched to the possible arguments wasmatched = 1; was_set(jj) = 1; if strcmp(narglist{jj,2}, '__input') if (nextinput > length(Inputs)) error(['Input ' narglist{jj,1} ' has no corresponding input!']); end narglist{jj,2} = 'OK_in'; nextinput = nextinput + 1; elseif strcmp(narglist{jj,2}, '__output') if (nextoutput > nargout) error(['Output nr. ' narglist{jj,1} ' is not present in the assignment list of outputs !']); end if (isempty(arglist{ii,2})) narglist{jj,2} = 'OK_out'; else narglist{jj,2} = arglist{ii,2}; end nextoutput = nextoutput + 1; if (minval{jj} == 0) NumReqOutputs = NumReqOutputs - 1; end elseif isstr(arglist{ii,2}) narglist{jj,2} = arglist{ii,2}; else if strcmp(paramtype{jj}, 'Integer') & (round(arglist{ii,2}) ~= arglist{ii,2}) error(['Argument ' arglist{ii,1} ' is of integer type but non-integer number ' arglist{ii,2} ' was supplied']); end if (minval{jj} ~= 0 | maxval{jj} ~= 0) if (minval{jj} == 1 & maxval{jj} == 1 & arglist{ii,2} < 0) error(['Argument ' arglist{ii,1} ' must be bigger or equal to zero!']); elseif (minval{jj} == -1 & maxval{jj} == -1 & arglist{ii,2} > 0) error(['Argument ' arglist{ii,1} ' must be smaller or equal to zero!']); elseif (minval{jj} == 2 & maxval{jj} == 2 & arglist{ii,2} <= 0) error(['Argument ' arglist{ii,1} ' must be bigger than zero!']); elseif (minval{jj} == -2 & maxval{jj} == -2 & arglist{ii,2} >= 0) error(['Argument ' arglist{ii,1} ' must be smaller than zero!']); elseif (minval{jj} ~= maxval{jj} & arglist{ii,2} < minval{jj}) error(['Argument ' arglist{ii,1} ' must be bigger than ' num2str(minval{jj})]); elseif (minval{jj} ~= maxval{jj} & arglist{ii,2} > maxval{jj}) error(['Argument ' arglist{ii,1} ' must be smaller than ' num2str(maxval{jj})]); end end end if ~strcmp(narglist{jj,2},'OK_out') & ~strcmp(narglist{jj,2},'OK_in') narglist{jj,2} = arglist{ii,2}; end end end if (wasmatched == 0 & ~strcmp(arglist{ii,1},'')) error(['Argument ' arglist{ii,1} ' is not a valid argument for this function']); end end % match the remaining inputs/outputs to the unused arguments and test for missing required inputs for jj=1:size(narglist,1) if strcmp(paramtype{jj}, 'Toggle') if (narglist{jj,2} ==0) narglist{jj,1} = ''; end; narglist{jj,2} = ''; end; if ~strcmp(narglist{jj,2},'__input') && ~strcmp(narglist{jj,2},'__output') && istoggle(jj) && ~ was_set(jj) narglist{jj,1} = ''; narglist{jj,2} = ''; end; if strcmp(narglist{jj,2}, '__input') if (minval{jj} == 0) % meaning this input is required if (nextinput > size(Inputs)) error(['Required input ' narglist{jj,1} ' has no corresponding input in the list!']); else narglist{jj,2} = 'OK_in'; nextinput = nextinput + 1; end else % this is an optional input if (nextinput <= length(Inputs)) narglist{jj,2} = 'OK_in'; nextinput = nextinput + 1; else narglist{jj,1} = ''; narglist{jj,2} = ''; end; end; else if strcmp(narglist{jj,2}, '__output') if (minval{jj} == 0) % this is a required output if (nextoutput > nargout & nargout > 1) error(['Required output ' narglist{jj,1} ' is not stated in the assignment list!']); else narglist{jj,2} = 'OK_out'; nextoutput = nextoutput + 1; NumReqOutputs = NumReqOutputs-1; end else % this is an optional output if (nargout - nextoutput >= NumReqOutputs) narglist{jj,2} = 'OK_out'; nextoutput = nextoutput + 1; else narglist{jj,1} = ''; narglist{jj,2} = ''; end; end end end end if nargout varargout = cell(1,nargout); else varargout = cell(1,1); end global KhorosRoot if exist('KhorosRoot') && ~isempty(KhorosRoot) w=['"' KhorosRoot]; else if ispc w='"C:\Program Files\dip\khorosBin\'; else [s,w] = system('which cantata'); w=['"' w(1:end-8)]; end end [varargout{:}]=callKhoros([w 'kimportasc" '],Inputs,narglist);
#include <gsl/gsl_interp.h> #include <gsl/gsl_spline.h> #include <gsl/gsl_interp2d.h> #include <gsl/gsl_spline2d.h> const gsl_interp_type *types[7]; const gsl_interp2d_type *types2d[2]; void init(void) { types[0] = gsl_interp_linear; types[1] = gsl_interp_polynomial; types[2] = gsl_interp_cspline; types[3] = gsl_interp_cspline_periodic; types[4] = gsl_interp_akima; types[5] = gsl_interp_akima_periodic; types[6] = gsl_interp_steffen; types2d[0] = gsl_interp2d_bilinear; types2d[1] = gsl_interp2d_bicubic; } /* 1D */ gsl_interp *mgsl_interp_alloc(int type, size_t size) { if(types[0] == NULL) init(); return gsl_interp_alloc(types[type], size); } unsigned int mgsl_interp_type_min_size(int type) { if(types[0] == NULL) init(); return gsl_interp_type_min_size(types[type]); } gsl_spline *mgsl_spline_alloc(int type, size_t size) { if(types[0] == NULL) init(); return gsl_spline_alloc(types[type], size); } /* 2D */ gsl_interp2d *mgsl_interp2d_alloc(int type, size_t xsize, size_t ysize) { if(types[0] == NULL) init(); return gsl_interp2d_alloc(types2d[type], xsize, ysize); } unsigned int mgsl_interp2d_type_min_size(int type) { if(types[0] == NULL) init(); return gsl_interp2d_type_min_size(types2d[type]); } gsl_spline2d *mgsl_spline2d_alloc(int type, size_t xsize, size_t ysize) { if(types[0] == NULL) init(); return gsl_spline2d_alloc(types2d[type], xsize, ysize); }
function qr=v_rotmr2qr(mr) %V_ROTMR2QR converts a matrix of real quaternion matrices to quaternion vectors % Inputs: % % MR(4m,4n,...) mxn matrix of real quaternion matrices (each 4x4) % % Outputs: % % QR(4m,n,...) mxn matrix of real quaternion vectors (each 4x1) % % In matrix form, quaternions can be multiplied and added using normal matrix % arithmetic. Each element of an mxn matrix of quaternions is itself a 4x4 block % so the total dimension of MR is 4m x 4n. % % Copyright (C) Mike Brookes 2000-2018 % Version: $Id: v_rotmr2qr.m 10865 2018-09-21 17:22:45Z dmb $ % % VOICEBOX is a MATLAB toolbox for speech processing. % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % This program is free software; you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by % the Free Software Foundation; either version 2 of the License, or % (at your option) any later version. % % This program is distributed in the hope that it will be useful, % but WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % GNU General Public License for more details. % % You can obtain a copy of the GNU General Public License from % http://www.gnu.org/copyleft/gpl.html or by writing to % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% s=size(mr); s(2)=s(2)/4; mr=reshape(mr,s(1),[]); qr=reshape(mr(:,1:4:end),s); if ~nargout qr=qr(1:4); % select the first element v_rotqr2ro(qr(:)); % plot a rotated cube end
import os,sys,shutil,random,csv from iotbx import pdb, mtz from subprocess import call import numpy as np from scitbx.array_family import flex f = open('pdb_ids_all').read().splitlines() pdb_unique_ids = sorted(list(set(f))) pdb_unique_ids.sort() phaser_res_pdb = 'PHASER.1.pdb' run_mask='cphasematch -mtzin tmp.mtz -colin-fo "*/*/[F,SIGF]" -colin-fc-1 "*/*/[FCORIG,PHIFCORIG]" -colin-fc-2 "*/*/[FC,PHIFC]" > phasematch.log' work_dir = "Folding" file_pref = "../../../Data/" log_template = "phasematch.log" os.chdir(work_dir) resultFile = open("ample_phaseerr_table_pdb.csv",'wb') resultFile_best = open("ample_phaseerr_table_best_pdb.csv",'wb') wr = csv.writer(resultFile, dialect='excel') wr_best = csv.writer(resultFile_best, dialect='excel') results_all = [] for pdb_id in pdb_unique_ids: if not os.path.exists(pdb_id): continue result_path = pdb_id+"/phase_err_ample" phaser_res_path = pdb_id+"/phaser_ample" if not os.path.exists(phaser_res_path): continue cluster_dirs = os.listdir(phaser_res_path) if not os.path.exists(result_path): os.makedirs(result_path) os.chdir(result_path) print "processing "+pdb_id results_cur = [] file_pdb = file_pref + pdb_id + ".pdb" pdb_inp = pdb.input(file_name=file_pdb) cs = pdb_inp.crystal_symmetry_from_cryst1() structure = pdb_inp.xray_structure_simple(crystal_symmetry=cs) miller_pdb = structure.structure_factors(d_min=2).f_calc() for cluster_dir in cluster_dirs: file_phaser = os.path.join("../phaser_ample/",cluster_dir,phaser_res_pdb) phaseerr_val = '90' if not os.path.exists(file_phaser): results_cur.append((pdb_id,cluster_dir,phaseerr_val)) continue pdb_inp_search = pdb.input(file_name=file_phaser) cs_search = pdb_inp_search.crystal_symmetry_from_cryst1() structure_search = pdb_inp_search.xray_structure_simple(crystal_symmetry=cs) miller_pdb_search = structure_search.structure_factors(d_min=2).f_calc() sigmas = flex.double(miller_pdb.size(),1) fobs = miller_pdb.amplitudes() fobs.set_sigmas(sigmas) fc_phic_search = miller_pdb_search mtz_data = fobs.as_mtz_dataset(column_root_label="F") mtz_data.add_miller_array(fc_phic_search, column_root_label="FC") if not cs_search.is_similar_symmetry(cs): results_cur.append((pdb_id,cluster_dir,phaseerr_val)) continue mtz_data.add_miller_array(miller_pdb, column_root_label="FCORIG") mtz_data.mtz_object().write("tmp.mtz") run_string = run_mask call(run_string,shell=True) asm_output = open(log_template, 'r').readlines() for i_line,line in enumerate(asm_output): if line.startswith(" Mean phase error before"): phaseerr_val = line.split()[-1] continue if line.startswith(" Mean phase error after"): phaseerr_val_tmp = line.split()[-1] if float(phaseerr_val_tmp) < float(phaseerr_val): phaseerr_val = phaseerr_val_tmp break results_cur.append((pdb_id,cluster_dir,phaseerr_val)) best_ind = np.argsort([float(m) for p,c,m in results_cur])[0] wr.writerows(results_cur) wr_best.writerow(results_cur[best_ind]) resultFile.flush() resultFile_best.flush() results_all.append(results_cur) os.chdir("../..") resultFile.close() resultFile_best.close()
module Commons.Control.File import Control.ST import Commons.Control.ST import Commons.Data.Action %access public export %default total -- -------------------------------------------------------------- [ Predicates ] ||| A record of the file modes that can read from a file. data ValidModeRead : Mode -> Type where VMRRead : ValidModeRead Read VMRReadW : ValidModeRead ReadWrite VMRReadWT : ValidModeRead ReadWriteTruncate VMRReadA : ValidModeRead ReadAppend ||| A record of the file modes that can write from a file. data ValidModeWrite : Mode -> Type where VMWWrite : ValidModeWrite WriteTruncate VMWAppend : ValidModeWrite Append VMWReadW : ValidModeWrite ReadWrite VMWReadWT : ValidModeWrite ReadWriteTruncate data State = Closed | Open -- -------------------------------------------------- [ Custom Error Reporting ] ||| Alias for File actions. FileAction : ActionTy -> Type -> Type FileAction action = Action action FileError interface FileIO (m : Type -> Type) where data File : Mode -> State -> Type open : (fname : String) -> (fmode : Mode) -> ST m (FileAction RESULT Var) [addIfResult $ File fmode Open] openX : (fname : String) -> (fmode : Mode) -> ST m (FileAction RESULT Var) [addIfResult $ File fmode Open] close : (fh : Var) -> ST m () [Remove fh (File fm st)] readChar : (fh : Var) -> {auto prf : ValidModeRead fm} -> ST m (FileAction RESULT Char) [fh ::: File fm Open :-> onAction (File fm Open) (File fm Closed)] readLine : (fh : Var) -> {auto prf : ValidModeRead fm} -> ST m (FileAction RESULT String) [fh ::: File fm Open :-> onAction (File fm Open) (File fm Closed)] readFile : (fname : String) -> STrans m (FileAction RESULT String) xs (const xs) writeStr : (fh : Var) -> (str : String) -> {auto prf : ValidModeWrite fm} -> ST m (FileAction SUCCESS ()) [fh ::: File fm Open :-> onAction (File fm Open) (File fm Closed)] writeLine : (fh : Var) -> (str : String) -> {auto prf : ValidModeWrite fm} -> ST m (FileAction SUCCESS ()) [fh ::: File fm Open :-> onAction (File fm Open) (File fm Closed)] writeFile : (fname : String) -> (str : String) -> STrans m (FileAction SUCCESS ()) xs (const xs) -- misc flush : (fh : Var) -> ST m () [fh ::: File fm Open] eof : (fh : Var) -> ST m Bool [fh ::: File fm Open] FileIO IO where File x y = State File open fname fmode = do res <- lift $ openFile fname fmode case res of Left err => pure $ Error err Right fh => do v <- new fh pure $ Result v openX fname fmode = do res <- lift $ openFileX fname fmode case res of Left err => pure $ Error err Right fh => do v <- new fh pure $ Result v close v = do fh <- read v lift $ closeFile fh delete v pure () readChar var = do fh <- read var case !(lift $ fgetc fh) of Left err => pure $ Error err Right ln => pure $ Result ln readLine var = do fh <- read var case !(lift $ fGetLine fh) of Left err => pure $ Error err Right ln => pure $ Result ln readFile fname = do case !(lift $ readFile fname) of Left err => pure $ Error err Right str => pure $ Result str writeStr var str = do fh <- read var case !(lift $ fPutStr fh str) of Left err => pure $ Error err Right _ => pure $ Success writeLine var str = do fh <- read var case !(lift $ fPutStrLn fh str) of Left err => pure $ Error err Right _ => pure $ Success writeFile fname str = do case !(lift $ writeFile fname str) of Left err => pure $ Error err Right _ => pure $ Success flush var = do fh <- read var res <- lift $ fflush fh pure res eof var = do fh <- read var res <- lift $ fEOF fh pure res -- --------------------------------------------------------------------- [ EOF ]
import matplotlib.pyplot as plt import numpy as np vendas = np.random.randint(1000, 3000, 50) meses = np.arange(1, 51) plt.figure(1, figsize=(15, 3))# tenho que colocar o tamanho da figura para ficar melhor 15largura, 3 altura plt.subplot(1, 3, 1)# 1 linha de grafico na figure, 3 colunas, indice 1 pq quero ele em primeiro lugar na sequencia plt.plot(meses, vendas,'b^-') plt.subplot(1, 3, 2) # 2º grafico plt.bar(meses,vendas) plt.subplot(1, 3, 3) # 3º grafico plt.scatter(meses,vendas) plt.show()
Set Warnings "-notation-overridden". Require Import Category.Lib. Require Export Category.Theory.Functor. Require Export Category.Structure.Terminal. Require Export Category.Construction.Opposite. Require Export Category.Construction.Product. Require Export Category.Instance.Fun. Generalizable All Variables. Set Primitive Projections. Set Universe Polymorphism. Unset Transparent Obligations. Section Dinatural. Context {C : Category}. Context `{@Terminal C}. Context `{@Terminal (C^op)}. Context {D : Category}. Context {F : C^op ∏ C ⟶ D}. Context {G : C^op ∏ C ⟶ D}. Definition prod_split {x y z w} (f : x ~{C^op}~> z) (g : y ~{C}~> w) : (x, y) ~{ (C ^op) ∏ C }~> (z, w) := (f, g). Arguments prod_split {_ _ _ _} _ _ /. Infix "⋆⋆⋆" := prod_split (at level 100) : category_scope. Class Dinatural := { ditransform {x} : F (x, x) ~> G (x, x); dinaturality {x y} (f : x ~{C}~> y) : fmap[G] (op f ⋆⋆⋆ id) ∘ ditransform ∘ fmap[F] (id ⋆⋆⋆ f) ≈ fmap[G] (id ⋆⋆⋆ f) ∘ ditransform ∘ fmap[F] (op f ⋆⋆⋆ id) }. Global Program Instance Dinatural_Setoid : Setoid Dinatural. End Dinatural. Notation "ditransform[ F ]" := (@ditransform _ _ _ _ F) (at level 9, format "ditransform[ F ]") : category_scope. (* Dinatural transformations can be applied directly to functorial values to perform the functor mapping they imply. *) Coercion ditransform : Dinatural >-> Funclass.
theory hw04 imports Main "~~/src/HOL/Library/Tree" begin declare Let_def [simp] datatype 'a rtree = Leaf | Node "'a rtree" nat 'a "'a rtree" fun num_nodes:: "'a rtree \<Rightarrow> nat" where "num_nodes Leaf = 0" | "num_nodes (Node l n b r) = 1 + num_nodes l + num_nodes r" fun rbst:: "'a::linorder rtree \<Rightarrow> bool" where "rbst Leaf = True" | "rbst (Node l a b r) = (rbst l \<and> (\<forall>x\<in>set_rtree l. (b > x)) \<and> (\<forall>x\<in>set_rtree r. (b < x)) \<and> (a = num_nodes l) \<and> rbst r)" value "rbst (Node (Node Leaf (0::nat) (1::nat) Leaf) (1::nat) 2 (Node Leaf (0::nat) 3 Leaf))" fun rins:: "'a::linorder \<Rightarrow> 'a rtree \<Rightarrow> 'a rtree" where "rins x Leaf = (Node Leaf 0 x Leaf)" | "rins x (Node l n b r) = (if (x < b) then (Node (rins x l) (Suc n) b r) else (Node l n b (rins x r)))" value "rins (4::nat) (Node (Node Leaf (0::nat) (1::nat) Leaf) (1::nat) 2 (Node Leaf (0::nat) 3 Leaf))" lemma rins_set[simp]: "set_rtree (rins x t) = insert x (set_rtree t)" apply(induction t arbitrary:x) apply(auto) done lemma aux1[simp]: "(x\<notin>set_rtree t) \<Longrightarrow> num_nodes (rins x t) = Suc(num_nodes t)" apply(induction t arbitrary: x) apply(auto) done lemma aux2[simp]: "rbst(Node l a b r) \<Longrightarrow> (num_nodes l = a) " apply(auto) done value "rbst (rtree.Node rtree.Leaf 0 (1::nat) (rtree.Node rtree.Leaf 0 (1::nat) rtree.Leaf))" lemma "x\<notin>set_rtree t \<Longrightarrow> rbst t \<Longrightarrow> rbst (rins x t)" apply(induction t arbitrary: x rule:rbst.induct) apply(auto) done fun risin :: "'a::linorder \<Rightarrow> 'a rtree \<Rightarrow> bool" where "risin x Leaf = False" | "risin x (Node l a b r) = ( if (b < x) then (risin x r) else if (b > x) then (risin x l) else True )" value "risin (3::nat) (Node (Node Leaf (0::nat) (1::nat) Leaf) (1::nat) 2 (Node Leaf (0::nat) 3 Leaf))" lemma "rbst t \<Longrightarrow> risin x t \<longleftrightarrow> x\<in>set_rtree t" apply(induction t) apply(auto) done fun inorder:: "'a rtree \<Rightarrow> 'a list" where "inorder Leaf = []" | "inorder (Node l a b r) = inorder l @ [b] @ inorder r" fun rank::"'a::linorder \<Rightarrow> _" where "rank x Leaf = undefined" | "rank x (Node l a b r) = (if (x = b) then a else if (x < b) then (rank x l) else (a + 1 + rank x r))" definition "at_index i l x \<equiv> i<length l \<and> l!i=x" lemma aux3[simp]:"rbst t \<Longrightarrow> num_nodes t = length (inorder t)" apply(induction t) apply(auto) done lemma "rbst t \<Longrightarrow> x\<in>set_rtree t \<Longrightarrow> at_index (rank x t) (inorder t) x" unfolding at_index_def apply(induction t rule:inorder.induct) apply(auto) sorry fun select :: "nat \<Rightarrow> 'a::linorder rtree \<Rightarrow> 'a" where "select n Leaf = undefined" | "select n (Node l a b r) = (if (n = a) then b else if n < a then select n l else select (n-a-1) r)" lemma select_correct: "rbst t \<Longrightarrow> i<length (inorder t) \<Longrightarrow> select i t = inorder t ! i" apply(induction i t rule:select.induct) apply(auto) sorry end
[STATEMENT] lemma frange_vinsert[simp]: "\<R>\<^sub>\<bullet> (vinsert [a, b]\<^sub>\<circ> r) = vinsert b (\<R>\<^sub>\<bullet> r)" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<R>\<^sub>\<bullet> (vinsert [a, b]\<^sub>\<circ> r) = vinsert b (\<R>\<^sub>\<bullet> r) [PROOF STEP] by auto
Formal statement is: lemma setdist_subset_right: "\<lbrakk>T \<noteq> {}; T \<subseteq> u\<rbrakk> \<Longrightarrow> setdist S u \<le> setdist S T" Informal statement is: If $T$ is a nonempty subset of $u$, then the distance from $S$ to $u$ is less than or equal to the distance from $S$ to $T$.
function simpletrans % 1D transport - modelling with extensions for decay and linear sorption % using mixing cell method % % $Ekkehard Holzbecher $Date: 2006/02/08 $ %-------------------------------------------------------------------------- T = 2; % maximum time [s] L = 1; % length [m] D = 0.1; % dispersivity [m*m/s] v = 1; % velocity [m/s] lambda = 1.2; % decay constant [1/s] R = 1; % retardation [1] c0 = 0; % initial concentration [kg/m*m*m] cin = 1; % inflow concentration [kg/m*m*m] dtout = 0.05; % output-timestep [s] dxmax = 0.02; % maximum grid spacing [m] %------------------------ output parameters gplot = 2; % =1: breakthrough curves; =2: profiles gsurf = 0; % surface gcont = 0; % =1: contours; =2: filled contours ganim = 2; % animation %------------------------ execution---------------------------------------- dtout = dtout/R; % timestep reduction for retardation case dx = dtout*v; % grid spacing K = 1; % K = reduction factor for grid spacing if (dx>dxmax) K = ceil(dx/dxmax); end dx = dx/K; % reduced grid spacing dtadv=dtout/K; % advection-timestep N = ceil(L/dx); % N = number of cells x = linspace(0,(N-1)*dx,N);% nodes on x-axis Neumann = D*dtadv/dx/dx; % Neumann-number for dispersion M = max (1,ceil(3*Neumann)); % M = reduction factor to fulfill Neumann-condition Neumann = Neumann/M/R; % reduced Neumann-number dtdiff = dtadv/M; % diffusion timestep t = dtadv; clear c c1 c2; c(1:N) = c0; c1 = c; k = 1; kanim = 1; while (t < T/R) for i=1:M kinetics; % decay (1. order kinetics) diffusion; % diffusion end advection; % advection if k >= K c = [c;c1]; k=0; end t = t + dtadv; k = k+1; end xlabel ('space'); ylabel ('concentration'); %-------------------- graphical output------------------------------------- switch gplot case 1 plot (c) % breakthrough curves xlabel ('time'); ylabel ('concentration'); case 2 plot (x,c','--')% profiles xlabel ('space'); ylabel ('concentration'); end if gsurf % surface figure; surf (x,[0 t],c); xlabel ('space'); ylabel ('time'); zlabel('concentration'); end if gcont figure; end switch gcont case 1 contour (c) % contours grid on; xlabel ('space'); ylabel ('time'); case 2 contourf(c) % filled contours colorbar; xlabel ('space'); ylabel ('time'); end if (ganim) [FileName,PathName] = uiputfile('*.mpg'); figure; if (ganim > 1) hold on; end for j = 1:size(c,1) axis manual; plot (x,c(j,:),'r','LineWidth',2); YLim = [min(c0,cin) max(c0,cin)]; legend (['t=' num2str(dtout*(j-1))]); Anim(j) = getframe; plot (x,c(j,:),'b','LineWidth',2); end mpgwrite (Anim,colormap,[PathName '/' FileName]); % mgwrite not standard MATLAB movie (Anim,0); % play animation end
lemma prime_ge_2_nat: "p \<ge> 2" if "prime p" for p :: nat
[STATEMENT] lemma while_simulate_left_1: "x * z \<le> z * y \<Longrightarrow> x \<star> (z * v) \<le> z * (y \<star> v) \<squnion> (x \<star> bot)" [PROOF STATE] proof (prove) goal (1 subgoal): 1. x * z \<le> z * y \<Longrightarrow> x \<star> z * v \<le> z * (y \<star> v) \<squnion> (x \<star> bot) [PROOF STEP] by (meson order.trans mult_right_isotone while_one_increasing while_simulate_left_plus_1)
import numpy as np import pyopencl as cl import pytest import os gpu_idx = int(os.environ.get('CL_GPUOFFSET', 0)) mf = cl.mem_flags @pytest.fixture(scope='module') def context(): platforms = cl.get_platforms() i = 0 ctx = None for platform in platforms: if os.environ.get('COCL_DEVICES_ALL', None) == '1': print('Warning! Using COCL_DEVICES_ALL. This is a maintainer-oriented option, and is likely to lead to errors') gpu_devices = platform.get_devices(device_type=cl.device_type.ALL) else: gpu_devices = platform.get_devices(device_type=cl.device_type.GPU) if gpu_idx < i + len(gpu_devices): ctx = cl.Context(devices=[gpu_devices[gpu_idx - i]]) break i += len(gpu_devices) if ctx is None: raise Exception('unable to find gpu at index %s' % gpu_idx) print('context', ctx) # ctx = cl.create_some_context() return ctx @pytest.fixture(scope='module') def queue(context): q = cl.CommandQueue(context) return q @pytest.fixture(scope='module') def q(queue): return queue @pytest.fixture(scope='module') def ctx(context): return context @pytest.fixture def int_data(): np.random.seed(123) int_data = np.random.randint(1024, size=(1024,), dtype=np.int32) return int_data @pytest.fixture def float_data(): np.random.seed(124) float_data = np.random.randn(1024).astype(np.float32) return float_data @pytest.fixture def int_data_gpu(int_data, ctx): int_data_gpu = cl.Buffer(ctx, mf.READ_WRITE | mf.COPY_HOST_PTR, hostbuf=int_data) return int_data_gpu @pytest.fixture def float_data_gpu(float_data, ctx): float_data_gpu = cl.Buffer(ctx, mf.READ_WRITE | mf.COPY_HOST_PTR, hostbuf=float_data) return float_data_gpu
Formal statement is: lemma eventually_ae_filter: "eventually P (ae_filter M) \<longleftrightarrow> (\<exists>N\<in>null_sets M. {x \<in> space M. \<not> P x} \<subseteq> N)" Informal statement is: A property holds almost everywhere if and only if it holds outside a set of measure zero.
[GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝¹ : DecidableEq α inst✝ : DecidableEq β a : α l : List α ⊢ length (permsOfList (a :: l)) = (length (a :: l))! [PROOFSTEP] rw [length_cons, Nat.factorial_succ] [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝¹ : DecidableEq α inst✝ : DecidableEq β a : α l : List α ⊢ length (permsOfList (a :: l)) = (length l + 1) * (length l)! [PROOFSTEP] simp only [permsOfList, length_append, length_permsOfList, length_bind, comp, length_map, map_const', sum_replicate, smul_eq_mul, succ_mul] [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝¹ : DecidableEq α inst✝ : DecidableEq β a : α l : List α ⊢ (length l)! + length l * (length l)! = length l * (length l)! + (length l)! [PROOFSTEP] ring [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝¹ : DecidableEq α inst✝ : DecidableEq β l : List α f : Equiv.Perm α h : ∀ (x : α), ↑f x ≠ x → x ∈ l ⊢ f ∈ permsOfList l [PROOFSTEP] induction l generalizing f with | nil => -- Porting note: applied `not_mem_nil` because it is no longer true definitionally. simp only [not_mem_nil] at h exact List.mem_singleton.2 (Equiv.ext fun x => Decidable.by_contradiction <| h x) | cons a l IH => by_cases hfa : f a = a · refine' mem_append_left _ (IH fun x hx => mem_of_ne_of_mem _ (h x hx)) rintro rfl exact hx hfa have hfa' : f (f a) ≠ f a := mt (fun h => f.injective h) hfa have : ∀ x : α, (Equiv.swap a (f a) * f) x ≠ x → x ∈ l := by intro x hx have hxa : x ≠ a := by rintro rfl apply hx simp only [mul_apply, swap_apply_right] refine' List.mem_of_ne_of_mem hxa (h x fun h => _) simp only [mul_apply, swap_apply_def, mul_apply, Ne.def, apply_eq_iff_eq] at hx split_ifs at hx with h_1 exacts [hxa (h.symm.trans h_1), hx h] suffices f ∈ permsOfList l ∨ ∃ b ∈ l, ∃ g ∈ permsOfList l, Equiv.swap a b * g = f by simpa only [permsOfList, exists_prop, List.mem_map, mem_append, List.mem_bind] refine' or_iff_not_imp_left.2 fun _hfl => ⟨f a, _, Equiv.swap a (f a) * f, IH this, _⟩ · exact mem_of_ne_of_mem hfa (h _ hfa') · rw [← mul_assoc, mul_def (swap a (f a)) (swap a (f a)), swap_swap, ← Perm.one_def, one_mul] [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝¹ : DecidableEq α inst✝ : DecidableEq β l : List α f : Equiv.Perm α h : ∀ (x : α), ↑f x ≠ x → x ∈ l ⊢ f ∈ permsOfList l [PROOFSTEP] induction l generalizing f with | nil => -- Porting note: applied `not_mem_nil` because it is no longer true definitionally. simp only [not_mem_nil] at h exact List.mem_singleton.2 (Equiv.ext fun x => Decidable.by_contradiction <| h x) | cons a l IH => by_cases hfa : f a = a · refine' mem_append_left _ (IH fun x hx => mem_of_ne_of_mem _ (h x hx)) rintro rfl exact hx hfa have hfa' : f (f a) ≠ f a := mt (fun h => f.injective h) hfa have : ∀ x : α, (Equiv.swap a (f a) * f) x ≠ x → x ∈ l := by intro x hx have hxa : x ≠ a := by rintro rfl apply hx simp only [mul_apply, swap_apply_right] refine' List.mem_of_ne_of_mem hxa (h x fun h => _) simp only [mul_apply, swap_apply_def, mul_apply, Ne.def, apply_eq_iff_eq] at hx split_ifs at hx with h_1 exacts [hxa (h.symm.trans h_1), hx h] suffices f ∈ permsOfList l ∨ ∃ b ∈ l, ∃ g ∈ permsOfList l, Equiv.swap a b * g = f by simpa only [permsOfList, exists_prop, List.mem_map, mem_append, List.mem_bind] refine' or_iff_not_imp_left.2 fun _hfl => ⟨f a, _, Equiv.swap a (f a) * f, IH this, _⟩ · exact mem_of_ne_of_mem hfa (h _ hfa') · rw [← mul_assoc, mul_def (swap a (f a)) (swap a (f a)), swap_swap, ← Perm.one_def, one_mul] [GOAL] case nil α : Type u_1 β : Type u_2 γ : Type u_3 inst✝¹ : DecidableEq α inst✝ : DecidableEq β f : Equiv.Perm α h : ∀ (x : α), ↑f x ≠ x → x ∈ [] ⊢ f ∈ permsOfList [] [PROOFSTEP] | nil => -- Porting note: applied `not_mem_nil` because it is no longer true definitionally. simp only [not_mem_nil] at h exact List.mem_singleton.2 (Equiv.ext fun x => Decidable.by_contradiction <| h x) [GOAL] case nil α : Type u_1 β : Type u_2 γ : Type u_3 inst✝¹ : DecidableEq α inst✝ : DecidableEq β f : Equiv.Perm α h : ∀ (x : α), ↑f x ≠ x → x ∈ [] ⊢ f ∈ permsOfList [] [PROOFSTEP] simp only [not_mem_nil] at h [GOAL] case nil α : Type u_1 β : Type u_2 γ : Type u_3 inst✝¹ : DecidableEq α inst✝ : DecidableEq β f : Equiv.Perm α h : ∀ (x : α), ↑f x ≠ x → False ⊢ f ∈ permsOfList [] [PROOFSTEP] exact List.mem_singleton.2 (Equiv.ext fun x => Decidable.by_contradiction <| h x) [GOAL] case cons α : Type u_1 β : Type u_2 γ : Type u_3 inst✝¹ : DecidableEq α inst✝ : DecidableEq β a : α l : List α IH : ∀ {f : Equiv.Perm α}, (∀ (x : α), ↑f x ≠ x → x ∈ l) → f ∈ permsOfList l f : Equiv.Perm α h : ∀ (x : α), ↑f x ≠ x → x ∈ a :: l ⊢ f ∈ permsOfList (a :: l) [PROOFSTEP] | cons a l IH => by_cases hfa : f a = a · refine' mem_append_left _ (IH fun x hx => mem_of_ne_of_mem _ (h x hx)) rintro rfl exact hx hfa have hfa' : f (f a) ≠ f a := mt (fun h => f.injective h) hfa have : ∀ x : α, (Equiv.swap a (f a) * f) x ≠ x → x ∈ l := by intro x hx have hxa : x ≠ a := by rintro rfl apply hx simp only [mul_apply, swap_apply_right] refine' List.mem_of_ne_of_mem hxa (h x fun h => _) simp only [mul_apply, swap_apply_def, mul_apply, Ne.def, apply_eq_iff_eq] at hx split_ifs at hx with h_1 exacts [hxa (h.symm.trans h_1), hx h] suffices f ∈ permsOfList l ∨ ∃ b ∈ l, ∃ g ∈ permsOfList l, Equiv.swap a b * g = f by simpa only [permsOfList, exists_prop, List.mem_map, mem_append, List.mem_bind] refine' or_iff_not_imp_left.2 fun _hfl => ⟨f a, _, Equiv.swap a (f a) * f, IH this, _⟩ · exact mem_of_ne_of_mem hfa (h _ hfa') · rw [← mul_assoc, mul_def (swap a (f a)) (swap a (f a)), swap_swap, ← Perm.one_def, one_mul] [GOAL] case cons α : Type u_1 β : Type u_2 γ : Type u_3 inst✝¹ : DecidableEq α inst✝ : DecidableEq β a : α l : List α IH : ∀ {f : Equiv.Perm α}, (∀ (x : α), ↑f x ≠ x → x ∈ l) → f ∈ permsOfList l f : Equiv.Perm α h : ∀ (x : α), ↑f x ≠ x → x ∈ a :: l ⊢ f ∈ permsOfList (a :: l) [PROOFSTEP] by_cases hfa : f a = a [GOAL] case pos α : Type u_1 β : Type u_2 γ : Type u_3 inst✝¹ : DecidableEq α inst✝ : DecidableEq β a : α l : List α IH : ∀ {f : Equiv.Perm α}, (∀ (x : α), ↑f x ≠ x → x ∈ l) → f ∈ permsOfList l f : Equiv.Perm α h : ∀ (x : α), ↑f x ≠ x → x ∈ a :: l hfa : ↑f a = a ⊢ f ∈ permsOfList (a :: l) [PROOFSTEP] refine' mem_append_left _ (IH fun x hx => mem_of_ne_of_mem _ (h x hx)) [GOAL] case pos α : Type u_1 β : Type u_2 γ : Type u_3 inst✝¹ : DecidableEq α inst✝ : DecidableEq β a : α l : List α IH : ∀ {f : Equiv.Perm α}, (∀ (x : α), ↑f x ≠ x → x ∈ l) → f ∈ permsOfList l f : Equiv.Perm α h : ∀ (x : α), ↑f x ≠ x → x ∈ a :: l hfa : ↑f a = a x : α hx : ↑f x ≠ x ⊢ x ≠ a [PROOFSTEP] rintro rfl [GOAL] case pos α : Type u_1 β : Type u_2 γ : Type u_3 inst✝¹ : DecidableEq α inst✝ : DecidableEq β l : List α IH : ∀ {f : Equiv.Perm α}, (∀ (x : α), ↑f x ≠ x → x ∈ l) → f ∈ permsOfList l f : Equiv.Perm α x : α hx : ↑f x ≠ x h : ∀ (x_1 : α), ↑f x_1 ≠ x_1 → x_1 ∈ x :: l hfa : ↑f x = x ⊢ False [PROOFSTEP] exact hx hfa [GOAL] case neg α : Type u_1 β : Type u_2 γ : Type u_3 inst✝¹ : DecidableEq α inst✝ : DecidableEq β a : α l : List α IH : ∀ {f : Equiv.Perm α}, (∀ (x : α), ↑f x ≠ x → x ∈ l) → f ∈ permsOfList l f : Equiv.Perm α h : ∀ (x : α), ↑f x ≠ x → x ∈ a :: l hfa : ¬↑f a = a ⊢ f ∈ permsOfList (a :: l) [PROOFSTEP] have hfa' : f (f a) ≠ f a := mt (fun h => f.injective h) hfa [GOAL] case neg α : Type u_1 β : Type u_2 γ : Type u_3 inst✝¹ : DecidableEq α inst✝ : DecidableEq β a : α l : List α IH : ∀ {f : Equiv.Perm α}, (∀ (x : α), ↑f x ≠ x → x ∈ l) → f ∈ permsOfList l f : Equiv.Perm α h : ∀ (x : α), ↑f x ≠ x → x ∈ a :: l hfa : ¬↑f a = a hfa' : ↑f (↑f a) ≠ ↑f a ⊢ f ∈ permsOfList (a :: l) [PROOFSTEP] have : ∀ x : α, (Equiv.swap a (f a) * f) x ≠ x → x ∈ l := by intro x hx have hxa : x ≠ a := by rintro rfl apply hx simp only [mul_apply, swap_apply_right] refine' List.mem_of_ne_of_mem hxa (h x fun h => _) simp only [mul_apply, swap_apply_def, mul_apply, Ne.def, apply_eq_iff_eq] at hx split_ifs at hx with h_1 exacts [hxa (h.symm.trans h_1), hx h] [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝¹ : DecidableEq α inst✝ : DecidableEq β a : α l : List α IH : ∀ {f : Equiv.Perm α}, (∀ (x : α), ↑f x ≠ x → x ∈ l) → f ∈ permsOfList l f : Equiv.Perm α h : ∀ (x : α), ↑f x ≠ x → x ∈ a :: l hfa : ¬↑f a = a hfa' : ↑f (↑f a) ≠ ↑f a ⊢ ∀ (x : α), ↑(Equiv.swap a (↑f a) * f) x ≠ x → x ∈ l [PROOFSTEP] intro x hx [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝¹ : DecidableEq α inst✝ : DecidableEq β a : α l : List α IH : ∀ {f : Equiv.Perm α}, (∀ (x : α), ↑f x ≠ x → x ∈ l) → f ∈ permsOfList l f : Equiv.Perm α h : ∀ (x : α), ↑f x ≠ x → x ∈ a :: l hfa : ¬↑f a = a hfa' : ↑f (↑f a) ≠ ↑f a x : α hx : ↑(Equiv.swap a (↑f a) * f) x ≠ x ⊢ x ∈ l [PROOFSTEP] have hxa : x ≠ a := by rintro rfl apply hx simp only [mul_apply, swap_apply_right] [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝¹ : DecidableEq α inst✝ : DecidableEq β a : α l : List α IH : ∀ {f : Equiv.Perm α}, (∀ (x : α), ↑f x ≠ x → x ∈ l) → f ∈ permsOfList l f : Equiv.Perm α h : ∀ (x : α), ↑f x ≠ x → x ∈ a :: l hfa : ¬↑f a = a hfa' : ↑f (↑f a) ≠ ↑f a x : α hx : ↑(Equiv.swap a (↑f a) * f) x ≠ x ⊢ x ≠ a [PROOFSTEP] rintro rfl [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝¹ : DecidableEq α inst✝ : DecidableEq β l : List α IH : ∀ {f : Equiv.Perm α}, (∀ (x : α), ↑f x ≠ x → x ∈ l) → f ∈ permsOfList l f : Equiv.Perm α x : α h : ∀ (x_1 : α), ↑f x_1 ≠ x_1 → x_1 ∈ x :: l hfa : ¬↑f x = x hfa' : ↑f (↑f x) ≠ ↑f x hx : ↑(Equiv.swap x (↑f x) * f) x ≠ x ⊢ False [PROOFSTEP] apply hx [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝¹ : DecidableEq α inst✝ : DecidableEq β l : List α IH : ∀ {f : Equiv.Perm α}, (∀ (x : α), ↑f x ≠ x → x ∈ l) → f ∈ permsOfList l f : Equiv.Perm α x : α h : ∀ (x_1 : α), ↑f x_1 ≠ x_1 → x_1 ∈ x :: l hfa : ¬↑f x = x hfa' : ↑f (↑f x) ≠ ↑f x hx : ↑(Equiv.swap x (↑f x) * f) x ≠ x ⊢ ↑(Equiv.swap x (↑f x) * f) x = x [PROOFSTEP] simp only [mul_apply, swap_apply_right] [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝¹ : DecidableEq α inst✝ : DecidableEq β a : α l : List α IH : ∀ {f : Equiv.Perm α}, (∀ (x : α), ↑f x ≠ x → x ∈ l) → f ∈ permsOfList l f : Equiv.Perm α h : ∀ (x : α), ↑f x ≠ x → x ∈ a :: l hfa : ¬↑f a = a hfa' : ↑f (↑f a) ≠ ↑f a x : α hx : ↑(Equiv.swap a (↑f a) * f) x ≠ x hxa : x ≠ a ⊢ x ∈ l [PROOFSTEP] refine' List.mem_of_ne_of_mem hxa (h x fun h => _) [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝¹ : DecidableEq α inst✝ : DecidableEq β a : α l : List α IH : ∀ {f : Equiv.Perm α}, (∀ (x : α), ↑f x ≠ x → x ∈ l) → f ∈ permsOfList l f : Equiv.Perm α h✝ : ∀ (x : α), ↑f x ≠ x → x ∈ a :: l hfa : ¬↑f a = a hfa' : ↑f (↑f a) ≠ ↑f a x : α hx : ↑(Equiv.swap a (↑f a) * f) x ≠ x hxa : x ≠ a h : ↑f x = x ⊢ False [PROOFSTEP] simp only [mul_apply, swap_apply_def, mul_apply, Ne.def, apply_eq_iff_eq] at hx [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝¹ : DecidableEq α inst✝ : DecidableEq β a : α l : List α IH : ∀ {f : Equiv.Perm α}, (∀ (x : α), ↑f x ≠ x → x ∈ l) → f ∈ permsOfList l f : Equiv.Perm α h✝ : ∀ (x : α), ↑f x ≠ x → x ∈ a :: l hfa : ¬↑f a = a hfa' : ↑f (↑f a) ≠ ↑f a x : α hxa : x ≠ a h : ↑f x = x hx : ¬(if ↑f x = a then ↑f a else if x = a then a else ↑f x) = x ⊢ False [PROOFSTEP] split_ifs at hx with h_1 [GOAL] case pos α : Type u_1 β : Type u_2 γ : Type u_3 inst✝¹ : DecidableEq α inst✝ : DecidableEq β a : α l : List α IH : ∀ {f : Equiv.Perm α}, (∀ (x : α), ↑f x ≠ x → x ∈ l) → f ∈ permsOfList l f : Equiv.Perm α h✝ : ∀ (x : α), ↑f x ≠ x → x ∈ a :: l hfa : ¬↑f a = a hfa' : ↑f (↑f a) ≠ ↑f a x : α hxa : x ≠ a h : ↑f x = x h_1 : ↑f x = a hx : ¬↑f a = x ⊢ False case neg α : Type u_1 β : Type u_2 γ : Type u_3 inst✝¹ : DecidableEq α inst✝ : DecidableEq β a : α l : List α IH : ∀ {f : Equiv.Perm α}, (∀ (x : α), ↑f x ≠ x → x ∈ l) → f ∈ permsOfList l f : Equiv.Perm α h✝ : ∀ (x : α), ↑f x ≠ x → x ∈ a :: l hfa : ¬↑f a = a hfa' : ↑f (↑f a) ≠ ↑f a x : α hxa : x ≠ a h : ↑f x = x h_1 : ¬↑f x = a hx : ¬↑f x = x ⊢ False [PROOFSTEP] exacts [hxa (h.symm.trans h_1), hx h] [GOAL] case neg α : Type u_1 β : Type u_2 γ : Type u_3 inst✝¹ : DecidableEq α inst✝ : DecidableEq β a : α l : List α IH : ∀ {f : Equiv.Perm α}, (∀ (x : α), ↑f x ≠ x → x ∈ l) → f ∈ permsOfList l f : Equiv.Perm α h : ∀ (x : α), ↑f x ≠ x → x ∈ a :: l hfa : ¬↑f a = a hfa' : ↑f (↑f a) ≠ ↑f a this : ∀ (x : α), ↑(Equiv.swap a (↑f a) * f) x ≠ x → x ∈ l ⊢ f ∈ permsOfList (a :: l) [PROOFSTEP] suffices f ∈ permsOfList l ∨ ∃ b ∈ l, ∃ g ∈ permsOfList l, Equiv.swap a b * g = f by simpa only [permsOfList, exists_prop, List.mem_map, mem_append, List.mem_bind] [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝¹ : DecidableEq α inst✝ : DecidableEq β a : α l : List α IH : ∀ {f : Equiv.Perm α}, (∀ (x : α), ↑f x ≠ x → x ∈ l) → f ∈ permsOfList l f : Equiv.Perm α h : ∀ (x : α), ↑f x ≠ x → x ∈ a :: l hfa : ¬↑f a = a hfa' : ↑f (↑f a) ≠ ↑f a this✝ : ∀ (x : α), ↑(Equiv.swap a (↑f a) * f) x ≠ x → x ∈ l this : f ∈ permsOfList l ∨ ∃ b, b ∈ l ∧ ∃ g, g ∈ permsOfList l ∧ Equiv.swap a b * g = f ⊢ f ∈ permsOfList (a :: l) [PROOFSTEP] simpa only [permsOfList, exists_prop, List.mem_map, mem_append, List.mem_bind] [GOAL] case neg α : Type u_1 β : Type u_2 γ : Type u_3 inst✝¹ : DecidableEq α inst✝ : DecidableEq β a : α l : List α IH : ∀ {f : Equiv.Perm α}, (∀ (x : α), ↑f x ≠ x → x ∈ l) → f ∈ permsOfList l f : Equiv.Perm α h : ∀ (x : α), ↑f x ≠ x → x ∈ a :: l hfa : ¬↑f a = a hfa' : ↑f (↑f a) ≠ ↑f a this : ∀ (x : α), ↑(Equiv.swap a (↑f a) * f) x ≠ x → x ∈ l ⊢ f ∈ permsOfList l ∨ ∃ b, b ∈ l ∧ ∃ g, g ∈ permsOfList l ∧ Equiv.swap a b * g = f [PROOFSTEP] refine' or_iff_not_imp_left.2 fun _hfl => ⟨f a, _, Equiv.swap a (f a) * f, IH this, _⟩ [GOAL] case neg.refine'_1 α : Type u_1 β : Type u_2 γ : Type u_3 inst✝¹ : DecidableEq α inst✝ : DecidableEq β a : α l : List α IH : ∀ {f : Equiv.Perm α}, (∀ (x : α), ↑f x ≠ x → x ∈ l) → f ∈ permsOfList l f : Equiv.Perm α h : ∀ (x : α), ↑f x ≠ x → x ∈ a :: l hfa : ¬↑f a = a hfa' : ↑f (↑f a) ≠ ↑f a this : ∀ (x : α), ↑(Equiv.swap a (↑f a) * f) x ≠ x → x ∈ l _hfl : ¬f ∈ permsOfList l ⊢ ↑f a ∈ l [PROOFSTEP] exact mem_of_ne_of_mem hfa (h _ hfa') [GOAL] case neg.refine'_2 α : Type u_1 β : Type u_2 γ : Type u_3 inst✝¹ : DecidableEq α inst✝ : DecidableEq β a : α l : List α IH : ∀ {f : Equiv.Perm α}, (∀ (x : α), ↑f x ≠ x → x ∈ l) → f ∈ permsOfList l f : Equiv.Perm α h : ∀ (x : α), ↑f x ≠ x → x ∈ a :: l hfa : ¬↑f a = a hfa' : ↑f (↑f a) ≠ ↑f a this : ∀ (x : α), ↑(Equiv.swap a (↑f a) * f) x ≠ x → x ∈ l _hfl : ¬f ∈ permsOfList l ⊢ Equiv.swap a (↑f a) * (Equiv.swap a (↑f a) * f) = f [PROOFSTEP] rw [← mul_assoc, mul_def (swap a (f a)) (swap a (f a)), swap_swap, ← Perm.one_def, one_mul] [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝¹ : DecidableEq α inst✝ : DecidableEq β f : Equiv.Perm α h : f ∈ permsOfList [] heq_iff_eq : α ⊢ ↑f heq_iff_eq ≠ heq_iff_eq → heq_iff_eq ∈ [] [PROOFSTEP] have : f = 1 := by simpa [permsOfList] using h [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝¹ : DecidableEq α inst✝ : DecidableEq β f : Equiv.Perm α h : f ∈ permsOfList [] heq_iff_eq : α ⊢ f = 1 [PROOFSTEP] simpa [permsOfList] using h [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝¹ : DecidableEq α inst✝ : DecidableEq β f : Equiv.Perm α h : f ∈ permsOfList [] heq_iff_eq : α this : f = 1 ⊢ ↑f heq_iff_eq ≠ heq_iff_eq → heq_iff_eq ∈ [] [PROOFSTEP] rw [this] [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝¹ : DecidableEq α inst✝ : DecidableEq β f : Equiv.Perm α h : f ∈ permsOfList [] heq_iff_eq : α this : f = 1 ⊢ ↑1 heq_iff_eq ≠ heq_iff_eq → heq_iff_eq ∈ [] [PROOFSTEP] simp [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝¹ : DecidableEq α inst✝ : DecidableEq β a : α l : List α f : Equiv.Perm α h✝ : f ∈ permsOfList (a :: l) x : α h : f ∈ List.bind l fun b => List.map (fun f => Equiv.swap a b * f) (permsOfList l) hx : ↑f x ≠ x y : α hy : y ∈ l hy' : f ∈ List.map (fun f => Equiv.swap a y * f) (permsOfList l) g : Equiv.Perm α hg₁ : g ∈ permsOfList l hg₂ : Equiv.swap a y * g = f hxa : x = a ⊢ x ∈ a :: l [PROOFSTEP] simp [hxa] [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝¹ : DecidableEq α inst✝ : DecidableEq β a : α l : List α f : Equiv.Perm α h✝ : f ∈ permsOfList (a :: l) x : α h : f ∈ List.bind l fun b => List.map (fun f => Equiv.swap a b * f) (permsOfList l) hx : ↑f x ≠ x y : α hy : y ∈ l hy' : f ∈ List.map (fun f => Equiv.swap a y * f) (permsOfList l) g : Equiv.Perm α hg₁ : g ∈ permsOfList l hg₂ : Equiv.swap a y * g = f hxa : ¬x = a hxy : x = y ⊢ x ∈ l [PROOFSTEP] rwa [hxy] [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝¹ : DecidableEq α inst✝ : DecidableEq β a : α l : List α f : Equiv.Perm α h✝ : f ∈ permsOfList (a :: l) x : α h : f ∈ List.bind l fun b => List.map (fun f => Equiv.swap a b * f) (permsOfList l) hx : ↑f x ≠ x y : α hy : y ∈ l hy' : f ∈ List.map (fun f => Equiv.swap a y * f) (permsOfList l) g : Equiv.Perm α hg₁ : g ∈ permsOfList l hg₂ : Equiv.swap a y * g = f hxa : ¬x = a hxy : ¬x = y ⊢ ↑g x ≠ x [PROOFSTEP] rw [eq_inv_mul_iff_mul_eq.2 hg₂, mul_apply, swap_inv, swap_apply_def] [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝¹ : DecidableEq α inst✝ : DecidableEq β a : α l : List α f : Equiv.Perm α h✝ : f ∈ permsOfList (a :: l) x : α h : f ∈ List.bind l fun b => List.map (fun f => Equiv.swap a b * f) (permsOfList l) hx : ↑f x ≠ x y : α hy : y ∈ l hy' : f ∈ List.map (fun f => Equiv.swap a y * f) (permsOfList l) g : Equiv.Perm α hg₁ : g ∈ permsOfList l hg₂ : Equiv.swap a y * g = f hxa : ¬x = a hxy : ¬x = y ⊢ (if ↑f x = a then y else if ↑f x = y then a else ↑f x) ≠ x [PROOFSTEP] split_ifs <;> [exact Ne.symm hxy; exact Ne.symm hxa; exact hx] [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝¹ : DecidableEq α inst✝ : DecidableEq β a : α l : List α f : Equiv.Perm α h✝ : f ∈ permsOfList (a :: l) x : α h : f ∈ List.bind l fun b => List.map (fun f => Equiv.swap a b * f) (permsOfList l) hx : ↑f x ≠ x y : α hy : y ∈ l hy' : f ∈ List.map (fun f => Equiv.swap a y * f) (permsOfList l) g : Equiv.Perm α hg₁ : g ∈ permsOfList l hg₂ : Equiv.swap a y * g = f hxa : ¬x = a hxy : ¬x = y ⊢ (if ↑f x = a then y else if ↑f x = y then a else ↑f x) ≠ x [PROOFSTEP] split_ifs [GOAL] case pos α : Type u_1 β : Type u_2 γ : Type u_3 inst✝¹ : DecidableEq α inst✝ : DecidableEq β a : α l : List α f : Equiv.Perm α h✝¹ : f ∈ permsOfList (a :: l) x : α h : f ∈ List.bind l fun b => List.map (fun f => Equiv.swap a b * f) (permsOfList l) hx : ↑f x ≠ x y : α hy : y ∈ l hy' : f ∈ List.map (fun f => Equiv.swap a y * f) (permsOfList l) g : Equiv.Perm α hg₁ : g ∈ permsOfList l hg₂ : Equiv.swap a y * g = f hxa : ¬x = a hxy : ¬x = y h✝ : ↑f x = a ⊢ y ≠ x [PROOFSTEP] exact Ne.symm hxy [GOAL] case pos α : Type u_1 β : Type u_2 γ : Type u_3 inst✝¹ : DecidableEq α inst✝ : DecidableEq β a : α l : List α f : Equiv.Perm α h✝² : f ∈ permsOfList (a :: l) x : α h : f ∈ List.bind l fun b => List.map (fun f => Equiv.swap a b * f) (permsOfList l) hx : ↑f x ≠ x y : α hy : y ∈ l hy' : f ∈ List.map (fun f => Equiv.swap a y * f) (permsOfList l) g : Equiv.Perm α hg₁ : g ∈ permsOfList l hg₂ : Equiv.swap a y * g = f hxa : ¬x = a hxy : ¬x = y h✝¹ : ¬↑f x = a h✝ : ↑f x = y ⊢ a ≠ x [PROOFSTEP] exact Ne.symm hxa [GOAL] case neg α : Type u_1 β : Type u_2 γ : Type u_3 inst✝¹ : DecidableEq α inst✝ : DecidableEq β a : α l : List α f : Equiv.Perm α h✝² : f ∈ permsOfList (a :: l) x : α h : f ∈ List.bind l fun b => List.map (fun f => Equiv.swap a b * f) (permsOfList l) hx : ↑f x ≠ x y : α hy : y ∈ l hy' : f ∈ List.map (fun f => Equiv.swap a y * f) (permsOfList l) g : Equiv.Perm α hg₁ : g ∈ permsOfList l hg₂ : Equiv.swap a y * g = f hxa : ¬x = a hxy : ¬x = y h✝¹ : ¬↑f x = a h✝ : ¬↑f x = y ⊢ ↑f x ≠ x [PROOFSTEP] exact hx [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝¹ : DecidableEq α inst✝ : DecidableEq β x✝ : Nodup [] ⊢ Nodup (permsOfList []) [PROOFSTEP] simp [permsOfList] [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝¹ : DecidableEq α inst✝ : DecidableEq β a : α l : List α hl : Nodup (a :: l) ⊢ Nodup (permsOfList (a :: l)) [PROOFSTEP] have hl' : l.Nodup := hl.of_cons [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝¹ : DecidableEq α inst✝ : DecidableEq β a : α l : List α hl : Nodup (a :: l) hl' : Nodup l ⊢ Nodup (permsOfList (a :: l)) [PROOFSTEP] have hln' : (permsOfList l).Nodup := nodup_permsOfList hl' [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝¹ : DecidableEq α inst✝ : DecidableEq β a : α l : List α hl : Nodup (a :: l) hl' : Nodup l hln' : Nodup (permsOfList l) ⊢ Nodup (permsOfList (a :: l)) [PROOFSTEP] have hmeml : ∀ {f : Perm α}, f ∈ permsOfList l → f a = a := fun {f} hf => not_not.1 (mt (mem_of_mem_permsOfList hf _) (nodup_cons.1 hl).1) [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝¹ : DecidableEq α inst✝ : DecidableEq β a : α l : List α hl : Nodup (a :: l) hl' : Nodup l hln' : Nodup (permsOfList l) hmeml : ∀ {f : Equiv.Perm α}, f ∈ permsOfList l → ↑f a = a ⊢ Nodup (permsOfList (a :: l)) [PROOFSTEP] rw [permsOfList, List.nodup_append, List.nodup_bind, pairwise_iff_get] [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝¹ : DecidableEq α inst✝ : DecidableEq β a : α l : List α hl : Nodup (a :: l) hl' : Nodup l hln' : Nodup (permsOfList l) hmeml : ∀ {f : Equiv.Perm α}, f ∈ permsOfList l → ↑f a = a ⊢ Nodup (permsOfList l) ∧ ((∀ (x : α), x ∈ l → Nodup (List.map (fun f => Equiv.swap a x * f) (permsOfList l))) ∧ ∀ (i j : Fin (length l)), i < j → List.Disjoint (List.map (fun f => Equiv.swap a (List.get l i) * f) (permsOfList l)) (List.map (fun f => Equiv.swap a (List.get l j) * f) (permsOfList l))) ∧ List.Disjoint (permsOfList l) (List.bind l fun b => List.map (fun f => Equiv.swap a b * f) (permsOfList l)) [PROOFSTEP] refine ⟨?_, ⟨⟨?_, ?_⟩, ?_⟩⟩ [GOAL] case refine_1 α : Type u_1 β : Type u_2 γ : Type u_3 inst✝¹ : DecidableEq α inst✝ : DecidableEq β a : α l : List α hl : Nodup (a :: l) hl' : Nodup l hln' : Nodup (permsOfList l) hmeml : ∀ {f : Equiv.Perm α}, f ∈ permsOfList l → ↑f a = a ⊢ Nodup (permsOfList l) [PROOFSTEP] exact hln' [GOAL] case refine_2 α : Type u_1 β : Type u_2 γ : Type u_3 inst✝¹ : DecidableEq α inst✝ : DecidableEq β a : α l : List α hl : Nodup (a :: l) hl' : Nodup l hln' : Nodup (permsOfList l) hmeml : ∀ {f : Equiv.Perm α}, f ∈ permsOfList l → ↑f a = a ⊢ ∀ (x : α), x ∈ l → Nodup (List.map (fun f => Equiv.swap a x * f) (permsOfList l)) [PROOFSTEP] exact fun _ _ => hln'.map fun _ _ => mul_left_cancel [GOAL] case refine_3 α : Type u_1 β : Type u_2 γ : Type u_3 inst✝¹ : DecidableEq α inst✝ : DecidableEq β a : α l : List α hl : Nodup (a :: l) hl' : Nodup l hln' : Nodup (permsOfList l) hmeml : ∀ {f : Equiv.Perm α}, f ∈ permsOfList l → ↑f a = a ⊢ ∀ (i j : Fin (length l)), i < j → List.Disjoint (List.map (fun f => Equiv.swap a (List.get l i) * f) (permsOfList l)) (List.map (fun f => Equiv.swap a (List.get l j) * f) (permsOfList l)) [PROOFSTEP] intros i j hij x hx₁ hx₂ [GOAL] case refine_3 α : Type u_1 β : Type u_2 γ : Type u_3 inst✝¹ : DecidableEq α inst✝ : DecidableEq β a : α l : List α hl : Nodup (a :: l) hl' : Nodup l hln' : Nodup (permsOfList l) hmeml : ∀ {f : Equiv.Perm α}, f ∈ permsOfList l → ↑f a = a i j : Fin (length l) hij : i < j x : Equiv.Perm α hx₁ : x ∈ List.map (fun f => Equiv.swap a (List.get l i) * f) (permsOfList l) hx₂ : x ∈ List.map (fun f => Equiv.swap a (List.get l j) * f) (permsOfList l) ⊢ False [PROOFSTEP] let ⟨f, hf⟩ := List.mem_map.1 hx₁ [GOAL] case refine_3 α : Type u_1 β : Type u_2 γ : Type u_3 inst✝¹ : DecidableEq α inst✝ : DecidableEq β a : α l : List α hl : Nodup (a :: l) hl' : Nodup l hln' : Nodup (permsOfList l) hmeml : ∀ {f : Equiv.Perm α}, f ∈ permsOfList l → ↑f a = a i j : Fin (length l) hij : i < j x : Equiv.Perm α hx₁ : x ∈ List.map (fun f => Equiv.swap a (List.get l i) * f) (permsOfList l) hx₂ : x ∈ List.map (fun f => Equiv.swap a (List.get l j) * f) (permsOfList l) f : Equiv.Perm α hf : f ∈ permsOfList l ∧ Equiv.swap a (List.get l i) * f = x ⊢ False [PROOFSTEP] let ⟨g, hg⟩ := List.mem_map.1 hx₂ [GOAL] case refine_3 α : Type u_1 β : Type u_2 γ : Type u_3 inst✝¹ : DecidableEq α inst✝ : DecidableEq β a : α l : List α hl : Nodup (a :: l) hl' : Nodup l hln' : Nodup (permsOfList l) hmeml : ∀ {f : Equiv.Perm α}, f ∈ permsOfList l → ↑f a = a i j : Fin (length l) hij : i < j x : Equiv.Perm α hx₁ : x ∈ List.map (fun f => Equiv.swap a (List.get l i) * f) (permsOfList l) hx₂ : x ∈ List.map (fun f => Equiv.swap a (List.get l j) * f) (permsOfList l) f : Equiv.Perm α hf : f ∈ permsOfList l ∧ Equiv.swap a (List.get l i) * f = x g : Equiv.Perm α hg : g ∈ permsOfList l ∧ Equiv.swap a (List.get l j) * g = x ⊢ False [PROOFSTEP] have hix : x a = List.get l i := by rw [← hf.2, mul_apply, hmeml hf.1, swap_apply_left] [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝¹ : DecidableEq α inst✝ : DecidableEq β a : α l : List α hl : Nodup (a :: l) hl' : Nodup l hln' : Nodup (permsOfList l) hmeml : ∀ {f : Equiv.Perm α}, f ∈ permsOfList l → ↑f a = a i j : Fin (length l) hij : i < j x : Equiv.Perm α hx₁ : x ∈ List.map (fun f => Equiv.swap a (List.get l i) * f) (permsOfList l) hx₂ : x ∈ List.map (fun f => Equiv.swap a (List.get l j) * f) (permsOfList l) f : Equiv.Perm α hf : f ∈ permsOfList l ∧ Equiv.swap a (List.get l i) * f = x g : Equiv.Perm α hg : g ∈ permsOfList l ∧ Equiv.swap a (List.get l j) * g = x ⊢ ↑x a = List.get l i [PROOFSTEP] rw [← hf.2, mul_apply, hmeml hf.1, swap_apply_left] [GOAL] case refine_3 α : Type u_1 β : Type u_2 γ : Type u_3 inst✝¹ : DecidableEq α inst✝ : DecidableEq β a : α l : List α hl : Nodup (a :: l) hl' : Nodup l hln' : Nodup (permsOfList l) hmeml : ∀ {f : Equiv.Perm α}, f ∈ permsOfList l → ↑f a = a i j : Fin (length l) hij : i < j x : Equiv.Perm α hx₁ : x ∈ List.map (fun f => Equiv.swap a (List.get l i) * f) (permsOfList l) hx₂ : x ∈ List.map (fun f => Equiv.swap a (List.get l j) * f) (permsOfList l) f : Equiv.Perm α hf : f ∈ permsOfList l ∧ Equiv.swap a (List.get l i) * f = x g : Equiv.Perm α hg : g ∈ permsOfList l ∧ Equiv.swap a (List.get l j) * g = x hix : ↑x a = List.get l i ⊢ False [PROOFSTEP] have hiy : x a = List.get l j := by rw [← hg.2, mul_apply, hmeml hg.1, swap_apply_left] [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝¹ : DecidableEq α inst✝ : DecidableEq β a : α l : List α hl : Nodup (a :: l) hl' : Nodup l hln' : Nodup (permsOfList l) hmeml : ∀ {f : Equiv.Perm α}, f ∈ permsOfList l → ↑f a = a i j : Fin (length l) hij : i < j x : Equiv.Perm α hx₁ : x ∈ List.map (fun f => Equiv.swap a (List.get l i) * f) (permsOfList l) hx₂ : x ∈ List.map (fun f => Equiv.swap a (List.get l j) * f) (permsOfList l) f : Equiv.Perm α hf : f ∈ permsOfList l ∧ Equiv.swap a (List.get l i) * f = x g : Equiv.Perm α hg : g ∈ permsOfList l ∧ Equiv.swap a (List.get l j) * g = x hix : ↑x a = List.get l i ⊢ ↑x a = List.get l j [PROOFSTEP] rw [← hg.2, mul_apply, hmeml hg.1, swap_apply_left] [GOAL] case refine_3 α : Type u_1 β : Type u_2 γ : Type u_3 inst✝¹ : DecidableEq α inst✝ : DecidableEq β a : α l : List α hl : Nodup (a :: l) hl' : Nodup l hln' : Nodup (permsOfList l) hmeml : ∀ {f : Equiv.Perm α}, f ∈ permsOfList l → ↑f a = a i j : Fin (length l) hij : i < j x : Equiv.Perm α hx₁ : x ∈ List.map (fun f => Equiv.swap a (List.get l i) * f) (permsOfList l) hx₂ : x ∈ List.map (fun f => Equiv.swap a (List.get l j) * f) (permsOfList l) f : Equiv.Perm α hf : f ∈ permsOfList l ∧ Equiv.swap a (List.get l i) * f = x g : Equiv.Perm α hg : g ∈ permsOfList l ∧ Equiv.swap a (List.get l j) * g = x hix : ↑x a = List.get l i hiy : ↑x a = List.get l j ⊢ False [PROOFSTEP] have hieqj : i = j := nodup_iff_injective_get.1 hl' (hix.symm.trans hiy) [GOAL] case refine_3 α : Type u_1 β : Type u_2 γ : Type u_3 inst✝¹ : DecidableEq α inst✝ : DecidableEq β a : α l : List α hl : Nodup (a :: l) hl' : Nodup l hln' : Nodup (permsOfList l) hmeml : ∀ {f : Equiv.Perm α}, f ∈ permsOfList l → ↑f a = a i j : Fin (length l) hij : i < j x : Equiv.Perm α hx₁ : x ∈ List.map (fun f => Equiv.swap a (List.get l i) * f) (permsOfList l) hx₂ : x ∈ List.map (fun f => Equiv.swap a (List.get l j) * f) (permsOfList l) f : Equiv.Perm α hf : f ∈ permsOfList l ∧ Equiv.swap a (List.get l i) * f = x g : Equiv.Perm α hg : g ∈ permsOfList l ∧ Equiv.swap a (List.get l j) * g = x hix : ↑x a = List.get l i hiy : ↑x a = List.get l j hieqj : i = j ⊢ False [PROOFSTEP] exact absurd hieqj (_root_.ne_of_lt hij) [GOAL] case refine_4 α : Type u_1 β : Type u_2 γ : Type u_3 inst✝¹ : DecidableEq α inst✝ : DecidableEq β a : α l : List α hl : Nodup (a :: l) hl' : Nodup l hln' : Nodup (permsOfList l) hmeml : ∀ {f : Equiv.Perm α}, f ∈ permsOfList l → ↑f a = a ⊢ List.Disjoint (permsOfList l) (List.bind l fun b => List.map (fun f => Equiv.swap a b * f) (permsOfList l)) [PROOFSTEP] intros f hf₁ hf₂ [GOAL] case refine_4 α : Type u_1 β : Type u_2 γ : Type u_3 inst✝¹ : DecidableEq α inst✝ : DecidableEq β a : α l : List α hl : Nodup (a :: l) hl' : Nodup l hln' : Nodup (permsOfList l) hmeml : ∀ {f : Equiv.Perm α}, f ∈ permsOfList l → ↑f a = a f : Equiv.Perm α hf₁ : f ∈ permsOfList l hf₂ : f ∈ List.bind l fun b => List.map (fun f => Equiv.swap a b * f) (permsOfList l) ⊢ False [PROOFSTEP] let ⟨x, hx, hx'⟩ := List.mem_bind.1 hf₂ [GOAL] case refine_4 α : Type u_1 β : Type u_2 γ : Type u_3 inst✝¹ : DecidableEq α inst✝ : DecidableEq β a : α l : List α hl : Nodup (a :: l) hl' : Nodup l hln' : Nodup (permsOfList l) hmeml : ∀ {f : Equiv.Perm α}, f ∈ permsOfList l → ↑f a = a f : Equiv.Perm α hf₁ : f ∈ permsOfList l hf₂ : f ∈ List.bind l fun b => List.map (fun f => Equiv.swap a b * f) (permsOfList l) x : α hx : x ∈ l hx' : f ∈ List.map (fun f => Equiv.swap a x * f) (permsOfList l) ⊢ False [PROOFSTEP] let ⟨g, hg⟩ := List.mem_map.1 hx' [GOAL] case refine_4 α : Type u_1 β : Type u_2 γ : Type u_3 inst✝¹ : DecidableEq α inst✝ : DecidableEq β a : α l : List α hl : Nodup (a :: l) hl' : Nodup l hln' : Nodup (permsOfList l) hmeml : ∀ {f : Equiv.Perm α}, f ∈ permsOfList l → ↑f a = a f : Equiv.Perm α hf₁ : f ∈ permsOfList l hf₂ : f ∈ List.bind l fun b => List.map (fun f => Equiv.swap a b * f) (permsOfList l) x : α hx : x ∈ l hx' : f ∈ List.map (fun f => Equiv.swap a x * f) (permsOfList l) g : Equiv.Perm α hg : g ∈ permsOfList l ∧ Equiv.swap a x * g = f ⊢ False [PROOFSTEP] have hgxa : g⁻¹ x = a := f.injective <| by rw [hmeml hf₁, ← hg.2]; simp [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝¹ : DecidableEq α inst✝ : DecidableEq β a : α l : List α hl : Nodup (a :: l) hl' : Nodup l hln' : Nodup (permsOfList l) hmeml : ∀ {f : Equiv.Perm α}, f ∈ permsOfList l → ↑f a = a f : Equiv.Perm α hf₁ : f ∈ permsOfList l hf₂ : f ∈ List.bind l fun b => List.map (fun f => Equiv.swap a b * f) (permsOfList l) x : α hx : x ∈ l hx' : f ∈ List.map (fun f => Equiv.swap a x * f) (permsOfList l) g : Equiv.Perm α hg : g ∈ permsOfList l ∧ Equiv.swap a x * g = f ⊢ ↑f (↑g⁻¹ x) = ↑f a [PROOFSTEP] rw [hmeml hf₁, ← hg.2] [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝¹ : DecidableEq α inst✝ : DecidableEq β a : α l : List α hl : Nodup (a :: l) hl' : Nodup l hln' : Nodup (permsOfList l) hmeml : ∀ {f : Equiv.Perm α}, f ∈ permsOfList l → ↑f a = a f : Equiv.Perm α hf₁ : f ∈ permsOfList l hf₂ : f ∈ List.bind l fun b => List.map (fun f => Equiv.swap a b * f) (permsOfList l) x : α hx : x ∈ l hx' : f ∈ List.map (fun f => Equiv.swap a x * f) (permsOfList l) g : Equiv.Perm α hg : g ∈ permsOfList l ∧ Equiv.swap a x * g = f ⊢ ↑(Equiv.swap a x * g) (↑g⁻¹ x) = a [PROOFSTEP] simp [GOAL] case refine_4 α : Type u_1 β : Type u_2 γ : Type u_3 inst✝¹ : DecidableEq α inst✝ : DecidableEq β a : α l : List α hl : Nodup (a :: l) hl' : Nodup l hln' : Nodup (permsOfList l) hmeml : ∀ {f : Equiv.Perm α}, f ∈ permsOfList l → ↑f a = a f : Equiv.Perm α hf₁ : f ∈ permsOfList l hf₂ : f ∈ List.bind l fun b => List.map (fun f => Equiv.swap a b * f) (permsOfList l) x : α hx : x ∈ l hx' : f ∈ List.map (fun f => Equiv.swap a x * f) (permsOfList l) g : Equiv.Perm α hg : g ∈ permsOfList l ∧ Equiv.swap a x * g = f hgxa : ↑g⁻¹ x = a ⊢ False [PROOFSTEP] have hxa : x ≠ a := fun h => (List.nodup_cons.1 hl).1 (h ▸ hx) [GOAL] case refine_4 α : Type u_1 β : Type u_2 γ : Type u_3 inst✝¹ : DecidableEq α inst✝ : DecidableEq β a : α l : List α hl : Nodup (a :: l) hl' : Nodup l hln' : Nodup (permsOfList l) hmeml : ∀ {f : Equiv.Perm α}, f ∈ permsOfList l → ↑f a = a f : Equiv.Perm α hf₁ : f ∈ permsOfList l hf₂ : f ∈ List.bind l fun b => List.map (fun f => Equiv.swap a b * f) (permsOfList l) x : α hx : x ∈ l hx' : f ∈ List.map (fun f => Equiv.swap a x * f) (permsOfList l) g : Equiv.Perm α hg : g ∈ permsOfList l ∧ Equiv.swap a x * g = f hgxa : ↑g⁻¹ x = a hxa : x ≠ a ⊢ False [PROOFSTEP] exact (List.nodup_cons.1 hl).1 <| hgxa ▸ mem_of_mem_permsOfList hg.1 _ (by rwa [apply_inv_self, hgxa]) [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝¹ : DecidableEq α inst✝ : DecidableEq β a : α l : List α hl : Nodup (a :: l) hl' : Nodup l hln' : Nodup (permsOfList l) hmeml : ∀ {f : Equiv.Perm α}, f ∈ permsOfList l → ↑f a = a f : Equiv.Perm α hf₁ : f ∈ permsOfList l hf₂ : f ∈ List.bind l fun b => List.map (fun f => Equiv.swap a b * f) (permsOfList l) x : α hx : x ∈ l hx' : f ∈ List.map (fun f => Equiv.swap a x * f) (permsOfList l) g : Equiv.Perm α hg : g ∈ permsOfList l ∧ Equiv.swap a x * g = f hgxa : ↑g⁻¹ x = a hxa : x ≠ a ⊢ ↑g (↑g⁻¹ x) ≠ ↑g⁻¹ x [PROOFSTEP] rwa [apply_inv_self, hgxa] [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝¹ : DecidableEq α inst✝ : DecidableEq β s : Finset α a b : List α hab : a ≈ b ha : Multiset.Nodup (Quotient.mk (isSetoid α) a) hb : Multiset.Nodup (Quotient.mk (isSetoid α) b) x✝ : HEq ha hb ⊢ ∀ (a_1 : Equiv.Perm α), a_1 ∈ { val := ↑(permsOfList a), nodup := (_ : Nodup (permsOfList a)) } ↔ a_1 ∈ { val := ↑(permsOfList b), nodup := (_ : Nodup (permsOfList b)) } [PROOFSTEP] simp [mem_permsOfList_iff, hab.mem_iff] [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝¹ : DecidableEq α inst✝ : DecidableEq β ⊢ ∀ {s : Finset α} {f : Equiv.Perm α}, f ∈ permsOfFinset s ↔ ∀ {x : α}, ↑f x ≠ x → x ∈ s [PROOFSTEP] rintro ⟨⟨l⟩, hs⟩ f [GOAL] case mk.mk α : Type u_1 β : Type u_2 γ : Type u_3 inst✝¹ : DecidableEq α inst✝ : DecidableEq β val✝ : Multiset α l : List α hs : Multiset.Nodup (Quot.mk Setoid.r l) f : Equiv.Perm α ⊢ f ∈ permsOfFinset { val := Quot.mk Setoid.r l, nodup := hs } ↔ ∀ {x : α}, ↑f x ≠ x → x ∈ { val := Quot.mk Setoid.r l, nodup := hs } [PROOFSTEP] exact mem_permsOfList_iff [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝¹ : DecidableEq α inst✝ : DecidableEq β ⊢ ∀ (s : Finset α), card (permsOfFinset s) = (card s)! [PROOFSTEP] rintro ⟨⟨l⟩, hs⟩ [GOAL] case mk.mk α : Type u_1 β : Type u_2 γ : Type u_3 inst✝¹ : DecidableEq α inst✝ : DecidableEq β val✝ : Multiset α l : List α hs : Multiset.Nodup (Quot.mk Setoid.r l) ⊢ card (permsOfFinset { val := Quot.mk Setoid.r l, nodup := hs }) = (card { val := Quot.mk Setoid.r l, nodup := hs })! [PROOFSTEP] exact length_permsOfList l [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝² : DecidableEq α inst✝¹ : DecidableEq β inst✝ : Fintype α ⊢ ∀ (x : Equiv.Perm α), x ∈ permsOfFinset univ [PROOFSTEP] simp [mem_perms_of_finset_iff]
{-# OPTIONS --without-K --safe #-} open import Categories.Category -- Power Functors, Exponentials over a Category C -- Mainly categories where the objects are functions (Fin n -> Obj) considered pointwise -- and then upgraded to Functors. module Categories.Functor.Power {o ℓ e} (C : Category o ℓ e) where open Category C open HomReasoning open import Level using (Level; _⊔_) open import Data.Nat using (ℕ; _+_; zero; suc; _<_) open import Data.Product using (_,_) open import Data.Fin using (Fin; inject+; raise; zero; suc; fromℕ<) open import Data.Sum using (_⊎_; inj₁; inj₂; map) renaming ([_,_] to ⟦_,_⟧; [_,_]′ to ⟦_,_⟧′) open import Data.Vec.N-ary hiding (curryⁿ) open import Function as Fun using (flip; _$_) renaming (_∘_ to _∙_; id to idf) open import Categories.Category.Product using (Product; _⁂_) open import Categories.Functor hiding (id) open import Categories.Functor.Bifunctor using (Bifunctor; overlap-×) private variable i j k : Level I I′ J J′ : Set i D E : Category i j k n n′ m m′ : ℕ Exp : Set i → Category _ _ _ Exp I = record { Obj = I → Obj ; _⇒_ = λ x y → ∀ i → x i ⇒ y i ; _≈_ = λ f g → ∀ i → f i ≈ g i ; id = λ _ → id ; _∘_ = λ f g i → f i ∘ g i ; assoc = λ _ → assoc ; sym-assoc = λ _ → sym-assoc ; identityˡ = λ _ → identityˡ ; identityʳ = λ _ → identityʳ ; identity² = λ _ → identity² ; equiv = record { refl = λ _ → refl ; sym = λ eq i → sym $ eq i ; trans = λ eq₁ eq₂ i → trans (eq₁ i) (eq₂ i) } ; ∘-resp-≈ = λ eq₁ eq₂ i → ∘-resp-≈ (eq₁ i) (eq₂ i) } Power : (n : ℕ) → Category o ℓ e Power n = Exp (Fin n) -- Convention: the ′ version is for a general index set, unprimed for a ℕ -- representing Fin n. So Powerfunctor D n is Exp C (Fin n) ⇒ D, i.e. -- essentially C ^ n ⇒ D. Powerfunctor′ : (D : Category o ℓ e) (I : Set i) → Set (i ⊔ e ⊔ ℓ ⊔ o) Powerfunctor′ D I = Functor (Exp I) D Powerfunctor : (D : Category o ℓ e) (n : ℕ) → Set (e ⊔ ℓ ⊔ o) Powerfunctor D n = Powerfunctor′ D (Fin n) -- With C = D, so Powerendo n is C ^ n => C Powerendo′ : (I : Set i) → Set (i ⊔ e ⊔ ℓ ⊔ o) Powerendo′ I = Powerfunctor′ C I Powerendo : (n : ℕ) → Set (e ⊔ ℓ ⊔ o) Powerendo n = Powerfunctor C n -- Hyperendo n m is C ^ n ⇒ C ^ m Hyperendo : (n m : ℕ) → Set (e ⊔ ℓ ⊔ o) Hyperendo n m = Functor (Power n) (Power m) -- Hyperendo′ I J is C ^ I → C ^ J Hyperendo′ : (I : Set i) (J : Set j) → Set (i ⊔ j ⊔ e ⊔ ℓ ⊔ o) Hyperendo′ I J = Functor (Exp I) (Exp J) -- Parallel composition of Hyperendo′ (via disjoint union of index sets) infixr 9 _par_ _par_ : (F : Hyperendo′ I I′) (G : Hyperendo′ J J′) → Hyperendo′ (I ⊎ J) (I′ ⊎ J′) F par G = record { F₀ = λ xs → ⟦ F.F₀ (xs ∙ inj₁) , G.F₀ (xs ∙ inj₂) ⟧′ ; F₁ = λ fs → ⟦ F.F₁ (fs ∙ inj₁) , G.F₁ (fs ∙ inj₂) ⟧ ; identity = ⟦ F.identity , G.identity ⟧ ; homomorphism = ⟦ F.homomorphism , G.homomorphism ⟧ ; F-resp-≈ = λ fs≈gs → ⟦ F.F-resp-≈ (fs≈gs ∙ inj₁) , G.F-resp-≈ (fs≈gs ∙ inj₂) ⟧ } where module F = Functor F module G = Functor G -- "flattening" means going from a general disjoint union of Fin to a single Fin, -- which has the effect of doing from Powerfunctor′ to Powerfunctor flattenP : (F : Powerfunctor′ D (Fin n ⊎ Fin m)) → Powerfunctor D (n + m) flattenP {n = n} {m = m} F = record { F₀ = λ As → F₀ (As ∙ pack) ; F₁ = λ fs → F₁ (fs ∙ pack) ; identity = identity ; homomorphism = homomorphism ; F-resp-≈ = λ fs≈gs → F-resp-≈ (fs≈gs ∙ pack) } where open Functor F pack = ⟦ inject+ m , raise n ⟧′ -- TODO unpackFun (and pack above) should be in stdlib private unpackFin : ∀ n → Fin (n + m) → Fin n ⊎ Fin m unpackFin zero f = inj₂ f unpackFin (suc n) zero = inj₁ zero unpackFin (suc n) (suc f) = map suc idf (unpackFin n f) -- needs a better name? unflattenP : Powerfunctor D (n + m) → Powerfunctor′ D (Fin n ⊎ Fin m) unflattenP {n = n} {m = m} F = record { F₀ = λ As → F₀ (As ∙ unpackFin _) ; F₁ = λ fs → F₁ (fs ∙ unpackFin _) ; identity = identity ; homomorphism = homomorphism ; F-resp-≈ = λ fs≈gs → F-resp-≈ (fs≈gs ∙ unpackFin _) } where open Functor F -- flatten a Hyperendo′ "on the right" when over a union of Fin flattenHʳ : (F : Hyperendo′ I (Fin n ⊎ Fin m)) → Hyperendo′ I (Fin (n + m)) flattenHʳ {n = n} {m = m} F = record { F₀ = λ As → F₀ As ∙ unpackFin n ; F₁ = λ fs → F₁ fs ∙ unpackFin n ; identity = identity ∙ unpackFin n ; homomorphism = homomorphism ∙ unpackFin n ; F-resp-≈ = λ fs≈gs → F-resp-≈ fs≈gs ∙ unpackFin n } where open Functor F -- flatten on both sides. flattenH : (F : Hyperendo′ (Fin n ⊎ Fin m) (Fin n′ ⊎ Fin m′)) → Hyperendo (n + m) (n′ + m′) flattenH = flattenHʳ ∙ flattenP -- Pretty syntax for flattening of parallel composition of Hyperendo infixr 9 _∥_ _∥_ : (F : Hyperendo n n′) (G : Hyperendo m m′) → Hyperendo (n + m) (n′ + m′) F ∥ G = flattenH (F par G) -- split is C ^ (I ⊎ J) to C ^ I × C ^ J, as a Functor split : Functor (Exp (I ⊎ J)) (Product (Exp I) (Exp J)) split = record { F₀ = λ As → As ∙ inj₁ , As ∙ inj₂ ; F₁ = λ fs → fs ∙ inj₁ , fs ∙ inj₂ ; identity = (λ _ → refl) , λ _ → refl ; homomorphism = (λ _ → refl) , λ _ → refl ; F-resp-≈ = λ eq → (λ i → eq (inj₁ i)) , λ i → eq (inj₂ i) } reduce′ : (H : Bifunctor C C C) (F : Powerendo′ I) (G : Powerendo′ J) → Powerendo′ (I ⊎ J) reduce′ H F G = H ∘F (F ⁂ G) ∘F split reduce : ∀ (H : Bifunctor C C C) {n m} (F : Powerendo n) (G : Powerendo m) → Powerendo (n + m) reduce H F G = flattenP $ reduce′ H F G flattenP-assocʳ : ∀ {n₁ n₂ n₃} (F : Powerendo′ (Fin n₁ ⊎ Fin n₂ ⊎ Fin n₃)) → Powerendo (n₁ + n₂ + n₃) flattenP-assocʳ {n₁} {n₂} {n₃} F = record { F₀ = λ As → F.F₀ (As ∙ pack) ; F₁ = λ fs → F.F₁ (fs ∙ pack) ; identity = F.identity ; homomorphism = F.homomorphism ; F-resp-≈ = λ fs≈gs → F.F-resp-≈ (fs≈gs ∙ pack) } where module F = Functor F pack = ⟦ inject+ n₃ ∙ inject+ n₂ , ⟦ inject+ n₃ ∙ raise n₁ , raise (n₁ + n₂) ⟧′ ⟧′ reduce2ʳ : ∀ (G : Bifunctor C C C) {n₁ n₂ n₃} (F₁ : Powerendo n₁) (F₂ : Powerendo n₂) (F₃ : Powerendo n₃) → Powerendo ((n₁ + n₂) + n₃) reduce2ʳ G F₁ F₂ F₃ = flattenP-assocʳ $ reduce′ G F₁ $ reduce′ G F₂ F₃ overlaps : (H : Bifunctor D D E) (F G : Powerfunctor′ D I) → Powerfunctor′ E I overlaps = overlap-× overlap2ʳ : (G : Bifunctor C C C) (F₁ F₂ F₃ : Powerendo n) → Powerendo n overlap2ʳ G F₁ F₂ F₃ = overlaps G F₁ (overlaps G F₂ F₃) -- select′ i always evaluates at i select′ : (i : I) → Powerendo′ I select′ i = record { F₀ = _$ i ; F₁ = _$ i ; identity = refl ; homomorphism = refl ; F-resp-≈ = _$ i } -- select (m < n) is really select′ (Fin n), but only for m < n select : m < n → Powerendo n select m<n = select′ (fromℕ< m<n) triv : (n : ℕ) → Hyperendo n n triv n = record { F₀ = idf ; F₁ = idf ; identity = λ _ → refl ; homomorphism = λ _ → refl ; F-resp-≈ = idf } -- pad a Hyperendo on the left and right by trivial (i.e. identity) endofunctors pad : ∀ (l r : ℕ) (F : Hyperendo n m) → Hyperendo ((l + n) + r) ((l + m) + r) pad l r F = (triv l ∥ F) ∥ triv r padˡ : ∀ (l : ℕ) (F : Hyperendo n m) → Hyperendo (l + n) (l + m) padˡ l F = triv l ∥ F padʳ : ∀ (r : ℕ) (F : Hyperendo n m) → Hyperendo (n + r) (m + r) padʳ r F = F ∥ triv r unary : Endofunctor C → Powerendo 1 unary F = record { F₀ = λ As → F.F₀ (As zero) ; F₁ = λ fs → F.F₁ (fs zero) ; identity = F.identity ; homomorphism = F.homomorphism ; F-resp-≈ = λ fs≈gs → F.F-resp-≈ (fs≈gs zero) } where module F = Functor F unaryH : Endofunctor C → Hyperendo 1 1 unaryH F = record { F₀ = λ As → F.F₀ ∙ As ; F₁ = λ fs → F.F₁ ∙ fs ; identity = λ _ → F.identity ; homomorphism = λ _ → F.homomorphism ; F-resp-≈ = λ fs≈gs → F.F-resp-≈ ∙ fs≈gs } where module F = Functor F -- "constant" nullary : Obj → Powerendo 0 nullary X = record { F₀ = λ _ → X ; F₁ = λ _ → id ; identity = refl ; homomorphism = sym identity² ; F-resp-≈ = λ _ → refl } nullaryH : Obj → Hyperendo 0 1 nullaryH X = record { F₀ = λ _ _ → X ; F₁ = λ _ _ → id ; identity = λ _ → refl ; homomorphism = λ _ → sym identity² ; F-resp-≈ = λ _ _ → refl } binary : Bifunctor C C C → Powerendo 2 binary F = record { F₀ = λ As → F.F₀ (As zero , As (suc zero)) ; F₁ = λ fs → F.F₁ (fs zero , fs (suc zero)) ; identity = F.identity ; homomorphism = F.homomorphism ; F-resp-≈ = λ fs≈gs → F.F-resp-≈ (fs≈gs zero , fs≈gs (suc zero)) } where module F = Functor F binaryH : Bifunctor C C C → Hyperendo 2 1 binaryH F = record { F₀ = λ As _ → F.F₀ (As zero , As (suc zero)) ; F₁ = λ fs _ → F.F₁ (fs zero , fs (suc zero)) ; identity = λ _ → F.identity ; homomorphism = λ _ → F.homomorphism ; F-resp-≈ = λ fs≈gs _ → F.F-resp-≈ (fs≈gs zero , fs≈gs (suc zero)) } where module F = Functor F hyp : Powerendo n → Hyperendo n 1 hyp F = record { F₀ = λ As _ → F.F₀ As ; F₁ = λ fs _ → F.F₁ fs ; identity = λ _ → F.identity ; homomorphism = λ _ → F.homomorphism ; F-resp-≈ = λ fs≈gs _ → F.F-resp-≈ fs≈gs } where module F = Functor F private curryⁿ : ∀ n {a b} {A : Set a} {B : Set b} → ((Fin n → A) → B) → N-ary n A B curryⁿ zero f = f (λ ()) curryⁿ (suc n) {A = A} f = λ x → curryⁿ n (f ∙ addon x) where addon : A → (Fin n → A) → Fin (suc n) → A addon x _ zero = x addon _ g (suc i) = g i plex′ : (J → Powerendo′ I) → Hyperendo′ I J plex′ Fs = record { F₀ = flip (Functor.F₀ ∙ Fs) ; F₁ = flip (λ j → Functor.F₁ (Fs j)) ; identity = λ j → Functor.identity (Fs j) ; homomorphism = λ j → Functor.homomorphism (Fs j) ; F-resp-≈ = flip (λ j → Functor.F-resp-≈ (Fs j)) } plex : N-ary n (Powerendo′ I) (Hyperendo′ I (Fin n)) plex {n = n} = curryⁿ n plex′ -- like pad, but for Powerendo -- on left or right. widenˡ : ∀ (l : ℕ) (F : Powerendo n) → Powerendo (l + n) widenˡ l F = record { F₀ = λ As → F.F₀ (As ∙ pack) ; F₁ = λ {As Bs} fs → F.F₁ (fs ∙ pack) ; identity = F.identity ; homomorphism = F.homomorphism ; F-resp-≈ = λ fs≈gs → F.F-resp-≈ (fs≈gs ∙ pack) } where module F = Functor F pack = raise l widenʳ : ∀ (r : ℕ) (F : Powerendo n) → Powerendo (n + r) widenʳ r F = record { F₀ = λ As → F.F₀ (As ∙ pack) ; F₁ = λ fs → F.F₁ (fs ∙ pack) ; identity = F.identity ; homomorphism = F.homomorphism ; F-resp-≈ = λ fs≈gs → F.F-resp-≈ (fs≈gs ∙ pack) } where module F = Functor F pack = inject+ r
Formal statement is: lemma convergentI: "X \<longlonglongrightarrow> L \<Longrightarrow> convergent X" Informal statement is: If a sequence converges, then it is convergent.
Require Import Crypto.Arithmetic.PrimeFieldTheorems. Require Import Crypto.Specific.solinas64_2e416m2e208m1_9limbs.Synthesis. (* TODO : change this to field once field isomorphism happens *) Definition carry : { carry : feBW_loose -> feBW_tight | forall a, phiBW_tight (carry a) = (phiBW_loose a) }. Proof. Set Ltac Profiling. Time synthesize_carry (). Show Ltac Profile. Time Defined. Print Assumptions carry.
module Optics.Iso where open import Agda.Primitive using (Level; _⊔_; lsuc) open import Function.Equality using (Π) open import Function.Inverse using (_↔_; inverse; Inverse; _InverseOf_) open import Relation.Binary.PropositionalEquality using (_≡_; →-to-⟶; refl) open import Category.Functor.Arr open import Category.Functor.Const open import Category.Profunctor open import Category.Profunctor.Star open import Category.Profunctor.Joker open import Optics Iso : ∀ {l} (S T A B : Set l) → Set (lsuc l) Iso = Optic ProfunctorImp module Iso {l} {S T A B : Set l} (iso : Iso S T A B) where get : S → A get = getOptic S T A B (starProfunctor constFunctor) iso put : B → T put = putOptic S T A B (jokerProfunctor arrFunctor) iso record LawfulIsoImp {l} {S A : Set l} (iso' : Iso S S A A) : Set (lsuc l) where open Iso iso' field putget : ∀ (s : S) → put (get s) ≡ s getput : ∀ (a : A) → get (put a) ≡ a module LawfulIso {l} {S A : Set l} {iso' : Iso S S A A} (isLawful : LawfulIsoImp iso') where open Iso iso' public iso : Iso S S A A iso = iso' open LawfulIsoImp isLawful public isoIso : ∀ {S A : Set} {iso : Iso S S A A} → (i : LawfulIsoImp iso) → S ↔ A isoIso {S} {A} i = inverse to from from∘to to∘from where open LawfulIso i to = get from = put from∘to : (s : S) → from (to s) ≡ s from∘to = putget to∘from : (a : A) → to (from a) ≡ a to∘from = getput invLawfulIso : ∀ {l} {S A : Set l} {get : S → A} {put : A → S} → (→-to-⟶ get) InverseOf (→-to-⟶ put) ↔ LawfulIsoImp (λ p → Profunctor.dimap p get put) invLawfulIso = inverse invertibleIsLawful lawfulIsInvertible (λ _ → refl) (λ _ → refl) where invertibleIsLawful : ∀ {l} {S A : Set l} {get : S → A} {put : A → S} → (→-to-⟶ get) InverseOf (→-to-⟶ put) → LawfulIsoImp (λ p → Profunctor.dimap p get put) invertibleIsLawful i = record { putget = right-inverse-of ; getput = left-inverse-of } where open _InverseOf_ i lawfulIsInvertible : ∀ {l} {S A : Set l} {get : S → A} {put : A → S} → LawfulIsoImp (λ p → Profunctor.dimap p get put) → (→-to-⟶ get) InverseOf (→-to-⟶ put) lawfulIsInvertible isLawful = record { left-inverse-of = getput ; right-inverse-of = putget } where open LawfulIso isLawful
In 1995 , Reines was honored , along with Martin L. Perl with the Nobel Prize in Physics for his work with Cowan in first detecting the neutrino . Unfortunately , Cowan had died in 1974 , and the Nobel Prize is not awarded posthumously . Reines also received many other awards , including the J. Robert Oppenheimer Memorial Prize in 1981 , the National Medal of Science in 1985 , the Bruno Rossi Prize in 1989 , the Michelson – Morley Award in 1990 , the Panofsky Prize in 1992 , and the Franklin Medal in 1992 . He was elected a member of the National Academy of Sciences in 1980 and a foreign member of the Russian Academy of Sciences in 1994 . He remained dean of physical sciences at UCI until 1974 , and became a professor emeritus in 1988 , but he continued teaching until 1991 , and remained on UCI 's faculty until his death .
# -*- coding: utf-8 -*- """ Created on Thu Oct 17 20:04:03 2019 @author: Wenbin Yao """ import pandas as pd import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import axes3d from matplotlib import cm #define the global variable UnitX = 0.5 #every segment's length UnitTime = 0.00278 #unit time K = 180 #total round Vf = 100 #free speed DensityMax = 160 rk = 800 #for every time, on ramp flow is 800 veh/h beta = 0.1 #off ramp coefficient DensityIni = 20 #every segment's initial density class Segment: # define a class of segment. kt = 0 #document the time of round QoutNext_k2 = 0 #the flow of next segment at the time kt. Density_k1 = 0 #the density of time kt - 1 Density_k2 = 0 #the density of time kt Velocity = 0 #the speed of the segment at the time kt SegOrd = 0 #the order of segment QoutLast_k1 = 0 # last segment's flow at the time kt - 1 Qout_k1 = 0 # flow of time kt - 1 Qout_k2 = 0 #flow of time kt def __init__(self , DensityNextSeg_k2 , Density_k1 , kt , SegOrd , QoutLast_k1 , Qout_k1): self.DensityNextSeg_k2 = DensityNextSeg_k2 self.Density_k1 = Density_k1 self.kt = kt self.SegOrd = SegOrd self.QoutLast_k1 = QoutLast_k1 self.Qout_k1 = Qout_k1 def GetParameter(self): if self.SegOrd == 0 or self.SegOrd == 2 or self.SegOrd == 3 or self.SegOrd == 5: #get the parameter of the segment that we need, which is the order 1,3,4,6. there is no ramp. temp = self.Density_k1 + UnitTime / UnitX * (self.QoutLast_k1 - self.Qout_k1) #get next time density if temp > 160: self.Density_k2 = 160 elif temp < 0: self.Density_k2 = 0 else: self.Density_k2 = temp # get Qout at time kt if self.Density_k2 <= 80: QDemand = self.Density_k2 * Vf * (1 - self.Density_k2 / DensityMax) elif self.Density_k2 > 80: QDemand = 4000 if self.DensityNextSeg_k2 <= 80: QCapNextSeg = 4000 elif self.DensityNextSeg_k2 > 80: QCapNextSeg = self.DensityNextSeg_k2 * Vf * (1 - self.DensityNextSeg_k2 / DensityMax) self.Qout_k2 = min(QDemand , QCapNextSeg) #fet velocity if self.Density_k2 < 0.0000000001: self.Velocity = 0 else: self.Velocity = self.Qout_k2 / self.Density_k2 elif self.SegOrd == 1: #get the parameter of the segment that we need, which is the order 2. there is off ramp. temp = self.Density_k1 + UnitTime / UnitX * (self.QoutLast_k1 - self.Qout_k1 - beta * self.QoutLast_k1) #get next time density if temp > 160: self.Density_k2 = 160 elif temp < 0: self.Density_k2 = 0 else: self.Density_k2 = temp # get Qout at time kt if self.Density_k2 <= 80: QDemand = self.Density_k2 * Vf * (1 - self.Density_k2 / DensityMax) elif self.Density_k2 > 80: QDemand = 4000 if self.DensityNextSeg_k2 <= 80: QCapNextSeg = 4000 elif self.DensityNextSeg_k2 > 80: QCapNextSeg = self.DensityNextSeg_k2 * Vf * (1 - self.DensityNextSeg_k2 / DensityMax) self.Qout_k2 = min(QDemand , QCapNextSeg) #get velocity if self.Density_k2 < 0.0000000001: self.Velocity = 0 else: self.Velocity = self.Qout_k2 / self.Density_k2 elif self.SegOrd == 4: # get the parameter of the segment that we need, which is the order 4. there is on ramp. temp = self.Density_k1 + UnitTime / UnitX * (self.QoutLast_k1 - self.Qout_k1 + rk ) #get next time density if temp > 160: self.Density_k2 = 160 elif temp < 0: self.Density_k2 = 0 else: self.Density_k2 = temp # get Qout at time kt if self.Density_k2 <= 80: QDemand = self.Density_k2 * Vf * (1 - self.Density_k2 / DensityMax) elif self.Density_k2 > 80: QDemand = 4000 if self.DensityNextSeg_k2 <= 80: QCapNextSeg = 4000 elif self.DensityNextSeg_k2 > 80: QCapNextSeg = self.DensityNextSeg_k2 * Vf * (1 - self.DensityNextSeg_k2 / DensityMax) self.Qout_k2 = min(QDemand , QCapNextSeg) #get velocity if self.Density_k2 < 0.0000000001: self.Velocity = 0 else: self.Velocity = self.Qout_k2 / self.Density_k2 else: print("There is no such segment, please check the order of segment!") def Time(kt , SegmentListLasttime): ''' calculate the traffic flow of kt time input:kt:time ; SegmentListLasttime:a list of cevery segment last time ''' if kt == 1: # first time of evolution of the link SegmentList = [0 for j in range(6)] # new a list to store the segment 1-6 of this time for i in range(6): j = 5 - i if j == 5: SegmentTemp = Segment(0 , 20 , kt , j , 1750 , 1750) SegmentTemp.GetParameter() SegmentList[j] = SegmentTemp elif j == 0: SegmentTemp = Segment(SegmentList[j + 1].Density_k2 , 20 , kt , j , 4000 , 1750) SegmentTemp.GetParameter() SegmentList[j] = SegmentTemp else: SegmentTemp = Segment(SegmentList[j + 1].Density_k2 , 20 , kt , j , 1750 , 1750) SegmentTemp.GetParameter() SegmentList[j] = SegmentTemp return SegmentList elif kt > 1 and kt <= 100: SegmentList = [0 for j in range(6)] #new a list to store the segment1-6 of this time for i in range(6): j = 5 - i if j == 5: SegmentTemp = Segment(0 , SegmentListLasttime[j].Density_k2 , kt , j , \ SegmentListLasttime[j - 1].Qout_k2 , SegmentListLasttime[j].Qout_k2) SegmentTemp.GetParameter() SegmentList[j] = SegmentTemp elif j == 0: SegmentTemp = Segment(SegmentList[j + 1].Density_k2 , SegmentListLasttime[j].Density_k2 , kt , j , \ 4000 , SegmentListLasttime[j].Qout_k2) SegmentTemp.GetParameter() SegmentList[j] = SegmentTemp else: SegmentTemp = Segment(SegmentList[j + 1].Density_k2 , SegmentListLasttime[j].Density_k2 , kt , j , \ SegmentListLasttime[j - 1].Qout_k2 , SegmentListLasttime[j].Qout_k2) SegmentTemp.GetParameter() SegmentList[j] = SegmentTemp return SegmentList elif kt > 100 and kt <= 180: SegmentList = [0 for j in range(6)] #new a list to store the segment1-6 of this time for i in range(6): j = 5 - i if j == 5: SegmentTemp = Segment(0 , SegmentListLasttime[j].Density_k2 , kt , j , \ SegmentListLasttime[j - 1].Qout_k2 , SegmentListLasttime[j].Qout_k2) SegmentTemp.GetParameter() SegmentList[j] = SegmentTemp elif j == 0: SegmentTemp = Segment(SegmentList[j + 1].Density_k2 , SegmentListLasttime[j].Density_k2 , kt , j , \ 2000 , SegmentListLasttime[j].Qout_k2) SegmentTemp.GetParameter() SegmentList[j] = SegmentTemp else: SegmentTemp = Segment(SegmentList[j + 1].Density_k2 , SegmentListLasttime[j].Density_k2 , kt , j , \ SegmentListLasttime[j - 1].Qout_k2 , SegmentListLasttime[j].Qout_k2) SegmentTemp.GetParameter() SegmentList[j] = SegmentTemp return SegmentList else: print("Time restricted to 0-180, other time still not support!") return None def TimeSpacePlot(SegmentTimeseries): # 3-dimensional time-space plots for the speed and density SpeedList = [] # store every segment's speed over time DensityList = [] # store every segment's density over time for i in range(6): tempspeed = [] #store segment's flow over time tempdensity = [] #same func with above for ti in range(1 , K + 1): tempspeed.append(SegmentTimeseries[ti][i].Velocity) tempdensity.append(SegmentTimeseries[ti][i].Density_k2) SpeedList.append(tempspeed) DensityList.append(tempdensity) # plot 3-dimensional time-space plots for the speed TimeList = np.linspace(1, 180 , 180) #X轴数据 SegmentList = [0 for j in range(180)] SpeedList2 = SpeedList[0] DensityList2 = DensityList[0] # new a figure and set it into 3d plt.rcParams['savefig.dpi'] = 300 #图片像素 fig = plt.figure() ax = fig.gca(projection='3d') # set figure information ax.set_title(" 3-dimensional time-space plots for the speed ") ax.set_xlabel("Time(Unit)") ax.set_ylabel("Segment(start from 0)") ax.set_zlabel("Speed(km/h)") for i in range(5): TimeList = np.append(TimeList , np.linspace(1, 180 , 180)) SegmentList = np.append(SegmentList , [(i + 1) for j in range(180)]) SpeedList2 = np.append(SpeedList2 , SpeedList[i + 1]) DensityList2 = np.append(DensityList2 , DensityList[i + 1]) surf = ax.plot_trisurf(TimeList, SegmentList , SpeedList2 , cmap=cm.jet, linewidth=0.2) # Add a color bar which maps values to colors. fig.colorbar(surf, shrink=0.5, aspect=5) plt.savefig('速度三维时空图.png') plt.show() plt.rcParams['savefig.dpi'] = 300 #图片像素 fig = plt.figure() ax = fig.gca(projection='3d') # set figure information ax.set_title("3-dimensional time-space plots for the density ") ax.set_xlabel("Time(Unit)") ax.set_ylabel("Segment(start from 0)") ax.set_zlabel("Density(veh/km)") surf = ax.plot_trisurf(TimeList, SegmentList , DensityList2 , cmap=cm.jet, linewidth=0.2) # Add a color bar which maps values to colors. fig.colorbar(surf, shrink=0.5, aspect=5) plt.savefig('密度三维时空图.png') plt.show() def FlowDensityPlot(SegmentTimeseries): # plot of Flow and Density diagram over time FlowList = [] # store every segment's flow over time DensityList = [] # store every segment's density over time for i in range(6): tempflow = [] #store segment's flow over time tempdensity = [] #same func with above for ti in range(1 , K + 1): tempflow.append(SegmentTimeseries[ti][i].Qout_k2) tempdensity.append(SegmentTimeseries[ti][i].Density_k2) FlowList.append(tempflow) DensityList.append(tempdensity) #plot plt.rcParams['savefig.dpi'] = 300 #图片像素 plt.figure(figsize=(8,4)) x = np.linspace(1, 180 , 180)#X轴数据 for i in range(6): plt.plot(x , FlowList[i] , label = "Segment" + str(i) , linewidth=2)#将$包围的内容渲染为数学公式 plt.xlabel("Time(Unit)") plt.ylabel("Flow(veh/hour)") plt.title("Line chart of flow changing with time") # plt.ylim(-1.5,1.5) plt.legend()#显示左下角的图例 plt.savefig('流量随时间变化折线图.png') plt.show() #plot density changing with time for i in range(6): plt.plot(x , DensityList[i] , label = "Segment" + str(i) , linewidth=2)#将$包围的内容渲染为数学公式 plt.xlabel("Time(Unit)") plt.ylabel("Density(veh/km)") plt.title("Line chart of density changing with time") # plt.ylim(-1.5,1.5) plt.legend()#显示左下角的图例 plt.savefig('密度随时间变化折线图.png') plt.show() if __name__ == "__main__": SegmentTimeseries = [] #set a list to store every time's segment list SegmentTimeseries.append(None) SegmentListLasttime = None #initialize the SegmentListLasttime for ti in range(1 , K + 1): SegmentTimeseries.append( Time(ti , SegmentListLasttime) ) SegmentListLasttime = SegmentTimeseries[ti] #update SegmenntLasttime # Test blow result is right print("Time 1 segment 0 : Qout: " , SegmentTimeseries[1][0].Qout_k2 , " veh/hour") print("Time 2 segment 0 : Density: " , SegmentTimeseries[2][0].Density_k2 , " veh/km") print("Time 50 segment 5 : Qout: " , SegmentTimeseries[50][5].Qout_k2 , " veh/hour") print("Time 180 segment 3 : Qout: " , SegmentTimeseries[180][3].Qout_k2 , " veh/hour") print("Time 180 segment 4 : Qout: " , SegmentTimeseries[180][4].Qout_k2 , " veh/hour") # plot Flow and Density diagram over time FlowDensityPlot(SegmentTimeseries) # 3-dimensional time-space plots for the speed and density TimeSpacePlot(SegmentTimeseries)
(* Title: HOL/MicroJava/BV/Semilat.thy Author: Tobias Nipkow Copyright 2000 TUM Semilattices. *) chapter \<open>Data Flow Analysis Framework \label{cha:bv}\<close> section \<open>Semilattices\<close> theory Semilat imports Main "HOL-Library.While_Combinator" begin type_synonym 'a ord = "'a \<Rightarrow> 'a \<Rightarrow> bool" type_synonym 'a binop = "'a \<Rightarrow> 'a \<Rightarrow> 'a" type_synonym 'a sl = "'a set \<times> 'a ord \<times> 'a binop" definition lesub :: "'a \<Rightarrow> 'a ord \<Rightarrow> 'a \<Rightarrow> bool" where "lesub x r y \<longleftrightarrow> r x y" definition lesssub :: "'a \<Rightarrow> 'a ord \<Rightarrow> 'a \<Rightarrow> bool" where "lesssub x r y \<longleftrightarrow> lesub x r y \<and> x \<noteq> y" definition plussub :: "'a \<Rightarrow> ('a \<Rightarrow> 'b \<Rightarrow> 'c) \<Rightarrow> 'b \<Rightarrow> 'c" where "plussub x f y = f x y" notation (ASCII) "lesub" ("(_ /<='__ _)" [50, 1000, 51] 50) and "lesssub" ("(_ /<'__ _)" [50, 1000, 51] 50) and "plussub" ("(_ /+'__ _)" [65, 1000, 66] 65) notation "lesub" ("(_ /\<sqsubseteq>\<^bsub>_\<^esub> _)" [50, 0, 51] 50) and "lesssub" ("(_ /\<sqsubset>\<^bsub>_\<^esub> _)" [50, 0, 51] 50) and "plussub" ("(_ /\<squnion>\<^bsub>_\<^esub> _)" [65, 0, 66] 65) (* allow \<sub> instead of \<bsub>..\<esub> *) abbreviation (input) lesub1 :: "'a \<Rightarrow> 'a ord \<Rightarrow> 'a \<Rightarrow> bool" ("(_ /\<sqsubseteq>\<^sub>_ _)" [50, 1000, 51] 50) where "x \<sqsubseteq>\<^sub>r y == x \<sqsubseteq>\<^bsub>r\<^esub> y" abbreviation (input) lesssub1 :: "'a \<Rightarrow> 'a ord \<Rightarrow> 'a \<Rightarrow> bool" ("(_ /\<sqsubset>\<^sub>_ _)" [50, 1000, 51] 50) where "x \<sqsubset>\<^sub>r y == x \<sqsubset>\<^bsub>r\<^esub> y" abbreviation (input) plussub1 :: "'a \<Rightarrow> ('a \<Rightarrow> 'b \<Rightarrow> 'c) \<Rightarrow> 'b \<Rightarrow> 'c" ("(_ /\<squnion>\<^sub>_ _)" [65, 1000, 66] 65) where "x \<squnion>\<^sub>f y == x \<squnion>\<^bsub>f\<^esub> y" definition ord :: "('a \<times> 'a) set \<Rightarrow> 'a ord" where "ord r = (\<lambda>x y. (x,y) \<in> r)" definition order :: "'a ord \<Rightarrow> bool" where "order r \<longleftrightarrow> (\<forall>x. x \<sqsubseteq>\<^sub>r x) \<and> (\<forall>x y. x \<sqsubseteq>\<^sub>r y \<and> y \<sqsubseteq>\<^sub>r x \<longrightarrow> x=y) \<and> (\<forall>x y z. x \<sqsubseteq>\<^sub>r y \<and> y \<sqsubseteq>\<^sub>r z \<longrightarrow> x \<sqsubseteq>\<^sub>r z)" definition top :: "'a ord \<Rightarrow> 'a \<Rightarrow> bool" where "top r T \<longleftrightarrow> (\<forall>x. x \<sqsubseteq>\<^sub>r T)" definition acc :: "'a set \<Rightarrow> 'a ord \<Rightarrow> bool" where "acc A r \<longleftrightarrow> wf {(y,x). x \<in> A \<and> y \<in> A \<and> x \<sqsubset>\<^sub>r y}" definition closed :: "'a set \<Rightarrow> 'a binop \<Rightarrow> bool" where "closed A f \<longleftrightarrow> (\<forall>x\<in>A. \<forall>y\<in>A. x \<squnion>\<^sub>f y \<in> A)" definition semilat :: "'a sl \<Rightarrow> bool" where "semilat = (\<lambda>(A,r,f). order r \<and> closed A f \<and> (\<forall>x\<in>A. \<forall>y\<in>A. x \<sqsubseteq>\<^sub>r x \<squnion>\<^sub>f y) \<and> (\<forall>x\<in>A. \<forall>y\<in>A. y \<sqsubseteq>\<^sub>r x \<squnion>\<^sub>f y) \<and> (\<forall>x\<in>A. \<forall>y\<in>A. \<forall>z\<in>A. x \<sqsubseteq>\<^sub>r z \<and> y \<sqsubseteq>\<^sub>r z \<longrightarrow> x \<squnion>\<^sub>f y \<sqsubseteq>\<^sub>r z))" definition is_ub :: "('a \<times> 'a) set \<Rightarrow> 'a \<Rightarrow> 'a \<Rightarrow> 'a \<Rightarrow> bool" where "is_ub r x y u \<longleftrightarrow> (x,u)\<in>r \<and> (y,u)\<in>r" definition is_lub :: "('a \<times> 'a) set \<Rightarrow> 'a \<Rightarrow> 'a \<Rightarrow> 'a \<Rightarrow> bool" where "is_lub r x y u \<longleftrightarrow> is_ub r x y u \<and> (\<forall>z. is_ub r x y z \<longrightarrow> (u,z)\<in>r)" definition some_lub :: "('a \<times> 'a) set \<Rightarrow> 'a \<Rightarrow> 'a \<Rightarrow> 'a" where "some_lub r x y = (SOME z. is_lub r x y z)" locale Semilat = fixes A :: "'a set" fixes r :: "'a ord" fixes f :: "'a binop" assumes semilat: "semilat (A, r, f)" lemma order_refl [simp, intro]: "order r \<Longrightarrow> x \<sqsubseteq>\<^sub>r x" (*<*) by (unfold order_def) (simp (no_asm_simp)) (*>*) lemma order_antisym: "\<lbrakk> order r; x \<sqsubseteq>\<^sub>r y; y \<sqsubseteq>\<^sub>r x \<rbrakk> \<Longrightarrow> x = y" (*<*) by (unfold order_def) (simp (no_asm_simp)) (*>*) lemma order_trans: "\<lbrakk> order r; x \<sqsubseteq>\<^sub>r y; y \<sqsubseteq>\<^sub>r z \<rbrakk> \<Longrightarrow> x \<sqsubseteq>\<^sub>r z" (*<*) by (unfold order_def) blast (*>*) lemma order_less_irrefl [intro, simp]: "order r \<Longrightarrow> \<not> x \<sqsubset>\<^sub>r x" (*<*) by (unfold order_def lesssub_def) blast (*>*) lemma order_less_trans: "\<lbrakk> order r; x \<sqsubset>\<^sub>r y; y \<sqsubset>\<^sub>r z \<rbrakk> \<Longrightarrow> x \<sqsubset>\<^sub>r z" (*<*) by (unfold order_def lesssub_def) blast (*>*) lemma topD [simp, intro]: "top r T \<Longrightarrow> x \<sqsubseteq>\<^sub>r T" (*<*) by (simp add: top_def) (*>*) lemma top_le_conv [simp]: "\<lbrakk> order r; top r T \<rbrakk> \<Longrightarrow> (T \<sqsubseteq>\<^sub>r x) = (x = T)" (*<*) by (blast intro: order_antisym) (*>*) lemma semilat_Def: "semilat(A,r,f) \<longleftrightarrow> order r \<and> closed A f \<and> (\<forall>x\<in>A. \<forall>y\<in>A. x \<sqsubseteq>\<^sub>r x \<squnion>\<^sub>f y) \<and> (\<forall>x\<in>A. \<forall>y\<in>A. y \<sqsubseteq>\<^sub>r x \<squnion>\<^sub>f y) \<and> (\<forall>x\<in>A. \<forall>y\<in>A. \<forall>z\<in>A. x \<sqsubseteq>\<^sub>r z \<and> y \<sqsubseteq>\<^sub>r z \<longrightarrow> x \<squnion>\<^sub>f y \<sqsubseteq>\<^sub>r z)" (*<*) by (unfold semilat_def) clarsimp (*>*) lemma (in Semilat) orderI [simp, intro]: "order r" (*<*) using semilat by (simp add: semilat_Def) (*>*) lemma (in Semilat) closedI [simp, intro]: "closed A f" (*<*) using semilat by (simp add: semilat_Def) (*>*) lemma closedD: "\<lbrakk> closed A f; x\<in>A; y\<in>A \<rbrakk> \<Longrightarrow> x \<squnion>\<^sub>f y \<in> A" (*<*) by (unfold closed_def) blast (*>*) lemma closed_UNIV [simp]: "closed UNIV f" (*<*) by (simp add: closed_def) (*>*) lemma (in Semilat) closed_f [simp, intro]: "\<lbrakk>x \<in> A; y \<in> A\<rbrakk> \<Longrightarrow> x \<squnion>\<^sub>f y \<in> A" (*<*) by (simp add: closedD [OF closedI]) (*>*) lemma (in Semilat) refl_r [intro, simp]: "x \<sqsubseteq>\<^sub>r x" by simp lemma (in Semilat) antisym_r [intro?]: "\<lbrakk> x \<sqsubseteq>\<^sub>r y; y \<sqsubseteq>\<^sub>r x \<rbrakk> \<Longrightarrow> x = y" (*<*) by (rule order_antisym) auto (*>*) lemma (in Semilat) trans_r [trans, intro?]: "\<lbrakk>x \<sqsubseteq>\<^sub>r y; y \<sqsubseteq>\<^sub>r z\<rbrakk> \<Longrightarrow> x \<sqsubseteq>\<^sub>r z" (*<*) by (auto intro: order_trans) (*>*) lemma (in Semilat) ub1 [simp, intro?]: "\<lbrakk> x \<in> A; y \<in> A \<rbrakk> \<Longrightarrow> x \<sqsubseteq>\<^sub>r x \<squnion>\<^sub>f y" (*<*) by (insert semilat) (unfold semilat_Def, simp) (*>*) lemma (in Semilat) ub2 [simp, intro?]: "\<lbrakk> x \<in> A; y \<in> A \<rbrakk> \<Longrightarrow> y \<sqsubseteq>\<^sub>r x \<squnion>\<^sub>f y" (*<*) by (insert semilat) (unfold semilat_Def, simp) (*>*) lemma (in Semilat) lub [simp, intro?]: "\<lbrakk> x \<sqsubseteq>\<^sub>r z; y \<sqsubseteq>\<^sub>r z; x \<in> A; y \<in> A; z \<in> A \<rbrakk> \<Longrightarrow> x \<squnion>\<^sub>f y \<sqsubseteq>\<^sub>r z" (*<*) by (insert semilat) (unfold semilat_Def, simp) (*>*) lemma (in Semilat) plus_le_conv [simp]: "\<lbrakk> x \<in> A; y \<in> A; z \<in> A \<rbrakk> \<Longrightarrow> (x \<squnion>\<^sub>f y \<sqsubseteq>\<^sub>r z) = (x \<sqsubseteq>\<^sub>r z \<and> y \<sqsubseteq>\<^sub>r z)" (*<*) by (blast intro: ub1 ub2 lub order_trans) (*>*) lemma (in Semilat) le_iff_plus_unchanged: assumes "x \<in> A" and "y \<in> A" shows "x \<sqsubseteq>\<^sub>r y \<longleftrightarrow> x \<squnion>\<^sub>f y = y" (is "?P \<longleftrightarrow> ?Q") (*<*) proof assume ?P with assms show ?Q by (blast intro: antisym_r lub ub2) next assume ?Q then have "y = x \<squnion>\<^bsub>f\<^esub> y" by simp moreover from assms have "x \<sqsubseteq>\<^bsub>r\<^esub> x \<squnion>\<^bsub>f\<^esub> y" by simp ultimately show ?P by simp qed (*>*) lemma (in Semilat) le_iff_plus_unchanged2: assumes "x \<in> A" and "y \<in> A" shows "x \<sqsubseteq>\<^sub>r y \<longleftrightarrow> y \<squnion>\<^sub>f x = y" (is "?P \<longleftrightarrow> ?Q") (*<*) proof assume ?P with assms show ?Q by (blast intro: antisym_r lub ub1) next assume ?Q then have "y = y \<squnion>\<^bsub>f\<^esub> x" by simp moreover from assms have "x \<sqsubseteq>\<^bsub>r\<^esub> y \<squnion>\<^bsub>f\<^esub> x" by simp ultimately show ?P by simp qed (*>*) lemma (in Semilat) plus_assoc [simp]: assumes a: "a \<in> A" and b: "b \<in> A" and c: "c \<in> A" shows "a \<squnion>\<^sub>f (b \<squnion>\<^sub>f c) = a \<squnion>\<^sub>f b \<squnion>\<^sub>f c" (*<*) proof - from a b have ab: "a \<squnion>\<^sub>f b \<in> A" .. from this c have abc: "(a \<squnion>\<^sub>f b) \<squnion>\<^sub>f c \<in> A" .. from b c have bc: "b \<squnion>\<^sub>f c \<in> A" .. from a this have abc': "a \<squnion>\<^sub>f (b \<squnion>\<^sub>f c) \<in> A" .. show ?thesis proof show "a \<squnion>\<^sub>f (b \<squnion>\<^sub>f c) \<sqsubseteq>\<^sub>r (a \<squnion>\<^sub>f b) \<squnion>\<^sub>f c" proof - from a b have "a \<sqsubseteq>\<^sub>r a \<squnion>\<^sub>f b" .. also from ab c have "\<dots> \<sqsubseteq>\<^sub>r \<dots> \<squnion>\<^sub>f c" .. finally have "a<": "a \<sqsubseteq>\<^sub>r (a \<squnion>\<^sub>f b) \<squnion>\<^sub>f c" . from a b have "b \<sqsubseteq>\<^sub>r a \<squnion>\<^sub>f b" .. also from ab c have "\<dots> \<sqsubseteq>\<^sub>r \<dots> \<squnion>\<^sub>f c" .. finally have "b<": "b \<sqsubseteq>\<^sub>r (a \<squnion>\<^sub>f b) \<squnion>\<^sub>f c" . from ab c have "c<": "c \<sqsubseteq>\<^sub>r (a \<squnion>\<^sub>f b) \<squnion>\<^sub>f c" .. from "b<" "c<" b c abc have "b \<squnion>\<^sub>f c \<sqsubseteq>\<^sub>r (a \<squnion>\<^sub>f b) \<squnion>\<^sub>f c" .. from "a<" this a bc abc show ?thesis .. qed show "(a \<squnion>\<^sub>f b) \<squnion>\<^sub>f c \<sqsubseteq>\<^sub>r a \<squnion>\<^sub>f (b \<squnion>\<^sub>f c)" proof - from b c have "b \<sqsubseteq>\<^sub>r b \<squnion>\<^sub>f c" .. also from a bc have "\<dots> \<sqsubseteq>\<^sub>r a \<squnion>\<^sub>f \<dots>" .. finally have "b<": "b \<sqsubseteq>\<^sub>r a \<squnion>\<^sub>f (b \<squnion>\<^sub>f c)" . from b c have "c \<sqsubseteq>\<^sub>r b \<squnion>\<^sub>f c" .. also from a bc have "\<dots> \<sqsubseteq>\<^sub>r a \<squnion>\<^sub>f \<dots>" .. finally have "c<": "c \<sqsubseteq>\<^sub>r a \<squnion>\<^sub>f (b \<squnion>\<^sub>f c)" . from a bc have "a<": "a \<sqsubseteq>\<^sub>r a \<squnion>\<^sub>f (b \<squnion>\<^sub>f c)" .. from "a<" "b<" a b abc' have "a \<squnion>\<^sub>f b \<sqsubseteq>\<^sub>r a \<squnion>\<^sub>f (b \<squnion>\<^sub>f c)" .. from this "c<" ab c abc' show ?thesis .. qed qed qed (*>*) lemma (in Semilat) plus_com_lemma: "\<lbrakk>a \<in> A; b \<in> A\<rbrakk> \<Longrightarrow> a \<squnion>\<^sub>f b \<sqsubseteq>\<^sub>r b \<squnion>\<^sub>f a" (*<*) proof - assume a: "a \<in> A" and b: "b \<in> A" from b a have "a \<sqsubseteq>\<^sub>r b \<squnion>\<^sub>f a" .. moreover from b a have "b \<sqsubseteq>\<^sub>r b \<squnion>\<^sub>f a" .. moreover note a b moreover from b a have "b \<squnion>\<^sub>f a \<in> A" .. ultimately show ?thesis .. qed (*>*) lemma (in Semilat) plus_commutative: "\<lbrakk>a \<in> A; b \<in> A\<rbrakk> \<Longrightarrow> a \<squnion>\<^sub>f b = b \<squnion>\<^sub>f a" (*<*) by(blast intro: order_antisym plus_com_lemma) (*>*) lemma is_lubD: "is_lub r x y u \<Longrightarrow> is_ub r x y u \<and> (\<forall>z. is_ub r x y z \<longrightarrow> (u,z) \<in> r)" (*<*) by (simp add: is_lub_def) (*>*) lemma is_ubI: "\<lbrakk> (x,u) \<in> r; (y,u) \<in> r \<rbrakk> \<Longrightarrow> is_ub r x y u" (*<*) by (simp add: is_ub_def) (*>*) lemma is_ubD: "is_ub r x y u \<Longrightarrow> (x,u) \<in> r \<and> (y,u) \<in> r" (*<*) by (simp add: is_ub_def) (*>*) lemma is_lub_bigger1 [iff]: "is_lub (r^* ) x y y = ((x,y)\<in>r^* )" (*<*) by (unfold is_lub_def is_ub_def) blast (*>*) lemma is_lub_bigger2 [iff]: "is_lub (r^* ) x y x = ((y,x)\<in>r^* )" (*<*) by (unfold is_lub_def is_ub_def) blast (*>*) lemma extend_lub: assumes "single_valued r" and "is_lub (r\<^sup>*) x y u" and "(x', x) \<in> r" shows "\<exists>v. is_lub (r\<^sup>*) x' y v" (*<*) proof (cases "(y, x) \<in> r\<^sup>*") case True show ?thesis proof (cases "(y, x') \<in> r\<^sup>*") case True with \<open>(y, x) \<in> r\<^sup>*\<close> show ?thesis by blast next case False with True assms show ?thesis by (unfold is_lub_def is_ub_def) (blast elim: converse_rtranclE dest: single_valuedD) qed next case False from assms have "(x', u) \<in> r\<^sup>*" and "(y, u) \<in> r\<^sup>*" by (auto simp add: is_lub_def is_ub_def) moreover from False assms have "\<And>z. (x', z) \<in> r\<^sup>* \<Longrightarrow> (y, z) \<in> r\<^sup>* \<Longrightarrow> (u, z) \<in> r\<^sup>*" by (unfold is_lub_def is_ub_def) (blast intro: rtrancl_into_rtrancl converse_rtrancl_into_rtrancl elim: converse_rtranclE dest: single_valuedD) ultimately have "is_lub (r\<^sup>*) x' y u" by (unfold is_lub_def is_ub_def) blast then show ?thesis .. qed (*>*) lemma single_valued_has_lubs: assumes "single_valued r" and in_r: "(x, u) \<in> r\<^sup>*" "(y, u) \<in> r\<^sup>*" shows "\<exists>z. is_lub (r\<^sup>*) x y z" (*<*) using in_r proof (induct arbitrary: y rule: converse_rtrancl_induct) case base then show ?case by (induct rule: converse_rtrancl_induct) (blast, blast intro: converse_rtrancl_into_rtrancl) next case step with \<open>single_valued r\<close> show ?case by (blast intro: extend_lub) qed (*>*) lemma some_lub_conv: "\<lbrakk> acyclic r; is_lub (r^* ) x y u \<rbrakk> \<Longrightarrow> some_lub (r^* ) x y = u" (*<*) apply (simp only: some_lub_def is_lub_def) apply (rule someI2) apply (simp only: is_lub_def) apply (blast intro: antisymD dest!: acyclic_impl_antisym_rtrancl) done (*>*) lemma is_lub_some_lub: "\<lbrakk> single_valued r; acyclic r; (x,u)\<in>r^*; (y,u)\<in>r^* \<rbrakk> \<Longrightarrow> is_lub (r^* ) x y (some_lub (r^* ) x y)" (*<*) by (fastforce dest: single_valued_has_lubs simp add: some_lub_conv) (*>*) subsection\<open>An executable lub-finder\<close> definition exec_lub :: "('a * 'a) set \<Rightarrow> ('a \<Rightarrow> 'a) \<Rightarrow> 'a binop" where "exec_lub r f x y = while (\<lambda>z. (x,z) \<notin> r\<^sup>*) f y" lemma exec_lub_refl: "exec_lub r f T T = T" by (simp add: exec_lub_def while_unfold) lemma acyclic_single_valued_finite: "\<lbrakk>acyclic r; single_valued r; (x,y) \<in> r\<^sup>*\<rbrakk> \<Longrightarrow> finite (r \<inter> {a. (x, a) \<in> r\<^sup>*} \<times> {b. (b, y) \<in> r\<^sup>*})" (*<*) apply(erule converse_rtrancl_induct) apply(rule_tac B = "{}" in finite_subset) apply(simp only:acyclic_def) apply(blast intro:rtrancl_into_trancl2 rtrancl_trancl_trancl) apply simp apply(rename_tac x x') apply(subgoal_tac "r \<inter> {a. (x,a) \<in> r\<^sup>*} \<times> {b. (b,y) \<in> r\<^sup>*} = insert (x,x') (r \<inter> {a. (x', a) \<in> r\<^sup>*} \<times> {b. (b, y) \<in> r\<^sup>*})") apply simp apply(blast intro:converse_rtrancl_into_rtrancl elim:converse_rtranclE dest:single_valuedD) done (*>*) lemma exec_lub_conv: "\<lbrakk> acyclic r; \<forall>x y. (x,y) \<in> r \<longrightarrow> f x = y; is_lub (r\<^sup>*) x y u \<rbrakk> \<Longrightarrow> exec_lub r f x y = u" (*<*) apply(unfold exec_lub_def) apply(rule_tac P = "\<lambda>z. (y,z) \<in> r\<^sup>* \<and> (z,u) \<in> r\<^sup>*" and r = "(r \<inter> {(a,b). (y,a) \<in> r\<^sup>* \<and> (b,u) \<in> r\<^sup>*})^-1" in while_rule) apply(blast dest: is_lubD is_ubD) apply(erule conjE) apply(erule_tac z = u in converse_rtranclE) apply(blast dest: is_lubD is_ubD) apply(blast dest:rtrancl_into_rtrancl) apply(rename_tac s) apply(subgoal_tac "is_ub (r\<^sup>*) x y s") prefer 2 apply(simp add:is_ub_def) apply(subgoal_tac "(u, s) \<in> r\<^sup>*") prefer 2 apply(blast dest:is_lubD) apply(erule converse_rtranclE) apply blast apply(simp only:acyclic_def) apply(blast intro:rtrancl_into_trancl2 rtrancl_trancl_trancl) apply(rule finite_acyclic_wf) apply simp apply(erule acyclic_single_valued_finite) apply(blast intro:single_valuedI) apply(simp add:is_lub_def is_ub_def) apply simp apply(erule acyclic_subset) apply blast apply simp apply(erule conjE) apply(erule_tac z = u in converse_rtranclE) apply(blast dest: is_lubD is_ubD) apply(blast dest:rtrancl_into_rtrancl) done (*>*) lemma is_lub_exec_lub: "\<lbrakk> single_valued r; acyclic r; (x,u):r^*; (y,u):r^*; \<forall>x y. (x,y) \<in> r \<longrightarrow> f x = y \<rbrakk> \<Longrightarrow> is_lub (r^* ) x y (exec_lub r f x y)" (*<*) by (fastforce dest: single_valued_has_lubs simp add: exec_lub_conv) (*>*) end
#include <idmlib/ise/iseindex.hpp> #include <boost/format.hpp> #include <boost/program_options.hpp> #include <boost/filesystem.hpp> #include <boost/filesystem/path.hpp> #include <vector> #include <string> #include <iostream> #include <fstream> namespace po = boost::program_options; namespace bfs = boost::filesystem; int main(int argc, char **argv) { std::string input; po::options_description desc("Allowed options"); desc.add_options() ("input,F", po::value(&input), "image directory") ("query,Q", "query image") ; po::positional_options_description p; po::variables_map vm; po::store(po::command_line_parser(argc, argv). options(desc).positional(p).run(), vm); po::notify(vm); if ((vm.count("input") == 0) && (vm.count("query") == 0)) { std::cerr << desc; return 1; } idmlib::ise::IseIndex iseIndex("ise", idmlib::ise::IseIndex::PSM); if (vm.count("input") != 0) { idmlib::ise::IseOptions options; options.range = 1000000; options.repeat = 100; options.w = 12.0F; options.dim = 128; options.ntables = 4; iseIndex.Reset(options); bfs::recursive_directory_iterator dir_iter(input), end_iter; for (; dir_iter!= end_iter; ++dir_iter) { if(bfs::is_regular_file(*dir_iter)) { iseIndex.Insert(bfs::path(*dir_iter).string()); } } iseIndex.Save(); } else if (vm.count("query") != 0) { for (;;) { std::string queryImgPath; std::cin >> queryImgPath; if(!std::cin) break; std::vector<std::string> results; iseIndex.Search(queryImgPath, results); std::cout << "query for: " << queryImgPath << std::endl; for (unsigned i = 0; i < results.size(); ++i) std::cout << results[i] << std::endl; std::cout << "result size: " << results.size() << std::endl; } } return 0; }
open import Nat open import Prelude open import Hazelnut-core module Hazelnut-deterministic where -- theorem 2 -- the same action applied to the same type makes the same resultant -- type. actdet1 : {t t' t'' : τ̂} {α : action} → (t + α +> t') → (t + α +> t'') → (t' == t'') actdet1 TMFirstChild TMFirstChild = refl actdet1 TMParent1 TMParent1 = refl actdet1 TMParent1 (TMZip1 ()) actdet1 TMParent2 TMParent2 = refl actdet1 TMParent2 (TMZip2 ()) actdet1 TMNextSib TMNextSib = refl actdet1 TMNextSib (TMZip1 ()) actdet1 TMPrevSib TMPrevSib = refl actdet1 TMPrevSib (TMZip2 ()) actdet1 TMDel TMDel = refl actdet1 TMConArrow TMConArrow = refl actdet1 TMConNum TMConNum = refl actdet1 (TMZip1 ()) TMParent1 actdet1 (TMZip1 ()) TMNextSib actdet1 (TMZip1 p1) (TMZip1 p2) with actdet1 p1 p2 ... | refl = refl actdet1 (TMZip2 ()) TMParent2 actdet1 (TMZip2 ()) TMPrevSib actdet1 (TMZip2 p1) (TMZip2 p2) with actdet1 p1 p2 ... | refl = refl -- all expressions only move to one other expression movedet : {e e' e'' : ê} {δ : direction} → (e + move δ +>e e') → (e + move δ +>e e'') → e' == e'' movedet EMAscFirstChild EMAscFirstChild = refl movedet EMAscParent1 EMAscParent1 = refl movedet EMAscParent2 EMAscParent2 = refl movedet EMAscNextSib EMAscNextSib = refl movedet EMAscPrevSib EMAscPrevSib = refl movedet EMLamFirstChild EMLamFirstChild = refl movedet EMLamParent EMLamParent = refl movedet EMPlusFirstChild EMPlusFirstChild = refl movedet EMPlusParent1 EMPlusParent1 = refl movedet EMPlusParent2 EMPlusParent2 = refl movedet EMPlusNextSib EMPlusNextSib = refl movedet EMPlusPrevSib EMPlusPrevSib = refl movedet EMApFirstChild EMApFirstChild = refl movedet EMApParent1 EMApParent1 = refl movedet EMApParent2 EMApParent2 = refl movedet EMApNextSib EMApNextSib = refl movedet EMApPrevSib EMApPrevSib = refl movedet EMFHoleFirstChild EMFHoleFirstChild = refl movedet EMFHoleParent EMFHoleParent = refl -- if a move action on a synthetic action makes a new form, it's unique synthmovedet : {Γ : ·ctx} {e e' e'' : ê} {t' t'' : τ̇} {δ : direction} → (Γ ⊢ e => t' ~ move δ ~> e'' => t'') → (e + move δ +>e e') → e'' == e' synthmovedet (SAMove EMAscFirstChild) EMAscFirstChild = refl synthmovedet (SAMove EMAscParent1) EMAscParent1 = refl synthmovedet (SAMove EMAscParent2) EMAscParent2 = refl synthmovedet (SAMove EMAscNextSib) EMAscNextSib = refl synthmovedet (SAMove EMAscPrevSib) EMAscPrevSib = refl synthmovedet (SAMove EMLamFirstChild) EMLamFirstChild = refl synthmovedet (SAMove EMLamParent) EMLamParent = refl synthmovedet (SAMove EMPlusFirstChild) EMPlusFirstChild = refl synthmovedet (SAMove EMPlusParent1) EMPlusParent1 = refl synthmovedet (SAMove EMPlusParent2) EMPlusParent2 = refl synthmovedet (SAMove EMPlusNextSib) EMPlusNextSib = refl synthmovedet (SAMove EMPlusPrevSib) EMPlusPrevSib = refl synthmovedet (SAMove EMApFirstChild) EMApFirstChild = refl synthmovedet (SAMove EMApParent1) EMApParent1 = refl synthmovedet (SAMove EMApParent2) EMApParent2 = refl synthmovedet (SAMove EMApNextSib) EMApNextSib = refl synthmovedet (SAMove EMApPrevSib) EMApPrevSib = refl synthmovedet (SAMove EMFHoleFirstChild) EMFHoleFirstChild = refl synthmovedet (SAMove EMFHoleParent) EMFHoleParent = refl -- all these cases lead to absurdities after a few levels synthmovedet (SAZipAsc1 (AASubsume _ (SAMove ()) _)) EMAscParent1 synthmovedet (SAZipAsc1 (AAMove ())) EMAscParent1 synthmovedet (SAZipAsc1 (AASubsume _ (SAMove ()) _)) EMAscNextSib synthmovedet (SAZipAsc1 (AAMove ())) EMAscNextSib synthmovedet (SAZipAsc2 () _) EMAscParent2 synthmovedet (SAZipAsc2 () _) EMAscPrevSib synthmovedet (SAZipAp1 _ (SAMove ()) (ASubsume _ _)) EMApParent1 synthmovedet (SAZipAp1 _ (SAMove ()) (ALam _ _)) EMApParent1 synthmovedet (SAZipAp1 _ (SAMove ()) _) EMApNextSib synthmovedet (SAZipAp2 _ (SAMove ()) _) EMApParent1 synthmovedet (SAZipAp2 _ (SAMove ()) _) EMApNextSib synthmovedet (SAZipAp3 _ (AASubsume _ (SAMove ()) _)) EMApParent2 synthmovedet (SAZipAp3 _ (AAMove ())) EMApParent2 synthmovedet (SAZipAp3 _ (AASubsume _ (SAMove ()) _)) EMApPrevSib synthmovedet (SAZipAp3 _ (AAMove ())) EMApPrevSib synthmovedet (SAZipAp4 _ (AASubsume _ (SAMove ()) _)) EMApParent2 synthmovedet (SAZipAp4 _ (AAMove ())) EMApParent2 synthmovedet (SAZipAp4 _ (AASubsume _ (SAMove ()) _)) EMApPrevSib synthmovedet (SAZipAp4 _ (AAMove ())) EMApPrevSib synthmovedet (SAZipPlus1 (AASubsume _ (SAMove ()) _)) EMPlusParent1 synthmovedet (SAZipPlus1 (AAMove ())) EMPlusParent1 synthmovedet (SAZipPlus1 (AASubsume _ (SAMove ()) _)) EMPlusNextSib synthmovedet (SAZipPlus1 (AAMove ())) EMPlusNextSib synthmovedet (SAZipPlus2 (AASubsume _ (SAMove ()) _)) EMPlusParent2 synthmovedet (SAZipPlus2 (AAMove ())) EMPlusParent2 synthmovedet (SAZipPlus2 (AASubsume _ (SAMove ()) _)) EMPlusPrevSib synthmovedet (SAZipPlus2 (AAMove ())) EMPlusPrevSib synthmovedet (SAZipHole1 _ (SAMove ()) x) EMFHoleParent synthmovedet (SAZipHole2 _ (SAMove ())) EMFHoleParent -- these are all a bunch of small techincal lemmas for the cases below. i -- don't understand why some of them can't be inlined. lem1 : {Γ : ·ctx} {t1 t2 : τ̇} → Γ ⊢ <||> <= (t1 ==> t2) → (t1 ==> t2) ~ (<||> ==> <||>) lem1 (ASubsume SEHole TCHole1) = TCArr TCHole1 TCHole1 lem3 : ∀{ Γ e t } → Γ ⊢ (e ·: t) <= t → Γ ⊢ e <= t lem3 (ASubsume (SAsc x) x₁) = x lem4 : ∀{ Γ e eh t t2 } → Γ ⊢ e ∘ (eh ◆e) => t → Γ ⊢ e => (t2 ==> t) → Γ ⊢ (eh ◆e) <= t2 lem4 (SAp (SAsc x₁) x) (SAsc x₂) = x lem4 {Γ = G} (SAp (SVar x₁) x) (SVar x₂) with ctxunicity {Γ = G} x₁ x₂ ... | refl = x lem4 (SAp (SAp d1 x₁) x) (SAp d2 x₂) with synthunicity d1 d2 ... | refl = x lem4 (SApHole () x) (SAsc x₁) lem4 {Γ = G} (SApHole (SVar x₁) x) (SVar x₂) with ctxunicity {Γ = G} x₁ x₂ ... | () lem4 (SApHole (SAp d1 x₁) x) (SAp d2 x₂) with synthunicity d1 d2 ... | () lem4 (SApHole (SApHole d1 x₁) x) (SAp d2 x₂) with synthunicity d1 d2 ... | () lem5 : ∀ {Γ e eh} → Γ ⊢ e => <||> → Γ ⊢ e ∘ (eh ◆e) => <||> → Γ ⊢ eh ◆e <= <||> lem5 d1 (SAp d2 x) with synthunicity d1 d2 ... | () lem5 d1 (SApHole d2 x) = x lem6 : ∀ {Γ e1 e2} → Γ ⊢ e1 ·+ e2 => num → Γ ⊢ e1 <= num × Γ ⊢ e2 <= num lem6 (SPlus x x₁) = x , x₁ lem7 : ∀{Γ e t e' t'} → Γ ⊢ <| e |> => <||> → Γ ⊢ ▹ e ◃ => t ~ move parent ~> e' => t' → ⊥ lem7 (SFHole _) (SAMove ()) lem8a : ∀ {Γ e e' t} → Γ ⊢ ▹ e ◃ ~ move nextSib ~> e' ⇐ t → ⊥ lem8a (AASubsume x (SAMove ()) x₂) lem8a (AAMove ()) -- expressions in focus don't move to next sib lem8s : ∀ {Γ e e' t t'} → Γ ⊢ ▹ e ◃ => t ~ move nextSib ~> e' => t' → ⊥ lem8s (SAMove ()) -- expressions in focus don't move to prev sib lem9a : ∀ {Γ e e' t} → Γ ⊢ ▹ e ◃ ~ move prevSib ~> e' ⇐ t → ⊥ lem9a (AASubsume x (SAMove ()) x₂) lem9a (AAMove ()) -- expressions in focus don't move to prev sib lem9s : ∀ {Γ e e' t t'} → Γ ⊢ ▹ e ◃ => t ~ move prevSib ~> e' => t' → ⊥ lem9s (SAMove ()) lem10 : ∀{Γ x t1 t2 e} → Γ ⊢ ·λ x (e ◆e) <= (t1 ==> t2) → (Γ ,, (x , t1)) ⊢ e ◆e <= t2 lem10 (ASubsume () x₂) lem10 (ALam x₁ d1) = d1 -- expressions in focus don't move to parent lem11 : ∀ {Γ e e' t} → Γ ⊢ ▹ e ◃ ~ move parent ~> e' ⇐ t → ⊥ lem11 (AASubsume x (SAMove ()) x₂) lem11 (AAMove ()) -- if a type isn't compatible with hole to hole, it isn't compatible with -- any function type at all. lem12 : {t : τ̇} → (t ~̸ (<||> ==> <||>)) → ((t1 t2 : τ̇) → t ~̸ (t1 ==> t2)) lem12 {num} p t1 t2 () lem12 {<||>} p t1 t2 TCHole2 = p TCHole2 lem12 {(t ==> t')} p t1 t2 x = p (TCArr TCHole1 TCHole1) mutual -- an action on an expression in a synthetic position produces one -- resultant expression and type. actdet2 : {Γ : ·ctx} {e e' e'' : ê} {t t' t'' : τ̇} {α : action} → (Γ ⊢ (e ◆e) => t) → (Γ ⊢ e => t ~ α ~> e' => t') → (Γ ⊢ e => t ~ α ~> e'' => t'') → (e' == e'' × t' == t'') actdet2 wt (SAMove x) (SAMove x₁) = movedet x x₁ , refl -- every other case of move in the left is an absurdity after a -- couple of levels actdet2 wt (SAMove EMAscParent1) (SAZipAsc1 (AASubsume _ (SAMove ()) _)) actdet2 wt (SAMove EMAscParent1) (SAZipAsc1 (AAMove ())) actdet2 wt (SAMove EMAscNextSib) (SAZipAsc1 (AASubsume _ (SAMove ()) _)) actdet2 wt (SAMove EMAscNextSib) (SAZipAsc1 (AAMove ())) actdet2 wt (SAMove EMAscParent2) (SAZipAsc2 () x₂) actdet2 wt (SAMove EMAscPrevSib) (SAZipAsc2 () x₂) actdet2 wt (SAMove EMApParent1) (SAZipAp1 x₁ (SAMove ()) x₂) actdet2 wt (SAMove EMApNextSib) (SAZipAp1 x₁ (SAMove ()) x₂) actdet2 wt (SAMove EMApParent1) (SAZipAp2 x₁ (SAMove ()) x₂) actdet2 wt (SAMove EMApNextSib) (SAZipAp2 x₁ (SAMove ()) x₂) actdet2 wt (SAMove EMApParent2) (SAZipAp3 x₁ (AASubsume x (SAMove ()) x₃)) actdet2 wt (SAMove EMApParent2) (SAZipAp3 x₁ (AAMove ())) actdet2 wt (SAMove EMApPrevSib) (SAZipAp3 x₁ (AASubsume x (SAMove ()) x₃)) actdet2 wt (SAMove EMApPrevSib) (SAZipAp3 x₁ (AAMove ())) actdet2 wt (SAMove EMApParent2) (SAZipAp4 x₁ (AASubsume x (SAMove ()) x₃)) actdet2 wt (SAMove EMApParent2) (SAZipAp4 x₁ (AAMove ())) actdet2 wt (SAMove EMApPrevSib) (SAZipAp4 x₁ (AASubsume x (SAMove ()) x₃)) actdet2 wt (SAMove EMApPrevSib) (SAZipAp4 x₁ (AAMove ())) actdet2 wt (SAMove EMPlusParent1) (SAZipPlus1 (AASubsume x (SAMove ()) x₂)) actdet2 wt (SAMove EMPlusParent1) (SAZipPlus1 (AAMove ())) actdet2 wt (SAMove EMPlusNextSib) (SAZipPlus1 (AASubsume x (SAMove ()) x₂)) actdet2 wt (SAMove EMPlusNextSib) (SAZipPlus1 (AAMove ())) actdet2 wt (SAMove EMPlusParent2) (SAZipPlus2 (AASubsume x (SAMove ()) x₂)) actdet2 wt (SAMove EMPlusParent2) (SAZipPlus2 (AAMove ())) actdet2 wt (SAMove EMPlusPrevSib) (SAZipPlus2 (AASubsume x (SAMove ()) x₂)) actdet2 wt (SAMove EMPlusPrevSib) (SAZipPlus2 (AAMove ())) actdet2 wt (SAMove EMFHoleParent) (SAZipHole1 x₁ (SAMove ()) x₂) actdet2 wt (SAMove EMFHoleParent) (SAZipHole2 x₁ (SAMove ())) actdet2 wt SADel SADel = refl , refl actdet2 wt SAConAsc SAConAsc = refl , refl actdet2 {Γ = G} wt (SAConVar p) (SAConVar p₁) with ctxunicity {Γ = G} p p₁ ... | refl = refl , refl actdet2 wt (SAConLam x₁) (SAConLam x₂) = refl , refl actdet2 wt SAConAp1 SAConAp1 = refl , refl actdet2 wt SAConAp1 (SAConAp3 x) = abort (lem12 x _ _ TCRefl) actdet2 wt SAConAp2 SAConAp2 = refl , refl actdet2 wt SAConAp2 (SAConAp3 x) = abort (x TCHole2) actdet2 wt (SAConAp3 x) SAConAp1 = abort (lem12 x _ _ TCRefl) actdet2 wt (SAConAp3 x) SAConAp2 = abort (x TCHole2) actdet2 wt (SAConAp3 x) (SAConAp3 x₁) = refl , refl actdet2 wt SAConArg SAConArg = refl , refl actdet2 wt SAConNumlit SAConNumlit = refl , refl actdet2 wt (SAConPlus1 x) (SAConPlus1 x₁) = refl , refl actdet2 wt (SAConPlus1 x) (SAConPlus2 x₁) = abort (x₁ x) actdet2 wt (SAConPlus2 x) (SAConPlus1 x₁) = abort (x x₁) actdet2 wt (SAConPlus2 x) (SAConPlus2 x₁) = refl , refl actdet2 wt (SAFinish x) (SAFinish x₁) with synthunicity x x₁ ... | refl = refl , refl actdet2 wt (SAZipAsc1 (AASubsume _ (SAMove ()) _)) (SAMove EMAscParent1) actdet2 wt (SAZipAsc1 (AAMove ())) (SAMove EMAscParent1) actdet2 wt (SAZipAsc1 x) (SAMove EMAscNextSib) = abort (lem8a x) actdet2 {t = t} wt (SAZipAsc1 x) (SAZipAsc1 x₁) = ap1 (λ q → q ·:₁ t) (actdet3 (lem3 (ASubsume wt TCRefl)) x x₁) , refl actdet2 wt (SAZipAsc2 () x₁) (SAMove EMAscParent2) actdet2 wt (SAZipAsc2 () x₁) (SAMove EMAscPrevSib) actdet2 wt (SAZipAsc2 x x₁) (SAZipAsc2 x₂ x₃) with actdet1 x x₂ ... | refl = refl , refl actdet2 wt (SAZipAp1 x (SAMove ()) x₁) (SAMove EMApParent1) actdet2 wt (SAZipAp1 x (SAMove ()) x₁) (SAMove EMApNextSib) actdet2 wt (SAZipAp1 x d1 x₁) (SAZipAp1 x₂ d2 x₃) with synthunicity x₂ x ... | refl with actdet2 x d1 d2 -- todo: double-barrelded with here .. ... | p1 , refl = (ap1 (λ q → q ∘₁ _) p1) , refl actdet2 wt (SAZipAp1 x d1 x₁) (SAZipAp2 x₂ d2 x₃) with synthunicity x x₂ ... | refl with actdet2 x d1 d2 -- todo: .. and here actdet2 wt (SAZipAp1 _ _ _ ) (SAZipAp2 _ _ _) | refl | _ , () actdet2 wt (SAZipAp2 x (SAMove ()) x₁) (SAMove EMApParent1) actdet2 wt (SAZipAp2 x (SAMove ()) x₁) (SAMove EMApNextSib) actdet2 wt (SAZipAp2 x d1 x₁) (SAZipAp1 x₂ d2 x₃) with synthunicity x x₂ ... | refl with actdet2 x d1 d2 actdet2 wt (SAZipAp2 x d1 x₁) (SAZipAp1 x₂ d2 x₃) | refl | p1 , () actdet2 wt (SAZipAp2 x d1 _) (SAZipAp2 x₂ d2 _) with synthunicity x x₂ ... | refl = (ap1 (λ q → q ∘₁ _) (π1 (actdet2 x₂ d1 d2))) , refl actdet2 wt (SAZipAp3 x (AASubsume x₁ (SAMove ()) x₃)) (SAMove EMApParent2) actdet2 wt (SAZipAp3 x (AAMove ())) (SAMove EMApParent2) actdet2 wt (SAZipAp3 x x₁) (SAMove EMApPrevSib) = abort (lem9a x₁) actdet2 wt (SAZipAp3 {eh = eh} x x₁) (SAZipAp3 x₂ x₃) with synthunicity x x₂ ... | refl = ap1 (_∘₂_ _) (actdet3 (lem4 {eh = eh} wt x) x₁ x₃) , refl actdet2 wt (SAZipAp3 x x₁) (SAZipAp4 x₂ x₃) with synthunicity x x₂ ... | () actdet2 wt (SAZipAp4 x (AASubsume x₁ (SAMove ()) x₃)) (SAMove EMApParent2) actdet2 wt (SAZipAp4 x (AAMove ())) (SAMove EMApParent2) actdet2 wt (SAZipAp4 x (AASubsume x₁ x₂ x₃)) (SAMove EMApPrevSib) = abort (lem9s x₂) actdet2 wt (SAZipAp4 x (AAMove ())) (SAMove EMApPrevSib) actdet2 wt (SAZipAp4 x x₁) (SAZipAp3 x₂ x₃) with synthunicity x x₂ ... | () actdet2 wt (SAZipAp4 {eh = eh} x x₁ ) (SAZipAp4 x₂ x₃) with actdet3 (lem5 {eh = eh} x₂ wt) x₁ x₃ ... | refl = refl , refl actdet2 wt (SAZipPlus1 (AASubsume x (SAMove ()) x₂)) (SAMove EMPlusParent1) actdet2 wt (SAZipPlus1 (AAMove ())) (SAMove EMPlusParent1) actdet2 wt (SAZipPlus1 (AASubsume x x₁ x₂)) (SAMove EMPlusNextSib) = abort (lem8s x₁) actdet2 wt (SAZipPlus1 (AAMove ())) (SAMove EMPlusNextSib) actdet2 wt (SAZipPlus1 x) (SAZipPlus1 x₁) with actdet3 (π1 (lem6 wt)) x x₁ -- todo: not sure why this needs to be a lemma ... | refl = refl , refl actdet2 wt (SAZipPlus2 (AASubsume x (SAMove ()) x₂)) (SAMove EMPlusParent2) actdet2 wt (SAZipPlus2 (AASubsume x x₁ x₂)) (SAMove EMPlusPrevSib) = abort (lem9s x₁) actdet2 wt (SAZipPlus2 (AAMove ())) (SAMove EMPlusParent2) actdet2 wt (SAZipPlus2 (AAMove ())) (SAMove EMPlusPrevSib) actdet2 wt (SAZipPlus2 x) (SAZipPlus2 x₁) with actdet3 (π2 (lem6 wt)) x x₁ -- .. or this one ... | refl = refl , refl actdet2 wt (SAZipHole1 x d1 x₁) (SAMove EMFHoleParent) = abort (lem7 wt d1) actdet2 wt (SAZipHole1 x d1 x₁) (SAZipHole1 x₂ d2 x₃) with synthunicity x x₂ ... | refl with actdet2 x d1 d2 ... | refl , refl = refl , refl actdet2 wt (SAZipHole1 x d1 x₁) (SAZipHole2 x₂ d2) with synthunicity x x₂ ... | refl with actdet2 x d1 d2 ... | p , _ = abort (x₁ p) actdet2 wt (SAZipHole2 x d1) (SAMove EMFHoleParent) = abort (lem7 wt d1) actdet2 wt (SAZipHole2 x d1) (SAZipHole1 x₁ d2 x₂) with synthunicity x x₁ ... | refl with actdet2 x d1 d2 ... | p , q = abort (x₂ (! p)) actdet2 wt (SAZipHole2 x d1) (SAZipHole2 x₁ d2) with synthunicity x x₁ ... | refl with actdet2 x d1 d2 ... | refl , refl = refl , refl -- an action on an expression in an analytic position produces one -- resultant expression and type. actdet3 : {Γ : ·ctx} {e e' e'' : ê} {t : τ̇} {α : action} → (Γ ⊢ (e ◆e) <= t) → (Γ ⊢ e ~ α ~> e' ⇐ t) → (Γ ⊢ e ~ α ~> e'' ⇐ t) → (e' == e'') actdet3 D1 (AASubsume x x₁ x₂) (AASubsume x₃ x₄ x₅) with synthunicity x x₃ ... | refl = π1 (actdet2 x x₁ x₄) actdet3 D1 (AASubsume _ y _) (AAMove w) = synthmovedet y w actdet3 D1 (AASubsume _ SADel _) AADel = refl actdet3 D1 (AASubsume {p = p} x SAConAsc x₂) AAConAsc = abort (π1 p refl) actdet3 {Γ = G} (ASubsume x x₁) (AASubsume x₂ (SAConVar p) x₄) (AAConVar x₅ p₁) with ctxunicity {Γ = G} p p₁ ... | refl = abort (x₅ x₄) actdet3 D1 (AASubsume {p = p} x₁ (SAConLam x₂) x₃) (AAConLam1 x₄) = abort (π2 p _ refl) actdet3 D1 (AASubsume x₁ (SAConLam x₃) x₂) (AAConLam2 x₄ x₅) = abort (x₅ x₂) actdet3 D1 (AASubsume x SAConNumlit x₂) (AAConNumlit x₃) = abort (x₃ x₂) actdet3 D1 (AASubsume x (SAFinish x₁) x₂) (AAFinish x₃) = refl actdet3 D1 (AASubsume x₁ (SAMove EMLamParent) x₂) (AAZipLam x₄ (AASubsume x₃ (SAMove ()) x₆)) actdet3 D1 (AASubsume x₁ (SAMove EMLamParent) x₂) (AAZipLam x₄ (AAMove ())) actdet3 D1 (AAMove x) (AASubsume x₁ x₂ x₃) = ! (synthmovedet x₂ x) actdet3 D1 (AAMove x) (AAMove x₁) = movedet x x₁ actdet3 D1 (AAMove EMLamParent) (AAZipLam x₃ (AASubsume x₁ (SAMove ()) x₄)) actdet3 D1 (AAMove EMLamParent) (AAZipLam x₃ (AAMove ())) actdet3 D1 AADel (AASubsume _ SADel _) = refl actdet3 D1 AADel AADel = refl actdet3 D1 AAConAsc (AASubsume {p = p} x SAConAsc x₂) = abort (π1 p refl) actdet3 D1 AAConAsc AAConAsc = refl actdet3 {Γ = G} D1 (AAConVar x₁ p) (AASubsume x₂ (SAConVar p₁) x₄) with ctxunicity {Γ = G} p p₁ ... | refl = abort (x₁ x₄) actdet3 D1 (AAConVar x₁ p) (AAConVar x₂ p₁) = refl actdet3 D1 (AAConLam1 x₃) (AASubsume {p = p} SEHole (SAConLam x₅) x₆) = abort (π2 p _ refl) actdet3 D1 (AAConLam1 x₁) (AAConLam1 x₂) = refl actdet3 D1 (AAConLam1 x₃) (AAConLam2 x₄ x₅) = abort (x₅ (lem1 D1)) actdet3 D1 (AAConLam2 x₁ x₂) (AASubsume x₃ (SAConLam x₄) x₅) = abort (x₂ x₅) actdet3 D1 (AAConLam2 x₁ x₂) (AAConLam1 x₃) = abort (x₂ (lem1 D1)) actdet3 D1 (AAConLam2 x₁ x₂) (AAConLam2 x₃ x₄) = refl actdet3 D1 (AAConNumlit x) (AASubsume x₁ SAConNumlit x₃) = abort (x x₃) actdet3 D1 (AAConNumlit x) (AAConNumlit x₁) = refl actdet3 D1 (AAFinish x) (AASubsume x₁ (SAFinish x₂) x₃) = refl actdet3 D1 (AAFinish x) (AAFinish x₁) = refl actdet3 D1 (AAZipLam x₃ D2) (AASubsume x₁ (SAMove EMLamParent) x₄) = abort (lem11 D2) actdet3 D1 (AAZipLam x₃ (AASubsume x₁ (SAMove ()) x₄)) (AAMove EMLamParent) actdet3 D1 (AAZipLam x₃ (AAMove ())) (AAMove EMLamParent) actdet3 D1 (AAZipLam {e = e} x₃ D2) (AAZipLam x₁ D3) with actdet3 (lem10 {e = e} D1) D2 D3 ... | refl = refl
### Functions to Compute Pose Graph Error ### ### Ted Steiner ### ### September 2014 ### # Compute pose position RMS error function posegraphError( posesA::Array{Pose2D,1}, posesB::Array{Pose2D,1} ) alignPoses!(posesA,posesB) err = poseError(posesA,posesB) rmse = sqrt( sum(err.*err) / length(posesA) ) return rmse end function poseError( posesA::Array{Pose2D,1}, posesB::Array{Pose2D,1} ) err = zeros(length(posesA),3) for k = 1:length(posesA) err[k,:] = poseError(posesA[k],posesB[k]) end return err end function poseError( poseA::Pose2D, poseB::Pose2D ) err = zeros(3) err[1] = poseA.x - poseB.x err[2] = poseA.y - poseB.y err[3] = 0.0 #poseA.theta - poseB.theta return err end function posegraphError( truth_filename::String, result_filename::String ) posesTruth = readiSAMOutput(truth_filename) posesResult = readiSAMOutput(result_filename) return posegraphError(posesTruth,posesResult) end function poseErrorCovTrace( cov::Array{Float64,2} ) err = zeros(size(cov,1)) for k = 1:length(err) err[k] = sqrt(cov[k,1]) + sqrt(cov[k,2]) + sqrt(cov[k,3]) end return err end # Pose Sigma (Pose position error standard deviation) function poseSigma( cov::Array{Float64,2} ) return sqrt( cov[1,1] + cov[1,2] ) end function poseSigmas( covs::Array{Float64,2} ) err = zeros(size(covs,1)) for k = 1:length(err) err[k] = poseSigma( covs[k,:] ) end return err end function epsilonTrajectory( covs::Array{Float64,2} ) return mean(poseSigmas(covs)) end # Trajectory Error Epsilon function errorRatio( mean_sigmas::Array, rounds::Int=Inf ) if rounds > size(mean_sigmas,1) rounds = size(mean_sigmas,1) end return mean(errorRatios(mean_sigmas,rounds),1) end function errorRatios( mean_sigmas::Array, rounds::Int=Inf ) if rounds > size(mean_sigmas,1) rounds = size(mean_sigmas,1) end anchors = size(mean_sigmas,2)-1 e_ratios = zeros(rounds,anchors) for r = 1:rounds e_full = mean_sigmas[r,end] for a = 1:anchors e_ratios[r,a] = (mean_sigmas[r,a] - e_full) / e_full end end return e_ratios end ###################### ### Pose Alignment ### ###################### function alignPoses!(posesA::Array{Pose2D,1}, posesB::Array{Pose2D,1}) R, t = kabsch(posesA,posesB) transformPoses!(posesB,R',-t) return nothing end # Kabsch Algorithm: Computes rotation and translation between two sets of points function kabsch( posesA::Array{Pose2D,1}, posesB::Array{Pose2D,1} ) A = poses2matrix(posesA) B = poses2matrix(posesB) return kabsch(A,B) end function kabsch( A::Array{Float64,2}, B::Array{Float64,2} ) assert(size(A,1) == size(B,1)) centroid_A = mean(A,1) centroid_B = mean(B,1) H = (A - repmat(centroid_A, size(A,1), 1))' * (B - repmat(centroid_B, size(B,1), 1)) U,S,V = svd(H) R = V*U'; if det(R) < 0 println("Reflection detected.") V[:,3] *= -1 R = V*U' end t = -R*centroid_A' + centroid_B' return R, t end function transformPoses!( poses::Array{Pose2D,1}, R, t ) R_theta = atan2(R[2,1],R[1,1]) for pose in poses pose.x += t[1] pose.y += t[2] pose.theta += R_theta end return nothing end function poses2matrix( poses::Array{Pose2D,1} ) A = zeros(length(poses),3) for k = 1:length(poses) A[k,1] = poses[k].x A[k,2] = poses[k].y end return A end
[GOAL] α : Type u_1 inst✝¹ : DecidableEq α inst✝ : Fintype α n : ℕ ⊢ card ↑(derangements (Fin (n + 2))) = (n + 1) * card ↑(derangements (Fin n)) + (n + 1) * card ↑(derangements (Fin (n + 1))) [PROOFSTEP] have h1 : ∀ a : Fin (n + 1), card ({ a }ᶜ : Set (Fin (n + 1))) = card (Fin n) := by intro a simp only [Fintype.card_fin, Finset.card_fin, Fintype.card_ofFinset, Finset.filter_ne' _ a, Set.mem_compl_singleton_iff, Finset.card_erase_of_mem (Finset.mem_univ a), add_tsub_cancel_right] [GOAL] α : Type u_1 inst✝¹ : DecidableEq α inst✝ : Fintype α n : ℕ ⊢ ∀ (a : Fin (n + 1)), card ↑{a}ᶜ = card (Fin n) [PROOFSTEP] intro a [GOAL] α : Type u_1 inst✝¹ : DecidableEq α inst✝ : Fintype α n : ℕ a : Fin (n + 1) ⊢ card ↑{a}ᶜ = card (Fin n) [PROOFSTEP] simp only [Fintype.card_fin, Finset.card_fin, Fintype.card_ofFinset, Finset.filter_ne' _ a, Set.mem_compl_singleton_iff, Finset.card_erase_of_mem (Finset.mem_univ a), add_tsub_cancel_right] [GOAL] α : Type u_1 inst✝¹ : DecidableEq α inst✝ : Fintype α n : ℕ h1 : ∀ (a : Fin (n + 1)), card ↑{a}ᶜ = card (Fin n) ⊢ card ↑(derangements (Fin (n + 2))) = (n + 1) * card ↑(derangements (Fin n)) + (n + 1) * card ↑(derangements (Fin (n + 1))) [PROOFSTEP] have h2 : card (Fin (n + 2)) = card (Option (Fin (n + 1))) := by simp only [card_fin, card_option] -- rewrite the LHS and substitute in our fintype-level equivalence [GOAL] α : Type u_1 inst✝¹ : DecidableEq α inst✝ : Fintype α n : ℕ h1 : ∀ (a : Fin (n + 1)), card ↑{a}ᶜ = card (Fin n) ⊢ card (Fin (n + 2)) = card (Option (Fin (n + 1))) [PROOFSTEP] simp only [card_fin, card_option] -- rewrite the LHS and substitute in our fintype-level equivalence [GOAL] α : Type u_1 inst✝¹ : DecidableEq α inst✝ : Fintype α n : ℕ h1 : ∀ (a : Fin (n + 1)), card ↑{a}ᶜ = card (Fin n) h2 : card (Fin (n + 2)) = card (Option (Fin (n + 1))) ⊢ card ↑(derangements (Fin (n + 2))) = (n + 1) * card ↑(derangements (Fin n)) + (n + 1) * card ↑(derangements (Fin (n + 1))) [PROOFSTEP] simp only [card_derangements_invariant h2, card_congr (@derangementsRecursionEquiv (Fin (n + 1)) _), -- push the cardinality through the Σ and ⊕ so that we can use `card_n`card_sigma, card_sum, card_derangements_invariant (h1 _), Finset.sum_const, nsmul_eq_mul, Finset.card_fin, mul_add, Nat.cast_id] [GOAL] α : Type u_1 inst✝¹ : DecidableEq α inst✝ : Fintype α n : ℕ ⊢ ↑(numDerangements (n + 1)) = (↑n + 1) * ↑(numDerangements n) - (-1) ^ n [PROOFSTEP] induction' n with n hn [GOAL] case zero α : Type u_1 inst✝¹ : DecidableEq α inst✝ : Fintype α ⊢ ↑(numDerangements (Nat.zero + 1)) = (↑Nat.zero + 1) * ↑(numDerangements Nat.zero) - (-1) ^ Nat.zero [PROOFSTEP] rfl [GOAL] case succ α : Type u_1 inst✝¹ : DecidableEq α inst✝ : Fintype α n : ℕ hn : ↑(numDerangements (n + 1)) = (↑n + 1) * ↑(numDerangements n) - (-1) ^ n ⊢ ↑(numDerangements (Nat.succ n + 1)) = (↑(Nat.succ n) + 1) * ↑(numDerangements (Nat.succ n)) - (-1) ^ Nat.succ n [PROOFSTEP] simp only [numDerangements_add_two, hn, pow_succ, Int.ofNat_mul, Int.ofNat_add, Int.ofNat_succ] [GOAL] case succ α : Type u_1 inst✝¹ : DecidableEq α inst✝ : Fintype α n : ℕ hn : ↑(numDerangements (n + 1)) = (↑n + 1) * ↑(numDerangements n) - (-1) ^ n ⊢ (↑n + 1) * (↑(numDerangements n) + ((↑n + 1) * ↑(numDerangements n) - (-1) ^ n)) = (↑n + 1 + 1) * ((↑n + 1) * ↑(numDerangements n) - (-1) ^ n) - -1 * (-1) ^ n [PROOFSTEP] ring [GOAL] α : Type u_1 inst✝¹ : DecidableEq α inst✝ : Fintype α n : ℕ ⊢ card ↑(derangements (Fin n)) = numDerangements n [PROOFSTEP] induction' n using Nat.strong_induction_on with n hyp [GOAL] case h α : Type u_1 inst✝¹ : DecidableEq α inst✝ : Fintype α n : ℕ hyp : ∀ (m : ℕ), m < n → card ↑(derangements (Fin m)) = numDerangements m ⊢ card ↑(derangements (Fin n)) = numDerangements n [PROOFSTEP] rcases n with _ | _ | n [GOAL] case h.zero α : Type u_1 inst✝¹ : DecidableEq α inst✝ : Fintype α hyp : ∀ (m : ℕ), m < Nat.zero → card ↑(derangements (Fin m)) = numDerangements m ⊢ card ↑(derangements (Fin Nat.zero)) = numDerangements Nat.zero [PROOFSTEP] convert_to card ↑{f : Perm (Fin 0) | ∀ (x : Fin 0), f x ≠ x} = _ using 2 [GOAL] case h.zero.convert_2 α : Type u_1 inst✝¹ : DecidableEq α inst✝ : Fintype α hyp : ∀ (m : ℕ), m < Nat.zero → card ↑(derangements (Fin m)) = numDerangements m ⊢ card ↑{f | ∀ (x : Fin 0), ↑f x ≠ x} = numDerangements Nat.zero [PROOFSTEP] rfl [GOAL] case h.succ.zero α : Type u_1 inst✝¹ : DecidableEq α inst✝ : Fintype α hyp : ∀ (m : ℕ), m < Nat.succ Nat.zero → card ↑(derangements (Fin m)) = numDerangements m ⊢ card ↑(derangements (Fin (Nat.succ Nat.zero))) = numDerangements (Nat.succ Nat.zero) [PROOFSTEP] convert_to card ↑{f : Perm (Fin 1) | ∀ (x : Fin 1), f x ≠ x} = _ using 2 [GOAL] case h.succ.zero.convert_2 α : Type u_1 inst✝¹ : DecidableEq α inst✝ : Fintype α hyp : ∀ (m : ℕ), m < Nat.succ Nat.zero → card ↑(derangements (Fin m)) = numDerangements m ⊢ card ↑{f | ∀ (x : Fin 1), ↑f x ≠ x} = numDerangements (Nat.succ Nat.zero) [PROOFSTEP] rfl -- knock out cases 0 and 1 -- now we have n ≥ 2. rewrite everything in terms of card_derangements, so that we can use -- `card_derangements_fin_add_two` [GOAL] case h.succ.succ α : Type u_1 inst✝¹ : DecidableEq α inst✝ : Fintype α n : ℕ hyp : ∀ (m : ℕ), m < Nat.succ (Nat.succ n) → card ↑(derangements (Fin m)) = numDerangements m ⊢ card ↑(derangements (Fin (Nat.succ (Nat.succ n)))) = numDerangements (Nat.succ (Nat.succ n)) [PROOFSTEP] rw [numDerangements_add_two, card_derangements_fin_add_two, mul_add, hyp _ (Nat.lt_add_of_pos_right zero_lt_two), hyp _ (lt_add_one _)] [GOAL] α✝ : Type u_1 inst✝³ : DecidableEq α✝ inst✝² : Fintype α✝ α : Type u_2 inst✝¹ : Fintype α inst✝ : DecidableEq α ⊢ card ↑(derangements α) = numDerangements (card α) [PROOFSTEP] rw [← card_derangements_invariant (card_fin _)] [GOAL] α✝ : Type u_1 inst✝³ : DecidableEq α✝ inst✝² : Fintype α✝ α : Type u_2 inst✝¹ : Fintype α inst✝ : DecidableEq α ⊢ card ↑(derangements (Fin (card α))) = numDerangements (card α) [PROOFSTEP] exact card_derangements_fin_eq_numDerangements [GOAL] α : Type u_1 inst✝¹ : DecidableEq α inst✝ : Fintype α n : ℕ ⊢ ↑(numDerangements n) = ∑ k in Finset.range (n + 1), (-1) ^ k * ↑(Nat.ascFactorial k (n - k)) [PROOFSTEP] induction' n with n hn [GOAL] case zero α : Type u_1 inst✝¹ : DecidableEq α inst✝ : Fintype α ⊢ ↑(numDerangements Nat.zero) = ∑ k in Finset.range (Nat.zero + 1), (-1) ^ k * ↑(Nat.ascFactorial k (Nat.zero - k)) [PROOFSTEP] rfl [GOAL] case succ α : Type u_1 inst✝¹ : DecidableEq α inst✝ : Fintype α n : ℕ hn : ↑(numDerangements n) = ∑ k in Finset.range (n + 1), (-1) ^ k * ↑(Nat.ascFactorial k (n - k)) ⊢ ↑(numDerangements (Nat.succ n)) = ∑ k in Finset.range (Nat.succ n + 1), (-1) ^ k * ↑(Nat.ascFactorial k (Nat.succ n - k)) [PROOFSTEP] rw [Finset.sum_range_succ, numDerangements_succ, hn, Finset.mul_sum, tsub_self, Nat.ascFactorial_zero, Int.ofNat_one, mul_one, pow_succ, neg_one_mul, sub_eq_add_neg, add_left_inj, Finset.sum_congr rfl] -- show that (n + 1) * (-1)^x * asc_fac x (n - x) = (-1)^x * asc_fac x (n.succ - x) [GOAL] case succ α : Type u_1 inst✝¹ : DecidableEq α inst✝ : Fintype α n : ℕ hn : ↑(numDerangements n) = ∑ k in Finset.range (n + 1), (-1) ^ k * ↑(Nat.ascFactorial k (n - k)) ⊢ ∀ (x : ℕ), x ∈ Finset.range (n + 1) → (↑n + 1) * ((-1) ^ x * ↑(Nat.ascFactorial x (n - x))) = (-1) ^ x * ↑(Nat.ascFactorial x (Nat.succ n - x)) [PROOFSTEP] intro x hx [GOAL] case succ α : Type u_1 inst✝¹ : DecidableEq α inst✝ : Fintype α n : ℕ hn : ↑(numDerangements n) = ∑ k in Finset.range (n + 1), (-1) ^ k * ↑(Nat.ascFactorial k (n - k)) x : ℕ hx : x ∈ Finset.range (n + 1) ⊢ (↑n + 1) * ((-1) ^ x * ↑(Nat.ascFactorial x (n - x))) = (-1) ^ x * ↑(Nat.ascFactorial x (Nat.succ n - x)) [PROOFSTEP] have h_le : x ≤ n := Finset.mem_range_succ_iff.mp hx [GOAL] case succ α : Type u_1 inst✝¹ : DecidableEq α inst✝ : Fintype α n : ℕ hn : ↑(numDerangements n) = ∑ k in Finset.range (n + 1), (-1) ^ k * ↑(Nat.ascFactorial k (n - k)) x : ℕ hx : x ∈ Finset.range (n + 1) h_le : x ≤ n ⊢ (↑n + 1) * ((-1) ^ x * ↑(Nat.ascFactorial x (n - x))) = (-1) ^ x * ↑(Nat.ascFactorial x (Nat.succ n - x)) [PROOFSTEP] rw [Nat.succ_sub h_le, Nat.ascFactorial_succ, add_tsub_cancel_of_le h_le, Int.ofNat_mul, Int.ofNat_succ, mul_left_comm]
\documentclass{article} \usepackage{amsmath} \usepackage{numprint} \author{Daniel Fernandes Martins (danielfmt)} \title{Question \#1 Solution} \begin{document} \maketitle \textbf{Disclaimer.} This is the reasoning I used to solve the problem; it may be wrong though. This is intended just as food for thought. \section{Simplifying The Original VC Bound} The original VC bound looks like this: \begin{equation*} \epsilon \leq \sqrt{\frac{8}{N}\ln{\frac{4m_{\mathcal{H}}(2N)}{\delta}}} \end{equation*} Putting it in terms of $N$: \begin{equation*} N \geq \frac{8}{\epsilon^2}\ln{\frac{4m_{\mathcal{H}}(2N)}{\delta}} \end{equation*} Now, defining the growth function $m_{\mathcal{H}}(N)$ in terms of the upper bound in $d_{vc}$: \begin{equation*} N \geq \frac{8}{\epsilon^2}\ln{\frac{4(2N)^{d_{vc}}}{\delta}} \end{equation*} \section{Solving Through Successive Approximations} Starting from $N=10^5$, let's try to find the $N$ that safisfies that inequality. If we plug in this first $N$ along with $d_{vc}=10$, $\epsilon=0.05$ and $\delta=0.05$ in the formula, we have: \begin{equation*} N \geq \frac{8}{0.05^2}\ln{\frac{4(2\cdot10^5)^{10}}{0.05}} \approx 404,617 \end{equation*} We've missed by a long shot! If we feed $N=\numprint{404617}$ into the same equation: \begin{equation*} N \geq \frac{8}{0.05^2}\ln{\frac{4(2\cdot404617)^{10}}{0.05}} \approx 449,345 \end{equation*} Keep doing this long enough so that $N$ converges to approximately \numprint{452956}. \end{document}
library(shiny) faas <- tools::file_path_as_absolute(system.file("ShinyApps/faas", package="Rfiglet")) runApp(faas)
/- Copyright (c) 2019 Floris van Doorn. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Floris van Doorn -/ import tactic.rcases /-! # lift tactic This file defines the `lift` tactic, allowing the user to lift elements from one type to another under a specified condition. ## Tags lift, tactic -/ /-- A class specifying that you can lift elements from `α` to `β` assuming `cond` is true. Used by the tactic `lift`. -/ class can_lift (α β : Sort*) (coe : out_param $ β → α) (cond : out_param $ α → Prop) := (prf : ∀(x : α), cond x → ∃(y : β), coe y = x) instance : can_lift ℤ ℕ coe ((≤) 0) := ⟨λ n hn, ⟨n.nat_abs, int.nat_abs_of_nonneg hn⟩⟩ /-- Enable automatic handling of pi types in `can_lift`. -/ instance pi.can_lift (ι : Sort*) (α β : ι → Sort*) (coe : Π i, β i → α i) (P : Π i, α i → Prop) [Π i : ι, can_lift (α i) (β i) (coe i) (P i)] : can_lift (Π i : ι, α i) (Π i : ι, β i) (λ f i, coe i (f i)) (λ f, ∀ i, P i (f i)) := { prf := λ f hf, ⟨λ i, classical.some (can_lift.prf (f i) (hf i)), funext $ λ i, classical.some_spec (can_lift.prf (f i) (hf i))⟩ } lemma subtype.exists_pi_extension {ι : Sort*} {α : ι → Sort*} [ne : Π i, nonempty (α i)] {p : ι → Prop} (f : Π i : subtype p, α i) : ∃ g : Π i : ι, α i, (λ i : subtype p, g i) = f := begin tactic.classical, refine ⟨λ i, if hi : p i then f ⟨i, hi⟩ else classical.choice (ne i), funext _⟩, rintro ⟨i, hi⟩, exact dif_pos hi end instance pi_subtype.can_lift (ι : Sort*) (α : ι → Sort*) [ne : Π i, nonempty (α i)] (p : ι → Prop) : can_lift (Π i : subtype p, α i) (Π i, α i) (λ f i, f i) (λ _, true) := { prf := λ f _, subtype.exists_pi_extension f } instance pi_subtype.can_lift' (ι : Sort*) (α : Sort*) [ne : nonempty α] (p : ι → Prop) : can_lift (subtype p → α) (ι → α) (λ f i, f i) (λ _, true) := pi_subtype.can_lift ι (λ _, α) p instance subtype.can_lift {α : Sort*} (p : α → Prop) : can_lift α {x // p x} coe p := { prf := λ a ha, ⟨⟨a, ha⟩, rfl⟩ } open tactic namespace tactic /-- Construct the proof of `cond x` in the lift tactic. * `e` is the expression being lifted and `h` is the specified proof of `can_lift.cond e`. * `old_tp` and `new_tp` are the arguments to `can_lift` and `inst` is the `can_lift`-instance. * `s` and `to_unfold` contain the information of the simp set used to simplify. If the proof was specified, we check whether it has the correct type. If it doesn't have the correct type, we display an error message. If the proof was not specified, we create assert it as a local constant. (The name of this local constant doesn't matter, since `lift` will remove it from the context.) -/ meta def get_lift_prf (h : option pexpr) (e P : expr) : tactic (expr × bool) := do let expected_prf_ty := P.app e, expected_prf_ty ← simp_lemmas.mk.dsimplify [] expected_prf_ty {fail_if_unchanged := ff}, match h with | some h := do e ← decorate_error "lift tactic failed." (i_to_expr ``((%%h : %%expected_prf_ty))), return (e, tt) | none := do prf_nm ← get_unused_name, prf ← assert prf_nm expected_prf_ty, swap, return (prf, ff) end /-- Lift the expression `p` to the type `t`, with proof obligation given by `h`. The list `n` is used for the two newly generated names, and to specify whether `h` should remain in the local context. See the doc string of `tactic.interactive.lift` for more information. -/ meta def lift (p : pexpr) (t : pexpr) (h : option pexpr) (n : list name) : tactic unit := do propositional_goal <|> fail "lift tactic failed. Tactic is only applicable when the target is a proposition.", e ← i_to_expr p, old_tp ← infer_type e, new_tp ← i_to_expr ``(%%t : Sort*), coe ← i_to_expr (``(%%new_tp → %%old_tp)) >>= mk_meta_var, P ← i_to_expr (``(%%old_tp → Prop)) >>= mk_meta_var, inst_type ← mk_app ``can_lift [old_tp, new_tp, coe, P], inst ← mk_instance inst_type <|> pformat!"Failed to find a lift from {old_tp} to {new_tp}. Provide an instance of\n {inst_type}" >>= fail, inst ← instantiate_mvars inst, coe ← instantiate_mvars coe, P ← instantiate_mvars P, (prf_cond, b) ← get_lift_prf h e P, let prf_nm := if prf_cond.is_local_constant then some prf_cond.local_pp_name else none, /- We use mk_mapp to apply `can_lift.prf` to all but one argument, and then just use expr.app for the last argument. For some reason we get an error when applying mk_mapp it to all arguments. -/ prf_ex0 ← mk_mapp `can_lift.prf [old_tp, new_tp, coe, P, inst, e], let prf_ex := prf_ex0 prf_cond, /- Find the name of the new variable -/ new_nm ← if n ≠ [] then return n.head else if e.is_local_constant then return e.local_pp_name else get_unused_name, /- Find the name of the proof of the equation -/ eq_nm ← if hn : 1 < n.length then return (n.nth_le 1 hn) else if e.is_local_constant then return `rfl else get_unused_name `h, /- We add the proof of the existential statement to the context -/ temp_nm ← get_unused_name, temp_e ← note temp_nm none prf_ex, dsimp_hyp temp_e none [] { fail_if_unchanged := ff }, /- We case on the existential. We use `rcases` because `eq_nm` could be `rfl`. -/ rcases none (pexpr.of_expr temp_e) $ rcases_patt.tuple ([new_nm, eq_nm].map rcases_patt.one), /- If the lifted variable is not a local constant, try to rewrite it away using the new equality. -/ when (¬ e.is_local_constant) (get_local eq_nm >>= λ e, interactive.rw ⟨[⟨⟨0, 0⟩, tt, (pexpr.of_expr e)⟩], none⟩ interactive.loc.wildcard), /- If the proof `prf_cond` is a local constant, remove it from the context, unless `n` specifies to keep it. -/ if h_prf_nm : prf_nm.is_some ∧ n.nth 2 ≠ prf_nm then get_local (option.get h_prf_nm.1) >>= clear else skip, if b then skip else swap setup_tactic_parser /-- Parses an optional token "using" followed by a trailing `pexpr`. -/ meta def using_texpr := (tk "using" *> texpr)? /-- Parses a token "to" followed by a trailing `pexpr`. -/ meta def to_texpr := (tk "to" *> texpr) namespace interactive /-- Lift an expression to another type. * Usage: `'lift' expr 'to' expr ('using' expr)? ('with' id (id id?)?)?`. * If `n : ℤ` and `hn : n ≥ 0` then the tactic `lift n to ℕ using hn` creates a new constant of type `ℕ`, also named `n` and replaces all occurrences of the old variable `(n : ℤ)` with `↑n` (where `n` in the new variable). It will remove `n` and `hn` from the context. + So for example the tactic `lift n to ℕ using hn` transforms the goal `n : ℤ, hn : n ≥ 0, h : P n ⊢ n = 3` to `n : ℕ, h : P ↑n ⊢ ↑n = 3` (here `P` is some term of type `ℤ → Prop`). * The argument `using hn` is optional, the tactic `lift n to ℕ` does the same, but also creates a new subgoal that `n ≥ 0` (where `n` is the old variable). This subgoal will be placed at the top of the goal list. + So for example the tactic `lift n to ℕ` transforms the goal `n : ℤ, h : P n ⊢ n = 3` to two goals `n : ℤ, h : P n ⊢ n ≥ 0` and `n : ℕ, h : P ↑n ⊢ ↑n = 3`. * You can also use `lift n to ℕ using e` where `e` is any expression of type `n ≥ 0`. * Use `lift n to ℕ with k` to specify the name of the new variable. * Use `lift n to ℕ with k hk` to also specify the name of the equality `↑k = n`. In this case, `n` will remain in the context. You can use `rfl` for the name of `hk` to substitute `n` away (i.e. the default behavior). * You can also use `lift e to ℕ with k hk` where `e` is any expression of type `ℤ`. In this case, the `hk` will always stay in the context, but it will be used to rewrite `e` in all hypotheses and the target. + So for example the tactic `lift n + 3 to ℕ using hn with k hk` transforms the goal `n : ℤ, hn : n + 3 ≥ 0, h : P (n + 3) ⊢ n + 3 = 2 * n` to the goal `n : ℤ, k : ℕ, hk : ↑k = n + 3, h : P ↑k ⊢ ↑k = 2 * n`. * The tactic `lift n to ℕ using h` will remove `h` from the context. If you want to keep it, specify it again as the third argument to `with`, like this: `lift n to ℕ using h with n rfl h`. * More generally, this can lift an expression from `α` to `β` assuming that there is an instance of `can_lift α β`. In this case the proof obligation is specified by `can_lift.cond`. * Given an instance `can_lift β γ`, it can also lift `α → β` to `α → γ`; more generally, given `β : Π a : α, Type*`, `γ : Π a : α, Type*`, and `[Π a : α, can_lift (β a) (γ a)]`, it automatically generates an instance `can_lift (Π a, β a) (Π a, γ a)`. `lift` is in some sense dual to the `zify` tactic. `lift (z : ℤ) to ℕ` will change the type of an integer `z` (in the supertype) to `ℕ` (the subtype), given a proof that `z ≥ 0`; propositions concerning `z` will still be over `ℤ`. `zify` changes propositions about `ℕ` (the subtype) to propositions about `ℤ` (the supertype), without changing the type of any variable. -/ meta def lift (p : parse texpr) (t : parse to_texpr) (h : parse using_texpr) (n : parse with_ident_list) : tactic unit := tactic.lift p t h n add_tactic_doc { name := "lift", category := doc_category.tactic, decl_names := [`tactic.interactive.lift], tags := ["coercions"] } end interactive end tactic
Module Playground1. Inductive nat : Type := | O : nat | S : nat -> nat. Definition pred (n : nat) : nat := match n with | O => O | S n' => n' end. End Playground1. Definition minustwo (n : nat) : nat := match n with | O => O | S O => O | S (S n') => n' end. Check (S (S (S (S O)))). Eval compute in (minustwo 4). Check S. Check pred. Check minustwo. Fixpoint evenb (n:nat) : bool := match n with | O => true | S O => false | S (S n') => evenb n' end. Definition oddb (n:nat) : bool := negb (evenb n). Example test_oddb1: (oddb (S O)) = true. Proof. reflexivity. Qed. Example test_oddb2: (oddb (S (S (S (S O))))) = false. Proof. reflexivity. Qed. Module Playground2. Fixpoint plus (n : nat) (m : nat) : nat := match n with | O => m | S n' => S (plus n' m) end. Eval compute in (plus (S (S (S O))) (S (S O))). Fixpoint mult (n m : nat) : nat := match n with | O => O | S n' => plus m (mult n' m) end. Example test_mult1: (mult 3 3) = 9. Proof. reflexivity. Qed. Fixpoint minus (n m:nat) : nat := match n, m with | O , _ => O | S _ , O => n | S n', S m' => minus n' m' end. End Playground2. Fixpoint exp (base power : nat) : nat := match power with | O => S O | S p => mult base (exp base p) end.
theory CS_Ch3 imports Main begin type_synonym vname = string datatype aexp = N int | V vname | Plus aexp aexp type_synonym val = int type_synonym state = "vname \<Rightarrow> val" fun aval :: "aexp \<Rightarrow> state \<Rightarrow> val" where "aval (N n) s = n" | "aval (V x) s = s x" | "aval (Plus a1 a2) s = aval a1 s + aval a2 s" fun asimp_const :: "aexp \<Rightarrow> aexp" where "asimp_const (N n) = N n" | "asimp_const (V x) = V x" | "asimp_const (Plus a1 a2) = (case (asimp_const a1, asimp_const a2) of (N n1, N n2) \<Rightarrow> N (n1+n2) | (b1, b2) \<Rightarrow> Plus b1 b2)" lemma "aval (asimp_const a) s = aval a s" apply(induction a) apply(auto split: aexp.split) done fun plus :: "aexp \<Rightarrow> aexp \<Rightarrow> aexp" where "plus (N i1) (N i2) = N (i1 + i2)" | "plus (N i) a = (if i = 0 then a else Plus (N i) a)" | "plus a (N i) = (if i = 0 then a else Plus a (N i))" | "plus a1 a2 = Plus a1 a2" lemma aval_plus: "aval (plus a1 a2) s = aval a1 s + aval a2 s" apply(induction a1 a2 rule: plus.induct) apply(auto) done fun asimp :: "aexp \<Rightarrow> aexp" where "asimp (N n) = N n" | "asimp (V x) = V x" | "asimp (Plus a1 a2) = plus (asimp a1) (asimp a2)" lemma "aval (asimp a) s = aval a s" apply(induction a) apply(auto simp add: aval_plus) done (* 3.1 *) fun optimal :: "aexp \<Rightarrow> bool" where "optimal (N a) = True" | "optimal (V x) = True" | "optimal (Plus (N a) (N b)) = False" | "optimal (Plus a b) = (optimal a \<and> optimal b)" lemma "optimal (asimp_const a)" apply(induction a) apply(auto split: aexp.split) done (* 3.2 *) (* If you view this as a rewriting system that is designed to work only in conjunction with full_asimp, the structure of this function makes sense. We apply full_asimp recursively, so this function can look as few layers deep as it wants into the expression and full_asimp will glue it together. That is, its correctness can be inductively proven. *) fun full_plus :: "aexp \<Rightarrow> aexp \<Rightarrow> aexp" where "full_plus (N i1) (N i2) = N (i1 + i2)" | "full_plus (N i1) (Plus a (N i2)) = Plus a (N (i1 + i2))" | "full_plus (Plus a (N i1)) (N i2) = Plus a (N (i1 + i2))" | "full_plus a (Plus b (N i1)) = Plus (Plus a b) (N i1)" | "full_plus (Plus a (N i1)) b = Plus (Plus a b) (N i1)" | "full_plus (N i) a = (if i = 0 then a else Plus (N i) a)" | "full_plus a (N i) = (if i = 0 then a else Plus a (N i))" | "full_plus a1 a2 = Plus a1 a2" fun full_asimp :: "aexp \<Rightarrow> aexp" where "full_asimp (N a) = N a" | "full_asimp (V x) = V x" | "full_asimp (Plus a b) = full_plus (full_asimp a) (full_asimp b)" lemma aval_full_plus: "aval (full_plus a b) s = aval a s + aval b s" apply(induction rule: full_plus.induct) apply(auto) done lemma "aval (full_asimp a) s = aval a s" apply(induction a) apply(auto simp add: aval_full_plus) done (* 3.3 *) fun subst :: "vname \<Rightarrow> aexp \<Rightarrow> aexp \<Rightarrow> aexp" where "subst x a (N i1) = N i1" | "subst x a (V y) = (if x = y then a else (V y))" | "subst x a (Plus b1 b2) = Plus (subst x a b1) (subst x a b2)" lemma subst_lemma: "aval (subst x a e) s = aval e (s(x := aval a s))" apply(induction e) apply(auto) done lemma "aval a1 s = aval a2 s \<Longrightarrow> aval (subst x a1 e) s = aval (subst x a2 e) s" apply(induction e) apply(auto) done (* 3.4 is a separate theory, CS_Ch3_Ex4 *) (* 3.5 *) datatype aexp2 = N2 int | V2 vname | Plus2 aexp2 aexp2 | PostIncr2 vname | Div2 aexp2 aexp2 fun aval2 :: "aexp2 \<Rightarrow> state \<Rightarrow> (val \<times> state) option" where "aval2 (N2 i) s = Some (i, s)" | "aval2 (V2 x) s = Some (s x, s)" | "aval2 (Plus2 a b) s = (case (aval2 a s) of Some (a', s') \<Rightarrow> (case (aval2 b s') of Some (b', s'') \<Rightarrow> Some (a' + b', s'') | None \<Rightarrow> None) | None \<Rightarrow> None)" | "aval2 (PostIncr2 x) s = Some (s x, s(x := (s x) + 1))" | "aval2 (Div2 a b) s = (case (aval2 b s) of Some (b', s') \<Rightarrow> (if b' = 0 then None else Some ( case (aval2 a s') of Some (a', s'') \<Rightarrow> (a' div b', s''))) | None \<Rightarrow> None)" lemma "aval2 (Div2 (N2 3) (Plus2 (N2 1) (V2 ''x''))) (\<lambda>x. -1) = None" apply(auto) done lemma "case aval2 (Div2 (N2 3) (PostIncr2 ''x'')) (\<lambda>x. 1) of Some (a, b) \<Rightarrow> (a = 3 \<and> b(''x'') = 2) | None \<Rightarrow> False" apply(auto) done (* 3.6 *) datatype lexp = Nl int | Vl vname | Plusl lexp lexp | LET vname lexp lexp fun lval :: "lexp \<Rightarrow> state \<Rightarrow> int" where "lval (Nl i) s = i" | "lval (Vl x) s = s x" | "lval (Plusl a b) s = lval a s + lval b s" | "lval (LET x val body) s = lval body (s(x := lval val s))" fun inline :: "lexp \<Rightarrow> aexp" where "inline (Nl i) = (N i)" | "inline (Vl x) = (V x)" | "inline (Plusl a b) = Plus (inline a) (inline b)" | "inline (LET x val body) = subst x (inline val) (inline body)" lemma "lval e s = aval (inline e) s" apply(induction e arbitrary: s) apply(auto simp add: subst_lemma) done datatype bexp = Bc bool | Not bexp | And bexp bexp | Less aexp aexp fun bval :: "bexp \<Rightarrow> state \<Rightarrow> bool" where "bval (Bc v) s = v" | "bval (Not b) s = (\<not> bval b s)" | "bval (And b\<^sub>1 b\<^sub>2) s = (bval b\<^sub>1 s \<and> bval b\<^sub>2 s)" | "bval (Less a\<^sub>1 a\<^sub>2) s = (aval a\<^sub>1 s < aval a\<^sub>2 s)" fun not :: "bexp \<Rightarrow> bexp" where "not (Bc True) = Bc False" | "not (Bc False) = Bc True" | "not b = Not b" fun "and" :: "bexp \<Rightarrow> bexp \<Rightarrow> bexp" where "and (Bc True) b = b" | "and b (Bc True) = b" | "and (Bc False) b = Bc False" | "and b (Bc False) = Bc False" | "and b\<^sub>1 b\<^sub>2 = And b\<^sub>1 b\<^sub>2" fun less :: "aexp \<Rightarrow> aexp \<Rightarrow> bexp" where "less (aexp.N n\<^sub>1) (aexp.N n\<^sub>2) = Bc (n\<^sub>1 < n\<^sub>2)" | "less a\<^sub>1 a\<^sub>2 = Less a\<^sub>1 a\<^sub>2" fun bsimp :: "bexp \<Rightarrow> bexp" where "bsimp (Bc v) = Bc v" | "bsimp (Not b) = not (bsimp b)" | "bsimp (And b\<^sub>1 b\<^sub>2) = and (bsimp b\<^sub>1) (bsimp b\<^sub>2)" | "bsimp (Less a\<^sub>1 a\<^sub>2) = less (asimp a\<^sub>1) (asimp a\<^sub>2)" (* 3.7 *) fun Eq :: "aexp \<Rightarrow> aexp \<Rightarrow> bexp" where "Eq a b = And (Not (Less a b)) (Not (Less b a))" lemma "bval (Eq a b) s = (aval a s = aval b s)" apply(auto) done fun Le :: "aexp \<Rightarrow> aexp \<Rightarrow> bexp" where "Le a b = Not (And (Not (Less a b)) (Not (Eq a b)))" lemma "bval (Le a b) s = (aval a s \<le> aval b s)" apply(auto) done (* 3.8 *) datatype ifexp = Bc2 bool | If ifexp ifexp ifexp | Less2 aexp aexp fun ifval :: "ifexp \<Rightarrow> state \<Rightarrow> bool" where "ifval (Bc2 b) s = b" | "ifval (If a b c) s = (if ifval a s then ifval b s else ifval c s)" | "ifval (Less2 a b) s = (aval a s < aval b s)" fun b2ifexp :: "bexp \<Rightarrow> ifexp" where "b2ifexp (Less a b) = (Less2 a b)" | "b2ifexp (Not a) = If (b2ifexp a) (Bc2 False) (Bc2 True)" | "b2ifexp (And a b) = If (b2ifexp a) (b2ifexp b) (Bc2 False)" | "b2ifexp (Bc b) = Bc2 b" lemma "bval b s = ifval (b2ifexp b) s" apply(induction b) apply(auto) done fun if2bexp :: "ifexp \<Rightarrow> bexp" where "if2bexp (Bc2 b) = Bc b" | "if2bexp (If c t f) = And (Not (And (if2bexp c) (Not (if2bexp t)))) (Not (And (Not (if2bexp c)) (Not (if2bexp f))))" | "if2bexp (Less2 a b) = Less a b" lemma "ifval i s = bval (if2bexp i) s" apply(induction i) apply(auto) done (* 3.9 *) datatype pbexp = VAR vname | NOT pbexp | AND pbexp pbexp | OR pbexp pbexp fun pbval :: "pbexp \<Rightarrow> (vname \<Rightarrow> bool) \<Rightarrow> bool" where "pbval (VAR x) s = s x" | "pbval (NOT b) s = (\<not> pbval b s)" | "pbval (AND b\<^sub>1 b\<^sub>2) s = (pbval b\<^sub>1 s \<and> pbval b\<^sub>2 s)" | "pbval (OR b\<^sub>1 b\<^sub>2) s = (pbval b\<^sub>1 s \<or> pbval b\<^sub>2 s)" fun is_nnf :: "pbexp \<Rightarrow> bool" where "is_nnf (VAR x) = True" | "is_nnf (NOT (VAR x)) = True" | "is_nnf (NOT y) = False" | "is_nnf (OR a b) = (is_nnf a \<and> is_nnf b)" | "is_nnf (AND a b) = (is_nnf a \<and> is_nnf b)" fun nnf :: "pbexp \<Rightarrow> pbexp" where "nnf (VAR x) = VAR x" | "nnf (NOT (VAR x)) = (NOT (VAR x))" | "nnf (NOT (AND a b)) = OR (nnf (NOT a)) (nnf (NOT b))" | "nnf (NOT (OR a b)) = AND (nnf (NOT a)) (nnf (NOT b))" | "nnf (NOT (NOT b)) = nnf b " | "nnf (AND a b) = AND (nnf a) (nnf b)" | "nnf (OR a b) = OR (nnf a) (nnf b)" lemma "is_nnf (nnf b)" apply(induction b rule: nnf.induct) apply(auto) done fun is_dnf :: "pbexp \<Rightarrow> bool" where "is_dnf (VAR x) = True" | (* since we assume NNF, we don't need to handle NOT *) "is_dnf (NOT x) = True" | "is_dnf (AND (OR _ _) _) = False" | "is_dnf (AND _ (OR _ _)) = False" | "is_dnf (AND a b) = (is_dnf a \<and> is_dnf b)" | "is_dnf (OR a b) = (is_dnf a \<and> is_dnf b)" fun dnf_of_nnf :: "pbexp \<Rightarrow> pbexp" where "dnf_of_nnf (VAR x) = VAR x" | "dnf_of_nnf (NOT x) = NOT x" | "dnf_of_nnf (OR a b) = OR (dnf_of_nnf a) (dnf_of_nnf b)" | "dnf_of_nnf (AND (OR o\<^sub>1 o\<^sub>2) a) = OR (AND o\<^sub>1 a) (AND o\<^sub>2 a)" | "dnf_of_nnf (AND a (OR o\<^sub>1 o\<^sub>2)) = OR (AND o\<^sub>1 a) (AND o\<^sub>2 a)" | "dnf_of_nnf (AND a b) = AND (dnf_of_nnf a) (dnf_of_nnf b)" lemma "pbval (dnf_of_nnf b) s = pbval b s" apply(induction b rule: dnf_of_nnf.induct) apply(auto) done lemma "is_nnf b \<Longrightarrow> is_nnf (dnf_of_nnf b)" apply(induction b rule: dnf_of_nnf.induct) apply(auto) done datatype instr = LOADI val | LOAD vname | ADD type_synonym stack = "val list" abbreviation "hd2 xs == hd(tl xs)" abbreviation "tl2 xs == tl(tl xs)" fun exec1 :: "instr \<Rightarrow> state \<Rightarrow> stack \<Rightarrow> stack option" where "exec1 (LOADI n) _ stk = Some (n # stk)" | "exec1 (LOAD x) s stk = Some ((s x) # stk)" | "exec1 ADD _ (h # h2 # rst) = Some ((h2 + h) # rst)" | "exec1 ADD _ _ = None" (* I tried using Option.bind etc but I can't seem to get anything proven when I'm using it. Expanding it manually works, though. Oh well. *) fun exec :: "instr list \<Rightarrow> state \<Rightarrow> stack \<Rightarrow> stack option" where "exec [] _ stk = Some (stk)" | "exec (i # is) s stk = (case (exec1 i s stk) of Some stk' \<Rightarrow> exec is s stk' | None \<Rightarrow> None)" fun comp :: "aexp \<Rightarrow> instr list" where "comp (N n) = [LOADI n]" | "comp (V x) = [LOAD x]" | "comp (Plus e\<^sub>1 e\<^sub>2) = comp e\<^sub>1 @ comp e\<^sub>2 @ [ADD]" (* I originally tried to formulate these lemmas like, "case (exec is\<^sub>1 s stk) of Some stk' \<Rightarrow> exec (is\<^sub>1 @ is\<^sub>2) s stk = exec is\<^sub>2 s stk' | None \<Rightarrow> exec (is\<^sub>1 @ is\<^sub>2) s stk = None" but was unable to prove them. *) lemma exec_append: "exec is\<^sub>1 s stk = Some stk' \<Longrightarrow> exec (is\<^sub>1 @ is\<^sub>2) s stk = exec is\<^sub>2 s stk'" apply(induction is\<^sub>1 arbitrary: stk) apply(auto split: option.split) done lemma "exec (comp a) s stk = Some (aval a s # stk)" apply(induction a arbitrary: stk) apply(auto simp add: exec_append) done (* 3.11 *) type_synonym reg = nat datatype reginstr = LDI int reg | LD vname reg | ADD reg reg fun regexec1 :: "reginstr \<Rightarrow> state \<Rightarrow> (reg \<Rightarrow> int) \<Rightarrow> reg \<Rightarrow> int" where "regexec1 (LDI v r) s file = file(r := v)" | "regexec1 (LD x r) s file = file(r := s x)" | "regexec1 (ADD r\<^sub>1 r\<^sub>2) s file = file(r\<^sub>1 := (file r\<^sub>1) + (file r\<^sub>2))" fun regexec :: "reginstr list \<Rightarrow> state \<Rightarrow> (reg \<Rightarrow> int) \<Rightarrow> reg \<Rightarrow> int" where "regexec [] s file = file" | "regexec (i # is) s file = regexec is s (regexec1 i s file)" fun regcomp :: "aexp \<Rightarrow> reg \<Rightarrow> reginstr list" where "regcomp (N n) r = [LDI n r]" | "regcomp (V x) r = [LD x r]" | "regcomp (Plus e\<^sub>1 e\<^sub>2) r = regcomp e\<^sub>1 r @ regcomp e\<^sub>2 (r+1) @ [ADD r (r+1)]" lemma regexec_append: "regexec (is\<^sub>1 @ is\<^sub>2) s file = regexec is\<^sub>2 s (regexec is\<^sub>1 s file)" apply(induction is\<^sub>1 arbitrary: "file") apply(auto) done lemma regcomp_dont_touch_small_regs: "q < r \<Longrightarrow> regexec (regcomp a r) s file q = file q" apply(induction a arbitrary: r "file") apply(auto simp add: regexec_append) done lemma "(regexec (regcomp a r) s file) r = aval a s" apply(induction a arbitrary: s r "file") apply(auto simp add: regexec_append regcomp_dont_touch_small_regs) done (* 3.12 *) datatype instr0 = LDI0 val | LD0 vname | MV0 reg | ADD0 reg fun exec10 :: "instr0 \<Rightarrow> state \<Rightarrow> (reg \<Rightarrow> int) \<Rightarrow> reg \<Rightarrow> int" where "exec10 (LDI0 val) s file = file(0 := val)" | "exec10 (LD0 vname) s file = file(0 := s vname)" | "exec10 (MV0 reg) s file = file(reg := file 0)" | "exec10 (ADD0 reg) s file = file(0 := (file 0) + (file reg))" fun exec0 :: "instr0 list \<Rightarrow> state \<Rightarrow> (reg \<Rightarrow> int) \<Rightarrow> reg \<Rightarrow> int" where "exec0 [] s file = file" | "exec0 (i # is) s file = exec0 is s (exec10 i s file)" fun comp0 :: "aexp \<Rightarrow> reg \<Rightarrow> instr0 list" where "comp0 (N n) r = [LDI0 n]" | "comp0 (V x) r = [LD0 x]" | "comp0 (Plus e\<^sub>1 e\<^sub>2) r = (comp0 e\<^sub>1 (r+1)) @ [MV0 (r+1)] @ (comp0 e\<^sub>2 (r+2)) @ [ADD0 (r+1)]" lemma exec0_append: "exec0 (is\<^sub>1 @ is\<^sub>2) s file = exec0 is\<^sub>2 s (exec0 is\<^sub>1 s file)" apply(induction is\<^sub>1 arbitrary: "file") apply(auto) done lemma comp0_register_preservation: "0 \<noteq> q \<Longrightarrow> q < r \<Longrightarrow> exec0 (comp0 a r) s file q = file q" apply(induction a arbitrary: r q "file") apply(auto simp add: exec0_append) done lemma "exec0 (comp0 a r) s rs 0 = aval a s" apply(induction a arbitrary: r s rs) apply(auto simp add: exec0_append comp0_register_preservation) done end
subsection \<open>Masking properties\<close> theory MachineMasking imports RegisterMachineSimulation "../Diophantine/Binary_And" begin (* [D] 4.18 *) definition E :: "nat \<Rightarrow> nat \<Rightarrow> nat" where "(E q b) = (\<Sum>t = 0..q. b^t)" lemma e_geom_series: assumes "b \<ge> 2" shows "(E q b = e) \<longleftrightarrow> ((b-1) * e = b^(Suc q) - 1 )" (is "?P \<longleftrightarrow> ?Q") proof- have "sum ((^) (int b)) {..<Suc q} = sum ((^) b) {0..q}" by (simp add: atLeast0AtMost lessThan_Suc_atMost) then have "(int b - 1) * (E q b) = int b ^ Suc q - 1" using E_def by (metis power_diff_1_eq) moreover have "int b ^ Suc q - 1 = b ^ (Suc q) - 1" using one_le_power[of "int b" "Suc q"] assms by (simp add: of_nat_diff) moreover have "int b - 1 = b - 1 " using assms by auto ultimately show ?thesis using assms by (metis Suc_1 Suc_diff_le Zero_not_Suc diff_Suc_Suc int_ops(7) mult_cancel_left of_nat_eq_iff) qed (* [D] 4.16 *) definition D :: "nat \<Rightarrow> nat \<Rightarrow> nat \<Rightarrow> nat" where "(D q c b) = (\<Sum>t = 0..q. (2^c - 1) * b^t)" lemma d_geom_series: assumes "b = 2^(Suc c)" shows "(D q c b = d) \<longleftrightarrow> ((b-1) * d = (2^c - 1) * (b^(Suc q) - 1))" (is "?P \<longleftrightarrow> ?Q") proof- have "D q c b = (2^c - 1) * E q b" by (auto simp: E_def D_def sum_distrib_left sum_distrib_right) moreover have "b \<ge> 2" using assms by fastforce ultimately show ?thesis by (smt e_geom_series mult.left_commute mult_cancel_left) qed (* [D] 4.21 *) definition F :: "nat \<Rightarrow> nat \<Rightarrow> nat \<Rightarrow> nat" where "(F q c b) = (\<Sum>t = 0..q. 2^c * b^t)" lemma f_geom_series: assumes "b = 2^(Suc c)" shows "(F q c b = f) \<longleftrightarrow> ( (b-1) * f = 2^c * (b^(Suc q) - 1) )" proof- have "F q c b = 2^c * E q b" by (auto simp: E_def F_def sum_distrib_left sum_distrib_right) moreover have "b \<ge> 2" using assms by fastforce ultimately show ?thesis by (smt e_geom_series mult.left_commute mult_cancel_left) qed (* AUX LEMMAS *) lemma aux_lt_implies_mask: assumes "a < 2^k" shows "\<forall>r\<ge>k. a \<exclamdown> r = 0" using nth_bit_def assms apply auto proof - (* found by e *) fix r :: nat assume a1: "a < 2 ^ k" assume a2: "k \<le> r" from a1 have "a div 2 ^ k = 0" by simp then have "2 = (0::nat) \<or> a < 2 ^ r" using a2 by (metis (no_types) div_le_mono nat_zero_less_power_iff neq0_conv not_le power_diff) then show "a div 2 ^ r mod 2 = 0" by simp qed lemma lt_implies_mask: fixes a b :: nat assumes "\<exists>k. a < 2^k \<and> (\<forall>r<k. nth_bit b r = 1)" (* this means a < b and b = xx11..11 *) shows "a \<preceq> b" proof - obtain k where assms: "a < 2^k \<and> (\<forall>r<k. nth_bit b r = 1)" using assms by auto have k1: "\<forall>r<k. a \<exclamdown> r \<le> b \<exclamdown> r" using nth_bit_bounded by (simp add: \<open>a < 2 ^ k \<and> (\<forall>r<k. b \<exclamdown> r = 1)\<close>) hence k2: "\<forall>r\<ge>k. a \<exclamdown> r = 0" using aux_lt_implies_mask assms by auto show ?thesis using masks_leq_equiv by auto (metis k1 k2 le0 not_less) qed lemma mask_conversed_shift: fixes a b k :: nat assumes asm: "a \<preceq> b" shows "a * 2^k \<preceq> b * 2^k" proof - have shift: "x \<preceq> y \<Longrightarrow> 2*x \<preceq> 2*y" for x y by (induction x; auto) have "a * 2 ^ k \<preceq> b * 2 ^ k \<Longrightarrow> 2 * (a * 2 ^ k) \<preceq> 2 * (b * 2 ^ k)" for k using shift[of "a*2^k" "b*2^k"] by auto thus ?thesis by (induction k; auto simp: asm shift algebra_simps) qed lemma base_summation_bound: fixes c q :: nat and f :: "(nat \<Rightarrow> nat)" defines b: "b \<equiv> B c" assumes bound: "\<forall>t. f t < 2 ^ Suc c - (1::nat)" shows "(\<Sum>t = 0..q. f t * b^t) < b^(Suc q)" proof (induction q) case 0 then show ?case using B_def b bound less_imp_diff_less not_less_eq by auto blast next case (Suc q) have "(\<Sum>t = 0..Suc q. f t * b ^ t) = f (Suc q) * b ^ (Suc q) + (\<Sum>t = 0..q. f t * b ^ t)" by (auto cong: sum.cong) also have "... < (f (Suc q) + 1) * b ^ (Suc q)" using Suc.IH by auto also have "... < b * b ^ (Suc q)" by (metis bound b less_diff_conv B_def mult_less_cancel2 zero_less_numeral zero_less_power) finally show ?case by auto qed lemma mask_conserved_sum: fixes y c q :: nat and x :: "(nat \<Rightarrow> nat)" defines b: "b \<equiv> B c" assumes mask: "\<forall>t. x t \<preceq> y" assumes xlt: "\<forall>t. x t \<le> 2 ^ c - Suc 0" assumes ylt: "y \<le> 2 ^ c - Suc 0" shows "(\<Sum>t = 0..q. x t * b^t) \<preceq> (\<Sum>t = 0..q. y * b^t)" proof (induction q) case 0 then show ?case using mask by auto next case (Suc q) have xb: "\<forall>t. x t < 2^Suc c - Suc 0" using xlt by (smt Suc_pred leI le_imp_less_Suc less_SucE less_trans n_less_m_mult_n numeral_2_eq_2 power.simps(2) zero_less_numeral zero_less_power) have yb: "y < 2^c" using ylt b B_def leI order_trans by fastforce have sumxlt: "(\<Sum>t = 0..q. x t * b ^ t) < b^(Suc q)" using base_summation_bound xb b B_def by auto have sumylt: "(\<Sum>t = 0..q. y * b ^ t) < b^(Suc q)" using base_summation_bound yb b B_def by auto have "((\<Sum>t = 0..Suc q. x t * b ^ t) \<preceq> (\<Sum>t = 0..Suc q. y * b ^ t)) = (x (Suc q) * b^Suc q + (\<Sum>t = 0..q. x t * b ^ t) \<preceq> y * b^Suc q + (\<Sum>t = 0..q. y * b ^ t))" by (auto simp: atLeast0_lessThan_Suc add.commute) also have "... = (x (Suc q) * b^Suc q \<preceq> y * b^Suc q) \<and> (\<Sum>t = 0..q. x t * b ^ t) \<preceq> (\<Sum>t = 0..q. y * b ^ t)" using mask_linear[where ?t = "Suc c * Suc q"] sumxlt sumylt Suc.IH b B_def apply auto apply (smt mask mask_conversed_shift power_Suc power_mult power_mult_distrib) by (smt mask mask_linear power_Suc power_mult power_mult_distrib) finally show ?case using mask_linear Suc.IH B_def by (metis (no_types, lifting) b mask mask_conversed_shift power_mult) qed lemma aux_powertwo_digits: fixes k c :: nat assumes "k < c" shows "nth_bit (2^c) k = 0" proof - have h: "(2::nat) ^ c div 2 ^ k = 2 ^ (c - k)" by (simp add: assms less_imp_le power_diff) thus ?thesis by (auto simp: h nth_bit_def assms) qed lemma obtain_digit_rep: fixes x c :: nat shows "x && 2^c = (\<Sum>t<Suc c. 2^t * (nth_bit x t) * (nth_bit (2^c) t))" proof - have "x && 2^c \<preceq> 2^c" by (simp add: lm0245) hence "x && 2^c \<le> 2^c" by (simp add: masks_leq) hence h: "x && 2^c < 2^Suc c" by (smt Suc_lessD le_neq_implies_less lessI less_trans_Suc n_less_m_mult_n numeral_2_eq_2 power_Suc zero_less_power) have "\<forall>t. (x && 2^c) \<exclamdown> t = (nth_bit x t) * (nth_bit (2^c) t)" using bitAND_digit_mult by auto then show ?thesis using h digit_sum_repr[of "(x && 2^c)" "Suc c"] by (auto) (simp add: mult.commute semiring_normalization_rules(19)) qed lemma nth_digit_bitAND_equiv: fixes x c :: nat shows "2^c * nth_bit x c = (x && 2^c)" proof - have d1: "nth_bit (2^c) c = 1" using nth_bit_def by auto moreover have "x && 2^c = (2::nat)^c * (x \<exclamdown> c) * (((2::nat)^c) \<exclamdown> c) + (\<Sum>t<c. (2::nat)^t * (x \<exclamdown> t) * (((2::nat)^c) \<exclamdown> t))" using obtain_digit_rep by (auto cong: sum.cong) moreover have "(\<Sum>t<c. 2^t * (nth_bit x t) * (nth_bit ((2::nat)^c) t)) = 0" using aux_powertwo_digits by auto ultimately show ?thesis using d1 by auto qed lemma bitAND_single_digit: fixes x c :: nat assumes "2 ^ c \<le> x" assumes "x < 2 ^ Suc c" shows "nth_bit x c = 1" proof - obtain b where b: "x = 2^c + b" using assms(1) le_Suc_ex by auto have bb: "b < 2^c" using assms(2) b by auto have "(2 ^ c + b) div 2 ^ c mod 2 = (1 + b div 2 ^ c) mod 2" by (auto simp: div_add_self1) also have "... = 1" by (auto simp: bb) finally show ?thesis by (simp only: nth_bit_def b) qed lemma aux_bitAND_distrib: "2 * (a && b) = (2 * a) && (2 * b)" by (induct a b rule: bitAND_nat.induct; auto) lemma bitAND_distrib: "2^c * (a && b) = (2^c * a) && (2^c * b)" proof (induction c) case 0 then show ?case by auto next case (Suc c) have "2 ^ Suc c * (a && b) = 2 * (2 ^ c * (a && b))" by auto also have "... = 2 * ((2^c * a) && (2^c * b))" using Suc.IH by auto also have "... = ((2^Suc c * a) && (2^Suc c * b))" using aux_bitAND_distrib[of "2^c * a" "2^c * b"] by (auto simp add: ab_semigroup_mult_class.mult_ac(1)) finally show ?case by auto qed lemma bitAND_linear_sum: fixes x y :: "nat \<Rightarrow> nat" and c :: nat and q :: nat defines b: "b == 2 ^ Suc c" assumes xb: "\<forall>t. x t < 2 ^ Suc c - 1" assumes yb: "\<forall>t. y t < 2 ^ Suc c - 1" shows "(\<Sum>t = 0..q. (x t && y t) * b^t) = (\<Sum>t = 0..q. x t * b^t) && (\<Sum>t = 0..q. y t * b^t)" proof (induction q) case 0 then show ?case by (auto simp: b B_def) next case (Suc q) have "(\<Sum>t = 0..Suc q. (x t && y t) * b ^ t) = (x (Suc q) && y (Suc q)) * b ^ Suc q + (\<Sum>t = 0..q. (x t && y t) * b ^ t)" by (auto cong: sum.cong) moreover have h0: "(x (Suc q) && y (Suc q)) * b ^ Suc q = (x (Suc q) * b^Suc q) && (y (Suc q) * b^Suc q)" using b bitAND_distrib by (auto) (smt mult.commute power_Suc power_mult) moreover have h1: "(\<Sum>t = 0..q. (x t && y t) * b ^ t) = (\<Sum>t = 0..q. x t * b^t) && (\<Sum>t = 0..q. y t * b^t)" using Suc.IH by auto ultimately have h2: "(\<Sum>t = 0..Suc q. (x t && y t) * b ^ t) = ((x (Suc q) * b^Suc q) && (y (Suc q) * b^Suc q)) + ((\<Sum>t = 0..q. x t * b^t) && (\<Sum>t = 0..q. y t * b^t))" by auto have sumxb: "(\<Sum>t = 0..q. x t * b ^ t) < b ^ Suc q" using base_summation_bound xb b B_def by auto have sumyb: "(\<Sum>t = 0..q. y t * b ^ t) < b ^ Suc q" using base_summation_bound yb b B_def by auto have h3: "((x (Suc q) * b^Suc q) && (y (Suc q) * b^Suc q)) + ((\<Sum>t = 0..q. x t * b^t) && (\<Sum>t = 0..q. y t * b^t)) = ((\<Sum>t = 0..q. x t * b^t) + x (Suc q) * b^Suc q) && ((\<Sum>t = 0..q. y t * b^t) + y (Suc q) * b^Suc q)" using sumxb sumyb bitAND_linear h2 h0 by (auto) (smt add.commute b power_Suc power_mult) thus ?case using h2 by (auto cong: sum.cong) qed lemma dmask_aux0: fixes x :: nat assumes "x > 0" shows "(2 ^ x - Suc 0) div 2 = 2 ^ (x - 1) - Suc 0" proof - have 0: "(2^x - Suc 0) div 2 = (2^x - 2) div 2" by (smt Suc_diff_Suc Suc_pred assms dvd_power even_Suc even_Suc_div_two nat_power_eq_Suc_0_iff neq0_conv numeral_2_eq_2 zero_less_diff zero_less_power) (* can do manual parity distinction *) moreover have divides: "(2::nat) dvd 2^x" by (simp add: assms dvd_power[of x "2::nat"]) moreover have "(2^x - 2::nat) div 2 = 2^x div 2 - 2 div 2" using div_plus_div_distrib_dvd_left[of "2" "2^x" "2"] divides by auto moreover have "... = 2 ^ (x - 1) - Suc 0" by (simp add: Suc_leI assms power_diff) ultimately have 1: "(2 ^ x - Suc 0) div 2 = 2 ^ (x - 1) - Suc 0" by (smt One_nat_def) thus ?thesis by simp qed lemma dmask_aux: fixes c :: nat shows "d < c \<Longrightarrow> (2^c - Suc 0) div 2^d = 2 ^ (c - d) - Suc 0" proof (induction d) case 0 then show ?case by (auto) next case (Suc d) have d: "d < c" using Suc.prems by auto have "(2 ^ c - Suc 0) div 2 ^ Suc d = (2 ^ c - Suc 0) div 2 ^ d div 2" by (auto) (metis mult.commute div_mult2_eq) also have "... = (2 ^ (c - d) - Suc 0) div 2" by (subst Suc.IH) (auto simp: d) also have "... = 2 ^ (c - Suc d) - Suc 0" apply (subst dmask_aux0[of "c - d"]) using d by (auto) finally show ?case by auto qed (* REGISTERS *) lemma register_cells_masked: fixes l :: register and t :: nat and ic :: configuration and p :: program assumes cells_bounded: "cells_bounded ic p c" assumes l: "l < length (snd ic)" shows "R ic p l t \<preceq> 2^c - 1" proof - have a: "R ic p l t \<le> 2^c - 1" using cells_bounded less_Suc_eq_le using l by fastforce have b: "r < c \<Longrightarrow> nth_bit (2^c - 1) r = 1" for r apply (auto simp: nth_bit_def) apply (subst dmask_aux) apply (auto) by (metis Suc_pred dvd_power even_Suc mod_0_imp_dvd not_mod2_eq_Suc_0_eq_0 zero_less_diff zero_less_numeral zero_less_power) show ?thesis using lt_implies_mask cells_bounded l by (auto) (metis One_nat_def b) qed lemma lm04_15_register_masking: fixes c :: nat and l :: register and ic :: configuration and p :: program and q :: nat defines "b == B c" defines "d == D q c b" assumes cells_bounded: "cells_bounded ic p c" assumes l: "l < length (snd ic)" defines "r == RLe ic p b q" shows "r l \<preceq> d" proof - have "\<And>t. R ic p l t \<preceq> 2^c - 1" using cells_bounded l by (rule register_cells_masked) hence rmasked: "\<forall>t. R ic p l t \<preceq> 2^c - 1" by (intro allI) have rlt: "\<forall>t. R ic p l t \<le> 2^c - 1" using cells_bounded less_Suc_eq_le l by fastforce have rlmasked: "(\<Sum>t = 0..q. R ic p l t * b^t) \<preceq> (\<Sum>t = 0..q. (2^c - 1) * b^t)" using rmasked rlt b_def B_def mask_conserved_sum by (auto) thus ?thesis by (auto simp: r_def d_def D_def RLe_def mult.commute cong: sum.cong) qed (* ZERO INDICATORS *) lemma zero_cells_masked: fixes l :: register and t :: nat and ic :: configuration and p :: program assumes l: "l < length (snd ic)" shows "Z ic p l t \<preceq> 1" proof - have "nth_bit 1 0 = 1" by (auto simp: nth_bit_def) thus ?thesis apply (auto) apply (rule lt_implies_mask) by (metis (full_types) One_nat_def Suc_1 Z_bounded less_Suc_eq_le less_one power_one_right) qed lemma lm04_15_zero_masking: fixes c :: nat and l :: register and ic :: configuration and p :: program and q :: nat defines "b == B c" defines "e == E q b" assumes cells_bounded: "cells_bounded ic p c" assumes l: "l < length (snd ic)" assumes c: "c > 0" defines "z == ZLe ic p b q" shows "z l \<preceq> e" proof - have "\<And>t. Z ic p l t \<preceq> 1" using l by (rule zero_cells_masked) hence zmasked: "\<forall>t. Z ic p l t \<preceq> 1" by (intro allI) have zlt: "\<forall>t. Z ic p l t \<le> 2 ^ c - 1" using cells_bounded less_Suc_eq_le by fastforce have 1: "(1::nat) \<le> 2 ^ c - 1" using c by (simp add: Nat.le_diff_conv2 numeral_2_eq_2 self_le_power) have rlmasked: "(\<Sum>t = 0..q. Z ic p l t * b^t) \<preceq> (\<Sum>t = 0..q. 1 * b^t)" using zmasked zlt 1 b_def B_def mask_conserved_sum[of "Z ic p l" 1] by (auto) thus ?thesis by (auto simp: z_def e_def E_def ZLe_def mult.commute cong: sum.cong) qed (* Relation between zero indicator and register *) lemma lm04_19_zero_register_relations: fixes c :: nat and l :: register and t :: nat and ic :: configuration and p :: program assumes cells_bounded: "cells_bounded ic p c" assumes l: "l < length (snd ic)" defines "z == Z ic p" defines "r == R ic p" shows "2^c * z l t = (r l t + 2^c - 1) && 2^c" proof - have a1: "R ic p l t \<noteq> 0 \<Longrightarrow> 2^c \<le> R ic p l t + 2^c - 1" by auto have a2: "R ic p l t + 2^c - 1 < 2^Suc c" using cells_bounded by (simp add: l less_imp_diff_less) have "Z ic p l t = nth_bit (R ic p l t + 2^c - 1) c" apply (cases "R ic p l t = 0") subgoal by (auto simp add: Z_def R_def nth_bit_def) subgoal using cells_bounded bitAND_single_digit a1 a2 Z_def by auto done also have "2^c * nth_bit (R ic p l t + 2^c - 1) c = ((R ic p l t + 2^c - 1) && 2^c)" using nth_digit_bitAND_equiv by auto finally show ?thesis by (auto simp: z_def r_def) qed lemma lm04_20_zero_definition: fixes c :: nat and l :: register and ic :: configuration and p :: program and q :: nat defines "b == B c" defines "f == F q c b" defines "d == D q c b" assumes cells_bounded: "cells_bounded ic p c" assumes l: "l < length (snd ic)" assumes c: "c > 0" defines "z == ZLe ic p b q" defines "r == RLe ic p b q" shows "2^c * z l = (r l + d) && f" proof - have "\<And>t. 2^c * Z ic p l t = (R ic p l t + 2^c - 1) && 2^c" by (rule lm04_19_zero_register_relations cells_bounded l) + hence raw_sums: "(\<Sum>t = 0..q. 2^c * Z ic p l t * b^t) = (\<Sum>t = 0..q. ((R ic p l t + 2^c - 1) && 2^c) * b^t)" by auto have "(\<Sum>t = 0..q. 2^c * Z ic p l t * b^t) = 2^c * (\<Sum>t = 0..q. Z ic p l t * b^t)" by (auto simp: sum_distrib_left mult.assoc cong: sum.cong) also have "... = 2^c * z l" by (auto simp: z_def ZLe_def mult.commute) finally have lhs: "(\<Sum>t = 0..q. 2^c * Z ic p l t * b^t) = 2^c * z l" by auto have "(\<Sum>t = 0..q. (R ic p l t + (2^c - 1)) * b^t) = (\<Sum>t = 0..q. R ic p l t * b^t + (2^c - 1) * b^t)" apply (rule sum.cong) apply (auto simp: add.commute mult.commute) subgoal for x using distrib_left[of "b^x" "R ic p l x" "2^c - 1"] by (auto simp: algebra_simps) done also have "... = (\<Sum>t = 0..q. (R ic p l t * b^t)) + (\<Sum>t = 0..q. (2^c - 1) * b^t)" by (rule sum.distrib) also have "... = r l + d" by (auto simp: r_def RLe_def d_def D_def mult.commute) finally have split_sums: "(\<Sum>t = 0..q. (R ic p l t + (2^c - 1)) * b^t) = r l + d" by auto have a1: "(2::nat) ^ c < (2::nat) ^ Suc c - 1" using c by (induct c, auto, fastforce) have a2: "\<forall>t. R ic p l t + 2 ^ c - 1 \<le> 2 ^ Suc c" using cells_bounded B_def by (simp add: less_imp_diff_less l) (simp add: Suc_leD l less_imp_le_nat numeral_Bit0) have "(\<Sum>t = 0..q. ((R ic p l t + 2^c - 1) && 2^c) * b^t) = (\<Sum>t = 0..q. (R ic p l t + 2^c - 1) * b^t) && (\<Sum>t = 0..q. 2^c * b^t)" using bitAND_linear_sum[of "\<lambda>t. R ic p l t + 2^c - 1" "c" "\<lambda>t. 2^c"] cells_bounded b_def B_def a1 a2 apply auto by (smt One_nat_def Suc_less_eq Suc_pred a1 add.commute add_gr_0 l mult_2 nat_add_left_cancel_less power_Suc zero_less_numeral zero_less_power) also have "... = (\<Sum>t = 0..q. (R ic p l t + 2^c - 1) * b^t) && f" by (auto simp: f_def F_def) also have "... = (r l + d) && f" using split_sums by auto finally have rhs: "(\<Sum>t = 0..q. ((R ic p l t + 2^c - 1) && 2^c) * b^t) = (r l + d) && f" by auto show ?thesis using raw_sums lhs rhs by auto qed lemma state_mask: fixes c :: nat and l :: register and ic :: configuration and p :: program and q :: nat and a :: nat defines "b \<equiv> B c" and "m \<equiv> length p - 1" defines "e \<equiv> E q b" assumes is_val: "is_valid_initial ic p a" and q: "q > 0" and "c > 0" assumes terminate: "terminates ic p q" shows "SKe ic p b q k \<preceq> e" proof - have "1 \<le> 2 ^ c - Suc 0" using \<open>c>0\<close> by (metis One_nat_def Suc_leI one_less_numeral_iff one_less_power semiring_norm(76) zero_less_diff) have Smask: "S ic p k t \<preceq> 1" for t by (simp add: S_def) have Sbound: "S ic p k t \<le> 2 ^ c - Suc 0" for t using \<open>1\<le>2^c-Suc 0\<close> by (simp add: S_def) have rlmasked: "(\<Sum>t = 0..q. S ic p k t * b^t) \<preceq> (\<Sum>t = 0..q. 1 * b^t)" using b_def B_def Smask Sbound mask_conserved_sum[of "S ic p k" 1] \<open>1 \<le> 2^c-Suc 0\<close> by auto thus ?thesis using SKe_def e_def E_def by (auto simp: mult.commute) qed lemma state_sum_mask: fixes c :: nat and l :: register and ic :: configuration and p :: program and q :: nat and a :: nat defines "b \<equiv> B c" and "m \<equiv> length p - 1" defines "e \<equiv> E q b" assumes is_val: "is_valid_initial ic p a" and q: "q > 0" and "c > 0" and "b > 1" assumes "M\<le>m" assumes terminate: "terminates ic p q" shows "(\<Sum>k\<le>M. SKe ic p b q k) \<preceq> e" proof - have e_aux: "nth_digit e t b = (if t\<le>q then 1 else 0)" for t unfolding e_def E_def b_def B_def using `b>1` b_def nth_digit_gen_power_series[of "\<lambda>k. Suc 0" "c" "q"] by (auto simp: b_def B_def) have state_unique: "\<forall>k\<le>m. S ic p k t = 1 \<longrightarrow> (\<forall>j\<noteq>k. S ic p j t = 0)" for t using S_def by (induction t, auto) have h1: "\<forall>t. nth_digit (\<Sum>k\<le>M. SKe ic p b q k) t b \<le> (if t\<le>q then 1 else 0)" proof - { fix t have aux_bound_1: "(\<Sum>k\<le>M. S ic p k t') \<le> 1" for t' proof (cases "\<exists>k\<le>M. S ic p k t' = 1") case True then obtain k where k: "k\<le>M \<and> S ic p k t' = 1" by auto moreover have "\<forall>j\<le>M. j \<noteq> k \<longrightarrow> S ic p j t' = 0" using state_unique `M<=m` k S_def by (auto) (presburger) ultimately have "(\<Sum>k\<le>M. S ic p k t') = 1" using S_def by auto then show ?thesis by auto next case False then show ?thesis using S_bounded by (auto) (metis (no_types, lifting) S_def atMost_iff eq_imp_le le_SucI sum_nonpos) qed hence aux_bound_2: "\<And>t'. (\<Sum>k\<le>M. S ic p k t') < 2^c" by (metis Suc_1 `c>0` le_less_trans less_Suc_eq one_less_power) have h2: "(\<Sum>k\<le>M. SKe ic p b q k) = (\<Sum>t = 0..q. \<Sum>k\<le>M. b ^ t * S ic p k t)" unfolding SKe_def using sum.swap by auto hence "(\<Sum>k\<le>M. SKe ic p b q k) = (\<Sum>t = 0..q. b^t * (\<Sum>k\<le>M. S ic p k t))" unfolding SKe_def by (simp add: sum_distrib_left) hence "nth_digit (\<Sum>k\<le>M. SKe ic p b q k) t b = (if t\<le>q then (\<Sum>k\<le>M. S ic p k t) else 0)" using `c>0` aux_bound_2 h2 unfolding SKe_def using nth_digit_gen_power_series[of "\<lambda>t. (\<Sum>k\<le>M. S ic p k t)" "c" "q" "t"] by (smt B_def Groups.mult_ac(2) assms(7) aux_bound_1 b_def le_less_trans sum.cong) hence "nth_digit (\<Sum>k\<le>M. SKe ic p b q k) t b \<le> (if t\<le>q then 1 else 0)" using aux_bound_1 by auto } thus ?thesis by auto qed moreover have "\<forall>t>q. nth_digit (\<Sum>k\<le>M. SKe ic p b q k) t b = 0" by (metis (full_types) h1 le_0_eq not_less) ultimately have "\<forall>t. \<forall>i<Suc c. nth_digit (\<Sum>k\<le>M. SKe ic p b q k) t b \<exclamdown> i \<le> nth_digit e t b \<exclamdown> i" using aux_lt_implies_mask linorder_neqE_nat e_aux by (smt One_nat_def le_0_eq le_SucE less_or_eq_imp_le nat_zero_less_power_iff numeral_2_eq_2 zero_less_Suc) hence "\<forall>t. \<forall>i<Suc c. (\<Sum>k\<le>M. SKe ic p b q k) \<exclamdown> (Suc c * t + i) \<le> e \<exclamdown> (Suc c * t + i)" using digit_gen_pow2_reduct[where ?c = "Suc c" and ?a = "(\<Sum>k\<le>M. SKe ic p b q k)"] using digit_gen_pow2_reduct[where ?c = "Suc c" and ?a = e] by (simp add: b_def B_def) moreover have "\<forall>j. \<exists>t i. i < Suc c \<and> j = (Suc c * t + i)" using mod_less_divisor zero_less_Suc by (metis add.commute mod_mult_div_eq) ultimately have "\<forall>j. (\<Sum>k\<le>M. SKe ic p b q k) \<exclamdown> j \<le> e \<exclamdown> j" by metis thus ?thesis using masks_leq_equiv by auto qed end
\section{Usage and Examples} See the \texttt{readme} file of our repository for code structure and usage. Here we give some examples of $\lambda_Q$ program. Note that a $\lambda_Q$ program should contain at least one circuit abstraction (i.e. $\kappa$ abstraction) as its entry point, just like the main function in other programming languages. For simplicity, we assume the last circuit abstraction is the entry point. \subsection{Quantum Teleportation} This is a classical example also appeared in some other papers about quantum programming languages. It can be written in $\lambda_Q$ like follows. \begin{lstlisting}[language=Lambda] fun bell00 = / () : One . a <- gate init0 (); b <- gate init0 (); a <- gate H a; (a, b) <- gate CNOT (a, b); output (a, b) fun alice = / (q, a) : Qubit # Qubit . (q, a) <- gate CNOT (q, a); q <- gate H q; x <- gate meas q; y <- gate meas a; output (x,y) fun bob = / ((w1, w2), q) : Bit # Bit # Qubit . (x1, x2) <-| lift (w1, w2); q <- capp (if x2 then (/ t : Qubit . gate X t) else (/ t : Qubit . output t) ) to q; capp (if x1 then (/ t : Qubit . gate Z t) else (/ t : Qubit . output t) ) to q fun teleport = / () : One . q <- gate init0 (); (a, b) <- capp bell00 to (); (x, y) <- capp alice to (q, a); capp bob to ((x, y), b); \end{lstlisting} The output of the frontend is: \begin{lstlisting}[language=lambda] openqasm 2.0; qreg r0[1]; qreg r1[1]; qreg r2[1]; H r1; CX r1, r2; CX r0, r1; H r0; creg r3[1]; measure r0 -> r3; creg r4[1]; measure r1 -> r4; if (r4 == 1) X r2; if (r3 == 1) Z r2; \end{lstlisting} And the output of the backend is: \begin{lstlisting}[language=lambda] openqasm 2.0; qreg q[3]; H q[1]; CX q[1], q[2]; CX q[0], q[1]; H q[0]; creg r3[1]; measure q[0]->r3; creg r4[1]; measure q[1]->r4; if(r4 == 1) X q[2]; if(r3 == 1) Z q[2]; \end{lstlisting} There is not too much difference between IR and output because this quantum does not fit any optimization. \subsection{Simple Optimization} Here is another simple example to show the optimization power of our backend. The original $\lambda_Q$ program is: \begin{lstlisting}[language=lambda] fun qwq = / () : One . a <- gate init0 (); b <- gate init0 (); a <- gate H a; b <- gate H b; (c, d) <- gate CNOT (a, b); c <- gate H c; d <- gate H d; output (c, d) \end{lstlisting} The output of the frontend is: \begin{lstlisting}[language=lambda] openqasm 2.0; qreg r0[1]; qreg r1[1]; H r0; H r1; CX r0, r1; H r0; H r1; \end{lstlisting} And the output of the backend is: \begin{lstlisting}[language=lambda] openqasm 2.0; qreg q[2]; CX q[1], q[0]; \end{lstlisting} The optimization really works!
Formal statement is: lemma tendsto_mono: "F \<le> F' \<Longrightarrow> (f \<longlongrightarrow> l) F' \<Longrightarrow> (f \<longlongrightarrow> l) F" Informal statement is: If $F$ is a filter on a set $X$ and $F'$ is a filter on $X$ such that $F \leq F'$, then if $f$ converges to $l$ with respect to $F'$, then $f$ converges to $l$ with respect to $F$.
CD/DVD recordings of the ALl-VA Performances can be ordered. Welcome To The New VCDA!!
Formal statement is: lemma has_contour_integral_neg: "(f has_contour_integral i) g \<Longrightarrow> ((\<lambda>x. -(f x)) has_contour_integral (-i)) g" Informal statement is: If $f$ has a contour integral $i$ along a contour $g$, then $-f$ has a contour integral $-i$ along $g$.
From Test Require Import tactic. Section FOFProblem. Variable Universe : Set. Variable UniverseElement : Universe. Variable wd_ : Universe -> Universe -> Prop. Variable col_ : Universe -> Universe -> Universe -> Prop. Variable col_swap1_1 : (forall A B C : Universe, (col_ A B C -> col_ B A C)). Variable col_swap2_2 : (forall A B C : Universe, (col_ A B C -> col_ B C A)). Variable col_triv_3 : (forall A B : Universe, col_ A B B). Variable wd_swap_4 : (forall A B : Universe, (wd_ A B -> wd_ B A)). Variable col_trans_5 : (forall P Q A B C : Universe, ((wd_ P Q /\ (col_ P Q A /\ (col_ P Q B /\ col_ P Q C))) -> col_ A B C)). Theorem pipo_6 : (forall O E Eprime A B C Oprime Aprime Cprime Eprimeprime Bprimeprime C2 C3 : Universe, ((wd_ O E /\ (wd_ Oprime Eprime /\ (wd_ A O /\ (wd_ B O /\ (wd_ C O /\ (wd_ A E /\ (wd_ Eprimeprime O /\ (wd_ O Oprime /\ (wd_ B Oprime /\ (wd_ Bprimeprime O /\ (wd_ Eprimeprime A /\ (wd_ E Eprimeprime /\ (wd_ E Eprime /\ (wd_ O Eprime /\ (wd_ Oprime Eprimeprime /\ (wd_ E Oprime /\ (wd_ B Bprimeprime /\ (wd_ Eprime C2 /\ (wd_ Aprime C2 /\ (wd_ Oprime Aprime /\ (wd_ A Aprime /\ (wd_ C Cprime /\ (col_ O E A /\ (col_ O E B /\ (col_ O E C /\ (col_ Oprime Eprime Aprime /\ (col_ Oprime Eprime Oprime /\ (col_ Oprime Eprime Cprime /\ (col_ O Eprimeprime Bprimeprime /\ (col_ O Eprimeprime Oprime /\ (col_ O Eprimeprime C2 /\ (col_ O B Oprime /\ (col_ Oprime B Oprime /\ col_ O Eprimeprime C3))))))))))))))))))))))))))))))))) -> col_ Oprime O E)). Proof. time tac. Qed. End FOFProblem.
module Graphs import Base.add abstract Value type Node value::Value refs::Set{Node} replacement::Union{Node,Nothing} Node(value) = new(value, Set{Node}(), nothing) end type Graph nodes::Dict{Value, Node} Graph() = new(Dict{Value,Node}()) end add(g::Graph, v::Value) = (has(g.nodes, v) ? g.nodes[v] : g.nodes[v] = Node(v)) function subs!(g::Graph, from::Value, to::Value) has(g.nodes, from) ? subs!(g, g.nodes[from], to) : nothing end function subs!(g::Graph, from::Node, to_value::Value) if has(g.nodes, to_value) subs!(g, from, g.nodes[to_value]) else from.value = to_value g.nodes[to_value] = from return end end function subs!(g::Graph, from::Node, to::Node) from.replacement = to g.nodes[from.value] = to # replace from with to in all references to from for refnode in from.refs subs!(g, refnode, subs(refnode.value, from, to)) end add_each(to.refs, from.refs) end end # module
If $f$ is continuous on the closed segment from $a$ to $b$, then the contour integral of $f$ along the line segment from $a$ to $b$ is equal to the negative of the contour integral of $f$ along the line segment from $b$ to $a$.