Datasets:
AI4M
/

text
stringlengths
0
3.34M
(* Title: Examples/SML_Relativization/Algebra/SML_Groups.thy Author: Mihails Milehins Copyright 2021 (C) Mihails Milehins *) section\<open>Relativization of the results about groups\<close> theory SML_Groups imports SML_Monoids begin subsection\<open>Simple groups\<close> subsubsection\<open>Definitions and common properties\<close> locale group_ow = semigroup_ow U f for U :: "'ag set" and f + fixes z (\<open>\<^bold>1\<^sub>o\<^sub>w\<close>) and inverse :: "'ag \<Rightarrow> 'ag" assumes z_closed[simp]: "\<^bold>1\<^sub>o\<^sub>w \<in> U" and inverse_closed[simp]: "a \<in> U \<Longrightarrow> inverse a \<in> U" and group_left_neutral: "a \<in> U \<Longrightarrow> \<^bold>1\<^sub>o\<^sub>w \<^bold>*\<^sub>o\<^sub>w a = a" and left_inverse[simp]: "a \<in> U \<Longrightarrow> inverse a \<^bold>*\<^sub>o\<^sub>w a = \<^bold>1\<^sub>o\<^sub>w" begin notation z (\<open>\<^bold>1\<^sub>o\<^sub>w\<close>) lemma inverse_closed': "inverse ` U \<subseteq> U" by auto lemma inverse_closed'': "\<forall>x\<in>U. inverse x \<in> U" by auto lemma left_cancel: assumes "a \<in> U" and "b \<in> U" and "c \<in> U" shows "a \<^bold>*\<^sub>o\<^sub>w b = a \<^bold>*\<^sub>o\<^sub>w c \<longleftrightarrow> b = c" proof assume "a \<^bold>*\<^sub>o\<^sub>w b = a \<^bold>*\<^sub>o\<^sub>w c" then have "inverse a \<^bold>*\<^sub>o\<^sub>w (a \<^bold>*\<^sub>o\<^sub>w b) = inverse a \<^bold>*\<^sub>o\<^sub>w (a \<^bold>*\<^sub>o\<^sub>w c)" by simp with assms have "(inverse a \<^bold>*\<^sub>o\<^sub>w a) \<^bold>*\<^sub>o\<^sub>w b = (inverse a \<^bold>*\<^sub>o\<^sub>w a) \<^bold>*\<^sub>o\<^sub>w c" by (metis assoc inverse_closed) with assms show "b = c" using group_ow_axioms by (fastforce simp: group_ow.group_left_neutral) qed simp sublocale monoid_ow U \<open>(\<^bold>*\<^sub>o\<^sub>w)\<close> \<open>\<^bold>1\<^sub>o\<^sub>w\<close> proof show "a \<in> U \<Longrightarrow> a \<^bold>*\<^sub>o\<^sub>w \<^bold>1\<^sub>o\<^sub>w = a" for a proof- assume "a \<in> U" with left_inverse[OF this] have "inverse a \<^bold>*\<^sub>o\<^sub>w (a \<^bold>*\<^sub>o\<^sub>w \<^bold>1\<^sub>o\<^sub>w) = inverse a \<^bold>*\<^sub>o\<^sub>w a" by (metis assoc group_left_neutral inverse_closed z_closed) with \<open>a \<in> U\<close> z_closed show "a \<^bold>*\<^sub>o\<^sub>w \<^bold>1\<^sub>o\<^sub>w = a" by (meson left_cancel f_closed inverse_closed) qed qed (simp add: group_left_neutral)+ lemma inverse_image[simp]: "inverse ` U \<subseteq> U" by (simp add: image_subsetI) end lemma group_ow: "group = group_ow UNIV" unfolding group_def group_ow_def group_axioms_def group_ow_axioms_def semigroup_ow by simp locale uminus_ow = fixes U :: "'ag set" and uminus :: "'ag \<Rightarrow> 'ag" (\<open>-\<^sub>o\<^sub>w _\<close> [81] 80) assumes uminus_closed: "a \<in> U \<Longrightarrow> -\<^sub>o\<^sub>w a \<in> U" begin notation uminus (\<open>-\<^sub>o\<^sub>w _\<close> [81] 80) lemma uminus_closed': "uminus ` U \<subseteq> U" by (auto simp: uminus_closed) lemma uminus_closed'': "\<forall>a\<in>U. -\<^sub>o\<^sub>w a \<in> U" by (simp add: uminus_closed) tts_register_sbts uminus | U by (rule tts_AB_transfer[OF uminus_closed']) end locale group_add_ow = minus_ow U minus + uminus_ow U uminus + monoid_add_ow U plus zero for U :: "'ag set" and minus plus zero uminus + assumes left_inverse: "a \<in> U \<Longrightarrow> (-\<^sub>o\<^sub>w a) +\<^sub>o\<^sub>w a = 0\<^sub>o\<^sub>w" and add_inv_conv_diff: "\<lbrakk> a \<in> U; b \<in> U \<rbrakk> \<Longrightarrow> a +\<^sub>o\<^sub>w (-\<^sub>o\<^sub>w b) = a -\<^sub>o\<^sub>w b" begin sublocale add: group_ow U \<open>(+\<^sub>o\<^sub>w)\<close> \<open>0\<^sub>o\<^sub>w\<close> uminus by unfold_locales (auto simp: uminus_closed left_inverse) lemma inverse_unique: assumes "a \<in> U" and "b \<in> U" and "a +\<^sub>o\<^sub>w b = 0\<^sub>o\<^sub>w" shows "-\<^sub>o\<^sub>w a = b" proof- from assms have "(-\<^sub>o\<^sub>w a +\<^sub>o\<^sub>w a) +\<^sub>o\<^sub>w b = -\<^sub>o\<^sub>w a" by (metis add.assoc uminus_closed add.right_neutral_mow) thus ?thesis unfolding left_inverse[OF \<open>a \<in> U\<close>] add.left_neutral_mow[OF \<open>b \<in> U\<close>] by simp qed lemma inverse_neutral[simp]: "-\<^sub>o\<^sub>w 0\<^sub>o\<^sub>w = 0\<^sub>o\<^sub>w" by ( rule inverse_unique[ OF zero_closed zero_closed add.left_neutral_mow[OF zero_closed] ] ) lemma inverse_inverse: assumes "a \<in> U" shows "-\<^sub>o\<^sub>w (-\<^sub>o\<^sub>w a) = a" by ( rule inverse_unique[ OF uminus_closed[OF assms] assms left_inverse[OF assms] ] ) lemma right_inverse: assumes "a \<in> U" shows "a +\<^sub>o\<^sub>w (-\<^sub>o\<^sub>w a) = 0\<^sub>o\<^sub>w" proof - from assms have "a +\<^sub>o\<^sub>w (-\<^sub>o\<^sub>w a) = -\<^sub>o\<^sub>w (-\<^sub>o\<^sub>w a) +\<^sub>o\<^sub>w (-\<^sub>o\<^sub>w a)" by (simp add: inverse_inverse) moreover have "\<dots> = 0\<^sub>o\<^sub>w" by (rule left_inverse[OF uminus_closed[OF assms]]) ultimately show ?thesis by simp qed sublocale cancel_semigroup_add_ow U \<open>(+\<^sub>o\<^sub>w)\<close> proof fix a b c assume "a \<in> U" and "b \<in> U" and "c \<in> U" and "a +\<^sub>o\<^sub>w b = a +\<^sub>o\<^sub>w c" from \<open>a \<in> U\<close> \<open>b \<in> U\<close> \<open>c \<in> U\<close> this have "((-\<^sub>o\<^sub>w a) +\<^sub>o\<^sub>w a) +\<^sub>o\<^sub>w b = ((-\<^sub>o\<^sub>w a) +\<^sub>o\<^sub>w a) +\<^sub>o\<^sub>w c" by (auto simp: add.left_cancel) thus "b = c" unfolding left_inverse[OF \<open>a \<in> U\<close>] add.left_neutral_mow[OF \<open>b \<in> U\<close>] add.left_neutral_mow[OF \<open>c \<in> U\<close>] by simp next fix a b c assume "a \<in> U" and "b \<in> U" and "c \<in> U" and "b +\<^sub>o\<^sub>w a = c +\<^sub>o\<^sub>w a" then have "b +\<^sub>o\<^sub>w (a +\<^sub>o\<^sub>w (-\<^sub>o\<^sub>w a)) = c +\<^sub>o\<^sub>w (a +\<^sub>o\<^sub>w (-\<^sub>o\<^sub>w a))" by (metis add.assoc uminus_closed) thus "b = c" unfolding right_inverse[OF \<open>a \<in> U\<close>] add.left_neutral_mow[OF \<open>b \<in> U\<close>] add.right_neutral_mow[OF \<open>c \<in> U\<close>] by (simp add: \<open>b \<in> U\<close>) qed end lemma group_add_ow: "class.group_add = group_add_ow UNIV" unfolding class.group_add_def group_add_ow_def class.group_add_axioms_def group_add_ow_axioms_def minus_ow_def uminus_ow_def monoid_add_ow by simp subsubsection\<open>Transfer rules\<close> context includes lifting_syntax begin lemma group_transfer[transfer_rule]: assumes [transfer_rule]: "bi_unique A" "right_total A" shows "((A ===> A ===> A) ===> A ===> (A ===> A) ===> (=)) (group_ow (Collect (Domainp A))) group" proof - let ?P = "((A ===> A ===> A) ===> A ===> (A ===> A) ===> (=))" let ?group_ow = "group_ow (Collect (Domainp A))" have "?P (\<lambda>f z inv. ?group_ow f z inv) (\<lambda>f z inv. z \<in> UNIV \<and> (\<forall>x\<in>UNIV. inv x \<in> UNIV) \<and> group f z inv)" unfolding group_ow_def group_def group_ow_axioms_def group_axioms_def apply transfer_prover_start apply transfer_step+ by blast thus ?thesis by simp qed lemma group_add_transfer[transfer_rule]: assumes [transfer_rule]: "bi_unique A" "right_total A" shows "((A ===> A ===> A) ===> (A ===> A ===> A) ===> A ===> (A ===> A) ===> (=)) (group_add_ow (Collect (Domainp A))) class.group_add" proof - let ?P = "((A ===> A ===> A) ===> (A ===> A ===> A) ===> A ===> (A ===> A) ===> (=))" let ?group_add_ow = "group_add_ow (Collect (Domainp A))" have "?P (\<lambda>minus plus zero uminus. ?group_add_ow minus plus zero uminus) ( \<lambda>fi f z inv_f. (\<forall>x\<in>UNIV. \<forall>y\<in>UNIV. fi x y \<in> UNIV) \<and> (\<forall>x\<in>UNIV. inv_f x \<in> UNIV) \<and> class.group_add fi f z inv_f )" unfolding group_add_ow_def class.group_add_def group_add_ow_axioms_def class.group_add_axioms_def minus_ow_def uminus_ow_def apply transfer_prover_start apply transfer_step+ by simp thus ?thesis by simp qed end subsubsection\<open>Relativization\<close> context group_ow begin tts_context tts: (?'a to U) rewriting ctr_simps substituting group_ow_axioms and not_empty applying [OF f_closed' z_closed inverse_closed''] begin tts_lemma inverse_neutral: "inverse \<^bold>1\<^sub>o\<^sub>w = \<^bold>1\<^sub>o\<^sub>w" is group.inverse_neutral. tts_lemma inverse_inverse: assumes "a \<in> U" shows "inverse (inverse a) = a" is group.inverse_inverse. tts_lemma right_inverse: assumes "a \<in> U" shows "a \<^bold>*\<^sub>o\<^sub>w inverse a = \<^bold>1\<^sub>o\<^sub>w" is group.right_inverse. tts_lemma inverse_distrib_swap: assumes "a \<in> U" and "b \<in> U" shows "inverse (a \<^bold>*\<^sub>o\<^sub>w b) = inverse b \<^bold>*\<^sub>o\<^sub>w inverse a" is group.inverse_distrib_swap. tts_lemma right_cancel: assumes "b \<in> U" and "a \<in> U" and "c \<in> U" shows "(b \<^bold>*\<^sub>o\<^sub>w a = c \<^bold>*\<^sub>o\<^sub>w a) = (b = c)" is group.right_cancel. tts_lemma inverse_unique: assumes "a \<in> U" and "b \<in> U" and "a \<^bold>*\<^sub>o\<^sub>w b = \<^bold>1\<^sub>o\<^sub>w" shows "inverse a = b" is group.inverse_unique. end end context group_add_ow begin tts_context tts: (?'a to U) rewriting ctr_simps substituting group_add_ow_axioms and zero.not_empty applying [OF minus_closed' plus_closed' zero_closed add.inverse_closed''] begin tts_lemma diff_0: assumes "a \<in> U" shows "0\<^sub>o\<^sub>w -\<^sub>o\<^sub>w a = -\<^sub>o\<^sub>w a" is group_add_class.diff_0. tts_lemma diff_0_right: assumes "a \<in> U" shows "a -\<^sub>o\<^sub>w 0\<^sub>o\<^sub>w = a" is group_add_class.diff_0_right. tts_lemma diff_self: assumes "a \<in> U" shows "a -\<^sub>o\<^sub>w a = 0\<^sub>o\<^sub>w" is group_add_class.diff_self. tts_lemma group_left_neutral: assumes "a \<in> U" shows "0\<^sub>o\<^sub>w +\<^sub>o\<^sub>w a = a" is group_add_class.add.group_left_neutral. tts_lemma minus_minus: assumes "a \<in> U" shows "-\<^sub>o\<^sub>w (-\<^sub>o\<^sub>w a) = a" is group_add_class.minus_minus. tts_lemma right_minus: assumes "a \<in> U" shows "a +\<^sub>o\<^sub>w -\<^sub>o\<^sub>w a = 0\<^sub>o\<^sub>w" is group_add_class.right_minus. tts_lemma left_minus: assumes "a \<in> U" shows "-\<^sub>o\<^sub>w a +\<^sub>o\<^sub>w a = 0\<^sub>o\<^sub>w" is group_add_class.left_minus. tts_lemma add_diff_cancel: assumes "a \<in> U" and "b \<in> U" shows "a +\<^sub>o\<^sub>w b -\<^sub>o\<^sub>w b = a" is group_add_class.add_diff_cancel. tts_lemma diff_add_cancel: assumes "a \<in> U" and "b \<in> U" shows "a -\<^sub>o\<^sub>w b +\<^sub>o\<^sub>w b = a" is group_add_class.diff_add_cancel. tts_lemma diff_conv_add_uminus: assumes "a \<in> U" and "b \<in> U" shows "a -\<^sub>o\<^sub>w b = a +\<^sub>o\<^sub>w -\<^sub>o\<^sub>w b" is group_add_class.diff_conv_add_uminus. tts_lemma diff_minus_eq_add: assumes "a \<in> U" and "b \<in> U" shows "a -\<^sub>o\<^sub>w -\<^sub>o\<^sub>w b = a +\<^sub>o\<^sub>w b" is group_add_class.diff_minus_eq_add. tts_lemma add_uminus_conv_diff: assumes "a \<in> U" and "b \<in> U" shows "a +\<^sub>o\<^sub>w -\<^sub>o\<^sub>w b = a -\<^sub>o\<^sub>w b" is group_add_class.add_uminus_conv_diff. tts_lemma minus_diff_eq: assumes "a \<in> U" and "b \<in> U" shows "-\<^sub>o\<^sub>w (a -\<^sub>o\<^sub>w b) = b -\<^sub>o\<^sub>w a" is group_add_class.minus_diff_eq. tts_lemma add_minus_cancel: assumes "a \<in> U" and "b \<in> U" shows "a +\<^sub>o\<^sub>w (-\<^sub>o\<^sub>w a +\<^sub>o\<^sub>w b) = b" is group_add_class.add_minus_cancel. tts_lemma minus_add_cancel: assumes "a \<in> U" and "b \<in> U" shows "-\<^sub>o\<^sub>w a +\<^sub>o\<^sub>w (a +\<^sub>o\<^sub>w b) = b" is group_add_class.minus_add_cancel. tts_lemma neg_0_equal_iff_equal: assumes "a \<in> U" shows "(0\<^sub>o\<^sub>w = -\<^sub>o\<^sub>w a) = (0\<^sub>o\<^sub>w = a)" is group_add_class.neg_0_equal_iff_equal. tts_lemma neg_equal_0_iff_equal: assumes "a \<in> U" shows "(-\<^sub>o\<^sub>w a = 0\<^sub>o\<^sub>w) = (a = 0\<^sub>o\<^sub>w)" is group_add_class.neg_equal_0_iff_equal. tts_lemma eq_iff_diff_eq_0: assumes "a \<in> U" and "b \<in> U" shows "(a = b) = (a -\<^sub>o\<^sub>w b = 0\<^sub>o\<^sub>w)" is group_add_class.eq_iff_diff_eq_0. tts_lemma equation_minus_iff: assumes "a \<in> U" and "b \<in> U" shows "(a = -\<^sub>o\<^sub>w b) = (b = -\<^sub>o\<^sub>w a)" is group_add_class.equation_minus_iff. tts_lemma minus_equation_iff: assumes "a \<in> U" and "b \<in> U" shows "(-\<^sub>o\<^sub>w a = b) = (-\<^sub>o\<^sub>w b = a)" is group_add_class.minus_equation_iff. tts_lemma neg_equal_iff_equal: assumes "a \<in> U" and "b \<in> U" shows "(-\<^sub>o\<^sub>w a = -\<^sub>o\<^sub>w b) = (a = b)" is group_add_class.neg_equal_iff_equal. tts_lemma right_minus_eq: assumes "a \<in> U" and "b \<in> U" shows "(a -\<^sub>o\<^sub>w b = 0\<^sub>o\<^sub>w) = (a = b)" is group_add_class.right_minus_eq. tts_lemma minus_add: assumes "a \<in> U" and "b \<in> U" shows "-\<^sub>o\<^sub>w (a +\<^sub>o\<^sub>w b) = -\<^sub>o\<^sub>w b +\<^sub>o\<^sub>w -\<^sub>o\<^sub>w a" is group_add_class.minus_add. tts_lemma eq_neg_iff_add_eq_0: assumes "a \<in> U" and "b \<in> U" shows "(a = -\<^sub>o\<^sub>w b) = (a +\<^sub>o\<^sub>w b = 0\<^sub>o\<^sub>w)" is group_add_class.eq_neg_iff_add_eq_0. tts_lemma neg_eq_iff_add_eq_0: assumes "a \<in> U" and "b \<in> U" shows "(-\<^sub>o\<^sub>w a = b) = (a +\<^sub>o\<^sub>w b = 0\<^sub>o\<^sub>w)" is group_add_class.neg_eq_iff_add_eq_0. tts_lemma add_eq_0_iff2: assumes "a \<in> U" and "b \<in> U" shows "(a +\<^sub>o\<^sub>w b = 0\<^sub>o\<^sub>w) = (a = -\<^sub>o\<^sub>w b)" is group_add_class.add_eq_0_iff2. tts_lemma add_eq_0_iff: assumes "a \<in> U" and "b \<in> U" shows "(a +\<^sub>o\<^sub>w b = 0\<^sub>o\<^sub>w) = (b = -\<^sub>o\<^sub>w a)" is group_add_class.add_eq_0_iff. tts_lemma diff_diff_eq2: assumes "a \<in> U" and "b \<in> U" and "c \<in> U" shows "a -\<^sub>o\<^sub>w (b -\<^sub>o\<^sub>w c) = a +\<^sub>o\<^sub>w c -\<^sub>o\<^sub>w b" is group_add_class.diff_diff_eq2. tts_lemma diff_add_eq_diff_diff_swap: assumes "a \<in> U" and "b \<in> U" and "c \<in> U" shows "a -\<^sub>o\<^sub>w (b +\<^sub>o\<^sub>w c) = a -\<^sub>o\<^sub>w c -\<^sub>o\<^sub>w b" is group_add_class.diff_add_eq_diff_diff_swap. tts_lemma add_diff_eq: assumes "a \<in> U" and "b \<in> U" and "c \<in> U" shows "a +\<^sub>o\<^sub>w (b -\<^sub>o\<^sub>w c) = a +\<^sub>o\<^sub>w b -\<^sub>o\<^sub>w c" is group_add_class.add_diff_eq. tts_lemma eq_diff_eq: assumes "a \<in> U" and "c \<in> U" and "b \<in> U" shows "(a = c -\<^sub>o\<^sub>w b) = (a +\<^sub>o\<^sub>w b = c)" is group_add_class.eq_diff_eq. tts_lemma diff_eq_eq: assumes "a \<in> U" and "b \<in> U" and "c \<in> U" shows "(a -\<^sub>o\<^sub>w b = c) = (a = c +\<^sub>o\<^sub>w b)" is group_add_class.diff_eq_eq. tts_lemma left_cancel: assumes "a \<in> U" and "b \<in> U" and "c \<in> U" shows "(a +\<^sub>o\<^sub>w b = a +\<^sub>o\<^sub>w c) = (b = c)" is group_add_class.add.left_cancel. tts_lemma right_cancel: assumes "b \<in> U" and "a \<in> U" and "c \<in> U" shows "(b +\<^sub>o\<^sub>w a = c +\<^sub>o\<^sub>w a) = (b = c)" is group_add_class.add.right_cancel. tts_lemma minus_unique: assumes "a \<in> U" and "b \<in> U" and "a +\<^sub>o\<^sub>w b = 0\<^sub>o\<^sub>w" shows "-\<^sub>o\<^sub>w a = b" is group_add_class.minus_unique. tts_lemma diff_eq_diff_eq: assumes "a \<in> U" and "b \<in> U" and "c \<in> U" and "d \<in> U" and "a -\<^sub>o\<^sub>w b = c -\<^sub>o\<^sub>w d" shows "(a = b) = (c = d)" is group_add_class.diff_eq_diff_eq. end end subsection\<open>Abelian groups\<close> subsubsection\<open>Definitions and common properties\<close> locale ab_group_add_ow = minus_ow U minus + uminus_ow U uminus + comm_monoid_add_ow U plus zero for U :: "'ag set" and plus zero minus uminus + assumes ab_left_minus: "a \<in> U \<Longrightarrow> -\<^sub>o\<^sub>w a +\<^sub>o\<^sub>w a = 0\<^sub>o\<^sub>w" assumes ab_diff_conv_add_uminus: "\<lbrakk> a \<in> U; b \<in> U \<rbrakk> \<Longrightarrow> a -\<^sub>o\<^sub>w b = a +\<^sub>o\<^sub>w (-\<^sub>o\<^sub>w b)" begin sublocale group_add_ow by unfold_locales (simp_all add: ab_left_minus ab_diff_conv_add_uminus) sublocale cancel_comm_monoid_add_ow apply unfold_locales subgoal using add.commute by (fastforce simp: add_diff_cancel) subgoal by (metis add.commute diff_add_eq_diff_diff_swap) done end lemma ab_group_add_ow: "class.ab_group_add = ab_group_add_ow UNIV" unfolding class.ab_group_add_def ab_group_add_ow_def class.ab_group_add_axioms_def ab_group_add_ow_axioms_def minus_ow_def uminus_ow_def comm_monoid_add_ow by simp lemma ab_group_add_ow_UNIV_axioms: "ab_group_add_ow (UNIV::'a::ab_group_add set) (+) 0 (-) uminus" by (fold ab_group_add_ow) (rule ab_group_add_class.ab_group_add_axioms) subsubsection\<open>Transfer rules\<close> context includes lifting_syntax begin lemma ab_group_add_transfer[transfer_rule]: assumes [transfer_rule]: "bi_unique A" "right_total A" shows "((A ===> A ===> A) ===> A ===> (A ===> A ===> A) ===> (A ===> A) ===> (=)) (ab_group_add_ow (Collect (Domainp A))) class.ab_group_add" proof - let ?P = "((A ===> A ===> A) ===> A ===> (A ===> A ===> A) ===> (A ===> A) ===> (=))" let ?ab_group_add_ow = "ab_group_add_ow (Collect (Domainp A))" have "?P ?ab_group_add_ow ( \<lambda>plus zero minus uminus. (\<forall>x\<in>UNIV. \<forall>y\<in>UNIV. minus x y \<in> UNIV) \<and> (\<forall>x\<in>UNIV. uminus x \<in> UNIV) \<and> class.ab_group_add plus zero minus uminus )" unfolding ab_group_add_ow_def class.ab_group_add_def ab_group_add_ow_axioms_def class.ab_group_add_axioms_def minus_ow_def uminus_ow_def apply transfer_prover_start apply transfer_step+ by simp thus ?thesis by simp qed end subsubsection\<open>Relativization\<close> context ab_group_add_ow begin tts_context tts: (?'a to U) rewriting ctr_simps substituting ab_group_add_ow_axioms and zero.not_empty applying [OF plus_closed' zero_closed minus_closed' add.inverse_closed''] begin tts_lemma uminus_add_conv_diff: assumes "a \<in> U" and "b \<in> U" shows "-\<^sub>o\<^sub>w a +\<^sub>o\<^sub>w b = b -\<^sub>o\<^sub>w a" is ab_group_add_class.uminus_add_conv_diff. tts_lemma diff_add_eq: assumes "a \<in> U" and "b \<in> U" and "c \<in> U" shows "a -\<^sub>o\<^sub>w b +\<^sub>o\<^sub>w c = a +\<^sub>o\<^sub>w c -\<^sub>o\<^sub>w b" is ab_group_add_class.diff_add_eq. end end text\<open>\newpage\<close> end
[STATEMENT] lemma StepConf_EmptySet [simp]: "StepConf A C {} = C" [PROOF STATE] proof (prove) goal (1 subgoal): 1. StepConf A C {} = C [PROOF STEP] by (unfold StepConf_def, auto)
import .reverse set_option trace.simplify.rewrite true #print reverse_right open list(nil) -- axiom append.base (x : α) : append nil x = [x] -- axiom append.step (x y : α) (xs : list α) : -- append (x :: xs) y = x :: append xs y -- axiom reverse.base : reverse nil = nil -- axiom reverse.step (x : α) (xs : list α) : -- reverse (x :: xs) = append (reverse xs) x axiom reverse2.base : reverse2 nil = nil -- nil ~ [] axiom reverse2.step (x y : α) (xs : list α) : reverse2 (append (x :: xs) y) = append (y :: reverse2 xs) x attribute [simp] reverse2.base reverse2.step -- how to prove that reverse2.single is not provable if we have only two axioms: -- reverse2.base, reverse.step + append axioms @[simp] lemma reverse2.single (x : α) : reverse2 [x] = [x] := begin type_check append.base x, type_check append.step x x [], conv { to_lhs, rw ←append.base, }, sorry, end lemma reverse2_right (x : α) (xs : list α) : reverse2 (append xs x) = x :: reverse2 xs := begin induction xs with y ys ih, { simp }, -- rw append.step, rw reverse2.step, rw ←ih, sorry, end theorem reverse_and_reverse2_are_equivalent (xs : list α) : reverse xs = reverse2 xs := begin induction xs with y ys ih, { simp, }, { simp [ih], induction ys with z zs ih2, { simp }, sorry, }, end
record R (A : Set) : Set where constructor c₂ field f : A → A open module R′ (A : Set) (r : R A) = R {A = A} r renaming (f to f′) _ : (@0 A : Set) → R A → A → A _ = λ A → f′ {A = A}
# Copyright (c) 2018-2021, Carnegie Mellon University # See LICENSE for details Latex := x -> Cond(IsRec(x) and IsBound(x.latex), x.latex(), IsRec(x) and IsBound(x.cprint), x.cprint(), Print(x)); Cprint := x -> When(IsRec(x) and IsBound(x.cprint), x.cprint(), Print(x)); _infix_print := function ( lst, sep, prfunc ) local first, c; first := true; for c in lst do if first then first := false; else Print(sep); fi; prfunc(c); od; return ""; end; Gath.latex := self >> Print("\\Gath{", self.func.latex(), "}"); Scat.latex := self >> Print("\\Scat{", self.func.latex(), "}"); Diag.latex := self >> Print("\\Diag{", self.element.latex(), "}"); Prm.latex := self >> Print("\\Prm{", self.func.latex(), "}"); FuncClass.latex := self >> Print("\\f", self.name, DoForAll(self.params, p -> Print("{",Cprint(p),"}"))); FDataOfs.latex := self >> Print("\\f", self.name, DoForAll(self.rChildren(), p -> Print("{",Cprint(p),"}"))); HH.latex := self >> PrintEvalF("\\f$1{$2}{$3}{$4}{$5}", self.name, ()->Latex(self.params[1]), ()->Latex(self.params[2]), ()->Latex(self.params[3]), ()->_infix_print(self.params[4],", ",Latex)); BHH.latex := self >> PrintEvalF("\\f$1{$2}{$3}{$4}{$5}", self.name, ()->Cprint(self.params[1]), ()->Cprint(self.params[2]), ()->Cprint(self.params[3]), ()->_infix_print(self.params[4],", ",Cprint)); HHZ.latex := self >> PrintEvalF("\\f$1{$2}{$3}{$4}{$5}", self.name, ()->Cprint(self.params[1]), ()->Cprint(self.params[2]), ()->Cprint(self.params[3]), ()->_infix_print(self.params[4],", ", Cprint)); NonTerminal.latex := self >> Print("\\n", self.name, DoForAll(self.params, p -> Print("{",Latex(p),"}"))); Sym.latex := FuncClass.latex; ISum.latex := self >> PrintEvalF("\\ISum{$1 0}{$2}{$3}", () -> When(IsBound(self.var), Print(self.var, "=")), () -> Latex(self.domain-1), () -> self.child(1).latex()); Compose.latex := self >> DoForAll(self.children(), c->c.latex()); BaseContainer.latex := self >> PrintEvalF("\\$1{$2}", self.name, ()->self.child(1).latex()); BaseOperation.latex := self >> Print("\\", self.name, DoForAll(self.children(), c->Print("{",c.latex(),"}"))); SUM.latex := self >> Chain( DoForAllButLast(self.children(), c->Print(c.latex(), "+")), Last(self.children()).latex()); gammaTensor.latex := self >> InfixPrint(self.children(), "\\boxtimes", c->c.latex()); fTensor.latex := self >> InfixPrint(self.children(), "\\otimes", c->c.latex()); fDirsum.latex := self >> InfixPrint(self.children(), "\\oplus", c->c.latex()); fCompose.latex := self >> InfixPrint(self.children(), "\\circ", c->c.latex()); Blk.latex := self >> self.print(0,0);
import field_definition import field_results import numbers import roots def quadratic_subst (f : Type) [myfld f] : f -> f -> f -> f -> f | x a b c := (a .* (x .* x)) .+ ((b .* x) .+ c) lemma complete_the_square (f : Type) [myfld f] (x b : f) : (x .* x) .+ (((two f) .* b) .* x) = (square f (x .+ b)) .+ (.- (square f b)) := begin unfold square, unfold two, rw distrib_simp, rw distrib_simp_alt, repeat {rw distrib_simp}, rw one_mul, repeat {rw <- myfld.add_assoc _ _ _}, rw myfld.add_negate _, rw zero_simp f _, rw myfld.mul_comm x b, end lemma multiply_out_squared (f : Type) [myfld f] (x a : f) : (square f (x .+ a)) = ((square f x) .+ (((two f) .* (a .* x)) .+ (square f a))) := begin unfold square, unfold two, repeat {rw distrib_simp f _ _ _}, repeat {rw distrib_simp_alt f _ _ _}, rw one_mul_simp f _, rw myfld.mul_comm a x, repeat {rw myfld.add_assoc _ _ _}, end def quadratic_formula (f : Type) [myfld f] [fld_with_sqrt f] [fld_not_char_two f] (a b c : f) (a_ne_zero : a ≠ myfld.zero) := (.- b .+ (sqroot ((b .* b) .+ (.- ((four f) .* (a .* c)))))) .* (myfld.reciprocal ((two f) .* a) (mul_nonzero f (two f) a (two_ne_zero f) a_ne_zero)) /- The proof of the correctness of the quadratic formula starts here. The proof is split into a couple of different sections so that they can be reused when it comes time to prove that negating the square root still gives a correct formula.-/ /- This first section does all the work between unfolding the formula and multiplying the square root by itself.-/ lemma quadratic_formula_sub_proof_a (f : Type) [myfld f] [fld_with_sqrt f] [fld_not_char_two f] (a b c sqrt : f) (a_ne_zero : a ≠ myfld.zero) : (((a .* (((.- b) .* (myfld.reciprocal ((two f) .* a) (mul_nonzero f (two f) a (two_ne_zero f) a_ne_zero))) .* ((.- b) .* (myfld.reciprocal ((two f) .* a) (mul_nonzero f (two f) a (two_ne_zero f) a_ne_zero))))) .+ (a .* (((.- b) .* (myfld.reciprocal ((two f) .* a) (mul_nonzero f (two f) a (two_ne_zero f) a_ne_zero))) .* (sqrt .* (myfld.reciprocal ((two f) .* a) (mul_nonzero f (two f) a (two_ne_zero f) a_ne_zero)))))) .+ ((a .* ((sqrt .* (myfld.reciprocal ((two f) .* a) (mul_nonzero f (two f) a (two_ne_zero f) a_ne_zero))) .* ((.- b) .* (myfld.reciprocal ((two f) .* a) (mul_nonzero f (two f) a (two_ne_zero f) a_ne_zero))))) .+ (a .* ((sqrt .* (myfld.reciprocal ((two f) .* a) (mul_nonzero f (two f) a (two_ne_zero f) a_ne_zero))) .* (sqrt .* (myfld.reciprocal ((two f) .* a) (mul_nonzero f (two f) a (two_ne_zero f) a_ne_zero))))))) .+ (((b .* ((.- b) .* (myfld.reciprocal ((two f) .* a) (mul_nonzero f (two f) a (two_ne_zero f) a_ne_zero)))) .+ (b .* (sqrt .* (myfld.reciprocal ((two f) .* a) (mul_nonzero f (two f) a (two_ne_zero f) a_ne_zero))))) .+ c) = c .+ ((myfld.reciprocal ((two f) .* a) (mul_nonzero f (two f) a (two_ne_zero f) a_ne_zero)) .* ((b .* (b .* (myfld.reciprocal (two f) (two_ne_zero f)))) .+ ((sqrt .* ((myfld.reciprocal (two f) (two_ne_zero f)) .* sqrt)) .+ ((.- b) .* b)))) := begin /- First we can cancel inside some terms that have a * 1/2a.-/ rw myfld.mul_comm _ (myfld.reciprocal ((two f) .* a) _), repeat {rw <- myfld.mul_assoc (myfld.reciprocal ((two f) .* a) _) _ _}, repeat {rw myfld.mul_assoc a (myfld.reciprocal ((two f) .* a) _) _}, rw myfld.mul_comm sqrt (myfld.reciprocal ((two f) .* a) _), rw <- myfld.mul_assoc (myfld.reciprocal ((two f) .* a) _) sqrt _, rw myfld.mul_assoc a (myfld.reciprocal ((two f) .* a) _) _, have cancel_a : (a .* (myfld.reciprocal ((two f) .* a) _)) = (myfld.reciprocal (two f) (two_ne_zero f)), rw split_reciprocal f (two f) a _, rw only_one_reciprocal f (two f) _ (two_ne_zero f), rw myfld.mul_comm (myfld.reciprocal (two f) _) (myfld.reciprocal a _), rw myfld.mul_assoc, rw myfld.mul_reciprocal a _, rw myfld.mul_comm _ _, rw <- myfld.mul_one (myfld.reciprocal (two f) (two_ne_zero f)), rw cancel_a, /- There are two terms consisting of 1/2 * (-b) * 1/2a * sqrt (det) . We can add these together into a single (-b) * 1/2a * sqrt (det) term.-/ rw myfld.mul_assoc sqrt (myfld.reciprocal ((two f) .* a) _) (.- b), rw myfld.mul_comm (sqrt .* (myfld.reciprocal ((two f) .* a) _)) (.- b), rw myfld.mul_comm sqrt (myfld.reciprocal ((two f) .* a) _), rw assoc_tree f _ ((myfld.reciprocal (two f) _) .* ((.- b) .* ((myfld.reciprocal ((two f) .* a) _) .* sqrt))) ((myfld.reciprocal (two f) _) .* ((.- b) .* ((myfld.reciprocal ((two f) .* a) _) .* sqrt))) _, rw <- distrib_simp f (myfld.reciprocal (two f) _) _ _, rw only_one_reciprocal f (two f) _ (two_ne_zero f), rw add_two_halves f, rw one_mul f _, /- (-b) * 1/2a * sqrt (det) cancels with b * 1/2a * sqrt (det) -/ repeat {rw mul_negate f b _}, rw myfld.add_comm (.- (b .* ((myfld.reciprocal ((two f) .* a) _) .* sqrt))) (a .* (((myfld.reciprocal ((two f) .* a) _) .* sqrt) .* ((myfld.reciprocal ((two f) .* a) _) .* sqrt))), rw myfld.add_comm (b .* ((myfld.reciprocal ((two f) .* a) _) .* (.- b))) (b .* ((myfld.reciprocal ((two f) .* a) _) .* sqrt)), repeat {rw <- myfld.add_assoc}, rw myfld.add_assoc (.- (b .* ((myfld.reciprocal ((two f) .* a) _) .* sqrt))) (b .* ((myfld.reciprocal ((two f) .* a) _) .* sqrt)) ((b .* ((myfld.reciprocal ((two f) .* a) _) .* (.- b))) .+ c), rw myfld.add_comm (.- (b .* ((myfld.reciprocal ((two f) .* a) _) .* sqrt))) (b .* ((myfld.reciprocal ((two f) .* a) _) .* sqrt)), rw myfld.add_negate (b .* ((myfld.reciprocal ((two f) .* a) _) .* sqrt)), rw myfld.add_comm myfld.zero _, rw zero_simp f _, /- We can factorise out a common factor of 1/2a from everything except the +c at the end.-/ rw myfld.mul_comm b ((myfld.reciprocal ((two f) .* a) _) .* (.- b)), repeat {rw myfld.add_assoc _ _ _}, rw myfld.add_comm _ c, repeat {rw <- myfld.add_assoc _ _ _}, rw myfld.mul_comm (myfld.reciprocal (two f) _) (.- (((myfld.reciprocal ((two f) .* a) _) .* (.- b)) .* b)), rw <- mul_negate f ((myfld.reciprocal ((two f) .* a) _) .* (.- b)) b, rw mul_negate_alt f (myfld.reciprocal ((two f) .* a) _) (.- b), rw double_negative f b, rw myfld.mul_comm a (((myfld.reciprocal ((two f) .* a) _) .* sqrt) .* ((myfld.reciprocal ((two f) .* a) _) .* sqrt)), repeat {rw <- myfld.mul_assoc _ _ _}, rw only_one_reciprocal f ((two f) .* a) _ (mul_nonzero f (two f) a (two_ne_zero f) a_ne_zero), repeat {rw <- distrib_simp_alt f (myfld.reciprocal ((two f) .* a) _) _ _}, /- There's one term left with a * 1/2a, which we cancel..-/ rw myfld.mul_comm sqrt a, rw myfld.mul_assoc (myfld.reciprocal ((two f) .* a) _) a _, rw myfld.mul_comm (myfld.reciprocal ((two f) .* a) _) a, rw cancel_a, clear cancel_a, rw only_one_reciprocal f ((two f) .* a) _ (mul_nonzero f (two f) a (two_ne_zero f) a_ne_zero), rw only_one_reciprocal f (two f) _ (two_ne_zero f), rw mul_negate f b b, end /- This second section does all the work after the part that goes (sqrt discriminant) * (sqrt discriminant) = discriminant.-/ lemma quadratic_formula_sub_proof_b (f : Type) [myfld f] [fld_with_sqrt f] [fld_not_char_two f] (a b c : f) (a_ne_zero : a ≠ myfld.zero) : c .+ ((myfld.reciprocal ((two f) .* a) (mul_nonzero f (two f) a (two_ne_zero f) a_ne_zero)) .* ((b .* (b .* (myfld.reciprocal (two f) (two_ne_zero f)))) .+ ((((b .* b) .* (myfld.reciprocal (two f) (two_ne_zero f))) .+ ((.- ((four f) .* (a .* c))) .* (myfld.reciprocal (two f) (two_ne_zero f)))) .+ ((.- b) .* b)))) = myfld.zero := begin /- Two copies of b * b * 1/2 add together to give b * b...-/ rw myfld.mul_assoc b b (myfld.reciprocal (two f) _), repeat {rw <- myfld.add_assoc _ _ _}, rw myfld.add_assoc ((b .* b) .* (myfld.reciprocal (two f) _)) ((b .* b) .* (myfld.reciprocal (two f) _)) _, rw <- distrib_simp_alt f (b .* b) _ _, rw add_two_halves f, rw <- myfld.mul_one (b .* b), /- The b^2 that we just made cancels with the -b^2...-/ rw myfld.add_comm (b .* b) (((.- ((four f) .* (a .* c))) .* (myfld.reciprocal (two f) _)) .+ ((.- b) .* b)), rw <- myfld.add_assoc _ ((.- b) .* b) (b .* b), rw mul_negate f b b, rw myfld.add_comm (.- (b .* b)) (b .* b), rw myfld.add_negate (b .* b), rw <- myfld.add_zero ((.- ((four f) .* (a .* c))) .* (myfld.reciprocal (two f) _)), /- We're now down to c + 1/2a * 4ac * 1/2, which is fairly obviously zero.-/ /- All that's left to do is to simplify the second term.-/ rw split_reciprocal f (two f) a _, rw myfld.mul_assoc (four f) a c, rw myfld.mul_comm (four f) a, rw mul_negate _ _, rw <- mul_negate_alt _ _, rw assoc_tree_mul f _ _ _ _, rw myfld.mul_assoc (myfld.reciprocal a _) _ _, rw myfld.mul_assoc (myfld.reciprocal a _) a _, rw myfld.mul_comm (myfld.reciprocal a _) a, rw myfld.mul_reciprocal a _, rw one_mul f (four f), rw myfld.mul_comm ((four f) .* c) (myfld.reciprocal (two f) _), rw myfld.mul_assoc _ _ _, rw mul_two_reciprocals f (two f) (two f) _ _, unfold four, rw two_plus_two f, rw myfld.mul_assoc (myfld.reciprocal ((two f) .* (two f)) _) ((two f) .* (two f)) c, rw myfld.mul_comm (myfld.reciprocal ((two f) .* (two f)) _) ((two f) .* (two f)), rw myfld.mul_reciprocal ((two f) .* (two f)) _, rw one_mul f c, exact myfld.add_negate c, end /- And so this brings the two halves together into a proof of the correctness of the formula.-/ lemma quadratic_formula_works (f : Type) [myfld f] [fld_with_sqrt f] [fld_not_char_two f] (a b c : f) (a_ne_zero : a ≠ myfld.zero) : quadratic_subst f (quadratic_formula f a b c a_ne_zero) a b c = myfld.zero := begin unfold quadratic_formula, unfold quadratic_subst, rw distrib_simp f _ _ _, rw distrib_simp f _ _ _, repeat {rw distrib_simp_alt f _ _ _}, rw quadratic_formula_sub_proof_a f a b c (sqroot ((b .* b) .+ (.- ((four f) .* (a .* c))))) a_ne_zero, /- One of our terms now has the square root of the discriminant multiplied by itself. This, of course, gives us the discriminant.-/ rw myfld.mul_comm (myfld.reciprocal (two f) _) (sqroot ((b .* b) .+ (.- ((four f) .* (a .* c))))), rw myfld.mul_assoc (sqroot ((b .* b) .+ (.- ((four f) .* (a .* c))))) (sqroot ((b .* b) .+ (.- ((four f) .* (a .* c))))) _, rw fld_with_sqrt.sqrt_mul_sqrt ((b .* b) .+ (.- ((four f) .* (a .* c)))), rw distrib_simp f _ _ _, exact quadratic_formula_sub_proof_b f a b c a_ne_zero, end /- Of course, a given quadratic has two solutions...-/ def quadratic_formula_alt (f : Type) [myfld f] [fld_with_sqrt f] [fld_not_char_two f] (a b c : f) (a_ne_zero : a ≠ myfld.zero) := ((.- b) .+ (.- (sqroot ((b .* b) .+ (.- ((four f) .* (a .* c))))))) .* (myfld.reciprocal ((two f) .* a) (mul_nonzero f (two f) a (two_ne_zero f) a_ne_zero)) /- And both solutions are correct...-/ lemma quadratic_formula_alt_works (f : Type) [myfld f] [fld_with_sqrt f] [fld_not_char_two f] (a b c : f) (a_ne_zero : a ≠ myfld.zero) : quadratic_subst f (quadratic_formula_alt f a b c a_ne_zero) a b c = myfld.zero := begin unfold quadratic_formula_alt, unfold quadratic_subst, rw distrib_simp f _ _ _, rw distrib_simp f _ _ _, repeat {rw distrib_simp_alt f _ _ _}, rw quadratic_formula_sub_proof_a f a b c (.- (sqroot ((b .* b) .+ (.- ((four f) .* (a .* c)))))) a_ne_zero, /- One of our terms now has the negative of the square root of the discriminant multiplied by itself. This, of course, gives us the discriminant.-/ rw myfld.mul_comm (myfld.reciprocal (two f) _) (.- (sqroot ((b .* b) .+ (.- ((four f) .* (a .* c)))))), rw myfld.mul_assoc (.- (sqroot ((b .* b) .+ (.- ((four f) .* (a .* c)))))) (.- (sqroot ((b .* b) .+ (.- ((four f) .* (a .* c)))))) _, rw negative_sqrt f ((b .* b) .+ (.- ((four f) .* (a .* c)))), rw distrib_simp f _ _ _, exact quadratic_formula_sub_proof_b f a b c a_ne_zero, end /- So both versions of the quadratic formula work properly.-/ /- However we have not proven that these are the only solutions.-/ /- OK: proof that no solutions to a quadratic exist besides the formula ones. -/ lemma quadratic_solution_unique (f : Type) [myfld f] [fld_with_sqrt f] [fld_not_char_two f] (a b c x : f) (a_ne_zero : a ≠ myfld.zero) : (x ≠ quadratic_formula f a b c a_ne_zero /\ x ≠ quadratic_formula_alt f a b c a_ne_zero) -> quadratic_subst f x a b c ≠ myfld.zero := begin intros not_formula h, /- This will involve reducing the introduced formulae into a form that can be passed to only_two_square_roots, which requires three formulae of the forms: k ≠ sqrt (y) k ≠ - sqrt (y) k * k = y So we first have to unfold the statement that x is not the solution to the quadratic formula and reduce it to a form that looks like something ≠ ± (sqrt (something else)) . -/ unfold quadratic_formula at not_formula, unfold quadratic_formula_alt at not_formula, repeat {rw distrib_simp f _ _ _ at not_formula}, repeat {rw myfld.add_comm ((.- b) .* (myfld.reciprocal ((two f) .* a) _)) _ at not_formula}, rw mul_negate f _ _ at not_formula, repeat {rw <- carry_term_across_ne f x _ (b .* (myfld.reciprocal ((two f) .* a) _)) at not_formula}, cases not_formula with nfa nfb, have two_a_ne_zero : ((two f) .* a) ≠ myfld.zero, exact mul_nonzero f (two f) a (two_ne_zero f) a_ne_zero, have nfa_tmp : (x .+ (b .* (myfld.reciprocal ((two f) .* a) _))) .* ((two f) .* a) ≠ ((sqroot ((b .* b) .+ (.- ((four f) .* (a .* c))))) .* (myfld.reciprocal ((two f) .* a) _)) .* ((two f) .* a) , exact mul_both_sides_ne f _ _ ((two f) .* a) nfa two_a_ne_zero, clear nfa, rename nfa_tmp nfa, have nfb_tmp : (x .+ (b .* (myfld.reciprocal ((two f) .* a) _))) .* ((two f) .* a) ≠ ((.- (sqroot ((b .* b) .+ (.- ((four f) .* (a .* c)))))) .* (myfld.reciprocal ((two f) .* a) _)) .* ((two f) .* a) , exact mul_both_sides_ne f _ _ ((two f) .* a) nfb two_a_ne_zero, clear nfb, rename nfb_tmp nfb, rw distrib_simp f x (b .* (myfld.reciprocal ((two f) .* a) _)) _ at nfa nfb, rw <- myfld.mul_assoc _ _ ((two f) .* a) at nfa nfb, rw <- myfld.mul_assoc _ _ ((two f) .* a) at nfa nfb, repeat {rw myfld.mul_comm (myfld.reciprocal ((two f) .* a) _) ((two f) .* a) at nfa nfb}, repeat {rw myfld.mul_reciprocal ((two f) .* a) _ at nfa nfb}, rw <- myfld.mul_one b at nfa nfb, rw <- myfld.mul_one (sqroot ((b .* b) .+ (.- ((four f) .* (a .* c))))) at nfa, rw <- myfld.mul_one (.- (sqroot ((b .* b) .+ (.- ((four f) .* (a .* c)))))) at nfb, clear two_a_ne_zero, /- Next we have to unfold the actual quadratic and transform it into a similar form as the above, but with square (something) ≠ (something else) . This is pretty much just using the method of "completing the square" that we all learned at school.-/ unfold quadratic_subst at h, have h1 : ((a .* (x .* x)) .+ ((b .* x) .+ c)) .* (myfld.reciprocal a a_ne_zero) = myfld.zero, rw h, exact mul_zero f _, clear h, rename h1 h, rw distrib_simp f _ _ _ at h, rw myfld.mul_comm (a .* (x .* x)) (myfld.reciprocal a a_ne_zero) at h, rw myfld.mul_assoc (myfld.reciprocal a a_ne_zero) a _ at h, rw myfld.mul_comm (myfld.reciprocal a a_ne_zero) a at h, rw myfld.mul_reciprocal a _ at h, rw one_mul f _ at h, rw distrib_simp f _ _ _ at h, rw myfld.add_assoc _ _ _ at h, have tmp : ((b .* x) .* (myfld.reciprocal a a_ne_zero)) = ((two f) .* ((myfld.reciprocal (two f) fld_not_char_two.not_char_two) .* ((b .* x) .* (myfld.reciprocal a a_ne_zero)))), have sub_tmp : ((two f) .* (myfld.reciprocal (two f) fld_not_char_two.not_char_two)) = myfld.one, exact myfld.mul_reciprocal (two f) _, rw myfld.mul_assoc (two f) (myfld.reciprocal (two f) _) _, rw sub_tmp, rw one_mul f _, rw tmp at h, clear tmp, rw <- myfld.mul_assoc b x _ at h, rw myfld.mul_comm x (myfld.reciprocal a a_ne_zero) at h, rw myfld.mul_assoc _ _ x at h, rw myfld.mul_assoc _ _ x at h, rw myfld.mul_assoc _ _ x at h, rw complete_the_square f x _ at h, rw carry_term_across f _ _ (c .* (myfld.reciprocal a a_ne_zero)) at h, rw simp_zero at h, rw carry_term_across f _ _ (.- (square f ((myfld.reciprocal (two f) fld_not_char_two.not_char_two) .* (b .* (myfld.reciprocal a a_ne_zero))))) at h, /- All the work that is at all interesting has been done above, the below is just a load of tedious rearranging to make various expressions that anyone can see are equivalent visibly equal to the computer. I wouldn't bother scrutinizing the below in detail unless you're having insomnia trouble.-/ have h1 : (square f (x .+ ((myfld.reciprocal (two f) fld_not_char_two.not_char_two) .* (b .* (myfld.reciprocal a a_ne_zero))))) .* (square f ((two f) .* a)) = ((.- (c .* (myfld.reciprocal a a_ne_zero))) .+ (.- (.- (square f ((myfld.reciprocal (two f) fld_not_char_two.not_char_two) .* (b .* (myfld.reciprocal a a_ne_zero))))))) .* (square f ((two f) .* a)) , have h_tmp : (square f (x .+ ((myfld.reciprocal (two f) fld_not_char_two.not_char_two) .* (b .* (myfld.reciprocal a a_ne_zero))))) .* (square f ((two f) .* a)) = (square f (x .+ ((myfld.reciprocal (two f) fld_not_char_two.not_char_two) .* (b .* (myfld.reciprocal a a_ne_zero))))) .* (square f ((two f) .* a)) , refl, rw h at h_tmp {occs := occurrences.pos [2]}, exact h_tmp, clear h, rename h1 h, rw multiply_two_squares f _ _ at h, rw distrib_simp f _ _ _ at h, rw myfld.mul_assoc ((myfld.reciprocal (two f) fld_not_char_two.not_char_two) .* (b .* (myfld.reciprocal a a_ne_zero))) (two f) a at h, rw myfld.mul_comm (myfld.reciprocal (two f) fld_not_char_two.not_char_two) _ at h, rw <- myfld.mul_assoc _ (myfld.reciprocal (two f) fld_not_char_two.not_char_two) (two f) at h, rw myfld.mul_comm (myfld.reciprocal (two f) fld_not_char_two.not_char_two) (two f) at h, rw myfld.mul_reciprocal _ _ at h, rw simp_mul_one f _ at h, rw <- myfld.mul_assoc _ (myfld.reciprocal a a_ne_zero) a at h, rw myfld.mul_comm (myfld.reciprocal a a_ne_zero) a at h, rw myfld.mul_reciprocal _ _ at h, rw simp_mul_one f _ at h, rw double_negative f _ at h, rw distrib_simp f _ _ _ at h, rw multiply_two_squares f _ _ at h, have tmp : (square f ((two f) .* a)) = a .* ((four f) .* a) , unfold square, unfold four, rw two_plus_two f, rw <- myfld.mul_assoc (two f) (two f) a, have tmp_tmp : a .* ((two f) .* ((two f) .* a)) = a .* ((two f) .* (a .* (two f))) , rw myfld.mul_comm (two f) a, rw tmp_tmp, rw myfld.mul_comm (two f) a, repeat {rw myfld.mul_assoc _ _ _}, rw tmp at h, clear tmp, rw mul_negate at h, rw myfld.mul_assoc (c .* (myfld.reciprocal a a_ne_zero)) a _ at h, rw <- myfld.mul_assoc c _ a at h, rw myfld.mul_comm (myfld.reciprocal a _) a at h, rw myfld.mul_reciprocal a _ at h, rw simp_mul_one f _ at h, rw <- myfld.mul_assoc _ (myfld.reciprocal (two f) _) _ at h, rw myfld.mul_assoc (myfld.reciprocal (two f) _) (two f) a at h, rw myfld.mul_comm (myfld.reciprocal (two f) _) (two f) at h, rw myfld.mul_reciprocal (two f) _ at h, rw one_mul f _ at h, rw <- myfld.mul_assoc b _ a at h, rw myfld.mul_comm (myfld.reciprocal a a_ne_zero) a at h, rw myfld.mul_reciprocal a a_ne_zero at h, rw simp_mul_one f b at h, have tmp : (square f b) = b .* b, unfold square, rw tmp at h, clear tmp, rw myfld.add_comm _ (b .* b) at h, rw myfld.mul_assoc c (four f) a at h, rw myfld.mul_comm c (four f) at h, rw <- myfld.mul_assoc (four f) c a at h, rw myfld.mul_comm c a at h, /- Having finally finished rearranging, the problem has been reduced to the question of whether more than two square roots of the same number can exist. They can't.-/ exact only_two_square_roots f ((x .* ((two f) .* a)) .+ b) ((b .* b) .+ (.- ((four f) .* (a .* c)))) nfa nfb h, end /- QED.-/ lemma quadratic_factorize (f : Type) [myfld f] [fld_with_sqrt f] [fld_not_char_two f] (b c x : f) : (x .+ .- (quadratic_formula f myfld.one b c myfld.zero_distinct_one)) .* (x .+ .- (quadratic_formula_alt f myfld.one b c myfld.zero_distinct_one)) = (quadratic_subst f x myfld.one b c) := begin rw distrib_simp, rw distrib_simp_alt, rw distrib_simp_alt, repeat {rw mul_negate, rw mul_negate_alt_simp}, rw double_negative, rw myfld.mul_comm (quadratic_formula f myfld.one b c _) x, repeat {rw <- myfld.add_assoc}, rw myfld.add_assoc (.- _) (.- _) _, rw <- add_negate, rw <- distrib_simp_alt, have tmp : (quadratic_formula f myfld.one b c myfld.zero_distinct_one) .+ (quadratic_formula_alt f myfld.one b c myfld.zero_distinct_one) = .- b, unfold quadratic_formula, unfold quadratic_formula_alt, rw <- distrib_simp, repeat {rw <- myfld.add_assoc}, rw reciprocal_rewrite f _ _ (simp_mul_one f _) _, rw one_mul_simp f, rw myfld.add_comm _ (.- sqroot _), rw myfld.add_assoc (sqroot _) (.- sqroot _) _, rw myfld.add_negate, rw simp_zero, rw distrib_simp, rw <- distrib_simp_alt, rw add_two_halves, rw simp_mul_one, rw myfld.add_comm at tmp, rw tmp, clear tmp, have clear_term : ∀ (a b x : f), a = b -> (x .+ a) = (x .+ b), intros a b x h, rw h, unfold quadratic_subst, rw one_mul_simp, apply clear_term, rw mul_negate_alt_simp, rw double_negative, rw myfld.mul_comm x b, apply clear_term, clear clear_term, unfold quadratic_formula, unfold quadratic_formula_alt, repeat {rw <- myfld.mul_assoc}, rw myfld.mul_comm (myfld.reciprocal _ _) _, repeat {rw myfld.mul_assoc}, rw difference_of_squares, rw sqrt_squared, unfold square, rw mul_negate, rw mul_negate_alt_simp, rw double_negative, rw add_negate, rw myfld.add_assoc, rw myfld.add_negate, rw simp_zero, rw double_negative, rw <- myfld.mul_assoc, rw reciprocal_rewrite f _ _ (simp_mul_one f _) _, rw mul_two_reciprocals, rw myfld.mul_comm _ c, rw <- myfld.mul_assoc c _ _, rw simp_mul_one, unfold four, rw two_plus_two, rw myfld.mul_reciprocal, rw simp_mul_one, end
(*<*) (*********************************************************************** * HiVe theory files * * Copyright (C) 2015 Commonwealth of Australia as represented by Defence Science and Technology * Group (DST Group) * * All rights reserved. * * The HiVe theory files are free software: released for redistribution and use, and/or modification, * under the BSD License, details of which can be found in the LICENSE file included in the * distribution. ************************************************************************) theory Z_Numbers_Chap imports Z_Fun Orders Equipotence begin(*>*) lemma fin_card_dom: assumes a1: "finite f" and a2: "card (\<zdom> f) = card f" shows "functional f" proof - from a1 have b1: "card (\<zdom> f) = card f \<Rightarrow> functional f" (is "?P f") proof (induct f set: finite) show "?P \<emptyset>" by (simp add: empty_functional) next apply_end (tactic {* split_all_tac @{context} 1 *} ) fix f x y assume c1: "finite f" and c2: "(x \<mapsto> y) \<notin> f" and c3: "?P f" show "?P (insert (x \<mapsto> y) f)" proof assume d1: "card (\<zdom> (insert (x \<mapsto> y) f)) = card (insert (x \<mapsto> y) f)" from c1 c2 have d2: "card (insert (x \<mapsto> y) f) = card f + 1" by (simp) have d3: "\<zdom> f \<subseteq> \<fst>\<lparr>f\<rparr>" by (auto simp add: image_def) from c1 c1 [THEN fun_finite_dom] have d4: "card (\<zdom> (insert (x \<mapsto> y) f)) \<le> card (\<zdom> f) + 1" by (simp add: insert_dom card_insert_if) with c1 c2 have "card f \<le> card (\<zdom> f)" apply (simp only: d1) apply (simp) done moreover from c1 c1 [THEN fun_finite_dom] subepIsurj [OF d3] have "card (\<zdom> f) \<le> card f" by (simp add: finite_subequipotent_card) ultimately have d5: "card (\<zdom> f) = card f" by (auto) with c1 c2 have d6: "card (\<zdom> (insert (x \<mapsto> y) f)) = card (\<zdom> f) + 1" apply (simp only: d1) apply (auto) done from d5 c3 have "functional f" by (simp) then show "functional (insert (x \<mapsto> y) f)" apply (rule insert_functionalI) using d6 c1 [THEN fun_finite_dom] apply (simp add: card_insert_if) apply (cases "x \<in> \<zdom> f") apply (auto) done qed qed with a2 show "?thesis" by (simp) qed chapter {* The Z Mathkit: Numbers *} (*<*)end(*>*)
{-# LANGUAGE QuantifiedConstraints #-} {-# LANGUAGE UndecidableInstances #-} {-# LANGUAGE InstanceSigs #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE FlexibleInstances #-} module Vector where import Tensor import Data.Monoid import Data.Maybe import Data.Complex import Helper import Data.Either import System.Random data Vector a = Scalar a | Row [Vector a] | Column [Vector a] -- This Eq implementation ignores structural differences instance (Eq a) => Eq (Vector a) where x == y = wx == wy && hx == hy && go 0 0 where wx = width x wy = width y hx = height x hy = height y go i j | i == hx = True | j == wx = go (i + 1) 0 | otherwise = atM x (i, j) == atM y (i, j) && go i (j + 1) instance Functor Vector where fmap f (Scalar s) = Scalar $ f s fmap f (Row t) = Row $ map (fmap f) t fmap f (Column t) = Column $ map (fmap f) t instance Applicative Vector where pure = Scalar Scalar s <*> t = fmap s t t <*> (Scalar s) = fmap ($s) t Row r <*> t = Row $ map (<*> t) r Column c <*> t = Column $ map (<*> t) c instance Monad Vector where Scalar s >>= f = f s Row r >>= f = Row $ map (>>= f) r Column c >>= f = Column $ map (>>= f) c instance Num a => Num (Vector a) where Row x + (Row y) = Row $ zipWith (+) x y Column x + (Column y) = Column $ zipWith (+) x y Scalar x + y = fmap (+ x) y x + (Scalar y) = fmap (+ y) x _+_ = error "Vector Addition: Dimension mismatch" Scalar x * y = fmap (* x) y x * Scalar y = fmap (* y) x Row x * (Column y) = getSum $ foldMap Sum $ zipWith (*) x y Column x * (Column y) = Column $ map (* Column y) x x * (Row y) = Row $ map (x *) y abs = fmap abs signum = fmap signum fromInteger = Scalar . fromInteger negate = fmap negate instance Foldable Vector where foldr f acc (Scalar s) = f s acc foldr f acc (Row r) = foldr (flip (foldr f)) acc r foldr f acc (Column c) = foldr (flip (foldr f)) acc c instance Traversable Vector where traverse f (Scalar s) = Scalar <$> f s traverse f (Row r) = Row <$> traverse (traverse f) r traverse f (Column c) = Column <$> traverse (traverse f) c instance (Num a) => Semigroup (Vector a) where x <> y = (*) <$> x <*> y instance (Num a) => Monoid (Vector a) where mempty = Scalar 1 instance (Cmplx a) => Cmplx (Vector a) where conj = fmap conj . transposeStruct instance (Num a, Cmplx a) => Tensor Vector a where inner = dot -- TODO: norm for matrices norm t = (/ (sqrt.getSum $ foldMap (Sum . (**2) . abs) t)) <$> t fromList xs dim = go (foldr (con . Scalar) (Column []) xs) dim where go (Column c) n | n == 1 = Column [go (Row c) dim] | l <= fromIntegral dim = Column c | otherwise = go (Row $ take (l `div` fromIntegral n) c) dim `con` go (Column $ drop (l `div` fromIntegral n) c) (n - 1) where l = length c go (Row r) n | n == 1 = Row [go (Column r) dim] | l <= fromIntegral dim = Row r | otherwise = go (Column $ take (l `div` fromIntegral n) r) dim `con` go (Row $ drop (l `div` fromIntegral n) r) (n - 1) where l = length r go s n = error "error when adding tensor rank" rank (Scalar s) = 0 rank (Row []) = 1 rank (Column []) = 1 rank (Row (r:rs)) = rank r + 1 rank (Column (c:cs)) = rank c + 1 isSquare t | (Scalar _) <- t = True | (Column c) <- t = getAll $ go (Column c) (length c) | (Row r) <- t = getAll $ go (Row r) (length r) where go (Column c) l | length c == l = foldMap (`go` l) c | otherwise = All False go (Row r) l | length r == l = foldMap (`go` l) r | otherwise = All False go (Scalar _) _ = All True conjTr = conj instance (Floating a, Eq a, Show a, Ord a, UniformRange a, Cmplx a) => QuantumRegister Vector a where densityOp x = transposeStruct x * x initQubit zero one | abs zero ** 2 + abs one ** 2 == 1 = Right $ fromList [zero, one] 2 | otherwise = Left "Sum of probability of |0> and |1> state does not equal to 1" initQubit0 = fromList [1, 0] 2 initNumQubit0 n | n < 1 = Left "Invalid qubit number" | otherwise = Right $ foldr (|*|) initQubit0 $ replicate (fromIntegral n - 1) initQubit0 toQuantumRegister q | isLeft num = Left "Input list length is not a power of 2" | otherwise = Right . norm $ fromList q 2 where num = integralLog 2 (length q) illegalPeek (Scalar s) = show s illegalPeek q = go 0 0 where w = width q h = height q go i j | i == h = mempty | j == w = "\t|\n" ++ go (i + 1) 0 | j == 0 = "|\t" <> current <> "\t" <> go i (j + 1) | otherwise = current <> "\t" <> go i (j + 1) where current = maybe "null" show (atM q (i, j)) subSystem lst q | getAny $ foldMap (Any . (\ x -> x >= rank q || x < 0)) lst = Left "Index out of bounds" | not (isSquare q) = Left "Invalid Quantum Register" | otherwise = Right . fmap sqrt $ go lst (fmap (\x -> conj x * x) q) where go [] (Scalar s) = Scalar s go is (Row r) | null is || Prelude.head is /= 0 = foldr (+) (Scalar 0) preSum | otherwise = Row $ map (go $ fmap (flip (-) 1) (Prelude.tail is)) r where preSum = map (go $ fmap (flip (-) 1) is) r go is (Column c) | null is || Prelude.head is /= 0 = foldr (+) (Scalar 0) preSum | otherwise = Column $ map (go $ fmap (flip (-) 1) (Prelude.tail is)) c where preSum = map (go $ fmap (flip (-) 1) is) c go _ _ = error "Exceptions not handled by subSystem function" isEntangled lst q = do reduced <- reducedDensity lst q return $ abs (trace (reduced * reduced) - 1) > 1e-13 mask0 = Row [ Column[1, 0], Column[0, 0] ] mask1 = Row [ Column[0, 0], Column[0, 1] ] pauliId = Row [ Column [1, 0], Column [0, 1] ] instance (RealFloat a, Show a, UniformRange a) => Gates Vector (Complex a) where pauliX = Row [ Column [Scalar (0 :+ 0), Scalar (1 :+ 0)], Column [Scalar (1 :+ 0), Scalar (0 :+ 0)] ] pauliY = Row [ Column [Scalar (0 :+ 0), Scalar (0 :+ 1)], Column [Scalar (0 :+ (-1)), Scalar (0 :+ 0)] ] pauliZ = Row [ Column [Scalar (1 :+ 0), Scalar (0 :+ 0)], Column [Scalar (0 :+ 0), Scalar ((-1) :+ 0)] ] hadamard = Row [ Column [Scalar (1 / sqrt 2 :+ 0), Scalar (1 / sqrt 2 :+ 0)], Column [Scalar (1 / sqrt 2 :+ 0), Scalar ((-1) / sqrt 2 :+ 0)] ] at :: Integral b => a -> Vector a -> (b, b) -> a at x y z = fromMaybe x (atM y z) atM :: Integral b => Vector a -> (b, b) -> Maybe a atM (Scalar s) (0, 0) = Just s atM (Column (c:cs)) (i, j) | height (Column (c:cs)) > i = let offset = height c in if offset > i then atM c (i, j) else atM (Column cs) (i - offset, j) | otherwise = Nothing atM (Row (r:rs)) (i, j) | width (Row (r:rs)) > j = let offset = width r in if offset > j then atM r (i, j) else atM (Row rs) (i, j - offset) | otherwise = Nothing atM _ _ = Nothing con :: Vector a -> Vector a -> Vector a con x (Row y) = Row $ x : y con x (Column y) = Column $ x : y con _ _ = error "Appending to Scalar is prohibited" append :: Vector a -> Vector a -> Vector a append (Row x) (Row y) = Row $ x ++ y append (Column x) (Column y) = Column $ x ++ y append _ _ = error "Vector direction mismatch" width :: Integral b => Vector a -> b width (Scalar s) = 1 width (Row r) = getSum $ foldMap (Sum . width) r width (Column c) = width $ Prelude.head c height :: Integral b => Vector a -> b height (Scalar s) = 1 height (Column c) = getSum $ foldMap (Sum . height) c height (Row r) = height $ Prelude.head r -- Transform structure retaining the original rank and shape transformStruct :: Vector a -> Vector a transformStruct (Row (Column c:cs)) = Column . go $ Column c:cs where go (Row [] : _) = [] go (Column [] : _) = [] go cs = Row (map (transformStruct . Vector.head) cs) : go (map Vector.tail cs) transformStruct (Column (Row r:rs)) = Row . go $ Row r:rs where go (Row [] : _) = [] go (Column [] : _) = [] go rs = Column (map (transformStruct . Vector.head) rs) : go (map Vector.tail rs) transformStruct (Column cs) = Column $ map transformStruct cs transformStruct (Row rs) = Row $ map transformStruct rs transformStruct t = t -- transpose via structure transposeStruct :: Vector a -> Vector a transposeStruct (Scalar s) = Scalar s transposeStruct (Row r) = Column $ map transposeStruct r transposeStruct (Column c) = Row $ map transposeStruct c -- transpose retaining structure transpose :: Vector a -> Vector a transpose = transformStruct . transposeStruct head :: Vector a -> Vector a head (Scalar s) = Scalar s head (Row r) = Prelude.head r head (Column c) = Prelude.head c last :: Vector a -> Vector a last (Scalar s) = Scalar s last (Row r) = Prelude.last r last (Column c) = Prelude.last c tail :: Vector a -> Vector a tail (Scalar s) = Scalar s tail (Row r) = Row $ Prelude.tail r tail (Column c) = Column $ Prelude.tail c init :: Vector a -> Vector a init (Scalar s) = Scalar s init (Row r) = Row $ Prelude.init r init (Column c) = Column $ Prelude.init c dot :: Num a => Vector a -> Vector a -> Vector a dot x y = transposeStruct x * y reducedDensity :: (Num a, Cmplx a, Floating a) => [Int] -> Vector a -> Either String (Vector a) reducedDensity lst q | getAny $ foldMap (Any . (\ x -> x >= rank q || x < 0)) lst = Left "Index out of bounds" | not (isSquare q) = Left "Invalid Quantum Register" | otherwise = Right $ go lst q (transposeStruct q) where go [] (Scalar s) (Scalar t) = Scalar (s * t) go is (Column c) (Row r) | null is || Prelude.head is /= 0 = (getSum . foldMap Sum) $ zipWith (go (flip (-) 1 <$> is)) c r | otherwise = Row $ map (Column . ($ c) . (\ b a -> map (\ x -> go (flip (-) 1 <$> Prelude.tail is) x b) a)) r go _ _ _ = error "Input is not a valid statevector" isColumn :: Vector a -> Bool isColumn (Column _) = True isColumn _ = False isRow :: Vector a -> Bool isRow (Row _) = True isRow _ = False isScalar :: Vector a -> Bool isScalar (Scalar _) = True isScalar _ = False trace :: (Num a) => Vector a -> a trace (Scalar s) = s trace (Row r) = (getSum . foldMap Sum) $ zipWith go [0, 1 ..] r where go i (Row r) = trace (r !! i) go i (Column c) = trace (c !! i) go i (Scalar s) = s {- Tensor type: All one-dimensional tensors are column vectors. This means matrices, which are rank 2 tensors, compose of multiple column tensors, which may not follow conventional representation in other traversable types. -} -- data Tensor a = Scalar a | Tensor [Tensor a] -- deriving(Eq) -- instance (Show a) => Show (Tensor a) where -- show (Scalar s) = show s -- show (Tensor ((Tensor t):ts)) = "[\n" ++ unlines (go (Tensor t:ts)) ++ "]" -- where go = fmap (" " ++).concatMap(lines . show) -- show (Tensor s) = show s ++ "\n" -- instance Functor Tensor where -- fmap f (Scalar s) = Scalar $ f s -- fmap f (Tensor t) = Tensor $ map (fmap f) t -- instance Applicative Tensor where -- pure = Scalar -- (Scalar s) <*> t = fmap s t -- t <*> (Scalar s) = fmap ($ s) t -- (Tensor []) <*> _ = Tensor [] -- (Tensor (Scalar s : ss)) <*> t = Tensor $ fmap s t : tensorList -- where Tensor tensorList = Tensor ss <*> t -- (Tensor (Tensor t : ts)) <*> t2 = Tensor $ (Tensor t <*> t2) : tensorList -- where Tensor tensorList = Tensor ts <*> t2 -- instance Monad Tensor where -- (Scalar s) >>= f = f s -- (Tensor t) >>= f = Tensor $ map (>>= f) t -- instance (Num a) => Num (Tensor a) where -- (Scalar s) + t = fmap (+ s) t -- t + (Scalar s) = fmap (+ s) t -- (Tensor xs) + (Tensor ys) = Tensor $ zipWith (+) xs ys -- (Scalar s) * t = fmap (* s) t -- t * (Scalar s) = fmap (* s) t -- _ * Tensor[] = Tensor [] -- (Tensor x) * (Tensor y) = getSum $ foldMap Sum (zipWith go x y) -- where -- go (Tensor a) b = Tensor $ map (* b) a -- go a b = a * b -- abs = fmap abs -- signum = fmap signum -- negate = fmap negate -- fromInteger i = Scalar $ fromInteger i -- instance Foldable Tensor where -- foldr f acc (Tensor t) = foldr (flip $ foldr f) acc t -- foldr f acc (Scalar s) = f s acc -- instance Traversable Tensor where -- traverse f (Scalar s) = Scalar <$> f s -- traverse f (Tensor t) = Tensor <$> traverse (traverse f) t -- -- TODO: revise function for higher-dimension tensors -- fromList :: [a] -> Int -> Tensor a -- fromList xs dim = go (foldr (con . Scalar) (Tensor[]) xs) dim -- where -- go (Tensor t) n -- | n == 1 = Tensor [go (Tensor t) dim] -- | length t <= dim = Tensor t -- | otherwise = go (Tensor $ take (length t `div` n) t) dim -- `con` go (Tensor $ drop (length t `div` n) t) (n - 1) -- go s n = error "error when adding tensor rank" -- product :: (Num a) => Tensor a -> Tensor a -> Tensor a -- product (Scalar s) t = Scalar s * t -- product t (Scalar s) = t * Scalar s -- product (Tensor []) _ = Tensor [] -- product _ (Tensor []) = Tensor [] -- product (Tensor (x:xs)) y = Tensor $ current : rest -- where -- current = Tensor.product x y -- Tensor rest = Tensor.product (Tensor xs) y -- norm :: (Floating a) => Tensor a -> Tensor a -- norm t= (/ (sqrt.getSum $ foldMap (Sum . (**2) . abs) t)) <$> t -- append :: Tensor a -> Tensor a -> Tensor a -- append (Tensor x) (Tensor y) = Tensor $ x ++ y -- append _ _ = error "Concatenating scalars is prohibited" -- con :: Tensor a -> Tensor a -> Tensor a -- con x (Tensor y) = Tensor $ x : y -- con _ _ = error "Appending to Scalar is prohibited" -- dot :: Num a => Tensor a -> Tensor a -> a -- dot (Tensor x) (Tensor y) = getSum $ foldMap Sum (zipWith dot x y) -- dot (Scalar x) (Scalar y) = x * y -- dot _ _ = error "Length mismatch" -- flatten2d :: Tensor a -> Tensor a -- flatten2d (Tensor ((Tensor ((Tensor (t:ts)):ss)):xs)) = Tensor . go $ Tensor (Tensor (t:ts):ss):xs -- where -- go :: [Tensor a] -> [Tensor a] -- go (Tensor (Tensor (Scalar s:ss):us):ys) = foldr (\a acc -> -- let (Tensor result) = Tensor.transpose a -- in result ++ acc -- ) [] (Tensor (Tensor (Scalar s:ss):us):ys) -- go y = go flattened -- where flattened = foldr (\a acc -> -- let (Tensor next) = a -- in Tensor (go next) : acc -- ) [] y -- flatten2d t = t -- head :: Tensor a -> Tensor a -- head (Tensor ts) = Prelude.head ts -- head t = t -- last :: Tensor a -> Tensor a -- last (Tensor ts) = Prelude.last ts -- last t = t -- tail :: Tensor a -> Tensor a -- tail (Tensor ts) = Tensor $ Prelude.tail ts -- tail t = t -- init :: Tensor a -> Tensor a -- init (Tensor ts) = Tensor $ Prelude.init ts -- init t = t -- transpose :: Tensor a -> Tensor a -- transpose (Tensor (Tensor t:ts)) = Tensor $ go $ Tensor t:ts -- where -- go :: [Tensor a] -> [Tensor a] -- go (Tensor [] : _) = [] -- go xs = Tensor (map Tensor.head xs) : go (map Tensor.tail xs) -- transpose (Tensor (Scalar s:ss)) = Tensor $ map (Tensor.(:[])) (Scalar s:ss) -- transpose t = t -- isSquare :: Tensor a -> Bool -- isSquare (Scalar _) = True -- isSquare (Tensor []) = True -- isSquare (Tensor t) = getAll $ go (Tensor t) (length t) -- where -- go (Tensor x) l -- | length x == l = foldMap (`go` l) x -- | otherwise = All False -- go (Scalar _) _ = All True -- rank :: Integral b => Tensor a -> b -- rank (Scalar s) = 0 -- rank (Tensor []) = 1 -- rank (Tensor (t:ts)) = rank t + 1
State Before: α✝ β✝ α β : Type u inst✝¹ : Fintype α inst✝ : Zero β ⊢ (#α →₀ β) = (#β) ^ Fintype.card α State After: no goals Tactic: simp
Require Import Logic.Axiom.Extensionality. Require Import Logic.Rel.R. Require Import Logic.Rel.Id. Require Import Logic.Rel.Range. Require Import Logic.Rel.Include. Require Import Logic.Rel.Converse. Require Import Logic.Rel.Intersect. Require Import Logic.Rel.Composition. Require Import Logic.Rel.Coreflexive. (* Domain of a relation defined as coreflexive relation rather than set *) Inductive dom (a b:Type) (r:R a b) : Rel a := | mkDom : forall (x:a), (exists (y:b), r x y) -> dom a b r x x . Arguments dom {a} {b}. Lemma dom_corefl : forall (a b:Type) (r:R a b), coreflexive (dom r). Proof. unfold coreflexive. intros a b r. apply incl_charac. intros x y H1. destruct H1. constructor. Qed. Lemma dom_universal : forall (a b:Type) (r:R a b) (s:Rel a), s <= id -> dom r <= s <-> r <= r ; s. Proof. intros a b r s H1. split; intros H2; apply incl_charac; intros x y H3. - unfold comp. exists x. split; try assumption. assert (dom r x x) as H4. { constructor. exists y. assumption. } apply incl_charac_to with (dom r); assumption. - destruct H3 as [x [y H3]]. apply (incl_charac_to _ _ _ (r ; s)) in H3; try assumption. unfold comp in H3. destruct H3 as [z [H3 H4]]. generalize H3. intros H3'. apply (incl_charac_to _ _ _ id) in H3'; try assumption. destruct H3'. assumption. Qed. Lemma dom_inter : forall (a b:Type) (r:R a b), dom r = ((conv r ; r) /\ id). Proof. intros a b r. apply Ext. intros x y. split; intros H1. - destruct H1 as [x [y H1]]. unfold inter, conv, comp. split. + exists y. split; assumption. + constructor. - unfold inter in H1. destruct H1 as [H1 H2]. destruct H2 as [x]. constructor. unfold comp in H1. destruct H1 as [y [H1 H2]]. exists y. assumption. Qed. Lemma dom_comp_self : forall (a b:Type) (r:R a b), r = r ; dom r. Proof. intros a b r. apply Ext. intros x y. unfold comp. split; intros H1. - exists x. split; try assumption. constructor. exists y. assumption. - destruct H1 as [z [H1 H2]]. destruct H1. assumption. Qed. Lemma dom_comp : forall (a b c:Type) (r:R a b) (s:R b c), dom (s ; r) = dom (dom s ; r). Proof. intros a b c r s. apply Ext. intros x y. split; intros H1. - destruct H1 as [x [y H1]]. constructor. unfold comp in H1. destruct H1 as [z [H1 H2]]. exists z. unfold comp. exists z. split; try assumption. constructor. exists y. assumption. - destruct H1 as [x [y H1]]. constructor. unfold comp in H1. destruct H1 as [z [H1 H2]]. destruct H2 as [z [y H2]]. exists y. exists z. split; assumption. Qed. Lemma dom_comp_incl : forall (a b c:Type) (r:R a b) (s:R b c), dom (s ; r) <= dom r. Proof. intros a b c r s. apply incl_charac. intros x y H1. destruct H1 as [x [z [y [H1 H2]]]]. constructor. exists y. assumption. Qed. Lemma dom_inter_conv : forall (a b:Type) (r s:R a b), dom (s /\ r) = (id /\ (conv r ; s)). Proof. intros a b r s. apply Ext. intros x y. split; intros H1. - destruct H1 as [x [y [H1 H2]]]. split; try constructor. exists y. split; assumption. - destruct H1 as [H1 [z [H2 H3]]]. destruct H1. constructor. exists z. split; assumption. Qed. Lemma dom_incl_compat : forall (a b:Type) (r s:R a b), r <= s -> dom r <= dom s. Proof. intros a b r s H1. apply incl_charac. intros x y H2. destruct H2 as [x [y H2]]. constructor. exists y. apply incl_charac_to with r; assumption. Qed. Lemma dom_rng_conv : forall (a b:Type) (r:R a b), dom r = rng (conv r). Proof. intros a b r. apply Ext. intros x y. split; intros H1; destruct H1 as [x [y H1]]; constructor; exists y; assumption. Qed. Lemma rng_dom_conv : forall (a b:Type) (r:R a b), rng r = dom (conv r). Proof. intros a b r. apply Ext. intros x y. split; intros H1; destruct H1 as [y [x H1]]; constructor; exists x; assumption. Qed.
```python import numpy as np %matplotlib inline from mpl_toolkits import mplot3d import matplotlib.pyplot as plt import pickle ``` # 8-7. Batch Normalizations Just like we normalize the input of the network, it turns out that normalizing values before the activation each layer is beneficial for training neural networks. Usually, a batch norm layer is inserted before an activation layer. The benefits of batch norm are: 1. Faster training via higher learning rate 1. Robustness for initial weight 1. Slight regularization effect Paper: Batch Normalization: Accelerating Deep Network Training by Reducing Internal Covariate Shift [arXiv:1502.03167](https://arxiv.org/abs/1502.03167) With the learnable parameter $\gamma$ and $\beta$ (initially 1 and 0), the forward pass of batch norm is defined as followings: \begin{align} \mu &\leftarrow \frac{1}{m} \sum_{i=1}^{m} x_i \\ \sigma^2 &\leftarrow \frac{1}{m} \sum_{i=1}^{m} (x_i - \mu)^2 \\ \hat{x_i}&\leftarrow \frac{x_i - \mu}{\sqrt{\sigma^2 + \epsilon}} \\ y_i &\leftarrow \gamma \hat{x_i} + \beta \end{align} The backward pass can be derived using computational graph. [Understanding the backward pass through Batch Normalization Layer](https://kratzert.github.io/2016/02/12/understanding-the-gradient-flow-through-the-batch-normalization-layer.html) by Frederik Kratzert has a detailed explanation. ## Five layer net w/ or wo/ batch normalization * Five layers * Around 40 neurons * ReLU * Random initialization ($10$–$10^{-4}$) * With or without batch normalization ```python plt.rcParams['figure.figsize'] = [16, 16] ``` ```python fig, axes = plt.subplots(4, 4) for row in range(4): for col in range(4): index = row * 4 + col with_log = pickle.load(open('code/08_techniques/08_7_batch_norm/experiment_{}_True.pkl'.format(index), "rb")) without_log = pickle.load(open('code/08_techniques/08_7_batch_norm/experiment_{}_False.pkl'.format(index), "rb")) current = axes[row, col] current.plot(with_log['accuracy_test_itr'], with_log['accuracy_test'], 'b', label='with bn') current.plot(without_log['accuracy_test_itr'], without_log['accuracy_test'], 'r', label='without bn') current.legend() current.set_title('stddev %.5f' % with_log['weight_stddev']) plt.show() ```
[STATEMENT] lemma crel_vs_iterate_state: "crel_vs (=) () (iterate_state f xs)" if "((=) ===>\<^sub>T R) g f" [PROOF STATE] proof (prove) goal (1 subgoal): 1. crel_vs (=) () (iterate_state f xs) [PROOF STEP] proof (induction xs) [PROOF STATE] proof (state) goal (2 subgoals): 1. crel_vs (=) () (iterate_state f []) 2. \<And>a xs. crel_vs (=) () (iterate_state f xs) \<Longrightarrow> crel_vs (=) () (iterate_state f (a # xs)) [PROOF STEP] case Nil [PROOF STATE] proof (state) this: goal (2 subgoals): 1. crel_vs (=) () (iterate_state f []) 2. \<And>a xs. crel_vs (=) () (iterate_state f xs) \<Longrightarrow> crel_vs (=) () (iterate_state f (a # xs)) [PROOF STEP] then [PROOF STATE] proof (chain) picking this: [PROOF STEP] show ?case [PROOF STATE] proof (prove) goal (1 subgoal): 1. crel_vs (=) () (iterate_state f []) [PROOF STEP] by (simp; rule crel_vs_return_ext[unfolded Transfer.Rel_def]; simp; fail) [PROOF STATE] proof (state) this: crel_vs (=) () (iterate_state f []) goal (1 subgoal): 1. \<And>a xs. crel_vs (=) () (iterate_state f xs) \<Longrightarrow> crel_vs (=) () (iterate_state f (a # xs)) [PROOF STEP] next [PROOF STATE] proof (state) goal (1 subgoal): 1. \<And>a xs. crel_vs (=) () (iterate_state f xs) \<Longrightarrow> crel_vs (=) () (iterate_state f (a # xs)) [PROOF STEP] case (Cons x xs) [PROOF STATE] proof (state) this: crel_vs (=) () (iterate_state f xs) goal (1 subgoal): 1. \<And>a xs. crel_vs (=) () (iterate_state f xs) \<Longrightarrow> crel_vs (=) () (iterate_state f (a # xs)) [PROOF STEP] have unit_expand: "() = (\<lambda> a f. f a) () (\<lambda> _. ())" [PROOF STATE] proof (prove) goal (1 subgoal): 1. () = () [PROOF STEP] .. [PROOF STATE] proof (state) this: () = () goal (1 subgoal): 1. \<And>a xs. crel_vs (=) () (iterate_state f xs) \<Longrightarrow> crel_vs (=) () (iterate_state f (a # xs)) [PROOF STEP] from Cons [PROOF STATE] proof (chain) picking this: crel_vs (=) () (iterate_state f xs) [PROOF STEP] show ?case [PROOF STATE] proof (prove) using this: crel_vs (=) () (iterate_state f xs) goal (1 subgoal): 1. crel_vs (=) () (iterate_state f (x # xs)) [PROOF STEP] by simp (rule bind_transfer[unfolded rel_fun_def, rule_format, unfolded unit_expand] that[unfolded rel_fun_def, rule_format] HOL.refl )+ [PROOF STATE] proof (state) this: crel_vs (=) () (iterate_state f (x # xs)) goal: No subgoals! [PROOF STEP] qed
# Global configuration settings "Configuration options" module config # Data directories "Location of the data files in this package" const datadir = normpath(joinpath(dirname(@__FILE__), "..", "data")) end include("config_defaults.jl")
T-to-≡ : ∀ {x} → T x → x ≡ true T-to-≡ {true} tx = refl ≡-to-T : ∀ {x} → x ≡ true → T x ≡-to-T {true} x≡true = tt ≤-to-→ : ∀ {x y} → x 𝔹.≤ y → T x → T y ≤-to-→ {true} {true} x≤y _ = tt →-to-≤ : ∀ {x y} → (T x → T y) → x 𝔹.≤ y →-to-≤ {false} {false} Tx→Ty = b≤b →-to-≤ {false} {true} Tx→Ty = f≤t →-to-≤ {true} {false} Tx→Ty = ⊥-elim (Tx→Ty tt) →-to-≤ {true} {true} Tx→Ty = b≤b toFun : (x : ℕ → Bool) → (∀ i → x (suc i) 𝔹.≤ x i) → ∀ i → T (x (suc i)) → T (x i) toFun x p i = ≤-to-→ (p i) fromFun : (x : ℕ → Bool) → (∀ i → T (x (suc i)) → T (x i)) → ∀ i → x (suc i) 𝔹.≤ x i fromFun _ f i = →-to-≤ (f i) Dec-T : ∀ b → Dec (T b) Dec-T false = no id Dec-T true = yes tt private _≈Decidable_ : ∀ {P Q : ℕ → Set} (P? : U.Decidable P) (Q? : U.Decidable Q) → Set P? ≈Decidable Q? = ∀ x → isYes (P? x) ≡ isYes (Q? x) make≈Decidable : {P Q : ℕ → Set} → (∀ x → P x → Q x) → (∀ x → Q x → P x) → (P? : U.Decidable P) (Q? : U.Decidable Q) → P? ≈Decidable Q? make≈Decidable P→Q Q→P P? Q? x with P? x | Q? x ... | yes p | yes q = refl ... | yes p | no ¬q = contradiction (P→Q _ p) ¬q ... | no ¬p | yes q = contradiction (Q→P _ q) ¬p ... | no ¬p | no ¬q = refl ℕ≤-all-dec′ : ∀ {P : ℕ → Set} → U.Decidable P → U.Decidable (λ n → ∀ i → i ≤ n → P i) ℕ≤-all-dec′ P? = DecU⇒decidable $ ℕ≤-all-dec (decidable⇒DecU P?) idem-map-Pred : (α : ℕ → Bool) → ℕ → Set idem-map-Pred α n = ∀ i → i ≤ n → T (α i) idem-map-Pred? : (α : ℕ → Bool) → U.Decidable (idem-map-Pred α) idem-map-Pred? α = ℕ≤-all-dec′ (λ i → Dec-T (α i)) idem-map : (ℕ → Bool) → (ℕ → Bool) idem-map α n = isYes (idem-map-Pred? α n) idem-map-idem : ∀ α → idem-map (idem-map α) ≈ idem-map α idem-map-idem α = make≈Decidable (λ n x i i≤n → {! !}) {! !} (idem-map-Pred? (λ n → isYes (idem-map-Pred? α n))) (idem-map-Pred? α) -- x : idem-map-Pred (λ n₁ → isYes (idem-map-Pred? α n₁)) n -- x : ∀ i → i ≤ n → T (isYes (idem-map-Pred? α i)) -- True toWitness -- hyp : idem-map-Pred α i -- hyp : ∀ i → -- Goal : ∀ i → i ≤ n → T (α i) -- idem-map α n -- isYes (ℕ-all-dec′ (λ i → Dec-⊤ (α i)) n) idem-map-image : ∀ α → let x = idem-map α in (∀ i → T (x (suc i)) → T (x i)) idem-map-image α n ppp with ℕ≤-all-dec′ (λ i → Dec-T (α i)) n ... | yes _ = {! !} ... | no _ = {! !}
/- Copyright (c) 2021 Yury G. Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury G. Kudryashov ! This file was ported from Lean 3 source module geometry.manifold.whitney_embedding ! leanprover-community/mathlib commit f2ce6086713c78a7f880485f7917ea547a215982 ! Please do not edit these lines, except to modify the commit id ! if you have ported upstream changes. -/ import Mathbin.Geometry.Manifold.Diffeomorph import Mathbin.Geometry.Manifold.Instances.Real import Mathbin.Geometry.Manifold.PartitionOfUnity /-! # Whitney embedding theorem In this file we prove a version of the Whitney embedding theorem: for any compact real manifold `M`, for sufficiently large `n` there exists a smooth embedding `M → ℝ^n`. ## TODO * Prove the weak Whitney embedding theorem: any `σ`-compact smooth `m`-dimensional manifold can be embedded into `ℝ^(2m+1)`. This requires a version of Sard's theorem: for a locally Lipschitz continuous map `f : ℝ^m → ℝ^n`, `m < n`, the range has Hausdorff dimension at most `m`, hence it has measure zero. ## Tags partition of unity, smooth bump function, whitney theorem -/ universe uι uE uH uM variable {ι : Type uι} {E : Type uE} [NormedAddCommGroup E] [NormedSpace ℝ E] [FiniteDimensional ℝ E] {H : Type uH} [TopologicalSpace H] {I : ModelWithCorners ℝ E H} {M : Type uM} [TopologicalSpace M] [ChartedSpace H M] [SmoothManifoldWithCorners I M] open Function Filter FiniteDimensional Set open Topology Manifold Classical Filter BigOperators noncomputable section namespace SmoothBumpCovering /-! ### Whitney embedding theorem In this section we prove a version of the Whitney embedding theorem: for any compact real manifold `M`, for sufficiently large `n` there exists a smooth embedding `M → ℝ^n`. -/ variable [T2Space M] [hi : Fintype ι] {s : Set M} (f : SmoothBumpCovering ι I M s) include hi /-- Smooth embedding of `M` into `(E × ℝ) ^ ι`. -/ def embeddingPiTangent : C^∞⟮I, M; 𝓘(ℝ, ι → E × ℝ), ι → E × ℝ⟯ where toFun x i := (f i x • extChartAt I (f.c i) x, f i x) contMdiff_toFun := contMdiff_pi_space.2 fun i => ((f i).smooth_smul contMdiffOn_extChartAt).prod_mk_space (f i).Smooth #align smooth_bump_covering.embedding_pi_tangent SmoothBumpCovering.embeddingPiTangent @[local simp] theorem embeddingPiTangent_coe : ⇑f.embeddingPiTangent = fun x i => (f i x • extChartAt I (f.c i) x, f i x) := rfl #align smooth_bump_covering.embedding_pi_tangent_coe SmoothBumpCovering.embeddingPiTangent_coe theorem embeddingPiTangent_injOn : InjOn f.embeddingPiTangent s := by intro x hx y hy h simp only [embedding_pi_tangent_coe, funext_iff] at h obtain ⟨h₁, h₂⟩ := Prod.mk.inj_iff.1 (h (f.ind x hx)) rw [f.apply_ind x hx] at h₂ rw [← h₂, f.apply_ind x hx, one_smul, one_smul] at h₁ have := f.mem_ext_chart_at_source_of_eq_one h₂.symm exact (extChartAt I (f.c _)).InjOn (f.mem_ext_chart_at_ind_source x hx) this h₁ #align smooth_bump_covering.embedding_pi_tangent_inj_on SmoothBumpCovering.embeddingPiTangent_injOn theorem embeddingPiTangent_injective (f : SmoothBumpCovering ι I M) : Injective f.embeddingPiTangent := injective_iff_injOn_univ.2 f.embeddingPiTangent_injOn #align smooth_bump_covering.embedding_pi_tangent_injective SmoothBumpCovering.embeddingPiTangent_injective theorem comp_embeddingPiTangent_mfderiv (x : M) (hx : x ∈ s) : ((ContinuousLinearMap.fst ℝ E ℝ).comp (@ContinuousLinearMap.proj ℝ _ ι (fun _ => E × ℝ) _ _ (fun _ => inferInstance) (f.ind x hx))).comp (mfderiv I 𝓘(ℝ, ι → E × ℝ) f.embeddingPiTangent x) = mfderiv I I (chartAt H (f.c (f.ind x hx))) x := by set L := (ContinuousLinearMap.fst ℝ E ℝ).comp (@ContinuousLinearMap.proj ℝ _ ι (fun _ => E × ℝ) _ _ (fun _ => inferInstance) (f.ind x hx)) have := L.has_mfderiv_at.comp x f.embedding_pi_tangent.mdifferentiable_at.has_mfderiv_at convert hasMfderivAt_unique this _ refine' (hasMfderivAt_extChartAt I (f.mem_chart_at_ind_source x hx)).congr_of_eventuallyEq _ refine' (f.eventually_eq_one x hx).mono fun y hy => _ simp only [embedding_pi_tangent_coe, ContinuousLinearMap.coe_comp', (· ∘ ·), ContinuousLinearMap.coe_fst', ContinuousLinearMap.proj_apply] rw [hy, Pi.one_apply, one_smul] #align smooth_bump_covering.comp_embedding_pi_tangent_mfderiv SmoothBumpCovering.comp_embeddingPiTangent_mfderiv theorem embeddingPiTangent_ker_mfderiv (x : M) (hx : x ∈ s) : LinearMap.ker (mfderiv I 𝓘(ℝ, ι → E × ℝ) f.embeddingPiTangent x) = ⊥ := by apply bot_unique rw [← (mdifferentiable_chart I (f.c (f.ind x hx))).ker_mfderiv_eq_bot (f.mem_chart_at_ind_source x hx), ← comp_embedding_pi_tangent_mfderiv] exact LinearMap.ker_le_ker_comp _ _ #align smooth_bump_covering.embedding_pi_tangent_ker_mfderiv SmoothBumpCovering.embeddingPiTangent_ker_mfderiv theorem embeddingPiTangent_injective_mfderiv (x : M) (hx : x ∈ s) : Injective (mfderiv I 𝓘(ℝ, ι → E × ℝ) f.embeddingPiTangent x) := LinearMap.ker_eq_bot.1 (f.embeddingPiTangent_ker_mfderiv x hx) #align smooth_bump_covering.embedding_pi_tangent_injective_mfderiv SmoothBumpCovering.embeddingPiTangent_injective_mfderiv omit hi /-- Baby version of the **Whitney weak embedding theorem**: if `M` admits a finite covering by supports of bump functions, then for some `n` it can be immersed into the `n`-dimensional Euclidean space. -/ theorem exists_immersion_euclidean [Finite ι] (f : SmoothBumpCovering ι I M) : ∃ (n : ℕ)(e : M → EuclideanSpace ℝ (Fin n)), Smooth I (𝓡 n) e ∧ Injective e ∧ ∀ x : M, Injective (mfderiv I (𝓡 n) e x) := by cases nonempty_fintype ι set F := EuclideanSpace ℝ (Fin <| finrank ℝ (ι → E × ℝ)) letI : IsNoetherian ℝ (E × ℝ) := IsNoetherian.iff_fg.2 inferInstance letI : FiniteDimensional ℝ (ι → E × ℝ) := IsNoetherian.iff_fg.1 inferInstance set eEF : (ι → E × ℝ) ≃L[ℝ] F := ContinuousLinearEquiv.ofFinrankEq finrank_euclidean_space_fin.symm refine' ⟨_, eEF ∘ f.embedding_pi_tangent, eEF.to_diffeomorph.smooth.comp f.embedding_pi_tangent.smooth, eEF.injective.comp f.embedding_pi_tangent_injective, fun x => _⟩ rw [mfderiv_comp _ eEF.differentiable_at.mdifferentiable_at f.embedding_pi_tangent.mdifferentiable_at, eEF.mfderiv_eq] exact eEF.injective.comp (f.embedding_pi_tangent_injective_mfderiv _ trivial) #align smooth_bump_covering.exists_immersion_euclidean SmoothBumpCovering.exists_immersion_euclidean end SmoothBumpCovering /-- Baby version of the Whitney weak embedding theorem: if `M` admits a finite covering by supports of bump functions, then for some `n` it can be embedded into the `n`-dimensional Euclidean space. -/ theorem exists_embedding_euclidean_of_compact [T2Space M] [CompactSpace M] : ∃ (n : ℕ)(e : M → EuclideanSpace ℝ (Fin n)), Smooth I (𝓡 n) e ∧ ClosedEmbedding e ∧ ∀ x : M, Injective (mfderiv I (𝓡 n) e x) := by rcases SmoothBumpCovering.exists_isSubordinate I isClosed_univ fun (x : M) _ => univ_mem with ⟨ι, f, -⟩ haveI := f.fintype rcases f.exists_immersion_euclidean with ⟨n, e, hsmooth, hinj, hinj_mfderiv⟩ exact ⟨n, e, hsmooth, hsmooth.continuous.closed_embedding hinj, hinj_mfderiv⟩ #align exists_embedding_euclidean_of_compact exists_embedding_euclidean_of_compact
/** * * @file core_dgbelr.c * * PLASMA core_blas kernel * PLASMA is a software package provided by Univ. of Tennessee, * Univ. of California Berkeley and Univ. of Colorado Denver * * @version 2.6.0 * @author Azzam Haidar * @date 2011-05-15 * @generated d Tue Jan 7 11:44:50 2014 * **/ #include <lapacke.h> #include "common.h" #define A(_m, _n) (double *)plasma_geteltaddr(A, ((_m)-1), ((_n)-1), eltsize) #define V(_m) &(V[(_m)-1]) #define TAU(_m) &(TAU[(_m)-1]) /***************************************************************************//** * * @ingroup CORE_double * * CORE_dgbelr is a kernel that will operate on a region (triangle) of data * bounded by st and ed. This kernel eliminate a column by an element-wise * annihiliation, and for each annihiliation, it apply a left update, followed * by an right update on the diagonal 2x2 element, where it create a new nnz, * eliminate it and update V and TAU, then it continue until finishing the the * whole column. When this is done, it take advantage that data are on cache * and will apply the right on the remaining part of this region that has not * been updated by the right yet. * Note that the column to be eliminated is located at st-1. * ******************************************************************************* * * @param[in] uplo * @arg PlasmaLower: * @arg PlasmaUpper: * * @param[in] N * The order of the matrix A. * * @param[in, out] A * A pointer to the descriptor of the matrix A. * * @param[out] V * double array, dimension (N). * The scalar elementary reflectors are written in this * array. So it is used as a workspace for V at each step * of the bulge chasing algorithm. * * @param[out] TAU * double array, dimension (N). * The scalar factors of the elementary reflectors are written * in thisarray. So it is used as a workspace for TAU at each step * of the bulge chasing algorithm. * * @param[in] st * A pointer to the start index where this kernel will operate. * * @param[in] ed * A pointer to the end index where this kernel will operate. * * @param[in] eltsize * PLASMA internal value which refer to the size of the precision. * ******************************************************************************* * * @return * \retval PLASMA_SUCCESS successful exit * \retval <0 if -i, the i-th argument had an illegal value * ******************************************************************************/ /***************************************************************************//** * TYPE 1-BDL Householder * add -1 because of C ******************************************************************************/ int CORE_dgbelr(PLASMA_enum uplo, int N, PLASMA_desc *A, double *V, double *TAU, int st, int ed, int eltsize) { int NB, J1, J2; int len1, len2, t1ed, t2st; int i; static double zzero = 0.0; PLASMA_desc vA=*A; /* Check input arguments */ if (N < 0) { coreblas_error(2, "Illegal value of N"); return -2; } if (ed <= st) { coreblas_error(6, "Illegal value of st and ed (internal)"); return -6; } /* Quick return */ if (N == 0) return PLASMA_SUCCESS; NB = A->mb; if( uplo == PlasmaLower ){ /* ======================== * LOWER CASE * ========================*/ for (i = ed; i >= st+1 ; i--){ /* generate Householder to annihilate a(i+k-1,i) within the band*/ *V(i) = *A(i, (st-1)); *A(i, (st-1)) = zzero; LAPACKE_dlarfg_work( 2, A((i-1),(st-1)), V(i), 1, TAU(i)); /* apply reflector from the left (horizontal row) and from the right for only the diagonal 2x2.*/ J1 = st; J2 = i-2; t1ed = (J2/NB)*NB; t2st = max(t1ed+1,J1); len1 = t1ed-J1+1; len2 = J2-t2st+1; if(len1>0)CORE_dlarfx2(PlasmaLeft, len1 , *V(i), (*TAU(i)), A(i-1, J1 ), ELTLDD(vA, (i-1)), A(i, J1 ), ELTLDD(vA, i) ); if(len2>0)CORE_dlarfx2(PlasmaLeft, len2 , *V(i), (*TAU(i)), A(i-1, t2st), ELTLDD(vA, (i-1)), A(i, t2st), ELTLDD(vA, i) ); CORE_dlarfx2ce(PlasmaLower, V(i), TAU(i), A(i-1,i-1), A(i,i-1), A(i,i)); } /* APPLY RIGHT ON THE REMAINING ELEMENT OF KERNEL 1 */ for (i = ed; i >= st+1 ; i--){ J1 = i+1; J2 = min(ed,N); t1ed = (J2/NB)*NB; t2st = max(t1ed+1,J1); len1 = t1ed-J1+1; len2 = J2-t2st+1; if(len1>0)CORE_dlarfx2(PlasmaRight, len1, (*V(i)), (*TAU(i)), A(J1,i-1), ELTLDD(vA, J1) , A(J1 , i), ELTLDD(vA, J1) ); if(len2>0)CORE_dlarfx2(PlasmaRight, len2, (*V(i)), (*TAU(i)), A(t2st,i-1), ELTLDD(vA, t2st), A(t2st, i), ELTLDD(vA, t2st) ); } } else { /* ======================== * UPPER CASE * ========================*/ for (i = ed; i >= st+1 ; i--){ /* generate Householder to annihilate a(i+k-1,i) within the band*/ *V(i) = *A((st-1), i); *A((st-1), i) = zzero; LAPACKE_dlarfg_work( 2, A((st-1), (i-1)), V(i), 1, TAU(i)); /* apply reflector from the left (horizontal row) and from the right for only the diagonal 2x2.*/ J1 = st; J2 = i-2; t1ed = (J2/NB)*NB; t2st = max(t1ed+1,J1); len1 = t1ed-J1+1; len2 = J2-t2st+1; if(len1>0)CORE_dlarfx2(PlasmaRight, len1, (*V(i)), (*TAU(i)), A(J1,i-1), ELTLDD(vA, J1) , A(J1 , i), ELTLDD(vA, J1) ); if(len2>0)CORE_dlarfx2(PlasmaRight, len2, (*V(i)), (*TAU(i)), A(t2st,i-1), ELTLDD(vA, t2st), A(t2st, i), ELTLDD(vA, t2st) ); CORE_dlarfx2ce(PlasmaUpper, V(i), TAU(i), A((i-1),(i-1)), A((i-1), i), A(i,i)); } /* APPLY LEFT ON THE REMAINING ELEMENT OF KERNEL 1*/ for (i = ed; i >= st+1 ; i--){ J1 = i+1; J2 = min(ed,N); t1ed = (J2/NB)*NB; t2st = max(t1ed+1,J1); len1 = t1ed-J1+1; len2 = J2-t2st+1; if(len1>0)CORE_dlarfx2(PlasmaLeft, len1 , *V(i), (*TAU(i)), A(i-1, J1 ), ELTLDD(vA, (i-1)), A(i, J1 ), ELTLDD(vA, i) ); if(len2>0)CORE_dlarfx2(PlasmaLeft, len2 , *V(i), (*TAU(i)), A(i-1, t2st), ELTLDD(vA, (i-1)), A(i, t2st), ELTLDD(vA, i) ); } } /* end of else for the upper case*/ return PLASMA_SUCCESS; }
import ring_theory.coprime import data.real.basic import data.nat.modeq open nat noncomputable theory namespace fermat def is_sum_of_relprime_squares (n:ℕ) := ∃ a b, n = a^2 + b^2 ∧ gcd a b = 1. theorem lem_1_4 (N q: ℕ) : is_sum_of_relprime_squares N → nat.prime q → is_sum_of_relprime_squares q → q ∣ N → is_sum_of_relprime_squares (N/q) := begin intros Hrel Hqprime Hqsq Hqdiv, unfold is_sum_of_relprime_squares at Hrel, cases Hrel with a Hrel, cases Hrel with b Hrel, cases Hrel with H1 H2, sorry end theorem strong_induction {p : ℕ → Prop} (n : ℕ) (h : ∀ (k : ℕ), (∀ (m : ℕ), m < k → p m) → p k) : p n := sorry. -- induction on N, then induction on p -- theorem descent_wolog (p N : ℕ) : N > 0 → prime p → p ∣ N → is_sum_of_relprime_squares N → is_sum_of_relprime_squares p:= begin revert N, apply strong_induction p, intros p Hih1 N, apply strong_induction N, clear N, intros Ntemp Hih2, intros HNpos Hprime Hdiv Hsum, have HN : ∃ N, 0 < N ∧ is_sum_of_relprime_squares N ∧ p ∣ N ∧ N < p^2/2, { sorry, }, clear Hdiv Hsum, rcases HN with ⟨N, HNpos, Hsum, Hdiv, Hle⟩, have Hcases : (N = p ∨ p < N), { let H : _ := nat.le_of_dvd HNpos Hdiv, -- This shouldn't be so complicated. by_contra, push_neg at h, have h2 : (p = N), { exact le_antisymm H h.2, }, rw h2 at h, let H := h.1, contradiction, }, cases Hcases with Heasy HpltN, { -- case N = p; easy! rw ←Heasy, assumption, }, { -- case p < N -- show that there's a smaller prime factor q have Hq : ∃ q, prime q ∧ q ∣ N ∧ q < p, { -- split into cases using dite exact dite (N.factors = [p]) (begin -- case p is the only prime factor; contradiction intros Hps2, let h2 := prod_factors HNpos, rewrite Hps2 at h2, simp at h2, exfalso, linarith end ) (begin -- case that there are factors other than p let Hpfactor := (mem_factors HNpos).2 ⟨Hprime, Hdiv⟩, have Hp : [p] ⊆ N.factors, { sorry, }, intros HNp, have Hothers : ∀ q ∈ (N/p).factors, q < p, { sorry, }, have Hp : ¬((N/p).factors = list.nil), { sorry }, set qs := (N/p).factors, destruct qs, { sorry }, -- contradiction { intros q _ Hqs, specialize Hothers q _, { rewrite Hqs, simp }, existsi q, let Hy := (nat.mem_factors HNpos).1 _, swap, { exact q }, swap, { -- q ∈ (N/p).factors → q ∈ N.factors sorry, }, { have Hyy : prime q ∧ q ∣ N, { exact Hy }, cases Hyy with Hqprime Hqdiv, split, { assumption }, split, { assumption }, { assumption }, }, } end ) }, -- use lemma 1.4 to show that p | (N/q) and N/q is also a sum of squares of rel prime integers cases Hq with q Hq, specialize Hih1 q Hq.2.2 N HNpos Hq.1 Hq.2.1 Hsum, -- by our strong induction on N (Hih2), we'll be done apply Hih2 (N/q), { sorry, }, { -- Prove that N/q is non-negative sorry }, { assumption }, { sorry }, { apply lem_1_4 N q Hsum Hq.1 Hih1 Hq.2.1, } } end theorem descent (p x y : ℕ) : p ∣ x^2 + y^2 → gcd x y = 1 → ∃ z w, p = z^2 + w^2 := begin intros Hp Hrel, sorry end -- Reciprocity step theorem reciprocity (p : ℕ) : prime p → 1 ≡ p [MOD 4] → ∃ N, N > 0 ∧ p ∣ N ∧ is_sum_of_relprime_squares N := begin intros Hprime Hpmod, rw modeq.modeq_iff_dvd' at Hpmod, swap, { sorry, }, rcases Hpmod with ⟨k, Hpmod⟩, have Hp : p = 4 * k + 1, { unfold prime at Hprime, rcases Hprime with ⟨Hpineq, _⟩, sorry, }, have h₁ : ∀ x, x ≠ 0 → (x^(2 * k) - 1) * (x^(2*k) + 1) ≡ 0 [MOD p], { sorry }, sorry end theorem fermat (p : ℕ) : prime p → 1 ≡ p [MOD 4] → ∃ a b, p = a^2 + b^2 := begin intros Hprime Hpmod, rcases (reciprocity p Hprime Hpmod) with ⟨N, HNpos, Hdiv, Hsum⟩, rcases (descent_wolog p N HNpos Hprime Hdiv Hsum) with ⟨a, b, Hsum, _⟩, existsi a, existsi b, assumption end end fermat
<unk> <unk> Harvey , which originated in Australia and was first recorded by M. De Valera in 1939
[GOAL] R : Type u_1 inst✝³ : Ring R M : Type u_2 inst✝² : AddCommGroup M inst✝¹ : Module R M inst✝ : IsSimpleModule R M ⊢ ∃ y, 0 ≠ y [PROOFSTEP] have h : (⊥ : Submodule R M) ≠ ⊤ := bot_ne_top [GOAL] R : Type u_1 inst✝³ : Ring R M : Type u_2 inst✝² : AddCommGroup M inst✝¹ : Module R M inst✝ : IsSimpleModule R M h : ⊥ ≠ ⊤ ⊢ ∃ y, 0 ≠ y [PROOFSTEP] contrapose! h [GOAL] R : Type u_1 inst✝³ : Ring R M : Type u_2 inst✝² : AddCommGroup M inst✝¹ : Module R M inst✝ : IsSimpleModule R M h : ∀ (y : M), 0 = y ⊢ ⊥ = ⊤ [PROOFSTEP] ext x [GOAL] case h R : Type u_1 inst✝³ : Ring R M : Type u_2 inst✝² : AddCommGroup M inst✝¹ : Module R M inst✝ : IsSimpleModule R M h : ∀ (y : M), 0 = y x : M ⊢ x ∈ ⊥ ↔ x ∈ ⊤ [PROOFSTEP] simp [Submodule.mem_bot, Submodule.mem_top, h x] [GOAL] R : Type u_1 inst✝⁴ : Ring R M : Type u_2 inst✝³ : AddCommGroup M inst✝² : Module R M m : Submodule R M N : Type u_3 inst✝¹ : AddCommGroup N inst✝ : Module R N ⊢ IsSimpleModule R { x // x ∈ m } ↔ IsAtom m [PROOFSTEP] rw [← Set.isSimpleOrder_Iic_iff_isAtom] [GOAL] R : Type u_1 inst✝⁴ : Ring R M : Type u_2 inst✝³ : AddCommGroup M inst✝² : Module R M m : Submodule R M N : Type u_3 inst✝¹ : AddCommGroup N inst✝ : Module R N ⊢ IsSimpleModule R { x // x ∈ m } ↔ IsSimpleOrder ↑(Set.Iic m) [PROOFSTEP] apply OrderIso.isSimpleOrder_iff [GOAL] case f R : Type u_1 inst✝⁴ : Ring R M : Type u_2 inst✝³ : AddCommGroup M inst✝² : Module R M m : Submodule R M N : Type u_3 inst✝¹ : AddCommGroup N inst✝ : Module R N ⊢ Submodule R { x // x ∈ m } ≃o ↑(Set.Iic m) [PROOFSTEP] exact Submodule.MapSubtype.relIso m [GOAL] R : Type u_1 inst✝⁴ : Ring R M : Type u_2 inst✝³ : AddCommGroup M inst✝² : Module R M m : Submodule R M N : Type u_3 inst✝¹ : AddCommGroup N inst✝ : Module R N ⊢ IsSimpleModule R (M ⧸ m) ↔ IsCoatom m [PROOFSTEP] rw [← Set.isSimpleOrder_Ici_iff_isCoatom] [GOAL] R : Type u_1 inst✝⁴ : Ring R M : Type u_2 inst✝³ : AddCommGroup M inst✝² : Module R M m : Submodule R M N : Type u_3 inst✝¹ : AddCommGroup N inst✝ : Module R N ⊢ IsSimpleModule R (M ⧸ m) ↔ IsSimpleOrder ↑(Set.Ici m) [PROOFSTEP] apply OrderIso.isSimpleOrder_iff [GOAL] case f R : Type u_1 inst✝⁴ : Ring R M : Type u_2 inst✝³ : AddCommGroup M inst✝² : Module R M m : Submodule R M N : Type u_3 inst✝¹ : AddCommGroup N inst✝ : Module R N ⊢ Submodule R (M ⧸ m) ≃o ↑(Set.Ici m) [PROOFSTEP] exact Submodule.comapMkQRelIso m [GOAL] R : Type u_1 inst✝⁴ : Ring R M : Type u_2 inst✝³ : AddCommGroup M inst✝² : Module R M m : Submodule R M N : Type u_3 inst✝¹ : AddCommGroup N inst✝ : Module R N A B : Submodule R M hAB : A ≤ B ⊢ A ⋖ B ↔ IsSimpleModule R ({ x // x ∈ B } ⧸ Submodule.comap (Submodule.subtype B) A) [PROOFSTEP] set f : Submodule R B ≃o Set.Iic B := Submodule.MapSubtype.relIso B with hf [GOAL] R : Type u_1 inst✝⁴ : Ring R M : Type u_2 inst✝³ : AddCommGroup M inst✝² : Module R M m : Submodule R M N : Type u_3 inst✝¹ : AddCommGroup N inst✝ : Module R N A B : Submodule R M hAB : A ≤ B f : Submodule R { x // x ∈ B } ≃o ↑(Set.Iic B) := Submodule.MapSubtype.relIso B hf : f = Submodule.MapSubtype.relIso B ⊢ A ⋖ B ↔ IsSimpleModule R ({ x // x ∈ B } ⧸ Submodule.comap (Submodule.subtype B) A) [PROOFSTEP] rw [covby_iff_coatom_Iic hAB, isSimpleModule_iff_isCoatom, ← OrderIso.isCoatom_iff f, hf] [GOAL] R : Type u_1 inst✝⁴ : Ring R M : Type u_2 inst✝³ : AddCommGroup M inst✝² : Module R M m : Submodule R M N : Type u_3 inst✝¹ : AddCommGroup N inst✝ : Module R N A B : Submodule R M hAB : A ≤ B f : Submodule R { x // x ∈ B } ≃o ↑(Set.Iic B) := Submodule.MapSubtype.relIso B hf : f = Submodule.MapSubtype.relIso B ⊢ IsCoatom { val := A, property := hAB } ↔ IsCoatom (↑(Submodule.MapSubtype.relIso B) (Submodule.comap (Submodule.subtype B) A)) [PROOFSTEP] simp [-OrderIso.isCoatom_iff, Submodule.MapSubtype.relIso, Submodule.map_comap_subtype, inf_eq_right.2 hAB] [GOAL] R : Type u_1 inst✝⁴ : Ring R M : Type u_2 inst✝³ : AddCommGroup M inst✝² : Module R M m : Submodule R M N : Type u_3 inst✝¹ : AddCommGroup N inst✝ : Module R N h : sSup {m | IsSimpleModule R { x // x ∈ m }} = ⊤ ⊢ sSup {a | IsAtom a} = ⊤ [PROOFSTEP] simp_rw [← h, isSimpleModule_iff_isAtom] [GOAL] R : Type u_1 inst✝⁵ : Ring R M : Type u_2 inst✝⁴ : AddCommGroup M inst✝³ : Module R M m : Submodule R M N : Type u_3 inst✝² : AddCommGroup N inst✝¹ : Module R N inst✝ : IsSemisimpleModule R M ⊢ sSup {m | IsSimpleModule R { x // x ∈ m }} = ⊤ [PROOFSTEP] simp_rw [isSimpleModule_iff_isAtom] [GOAL] R : Type u_1 inst✝⁵ : Ring R M : Type u_2 inst✝⁴ : AddCommGroup M inst✝³ : Module R M m : Submodule R M N : Type u_3 inst✝² : AddCommGroup N inst✝¹ : Module R N inst✝ : IsSemisimpleModule R M ⊢ sSup {m | IsAtom m} = ⊤ [PROOFSTEP] exact sSup_atoms_eq_top [GOAL] R : Type u_1 inst✝⁴ : Ring R M : Type u_2 inst✝³ : AddCommGroup M inst✝² : Module R M m : Submodule R M N : Type u_3 inst✝¹ : AddCommGroup N inst✝ : Module R N ⊢ IsSemisimpleModule R M → sSup {m | IsSimpleModule R { x // x ∈ m }} = ⊤ [PROOFSTEP] intro [GOAL] R : Type u_1 inst✝⁴ : Ring R M : Type u_2 inst✝³ : AddCommGroup M inst✝² : Module R M m : Submodule R M N : Type u_3 inst✝¹ : AddCommGroup N inst✝ : Module R N a✝ : IsSemisimpleModule R M ⊢ sSup {m | IsSimpleModule R { x // x ∈ m }} = ⊤ [PROOFSTEP] exact IsSemisimpleModule.sSup_simples_eq_top [GOAL] R : Type u_1 inst✝⁵ : Ring R M : Type u_2 inst✝⁴ : AddCommGroup M inst✝³ : Module R M m : Submodule R M N : Type u_3 inst✝² : AddCommGroup N inst✝¹ : Module R N inst✝ : IsSimpleModule R M f : M →ₗ[R] N ⊢ Function.Injective ↑f ∨ f = 0 [PROOFSTEP] rw [← ker_eq_bot, ← ker_eq_top] [GOAL] R : Type u_1 inst✝⁵ : Ring R M : Type u_2 inst✝⁴ : AddCommGroup M inst✝³ : Module R M m : Submodule R M N : Type u_3 inst✝² : AddCommGroup N inst✝¹ : Module R N inst✝ : IsSimpleModule R M f : M →ₗ[R] N ⊢ ker f = ⊥ ∨ ker f = ⊤ [PROOFSTEP] apply eq_bot_or_eq_top [GOAL] R : Type u_1 inst✝⁵ : Ring R M : Type u_2 inst✝⁴ : AddCommGroup M inst✝³ : Module R M m : Submodule R M N : Type u_3 inst✝² : AddCommGroup N inst✝¹ : Module R N inst✝ : IsSimpleModule R N f : M →ₗ[R] N ⊢ Function.Surjective ↑f ∨ f = 0 [PROOFSTEP] rw [← range_eq_top, ← range_eq_bot, or_comm] [GOAL] R : Type u_1 inst✝⁵ : Ring R M : Type u_2 inst✝⁴ : AddCommGroup M inst✝³ : Module R M m : Submodule R M N : Type u_3 inst✝² : AddCommGroup N inst✝¹ : Module R N inst✝ : IsSimpleModule R N f : M →ₗ[R] N ⊢ range f = ⊥ ∨ range f = ⊤ [PROOFSTEP] apply eq_bot_or_eq_top [GOAL] R : Type u_1 inst✝⁶ : Ring R M : Type u_2 inst✝⁵ : AddCommGroup M inst✝⁴ : Module R M m : Submodule R M N : Type u_3 inst✝³ : AddCommGroup N inst✝² : Module R N inst✝¹ : IsSimpleModule R M inst✝ : IsSimpleModule R N f : M →ₗ[R] N ⊢ Function.Bijective ↑f ∨ f = 0 [PROOFSTEP] by_cases h : f = 0 [GOAL] case pos R : Type u_1 inst✝⁶ : Ring R M : Type u_2 inst✝⁵ : AddCommGroup M inst✝⁴ : Module R M m : Submodule R M N : Type u_3 inst✝³ : AddCommGroup N inst✝² : Module R N inst✝¹ : IsSimpleModule R M inst✝ : IsSimpleModule R N f : M →ₗ[R] N h : f = 0 ⊢ Function.Bijective ↑f ∨ f = 0 [PROOFSTEP] right [GOAL] case pos.h R : Type u_1 inst✝⁶ : Ring R M : Type u_2 inst✝⁵ : AddCommGroup M inst✝⁴ : Module R M m : Submodule R M N : Type u_3 inst✝³ : AddCommGroup N inst✝² : Module R N inst✝¹ : IsSimpleModule R M inst✝ : IsSimpleModule R N f : M →ₗ[R] N h : f = 0 ⊢ f = 0 [PROOFSTEP] exact h [GOAL] case neg R : Type u_1 inst✝⁶ : Ring R M : Type u_2 inst✝⁵ : AddCommGroup M inst✝⁴ : Module R M m : Submodule R M N : Type u_3 inst✝³ : AddCommGroup N inst✝² : Module R N inst✝¹ : IsSimpleModule R M inst✝ : IsSimpleModule R N f : M →ₗ[R] N h : ¬f = 0 ⊢ Function.Bijective ↑f ∨ f = 0 [PROOFSTEP] exact Or.intro_left _ ⟨injective_of_ne_zero h, surjective_of_ne_zero h⟩ [GOAL] R : Type u_1 inst✝⁵ : Ring R M : Type u_2 inst✝⁴ : AddCommGroup M inst✝³ : Module R M m : Submodule R M N : Type u_3 inst✝² : AddCommGroup N inst✝¹ : Module R N inst✝ : IsSimpleModule R N f : M →ₗ[R] N hf : Function.Surjective ↑f ⊢ IsCoatom (ker f) [PROOFSTEP] rw [← isSimpleModule_iff_isCoatom] [GOAL] R : Type u_1 inst✝⁵ : Ring R M : Type u_2 inst✝⁴ : AddCommGroup M inst✝³ : Module R M m : Submodule R M N : Type u_3 inst✝² : AddCommGroup N inst✝¹ : Module R N inst✝ : IsSimpleModule R N f : M →ₗ[R] N hf : Function.Surjective ↑f ⊢ IsSimpleModule R (M ⧸ ker f) [PROOFSTEP] exact IsSimpleModule.congr (f.quotKerEquivOfSurjective hf) [GOAL] R : Type u_1 inst✝⁶ : Ring R M : Type u_2 inst✝⁵ : AddCommGroup M inst✝⁴ : Module R M m : Submodule R M N : Type u_3 inst✝³ : AddCommGroup N inst✝² : Module R N inst✝¹ : DecidableEq (Module.End R M) inst✝ : IsSimpleModule R M src✝ : Ring (Module.End R M) := Module.End.ring ⊢ 0 ≠ 1 [PROOFSTEP] haveI := IsSimpleModule.nontrivial R M [GOAL] R : Type u_1 inst✝⁶ : Ring R M : Type u_2 inst✝⁵ : AddCommGroup M inst✝⁴ : Module R M m : Submodule R M N : Type u_3 inst✝³ : AddCommGroup N inst✝² : Module R N inst✝¹ : DecidableEq (Module.End R M) inst✝ : IsSimpleModule R M src✝ : Ring (Module.End R M) := Module.End.ring this : Nontrivial M ⊢ 0 ≠ 1 [PROOFSTEP] have h := exists_pair_ne M [GOAL] R : Type u_1 inst✝⁶ : Ring R M : Type u_2 inst✝⁵ : AddCommGroup M inst✝⁴ : Module R M m : Submodule R M N : Type u_3 inst✝³ : AddCommGroup N inst✝² : Module R N inst✝¹ : DecidableEq (Module.End R M) inst✝ : IsSimpleModule R M src✝ : Ring (Module.End R M) := Module.End.ring this : Nontrivial M h : ∃ x y, x ≠ y ⊢ 0 ≠ 1 [PROOFSTEP] contrapose! h [GOAL] R : Type u_1 inst✝⁶ : Ring R M : Type u_2 inst✝⁵ : AddCommGroup M inst✝⁴ : Module R M m : Submodule R M N : Type u_3 inst✝³ : AddCommGroup N inst✝² : Module R N inst✝¹ : DecidableEq (Module.End R M) inst✝ : IsSimpleModule R M src✝ : Ring (Module.End R M) := Module.End.ring this : Nontrivial M h : 0 = 1 ⊢ ∀ (x y : M), x = y [PROOFSTEP] intro x y [GOAL] R : Type u_1 inst✝⁶ : Ring R M : Type u_2 inst✝⁵ : AddCommGroup M inst✝⁴ : Module R M m : Submodule R M N : Type u_3 inst✝³ : AddCommGroup N inst✝² : Module R N inst✝¹ : DecidableEq (Module.End R M) inst✝ : IsSimpleModule R M src✝ : Ring (Module.End R M) := Module.End.ring this : Nontrivial M h : 0 = 1 x y : M ⊢ x = y [PROOFSTEP] simp_rw [ext_iff, one_apply, zero_apply] at h [GOAL] R : Type u_1 inst✝⁶ : Ring R M : Type u_2 inst✝⁵ : AddCommGroup M inst✝⁴ : Module R M m : Submodule R M N : Type u_3 inst✝³ : AddCommGroup N inst✝² : Module R N inst✝¹ : DecidableEq (Module.End R M) inst✝ : IsSimpleModule R M src✝ : Ring (Module.End R M) := Module.End.ring this : Nontrivial M x y : M h : ∀ (x : M), 0 = x ⊢ x = y [PROOFSTEP] rw [← h x, h y] [GOAL] R : Type u_1 inst✝⁶ : Ring R M : Type u_2 inst✝⁵ : AddCommGroup M inst✝⁴ : Module R M m : Submodule R M N : Type u_3 inst✝³ : AddCommGroup N inst✝² : Module R N inst✝¹ : DecidableEq (Module.End R M) inst✝ : IsSimpleModule R M src✝ : Ring (Module.End R M) := Module.End.ring ⊢ ∀ (a : Module.End R M), a ≠ 0 → a * a⁻¹ = 1 [PROOFSTEP] intro a a0 [GOAL] R : Type u_1 inst✝⁶ : Ring R M : Type u_2 inst✝⁵ : AddCommGroup M inst✝⁴ : Module R M m : Submodule R M N : Type u_3 inst✝³ : AddCommGroup N inst✝² : Module R N inst✝¹ : DecidableEq (Module.End R M) inst✝ : IsSimpleModule R M src✝ : Ring (Module.End R M) := Module.End.ring a : Module.End R M a0 : a ≠ 0 ⊢ a * a⁻¹ = 1 [PROOFSTEP] change a * dite _ _ _ = 1 [GOAL] R : Type u_1 inst✝⁶ : Ring R M : Type u_2 inst✝⁵ : AddCommGroup M inst✝⁴ : Module R M m : Submodule R M N : Type u_3 inst✝³ : AddCommGroup N inst✝² : Module R N inst✝¹ : DecidableEq (Module.End R M) inst✝ : IsSimpleModule R M src✝ : Ring (Module.End R M) := Module.End.ring a : Module.End R M a0 : a ≠ 0 ⊢ (a * if h : a = 0 then 0 else inverse a (Equiv.ofBijective ↑a (_ : Function.Bijective ↑a)).invFun (_ : Function.LeftInverse (Equiv.ofBijective ↑a (_ : Function.Bijective ↑a)).invFun (Equiv.ofBijective ↑a (_ : Function.Bijective ↑a)).toFun) (_ : Function.RightInverse (Equiv.ofBijective ↑a (_ : Function.Bijective ↑a)).invFun (Equiv.ofBijective ↑a (_ : Function.Bijective ↑a)).toFun)) = 1 [PROOFSTEP] ext x [GOAL] case h R : Type u_1 inst✝⁶ : Ring R M : Type u_2 inst✝⁵ : AddCommGroup M inst✝⁴ : Module R M m : Submodule R M N : Type u_3 inst✝³ : AddCommGroup N inst✝² : Module R N inst✝¹ : DecidableEq (Module.End R M) inst✝ : IsSimpleModule R M src✝ : Ring (Module.End R M) := Module.End.ring a : Module.End R M a0 : a ≠ 0 x : M ⊢ ↑(a * if h : a = 0 then 0 else inverse a (Equiv.ofBijective ↑a (_ : Function.Bijective ↑a)).invFun (_ : Function.LeftInverse (Equiv.ofBijective ↑a (_ : Function.Bijective ↑a)).invFun (Equiv.ofBijective ↑a (_ : Function.Bijective ↑a)).toFun) (_ : Function.RightInverse (Equiv.ofBijective ↑a (_ : Function.Bijective ↑a)).invFun (Equiv.ofBijective ↑a (_ : Function.Bijective ↑a)).toFun)) x = ↑1 x [PROOFSTEP] rw [dif_neg a0, mul_eq_comp, one_apply, comp_apply] [GOAL] case h R : Type u_1 inst✝⁶ : Ring R M : Type u_2 inst✝⁵ : AddCommGroup M inst✝⁴ : Module R M m : Submodule R M N : Type u_3 inst✝³ : AddCommGroup N inst✝² : Module R N inst✝¹ : DecidableEq (Module.End R M) inst✝ : IsSimpleModule R M src✝ : Ring (Module.End R M) := Module.End.ring a : Module.End R M a0 : a ≠ 0 x : M ⊢ ↑a (↑(inverse a (Equiv.ofBijective ↑a (_ : Function.Bijective ↑a)).invFun (_ : Function.LeftInverse (Equiv.ofBijective ↑a (_ : Function.Bijective ↑a)).invFun (Equiv.ofBijective ↑a (_ : Function.Bijective ↑a)).toFun) (_ : Function.RightInverse (Equiv.ofBijective ↑a (_ : Function.Bijective ↑a)).invFun (Equiv.ofBijective ↑a (_ : Function.Bijective ↑a)).toFun)) x) = x [PROOFSTEP] exact (Equiv.ofBijective _ (bijective_of_ne_zero a0)).right_inv x [GOAL] R : Type u_1 inst✝⁴ : Ring R M : Type u_2 inst✝³ : AddCommGroup M inst✝² : Module R M m : Submodule R M N : Type u_3 inst✝¹ : AddCommGroup N inst✝ : Module R N X Y : Submodule R M x✝ : X ⋖ X ⊔ Y ⊢ Iso (X, X ⊔ Y) (X ⊓ Y, Y) [PROOFSTEP] constructor [GOAL] case val R : Type u_1 inst✝⁴ : Ring R M : Type u_2 inst✝³ : AddCommGroup M inst✝² : Module R M m : Submodule R M N : Type u_3 inst✝¹ : AddCommGroup N inst✝ : Module R N X Y : Submodule R M x✝ : X ⋖ X ⊔ Y ⊢ ({ x // x ∈ (X, X ⊔ Y).snd } ⧸ Submodule.comap (Submodule.subtype (X, X ⊔ Y).snd) (X, X ⊔ Y).fst) ≃ₗ[R] { x // x ∈ (X ⊓ Y, Y).snd } ⧸ Submodule.comap (Submodule.subtype (X ⊓ Y, Y).snd) (X ⊓ Y, Y).fst [PROOFSTEP] rw [sup_comm, inf_comm] [GOAL] case val R : Type u_1 inst✝⁴ : Ring R M : Type u_2 inst✝³ : AddCommGroup M inst✝² : Module R M m : Submodule R M N : Type u_3 inst✝¹ : AddCommGroup N inst✝ : Module R N X Y : Submodule R M x✝ : X ⋖ X ⊔ Y ⊢ ({ x // x ∈ (X, Y ⊔ X).snd } ⧸ Submodule.comap (Submodule.subtype (X, Y ⊔ X).snd) (X, Y ⊔ X).fst) ≃ₗ[R] { x // x ∈ (Y ⊓ X, Y).snd } ⧸ Submodule.comap (Submodule.subtype (Y ⊓ X, Y).snd) (Y ⊓ X, Y).fst [PROOFSTEP] dsimp [GOAL] case val R : Type u_1 inst✝⁴ : Ring R M : Type u_2 inst✝³ : AddCommGroup M inst✝² : Module R M m : Submodule R M N : Type u_3 inst✝¹ : AddCommGroup N inst✝ : Module R N X Y : Submodule R M x✝ : X ⋖ X ⊔ Y ⊢ ({ x // x ∈ Y ⊔ X } ⧸ Submodule.comap (Submodule.subtype (Y ⊔ X)) X) ≃ₗ[R] { x // x ∈ Y } ⧸ Submodule.comap (Submodule.subtype Y) Y ⊓ Submodule.comap (Submodule.subtype Y) X [PROOFSTEP] exact (LinearMap.quotientInfEquivSupQuotient Y X).symm
Formal statement is: lemma pointwise_minimal_pointwise_maximal: fixes s :: "(nat \<Rightarrow> nat) set" assumes "finite s" and "s \<noteq> {}" and "\<forall>x\<in>s. \<forall>y\<in>s. x \<le> y \<or> y \<le> x" shows "\<exists>a\<in>s. \<forall>x\<in>s. a \<le> x" and "\<exists>a\<in>s. \<forall>x\<in>s. x \<le> a" Informal statement is: If $s$ is a finite set of functions from $\mathbb{N}$ to $\mathbb{N}$ such that for every $x, y \in s$, either $x \leq y$ or $y \leq x$, then there exists a function $a \in s$ such that for every $x \in s$, $a \leq x$, and there exists a function $a \in s$ such that for every $x \in s$, $x \leq a$.
[GOAL] as bs : List Char ⊢ length ({ data := as } ++ { data := bs }) = length { data := as } + length { data := bs } [PROOFSTEP] rw [congr_append] [GOAL] as bs : List Char ⊢ length { data := { data := as }.data ++ { data := bs }.data } = length { data := as } + length { data := bs } [PROOFSTEP] simp only [String.length] [GOAL] as bs : List Char ⊢ List.length (as ++ bs) = List.length as + List.length bs [PROOFSTEP] exact List.length_append as bs [GOAL] n : ℕ c : Char ⊢ length (replicate n c) = n [PROOFSTEP] simp only [String.length, String.replicate, List.length_replicate] [GOAL] l : List Char ⊢ length { data := l } = List.length l [PROOFSTEP] simp only [String.length] [GOAL] n : ℕ c : Char s : List Char ⊢ length (leftpad n c { data := s }) = max n (length { data := s }) [PROOFSTEP] simp only [leftpad, String.length, List.leftpad_length] [GOAL] n : ℕ c : Char l : List Char ⊢ isPrefix (replicate (n - length { data := l }) c) (leftpad n c { data := l }) [PROOFSTEP] simp only [isPrefix, replicate, leftpad, String.length, List.leftpad_prefix] [GOAL] n : ℕ c : Char l : List Char ⊢ isSuffix { data := l } (leftpad n c { data := l }) [PROOFSTEP] simp only [isSuffix, replicate, leftpad, String.length, List.leftpad_suffix]
#!/usr/bin/Rscript # small sample that reads data from a CSV file and # uses 'plot' for creating both a png and a pdf with the data plotted # 'plot' documentation # https://www.rdocumentation.org/packages/graphics/versions/3.6.2/topics/plot data <- read.csv("datafile.csv", header = TRUE) # Read from csv file print(data) # Print the file contents. print(data$x) # Print values for column X print(data[2]) # Print values for column '2' png("out/plotcsv.png") # Specify the png output file name plot(data, type = "l") # Plot the values as a line = l pdf("out/plotcsv.pdf") # Specify the pdf output file name plot(data, type = "l") # Plot the values as a line = l
" You 're Gonna Love Tomorrow " received mostly positive reviews from television critics , most of whom agreed that the time jump refreshed the show . According to Nielsen ratings , the episode drew over 18 million viewers , making it the most @-@ watched show of the night and the second most @-@ watched program of the week across all networks .
theory NthRoot_Limits imports Complex_Main "~~/src/HOL/Number_Theory/Binomial" begin text {* This does not fit into @{text Complex_Main}, as it depends on @{text Binomial} *} lemma LIMSEQ_root: "(\<lambda>n. root n n) ----> 1" proof - def x \<equiv> "\<lambda>n. root n n - 1" have "x ----> sqrt 0" proof (rule tendsto_sandwich[OF _ _ tendsto_const]) show "(\<lambda>x. sqrt (2 / x)) ----> sqrt 0" by (intro tendsto_intros tendsto_divide_0[OF tendsto_const] filterlim_mono[OF filterlim_real_sequentially]) (simp_all add: at_infinity_eq_at_top_bot) { fix n :: nat assume "2 < n" have "1 + (real (n - 1) * n) / 2 * x n^2 = 1 + of_nat (n choose 2) * x n^2" using `2 < n` unfolding gbinomial_def binomial_gbinomial by (simp add: atLeast0AtMost atMost_Suc field_simps real_of_nat_diff numeral_2_eq_2 real_eq_of_nat[symmetric]) also have "\<dots> \<le> (\<Sum>k\<in>{0, 2}. of_nat (n choose k) * x n^k)" by (simp add: x_def) also have "\<dots> \<le> (\<Sum>k=0..n. of_nat (n choose k) * x n^k)" using `2 < n` by (intro setsum_mono2) (auto intro!: mult_nonneg_nonneg zero_le_power simp: x_def le_diff_eq) also have "\<dots> = (x n + 1) ^ n" by (simp add: binomial_ring) also have "\<dots> = n" using `2 < n` by (simp add: x_def) finally have "real (n - 1) * (real n / 2 * (x n)\<^sup>2) \<le> real (n - 1) * 1" by simp then have "(x n)\<^sup>2 \<le> 2 / real n" using `2 < n` unfolding mult_le_cancel_left by (simp add: field_simps) from real_sqrt_le_mono[OF this] have "x n \<le> sqrt (2 / real n)" by simp } then show "eventually (\<lambda>n. x n \<le> sqrt (2 / real n)) sequentially" by (auto intro!: exI[of _ 3] simp: eventually_sequentially) show "eventually (\<lambda>n. sqrt 0 \<le> x n) sequentially" by (auto intro!: exI[of _ 1] simp: eventually_sequentially le_diff_eq x_def) qed from tendsto_add[OF this tendsto_const[of 1]] show ?thesis by (simp add: x_def) qed lemma LIMSEQ_root_const: assumes "0 < c" shows "(\<lambda>n. root n c) ----> 1" proof - { fix c :: real assume "1 \<le> c" def x \<equiv> "\<lambda>n. root n c - 1" have "x ----> 0" proof (rule tendsto_sandwich[OF _ _ tendsto_const]) show "(\<lambda>n. c / n) ----> 0" by (intro tendsto_divide_0[OF tendsto_const] filterlim_mono[OF filterlim_real_sequentially]) (simp_all add: at_infinity_eq_at_top_bot) { fix n :: nat assume "1 < n" have "1 + x n * n = 1 + of_nat (n choose 1) * x n^1" using `1 < n` unfolding gbinomial_def binomial_gbinomial by (simp add: real_eq_of_nat[symmetric]) also have "\<dots> \<le> (\<Sum>k\<in>{0, 1}. of_nat (n choose k) * x n^k)" by (simp add: x_def) also have "\<dots> \<le> (\<Sum>k=0..n. of_nat (n choose k) * x n^k)" using `1 < n` `1 \<le> c` by (intro setsum_mono2) (auto intro!: mult_nonneg_nonneg zero_le_power simp: x_def le_diff_eq) also have "\<dots> = (x n + 1) ^ n" by (simp add: binomial_ring) also have "\<dots> = c" using `1 < n` `1 \<le> c` by (simp add: x_def) finally have "x n \<le> c / n" using `1 \<le> c` `1 < n` by (simp add: field_simps) } then show "eventually (\<lambda>n. x n \<le> c / n) sequentially" by (auto intro!: exI[of _ 3] simp: eventually_sequentially) show "eventually (\<lambda>n. 0 \<le> x n) sequentially" using `1 \<le> c` by (auto intro!: exI[of _ 1] simp: eventually_sequentially le_diff_eq x_def) qed from tendsto_add[OF this tendsto_const[of 1]] have "(\<lambda>n. root n c) ----> 1" by (simp add: x_def) } note ge_1 = this show ?thesis proof cases assume "1 \<le> c" with ge_1 show ?thesis by blast next assume "\<not> 1 \<le> c" with `0 < c` have "1 \<le> 1 / c" by simp then have "(\<lambda>n. 1 / root n (1 / c)) ----> 1 / 1" by (intro tendsto_divide tendsto_const ge_1 `1 \<le> 1 / c` one_neq_zero) then show ?thesis by (rule filterlim_cong[THEN iffD1, rotated 3]) (auto intro!: exI[of _ 1] simp: eventually_sequentially real_root_divide) qed qed end
// Copyright 2007 Matthew A. Kucenski // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #ifndef _BOOST_LEXICAL_CAST_WRAPPER_HPP_ #define _BOOST_LEXICAL_CAST_WRAPPER_HPP_ #include <boost/lexical_cast.hpp> #include "errMsgs.h" template <typename TargetType, typename SourceType> int boost_lexical_cast_wrapper(const SourceType& src, TargetType* ptarget) { int rv = -1; try { *ptarget = boost::lexical_cast<TargetType>(src); rv = 0; } catch(boost::bad_lexical_cast&) { DEBUG("boost_lexical_cast_wrapper() Caught exception on conversion."); } return rv; } template <typename TargetType, typename SourceType> TargetType boost_lexical_cast_wrapper(const SourceType& src) { TargetType target; boost_lexical_cast_wrapper<TargetType>(src, &target); return target; } #endif //_BOOST_LEXICAL_CAST_WRAPPER_HPP_
Require Import stdpp.list. From Tweetnacl Require Export Libs.Lists_extended. From Tweetnacl Require Import Libs.LibTactics. Lemma Forall_nth_d: forall A (l:list A) (P:A -> Prop) d, P d -> Forall P l -> forall i, P (nth i l d). Proof. intros A l P d Hd Hl. induction l ; destruct i ; inv Hl ; go. Qed. Lemma Forall_nth_len: forall A (l:list A) (P:A -> Prop) d, Forall P l -> forall i, i < length l -> P (nth i l d). Proof. intros A l P d Hl. induction l; intros i Hi. - simpl in Hi. inv Hi. - destruct i; inv Hl ; go. Qed. Lemma nth_Forall: forall A (l: list A) (P:A -> Prop) d, (forall i, P (nth i l d)) -> Forall P l. Proof. induction l ; go. intros P d Hnth ; apply Forall_cons_2. apply (Hnth 0). eapply IHl. intros i. apply (Hnth (S i)). Qed. Lemma upd_nth_Forall: forall i A (l:list A) (P: A -> Prop) v, Forall P l -> P v -> Forall P (upd_nth i l v). Proof. induction i => A [|h q] P v Hl Hv ; simpl; try solve[apply Forall_cons_2 ; go]; apply Forall_cons in Hl ; destruct Hl as [Ha Hl] ; apply Forall_cons_2 ; go. Qed. Lemma Forall_take_n_m : forall m n A (l:list A) (P: A -> Prop), n <= m -> Forall P (take m l) -> Forall P (take n l). Proof. induction m ; intros. inv H. rewrite firstn_O ; apply Forall_nil_2. destruct n. rewrite firstn_O ; apply Forall_nil_2. destruct l. simpl ; apply Forall_nil_2. simpl. simpl in H0. apply Forall_cons in H0 ; destruct H0. apply Forall_cons_2 ; go. Qed. Open Scope Z. Lemma Forall_bounds_le_lt: forall a b l, Forall (fun x => a < x < b) l -> Forall (fun x => a <= x <= b) l. Proof. intros; eapply Forall_impl ; eauto ; intros ; go. Qed. Close Scope Z.
/* Copyright (c) Facebook, Inc. and its affiliates. * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ #include <cblas.h> #include <complex.h> #defmacro DEFINE_SVV(TNAME, TYPE, OPNAME, OPTEXT) #define OPER(a,b) OPTEXT TYPE TNAME##Vector_##OPNAME(TYPE *a, TYPE *b, int n) { /* try cblas */ #if #TYPE == "float" && #OPNAME == "dot" return cblas_sdot(n, a, 1, b, 1); #elif #TYPE == "double" && #OPNAME == "dot" return cblas_ddot(n, a, 1, b, 1); #else int i; TYPE s = 0; # pragma unroll(i) for(i=0;i<n;i++) s += OPER(a[i],b[i]); return s; #endif } #endmacro #defmacro FORALLTYPES(macro,...) macro(Int, int, __VA_ARGS__) macro(Long, long, __VA_ARGS__) macro(Float, float, __VA_ARGS__) macro(Double, double, __VA_ARGS__) macro(Complex, complex double, __VA_ARGS__) #endmacro FORALLTYPES(DEFINE_SVV,dot,(a)*(b)); FORALLTYPES(DEFINE_SVV,sqrdist,((a)-(b))*((a)-(b))) #define DEFINE_TYPEINFO(TNAME,TYPE) { #TNAME, #TYPE }, struct { const char *tname, *type; } typeInfo[] = { FORALLTYPES(DEFINE_TYPEINFO) };
Require Import Coq.Strings.String Coq.Classes.RelationClasses. Require Import Crypto.Compilers.Syntax. Require Import Crypto.Compilers.Wf. Require Import Crypto.Compilers.Relations. Require Import Crypto.Util.Tuple. Require Import Crypto.Util.Sigma. Require Import Crypto.Util.Prod. Require Import Crypto.Util.Tactics.DestructHead. Require Import Crypto.Util.Tactics.SpecializeBy. Require Import Crypto.Util.Tactics.RewriteHyp. Require Import Crypto.Util.Notations. Local Open Scope ctype_scope. Local Open Scope expr_scope. Section language. Context {base_type_code : Type} {interp_base_type : base_type_code -> Type} {op : flat_type base_type_code -> flat_type base_type_code -> Type} (interp_op : forall src dst, op src dst -> interp_flat_type interp_base_type src -> interp_flat_type interp_base_type dst). Local Notation exprf := (@exprf base_type_code op interp_base_type). Local Notation expr := (@expr base_type_code op interp_base_type). Local Notation Expr := (@Expr base_type_code op). Local Notation interpf := (@interpf base_type_code interp_base_type op interp_op). Local Notation interp := (@interp base_type_code interp_base_type op interp_op). Local Notation Interp := (@Interp base_type_code interp_base_type op interp_op). Lemma eq_in_flatten_binding_list {t x x' T e} (HIn : List.In (existT (fun t : base_type_code => (interp_base_type t * interp_base_type t)%type) t (x, x')%core) (flatten_binding_list (t:=T) e e)) : x = x'. Proof using Type. induction T; simpl in *; [ | | rewrite List.in_app_iff in HIn ]; repeat first [ progress destruct_head or | progress destruct_head False | progress destruct_head and | progress inversion_sigma | progress inversion_prod | progress subst | solve [ eauto ] ]. Qed. Local Hint Resolve List.in_app_or List.in_or_app eq_in_flatten_binding_list. Section wf. Lemma interpf_wff {t} {e1 e2 : exprf t} {G} (HG : forall t x x', List.In (existT (fun t : base_type_code => (interp_base_type t * interp_base_type t)%type) t (x, x')%core) G -> x = x') (Rwf : wff G e1 e2) : interpf e1 = interpf e2. Proof using Type. induction Rwf; simpl; auto; specialize_by auto; try congruence. rewrite_hyp !*; auto. repeat match goal with | [ H : context[List.In _ (_ ++ _)] |- _ ] => setoid_rewrite List.in_app_iff in H end. match goal with | [ H : _ |- _ ] => apply H; intros; destruct_head' or; solve [ eauto ] end. Qed. Local Hint Resolve interpf_wff. Lemma interp_wf {t} {e1 e2 : expr t} (Rwf : wf e1 e2) : forall x, interp e1 x = interp e2 x. Proof using Type. destruct Rwf; simpl; eauto. Qed. End wf. End language.
lemma uniformity_bot: "uniformity \<noteq> bot"
import data.nat.prime open nat theorem infinitude_of_primes (n : ℕ) : ∃ (p : ℕ), prime p ∧ n ≤ p := -- For every natural number n, -- there exists a number p, such that -- n is less than or equal to p and p is prime begin let m := n.factorial + 1, let p := min_fac m, use p, -- use the smallest prime factor of n! + 1. have p_is_prime : prime p := min_fac_prime (ne_of_gt (succ_lt_succ (factorial_pos n))), -- proof that p is prime split, -- break the "and" into two propositions begin -- proof that p is prime exact p_is_prime, end, begin -- proof that n is less than or equal to p by_contradiction h, push_neg at h, -- proof by contradiction -- suppose instead that p is less than n have p_dvd_n : p ∣ n.factorial := dvd_factorial (min_fac_pos _) (le_of_lt h), -- then p divides n! have p_dvd_one : p ∣ 1 := (nat.dvd_add_iff_right p_dvd_n).2 (min_fac_dvd _), -- because p divides n! and n! + 1, p divides 1 exact p_is_prime.not_dvd_one p_dvd_one, -- but this is not possible end, end
[STATEMENT] lemma epigraph_subset_iff: fixes f g :: "'a::metric_space \<Rightarrow> ereal" shows "Epigraph UNIV f \<le> Epigraph UNIV g \<longleftrightarrow> (\<forall>x. g x \<le> f x)" [PROOF STATE] proof (prove) goal (1 subgoal): 1. (Epigraph UNIV f \<subseteq> Epigraph UNIV g) = (\<forall>x. g x \<le> f x) [PROOF STEP] proof- [PROOF STATE] proof (state) goal (1 subgoal): 1. (Epigraph UNIV f \<subseteq> Epigraph UNIV g) = (\<forall>x. g x \<le> f x) [PROOF STEP] { [PROOF STATE] proof (state) goal (1 subgoal): 1. (Epigraph UNIV f \<subseteq> Epigraph UNIV g) = (\<forall>x. g x \<le> f x) [PROOF STEP] assume epi: "Epigraph UNIV f \<le> Epigraph UNIV g" [PROOF STATE] proof (state) this: Epigraph UNIV f \<subseteq> Epigraph UNIV g goal (1 subgoal): 1. (Epigraph UNIV f \<subseteq> Epigraph UNIV g) = (\<forall>x. g x \<le> f x) [PROOF STEP] { [PROOF STATE] proof (state) this: Epigraph UNIV f \<subseteq> Epigraph UNIV g goal (1 subgoal): 1. (Epigraph UNIV f \<subseteq> Epigraph UNIV g) = (\<forall>x. g x \<le> f x) [PROOF STEP] fix x [PROOF STATE] proof (state) goal (1 subgoal): 1. (Epigraph UNIV f \<subseteq> Epigraph UNIV g) = (\<forall>x. g x \<le> f x) [PROOF STEP] { [PROOF STATE] proof (state) goal (1 subgoal): 1. (Epigraph UNIV f \<subseteq> Epigraph UNIV g) = (\<forall>x. g x \<le> f x) [PROOF STEP] fix z [PROOF STATE] proof (state) goal (1 subgoal): 1. (Epigraph UNIV f \<subseteq> Epigraph UNIV g) = (\<forall>x. g x \<le> f x) [PROOF STEP] assume "f x \<le> ereal z" [PROOF STATE] proof (state) this: f x \<le> ereal z goal (1 subgoal): 1. (Epigraph UNIV f \<subseteq> Epigraph UNIV g) = (\<forall>x. g x \<le> f x) [PROOF STEP] hence "(x,z)\<in>Epigraph UNIV f" [PROOF STATE] proof (prove) using this: f x \<le> ereal z goal (1 subgoal): 1. (x, z) \<in> Epigraph UNIV f [PROOF STEP] unfolding Epigraph_def [PROOF STATE] proof (prove) using this: f x \<le> ereal z goal (1 subgoal): 1. (x, z) \<in> {xy. fst xy \<in> UNIV \<and> f (fst xy) \<le> ereal (snd xy)} [PROOF STEP] by auto [PROOF STATE] proof (state) this: (x, z) \<in> Epigraph UNIV f goal (1 subgoal): 1. (Epigraph UNIV f \<subseteq> Epigraph UNIV g) = (\<forall>x. g x \<le> f x) [PROOF STEP] hence "(x,z)\<in>Epigraph UNIV g" [PROOF STATE] proof (prove) using this: (x, z) \<in> Epigraph UNIV f goal (1 subgoal): 1. (x, z) \<in> Epigraph UNIV g [PROOF STEP] using epi [PROOF STATE] proof (prove) using this: (x, z) \<in> Epigraph UNIV f Epigraph UNIV f \<subseteq> Epigraph UNIV g goal (1 subgoal): 1. (x, z) \<in> Epigraph UNIV g [PROOF STEP] by auto [PROOF STATE] proof (state) this: (x, z) \<in> Epigraph UNIV g goal (1 subgoal): 1. (Epigraph UNIV f \<subseteq> Epigraph UNIV g) = (\<forall>x. g x \<le> f x) [PROOF STEP] hence "g x \<le> ereal z" [PROOF STATE] proof (prove) using this: (x, z) \<in> Epigraph UNIV g goal (1 subgoal): 1. g x \<le> ereal z [PROOF STEP] unfolding Epigraph_def [PROOF STATE] proof (prove) using this: (x, z) \<in> {xy. fst xy \<in> UNIV \<and> g (fst xy) \<le> ereal (snd xy)} goal (1 subgoal): 1. g x \<le> ereal z [PROOF STEP] by auto [PROOF STATE] proof (state) this: g x \<le> ereal z goal (1 subgoal): 1. (Epigraph UNIV f \<subseteq> Epigraph UNIV g) = (\<forall>x. g x \<le> f x) [PROOF STEP] } [PROOF STATE] proof (state) this: f x \<le> ereal ?z2 \<Longrightarrow> g x \<le> ereal ?z2 goal (1 subgoal): 1. (Epigraph UNIV f \<subseteq> Epigraph UNIV g) = (\<forall>x. g x \<le> f x) [PROOF STEP] hence "g x \<le> f x" [PROOF STATE] proof (prove) using this: f x \<le> ereal ?z2 \<Longrightarrow> g x \<le> ereal ?z2 goal (1 subgoal): 1. g x \<le> f x [PROOF STEP] apply (subst ereal_le_real) [PROOF STATE] proof (prove) goal (2 subgoals): 1. \<And>z. \<lbrakk>\<And>z. f x \<le> ereal z \<Longrightarrow> g x \<le> ereal z; f x \<le> ereal z\<rbrakk> \<Longrightarrow> g x \<le> ereal z 2. (\<And>z. f x \<le> ereal z \<Longrightarrow> g x \<le> ereal z) \<Longrightarrow> True [PROOF STEP] by auto [PROOF STATE] proof (state) this: g x \<le> f x goal (1 subgoal): 1. (Epigraph UNIV f \<subseteq> Epigraph UNIV g) = (\<forall>x. g x \<le> f x) [PROOF STEP] } [PROOF STATE] proof (state) this: g ?x2 \<le> f ?x2 goal (1 subgoal): 1. (Epigraph UNIV f \<subseteq> Epigraph UNIV g) = (\<forall>x. g x \<le> f x) [PROOF STEP] } [PROOF STATE] proof (state) this: Epigraph UNIV f \<subseteq> Epigraph UNIV g \<Longrightarrow> g ?x2 \<le> f ?x2 goal (1 subgoal): 1. (Epigraph UNIV f \<subseteq> Epigraph UNIV g) = (\<forall>x. g x \<le> f x) [PROOF STEP] moreover [PROOF STATE] proof (state) this: Epigraph UNIV f \<subseteq> Epigraph UNIV g \<Longrightarrow> g ?x2 \<le> f ?x2 goal (1 subgoal): 1. (Epigraph UNIV f \<subseteq> Epigraph UNIV g) = (\<forall>x. g x \<le> f x) [PROOF STEP] { [PROOF STATE] proof (state) this: Epigraph UNIV f \<subseteq> Epigraph UNIV g \<Longrightarrow> g ?x2 \<le> f ?x2 goal (1 subgoal): 1. (Epigraph UNIV f \<subseteq> Epigraph UNIV g) = (\<forall>x. g x \<le> f x) [PROOF STEP] assume le: "\<forall>x. g x \<le> f x" [PROOF STATE] proof (state) this: \<forall>x. g x \<le> f x goal (1 subgoal): 1. (Epigraph UNIV f \<subseteq> Epigraph UNIV g) = (\<forall>x. g x \<le> f x) [PROOF STEP] { [PROOF STATE] proof (state) this: \<forall>x. g x \<le> f x goal (1 subgoal): 1. (Epigraph UNIV f \<subseteq> Epigraph UNIV g) = (\<forall>x. g x \<le> f x) [PROOF STEP] fix x y [PROOF STATE] proof (state) goal (1 subgoal): 1. (Epigraph UNIV f \<subseteq> Epigraph UNIV g) = (\<forall>x. g x \<le> f x) [PROOF STEP] assume "(x,y):Epigraph UNIV f" [PROOF STATE] proof (state) this: (x, y) \<in> Epigraph UNIV f goal (1 subgoal): 1. (Epigraph UNIV f \<subseteq> Epigraph UNIV g) = (\<forall>x. g x \<le> f x) [PROOF STEP] hence "f x \<le> ereal y" [PROOF STATE] proof (prove) using this: (x, y) \<in> Epigraph UNIV f goal (1 subgoal): 1. f x \<le> ereal y [PROOF STEP] unfolding Epigraph_def [PROOF STATE] proof (prove) using this: (x, y) \<in> {xy. fst xy \<in> UNIV \<and> f (fst xy) \<le> ereal (snd xy)} goal (1 subgoal): 1. f x \<le> ereal y [PROOF STEP] by auto [PROOF STATE] proof (state) this: f x \<le> ereal y goal (1 subgoal): 1. (Epigraph UNIV f \<subseteq> Epigraph UNIV g) = (\<forall>x. g x \<le> f x) [PROOF STEP] moreover [PROOF STATE] proof (state) this: f x \<le> ereal y goal (1 subgoal): 1. (Epigraph UNIV f \<subseteq> Epigraph UNIV g) = (\<forall>x. g x \<le> f x) [PROOF STEP] have "g x \<le> f x" [PROOF STATE] proof (prove) goal (1 subgoal): 1. g x \<le> f x [PROOF STEP] using le [PROOF STATE] proof (prove) using this: \<forall>x. g x \<le> f x goal (1 subgoal): 1. g x \<le> f x [PROOF STEP] by auto [PROOF STATE] proof (state) this: g x \<le> f x goal (1 subgoal): 1. (Epigraph UNIV f \<subseteq> Epigraph UNIV g) = (\<forall>x. g x \<le> f x) [PROOF STEP] ultimately [PROOF STATE] proof (chain) picking this: f x \<le> ereal y g x \<le> f x [PROOF STEP] have "g x \<le> ereal y" [PROOF STATE] proof (prove) using this: f x \<le> ereal y g x \<le> f x goal (1 subgoal): 1. g x \<le> ereal y [PROOF STEP] by auto [PROOF STATE] proof (state) this: g x \<le> ereal y goal (1 subgoal): 1. (Epigraph UNIV f \<subseteq> Epigraph UNIV g) = (\<forall>x. g x \<le> f x) [PROOF STEP] hence "(x,y):Epigraph UNIV g" [PROOF STATE] proof (prove) using this: g x \<le> ereal y goal (1 subgoal): 1. (x, y) \<in> Epigraph UNIV g [PROOF STEP] unfolding Epigraph_def [PROOF STATE] proof (prove) using this: g x \<le> ereal y goal (1 subgoal): 1. (x, y) \<in> {xy. fst xy \<in> UNIV \<and> g (fst xy) \<le> ereal (snd xy)} [PROOF STEP] by auto [PROOF STATE] proof (state) this: (x, y) \<in> Epigraph UNIV g goal (1 subgoal): 1. (Epigraph UNIV f \<subseteq> Epigraph UNIV g) = (\<forall>x. g x \<le> f x) [PROOF STEP] } [PROOF STATE] proof (state) this: (?x2, ?y2) \<in> Epigraph UNIV f \<Longrightarrow> (?x2, ?y2) \<in> Epigraph UNIV g goal (1 subgoal): 1. (Epigraph UNIV f \<subseteq> Epigraph UNIV g) = (\<forall>x. g x \<le> f x) [PROOF STEP] } [PROOF STATE] proof (state) this: \<lbrakk>\<forall>x. g x \<le> f x; (?x2, ?y2) \<in> Epigraph UNIV f\<rbrakk> \<Longrightarrow> (?x2, ?y2) \<in> Epigraph UNIV g goal (1 subgoal): 1. (Epigraph UNIV f \<subseteq> Epigraph UNIV g) = (\<forall>x. g x \<le> f x) [PROOF STEP] ultimately [PROOF STATE] proof (chain) picking this: Epigraph UNIV f \<subseteq> Epigraph UNIV g \<Longrightarrow> g ?x2 \<le> f ?x2 \<lbrakk>\<forall>x. g x \<le> f x; (?x2, ?y2) \<in> Epigraph UNIV f\<rbrakk> \<Longrightarrow> (?x2, ?y2) \<in> Epigraph UNIV g [PROOF STEP] show ?thesis [PROOF STATE] proof (prove) using this: Epigraph UNIV f \<subseteq> Epigraph UNIV g \<Longrightarrow> g ?x2 \<le> f ?x2 \<lbrakk>\<forall>x. g x \<le> f x; (?x2, ?y2) \<in> Epigraph UNIV f\<rbrakk> \<Longrightarrow> (?x2, ?y2) \<in> Epigraph UNIV g goal (1 subgoal): 1. (Epigraph UNIV f \<subseteq> Epigraph UNIV g) = (\<forall>x. g x \<le> f x) [PROOF STEP] by auto [PROOF STATE] proof (state) this: (Epigraph UNIV f \<subseteq> Epigraph UNIV g) = (\<forall>x. g x \<le> f x) goal: No subgoals! [PROOF STEP] qed
import data.nat.modeq -- modular arithmetic import topology.basic example : 5 ≡ 8 [MOD 3] := begin apply rfl, end #check nat.modeq.modeq_mul example (a b c d m : ℕ) : a ≡ b [MOD m] → c ≡ d [MOD m] → a * c ≡ b * d [MOD m] := begin apply nat.modeq.modeq_mul, end lemma cong_mul1 (a b c d m : ℕ) : a ≡ b [MOD m] → a * c ≡ b * c [MOD m] := begin intro h1, apply nat.modeq.modeq_mul h1, apply rfl, end theorem cong_product (a b c d m : ℕ) (h1: a ≡ b * c [MOD m]) (h2: c ≡ d [MOD m]) : a ≡ b * d [MOD m] := begin have h3: b * c ≡ b * d [MOD m], from begin apply nat.modeq.modeq_mul, apply rfl, assumption end, apply nat.modeq.trans h1 h3, end lemma aaa (rr R R_INV a ar aar aaa n : ℕ) : R * R_INV ≡ 1 [MOD n] → rr ≡ R * R [MOD n] → ar ≡ a * R_INV * rr [MOD n] → aar ≡ ar * ar * R_INV [MOD n] → aaa ≡ aar * a * R_INV [MOD n] → aaa ≡ a * a * a [MOD n] := begin intros h1 h2 h3 h4 h5, have h: ar ≡ a * R_INV * R * R [MOD n], from begin rw [mul_assoc], apply cong_product ar (a * R_INV) rr (R * R) n, assumption, assumption, end, have h: ar ≡ a * R * 1 [MOD n], from begin apply cong_product ar (a * R) (R_INV * R) 1 n, rw [<- mul_assoc, mul_assoc a R, mul_comm R R_INV, <-mul_assoc], assumption, rw [mul_comm], assumption, end, sorry end
#!/usr/bin/env python #========================================================================= # # Extract texture features from a region-of-interest within a GBM dicom image # # #========================================================================= # log # # Test Dr. Ross Mitchell's algorithm on GBM data # to find error on our code # import csv import os import matplotlib as mpl import numpy as np import GLCMTextureSecret import TextureSecret print mpl.get_cachedir() # import SimpleITK as sitk # from string import maketrans rootDir = '/Users/yanzhexu/Desktop/Research/GBM/aCGH_whole_tumor_maps_for_Neuro-Onc_dataset/RWh_slices_only/slice17/' outputDir = '/Users/yanzhexu/Desktop/Research/GBM/TestGLCM' featuresOutFn = 'GBM_features_GLCM_test_X_Y_ym4xm4_yp4xp4_TestAlgorithm.csv' featureCSVFn = os.path.join(outputDir,featuresOutFn) grayScales = 256 ycoord = 126 xcoord = 161 rootFnImg = os.path.join(rootDir,'EPI+C_IM-0003-0017.dcm') inputImage = TextureSecret.readDicomImage(rootFnImg) subImage = inputImage[ycoord - 4: ycoord + 4,xcoord - 4:xcoord + 4 ] print subImage print np.min(subImage) print np.max(subImage) subImage = TextureSecret.scaleIntensity(subImage, 0, grayScales) subImage = np.rint(subImage).astype(np.uint8) print subImage features = GLCMTextureSecret.computeFeatures(subImage) featureTitle = GLCMTextureSecret._getGLCMFeatureNames() print featureTitle print len(featureTitle) print features print len(features) rowfeature = list() for eachtitle in featureTitle: featurename = eachtitle +' Mean' rowfeature.append(features[featurename]) print rowfeature with open(featureCSVFn, 'wb') as featureCSVFile: featureWriter = csv.writer(featureCSVFile, dialect='excel') featureWriter.writerow(featureTitle) featureWriter.writerow(rowfeature)
% GAUSS3D - generate a 3-dimensional gaussian matrix % % Usage: % >> [ gaussmatrix ] = gauss2d( nX, nY, nZ); % >> [ gaussmatrix ] = gauss2d( nX, nY, nZ, ... % sigmaX, sigmaY, sigmaZ, ... % centerX, centerY, centerZ, mask) % % Example: % >> gauss3d(3,3,3); % generate a 3x3x3 gaussian matrix % % Inputs: % nX - number of values in first dimension % nY - number of values in second dimension % nZ - number of values in third dimension % sigmaX - width of standard deviation in first dim (default: nX/5) % sigmaY - width of standard deviation in second dim (default: nY/5) % sigmaZ - width of standard deviation in third dim (default: nZ/5) % centerX - location of center (default: nX/2) % centerY - location of center (default: nY/2) % centerZ - location of center (default: nZ/2) % mask - (0->1) percentage of low values in the matrix to mask % with zeros (default: 0 or none) % % Output: % gaussmatrix - 3-D gaussian matrix % % Author: Arnaud Delorme, 2009 % Copyright (C) 2009 Arnaud Delorme, Salk Institute, [email protected] % % This file is part of EEGLAB, see http://www.eeglab.org % for the documentation and details. % % Redistribution and use in source and binary forms, with or without % modification, are permitted provided that the following conditions are met: % % 1. Redistributions of source code must retain the above copyright notice, % this list of conditions and the following disclaimer. % % 2. Redistributions in binary form must reproduce the above copyright notice, % this list of conditions and the following disclaimer in the documentation % and/or other materials provided with the distribution. % % THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" % AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE % IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE % ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE % LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR % CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF % SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS % INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN % CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) % ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF % THE POSSIBILITY OF SUCH DAMAGE. function mat = gauss3d( sizeX, sizeY, sizeZ, sigmaX, sigmaY, sigmaZ, meanX, meanY, meanZ, cut); if nargin < 2 help gauss2d return; end if nargin < 4 sigmaX = sizeX/5; end if nargin < 5 sigmaY = sizeY/5; end if nargin < 6 sigmaZ = sizeZ/5; end if nargin < 7 meanX = (sizeX+1)/2; end if nargin < 8 meanY = (sizeY+1)/2; end if nargin < 9 meanZ = (sizeZ+1)/2; end if nargin < 10 cut = 0; end [X,Y,Z] = ndgrid(1:sizeX,1:sizeY,1:sizeZ); mat = exp(-0.5*( ((X-meanX)/sigmaX).*((X-meanX)/sigmaX)... +((Y-meanY)/sigmaY).*((Y-meanY)/sigmaY)... +((Z-meanZ)/sigmaZ).*((Z-meanZ)/sigmaZ)))... /((sigmaX*sigmaY*sigmaZ)^(0.5)*pi); if cut > 0 maximum = max(mat(:))*cut; I = find(mat < maximum); mat(I) = 0; end return;
-- Exercise 1 -- -- Go back to the exercises in Chapter 3 and Chapter 4 and redo as many as you -- can now with tactic proofs, using also rw and simp as appropriate. -- NOTE: I had alreadty been doing this, so I don't think I need to go back and -- do them again... oops. -- Exercise 2 -- -- Use tactic combinators to obtain a one line proof of the following: example (p q r : Prop) (hp : p) : (p ∨ q ∨ r) ∧ (q ∨ p ∨ r) ∧ (q ∨ r ∨ p) := by { repeat {split}, repeat { { left, assumption } <|> right <|> assumption } }
/- Alex Sanchez This file formalizes the first ** problem in Herstein's celebrated text, "Topics in Algebra". -/ import tactic -- tactics import group_theory.subgroup.basic -- subgroups import group_theory.order_of_element -- elemental order import data.nat.factorization.basic -- prime factorization variables (G : Type) [comm_group G] -- tests example (a : ℕ) : nat.lcm (0 : ℕ) a = (0 : ℕ) := begin exact nat.lcm_zero_left a, end -- proofs theorem single_star (h h' : G) : ∃ g : G, order_of g = nat.lcm (order_of h) (order_of h') := begin --break into cases with both nonzero, otherwise etc. let m : ℕ := order_of h, let n : ℕ := order_of h', by_cases hyp : m = 0 ∨ n = 0, { --trivial case cases hyp, { use h, conv begin congr, { change m, rw hyp, }, { congr, { change m, rw hyp, }, { change n, } } end, exact (nat.lcm_zero_left n).symm, }, { use h', conv begin congr, { change n, rw hyp, }, { congr, { change m, }, { change n, rw hyp, } } end, exact (nat.lcm_zero_right m).symm, }, }, { --nontrivial case -- get nice forms of assumptions -- refactor to get both have fin_h : m > 0 := begin have temp : ¬m=0 := begin rw not_or_distrib at hyp, exact hyp.left, end, have temp_two : m ≥ 0 := zero_le m, have temp_three : m > 0 ∨ m = 0 := begin have temp_temp : m > 0 ∨ m = 0 ∨ m < 0 := trichotomous m 0, cases temp_temp with a b, { left, exact a, }, { cases b with c d, { right, exact c, }, { exfalso, apply not_lt.mpr temp_two, exact d, }, }, end, cases temp_three with a b, { exact a, }, { exfalso, exact temp b, }, end, let ps_m := nat.factorization m, let ps_n := nat.factorization n, -- find some way to identify the finite support sorry, }, end theorem double_star (H H' : subgroup G) : ∃ H'' : subgroup G, nat.card H'' = nat.lcm (nat.card H) (nat.card H') := begin sorry, end
MODULE m_eop_igu ! ---------------------------------------------------------------------- ! MODULE: m_eop_igu.f03 ! ---------------------------------------------------------------------- ! Purpose: ! Module for calling the modified eop_igu subroutine ! ! ---------------------------------------------------------------------- ! Author : Dr. Thomas Papanikolaou, Geoscience Australia ! Created: 28 August 2018 ! ---------------------------------------------------------------------- IMPLICIT NONE !SAVE Contains SUBROUTINE eop_igu (mjd, ERP_fname, ERP_days, EOP_days, EOP_Nint, EOP_int) ! ---------------------------------------------------------------------- ! Subroutine: eop_igu.f90 ! ---------------------------------------------------------------------- ! Purpose: ! EOP data reading and processing by using: ! - ERP (Earth Rotation Parameters) data from the ultra-rapid products ! provided by the IGS (International GNSS Service). ! - Corrections to the precession-nutation model are obtained from the ! daily solutions (finals2000A.daily) provided by the International ! Earth Rotation Service and Reference Systems (IERS) ! Rapid Service/Prediction Center (RS/PC) ! ---------------------------------------------------------------------- ! Input arguments: ! - mjd: Modified Julian Day number at the required epoch ! (including fraction of the day) ! - ERP_fname: IGS ultra-rapid ERP data file name e.g. igu18861_00.erp ! - EOP_days: EOP data array of the days (data points aplied for interpolation) based on IERS RS/PC EOP data ! - EOP_Nint: Number of points to use for interpolation ! - arc_length: Number of hours of arc to read from file ! ! Output arguments: ! - eop_int: EOP data array at the input epoch ! eop_int = [MJD xp yp UT1_UTC LOD dX dY] ! MJD: MJD at the input epoch (including fraction of the day) ! x,y: Polar motion coordinates (arcsec) ! UT1_UTC: Difference between UT1 and UTC (sec) ! dX,dY: Corrections to Precession-Nutation model (arcsec) ! ---------------------------------------------------------------------- ! Dr. Thomas Papanikolaou, Geoscience Australia March 2016 ! ---------------------------------------------------------------------- USE mdl_precision USE mdl_num use pod_yaml IMPLICIT NONE ! ---------------------------------------------------------------------- ! Dummy arguments declaration ! ---------------------------------------------------------------------- ! IN REAL (KIND = prec_d), INTENT(IN) :: mjd CHARACTER (LEN=512), INTENT(IN) :: ERP_fname REAL (KIND = prec_d), INTENT(IN), DIMENSION(:,:), ALLOCATABLE :: ERP_days, EOP_days INTEGER, INTENT (IN) :: EOP_Nint ! OUT REAL (KIND = prec_d), INTENT(OUT) :: EOP_int(EOP_MAX_ARRAY) ! ---------------------------------------------------------------------- ! ---------------------------------------------------------------------- ! Local variables declaration ! ---------------------------------------------------------------------- REAL (KIND = prec_d) :: ERP_igu_data(EOP_Nint,EOP_MAX_ARRAY), ERP_int(EOP_MAX_ARRAY), mjd_t LOGICAL :: igu_flag INTEGER (KIND = prec_int8) :: mjd_UTC_day REAL (KIND = prec_d) :: mjd_ar(EOP_Nint), Xpole_ar(EOP_Nint), Ypole_ar(EOP_Nint), UT1UTC_ar(EOP_Nint), LOD_ar(EOP_Nint) REAL (KIND = prec_d) :: Xerr_ar(EOP_Nint), Yerr_ar(EOP_Nint), UT1err_ar(EOP_Nint), LODerr_ar(EOP_Nint) REAL (KIND = prec_d) :: mjd_int, Xpole_int, Ypole_int, UT1UTC_int, LOD_int REAL (KIND = prec_d) :: Xerr_int, Yerr_int, UT1err_int, LODerr_int REAL (KIND = prec_d) :: dX_eop, dY_eop INTEGER (KIND = prec_int4) :: i, j, sz1_EOP, sz2_EOP, EOP_nint_used, saved_row_count = 0 INTEGER (KIND = prec_int4) :: lo, hi, offset INTEGER MAX_EOP_DATA parameter (MAX_EOP_DATA = 30) REAL (KIND = prec_d) :: ERP_read_data(MAX_EOP_DATA, EOP_MAX_ARRAY) igu_flag = .false. ERP_igu_data = 0.d0 ! ---------------------------------------------------------------------- ! check we don't have the required data already if (allocated(ERP_days)) then saved_row_count = SIZE(ERP_days, DIM=1) do i = 1, saved_row_count if (ERP_days(i,EOP_MJD) == 0.d0) then saved_row_count = i-1 exit end if ERP_read_data(i,:) = ERP_days(i, :) end do DO i = 1, saved_row_count - 1 if ((ERP_read_data(i, EOP_MJD) <= mjd) .and. (mjd <= ERP_read_data(i+1, EOP_MJD))) then igu_flag = .true. if (i > (EOP_Nint / 2) .and. ((i + 1) <= (saved_row_count - EOP_Nint / 2))) then if (MOD(EOP_Nint, 2) == 1) then lo = i-EOP_Nint/2 hi = i+1+EOP_Nint/2 if (lo == 0) then lo = lo + 1 hi = hi + 1 end if else lo = i-EOP_Nint/2+1 hi = i+EOP_Nint/2 end if ERP_igu_data = ERP_read_data(lo:hi, :) EOP_Nint_used = EOP_Nint else if (i <= EOP_nint/2) then ERP_igu_data = ERP_read_data(1:EOP_Nint,:) EOP_Nint_used = EOP_nint else if (i >= (saved_row_count - EOP_Nint/2)) then ERP_igu_data = ERP_read_data(saved_row_count - EOP_Nint + 1:saved_row_count, :) EOP_nint_used = EOP_Nint end if exit end if end do if (.not. igu_flag) then !print *, "mjd=", mjd, ", last row of data is mjd ", ERP_read_data(saved_row_count, EOP_MJD) if (mjd < ERP_read_data(saved_row_count, EOP_MJD) + 1.0d0) then igu_flag = .true. ERP_igu_data = ERP_read_data(saved_row_count - EOP_Nint + 1:saved_row_count, :) EOP_Nint_used = EOP_Nint else if (mjd < ERP_read_data(1, EOP_MJD)) then igu_flag = .true. ERP_igu_data = ERP_read_data(1:EOP_nint,:) EOP_Nint_used = EOP_Nint end if end if end if ! ---------------------------------------------------------------------- ! ERP data reading if (.not. igu_flag) then if (MOD(EOP_Nint, 2) == 1) then !EOP_Nint is odd, use Nint/2 points below if mjd is above 0.5, else Nint/2 + 1 points below mjd_t = mjd - int(mjd) if (mjd_t > 0.5) then lo = int(mjd) - EOP_Nint/2 + 1 hi = INT(mjd) + EOP_Nint/2 + 1 else lo = int(mjd) - EOP_Nint/2 hi = int(mjd) + EOP_Nint/2 end if else !EOP_nint is even use half above and half below precisely lo = int(mjd) - EOP_Nint/2 + 1 hi = int(mjd) + EOP_Nint/2 end if offset = 1 EOP_nint_used = 0 do i = hi, lo, -1 mjd_t = float(i) CALL erp_igu (ERP_fname, mjd_t, ERP_int, igu_flag) if (igu_flag) then erp_igu_data (i - lo + offset, :) = ERP_int if (EOP_Nint_used == 0) then EOP_Nint_used = i - lo + offset end if else offset = offset + 1 end if end do end if if (.not. igu_flag .and. offset > 2 ) then PRINT *,"--------------------------------------------------------" PRINT *, "Warning error: Subroutine erp_igu.f90" PRINT *, "Input epoch is out of the range covered by the IGS ultra-rapid ERP file" PRINT *, "Check the input ", ERP_fname PRINT *,"--------------------------------------------------------" STOP ! END PROGRAM end if ! ---------------------------------------------------------------------- ! ---------------------------------------------------------------------- ! ERP interpolation ERP_int = 0.d0 mjd_int = mjd mjd_ar = ERP_igu_data(1:EOP_Nint_used,EOP_MJD) Xpole_ar = ERP_igu_data(1:EOP_Nint_used,EOP_X) Ypole_ar = ERP_igu_data(1:EOP_Nint_used,EOP_Y) UT1UTC_ar = ERP_igu_data(1:EOP_Nint_used,EOP_UT1) LOD_ar = ERP_igu_data(1:EOP_Nint_used,EOP_LOD) Xerr_ar = ERP_igu_data(1:EOP_Nint_used,EOP_X_ERR) Yerr_ar = ERP_igu_data(1:EOP_Nint_used,EOP_Y_ERR) UT1err_ar = ERP_igu_data(1:EOP_Nint_used,EOP_UT1_ERR) LODerr_ar = ERP_igu_data(1:EOP_Nint_used,EOP_LOD_ERR) ! do we need to correct, or should that have already been applied? call interp_iers(mjd_ar, Xpole_ar, Ypole_ar, UT1UTC_ar, EOP_Nint_used, EOP_Nint_used, & mjd_int, Xpole_int, Ypole_int, UT1UTC_int) !CALL LAGINT(mjd_ar, Xpole_ar, EOP_Nint_used, EOP_Nint_used, mjd_int, Xpole_int) !CALL LAGINT(mjd_ar, Ypole_ar, EOP_Nint_used, EOP_Nint_used, mjd_int, Ypole_int) !CALL LAGINT(mjd_ar, UT1UTC_ar, EOP_Nint_used, EOP_Nint_used, mjd_int, UT1UTC_int) CALL LAGINT(mjd_ar, LOD_ar, EOP_Nint_used, EOP_Nint_used, mjd_int, LOD_int) CALL LAGINT(mjd_ar, Xerr_ar, EOP_Nint_used, EOP_Nint_used, mjd_int, Xerr_int) CALL LAGINT(mjd_ar, Yerr_ar, EOP_Nint_used, EOP_Nint_used, mjd_int, Yerr_int) CALL LAGINT(mjd_ar, UT1err_ar, EOP_Nint_used, EOP_Nint_used, mjd_int, UT1err_int) CALL LAGINT(mjd_ar, LODerr_ar, EOP_Nint_used, EOP_Nint_used, mjd_int, LODerr_int) ERP_int (EOP_MJD) = mjd_int ERP_int (EOP_X) = Xpole_int ERP_int (EOP_Y) = Ypole_int ERP_int (EOP_UT1) = UT1UTC_int ERP_int (EOP_LOD) = LOD_int ERP_int (EOP_X_ERR) = Xerr_int ERP_int (EOP_Y_ERR) = Yerr_int ERP_int (EOP_UT1_ERR) = ut1err_int ERP_int (EOP_LOD_ERR) = LODerr_int ! ---------------------------------------------------------------------- ! ---------------------------------------------------------------------- ! dX,dY : Corrections w.r.t Precession-Nutation model !mjd_UTC_day = INT (mjd) !CALL eop_finals2000A (EOP_fname, mjd_UTC_day , EOP_data) !dX = EOP_data(6) !dY = EOP_data(7) !---------------------------------------------------------- ! init next two var to something sensible dX_eop = 0.d0 dY_eop = 0.d0 sz1_EOP = SIZE (EOP_days,DIM=1) sz2_EOP = SIZE (EOP_days,DIM=2) DO i = 1 , sz1_EOP If (mjd_int == EOP_days(i,EOP_MJD) ) then ! dX,dY (arcsec) dX_eop = EOP_days(i,EOP_DX) dY_eop = EOP_days(i,EOP_DY) End If END DO ! ---------------------------------------------------------------------- ! ---------------------------------------------------------------------- EOP_int (EOP_MJD) = mjd_int EOP_int (EOP_X) = Xpole_int EOP_int (EOP_Y) = Ypole_int EOP_int (EOP_UT1) = UT1UTC_int EOP_int (EOP_LOD) = LOD_int ! dX,dY : Precession-Nutation model corrections EOP_int (EOP_DX) = dX_eop !EOP_data (6) EOP_int (EOP_DY) = dY_eop !EOP_data (7) ! ---------------------------------------------------------------------- EOP_int (EOP_X_ERR) = Xerr_int EOP_int (EOP_Y_ERR) = Yerr_int EOP_int (EOP_UT1_ERR) = ut1err_int EOP_int (EOP_LOD_ERR) = LODerr_int ! PRINT *,"--------------------------------------------------------" ! PRINT *, "ERP_igu_data" ! PRINT *, ERP_igu_data ! PRINT *, "ERP_int" ! PRINT *, ERP_int ! PRINT *,"--------------------------------------------------------" END SUBROUTINE END
module test_Plot3 import ..ModiaMath using Test using Unitful t = range(0.0, stop=10.0, length=100) result = Dict{AbstractString,Any}() result["time"] = t result["phi"] = sin.(t)u"rad" result["phi2"] = 0.5 * sin.(t)u"rad" result["w"] = cos.(t)u"rad/s" result["phi_max"] = 1.1u"rad" result["phi_max_int"] = 1 result["open"] = false println("\n... Next plot should give a warning:") ModiaMath.plot(result, (:phi_max, :phi_max_int, :open, :phi, :phi2, :w, :signalNotDefined), heading="Sine(time)", figure=1) ModiaMath.plot(result, [:phi, :phi2, :w], heading="Sine(time)", figure=2) ModiaMath.plot(result, :phi, xAxis=:w, heading="phi=f(w)", figure=3) println("\n... Next plot should give a warning:") ModiaMath.plot(result, :phi, xAxis=:xAxisNotDefined, heading="phi=f(w)", figure=4) # Print result variables println("\n... result variables = ", ModiaMath.resultTable(result)) # Add new simulation result result["phi"] = 1.2*result["phi"] result["phi2"] = 1.1*result["phi2"] result["w"] = 0.5*result["w"] ModiaMath.plot(result, (:phi, :phi2, :w), figure=1, prefix="Sim 2: ", reuse=true) ModiaMath.plot(result, [:phi, :phi2, :w], figure=2, prefix="Sim 2: ", reuse=true) end
section\<open>Preliminaries\<close> (* Session: Kneser_Cauchy_Davenport Title: Kneser_Cauchy_Davenport_preliminaries.thy Authors: Mantas Bakšys and Angeliki Koutsoukou-Argyraki Affiliation: University of Cambridge Date: September 2022. *) theory Kneser_Cauchy_Davenport_preliminaries imports Complex_Main "Pluennecke_Ruzsa_Inequality.Pluennecke_Ruzsa_Inequality" "HOL-Number_Theory.Prime_Powers" begin context subgroup_of_group begin interpretation left: left_translations_of_group .. interpretation right: right_translations_of_group .. interpretation transformation_group "left.translation ` H" G .. lemma Right_Coset_eq_iff: assumes "x \<in> G" and "y \<in> G" shows "H |\<cdot> x = (H |\<cdot> y) \<longleftrightarrow> H |\<cdot> x \<inter> (H |\<cdot> y) \<noteq> {}" using assms Right_Coset_is_orbit by (metis Int_absorb orbit.disjoint orbit.natural.map_closed orbit.non_vacuous) end context additive_abelian_group begin subsection\<open>Elementary lemmas on sumsets \<close> (*this subsection can be moved to Pluennecke_Ruzsa_Inequality. *) lemma sumset_translate_eq_right: assumes "A \<subseteq> G" and "B \<subseteq> G" and "x \<in> G" shows "(sumset A {x} = sumset B {x}) \<longleftrightarrow> A = B" using assms by (smt (verit, best) Diff_Int_distrib2 Diff_eq_empty_iff Int_Un_eq(1) Int_absorb2 Un_Diff_cancel2 Un_commute insert_disjoint(2) subset_refl sumset_is_empty_iff sumsetdiff_sing) lemma sumset_translate_eq_left: assumes "A \<subseteq> G" and "B \<subseteq> G" and "x \<in> G" shows " (sumset {x} A = sumset {x} B) \<longleftrightarrow> A = B" using assms by (simp add: sumset_commute sumset_translate_eq_right) lemma differenceset_translate_eq_right: assumes "A \<subseteq> G" and "B \<subseteq> G" and "x \<in> G" shows "(differenceset A {x} = differenceset B {x}) \<longleftrightarrow> A = B" using assms by (metis Int_absorb2 differenceset_commute minus_minusset minusset_subset_carrier sumset_translate_eq_left) lemma differenceset_translate_eq_left: assumes "A \<subseteq> G" and "B \<subseteq> G" and "x \<in> G" shows "(differenceset {x} A = differenceset {x} B) \<longleftrightarrow> A = B" using assms by (metis differenceset_commute differenceset_translate_eq_right) lemma sumset_inter_union_subset: "sumset (A \<inter> B) (A \<union> B) \<subseteq> sumset A B" by (metis Int_Diff_Un Int_Un_eq(2) Un_subset_iff sumset_commute sumset_subset_Un(2) sumset_subset_Un2) lemma differenceset_group_eq: "G = differenceset G G" using equalityE minusset_eq minusset_triv subset_antisym sumset_D(1) sumset_subset_carrier sumset_mono image_mono Int_absorb by metis lemma card_sumset_singleton_subset_eq: assumes "a \<in> G" and "A \<subseteq> G" shows "card (sumset {a} A) = card A" using assms card_sumset_singleton_eq card.infinite card_sumset_0_iff' le_iff_inf sumset_commute by metis lemma card_differenceset_singleton_mem_eq: assumes "a \<in> G" and "A \<subseteq> G" shows "card A = card (differenceset A {a})" using assms by (metis card_minusset' card_sumset_singleton_subset_eq differenceset_commute minusset_subset_carrier) lemma card_singleton_differenceset_eq: assumes "a \<in> G" and "A \<subseteq> G" shows "card A = card (differenceset {a} A)" using assms by (metis card_minusset' card_sumset_singleton_subset_eq minusset_subset_carrier) lemma sumset_eq_Union_left: assumes "A \<subseteq> G" shows "sumset A B = (\<Union> a \<in> A. sumset {a} B)" proof show "sumset A B \<subseteq> (\<Union> a \<in> A. sumset {a} B)" using assms sumset.cases Int_absorb2 Int_iff UN_iff singletonI sumset.sumsetI by (smt (verit, del_insts) subsetI) next show "(\<Union> a \<in> A. sumset {a} B) \<subseteq> sumset A B" using sumset by auto qed lemma sumset_eq_Union_right: assumes "B \<subseteq> G" shows "sumset A B = (\<Union> b \<in> B. sumset A {b})" using assms sumset_commute sumset_eq_Union_left by (metis (no_types, lifting) Sup.SUP_cong) lemma sumset_singletons_eq: assumes "a \<in> G" and "b \<in> G" shows "sumset {a} {b} = {a \<oplus> b}" using assms sumset.simps subset_antisym by auto lemma sumset_eq_subset_differenceset: assumes "K \<subseteq> G" and "K \<noteq> {}" and "A \<subseteq> G" and "sumset A K = sumset B K" shows "A \<subseteq> differenceset (sumset B K) K" proof fix a assume ha: "a \<in> A" obtain k where hk: "k \<in> K" using assms(2) by blast then have "a \<oplus> k \<in> sumset B K" using assms sumset.sumsetI ha by blast then have "a \<oplus> (k \<ominus> k) \<in> differenceset (sumset B K) K" using hk assms ha minusset.minussetI subset_iff sumset.sumsetI by (smt (verit) associative composition_closed inverse_closed) then show "a \<in> differenceset (sumset B K) K" using hk ha subsetD assms right_unit by (metis invertible invertible_right_inverse) qed end locale subgroup_of_additive_abelian_group = subgroup_of_abelian_group H G "(\<oplus>)" \<zero> + additive_abelian_group G "(\<oplus>)" \<zero> for H G and addition (infixl "\<oplus>" 65) and zero ("\<zero>") begin notation Left_Coset (infixl "\<cdot>|" 70) lemma Left_Coset_eq_sumset: assumes "x \<in> G" shows "sumset {x} H = x \<cdot>| H" using assms Left_Coset_memI sumset.simps by fastforce lemma sumset_subgroup_eq_iff: assumes "a \<in> G" and "b \<in> G" shows "sumset {a} H = sumset {b} H \<longleftrightarrow> (sumset {a} H) \<inter> (sumset {b} H) \<noteq> {}" using Right_Coset_eq_iff assms Left_Coset_eq_sumset Left_equals_Right_coset by presburger lemma card_divide_sumset: assumes "A \<subseteq> G" shows "card H dvd card (sumset A H)" proof(cases "finite H \<and> finite A") case hfin: True then have hfinsum: "\<And> X. X \<in> ((\<lambda> a. sumset {a} H) ` A) \<Longrightarrow> finite X" using finite_sumset by force moreover have "pairwise disjnt ((\<lambda> a. sumset {a} H) ` A)" using pairwise_imageI disjnt_def sumset_subgroup_eq_iff subset_eq assms by (smt (verit, best)) moreover have "card H dvd sum card ((\<lambda> a. sumset {a} H) ` A)" proof(intro dvd_sum) fix X assume "X \<in> (\<lambda> a. sumset {a} H) ` A" then show "card H dvd card X" using dvd_refl using Left_equals_Right_coset Right_Coset_cardinality assms Left_Coset_eq_sumset by auto qed ultimately show ?thesis using assms sumset_eq_Union_left card_Union_disjoint by metis next case False then show ?thesis using assms card_sumset_0_iff by (metis card_eq_0_iff dvd_0_right sub subsetI) qed lemma sumset_subgroup_eq_Class_Union: assumes "A \<subseteq> G" shows "sumset A H = (\<Union> (Class ` A))" proof show "sumset A H \<subseteq> \<Union> (Class ` A)" proof fix x assume "x \<in> sumset A H" then obtain a b where ha: "a \<in> A" and "b \<in> H" and "x = a \<oplus> b" using sumset.cases by blast then have "x \<in> Class a" using Left_Coset_Class_unit Left_Coset_eq_sumset assms by blast thus "x \<in> \<Union> (Class ` A)" using ha by blast qed next show "\<Union> (Class ` A) \<subseteq> sumset A H" proof(intro Union_least) fix X assume "X \<in> Class ` A" then obtain a where "a \<in> A" and "X = Class a" by blast moreover hence "{a} \<subseteq> A" by auto ultimately show "X \<subseteq> sumset A H" using Left_Coset_Class_unit Left_Coset_eq_sumset assms sumset_mono subset_refl in_mono by metis qed qed lemma Class_image_sumset_subgroup_eq: assumes "A \<subseteq> G" shows "Class ` (sumset A H) = Class ` A" proof show "Class ` sumset A H \<subseteq> Class ` A" proof fix x assume "x \<in> Class ` sumset A H" then obtain c where hc: "c \<in> sumset A H" and "x = Class c" by blast moreover obtain a b where ha: "a \<in> A" and "b \<in> H" and "c = a \<oplus> b" using hc sumset.cases by blast ultimately show "x \<in> Class ` A" using ha Class_eq CongruenceI assms composition_closed sumset.cases Partition_def commutative image_eqI left_unit sub unit_closed by (smt (verit, ccfv_threshold) Block_self Class_cong Normal_def) qed next show "Class ` A \<subseteq> Class ` sumset A H" using assms right_unit subsetD subsetI sumset.sumsetI unit_closed by (smt (verit, del_insts) image_subset_iff sub_unit_closed) qed lemma Class_cover_imp_subset_or_disj: assumes "A = (\<Union> (Class ` C))" and "x \<in> G" and "C \<subseteq> G" shows "Class x \<subseteq> A \<or> Class x \<inter> A = {}" proof(intro disjCI) assume "Class x \<inter> A \<noteq> {}" then obtain c where "c \<in> C" and "Class x \<inter> Class c \<noteq> {}" using assms by blast then show "Class x \<subseteq> A" using assms not_disjoint_implies_equal Sup_upper imageI subset_iff by blast qed end context additive_abelian_group begin subsection\<open>Stabilizer and basic properties\<close> text\<open>We define the stabilizer or group of periods of a nonempty subset of an abelian group.\<close> definition stabilizer::"'a set \<Rightarrow> 'a set " where "stabilizer S \<equiv> {x \<in> G. sumset {x} (S \<inter> G) = S \<inter> G}" lemma stabilizer_is_subgroup: fixes S :: "'a set" shows "subgroup (stabilizer S) G (\<oplus>) (\<zero>)" proof (intro subgroupI) show "stabilizer S \<subseteq> G" using stabilizer_def by auto next show "\<zero> \<in> stabilizer S" using stabilizer_def by (simp add: Int_absorb1 Int_commute) next fix a b assume haS: "a \<in> stabilizer S" and hbS: "b \<in> stabilizer S" then have haG: "a \<in> G" and hbG: "b \<in> G" using stabilizer_def by auto have "sumset {a \<oplus> b} (S \<inter> G) = sumset {a} (sumset {b} (S \<inter> G))" proof show "sumset {a \<oplus> b} (S \<inter> G) \<subseteq> sumset {a} (sumset {b} (S \<inter> G))" using haG hbG empty_subsetI insert_subset subsetI sumset.simps sumset_assoc sumset_mono by metis show "sumset {a} (sumset {b} (S \<inter> G)) \<subseteq> sumset {a \<oplus> b} (S \<inter> G)" using empty_iff insert_iff sumset.simps sumset_assoc by (smt (verit, best) subsetI) qed then show "a \<oplus> b \<in> stabilizer S" using haS hbS stabilizer_def by auto next fix g assume "g \<in> stabilizer S" thus "invertible g" using stabilizer_def by auto next fix g assume hgS: "g \<in> stabilizer S" then have hinvsum : "inverse g \<oplus> g = \<zero>" using stabilizer_def by simp have "sumset {inverse g} (sumset {g} (S \<inter> G)) = (S \<inter> G)" proof show "sumset {inverse g} (sumset {g} (S \<inter> G)) \<subseteq> (S \<inter> G)" using empty_iff insert_iff sumset.simps sumset_assoc subsetI left_unit hinvsum by (smt (verit, ccfv_threshold)) show "(S \<inter> G) \<subseteq> sumset {inverse g} (sumset {g} (S \<inter> G))" proof fix s assume hs: "s \<in> (S \<inter> G)" then have "inverse g \<oplus> g \<oplus> s \<in> sumset {inverse g} (sumset {g} (S \<inter> G))" using hgS stabilizer_def additive_abelian_group.sumset.sumsetI additive_abelian_group_axioms associative in_mono inverse_closed mem_Collect_eq singletonI by (smt (z3) IntD2) thus "s \<in> sumset {inverse g} (sumset {g} (S \<inter> G))" using hinvsum hs by simp qed qed thus "inverse g \<in> stabilizer S" using hgS stabilizer_def by auto qed interpretation subgroup_of_additive_abelian_group "stabilizer A" "G" "(\<oplus>)" "\<zero>" using stabilizer_is_subgroup subgroup_of_abelian_group_def by (metis abelian_group_axioms additive_abelian_group_axioms group_axioms subgroup_of_additive_abelian_group_def subgroup_of_group_def) lemma zero_mem_stabilizer: "\<zero> \<in> stabilizer A" .. lemma stabilizer_is_nonempty: shows "stabilizer S \<noteq> {}" using sub_unit_closed by blast lemma Left_Coset_eq_sumset_stabilizer: assumes "x \<in> G" shows "sumset {x} (stabilizer B) = x \<cdot>| (stabilizer B)" by (simp add: Left_Coset_eq_sumset assms) lemma stabilizer_subset_difference_singleton: assumes "S \<subseteq> G" and "s \<in> S" shows "stabilizer S \<subseteq> differenceset S {s}" proof fix x assume hx: "x \<in> stabilizer S" then obtain t where ht: "t \<in> S" and "x \<oplus> s = t" using assms stabilizer_def by blast then have "x = t \<ominus> s" using hx stabilizer_def assms associative by (metis (no_types, lifting) in_mono inverse_closed invertible invertible_right_inverse sub sub.right_unit) thus "x \<in> differenceset S {s}" using ht assms by (simp add: minusset.minussetI subsetD sumset.sumsetI) qed lemma stabilizer_subset_singleton_difference: assumes "S \<subseteq> G" and "s \<in> S" shows "stabilizer S \<subseteq> differenceset {s} S" proof- have "stabilizer S \<subseteq> minusset (stabilizer S)" using assms Int_absorb2 minusset_eq subgroup.image_of_inverse submonoid.sub subset_eq by (smt (verit) stabilizer_is_subgroup stabilizer_subset_difference_singleton sumset_subset_carrier) moreover have "minusset (stabilizer S) \<subseteq> minusset (differenceset S {s})" proof fix x assume hx1: "x \<in> minusset (stabilizer S)" then have hx: "inverse x \<in> stabilizer S" by (metis invertible invertible_inverse_inverse minusset.cases) then obtain t where ht: "t \<in> S" and "inverse x \<oplus> s = t" using assms stabilizer_def by blast then have hx2: "inverse x = t \<ominus> s" using hx stabilizer_def assms by (smt (verit, ccfv_threshold) commutative in_mono inverse_closed invertible invertible_left_inverse2 sub) thus "x \<in> minusset (differenceset S {s})" using ht assms by (smt (verit, best) hx1 additive_abelian_group.sumset.sumsetI additive_abelian_group_axioms inverse_closed invertible invertible_inverse_inverse minusset.cases minusset.minussetI singletonI subset_iff) qed ultimately show ?thesis using differenceset_commute assms by blast qed lemma stabilizer_subset_nempty: assumes "S \<noteq> {}" and "S \<subseteq> G" shows "stabilizer S \<subseteq> differenceset S S" proof fix x assume hx: "x \<in> stabilizer S" then obtain s where hs: "s \<in> S \<inter> G" using assms by blast then have "x \<oplus> s \<in> S \<inter> G" using stabilizer_def assms hx mem_Collect_eq singletonI sumset.sumsetI sumset_Int_carrier by blast then obtain t where ht: "t \<in> S" and "x \<oplus> s = t" by blast then have "x = t \<ominus> s" using hx stabilizer_def assms(2) hs ht associative by (metis IntD2 inverse_closed invertible invertible_right_inverse sub sub.right_unit) thus "x \<in> differenceset S S" using ht hs using assms(2) by blast qed lemma stabilizer_coset_subset: assumes "A \<subseteq> G" and "x \<in> A" shows "sumset {x} (stabilizer A) \<subseteq> A" proof fix y assume "y \<in> sumset {x} (stabilizer A)" moreover hence "stabilizer A \<subseteq> differenceset A {x}" using assms stabilizer_subset_difference_singleton by auto moreover have "sumset {x} (differenceset A {x}) \<subseteq> A" proof fix z assume "z \<in> sumset {x} (differenceset A {x})" then obtain a where "a \<in> A" and "z = x \<oplus> (a \<ominus> x)" using additive_abelian_group.sumset.cases additive_abelian_group_axioms singletonD minusset.cases assms subsetD by (smt (verit, ccfv_SIG)) thus "z \<in> A" using assms by (metis additive_abelian_group.inverse_closed additive_abelian_group_axioms commutative in_mono invertible invertible_right_inverse2) qed ultimately show "y \<in> A" by (meson in_mono subset_singleton_iff sumset_mono) qed lemma stabilizer_subset_stabilizer_dvd: assumes "stabilizer A \<subseteq> stabilizer B" shows "card (stabilizer A) dvd card (stabilizer B)" proof(cases "finite (stabilizer B)") case hB: True interpret H: subgroup_of_group "stabilizer A" "stabilizer B" "(\<oplus>)" "\<zero>" proof(unfold_locales) show "stabilizer A \<subseteq> stabilizer B" using assms by blast next show "\<And>a b. a \<in> stabilizer A \<Longrightarrow> b \<in> stabilizer A \<Longrightarrow> a \<oplus> b \<in> stabilizer A" using stabilizer_is_subgroup group_axioms by simp next show "\<zero> \<in> stabilizer A" using sub_unit_closed by blast qed show ?thesis using H.lagrange hB by auto next case False then show ?thesis by simp qed lemma stabilizer_coset_Un: assumes "A \<subseteq> G" shows "(\<Union> x \<in> A. sumset {x} (stabilizer A)) = A" proof show "(\<Union>x\<in>A. sumset {x} (stabilizer A)) \<subseteq> A" using stabilizer_coset_subset assms by blast next show "A \<subseteq> (\<Union>x\<in>A. sumset {x} (stabilizer A))" proof fix x assume hx: "x \<in> A" then have "x \<in> sumset {x} (stabilizer A)" using sub_unit_closed assms by (metis in_mono right_unit singletonI sumset.sumsetI unit_closed) thus "x \<in> (\<Union>x\<in>A. sumset {x} (stabilizer A))" using hx by blast qed qed lemma stabilizer_empty: "stabilizer {} = G" using sumset_empty Int_empty_left stabilizer_def subset_antisym by (smt (verit, best) mem_Collect_eq subsetI sumset_Int_carrier_eq(1) sumset_commute) lemma stabilizer_finite: assumes "S \<subseteq> G" and "S \<noteq> {}" and "finite S" shows "finite (stabilizer S)" using stabilizer_subset_nempty assms by (meson finite_minusset finite_sumset rev_finite_subset) lemma stabilizer_subset_group: shows "stabilizer S \<subseteq> G" using stabilizer_def by blast lemma sumset_stabilizer_eq_iff: assumes "a \<in> G" and "b \<in> G" shows "sumset {a} (stabilizer A) = sumset {b} (stabilizer A) \<longleftrightarrow> (sumset {a} (stabilizer A)) \<inter> (sumset {b} (stabilizer A)) \<noteq> {}" by (simp add: assms sumset_subgroup_eq_iff) lemma sumset_stabilizer_eq_Class_Union: assumes "A \<subseteq> G" shows "sumset A (stabilizer B) = (\<Union> (Class B ` A))" by (simp add: assms sumset_subgroup_eq_Class_Union) lemma card_stabilizer_divide_sumset: assumes "A \<subseteq> G" shows "card (stabilizer B) dvd card (sumset A (stabilizer B))" by (simp add: assms card_divide_sumset) lemma Class_image_sumset_stabilizer_eq: assumes "A \<subseteq> G" shows "Class B ` (sumset A (stabilizer B)) = Class B ` A" by (simp add: Class_image_sumset_subgroup_eq assms) lemma Class_cover_imp_subset_or_disj: assumes "A = (\<Union> (Class B ` C))" and "x \<in> G" and "C \<subseteq> G" shows "Class B x \<subseteq> A \<or> Class B x \<inter> A = {}" by (simp add: Class_cover_imp_subset_or_disj assms) lemma stabilizer_sumset_disjoint: fixes S1 S2 :: "'a set" assumes "stabilizer S1 \<inter> stabilizer S2 = {\<zero>}" and "S1 \<subseteq> G" and "S2 \<subseteq> G" and "finite S1" and "finite S2" and "S1 \<noteq> {}" and "S2 \<noteq> {}" shows "card (sumset (stabilizer S1) (stabilizer S2)) = card (stabilizer S1) * card (stabilizer S2)" proof- have inj_on : "inj_on (\<lambda> (a, b). a \<oplus> b) (stabilizer S1 \<times> stabilizer S2)" proof(intro inj_onI) fix x y assume "x \<in> stabilizer S1 \<times> stabilizer S2" and "y \<in> stabilizer S1 \<times> stabilizer S2" and "(case x of (a, b) \<Rightarrow> a \<oplus> b) = (case y of (a, b) \<Rightarrow> a \<oplus> b)" then obtain a b c d where hx: "x = (a, b)" and hy: "y = (c, d)" and ha: "a \<in> stabilizer S1" and hb: "b \<in> stabilizer S2" and hc: "c \<in> stabilizer S1" and hd: "d \<in> stabilizer S2" and habcd: "a \<oplus> b = c \<oplus> d" by auto then have haG: "a \<in> G" using stabilizer_def by blast have hbG: "b \<in> G" using hb stabilizer_def by blast have hcG: "c \<in> G" using hc stabilizer_def by blast have hdG: "d \<in> G" using hd stabilizer_def by blast then have "a \<ominus> c = d \<ominus> b" using habcd haG hbG hcG hdG by (metis (full_types) associative commutative composition_closed inverse_equality invertible invertible_def invertible_left_inverse2) moreover have "a \<ominus> c \<in> stabilizer S1" using ha hc stabilizer_is_subgroup subgroup.axioms(1) submonoid.sub_composition_closed by (metis group.invertible group_axioms hcG subgroup.subgroup_inverse_iff) moreover have "d \<ominus> b \<in> stabilizer S2" using hd hb stabilizer_is_subgroup subgroup.axioms(1) submonoid.sub_composition_closed by (metis group.invertible group_axioms hbG subgroup.subgroup_inverse_iff) ultimately have "a \<ominus> c = \<zero>" and "d \<ominus> b = \<zero>" using assms(1) by auto thus "x = y" using hx hy haG hbG hcG hdG by (metis inverse_closed invertible invertible_right_cancel invertible_right_inverse) qed moreover have himage : "(\<lambda> (a, b). a \<oplus> b) ` (stabilizer S1 \<times> stabilizer S2) = sumset (stabilizer S1) (stabilizer S2)" proof show "(\<lambda>(a, b). a \<oplus> b) ` (stabilizer S1 \<times> stabilizer S2) \<subseteq> sumset (stabilizer S1) (stabilizer S2)" using stabilizer_subset_group by force next show "sumset (stabilizer S1) (stabilizer S2) \<subseteq> (\<lambda>(a, b). a \<oplus> b) ` (stabilizer S1 \<times> stabilizer S2)" proof fix x assume "x \<in> sumset (stabilizer S1) (stabilizer S2)" then obtain s1 s2 where hs1: "s1 \<in> stabilizer S1" and hs2: "s2 \<in> stabilizer S2" and "x = s1 \<oplus> s2" by (meson sumset.cases) thus "x \<in> (\<lambda>(a, b). a \<oplus> b) ` (stabilizer S1 \<times> stabilizer S2)" using hs1 hs2 by auto qed qed ultimately show ?thesis using card_image card_cartesian_product by fastforce qed lemma stabilizer_sub_sumset_left: "stabilizer A \<subseteq> stabilizer (sumset A B)" proof fix x assume hx: "x \<in> stabilizer A" then have "sumset {x} (sumset A B) = sumset A B" using stabilizer_def sumset_assoc mem_Collect_eq by (smt (verit, del_insts) sumset_Int_carrier_eq(1) sumset_commute) thus "x \<in> stabilizer (sumset A B)" using hx stabilizer_def by (metis (mono_tags, lifting) mem_Collect_eq sumset_Int_carrier) qed lemma stabilizer_sub_sumset_right: "stabilizer B \<subseteq> stabilizer (sumset A B)" using stabilizer_sub_sumset_left sumset_commute by fastforce lemma not_mem_stabilizer_obtain: assumes "A \<noteq> {}" and "x \<notin> stabilizer A" and "x \<in> G" and "A \<subseteq> G" and "finite A" obtains a where "a \<in> A" and "x \<oplus> a \<notin> A" proof- have "sumset {x} A \<noteq> A" using assms stabilizer_def by (metis (mono_tags, lifting) inf.orderE mem_Collect_eq) moreover have "card (sumset {x} A) = card A" using assms by (metis card_sumset_singleton_eq inf.orderE sumset_commute) ultimately obtain y where "y \<in> sumset {x} A" and "y \<notin> A" using assms by (meson card_subset_eq subsetI) then obtain a where "a \<in> A" and "x \<oplus> a \<notin> A" using assms by (metis singletonD sumset.cases) thus ?thesis using that by blast qed lemma sumset_eq_sub_stabilizer: assumes "A \<subseteq> G" and "B \<subseteq> G" and "finite B" shows "sumset A B = B \<Longrightarrow> A \<subseteq> stabilizer B" proof fix x assume hsum: "sumset A B = B" and hx: "x \<in> A" have "sumset {x} B = B" proof- have "sumset {x} B \<subseteq> B" using hsum hx by (metis empty_subsetI equalityE insert_subset sumset_mono) moreover have "card (sumset {x} B) = card B" using assms by (metis IntD1 Int_absorb1 card_sumset_singleton_eq hx inf_commute sumset_commute) ultimately show ?thesis using card_subset_eq assms(3) by auto qed thus "x \<in> stabilizer B" using hx assms(1) stabilizer_def by (metis (mono_tags, lifting) assms(2) inf.orderE mem_Collect_eq subsetD) qed lemma sumset_stabilizer_eq: shows "sumset (stabilizer A) (stabilizer A) = stabilizer A" proof show "sumset (stabilizer A) (stabilizer A) \<subseteq> stabilizer A" using stabilizer_is_subgroup subgroup.axioms(1) subsetI by (metis (mono_tags, lifting) additive_abelian_group.sumset.simps additive_abelian_group_axioms submonoid.sub_composition_closed) next show "stabilizer A \<subseteq> sumset (stabilizer A) (stabilizer A)" using Left_Coset_eq_sumset stabilizer_is_nonempty stabilizer_subset_group sub_unit_closed additive_abelian_group_axioms right_unit subset_iff sumsetI by (smt (verit, best)) qed lemma differenceset_stabilizer_eq: shows "differenceset (stabilizer A) (stabilizer A) = stabilizer A" proof show "differenceset (stabilizer A) (stabilizer A) \<subseteq> stabilizer A" proof fix x assume "x \<in> differenceset (stabilizer A) (stabilizer A)" then obtain a b where "a \<in> stabilizer A" and "b \<in> stabilizer A" and "x = a \<ominus> b" by (metis minusset.cases sumset.cases) thus "x \<in> stabilizer A" using stabilizer_is_subgroup subgroup.axioms(1) by (smt (verit, ccfv_threshold) in_mono invertible stabilizer_subset_group subgroup_inverse_iff sub_composition_closed) qed next show "stabilizer A \<subseteq> differenceset (stabilizer A) (stabilizer A)" proof fix x assume hx: "x \<in> stabilizer A" then have "x \<ominus> \<zero> \<in> differenceset (stabilizer A) (stabilizer A)" by blast then show "x \<in> differenceset (stabilizer A) (stabilizer A)" using hx by simp qed qed lemma stabilizer2_sub_stabilizer: shows "stabilizer(stabilizer A) \<subseteq> stabilizer A" proof(cases "A \<noteq> {}") case True then have "stabilizer(stabilizer A) \<subseteq> differenceset (stabilizer A) (stabilizer A)" by (simp add: stabilizer_is_nonempty stabilizer_subset_group stabilizer_subset_nempty) thus ?thesis using differenceset_stabilizer_eq by blast next case False then show ?thesis by (simp add: stabilizer_empty stabilizer_subset_group) qed lemma stabilizer_left_sumset_invariant: assumes "a \<in> G" and "A \<subseteq> G" shows "stabilizer (sumset {a} A) = stabilizer A" proof show "stabilizer (sumset {a} A) \<subseteq> stabilizer A" proof fix x assume hx: "x \<in> stabilizer (sumset {a} A)" then have hxG: "x \<in> G" using stabilizer_def by blast have "sumset {x} (sumset {a} A) = sumset {a} A" using stabilizer_def hx by (metis (mono_tags, lifting) mem_Collect_eq sumset_Int_carrier) then have "sumset {x} A = A" using assms by (metis (full_types) sumset_assoc sumset_commute sumset_subset_carrier sumset_translate_eq_right) thus "x \<in> stabilizer A" using hxG stabilizer_def by (metis (mono_tags, lifting) mem_Collect_eq sumset_Int_carrier) qed next show "stabilizer A \<subseteq> stabilizer (sumset {a} A)" using stabilizer_def using stabilizer_sub_sumset_right by meson qed lemma stabilizer_right_sumset_invariant: assumes "a \<in> G" and "A \<subseteq> G" shows "stabilizer (sumset A {a}) = stabilizer A" using sumset_commute stabilizer_left_sumset_invariant assms by simp lemma stabilizer_right_differenceset_invariant: assumes "b \<in> G" and "A \<subseteq> G" shows "stabilizer (differenceset A {b}) = stabilizer A" using assms minusset_eq stabilizer_right_sumset_invariant by auto lemma stabilizer_unchanged: assumes "a \<in> G" and "b \<in> G" shows "stabilizer (sumset A B) = stabilizer (sumset A (sumset (differenceset B {b}) {a}))" proof- have "sumset A (sumset (differenceset B {b}) {a}) = sumset (differenceset (sumset A B) {b}) {a}" by (simp add: sumset_assoc) thus ?thesis using stabilizer_right_sumset_invariant stabilizer_right_differenceset_invariant assms sumset_subset_carrier by simp qed lemma subset_stabilizer_of_subset_sumset: assumes "A \<subseteq> sumset {x} (stabilizer B)" and "x \<in> G" and "A \<noteq> {}" and "A \<subseteq> G" shows "stabilizer A \<subseteq> stabilizer B" proof- obtain a where ha: "a \<in> A" using assms by blast moreover then obtain b where hb: "b \<in> stabilizer B" and haxb: "a = x \<oplus> b" using sumset.cases assms by blast ultimately have "stabilizer A \<subseteq> differenceset A {a}" using assms sumset_subset_carrier stabilizer_subset_difference_singleton by (meson subset_trans) also have "... = sumset {inverse a} A" using sumset_commute ha assms(4) inverse_closed subsetD minusset_eq by auto also have "... \<subseteq> sumset {inverse x \<oplus> inverse b} (sumset {x} (stabilizer B))" using assms sumset_mono haxb inverse_closed hb stabilizer_subset_group subsetD commutative inverse_composition_commute by (metis invertible subset_singleton_iff) also have "... = sumset {inverse b} (stabilizer B)" using sumset_singletons_eq commutative assms sumset_assoc hb stabilizer_subset_group inverse_closed invertible by (metis composition_closed invertible_right_inverse2 sub) also have "... = stabilizer B" using hb Left_Coset_eq_sumset sub_unit_closed sub subset_iff additive_abelian_group_axioms calculation disjoint_iff_not_equal factor_unit inverse_closed sumset_subgroup_eq_iff by (smt (verit, del_insts)) finally show ?thesis . qed lemma sumset_stabilizer_eq_self: assumes "A \<subseteq> G" shows "sumset (stabilizer A) A = A" using assms sumset_eq_Union_left[OF "stabilizer_subset_group"] Int_absorb2 stabilizer_coset_Un sumset_commute sumset_eq_Union_left by presburger lemma stabilizer_neq_subset_sumset: assumes "A \<subseteq> sumset {x} (stabilizer B)" and "x \<in> A" and "\<not> sumset {x} (stabilizer B) \<subseteq> C" and "A \<subseteq> C" and "C \<subseteq> G" shows "stabilizer A \<noteq> stabilizer B" proof assume heq: "stabilizer A = stabilizer B" obtain a where "a \<in> sumset {x} (stabilizer B)" and "a \<notin> C" using assms by blast moreover then obtain b where "b \<in> stabilizer B" and "a = x \<oplus> b" using sumset.cases by blast ultimately have "b \<oplus> x \<notin> A" using commutative stabilizer_subset_group assms in_mono by metis thus False using assms heq stabilizer_coset_subset subset_trans by metis qed lemma subset_stabilizer_Un: shows "stabilizer A \<inter> stabilizer B \<subseteq> stabilizer (A \<union> B)" proof fix x assume hx: "x \<in> stabilizer A \<inter> stabilizer B" then have "sumset {x} (A \<inter> G) = A \<inter> G" using stabilizer_def by blast moreover have "sumset {x} (B \<inter> G) = (B \<inter> G)" using stabilizer_def hx by blast ultimately have "sumset {x} ((A \<union> B) \<inter> G) = (A \<union> B) \<inter> G" using sumset_subset_Un2 boolean_algebra.conj_disj_distrib2 by auto then show "x \<in> stabilizer (A \<union> B)" using hx stabilizer_subset_group stabilizer_def by blast qed lemma mem_stabilizer_Un_and_left_imp_right: assumes "finite B" and "x \<in> stabilizer (A \<union> B)" and "x \<in> stabilizer A" and "disjnt A B" shows "x \<in> stabilizer B" proof- have "(A \<inter> G) \<union> sumset {x} (B \<inter> G) = (A \<inter> G) \<union> (B \<inter> G)" using assms(2) sumset_subset_Un2[of "{x}" "A \<inter> G" "B \<inter> G"] stabilizer_def[of "A \<union> B"] Int_Un_distrib2[of "A" "B" "G"] assms(3) stabilizer_def by (metis (mono_tags, lifting) mem_Collect_eq) then have "B \<inter> G \<subseteq> sumset {x} (B \<inter> G)" using assms(4) disjnt_def Int_Un_distrib2 Int_commute sumset_subset_Un1 by (smt (verit, del_insts) Int_assoc Un_Int_eq(2) inf.orderI insert_is_Un sumset_empty(2)) then show "x \<in> stabilizer B" using stabilizer_def[of "B"] assms(1) assms(3) card_subset_eq card_sumset_singleton_subset_eq finite.emptyI finite.insertI finite_Int finite_sumset inf.cobounded2 stabilizer_subset_group subsetD by (smt (verit) mem_Collect_eq) qed lemma mem_stabilizer_Un_and_right_imp_left: assumes "finite A" and "x \<in> stabilizer (A \<union> B)" and "x \<in> stabilizer B" and "disjnt A B" shows "x \<in> stabilizer A" using mem_stabilizer_Un_and_left_imp_right Un_commute assms disjnt_sym by metis lemma Union_stabilizer_Class_eq: assumes "A \<subseteq> G" shows "A = (\<Union> (Class A ` A))" using assms sumset_commute sumset_subgroup_eq_Class_Union sumset_stabilizer_eq_self by presburger lemma card_stabilizer_sumset_divide_sumset: "card (stabilizer (sumset A B)) dvd card (sumset A B)" using card_divide_sumset sumset_commute sumset_stabilizer_eq_self sumset_subset_carrier by metis lemma card_stabilizer_le: assumes "A \<subseteq> G" and "finite A" and "A \<noteq> {}" shows "card (stabilizer A) \<le> card A" using assms by (metis card_le_sumset finite.cases insertCI insert_subset stabilizer_finite stabilizer_subset_group sumset_commute sumset_stabilizer_eq_self) lemma sumset_Inter_subset_sumset: assumes "a \<in> G" and "b \<in> G" shows "sumset (A \<inter> sumset {a} (stabilizer C)) (B \<inter> sumset {b} (stabilizer C)) \<subseteq> sumset {a \<oplus> b} (stabilizer C)" (is "sumset ?A ?B \<subseteq> _") proof fix x assume "x \<in> sumset ?A ?B" then obtain d1 d2 where "d1 \<in> sumset {a} (stabilizer C)" and "d2 \<in> sumset {b} (stabilizer C)" and "x = d1 \<oplus> d2" by (meson IntD2 sumset.cases) then obtain c1 c2 where hc1: "c1 \<in> stabilizer C" and hc2: "c2 \<in> stabilizer C" and "x = (a \<oplus> c1) \<oplus> (b \<oplus> c2)" using sumset.simps by auto then have "x = (a \<oplus> b) \<oplus> (c1 \<oplus> c2)" using hc1 hc2 assms associative commutative stabilizer_subset_group by simp thus "x \<in> sumset {a \<oplus> b} (stabilizer C)" using stabilizer_is_subgroup hc1 hc2 stabilizer_subset_group sumset.simps sumset_stabilizer_eq assms by blast qed subsection\<open>Convergent\<close> (* I manually exclude the empty set from this definition as its stabilizer is too big *) definition convergent :: "'a set \<Rightarrow> 'a set \<Rightarrow> 'a set \<Rightarrow> bool" where "convergent C A B \<equiv> C \<subseteq> sumset A B \<and> C \<noteq> {} \<and> card C + card (stabilizer C) \<ge> card (A \<inter> B) + card (sumset (A \<union> B) (stabilizer C))" definition convergent_set :: "'a set \<Rightarrow> 'a set \<Rightarrow> 'a set set" where "convergent_set A B = Collect (\<lambda> C. convergent C A B)" lemma convergent_set_sub_powerset: "convergent_set A B \<subseteq> Pow (sumset A B)" using convergent_set_def convergent_def by blast lemma finite_convergent_set: assumes "finite A" and "finite B" shows "finite (convergent_set A B)" using convergent_set_sub_powerset finite_Pow_iff finite_sumset assms finite_subset by metis subsection\<open>Technical lemmas from DeVos's proof of Kneser's Theorem\<close> text\<open>The following lemmas correspond to intermediate arguments in the proof of Kneser's Theorem by DeVos that we will be following \cite{DeVos_Kneser}. \<close> lemma stabilizer_sumset_psubset_stabilizer: assumes "a \<in> G" and "b \<in> G" and "A \<inter> sumset {a} (stabilizer C) \<noteq> {}" and "B \<inter> sumset {b} (stabilizer C) \<noteq> {}" and hnotsub: "\<not> sumset {a \<oplus> b} (stabilizer C) \<subseteq> sumset A B" shows "stabilizer (sumset (A \<inter> sumset {a} (stabilizer C)) (B \<inter> sumset {b} (stabilizer C))) \<subset> stabilizer C" (is "?H \<subset> _") proof have "sumset (A \<inter> sumset {a} (stabilizer C)) (B \<inter> sumset {b} (stabilizer C)) \<noteq> {}" using assms by (simp add: inf_assoc) then show "?H \<subseteq> stabilizer C" by (meson assms(1) assms(2) composition_closed subset_stabilizer_of_subset_sumset sumset_Inter_subset_sumset sumset_subset_carrier) next obtain c1 c2 where "a \<oplus> c1 \<in> A" and "b \<oplus> c2 \<in> B" and hc1: "c1 \<in> stabilizer C" and hc2: "c2 \<in> stabilizer C" using assms(1, 2, 3, 4) Left_Coset_eq_sumset_stabilizer by fastforce then have hac1mem: "(a \<oplus> c1) \<in> A \<inter> sumset {a} (stabilizer C)" and hac1G: "a \<oplus> c1 \<in> G" and hbc2mem: "(b \<oplus> c2) \<in> B \<inter> sumset {b} (stabilizer C)" and hbc2G: "b \<oplus> c2 \<in> G" by (auto simp add: assms(1, 2) sumset.sumsetI) have "(a \<oplus> c1) \<oplus> (b \<oplus> c2) \<in> sumset {a \<oplus> b} (stabilizer C)" using assms hc1 hc2 by (smt (verit) associative commutative composition_closed insertI1 sub sub_composition_closed sumset.sumsetI) then have "sumset {a \<oplus> b} (stabilizer C) \<inter> sumset {(a \<oplus> c1) \<oplus> (b \<oplus> c2)} (stabilizer C) \<noteq> {}" using zero_mem_stabilizer by (smt (verit, ccfv_threshold) composition_closed disjoint_iff_not_equal hac1G hbc2G insertCI right_unit sumset.sumsetI unit_closed) then have hsumeq: "sumset {a \<oplus> b} (stabilizer C) = sumset {(a \<oplus> c1) \<oplus> (b \<oplus> c2)} (stabilizer C)" using sumset_stabilizer_eq_iff assms hac1G hbc2G composition_closed by presburger have "(sumset (A \<inter> sumset {a} (stabilizer C)) (B \<inter> sumset {b} (stabilizer C))) \<subseteq> sumset {a \<oplus> b} (stabilizer C)" by (simp add: assms(1, 2) sumset_Inter_subset_sumset) have hsummem: "(a \<oplus> c1) \<oplus> (b \<oplus> c2) \<in> sumset (A \<inter> sumset {a} (stabilizer C)) (B \<inter> sumset {b} (stabilizer C))" using hac1mem hbc2mem hac1G hbc2G sumset.sumsetI by blast show "?H \<noteq> stabilizer C" using stabilizer_neq_subset_sumset[OF _ hsummem] hnotsub hsumeq sumset_Inter_subset_sumset assms sumset_subset_carrier composition_closed sumset_mono sumset.sumsetI zero_mem_stabilizer inf.cobounded1 right_unit unit_closed by metis qed lemma stabilizer_eq_stabilizer_union: assumes "a \<in> G" and "b \<in> G" and"A \<inter> sumset {a} (stabilizer C) \<noteq> {}" and "B \<inter> sumset {b} (stabilizer C) \<noteq> {}" and hnotsub: "\<not> sumset {a \<oplus> b} (stabilizer C) \<subseteq> sumset A B" and "C \<subseteq> sumset A B" and "finite C" and "C \<inter> sumset (A \<inter> sumset {a} (stabilizer C)) (B \<inter> sumset {b} (stabilizer C)) = {}" and "C \<noteq> {}" and "finite A" and "finite B" shows "stabilizer (sumset (A \<inter> sumset {a} (stabilizer C)) (B \<inter> sumset {b} (stabilizer C))) = stabilizer (C \<union> sumset (A \<inter> sumset {a} (stabilizer C)) (B \<inter> sumset {b} (stabilizer C)))" (is "stabilizer ?H = stabilizer ?K") proof show "stabilizer ?H \<subseteq> stabilizer ?K" using subset_stabilizer_Un Int_absorb1 stabilizer_sumset_psubset_stabilizer psubset_imp_subset assms by metis next have hCG : "C \<subseteq> G" using assms(6) sumset_subset_carrier by force show "stabilizer ?K \<subseteq> stabilizer ?H" proof fix x assume hxC1: "x \<in> stabilizer ?K" moreover have "x \<in> stabilizer C" proof- have hC_Un: "C = (\<Union> (Class C ` C))" using Union_stabilizer_Class_eq hCG by simp have hCsumx: "sumset {x} C = (\<Union> y \<in> Class C ` C. sumset {x} y)" proof show "sumset {x} C \<subseteq> \<Union> (sumset {x} ` Class C ` C)" proof fix y assume hy: "y \<in> sumset {x} C" then obtain c where hc: "c \<in> C" and hyxc: "y = x \<oplus> c" using sumset.cases by blast then obtain K where hK: "K \<in> Class C ` C" and "c \<in> K" using hC_Un by blast then have "y \<in> sumset {x} K" using hyxc hc by (metis sumset.cases sumset.sumsetI hCG hy singletonD subset_iff) then show "y \<in> \<Union> (sumset {x} ` Class C ` C)" using hK by auto qed next show "\<Union> (sumset {x} ` Class C ` C) \<subseteq> sumset {x} C" proof(intro Union_least) fix X assume "X \<in> sumset {x} ` Class C ` C" then obtain K where "K \<in> Class C ` C" and "X = sumset {x} K" by blast then show "X \<subseteq> sumset {x} C" using sumset_mono[of "{x}" "{x}" "K" "C"] hC_Un subset_refl by blast qed qed have "x \<notin> stabilizer C \<Longrightarrow> False" proof- assume hxC: "x \<notin> stabilizer C" then have hxG: "x \<in> G" using hxC1 stabilizer_subset_group by blast then have hxCne: "sumset {x} C \<noteq> C" using stabilizer_def[of "C"] hCG Int_absorb2 hxC by (metis (mono_tags, lifting) mem_Collect_eq) moreover have hxsplit: "sumset {x} C \<union> sumset {x} ?H = C \<union> ?H" using hxC1 stabilizer_def[of "?K"] sumset_subset_carrier assms(6) sumset_subset_Un2 by force have "sumset {x} C \<inter> ?H \<noteq> {}" proof assume "sumset {x} C \<inter> ?H = {}" then have "sumset {x} C \<subset> C" using hxsplit hxCne by blast thus "False" using hCG assms(6) assms(7) hxC1 stabilizer_subset_group psubset_card_mono by (metis card_sumset_singleton_eq sumset_Int_carrier sumset_commute sumset_stabilizer_eq_self hxG less_irrefl_nat) qed then obtain c where hc: "c \<in> C" and hxcne: "sumset {x} (Class C c) \<inter> ?H \<noteq> {}" using hCsumx by blast then have hxc: "sumset {x} (Class C c) = Class C (x \<oplus> c)" using hxG assms(6) Left_Coset_Class_unit Left_Coset_eq_sumset_stabilizer sumset_assoc sumset_singletons_eq composition_closed sumset.cases sumset_stabilizer_eq_self hCG by (smt (verit)) have hClassCempty: "Class C (x \<oplus> c) \<inter> C = {}" proof- have "\<not> Class C (x \<oplus> c) \<subseteq> C" using hxc hxcne assms(8) by blast then show ?thesis using Class_cover_imp_subset_or_disj[OF hC_Un _ hCG] by (meson composition_closed hCG hc hxG subsetD) qed have "Class C (x \<oplus> c) \<subseteq> sumset {x} C" using hCsumx hc hxc by blast then have "Class C (x \<oplus> c) \<subseteq> ?H" using hClassCempty hxsplit by auto moreover have "card (Class C (x \<oplus> c)) = card (stabilizer C)" using hxG hc hCG composition_closed Right_Coset_Class_unit Right_Coset_cardinality sumset_Int_carrier Class_cover_imp_subset_or_disj assms by auto ultimately have "card (stabilizer C) \<le> card ?H" using card_mono finite_sumset assms(10, 11) finite_Int by metis moreover have "card ?H < card (sumset {a \<oplus> b} (stabilizer C))" proof (intro psubset_card_mono psubsetI sumset_Inter_subset_sumset assms(1) assms(2)) show "finite (sumset {a \<oplus> b} (stabilizer C))" using stabilizer_finite assms finite_sumset by (simp add: hCG) next show "?H \<noteq> sumset {a \<oplus> b} (stabilizer C)" using hnotsub sumset_mono by (metis Int_lower1) qed ultimately show "False" using assms(1, 2) stabilizer_subset_group by (simp add: card_sumset_singleton_subset_eq) qed then show ?thesis by auto qed moreover have "finite ?H" using finite_sumset assms(10, 11) finite_Int by simp ultimately show "x \<in> stabilizer ?H" using mem_stabilizer_Un_and_right_imp_left[of "?H" "x" "C"] disjnt_def assms Un_commute by (metis disjoint_iff_not_equal) qed qed lemma sumset_inter_ineq: assumes "B \<inter> sumset {a} (stabilizer C) = {}" and "stabilizer (sumset (A \<inter> sumset {a} (stabilizer C)) (B \<inter> sumset {b} (stabilizer C))) \<subset> stabilizer C" and "a \<in> A" and "a \<in> G" and "finite A" and "finite B" and "A \<noteq> {}" and "B \<noteq> {}" and "finite (stabilizer C)" shows "int (card (sumset (A \<union> B) (stabilizer C))) - card (sumset (A \<union> B) (stabilizer (sumset (A \<inter> sumset {a} (stabilizer C)) (B \<inter> sumset {b} (stabilizer C))))) \<ge> int (card (stabilizer C)) - card (sumset (A \<inter> sumset {a} (stabilizer C)) (stabilizer (sumset (A \<inter> sumset {a} (stabilizer C)) (B \<inter> sumset {b} (stabilizer C)))))" (is "int (card (sumset (A \<union> B) (stabilizer C))) - card (sumset (A \<union> B) ?H1) \<ge> int (card (stabilizer C)) - card (sumset ?A1 ?H1)") proof- have hfinsumH1:"finite (sumset (A \<union> B) ?H1)" using finite_sumset assms by (meson finite_Un psubsetE rev_finite_subset) have hsubsumH1: "sumset (A \<union> B) ?H1 \<subseteq> sumset (A \<union> B) (stabilizer C)" using sumset.cases assms by (meson psubsetE subset_refl sumset_mono) have hsumH1card_le: "card (sumset (A \<union> B) ?H1) \<le> card (sumset (A \<union> B) (stabilizer C))" using card_mono finite_sumset stabilizer_finite assms by (metis equalityE finite_UnI psubset_imp_subset sumset_mono) have hsub: "sumset ?A1 ?H1 \<subseteq> sumset {a} (stabilizer C)" proof fix x assume "x \<in> sumset ?A1 ?H1" then obtain h1 f where "h1 \<in> ?A1" and hf: "f \<in> ?H1" and hx: "x = h1 \<oplus> f" by (meson sumset.cases) then obtain c where hc: "c \<in> stabilizer C" and hac: "h1 = a \<oplus> c" by (metis Int_iff empty_iff insert_iff sumset.cases) then have hcf: "c \<oplus> f \<in> stabilizer C" using hf assms(2) stabilizer_is_subgroup subgroup_def monoid_axioms Group_Theory.group.axioms(1) Group_Theory.monoid_def subset_iff psubset_imp_subset by (smt (verit) stabilizer_subset_group sumset.sumsetI sumset_stabilizer_eq) have hcG: "c \<in> G" using hc stabilizer_subset_group by auto have hfG: "f \<in> G" using hf stabilizer_subset_group by auto show "x \<in> sumset {a} (stabilizer C)" using hx hac assms stabilizer_subset_group hcf using Left_Coset_eq_sumset_stabilizer Left_Coset_memI associative hcG hfG by presburger qed moreover have "finite (sumset ?A1 ?H1)" using finite_sumset assms stabilizer_finite finite_subset by (metis finite.simps hsub) ultimately have "card (sumset {a} (stabilizer C)) - card (sumset ?A1 ?H1) = card (sumset {a} (stabilizer C) - sumset ?A1 ?H1)" using card_Diff_subset by metis moreover have "card (sumset ?A1 ?H1) \<le> card (sumset {a} (stabilizer C))" using card_mono hsub finite_sumset assms by (metis finite.simps) ultimately have "int (card (sumset {a} (stabilizer C))) - card (sumset ?A1 ?H1) = card (sumset {a} (stabilizer C) - sumset ?A1 ?H1)" by linarith also have "... \<le> card ((sumset (A \<union> B) (stabilizer C)) - (sumset (A \<union> B) ?H1))" proof- have "sumset {a} (stabilizer C) - sumset ?A1 ?H1 \<subseteq> sumset (A \<union> B) (stabilizer C) - sumset (A \<union> B) ?H1" proof fix x assume hx: "x \<in> sumset {a} (stabilizer C) - sumset ?A1 ?H1" then obtain c where hxac: "x = a \<oplus> c" and hc: "c \<in> stabilizer C" and hcG: "c \<in> G" using sumset.cases by blast then have "x \<in> sumset (A \<union> B) (stabilizer C)" using assms sumset.cases by blast moreover have "x \<notin> sumset (A \<union> B) ?H1" proof assume "x \<in> sumset (A \<union> B) ?H1" then obtain y h1 where hy: "y \<in> A \<union> B" and hyG: "y \<in> G" and hh1G: "h1 \<in> G" and hh1: "h1 \<in> ?H1" and hxy: "x = y \<oplus> h1" by (meson sumset.cases) then have "y = a \<oplus> (c \<oplus> inverse h1)" using hxac hxy assms associative commutative composition_closed inverse_closed invertible invertible_left_inverse2 by (metis hcG) moreover have "h1 \<in> stabilizer C" using hh1 assms by auto moreover hence "c \<oplus> inverse h1 \<in> stabilizer C" using hc stabilizer_is_subgroup subgroup_def group_axioms invertible subgroup.subgroup_inverse_iff submonoid.sub_composition_closed hh1G by metis ultimately have "y \<in> sumset {a} (stabilizer C)" using assms hcG hh1G by blast moreover hence "y \<in> A" using assms(1) hy by auto ultimately have "x \<in> sumset ?A1 ?H1" using hxy hh1 by (simp add: hyG hh1G sumset.sumsetI) thus "False" using hx by auto qed ultimately show "x \<in> sumset (A \<union> B) (stabilizer C) - sumset (A \<union> B) ?H1" by simp qed thus ?thesis using card_mono finite_Diff finite_sumset assms by (metis finite_UnI nat_int_comparison(3)) qed also have "... = int (card (sumset (A \<union> B) (stabilizer C))) - card (sumset (A \<union> B) ?H1)" using card_Diff_subset[OF hfinsumH1 hsubsumH1] hsumH1card_le by linarith finally show "int (card (sumset (A \<union> B) (stabilizer C))) - card (sumset (A \<union> B) ?H1) \<ge> int (card (stabilizer C)) - card (sumset ?A1 ?H1)" using assms by (metis card_sumset_singleton_subset_eq stabilizer_subset_group) qed lemma exists_convergent_min_stabilizer: assumes hind: "\<forall>m<n. \<forall>C D. C \<subseteq> G \<longrightarrow> D \<subseteq> G \<longrightarrow> finite C \<longrightarrow> finite D \<longrightarrow> C \<noteq> {} \<longrightarrow> D \<noteq> {} \<longrightarrow> card (sumset C D) + card C = m \<longrightarrow> card (sumset C (stabilizer (sumset C D))) + card (sumset D (stabilizer (sumset C D))) - card ((stabilizer (sumset C D))) \<le> card (sumset C D)" and hAG: "A \<subseteq> G" and hBG: "B \<subseteq> G" and hA: "finite A" and hB: "finite B" and hAne: "A \<noteq> {}" and "A \<inter> B \<noteq> {}" and hcardsum: "card (sumset A B) + card A = n" and hintercardA: "card (A \<inter> B) < card A" obtains X where "convergent X A B" and "\<And> Y. Y \<in> convergent_set A B \<Longrightarrow> card (stabilizer Y) \<ge> card (stabilizer X)" proof- let ?C0 = "sumset (A \<inter> B) (A \<union> B)" have hC0ne: "?C0 \<noteq> {}" using assms by fast moreover have "finite ?C0" using sumset_inter_union_subset finite_sumset assms by auto ultimately have "finite (stabilizer ?C0)" using stabilizer_finite using sumset_subset_carrier by presburger then have hcard_sumset_le: "card (A \<inter> B) \<le> card (sumset (A \<inter> B) (stabilizer ?C0))" using card_le_sumset sumset_commute sub_unit_closed assms by (metis Int_Un_eq(3) Un_subset_iff finite_Int unit_closed) have "card ?C0 \<le> card (sumset A B)" using card_mono sumset_inter_union_subset finite_sumset assms by (simp add: card_mono finite_sumset hA hB sumset_inter_union_subset) then have "card ?C0 + card (A \<inter> B) < card (sumset A B) + card A" using hintercardA by auto then obtain m where "m < n" and "card ?C0 + card (A \<inter> B) = m" using hcardsum by auto then have "card (sumset (A \<inter> B) (stabilizer ?C0)) + card (sumset (A \<union> B) (stabilizer ?C0)) - card (stabilizer ?C0) \<le> card ?C0" using assms finite_Un finite_Int by (metis Int_Un_eq(4) Un_empty Un_subset_iff) then have "card ?C0 + card (stabilizer ?C0) \<ge> card (A \<inter> B) + card (sumset (A \<union> B) (stabilizer ?C0))" using hcard_sumset_le by auto then have "?C0 \<in> convergent_set A B" using convergent_set_def convergent_def sumset_inter_union_subset hC0ne by auto then have hconvergent_ne: "convergent_set A B \<noteq> {}" by auto define KS where "KS \<equiv> (\<lambda> X. card (stabilizer X)) ` convergent_set A B" define K where "K \<equiv> Min KS" define C where "C \<equiv> @C. C \<in> convergent_set A B \<and> K = card (stabilizer C)" obtain KS: "finite KS" "KS \<noteq> {}" using hconvergent_ne finite_convergent_set assms KS_def by auto then have "K \<in> KS" using K_def Min_in by blast then have "\<exists> X. X \<in> convergent_set A B \<and> K = card (stabilizer X)" using KS_def by auto then obtain "C \<in> convergent_set A B" and Keq: "K = card (stabilizer C)" by (metis (mono_tags, lifting) C_def someI_ex) then have hC: "C \<subseteq> sumset A B" and hCne: "C \<noteq> {}" and hCcard: "card C + card (stabilizer C) \<ge> card (A \<inter> B) + card (sumset (A \<union> B) (stabilizer C))" using convergent_set_def convergent_def by auto have hCmin: "\<And> Y. Y \<in> convergent_set A B \<Longrightarrow> card (stabilizer Y) \<ge> card (stabilizer C)" using K_def KS_def Keq Min_le KS(1) by auto show ?thesis using hCmin hC hCcard hCne local.convergent_def that by presburger qed end context normal_subgroup begin subsection\<open> A function that picks coset representatives randomly\<close> definition \<phi> :: "'a set \<Rightarrow> 'a" where "\<phi> = (\<lambda> x. if x \<in> G // K then (SOME a. a \<in> G \<and> x = a \<cdot>| K) else undefined)" definition quot_comp_alt :: "'a \<Rightarrow> 'a \<Rightarrow> 'a" where "quot_comp_alt a b = \<phi> ((a \<cdot> b) \<cdot>| K)" lemma phi_eq_coset: assumes "\<phi> x = a" and "a \<in> G" and "x \<in> G // K" shows "x = a \<cdot>| K" proof- have "(SOME a. a \<in> G \<and> x = a \<cdot>| K) = a" using \<phi>_def assms by simp then show ?thesis using some_eq_ex representant_exists Left_Coset_Class_unit assms by (metis (mono_tags, lifting)) qed lemma phi_coset_mem: assumes "a \<in> G" shows "\<phi> (a \<cdot>| K) \<in> a \<cdot>| K" proof- obtain x where hx: "x = \<phi> (a \<cdot>| K)" by auto then have "x = (SOME x. x \<in> G \<and> a \<cdot>| K = x \<cdot>| K)" using \<phi>_def assms Class_in_Partition Left_Coset_Class_unit by presburger then show ?thesis using \<phi>_def Class_self Left_Coset_Class_unit hx assms by (smt (verit, ccfv_SIG) tfl_some) qed lemma phi_coset_eq: assumes "a \<in> G" and "\<phi> x = a" and "x \<in> G // K" shows "\<phi> (a \<cdot>| K) = a" using phi_eq_coset assms by metis lemma phi_inverse_right: assumes "g \<in> G" shows "quot_comp_alt g (\<phi> (inverse g \<cdot>| K)) = \<phi> K" proof- have "g \<cdot> (\<phi> (inverse g \<cdot>| K)) \<in> (g \<cdot> (inverse g) \<cdot>| K)" using phi_coset_mem assms by (smt (z3) Left_Coset_memE factor_unit invertible invertible_right_inverse invertible_inverse_closed invertible_inverse_inverse sub invertible_left_inverse2) then have "g \<cdot> (\<phi> (inverse g \<cdot>| K)) \<cdot>| K = K" using Block_self Left_Coset_Class_unit Normal_def quotient.unit_closed sub by (metis assms composition_closed invertible invertible_inverse_closed invertible_right_inverse) then show ?thesis using quot_comp_alt_def by auto qed lemma phi_inverse_left: assumes "g \<in> G" shows "quot_comp_alt (\<phi> (inverse g \<cdot>| K)) g = \<phi> K" proof- have "(\<phi> (inverse g \<cdot>| K)) \<cdot> g \<in> ((inverse g) \<cdot> g) \<cdot>| K" using phi_coset_mem assms by (metis Left_Coset_memE factor_unit invertible invertible_inverse_closed invertible_left_inverse normal) then have "(\<phi> (inverse g \<cdot>| K)) \<cdot> g \<cdot>| K = K" using Block_self Left_Coset_Class_unit Normal_def quotient.unit_closed sub by (smt (verit, best) assms composition_closed invertible invertible_inverse_closed invertible_left_inverse) then show ?thesis using quot_comp_alt_def by auto qed lemma phi_mem_coset_eq: assumes "a \<in> G // K" and "b \<in> G" shows "\<phi> a \<in> b \<cdot>| K \<Longrightarrow> a = (b \<cdot>| K)" proof- assume "\<phi> a \<in> b \<cdot>| K" then have "a \<inter> (b \<cdot>| K) \<noteq> {}" by (metis Class_closed Class_is_Left_Coset Int_iff assms empty_iff phi_coset_mem phi_eq_coset) then show "a = b \<cdot>| K" by (metis Class_in_Partition Class_is_Left_Coset assms disjoint) qed lemma forall_unique_repr: "\<forall> x \<in> G // K. \<exists>! k \<in> \<phi> ` (G // K). x = k \<cdot>| K" proof fix x assume hx: "x \<in> G // K" then have "\<phi> x \<cdot>| K = x" by (metis Class_is_Left_Coset block_closed phi_coset_mem phi_eq_coset representant_exists) then have hex: "\<exists> k \<in> \<phi> ` (G // K). x = k \<cdot>| K" using hx by blast moreover have "\<And> a b. a \<in> \<phi> ` (G // K) \<Longrightarrow> x = a \<cdot>| K \<Longrightarrow> b \<in> \<phi> ` (G // K) \<Longrightarrow> x = b \<cdot>| K \<Longrightarrow> a = b" proof- fix a b assume "a \<in> \<phi> ` (G // K)" and hxa: "x = a \<cdot>| K" and "b \<in> \<phi> ` (G // K)" and hxb: "x = b \<cdot>| K" then obtain z w where "a = \<phi> (z \<cdot>| K)" and "b = \<phi> (w \<cdot>| K)" and "z \<in> G" and "w \<in> G" using representant_exists Left_Coset_Class_unit by force then show "a = b" using hxa hxb by (metis Class_in_Partition Class_is_Left_Coset block_closed phi_coset_mem phi_eq_coset) qed ultimately show "\<exists>! k \<in> \<phi> ` (G // K). x = k \<cdot>| K" by blast qed lemma phi_inj_on: shows "inj_on \<phi> (G // K)" proof(intro inj_onI) fix x y assume "x \<in> G // K" and hy: "y \<in> G // K" and hxy: "\<phi> x = \<phi> y" then obtain a b where "x = a \<cdot>| K" and "y = b \<cdot>| K" and "a \<in> G" and "b \<in> G" using representant_exists Left_Coset_Class_unit by metis then show "x = y" using hxy hy by (metis phi_coset_mem phi_mem_coset_eq) qed lemma phi_coset_eq_self: assumes "a \<in> G // K" shows "\<phi> a \<cdot>| K = a" by (metis Class_closed Class_is_Left_Coset assms phi_coset_mem phi_eq_coset representant_exists) lemma phi_coset_comp_eq: assumes "a \<in> G // K" and "b \<in> G // K" shows "\<phi> a \<cdot> \<phi> b \<cdot>| K = a [\<cdot>] b" using assms phi_coset_eq_self by (metis Class_is_Left_Coset block_closed factor_composition phi_coset_mem representant_exists) lemma phi_comp_eq: assumes "a \<in> G // K" and "b \<in> G // K" shows "\<phi> (a [\<cdot>] b) = quot_comp_alt (\<phi> a) (\<phi> b)" using phi_coset_comp_eq quot_comp_alt_def assms by auto lemma phi_image_subset: "\<phi> ` (G // K) \<subseteq> G" proof(intro image_subsetI, simp add: \<phi>_def) fix x assume "x \<in> G // K" then show "(SOME a. a \<in> G \<and> x = a \<cdot>| K) \<in> G" using Left_Coset_Class_unit representant_exists someI_ex by (metis (mono_tags, lifting)) qed lemma phi_image_group: "Group_Theory.group (\<phi> ` (G // K)) quot_comp_alt (\<phi> K)" proof- have hmonoid: "Group_Theory.monoid (\<phi> ` (G // K)) quot_comp_alt (\<phi> K)" proof show "\<And>a b. a \<in> \<phi> ` (G // K) \<Longrightarrow> b \<in> \<phi> ` (G // K) \<Longrightarrow> quot_comp_alt a b \<in> \<phi> ` (G // K)" using quot_comp_alt_def imageI phi_image_subset by (metis Class_in_Partition Left_Coset_Class_unit composition_closed subset_iff) next show "(\<phi> K) \<in> \<phi> ` (G // K)" using \<phi>_def Left_Coset_Class_unit imageI Normal_def by blast next show "\<And>a b c. a \<in> \<phi> ` Partition \<Longrightarrow> b \<in> \<phi> ` Partition \<Longrightarrow> c \<in> \<phi> ` Partition \<Longrightarrow> quot_comp_alt (quot_comp_alt a b) c = quot_comp_alt a (quot_comp_alt b c)" proof- fix a b c assume ha: "a \<in> \<phi> ` (G // K)" and hb: "b \<in> \<phi> ` (G // K)" and hc: "c \<in> \<phi> ` (G // K)" have habc: "a \<cdot> b \<cdot> c \<in> G" using ha hb hc composition_closed phi_image_subset by (meson subsetD) have hab: "quot_comp_alt a b \<in> (a \<cdot> b) \<cdot>| K" using phi_image_subset quot_comp_alt_def ha hb by (metis composition_closed phi_coset_mem subsetD) then have "quot_comp_alt (quot_comp_alt a b) c \<in> (a \<cdot> b \<cdot> c) \<cdot>| K" using quot_comp_alt_def phi_image_subset ha hb hc by (smt (z3) Block_self Class_closed Class_in_Partition Left_Coset_Class_unit composition_closed natural.commutes_with_composition phi_coset_mem subset_iff) moreover have hbc: "quot_comp_alt b c \<in> (b \<cdot> c) \<cdot>| K" using hb hc phi_image_subset quot_comp_alt_def by (metis composition_closed phi_coset_mem subset_iff) moreover hence "quot_comp_alt a (quot_comp_alt b c) \<in> (a \<cdot> b \<cdot> c) \<cdot>| K" using quot_comp_alt_def phi_image_subset ha hb hc by (smt (verit, del_insts) Block_self Class_closed Class_in_Partition Left_Coset_Class_unit associative composition_closed natural.commutes_with_composition phi_coset_mem subset_iff) moreover have "a \<cdot> (quot_comp_alt b c) \<cdot>| K \<in> G // K" using ha hb hc phi_image_subset by (metis Class_closed Class_in_Partition Class_is_Left_Coset hbc composition_closed in_mono subset_eq) moreover have "(quot_comp_alt a b) \<cdot> c \<cdot>| K \<in> G // K" using ha hb hc phi_image_subset by (metis Class_closed Class_in_Partition Left_Coset_Class_unit hab composition_closed in_mono) ultimately show "quot_comp_alt (quot_comp_alt a b) c = quot_comp_alt a (quot_comp_alt b c)" using phi_mem_coset_eq[OF _ habc] quot_comp_alt_def by metis qed next show "\<And>a. a \<in> \<phi> ` Partition \<Longrightarrow> quot_comp_alt (\<phi> K) a = a" using quot_comp_alt_def \<phi>_def phi_image_subset image_iff phi_coset_eq subsetD by (smt (z3) Normal_def Partition_def natural.image.sub_unit_closed phi_comp_eq quotient.left_unit) next show "\<And>a. a \<in> \<phi> ` Partition \<Longrightarrow> quot_comp_alt a (\<phi> K) = a" using quot_comp_alt_def \<phi>_def phi_image_subset image_iff phi_coset_eq subsetD by (smt (verit) Normal_def factor_composition factor_unit normal_subgroup.phi_coset_eq_self normal_subgroup_axioms quotient.unit_closed right_unit unit_closed) qed moreover show "Group_Theory.group (\<phi> ` (G // K)) quot_comp_alt (\<phi> K)" proof(simp add: group_def group_axioms_def hmonoid) show "\<forall>u. u \<in> \<phi> ` Partition \<longrightarrow> monoid.invertible (\<phi> ` Partition) quot_comp_alt (\<phi> K) u" proof(intro allI impI) fix g assume hg: "g \<in> \<phi> ` (G // K)" then have "quot_comp_alt g (\<phi> ((inverse g) \<cdot>| K)) = (\<phi> K)" and "quot_comp_alt (\<phi> ((inverse g) \<cdot>| K)) g = (\<phi> K)" using phi_image_subset phi_inverse_right phi_inverse_left by auto moreover have "\<phi> ((inverse g) \<cdot>| K) \<in> \<phi> ` (G // K)" using imageI hg phi_image_subset by (metis (no_types, opaque_lifting) Class_in_Partition Left_Coset_Class_unit in_mono invertible invertible_inverse_closed) ultimately show "monoid.invertible (\<phi> ` Partition) quot_comp_alt (\<phi> K) g" using monoid.invertibleI[OF hmonoid] hg by presburger qed qed qed lemma phi_map: "Set_Theory.map \<phi> Partition (\<phi> ` Partition)" by (auto simp add: Set_Theory.map_def \<phi>_def) lemma phi_image_isomorphic: "group_isomorphism \<phi> (G // K) ([\<cdot>]) (Class \<one>) (\<phi> ` (G // K)) quot_comp_alt (\<phi> K)" proof - have "bijective_map \<phi> Partition (\<phi> ` Partition)" using bijective_map_def bijective_def bij_betw_def phi_inj_on phi_map by blast moreover have "Group_Theory.monoid (\<phi> ` Partition) quot_comp_alt (\<phi> K)" using phi_image_group group_def by metis moreover have "\<phi> (Class \<one>) = \<phi> K" using Left_Coset_Class_unit Normal_def by auto ultimately show ?thesis by (auto simp add: group_isomorphism_def group_homomorphism_def monoid_homomorphism_def phi_image_group quotient.monoid_axioms quotient.group_axioms monoid_homomorphism_axioms_def phi_comp_eq phi_map) qed end context subgroup_of_additive_abelian_group begin lemma Union_Coset_card_eq: assumes hSG: "S \<subseteq> G" and hSU: "(\<Union> (Class ` S)) = S" shows "card S = card H * card (Class ` S)" proof(cases "finite H") case hH: True have hfin: "\<And>A. A \<in> Class ` S \<Longrightarrow> finite A" using hSG Right_Coset_Class_unit Right_Coset_cardinality hH card_eq_0_iff empty_iff sub_unit_closed subsetD by (smt (verit, del_insts) imageE) have "card S = card H * card (Class ` S)" when hS: "finite S" proof- have hdisj: "pairwise (\<lambda>s t. disjnt s t) (Class ` S)" proof (intro pairwiseI) fix x y assume "x \<in> Class ` S" and "y \<in> Class ` S" and hxy: "x \<noteq> y" then obtain a b where "x = Class a" and "y = Class b" and "a \<in> S" and "b \<in> S" by blast then show "disjnt x y" using disjnt_def hxy by (smt (verit, ccfv_threshold) not_disjoint_implies_equal hSG subsetD) qed then have "card (\<Union> (Class ` S)) = sum card (Class ` S)" using card_Union_disjoint hfin by blast moreover have "finite (Class ` S)" using hS by blast ultimately have "card (\<Union> (Class ` S)) = (\<Sum> a \<in> Class ` S. card a)" using sum_card_image hdisj by blast moreover have "\<And> a. a \<in> Class ` S \<Longrightarrow> card a = card H" using hSG Right_Coset_Class_unit Right_Coset_cardinality by auto ultimately show "card S = card H * card (Class ` S)" using hSU by simp qed moreover have "card S = card H * card (Class ` S)" when hS: "\<not> finite S" using finite_Union hfin hS hSU by (metis card_eq_0_iff mult_0_right) ultimately show ?thesis by blast next case hH: False have "card S = card H * card (Class ` S)" when "S = {}" by (simp add: that) then have hinf: "\<And> A. A \<in> Class ` S \<Longrightarrow> infinite A" using hSG Right_Coset_Class_unit Right_Coset_cardinality hH card_eq_0_iff empty_iff sub_unit_closed subsetD by (smt (verit) Class_self imageE) moreover have "card S = card H * card (Class ` S)" when "S \<noteq> {}" using hSU by (metis Class_closed2 Normal_def card.infinite card_sumset_0_iff hH hSG mult_is_0 sumset_subgroup_eq_Class_Union unit_closed) ultimately show ?thesis by fastforce qed end context subgroup_of_abelian_group begin interpretation GH: additive_abelian_group "G // H" "([\<cdot>])" "Class \<one>" proof fix x y assume "x \<in> G // H" and "y \<in> G // H" then show "x [\<cdot>] y = y [\<cdot>] x" using Class_commutes_with_composition commutative representant_exists by metis qed interpretation GH_repr: additive_abelian_group "\<phi> ` (G // H)" "quot_comp_alt" "\<phi> H" proof(simp add: additive_abelian_group_def abelian_group_def phi_image_group commutative_monoid_def commutative_monoid_axioms_def, intro conjI allI impI) show "Group_Theory.monoid (\<phi> ` Partition) quot_comp_alt (\<phi> H)" using phi_image_group group_def by metis next show "\<And> x y. x \<in> \<phi> ` Partition \<Longrightarrow> y \<in> \<phi> ` Partition \<Longrightarrow> quot_comp_alt x y = quot_comp_alt y x" by (auto) (metis GH.commutative phi_comp_eq) qed lemma phi_image_sumset_eq: assumes "A \<subseteq> G // H" and "B \<subseteq> G // H" shows "\<phi> ` (GH.sumset A B) = GH_repr.sumset (\<phi> ` A) (\<phi> ` B)" proof(intro subset_antisym image_subsetI subsetI) fix x assume "x \<in> GH.sumset A B" then obtain c d where "x = quotient_composition c d" and hc: "c \<in> A" and hd: "d \<in> B" using GH.sumset.cases by blast then have "\<phi> x = quot_comp_alt (\<phi> c) (\<phi> d)" using phi_comp_eq assms subsetD by blast then show "\<phi> x \<in> GH_repr.sumset (\<phi> ` A) (\<phi> ` B)" using hc hd assms subsetD GH_repr.sumsetI imageI by auto next fix x assume "x \<in> GH_repr.sumset (\<phi> ` A) (\<phi> ` B)" then obtain a b where "x = quot_comp_alt a b" and ha: "a \<in> \<phi> ` A" and hb: "b \<in> \<phi> ` B" using GH_repr.sumset.cases by metis moreover obtain c d where "a = \<phi> c" and "b = \<phi> d" and "c \<in> A" and "d \<in> B" using ha hb by blast ultimately show "x \<in> \<phi> ` GH.sumset A B" using phi_comp_eq assms imageI GH.sumsetI by (smt (verit, del_insts) subsetD) qed lemma phi_image_stabilizer_eq: assumes "A \<subseteq> G // H" shows "\<phi> ` (GH.stabilizer A) = GH_repr.stabilizer (\<phi> ` A)" proof(intro subset_antisym image_subsetI subsetI) fix x assume "x \<in> GH.stabilizer A" then have "GH.sumset {x} A = A" and hx: "x \<in> G // H" using GH.stabilizer_def assms by auto then have "GH_repr.sumset (\<phi> ` {x}) (\<phi> ` A) = \<phi> ` A" using assms phi_image_sumset_eq by (metis empty_subsetI insert_subset) then show "\<phi> x \<in> GH_repr.stabilizer (\<phi> ` A)" using GH_repr.stabilizer_def assms by (smt (z3) GH_repr.sumset_Int_carrier hx image_empty image_eqI image_insert mem_Collect_eq) next fix x assume "x \<in> GH_repr.stabilizer (\<phi> ` A)" then have hstab: "GH_repr.sumset {x} (\<phi> ` A) = (\<phi> ` A)" and hx: "x \<in> \<phi> ` (G // H)" using GH_repr.stabilizer_def assms phi_image_subset by auto then obtain B where hB: "B \<in> G // H" and hBx: "\<phi> B = x" by blast then have "GH_repr.sumset (\<phi> ` {B}) (\<phi> ` A) = \<phi> ` A" using hstab by auto then have "GH.sumset {B} A = A" using phi_image_sumset_eq phi_inj_on assms hB GH.sumset_subset_carrier by (smt (z3) GH.sumset_singletons_eq inj_on_image_eq_iff quotient.right_unit quotient.unit_closed) then show "x \<in> \<phi> ` (GH.stabilizer A)" using assms hBx GH.stabilizer_def by (smt (z3) GH.sumset_Int_carrier hB image_iff mem_Collect_eq) qed end subsection\<open>Useful group-theoretic results\<close> lemma residue_group: "abelian_group {0..(m :: nat)-1} (\<lambda> x y. ((x + y) mod m)) (0 :: int)" proof(cases "m > 1") case hm: True then have hmonoid: "Group_Theory.monoid {0..m-1} (\<lambda> x y. ((x + y) mod m)) (0 :: int)" by (unfold_locales, auto simp add: of_nat_diff, presburger) moreover have "monoid.invertible {0..int (m - 1)} (\<lambda>x y. (x + y) mod int m) 0 u" if "u \<in> {0..int (m - 1)}" for u proof(cases "u = 0") case True then show ?thesis using monoid.invertible_def[OF hmonoid that] monoid.unit_invertible[OF hmonoid] by simp next case hx: False then have "((m - u) + u) mod m = 0" and "(u + (m - u)) mod m = 0" and "m - u \<in> {0..int(m-1)}" using atLeastAtMost_iff hx that by auto then show ?thesis using monoid.invertible_def[OF hmonoid that] by metis qed moreover have "commutative_monoid {0..m-1} (\<lambda> x y. ((x + y) mod m)) (0 :: int)" using hmonoid commutative_monoid_def commutative_monoid_axioms_def by (smt (verit)) ultimately show ?thesis by (simp add: abelian_group_def group_def group_axioms_def hmonoid) next case hm: False moreover have hmonoid: "Group_Theory.monoid {0} (\<lambda> x y. ((x + y) mod m)) (0 :: int)" by (unfold_locales, auto) moreover have "monoid.invertible {0} (\<lambda>x y. (x + y) mod int m) 0 0" using monoid.invertible_def[OF hmonoid] monoid.unit_invertible[OF hmonoid] hm by simp ultimately show ?thesis by (unfold_locales, auto) qed lemma (in subgroup_of_group) prime_order_simple: assumes "prime (card G)" shows "H = {\<one>} \<or> H = G" proof- have "card H dvd card G" using lagrange assms card.infinite dvdI not_prime_0 by fastforce then have "card H = 1 \<or> card H = card G" using assms prime_nat_iff by blast then show ?thesis using card_1_singletonE sub_unit_closed card.infinite card_subset_eq sub assms not_prime_0 subsetI insertE empty_iff by metis qed lemma residue_group_simple: assumes "prime p" and "subgroup H {0..(p :: nat)-1} (\<lambda> x y. ((x + y) mod p)) (0 :: int)" shows "H = {0} \<or> H = {0..int(p-1)}" proof- have hprime: "prime (card {0..int(p-1)})" using card_atLeastAtMost_int assms int_ops by auto moreover have hsub:"subgroup_of_group H {0..(p :: nat)-1} (\<lambda> x y. ((x + y) mod p)) (0 :: int)" using subgroup_of_group_def assms abelian_group_def residue_group by fast ultimately show ?thesis using assms subgroup_of_group.prime_order_simple[OF hsub hprime] by blast qed end
section \<open>Termination heuristics\<close> text_raw \<open>\label{sec:termination}\<close> theory Termination imports "../Dict_Construction" begin text \<open> As indicated in the introduction, the newly-defined functions must be proven terminating. In general, we cannot reuse the original termination proof, as the following example illustrates: \<close> fun f :: "nat \<Rightarrow> nat" where "f 0 = 0" | "f (Suc n) = f n" text \<open> The invocation of @{theory_text \<open>declassify f\<close>} would fail, because @{const f}'s code equations are not terminating. Hence, in the general case where users have modified the code equations, we need to fall back to an (automated) attempt to prove termination. In the remainder of this section, we will illustrate the special case where the user has not modified the code equations, i.e., the original termination proof should ``morally'' be still applicable. For this, we will perform the dictionary construction manually. \<close> \<comment> \<open>Some ML incantations to ensure that the dictionary types are present\<close> local_setup \<open>Class_Graph.ensure_class @{class plus} #> snd\<close> local_setup \<open>Class_Graph.ensure_class @{class zero} #> snd\<close> fun sum_list :: "'a::{plus,zero} list \<Rightarrow> 'a" where "sum_list [] = 0" | "sum_list (x # xs) = x + sum_list xs" text \<open> The above function carries two distinct class constraints, which are translated into two dictionary parameters: \<close> function sum_list' where "sum_list' d_plus d_zero [] = Groups_zero__class_zero__field d_zero" | "sum_list' d_plus d_zero (x # xs) = Groups_plus__class_plus__field d_plus x (sum_list' d_plus d_zero xs)" by pat_completeness auto text \<open> Now, we need to carry out the termination proof of @{const sum_list'}. The @{theory_text function} package analyzes the function definition and discovers one recursive call. In pseudo-notation: @{text [display] \<open>(d_plus, d_zero, x # xs) \<leadsto> (d_plus, d_zero, xs)\<close>} The result of this analysis is captured in the inductive predicate @{const sum_list'_rel}. Its introduction rules look as follows: \<close> thm sum_list'_rel.intros \<comment> \<open>@{thm sum_list'_rel.intros}\<close> text \<open>Compare this to the relation for @{const sum_list}:\<close> thm sum_list_rel.intros \<comment> \<open>@{thm sum_list_rel.intros}\<close> text \<open> Except for the additional (unchanging) dictionary arguments, these relations are more or less equivalent to each other. There is an important difference, though: @{const sum_list_rel} has sort constraints, @{const sum_list'_rel} does not. (This will become important later on.) \<close> context notes [[show_sorts]] begin term sum_list_rel \<comment> \<open>@{typ \<open>'a::{plus,zero} list \<Rightarrow> 'a::{plus,zero} list \<Rightarrow> bool\<close>}\<close> term sum_list'_rel \<comment> \<open>@{typ \<open>'a::type Groups_plus__dict \<times> 'a::type Groups_zero__dict \<times> 'a::type list \<Rightarrow> 'a::type Groups_plus__dict \<times> 'a::type Groups_zero__dict \<times> 'a::type list \<Rightarrow> bool\<close>}\<close> end text \<open> Let us know discuss the rough concept of the termination proof for @{const sum_list'}. The goal is to show that @{const sum_list'_rel} is well-founded. Usually, this is proved by specifying a \<^emph>\<open>measure function\<close> that \<^enum> maps the arguments to natural numbers \<^enum> decreases for each recursive call. \<close> text \<open> Here, however, we want to instead show that each recursive call in @{const sum_list'} has a corresponding recursive call in @{const sum_list}. In other words, we want to show that the existing proof of well-foundedness of @{const sum_list_rel} can be lifted to a proof of well-foundedness of @{const sum_list'_rel}. This is what the theorem @{thm [source=true] wfP_simulate_simple} states: @{thm [display=true] wfP_simulate_simple} Given any well-founded relation \<open>r\<close> and a function \<open>g\<close> that maps function arguments from \<open>r'\<close> to \<open>r\<close>, we can deduce that \<open>r'\<close> is also well-founded. For our example, we need to provide a function \<open>g\<close> of type @{typ \<open>'b Groups_plus__dict \<times> 'b Groups_zero__dict \<times> 'b list \<Rightarrow> 'a list\<close>}. Because the dictionary parameters are not changing, they can safely be dropped by \<open>g\<close>. However, because of the sort constraint in @{const sum_list_rel}, the term @{term "snd \<circ> snd"} is not a well-typed instantiation for \<open>g\<close>. Instead (this is where the heuristic comes in), we assume that the original function @{const sum_list} is parametric, i.e., termination does not depend on the elements of the list passed to it, but only on the structure of the list. Additionally, we assume that all involved type classes have at least one instantiation. With this in mind, we can use @{term "map (\<lambda>_. undefined) \<circ> snd \<circ> snd"} as \<open>g\<close>: \<close> thm wfP_simulate_simple[where r = sum_list_rel and r' = sum_list'_rel and g = "map (\<lambda>_. undefined) \<circ> snd \<circ> snd"] text \<open> Finally, we can prove the termination of @{const sum_list'}. \<close> termination sum_list' proof - have "wfP sum_list'_rel" proof (rule wfP_simulate_simple) \<comment> \<open>We first need to obtain the well-foundedness theorem for @{const sum_list_rel} from the ML guts of the @{theory_text function} package.\<close> show "wfP sum_list_rel" apply (rule accp_wfPI) apply (tactic \<open>resolve_tac @{context} [Function.get_info @{context} @{term sum_list} |> #totality |> the] 1\<close>) done define g :: "'b Groups_plus__dict \<times> 'b Groups_zero__dict \<times> 'b list \<Rightarrow> 'c::{plus,zero} list" where "g = map (\<lambda>_. undefined) \<circ> snd \<circ> snd" \<comment> \<open>Prove the simulation of @{const sum_list'_rel} by @{const sum_list_rel} by rule induction.\<close> show "sum_list_rel (g x) (g y)" if "sum_list'_rel x y" for x y using that proof (induction x y rule: sum_list'_rel.induct) case (1 d_plus d_zero x xs) show ?case \<comment> \<open>Unfold the constituent parts of @{term g}:\<close> apply (simp only: g_def comp_apply snd_conv list.map) \<comment> \<open>Use the corresponding introduction rule of @{const sum_list_rel} and hope for the best:\<close> apply (rule sum_list_rel.intros(1)) done qed qed \<comment> \<open>This is the goal that the @{theory_text function} package expects.\<close> then show "\<forall>x. sum_list'_dom x" by (rule wfP_implies_dom) qed text \<open>This can be automated with a special tactic:\<close> experiment begin termination sum_list' apply (tactic \<open> Transfer_Termination.termination_tac (Function.get_info @{context} @{term sum_list'}) (Function.get_info @{context} @{term sum_list}) @{context} 1\<close>; fail) done end text \<open> A similar technique can be used for making functions defined in locales executable when, for some reason, the definition of a ``defs'' locale is not feasible. \<close> locale foo = fixes A :: "nat" assumes "A > 0" begin fun f where "f 0 = A" | "f (Suc n) = Suc (f n)" \<comment> \<open>We carry out this proof in the locale for simplicity; a real implementation would probably have to set up a local theory properly.\<close> lemma f_total: "wfP f_rel" apply (rule accp_wfPI) apply (tactic \<open>resolve_tac @{context} [Function.get_info @{context} @{term f} |> #totality |> the] 1\<close>) done end \<comment> \<open>The dummy interpretation serves the same purpose as the assumption that class constraints have at least one instantiation.\<close> interpretation dummy: foo 1 by standard simp function f' where "f' A 0 = A" | "f' A (Suc n) = Suc (f' A n)" by pat_completeness auto termination f' apply (rule wfP_implies_dom) apply (rule wfP_simulate_simple[where g = "snd"]) apply (rule dummy.f_total) subgoal for x y apply (induction x y rule: f'_rel.induct) subgoal apply (simp only: snd_conv) apply (rule dummy.f_rel.intros) done done done text \<open>Automatic:\<close> experiment begin termination f' apply (tactic \<open> Transfer_Termination.termination_tac (Function.get_info @{context} @{term f'}) (Function.get_info @{context} @{term dummy.f}) @{context} 1\<close>; fail) done end end
To see Jack 's paper plaster ;
To see Jack 's paper plaster ;
% % % Copyright (c) 2012 University of Crete - Computer Science Department (UOC-CSD) % % License % This file is under the LGPL license, 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. This file 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. % % This function is part of the Covarep project: http://covarep.github.io/covarep % % Author % Gilles Degottex <[email protected]> % function p = wrappednormpdf(x, m, s, N) % N=10 gives a log error smaller than 1e-12 for s=8 % with s=8 distribution is "almost" uniform (std < 1e-12) if nargin<4; N=10; end p = 0; for k=-N:N p = p + normpdf(x+2.*pi.*k, m, s); end return
import .love09_hoare_logic_demo /-! # LoVe Exercise 9: Hoare Logic -/ set_option pp.beta true namespace LoVe /-! ## Question 1: Program Verification The following WHILE program is intended to compute the Gaussian sum up to `n`, leaving the result in `r`. -/ def GAUSS : stmt := stmt.assign "r" (λs, 0) ;; stmt.while (λs, s "n" ≠ 0) (stmt.assign "r" (λs, s "r" + s "n") ;; stmt.assign "n" (λs, s "n" - 1)) /-! The summation function: -/ def sum_upto : ℕ → ℕ | 0 := 0 | (n + 1) := n + 1 + sum_upto n /-! 1.1. Prove the correctness of `GAUSS` using `vcg`. The main challenge is to figure out which invariant to use for the while loop. The invariant should capture both the work that has been done already (the intermediate result) and the work that remains to be done. -/ lemma GAUSS_correct (n₀ : ℕ) : {* λs, s "n" = n₀ *} GAUSS {* λs, s "r" = sum_upto n₀ *} := show {* λs, s "n" = n₀ *} stmt.assign "r" (λs, 0) ;; stmt.while_inv (λ s, (sum_upto (s "n")) + s "r" == sum_upto n₀ ) (λs, s "n" ≠ 0) (stmt.assign "r" (λs, s "r" + s "n") ;; stmt.assign "n" (λs, s "n" - 1)) {* λs, s "r" = sum_upto n₀ *}, from begin vcg; simp {contextual := tt}, { intros s hinv hloop, rw <- hinv, have h: (sum_upto (s "n" - 1)) + s "n" = sum_upto (s "n"), by { cases (s "n"), { triv,}, { have h2: sum_upto(n.succ - 1) == sum_upto n, by { simp, }, simp [h2, sum_upto], have h3: (sum_upto n) + n.succ = (sum_upto n) + (n + 1), by { have h4: n.succ = n + 1, by { simp }, simp [h4], }, simp [h3], cc, } }, rw <- h, cc, }, { intros s hinv hloop, rw <- hloop, unfold sum_upto, finish, } end /-! 1.2. The following WHILE program is intended to compute the product of `n` and `m`, leaving the result in `r`. Prove its correctness using `vcg`. Hint: If a variable `x` does not change in a program, it might be useful to record this in the invariant, by adding a conjunct `s "x" = x₀`. -/ def MUL : stmt := stmt.assign "r" (λs, 0) ;; stmt.while (λs, s "n" ≠ 0) (stmt.assign "r" (λs, s "r" + s "m") ;; stmt.assign "n" (λs, s "n" - 1)) lemma MUL_correct (n₀ m₀ : ℕ) : {* λs, s "n" = n₀ ∧ s "m" = m₀ *} MUL {* λs, s "r" = n₀ * m₀ *} := sorry /-! ## Question 2: Hoare Triples for Total Correctness -/ def total_hoare (P : state → Prop) (S : stmt) (Q : state → Prop) : Prop := ∀s, P s → ∃t, (S, s) ⟹ t ∧ Q t #print total_hoare notation `[* ` P : 1 ` *] ` S : 1 ` [* ` Q : 1 ` *]` := total_hoare P S Q namespace total_hoare /-! 2.1. Prove the consequence rule. -/ lemma consequence {P P' Q Q' : state → Prop} {S} (hS : [* P *] S [* Q *]) (hP : ∀s, P' s → P s) (hQ : ∀s, Q s → Q' s) : [* P' *] S [* Q' *] := begin intro s, intro hps, cases hS s (hP s hps), use w, cases h, tautology, end /-! 2.2. Prove the rule for `skip`. -/ lemma skip_intro {P} : [* P *] stmt.skip [* P *] := sorry /-! 2.3. Prove the rule for `assign`. -/ lemma assign_intro {P : state → Prop} {x} {a : state → ℕ} : [* λs, P (s{x ↦ a s}) *] stmt.assign x a [* P *] := sorry /-! 2.4. Prove the rule for `seq`. -/ lemma seq_intro {P Q R S T} (hS : [* P *] S [* Q *]) (hT : [* Q *] T [* R *]) : [* P *] S ;; T [* R *] := sorry /-! 2.5. Complete the proof of the rule for `ite`. Hint: This requires a case distinction on the truth value of `b s`. -/ lemma ite_intro {b P Q : state → Prop} {S T} (hS : [* λs, P s ∧ b s *] S [* Q *]) (hT : [* λs, P s ∧ ¬ b s *] T [* Q *]) : [* P *] stmt.ite b S T [* Q *] := sorry /-! 2.6 (**optional**). Try to prove the rule for `while`. The rule is parameterized by a loop invariant `I` and by a variant `V` that decreases with each iteration of the loop body. Before we prove the desired lemma, we introduce an auxiliary lemma. Its proof requires well-founded induction. When using `while_intro.aux` as induction hypothesis we recommend to do it directly after proving that the argument is less than `v₀`: have ih : ∃u, (stmt.while b S, t) ⟹ u ∧ I u ∧ ¬ b u := have V t < v₀ := …, while_intro.aux (V t) …, Similarly to `ite`, the proof requires a case distinction on `b s ∨ ¬ b s`. -/ lemma while_intro.aux {b : state → Prop} (I : state → Prop) (V : state → ℕ) {S} (h_inv : ∀v₀, [* λs, I s ∧ b s ∧ V s = v₀ *] S [* λs, I s ∧ V s < v₀ *]) : ∀v₀ s, V s = v₀ → I s → ∃t, (stmt.while b S, s) ⟹ t ∧ I t ∧ ¬ b t | v₀ s V_eq hs := sorry lemma while_intro {b : state → Prop} (I : state → Prop) (V : state → ℕ) {S} (hinv : ∀v₀, [* λs, I s ∧ b s ∧ V s = v₀ *] S [* λs, I s ∧ V s < v₀ *]) : [* I *] stmt.while b S [* λs, I s ∧ ¬ b s *] := sorry end total_hoare end LoVe
As a young surgeon , C. Everett Koop was part of the research team at the University of Pennsylvania School of Medicine . He related his experience with CPS test subjects :
Looking for a special holiday treat for your pup? This “nice cream” recipe is the perfect Thanksgiving dinner for the four-legged family members. It won food blogger and recipe developer Wendy Perry a ribbon at the Sweet Potato Festival a few years back. She says it’s “people edible, too” and with peanut butter and sweet potatoes it’s a healthy and nutritious treat for your pets. North Carolina is ranked no. 1 in sweet potato production in the United States. With nearly 60% of the nation’s supply, North Carolina harvested almost 95,000 acres of sweet potatoes in 2016. Remember, it’s always best to grab these sweet vegetables locally to support our N.C. farmers and agribusiness!
Formal statement is: lemma (in sigma_algebra) restriction_in_sets: fixes A :: "nat \<Rightarrow> 'a set" assumes "S \<in> M" and *: "range A \<subseteq> (\<lambda>A. S \<inter> A) ` M" (is "_ \<subseteq> ?r") shows "range A \<subseteq> M" "(\<Union>i. A i) \<in> (\<lambda>A. S \<inter> A) ` M" Informal statement is: If $S$ is a measurable set and $A_i$ is a sequence of measurable sets such that $A_i \cap S$ is measurable for all $i$, then $A_i$ is measurable for all $i$ and $\bigcup_i A_i$ is measurable.
import UncertainData: AbstractUncertainValue, AbstractUncertainValueDataset, AbstractUncertainIndexValueDataset, resample function get_random_segment(source, target, seq::RandomSequences) seq_length = seq.sequence_length N = length(source) if seq_length isa Int idx_start = rand(1:(length(source) - seq_length)) r = idx_start:(idx_start + seq_length) elseif seq_length isa AbstractVector{Int} # seq_length is now something we can sample directly from seqlen = rand(seq_length) idx_start = rand(1:(N + 1 - seqlen)) r = idx_start:(idx_start + seqlen - 1) else throw(ArgumentError("`resampling.sequence_length`must be an integer or a collection of integers")) end return r end """ resample_and_subset(x, r::AbstractVector{Int}) Resample `x` assuming the points in `x` are independent, then return the points with indices `r`. """ function resample_and_subset(x, r::AbstractVector{Int}) v = zeros(Float64, length(r)) if x isa AbstractVector v[:] = x[r] elseif typeof(x) <: Union{Vector{<:AbstractUncertainValue}, AbstractUncertainValueDataset} v[:] = resample(x)[r] elseif typeof(x) <: AbstractUncertainIndexValueDataset v[:] = resample(x)[2][r] end return v end """ causality(source, target, test::RandomSequencesTest) Apply a causality test on random, consecutive chunks of `x` and `y`. The chunk length can be fixed (an integer) or a collection of chunk lengths. Works on any inputs `x` and `y`, both scalar vectors and uncertain datasets. ## Example For scalar valued vectors: ```julia x, y = rand(100), rand(100) # Use a cross-mapping test with default parameters (not recommended, # make sure you understand the parameters!) cm_test = CrossMappingTest() # A random sequences test that applies the cross mapping test # to 150 different random chunks of the data of lengths 80 to 90 n_realisations, chunk_lengths = 150, 80:90 rs = RandomSequences(n_realisations, chunk_lengths) # Combine to a RandomSequencesTest rs_test = RandomSequencesTest(cm_test, chunk_lengths) # Compute causality statistic causality(x, y, rs_test) ``` This also works on uncertain data, or any combination of scalar vectors and uncertain data: ```julia # Some example data N = 300 sys = ar1_unidir(c_xy = 0.8) X, Y = example_uncertain_indexvalue_datasets(sys, N, (1, 2), d_xval = Uniform(0.001, 0.05), d_yval = Uniform(0.001, 0.05)); # Apply cross mapping test on 100 different randomly selected chunks # of lengths 75 to 90 r = RandomSequences(100, 75:90) rs_test = RandomSequencesTest(CrossMappingTest(), r) causality(X, Y, rs_test) ``` """ function causality( source::Union{AbstractVector, Vector{<:AbstractUncertainValue}, AbstractUncertainValueDataset, AbstractUncertainIndexValueDataset}, target::Union{AbstractVector, Vector{<:AbstractUncertainValue}, AbstractUncertainValueDataset, AbstractUncertainIndexValueDataset}, test::RandomSequencesTest) n_sequences = test.sequences_resampling.n # Get the return type of the causality test causality_test = test.test RT = get_return_type(causality_test) results = Vector{RT}(undef, n_sequences) for i = 1:n_sequences r = get_random_segment(source, target, test.sequences_resampling) source_segment = resample_and_subset(source, r) target_segment = resample_and_subset(target, r) results[i] = causality(source_segment, target_segment, causality_test) end return results end function causality( source::Union{AbstractVector, Vector{<:AbstractUncertainValue}, AbstractUncertainValueDataset, AbstractUncertainIndexValueDataset}, target::Union{AbstractVector, Vector{<:AbstractUncertainValue}, AbstractUncertainValueDataset, AbstractUncertainIndexValueDataset}, cond::Union{AbstractVector, Vector{<:AbstractUncertainValue}, AbstractUncertainValueDataset, AbstractUncertainIndexValueDataset}, test::RandomSequencesTest) n_sequences = test.sequences_resampling.n # Get the return type of the causality test causality_test = test.test RT = get_return_type(causality_test) results = Vector{RT}(undef, n_sequences) for i = 1:n_sequences r = get_random_segment(source, target, test.sequences_resampling) source_segment = resample_and_subset(source, r) target_segment = resample_and_subset(target, r) cond_segment = resample_and_subset(cond, r) results[i] = causality(source_segment, target_segment, cond_segment, causality_test) end return results end export causality, resample_and_subset
using ACSF using Test, LinearAlgebra, BenchmarkTools using JuLIP, JuLIP.Testing using ACSF: acsf @testset "ACSF.jl" begin include("test.jl") #include("test2.jl") end
import action group_theory.quotient_group open quotient_group mul_action section parameter {α : Type} parameters (H : set (free_group α)) [is_subgroup H] def Q := quotient H def r : Q := mk 1 lemma r_mk_one : r = mk 1 := rfl instance mul_act : mul_action (free_group α) Q := mul_action.mul_action H lemma mul_mk (g g') : g • (mk g' : Q) = mk (g * g') := rfl lemma smul_r (g : free_group α) : g • r = mk g := by rw [r_mk_one, mul_mk, mul_one] lemma trans_act : orbit (free_group α) r = set.univ := set.ext $ λ q, (quot.ind $ λ a, (iff_true _).mpr (⟨a, smul_r a⟩)) q lemma mk_eq_iff (g g') : (mk g : Q) = mk g' ↔ g⁻¹ * g' ∈ H := quotient_group.eq lemma h_is_stab : H = stabilizer _ r := set.ext $ λ x, begin simp, rw [smul_r, r_mk_one, mk_eq_iff, mul_one], symmetry, exact is_subgroup.inv_mem_iff H, end def h_isom : H ≃* stabilizer (free_group α) r := ⟨λ ⟨x, h⟩, ⟨x, h_is_stab ▸ h⟩, λ ⟨x, h⟩, ⟨x, h_is_stab.symm ▸ h⟩, λ ⟨_, _⟩, rfl, λ ⟨_, _⟩, rfl, λ ⟨_, _⟩ ⟨_, _⟩, rfl⟩ theorem nielsen_schreier : ∃ (R : Type), nonempty (H ≃* free_group R) ∧ nonempty (Q × α ⊕ unit ≃ Q ⊕ R) := ⟨R Q r trans_act, ⟨mul_equiv.trans h_isom $ isom _ _ _⟩, ⟨index_equiv _ _ _⟩⟩ end
# --- # title: 1475. Final Prices With a Special Discount in a Shop # id: problem1475 # author: Tian Jun # date: 2020-10-31 # difficulty: Easy # categories: Array # link: <https://leetcode.com/problems/final-prices-with-a-special-discount-in-a-shop/description/> # hidden: true # --- # # Given the array `prices` where `prices[i]` is the price of the `ith` item in a # shop. There is a special discount for items in the shop, if you buy the `ith` # item, then you will receive a discount equivalent to `prices[j]` where `j` is # the **minimum** index such that `j > i` and `prices[j] <= prices[i]`, # otherwise, you will not receive any discount at all. # # _Return an array where the`ith` element is the final price you will pay for # the `ith` item of the shop considering the special discount._ # # # # **Example 1:** # # # # Input: prices = [8,4,6,2,3] # Output: [4,2,4,2,3] # Explanation: # For item 0 with price[0]=8 you will receive a discount equivalent to prices[1]=4, therefore, the final price you will pay is 8 - 4 = 4. # For item 1 with price[1]=4 you will receive a discount equivalent to prices[3]=2, therefore, the final price you will pay is 4 - 2 = 2. # For item 2 with price[2]=6 you will receive a discount equivalent to prices[3]=2, therefore, the final price you will pay is 6 - 2 = 4. # For items 3 and 4 you will not receive any discount at all. # # # **Example 2:** # # # # Input: prices = [1,2,3,4,5] # Output: [1,2,3,4,5] # Explanation: In this case, for all items, you will not receive any discount at all. # # # **Example 3:** # # # # Input: prices = [10,1,1,6] # Output: [9,0,1,6] # # # # # **Constraints:** # # * `1 <= prices.length <= 500` # * `1 <= prices[i] <= 10^3` # # ## @lc code=start using LeetCode ## add your code here: ## @lc code=end
[GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝² : TopologicalSpace α inst✝¹ : TopologicalSpace β inst✝ : TopologicalSpace γ x✝ : Set C(α, β) ⊢ x✝ ∈ {m | ∃ s x u x, m = CompactOpen.gen s u} ↔ x✝ ∈ image2 CompactOpen.gen {s | IsCompact s} {t | IsOpen t} [PROOFSTEP] simp [eq_comm] [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝² : TopologicalSpace α inst✝¹ : TopologicalSpace β inst✝ : TopologicalSpace γ s : Set α hs : IsCompact s u : Set β hu : IsOpen u ⊢ CompactOpen.gen s u ∈ {m | ∃ s x u x, m = CompactOpen.gen s u} [PROOFSTEP] dsimp [mem_setOf_eq] [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝² : TopologicalSpace α inst✝¹ : TopologicalSpace β inst✝ : TopologicalSpace γ s : Set α hs : IsCompact s u : Set β hu : IsOpen u ⊢ ∃ s_1 x u_1 x, CompactOpen.gen s u = CompactOpen.gen s_1 u_1 [PROOFSTEP] tauto [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝² : TopologicalSpace α inst✝¹ : TopologicalSpace β inst✝ : TopologicalSpace γ g : C(β, γ) s : Set α u : Set γ ⊢ comp g ⁻¹' CompactOpen.gen s u = CompactOpen.gen s (↑g ⁻¹' u) [PROOFSTEP] ext ⟨f, _⟩ [GOAL] case h.mk α : Type u_1 β : Type u_2 γ : Type u_3 inst✝² : TopologicalSpace α inst✝¹ : TopologicalSpace β inst✝ : TopologicalSpace γ g : C(β, γ) s : Set α u : Set γ f : α → β continuous_toFun✝ : Continuous f ⊢ mk f ∈ comp g ⁻¹' CompactOpen.gen s u ↔ mk f ∈ CompactOpen.gen s (↑g ⁻¹' u) [PROOFSTEP] change g ∘ f '' s ⊆ u ↔ f '' s ⊆ g ⁻¹' u [GOAL] case h.mk α : Type u_1 β : Type u_2 γ : Type u_3 inst✝² : TopologicalSpace α inst✝¹ : TopologicalSpace β inst✝ : TopologicalSpace γ g : C(β, γ) s : Set α u : Set γ f : α → β continuous_toFun✝ : Continuous f ⊢ ↑g ∘ f '' s ⊆ u ↔ f '' s ⊆ ↑g ⁻¹' u [PROOFSTEP] rw [image_comp, image_subset_iff] [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝² : TopologicalSpace α inst✝¹ : TopologicalSpace β inst✝ : TopologicalSpace γ g : C(β, γ) m : Set C(α, γ) x✝ : m ∈ {m | ∃ s x u x, m = CompactOpen.gen s u} s : Set α hs : IsCompact s u : Set γ hu : IsOpen u hm : m = CompactOpen.gen s u ⊢ IsOpen (comp g ⁻¹' m) [PROOFSTEP] rw [hm, preimage_gen g] [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝² : TopologicalSpace α inst✝¹ : TopologicalSpace β inst✝ : TopologicalSpace γ g : C(β, γ) m : Set C(α, γ) x✝ : m ∈ {m | ∃ s x u x, m = CompactOpen.gen s u} s : Set α hs : IsCompact s u : Set γ hu : IsOpen u hm : m = CompactOpen.gen s u ⊢ IsOpen (CompactOpen.gen s (↑g ⁻¹' u)) [PROOFSTEP] exact ContinuousMap.isOpen_gen hs (hu.preimage g.2) [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝² : TopologicalSpace α inst✝¹ : TopologicalSpace β inst✝ : TopologicalSpace γ g : C(β, γ) hg : Inducing ↑g ⊢ compactOpen = TopologicalSpace.induced (comp g) compactOpen [PROOFSTEP] simp only [compactOpen_eq, induced_generateFrom_eq, image_image2, preimage_gen, hg.setOf_isOpen, image2_image_right] [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝² : TopologicalSpace α inst✝¹ : TopologicalSpace β inst✝ : TopologicalSpace γ g : C(β, γ) f : C(α, β) s : Set α x✝¹ : IsCompact s u : Set γ x✝ : IsOpen u ⊢ (fun g => comp g f) ⁻¹' CompactOpen.gen s u = CompactOpen.gen (↑f '' s) u [PROOFSTEP] ext ⟨g, _⟩ [GOAL] case h.mk α : Type u_1 β : Type u_2 γ : Type u_3 inst✝² : TopologicalSpace α inst✝¹ : TopologicalSpace β inst✝ : TopologicalSpace γ g✝ : C(β, γ) f : C(α, β) s : Set α x✝¹ : IsCompact s u : Set γ x✝ : IsOpen u g : β → γ continuous_toFun✝ : Continuous g ⊢ mk g ∈ (fun g => comp g f) ⁻¹' CompactOpen.gen s u ↔ mk g ∈ CompactOpen.gen (↑f '' s) u [PROOFSTEP] change g ∘ f '' s ⊆ u ↔ g '' (f '' s) ⊆ u [GOAL] case h.mk α : Type u_1 β : Type u_2 γ : Type u_3 inst✝² : TopologicalSpace α inst✝¹ : TopologicalSpace β inst✝ : TopologicalSpace γ g✝ : C(β, γ) f : C(α, β) s : Set α x✝¹ : IsCompact s u : Set γ x✝ : IsOpen u g : β → γ continuous_toFun✝ : Continuous g ⊢ g ∘ ↑f '' s ⊆ u ↔ g '' (↑f '' s) ⊆ u [PROOFSTEP] rw [Set.image_comp] [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝² : TopologicalSpace α inst✝¹ : TopologicalSpace β inst✝ : TopologicalSpace γ g : C(β, γ) f : C(α, β) m : Set C(α, γ) x✝ : m ∈ {m | ∃ s x u x, m = CompactOpen.gen s u} s : Set α hs : IsCompact s u : Set γ hu : IsOpen u hm : m = CompactOpen.gen s u ⊢ IsOpen ((fun g => comp g f) ⁻¹' m) [PROOFSTEP] rw [hm, image_gen f hs hu] [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝² : TopologicalSpace α inst✝¹ : TopologicalSpace β inst✝ : TopologicalSpace γ g : C(β, γ) f : C(α, β) m : Set C(α, γ) x✝ : m ∈ {m | ∃ s x u x, m = CompactOpen.gen s u} s : Set α hs : IsCompact s u : Set γ hu : IsOpen u hm : m = CompactOpen.gen s u ⊢ IsOpen (CompactOpen.gen (↑f '' s) u) [PROOFSTEP] exact ContinuousMap.isOpen_gen (hs.image f.2) hu [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝³ : TopologicalSpace α inst✝² : TopologicalSpace β inst✝¹ : TopologicalSpace γ g : C(β, γ) f : C(α, β) inst✝ : LocallyCompactSpace β ⊢ ∀ (s : Set C(α, γ)), s ∈ {m | ∃ s x u x, m = CompactOpen.gen s u} → IsOpen ((fun x => comp x.snd x.fst) ⁻¹' s) [PROOFSTEP] rintro M ⟨K, hK, U, hU, rfl⟩ [GOAL] case intro.intro.intro.intro α : Type u_1 β : Type u_2 γ : Type u_3 inst✝³ : TopologicalSpace α inst✝² : TopologicalSpace β inst✝¹ : TopologicalSpace γ g : C(β, γ) f : C(α, β) inst✝ : LocallyCompactSpace β K : Set α hK : IsCompact K U : Set γ hU : IsOpen U ⊢ IsOpen ((fun x => comp x.snd x.fst) ⁻¹' CompactOpen.gen K U) [PROOFSTEP] conv => congr rw [CompactOpen.gen, preimage_setOf_eq] --congr ext; dsimp [setOf] rw [image_comp, image_subset_iff] [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝³ : TopologicalSpace α inst✝² : TopologicalSpace β inst✝¹ : TopologicalSpace γ g : C(β, γ) f : C(α, β) inst✝ : LocallyCompactSpace β K : Set α hK : IsCompact K U : Set γ hU : IsOpen U | IsOpen ((fun x => comp x.snd x.fst) ⁻¹' CompactOpen.gen K U) [PROOFSTEP] congr rw [CompactOpen.gen, preimage_setOf_eq] --congr ext; dsimp [setOf] rw [image_comp, image_subset_iff] [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝³ : TopologicalSpace α inst✝² : TopologicalSpace β inst✝¹ : TopologicalSpace γ g : C(β, γ) f : C(α, β) inst✝ : LocallyCompactSpace β K : Set α hK : IsCompact K U : Set γ hU : IsOpen U | IsOpen ((fun x => comp x.snd x.fst) ⁻¹' CompactOpen.gen K U) [PROOFSTEP] congr rw [CompactOpen.gen, preimage_setOf_eq] --congr ext; dsimp [setOf] rw [image_comp, image_subset_iff] [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝³ : TopologicalSpace α inst✝² : TopologicalSpace β inst✝¹ : TopologicalSpace γ g : C(β, γ) f : C(α, β) inst✝ : LocallyCompactSpace β K : Set α hK : IsCompact K U : Set γ hU : IsOpen U | IsOpen ((fun x => comp x.snd x.fst) ⁻¹' CompactOpen.gen K U) [PROOFSTEP] congr [GOAL] case a α : Type u_1 β : Type u_2 γ : Type u_3 inst✝³ : TopologicalSpace α inst✝² : TopologicalSpace β inst✝¹ : TopologicalSpace γ g : C(β, γ) f : C(α, β) inst✝ : LocallyCompactSpace β K : Set α hK : IsCompact K U : Set γ hU : IsOpen U | (fun x => comp x.snd x.fst) ⁻¹' CompactOpen.gen K U [PROOFSTEP] rw [CompactOpen.gen, preimage_setOf_eq] --congr [GOAL] case a α : Type u_1 β : Type u_2 γ : Type u_3 inst✝³ : TopologicalSpace α inst✝² : TopologicalSpace β inst✝¹ : TopologicalSpace γ g : C(β, γ) f : C(α, β) inst✝ : LocallyCompactSpace β K : Set α hK : IsCompact K U : Set γ hU : IsOpen U | {a | ↑(comp a.snd a.fst) '' K ⊆ U} [PROOFSTEP] ext [GOAL] case a.h α : Type u_1 β : Type u_2 γ : Type u_3 inst✝³ : TopologicalSpace α inst✝² : TopologicalSpace β inst✝¹ : TopologicalSpace γ g : C(β, γ) f : C(α, β) inst✝ : LocallyCompactSpace β K : Set α hK : IsCompact K U : Set γ hU : IsOpen U x✝ : C(α, β) × C(β, γ) | setOf (fun a => ↑(comp a.snd a.fst) '' K ⊆ U) x✝ [PROOFSTEP] dsimp [setOf] [GOAL] case a.h α : Type u_1 β : Type u_2 γ : Type u_3 inst✝³ : TopologicalSpace α inst✝² : TopologicalSpace β inst✝¹ : TopologicalSpace γ g : C(β, γ) f : C(α, β) inst✝ : LocallyCompactSpace β K : Set α hK : IsCompact K U : Set γ hU : IsOpen U x✝ : C(α, β) × C(β, γ) | ↑x✝.snd ∘ ↑x✝.fst '' K ⊆ U [PROOFSTEP] rw [image_comp, image_subset_iff] [GOAL] case intro.intro.intro.intro α : Type u_1 β : Type u_2 γ : Type u_3 inst✝³ : TopologicalSpace α inst✝² : TopologicalSpace β inst✝¹ : TopologicalSpace γ g : C(β, γ) f : C(α, β) inst✝ : LocallyCompactSpace β K : Set α hK : IsCompact K U : Set γ hU : IsOpen U ⊢ IsOpen fun x => ↑x.fst '' K ⊆ ↑x.snd ⁻¹' U [PROOFSTEP] rw [isOpen_iff_forall_mem_open] [GOAL] case intro.intro.intro.intro α : Type u_1 β : Type u_2 γ : Type u_3 inst✝³ : TopologicalSpace α inst✝² : TopologicalSpace β inst✝¹ : TopologicalSpace γ g : C(β, γ) f : C(α, β) inst✝ : LocallyCompactSpace β K : Set α hK : IsCompact K U : Set γ hU : IsOpen U ⊢ ∀ (x : C(α, β) × C(β, γ)), (x ∈ fun x => ↑x.fst '' K ⊆ ↑x.snd ⁻¹' U) → ∃ t, (t ⊆ fun x => ↑x.fst '' K ⊆ ↑x.snd ⁻¹' U) ∧ IsOpen t ∧ x ∈ t [PROOFSTEP] rintro ⟨φ₀, ψ₀⟩ H [GOAL] case intro.intro.intro.intro.mk α : Type u_1 β : Type u_2 γ : Type u_3 inst✝³ : TopologicalSpace α inst✝² : TopologicalSpace β inst✝¹ : TopologicalSpace γ g : C(β, γ) f : C(α, β) inst✝ : LocallyCompactSpace β K : Set α hK : IsCompact K U : Set γ hU : IsOpen U φ₀ : C(α, β) ψ₀ : C(β, γ) H : (φ₀, ψ₀) ∈ fun x => ↑x.fst '' K ⊆ ↑x.snd ⁻¹' U ⊢ ∃ t, (t ⊆ fun x => ↑x.fst '' K ⊆ ↑x.snd ⁻¹' U) ∧ IsOpen t ∧ (φ₀, ψ₀) ∈ t [PROOFSTEP] obtain ⟨L, hL, hKL, hLU⟩ := exists_compact_between (hK.image φ₀.2) (hU.preimage ψ₀.2) H [GOAL] case intro.intro.intro.intro.mk.intro.intro.intro α : Type u_1 β : Type u_2 γ : Type u_3 inst✝³ : TopologicalSpace α inst✝² : TopologicalSpace β inst✝¹ : TopologicalSpace γ g : C(β, γ) f : C(α, β) inst✝ : LocallyCompactSpace β K : Set α hK : IsCompact K U : Set γ hU : IsOpen U φ₀ : C(α, β) ψ₀ : C(β, γ) H : (φ₀, ψ₀) ∈ fun x => ↑x.fst '' K ⊆ ↑x.snd ⁻¹' U L : Set β hL : IsCompact L hKL : φ₀.toFun '' K ⊆ interior L hLU : L ⊆ ψ₀.toFun ⁻¹' U ⊢ ∃ t, (t ⊆ fun x => ↑x.fst '' K ⊆ ↑x.snd ⁻¹' U) ∧ IsOpen t ∧ (φ₀, ψ₀) ∈ t [PROOFSTEP] use{φ : C(α, β) | φ '' K ⊆ interior L} ×ˢ {ψ : C(β, γ) | ψ '' L ⊆ U} -- porting note: typing hint `: φ '' K ⊆ interior L` wasn't previously required [GOAL] case h α : Type u_1 β : Type u_2 γ : Type u_3 inst✝³ : TopologicalSpace α inst✝² : TopologicalSpace β inst✝¹ : TopologicalSpace γ g : C(β, γ) f : C(α, β) inst✝ : LocallyCompactSpace β K : Set α hK : IsCompact K U : Set γ hU : IsOpen U φ₀ : C(α, β) ψ₀ : C(β, γ) H : (φ₀, ψ₀) ∈ fun x => ↑x.fst '' K ⊆ ↑x.snd ⁻¹' U L : Set β hL : IsCompact L hKL : φ₀.toFun '' K ⊆ interior L hLU : L ⊆ ψ₀.toFun ⁻¹' U ⊢ ({φ | ↑φ '' K ⊆ interior L} ×ˢ {ψ | ↑ψ '' L ⊆ U} ⊆ fun x => ↑x.fst '' K ⊆ ↑x.snd ⁻¹' U) ∧ IsOpen ({φ | ↑φ '' K ⊆ interior L} ×ˢ {ψ | ↑ψ '' L ⊆ U}) ∧ (φ₀, ψ₀) ∈ {φ | ↑φ '' K ⊆ interior L} ×ˢ {ψ | ↑ψ '' L ⊆ U} [PROOFSTEP] use fun ⟨φ, ψ⟩ ⟨(hφ : φ '' K ⊆ interior L), hψ⟩ => subset_trans hφ (interior_subset.trans <| image_subset_iff.mp hψ) [GOAL] case right α : Type u_1 β : Type u_2 γ : Type u_3 inst✝³ : TopologicalSpace α inst✝² : TopologicalSpace β inst✝¹ : TopologicalSpace γ g : C(β, γ) f : C(α, β) inst✝ : LocallyCompactSpace β K : Set α hK : IsCompact K U : Set γ hU : IsOpen U φ₀ : C(α, β) ψ₀ : C(β, γ) H : (φ₀, ψ₀) ∈ fun x => ↑x.fst '' K ⊆ ↑x.snd ⁻¹' U L : Set β hL : IsCompact L hKL : φ₀.toFun '' K ⊆ interior L hLU : L ⊆ ψ₀.toFun ⁻¹' U ⊢ IsOpen ({φ | ↑φ '' K ⊆ interior L} ×ˢ {ψ | ↑ψ '' L ⊆ U}) ∧ (φ₀, ψ₀) ∈ {φ | ↑φ '' K ⊆ interior L} ×ˢ {ψ | ↑ψ '' L ⊆ U} [PROOFSTEP] use(ContinuousMap.isOpen_gen hK isOpen_interior).prod (ContinuousMap.isOpen_gen hL hU) [GOAL] case right α : Type u_1 β : Type u_2 γ : Type u_3 inst✝³ : TopologicalSpace α inst✝² : TopologicalSpace β inst✝¹ : TopologicalSpace γ g : C(β, γ) f : C(α, β) inst✝ : LocallyCompactSpace β K : Set α hK : IsCompact K U : Set γ hU : IsOpen U φ₀ : C(α, β) ψ₀ : C(β, γ) H : (φ₀, ψ₀) ∈ fun x => ↑x.fst '' K ⊆ ↑x.snd ⁻¹' U L : Set β hL : IsCompact L hKL : φ₀.toFun '' K ⊆ interior L hLU : L ⊆ ψ₀.toFun ⁻¹' U ⊢ (φ₀, ψ₀) ∈ {φ | ↑φ '' K ⊆ interior L} ×ˢ {ψ | ↑ψ '' L ⊆ U} [PROOFSTEP] exact mem_prod.mpr ⟨hKL, image_subset_iff.mpr hLU⟩ [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝³ : TopologicalSpace α inst✝² : TopologicalSpace β inst✝¹ : TopologicalSpace γ inst✝ : LocallyCompactSpace α x✝ : C(α, β) × α n : Set β f : C(α, β) x : α hn : n ∈ 𝓝 (↑(f, x).fst (f, x).snd) v : Set β vn : v ⊆ n vo : IsOpen v fxv : ↑(f, x).fst (f, x).snd ∈ v this✝² : v ∈ 𝓝 (↑f x) s : Set α hs : s ∈ 𝓝 x sv : s ⊆ ↑f ⁻¹' v sc : IsCompact s u : Set α us : u ⊆ s uo : IsOpen u xu : x ∈ u w : Set (C(α, β) × α) := CompactOpen.gen s v ×ˢ u this✝¹ : w ⊆ (fun p => ↑p.fst p.snd) ⁻¹' n this✝ : IsOpen w this : (f, x) ∈ w ⊢ w ⊆ (fun p => ↑p.fst p.snd) ⁻¹' n [PROOFSTEP] assumption [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝³ : TopologicalSpace α inst✝² : TopologicalSpace β inst✝¹ : TopologicalSpace γ inst✝ : LocallyCompactSpace α x✝ : C(α, β) × α n : Set β f : C(α, β) x : α hn : n ∈ 𝓝 (↑(f, x).fst (f, x).snd) v : Set β vn : v ⊆ n vo : IsOpen v fxv : ↑(f, x).fst (f, x).snd ∈ v this✝² : v ∈ 𝓝 (↑f x) s : Set α hs : s ∈ 𝓝 x sv : s ⊆ ↑f ⁻¹' v sc : IsCompact s u : Set α us : u ⊆ s uo : IsOpen u xu : x ∈ u w : Set (C(α, β) × α) := CompactOpen.gen s v ×ˢ u this✝¹ : w ⊆ (fun p => ↑p.fst p.snd) ⁻¹' n this✝ : IsOpen w this : (f, x) ∈ w ⊢ IsOpen w [PROOFSTEP] assumption [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝³ : TopologicalSpace α inst✝² : TopologicalSpace β inst✝¹ : TopologicalSpace γ inst✝ : LocallyCompactSpace α x✝ : C(α, β) × α n : Set β f : C(α, β) x : α hn : n ∈ 𝓝 (↑(f, x).fst (f, x).snd) v : Set β vn : v ⊆ n vo : IsOpen v fxv : ↑(f, x).fst (f, x).snd ∈ v this✝² : v ∈ 𝓝 (↑f x) s : Set α hs : s ∈ 𝓝 x sv : s ⊆ ↑f ⁻¹' v sc : IsCompact s u : Set α us : u ⊆ s uo : IsOpen u xu : x ∈ u w : Set (C(α, β) × α) := CompactOpen.gen s v ×ˢ u this✝¹ : w ⊆ (fun p => ↑p.fst p.snd) ⁻¹' n this✝ : IsOpen w this : (f, x) ∈ w ⊢ (f, x) ∈ w [PROOFSTEP] assumption [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝² : TopologicalSpace α inst✝¹ : TopologicalSpace β inst✝ : TopologicalSpace γ a : α ⊢ Continuous fun f => ↑f a [PROOFSTEP] refine continuous_def.2 fun U hU ↦ ?_ [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝² : TopologicalSpace α inst✝¹ : TopologicalSpace β inst✝ : TopologicalSpace γ a : α U : Set ((fun x => β) a) hU : IsOpen U ⊢ IsOpen ((fun f => ↑f a) ⁻¹' U) [PROOFSTEP] convert ContinuousMap.isOpen_gen (isCompact_singleton (a := a)) hU using 1 [GOAL] case h.e'_3 α : Type u_1 β : Type u_2 γ : Type u_3 inst✝² : TopologicalSpace α inst✝¹ : TopologicalSpace β inst✝ : TopologicalSpace γ a : α U : Set ((fun x => β) a) hU : IsOpen U ⊢ (fun f => ↑f a) ⁻¹' U = CompactOpen.gen {a} U [PROOFSTEP] ext [GOAL] case h.e'_3.h α : Type u_1 β : Type u_2 γ : Type u_3 inst✝² : TopologicalSpace α inst✝¹ : TopologicalSpace β inst✝ : TopologicalSpace γ a : α U : Set ((fun x => β) a) hU : IsOpen U x✝ : C(α, β) ⊢ x✝ ∈ (fun f => ↑f a) ⁻¹' U ↔ x✝ ∈ CompactOpen.gen {a} U [PROOFSTEP] simp [CompactOpen.gen] [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝² : TopologicalSpace α inst✝¹ : TopologicalSpace β inst✝ : TopologicalSpace γ s : Set α ⊢ compactOpen ≤ TopologicalSpace.induced (restrict s) compactOpen [PROOFSTEP] simp only [induced_generateFrom_eq, ContinuousMap.compactOpen] [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝² : TopologicalSpace α inst✝¹ : TopologicalSpace β inst✝ : TopologicalSpace γ s : Set α ⊢ TopologicalSpace.generateFrom {m | ∃ s x u x, m = CompactOpen.gen s u} ≤ TopologicalSpace.generateFrom (preimage (restrict s) '' {m | ∃ s_1 x u x, m = CompactOpen.gen s_1 u}) [PROOFSTEP] apply TopologicalSpace.generateFrom_anti [GOAL] case h α : Type u_1 β : Type u_2 γ : Type u_3 inst✝² : TopologicalSpace α inst✝¹ : TopologicalSpace β inst✝ : TopologicalSpace γ s : Set α ⊢ preimage (restrict s) '' {m | ∃ s_1 x u x, m = CompactOpen.gen s_1 u} ⊆ {m | ∃ s x u x, m = CompactOpen.gen s u} [PROOFSTEP] rintro b ⟨a, ⟨c, hc, u, hu, rfl⟩, rfl⟩ [GOAL] case h.intro.intro.intro.intro.intro.intro α : Type u_1 β : Type u_2 γ : Type u_3 inst✝² : TopologicalSpace α inst✝¹ : TopologicalSpace β inst✝ : TopologicalSpace γ s : Set α c : Set ↑s hc : IsCompact c u : Set β hu : IsOpen u ⊢ restrict s ⁻¹' CompactOpen.gen c u ∈ {m | ∃ s x u x, m = CompactOpen.gen s u} [PROOFSTEP] refine' ⟨(↑) '' c, hc.image continuous_subtype_val, u, hu, _⟩ [GOAL] case h.intro.intro.intro.intro.intro.intro α : Type u_1 β : Type u_2 γ : Type u_3 inst✝² : TopologicalSpace α inst✝¹ : TopologicalSpace β inst✝ : TopologicalSpace γ s : Set α c : Set ↑s hc : IsCompact c u : Set β hu : IsOpen u ⊢ restrict s ⁻¹' CompactOpen.gen c u = CompactOpen.gen (Subtype.val '' c) u [PROOFSTEP] ext f [GOAL] case h.intro.intro.intro.intro.intro.intro.h α : Type u_1 β : Type u_2 γ : Type u_3 inst✝² : TopologicalSpace α inst✝¹ : TopologicalSpace β inst✝ : TopologicalSpace γ s : Set α c : Set ↑s hc : IsCompact c u : Set β hu : IsOpen u f : C(α, β) ⊢ f ∈ restrict s ⁻¹' CompactOpen.gen c u ↔ f ∈ CompactOpen.gen (Subtype.val '' c) u [PROOFSTEP] simp only [CompactOpen.gen, mem_setOf_eq, mem_preimage, ContinuousMap.coe_restrict] [GOAL] case h.intro.intro.intro.intro.intro.intro.h α : Type u_1 β : Type u_2 γ : Type u_3 inst✝² : TopologicalSpace α inst✝¹ : TopologicalSpace β inst✝ : TopologicalSpace γ s : Set α c : Set ↑s hc : IsCompact c u : Set β hu : IsOpen u f : C(α, β) ⊢ (fun a => (↑f ∘ Subtype.val) a) '' c ⊆ u ↔ (fun a => ↑f a) '' (Subtype.val '' c) ⊆ u [PROOFSTEP] rw [image_comp f ((↑) : s → α)] [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝² : TopologicalSpace α inst✝¹ : TopologicalSpace β inst✝ : TopologicalSpace γ ⊢ compactOpen = ⨅ (s : Set α) (_ : IsCompact s), TopologicalSpace.induced (restrict s) compactOpen [PROOFSTEP] refine' le_antisymm _ _ [GOAL] case refine'_1 α : Type u_1 β : Type u_2 γ : Type u_3 inst✝² : TopologicalSpace α inst✝¹ : TopologicalSpace β inst✝ : TopologicalSpace γ ⊢ compactOpen ≤ ⨅ (s : Set α) (_ : IsCompact s), TopologicalSpace.induced (restrict s) compactOpen [PROOFSTEP] refine' le_iInf₂ _ [GOAL] case refine'_1 α : Type u_1 β : Type u_2 γ : Type u_3 inst✝² : TopologicalSpace α inst✝¹ : TopologicalSpace β inst✝ : TopologicalSpace γ ⊢ ∀ (i : Set α), IsCompact i → compactOpen ≤ TopologicalSpace.induced (restrict i) compactOpen [PROOFSTEP] exact fun s _ => compactOpen_le_induced s [GOAL] case refine'_2 α : Type u_1 β : Type u_2 γ : Type u_3 inst✝² : TopologicalSpace α inst✝¹ : TopologicalSpace β inst✝ : TopologicalSpace γ ⊢ ⨅ (s : Set α) (_ : IsCompact s), TopologicalSpace.induced (restrict s) compactOpen ≤ compactOpen [PROOFSTEP] simp only [← generateFrom_iUnion, induced_generateFrom_eq, ContinuousMap.compactOpen] [GOAL] case refine'_2 α : Type u_1 β : Type u_2 γ : Type u_3 inst✝² : TopologicalSpace α inst✝¹ : TopologicalSpace β inst✝ : TopologicalSpace γ ⊢ TopologicalSpace.generateFrom (⋃ (i : Set α) (_ : IsCompact i), preimage (restrict i) '' {m | ∃ s x u x, m = CompactOpen.gen s u}) ≤ TopologicalSpace.generateFrom {m | ∃ s x u x, m = CompactOpen.gen s u} [PROOFSTEP] apply TopologicalSpace.generateFrom_anti [GOAL] case refine'_2.h α : Type u_1 β : Type u_2 γ : Type u_3 inst✝² : TopologicalSpace α inst✝¹ : TopologicalSpace β inst✝ : TopologicalSpace γ ⊢ {m | ∃ s x u x, m = CompactOpen.gen s u} ⊆ ⋃ (i : Set α) (_ : IsCompact i), preimage (restrict i) '' {m | ∃ s x u x, m = CompactOpen.gen s u} [PROOFSTEP] rintro _ ⟨s, hs, u, hu, rfl⟩ [GOAL] case refine'_2.h.intro.intro.intro.intro α : Type u_1 β : Type u_2 γ : Type u_3 inst✝² : TopologicalSpace α inst✝¹ : TopologicalSpace β inst✝ : TopologicalSpace γ s : Set α hs : IsCompact s u : Set β hu : IsOpen u ⊢ CompactOpen.gen s u ∈ ⋃ (i : Set α) (_ : IsCompact i), preimage (restrict i) '' {m | ∃ s x u x, m = CompactOpen.gen s u} [PROOFSTEP] rw [mem_iUnion₂] [GOAL] case refine'_2.h.intro.intro.intro.intro α : Type u_1 β : Type u_2 γ : Type u_3 inst✝² : TopologicalSpace α inst✝¹ : TopologicalSpace β inst✝ : TopologicalSpace γ s : Set α hs : IsCompact s u : Set β hu : IsOpen u ⊢ ∃ i j, CompactOpen.gen s u ∈ preimage (restrict i) '' {m | ∃ s x u x, m = CompactOpen.gen s u} [PROOFSTEP] refine' ⟨s, hs, _, ⟨univ, isCompact_iff_isCompact_univ.mp hs, u, hu, rfl⟩, _⟩ [GOAL] case refine'_2.h.intro.intro.intro.intro α : Type u_1 β : Type u_2 γ : Type u_3 inst✝² : TopologicalSpace α inst✝¹ : TopologicalSpace β inst✝ : TopologicalSpace γ s : Set α hs : IsCompact s u : Set β hu : IsOpen u ⊢ restrict s ⁻¹' CompactOpen.gen univ u = CompactOpen.gen s u [PROOFSTEP] ext f [GOAL] case refine'_2.h.intro.intro.intro.intro.h α : Type u_1 β : Type u_2 γ : Type u_3 inst✝² : TopologicalSpace α inst✝¹ : TopologicalSpace β inst✝ : TopologicalSpace γ s : Set α hs : IsCompact s u : Set β hu : IsOpen u f : C(α, β) ⊢ f ∈ restrict s ⁻¹' CompactOpen.gen univ u ↔ f ∈ CompactOpen.gen s u [PROOFSTEP] simp only [CompactOpen.gen, mem_setOf_eq, mem_preimage, ContinuousMap.coe_restrict] [GOAL] case refine'_2.h.intro.intro.intro.intro.h α : Type u_1 β : Type u_2 γ : Type u_3 inst✝² : TopologicalSpace α inst✝¹ : TopologicalSpace β inst✝ : TopologicalSpace γ s : Set α hs : IsCompact s u : Set β hu : IsOpen u f : C(α, β) ⊢ (fun a => (↑f ∘ Subtype.val) a) '' univ ⊆ u ↔ (fun a => ↑f a) '' s ⊆ u [PROOFSTEP] rw [image_comp f ((↑) : s → α)] [GOAL] case refine'_2.h.intro.intro.intro.intro.h α : Type u_1 β : Type u_2 γ : Type u_3 inst✝² : TopologicalSpace α inst✝¹ : TopologicalSpace β inst✝ : TopologicalSpace γ s : Set α hs : IsCompact s u : Set β hu : IsOpen u f : C(α, β) ⊢ ↑f '' (Subtype.val '' univ) ⊆ u ↔ (fun a => ↑f a) '' s ⊆ u [PROOFSTEP] simp [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝² : TopologicalSpace α inst✝¹ : TopologicalSpace β inst✝ : TopologicalSpace γ s : Set α ⊢ Continuous fun F => restrict s F [PROOFSTEP] rw [continuous_iff_le_induced] [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝² : TopologicalSpace α inst✝¹ : TopologicalSpace β inst✝ : TopologicalSpace γ s : Set α ⊢ compactOpen ≤ TopologicalSpace.induced (fun F => restrict s F) compactOpen [PROOFSTEP] exact compactOpen_le_induced s [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝² : TopologicalSpace α inst✝¹ : TopologicalSpace β inst✝ : TopologicalSpace γ f : C(α, β) ⊢ 𝓝 f = ⨅ (s : Set α) (_ : IsCompact s), Filter.comap (restrict s) (𝓝 (restrict s f)) [PROOFSTEP] rw [compactOpen_eq_sInf_induced] [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝² : TopologicalSpace α inst✝¹ : TopologicalSpace β inst✝ : TopologicalSpace γ f : C(α, β) ⊢ 𝓝 f = ⨅ (s : Set α) (_ : IsCompact s), Filter.comap (restrict s) (𝓝 (restrict s f)) [PROOFSTEP] simp [nhds_iInf, nhds_induced] [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝² : TopologicalSpace α inst✝¹ : TopologicalSpace β inst✝ : TopologicalSpace γ ι : Type u_4 l : Filter ι F : ι → C(α, β) f : C(α, β) ⊢ Filter.Tendsto F l (𝓝 f) ↔ ∀ (s : Set α), IsCompact s → Filter.Tendsto (fun i => restrict s (F i)) l (𝓝 (restrict s f)) [PROOFSTEP] rw [compactOpen_eq_sInf_induced] [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝² : TopologicalSpace α inst✝¹ : TopologicalSpace β inst✝ : TopologicalSpace γ ι : Type u_4 l : Filter ι F : ι → C(α, β) f : C(α, β) ⊢ Filter.Tendsto F l (𝓝 f) ↔ ∀ (s : Set α), IsCompact s → Filter.Tendsto (fun i => restrict s (F i)) l (𝓝 (restrict s f)) [PROOFSTEP] simp [nhds_iInf, nhds_induced, Filter.tendsto_comap_iff, Function.comp] [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝⁵ : TopologicalSpace α inst✝⁴ : TopologicalSpace β inst✝³ : TopologicalSpace γ inst✝² : LocallyCompactSpace α inst✝¹ : T2Space β ι : Type u_4 l : Filter ι inst✝ : Filter.NeBot l F : ι → C(α, β) ⊢ (∃ f, Filter.Tendsto F l (𝓝 f)) ↔ ∀ (s : Set α), IsCompact s → ∃ f, Filter.Tendsto (fun i => restrict s (F i)) l (𝓝 f) [PROOFSTEP] constructor [GOAL] case mp α : Type u_1 β : Type u_2 γ : Type u_3 inst✝⁵ : TopologicalSpace α inst✝⁴ : TopologicalSpace β inst✝³ : TopologicalSpace γ inst✝² : LocallyCompactSpace α inst✝¹ : T2Space β ι : Type u_4 l : Filter ι inst✝ : Filter.NeBot l F : ι → C(α, β) ⊢ (∃ f, Filter.Tendsto F l (𝓝 f)) → ∀ (s : Set α), IsCompact s → ∃ f, Filter.Tendsto (fun i => restrict s (F i)) l (𝓝 f) [PROOFSTEP] rintro ⟨f, hf⟩ s _ [GOAL] case mp.intro α : Type u_1 β : Type u_2 γ : Type u_3 inst✝⁵ : TopologicalSpace α inst✝⁴ : TopologicalSpace β inst✝³ : TopologicalSpace γ inst✝² : LocallyCompactSpace α inst✝¹ : T2Space β ι : Type u_4 l : Filter ι inst✝ : Filter.NeBot l F : ι → C(α, β) f : C(α, β) hf : Filter.Tendsto F l (𝓝 f) s : Set α hs✝ : IsCompact s ⊢ ∃ f, Filter.Tendsto (fun i => restrict s (F i)) l (𝓝 f) [PROOFSTEP] exact ⟨f.restrict s, tendsto_compactOpen_restrict hf s⟩ [GOAL] case mpr α : Type u_1 β : Type u_2 γ : Type u_3 inst✝⁵ : TopologicalSpace α inst✝⁴ : TopologicalSpace β inst✝³ : TopologicalSpace γ inst✝² : LocallyCompactSpace α inst✝¹ : T2Space β ι : Type u_4 l : Filter ι inst✝ : Filter.NeBot l F : ι → C(α, β) ⊢ (∀ (s : Set α), IsCompact s → ∃ f, Filter.Tendsto (fun i => restrict s (F i)) l (𝓝 f)) → ∃ f, Filter.Tendsto F l (𝓝 f) [PROOFSTEP] intro h [GOAL] case mpr α : Type u_1 β : Type u_2 γ : Type u_3 inst✝⁵ : TopologicalSpace α inst✝⁴ : TopologicalSpace β inst✝³ : TopologicalSpace γ inst✝² : LocallyCompactSpace α inst✝¹ : T2Space β ι : Type u_4 l : Filter ι inst✝ : Filter.NeBot l F : ι → C(α, β) h : ∀ (s : Set α), IsCompact s → ∃ f, Filter.Tendsto (fun i => restrict s (F i)) l (𝓝 f) ⊢ ∃ f, Filter.Tendsto F l (𝓝 f) [PROOFSTEP] choose f hf using h [GOAL] case mpr α : Type u_1 β : Type u_2 γ : Type u_3 inst✝⁵ : TopologicalSpace α inst✝⁴ : TopologicalSpace β inst✝³ : TopologicalSpace γ inst✝² : LocallyCompactSpace α inst✝¹ : T2Space β ι : Type u_4 l : Filter ι inst✝ : Filter.NeBot l F : ι → C(α, β) f : (s : Set α) → IsCompact s → C(↑s, β) hf : ∀ (s : Set α) (hs : IsCompact s), Filter.Tendsto (fun i => restrict s (F i)) l (𝓝 (f s hs)) ⊢ ∃ f, Filter.Tendsto F l (𝓝 f) [PROOFSTEP] have h : ∀ (s₁) (hs₁ : IsCompact s₁) (s₂) (hs₂ : IsCompact s₂) (x : α) (hxs₁ : x ∈ s₁) (hxs₂ : x ∈ s₂), f s₁ hs₁ ⟨x, hxs₁⟩ = f s₂ hs₂ ⟨x, hxs₂⟩ := by rintro s₁ hs₁ s₂ hs₂ x hxs₁ hxs₂ haveI := isCompact_iff_compactSpace.mp hs₁ haveI := isCompact_iff_compactSpace.mp hs₂ have h₁ := (continuous_eval_const (⟨x, hxs₁⟩ : s₁)).continuousAt.tendsto.comp (hf s₁ hs₁) have h₂ := (continuous_eval_const (⟨x, hxs₂⟩ : s₂)).continuousAt.tendsto.comp (hf s₂ hs₂) exact tendsto_nhds_unique h₁ h₂ [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝⁵ : TopologicalSpace α inst✝⁴ : TopologicalSpace β inst✝³ : TopologicalSpace γ inst✝² : LocallyCompactSpace α inst✝¹ : T2Space β ι : Type u_4 l : Filter ι inst✝ : Filter.NeBot l F : ι → C(α, β) f : (s : Set α) → IsCompact s → C(↑s, β) hf : ∀ (s : Set α) (hs : IsCompact s), Filter.Tendsto (fun i => restrict s (F i)) l (𝓝 (f s hs)) ⊢ ∀ (s₁ : Set α) (hs₁ : IsCompact s₁) (s₂ : Set α) (hs₂ : IsCompact s₂) (x : α) (hxs₁ : x ∈ s₁) (hxs₂ : x ∈ s₂), ↑(f s₁ hs₁) { val := x, property := hxs₁ } = ↑(f s₂ hs₂) { val := x, property := hxs₂ } [PROOFSTEP] rintro s₁ hs₁ s₂ hs₂ x hxs₁ hxs₂ [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝⁵ : TopologicalSpace α inst✝⁴ : TopologicalSpace β inst✝³ : TopologicalSpace γ inst✝² : LocallyCompactSpace α inst✝¹ : T2Space β ι : Type u_4 l : Filter ι inst✝ : Filter.NeBot l F : ι → C(α, β) f : (s : Set α) → IsCompact s → C(↑s, β) hf : ∀ (s : Set α) (hs : IsCompact s), Filter.Tendsto (fun i => restrict s (F i)) l (𝓝 (f s hs)) s₁ : Set α hs₁ : IsCompact s₁ s₂ : Set α hs₂ : IsCompact s₂ x : α hxs₁ : x ∈ s₁ hxs₂ : x ∈ s₂ ⊢ ↑(f s₁ hs₁) { val := x, property := hxs₁ } = ↑(f s₂ hs₂) { val := x, property := hxs₂ } [PROOFSTEP] haveI := isCompact_iff_compactSpace.mp hs₁ [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝⁵ : TopologicalSpace α inst✝⁴ : TopologicalSpace β inst✝³ : TopologicalSpace γ inst✝² : LocallyCompactSpace α inst✝¹ : T2Space β ι : Type u_4 l : Filter ι inst✝ : Filter.NeBot l F : ι → C(α, β) f : (s : Set α) → IsCompact s → C(↑s, β) hf : ∀ (s : Set α) (hs : IsCompact s), Filter.Tendsto (fun i => restrict s (F i)) l (𝓝 (f s hs)) s₁ : Set α hs₁ : IsCompact s₁ s₂ : Set α hs₂ : IsCompact s₂ x : α hxs₁ : x ∈ s₁ hxs₂ : x ∈ s₂ this : CompactSpace ↑s₁ ⊢ ↑(f s₁ hs₁) { val := x, property := hxs₁ } = ↑(f s₂ hs₂) { val := x, property := hxs₂ } [PROOFSTEP] haveI := isCompact_iff_compactSpace.mp hs₂ [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝⁵ : TopologicalSpace α inst✝⁴ : TopologicalSpace β inst✝³ : TopologicalSpace γ inst✝² : LocallyCompactSpace α inst✝¹ : T2Space β ι : Type u_4 l : Filter ι inst✝ : Filter.NeBot l F : ι → C(α, β) f : (s : Set α) → IsCompact s → C(↑s, β) hf : ∀ (s : Set α) (hs : IsCompact s), Filter.Tendsto (fun i => restrict s (F i)) l (𝓝 (f s hs)) s₁ : Set α hs₁ : IsCompact s₁ s₂ : Set α hs₂ : IsCompact s₂ x : α hxs₁ : x ∈ s₁ hxs₂ : x ∈ s₂ this✝ : CompactSpace ↑s₁ this : CompactSpace ↑s₂ ⊢ ↑(f s₁ hs₁) { val := x, property := hxs₁ } = ↑(f s₂ hs₂) { val := x, property := hxs₂ } [PROOFSTEP] have h₁ := (continuous_eval_const (⟨x, hxs₁⟩ : s₁)).continuousAt.tendsto.comp (hf s₁ hs₁) [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝⁵ : TopologicalSpace α inst✝⁴ : TopologicalSpace β inst✝³ : TopologicalSpace γ inst✝² : LocallyCompactSpace α inst✝¹ : T2Space β ι : Type u_4 l : Filter ι inst✝ : Filter.NeBot l F : ι → C(α, β) f : (s : Set α) → IsCompact s → C(↑s, β) hf : ∀ (s : Set α) (hs : IsCompact s), Filter.Tendsto (fun i => restrict s (F i)) l (𝓝 (f s hs)) s₁ : Set α hs₁ : IsCompact s₁ s₂ : Set α hs₂ : IsCompact s₂ x : α hxs₁ : x ∈ s₁ hxs₂ : x ∈ s₂ this✝ : CompactSpace ↑s₁ this : CompactSpace ↑s₂ h₁ : Filter.Tendsto ((fun f => ↑f { val := x, property := hxs₁ }) ∘ fun i => restrict s₁ (F i)) l (𝓝 (↑(f s₁ hs₁) { val := x, property := hxs₁ })) ⊢ ↑(f s₁ hs₁) { val := x, property := hxs₁ } = ↑(f s₂ hs₂) { val := x, property := hxs₂ } [PROOFSTEP] have h₂ := (continuous_eval_const (⟨x, hxs₂⟩ : s₂)).continuousAt.tendsto.comp (hf s₂ hs₂) [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝⁵ : TopologicalSpace α inst✝⁴ : TopologicalSpace β inst✝³ : TopologicalSpace γ inst✝² : LocallyCompactSpace α inst✝¹ : T2Space β ι : Type u_4 l : Filter ι inst✝ : Filter.NeBot l F : ι → C(α, β) f : (s : Set α) → IsCompact s → C(↑s, β) hf : ∀ (s : Set α) (hs : IsCompact s), Filter.Tendsto (fun i => restrict s (F i)) l (𝓝 (f s hs)) s₁ : Set α hs₁ : IsCompact s₁ s₂ : Set α hs₂ : IsCompact s₂ x : α hxs₁ : x ∈ s₁ hxs₂ : x ∈ s₂ this✝ : CompactSpace ↑s₁ this : CompactSpace ↑s₂ h₁ : Filter.Tendsto ((fun f => ↑f { val := x, property := hxs₁ }) ∘ fun i => restrict s₁ (F i)) l (𝓝 (↑(f s₁ hs₁) { val := x, property := hxs₁ })) h₂ : Filter.Tendsto ((fun f => ↑f { val := x, property := hxs₂ }) ∘ fun i => restrict s₂ (F i)) l (𝓝 (↑(f s₂ hs₂) { val := x, property := hxs₂ })) ⊢ ↑(f s₁ hs₁) { val := x, property := hxs₁ } = ↑(f s₂ hs₂) { val := x, property := hxs₂ } [PROOFSTEP] exact tendsto_nhds_unique h₁ h₂ [GOAL] case mpr α : Type u_1 β : Type u_2 γ : Type u_3 inst✝⁵ : TopologicalSpace α inst✝⁴ : TopologicalSpace β inst✝³ : TopologicalSpace γ inst✝² : LocallyCompactSpace α inst✝¹ : T2Space β ι : Type u_4 l : Filter ι inst✝ : Filter.NeBot l F : ι → C(α, β) f : (s : Set α) → IsCompact s → C(↑s, β) hf : ∀ (s : Set α) (hs : IsCompact s), Filter.Tendsto (fun i => restrict s (F i)) l (𝓝 (f s hs)) h : ∀ (s₁ : Set α) (hs₁ : IsCompact s₁) (s₂ : Set α) (hs₂ : IsCompact s₂) (x : α) (hxs₁ : x ∈ s₁) (hxs₂ : x ∈ s₂), ↑(f s₁ hs₁) { val := x, property := hxs₁ } = ↑(f s₂ hs₂) { val := x, property := hxs₂ } ⊢ ∃ f, Filter.Tendsto F l (𝓝 f) [PROOFSTEP] have hs : ∀ x : α, ∃ (s : _), IsCompact s ∧ s ∈ 𝓝 x := by intro x obtain ⟨s, hs, hs'⟩ := exists_compact_mem_nhds x exact ⟨s, hs, hs'⟩ [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝⁵ : TopologicalSpace α inst✝⁴ : TopologicalSpace β inst✝³ : TopologicalSpace γ inst✝² : LocallyCompactSpace α inst✝¹ : T2Space β ι : Type u_4 l : Filter ι inst✝ : Filter.NeBot l F : ι → C(α, β) f : (s : Set α) → IsCompact s → C(↑s, β) hf : ∀ (s : Set α) (hs : IsCompact s), Filter.Tendsto (fun i => restrict s (F i)) l (𝓝 (f s hs)) h : ∀ (s₁ : Set α) (hs₁ : IsCompact s₁) (s₂ : Set α) (hs₂ : IsCompact s₂) (x : α) (hxs₁ : x ∈ s₁) (hxs₂ : x ∈ s₂), ↑(f s₁ hs₁) { val := x, property := hxs₁ } = ↑(f s₂ hs₂) { val := x, property := hxs₂ } ⊢ ∀ (x : α), ∃ s, IsCompact s ∧ s ∈ 𝓝 x [PROOFSTEP] intro x [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝⁵ : TopologicalSpace α inst✝⁴ : TopologicalSpace β inst✝³ : TopologicalSpace γ inst✝² : LocallyCompactSpace α inst✝¹ : T2Space β ι : Type u_4 l : Filter ι inst✝ : Filter.NeBot l F : ι → C(α, β) f : (s : Set α) → IsCompact s → C(↑s, β) hf : ∀ (s : Set α) (hs : IsCompact s), Filter.Tendsto (fun i => restrict s (F i)) l (𝓝 (f s hs)) h : ∀ (s₁ : Set α) (hs₁ : IsCompact s₁) (s₂ : Set α) (hs₂ : IsCompact s₂) (x : α) (hxs₁ : x ∈ s₁) (hxs₂ : x ∈ s₂), ↑(f s₁ hs₁) { val := x, property := hxs₁ } = ↑(f s₂ hs₂) { val := x, property := hxs₂ } x : α ⊢ ∃ s, IsCompact s ∧ s ∈ 𝓝 x [PROOFSTEP] obtain ⟨s, hs, hs'⟩ := exists_compact_mem_nhds x [GOAL] case intro.intro α : Type u_1 β : Type u_2 γ : Type u_3 inst✝⁵ : TopologicalSpace α inst✝⁴ : TopologicalSpace β inst✝³ : TopologicalSpace γ inst✝² : LocallyCompactSpace α inst✝¹ : T2Space β ι : Type u_4 l : Filter ι inst✝ : Filter.NeBot l F : ι → C(α, β) f : (s : Set α) → IsCompact s → C(↑s, β) hf : ∀ (s : Set α) (hs : IsCompact s), Filter.Tendsto (fun i => restrict s (F i)) l (𝓝 (f s hs)) h : ∀ (s₁ : Set α) (hs₁ : IsCompact s₁) (s₂ : Set α) (hs₂ : IsCompact s₂) (x : α) (hxs₁ : x ∈ s₁) (hxs₂ : x ∈ s₂), ↑(f s₁ hs₁) { val := x, property := hxs₁ } = ↑(f s₂ hs₂) { val := x, property := hxs₂ } x : α s : Set α hs : IsCompact s hs' : s ∈ 𝓝 x ⊢ ∃ s, IsCompact s ∧ s ∈ 𝓝 x [PROOFSTEP] exact ⟨s, hs, hs'⟩ [GOAL] case mpr α : Type u_1 β : Type u_2 γ : Type u_3 inst✝⁵ : TopologicalSpace α inst✝⁴ : TopologicalSpace β inst✝³ : TopologicalSpace γ inst✝² : LocallyCompactSpace α inst✝¹ : T2Space β ι : Type u_4 l : Filter ι inst✝ : Filter.NeBot l F : ι → C(α, β) f : (s : Set α) → IsCompact s → C(↑s, β) hf : ∀ (s : Set α) (hs : IsCompact s), Filter.Tendsto (fun i => restrict s (F i)) l (𝓝 (f s hs)) h : ∀ (s₁ : Set α) (hs₁ : IsCompact s₁) (s₂ : Set α) (hs₂ : IsCompact s₂) (x : α) (hxs₁ : x ∈ s₁) (hxs₂ : x ∈ s₂), ↑(f s₁ hs₁) { val := x, property := hxs₁ } = ↑(f s₂ hs₂) { val := x, property := hxs₂ } hs : ∀ (x : α), ∃ s, IsCompact s ∧ s ∈ 𝓝 x ⊢ ∃ f, Filter.Tendsto F l (𝓝 f) [PROOFSTEP] refine ⟨liftCover' _ _ h hs, ?_⟩ [GOAL] case mpr α : Type u_1 β : Type u_2 γ : Type u_3 inst✝⁵ : TopologicalSpace α inst✝⁴ : TopologicalSpace β inst✝³ : TopologicalSpace γ inst✝² : LocallyCompactSpace α inst✝¹ : T2Space β ι : Type u_4 l : Filter ι inst✝ : Filter.NeBot l F : ι → C(α, β) f : (s : Set α) → IsCompact s → C(↑s, β) hf : ∀ (s : Set α) (hs : IsCompact s), Filter.Tendsto (fun i => restrict s (F i)) l (𝓝 (f s hs)) h : ∀ (s₁ : Set α) (hs₁ : IsCompact s₁) (s₂ : Set α) (hs₂ : IsCompact s₂) (x : α) (hxs₁ : x ∈ s₁) (hxs₂ : x ∈ s₂), ↑(f s₁ hs₁) { val := x, property := hxs₁ } = ↑(f s₂ hs₂) { val := x, property := hxs₂ } hs : ∀ (x : α), ∃ s, IsCompact s ∧ s ∈ 𝓝 x ⊢ Filter.Tendsto F l (𝓝 (liftCover' (fun s => ∀ ⦃f : Filter α⦄ [inst : Filter.NeBot f], f ≤ Filter.principal s → ∃ a, a ∈ s ∧ ClusterPt a f) (fun s hs => f s hs) h hs)) [PROOFSTEP] rw [tendsto_compactOpen_iff_forall] [GOAL] case mpr α : Type u_1 β : Type u_2 γ : Type u_3 inst✝⁵ : TopologicalSpace α inst✝⁴ : TopologicalSpace β inst✝³ : TopologicalSpace γ inst✝² : LocallyCompactSpace α inst✝¹ : T2Space β ι : Type u_4 l : Filter ι inst✝ : Filter.NeBot l F : ι → C(α, β) f : (s : Set α) → IsCompact s → C(↑s, β) hf : ∀ (s : Set α) (hs : IsCompact s), Filter.Tendsto (fun i => restrict s (F i)) l (𝓝 (f s hs)) h : ∀ (s₁ : Set α) (hs₁ : IsCompact s₁) (s₂ : Set α) (hs₂ : IsCompact s₂) (x : α) (hxs₁ : x ∈ s₁) (hxs₂ : x ∈ s₂), ↑(f s₁ hs₁) { val := x, property := hxs₁ } = ↑(f s₂ hs₂) { val := x, property := hxs₂ } hs : ∀ (x : α), ∃ s, IsCompact s ∧ s ∈ 𝓝 x ⊢ ∀ (s : Set α), IsCompact s → Filter.Tendsto (fun i => restrict s (F i)) l (𝓝 (restrict s (liftCover' (fun s => ∀ ⦃f : Filter α⦄ [inst : Filter.NeBot f], f ≤ Filter.principal s → ∃ a, a ∈ s ∧ ClusterPt a f) (fun s hs => f s hs) h hs))) [PROOFSTEP] intro s hs [GOAL] case mpr α : Type u_1 β : Type u_2 γ : Type u_3 inst✝⁵ : TopologicalSpace α inst✝⁴ : TopologicalSpace β inst✝³ : TopologicalSpace γ inst✝² : LocallyCompactSpace α inst✝¹ : T2Space β ι : Type u_4 l : Filter ι inst✝ : Filter.NeBot l F : ι → C(α, β) f : (s : Set α) → IsCompact s → C(↑s, β) hf : ∀ (s : Set α) (hs : IsCompact s), Filter.Tendsto (fun i => restrict s (F i)) l (𝓝 (f s hs)) h : ∀ (s₁ : Set α) (hs₁ : IsCompact s₁) (s₂ : Set α) (hs₂ : IsCompact s₂) (x : α) (hxs₁ : x ∈ s₁) (hxs₂ : x ∈ s₂), ↑(f s₁ hs₁) { val := x, property := hxs₁ } = ↑(f s₂ hs₂) { val := x, property := hxs₂ } hs✝ : ∀ (x : α), ∃ s, IsCompact s ∧ s ∈ 𝓝 x s : Set α hs : IsCompact s ⊢ Filter.Tendsto (fun i => restrict s (F i)) l (𝓝 (restrict s (liftCover' (fun s => ∀ ⦃f : Filter α⦄ [inst : Filter.NeBot f], f ≤ Filter.principal s → ∃ a, a ∈ s ∧ ClusterPt a f) (fun s hs => f s hs) h hs✝))) [PROOFSTEP] rw [liftCover_restrict'] [GOAL] case mpr α : Type u_1 β : Type u_2 γ : Type u_3 inst✝⁵ : TopologicalSpace α inst✝⁴ : TopologicalSpace β inst✝³ : TopologicalSpace γ inst✝² : LocallyCompactSpace α inst✝¹ : T2Space β ι : Type u_4 l : Filter ι inst✝ : Filter.NeBot l F : ι → C(α, β) f : (s : Set α) → IsCompact s → C(↑s, β) hf : ∀ (s : Set α) (hs : IsCompact s), Filter.Tendsto (fun i => restrict s (F i)) l (𝓝 (f s hs)) h : ∀ (s₁ : Set α) (hs₁ : IsCompact s₁) (s₂ : Set α) (hs₂ : IsCompact s₂) (x : α) (hxs₁ : x ∈ s₁) (hxs₂ : x ∈ s₂), ↑(f s₁ hs₁) { val := x, property := hxs₁ } = ↑(f s₂ hs₂) { val := x, property := hxs₂ } hs✝ : ∀ (x : α), ∃ s, IsCompact s ∧ s ∈ 𝓝 x s : Set α hs : IsCompact s ⊢ Filter.Tendsto (fun i => restrict s (F i)) l (𝓝 (f s ?m.52935)) α : Type u_1 β : Type u_2 γ : Type u_3 inst✝⁵ : TopologicalSpace α inst✝⁴ : TopologicalSpace β inst✝³ : TopologicalSpace γ inst✝² : LocallyCompactSpace α inst✝¹ : T2Space β ι : Type u_4 l : Filter ι inst✝ : Filter.NeBot l F : ι → C(α, β) f : (s : Set α) → IsCompact s → C(↑s, β) hf : ∀ (s : Set α) (hs : IsCompact s), Filter.Tendsto (fun i => restrict s (F i)) l (𝓝 (f s hs)) h : ∀ (s₁ : Set α) (hs₁ : IsCompact s₁) (s₂ : Set α) (hs₂ : IsCompact s₂) (x : α) (hxs₁ : x ∈ s₁) (hxs₂ : x ∈ s₂), ↑(f s₁ hs₁) { val := x, property := hxs₁ } = ↑(f s₂ hs₂) { val := x, property := hxs₂ } hs✝ : ∀ (x : α), ∃ s, IsCompact s ∧ s ∈ 𝓝 x s : Set α hs : IsCompact s ⊢ s ∈ fun s => ∀ ⦃f : Filter α⦄ [inst : Filter.NeBot f], f ≤ Filter.principal s → ∃ a, a ∈ s ∧ ClusterPt a f [PROOFSTEP] exact hf s hs [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝² : TopologicalSpace α inst✝¹ : TopologicalSpace β inst✝ : TopologicalSpace γ y : β s : Set α ⊢ ↑(coev α β y) '' s = {y} ×ˢ s [PROOFSTEP] aesop [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝² : TopologicalSpace α inst✝¹ : TopologicalSpace β inst✝ : TopologicalSpace γ ⊢ ∀ (s : Set C(α, β × α)), s ∈ {m | ∃ s x u x, m = CompactOpen.gen s u} → IsOpen (coev α β ⁻¹' s) [PROOFSTEP] rintro _ ⟨s, sc, u, uo, rfl⟩ [GOAL] case intro.intro.intro.intro α : Type u_1 β : Type u_2 γ : Type u_3 inst✝² : TopologicalSpace α inst✝¹ : TopologicalSpace β inst✝ : TopologicalSpace γ s : Set α sc : IsCompact s u : Set (β × α) uo : IsOpen u ⊢ IsOpen (coev α β ⁻¹' CompactOpen.gen s u) [PROOFSTEP] rw [isOpen_iff_forall_mem_open] [GOAL] case intro.intro.intro.intro α : Type u_1 β : Type u_2 γ : Type u_3 inst✝² : TopologicalSpace α inst✝¹ : TopologicalSpace β inst✝ : TopologicalSpace γ s : Set α sc : IsCompact s u : Set (β × α) uo : IsOpen u ⊢ ∀ (x : β), x ∈ coev α β ⁻¹' CompactOpen.gen s u → ∃ t, t ⊆ coev α β ⁻¹' CompactOpen.gen s u ∧ IsOpen t ∧ x ∈ t [PROOFSTEP] intro y hy [GOAL] case intro.intro.intro.intro α : Type u_1 β : Type u_2 γ : Type u_3 inst✝² : TopologicalSpace α inst✝¹ : TopologicalSpace β inst✝ : TopologicalSpace γ s : Set α sc : IsCompact s u : Set (β × α) uo : IsOpen u y : β hy : y ∈ coev α β ⁻¹' CompactOpen.gen s u ⊢ ∃ t, t ⊆ coev α β ⁻¹' CompactOpen.gen s u ∧ IsOpen t ∧ y ∈ t [PROOFSTEP] have hy' : (↑(coev α β y) '' s ⊆ u) := hy [GOAL] case intro.intro.intro.intro α : Type u_1 β : Type u_2 γ : Type u_3 inst✝² : TopologicalSpace α inst✝¹ : TopologicalSpace β inst✝ : TopologicalSpace γ s : Set α sc : IsCompact s u : Set (β × α) uo : IsOpen u y : β hy : y ∈ coev α β ⁻¹' CompactOpen.gen s u hy' : ↑(coev α β y) '' s ⊆ u ⊢ ∃ t, t ⊆ coev α β ⁻¹' CompactOpen.gen s u ∧ IsOpen t ∧ y ∈ t [PROOFSTEP] rw [image_coev s] at hy' [GOAL] case intro.intro.intro.intro α : Type u_1 β : Type u_2 γ : Type u_3 inst✝² : TopologicalSpace α inst✝¹ : TopologicalSpace β inst✝ : TopologicalSpace γ s : Set α sc : IsCompact s u : Set (β × α) uo : IsOpen u y : β hy : y ∈ coev α β ⁻¹' CompactOpen.gen s u hy' : {y} ×ˢ s ⊆ u ⊢ ∃ t, t ⊆ coev α β ⁻¹' CompactOpen.gen s u ∧ IsOpen t ∧ y ∈ t [PROOFSTEP] rcases generalized_tube_lemma isCompact_singleton sc uo hy' with ⟨v, w, vo, _, yv, sw, vwu⟩ [GOAL] case intro.intro.intro.intro.intro.intro.intro.intro.intro.intro α : Type u_1 β : Type u_2 γ : Type u_3 inst✝² : TopologicalSpace α inst✝¹ : TopologicalSpace β inst✝ : TopologicalSpace γ s : Set α sc : IsCompact s u : Set (β × α) uo : IsOpen u y : β hy : y ∈ coev α β ⁻¹' CompactOpen.gen s u hy' : {y} ×ˢ s ⊆ u v : Set β w : Set α vo : IsOpen v left✝ : IsOpen w yv : {y} ⊆ v sw : s ⊆ w vwu : v ×ˢ w ⊆ u ⊢ ∃ t, t ⊆ coev α β ⁻¹' CompactOpen.gen s u ∧ IsOpen t ∧ y ∈ t [PROOFSTEP] refine' ⟨v, _, vo, singleton_subset_iff.mp yv⟩ [GOAL] case intro.intro.intro.intro.intro.intro.intro.intro.intro.intro α : Type u_1 β : Type u_2 γ : Type u_3 inst✝² : TopologicalSpace α inst✝¹ : TopologicalSpace β inst✝ : TopologicalSpace γ s : Set α sc : IsCompact s u : Set (β × α) uo : IsOpen u y : β hy : y ∈ coev α β ⁻¹' CompactOpen.gen s u hy' : {y} ×ˢ s ⊆ u v : Set β w : Set α vo : IsOpen v left✝ : IsOpen w yv : {y} ⊆ v sw : s ⊆ w vwu : v ×ˢ w ⊆ u ⊢ v ⊆ coev α β ⁻¹' CompactOpen.gen s u [PROOFSTEP] intro y' hy' [GOAL] case intro.intro.intro.intro.intro.intro.intro.intro.intro.intro α : Type u_1 β : Type u_2 γ : Type u_3 inst✝² : TopologicalSpace α inst✝¹ : TopologicalSpace β inst✝ : TopologicalSpace γ s : Set α sc : IsCompact s u : Set (β × α) uo : IsOpen u y : β hy : y ∈ coev α β ⁻¹' CompactOpen.gen s u hy'✝ : {y} ×ˢ s ⊆ u v : Set β w : Set α vo : IsOpen v left✝ : IsOpen w yv : {y} ⊆ v sw : s ⊆ w vwu : v ×ˢ w ⊆ u y' : β hy' : y' ∈ v ⊢ y' ∈ coev α β ⁻¹' CompactOpen.gen s u [PROOFSTEP] change coev α β y' '' s ⊆ u [GOAL] case intro.intro.intro.intro.intro.intro.intro.intro.intro.intro α : Type u_1 β : Type u_2 γ : Type u_3 inst✝² : TopologicalSpace α inst✝¹ : TopologicalSpace β inst✝ : TopologicalSpace γ s : Set α sc : IsCompact s u : Set (β × α) uo : IsOpen u y : β hy : y ∈ coev α β ⁻¹' CompactOpen.gen s u hy'✝ : {y} ×ˢ s ⊆ u v : Set β w : Set α vo : IsOpen v left✝ : IsOpen w yv : {y} ⊆ v sw : s ⊆ w vwu : v ×ˢ w ⊆ u y' : β hy' : y' ∈ v ⊢ ↑(coev α β y') '' s ⊆ u [PROOFSTEP] rw [image_coev s] [GOAL] case intro.intro.intro.intro.intro.intro.intro.intro.intro.intro α : Type u_1 β : Type u_2 γ : Type u_3 inst✝² : TopologicalSpace α inst✝¹ : TopologicalSpace β inst✝ : TopologicalSpace γ s : Set α sc : IsCompact s u : Set (β × α) uo : IsOpen u y : β hy : y ∈ coev α β ⁻¹' CompactOpen.gen s u hy'✝ : {y} ×ˢ s ⊆ u v : Set β w : Set α vo : IsOpen v left✝ : IsOpen w yv : {y} ⊆ v sw : s ⊆ w vwu : v ×ˢ w ⊆ u y' : β hy' : y' ∈ v ⊢ {y'} ×ˢ s ⊆ u [PROOFSTEP] exact (prod_mono (singleton_subset_iff.mpr hy') sw).trans vwu [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝² : TopologicalSpace α inst✝¹ : TopologicalSpace β inst✝ : TopologicalSpace γ f : C(α × β, γ) ⊢ curry' f = comp f ∘ coev β α [PROOFSTEP] ext [GOAL] case h.h α : Type u_1 β : Type u_2 γ : Type u_3 inst✝² : TopologicalSpace α inst✝¹ : TopologicalSpace β inst✝ : TopologicalSpace γ f : C(α × β, γ) x✝ : α a✝ : β ⊢ ↑(curry' f x✝) a✝ = ↑((comp f ∘ coev β α) x✝) a✝ [PROOFSTEP] rfl [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝³ : TopologicalSpace α inst✝² : TopologicalSpace β inst✝¹ : TopologicalSpace γ inst✝ : LocallyCompactSpace (α × β) ⊢ Continuous curry [PROOFSTEP] apply continuous_of_continuous_uncurry [GOAL] case h α : Type u_1 β : Type u_2 γ : Type u_3 inst✝³ : TopologicalSpace α inst✝² : TopologicalSpace β inst✝¹ : TopologicalSpace γ inst✝ : LocallyCompactSpace (α × β) ⊢ Continuous (Function.uncurry fun x y => ↑(curry x) y) [PROOFSTEP] apply continuous_of_continuous_uncurry [GOAL] case h.h α : Type u_1 β : Type u_2 γ : Type u_3 inst✝³ : TopologicalSpace α inst✝² : TopologicalSpace β inst✝¹ : TopologicalSpace γ inst✝ : LocallyCompactSpace (α × β) ⊢ Continuous (Function.uncurry fun x y => ↑(Function.uncurry (fun x y => ↑(curry x) y) x) y) [PROOFSTEP] rw [← (Homeomorph.prodAssoc _ _ _).symm.comp_continuous_iff'] [GOAL] case h.h α : Type u_1 β : Type u_2 γ : Type u_3 inst✝³ : TopologicalSpace α inst✝² : TopologicalSpace β inst✝¹ : TopologicalSpace γ inst✝ : LocallyCompactSpace (α × β) ⊢ Continuous ((Function.uncurry fun x y => ↑(Function.uncurry (fun x y => ↑(curry x) y) x) y) ∘ ↑(Homeomorph.symm (Homeomorph.prodAssoc C(α × β, γ) α β))) [PROOFSTEP] exact continuous_eval' [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝⁴ : TopologicalSpace α inst✝³ : TopologicalSpace β inst✝² : TopologicalSpace γ inst✝¹ : LocallyCompactSpace α inst✝ : LocallyCompactSpace β ⊢ Continuous uncurry [PROOFSTEP] apply continuous_of_continuous_uncurry [GOAL] case h α : Type u_1 β : Type u_2 γ : Type u_3 inst✝⁴ : TopologicalSpace α inst✝³ : TopologicalSpace β inst✝² : TopologicalSpace γ inst✝¹ : LocallyCompactSpace α inst✝ : LocallyCompactSpace β ⊢ Continuous (Function.uncurry fun x y => ↑(uncurry x) y) [PROOFSTEP] rw [← (Homeomorph.prodAssoc _ _ _).comp_continuous_iff'] [GOAL] case h α : Type u_1 β : Type u_2 γ : Type u_3 inst✝⁴ : TopologicalSpace α inst✝³ : TopologicalSpace β inst✝² : TopologicalSpace γ inst✝¹ : LocallyCompactSpace α inst✝ : LocallyCompactSpace β ⊢ Continuous ((Function.uncurry fun x y => ↑(uncurry x) y) ∘ ↑(Homeomorph.prodAssoc C(α, C(β, γ)) α β)) [PROOFSTEP] apply continuous_eval'.comp (continuous_eval'.prod_map continuous_id) [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝⁴ : TopologicalSpace α inst✝³ : TopologicalSpace β inst✝² : TopologicalSpace γ inst✝¹ : LocallyCompactSpace α inst✝ : LocallyCompactSpace β ⊢ Function.LeftInverse uncurry ContinuousMap.curry [PROOFSTEP] intro [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝⁴ : TopologicalSpace α inst✝³ : TopologicalSpace β inst✝² : TopologicalSpace γ inst✝¹ : LocallyCompactSpace α inst✝ : LocallyCompactSpace β x✝ : C(α × β, γ) ⊢ uncurry (ContinuousMap.curry x✝) = x✝ [PROOFSTEP] ext [GOAL] case h α : Type u_1 β : Type u_2 γ : Type u_3 inst✝⁴ : TopologicalSpace α inst✝³ : TopologicalSpace β inst✝² : TopologicalSpace γ inst✝¹ : LocallyCompactSpace α inst✝ : LocallyCompactSpace β x✝ : C(α × β, γ) a✝ : α × β ⊢ ↑(uncurry (ContinuousMap.curry x✝)) a✝ = ↑x✝ a✝ [PROOFSTEP] rfl [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝⁴ : TopologicalSpace α inst✝³ : TopologicalSpace β inst✝² : TopologicalSpace γ inst✝¹ : LocallyCompactSpace α inst✝ : LocallyCompactSpace β ⊢ Function.RightInverse uncurry ContinuousMap.curry [PROOFSTEP] intro [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝⁴ : TopologicalSpace α inst✝³ : TopologicalSpace β inst✝² : TopologicalSpace γ inst✝¹ : LocallyCompactSpace α inst✝ : LocallyCompactSpace β x✝ : C(α, C(β, γ)) ⊢ ContinuousMap.curry (uncurry x✝) = x✝ [PROOFSTEP] ext [GOAL] case h.h α : Type u_1 β : Type u_2 γ : Type u_3 inst✝⁴ : TopologicalSpace α inst✝³ : TopologicalSpace β inst✝² : TopologicalSpace γ inst✝¹ : LocallyCompactSpace α inst✝ : LocallyCompactSpace β x✝ : C(α, C(β, γ)) a✝¹ : α a✝ : β ⊢ ↑(↑(ContinuousMap.curry (uncurry x✝)) a✝¹) a✝ = ↑(↑x✝ a✝¹) a✝ [PROOFSTEP] rfl [GOAL] α : Type u_1 β : Type u_2 γ : Type u_3 inst✝³ : TopologicalSpace α inst✝² : TopologicalSpace β inst✝¹ : TopologicalSpace γ inst✝ : Unique α f : C(α, β) ⊢ const α ((fun f => ↑f default) f) = f [PROOFSTEP] ext a [GOAL] case h α : Type u_1 β : Type u_2 γ : Type u_3 inst✝³ : TopologicalSpace α inst✝² : TopologicalSpace β inst✝¹ : TopologicalSpace γ inst✝ : Unique α f : C(α, β) a : α ⊢ ↑(const α ((fun f => ↑f default) f)) a = ↑f a [PROOFSTEP] rw [Unique.eq_default a] [GOAL] case h α : Type u_1 β : Type u_2 γ : Type u_3 inst✝³ : TopologicalSpace α inst✝² : TopologicalSpace β inst✝¹ : TopologicalSpace γ inst✝ : Unique α f : C(α, β) a : α ⊢ ↑(const α ((fun f => ↑f default) f)) default = ↑f default [PROOFSTEP] rfl [GOAL] X₀ : Type u_1 X : Type u_2 Y : Type u_3 Z : Type u_4 inst✝⁴ : TopologicalSpace X₀ inst✝³ : TopologicalSpace X inst✝² : TopologicalSpace Y inst✝¹ : TopologicalSpace Z inst✝ : LocallyCompactSpace Y f : X₀ → X hf : QuotientMap f g : X × Y → Z hg : Continuous fun p => g (f p.fst, p.snd) ⊢ Continuous g [PROOFSTEP] let Gf : C(X₀, C(Y, Z)) := ContinuousMap.curry ⟨_, hg⟩ [GOAL] X₀ : Type u_1 X : Type u_2 Y : Type u_3 Z : Type u_4 inst✝⁴ : TopologicalSpace X₀ inst✝³ : TopologicalSpace X inst✝² : TopologicalSpace Y inst✝¹ : TopologicalSpace Z inst✝ : LocallyCompactSpace Y f : X₀ → X hf : QuotientMap f g : X × Y → Z hg : Continuous fun p => g (f p.fst, p.snd) Gf : C(X₀, C(Y, Z)) := curry (mk fun p => g (f p.fst, p.snd)) ⊢ Continuous g [PROOFSTEP] have h : ∀ x : X, Continuous fun y => g (x, y) := by intro x obtain ⟨x₀, rfl⟩ := hf.surjective x exact (Gf x₀).continuous [GOAL] X₀ : Type u_1 X : Type u_2 Y : Type u_3 Z : Type u_4 inst✝⁴ : TopologicalSpace X₀ inst✝³ : TopologicalSpace X inst✝² : TopologicalSpace Y inst✝¹ : TopologicalSpace Z inst✝ : LocallyCompactSpace Y f : X₀ → X hf : QuotientMap f g : X × Y → Z hg : Continuous fun p => g (f p.fst, p.snd) Gf : C(X₀, C(Y, Z)) := curry (mk fun p => g (f p.fst, p.snd)) ⊢ ∀ (x : X), Continuous fun y => g (x, y) [PROOFSTEP] intro x [GOAL] X₀ : Type u_1 X : Type u_2 Y : Type u_3 Z : Type u_4 inst✝⁴ : TopologicalSpace X₀ inst✝³ : TopologicalSpace X inst✝² : TopologicalSpace Y inst✝¹ : TopologicalSpace Z inst✝ : LocallyCompactSpace Y f : X₀ → X hf : QuotientMap f g : X × Y → Z hg : Continuous fun p => g (f p.fst, p.snd) Gf : C(X₀, C(Y, Z)) := curry (mk fun p => g (f p.fst, p.snd)) x : X ⊢ Continuous fun y => g (x, y) [PROOFSTEP] obtain ⟨x₀, rfl⟩ := hf.surjective x [GOAL] case intro X₀ : Type u_1 X : Type u_2 Y : Type u_3 Z : Type u_4 inst✝⁴ : TopologicalSpace X₀ inst✝³ : TopologicalSpace X inst✝² : TopologicalSpace Y inst✝¹ : TopologicalSpace Z inst✝ : LocallyCompactSpace Y f : X₀ → X hf : QuotientMap f g : X × Y → Z hg : Continuous fun p => g (f p.fst, p.snd) Gf : C(X₀, C(Y, Z)) := curry (mk fun p => g (f p.fst, p.snd)) x₀ : X₀ ⊢ Continuous fun y => g (f x₀, y) [PROOFSTEP] exact (Gf x₀).continuous [GOAL] X₀ : Type u_1 X : Type u_2 Y : Type u_3 Z : Type u_4 inst✝⁴ : TopologicalSpace X₀ inst✝³ : TopologicalSpace X inst✝² : TopologicalSpace Y inst✝¹ : TopologicalSpace Z inst✝ : LocallyCompactSpace Y f : X₀ → X hf : QuotientMap f g : X × Y → Z hg : Continuous fun p => g (f p.fst, p.snd) Gf : C(X₀, C(Y, Z)) := curry (mk fun p => g (f p.fst, p.snd)) h : ∀ (x : X), Continuous fun y => g (x, y) ⊢ Continuous g [PROOFSTEP] let G : X → C(Y, Z) := fun x => ⟨_, h x⟩ [GOAL] X₀ : Type u_1 X : Type u_2 Y : Type u_3 Z : Type u_4 inst✝⁴ : TopologicalSpace X₀ inst✝³ : TopologicalSpace X inst✝² : TopologicalSpace Y inst✝¹ : TopologicalSpace Z inst✝ : LocallyCompactSpace Y f : X₀ → X hf : QuotientMap f g : X × Y → Z hg : Continuous fun p => g (f p.fst, p.snd) Gf : C(X₀, C(Y, Z)) := curry (mk fun p => g (f p.fst, p.snd)) h : ∀ (x : X), Continuous fun y => g (x, y) G : X → C(Y, Z) := fun x => mk fun y => g (x, y) ⊢ Continuous g [PROOFSTEP] have : Continuous G := by rw [hf.continuous_iff] exact Gf.continuous [GOAL] X₀ : Type u_1 X : Type u_2 Y : Type u_3 Z : Type u_4 inst✝⁴ : TopologicalSpace X₀ inst✝³ : TopologicalSpace X inst✝² : TopologicalSpace Y inst✝¹ : TopologicalSpace Z inst✝ : LocallyCompactSpace Y f : X₀ → X hf : QuotientMap f g : X × Y → Z hg : Continuous fun p => g (f p.fst, p.snd) Gf : C(X₀, C(Y, Z)) := curry (mk fun p => g (f p.fst, p.snd)) h : ∀ (x : X), Continuous fun y => g (x, y) G : X → C(Y, Z) := fun x => mk fun y => g (x, y) ⊢ Continuous G [PROOFSTEP] rw [hf.continuous_iff] [GOAL] X₀ : Type u_1 X : Type u_2 Y : Type u_3 Z : Type u_4 inst✝⁴ : TopologicalSpace X₀ inst✝³ : TopologicalSpace X inst✝² : TopologicalSpace Y inst✝¹ : TopologicalSpace Z inst✝ : LocallyCompactSpace Y f : X₀ → X hf : QuotientMap f g : X × Y → Z hg : Continuous fun p => g (f p.fst, p.snd) Gf : C(X₀, C(Y, Z)) := curry (mk fun p => g (f p.fst, p.snd)) h : ∀ (x : X), Continuous fun y => g (x, y) G : X → C(Y, Z) := fun x => mk fun y => g (x, y) ⊢ Continuous (G ∘ f) [PROOFSTEP] exact Gf.continuous [GOAL] X₀ : Type u_1 X : Type u_2 Y : Type u_3 Z : Type u_4 inst✝⁴ : TopologicalSpace X₀ inst✝³ : TopologicalSpace X inst✝² : TopologicalSpace Y inst✝¹ : TopologicalSpace Z inst✝ : LocallyCompactSpace Y f : X₀ → X hf : QuotientMap f g : X × Y → Z hg : Continuous fun p => g (f p.fst, p.snd) Gf : C(X₀, C(Y, Z)) := curry (mk fun p => g (f p.fst, p.snd)) h : ∀ (x : X), Continuous fun y => g (x, y) G : X → C(Y, Z) := fun x => mk fun y => g (x, y) this : Continuous G ⊢ Continuous g [PROOFSTEP] exact ContinuousMap.continuous_uncurry_of_continuous ⟨G, this⟩ [GOAL] X₀ : Type u_1 X : Type u_2 Y : Type u_3 Z : Type u_4 inst✝⁴ : TopologicalSpace X₀ inst✝³ : TopologicalSpace X inst✝² : TopologicalSpace Y inst✝¹ : TopologicalSpace Z inst✝ : LocallyCompactSpace Y f : X₀ → X hf : QuotientMap f g : Y × X → Z hg : Continuous fun p => g (p.fst, f p.snd) ⊢ Continuous g [PROOFSTEP] have : Continuous fun p : X₀ × Y => g ((Prod.swap p).1, f (Prod.swap p).2) := hg.comp continuous_swap [GOAL] X₀ : Type u_1 X : Type u_2 Y : Type u_3 Z : Type u_4 inst✝⁴ : TopologicalSpace X₀ inst✝³ : TopologicalSpace X inst✝² : TopologicalSpace Y inst✝¹ : TopologicalSpace Z inst✝ : LocallyCompactSpace Y f : X₀ → X hf : QuotientMap f g : Y × X → Z hg : Continuous fun p => g (p.fst, f p.snd) this : Continuous fun p => g ((Prod.swap p).fst, f (Prod.swap p).snd) ⊢ Continuous g [PROOFSTEP] have : Continuous fun p : X₀ × Y => (g ∘ Prod.swap) (f p.1, p.2) := this [GOAL] X₀ : Type u_1 X : Type u_2 Y : Type u_3 Z : Type u_4 inst✝⁴ : TopologicalSpace X₀ inst✝³ : TopologicalSpace X inst✝² : TopologicalSpace Y inst✝¹ : TopologicalSpace Z inst✝ : LocallyCompactSpace Y f : X₀ → X hf : QuotientMap f g : Y × X → Z hg : Continuous fun p => g (p.fst, f p.snd) this✝ : Continuous fun p => g ((Prod.swap p).fst, f (Prod.swap p).snd) this : Continuous fun p => (g ∘ Prod.swap) (f p.fst, p.snd) ⊢ Continuous g [PROOFSTEP] exact (hf.continuous_lift_prod_left this).comp continuous_swap
lemma in_bigo_zero_iff [simp]: "f \<in> O[F](\<lambda>_. 0) \<longleftrightarrow> eventually (\<lambda>x. f x = 0) F"
From mathcomp Require Import ssreflect ssrfun eqtype seq ssrint. From CoqUtils Require Import fmap fset word. Require Extraction. Require extraction.ExtrOcamlString. Require Import Intermediate.Machine. Require Import Common.Definitions. Require Import MicroPolicies.Instance. Require Import MicroPolicies.Printer. Require Import I2MP.Encode. Require Import I2MP.Linearize. Require Import MicroPolicies.Utils. Import DoNotation. Definition test_program : Intermediate.program := let c0 := [fmap (0, [:: ICall 1 0; IReturn])] in let c0_i := Component.mkCompInterface fset0 (fset [:: (1, 0)]) in let c1 := [fmap (0, [:: IConst (IInt 5) R_COM; IReturn])] in let c1_i := Component.mkCompInterface (fset [:: 0]) fset0 in Intermediate.mkProg [fmap (0, c0_i); (1, c1_i)] (* Interface: nothing imported/exported*) [fmap (0, c0); (1, c1)] (* code *) (emptym) (* Pre-allocated buffers *) (Some 0). (* Main procedure idtac *) Definition test_alloc : Intermediate.program := let c0 := [fmap (0, [:: IConst (IInt 5) R_ONE ; IAlloc R_COM R_ONE; IReturn])] in let c0_i := Component.mkCompInterface fset0 fset0 in Intermediate.mkProg emptym (* Interface: nothing imported/exported*) [fmap (0, c0)] (* code *) (emptym) (* Pre-allocated buffers *) (Some 0). (* Main procedure idtac *) Definition test_program_machine := load (encode (linearize test_program)). Definition test_alloc_machine := load (encode (linearize test_alloc)). Extraction "/tmp/tl_test.ml" coqstring_of_state test_program_machine test_alloc_machine stepf.
If $f$ is a function from sets to a commutative monoid with identity $0$, then $\sum_{n=0}^\infty f(A \cup B^n) = f(A) + f(B)$.
Formal statement is: lemma measurable_Max_nat[measurable (raw)]: fixes P :: "nat \<Rightarrow> 'a \<Rightarrow> bool" assumes [measurable]: "\<And>i. Measurable.pred M (P i)" shows "(\<lambda>x. Max {i. P i x}) \<in> measurable M (count_space UNIV)" Informal statement is: If $P_i$ is a measurable predicate for each $i$, then the function $x \mapsto \max\{i \mid P_i(x)\}$ is measurable.
------------------------------------------------------------------------ -- INCREMENTAL λ-CALCULUS -- -- Delta-observational equivalence - support for equational reasoning ------------------------------------------------------------------------ module Base.Change.Equivalence.EqReasoning where open import Relation.Binary.PropositionalEquality open import Base.Change.Algebra open import Level open import Data.Unit open import Function open import Base.Change.Equivalence.Base public module _ {a} {A : Set a} {{ca : ChangeAlgebra A}} {x : A} where ------------------------------------------------------------------------ -- Convenient syntax for equational reasoning import Relation.Binary.EqReasoning as EqR module ≙-Reasoning where open EqR (≙-setoid {x = x}) public renaming (_≈⟨_⟩_ to _≙⟨_⟩_)
[STATEMENT] lemma SN_on_weakening: assumes "SN_on R1 A" shows "SN_on (R1 \<inter> R2) A" [PROOF STATE] proof (prove) goal (1 subgoal): 1. SN_on (R1 \<inter> R2) A [PROOF STEP] proof - [PROOF STATE] proof (state) goal (1 subgoal): 1. SN_on (R1 \<inter> R2) A [PROOF STEP] { [PROOF STATE] proof (state) goal (1 subgoal): 1. SN_on (R1 \<inter> R2) A [PROOF STEP] assume "\<exists>S. S 0 \<in> A \<and> chain (R1 \<inter> R2) S" [PROOF STATE] proof (state) this: \<exists>S. S 0 \<in> A \<and> (\<forall>i. (S i, S (Suc i)) \<in> R1 \<inter> R2) goal (1 subgoal): 1. SN_on (R1 \<inter> R2) A [PROOF STEP] then [PROOF STATE] proof (chain) picking this: \<exists>S. S 0 \<in> A \<and> (\<forall>i. (S i, S (Suc i)) \<in> R1 \<inter> R2) [PROOF STEP] obtain S where S0: "S 0 \<in> A" and SN: "chain (R1 \<inter> R2) S" [PROOF STATE] proof (prove) using this: \<exists>S. S 0 \<in> A \<and> (\<forall>i. (S i, S (Suc i)) \<in> R1 \<inter> R2) goal (1 subgoal): 1. (\<And>S. \<lbrakk>S 0 \<in> A; \<forall>i. (S i, S (Suc i)) \<in> R1 \<inter> R2\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis [PROOF STEP] by auto [PROOF STATE] proof (state) this: S 0 \<in> A \<forall>i. (S i, S (Suc i)) \<in> R1 \<inter> R2 goal (1 subgoal): 1. SN_on (R1 \<inter> R2) A [PROOF STEP] from SN [PROOF STATE] proof (chain) picking this: \<forall>i. (S i, S (Suc i)) \<in> R1 \<inter> R2 [PROOF STEP] have SN': "chain R1 S" [PROOF STATE] proof (prove) using this: \<forall>i. (S i, S (Suc i)) \<in> R1 \<inter> R2 goal (1 subgoal): 1. \<forall>i. (S i, S (Suc i)) \<in> R1 [PROOF STEP] by simp [PROOF STATE] proof (state) this: \<forall>i. (S i, S (Suc i)) \<in> R1 goal (1 subgoal): 1. SN_on (R1 \<inter> R2) A [PROOF STEP] with S0 and assms [PROOF STATE] proof (chain) picking this: S 0 \<in> A SN_on R1 A \<forall>i. (S i, S (Suc i)) \<in> R1 [PROOF STEP] have "False" [PROOF STATE] proof (prove) using this: S 0 \<in> A SN_on R1 A \<forall>i. (S i, S (Suc i)) \<in> R1 goal (1 subgoal): 1. False [PROOF STEP] by auto [PROOF STATE] proof (state) this: False goal (1 subgoal): 1. SN_on (R1 \<inter> R2) A [PROOF STEP] } [PROOF STATE] proof (state) this: \<exists>S. S 0 \<in> A \<and> (\<forall>i. (S i, S (Suc i)) \<in> R1 \<inter> R2) \<Longrightarrow> False goal (1 subgoal): 1. SN_on (R1 \<inter> R2) A [PROOF STEP] then [PROOF STATE] proof (chain) picking this: \<exists>S. S 0 \<in> A \<and> (\<forall>i. (S i, S (Suc i)) \<in> R1 \<inter> R2) \<Longrightarrow> False [PROOF STEP] show ?thesis [PROOF STATE] proof (prove) using this: \<exists>S. S 0 \<in> A \<and> (\<forall>i. (S i, S (Suc i)) \<in> R1 \<inter> R2) \<Longrightarrow> False goal (1 subgoal): 1. SN_on (R1 \<inter> R2) A [PROOF STEP] by force [PROOF STATE] proof (state) this: SN_on (R1 \<inter> R2) A goal: No subgoals! [PROOF STEP] qed
/- Copyright (c) 2019 Mario Carneiro. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mario Carneiro, Scott Morrison ! This file was ported from Lean 3 source module set_theory.surreal.basic ! leanprover-community/mathlib commit ee02a30e209a2a77b93eac1254e8c66e76192f54 ! Please do not edit these lines, except to modify the commit id ! if you have ported upstream changes. -/ import Mathbin.Algebra.Order.Hom.Monoid import Mathbin.SetTheory.Game.Ordinal /-! # Surreal numbers The basic theory of surreal numbers, built on top of the theory of combinatorial (pre-)games. A pregame is `numeric` if all the Left options are strictly smaller than all the Right options, and all those options are themselves numeric. In terms of combinatorial games, the numeric games have "frozen"; you can only make your position worse by playing, and Left is some definite "number" of moves ahead (or behind) Right. A surreal number is an equivalence class of numeric pregames. In fact, the surreals form a complete ordered field, containing a copy of the reals (and much else besides!) but we do not yet have a complete development. ## Order properties Surreal numbers inherit the relations `≤` and `<` from games (`surreal.has_le` and `surreal.has_lt`), and these relations satisfy the axioms of a partial order. ## Algebraic operations We show that the surreals form a linear ordered commutative group. One can also map all the ordinals into the surreals! ### Multiplication of surreal numbers The proof that multiplication lifts to surreal numbers is surprisingly difficult and is currently missing in the library. A sample proof can be found in Theorem 3.8 in the second reference below. The difficulty lies in the length of the proof and the number of theorems that need to proven simultaneously. This will make for a fun and challenging project. The branch `surreal_mul` contains some progress on this proof. ### Todo - Define the field structure on the surreals. ## References * [Conway, *On numbers and games*][conway2001] * [Schleicher, Stoll, *An introduction to Conway's games and numbers*][schleicher_stoll] -/ universe u open Pgame namespace Pgame /-- A pre-game is numeric if everything in the L set is less than everything in the R set, and all the elements of L and R are also numeric. -/ def Numeric : Pgame → Prop | ⟨l, r, L, R⟩ => (∀ i j, L i < R j) ∧ (∀ i, numeric (L i)) ∧ ∀ j, numeric (R j) #align pgame.numeric Pgame.Numeric theorem numeric_def {x : Pgame} : Numeric x ↔ (∀ i j, x.moveLeft i < x.moveRight j) ∧ (∀ i, Numeric (x.moveLeft i)) ∧ ∀ j, Numeric (x.moveRight j) := by cases x rfl #align pgame.numeric_def Pgame.numeric_def namespace Numeric theorem mk {x : Pgame} (h₁ : ∀ i j, x.moveLeft i < x.moveRight j) (h₂ : ∀ i, Numeric (x.moveLeft i)) (h₃ : ∀ j, Numeric (x.moveRight j)) : Numeric x := numeric_def.2 ⟨h₁, h₂, h₃⟩ #align pgame.numeric.mk Pgame.Numeric.mk theorem left_lt_right {x : Pgame} (o : Numeric x) (i : x.LeftMoves) (j : x.RightMoves) : x.moveLeft i < x.moveRight j := by cases x exact o.1 i j #align pgame.numeric.left_lt_right Pgame.Numeric.left_lt_right theorem moveLeft {x : Pgame} (o : Numeric x) (i : x.LeftMoves) : Numeric (x.moveLeft i) := by cases x exact o.2.1 i #align pgame.numeric.move_left Pgame.Numeric.moveLeft theorem moveRight {x : Pgame} (o : Numeric x) (j : x.RightMoves) : Numeric (x.moveRight j) := by cases x exact o.2.2 j #align pgame.numeric.move_right Pgame.Numeric.moveRight end Numeric @[elab_as_elim] theorem numeric_rec {C : Pgame → Prop} (H : ∀ (l r) (L : l → Pgame) (R : r → Pgame), (∀ i j, L i < R j) → (∀ i, Numeric (L i)) → (∀ i, Numeric (R i)) → (∀ i, C (L i)) → (∀ i, C (R i)) → C ⟨l, r, L, R⟩) : ∀ x, Numeric x → C x | ⟨l, r, L, R⟩, ⟨h, hl, hr⟩ => H _ _ _ _ h hl hr (fun i => numeric_rec _ (hl i)) fun i => numeric_rec _ (hr i) #align pgame.numeric_rec Pgame.numeric_rec theorem Relabelling.numeric_imp {x y : Pgame} (r : x ≡r y) (ox : Numeric x) : Numeric y := by induction' x using Pgame.moveRecOn with x IHl IHr generalizing y apply numeric.mk (fun i j => _) (fun i => _) fun j => _ · rw [← lt_congr (r.move_left_symm i).Equiv (r.move_right_symm j).Equiv] apply ox.left_lt_right · exact IHl _ (ox.move_left _) (r.move_left_symm i) · exact IHr _ (ox.move_right _) (r.move_right_symm j) #align pgame.relabelling.numeric_imp Pgame.Relabelling.numeric_imp /-- Relabellings preserve being numeric. -/ theorem Relabelling.numeric_congr {x y : Pgame} (r : x ≡r y) : Numeric x ↔ Numeric y := ⟨r.numeric_imp, r.symm.numeric_imp⟩ #align pgame.relabelling.numeric_congr Pgame.Relabelling.numeric_congr theorem lf_asymm {x y : Pgame} (ox : Numeric x) (oy : Numeric y) : x ⧏ y → ¬y ⧏ x := by refine' numeric_rec (fun xl xr xL xR hx oxl oxr IHxl IHxr => _) x ox y oy refine' numeric_rec fun yl yr yL yR hy oyl oyr IHyl IHyr => _ rw [mk_lf_mk, mk_lf_mk]; rintro (⟨i, h₁⟩ | ⟨j, h₁⟩) (⟨i, h₂⟩ | ⟨j, h₂⟩) · exact IHxl _ _ (oyl _) (h₁.move_left_lf _) (h₂.move_left_lf _) · exact (le_trans h₂ h₁).not_gf (lf_of_lt (hy _ _)) · exact (le_trans h₁ h₂).not_gf (lf_of_lt (hx _ _)) · exact IHxr _ _ (oyr _) (h₁.lf_move_right _) (h₂.lf_move_right _) #align pgame.lf_asymm Pgame.lf_asymm theorem le_of_lf {x y : Pgame} (h : x ⧏ y) (ox : Numeric x) (oy : Numeric y) : x ≤ y := not_lf.1 (lf_asymm ox oy h) #align pgame.le_of_lf Pgame.le_of_lf alias le_of_lf ← lf.le #align pgame.lf.le Pgame.Lf.le theorem lt_of_lf {x y : Pgame} (h : x ⧏ y) (ox : Numeric x) (oy : Numeric y) : x < y := (lt_or_fuzzy_of_lf h).resolve_right (not_fuzzy_of_le (h.le ox oy)) #align pgame.lt_of_lf Pgame.lt_of_lf alias lt_of_lf ← lf.lt #align pgame.lf.lt Pgame.Lf.lt theorem lf_iff_lt {x y : Pgame} (ox : Numeric x) (oy : Numeric y) : x ⧏ y ↔ x < y := ⟨fun h => h.lt ox oy, lf_of_lt⟩ #align pgame.lf_iff_lt Pgame.lf_iff_lt /-- Definition of `x ≤ y` on numeric pre-games, in terms of `<` -/ theorem le_iff_forall_lt {x y : Pgame} (ox : x.Numeric) (oy : y.Numeric) : x ≤ y ↔ (∀ i, x.moveLeft i < y) ∧ ∀ j, x < y.moveRight j := by refine' le_iff_forall_lf.trans (and_congr _ _) <;> refine' forall_congr' fun i => lf_iff_lt _ _ <;> apply_rules [numeric.move_left, numeric.move_right] #align pgame.le_iff_forall_lt Pgame.le_iff_forall_lt /-- Definition of `x < y` on numeric pre-games, in terms of `≤` -/ theorem lt_iff_exists_le {x y : Pgame} (ox : x.Numeric) (oy : y.Numeric) : x < y ↔ (∃ i, x ≤ y.moveLeft i) ∨ ∃ j, x.moveRight j ≤ y := by rw [← lf_iff_lt ox oy, lf_iff_exists_le] #align pgame.lt_iff_exists_le Pgame.lt_iff_exists_le theorem lt_of_exists_le {x y : Pgame} (ox : x.Numeric) (oy : y.Numeric) : ((∃ i, x ≤ y.moveLeft i) ∨ ∃ j, x.moveRight j ≤ y) → x < y := (lt_iff_exists_le ox oy).2 #align pgame.lt_of_exists_le Pgame.lt_of_exists_le /-- The definition of `x < y` on numeric pre-games, in terms of `<` two moves later. -/ theorem lt_def {x y : Pgame} (ox : x.Numeric) (oy : y.Numeric) : x < y ↔ (∃ i, (∀ i', x.moveLeft i' < y.moveLeft i) ∧ ∀ j, x < (y.moveLeft i).moveRight j) ∨ ∃ j, (∀ i, (x.moveRight j).moveLeft i < y) ∧ ∀ j', x.moveRight j < y.moveRight j' := by rw [← lf_iff_lt ox oy, lf_def] refine' or_congr _ _ <;> refine' exists_congr fun x_1 => _ <;> refine' and_congr _ _ <;> refine' forall_congr' fun i => lf_iff_lt _ _ <;> apply_rules [numeric.move_left, numeric.move_right] #align pgame.lt_def Pgame.lt_def theorem not_fuzzy {x y : Pgame} (ox : Numeric x) (oy : Numeric y) : ¬Fuzzy x y := fun h => not_lf.2 ((lf_of_fuzzy h).le ox oy) h.2 #align pgame.not_fuzzy Pgame.not_fuzzy theorem lt_or_equiv_or_gt {x y : Pgame} (ox : Numeric x) (oy : Numeric y) : x < y ∨ (x ≈ y) ∨ y < x := ((lf_or_equiv_or_gf x y).imp fun h => h.lt ox oy) <| Or.imp_right fun h => h.lt oy ox #align pgame.lt_or_equiv_or_gt Pgame.lt_or_equiv_or_gt theorem numeric_of_isEmpty (x : Pgame) [IsEmpty x.LeftMoves] [IsEmpty x.RightMoves] : Numeric x := Numeric.mk isEmptyElim isEmptyElim isEmptyElim #align pgame.numeric_of_is_empty Pgame.numeric_of_isEmpty theorem numeric_of_isEmpty_leftMoves (x : Pgame) [IsEmpty x.LeftMoves] : (∀ j, Numeric (x.moveRight j)) → Numeric x := Numeric.mk isEmptyElim isEmptyElim #align pgame.numeric_of_is_empty_left_moves Pgame.numeric_of_isEmpty_leftMoves theorem numeric_of_isEmpty_rightMoves (x : Pgame) [IsEmpty x.RightMoves] (H : ∀ i, Numeric (x.moveLeft i)) : Numeric x := Numeric.mk (fun _ => isEmptyElim) H isEmptyElim #align pgame.numeric_of_is_empty_right_moves Pgame.numeric_of_isEmpty_rightMoves theorem numeric_zero : Numeric 0 := numeric_of_isEmpty 0 #align pgame.numeric_zero Pgame.numeric_zero theorem numeric_one : Numeric 1 := numeric_of_isEmpty_rightMoves 1 fun _ => numeric_zero #align pgame.numeric_one Pgame.numeric_one theorem Numeric.neg : ∀ {x : Pgame} (o : Numeric x), Numeric (-x) | ⟨l, r, L, R⟩, o => ⟨fun j i => neg_lt_neg_iff.2 (o.1 i j), fun j => (o.2.2 j).neg, fun i => (o.2.1 i).neg⟩ #align pgame.numeric.neg Pgame.Numeric.neg namespace Numeric theorem moveLeft_lt {x : Pgame} (o : Numeric x) (i) : x.moveLeft i < x := (moveLeft_lf i).lt (o.moveLeft i) o #align pgame.numeric.move_left_lt Pgame.Numeric.moveLeft_lt theorem moveLeft_le {x : Pgame} (o : Numeric x) (i) : x.moveLeft i ≤ x := (o.moveLeft_lt i).le #align pgame.numeric.move_left_le Pgame.Numeric.moveLeft_le theorem lt_moveRight {x : Pgame} (o : Numeric x) (j) : x < x.moveRight j := (lf_moveRight j).lt o (o.moveRight j) #align pgame.numeric.lt_move_right Pgame.Numeric.lt_moveRight theorem le_moveRight {x : Pgame} (o : Numeric x) (j) : x ≤ x.moveRight j := (o.lt_moveRight j).le #align pgame.numeric.le_move_right Pgame.Numeric.le_moveRight theorem add : ∀ {x y : Pgame} (ox : Numeric x) (oy : Numeric y), Numeric (x + y) | ⟨xl, xr, xL, xR⟩, ⟨yl, yr, yL, yR⟩, ox, oy => ⟨by rintro (ix | iy) (jx | jy) · exact add_lt_add_right (ox.1 ix jx) _ · exact (add_lf_add_of_lf_of_le (lf_mk _ _ ix) (oy.le_move_right jy)).lt ((ox.move_left ix).add oy) (ox.add (oy.move_right jy)) · exact (add_lf_add_of_lf_of_le (mk_lf _ _ jx) (oy.move_left_le iy)).lt (ox.add (oy.move_left iy)) ((ox.move_right jx).add oy) · exact add_lt_add_left (oy.1 iy jy) ⟨xl, xr, xL, xR⟩, by constructor · rintro (ix | iy) · exact (ox.move_left ix).add oy · exact ox.add (oy.move_left iy) · rintro (jx | jy) · apply (ox.move_right jx).add oy · apply ox.add (oy.move_right jy)⟩decreasing_by pgame_wf_tac #align pgame.numeric.add Pgame.Numeric.add theorem sub {x y : Pgame} (ox : Numeric x) (oy : Numeric y) : Numeric (x - y) := ox.add oy.neg #align pgame.numeric.sub Pgame.Numeric.sub end Numeric /-- Pre-games defined by natural numbers are numeric. -/ theorem numeric_nat : ∀ n : ℕ, Numeric n | 0 => numeric_zero | n + 1 => (numeric_nat n).add numeric_one #align pgame.numeric_nat Pgame.numeric_nat /-- Ordinal games are numeric. -/ theorem numeric_toPgame (o : Ordinal) : o.toPgame.Numeric := by induction' o using Ordinal.induction with o IH apply numeric_of_is_empty_right_moves simpa using fun i => IH _ (Ordinal.toLeftMovesToPgame_symm_lt i) #align pgame.numeric_to_pgame Pgame.numeric_toPgame end Pgame open Pgame /-- The type of surreal numbers. These are the numeric pre-games quotiented by the equivalence relation `x ≈ y ↔ x ≤ y ∧ y ≤ x`. In the quotient, the order becomes a total order. -/ def Surreal := Quotient (Subtype.setoid Numeric) #align surreal Surreal namespace Surreal /-- Construct a surreal number from a numeric pre-game. -/ def mk (x : Pgame) (h : x.Numeric) : Surreal := ⟦⟨x, h⟩⟧ #align surreal.mk Surreal.mk instance : Zero Surreal := ⟨mk 0 numeric_zero⟩ instance : One Surreal := ⟨mk 1 numeric_one⟩ instance : Inhabited Surreal := ⟨0⟩ /-- Lift an equivalence-respecting function on pre-games to surreals. -/ def lift {α} (f : ∀ x, Numeric x → α) (H : ∀ {x y} (hx : Numeric x) (hy : Numeric y), x.Equiv y → f x hx = f y hy) : Surreal → α := Quotient.lift (fun x : { x // Numeric x } => f x.1 x.2) fun x y => H x.2 y.2 #align surreal.lift Surreal.lift /-- Lift a binary equivalence-respecting function on pre-games to surreals. -/ def lift₂ {α} (f : ∀ x y, Numeric x → Numeric y → α) (H : ∀ {x₁ y₁ x₂ y₂} (ox₁ : Numeric x₁) (oy₁ : Numeric y₁) (ox₂ : Numeric x₂) (oy₂ : Numeric y₂), x₁.Equiv x₂ → y₁.Equiv y₂ → f x₁ y₁ ox₁ oy₁ = f x₂ y₂ ox₂ oy₂) : Surreal → Surreal → α := lift (fun x ox => lift (fun y oy => f x y ox oy) fun y₁ y₂ oy₁ oy₂ => H _ _ _ _ equiv_rfl) fun x₁ x₂ ox₁ ox₂ h => funext <| Quotient.ind fun ⟨y, oy⟩ => H _ _ _ _ h equiv_rfl #align surreal.lift₂ Surreal.lift₂ instance : LE Surreal := ⟨lift₂ (fun x y _ _ => x ≤ y) fun x₁ y₁ x₂ y₂ _ _ _ _ hx hy => propext (le_congr hx hy)⟩ instance : LT Surreal := ⟨lift₂ (fun x y _ _ => x < y) fun x₁ y₁ x₂ y₂ _ _ _ _ hx hy => propext (lt_congr hx hy)⟩ /-- Addition on surreals is inherited from pre-game addition: the sum of `x = {xL | xR}` and `y = {yL | yR}` is `{xL + y, x + yL | xR + y, x + yR}`. -/ instance : Add Surreal := ⟨Surreal.lift₂ (fun (x y : Pgame) ox oy => ⟦⟨x + y, ox.add oy⟩⟧) fun x₁ y₁ x₂ y₂ _ _ _ _ hx hy => Quotient.sound (add_congr hx hy)⟩ /-- Negation for surreal numbers is inherited from pre-game negation: the negation of `{L | R}` is `{-R | -L}`. -/ instance : Neg Surreal := ⟨Surreal.lift (fun x ox => ⟦⟨-x, ox.neg⟩⟧) fun _ _ _ _ a => Quotient.sound (neg_equiv_neg_iff.2 a)⟩ instance : OrderedAddCommGroup Surreal where add := (· + ·) add_assoc := by rintro ⟨_⟩ ⟨_⟩ ⟨_⟩ exact Quotient.sound add_assoc_equiv zero := 0 zero_add := by rintro ⟨_⟩ exact Quotient.sound (zero_add_equiv a) add_zero := by rintro ⟨_⟩ exact Quotient.sound (add_zero_equiv a) neg := Neg.neg add_left_neg := by rintro ⟨_⟩ exact Quotient.sound (add_left_neg_equiv a) add_comm := by rintro ⟨_⟩ ⟨_⟩ exact Quotient.sound add_comm_equiv le := (· ≤ ·) lt := (· < ·) le_refl := by rintro ⟨_⟩ apply @le_rfl Pgame le_trans := by rintro ⟨_⟩ ⟨_⟩ ⟨_⟩ apply @le_trans Pgame lt_iff_le_not_le := by rintro ⟨_, ox⟩ ⟨_, oy⟩ apply @lt_iff_le_not_le Pgame le_antisymm := by rintro ⟨_⟩ ⟨_⟩ h₁ h₂ exact Quotient.sound ⟨h₁, h₂⟩ add_le_add_left := by rintro ⟨_⟩ ⟨_⟩ hx ⟨_⟩ exact @add_le_add_left Pgame _ _ _ _ _ hx _ noncomputable instance : LinearOrderedAddCommGroup Surreal := { Surreal.orderedAddCommGroup with le_total := by rintro ⟨⟨x, ox⟩⟩ ⟨⟨y, oy⟩⟩ <;> classical skip <;> exact or_iff_not_imp_left.2 fun h => (Pgame.not_le.1 h).le oy ox decidableLe := Classical.decRel _ } instance : AddMonoidWithOne Surreal := AddMonoidWithOne.unary /-- Casts a `surreal` number into a `game`. -/ def toGame : Surreal →+o Game where toFun := lift (fun x _ => ⟦x⟧) fun x y ox oy => Quot.sound map_zero' := rfl map_add' := by rintro ⟨_, _⟩ ⟨_, _⟩ rfl monotone' := by rintro ⟨_, _⟩ ⟨_, _⟩ exact id #align surreal.to_game Surreal.toGame theorem zero_toGame : toGame 0 = 0 := rfl #align surreal.zero_to_game Surreal.zero_toGame @[simp] theorem one_toGame : toGame 1 = 1 := rfl #align surreal.one_to_game Surreal.one_toGame @[simp] theorem nat_toGame : ∀ n : ℕ, toGame n = n := map_natCast' _ one_toGame #align surreal.nat_to_game Surreal.nat_toGame end Surreal open Surreal namespace Ordinal /-- Converts an ordinal into the corresponding surreal. -/ noncomputable def toSurreal : Ordinal ↪o Surreal where toFun o := mk _ (numeric_toPgame o) inj' a b h := toPgame_equiv_iff.1 (Quotient.exact h) map_rel_iff' := @toPgame_le_iff #align ordinal.to_surreal Ordinal.toSurreal end Ordinal
Formal statement is: lemma measure_UNION: assumes measurable: "range A \<subseteq> sets M" "disjoint_family A" assumes finite: "emeasure M (\<Union>i. A i) \<noteq> \<infinity>" shows "(\<lambda>i. measure M (A i)) sums (measure M (\<Union>i. A i))" Informal statement is: If $A_1, A_2, \ldots$ is a disjoint family of measurable sets, then $\sum_{i=1}^\infty \mu(A_i) = \mu(\bigcup_{i=1}^\infty A_i)$.
function pascal_to_i4_test ( ) %*****************************************************************************80 % %% PASCAL_TO_I4_TEST tests PASCAL_TO_I4. % % Location: % % http://people.sc.fsu.edu/~jburkardt/m_src/triangle_integrals/pascal_to_i4.m % % Licensing: % % This code is distributed under the GNU LGPL license. % % Modified: % % 13 April 2015 % % Author: % % John Burkardt % fprintf ( 1, '\n' ); fprintf ( 1, 'PASCAL_TO_I4_TEST\n' ); fprintf ( 1, ' PASCAL_TO_I4 converts Pascal triangle indices to a\n' ); fprintf ( 1, ' linear index.\n' ); fprintf ( 1, '\n' ); fprintf ( 1, ' I J => K\n' ); fprintf ( 1, '\n' ); for d = 0 : 4 for i = d : -1 : 0 j = d - i; k = pascal_to_i4 ( i, j ); fprintf ( 1, ' %4d %4d %4d\n', i, j, k ); end fprintf ( 1, '\n' ); end return end
''' MLSS: Machine Learning with Spark Streaming Dataset: Tweet Sentiment Analysis Submission by: Team BD_078_460_474_565 Course: Big Data, Fall 2021 ''' import numpy as np from pyspark.mllib.linalg import Vectors def LRLearning(X, y, spark, classifier, model_version): """ Perform logistic regression on the dataframe with incremental learning """ # Fit the LR classifier classifier.partial_fit(X, y, classes=np.unique(y)) predictions = classifier.predict(X) accuracy = np.count_nonzero(np.array(predictions) == y)/y.shape[0] print(f"Accuracy of LR_{model_version}:", accuracy) with open(f'./model_accuracies/lr_{model_version}.txt', "a") as ma: ma.write(str(accuracy)+'\n') return classifier
(* Consider the following two inductively defined types. *) Inductive mumble : Type := | a | b (x : mumble) (y : nat) | c. Inductive grumble (X:Type) : Type := | d (m : mumble) | e (x : X). (* Which of the following are well-typed elements of grumble X for some type X? (Add YES or NO to each line.) *) (* d (b a 5) YES d mumble (b a 5) YES d bool (b a 5) YES e bool true YES e mumble (b c 0) YES e bool (b c 0) NO c YES *)
[STATEMENT] lemma C4_a [simp]: "-r (-l x) = x" [PROOF STATE] proof (prove) goal (1 subgoal): 1. -r (-l x) = x [PROOF STEP] apply (unfold C3_b [THEN sym] C3_a [THEN sym]) [PROOF STATE] proof (prove) goal (1 subgoal): 1. (x l\<rightarrow> (0::'a)) r\<rightarrow> (0::'a) = x [PROOF STEP] apply (subst W2a) [PROOF STATE] proof (prove) goal (1 subgoal): 1. ((0::'a) l\<rightarrow> x) r\<rightarrow> x = x [PROOF STEP] by simp
import numpy as np from scipy.optimize import fsolve def rotation_x(theta): """Matrix of rotation about x axis.""" return np.matrix([[ 1, 0, 0], [ 0, np.cos(theta), -np.sin(theta)], [ 0, np.sin(theta), np.cos(theta)]]) def rotation_y(theta): """Matrix of rotation about y axis.""" return np.matrix([[ np.cos(theta), 0, np.sin(theta)], [ 0, 1, 0], [-np.sin(theta), 0, np.cos(theta)]]) def rotation_z(theta): """Matrix of rotation about z axis.""" return np.matrix([[ np.cos(theta), -np.sin(theta), 0], [ np.sin(theta), np.cos(theta), 0], [ 0, 0, 1]]) def rotation_fixed_angle(gamma, beta, alpha): """Matrix for X-Y-Z fixed angle rotation.""" return rotation_z(alpha) * rotation_y(beta) * rotation_x(gamma) def trisphere_forward_kinematics(j_p, j_np, c_np, c_p0=np.zeros(3), c_r0=np.zeros(3)): """Forward kinematics of the Tri-sphere 6D system. :param tuple: jacks' target positions (j1_p, j2_p, j3_p) relative to their respective null positions. :param tuple j_np: null positions of the jacks (j1_np, j2_np, j3_np). :param numpy.array c_np: null position (x, y, z) of the control point. :param numpy.array c_p0: current position (x, y, z) of the control point relative to its null position. :param numpy.array c_r0: current rotation (gamma, beta, alpha) of the control point. :return: target of the position (x, y, z) and rotation (gamma, beta, alpha) of the control point. Note: c_p0 and c_r0 are simply used as a starting point for solving the forward kinematics. """ if j_p[0][0] != 0 or j_p[1][2] !=0 or j_p[2][2] != 0: raise ValueError("Invalid jacks' target position!") def obj_func(x): ret, _ = trisphere_inverse_kinematics(x[:3], x[3:], c_np, j_np) # z1, y1, x2, y2, x3, y3 return np.array([ret[0][2] - j_p[0][2], ret[0][1] - j_p[0][1], ret[1][0] - j_p[1][0], ret[1][1] - j_p[1][1], ret[2][0] - j_p[2][0], ret[2][1] - j_p[2][1]]) x0 = np.concatenate((c_p0, c_r0)) ret = fsolve(obj_func, x0) # c_p and c_r return ret[:3], ret[3:] def trisphere_inverse_kinematics(c_p, c_r, c_np, j_np): """Inverse kinematics of the Tri-sphere 6D system. :param numpy.array c_p: target position (x, y, z) of the control point relative to its null position. :param numpy.array c_r: target rotation (gamma, beta, alpha) of the control point. :param numpy.array c_np: null position of the control point. :param tuple j_np: null positions of the jacks (j1_np, j2_np, j3_np). :return: jacks' target positions (j1_p, j2_p, j3_p) relative to their respective null position and "transformed null positions" (j1_tnp, j2_tnp, j3_tnp). The latter is used for testing and debugging. """ j1_np, j2_np, j3_np = j_np gamma, beta, alpha = c_r # calculate rotation matrix rt_matrix = rotation_fixed_angle(gamma, beta, alpha) # calculate transformed null positions j1_tnp = ((j1_np - c_np) * rt_matrix.T).getA()[0] + c_np + c_p j2_tnp = ((j2_np - c_np) * rt_matrix.T).getA()[0] + c_np + c_p j3_tnp = ((j3_np - c_np) * rt_matrix.T).getA()[0] + c_np + c_p # calculate jacks' new positions j1_p = j1_tnp - j1_np dx = j1_np[0] - j1_tnp[0] j1_p[0] = 0 j1_p[1] += np.tan(alpha) * dx j1_p[2] += -np.tan(beta)/np.cos(alpha) * dx j2_p = j2_tnp - j2_np dz = j2_np[2] - j2_tnp[2] j2_p[0] += (np.tan(beta)*np.cos(alpha) + np.sin(alpha)*np.tan(gamma)/np.cos(beta)) * dz j2_p[1] += -(np.tan(gamma)/np.cos(beta)*np.cos(alpha) - np.tan(beta)*np.sin(alpha)) * dz j2_p[2] = 0 j3_p = j3_tnp - j3_np dz = j3_np[2] - j3_tnp[2] j3_p[0] += (np.tan(beta)*np.cos(alpha) + np.sin(alpha)*np.tan(gamma)/np.cos(beta)) * dz j3_p[1] += -(np.tan(gamma)/np.cos(beta)*np.cos(alpha) - np.tan(beta)*np.sin(alpha)) * dz j3_p[2] = 0 return (j1_p, j2_p, j3_p), (j1_tnp, j2_tnp, j3_tnp)
import math import numpy import tensorflow as tf def BatchClipByL2norm(t, upper_bound, name=None): assert upper_bound > 0 saved_shape = tf.shape(t) #batch_size = tf.slice(saved_shape, [0], [1]) batch_size = tf.constant(1.0) shape = tf.concat(0, [[tf.constant(128)], [-1]]) t2 = tf.reshape(t, shape) upper_bound_inv = tf.fill(tf.slice(saved_shape, [0], [1]), tf.constant(1.0/upper_bound)) # Add a small number to avoid divide by 0 l2norm_inv = tf.math.rsqrt(tf.reduce_sum(t2 * t2, [1]) + 0.000001) scale = tf.minimum(l2norm_inv, upper_bound_inv) * upper_bound clipped_t = tf.matmul(tf.diag(scale), t2) clipped_t = tf.reshape(clipped_t, saved_shape, name=name) return clipped_t def AddGaussianNoise(t, sigma, name=None): noisy_t = t + tf.random.normal(tf.shape(t), stddev=sigma) return noisy_t def GetTensorOpName(x): t = x.name.rsplit(":", 1) if len(t) == 1: return x.name else: return t[0]
[GOAL] E : Type uE inst✝⁶ : NormedAddCommGroup E inst✝⁵ : NormedSpace ℝ E inst✝⁴ : FiniteDimensional ℝ E H : Type uH inst✝³ : TopologicalSpace H I : ModelWithCorners ℝ E H M : Type uM inst✝² : TopologicalSpace M inst✝¹ : ChartedSpace H M inst✝ : SmoothManifoldWithCorners I M c : M f : SmoothBumpFunction I c x : M hs : x ∈ (chartAt H c).toLocalEquiv.source hd : dist (↑(extChartAt I c) x) (↑(extChartAt I c) c) ≤ f.rIn ⊢ ↑f x = 1 [PROOFSTEP] simp only [f.eqOn_source hs, (· ∘ ·), f.one_of_mem_closedBall hd] [GOAL] E : Type uE inst✝⁶ : NormedAddCommGroup E inst✝⁵ : NormedSpace ℝ E inst✝⁴ : FiniteDimensional ℝ E H : Type uH inst✝³ : TopologicalSpace H I : ModelWithCorners ℝ E H M : Type uM inst✝² : TopologicalSpace M inst✝¹ : ChartedSpace H M inst✝ : SmoothManifoldWithCorners I M c : M f : SmoothBumpFunction I c x : M ⊢ support ↑f = (chartAt H c).toLocalEquiv.source ∩ ↑(extChartAt I c) ⁻¹' ball (↑(extChartAt I c) c) f.rOut [PROOFSTEP] rw [coe_def, support_indicator, support_comp_eq_preimage, ← extChartAt_source I, ← (extChartAt I c).symm_image_target_inter_eq', ← (extChartAt I c).symm_image_target_inter_eq', f.support_eq] [GOAL] E : Type uE inst✝⁶ : NormedAddCommGroup E inst✝⁵ : NormedSpace ℝ E inst✝⁴ : FiniteDimensional ℝ E H : Type uH inst✝³ : TopologicalSpace H I : ModelWithCorners ℝ E H M : Type uM inst✝² : TopologicalSpace M inst✝¹ : ChartedSpace H M inst✝ : SmoothManifoldWithCorners I M c : M f : SmoothBumpFunction I c x : M ⊢ IsOpen (support ↑f) [PROOFSTEP] rw [support_eq_inter_preimage] [GOAL] E : Type uE inst✝⁶ : NormedAddCommGroup E inst✝⁵ : NormedSpace ℝ E inst✝⁴ : FiniteDimensional ℝ E H : Type uH inst✝³ : TopologicalSpace H I : ModelWithCorners ℝ E H M : Type uM inst✝² : TopologicalSpace M inst✝¹ : ChartedSpace H M inst✝ : SmoothManifoldWithCorners I M c : M f : SmoothBumpFunction I c x : M ⊢ IsOpen ((chartAt H c).toLocalEquiv.source ∩ ↑(extChartAt I c) ⁻¹' ball (↑(extChartAt I c) c) f.rOut) [PROOFSTEP] exact isOpen_extChartAt_preimage I c isOpen_ball [GOAL] E : Type uE inst✝⁶ : NormedAddCommGroup E inst✝⁵ : NormedSpace ℝ E inst✝⁴ : FiniteDimensional ℝ E H : Type uH inst✝³ : TopologicalSpace H I : ModelWithCorners ℝ E H M : Type uM inst✝² : TopologicalSpace M inst✝¹ : ChartedSpace H M inst✝ : SmoothManifoldWithCorners I M c : M f : SmoothBumpFunction I c x : M ⊢ support ↑f = ↑(LocalEquiv.symm (extChartAt I c)) '' (ball (↑(extChartAt I c) c) f.rOut ∩ range ↑I) [PROOFSTEP] rw [f.support_eq_inter_preimage, ← extChartAt_source I, ← (extChartAt I c).symm_image_target_inter_eq', inter_comm, ball_inter_range_eq_ball_inter_target] [GOAL] E : Type uE inst✝⁶ : NormedAddCommGroup E inst✝⁵ : NormedSpace ℝ E inst✝⁴ : FiniteDimensional ℝ E H : Type uH inst✝³ : TopologicalSpace H I : ModelWithCorners ℝ E H M : Type uM inst✝² : TopologicalSpace M inst✝¹ : ChartedSpace H M inst✝ : SmoothManifoldWithCorners I M c : M f : SmoothBumpFunction I c x : M ⊢ support ↑f ⊆ (chartAt H c).toLocalEquiv.source [PROOFSTEP] rw [f.support_eq_inter_preimage, ← extChartAt_source I] [GOAL] E : Type uE inst✝⁶ : NormedAddCommGroup E inst✝⁵ : NormedSpace ℝ E inst✝⁴ : FiniteDimensional ℝ E H : Type uH inst✝³ : TopologicalSpace H I : ModelWithCorners ℝ E H M : Type uM inst✝² : TopologicalSpace M inst✝¹ : ChartedSpace H M inst✝ : SmoothManifoldWithCorners I M c : M f : SmoothBumpFunction I c x : M ⊢ (extChartAt I c).source ∩ ↑(extChartAt I c) ⁻¹' ball (↑(extChartAt I c) c) f.rOut ⊆ (extChartAt I c).source [PROOFSTEP] exact inter_subset_left _ _ [GOAL] E : Type uE inst✝⁶ : NormedAddCommGroup E inst✝⁵ : NormedSpace ℝ E inst✝⁴ : FiniteDimensional ℝ E H : Type uH inst✝³ : TopologicalSpace H I : ModelWithCorners ℝ E H M : Type uM inst✝² : TopologicalSpace M inst✝¹ : ChartedSpace H M inst✝ : SmoothManifoldWithCorners I M c : M f : SmoothBumpFunction I c x : M s : Set M hs : s ⊆ support ↑f ⊢ ↑(extChartAt I c) '' s = closedBall (↑(extChartAt I c) c) f.rOut ∩ range ↑I ∩ ↑(LocalEquiv.symm (extChartAt I c)) ⁻¹' s [PROOFSTEP] rw [support_eq_inter_preimage, subset_inter_iff, ← extChartAt_source I, ← image_subset_iff] at hs [GOAL] E : Type uE inst✝⁶ : NormedAddCommGroup E inst✝⁵ : NormedSpace ℝ E inst✝⁴ : FiniteDimensional ℝ E H : Type uH inst✝³ : TopologicalSpace H I : ModelWithCorners ℝ E H M : Type uM inst✝² : TopologicalSpace M inst✝¹ : ChartedSpace H M inst✝ : SmoothManifoldWithCorners I M c : M f : SmoothBumpFunction I c x : M s : Set M hs : s ⊆ (extChartAt I c).source ∧ ↑(extChartAt I c) '' s ⊆ ball (↑(extChartAt I c) c) f.rOut ⊢ ↑(extChartAt I c) '' s = closedBall (↑(extChartAt I c) c) f.rOut ∩ range ↑I ∩ ↑(LocalEquiv.symm (extChartAt I c)) ⁻¹' s [PROOFSTEP] cases' hs with hse hsf [GOAL] case intro E : Type uE inst✝⁶ : NormedAddCommGroup E inst✝⁵ : NormedSpace ℝ E inst✝⁴ : FiniteDimensional ℝ E H : Type uH inst✝³ : TopologicalSpace H I : ModelWithCorners ℝ E H M : Type uM inst✝² : TopologicalSpace M inst✝¹ : ChartedSpace H M inst✝ : SmoothManifoldWithCorners I M c : M f : SmoothBumpFunction I c x : M s : Set M hse : s ⊆ (extChartAt I c).source hsf : ↑(extChartAt I c) '' s ⊆ ball (↑(extChartAt I c) c) f.rOut ⊢ ↑(extChartAt I c) '' s = closedBall (↑(extChartAt I c) c) f.rOut ∩ range ↑I ∩ ↑(LocalEquiv.symm (extChartAt I c)) ⁻¹' s [PROOFSTEP] apply Subset.antisymm [GOAL] case intro.h₁ E : Type uE inst✝⁶ : NormedAddCommGroup E inst✝⁵ : NormedSpace ℝ E inst✝⁴ : FiniteDimensional ℝ E H : Type uH inst✝³ : TopologicalSpace H I : ModelWithCorners ℝ E H M : Type uM inst✝² : TopologicalSpace M inst✝¹ : ChartedSpace H M inst✝ : SmoothManifoldWithCorners I M c : M f : SmoothBumpFunction I c x : M s : Set M hse : s ⊆ (extChartAt I c).source hsf : ↑(extChartAt I c) '' s ⊆ ball (↑(extChartAt I c) c) f.rOut ⊢ ↑(extChartAt I c) '' s ⊆ closedBall (↑(extChartAt I c) c) f.rOut ∩ range ↑I ∩ ↑(LocalEquiv.symm (extChartAt I c)) ⁻¹' s [PROOFSTEP] refine' subset_inter (subset_inter (hsf.trans ball_subset_closedBall) _) _ [GOAL] case intro.h₁.refine'_1 E : Type uE inst✝⁶ : NormedAddCommGroup E inst✝⁵ : NormedSpace ℝ E inst✝⁴ : FiniteDimensional ℝ E H : Type uH inst✝³ : TopologicalSpace H I : ModelWithCorners ℝ E H M : Type uM inst✝² : TopologicalSpace M inst✝¹ : ChartedSpace H M inst✝ : SmoothManifoldWithCorners I M c : M f : SmoothBumpFunction I c x : M s : Set M hse : s ⊆ (extChartAt I c).source hsf : ↑(extChartAt I c) '' s ⊆ ball (↑(extChartAt I c) c) f.rOut ⊢ ↑(extChartAt I c) '' s ⊆ range ↑I [PROOFSTEP] rintro _ ⟨x, -, rfl⟩ [GOAL] case intro.h₁.refine'_1.intro.intro E : Type uE inst✝⁶ : NormedAddCommGroup E inst✝⁵ : NormedSpace ℝ E inst✝⁴ : FiniteDimensional ℝ E H : Type uH inst✝³ : TopologicalSpace H I : ModelWithCorners ℝ E H M : Type uM inst✝² : TopologicalSpace M inst✝¹ : ChartedSpace H M inst✝ : SmoothManifoldWithCorners I M c : M f : SmoothBumpFunction I c x✝ : M s : Set M hse : s ⊆ (extChartAt I c).source hsf : ↑(extChartAt I c) '' s ⊆ ball (↑(extChartAt I c) c) f.rOut x : M ⊢ ↑(extChartAt I c) x ∈ range ↑I [PROOFSTEP] exact mem_range_self _ [GOAL] case intro.h₁.refine'_2 E : Type uE inst✝⁶ : NormedAddCommGroup E inst✝⁵ : NormedSpace ℝ E inst✝⁴ : FiniteDimensional ℝ E H : Type uH inst✝³ : TopologicalSpace H I : ModelWithCorners ℝ E H M : Type uM inst✝² : TopologicalSpace M inst✝¹ : ChartedSpace H M inst✝ : SmoothManifoldWithCorners I M c : M f : SmoothBumpFunction I c x : M s : Set M hse : s ⊆ (extChartAt I c).source hsf : ↑(extChartAt I c) '' s ⊆ ball (↑(extChartAt I c) c) f.rOut ⊢ ↑(extChartAt I c) '' s ⊆ ↑(LocalEquiv.symm (extChartAt I c)) ⁻¹' s [PROOFSTEP] rw [(extChartAt I c).image_eq_target_inter_inv_preimage hse] [GOAL] case intro.h₁.refine'_2 E : Type uE inst✝⁶ : NormedAddCommGroup E inst✝⁵ : NormedSpace ℝ E inst✝⁴ : FiniteDimensional ℝ E H : Type uH inst✝³ : TopologicalSpace H I : ModelWithCorners ℝ E H M : Type uM inst✝² : TopologicalSpace M inst✝¹ : ChartedSpace H M inst✝ : SmoothManifoldWithCorners I M c : M f : SmoothBumpFunction I c x : M s : Set M hse : s ⊆ (extChartAt I c).source hsf : ↑(extChartAt I c) '' s ⊆ ball (↑(extChartAt I c) c) f.rOut ⊢ (extChartAt I c).target ∩ ↑(LocalEquiv.symm (extChartAt I c)) ⁻¹' s ⊆ ↑(LocalEquiv.symm (extChartAt I c)) ⁻¹' s [PROOFSTEP] exact inter_subset_right _ _ [GOAL] case intro.h₂ E : Type uE inst✝⁶ : NormedAddCommGroup E inst✝⁵ : NormedSpace ℝ E inst✝⁴ : FiniteDimensional ℝ E H : Type uH inst✝³ : TopologicalSpace H I : ModelWithCorners ℝ E H M : Type uM inst✝² : TopologicalSpace M inst✝¹ : ChartedSpace H M inst✝ : SmoothManifoldWithCorners I M c : M f : SmoothBumpFunction I c x : M s : Set M hse : s ⊆ (extChartAt I c).source hsf : ↑(extChartAt I c) '' s ⊆ ball (↑(extChartAt I c) c) f.rOut ⊢ closedBall (↑(extChartAt I c) c) f.rOut ∩ range ↑I ∩ ↑(LocalEquiv.symm (extChartAt I c)) ⁻¹' s ⊆ ↑(extChartAt I c) '' s [PROOFSTEP] refine' Subset.trans (inter_subset_inter_left _ f.closedBall_subset) _ [GOAL] case intro.h₂ E : Type uE inst✝⁶ : NormedAddCommGroup E inst✝⁵ : NormedSpace ℝ E inst✝⁴ : FiniteDimensional ℝ E H : Type uH inst✝³ : TopologicalSpace H I : ModelWithCorners ℝ E H M : Type uM inst✝² : TopologicalSpace M inst✝¹ : ChartedSpace H M inst✝ : SmoothManifoldWithCorners I M c : M f : SmoothBumpFunction I c x : M s : Set M hse : s ⊆ (extChartAt I c).source hsf : ↑(extChartAt I c) '' s ⊆ ball (↑(extChartAt I c) c) f.rOut ⊢ (extChartAt I c).target ∩ ↑(LocalEquiv.symm (extChartAt I c)) ⁻¹' s ⊆ ↑(extChartAt I c) '' s [PROOFSTEP] rw [(extChartAt I c).image_eq_target_inter_inv_preimage hse] [GOAL] E : Type uE inst✝⁶ : NormedAddCommGroup E inst✝⁵ : NormedSpace ℝ E inst✝⁴ : FiniteDimensional ℝ E H : Type uH inst✝³ : TopologicalSpace H I : ModelWithCorners ℝ E H M : Type uM inst✝² : TopologicalSpace M inst✝¹ : ChartedSpace H M inst✝ : SmoothManifoldWithCorners I M c : M f : SmoothBumpFunction I c x : M ⊢ ↑f x ∈ Icc 0 1 [PROOFSTEP] have : f x = 0 ∨ f x = _ := indicator_eq_zero_or_self _ _ _ [GOAL] E : Type uE inst✝⁶ : NormedAddCommGroup E inst✝⁵ : NormedSpace ℝ E inst✝⁴ : FiniteDimensional ℝ E H : Type uH inst✝³ : TopologicalSpace H I : ModelWithCorners ℝ E H M : Type uM inst✝² : TopologicalSpace M inst✝¹ : ChartedSpace H M inst✝ : SmoothManifoldWithCorners I M c : M f : SmoothBumpFunction I c x : M this : ↑f x = 0 ∨ ↑f x = (↑f.toContDiffBump ∘ ↑(extChartAt I c)) x ⊢ ↑f x ∈ Icc 0 1 [PROOFSTEP] cases' this with h h [GOAL] case inl E : Type uE inst✝⁶ : NormedAddCommGroup E inst✝⁵ : NormedSpace ℝ E inst✝⁴ : FiniteDimensional ℝ E H : Type uH inst✝³ : TopologicalSpace H I : ModelWithCorners ℝ E H M : Type uM inst✝² : TopologicalSpace M inst✝¹ : ChartedSpace H M inst✝ : SmoothManifoldWithCorners I M c : M f : SmoothBumpFunction I c x : M h : ↑f x = 0 ⊢ ↑f x ∈ Icc 0 1 [PROOFSTEP] rw [h] [GOAL] case inr E : Type uE inst✝⁶ : NormedAddCommGroup E inst✝⁵ : NormedSpace ℝ E inst✝⁴ : FiniteDimensional ℝ E H : Type uH inst✝³ : TopologicalSpace H I : ModelWithCorners ℝ E H M : Type uM inst✝² : TopologicalSpace M inst✝¹ : ChartedSpace H M inst✝ : SmoothManifoldWithCorners I M c : M f : SmoothBumpFunction I c x : M h : ↑f x = (↑f.toContDiffBump ∘ ↑(extChartAt I c)) x ⊢ ↑f x ∈ Icc 0 1 [PROOFSTEP] rw [h] [GOAL] case inl E : Type uE inst✝⁶ : NormedAddCommGroup E inst✝⁵ : NormedSpace ℝ E inst✝⁴ : FiniteDimensional ℝ E H : Type uH inst✝³ : TopologicalSpace H I : ModelWithCorners ℝ E H M : Type uM inst✝² : TopologicalSpace M inst✝¹ : ChartedSpace H M inst✝ : SmoothManifoldWithCorners I M c : M f : SmoothBumpFunction I c x : M h : ↑f x = 0 ⊢ 0 ∈ Icc 0 1 case inr E : Type uE inst✝⁶ : NormedAddCommGroup E inst✝⁵ : NormedSpace ℝ E inst✝⁴ : FiniteDimensional ℝ E H : Type uH inst✝³ : TopologicalSpace H I : ModelWithCorners ℝ E H M : Type uM inst✝² : TopologicalSpace M inst✝¹ : ChartedSpace H M inst✝ : SmoothManifoldWithCorners I M c : M f : SmoothBumpFunction I c x : M h : ↑f x = (↑f.toContDiffBump ∘ ↑(extChartAt I c)) x ⊢ (↑f.toContDiffBump ∘ ↑(extChartAt I c)) x ∈ Icc 0 1 [PROOFSTEP] exacts [left_mem_Icc.2 zero_le_one, ⟨f.nonneg, f.le_one⟩] [GOAL] E : Type uE inst✝⁶ : NormedAddCommGroup E inst✝⁵ : NormedSpace ℝ E inst✝⁴ : FiniteDimensional ℝ E H : Type uH inst✝³ : TopologicalSpace H I : ModelWithCorners ℝ E H M : Type uM inst✝² : TopologicalSpace M inst✝¹ : ChartedSpace H M inst✝ : SmoothManifoldWithCorners I M c : M f : SmoothBumpFunction I c x : M hs : x ∈ (chartAt H c).toLocalEquiv.source hd : dist (↑(extChartAt I c) x) (↑(extChartAt I c) c) < f.rIn ⊢ ↑f =ᶠ[𝓝 x] 1 [PROOFSTEP] filter_upwards [IsOpen.mem_nhds (isOpen_extChartAt_preimage I c isOpen_ball) ⟨hs, hd⟩] [GOAL] case h E : Type uE inst✝⁶ : NormedAddCommGroup E inst✝⁵ : NormedSpace ℝ E inst✝⁴ : FiniteDimensional ℝ E H : Type uH inst✝³ : TopologicalSpace H I : ModelWithCorners ℝ E H M : Type uM inst✝² : TopologicalSpace M inst✝¹ : ChartedSpace H M inst✝ : SmoothManifoldWithCorners I M c : M f : SmoothBumpFunction I c x : M hs : x ∈ (chartAt H c).toLocalEquiv.source hd : dist (↑(extChartAt I c) x) (↑(extChartAt I c) c) < f.rIn ⊢ ∀ (a : M), a ∈ (chartAt H c).toLocalEquiv.source ∩ ↑(extChartAt I c) ⁻¹' ball (↑(extChartAt I c) c) f.rIn → ↑f a = OfNat.ofNat 1 a [PROOFSTEP] rintro z ⟨hzs, hzd⟩ [GOAL] case h.intro E : Type uE inst✝⁶ : NormedAddCommGroup E inst✝⁵ : NormedSpace ℝ E inst✝⁴ : FiniteDimensional ℝ E H : Type uH inst✝³ : TopologicalSpace H I : ModelWithCorners ℝ E H M : Type uM inst✝² : TopologicalSpace M inst✝¹ : ChartedSpace H M inst✝ : SmoothManifoldWithCorners I M c : M f : SmoothBumpFunction I c x : M hs : x ∈ (chartAt H c).toLocalEquiv.source hd : dist (↑(extChartAt I c) x) (↑(extChartAt I c) c) < f.rIn z : M hzs : z ∈ (chartAt H c).toLocalEquiv.source hzd : z ∈ ↑(extChartAt I c) ⁻¹' ball (↑(extChartAt I c) c) f.rIn ⊢ ↑f z = OfNat.ofNat 1 z [PROOFSTEP] exact f.one_of_dist_le hzs <| le_of_lt hzd [GOAL] E : Type uE inst✝⁶ : NormedAddCommGroup E inst✝⁵ : NormedSpace ℝ E inst✝⁴ : FiniteDimensional ℝ E H : Type uH inst✝³ : TopologicalSpace H I : ModelWithCorners ℝ E H M : Type uM inst✝² : TopologicalSpace M inst✝¹ : ChartedSpace H M inst✝ : SmoothManifoldWithCorners I M c : M f : SmoothBumpFunction I c x : M ⊢ dist (↑(extChartAt I c) c) (↑(extChartAt I c) c) < f.rIn [PROOFSTEP] rw [dist_self] [GOAL] E : Type uE inst✝⁶ : NormedAddCommGroup E inst✝⁵ : NormedSpace ℝ E inst✝⁴ : FiniteDimensional ℝ E H : Type uH inst✝³ : TopologicalSpace H I : ModelWithCorners ℝ E H M : Type uM inst✝² : TopologicalSpace M inst✝¹ : ChartedSpace H M inst✝ : SmoothManifoldWithCorners I M c : M f : SmoothBumpFunction I c x : M ⊢ 0 < f.rIn [PROOFSTEP] exact f.rIn_pos [GOAL] E : Type uE inst✝⁶ : NormedAddCommGroup E inst✝⁵ : NormedSpace ℝ E inst✝⁴ : FiniteDimensional ℝ E H : Type uH inst✝³ : TopologicalSpace H I : ModelWithCorners ℝ E H M : Type uM inst✝² : TopologicalSpace M inst✝¹ : ChartedSpace H M inst✝ : SmoothManifoldWithCorners I M c : M f : SmoothBumpFunction I c x✝ x : M hx : ↑f x = OfNat.ofNat 1 x ⊢ ↑f x ≠ 0 [PROOFSTEP] rw [hx] [GOAL] E : Type uE inst✝⁶ : NormedAddCommGroup E inst✝⁵ : NormedSpace ℝ E inst✝⁴ : FiniteDimensional ℝ E H : Type uH inst✝³ : TopologicalSpace H I : ModelWithCorners ℝ E H M : Type uM inst✝² : TopologicalSpace M inst✝¹ : ChartedSpace H M inst✝ : SmoothManifoldWithCorners I M c : M f : SmoothBumpFunction I c x✝ x : M hx : ↑f x = OfNat.ofNat 1 x ⊢ OfNat.ofNat 1 x ≠ 0 [PROOFSTEP] exact one_ne_zero [GOAL] E : Type uE inst✝⁶ : NormedAddCommGroup E inst✝⁵ : NormedSpace ℝ E inst✝⁴ : FiniteDimensional ℝ E H : Type uH inst✝³ : TopologicalSpace H I : ModelWithCorners ℝ E H M : Type uM inst✝² : TopologicalSpace M inst✝¹ : ChartedSpace H M inst✝ : SmoothManifoldWithCorners I M c : M f : SmoothBumpFunction I c x : M ⊢ HasBasis (𝓝[range ↑I] ↑(extChartAt I c) c) (fun x => True) fun f => closedBall (↑(extChartAt I c) c) f.rOut ∩ range ↑I [PROOFSTEP] refine' ((nhdsWithin_hasBasis nhds_basis_closedBall _).restrict_subset (extChartAt_target_mem_nhdsWithin _ _)).to_has_basis' _ _ [GOAL] case refine'_1 E : Type uE inst✝⁶ : NormedAddCommGroup E inst✝⁵ : NormedSpace ℝ E inst✝⁴ : FiniteDimensional ℝ E H : Type uH inst✝³ : TopologicalSpace H I : ModelWithCorners ℝ E H M : Type uM inst✝² : TopologicalSpace M inst✝¹ : ChartedSpace H M inst✝ : SmoothManifoldWithCorners I M c : M f : SmoothBumpFunction I c x : M ⊢ ∀ (i : ℝ), 0 < i ∧ closedBall (↑(extChartAt I c) c) i ∩ range ↑I ⊆ (extChartAt I c).target → ∃ i', True ∧ closedBall (↑(extChartAt I c) c) i'.rOut ∩ range ↑I ⊆ closedBall (↑(extChartAt I c) c) i ∩ range ↑I [PROOFSTEP] rintro R ⟨hR0, hsub⟩ [GOAL] case refine'_1.intro E : Type uE inst✝⁶ : NormedAddCommGroup E inst✝⁵ : NormedSpace ℝ E inst✝⁴ : FiniteDimensional ℝ E H : Type uH inst✝³ : TopologicalSpace H I : ModelWithCorners ℝ E H M : Type uM inst✝² : TopologicalSpace M inst✝¹ : ChartedSpace H M inst✝ : SmoothManifoldWithCorners I M c : M f : SmoothBumpFunction I c x : M R : ℝ hR0 : 0 < R hsub : closedBall (↑(extChartAt I c) c) R ∩ range ↑I ⊆ (extChartAt I c).target ⊢ ∃ i', True ∧ closedBall (↑(extChartAt I c) c) i'.rOut ∩ range ↑I ⊆ closedBall (↑(extChartAt I c) c) R ∩ range ↑I [PROOFSTEP] exact ⟨⟨⟨R / 2, R, half_pos hR0, half_lt_self hR0⟩, hsub⟩, trivial, Subset.rfl⟩ [GOAL] case refine'_2 E : Type uE inst✝⁶ : NormedAddCommGroup E inst✝⁵ : NormedSpace ℝ E inst✝⁴ : FiniteDimensional ℝ E H : Type uH inst✝³ : TopologicalSpace H I : ModelWithCorners ℝ E H M : Type uM inst✝² : TopologicalSpace M inst✝¹ : ChartedSpace H M inst✝ : SmoothManifoldWithCorners I M c : M f : SmoothBumpFunction I c x : M ⊢ ∀ (i' : SmoothBumpFunction I c), True → closedBall (↑(extChartAt I c) c) i'.rOut ∩ range ↑I ∈ 𝓝[range ↑I] ↑(extChartAt I c) c [PROOFSTEP] exact fun f _ => inter_mem (mem_nhdsWithin_of_mem_nhds <| closedBall_mem_nhds _ f.rOut_pos) self_mem_nhdsWithin [GOAL] E : Type uE inst✝⁶ : NormedAddCommGroup E inst✝⁵ : NormedSpace ℝ E inst✝⁴ : FiniteDimensional ℝ E H : Type uH inst✝³ : TopologicalSpace H I : ModelWithCorners ℝ E H M : Type uM inst✝² : TopologicalSpace M inst✝¹ : ChartedSpace H M inst✝ : SmoothManifoldWithCorners I M c : M f : SmoothBumpFunction I c x : M s : Set M hsc : IsClosed s hs : s ⊆ support ↑f ⊢ IsClosed (↑(extChartAt I c) '' s) [PROOFSTEP] rw [f.image_eq_inter_preimage_of_subset_support hs] [GOAL] E : Type uE inst✝⁶ : NormedAddCommGroup E inst✝⁵ : NormedSpace ℝ E inst✝⁴ : FiniteDimensional ℝ E H : Type uH inst✝³ : TopologicalSpace H I : ModelWithCorners ℝ E H M : Type uM inst✝² : TopologicalSpace M inst✝¹ : ChartedSpace H M inst✝ : SmoothManifoldWithCorners I M c : M f : SmoothBumpFunction I c x : M s : Set M hsc : IsClosed s hs : s ⊆ support ↑f ⊢ IsClosed (closedBall (↑(extChartAt I c) c) f.rOut ∩ range ↑I ∩ ↑(LocalEquiv.symm (extChartAt I c)) ⁻¹' s) [PROOFSTEP] refine' ContinuousOn.preimage_closed_of_closed ((continuousOn_extChartAt_symm _ _).mono f.closedBall_subset) _ hsc [GOAL] E : Type uE inst✝⁶ : NormedAddCommGroup E inst✝⁵ : NormedSpace ℝ E inst✝⁴ : FiniteDimensional ℝ E H : Type uH inst✝³ : TopologicalSpace H I : ModelWithCorners ℝ E H M : Type uM inst✝² : TopologicalSpace M inst✝¹ : ChartedSpace H M inst✝ : SmoothManifoldWithCorners I M c : M f : SmoothBumpFunction I c x : M s : Set M hsc : IsClosed s hs : s ⊆ support ↑f ⊢ IsClosed (closedBall (↑(extChartAt I c) c) f.rOut ∩ range ↑I) [PROOFSTEP] exact IsClosed.inter isClosed_ball I.closed_range [GOAL] E : Type uE inst✝⁶ : NormedAddCommGroup E inst✝⁵ : NormedSpace ℝ E inst✝⁴ : FiniteDimensional ℝ E H : Type uH inst✝³ : TopologicalSpace H I : ModelWithCorners ℝ E H M : Type uM inst✝² : TopologicalSpace M inst✝¹ : ChartedSpace H M inst✝ : SmoothManifoldWithCorners I M c : M f : SmoothBumpFunction I c x : M s : Set M hsc : IsClosed s hs : s ⊆ support ↑f ⊢ ∃ r, r ∈ Ioo 0 f.rOut ∧ s ⊆ (chartAt H c).toLocalEquiv.source ∩ ↑(extChartAt I c) ⁻¹' ball (↑(extChartAt I c) c) r [PROOFSTEP] set e := extChartAt I c [GOAL] E : Type uE inst✝⁶ : NormedAddCommGroup E inst✝⁵ : NormedSpace ℝ E inst✝⁴ : FiniteDimensional ℝ E H : Type uH inst✝³ : TopologicalSpace H I : ModelWithCorners ℝ E H M : Type uM inst✝² : TopologicalSpace M inst✝¹ : ChartedSpace H M inst✝ : SmoothManifoldWithCorners I M c : M f : SmoothBumpFunction I c x : M s : Set M hsc : IsClosed s hs : s ⊆ support ↑f e : LocalEquiv M E := extChartAt I c ⊢ ∃ r, r ∈ Ioo 0 f.rOut ∧ s ⊆ (chartAt H c).toLocalEquiv.source ∩ ↑(extChartAt I c) ⁻¹' ball (↑(extChartAt I c) c) r [PROOFSTEP] have : IsClosed (e '' s) := f.isClosed_image_of_isClosed hsc hs [GOAL] E : Type uE inst✝⁶ : NormedAddCommGroup E inst✝⁵ : NormedSpace ℝ E inst✝⁴ : FiniteDimensional ℝ E H : Type uH inst✝³ : TopologicalSpace H I : ModelWithCorners ℝ E H M : Type uM inst✝² : TopologicalSpace M inst✝¹ : ChartedSpace H M inst✝ : SmoothManifoldWithCorners I M c : M f : SmoothBumpFunction I c x : M s : Set M hsc : IsClosed s hs : s ⊆ support ↑f e : LocalEquiv M E := extChartAt I c this : IsClosed (↑e '' s) ⊢ ∃ r, r ∈ Ioo 0 f.rOut ∧ s ⊆ (chartAt H c).toLocalEquiv.source ∩ ↑(extChartAt I c) ⁻¹' ball (↑(extChartAt I c) c) r [PROOFSTEP] rw [support_eq_inter_preimage, subset_inter_iff, ← image_subset_iff] at hs [GOAL] E : Type uE inst✝⁶ : NormedAddCommGroup E inst✝⁵ : NormedSpace ℝ E inst✝⁴ : FiniteDimensional ℝ E H : Type uH inst✝³ : TopologicalSpace H I : ModelWithCorners ℝ E H M : Type uM inst✝² : TopologicalSpace M inst✝¹ : ChartedSpace H M inst✝ : SmoothManifoldWithCorners I M c : M f : SmoothBumpFunction I c x : M s : Set M hsc : IsClosed s hs : s ⊆ (chartAt H c).toLocalEquiv.source ∧ ↑(extChartAt I c) '' s ⊆ ball (↑(extChartAt I c) c) f.rOut e : LocalEquiv M E := extChartAt I c this : IsClosed (↑e '' s) ⊢ ∃ r, r ∈ Ioo 0 f.rOut ∧ s ⊆ (chartAt H c).toLocalEquiv.source ∩ ↑(extChartAt I c) ⁻¹' ball (↑(extChartAt I c) c) r [PROOFSTEP] rcases exists_pos_lt_subset_ball f.rOut_pos this hs.2 with ⟨r, hrR, hr⟩ [GOAL] case intro.intro E : Type uE inst✝⁶ : NormedAddCommGroup E inst✝⁵ : NormedSpace ℝ E inst✝⁴ : FiniteDimensional ℝ E H : Type uH inst✝³ : TopologicalSpace H I : ModelWithCorners ℝ E H M : Type uM inst✝² : TopologicalSpace M inst✝¹ : ChartedSpace H M inst✝ : SmoothManifoldWithCorners I M c : M f : SmoothBumpFunction I c x : M s : Set M hsc : IsClosed s hs : s ⊆ (chartAt H c).toLocalEquiv.source ∧ ↑(extChartAt I c) '' s ⊆ ball (↑(extChartAt I c) c) f.rOut e : LocalEquiv M E := extChartAt I c this : IsClosed (↑e '' s) r : ℝ hrR : r ∈ Ioo 0 f.rOut hr : ↑e '' s ⊆ ball (↑(extChartAt I c) c) r ⊢ ∃ r, r ∈ Ioo 0 f.rOut ∧ s ⊆ (chartAt H c).toLocalEquiv.source ∩ ↑(extChartAt I c) ⁻¹' ball (↑(extChartAt I c) c) r [PROOFSTEP] exact ⟨r, hrR, subset_inter hs.1 (image_subset_iff.1 hr)⟩ [GOAL] E : Type uE inst✝⁶ : NormedAddCommGroup E inst✝⁵ : NormedSpace ℝ E inst✝⁴ : FiniteDimensional ℝ E H : Type uH inst✝³ : TopologicalSpace H I : ModelWithCorners ℝ E H M : Type uM inst✝² : TopologicalSpace M inst✝¹ : ChartedSpace H M inst✝ : SmoothManifoldWithCorners I M c : M f : SmoothBumpFunction I c x : M r : ℝ hr : r ∈ Ioo 0 f.rOut ⊢ support ↑(updateRIn f r hr) = support ↑f [PROOFSTEP] simp only [support_eq_inter_preimage, updateRIn_rOut] [GOAL] E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace ℝ E inst✝⁵ : FiniteDimensional ℝ E H : Type uH inst✝⁴ : TopologicalSpace H I : ModelWithCorners ℝ E H M : Type uM inst✝³ : TopologicalSpace M inst✝² : ChartedSpace H M inst✝¹ : SmoothManifoldWithCorners I M c : M f : SmoothBumpFunction I c x : M inst✝ : T2Space M ⊢ tsupport ↑f ⊆ ↑(LocalEquiv.symm (extChartAt I c)) '' (closedBall (↑(extChartAt I c) c) f.rOut ∩ range ↑I) [PROOFSTEP] rw [tsupport, support_eq_symm_image] [GOAL] E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace ℝ E inst✝⁵ : FiniteDimensional ℝ E H : Type uH inst✝⁴ : TopologicalSpace H I : ModelWithCorners ℝ E H M : Type uM inst✝³ : TopologicalSpace M inst✝² : ChartedSpace H M inst✝¹ : SmoothManifoldWithCorners I M c : M f : SmoothBumpFunction I c x : M inst✝ : T2Space M ⊢ closure (↑(LocalEquiv.symm (extChartAt I c)) '' (ball (↑(extChartAt I c) c) f.rOut ∩ range ↑I)) ⊆ ↑(LocalEquiv.symm (extChartAt I c)) '' (closedBall (↑(extChartAt I c) c) f.rOut ∩ range ↑I) [PROOFSTEP] exact closure_minimal (image_subset _ <| inter_subset_inter_left _ ball_subset_closedBall) f.isClosed_symm_image_closedBall [GOAL] E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace ℝ E inst✝⁵ : FiniteDimensional ℝ E H : Type uH inst✝⁴ : TopologicalSpace H I : ModelWithCorners ℝ E H M : Type uM inst✝³ : TopologicalSpace M inst✝² : ChartedSpace H M inst✝¹ : SmoothManifoldWithCorners I M c : M f : SmoothBumpFunction I c x : M inst✝ : T2Space M ⊢ tsupport ↑f ⊆ (chartAt H c).toLocalEquiv.source [PROOFSTEP] simpa only [extChartAt_source] using f.tsupport_subset_extChartAt_source [GOAL] E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace ℝ E inst✝⁵ : FiniteDimensional ℝ E H : Type uH inst✝⁴ : TopologicalSpace H I : ModelWithCorners ℝ E H M : Type uM inst✝³ : TopologicalSpace M inst✝² : ChartedSpace H M inst✝¹ : SmoothManifoldWithCorners I M c : M f : SmoothBumpFunction I c x : M inst✝ : T2Space M ⊢ HasBasis (𝓝 c) (fun x => True) fun f => tsupport ↑f [PROOFSTEP] have : (𝓝 c).HasBasis (fun _ : SmoothBumpFunction I c => True) fun f => (extChartAt I c).symm '' (closedBall (extChartAt I c c) f.rOut ∩ range I) := by rw [← map_extChartAt_symm_nhdsWithin_range I c] exact nhdsWithin_range_basis.map _ [GOAL] E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace ℝ E inst✝⁵ : FiniteDimensional ℝ E H : Type uH inst✝⁴ : TopologicalSpace H I : ModelWithCorners ℝ E H M : Type uM inst✝³ : TopologicalSpace M inst✝² : ChartedSpace H M inst✝¹ : SmoothManifoldWithCorners I M c : M f : SmoothBumpFunction I c x : M inst✝ : T2Space M ⊢ HasBasis (𝓝 c) (fun x => True) fun f => ↑(LocalEquiv.symm (extChartAt I c)) '' (closedBall (↑(extChartAt I c) c) f.rOut ∩ range ↑I) [PROOFSTEP] rw [← map_extChartAt_symm_nhdsWithin_range I c] [GOAL] E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace ℝ E inst✝⁵ : FiniteDimensional ℝ E H : Type uH inst✝⁴ : TopologicalSpace H I : ModelWithCorners ℝ E H M : Type uM inst✝³ : TopologicalSpace M inst✝² : ChartedSpace H M inst✝¹ : SmoothManifoldWithCorners I M c : M f : SmoothBumpFunction I c x : M inst✝ : T2Space M ⊢ HasBasis (map (↑(LocalEquiv.symm (extChartAt I c))) (𝓝[range ↑I] ↑(extChartAt I c) c)) (fun x => True) fun f => ↑(LocalEquiv.symm (extChartAt I c)) '' (closedBall (↑(extChartAt I c) c) f.rOut ∩ range ↑I) [PROOFSTEP] exact nhdsWithin_range_basis.map _ [GOAL] E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace ℝ E inst✝⁵ : FiniteDimensional ℝ E H : Type uH inst✝⁴ : TopologicalSpace H I : ModelWithCorners ℝ E H M : Type uM inst✝³ : TopologicalSpace M inst✝² : ChartedSpace H M inst✝¹ : SmoothManifoldWithCorners I M c : M f : SmoothBumpFunction I c x : M inst✝ : T2Space M this : HasBasis (𝓝 c) (fun x => True) fun f => ↑(LocalEquiv.symm (extChartAt I c)) '' (closedBall (↑(extChartAt I c) c) f.rOut ∩ range ↑I) ⊢ HasBasis (𝓝 c) (fun x => True) fun f => tsupport ↑f [PROOFSTEP] refine' this.to_has_basis' (fun f _ => ⟨f, trivial, f.tsupport_subset_symm_image_closedBall⟩) fun f _ => f.tsupport_mem_nhds [GOAL] E : Type uE inst✝⁸ : NormedAddCommGroup E inst✝⁷ : NormedSpace ℝ E inst✝⁶ : FiniteDimensional ℝ E H : Type uH inst✝⁵ : TopologicalSpace H I : ModelWithCorners ℝ E H M : Type uM inst✝⁴ : TopologicalSpace M inst✝³ : ChartedSpace H M inst✝² : SmoothManifoldWithCorners I M c : M f : SmoothBumpFunction I c x : M inst✝¹ : T2Space M inst✝ : SmoothManifoldWithCorners I M ⊢ Smooth I 𝓘(ℝ, ℝ) ↑f [PROOFSTEP] refine' contMDiff_of_support fun x hx => _ [GOAL] E : Type uE inst✝⁸ : NormedAddCommGroup E inst✝⁷ : NormedSpace ℝ E inst✝⁶ : FiniteDimensional ℝ E H : Type uH inst✝⁵ : TopologicalSpace H I : ModelWithCorners ℝ E H M : Type uM inst✝⁴ : TopologicalSpace M inst✝³ : ChartedSpace H M inst✝² : SmoothManifoldWithCorners I M c : M f : SmoothBumpFunction I c x✝ : M inst✝¹ : T2Space M inst✝ : SmoothManifoldWithCorners I M x : M hx : x ∈ tsupport ↑f ⊢ ContMDiffAt I 𝓘(ℝ, ℝ) ⊤ (↑f) x [PROOFSTEP] have : x ∈ (chartAt H c).source := f.tsupport_subset_chartAt_source hx [GOAL] E : Type uE inst✝⁸ : NormedAddCommGroup E inst✝⁷ : NormedSpace ℝ E inst✝⁶ : FiniteDimensional ℝ E H : Type uH inst✝⁵ : TopologicalSpace H I : ModelWithCorners ℝ E H M : Type uM inst✝⁴ : TopologicalSpace M inst✝³ : ChartedSpace H M inst✝² : SmoothManifoldWithCorners I M c : M f : SmoothBumpFunction I c x✝ : M inst✝¹ : T2Space M inst✝ : SmoothManifoldWithCorners I M x : M hx : x ∈ tsupport ↑f this : x ∈ (chartAt H c).toLocalEquiv.source ⊢ ContMDiffAt I 𝓘(ℝ, ℝ) ⊤ (↑f) x [PROOFSTEP] refine' ContMDiffAt.congr_of_eventuallyEq _ <| f.eqOn_source.eventuallyEq_of_mem <| IsOpen.mem_nhds (chartAt H c).open_source this [GOAL] E : Type uE inst✝⁸ : NormedAddCommGroup E inst✝⁷ : NormedSpace ℝ E inst✝⁶ : FiniteDimensional ℝ E H : Type uH inst✝⁵ : TopologicalSpace H I : ModelWithCorners ℝ E H M : Type uM inst✝⁴ : TopologicalSpace M inst✝³ : ChartedSpace H M inst✝² : SmoothManifoldWithCorners I M c : M f : SmoothBumpFunction I c x✝ : M inst✝¹ : T2Space M inst✝ : SmoothManifoldWithCorners I M x : M hx : x ∈ tsupport ↑f this : x ∈ (chartAt H c).toLocalEquiv.source ⊢ ContMDiffAt I 𝓘(ℝ, ℝ) ⊤ (↑f.toContDiffBump ∘ ↑(extChartAt I c)) x [PROOFSTEP] exact f.contDiffAt.contMDiffAt.comp _ (contMDiffAt_extChartAt' this) [GOAL] E : Type uE inst✝¹⁰ : NormedAddCommGroup E inst✝⁹ : NormedSpace ℝ E inst✝⁸ : FiniteDimensional ℝ E H : Type uH inst✝⁷ : TopologicalSpace H I : ModelWithCorners ℝ E H M : Type uM inst✝⁶ : TopologicalSpace M inst✝⁵ : ChartedSpace H M inst✝⁴ : SmoothManifoldWithCorners I M c : M f : SmoothBumpFunction I c x : M inst✝³ : T2Space M inst✝² : SmoothManifoldWithCorners I M G : Type u_1 inst✝¹ : NormedAddCommGroup G inst✝ : NormedSpace ℝ G g : M → G hg : SmoothOn I 𝓘(ℝ, G) g (chartAt H c).toLocalEquiv.source ⊢ Smooth I 𝓘(ℝ, G) fun x => ↑f x • g x [PROOFSTEP] refine contMDiff_of_support fun x hx => ?_ [GOAL] E : Type uE inst✝¹⁰ : NormedAddCommGroup E inst✝⁹ : NormedSpace ℝ E inst✝⁸ : FiniteDimensional ℝ E H : Type uH inst✝⁷ : TopologicalSpace H I : ModelWithCorners ℝ E H M : Type uM inst✝⁶ : TopologicalSpace M inst✝⁵ : ChartedSpace H M inst✝⁴ : SmoothManifoldWithCorners I M c : M f : SmoothBumpFunction I c x✝ : M inst✝³ : T2Space M inst✝² : SmoothManifoldWithCorners I M G : Type u_1 inst✝¹ : NormedAddCommGroup G inst✝ : NormedSpace ℝ G g : M → G hg : SmoothOn I 𝓘(ℝ, G) g (chartAt H c).toLocalEquiv.source x : M hx : x ∈ tsupport fun x => ↑f x • g x ⊢ ContMDiffAt I 𝓘(ℝ, G) ⊤ (fun x => ↑f x • g x) x [PROOFSTEP] have : x ∈ (chartAt H c).source [GOAL] case this E : Type uE inst✝¹⁰ : NormedAddCommGroup E inst✝⁹ : NormedSpace ℝ E inst✝⁸ : FiniteDimensional ℝ E H : Type uH inst✝⁷ : TopologicalSpace H I : ModelWithCorners ℝ E H M : Type uM inst✝⁶ : TopologicalSpace M inst✝⁵ : ChartedSpace H M inst✝⁴ : SmoothManifoldWithCorners I M c : M f : SmoothBumpFunction I c x✝ : M inst✝³ : T2Space M inst✝² : SmoothManifoldWithCorners I M G : Type u_1 inst✝¹ : NormedAddCommGroup G inst✝ : NormedSpace ℝ G g : M → G hg : SmoothOn I 𝓘(ℝ, G) g (chartAt H c).toLocalEquiv.source x : M hx : x ∈ tsupport fun x => ↑f x • g x ⊢ x ∈ (chartAt H c).toLocalEquiv.source [PROOFSTEP] exact f.tsupport_subset_chartAt_source <| tsupport_smul_subset_left _ _ hx [GOAL] E : Type uE inst✝¹⁰ : NormedAddCommGroup E inst✝⁹ : NormedSpace ℝ E inst✝⁸ : FiniteDimensional ℝ E H : Type uH inst✝⁷ : TopologicalSpace H I : ModelWithCorners ℝ E H M : Type uM inst✝⁶ : TopologicalSpace M inst✝⁵ : ChartedSpace H M inst✝⁴ : SmoothManifoldWithCorners I M c : M f : SmoothBumpFunction I c x✝ : M inst✝³ : T2Space M inst✝² : SmoothManifoldWithCorners I M G : Type u_1 inst✝¹ : NormedAddCommGroup G inst✝ : NormedSpace ℝ G g : M → G hg : SmoothOn I 𝓘(ℝ, G) g (chartAt H c).toLocalEquiv.source x : M hx : x ∈ tsupport fun x => ↑f x • g x this : x ∈ (chartAt H c).toLocalEquiv.source ⊢ ContMDiffAt I 𝓘(ℝ, G) ⊤ (fun x => ↑f x • g x) x [PROOFSTEP] exact f.smoothAt.smul ((hg _ this).contMDiffAt <| IsOpen.mem_nhds (chartAt _ _).open_source this)
lemma convex_empty[intro,simp]: "convex {}"
# -*- coding: utf-8 -*- # Created on Sat Jun 05 2021 # Last modified on Mon Jun 07 2021 # Copyright (c) CaMOS Development Team. All Rights Reserved. # Distributed under a MIT License. See LICENSE for more info. import numpy as np from collections import defaultdict from camos.tasks.analysis import Analysis from camos.utils.generategui import ( DatasetInput, NumericInput, ) from .heatmap import ISIHeatmap class InterspikeIntervalMask(Analysis): analysis_name = "Interspike Interval" def __init__(self, model=None, parent=None, signal=None): super(InterspikeIntervalMask, self).__init__( model, parent, signal, name=self.analysis_name ) self.plotter = ISIHeatmap self.colname = "ISI" def _run( self, electrode_x: NumericInput("Number of electrodes along one axis", 64), _i_data: DatasetInput("Source Dataset", 0), ): output_type = [("CellID", "int"), ("ISI", "float")] self.plotter = ISIHeatmap(electrode_n=electrode_x) # data should be provided in format of peaks data = self.signal.data[_i_data] self.dataname = self.signal.names[_i_data] if not ("Active" in data.dtype.names): return ROIs = np.unique(data[:]["CellID"]) # Create the output matrix self.output = np.zeros(shape=(len(ROIs), 1), dtype=output_type) # Save Cell IDs in the output matrix self.output[:]["CellID"] = ROIs.reshape(-1, 1) # Calculate a dictionary of the input, faster computation IDs_all = data[:]["CellID"] dict_events = defaultdict(list) # This explores all events if type(IDs_all[0]) == np.ndarray: for i in range(len(IDs_all)): dict_events[IDs_all[i][0]] += [data[i]["Active"][0]] self.intReady.emit(i * 100 / len(IDs_all)) else: for i in range(len(IDs_all)): dict_events[IDs_all[i]] += [data[i]["Active"]] self.intReady.emit(i * 100 / len(IDs_all)) ISI = np.zeros(len(ROIs)) for i, ROI in enumerate(ROIs): ISI[i] = np.average(np.diff(dict_events[ROI])) self.output[:]["ISI"] = ISI.reshape(-1, 1)
[STATEMENT] lemma erfc_real_less_cancel [simp]: "(erfc (a :: real) < erfc b) \<longleftrightarrow> a > b" [PROOF STATE] proof (prove) goal (1 subgoal): 1. (erfc a < erfc b) = (b < a) [PROOF STEP] by (simp add: erfc_def)
Bitcoin is a currency, used to exchange goods and services. However, a difference of other currencies, Bitcoin is an electronic currency that presents new features and stands out for its efficiency, security and ease of exchange. - ✓The buyer must provide: logo and address of his web or slogan or words that he wants to put under the logo.
subroutine r1(x, y, n, f1) integer n real*8 x(n), y(n) external f1 call f1(x, y, n) return end subroutine r2(x, y, n, f2) integer n real*8 x(n), y(n) external f2 call r1(x, y, n, f2) return end
%!TEX TS-program = lualatex %!TEX encoding = UTF-8 Unicode \documentclass[12pt]{exam} \usepackage{graphicx} \graphicspath{{/Users/goby/Pictures/teach/163/lab/} {img/}} % set of paths to search for images \usepackage{geometry} \geometry{letterpaper, left=1.5in, bottom=1in} %\geometry{landscape} % Activate for for rotated page geometry %\usepackage[parfill]{parskip} % Activate to begin paragraphs with an empty line rather than an indent \usepackage{amssymb, amsmath} %\usepackage{mathtools} % \everymath{\displaystyle} \usepackage{fontspec} \setmainfont[Ligatures={TeX}, BoldFont={* Bold}, ItalicFont={* Italic}, BoldItalicFont={* BoldItalic}, Numbers={OldStyle}]{Linux Libertine O} \setsansfont[Scale=MatchLowercase,Ligatures=TeX, Numbers={OldStyle}]{Linux Biolinum O} \usepackage{microtype} %\usepackage{unicode-math} %\setmathfont[Scale=MatchLowercase]{Asana Math} %\setmathfont[Scale=MatchLowercase]{XITS Math} % To define fonts for particular uses within a document. For example, % This sets the Libertine font to use tabular number format for tables. %\newfontfamily{\tablenumbers}[Numbers={Monospaced}]{Linux Libertine O} %\newfontfamily{\libertinedisplay}{Linux Libertine Display O} \usepackage{booktabs} \usepackage{multicol} \usepackage[normalem]{ulem} \usepackage{longtable} %\usepackage{siunitx} \usepackage{array} \newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}} \newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}p{#1}} \newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}p{#1}} \usepackage{enumitem} \setlist[enumerate]{font=\normalfont\scshape} \setlist[enumerate,1]{leftmargin=*} \usepackage{stmaryrd} \usepackage{hyperref} %\usepackage{placeins} %PRovides \FloatBarrier to flush all floats before a certain point. \usepackage{hanging} \usepackage[sc]{titlesec} \makeatletter \def\SetTotalwidth{\advance\linewidth by \@totalleftmargin \@totalleftmargin=0pt} \makeatother \pagestyle{headandfoot} \firstpageheader{BI 063: Evolution and Ecology}{}{\ifprintanswers\textbf{KEY}\else Name: \enspace \makebox[2.5in]{\hrulefill}\fi} \runningheader{}{}{\footnotesize{pg. \thepage}} \footer{}{}{} \runningheadrule \begin{document} \subsection*{Depicting your hypothesis as a phylogenetic tree} Below is a table of 21 organisms. If you do not know what some of the organisms are, try looking them up in a dictionary, your text, or on the internet (Google, as usual, is a good place to start). You will use this list to to make a hypothesis that shows how these organisms are or are not related to each other. Your hypothesis must take the form of a phylogenetic tree or trees. Your hypothesis should reflect \textit{your} ideas about whether the organisms are related in any way to each other. You cannot make an incorrect hypothesis, as long as you follow the simple rules outlined below. Do not copy a tree from the internet or from a friend. You can make as many or as few trees as needed to convey your idea. Below, I give you few tips to help you make a good hypothesis with correctly drawn trees. \begin{longtable}[c]{@{}L{1in}L{0.6in}|L{1in}L{0.6in}|L{1in}L{0.6in}@{}} \toprule \multicolumn{2}{c|}{Organism} & \multicolumn{2}{c|}{Organism} & \multicolumn{2}{c}{Organism}\tabularnewline % alligator & \includegraphics[width=0.5in]{alligator_small} & \emph{E. coli} & \includegraphics[width=0.5in]{ecoli_small} & marine worm & \includegraphics[width=0.5in]{marine_worm}\tabularnewline % bass & \includegraphics[width=0.5in]{bass} & frog & \includegraphics[width=0.5in]{frog} & \emph{Paramecium} & \includegraphics[width=0.5in]{paramecium}\tabularnewline % bat & \includegraphics[width=0.5in]{bat} & fungus & \includegraphics[width=0.4in]{fungus} & pigeon & \includegraphics[width=0.5in]{pigeon}\tabularnewline % bison & \includegraphics[width=0.5in]{bison} & \emph{Homo sapiens} & \includegraphics[width=0.5in]{human} & praying mantis & \includegraphics[width=0.4in]{praying_mantis}\tabularnewline % cactus & \includegraphics[width=0.35in]{cactus} & land snail & \includegraphics[width=0.5in]{land_snail} & snake & \includegraphics[width=0.4in]{snake}\tabularnewline % cat & \includegraphics[width=0.4in]{cat} & macaque & \includegraphics[width=0.5in]{macaque} & wasp & \includegraphics[width=0.5in]{wasp}\tabularnewline % chimpanzee & \includegraphics[width=0.5in]{chimpanzee} & maple tree & \includegraphics[width=0.4in]{maple_tree} & whale & \includegraphics[width=0.6in]{whale}\tabularnewline % \bottomrule \end{longtable} \vspace*{\baselineskip} \noindent\textsc{General tips} \begin{enumerate} \item Your hypothesis needs to account for all 21 organisms listed above. This means that you \emph{must} include all 21 on your tree. \item An easy way to start is put all the organisms across the top, grouping them by any relationships you will be drawing. All 21 of those are alive today, so all 21 had better be at the top of the tree, because that is the present time. %\end{enumerate} \begin{longtable}[c]{@{}ll@{}} First draw them: & Then draw the lines:\tabularnewline % \includegraphics[width=0.33\textwidth]{draw_step1} & \includegraphics[width=0.33\textwidth]{draw_step2} \tabularnewline % \end{longtable} %\begin{enumerate} \item The vertical (Y) axis represents time. Present time is at the top. Farther down the tree or page represents farther back in time. The oldest organism is thus the farthest back, or at the bottom of your tree. If the first organism or organisms are among the 21 listed above, you can put their names at the bottom too, but you do not have to. In fact, I recommend that you do not. Just starting a line is okay, as shown in earlier exercises. Obviously, if your first organisms are not among the 21, you will just have to start with lines at the bottom. \item The horizontal (X) axis does not represent anything in most phylogenetic trees. \item A line (branch) indicates an ancestor to descendant relationship, where successive generations would be the (invisible) points that make up the line leading from the start of life at the bottom to the present day at the top. Of course, if you want an organism to start sometime later, just do not start its line all the way down at the bottom. A fork in the line indicates a lineage splitting, as you saw in the Phylogenetic Forest exercise. \item You \emph{must} include a time scale labeled along the Y-axis. Do not simply write Present and Past. You must have a specific time scale, but the actual units (e.g, thousands of years, millions of years) is part of your hypothesis. \item Only two organisms can branch from one point. That is, you should get a split like a “goal post” (preferred) or {\Large$\Ydown$} with one kind of organism on one branch, a different organism on the other. This means that two groups of individuals from the same species got separated and one of the groups changed enough that they are no longer the same species. It would not happen that three groups would all do this at precisely the same moment. Hence, \newpage \begin{longtable}[c]{@{}lL{0.2in}lL{0.2in}l@{}} this is possible, & & this is \emph{not}, & & but this is!\tabularnewline % \includegraphics[height=2in]{03d_possible1} & & \includegraphics[height=2in]{03d_possible_not} & & \includegraphics[height=2in]{03d_possible2}\tabularnewline % \end{longtable} \item The image below shows nine examples of tree drawing, with explanations of each tree. Some trees show common mistakes made when drawing the trees (\textsc{b}--\textsc{e}). The other trees show a few things that are okay (\textsc{a, f--i}).\\[1\baselineskip] \textit{Do not do \textsc{b, c, d,} or \textsc{e}!} \end{enumerate} \noindent\includegraphics[width=\textwidth]{03d_example_do_dont} \begin{enumerate} \def\labelenumi{\alph{enumi}.} \item This shows a \emph{Paramecium} giving rise first to \emph{E. coli} and then to \emph{Amoeba}. All three are alive today—they are \emph{extant}. This is okay, and a testable hypothesis. \item This shows a \emph{Paramecium} giving rise first to \emph{E. coli} and \emph{Amoeba}. The \emph{Paramecium} is not alive today, though, according to this hypothesis. It is extinct. How do I know? It is not represented as a branch leading to the top of the tree. What this says is that it evolved into something else, but no \emph{Paramecium} line lasted to the present. You would not want to do this because \emph{Paramecium} is a living organism today. \item This shows \emph{Paramecium} giving rise first to \emph{E. coli} and then \emph{Amoeba}. The \emph{E. coli} went extinct a little less than 2 million years ago (\textsc{mya}), the other two are extant. How do I know this? The \emph{E. coli} line branches off about 3 \textsc{mya} but stops less than 2 \textsc{mya}; this is when it became extinct. Again, \emph{E. coli} is a modern organism, so you cannot do this. \item This is probably impossible. It shows \emph{Amoeba} and \textit{Paramecium} merging to become one organism. Other than a few rare cases with plants, this just does not happen. \emph{E. coli} is shown joining them later. Again, this is highly unlikely. Now, you may be thinking that some organisms are formed by having two different species mate to produce a new species. In fact, one definition of a species in biology is a group of organisms that can mate with each other and produce fertile offspring, but \emph{cannot} mate with members of another species to produce fertile offspring. Horses and donkeys are two species; they can mate, but the offspring are mules and are sterile. This method of producing new species just does not work, except in a few instances involving \emph{very} closely related animals, or slightly less closely related plants. Usually, with animals, such matings only work with closely related species within the same genus, and not always then. On the other hand, members of a species \emph{can} become so different from the rest of the species that they can no longer mate with the others and produce fertile offspring. We then say that they constitute a new species. So, diagrams like \textsc{a}, \textsc{b}, and \textsc{c} can happen—we have actually observed the process of new species forming in the laboratory. But the process shown in \textsc{d} has only been observed in a few cases with closely related organisms. \item This is a common mistake when drawing a tree. What this shows is that \emph{Paramecium} evolved into \emph{Amoeba} which evolved into \emph{E. coli}. This says that only \emph{E. coli} is alive today, the other two organisms are extinct, and of course, they actually are not. \item This says that \emph{Paramecium} is now as it always has been and that it did not evolve into anything or evolve from anything. This is a plausible, testable hypothesis. \item This shows the same thing as \textsc{f}. You do not need to put the name at the bottom. This is okay. \item This shows that \emph{Paramecium} just appeared on Earth very recently. This is also okay. \item This shows that \emph{Paramecium} appeared on Earth a little more than 2 \textsc{mya}. Again, this is okay. \end{enumerate} \noindent\textbf{N\textsc{ote}: Use \emph{only} the 21 organisms listed on the first page of this assignment. Do not include the other organisms, such as \emph{Amoeba}, dog or gorilla, used in the examples above, or extinct organisms like dinosaurs.} \end{document}
Formal statement is: lemma Re_divide_Reals [simp]: "r \<in> \<real> \<Longrightarrow> Re (z / r) = Re z / Re r" Informal statement is: If $r$ is a real number, then $\frac{\text{Re}(z)}{\text{Re}(r)} = \text{Re}(\frac{z}{r})$.
Hurrah! A cooperative worldwide effort to rescue Thailand children trapped in a flooded cave rescued them all in less than 3 weeks from the time they entered the cave to the time of their rescue. It should be much easier, shouldn’t even take a heroic effort, to rescue children trapped in separation from their families at the Mexican border. These things are possible, but this week, the administration did not even meet the first deadline to get all the children below 5 years old reunited with their families. It should even be logistically possible with a cooperative world wide effort to develop economic systems that could rescue all the hungry children everywhere living in poverty. In the U.S. alone, 1 in 5 children live in poverty, according to a recently released United Nations report. Such inequality and poverty is a direct result of economic policies that are chosen by elected leaders. The solution is to elect different leaders than the ones in power now. Please consider carefully when you vote this November.
function fields = TmodelFields() % Returns the field names of the `Tmodel` structure. This is % to help alleviate control between different scripts. % Called by `cleanTmodel`, `readCbTmodel`, `verifyModel`, `organizeModelCool`, `TmodelStats`, `orderModelFieldsBorg`. % % USAGE: % % fields = TmodelFields() % % OUTPUTS: % Fields: A column cell array that contains the following in order: % % * rxnFields % * rNumField % * metFields % * mNumFields % * allFields % % Please cite: % `Sauls, J. T., & Buescher, J. M. (2014). Assimilating genome-scale % metabolic reconstructions with modelBorgifier. Bioinformatics % (Oxford, England), 30(7), 1036?8`. http://doi.org/10.1093/bioinformatics/btt747 % % .. % Edit the above text to modify the response to help addMetInfo % Last Modified by GUIDE v2.5 06-Dec-2013 14:19:28 % This file is published under Creative Commons BY-NC-SA. % % Correspondance: % [email protected] % % Developed at: % BRAIN Aktiengesellschaft % Microbial Production Technologies Unit % Quantitative Biology and Sequencing Platform % Darmstaeter Str. 34-36 % 64673 Zwingenberg, Germany % www.brain-biotech.de fields = cell(4,1) ; % Declare fields % Reaction related fields that are cell arrays. rxnFields = {'rxns' 'rxnID' 'rxnNames' 'subSystems' 'rxnECNumbers' ... 'rxnKEGGID' 'rxnSEEDID' 'rxnEquations' ... 'rxnReferences' 'rxnNotes' 'grRules'}' ; fields{1,1} = rxnFields ; % Reaction related fields that are numeric arrays. rNumFields = {'lb' 'ub' 'c'}' ; fields{2,1} = rNumFields ; % Metabolite related fields that are cell arrays metFields = {'mets' 'metID' 'metNames' 'metFormulas' ... 'metKEGGID' 'metSEEDID' ... 'metChEBIID' 'metPubChemID' 'metInChIString'}' ; fields{3,1} = metFields ; % Metabolite related fields that are numeric arrays. mNumFields = {'metCharge'} ; fields{4,1} = mNumFields ; % All field names in correct order (27 fields). allFields = {'rxns' 'mets' 'S' 'lb' 'ub' 'c' ... 'rxnID' 'rxnNames' 'subSystems' 'rxnEquations' ... 'rxnECNumbers' 'rxnKEGGID' 'rxnSEEDID' ... 'rxnReferences' 'rxnNotes' 'grRules' ... 'metID' 'metNames' 'metFormulas' 'metCharge' ... 'metKEGGID' 'metSEEDID' 'metChEBIID' 'metPubChemID' ... 'metInChIString' ... 'genes' 'description'}' ; fields{5,1} = allFields ;
Require Import Coq.Program.Basics. Require Import Coq.Logic.FunctionalExtensionality. Require Import Coq.Program.Combinators. Require Import Setoid. Require Import ZArith. Require Import Psatz. Require Import FinProof.Common. Require Import FinProof.CommonInstances. Require Import FinProof.StateMonad2. Require Import FinProof.StateMonadInstances. Require Import FinProof.ProgrammingWith. Local Open Scope struct_scope. Require Import FinProof.CommonProofs. Require Import depoolContract.ProofEnvironment. Require Import depoolContract.DePoolClass. Require Import depoolContract.SolidityNotations. Require Import depoolContract.NewProofs.ProofHelpers. Require Import depoolContract.DePoolFunc. (* Set Typeclasses Iterative Deepening. Set Typeclasses Depth 100. *) Require Import depoolContract.Lib.CommonModelProofs. Module CommonModelProofs := CommonModelProofs StateMonadSig. Import CommonModelProofs. Require Import depoolContract.Lib.Tactics. Require Import depoolContract.Lib.ErrorValueProofs. Require Import depoolContract.Lib.CommonCommon. (* Require Import MultiSigWallet.Proofs.tvmFunctionsProofs. *) Import DePoolSpec.LedgerClass.SolidityNotations. Local Open Scope struct_scope. Local Open Scope Z_scope. Local Open Scope solidity_scope. Require Import Lists.List. Import ListNotations. Local Open Scope list_scope. Require Import depoolContract.DePoolConsts. Module DePoolContract_Ф_updateRound2 (dc : DePoolConstsTypesSig XTypesSig StateMonadSig). Module DePoolFuncs := DePoolFuncs XTypesSig StateMonadSig dc. Module ProofHelpers := ProofHelpers dc. Import dc. Import ProofHelpers. Import DePoolFuncs. Import DePoolSpec. Import LedgerClass. Opaque Z.eqb Z.add Z.sub Z.div Z.mul hmapLookup hmapInsert Z.ltb Z.geb Z.leb Z.gtb Z.modulo. Opaque DePoolContract_Ф_startRoundCompleting ProxyBase_Ф__recoverStake. Lemma DePoolContract_Ф_updateRound2_exec : forall ( Л_round2 : RoundsBase_ι_Round ) ( Л_prevValidatorHash : XInteger256 ) ( Л_curValidatorHash : XInteger256 ) ( Л_validationStart : XInteger32 ) (l: Ledger) , let round2 := Л_round2 in let if1 : bool := eqb ( round2 ->> RoundsBase_ι_Round_ι_step ) RoundsBase_ι_RoundStepP_ι_WaitingValidatorRequest in let if2 : bool := eqb ( round2 ->> RoundsBase_ι_Round_ι_completionReason ) RoundsBase_ι_CompletionReasonP_ι_Undefined in let if3 : bool := eqb (round2 ->> RoundsBase_ι_Round_ι_step ) RoundsBase_ι_RoundStepP_ι_Completing in let round2 := if if1 then if if2 then {$ round2 with (RoundsBase_ι_Round_ι_step, RoundsBase_ι_RoundStepP_ι_WaitingUnfreeze); (RoundsBase_ι_Round_ι_completionReason, RoundsBase_ι_CompletionReasonP_ι_NoValidatorRequest); (RoundsBase_ι_Round_ι_unfreeze, 0) $} else {$ round2 with (RoundsBase_ι_Round_ι_step, RoundsBase_ι_RoundStepP_ι_WaitingUnfreeze); (RoundsBase_ι_Round_ι_unfreeze, 0) $} else round2 in let oldMessages := VMState_ι_messages ( Ledger_ι_VMState l ) in let oldEvents := VMState_ι_events ( Ledger_ι_VMState l ) in let newMessage := {| contractAddress := 0 ; contractFunction := DePoolContract_Ф_completeRoundWithChunkF round2->>RoundsBase_ι_Round_ι_id 1 ; contractMessage := {| messageValue := 0 ; messageFlag := 0 ; messageBounce := false |} |} in let l' := if if1 then l else if if3 then {$ l With (VMState_ι_messages, newMessage :: oldMessages ) $} else l in let if4 : bool := ( ( negb ( eqb ( round2 ->> RoundsBase_ι_Round_ι_vsetHashInElectionPhase ) Л_curValidatorHash ) ) && ( negb ( eqb ( round2 ->> RoundsBase_ι_Round_ι_vsetHashInElectionPhase ) Л_prevValidatorHash ) ) && ( eqb (round2 ->> RoundsBase_ι_Round_ι_unfreeze) DePoolLib_ι_MAX_TIME ) )%bool in let round2 := if if4 then {$ round2 with (RoundsBase_ι_Round_ι_unfreeze, Л_validationStart + round2->>RoundsBase_ι_Round_ι_stakeHeldFor) $} else round2 in let if5 : bool := ( eval_state tvm_now l ) >=? ( (round2 ->> RoundsBase_ι_Round_ι_unfreeze) + DePoolLib_ι_ELECTOR_UNFREEZE_LAG ) in let if6 : bool := (( eqb (round2 ->> RoundsBase_ι_Round_ι_step) RoundsBase_ι_RoundStepP_ι_WaitingUnfreeze ) && negb ( eqb (round2 ->> RoundsBase_ι_Round_ι_completionReason) RoundsBase_ι_CompletionReasonP_ι_Undefined ))%bool in (* let if7 : bool := ( round2 ->> RoundsBase_ι_Round_ι_participantQty ) =? 0 in *) let if8 : bool := ( ( eqb (round2 ->> RoundsBase_ι_Round_ι_step) RoundsBase_ι_RoundStepP_ι_WaitingValidationStart ) || ( eqb (round2 ->> RoundsBase_ι_Round_ι_step) RoundsBase_ι_RoundStepP_ι_WaitingUnfreeze ))%bool in (* let round2' := if if5 then if if6 then eval_state ( ↓ DePoolContract_Ф_startRoundCompleting round2 round2 ->> RoundsBase_ι_Round_ι_completionReason) l' else if if8 then {$ round2 with (RoundsBase_ι_Round_ι_step, RoundsBase_ι_RoundStepP_ι_WaitingReward) $} else round2 else round2 in *) let l'' := if if5 then if if6 then exec_state ( ↓ DePoolContract_Ф_startRoundCompleting round2 round2 ->> RoundsBase_ι_Round_ι_completionReason) l' else if if8 then exec_state ( ↓ ProxyBase_Ф__recoverStake round2 ->> RoundsBase_ι_Round_ι_proxy round2 ->> RoundsBase_ι_Round_ι_id round2 ->> RoundsBase_ι_Round_ι_elector ) l' else l' else l' in exec_state ( ↓ DePoolContract_Ф_updateRound2 Л_round2 Л_prevValidatorHash Л_curValidatorHash Л_validationStart ) l = l''. Proof. intros. destructLedger l. destruct Л_round2. compute. idtac. Time do 3 destructIf_solve. idtac. - destruct (RoundsBase_ι_Round_ι_vsetHashInElectionPhase =? Л_curValidatorHash); destruct (RoundsBase_ι_Round_ι_vsetHashInElectionPhase =? Л_prevValidatorHash); destruct (0 =? DePoolLib_ι_MAX_TIME); try discriminate. idtac. time repeat destructIf_solve. idtac. destructFunction2 DePoolContract_Ф_startRoundCompleting; auto. - idtac. destruct (RoundsBase_ι_Round_ι_vsetHashInElectionPhase =? Л_curValidatorHash); destruct (RoundsBase_ι_Round_ι_vsetHashInElectionPhase =? Л_prevValidatorHash); destruct (0 =? DePoolLib_ι_MAX_TIME); try discriminate. idtac. all: time repeat destructIf_solve. idtac. all: destructFunction2 DePoolContract_Ф_startRoundCompleting; auto. - idtac. destruct (RoundsBase_ι_Round_ι_vsetHashInElectionPhase =? Л_curValidatorHash); destruct (RoundsBase_ι_Round_ι_vsetHashInElectionPhase =? Л_prevValidatorHash); destruct (0 =? DePoolLib_ι_MAX_TIME); try discriminate. idtac. all: time repeat destructIf_solve. idtac. all: destructFunction2 DePoolContract_Ф_startRoundCompleting; auto. - idtac. destruct (RoundsBase_ι_Round_ι_vsetHashInElectionPhase =? Л_curValidatorHash); destruct (RoundsBase_ι_Round_ι_vsetHashInElectionPhase =? Л_prevValidatorHash); destruct (0 =? DePoolLib_ι_MAX_TIME); try discriminate. idtac. all: time repeat destructIf_solve. idtac. all: destructFunction2 DePoolContract_Ф_startRoundCompleting; auto. - idtac. destruct (RoundsBase_ι_Round_ι_vsetHashInElectionPhase =? Л_curValidatorHash); destruct (RoundsBase_ι_Round_ι_vsetHashInElectionPhase =? Л_prevValidatorHash); destruct (RoundsBase_ι_Round_ι_unfreeze =? DePoolLib_ι_MAX_TIME); try discriminate. idtac. all: time repeat destructIf_solve. idtac. all: destructFunction2 DePoolContract_Ф_startRoundCompleting; auto. - idtac. destruct (RoundsBase_ι_Round_ι_vsetHashInElectionPhase =? Л_curValidatorHash); destruct (RoundsBase_ι_Round_ι_vsetHashInElectionPhase =? Л_prevValidatorHash); destruct (RoundsBase_ι_Round_ι_unfreeze =? DePoolLib_ι_MAX_TIME); try discriminate. idtac. all: time repeat destructIf_solve. idtac. all: destructFunction2 DePoolContract_Ф_startRoundCompleting; auto. - idtac. destruct (RoundsBase_ι_Round_ι_vsetHashInElectionPhase =? Л_curValidatorHash); destruct (RoundsBase_ι_Round_ι_vsetHashInElectionPhase =? Л_prevValidatorHash); destruct (RoundsBase_ι_Round_ι_unfreeze =? DePoolLib_ι_MAX_TIME); try discriminate. idtac. all: time repeat destructIf_solve. idtac. all: destructFunction2 DePoolContract_Ф_startRoundCompleting; auto. - idtac. destruct (RoundsBase_ι_Round_ι_vsetHashInElectionPhase =? Л_curValidatorHash); destruct (RoundsBase_ι_Round_ι_vsetHashInElectionPhase =? Л_prevValidatorHash); destruct (RoundsBase_ι_Round_ι_unfreeze =? DePoolLib_ι_MAX_TIME); try discriminate. idtac. all: time repeat destructIf_solve. idtac. all: destructFunction2 DePoolContract_Ф_startRoundCompleting; auto. Qed. Lemma DePoolContract_Ф_updateRound2_eval : forall ( Л_round2 : RoundsBase_ι_Round ) ( Л_prevValidatorHash : XInteger256 ) ( Л_curValidatorHash : XInteger256 ) ( Л_validationStart : XInteger32 ) (l: Ledger) , let round2 := Л_round2 in let if1 : bool := eqb ( round2 ->> RoundsBase_ι_Round_ι_step ) RoundsBase_ι_RoundStepP_ι_WaitingValidatorRequest in let if2 : bool := eqb ( round2 ->> RoundsBase_ι_Round_ι_completionReason ) RoundsBase_ι_CompletionReasonP_ι_Undefined in let if3 : bool := eqb (round2 ->> RoundsBase_ι_Round_ι_step ) RoundsBase_ι_RoundStepP_ι_Completing in let round2 := if if1 then if if2 then {$ round2 with (RoundsBase_ι_Round_ι_step, RoundsBase_ι_RoundStepP_ι_WaitingUnfreeze); (RoundsBase_ι_Round_ι_completionReason, RoundsBase_ι_CompletionReasonP_ι_NoValidatorRequest); (RoundsBase_ι_Round_ι_unfreeze, 0) $} else {$ round2 with (RoundsBase_ι_Round_ι_step, RoundsBase_ι_RoundStepP_ι_WaitingUnfreeze); (RoundsBase_ι_Round_ι_unfreeze, 0) $} else round2 in let oldMessages := VMState_ι_messages ( Ledger_ι_VMState l ) in let newMessage := {| contractAddress := 0 ; contractFunction := DePoolContract_Ф_completeRoundWithChunkF round2->>RoundsBase_ι_Round_ι_id 1 ; contractMessage := {| messageValue := 0 ; messageFlag := 0 ; messageBounce := false |} |} in let l' := if if1 then l else if if3 then {$ l With (VMState_ι_messages, newMessage :: oldMessages ) $} else l in let if4 : bool := (( negb ( eqb ( round2 ->> RoundsBase_ι_Round_ι_vsetHashInElectionPhase ) Л_curValidatorHash ) ) && ( negb ( eqb ( round2 ->> RoundsBase_ι_Round_ι_vsetHashInElectionPhase ) Л_prevValidatorHash ) ) && ( eqb (round2 ->> RoundsBase_ι_Round_ι_unfreeze) DePoolLib_ι_MAX_TIME ) )%bool in let round2 := if if4 then {$ round2 with (RoundsBase_ι_Round_ι_unfreeze, Л_validationStart + round2->>RoundsBase_ι_Round_ι_stakeHeldFor) $} else round2 in let if5 : bool := ( eval_state tvm_now l ) >=? ( (round2 ->> RoundsBase_ι_Round_ι_unfreeze) + DePoolLib_ι_ELECTOR_UNFREEZE_LAG ) in let if6 : bool := (( eqb (round2 ->> RoundsBase_ι_Round_ι_step) RoundsBase_ι_RoundStepP_ι_WaitingUnfreeze ) && negb ( eqb (round2 ->> RoundsBase_ι_Round_ι_completionReason) RoundsBase_ι_CompletionReasonP_ι_Undefined ))%bool in let if8 : bool := ( ( eqb (round2 ->> RoundsBase_ι_Round_ι_step) RoundsBase_ι_RoundStepP_ι_WaitingValidationStart ) || ( eqb (round2 ->> RoundsBase_ι_Round_ι_step) RoundsBase_ι_RoundStepP_ι_WaitingUnfreeze ))%bool in let round2 := if if5 then if if6 then eval_state ( ↓ DePoolContract_Ф_startRoundCompleting round2 round2 ->> RoundsBase_ι_Round_ι_completionReason) l' else if if8 then {$ round2 with (RoundsBase_ι_Round_ι_step, RoundsBase_ι_RoundStepP_ι_WaitingReward) $} else round2 else round2 in eval_state ( ↓ DePoolContract_Ф_updateRound2 Л_round2 Л_prevValidatorHash Л_curValidatorHash Л_validationStart ) l = round2. Proof. intros. destructLedger l. destruct Л_round2. compute. idtac. Time do 3 destructIf_solve. idtac. - idtac. destruct (RoundsBase_ι_Round_ι_vsetHashInElectionPhase =? Л_curValidatorHash); destruct (RoundsBase_ι_Round_ι_vsetHashInElectionPhase =? Л_prevValidatorHash); destruct (0 =? DePoolLib_ι_MAX_TIME); try discriminate. idtac. time repeat destructIf_solve. idtac. destructFunction2 DePoolContract_Ф_startRoundCompleting; auto. - idtac. destruct (RoundsBase_ι_Round_ι_vsetHashInElectionPhase =? Л_curValidatorHash); destruct (RoundsBase_ι_Round_ι_vsetHashInElectionPhase =? Л_prevValidatorHash); destruct (0 =? DePoolLib_ι_MAX_TIME); try discriminate. idtac. all: time repeat destructIf_solve. idtac. all: destructFunction2 DePoolContract_Ф_startRoundCompleting; auto. - idtac. destruct (RoundsBase_ι_Round_ι_vsetHashInElectionPhase =? Л_curValidatorHash); destruct (RoundsBase_ι_Round_ι_vsetHashInElectionPhase =? Л_prevValidatorHash); destruct (0 =? DePoolLib_ι_MAX_TIME); try discriminate. idtac. all: time repeat destructIf_solve. idtac. all: destructFunction2 DePoolContract_Ф_startRoundCompleting; auto. - idtac. destruct (RoundsBase_ι_Round_ι_vsetHashInElectionPhase =? Л_curValidatorHash); destruct (RoundsBase_ι_Round_ι_vsetHashInElectionPhase =? Л_prevValidatorHash); destruct (0 =? DePoolLib_ι_MAX_TIME); try discriminate. idtac. all: time repeat destructIf_solve. idtac. all: destructFunction2 DePoolContract_Ф_startRoundCompleting; auto. - idtac. destruct (RoundsBase_ι_Round_ι_vsetHashInElectionPhase =? Л_curValidatorHash); destruct (RoundsBase_ι_Round_ι_vsetHashInElectionPhase =? Л_prevValidatorHash); destruct (RoundsBase_ι_Round_ι_unfreeze =? DePoolLib_ι_MAX_TIME); try discriminate. idtac. all: time repeat destructIf_solve. idtac. all: destructFunction2 DePoolContract_Ф_startRoundCompleting; auto. - idtac. destruct (RoundsBase_ι_Round_ι_vsetHashInElectionPhase =? Л_curValidatorHash); destruct (RoundsBase_ι_Round_ι_vsetHashInElectionPhase =? Л_prevValidatorHash); destruct (RoundsBase_ι_Round_ι_unfreeze =? DePoolLib_ι_MAX_TIME); try discriminate. idtac. all: time repeat destructIf_solve. idtac. all: destructFunction2 DePoolContract_Ф_startRoundCompleting; auto. - idtac. destruct (RoundsBase_ι_Round_ι_vsetHashInElectionPhase =? Л_curValidatorHash); destruct (RoundsBase_ι_Round_ι_vsetHashInElectionPhase =? Л_prevValidatorHash); destruct (RoundsBase_ι_Round_ι_unfreeze =? DePoolLib_ι_MAX_TIME); try discriminate. idtac. all: time repeat destructIf_solve. idtac. all: destructFunction2 DePoolContract_Ф_startRoundCompleting; auto. - idtac. destruct (RoundsBase_ι_Round_ι_vsetHashInElectionPhase =? Л_curValidatorHash); destruct (RoundsBase_ι_Round_ι_vsetHashInElectionPhase =? Л_prevValidatorHash); destruct (RoundsBase_ι_Round_ι_unfreeze =? DePoolLib_ι_MAX_TIME); try discriminate. idtac. all: time repeat destructIf_solve. idtac. all: destructFunction2 DePoolContract_Ф_startRoundCompleting; auto. Qed. End DePoolContract_Ф_updateRound2.
[GOAL] α : Type u_1 F : Type u_2 m : MeasurableSpace α μ : Measure α inst✝ : NormedAddCommGroup F f : α → ℝ h : Memℒp f 2 ⊢ Integrable fun x => f x ^ 2 [PROOFSTEP] simpa [← memℒp_one_iff_integrable] using h.norm_rpow two_ne_zero ENNReal.two_ne_top [GOAL] α : Type u_1 F : Type u_2 m : MeasurableSpace α μ : Measure α inst✝ : NormedAddCommGroup F f : α → F hf : AEStronglyMeasurable f μ ⊢ Memℒp f 2 ↔ Integrable fun x => ‖f x‖ ^ 2 [PROOFSTEP] rw [← memℒp_one_iff_integrable] [GOAL] α : Type u_1 F : Type u_2 m : MeasurableSpace α μ : Measure α inst✝ : NormedAddCommGroup F f : α → F hf : AEStronglyMeasurable f μ ⊢ Memℒp f 2 ↔ Memℒp (fun x => ‖f x‖ ^ 2) 1 [PROOFSTEP] convert (memℒp_norm_rpow_iff hf two_ne_zero ENNReal.two_ne_top).symm [GOAL] case h.e'_2.h.e'_5.h α : Type u_1 F : Type u_2 m : MeasurableSpace α μ : Measure α inst✝ : NormedAddCommGroup F f : α → F hf : AEStronglyMeasurable f μ x✝ : α ⊢ ‖f x✝‖ ^ 2 = ‖f x✝‖ ^ ENNReal.toReal 2 [PROOFSTEP] simp [GOAL] case h.e'_2.h.e'_6 α : Type u_1 F : Type u_2 m : MeasurableSpace α μ : Measure α inst✝ : NormedAddCommGroup F f : α → F hf : AEStronglyMeasurable f μ ⊢ 1 = 2 / 2 [PROOFSTEP] rw [div_eq_mul_inv, ENNReal.mul_inv_cancel two_ne_zero ENNReal.two_ne_top] [GOAL] α : Type u_1 F : Type u_2 m : MeasurableSpace α μ : Measure α inst✝ : NormedAddCommGroup F f : α → ℝ hf : AEStronglyMeasurable f μ ⊢ Memℒp f 2 ↔ Integrable fun x => f x ^ 2 [PROOFSTEP] convert memℒp_two_iff_integrable_sq_norm hf using 3 [GOAL] case h.e'_2.h.e'_5.h α : Type u_1 F : Type u_2 m : MeasurableSpace α μ : Measure α inst✝ : NormedAddCommGroup F f : α → ℝ hf : AEStronglyMeasurable f μ x✝ : α ⊢ f x✝ ^ 2 = ‖f x✝‖ ^ 2 [PROOFSTEP] simp [GOAL] α : Type u_1 m : MeasurableSpace α p : ℝ≥0∞ μ : Measure α E : Type u_2 𝕜 : Type u_3 inst✝² : IsROrC 𝕜 inst✝¹ : NormedAddCommGroup E inst✝ : InnerProductSpace 𝕜 E f : α → E hf : Memℒp f p c : E x : α ⊢ ‖inner (f x) c‖ ≤ ?m.29677 hf c * ‖f x‖ [PROOFSTEP] rw [mul_comm] [GOAL] α : Type u_1 m : MeasurableSpace α p : ℝ≥0∞ μ : Measure α E : Type u_2 𝕜 : Type u_3 inst✝² : IsROrC 𝕜 inst✝¹ : NormedAddCommGroup E inst✝ : InnerProductSpace 𝕜 E f : α → E hf : Memℒp f p c : E x : α ⊢ ‖inner (f x) c‖ ≤ ‖f x‖ * ?m.29677 hf c α : Type u_1 m : MeasurableSpace α p : ℝ≥0∞ μ : Measure α E : Type u_2 𝕜 : Type u_3 inst✝² : IsROrC 𝕜 inst✝¹ : NormedAddCommGroup E inst✝ : InnerProductSpace 𝕜 E ⊢ {f : α → E} → Memℒp f p → E → ℝ [PROOFSTEP] exact norm_inner_le_norm _ _ [GOAL] α : Type u_1 m : MeasurableSpace α p : ℝ≥0∞ μ : Measure α E : Type u_2 𝕜 : Type u_3 inst✝² : IsROrC 𝕜 inst✝¹ : NormedAddCommGroup E inst✝ : InnerProductSpace 𝕜 E f : α → E c : E hf : Integrable f ⊢ Integrable fun x => inner c (f x) [PROOFSTEP] rw [← memℒp_one_iff_integrable] at hf ⊢ [GOAL] α : Type u_1 m : MeasurableSpace α p : ℝ≥0∞ μ : Measure α E : Type u_2 𝕜 : Type u_3 inst✝² : IsROrC 𝕜 inst✝¹ : NormedAddCommGroup E inst✝ : InnerProductSpace 𝕜 E f : α → E c : E hf : Memℒp f 1 ⊢ Memℒp (fun x => inner c (f x)) 1 [PROOFSTEP] exact hf.const_inner c [GOAL] α : Type u_1 m : MeasurableSpace α p : ℝ≥0∞ μ : Measure α E : Type u_2 𝕜 : Type u_3 inst✝² : IsROrC 𝕜 inst✝¹ : NormedAddCommGroup E inst✝ : InnerProductSpace 𝕜 E f : α → E hf : Integrable f c : E ⊢ Integrable fun x => inner (f x) c [PROOFSTEP] rw [← memℒp_one_iff_integrable] at hf ⊢ [GOAL] α : Type u_1 m : MeasurableSpace α p : ℝ≥0∞ μ : Measure α E : Type u_2 𝕜 : Type u_3 inst✝² : IsROrC 𝕜 inst✝¹ : NormedAddCommGroup E inst✝ : InnerProductSpace 𝕜 E f : α → E hf : Memℒp f 1 c : E ⊢ Memℒp (fun x => inner (f x) c) 1 [PROOFSTEP] exact hf.inner_const c [GOAL] α : Type u_1 m : MeasurableSpace α p : ℝ≥0∞ μ : Measure α E : Type u_2 𝕜 : Type u_3 inst✝⁴ : IsROrC 𝕜 inst✝³ : NormedAddCommGroup E inst✝² : InnerProductSpace 𝕜 E f✝ : α → E inst✝¹ : CompleteSpace E inst✝ : NormedSpace ℝ E f : α → E hf : Integrable f hf_int : ∀ (c : E), ∫ (x : α), inner c (f x) ∂μ = 0 ⊢ ∫ (x : α), f x ∂μ = 0 [PROOFSTEP] specialize hf_int (∫ x, f x ∂μ) [GOAL] α : Type u_1 m : MeasurableSpace α p : ℝ≥0∞ μ : Measure α E : Type u_2 𝕜 : Type u_3 inst✝⁴ : IsROrC 𝕜 inst✝³ : NormedAddCommGroup E inst✝² : InnerProductSpace 𝕜 E f✝ : α → E inst✝¹ : CompleteSpace E inst✝ : NormedSpace ℝ E f : α → E hf : Integrable f hf_int : ∫ (x : α), inner (∫ (x : α), f x ∂μ) (f x) ∂μ = 0 ⊢ ∫ (x : α), f x ∂μ = 0 [PROOFSTEP] rwa [integral_inner hf, inner_self_eq_zero] at hf_int [GOAL] α : Type u_1 E : Type u_2 F : Type u_3 𝕜 : Type u_4 inst✝⁴ : IsROrC 𝕜 inst✝³ : MeasurableSpace α μ : Measure α inst✝² : NormedAddCommGroup E inst✝¹ : InnerProductSpace 𝕜 E inst✝ : NormedAddCommGroup F f : { x // x ∈ Lp F 2 } ⊢ snorm (fun x => ‖↑↑f x‖ ^ 2) 1 μ < ⊤ [PROOFSTEP] have h_two : ENNReal.ofReal (2 : ℝ) = 2 := by simp [zero_le_one] [GOAL] α : Type u_1 E : Type u_2 F : Type u_3 𝕜 : Type u_4 inst✝⁴ : IsROrC 𝕜 inst✝³ : MeasurableSpace α μ : Measure α inst✝² : NormedAddCommGroup E inst✝¹ : InnerProductSpace 𝕜 E inst✝ : NormedAddCommGroup F f : { x // x ∈ Lp F 2 } ⊢ ENNReal.ofReal 2 = 2 [PROOFSTEP] simp [zero_le_one] [GOAL] α : Type u_1 E : Type u_2 F : Type u_3 𝕜 : Type u_4 inst✝⁴ : IsROrC 𝕜 inst✝³ : MeasurableSpace α μ : Measure α inst✝² : NormedAddCommGroup E inst✝¹ : InnerProductSpace 𝕜 E inst✝ : NormedAddCommGroup F f : { x // x ∈ Lp F 2 } h_two : ENNReal.ofReal 2 = 2 ⊢ snorm (fun x => ‖↑↑f x‖ ^ 2) 1 μ < ⊤ [PROOFSTEP] rw [snorm_norm_rpow f zero_lt_two, one_mul, h_two] [GOAL] α : Type u_1 E : Type u_2 F : Type u_3 𝕜 : Type u_4 inst✝⁴ : IsROrC 𝕜 inst✝³ : MeasurableSpace α μ : Measure α inst✝² : NormedAddCommGroup E inst✝¹ : InnerProductSpace 𝕜 E inst✝ : NormedAddCommGroup F f : { x // x ∈ Lp F 2 } h_two : ENNReal.ofReal 2 = 2 ⊢ snorm (↑↑f) 2 μ ^ 2 < ⊤ [PROOFSTEP] exact ENNReal.rpow_lt_top_of_nonneg zero_le_two (Lp.snorm_ne_top f) [GOAL] α : Type u_1 E : Type u_2 F : Type u_3 𝕜 : Type u_4 inst✝⁴ : IsROrC 𝕜 inst✝³ : MeasurableSpace α μ : Measure α inst✝² : NormedAddCommGroup E inst✝¹ : InnerProductSpace 𝕜 E inst✝ : NormedAddCommGroup F f g : { x // x ∈ Lp E 2 } ⊢ snorm (fun x => inner (↑↑f x) (↑↑g x)) 1 μ < ⊤ [PROOFSTEP] have h : ∀ x, ‖⟪f x, g x⟫‖ ≤ ‖‖f x‖ ^ (2 : ℝ) + ‖g x‖ ^ (2 : ℝ)‖ := by intro x rw [← @Nat.cast_two ℝ, Real.rpow_nat_cast, Real.rpow_nat_cast] calc ‖⟪f x, g x⟫‖ ≤ ‖f x‖ * ‖g x‖ := norm_inner_le_norm _ _ _ ≤ 2 * ‖f x‖ * ‖g x‖ := (mul_le_mul_of_nonneg_right (le_mul_of_one_le_left (norm_nonneg _) one_le_two) (norm_nonneg _)) _ ≤ ‖‖f x‖ ^ 2 + ‖g x‖ ^ 2‖ := (two_mul_le_add_sq _ _).trans (le_abs_self _) [GOAL] α : Type u_1 E : Type u_2 F : Type u_3 𝕜 : Type u_4 inst✝⁴ : IsROrC 𝕜 inst✝³ : MeasurableSpace α μ : Measure α inst✝² : NormedAddCommGroup E inst✝¹ : InnerProductSpace 𝕜 E inst✝ : NormedAddCommGroup F f g : { x // x ∈ Lp E 2 } ⊢ ∀ (x : α), ‖inner (↑↑f x) (↑↑g x)‖ ≤ ‖‖↑↑f x‖ ^ 2 + ‖↑↑g x‖ ^ 2‖ [PROOFSTEP] intro x [GOAL] α : Type u_1 E : Type u_2 F : Type u_3 𝕜 : Type u_4 inst✝⁴ : IsROrC 𝕜 inst✝³ : MeasurableSpace α μ : Measure α inst✝² : NormedAddCommGroup E inst✝¹ : InnerProductSpace 𝕜 E inst✝ : NormedAddCommGroup F f g : { x // x ∈ Lp E 2 } x : α ⊢ ‖inner (↑↑f x) (↑↑g x)‖ ≤ ‖‖↑↑f x‖ ^ 2 + ‖↑↑g x‖ ^ 2‖ [PROOFSTEP] rw [← @Nat.cast_two ℝ, Real.rpow_nat_cast, Real.rpow_nat_cast] [GOAL] α : Type u_1 E : Type u_2 F : Type u_3 𝕜 : Type u_4 inst✝⁴ : IsROrC 𝕜 inst✝³ : MeasurableSpace α μ : Measure α inst✝² : NormedAddCommGroup E inst✝¹ : InnerProductSpace 𝕜 E inst✝ : NormedAddCommGroup F f g : { x // x ∈ Lp E 2 } x : α ⊢ ‖inner (↑↑f x) (↑↑g x)‖ ≤ ‖‖↑↑f x‖ ^ 2 + ‖↑↑g x‖ ^ 2‖ [PROOFSTEP] calc ‖⟪f x, g x⟫‖ ≤ ‖f x‖ * ‖g x‖ := norm_inner_le_norm _ _ _ ≤ 2 * ‖f x‖ * ‖g x‖ := (mul_le_mul_of_nonneg_right (le_mul_of_one_le_left (norm_nonneg _) one_le_two) (norm_nonneg _)) _ ≤ ‖‖f x‖ ^ 2 + ‖g x‖ ^ 2‖ := (two_mul_le_add_sq _ _).trans (le_abs_self _) [GOAL] α : Type u_1 E : Type u_2 F : Type u_3 𝕜 : Type u_4 inst✝⁴ : IsROrC 𝕜 inst✝³ : MeasurableSpace α μ : Measure α inst✝² : NormedAddCommGroup E inst✝¹ : InnerProductSpace 𝕜 E inst✝ : NormedAddCommGroup F f g : { x // x ∈ Lp E 2 } h : ∀ (x : α), ‖inner (↑↑f x) (↑↑g x)‖ ≤ ‖‖↑↑f x‖ ^ 2 + ‖↑↑g x‖ ^ 2‖ ⊢ snorm (fun x => inner (↑↑f x) (↑↑g x)) 1 μ < ⊤ [PROOFSTEP] refine' (snorm_mono_ae (ae_of_all _ h)).trans_lt ((snorm_add_le _ _ le_rfl).trans_lt _) [GOAL] case refine'_1 α : Type u_1 E : Type u_2 F : Type u_3 𝕜 : Type u_4 inst✝⁴ : IsROrC 𝕜 inst✝³ : MeasurableSpace α μ : Measure α inst✝² : NormedAddCommGroup E inst✝¹ : InnerProductSpace 𝕜 E inst✝ : NormedAddCommGroup F f g : { x // x ∈ Lp E 2 } h : ∀ (x : α), ‖inner (↑↑f x) (↑↑g x)‖ ≤ ‖‖↑↑f x‖ ^ 2 + ‖↑↑g x‖ ^ 2‖ ⊢ AEStronglyMeasurable (fun a => ‖↑↑f a‖ ^ 2) μ [PROOFSTEP] exact ((Lp.aestronglyMeasurable f).norm.aemeasurable.pow_const _).aestronglyMeasurable [GOAL] case refine'_2 α : Type u_1 E : Type u_2 F : Type u_3 𝕜 : Type u_4 inst✝⁴ : IsROrC 𝕜 inst✝³ : MeasurableSpace α μ : Measure α inst✝² : NormedAddCommGroup E inst✝¹ : InnerProductSpace 𝕜 E inst✝ : NormedAddCommGroup F f g : { x // x ∈ Lp E 2 } h : ∀ (x : α), ‖inner (↑↑f x) (↑↑g x)‖ ≤ ‖‖↑↑f x‖ ^ 2 + ‖↑↑g x‖ ^ 2‖ ⊢ AEStronglyMeasurable (fun a => ‖↑↑g a‖ ^ 2) μ [PROOFSTEP] exact ((Lp.aestronglyMeasurable g).norm.aemeasurable.pow_const _).aestronglyMeasurable [GOAL] case refine'_3 α : Type u_1 E : Type u_2 F : Type u_3 𝕜 : Type u_4 inst✝⁴ : IsROrC 𝕜 inst✝³ : MeasurableSpace α μ : Measure α inst✝² : NormedAddCommGroup E inst✝¹ : InnerProductSpace 𝕜 E inst✝ : NormedAddCommGroup F f g : { x // x ∈ Lp E 2 } h : ∀ (x : α), ‖inner (↑↑f x) (↑↑g x)‖ ≤ ‖‖↑↑f x‖ ^ 2 + ‖↑↑g x‖ ^ 2‖ ⊢ snorm (fun a => ‖↑↑f a‖ ^ 2) 1 μ + snorm (fun a => ‖↑↑g a‖ ^ 2) 1 μ < ⊤ [PROOFSTEP] rw [ENNReal.add_lt_top] [GOAL] case refine'_3 α : Type u_1 E : Type u_2 F : Type u_3 𝕜 : Type u_4 inst✝⁴ : IsROrC 𝕜 inst✝³ : MeasurableSpace α μ : Measure α inst✝² : NormedAddCommGroup E inst✝¹ : InnerProductSpace 𝕜 E inst✝ : NormedAddCommGroup F f g : { x // x ∈ Lp E 2 } h : ∀ (x : α), ‖inner (↑↑f x) (↑↑g x)‖ ≤ ‖‖↑↑f x‖ ^ 2 + ‖↑↑g x‖ ^ 2‖ ⊢ snorm (fun a => ‖↑↑f a‖ ^ 2) 1 μ < ⊤ ∧ snorm (fun a => ‖↑↑g a‖ ^ 2) 1 μ < ⊤ [PROOFSTEP] exact ⟨snorm_rpow_two_norm_lt_top f, snorm_rpow_two_norm_lt_top g⟩ [GOAL] α : Type u_1 E : Type u_2 F : Type u_3 𝕜 : Type u_4 inst✝⁴ : IsROrC 𝕜 inst✝³ : MeasurableSpace α μ : Measure α inst✝² : NormedAddCommGroup E inst✝¹ : InnerProductSpace 𝕜 E inst✝ : NormedAddCommGroup F f : { x // x ∈ Lp E 2 } ⊢ ∫ (a : α), inner (↑↑f a) (↑↑f a) ∂μ = ↑(ENNReal.toReal (∫⁻ (a : α), ↑‖↑↑f a‖₊ ^ 2 ∂μ)) [PROOFSTEP] simp_rw [inner_self_eq_norm_sq_to_K] [GOAL] α : Type u_1 E : Type u_2 F : Type u_3 𝕜 : Type u_4 inst✝⁴ : IsROrC 𝕜 inst✝³ : MeasurableSpace α μ : Measure α inst✝² : NormedAddCommGroup E inst✝¹ : InnerProductSpace 𝕜 E inst✝ : NormedAddCommGroup F f : { x // x ∈ Lp E 2 } ⊢ ∫ (a : α), ↑‖↑↑f a‖ ^ 2 ∂μ = ↑(ENNReal.toReal (∫⁻ (a : α), ↑‖↑↑f a‖₊ ^ 2 ∂μ)) [PROOFSTEP] norm_cast [GOAL] α : Type u_1 E : Type u_2 F : Type u_3 𝕜 : Type u_4 inst✝⁴ : IsROrC 𝕜 inst✝³ : MeasurableSpace α μ : Measure α inst✝² : NormedAddCommGroup E inst✝¹ : InnerProductSpace 𝕜 E inst✝ : NormedAddCommGroup F f : { x // x ∈ Lp E 2 } ⊢ ∫ (a : α), ‖↑↑f a‖ ^ 2 ∂μ = ENNReal.toReal (∫⁻ (a : α), ↑(‖↑↑f a‖₊ ^ 2) ∂μ) [PROOFSTEP] rw [integral_eq_lintegral_of_nonneg_ae] [GOAL] α : Type u_1 E : Type u_2 F : Type u_3 𝕜 : Type u_4 inst✝⁴ : IsROrC 𝕜 inst✝³ : MeasurableSpace α μ : Measure α inst✝² : NormedAddCommGroup E inst✝¹ : InnerProductSpace 𝕜 E inst✝ : NormedAddCommGroup F f : { x // x ∈ Lp E 2 } ⊢ ENNReal.toReal (∫⁻ (a : α), ENNReal.ofReal (‖↑↑f a‖ ^ 2) ∂μ) = ENNReal.toReal (∫⁻ (a : α), ↑(‖↑↑f a‖₊ ^ 2) ∂μ) case hf α : Type u_1 E : Type u_2 F : Type u_3 𝕜 : Type u_4 inst✝⁴ : IsROrC 𝕜 inst✝³ : MeasurableSpace α μ : Measure α inst✝² : NormedAddCommGroup E inst✝¹ : InnerProductSpace 𝕜 E inst✝ : NormedAddCommGroup F f : { x // x ∈ Lp E 2 } ⊢ 0 ≤ᵐ[μ] fun a => ‖↑↑f a‖ ^ 2 case hfm α : Type u_1 E : Type u_2 F : Type u_3 𝕜 : Type u_4 inst✝⁴ : IsROrC 𝕜 inst✝³ : MeasurableSpace α μ : Measure α inst✝² : NormedAddCommGroup E inst✝¹ : InnerProductSpace 𝕜 E inst✝ : NormedAddCommGroup F f : { x // x ∈ Lp E 2 } ⊢ AEStronglyMeasurable (fun a => ‖↑↑f a‖ ^ 2) μ [PROOFSTEP] rotate_left [GOAL] case hf α : Type u_1 E : Type u_2 F : Type u_3 𝕜 : Type u_4 inst✝⁴ : IsROrC 𝕜 inst✝³ : MeasurableSpace α μ : Measure α inst✝² : NormedAddCommGroup E inst✝¹ : InnerProductSpace 𝕜 E inst✝ : NormedAddCommGroup F f : { x // x ∈ Lp E 2 } ⊢ 0 ≤ᵐ[μ] fun a => ‖↑↑f a‖ ^ 2 [PROOFSTEP] exact Filter.eventually_of_forall fun x => sq_nonneg _ [GOAL] case hfm α : Type u_1 E : Type u_2 F : Type u_3 𝕜 : Type u_4 inst✝⁴ : IsROrC 𝕜 inst✝³ : MeasurableSpace α μ : Measure α inst✝² : NormedAddCommGroup E inst✝¹ : InnerProductSpace 𝕜 E inst✝ : NormedAddCommGroup F f : { x // x ∈ Lp E 2 } ⊢ AEStronglyMeasurable (fun a => ‖↑↑f a‖ ^ 2) μ [PROOFSTEP] exact ((Lp.aestronglyMeasurable f).norm.aemeasurable.pow_const _).aestronglyMeasurable [GOAL] α : Type u_1 E : Type u_2 F : Type u_3 𝕜 : Type u_4 inst✝⁴ : IsROrC 𝕜 inst✝³ : MeasurableSpace α μ : Measure α inst✝² : NormedAddCommGroup E inst✝¹ : InnerProductSpace 𝕜 E inst✝ : NormedAddCommGroup F f : { x // x ∈ Lp E 2 } ⊢ ENNReal.toReal (∫⁻ (a : α), ENNReal.ofReal (‖↑↑f a‖ ^ 2) ∂μ) = ENNReal.toReal (∫⁻ (a : α), ↑(‖↑↑f a‖₊ ^ 2) ∂μ) [PROOFSTEP] congr [GOAL] case e_a.e_f α : Type u_1 E : Type u_2 F : Type u_3 𝕜 : Type u_4 inst✝⁴ : IsROrC 𝕜 inst✝³ : MeasurableSpace α μ : Measure α inst✝² : NormedAddCommGroup E inst✝¹ : InnerProductSpace 𝕜 E inst✝ : NormedAddCommGroup F f : { x // x ∈ Lp E 2 } ⊢ (fun a => ENNReal.ofReal (‖↑↑f a‖ ^ 2)) = fun a => ↑(‖↑↑f a‖₊ ^ 2) [PROOFSTEP] ext1 x [GOAL] case e_a.e_f.h α : Type u_1 E : Type u_2 F : Type u_3 𝕜 : Type u_4 inst✝⁴ : IsROrC 𝕜 inst✝³ : MeasurableSpace α μ : Measure α inst✝² : NormedAddCommGroup E inst✝¹ : InnerProductSpace 𝕜 E inst✝ : NormedAddCommGroup F f : { x // x ∈ Lp E 2 } x : α ⊢ ENNReal.ofReal (‖↑↑f x‖ ^ 2) = ↑(‖↑↑f x‖₊ ^ 2) [PROOFSTEP] have h_two : (2 : ℝ) = ((2 : ℕ) : ℝ) := by simp [GOAL] α : Type u_1 E : Type u_2 F : Type u_3 𝕜 : Type u_4 inst✝⁴ : IsROrC 𝕜 inst✝³ : MeasurableSpace α μ : Measure α inst✝² : NormedAddCommGroup E inst✝¹ : InnerProductSpace 𝕜 E inst✝ : NormedAddCommGroup F f : { x // x ∈ Lp E 2 } x : α ⊢ 2 = ↑2 [PROOFSTEP] simp [GOAL] case e_a.e_f.h α : Type u_1 E : Type u_2 F : Type u_3 𝕜 : Type u_4 inst✝⁴ : IsROrC 𝕜 inst✝³ : MeasurableSpace α μ : Measure α inst✝² : NormedAddCommGroup E inst✝¹ : InnerProductSpace 𝕜 E inst✝ : NormedAddCommGroup F f : { x // x ∈ Lp E 2 } x : α h_two : 2 = ↑2 ⊢ ENNReal.ofReal (‖↑↑f x‖ ^ 2) = ↑(‖↑↑f x‖₊ ^ 2) [PROOFSTEP] rw [← Real.rpow_nat_cast _ 2, ← h_two, ← ENNReal.ofReal_rpow_of_nonneg (norm_nonneg _) zero_le_two, ofReal_norm_eq_coe_nnnorm] [GOAL] case e_a.e_f.h α : Type u_1 E : Type u_2 F : Type u_3 𝕜 : Type u_4 inst✝⁴ : IsROrC 𝕜 inst✝³ : MeasurableSpace α μ : Measure α inst✝² : NormedAddCommGroup E inst✝¹ : InnerProductSpace 𝕜 E inst✝ : NormedAddCommGroup F f : { x // x ∈ Lp E 2 } x : α h_two : 2 = ↑2 ⊢ ↑‖↑↑f x‖₊ ^ 2 = ↑(‖↑↑f x‖₊ ^ 2) [PROOFSTEP] norm_cast [GOAL] α : Type u_1 E : Type u_2 F : Type u_3 𝕜 : Type u_4 inst✝⁴ : IsROrC 𝕜 inst✝³ : MeasurableSpace α μ : Measure α inst✝² : NormedAddCommGroup E inst✝¹ : InnerProductSpace 𝕜 E inst✝ : NormedAddCommGroup F f : { x // x ∈ Lp E 2 } ⊢ ‖f‖ ^ 2 = ↑IsROrC.re (inner f f) [PROOFSTEP] have h_two : (2 : ℝ≥0∞).toReal = 2 := by simp [GOAL] α : Type u_1 E : Type u_2 F : Type u_3 𝕜 : Type u_4 inst✝⁴ : IsROrC 𝕜 inst✝³ : MeasurableSpace α μ : Measure α inst✝² : NormedAddCommGroup E inst✝¹ : InnerProductSpace 𝕜 E inst✝ : NormedAddCommGroup F f : { x // x ∈ Lp E 2 } ⊢ ENNReal.toReal 2 = 2 [PROOFSTEP] simp [GOAL] α : Type u_1 E : Type u_2 F : Type u_3 𝕜 : Type u_4 inst✝⁴ : IsROrC 𝕜 inst✝³ : MeasurableSpace α μ : Measure α inst✝² : NormedAddCommGroup E inst✝¹ : InnerProductSpace 𝕜 E inst✝ : NormedAddCommGroup F f : { x // x ∈ Lp E 2 } h_two : ENNReal.toReal 2 = 2 ⊢ ‖f‖ ^ 2 = ↑IsROrC.re (inner f f) [PROOFSTEP] rw [inner_def, integral_inner_eq_sq_snorm, norm_def, ← ENNReal.toReal_pow, IsROrC.ofReal_re, ENNReal.toReal_eq_toReal (ENNReal.pow_ne_top (Lp.snorm_ne_top f)) _] [GOAL] α : Type u_1 E : Type u_2 F : Type u_3 𝕜 : Type u_4 inst✝⁴ : IsROrC 𝕜 inst✝³ : MeasurableSpace α μ : Measure α inst✝² : NormedAddCommGroup E inst✝¹ : InnerProductSpace 𝕜 E inst✝ : NormedAddCommGroup F f : { x // x ∈ Lp E 2 } h_two : ENNReal.toReal 2 = 2 ⊢ snorm (↑↑f) 2 μ ^ 2 = ∫⁻ (a : α), ↑‖↑↑f a‖₊ ^ 2 ∂μ [PROOFSTEP] rw [← ENNReal.rpow_nat_cast, snorm_eq_snorm' two_ne_zero ENNReal.two_ne_top, snorm', ← ENNReal.rpow_mul, one_div, h_two] [GOAL] α : Type u_1 E : Type u_2 F : Type u_3 𝕜 : Type u_4 inst✝⁴ : IsROrC 𝕜 inst✝³ : MeasurableSpace α μ : Measure α inst✝² : NormedAddCommGroup E inst✝¹ : InnerProductSpace 𝕜 E inst✝ : NormedAddCommGroup F f : { x // x ∈ Lp E 2 } h_two : ENNReal.toReal 2 = 2 ⊢ (∫⁻ (a : α), ↑‖↑↑f a‖₊ ^ 2 ∂μ) ^ (2⁻¹ * ↑2) = ∫⁻ (a : α), ↑‖↑↑f a‖₊ ^ 2 ∂μ [PROOFSTEP] simp [GOAL] α : Type u_1 E : Type u_2 F : Type u_3 𝕜 : Type u_4 inst✝⁴ : IsROrC 𝕜 inst✝³ : MeasurableSpace α μ : Measure α inst✝² : NormedAddCommGroup E inst✝¹ : InnerProductSpace 𝕜 E inst✝ : NormedAddCommGroup F f : { x // x ∈ Lp E 2 } h_two : ENNReal.toReal 2 = 2 ⊢ ∫⁻ (a : α), ↑‖↑↑f a‖₊ ^ 2 ∂μ ≠ ⊤ [PROOFSTEP] refine' (lintegral_rpow_nnnorm_lt_top_of_snorm'_lt_top zero_lt_two _).ne [GOAL] α : Type u_1 E : Type u_2 F : Type u_3 𝕜 : Type u_4 inst✝⁴ : IsROrC 𝕜 inst✝³ : MeasurableSpace α μ : Measure α inst✝² : NormedAddCommGroup E inst✝¹ : InnerProductSpace 𝕜 E inst✝ : NormedAddCommGroup F f : { x // x ∈ Lp E 2 } h_two : ENNReal.toReal 2 = 2 ⊢ snorm' (fun a => ↑↑f a) 2 μ < ⊤ [PROOFSTEP] rw [← h_two, ← snorm_eq_snorm' two_ne_zero ENNReal.two_ne_top] [GOAL] α : Type u_1 E : Type u_2 F : Type u_3 𝕜 : Type u_4 inst✝⁴ : IsROrC 𝕜 inst✝³ : MeasurableSpace α μ : Measure α inst✝² : NormedAddCommGroup E inst✝¹ : InnerProductSpace 𝕜 E inst✝ : NormedAddCommGroup F f : { x // x ∈ Lp E 2 } h_two : ENNReal.toReal 2 = 2 ⊢ snorm (fun a => ↑↑f a) 2 μ < ⊤ [PROOFSTEP] exact Lp.snorm_lt_top f [GOAL] α : Type u_1 E : Type u_2 F : Type u_3 𝕜 : Type u_4 inst✝⁴ : IsROrC 𝕜 inst✝³ : MeasurableSpace α μ : Measure α inst✝² : NormedAddCommGroup E inst✝¹ : InnerProductSpace 𝕜 E inst✝ : NormedAddCommGroup F f g : { x // x ∈ Lp E 2 } ⊢ AEEqFun.mk (fun x => inner (↑↑f x) (↑↑g x)) (_ : AEStronglyMeasurable (fun x => inner (↑↑f x) (↑↑g x)) μ) ∈ Lp 𝕜 1 [PROOFSTEP] simp_rw [mem_Lp_iff_snorm_lt_top, snorm_aeeqFun] [GOAL] α : Type u_1 E : Type u_2 F : Type u_3 𝕜 : Type u_4 inst✝⁴ : IsROrC 𝕜 inst✝³ : MeasurableSpace α μ : Measure α inst✝² : NormedAddCommGroup E inst✝¹ : InnerProductSpace 𝕜 E inst✝ : NormedAddCommGroup F f g : { x // x ∈ Lp E 2 } ⊢ snorm (fun x => inner (↑↑f x) (↑↑g x)) 1 μ < ⊤ [PROOFSTEP] exact snorm_inner_lt_top f g [GOAL] α : Type u_1 E : Type u_2 F : Type u_3 𝕜 : Type u_4 inst✝⁴ : IsROrC 𝕜 inst✝³ : MeasurableSpace α μ : Measure α inst✝² : NormedAddCommGroup E inst✝¹ : InnerProductSpace 𝕜 E inst✝ : NormedAddCommGroup F f f' g : { x // x ∈ Lp E 2 } ⊢ inner (f + f') g = inner f g + inner f' g [PROOFSTEP] simp_rw [inner_def, ← integral_add (integrable_inner f g) (integrable_inner f' g), ← inner_add_left] [GOAL] α : Type u_1 E : Type u_2 F : Type u_3 𝕜 : Type u_4 inst✝⁴ : IsROrC 𝕜 inst✝³ : MeasurableSpace α μ : Measure α inst✝² : NormedAddCommGroup E inst✝¹ : InnerProductSpace 𝕜 E inst✝ : NormedAddCommGroup F f f' g : { x // x ∈ Lp E 2 } ⊢ ∫ (a : α), inner (↑↑(f + f') a) (↑↑g a) ∂μ = ∫ (a : α), inner (↑↑f a + ↑↑f' a) (↑↑g a) ∂μ [PROOFSTEP] refine' integral_congr_ae ((coeFn_add f f').mono fun x hx => _) -- Porting note: was -- congr -- rwa [Pi.add_apply] at hx [GOAL] α : Type u_1 E : Type u_2 F : Type u_3 𝕜 : Type u_4 inst✝⁴ : IsROrC 𝕜 inst✝³ : MeasurableSpace α μ : Measure α inst✝² : NormedAddCommGroup E inst✝¹ : InnerProductSpace 𝕜 E inst✝ : NormedAddCommGroup F f f' g : { x // x ∈ Lp E 2 } x : α hx : ↑↑(f + f') x = (↑↑f + ↑↑f') x ⊢ (fun a => inner (↑↑(f + f') a) (↑↑g a)) x = (fun a => inner (↑↑f a + ↑↑f' a) (↑↑g a)) x [PROOFSTEP] simp only [GOAL] α : Type u_1 E : Type u_2 F : Type u_3 𝕜 : Type u_4 inst✝⁴ : IsROrC 𝕜 inst✝³ : MeasurableSpace α μ : Measure α inst✝² : NormedAddCommGroup E inst✝¹ : InnerProductSpace 𝕜 E inst✝ : NormedAddCommGroup F f f' g : { x // x ∈ Lp E 2 } x : α hx : ↑↑(f + f') x = (↑↑f + ↑↑f') x ⊢ inner (↑↑(f + f') x) (↑↑g x) = inner (↑↑f x + ↑↑f' x) (↑↑g x) [PROOFSTEP] rw [hx, Pi.add_apply] [GOAL] α : Type u_1 E : Type u_2 F : Type u_3 𝕜 : Type u_4 inst✝⁴ : IsROrC 𝕜 inst✝³ : MeasurableSpace α μ : Measure α inst✝² : NormedAddCommGroup E inst✝¹ : InnerProductSpace 𝕜 E inst✝ : NormedAddCommGroup F f g : { x // x ∈ Lp E 2 } r : 𝕜 ⊢ inner (r • f) g = ↑(starRingEnd 𝕜) r * inner f g [PROOFSTEP] rw [inner_def, inner_def, ← smul_eq_mul, ← integral_smul] [GOAL] α : Type u_1 E : Type u_2 F : Type u_3 𝕜 : Type u_4 inst✝⁴ : IsROrC 𝕜 inst✝³ : MeasurableSpace α μ : Measure α inst✝² : NormedAddCommGroup E inst✝¹ : InnerProductSpace 𝕜 E inst✝ : NormedAddCommGroup F f g : { x // x ∈ Lp E 2 } r : 𝕜 ⊢ ∫ (a : α), inner (↑↑(r • f) a) (↑↑g a) ∂μ = ∫ (a : α), ↑(starRingEnd 𝕜) r • inner (↑↑f a) (↑↑g a) ∂μ [PROOFSTEP] refine' integral_congr_ae ((coeFn_smul r f).mono fun x hx => _) [GOAL] α : Type u_1 E : Type u_2 F : Type u_3 𝕜 : Type u_4 inst✝⁴ : IsROrC 𝕜 inst✝³ : MeasurableSpace α μ : Measure α inst✝² : NormedAddCommGroup E inst✝¹ : InnerProductSpace 𝕜 E inst✝ : NormedAddCommGroup F f g : { x // x ∈ Lp E 2 } r : 𝕜 x : α hx : ↑↑(r • f) x = (r • ↑↑f) x ⊢ (fun a => inner (↑↑(r • f) a) (↑↑g a)) x = (fun a => ↑(starRingEnd 𝕜) r • inner (↑↑f a) (↑↑g a)) x [PROOFSTEP] simp only [GOAL] α : Type u_1 E : Type u_2 F : Type u_3 𝕜 : Type u_4 inst✝⁴ : IsROrC 𝕜 inst✝³ : MeasurableSpace α μ : Measure α inst✝² : NormedAddCommGroup E inst✝¹ : InnerProductSpace 𝕜 E inst✝ : NormedAddCommGroup F f g : { x // x ∈ Lp E 2 } r : 𝕜 x : α hx : ↑↑(r • f) x = (r • ↑↑f) x ⊢ inner (↑↑(r • f) x) (↑↑g x) = ↑(starRingEnd 𝕜) r • inner (↑↑f x) (↑↑g x) [PROOFSTEP] rw [smul_eq_mul, ← inner_smul_left, hx, Pi.smul_apply] -- Porting note: was -- rw [smul_eq_mul, ← inner_smul_left] -- congr -- rwa [Pi.smul_apply] at hx [GOAL] α : Type u_1 E : Type u_2 F : Type u_3 𝕜 : Type u_4 inst✝⁴ : IsROrC 𝕜 inst✝³ : MeasurableSpace α μ : Measure α inst✝² : NormedAddCommGroup E inst✝¹ : InnerProductSpace 𝕜 E inst✝ : NormedAddCommGroup F x✝¹ x✝ : { x // x ∈ Lp E 2 } ⊢ ↑(starRingEnd 𝕜) (inner x✝ x✝¹) = inner x✝¹ x✝ [PROOFSTEP] simp_rw [inner_def, ← integral_conj, inner_conj_symm] [GOAL] α : Type u_1 E : Type u_2 F : Type u_3 𝕜 : Type u_4 inst✝⁴ : IsROrC 𝕜 inst✝³ : MeasurableSpace α μ : Measure α inst✝² : NormedAddCommGroup E inst✝¹ : InnerProductSpace 𝕜 E inst✝ : NormedAddCommGroup F s : Set α f : { x // x ∈ Lp E 2 } hs : MeasurableSet s c : E hμs : ↑↑μ s ≠ ⊤ ⊢ inner (indicatorConstLp 2 hs hμs c) f = ∫ (x : α) in s, inner c (↑↑f x) ∂μ [PROOFSTEP] rw [inner_def, ← integral_add_compl hs (L2.integrable_inner _ f)] [GOAL] α : Type u_1 E : Type u_2 F : Type u_3 𝕜 : Type u_4 inst✝⁴ : IsROrC 𝕜 inst✝³ : MeasurableSpace α μ : Measure α inst✝² : NormedAddCommGroup E inst✝¹ : InnerProductSpace 𝕜 E inst✝ : NormedAddCommGroup F s : Set α f : { x // x ∈ Lp E 2 } hs : MeasurableSet s c : E hμs : ↑↑μ s ≠ ⊤ ⊢ ∫ (x : α) in s, inner (↑↑(indicatorConstLp 2 hs hμs c) x) (↑↑f x) ∂μ + ∫ (x : α) in sᶜ, inner (↑↑(indicatorConstLp 2 hs hμs c) x) (↑↑f x) ∂μ = ∫ (x : α) in s, inner c (↑↑f x) ∂μ [PROOFSTEP] have h_left : (∫ x in s, ⟪(indicatorConstLp 2 hs hμs c) x, f x⟫ ∂μ) = ∫ x in s, ⟪c, f x⟫ ∂μ := by suffices h_ae_eq : ∀ᵐ x ∂μ, x ∈ s → ⟪indicatorConstLp 2 hs hμs c x, f x⟫ = ⟪c, f x⟫ exact set_integral_congr_ae hs h_ae_eq have h_indicator : ∀ᵐ x : α ∂μ, x ∈ s → indicatorConstLp 2 hs hμs c x = c := indicatorConstLp_coeFn_mem refine' h_indicator.mono fun x hx hxs => _ congr exact hx hxs [GOAL] α : Type u_1 E : Type u_2 F : Type u_3 𝕜 : Type u_4 inst✝⁴ : IsROrC 𝕜 inst✝³ : MeasurableSpace α μ : Measure α inst✝² : NormedAddCommGroup E inst✝¹ : InnerProductSpace 𝕜 E inst✝ : NormedAddCommGroup F s : Set α f : { x // x ∈ Lp E 2 } hs : MeasurableSet s c : E hμs : ↑↑μ s ≠ ⊤ ⊢ ∫ (x : α) in s, inner (↑↑(indicatorConstLp 2 hs hμs c) x) (↑↑f x) ∂μ = ∫ (x : α) in s, inner c (↑↑f x) ∂μ [PROOFSTEP] suffices h_ae_eq : ∀ᵐ x ∂μ, x ∈ s → ⟪indicatorConstLp 2 hs hμs c x, f x⟫ = ⟪c, f x⟫ [GOAL] α : Type u_1 E : Type u_2 F : Type u_3 𝕜 : Type u_4 inst✝⁴ : IsROrC 𝕜 inst✝³ : MeasurableSpace α μ : Measure α inst✝² : NormedAddCommGroup E inst✝¹ : InnerProductSpace 𝕜 E inst✝ : NormedAddCommGroup F s : Set α f : { x // x ∈ Lp E 2 } hs : MeasurableSet s c : E hμs : ↑↑μ s ≠ ⊤ h_ae_eq : ∀ᵐ (x : α) ∂μ, x ∈ s → inner (↑↑(indicatorConstLp 2 hs hμs c) x) (↑↑f x) = inner c (↑↑f x) ⊢ ∫ (x : α) in s, inner (↑↑(indicatorConstLp 2 hs hμs c) x) (↑↑f x) ∂μ = ∫ (x : α) in s, inner c (↑↑f x) ∂μ case h_ae_eq α : Type u_1 E : Type u_2 F : Type u_3 𝕜 : Type u_4 inst✝⁴ : IsROrC 𝕜 inst✝³ : MeasurableSpace α μ : Measure α inst✝² : NormedAddCommGroup E inst✝¹ : InnerProductSpace 𝕜 E inst✝ : NormedAddCommGroup F s : Set α f : { x // x ∈ Lp E 2 } hs : MeasurableSet s c : E hμs : ↑↑μ s ≠ ⊤ ⊢ ∀ᵐ (x : α) ∂μ, x ∈ s → inner (↑↑(indicatorConstLp 2 hs hμs c) x) (↑↑f x) = inner c (↑↑f x) [PROOFSTEP] exact set_integral_congr_ae hs h_ae_eq [GOAL] case h_ae_eq α : Type u_1 E : Type u_2 F : Type u_3 𝕜 : Type u_4 inst✝⁴ : IsROrC 𝕜 inst✝³ : MeasurableSpace α μ : Measure α inst✝² : NormedAddCommGroup E inst✝¹ : InnerProductSpace 𝕜 E inst✝ : NormedAddCommGroup F s : Set α f : { x // x ∈ Lp E 2 } hs : MeasurableSet s c : E hμs : ↑↑μ s ≠ ⊤ ⊢ ∀ᵐ (x : α) ∂μ, x ∈ s → inner (↑↑(indicatorConstLp 2 hs hμs c) x) (↑↑f x) = inner c (↑↑f x) [PROOFSTEP] have h_indicator : ∀ᵐ x : α ∂μ, x ∈ s → indicatorConstLp 2 hs hμs c x = c := indicatorConstLp_coeFn_mem [GOAL] case h_ae_eq α : Type u_1 E : Type u_2 F : Type u_3 𝕜 : Type u_4 inst✝⁴ : IsROrC 𝕜 inst✝³ : MeasurableSpace α μ : Measure α inst✝² : NormedAddCommGroup E inst✝¹ : InnerProductSpace 𝕜 E inst✝ : NormedAddCommGroup F s : Set α f : { x // x ∈ Lp E 2 } hs : MeasurableSet s c : E hμs : ↑↑μ s ≠ ⊤ h_indicator : ∀ᵐ (x : α) ∂μ, x ∈ s → ↑↑(indicatorConstLp 2 hs hμs c) x = c ⊢ ∀ᵐ (x : α) ∂μ, x ∈ s → inner (↑↑(indicatorConstLp 2 hs hμs c) x) (↑↑f x) = inner c (↑↑f x) [PROOFSTEP] refine' h_indicator.mono fun x hx hxs => _ [GOAL] case h_ae_eq α : Type u_1 E : Type u_2 F : Type u_3 𝕜 : Type u_4 inst✝⁴ : IsROrC 𝕜 inst✝³ : MeasurableSpace α μ : Measure α inst✝² : NormedAddCommGroup E inst✝¹ : InnerProductSpace 𝕜 E inst✝ : NormedAddCommGroup F s : Set α f : { x // x ∈ Lp E 2 } hs : MeasurableSet s c : E hμs : ↑↑μ s ≠ ⊤ h_indicator : ∀ᵐ (x : α) ∂μ, x ∈ s → ↑↑(indicatorConstLp 2 hs hμs c) x = c x : α hx : x ∈ s → ↑↑(indicatorConstLp 2 hs hμs c) x = c hxs : x ∈ s ⊢ inner (↑↑(indicatorConstLp 2 hs hμs c) x) (↑↑f x) = inner c (↑↑f x) [PROOFSTEP] congr [GOAL] case h_ae_eq.e_a α : Type u_1 E : Type u_2 F : Type u_3 𝕜 : Type u_4 inst✝⁴ : IsROrC 𝕜 inst✝³ : MeasurableSpace α μ : Measure α inst✝² : NormedAddCommGroup E inst✝¹ : InnerProductSpace 𝕜 E inst✝ : NormedAddCommGroup F s : Set α f : { x // x ∈ Lp E 2 } hs : MeasurableSet s c : E hμs : ↑↑μ s ≠ ⊤ h_indicator : ∀ᵐ (x : α) ∂μ, x ∈ s → ↑↑(indicatorConstLp 2 hs hμs c) x = c x : α hx : x ∈ s → ↑↑(indicatorConstLp 2 hs hμs c) x = c hxs : x ∈ s ⊢ ↑↑(indicatorConstLp 2 hs hμs c) x = c [PROOFSTEP] exact hx hxs [GOAL] α : Type u_1 E : Type u_2 F : Type u_3 𝕜 : Type u_4 inst✝⁴ : IsROrC 𝕜 inst✝³ : MeasurableSpace α μ : Measure α inst✝² : NormedAddCommGroup E inst✝¹ : InnerProductSpace 𝕜 E inst✝ : NormedAddCommGroup F s : Set α f : { x // x ∈ Lp E 2 } hs : MeasurableSet s c : E hμs : ↑↑μ s ≠ ⊤ h_left : ∫ (x : α) in s, inner (↑↑(indicatorConstLp 2 hs hμs c) x) (↑↑f x) ∂μ = ∫ (x : α) in s, inner c (↑↑f x) ∂μ ⊢ ∫ (x : α) in s, inner (↑↑(indicatorConstLp 2 hs hμs c) x) (↑↑f x) ∂μ + ∫ (x : α) in sᶜ, inner (↑↑(indicatorConstLp 2 hs hμs c) x) (↑↑f x) ∂μ = ∫ (x : α) in s, inner c (↑↑f x) ∂μ [PROOFSTEP] have h_right : (∫ x in sᶜ, ⟪(indicatorConstLp 2 hs hμs c) x, f x⟫ ∂μ) = 0 := by suffices h_ae_eq : ∀ᵐ x ∂μ, x ∉ s → ⟪indicatorConstLp 2 hs hμs c x, f x⟫ = 0 · simp_rw [← Set.mem_compl_iff] at h_ae_eq suffices h_int_zero : (∫ x in sᶜ, inner (indicatorConstLp 2 hs hμs c x) (f x) ∂μ) = ∫ _ in sᶜ, (0 : 𝕜) ∂μ · rw [h_int_zero] simp exact set_integral_congr_ae hs.compl h_ae_eq have h_indicator : ∀ᵐ x : α ∂μ, x ∉ s → indicatorConstLp 2 hs hμs c x = 0 := indicatorConstLp_coeFn_nmem refine' h_indicator.mono fun x hx hxs => _ rw [hx hxs] exact inner_zero_left _ [GOAL] α : Type u_1 E : Type u_2 F : Type u_3 𝕜 : Type u_4 inst✝⁴ : IsROrC 𝕜 inst✝³ : MeasurableSpace α μ : Measure α inst✝² : NormedAddCommGroup E inst✝¹ : InnerProductSpace 𝕜 E inst✝ : NormedAddCommGroup F s : Set α f : { x // x ∈ Lp E 2 } hs : MeasurableSet s c : E hμs : ↑↑μ s ≠ ⊤ h_left : ∫ (x : α) in s, inner (↑↑(indicatorConstLp 2 hs hμs c) x) (↑↑f x) ∂μ = ∫ (x : α) in s, inner c (↑↑f x) ∂μ ⊢ ∫ (x : α) in sᶜ, inner (↑↑(indicatorConstLp 2 hs hμs c) x) (↑↑f x) ∂μ = 0 [PROOFSTEP] suffices h_ae_eq : ∀ᵐ x ∂μ, x ∉ s → ⟪indicatorConstLp 2 hs hμs c x, f x⟫ = 0 [GOAL] α : Type u_1 E : Type u_2 F : Type u_3 𝕜 : Type u_4 inst✝⁴ : IsROrC 𝕜 inst✝³ : MeasurableSpace α μ : Measure α inst✝² : NormedAddCommGroup E inst✝¹ : InnerProductSpace 𝕜 E inst✝ : NormedAddCommGroup F s : Set α f : { x // x ∈ Lp E 2 } hs : MeasurableSet s c : E hμs : ↑↑μ s ≠ ⊤ h_left : ∫ (x : α) in s, inner (↑↑(indicatorConstLp 2 hs hμs c) x) (↑↑f x) ∂μ = ∫ (x : α) in s, inner c (↑↑f x) ∂μ h_ae_eq : ∀ᵐ (x : α) ∂μ, ¬x ∈ s → inner (↑↑(indicatorConstLp 2 hs hμs c) x) (↑↑f x) = 0 ⊢ ∫ (x : α) in sᶜ, inner (↑↑(indicatorConstLp 2 hs hμs c) x) (↑↑f x) ∂μ = 0 [PROOFSTEP] simp_rw [← Set.mem_compl_iff] at h_ae_eq [GOAL] α : Type u_1 E : Type u_2 F : Type u_3 𝕜 : Type u_4 inst✝⁴ : IsROrC 𝕜 inst✝³ : MeasurableSpace α μ : Measure α inst✝² : NormedAddCommGroup E inst✝¹ : InnerProductSpace 𝕜 E inst✝ : NormedAddCommGroup F s : Set α f : { x // x ∈ Lp E 2 } hs : MeasurableSet s c : E hμs : ↑↑μ s ≠ ⊤ h_left : ∫ (x : α) in s, inner (↑↑(indicatorConstLp 2 hs hμs c) x) (↑↑f x) ∂μ = ∫ (x : α) in s, inner c (↑↑f x) ∂μ h_ae_eq : ∀ᵐ (x : α) ∂μ, x ∈ sᶜ → inner (↑↑(indicatorConstLp 2 hs hμs c) x) (↑↑f x) = 0 ⊢ ∫ (x : α) in sᶜ, inner (↑↑(indicatorConstLp 2 hs hμs c) x) (↑↑f x) ∂μ = 0 [PROOFSTEP] suffices h_int_zero : (∫ x in sᶜ, inner (indicatorConstLp 2 hs hμs c x) (f x) ∂μ) = ∫ _ in sᶜ, (0 : 𝕜) ∂μ [GOAL] α : Type u_1 E : Type u_2 F : Type u_3 𝕜 : Type u_4 inst✝⁴ : IsROrC 𝕜 inst✝³ : MeasurableSpace α μ : Measure α inst✝² : NormedAddCommGroup E inst✝¹ : InnerProductSpace 𝕜 E inst✝ : NormedAddCommGroup F s : Set α f : { x // x ∈ Lp E 2 } hs : MeasurableSet s c : E hμs : ↑↑μ s ≠ ⊤ h_left : ∫ (x : α) in s, inner (↑↑(indicatorConstLp 2 hs hμs c) x) (↑↑f x) ∂μ = ∫ (x : α) in s, inner c (↑↑f x) ∂μ h_ae_eq : ∀ᵐ (x : α) ∂μ, x ∈ sᶜ → inner (↑↑(indicatorConstLp 2 hs hμs c) x) (↑↑f x) = 0 h_int_zero : ∫ (x : α) in sᶜ, inner (↑↑(indicatorConstLp 2 hs hμs c) x) (↑↑f x) ∂μ = ∫ (x : α) in sᶜ, 0 ∂μ ⊢ ∫ (x : α) in sᶜ, inner (↑↑(indicatorConstLp 2 hs hμs c) x) (↑↑f x) ∂μ = 0 [PROOFSTEP] rw [h_int_zero] [GOAL] α : Type u_1 E : Type u_2 F : Type u_3 𝕜 : Type u_4 inst✝⁴ : IsROrC 𝕜 inst✝³ : MeasurableSpace α μ : Measure α inst✝² : NormedAddCommGroup E inst✝¹ : InnerProductSpace 𝕜 E inst✝ : NormedAddCommGroup F s : Set α f : { x // x ∈ Lp E 2 } hs : MeasurableSet s c : E hμs : ↑↑μ s ≠ ⊤ h_left : ∫ (x : α) in s, inner (↑↑(indicatorConstLp 2 hs hμs c) x) (↑↑f x) ∂μ = ∫ (x : α) in s, inner c (↑↑f x) ∂μ h_ae_eq : ∀ᵐ (x : α) ∂μ, x ∈ sᶜ → inner (↑↑(indicatorConstLp 2 hs hμs c) x) (↑↑f x) = 0 h_int_zero : ∫ (x : α) in sᶜ, inner (↑↑(indicatorConstLp 2 hs hμs c) x) (↑↑f x) ∂μ = ∫ (x : α) in sᶜ, 0 ∂μ ⊢ ∫ (x : α) in sᶜ, 0 ∂μ = 0 [PROOFSTEP] simp [GOAL] case h_int_zero α : Type u_1 E : Type u_2 F : Type u_3 𝕜 : Type u_4 inst✝⁴ : IsROrC 𝕜 inst✝³ : MeasurableSpace α μ : Measure α inst✝² : NormedAddCommGroup E inst✝¹ : InnerProductSpace 𝕜 E inst✝ : NormedAddCommGroup F s : Set α f : { x // x ∈ Lp E 2 } hs : MeasurableSet s c : E hμs : ↑↑μ s ≠ ⊤ h_left : ∫ (x : α) in s, inner (↑↑(indicatorConstLp 2 hs hμs c) x) (↑↑f x) ∂μ = ∫ (x : α) in s, inner c (↑↑f x) ∂μ h_ae_eq : ∀ᵐ (x : α) ∂μ, x ∈ sᶜ → inner (↑↑(indicatorConstLp 2 hs hμs c) x) (↑↑f x) = 0 ⊢ ∫ (x : α) in sᶜ, inner (↑↑(indicatorConstLp 2 hs hμs c) x) (↑↑f x) ∂μ = ∫ (x : α) in sᶜ, 0 ∂μ [PROOFSTEP] exact set_integral_congr_ae hs.compl h_ae_eq [GOAL] case h_ae_eq α : Type u_1 E : Type u_2 F : Type u_3 𝕜 : Type u_4 inst✝⁴ : IsROrC 𝕜 inst✝³ : MeasurableSpace α μ : Measure α inst✝² : NormedAddCommGroup E inst✝¹ : InnerProductSpace 𝕜 E inst✝ : NormedAddCommGroup F s : Set α f : { x // x ∈ Lp E 2 } hs : MeasurableSet s c : E hμs : ↑↑μ s ≠ ⊤ h_left : ∫ (x : α) in s, inner (↑↑(indicatorConstLp 2 hs hμs c) x) (↑↑f x) ∂μ = ∫ (x : α) in s, inner c (↑↑f x) ∂μ ⊢ ∀ᵐ (x : α) ∂μ, ¬x ∈ s → inner (↑↑(indicatorConstLp 2 hs hμs c) x) (↑↑f x) = 0 [PROOFSTEP] have h_indicator : ∀ᵐ x : α ∂μ, x ∉ s → indicatorConstLp 2 hs hμs c x = 0 := indicatorConstLp_coeFn_nmem [GOAL] case h_ae_eq α : Type u_1 E : Type u_2 F : Type u_3 𝕜 : Type u_4 inst✝⁴ : IsROrC 𝕜 inst✝³ : MeasurableSpace α μ : Measure α inst✝² : NormedAddCommGroup E inst✝¹ : InnerProductSpace 𝕜 E inst✝ : NormedAddCommGroup F s : Set α f : { x // x ∈ Lp E 2 } hs : MeasurableSet s c : E hμs : ↑↑μ s ≠ ⊤ h_left : ∫ (x : α) in s, inner (↑↑(indicatorConstLp 2 hs hμs c) x) (↑↑f x) ∂μ = ∫ (x : α) in s, inner c (↑↑f x) ∂μ h_indicator : ∀ᵐ (x : α) ∂μ, ¬x ∈ s → ↑↑(indicatorConstLp 2 hs hμs c) x = 0 ⊢ ∀ᵐ (x : α) ∂μ, ¬x ∈ s → inner (↑↑(indicatorConstLp 2 hs hμs c) x) (↑↑f x) = 0 [PROOFSTEP] refine' h_indicator.mono fun x hx hxs => _ [GOAL] case h_ae_eq α : Type u_1 E : Type u_2 F : Type u_3 𝕜 : Type u_4 inst✝⁴ : IsROrC 𝕜 inst✝³ : MeasurableSpace α μ : Measure α inst✝² : NormedAddCommGroup E inst✝¹ : InnerProductSpace 𝕜 E inst✝ : NormedAddCommGroup F s : Set α f : { x // x ∈ Lp E 2 } hs : MeasurableSet s c : E hμs : ↑↑μ s ≠ ⊤ h_left : ∫ (x : α) in s, inner (↑↑(indicatorConstLp 2 hs hμs c) x) (↑↑f x) ∂μ = ∫ (x : α) in s, inner c (↑↑f x) ∂μ h_indicator : ∀ᵐ (x : α) ∂μ, ¬x ∈ s → ↑↑(indicatorConstLp 2 hs hμs c) x = 0 x : α hx : ¬x ∈ s → ↑↑(indicatorConstLp 2 hs hμs c) x = 0 hxs : ¬x ∈ s ⊢ inner (↑↑(indicatorConstLp 2 hs hμs c) x) (↑↑f x) = 0 [PROOFSTEP] rw [hx hxs] [GOAL] case h_ae_eq α : Type u_1 E : Type u_2 F : Type u_3 𝕜 : Type u_4 inst✝⁴ : IsROrC 𝕜 inst✝³ : MeasurableSpace α μ : Measure α inst✝² : NormedAddCommGroup E inst✝¹ : InnerProductSpace 𝕜 E inst✝ : NormedAddCommGroup F s : Set α f : { x // x ∈ Lp E 2 } hs : MeasurableSet s c : E hμs : ↑↑μ s ≠ ⊤ h_left : ∫ (x : α) in s, inner (↑↑(indicatorConstLp 2 hs hμs c) x) (↑↑f x) ∂μ = ∫ (x : α) in s, inner c (↑↑f x) ∂μ h_indicator : ∀ᵐ (x : α) ∂μ, ¬x ∈ s → ↑↑(indicatorConstLp 2 hs hμs c) x = 0 x : α hx : ¬x ∈ s → ↑↑(indicatorConstLp 2 hs hμs c) x = 0 hxs : ¬x ∈ s ⊢ inner 0 (↑↑f x) = 0 [PROOFSTEP] exact inner_zero_left _ [GOAL] α : Type u_1 E : Type u_2 F : Type u_3 𝕜 : Type u_4 inst✝⁴ : IsROrC 𝕜 inst✝³ : MeasurableSpace α μ : Measure α inst✝² : NormedAddCommGroup E inst✝¹ : InnerProductSpace 𝕜 E inst✝ : NormedAddCommGroup F s : Set α f : { x // x ∈ Lp E 2 } hs : MeasurableSet s c : E hμs : ↑↑μ s ≠ ⊤ h_left : ∫ (x : α) in s, inner (↑↑(indicatorConstLp 2 hs hμs c) x) (↑↑f x) ∂μ = ∫ (x : α) in s, inner c (↑↑f x) ∂μ h_right : ∫ (x : α) in sᶜ, inner (↑↑(indicatorConstLp 2 hs hμs c) x) (↑↑f x) ∂μ = 0 ⊢ ∫ (x : α) in s, inner (↑↑(indicatorConstLp 2 hs hμs c) x) (↑↑f x) ∂μ + ∫ (x : α) in sᶜ, inner (↑↑(indicatorConstLp 2 hs hμs c) x) (↑↑f x) ∂μ = ∫ (x : α) in s, inner c (↑↑f x) ∂μ [PROOFSTEP] rw [h_left, h_right, add_zero] [GOAL] α : Type u_1 E : Type u_2 F : Type u_3 𝕜 : Type u_4 inst✝⁶ : IsROrC 𝕜 inst✝⁵ : MeasurableSpace α μ : Measure α inst✝⁴ : NormedAddCommGroup E inst✝³ : InnerProductSpace 𝕜 E inst✝² : NormedAddCommGroup F s : Set α inst✝¹ : CompleteSpace E inst✝ : NormedSpace ℝ E hs : MeasurableSet s hμs : ↑↑μ s ≠ ⊤ c : E f : { x // x ∈ Lp E 2 } ⊢ inner (indicatorConstLp 2 hs hμs c) f = inner c (∫ (x : α) in s, ↑↑f x ∂μ) [PROOFSTEP] rw [← integral_inner (integrableOn_Lp_of_measure_ne_top f fact_one_le_two_ennreal.elim hμs), L2.inner_indicatorConstLp_eq_set_integral_inner] [GOAL] α : Type u_1 E : Type u_2 F : Type u_3 𝕜 : Type u_4 inst✝⁴ : IsROrC 𝕜 inst✝³ : MeasurableSpace α μ : Measure α inst✝² : NormedAddCommGroup E inst✝¹ : InnerProductSpace 𝕜 E inst✝ : NormedAddCommGroup F s : Set α hs : MeasurableSet s hμs : ↑↑μ s ≠ ⊤ f : { x // x ∈ Lp 𝕜 2 } ⊢ inner (indicatorConstLp 2 hs hμs 1) f = ∫ (x : α) in s, ↑↑f x ∂μ [PROOFSTEP] rw [L2.inner_indicatorConstLp_eq_inner_set_integral 𝕜 hs hμs (1 : 𝕜) f] [GOAL] α : Type u_1 E : Type u_2 F : Type u_3 𝕜 : Type u_4 inst✝⁴ : IsROrC 𝕜 inst✝³ : MeasurableSpace α μ : Measure α inst✝² : NormedAddCommGroup E inst✝¹ : InnerProductSpace 𝕜 E inst✝ : NormedAddCommGroup F s : Set α hs : MeasurableSet s hμs : ↑↑μ s ≠ ⊤ f : { x // x ∈ Lp 𝕜 2 } ⊢ inner 1 (∫ (x : α) in s, ↑↑f x ∂μ) = ∫ (x : α) in s, ↑↑f x ∂μ [PROOFSTEP] simp [GOAL] α : Type u_1 inst✝⁴ : TopologicalSpace α inst✝³ : MeasureSpace α inst✝² : BorelSpace α 𝕜 : Type u_2 inst✝¹ : IsROrC 𝕜 μ : Measure α inst✝ : IsFiniteMeasure μ f g : α →ᵇ 𝕜 ⊢ inner (↑(BoundedContinuousFunction.toLp 2 μ 𝕜) f) (↑(BoundedContinuousFunction.toLp 2 μ 𝕜) g) = ∫ (x : α), ↑(starRingEnd ((fun a => 𝕜) x)) (↑f x) * ↑g x ∂μ [PROOFSTEP] apply integral_congr_ae [GOAL] case h α : Type u_1 inst✝⁴ : TopologicalSpace α inst✝³ : MeasureSpace α inst✝² : BorelSpace α 𝕜 : Type u_2 inst✝¹ : IsROrC 𝕜 μ : Measure α inst✝ : IsFiniteMeasure μ f g : α →ᵇ 𝕜 ⊢ (fun a => inner (↑↑(↑(BoundedContinuousFunction.toLp 2 μ 𝕜) f) a) (↑↑(↑(BoundedContinuousFunction.toLp 2 μ 𝕜) g) a)) =ᵐ[μ] fun a => ↑(starRingEnd ((fun a => 𝕜) a)) (↑f a) * ↑g a [PROOFSTEP] have hf_ae := f.coeFn_toLp 2 μ 𝕜 [GOAL] case h α : Type u_1 inst✝⁴ : TopologicalSpace α inst✝³ : MeasureSpace α inst✝² : BorelSpace α 𝕜 : Type u_2 inst✝¹ : IsROrC 𝕜 μ : Measure α inst✝ : IsFiniteMeasure μ f g : α →ᵇ 𝕜 hf_ae : ↑↑(↑(BoundedContinuousFunction.toLp 2 μ 𝕜) f) =ᵐ[μ] ↑f ⊢ (fun a => inner (↑↑(↑(BoundedContinuousFunction.toLp 2 μ 𝕜) f) a) (↑↑(↑(BoundedContinuousFunction.toLp 2 μ 𝕜) g) a)) =ᵐ[μ] fun a => ↑(starRingEnd ((fun a => 𝕜) a)) (↑f a) * ↑g a [PROOFSTEP] have hg_ae := g.coeFn_toLp 2 μ 𝕜 [GOAL] case h α : Type u_1 inst✝⁴ : TopologicalSpace α inst✝³ : MeasureSpace α inst✝² : BorelSpace α 𝕜 : Type u_2 inst✝¹ : IsROrC 𝕜 μ : Measure α inst✝ : IsFiniteMeasure μ f g : α →ᵇ 𝕜 hf_ae : ↑↑(↑(BoundedContinuousFunction.toLp 2 μ 𝕜) f) =ᵐ[μ] ↑f hg_ae : ↑↑(↑(BoundedContinuousFunction.toLp 2 μ 𝕜) g) =ᵐ[μ] ↑g ⊢ (fun a => inner (↑↑(↑(BoundedContinuousFunction.toLp 2 μ 𝕜) f) a) (↑↑(↑(BoundedContinuousFunction.toLp 2 μ 𝕜) g) a)) =ᵐ[μ] fun a => ↑(starRingEnd ((fun a => 𝕜) a)) (↑f a) * ↑g a [PROOFSTEP] filter_upwards [hf_ae, hg_ae] with _ hf hg [GOAL] case h α : Type u_1 inst✝⁴ : TopologicalSpace α inst✝³ : MeasureSpace α inst✝² : BorelSpace α 𝕜 : Type u_2 inst✝¹ : IsROrC 𝕜 μ : Measure α inst✝ : IsFiniteMeasure μ f g : α →ᵇ 𝕜 hf_ae : ↑↑(↑(BoundedContinuousFunction.toLp 2 μ 𝕜) f) =ᵐ[μ] ↑f hg_ae : ↑↑(↑(BoundedContinuousFunction.toLp 2 μ 𝕜) g) =ᵐ[μ] ↑g a✝ : α hf : ↑↑(↑(BoundedContinuousFunction.toLp 2 μ 𝕜) f) a✝ = ↑f a✝ hg : ↑↑(↑(BoundedContinuousFunction.toLp 2 μ 𝕜) g) a✝ = ↑g a✝ ⊢ inner (↑↑(↑(BoundedContinuousFunction.toLp 2 μ 𝕜) f) a✝) (↑↑(↑(BoundedContinuousFunction.toLp 2 μ 𝕜) g) a✝) = ↑(starRingEnd 𝕜) (↑f a✝) * ↑g a✝ [PROOFSTEP] rw [hf, hg] [GOAL] case h α : Type u_1 inst✝⁴ : TopologicalSpace α inst✝³ : MeasureSpace α inst✝² : BorelSpace α 𝕜 : Type u_2 inst✝¹ : IsROrC 𝕜 μ : Measure α inst✝ : IsFiniteMeasure μ f g : α →ᵇ 𝕜 hf_ae : ↑↑(↑(BoundedContinuousFunction.toLp 2 μ 𝕜) f) =ᵐ[μ] ↑f hg_ae : ↑↑(↑(BoundedContinuousFunction.toLp 2 μ 𝕜) g) =ᵐ[μ] ↑g a✝ : α hf : ↑↑(↑(BoundedContinuousFunction.toLp 2 μ 𝕜) f) a✝ = ↑f a✝ hg : ↑↑(↑(BoundedContinuousFunction.toLp 2 μ 𝕜) g) a✝ = ↑g a✝ ⊢ inner (↑f a✝) (↑g a✝) = ↑(starRingEnd 𝕜) (↑f a✝) * ↑g a✝ [PROOFSTEP] simp [GOAL] α : Type u_1 inst✝⁵ : TopologicalSpace α inst✝⁴ : MeasureSpace α inst✝³ : BorelSpace α 𝕜 : Type u_2 inst✝² : IsROrC 𝕜 μ : Measure α inst✝¹ : IsFiniteMeasure μ inst✝ : CompactSpace α f g : C(α, 𝕜) ⊢ inner (↑(ContinuousMap.toLp 2 μ 𝕜) f) (↑(ContinuousMap.toLp 2 μ 𝕜) g) = ∫ (x : α), ↑(starRingEnd ((fun x => 𝕜) x)) (↑f x) * ↑g x ∂μ [PROOFSTEP] apply integral_congr_ae [GOAL] case h α : Type u_1 inst✝⁵ : TopologicalSpace α inst✝⁴ : MeasureSpace α inst✝³ : BorelSpace α 𝕜 : Type u_2 inst✝² : IsROrC 𝕜 μ : Measure α inst✝¹ : IsFiniteMeasure μ inst✝ : CompactSpace α f g : C(α, 𝕜) ⊢ (fun a => inner (↑↑(↑(ContinuousMap.toLp 2 μ 𝕜) f) a) (↑↑(↑(ContinuousMap.toLp 2 μ 𝕜) g) a)) =ᵐ[μ] fun a => ↑(starRingEnd ((fun x => 𝕜) a)) (↑f a) * ↑g a [PROOFSTEP] have hf_ae := f.coeFn_toLp (p := 2) (𝕜 := 𝕜) μ [GOAL] case h α : Type u_1 inst✝⁵ : TopologicalSpace α inst✝⁴ : MeasureSpace α inst✝³ : BorelSpace α 𝕜 : Type u_2 inst✝² : IsROrC 𝕜 μ : Measure α inst✝¹ : IsFiniteMeasure μ inst✝ : CompactSpace α f g : C(α, 𝕜) hf_ae : ↑↑(↑(ContinuousMap.toLp 2 μ 𝕜) f) =ᵐ[μ] ↑f ⊢ (fun a => inner (↑↑(↑(ContinuousMap.toLp 2 μ 𝕜) f) a) (↑↑(↑(ContinuousMap.toLp 2 μ 𝕜) g) a)) =ᵐ[μ] fun a => ↑(starRingEnd ((fun x => 𝕜) a)) (↑f a) * ↑g a [PROOFSTEP] have hg_ae := g.coeFn_toLp (p := 2) (𝕜 := 𝕜) μ [GOAL] case h α : Type u_1 inst✝⁵ : TopologicalSpace α inst✝⁴ : MeasureSpace α inst✝³ : BorelSpace α 𝕜 : Type u_2 inst✝² : IsROrC 𝕜 μ : Measure α inst✝¹ : IsFiniteMeasure μ inst✝ : CompactSpace α f g : C(α, 𝕜) hf_ae : ↑↑(↑(ContinuousMap.toLp 2 μ 𝕜) f) =ᵐ[μ] ↑f hg_ae : ↑↑(↑(ContinuousMap.toLp 2 μ 𝕜) g) =ᵐ[μ] ↑g ⊢ (fun a => inner (↑↑(↑(ContinuousMap.toLp 2 μ 𝕜) f) a) (↑↑(↑(ContinuousMap.toLp 2 μ 𝕜) g) a)) =ᵐ[μ] fun a => ↑(starRingEnd ((fun x => 𝕜) a)) (↑f a) * ↑g a [PROOFSTEP] filter_upwards [hf_ae, hg_ae] with _ hf hg [GOAL] case h α : Type u_1 inst✝⁵ : TopologicalSpace α inst✝⁴ : MeasureSpace α inst✝³ : BorelSpace α 𝕜 : Type u_2 inst✝² : IsROrC 𝕜 μ : Measure α inst✝¹ : IsFiniteMeasure μ inst✝ : CompactSpace α f g : C(α, 𝕜) hf_ae : ↑↑(↑(ContinuousMap.toLp 2 μ 𝕜) f) =ᵐ[μ] ↑f hg_ae : ↑↑(↑(ContinuousMap.toLp 2 μ 𝕜) g) =ᵐ[μ] ↑g a✝ : α hf : ↑↑(↑(ContinuousMap.toLp 2 μ 𝕜) f) a✝ = ↑f a✝ hg : ↑↑(↑(ContinuousMap.toLp 2 μ 𝕜) g) a✝ = ↑g a✝ ⊢ inner (↑↑(↑(ContinuousMap.toLp 2 μ 𝕜) f) a✝) (↑↑(↑(ContinuousMap.toLp 2 μ 𝕜) g) a✝) = ↑(starRingEnd 𝕜) (↑f a✝) * ↑g a✝ [PROOFSTEP] rw [hf, hg] [GOAL] case h α : Type u_1 inst✝⁵ : TopologicalSpace α inst✝⁴ : MeasureSpace α inst✝³ : BorelSpace α 𝕜 : Type u_2 inst✝² : IsROrC 𝕜 μ : Measure α inst✝¹ : IsFiniteMeasure μ inst✝ : CompactSpace α f g : C(α, 𝕜) hf_ae : ↑↑(↑(ContinuousMap.toLp 2 μ 𝕜) f) =ᵐ[μ] ↑f hg_ae : ↑↑(↑(ContinuousMap.toLp 2 μ 𝕜) g) =ᵐ[μ] ↑g a✝ : α hf : ↑↑(↑(ContinuousMap.toLp 2 μ 𝕜) f) a✝ = ↑f a✝ hg : ↑↑(↑(ContinuousMap.toLp 2 μ 𝕜) g) a✝ = ↑g a✝ ⊢ inner (↑f a✝) (↑g a✝) = ↑(starRingEnd 𝕜) (↑f a✝) * ↑g a✝ [PROOFSTEP] simp
[GOAL] J : Type v inst✝ : SmallCategory J F : J ⥤ MonCat ⊢ Inhabited (ColimitType F) [PROOFSTEP] dsimp [ColimitType] [GOAL] J : Type v inst✝ : SmallCategory J F : J ⥤ MonCat ⊢ Inhabited (Quotient (colimitSetoid F)) [PROOFSTEP] infer_instance [GOAL] J : Type v inst✝ : SmallCategory J F : J ⥤ MonCat ⊢ Monoid (ColimitType F) [PROOFSTEP] infer_instance [GOAL] J : Type v inst✝ : SmallCategory J F : J ⥤ MonCat j j' : J f : j ⟶ j' ⊢ F.map f ≫ coconeMorphism F j' = coconeMorphism F j [PROOFSTEP] ext [GOAL] case w J : Type v inst✝ : SmallCategory J F : J ⥤ MonCat j j' : J f : j ⟶ j' x✝ : ↑(F.obj j) ⊢ ↑(F.map f ≫ coconeMorphism F j') x✝ = ↑(coconeMorphism F j) x✝ [PROOFSTEP] apply Quot.sound [GOAL] case w.a J : Type v inst✝ : SmallCategory J F : J ⥤ MonCat j j' : J f : j ⟶ j' x✝ : ↑(F.obj j) ⊢ Setoid.r (Prequotient.of j' (↑(F.map f) x✝)) (Prequotient.of j x✝) [PROOFSTEP] apply Relation.map [GOAL] J : Type v inst✝ : SmallCategory J F : J ⥤ MonCat j j' : J f : j ⟶ j' x : ↑(F.obj j) ⊢ ↑(coconeMorphism F j') (↑(F.map f) x) = ↑(coconeMorphism F j) x [PROOFSTEP] rw [← cocone_naturality F f] [GOAL] J : Type v inst✝ : SmallCategory J F : J ⥤ MonCat j j' : J f : j ⟶ j' x : ↑(F.obj j) ⊢ ↑(coconeMorphism F j') (↑(F.map f) x) = ↑(F.map f ≫ coconeMorphism F j') x [PROOFSTEP] rfl [GOAL] J : Type v inst✝ : SmallCategory J F : J ⥤ MonCat s : Cocone F ⊢ ColimitType F → ↑s.pt [PROOFSTEP] fapply Quot.lift [GOAL] case f J : Type v inst✝ : SmallCategory J F : J ⥤ MonCat s : Cocone F ⊢ Prequotient F → ↑s.pt [PROOFSTEP] exact descFunLift F s [GOAL] case a J : Type v inst✝ : SmallCategory J F : J ⥤ MonCat s : Cocone F ⊢ ∀ (a b : Prequotient F), Setoid.r a b → descFunLift F s a = descFunLift F s b [PROOFSTEP] intro x y r [GOAL] case a J : Type v inst✝ : SmallCategory J F : J ⥤ MonCat s : Cocone F x y : Prequotient F r : Setoid.r x y ⊢ descFunLift F s x = descFunLift F s y [PROOFSTEP] induction' r with _ _ _ _ h _ _ _ _ _ h₁ h₂ _ _ f x _ _ _ _ _ _ _ _ h _ _ _ _ h [GOAL] case a.refl J : Type v inst✝ : SmallCategory J F : J ⥤ MonCat s : Cocone F x y x✝ : Prequotient F ⊢ descFunLift F s x✝ = descFunLift F s x✝ [PROOFSTEP] try simp -- symm [GOAL] case a.refl J : Type v inst✝ : SmallCategory J F : J ⥤ MonCat s : Cocone F x y x✝ : Prequotient F ⊢ descFunLift F s x✝ = descFunLift F s x✝ [PROOFSTEP] simp -- symm [GOAL] case a.symm J : Type v inst✝ : SmallCategory J F : J ⥤ MonCat s : Cocone F x y x✝¹ y✝ : Prequotient F x✝ : Relation F x✝¹ y✝ h : descFunLift F s x✝¹ = descFunLift F s y✝ ⊢ descFunLift F s y✝ = descFunLift F s x✝¹ [PROOFSTEP] try simp -- symm [GOAL] case a.symm J : Type v inst✝ : SmallCategory J F : J ⥤ MonCat s : Cocone F x y x✝¹ y✝ : Prequotient F x✝ : Relation F x✝¹ y✝ h : descFunLift F s x✝¹ = descFunLift F s y✝ ⊢ descFunLift F s y✝ = descFunLift F s x✝¹ [PROOFSTEP] simp -- symm [GOAL] case a.trans J : Type v inst✝ : SmallCategory J F : J ⥤ MonCat s : Cocone F x y x✝² y✝ z✝ : Prequotient F x✝¹ : Relation F x✝² y✝ x✝ : Relation F y✝ z✝ h₁ : descFunLift F s x✝² = descFunLift F s y✝ h₂ : descFunLift F s y✝ = descFunLift F s z✝ ⊢ descFunLift F s x✝² = descFunLift F s z✝ [PROOFSTEP] try simp -- symm [GOAL] case a.trans J : Type v inst✝ : SmallCategory J F : J ⥤ MonCat s : Cocone F x y x✝² y✝ z✝ : Prequotient F x✝¹ : Relation F x✝² y✝ x✝ : Relation F y✝ z✝ h₁ : descFunLift F s x✝² = descFunLift F s y✝ h₂ : descFunLift F s y✝ = descFunLift F s z✝ ⊢ descFunLift F s x✝² = descFunLift F s z✝ [PROOFSTEP] simp -- symm [GOAL] case a.map J : Type v inst✝ : SmallCategory J F : J ⥤ MonCat s : Cocone F x✝ y : Prequotient F j✝ j'✝ : J f : j✝ ⟶ j'✝ x : ↑(F.obj j✝) ⊢ descFunLift F s (Prequotient.of j'✝ (↑(F.map f) x)) = descFunLift F s (Prequotient.of j✝ x) [PROOFSTEP] try simp -- symm [GOAL] case a.map J : Type v inst✝ : SmallCategory J F : J ⥤ MonCat s : Cocone F x✝ y : Prequotient F j✝ j'✝ : J f : j✝ ⟶ j'✝ x : ↑(F.obj j✝) ⊢ descFunLift F s (Prequotient.of j'✝ (↑(F.map f) x)) = descFunLift F s (Prequotient.of j✝ x) [PROOFSTEP] simp -- symm [GOAL] case a.mul J : Type v inst✝ : SmallCategory J F : J ⥤ MonCat s : Cocone F x y : Prequotient F j✝ : J x✝ y✝ : ↑(F.obj j✝) ⊢ descFunLift F s (Prequotient.of j✝ (x✝ * y✝)) = descFunLift F s (mul (Prequotient.of j✝ x✝) (Prequotient.of j✝ y✝)) [PROOFSTEP] try simp -- symm [GOAL] case a.mul J : Type v inst✝ : SmallCategory J F : J ⥤ MonCat s : Cocone F x y : Prequotient F j✝ : J x✝ y✝ : ↑(F.obj j✝) ⊢ descFunLift F s (Prequotient.of j✝ (x✝ * y✝)) = descFunLift F s (mul (Prequotient.of j✝ x✝) (Prequotient.of j✝ y✝)) [PROOFSTEP] simp -- symm [GOAL] case a.one J : Type v inst✝ : SmallCategory J F : J ⥤ MonCat s : Cocone F x y : Prequotient F j✝ : J ⊢ descFunLift F s (Prequotient.of j✝ 1) = descFunLift F s one [PROOFSTEP] try simp -- symm [GOAL] case a.one J : Type v inst✝ : SmallCategory J F : J ⥤ MonCat s : Cocone F x y : Prequotient F j✝ : J ⊢ descFunLift F s (Prequotient.of j✝ 1) = descFunLift F s one [PROOFSTEP] simp -- symm [GOAL] case a.mul_1 J : Type v inst✝ : SmallCategory J F : J ⥤ MonCat s : Cocone F x y x✝¹ x'✝ y✝ : Prequotient F x✝ : Relation F x✝¹ x'✝ h : descFunLift F s x✝¹ = descFunLift F s x'✝ ⊢ descFunLift F s (mul x✝¹ y✝) = descFunLift F s (mul x'✝ y✝) [PROOFSTEP] try simp -- symm [GOAL] case a.mul_1 J : Type v inst✝ : SmallCategory J F : J ⥤ MonCat s : Cocone F x y x✝¹ x'✝ y✝ : Prequotient F x✝ : Relation F x✝¹ x'✝ h : descFunLift F s x✝¹ = descFunLift F s x'✝ ⊢ descFunLift F s (mul x✝¹ y✝) = descFunLift F s (mul x'✝ y✝) [PROOFSTEP] simp -- symm [GOAL] case a.mul_2 J : Type v inst✝ : SmallCategory J F : J ⥤ MonCat s : Cocone F x y x✝¹ y✝ y'✝ : Prequotient F x✝ : Relation F y✝ y'✝ h : descFunLift F s y✝ = descFunLift F s y'✝ ⊢ descFunLift F s (mul x✝¹ y✝) = descFunLift F s (mul x✝¹ y'✝) [PROOFSTEP] try simp -- symm [GOAL] case a.mul_2 J : Type v inst✝ : SmallCategory J F : J ⥤ MonCat s : Cocone F x y x✝¹ y✝ y'✝ : Prequotient F x✝ : Relation F y✝ y'✝ h : descFunLift F s y✝ = descFunLift F s y'✝ ⊢ descFunLift F s (mul x✝¹ y✝) = descFunLift F s (mul x✝¹ y'✝) [PROOFSTEP] simp -- symm [GOAL] case a.mul_assoc J : Type v inst✝ : SmallCategory J F : J ⥤ MonCat s : Cocone F x y x✝ y✝ z✝ : Prequotient F ⊢ descFunLift F s (mul (mul x✝ y✝) z✝) = descFunLift F s (mul x✝ (mul y✝ z✝)) [PROOFSTEP] try simp -- symm [GOAL] case a.mul_assoc J : Type v inst✝ : SmallCategory J F : J ⥤ MonCat s : Cocone F x y x✝ y✝ z✝ : Prequotient F ⊢ descFunLift F s (mul (mul x✝ y✝) z✝) = descFunLift F s (mul x✝ (mul y✝ z✝)) [PROOFSTEP] simp -- symm [GOAL] case a.one_mul J : Type v inst✝ : SmallCategory J F : J ⥤ MonCat s : Cocone F x y x✝ : Prequotient F ⊢ descFunLift F s (mul one x✝) = descFunLift F s x✝ [PROOFSTEP] try simp -- symm [GOAL] case a.one_mul J : Type v inst✝ : SmallCategory J F : J ⥤ MonCat s : Cocone F x y x✝ : Prequotient F ⊢ descFunLift F s (mul one x✝) = descFunLift F s x✝ [PROOFSTEP] simp -- symm [GOAL] case a.mul_one J : Type v inst✝ : SmallCategory J F : J ⥤ MonCat s : Cocone F x y x✝ : Prequotient F ⊢ descFunLift F s (mul x✝ one) = descFunLift F s x✝ [PROOFSTEP] try simp -- symm [GOAL] case a.mul_one J : Type v inst✝ : SmallCategory J F : J ⥤ MonCat s : Cocone F x y x✝ : Prequotient F ⊢ descFunLift F s (mul x✝ one) = descFunLift F s x✝ [PROOFSTEP] simp -- symm [GOAL] case a.symm J : Type v inst✝ : SmallCategory J F : J ⥤ MonCat s : Cocone F x y x✝¹ y✝ : Prequotient F x✝ : Relation F x✝¹ y✝ h : descFunLift F s x✝¹ = descFunLift F s y✝ ⊢ descFunLift F s y✝ = descFunLift F s x✝¹ [PROOFSTEP] exact h.symm [GOAL] case a.trans J : Type v inst✝ : SmallCategory J F : J ⥤ MonCat s : Cocone F x y x✝² y✝ z✝ : Prequotient F x✝¹ : Relation F x✝² y✝ x✝ : Relation F y✝ z✝ h₁ : descFunLift F s x✝² = descFunLift F s y✝ h₂ : descFunLift F s y✝ = descFunLift F s z✝ ⊢ descFunLift F s x✝² = descFunLift F s z✝ [PROOFSTEP] exact h₁.trans h₂ [GOAL] case a.map J : Type v inst✝ : SmallCategory J F : J ⥤ MonCat s : Cocone F x✝ y : Prequotient F j✝ j'✝ : J f : j✝ ⟶ j'✝ x : ↑(F.obj j✝) ⊢ ↑(NatTrans.app s.ι j'✝) (↑(F.map f) x) = ↑(NatTrans.app s.ι j✝) x [PROOFSTEP] exact s.w_apply f x [GOAL] case a.mul_1 J : Type v inst✝ : SmallCategory J F : J ⥤ MonCat s : Cocone F x y x✝¹ x'✝ y✝ : Prequotient F x✝ : Relation F x✝¹ x'✝ h : descFunLift F s x✝¹ = descFunLift F s x'✝ ⊢ descFunLift F s x✝¹ * descFunLift F s y✝ = descFunLift F s x'✝ * descFunLift F s y✝ [PROOFSTEP] rw [h] -- mul_2 [GOAL] case a.mul_2 J : Type v inst✝ : SmallCategory J F : J ⥤ MonCat s : Cocone F x y x✝¹ y✝ y'✝ : Prequotient F x✝ : Relation F y✝ y'✝ h : descFunLift F s y✝ = descFunLift F s y'✝ ⊢ descFunLift F s x✝¹ * descFunLift F s y✝ = descFunLift F s x✝¹ * descFunLift F s y'✝ [PROOFSTEP] rw [h] -- mul_assoc [GOAL] case a.mul_assoc J : Type v inst✝ : SmallCategory J F : J ⥤ MonCat s : Cocone F x y x✝ y✝ z✝ : Prequotient F ⊢ descFunLift F s x✝ * descFunLift F s y✝ * descFunLift F s z✝ = descFunLift F s x✝ * (descFunLift F s y✝ * descFunLift F s z✝) [PROOFSTEP] rw [mul_assoc] [GOAL] J : Type v inst✝ : SmallCategory J F : J ⥤ MonCat s : Cocone F x y : ↑(colimit F) ⊢ OneHom.toFun { toFun := descFun F s, map_one' := (_ : descFun F s 1 = descFun F s 1) } (x * y) = OneHom.toFun { toFun := descFun F s, map_one' := (_ : descFun F s 1 = descFun F s 1) } x * OneHom.toFun { toFun := descFun F s, map_one' := (_ : descFun F s 1 = descFun F s 1) } y [PROOFSTEP] induction x using Quot.inductionOn [GOAL] case h J : Type v inst✝ : SmallCategory J F : J ⥤ MonCat s : Cocone F y : ↑(colimit F) a✝ : Prequotient F ⊢ OneHom.toFun { toFun := descFun F s, map_one' := (_ : descFun F s 1 = descFun F s 1) } (Quot.mk Setoid.r a✝ * y) = OneHom.toFun { toFun := descFun F s, map_one' := (_ : descFun F s 1 = descFun F s 1) } (Quot.mk Setoid.r a✝) * OneHom.toFun { toFun := descFun F s, map_one' := (_ : descFun F s 1 = descFun F s 1) } y [PROOFSTEP] induction y using Quot.inductionOn [GOAL] case h.h J : Type v inst✝ : SmallCategory J F : J ⥤ MonCat s : Cocone F a✝¹ a✝ : Prequotient F ⊢ OneHom.toFun { toFun := descFun F s, map_one' := (_ : descFun F s 1 = descFun F s 1) } (Quot.mk Setoid.r a✝¹ * Quot.mk Setoid.r a✝) = OneHom.toFun { toFun := descFun F s, map_one' := (_ : descFun F s 1 = descFun F s 1) } (Quot.mk Setoid.r a✝¹) * OneHom.toFun { toFun := descFun F s, map_one' := (_ : descFun F s 1 = descFun F s 1) } (Quot.mk Setoid.r a✝) [PROOFSTEP] dsimp [descFun] [GOAL] case h.h J : Type v inst✝ : SmallCategory J F : J ⥤ MonCat s : Cocone F a✝¹ a✝ : Prequotient F ⊢ Quot.lift (descFunLift F s) (_ : ∀ (x y : Prequotient F), Setoid.r x y → descFunLift F s x = descFunLift F s y) (Quot.mk Setoid.r a✝¹ * Quot.mk Setoid.r a✝) = descFunLift F s a✝¹ * descFunLift F s a✝ [PROOFSTEP] rw [← quot_mul] [GOAL] case h.h J : Type v inst✝ : SmallCategory J F : J ⥤ MonCat s : Cocone F a✝¹ a✝ : Prequotient F ⊢ Quot.lift (descFunLift F s) (_ : ∀ (x y : Prequotient F), Setoid.r x y → descFunLift F s x = descFunLift F s y) (Quot.mk Setoid.r (mul a✝¹ a✝)) = descFunLift F s a✝¹ * descFunLift F s a✝ [PROOFSTEP] simp only [descFunLift] [GOAL] J : Type v inst✝ : SmallCategory J F : J ⥤ MonCat s : Cocone F m : (colimitCocone F).pt ⟶ s.pt w : ∀ (j : J), NatTrans.app (colimitCocone F).ι j ≫ m = NatTrans.app s.ι j ⊢ m = (fun s => descMorphism F s) s [PROOFSTEP] ext x [GOAL] case w J : Type v inst✝ : SmallCategory J F : J ⥤ MonCat s : Cocone F m : (colimitCocone F).pt ⟶ s.pt w : ∀ (j : J), NatTrans.app (colimitCocone F).ι j ≫ m = NatTrans.app s.ι j x : ↑(colimitCocone F).pt ⊢ ↑m x = ↑((fun s => descMorphism F s) s) x [PROOFSTEP] induction' x using Quot.inductionOn with x [GOAL] case w.h J : Type v inst✝ : SmallCategory J F : J ⥤ MonCat s : Cocone F m : (colimitCocone F).pt ⟶ s.pt w : ∀ (j : J), NatTrans.app (colimitCocone F).ι j ≫ m = NatTrans.app s.ι j x : Prequotient F ⊢ ↑m (Quot.mk Setoid.r x) = ↑((fun s => descMorphism F s) s) (Quot.mk Setoid.r x) [PROOFSTEP] induction' x with j x x y hx hy [GOAL] case w.h.of J : Type v inst✝ : SmallCategory J F : J ⥤ MonCat s : Cocone F m : (colimitCocone F).pt ⟶ s.pt w : ∀ (j : J), NatTrans.app (colimitCocone F).ι j ≫ m = NatTrans.app s.ι j j : J x : ↑(F.obj j) ⊢ ↑m (Quot.mk Setoid.r (Prequotient.of j x)) = ↑((fun s => descMorphism F s) s) (Quot.mk Setoid.r (Prequotient.of j x)) [PROOFSTEP] change _ = s.ι.app j _ [GOAL] case w.h.of J : Type v inst✝ : SmallCategory J F : J ⥤ MonCat s : Cocone F m : (colimitCocone F).pt ⟶ s.pt w : ∀ (j : J), NatTrans.app (colimitCocone F).ι j ≫ m = NatTrans.app s.ι j j : J x : ↑(F.obj j) ⊢ ↑m (Quot.mk Setoid.r (Prequotient.of j x)) = ↑(NatTrans.app s.ι j) x [PROOFSTEP] rw [← w j] [GOAL] case w.h.of J : Type v inst✝ : SmallCategory J F : J ⥤ MonCat s : Cocone F m : (colimitCocone F).pt ⟶ s.pt w : ∀ (j : J), NatTrans.app (colimitCocone F).ι j ≫ m = NatTrans.app s.ι j j : J x : ↑(F.obj j) ⊢ ↑m (Quot.mk Setoid.r (Prequotient.of j x)) = ↑(NatTrans.app (colimitCocone F).ι j ≫ m) x [PROOFSTEP] rfl [GOAL] case w.h.one J : Type v inst✝ : SmallCategory J F : J ⥤ MonCat s : Cocone F m : (colimitCocone F).pt ⟶ s.pt w : ∀ (j : J), NatTrans.app (colimitCocone F).ι j ≫ m = NatTrans.app s.ι j ⊢ ↑m (Quot.mk Setoid.r one) = ↑((fun s => descMorphism F s) s) (Quot.mk Setoid.r one) [PROOFSTEP] rw [quot_one, map_one] [GOAL] case w.h.one J : Type v inst✝ : SmallCategory J F : J ⥤ MonCat s : Cocone F m : (colimitCocone F).pt ⟶ s.pt w : ∀ (j : J), NatTrans.app (colimitCocone F).ι j ≫ m = NatTrans.app s.ι j ⊢ 1 = ↑((fun s => descMorphism F s) s) 1 [PROOFSTEP] rfl [GOAL] case w.h.mul J : Type v inst✝ : SmallCategory J F : J ⥤ MonCat s : Cocone F m : (colimitCocone F).pt ⟶ s.pt w : ∀ (j : J), NatTrans.app (colimitCocone F).ι j ≫ m = NatTrans.app s.ι j x y : Prequotient F hx : ↑m (Quot.mk Setoid.r x) = ↑((fun s => descMorphism F s) s) (Quot.mk Setoid.r x) hy : ↑m (Quot.mk Setoid.r y) = ↑((fun s => descMorphism F s) s) (Quot.mk Setoid.r y) ⊢ ↑m (Quot.mk Setoid.r (mul x y)) = ↑((fun s => descMorphism F s) s) (Quot.mk Setoid.r (mul x y)) [PROOFSTEP] rw [quot_mul, map_mul, hx, hy] [GOAL] case w.h.mul J : Type v inst✝ : SmallCategory J F : J ⥤ MonCat s : Cocone F m : (colimitCocone F).pt ⟶ s.pt w : ∀ (j : J), NatTrans.app (colimitCocone F).ι j ≫ m = NatTrans.app s.ι j x y : Prequotient F hx : ↑m (Quot.mk Setoid.r x) = ↑((fun s => descMorphism F s) s) (Quot.mk Setoid.r x) hy : ↑m (Quot.mk Setoid.r y) = ↑((fun s => descMorphism F s) s) (Quot.mk Setoid.r y) ⊢ ↑((fun s => descMorphism F s) s) (Quot.mk Setoid.r x) * ↑((fun s => descMorphism F s) s) (Quot.mk Setoid.r y) = ↑((fun s => descMorphism F s) s) (Quot.mk Setoid.r x * Quot.mk Setoid.r y) [PROOFSTEP] dsimp [descMorphism, FunLike.coe, descFun] [GOAL] case w.h.mul J : Type v inst✝ : SmallCategory J F : J ⥤ MonCat s : Cocone F m : (colimitCocone F).pt ⟶ s.pt w : ∀ (j : J), NatTrans.app (colimitCocone F).ι j ≫ m = NatTrans.app s.ι j x y : Prequotient F hx : ↑m (Quot.mk Setoid.r x) = ↑((fun s => descMorphism F s) s) (Quot.mk Setoid.r x) hy : ↑m (Quot.mk Setoid.r y) = ↑((fun s => descMorphism F s) s) (Quot.mk Setoid.r y) ⊢ descFunLift F s x * descFunLift F s y = Quot.lift (descFunLift F s) (_ : ∀ (x y : Prequotient F), Setoid.r x y → descFunLift F s x = descFunLift F s y) (Quot.mk Setoid.r x * Quot.mk Setoid.r y) [PROOFSTEP] simp only [← quot_mul, descFunLift]
The basic imports and the variables we'll be using: ```python from __future__ import division import sympy from sympy import * from sympy import Rational as frac import simpletensors from simpletensors import Vector, TensorProduct, SymmetricTensorProduct, Tensor init_printing() var('vartheta, varphi') var('nu, m, delta, c, t') # These are related scalar functions of time var('r, v, Omega', cls=Function) r = r(t) v = v(t) Omega = Omega(t) # These get redefined momentarily, but have to exist first var('nHat, lambdaHat, ellHat', cls=Function) # And now we define them as vector functions of time nHat = Vector('nHat', r'\hat{n}', [cos(Omega*t),sin(Omega*t),0,])(t) lambdaHat = Vector('lambdaHat', r'\hat{\lambda}', [-sin(Omega*t),cos(Omega*t),0,])(t) ellHat = Vector('ellHat', r'\hat{\ell}', [0,0,1,])(t) # These are the spin functions -- first, the individual components as regular sympy.Function objects; then the vectors themselves var('S_n, S_lambda, S_ell', cls=Function) var('Sigma_n, Sigma_lambda, Sigma_ell', cls=Function) SigmaVec = Vector('SigmaVec', r'\vec{\Sigma}', [Sigma_n(t), Sigma_lambda(t), Sigma_ell(t)])(t) SVec = Vector('S', r'\vec{S}', [S_n(t), S_lambda(t), S_ell(t)])(t) ``` ## Examples and tests ```python nHat ``` ```python diff(nHat, t) ``` ```python diff(lambdaHat, t) ``` ```python diff(lambdaHat, t).components ``` ```python diff(lambdaHat, t).subs(t,0).components ``` ```python diff(lambdaHat, t, 2).components ``` ```python diff(lambdaHat, t, 2).subs(t,0).components ``` ```python diff(ellHat, t) ``` ```python diff(nHat, t, 2) ``` ```python diff(nHat,t, 3) ``` ```python diff(nHat,t, 4) ``` ```python diff(SigmaVec,t, 0) ``` ```python SigmaVec.fdiff() ``` ```python diff(SigmaVec,t, 1) ``` ```python diff(SigmaVec,t, 2) ``` ```python diff(SigmaVec,t, 2) | nHat ``` ```python T1 = TensorProduct(SigmaVec, SigmaVec, ellHat, coefficient=1) T2 = TensorProduct(SigmaVec, nHat, lambdaHat, coefficient=1) tmp = Tensor(T1,T2) display(T1, T2, tmp) ``` ```python diff(tmp, t, 1) ``` ```python T1+T2 ``` ```python T2*ellHat ``` ```python ellHat*T2 ``` ```python T1.trace(0,1) ``` ```python T2*ellHat ``` ```python for k in range(1,4): display((T2*ellHat).trace(0,k)) ``` ```python for k in range(1,4): display((T2*ellHat).trace(0,k).subs(t,0)) ``` ```python T1.trace(0,1) * T2 ``` Sympy can be a little tricky because it caches things, which means that the first implementation of this code silently changed tensors in place, without meaning to. Let's just check that our variables haven't changed: ```python display(T1, T2) ``` ```python T3 = SymmetricTensorProduct(SigmaVec, SigmaVec, ellHat, coefficient=1) display(T3) T3.trace(0,1) ``` ```python diff(T3, t, 1) ``` ```python T3.symmetric ``` True ```python T3*ellHat ``` ```python ellHat*T3 ``` ```python T1+T3 ``` ```python T1 = SymmetricTensorProduct(SigmaVec, SigmaVec, ellHat, nHat, coefficient=1) display(T1) display(T1.trace()) ``` ```python T1*T2 ``` ```python type(_) ``` simpletensors.TensorProductFunction_73 ```python import simpletensors isinstance(__, simpletensors.TensorProductFunction) ``` True ```python SymmetricTensorProduct(nHat, nHat, nHat).trace() ``` ```python diff(T1.trace(), t, 1) ``` ```python diff(T1.trace(), t, 2) ``` ```python diff(T1.trace(), t, 2).subs(t,0) ``` ```python ```
import YatimaStdLib.Algebra import YatimaStdLib.Nat import YatimaStdLib.Int namespace Fin def ofInt {n : Nat} (a : Int) : Fin n.succ := ⟨a.modToNat n.succ, Int.modToNat_le⟩ /- This is copied from core since it is private -/ theorem mlt {b : Nat} : {a : Nat} → a < n → b % n < n | 0 , h => Nat.mod_lt _ h | _+1, h => Nat.mod_lt _ (Nat.lt_trans (Nat.zero_lt_succ _) h) def inv : Fin n → Fin n | ⟨a, h⟩ => ⟨(Int.modToNat (Nat.GCD.gcdA a n) n) % n, mlt h⟩ instance : YatimaStdLib.Inv (Fin n) where inv a := Fin.inv a end Fin
module calculates implicit none contains real(kind=8) function determinant(A) real(kind=8), dimension(3,3), intent(in) :: A determinant = A(1,1)*(A(2,2)*A(3,3)-A(2,3)*A(3,2)) - A(1,2)*(A(2,1)*A(3,3)-A(2,3)*A(3,1))& + A(1,3)*(A(2,1)*A(3,2)-A(2,2)*A(3,1)) end function determinant subroutine writes (A) real(kind=8), dimension(3,3), intent(in) :: A integer :: i, j do i = 1, 3 write(*,'(20F8.3)') (A(i,j), j = 1, 3) end do write(*,*) end subroutine writes end module calculates
! <output_citychem_ase.for - A component of the City-scale ! Chemistry Transport Model EPISODE-CityChem> !*****************************************************************************! !* !* CITY-scale CHEMistry Transport Extension !* !* Copyright (C) 2018 Matthias Steffen Karl !* !* Contact Information: !* Institute of Coastal Research !* Helmholtz-Zentrum Geesthacht !* Max-Planck-Str. 1 !* 21502 Geesthacht !* Germany !* email: [email protected] !* !* EPISODE-CityChem, developed at Helmholtz-Zentrum Geesthacht (HZG) is designed !* for treating complex atmospheric chemistry in urban areas (Karl, 2018). The model !* is an extension of the EPISODE dispersion model to enable chemistry/transport !* simulations of reactive pollutants on city scale. EPISODE is an Eulerian dispersion !* model developed at the Norwegian Institute for Air Research (NILU) appropriate for !* air quality studies at the local scale (Slørdal et al. 2003 &2008). The model is an !* open source code subject to the Reciprocal Public License ("RPL") Version 1.5, !* https://opensource.org/licenses/RPL-1.5. !* !* Reference: !* Karl, M. (2018): Development of the city-scale chemistry transport model !* CityChem-EPISODE and its application to the city of Hamburg, !* Geosci. Model Dev. Discuss., !* https://doi.org/10.5194/gmd-2018-8, 2018. !* !* !* Unless explicitly acquired and licensed from Licensor under another license, !* the contents of this file are subject to the Reciprocal Public License ("RPL") !* Version 1.5, https://opensource.org/licenses/RPL-1.5 or subsequent versions as !* allowed by the RPL, and You may not copy or use this file in either source code !* or executable form, except in compliance with the terms and conditions of the RPL. !* !* All software distributed under the RPL is provided strictly on an "AS IS" basis, !* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, AND LICENSOR HEREBY !* DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF !* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT, OR NON-INFRINGEMENT. !* See the RPL for specific language governing rights and limitations under the RPL. !* !*****************************************************************************! ! !*********************************************************************** !*** !*** UECT !*** Urban Emission Conversion Tool !*** !*********************************************************************** subroutine output_citychem_ase(nhours,nps,ase_snap,xi,yi, & ase_src_param,ase_src_qemhour) !*********************************************************************** !*** Subroutine output_citychem_ase writes output for area sources !*** in CityChem format: !*** one file with emission values for each compound !*** for 3 different CityChem emission categories !*** 1 Residential Heating (=SNAP 2 ) !*** 2 Commercial and Industrial sources (=SNAP 1,3,4,5,9) !*** 3 Solvent Use and Traffic (=SNAP 6,7,10 ) !*** (4 Shipping is not applied in UECT) !*** The routine will stop for area sources with a different SNAP !*** EMEP vertical profiles: !*** 1 0.0 0.00 0.15 0.40 0.30 0.15 0.00 ! SNAP1 !*** 2 1.0 0.00 0.00 0.00 0.00 0.00 0.0 ! SNAP2 !*** 3 0.1 0.10 0.15 0.30 0.30 0.05 0.0 ! SNAP3 !*** 4 0.9 0.10 0.00 0.00 0.00 0.00 0.0 ! SNAP4 !*** 5 0.9 0.10 0.00 0.00 0.00 0.00 0.0 ! SNAP5 !*** 6 1.0 0.00 0.00 0.00 0.00 0.00 0.0 ! SNAP6 !*** 7 1.0 0.00 0.00 0.00 0.00 0.00 0.0 ! SNAP7 !*** 8 1.0 0.00 0.00 0.00 0.00 0.00 0.0 ! SNAP8 !*** 9 0.1 0.15 0.40 0.35 0.00 0.00 0.0 ! SNAP9 !*** 10 1.0 0.00 0.00 0.00 0.00 0.00 0.0 ! SNAP10 !*** 11 1.0 0.00 0.00 0.00 0.00 0.00 0.0 ! SNAP11 !*********************************************************************** ! ! Modification change log ! ----------------------- ! 14.06.2018 M.Karl(HZG) new netcdf output for SNAP8 (ship emission) !*********************************************************************** ! Declarations of variables by using the MODULES feature: use module_uect_io use module_uect_exe use module_uect_time use module_writenc implicit none !*********************************************************************** integer, intent(in) :: nhours integer, intent(in) :: nps integer, dimension(nps),intent(in) :: ase_snap real, dimension(nps,ncomp,nhours),intent(in) :: ase_src_qemhour real, dimension(nps,n_ase_params),intent(in) :: ase_src_param integer, dimension(nps), intent(in) :: xi integer, dimension(nps), intent(in) :: yi ! Local declarations: integer :: i,n,p,h integer :: jx,jy integer :: hourc integer :: narea_dome integer :: narea_solv integer :: narea_othe integer :: narea_ship integer :: yy, mony integer :: daynn, dayne integer :: hournn integer :: yeai integer :: daymm integer, dimension(12), parameter :: monlen = (/ 31, 28, 31, 30, 31, 30, & 31, 31, 30, 31, 30, 31 /) character(len=60) :: startdate_out character(len=60) :: enddate_out character(len=10) :: yyout, mmout character(len=10) :: ddout, deout character(len=48) :: line character(len=43) :: comm1 character (len=256) :: fname_area_loc1 character (len=256) :: fname_area_loc2 character (len=256) :: fname_area_loc3 character (len=256) :: fname_area_loc4 character(len=10) :: txt1 character(len=10) :: txt2 character (len=256) :: epsgn_u ! *** Emission: hourly compound emission amount per category, in g/s real, dimension(:,:,:,:), allocatable :: ase_src_dome real, dimension(:,:,:,:), allocatable :: ase_src_solv real, dimension(:,:,:,:), allocatable :: ase_src_othe real, dimension(:,:,:,:), allocatable :: ase_src_ship real, allocatable :: axm_i(:,:) real, allocatable :: axm_j(:,:) real, allocatable :: z(:) double precision, allocatable :: field2D_1(:,:) double precision, allocatable :: field2D_2(:,:) double precision, allocatable :: field2D_3(:,:) double precision, allocatable :: field2D_4(:,:) !*********************************************************************** ! Content of subroutine: ! *** ALLOCATE if (.not. allocated(ase_src_dome)) allocate( ase_src_dome(n_nx,n_ny,nhours,nccout) ) if (.not. allocated(ase_src_solv)) allocate( ase_src_solv(n_nx,n_ny,nhours,nccout) ) if (.not. allocated(ase_src_othe)) allocate( ase_src_othe(n_nx,n_ny,nhours,nccout) ) if (.not. allocated(ase_src_ship)) allocate( ase_src_ship(n_nx,n_ny,nhours,nccout) ) if (.not. allocated(axm_i) ) allocate( axm_i(n_nx,n_ny) ) if (.not. allocated(axm_j) ) allocate( axm_j(n_nx,n_ny) ) if (.not. allocated(z) ) allocate( z(n_nz) ) if (.not. allocated(field2D_1) ) allocate( field2D_1(n_ny,n_nx) ) if (.not. allocated(field2D_2) ) allocate( field2D_2(n_ny,n_nx) ) if (.not. allocated(field2D_3) ) allocate( field2D_3(n_ny,n_nx) ) if (.not. allocated(field2D_4) ) allocate( field2D_4(n_ny,n_nx) ) ! *** CITYCHEM compound names !nccout: all citychem output species cpnameo( 1) = 'no ' cpnameo( 2) = 'no2 ' cpnameo( 3) = 'so2 ' cpnameo( 4) = 'co ' cpnameo( 5) = 'c2h6 ' cpnameo( 6) = 'hcho ' cpnameo( 7) = 'ch3cho ' cpnameo( 8) = 'c2h4 ' cpnameo( 9) = 'nc4h10 ' cpnameo(10) = 'ch3coc2h5 ' cpnameo(11) = 'c3h6 ' cpnameo(12) = 'oxylen ' cpnameo(13) = 'pm2.5 ' cpnameo(14) = 'pm10 ' cpnameo(15) = 'isoprene ' cpnameo(16) = 'apinene ' cpnameo(17) = 'limonene ' ! *** Open the area source output emission value files: do i=1,nccout fname_area_loc1 = trim(fname_outpath)//'/asrc_domestic_' fname_area_loc2 = trim(fname_outpath)//'/asrc_solvent_' fname_area_loc3 = trim(fname_outpath)//'/asrc_other_' fname_area_loc4 = trim(fname_outpath)//'/asrc_ships_' fname_out_adome_emis(i) = trim(fname_area_loc1)//trim(cpnameo(i))//'_'//trim(startdate)//'_'//trim(enddate)//'.txt' funit_out_adome_emis(i) = nextun() open (funit_out_adome_emis(i), file = fname_out_adome_emis(i), status = 'unknown', form = 'formatted', action = 'write') fname_out_asolv_emis(i) = trim(fname_area_loc2)//trim(cpnameo(i))//'_'//trim(startdate)//'_'//trim(enddate)//'.txt' funit_out_asolv_emis(i) = nextun() open (funit_out_asolv_emis(i), file = fname_out_asolv_emis(i), status = 'unknown', form = 'formatted', action = 'write') fname_out_aothe_emis(i) = trim(fname_area_loc3)//trim(cpnameo(i))//'_'//trim(startdate)//'_'//trim(enddate)//'.txt' funit_out_aothe_emis(i) = nextun() open (funit_out_aothe_emis(i), file = fname_out_aothe_emis(i), status = 'unknown', form = 'formatted', action = 'write') fname_out_aship_emis(i) = trim(fname_area_loc4)//trim(cpnameo(i))//'_'//trim(startdate)//'_'//trim(enddate)//'.txt' funit_out_aship_emis(i) = nextun() open (funit_out_aship_emis(i), file = fname_out_aship_emis(i), status = 'unknown', form = 'formatted', action = 'write') enddo ! *** Write header for area source emission files ! *** Set date yy = year mony = mnth daynn = daym dayne = edat(3) write (yyout,'(I4)') yy write (mmout,'(I2)') mony write (ddout,'(I2)') daynn write (deout,'(I2)') dayne startdate_out = trim(yyout)//' '//trim(mmout)//' '//trim(ddout)//' 0' enddate_out = trim(yyout)//' '//trim(mmout)//' '//trim(deout)//' 23' ! *** Set comment lines line = '* ----------------------------------------------' comm1 = '* Hourly average gridded area emission file' ! *** Write header lines do i=1,nccout write (funit_out_adome_emis(i),'(A38)' ) simid write (funit_out_asolv_emis(i),'(A38)' ) simid write (funit_out_aothe_emis(i),'(A38)' ) simid write (funit_out_aship_emis(i),'(A38)' ) simid write (funit_out_adome_emis(i),'(A48)' ) line write (funit_out_asolv_emis(i),'(A48)' ) line write (funit_out_aothe_emis(i),'(A48)' ) line write (funit_out_aship_emis(i),'(A48)' ) line write (funit_out_adome_emis(i),'(A43)' ) comm1 write (funit_out_asolv_emis(i),'(A43)' ) comm1 write (funit_out_aothe_emis(i),'(A43)' ) comm1 write (funit_out_aship_emis(i),'(A43)' ) comm1 write (funit_out_adome_emis(i),'(A33)' ) '* Compound: '//trim(cpnameo(i))//' ' write (funit_out_asolv_emis(i),'(A33)' ) '* Compound: '//trim(cpnameo(i))//' ' write (funit_out_aothe_emis(i),'(A33)' ) '* Compound: '//trim(cpnameo(i))//' ' write (funit_out_aship_emis(i),'(A33)' ) '* Compound: '//trim(cpnameo(i))//' ' write (funit_out_adome_emis(i),'(A20)' ) '* Units: g/s' write (funit_out_asolv_emis(i),'(A20)' ) '* Units: g/s' write (funit_out_aothe_emis(i),'(A20)' ) '* Units: g/s' write (funit_out_aship_emis(i),'(A20)' ) '* Units: g/s' write (funit_out_adome_emis(i),'(A17,A14)') '* Starting date: ',trim(startdate_out) write (funit_out_asolv_emis(i),'(A17,A14)') '* Starting date: ',trim(startdate_out) write (funit_out_aothe_emis(i),'(A17,A14)') '* Starting date: ',trim(startdate_out) write (funit_out_aship_emis(i),'(A17,A14)') '* Starting date: ',trim(startdate_out) write (funit_out_adome_emis(i),'(A17,A14)') '* Ending date: ',trim(enddate_out) write (funit_out_asolv_emis(i),'(A17,A14)') '* Ending date: ',trim(enddate_out) write (funit_out_aothe_emis(i),'(A17,A14)') '* Ending date: ',trim(enddate_out) write (funit_out_aship_emis(i),'(A17,A14)') '* Ending date: ',trim(enddate_out) write (funit_out_adome_emis(i),'(A48)' ) line write (funit_out_asolv_emis(i),'(A48)' ) line write (funit_out_aothe_emis(i),'(A48)' ) line write (funit_out_aship_emis(i),'(A48)' ) line enddo ! *** Write hourly emission values ! hour counter hourc = 1 ! source counter narea_dome = 0 narea_solv = 0 narea_othe = 0 narea_ship = 0 !Initialize emission output fields ase_src_dome( :,:,:,: ) = 0.0 ase_src_solv( :,:,:,: ) = 0.0 ase_src_othe( :,:,:,: ) = 0.0 ase_src_ship( :,:,:,: ) = 0.0 do h = 1, nhours do n = 1, nps ! print *,'out_ase snap',n,ase_snap(n),ase_src_qemhour(n, 8,h) select case (ase_snap(n)) case(1) ! combustion for energy production ! call stopit('SNAP 1 not allowed for area sources') ! now attributed to 'other' ase_src_othe(xi(n),yi(n),h,1 ) = ase_src_othe(xi(n),yi(n),h,1 ) + ase_src_qemhour(n, 8,h) ! NO ase_src_othe(xi(n),yi(n),h,2 ) = ase_src_othe(xi(n),yi(n),h,2 ) + ase_src_qemhour(n, 9,h) ! NO2 ase_src_othe(xi(n),yi(n),h,3 ) = ase_src_othe(xi(n),yi(n),h,3 ) + ase_src_qemhour(n, 4,h) ! SO2 ase_src_othe(xi(n),yi(n),h,4 ) = ase_src_othe(xi(n),yi(n),h,4 ) + ase_src_qemhour(n, 3,h) ! CO ase_src_othe(xi(n),yi(n),h,5 ) = ase_src_othe(xi(n),yi(n),h,5 ) + ase_src_qemhour(n,12,h) ! c2h6 ase_src_othe(xi(n),yi(n),h,6 ) = ase_src_othe(xi(n),yi(n),h,6 ) + ase_src_qemhour(n,11,h) ! hcho ase_src_othe(xi(n),yi(n),h,7 ) = ase_src_othe(xi(n),yi(n),h,7 ) + ase_src_qemhour(n,13,h) ! ch3cho ase_src_othe(xi(n),yi(n),h,8 ) = ase_src_othe(xi(n),yi(n),h,8 ) + ase_src_qemhour(n,15,h) ! c2h4 ase_src_othe(xi(n),yi(n),h,9 ) = ase_src_othe(xi(n),yi(n),h,9 ) + ase_src_qemhour(n,14,h) ! nc4h10 ase_src_othe(xi(n),yi(n),h,10) = ase_src_othe(xi(n),yi(n),h,10) + ase_src_qemhour(n,18,h) ! ch3coc2h5 ase_src_othe(xi(n),yi(n),h,11) = ase_src_othe(xi(n),yi(n),h,11) + ase_src_qemhour(n,16,h) ! c3h6 ase_src_othe(xi(n),yi(n),h,12) = ase_src_othe(xi(n),yi(n),h,12) + ase_src_qemhour(n,17,h) ! oxylen ase_src_othe(xi(n),yi(n),h,13) = ase_src_othe(xi(n),yi(n),h,13) + ase_src_qemhour(n, 6,h) ! pm25 ase_src_othe(xi(n),yi(n),h,14) = ase_src_othe(xi(n),yi(n),h,14) + ase_src_qemhour(n, 7,h) ! pm10 if (h==1) narea_othe = narea_othe +1 case(2) ! domestic heating ase_src_dome(xi(n),yi(n),h,1 ) = ase_src_dome(xi(n),yi(n),h,1 ) + ase_src_qemhour(n, 8,h) ! NO ase_src_dome(xi(n),yi(n),h,2 ) = ase_src_dome(xi(n),yi(n),h,2 ) + ase_src_qemhour(n, 9,h) ! NO2 ase_src_dome(xi(n),yi(n),h,3 ) = ase_src_dome(xi(n),yi(n),h,3 ) + ase_src_qemhour(n, 4,h) ! SO2 ase_src_dome(xi(n),yi(n),h,4 ) = ase_src_dome(xi(n),yi(n),h,4 ) + ase_src_qemhour(n, 3,h) ! CO ase_src_dome(xi(n),yi(n),h,5 ) = ase_src_dome(xi(n),yi(n),h,5 ) + ase_src_qemhour(n,12,h) ! c2h6 ase_src_dome(xi(n),yi(n),h,6 ) = ase_src_dome(xi(n),yi(n),h,6 ) + ase_src_qemhour(n,11,h) ! hcho ase_src_dome(xi(n),yi(n),h,7 ) = ase_src_dome(xi(n),yi(n),h,7 ) + ase_src_qemhour(n,13,h) ! ch3cho ase_src_dome(xi(n),yi(n),h,8 ) = ase_src_dome(xi(n),yi(n),h,8 ) + ase_src_qemhour(n,15,h) ! c2h4 ase_src_dome(xi(n),yi(n),h,9 ) = ase_src_dome(xi(n),yi(n),h,9 ) + ase_src_qemhour(n,14,h) ! nc4h10 ase_src_dome(xi(n),yi(n),h,10) = ase_src_dome(xi(n),yi(n),h,10) + ase_src_qemhour(n,18,h) ! ch3coc2h5 ase_src_dome(xi(n),yi(n),h,11) = ase_src_dome(xi(n),yi(n),h,11) + ase_src_qemhour(n,16,h) ! c3h6 ase_src_dome(xi(n),yi(n),h,12) = ase_src_dome(xi(n),yi(n),h,12) + ase_src_qemhour(n,17,h) ! oxylen ase_src_dome(xi(n),yi(n),h,13) = ase_src_dome(xi(n),yi(n),h,13) + ase_src_qemhour(n, 6,h) ! pm25 ase_src_dome(xi(n),yi(n),h,14) = ase_src_dome(xi(n),yi(n),h,14) + ase_src_qemhour(n, 7,h) ! pm10 if (h==1) narea_dome = narea_dome +1 case(3) ! Commercial and Industrial sources ase_src_othe(xi(n),yi(n),h,1 ) = ase_src_othe(xi(n),yi(n),h,1 ) + ase_src_qemhour(n, 8,h) ! NO ase_src_othe(xi(n),yi(n),h,2 ) = ase_src_othe(xi(n),yi(n),h,2 ) + ase_src_qemhour(n, 9,h) ! NO2 ase_src_othe(xi(n),yi(n),h,3 ) = ase_src_othe(xi(n),yi(n),h,3 ) + ase_src_qemhour(n, 4,h) ! SO2 ase_src_othe(xi(n),yi(n),h,4 ) = ase_src_othe(xi(n),yi(n),h,4 ) + ase_src_qemhour(n, 3,h) ! CO ase_src_othe(xi(n),yi(n),h,5 ) = ase_src_othe(xi(n),yi(n),h,5 ) + ase_src_qemhour(n,12,h) ! c2h6 ase_src_othe(xi(n),yi(n),h,6 ) = ase_src_othe(xi(n),yi(n),h,6 ) + ase_src_qemhour(n,11,h) ! hcho ase_src_othe(xi(n),yi(n),h,7 ) = ase_src_othe(xi(n),yi(n),h,7 ) + ase_src_qemhour(n,13,h) ! ch3cho ase_src_othe(xi(n),yi(n),h,8 ) = ase_src_othe(xi(n),yi(n),h,8 ) + ase_src_qemhour(n,15,h) ! c2h4 ase_src_othe(xi(n),yi(n),h,9 ) = ase_src_othe(xi(n),yi(n),h,9 ) + ase_src_qemhour(n,14,h) ! nc4h10 ase_src_othe(xi(n),yi(n),h,10) = ase_src_othe(xi(n),yi(n),h,10) + ase_src_qemhour(n,18,h) ! ch3coc2h5 ase_src_othe(xi(n),yi(n),h,11) = ase_src_othe(xi(n),yi(n),h,11) + ase_src_qemhour(n,16,h) ! c3h6 ase_src_othe(xi(n),yi(n),h,12) = ase_src_othe(xi(n),yi(n),h,12) + ase_src_qemhour(n,17,h) ! oxylen ase_src_othe(xi(n),yi(n),h,13) = ase_src_othe(xi(n),yi(n),h,13) + ase_src_qemhour(n, 6,h) ! pm25 ase_src_othe(xi(n),yi(n),h,14) = ase_src_othe(xi(n),yi(n),h,14) + ase_src_qemhour(n, 7,h) ! pm10 if (h==1) narea_othe = narea_othe +1 case(4) ! Industry production ase_src_othe(xi(n),yi(n),h,1 ) = ase_src_othe(xi(n),yi(n),h,1 ) + ase_src_qemhour(n, 8,h) ! NO ase_src_othe(xi(n),yi(n),h,2 ) = ase_src_othe(xi(n),yi(n),h,2 ) + ase_src_qemhour(n, 9,h) ! NO2 ase_src_othe(xi(n),yi(n),h,3 ) = ase_src_othe(xi(n),yi(n),h,3 ) + ase_src_qemhour(n, 4,h) ! SO2 ase_src_othe(xi(n),yi(n),h,4 ) = ase_src_othe(xi(n),yi(n),h,4 ) + ase_src_qemhour(n, 3,h) ! CO ase_src_othe(xi(n),yi(n),h,5 ) = ase_src_othe(xi(n),yi(n),h,5 ) + ase_src_qemhour(n,12,h) ! c2h6 ase_src_othe(xi(n),yi(n),h,6 ) = ase_src_othe(xi(n),yi(n),h,6 ) + ase_src_qemhour(n,11,h) ! hcho ase_src_othe(xi(n),yi(n),h,7 ) = ase_src_othe(xi(n),yi(n),h,7 ) + ase_src_qemhour(n,13,h) ! ch3cho ase_src_othe(xi(n),yi(n),h,8 ) = ase_src_othe(xi(n),yi(n),h,8 ) + ase_src_qemhour(n,15,h) ! c2h4 ase_src_othe(xi(n),yi(n),h,9 ) = ase_src_othe(xi(n),yi(n),h,9 ) + ase_src_qemhour(n,14,h) ! nc4h10 ase_src_othe(xi(n),yi(n),h,10) = ase_src_othe(xi(n),yi(n),h,10) + ase_src_qemhour(n,18,h) ! ch3coc2h5 ase_src_othe(xi(n),yi(n),h,11) = ase_src_othe(xi(n),yi(n),h,11) + ase_src_qemhour(n,16,h) ! c3h6 ase_src_othe(xi(n),yi(n),h,12) = ase_src_othe(xi(n),yi(n),h,12) + ase_src_qemhour(n,17,h) ! oxylen ase_src_othe(xi(n),yi(n),h,13) = ase_src_othe(xi(n),yi(n),h,13) + ase_src_qemhour(n, 6,h) ! pm25 ase_src_othe(xi(n),yi(n),h,14) = ase_src_othe(xi(n),yi(n),h,14) + ase_src_qemhour(n, 7,h) ! pm10 if (h==1) narea_othe = narea_othe +1 !print *,'ase_othe ',h,n,ase_src_qemhour(n, 7,h),ase_src_othe(xi(n),yi(n),h,14),xi(n),yi(n) case(5) ! Distribution of fossil fuels ase_src_othe(xi(n),yi(n),h,1 ) = ase_src_othe(xi(n),yi(n),h,1 ) + ase_src_qemhour(n, 8,h) ! NO ase_src_othe(xi(n),yi(n),h,2 ) = ase_src_othe(xi(n),yi(n),h,2 ) + ase_src_qemhour(n, 9,h) ! NO2 ase_src_othe(xi(n),yi(n),h,3 ) = ase_src_othe(xi(n),yi(n),h,3 ) + ase_src_qemhour(n, 4,h) ! SO2 ase_src_othe(xi(n),yi(n),h,4 ) = ase_src_othe(xi(n),yi(n),h,4 ) + ase_src_qemhour(n, 3,h) ! CO ase_src_othe(xi(n),yi(n),h,5 ) = ase_src_othe(xi(n),yi(n),h,5 ) + ase_src_qemhour(n,12,h) ! c2h6 ase_src_othe(xi(n),yi(n),h,6 ) = ase_src_othe(xi(n),yi(n),h,6 ) + ase_src_qemhour(n,11,h) ! hcho ase_src_othe(xi(n),yi(n),h,7 ) = ase_src_othe(xi(n),yi(n),h,7 ) + ase_src_qemhour(n,13,h) ! ch3cho ase_src_othe(xi(n),yi(n),h,8 ) = ase_src_othe(xi(n),yi(n),h,8 ) + ase_src_qemhour(n,15,h) ! c2h4 ase_src_othe(xi(n),yi(n),h,9 ) = ase_src_othe(xi(n),yi(n),h,9 ) + ase_src_qemhour(n,14,h) ! nc4h10 ase_src_othe(xi(n),yi(n),h,10) = ase_src_othe(xi(n),yi(n),h,10) + ase_src_qemhour(n,18,h) ! ch3coc2h5 ase_src_othe(xi(n),yi(n),h,11) = ase_src_othe(xi(n),yi(n),h,11) + ase_src_qemhour(n,16,h) ! c3h6 ase_src_othe(xi(n),yi(n),h,12) = ase_src_othe(xi(n),yi(n),h,12) + ase_src_qemhour(n,17,h) ! oxylen ase_src_othe(xi(n),yi(n),h,13) = ase_src_othe(xi(n),yi(n),h,13) + ase_src_qemhour(n, 6,h) ! pm25 ase_src_othe(xi(n),yi(n),h,14) = ase_src_othe(xi(n),yi(n),h,14) + ase_src_qemhour(n, 7,h) ! pm10 if (h==1) narea_othe = narea_othe +1 !print *,'5', ase_src_qemhour(n,7,h),ase_src_qemhour(n,11,h),ase_src_qemhour(n,13,h),ase_src_qemhour(n,17,h) case(6) ! Solvent Use ase_src_solv(xi(n),yi(n),h,1 ) = ase_src_solv(xi(n),yi(n),h,1 ) + ase_src_qemhour(n, 8,h) ! NO ase_src_solv(xi(n),yi(n),h,2 ) = ase_src_solv(xi(n),yi(n),h,2 ) + ase_src_qemhour(n, 9,h) ! NO2 ase_src_solv(xi(n),yi(n),h,3 ) = ase_src_solv(xi(n),yi(n),h,3 ) + ase_src_qemhour(n, 4,h) ! SO2 ase_src_solv(xi(n),yi(n),h,4 ) = ase_src_solv(xi(n),yi(n),h,4 ) + ase_src_qemhour(n, 3,h) ! CO ase_src_solv(xi(n),yi(n),h,5 ) = ase_src_solv(xi(n),yi(n),h,5 ) + ase_src_qemhour(n,12,h) ! c2h6 ase_src_solv(xi(n),yi(n),h,6 ) = ase_src_solv(xi(n),yi(n),h,6 ) + ase_src_qemhour(n,11,h) ! hcho ase_src_solv(xi(n),yi(n),h,7 ) = ase_src_solv(xi(n),yi(n),h,7 ) + ase_src_qemhour(n,13,h) ! ch3cho ase_src_solv(xi(n),yi(n),h,8 ) = ase_src_solv(xi(n),yi(n),h,8 ) + ase_src_qemhour(n,15,h) ! c2h4 ase_src_solv(xi(n),yi(n),h,9 ) = ase_src_solv(xi(n),yi(n),h,9 ) + ase_src_qemhour(n,14,h) ! nc4h10 ase_src_solv(xi(n),yi(n),h,10) = ase_src_solv(xi(n),yi(n),h,10) + ase_src_qemhour(n,18,h) ! ch3coc2h5 ase_src_solv(xi(n),yi(n),h,11) = ase_src_solv(xi(n),yi(n),h,11) + ase_src_qemhour(n,16,h) ! c3h6 ase_src_solv(xi(n),yi(n),h,12) = ase_src_solv(xi(n),yi(n),h,12) + ase_src_qemhour(n,17,h) ! oxylen ase_src_solv(xi(n),yi(n),h,13) = ase_src_solv(xi(n),yi(n),h,13) + ase_src_qemhour(n, 6,h) ! pm25 ase_src_solv(xi(n),yi(n),h,14) = ase_src_solv(xi(n),yi(n),h,14) + ase_src_qemhour(n, 7,h) ! pm10 if (h==1) narea_solv = narea_solv +1 case(7) ! Traffic on small roads !call stopit('SNAP 7 not allowed for area sources') ! now attributed to 'solvents' ase_src_solv(xi(n),yi(n),h,1 ) = ase_src_solv(xi(n),yi(n),h,1 ) + ase_src_qemhour(n, 8,h) ! NO ase_src_solv(xi(n),yi(n),h,2 ) = ase_src_solv(xi(n),yi(n),h,2 ) + ase_src_qemhour(n, 9,h) ! NO2 ase_src_solv(xi(n),yi(n),h,3 ) = ase_src_solv(xi(n),yi(n),h,3 ) + ase_src_qemhour(n, 4,h) ! SO2 ase_src_solv(xi(n),yi(n),h,4 ) = ase_src_solv(xi(n),yi(n),h,4 ) + ase_src_qemhour(n, 3,h) ! CO ase_src_solv(xi(n),yi(n),h,5 ) = ase_src_solv(xi(n),yi(n),h,5 ) + ase_src_qemhour(n,12,h) ! c2h6 ase_src_solv(xi(n),yi(n),h,6 ) = ase_src_solv(xi(n),yi(n),h,6 ) + ase_src_qemhour(n,11,h) ! hcho ase_src_solv(xi(n),yi(n),h,7 ) = ase_src_solv(xi(n),yi(n),h,7 ) + ase_src_qemhour(n,13,h) ! ch3cho ase_src_solv(xi(n),yi(n),h,8 ) = ase_src_solv(xi(n),yi(n),h,8 ) + ase_src_qemhour(n,15,h) ! c2h4 ase_src_solv(xi(n),yi(n),h,9 ) = ase_src_solv(xi(n),yi(n),h,9 ) + ase_src_qemhour(n,14,h) ! nc4h10 ase_src_solv(xi(n),yi(n),h,10) = ase_src_solv(xi(n),yi(n),h,10) + ase_src_qemhour(n,18,h) ! ch3coc2h5 ase_src_solv(xi(n),yi(n),h,11) = ase_src_solv(xi(n),yi(n),h,11) + ase_src_qemhour(n,16,h) ! c3h6 ase_src_solv(xi(n),yi(n),h,12) = ase_src_solv(xi(n),yi(n),h,12) + ase_src_qemhour(n,17,h) ! oxylen ase_src_solv(xi(n),yi(n),h,13) = ase_src_solv(xi(n),yi(n),h,13) + ase_src_qemhour(n, 6,h) ! pm25 ase_src_solv(xi(n),yi(n),h,14) = ase_src_solv(xi(n),yi(n),h,14) + ase_src_qemhour(n, 7,h) ! pm10 if (h==1) narea_solv = narea_solv +1 case(8) ! Shipping traffic = ship ase_src_ship(xi(n),yi(n),h,1 ) = ase_src_ship(xi(n),yi(n),h,1 ) + ase_src_qemhour(n, 8,h) ! NO ase_src_ship(xi(n),yi(n),h,2 ) = ase_src_ship(xi(n),yi(n),h,2 ) + ase_src_qemhour(n, 9,h) ! NO2 ase_src_ship(xi(n),yi(n),h,3 ) = ase_src_ship(xi(n),yi(n),h,3 ) + ase_src_qemhour(n, 4,h) ! SO2 ase_src_ship(xi(n),yi(n),h,4 ) = ase_src_ship(xi(n),yi(n),h,4 ) + ase_src_qemhour(n, 3,h) ! CO ase_src_ship(xi(n),yi(n),h,5 ) = ase_src_ship(xi(n),yi(n),h,5 ) + ase_src_qemhour(n,12,h) ! c2h6 ase_src_ship(xi(n),yi(n),h,6 ) = ase_src_ship(xi(n),yi(n),h,6 ) + ase_src_qemhour(n,11,h) ! hcho ase_src_ship(xi(n),yi(n),h,7 ) = ase_src_ship(xi(n),yi(n),h,7 ) + ase_src_qemhour(n,13,h) ! ch3cho ase_src_ship(xi(n),yi(n),h,8 ) = ase_src_ship(xi(n),yi(n),h,8 ) + ase_src_qemhour(n,15,h) ! c2h4 ase_src_ship(xi(n),yi(n),h,9 ) = ase_src_ship(xi(n),yi(n),h,9 ) + ase_src_qemhour(n,14,h) ! nc4h10 ase_src_ship(xi(n),yi(n),h,10) = ase_src_ship(xi(n),yi(n),h,10) + ase_src_qemhour(n,18,h) ! ch3coc2h5 ase_src_ship(xi(n),yi(n),h,11) = ase_src_ship(xi(n),yi(n),h,11) + ase_src_qemhour(n,16,h) ! c3h6 ase_src_ship(xi(n),yi(n),h,12) = ase_src_ship(xi(n),yi(n),h,12) + ase_src_qemhour(n,17,h) ! oxylen ase_src_ship(xi(n),yi(n),h,13) = ase_src_ship(xi(n),yi(n),h,13) + ase_src_qemhour(n, 6,h) ! pm25 ase_src_ship(xi(n),yi(n),h,14) = ase_src_ship(xi(n),yi(n),h,14) + ase_src_qemhour(n, 7,h) ! pm10 if (h==1) narea_ship = narea_ship +1 case(9) ! Waste incineration call stopit('SNAP 9 not allowed for area sources') ase_src_othe(xi(n),yi(n),h,1 ) = ase_src_othe(xi(n),yi(n),h,1 ) + ase_src_qemhour(n, 8,h) ! NO ase_src_othe(xi(n),yi(n),h,2 ) = ase_src_othe(xi(n),yi(n),h,2 ) + ase_src_qemhour(n, 9,h) ! NO2 ase_src_othe(xi(n),yi(n),h,3 ) = ase_src_othe(xi(n),yi(n),h,3 ) + ase_src_qemhour(n, 4,h) ! SO2 ase_src_othe(xi(n),yi(n),h,4 ) = ase_src_othe(xi(n),yi(n),h,4 ) + ase_src_qemhour(n, 3,h) ! CO ase_src_othe(xi(n),yi(n),h,5 ) = ase_src_othe(xi(n),yi(n),h,5 ) + ase_src_qemhour(n,12,h) ! c2h6 ase_src_othe(xi(n),yi(n),h,6 ) = ase_src_othe(xi(n),yi(n),h,6 ) + ase_src_qemhour(n,11,h) ! hcho ase_src_othe(xi(n),yi(n),h,7 ) = ase_src_othe(xi(n),yi(n),h,7 ) + ase_src_qemhour(n,13,h) ! ch3cho ase_src_othe(xi(n),yi(n),h,8 ) = ase_src_othe(xi(n),yi(n),h,8 ) + ase_src_qemhour(n,15,h) ! c2h4 ase_src_othe(xi(n),yi(n),h,9 ) = ase_src_othe(xi(n),yi(n),h,9 ) + ase_src_qemhour(n,14,h) ! nc4h10 ase_src_othe(xi(n),yi(n),h,10) = ase_src_othe(xi(n),yi(n),h,10) + ase_src_qemhour(n,18,h) ! ch3coc2h5 ase_src_othe(xi(n),yi(n),h,11) = ase_src_othe(xi(n),yi(n),h,11) + ase_src_qemhour(n,16,h) ! c3h6 ase_src_othe(xi(n),yi(n),h,12) = ase_src_othe(xi(n),yi(n),h,12) + ase_src_qemhour(n,17,h) ! oxylen ase_src_othe(xi(n),yi(n),h,13) = ase_src_othe(xi(n),yi(n),h,13) + ase_src_qemhour(n, 6,h) ! pm25 ase_src_othe(xi(n),yi(n),h,14) = ase_src_othe(xi(n),yi(n),h,14) + ase_src_qemhour(n, 7,h) ! pm10 if (h==1) narea_othe = narea_othe +1 case(10) ! Agriculture => solvent/traffic ase_src_solv(xi(n),yi(n),h,1 ) = ase_src_solv(xi(n),yi(n),h,1 ) + ase_src_qemhour(n, 8,h) ! NO ase_src_solv(xi(n),yi(n),h,2 ) = ase_src_solv(xi(n),yi(n),h,2 ) + ase_src_qemhour(n, 9,h) ! NO2 ase_src_solv(xi(n),yi(n),h,3 ) = ase_src_solv(xi(n),yi(n),h,3 ) + ase_src_qemhour(n, 4,h) ! SO2 ase_src_solv(xi(n),yi(n),h,4 ) = ase_src_solv(xi(n),yi(n),h,4 ) + ase_src_qemhour(n, 3,h) ! CO ase_src_solv(xi(n),yi(n),h,5 ) = ase_src_solv(xi(n),yi(n),h,5 ) + ase_src_qemhour(n,12,h) ! c2h6 ase_src_solv(xi(n),yi(n),h,6 ) = ase_src_solv(xi(n),yi(n),h,6 ) + ase_src_qemhour(n,11,h) ! hcho ase_src_solv(xi(n),yi(n),h,7 ) = ase_src_solv(xi(n),yi(n),h,7 ) + ase_src_qemhour(n,13,h) ! ch3cho ase_src_solv(xi(n),yi(n),h,8 ) = ase_src_solv(xi(n),yi(n),h,8 ) + ase_src_qemhour(n,15,h) ! c2h4 ase_src_solv(xi(n),yi(n),h,9 ) = ase_src_solv(xi(n),yi(n),h,9 ) + ase_src_qemhour(n,14,h) ! nc4h10 ase_src_solv(xi(n),yi(n),h,10) = ase_src_solv(xi(n),yi(n),h,10) + ase_src_qemhour(n,18,h) ! ch3coc2h5 ase_src_solv(xi(n),yi(n),h,11) = ase_src_solv(xi(n),yi(n),h,11) + ase_src_qemhour(n,16,h) ! c3h6 ase_src_solv(xi(n),yi(n),h,12) = ase_src_solv(xi(n),yi(n),h,12) + ase_src_qemhour(n,17,h) ! oxylen ase_src_solv(xi(n),yi(n),h,13) = ase_src_solv(xi(n),yi(n),h,13) + ase_src_qemhour(n, 6,h) ! pm25 ase_src_solv(xi(n),yi(n),h,14) = ase_src_solv(xi(n),yi(n),h,14) + ase_src_qemhour(n, 7,h) ! pm10 if (h==1) narea_solv = narea_solv +1 case(11) ! Natural = other ase_src_othe(xi(n),yi(n),h,1 ) = ase_src_othe(xi(n),yi(n),h,1 ) + ase_src_qemhour(n, 8,h) ! NO ase_src_othe(xi(n),yi(n),h,2 ) = ase_src_othe(xi(n),yi(n),h,2 ) + ase_src_qemhour(n, 9,h) ! NO2 ase_src_othe(xi(n),yi(n),h,3 ) = ase_src_othe(xi(n),yi(n),h,3 ) + ase_src_qemhour(n, 4,h) ! SO2 ase_src_othe(xi(n),yi(n),h,4 ) = ase_src_othe(xi(n),yi(n),h,4 ) + ase_src_qemhour(n, 3,h) ! CO ase_src_othe(xi(n),yi(n),h,5 ) = ase_src_othe(xi(n),yi(n),h,5 ) + ase_src_qemhour(n,12,h) ! c2h6 ase_src_othe(xi(n),yi(n),h,6 ) = ase_src_othe(xi(n),yi(n),h,6 ) + ase_src_qemhour(n,11,h) ! hcho ase_src_othe(xi(n),yi(n),h,7 ) = ase_src_othe(xi(n),yi(n),h,7 ) + ase_src_qemhour(n,13,h) ! ch3cho ase_src_othe(xi(n),yi(n),h,8 ) = ase_src_othe(xi(n),yi(n),h,8 ) + ase_src_qemhour(n,15,h) ! c2h4 ase_src_othe(xi(n),yi(n),h,9 ) = ase_src_othe(xi(n),yi(n),h,9 ) + ase_src_qemhour(n,14,h) ! nc4h10 ase_src_othe(xi(n),yi(n),h,10) = ase_src_othe(xi(n),yi(n),h,10) + ase_src_qemhour(n,18,h) ! ch3coc2h5 ase_src_othe(xi(n),yi(n),h,11) = ase_src_othe(xi(n),yi(n),h,11) + ase_src_qemhour(n,16,h) ! c3h6 ase_src_othe(xi(n),yi(n),h,12) = ase_src_othe(xi(n),yi(n),h,12) + ase_src_qemhour(n,17,h) ! oxylen ase_src_othe(xi(n),yi(n),h,13) = ase_src_othe(xi(n),yi(n),h,13) + ase_src_qemhour(n, 6,h) ! pm25 ase_src_othe(xi(n),yi(n),h,14) = ase_src_othe(xi(n),yi(n),h,14) + ase_src_qemhour(n, 7,h) ! pm10 ! BVOC emission (EF*FD) ase_src_othe(xi(n),yi(n),h,15) = ase_src_othe(xi(n),yi(n),h,15) + ase_src_qemhour(n,19,h) ! isoprene ase_src_othe(xi(n),yi(n),h,16) = ase_src_othe(xi(n),yi(n),h,16) + ase_src_qemhour(n,20,h) ! apinene ase_src_othe(xi(n),yi(n),h,17) = ase_src_othe(xi(n),yi(n),h,17) + ase_src_qemhour(n,21,h) ! limonene if (h==1) narea_othe = narea_othe +1 case DEFAULT call stopit('Area source has no valid SNAP code') end select enddo ! n sources ! *** Write Area Source datalines !stop write(txt1,'(A6,I4)') ' H:',h write(txt2,'(A10)') ' no_index' do i = 1, nccout if(narea_dome>0) call write_2dfield(n_nx,n_ny,txt1,txt2,funit_out_adome_emis(i),EP_fm, ase_src_dome( :,:,h,i )) if(narea_solv>0) call write_2dfield(n_nx,n_ny,txt1,txt2,funit_out_asolv_emis(i),EP_fm, ase_src_solv( :,:,h,i )) if(narea_othe>0) call write_2dfield(n_nx,n_ny,txt1,txt2,funit_out_aothe_emis(i),EP_fm, ase_src_othe( :,:,h,i )) if(narea_ship>0) call write_2dfield(n_nx,n_ny,txt1,txt2,funit_out_aship_emis(i),EP_fm, ase_src_ship( :,:,h,i )) enddo ! *** Change date by one hour ! print *,hourc,daynn,mony hourc = hourc + 1 if ( hourc == 24 ) then write(6, '(A27,I4)') 'Finished writing for day: ',daynn hourc = 0 daynn = daynn + 1 endif if ( daynn > monlen(mony) ) then daynn = 1 if (mony==12) then mony=1 else mony=mony+1 endif endif enddo ! h hours ! *** Write number of category sources to LOG if (fe_log) then write(funit_log,'(1X,A56,I7)') & 'domestic heating area sources: ', narea_dome write(funit_log,'(1X,A56,I7)') & 'solvents area sources: ', narea_solv write(funit_log,'(1X,A56,I7)') & 'industrial/commercial/agric. area sources: ',narea_othe write(funit_log,'(1X,A56,I7)') & 'shipping traffic area sources: ',narea_ship endif ! *** Optional: Create netCDF output of the 2D area emission fields for checking ! *** Set netCDF output files for area emission 2D-fields ! *** The nccout chemical species will be written to the file if (NC_out==1) then write(6, '(A29)') 'Write ASE to netCDF files ...' write(6, '(A29)') 'This can take several minutes' fname_nc_adome_emis = trim(fname_outpath)//'/asrc_domestic_'//trim(startdate)//'_'//trim(enddate)//'.nc' fname_nc_asolv_emis = trim(fname_outpath)//'/asrc_solvent_'//trim(startdate)//'_'//trim(enddate)//'.nc' fname_nc_aothe_emis = trim(fname_outpath)//'/asrc_other_'//trim(startdate)//'_'//trim(enddate)//'.nc' fname_nc_aship_emis = trim(fname_outpath)//'/asrc_ships_'//trim(startdate)//'_'//trim(enddate)//'.nc' ! *** 14.06.2017 Define EPSGN code epsgn_u = trim('326'//utmzone(1:2)) ! *** Create a grid with the x- and y- coordinates of the grid centre-points do jx = 1, n_nx do jy = 1, n_ny axm_i(jy,jx) = sitex0 + (jx-1)*dxout axm_j(jy,jx) = sitey0 + (jy-1)*dxout enddo enddo z(1) = 10 call CreateNCfileGrid(fname_nc_adome_emis,n_nx,n_ny,1,axm_i,axm_j,z,dxout,utmzone,epsgn_u,sitex0,sitey0) call CreateNCfileGrid(fname_nc_asolv_emis,n_nx,n_ny,1,axm_i,axm_j,z,dxout,utmzone,epsgn_u,sitex0,sitey0) call CreateNCfileGrid(fname_nc_aothe_emis,n_nx,n_ny,1,axm_i,axm_j,z,dxout,utmzone,epsgn_u,sitex0,sitey0) call CreateNCfileGrid(fname_nc_aship_emis,n_nx,n_ny,1,axm_i,axm_j,z,dxout,utmzone,epsgn_u,sitex0,sitey0) ! *** Write the netCDF output file of all species, ! *** Area source emissions hourly 2D field [instantaneous, QA()] unitname = "g/s" validity = 'averaged' dopacking = .false. dofloat = .true. domirror = .true. ! *** houd - hour of day (1-24) h=1 is first hour ! *** dayw - day of week (1-7 ) ! *** mony - month of year (1-12) ! hour counter hourc = 1 daymm = daym mony = mnth yeai = year ! for now: write only 3 days do h = 1, 24*3 !nhours ! one time step Nhh_in = 1 ! current simulation date mdate(1,Nhh_in) = yeai mdate(2,Nhh_in) = mony mdate(3,Nhh_in) = daymm mdate(4,Nhh_in) = hourc do i = 1, nccout !07.08.2019: initialize the output fields field2D_1(:,:) = 0.0 field2D_2(:,:) = 0.0 field2D_3(:,:) = 0.0 field2D_4(:,:) = 0.0 namefield = cpnameo(i) if (trim(cpnameo(i)).eq."pm2.5") then namefield = "pm25 " endif do jx = 1,n_nx do jy = 1,n_ny field2D_1(jy,jx) = dble( ase_src_dome(jx,jy,h,i) ) field2D_2(jy,jx) = dble( ase_src_solv(jx,jy,h,i) ) field2D_3(jy,jx) = dble( ase_src_othe(jx,jy,h,i) ) field2D_4(jy,jx) = dble( ase_src_ship(jx,jy,h,i) ) enddo enddo call writeconcfield(fname_nc_adome_emis,namefield,unitname, & field2D_1(1:n_ny,1:n_nx), n_ny, n_nx, 1, & Nhh_in, mdate, validity, dopacking, dofloat, domirror) call writeconcfield(fname_nc_asolv_emis,namefield,unitname, & field2D_2(1:n_ny,1:n_nx), n_ny, n_nx, 1, & Nhh_in, mdate, validity, dopacking, dofloat, domirror) call writeconcfield(fname_nc_aothe_emis,namefield,unitname, & field2D_3(1:n_ny,1:n_nx), n_ny, n_nx, 1, & Nhh_in, mdate, validity, dopacking, dofloat, domirror) !07.08.2019: field2D_4 has the ship area emissions call writeconcfield(fname_nc_aship_emis,namefield,unitname, & field2D_4(1:n_ny,1:n_nx), n_ny, n_nx, 1, & Nhh_in, mdate, validity, dopacking, dofloat, domirror) enddo ! i compounds ! *** Change date by one hour hourc = hourc + 1 if (hourc == 25 ) then write(6, '(A36,I4)') 'Finished writing nc files for day: ',daymm hourc = 1 daymm = daymm + 1 ! *** Check if new month? if ( daymm > NDAY(mony) ) then daymm = 1 mony = mony + 1 endif if (mony == 13) then mony = 1 if (hourc==1) yeai = yeai +1 endif endif enddo ! h hours endif ! *** End Writing netCDF files ! *** Close files, free memory do i = 1, nccout close (funit_out_adome_emis(i) ) close (funit_out_asolv_emis(i) ) close (funit_out_aothe_emis(i) ) close (funit_out_aship_emis(i) ) enddo ! Deallocate if (allocated(axm_i)) deallocate(axm_i) if (allocated(axm_j)) deallocate(axm_j) if (allocated(z)) deallocate(z) if (allocated(ase_src_dome) ) deallocate(ase_src_dome ) if (allocated(ase_src_solv) ) deallocate(ase_src_solv ) if (allocated(ase_src_othe) ) deallocate(ase_src_othe ) if (allocated(ase_src_ship) ) deallocate(ase_src_ship ) if (allocated(field2D_1) ) deallocate(field2D_1 ) if (allocated(field2D_2) ) deallocate(field2D_2 ) if (allocated(field2D_3) ) deallocate(field2D_3 ) if (allocated(field2D_4) ) deallocate(field2D_4 ) return 2000 format(I6 ,1X, 8F11.1, I6) end subroutine output_citychem_ase
MODULE dist2_I INTERFACE !...Generated by Pacific-Sierra Research 77to90 4.4G 09:34:29 03/16/06 REAL(KIND(0.0D0)) FUNCTION dist2 (A, B) USE vast_kind_param,ONLY: DOUBLE REAL(DOUBLE), DIMENSION(3), INTENT(IN) :: A REAL(DOUBLE), DIMENSION(3), INTENT(IN) :: B END FUNCTION END INTERFACE END MODULE
Meanwhile , Angela Martin ( Angela Kinsey ) is evicted from her studio apartment after her cats were taken away by Animal Control . She considers living in a tent in the woods , prompting Oscar Martinez ( Oscar Nunez ) to offer her to stay with him until she gets back on her feet . She finally accepts with gratitude . As they set off to take Angela 's things to Oscar 's place , Oscar mentions her marriage to Robert Lipton and she breaks down into tears , saying " I love him . " However , she denies she still has feelings for Robert and claims she was talking about Dwight .
“Beth McCullough serves as our volunteer marketing manager for SolarTech, a Photovoltaic (PV) industry consortium focused on creating a Solar Center of Excellence in the Silicon Valley. In 2009 she helped us update the graphics on our website, and created an internal communications guide for outbound communication consistency across the consortium. This year Beth is responsible for writing content, implementing our email campaigns and distributing press announcements; these are all critical components in managing relationships and communicating with our partner companies and sponsors. “While I was CEO of the Chase Group, I hired Beth to run the numerous day-to-day functions of event and tradeshow planning. I knew she could hit the ground running because of her industry background; I got to see her firsthand while she was a client at SEMI. Very detailed-oriented and conscientious, Beth helped eBay – one of our biggest clients – save over $100,000 on a custom tradeshow kiosk. This project required custom fabrication as well as overcoming unique shipping challenges using industry knowledge and connections. During the pre-planning for our Power Seller Awards Dinner for eBay and Paypal, Beth used her diplomatic skills to successfully negotiate with eight of the top restaurants in San Francisco. Great at follow through, she arranged multiple menus ensuring high quality while keeping costs within budget and delivering everything on time. “I’ve known Beth for 10 years when we did work at IDEMA and for eBay at The Chase Group. She’s amazing with details, deadlines and event management. She makes sure that nothing falls through the cracks and there are no surprises onsite. Most recently, we managed a chapter event for the International Association of Exhibitions and Events. Taking initiative for all the social media communication for our event, Beth wrote all the messaging including invitations, curriculum, and background information to draw the 20+ attendees. “I’ve hired Beth many times over the years at SEMI because of her skill and knowledge. Our division focuses on environmental health, safety and sustainability issues, supporting 2000 corporate clients worldwide. Responsible communicating with over 5,000 professionals in our membership, Beth also managed our contact database and event coordination for our tradeshows. She’s done everything related to logistics, ensuring we have everything needed for specific seminars or programs, to pre- and post-planning. “I’ve known Beth for years and she helped IDEMA with the DISKCON USA Tradeshow in 2009. Her background with tradeshow and event management is impressive. Always reliable, Beth knows exactly what needs to be done. When I was unexpectedly ill the day before our event, Beth stepped in. Because she’s cool under pressure and keeps a strategic head on her shoulders, I didn’t worry about anything. I knew I could rely on her to take care of everything.
theory week03B_demo_automation imports Main begin definition xor :: "bool \<Rightarrow> bool \<Rightarrow> bool" where "xor A B \<equiv> (A \<and> \<not>B) \<or> (\<not>A \<and> B)" thm xor_def lemma xorI [intro!]: "\<lbrakk> \<lbrakk>A; B\<rbrakk> \<Longrightarrow> False; \<not>B \<Longrightarrow> A \<rbrakk> \<Longrightarrow> xor A B" apply (unfold xor_def) apply blast done lemma xorE [elim!]: "\<lbrakk> xor A B; \<lbrakk>A; \<not>B\<rbrakk> \<Longrightarrow> R; \<lbrakk>\<not>A; B\<rbrakk> \<Longrightarrow> R \<rbrakk> \<Longrightarrow> R" apply (unfold xor_def) apply blast done lemma "xor A A = False" by blast (* declare xorE [elim!] *) lemma "xor A B = xor B A" by blast lemma "\<not>\<not>x \<longrightarrow> x" apply (rule impI) apply (rule ccontr) apply (erule notE) apply assumption end
// SPDX-License-Identifier: Apache-2.0 /** * Copyright (C) 2020 Jijoong Moon <[email protected]> * * @file blas_interface.h * @date 28 Aug 2020 * @see https://github.com/nnstreamer/nntrainer * @author Jijoong Moon <[email protected]> * @bug No known bugs except for NYI items * @brief This is dummy header for blas support * */ #ifndef __BLAS_INTERFACE_H_ #define __BLAS_INTERFACE_H_ #ifdef __cplusplus #ifdef USE_BLAS extern "C" { #include <cblas.h> } #else enum CBLAS_ORDER { CblasRowMajor = 101, CblasColMajor = 102 }; enum CBLAS_TRANSPOSE { CblasNoTrans = 111, CblasTrans = 112, CblasConjTrans = 113 }; #endif #ifdef USE_CUBLAS #include <helper_cuda.h> #include <helper_functions.h> #endif namespace nntrainer { void sscal(const int N, const float alpha, float *X, const int incX); float snrm2(const int N, const float *X, const int incX); void scopy(const unsigned int N, const float *X, const int incX, float *Y, const int intY); float sdot(const unsigned int N, const float *X, const unsigned int incX, const float *Y, const unsigned int incY); void saxpy(const unsigned int N, const float alpha, const float *X, const int incX, float *Y, const int incY); void sgemm(CBLAS_ORDER order, CBLAS_TRANSPOSE TransA, CBLAS_TRANSPOSE TransB, const unsigned int M, const unsigned int N, const unsigned int K, const float alpha, const float *A, const unsigned int lda, const float *B, const unsigned int ldb, const float beta, float *C, const unsigned int ldc); void sgemv(CBLAS_ORDER order, CBLAS_TRANSPOSE TransA, const unsigned int M, const unsigned int N, const float alpha, const float *A, const unsigned int lda, const float *X, const int incX, const float beta, float *Y, const int incY); unsigned int isamax(const unsigned int N, const float *X, const int incX); } /* namespace nntrainer */ #endif /* __cplusplus */ #endif /* __BLAS_INTERFACE_H__ */
[STATEMENT] lemma (in subsemicategory) subdg_op_smc_smcf_inc[smc_op_simps]: "op_smcf (smcf_inc \<BB> \<CC>) = smcf_inc (op_smc \<BB>) (op_smc \<CC>)" [PROOF STATE] proof (prove) goal (1 subgoal): 1. op_smcf (dghm_inc \<BB> \<CC>) = dghm_inc (op_smc \<BB>) (op_smc \<CC>) [PROOF STEP] by ( rule smcf_eqI[of \<alpha> \<open>op_smc \<BB>\<close> \<open>op_smc \<CC>\<close>], unfold smc_op_simps dghm_inc_components ) ( auto simp: is_ft_semifunctorD subsemicategory_smcf_inc_op_smc_is_semifunctor inc.is_semifunctor_op )
import set_theory.surreal open pgame universe u local infix ` ≈ ` := pgame.equiv #check numeric -- def numeric : pgame → Prop -- | ⟨l, r, L, R⟩ := -- (∀ i j, L i < R j) ∧ (∀ i, numeric (L i)) ∧ (∀ i, numeric (R i)) lemma numeric_aux (x : pgame) : (∀ i, x.move_left i < x ∧ numeric (x.move_left i)) ∧ (∀ i, x < x.move_right i ∧ numeric (x.move_right i)) → x.numeric := sorry #check @le_def_lt -- ⊢ ∀ {x y : pgame}, -- x ≤ y ↔ -- ∀ (i : x.left_moves), x.move_left i < y ∧ -- ∀ (j : y.right_moves), x < y.move_right j theorem zero_le' {x : pgame} : 0 ≤ x ↔ (∀ j : x.right_moves, 0 < x.move_right j) := begin rw le_def_lt, split, rintros ⟨hi,hj⟩ j, exact hj j, rintros hj, split, rintros ⟨⟩, exact hj, end -- theorem le_def_lt {x y : pgame} : x ≤ y ↔ -- (∀ i : x.left_moves, x.move_left i < y) ∧ -- (∀ j : y.right_moves, x < y.move_right j) := -- by { cases x, cases y, refl } theorem le_zero' {x : pgame} : x ≤ 0 ↔ (∀ i : x.left_moves, x.move_left i < 0) := begin rw le_def_lt, split, rintros ⟨hi,hj⟩ i, exact hi i, rintros hj, split, exact hj, rintros ⟨⟩, end theorem zero_lt' {x : pgame} : 0 < x ↔ (∃ i : x.left_moves, 0 ≤ x.move_left i) := by {rw lt_def_le, dsimp, simp[forall_pempty] } -- (xL i < (mk xl xr xL xR)) ∧ ((mk xl xr xL xR) < xR j) ∧ numeric (xL i) ∧ numeric (xR j) → (mk xl xr xL xR).numeric := sorry example ( a b : ℤ ) : (0 < a) → (0 < b) → (0 < a * b) := begin exact mul_pos, end theorem foo (x : pgame) (ox : numeric x) : ¬ (x ≈ 0) → (0 < x) ∨ (x < 0) := sorry theorem numeric_mul_pos : Π {x y z w : pgame} (ox : numeric x) (oy : numeric y) (oz : numeric z) (ow : numeric w), (0 < x → 0 < y → 0 < x * y) ∧ (w ≈ 0 → w * z ≈ 0) | (mk xl xr xL xR) (mk yl yr yL yR) (mk zl zr zL zR) (mk wl wr wL wR) ox oy oz ow := begin set x := mk xl xr xL xR with hx, set y := mk yl yr yL yR with hy, set w := mk wl wr wL wR with hw, split, intros pos_x pos_y, rw zero_lt', cases zero_lt'.1 pos_x with i hi, cases zero_lt'.1 pos_y with j hj, dsimp at *, use sum.inl (i,j), dsimp, rw ←hx at *, rw ←hy at *, by_cases h : xL i ≈ 0, sorry, cases foo (xL i) (ox.2.1 i) h, sorry, sorry, intro hw, split, rw le_zero', rintros (⟨i,j⟩|⟨i,j⟩), dsimp, rw ←hx at *, sorry, dsimp, sorry, rw zero_le', rintros (⟨i,j⟩|⟨i,j⟩), dsimp, sorry, dsimp, sorry, end theorem numeric_mul_pos' : Π {x y : pgame} (ox : numeric x) (oy : numeric y) (oxy : numeric (x * y)) (neg_x : x < 0) (neg_y : y < 0), 0 < x * y := sorry theorem numeric_mul_neg : Π {x y : pgame} (ox : numeric x) (oy : numeric y) (oxy : numeric (x * y)) (pos_x : 0 < x) (neg_y : y < 0), x * y < 0 := sorry theorem numeric_sub : Π {x y : pgame} (ox : numeric x) (oy : numeric y), numeric (x - y) | ⟨xl, xr, xL, xR⟩ ⟨yl, yr, yL, yR⟩ ox oy := sorry theorem numeric_mul : Π {x y z : pgame} (ox : x.numeric) (oy : y.numeric), ((x * y).numeric ) ∧ ((x ≈ y) → ⟦x * z⟧ = ⟦y * z⟧) ∧ (Π {a b A B : pgame} (oA : numeric A) (oB : numeric B) (oa : numeric a) (ob : numeric b), a < A → b < B → a * B + b * A < a * b + A * B ) | (mk xl xr xL xR) (mk yl yr yL yR) := begin set x := mk xl xr xL xR with hx, set y := mk yl yr yL yR with hy, split, { intros ox oy, fsplit, rintro (⟨i, j⟩ | ⟨i, j⟩) (⟨k, l⟩ | ⟨j_fst, j_snd⟩), { change xL i * y + x * yL j - xL i * yL j < xL k * y + x * yR l - xL k * yR l, }, sorry, sorry, sorry, sorry, }, end
(* * Copyright 2014, NICTA * * This software may be distributed and modified according to the terms of * the BSD 2-Clause license. Note that NO WARRANTY is provided. * See "LICENSE_BSD2.txt" for details. * * @TAG(NICTA_BSD) *) theory Sep_Cancel_Set imports Separation_Algebra Sep_Tactic_Helpers begin ML {* structure SepCancel_Rules = Named_Thms ( val name = @{binding "sep_cancel"} val description = "sep_cancel rules" ) *} setup SepCancel_Rules.setup lemma refl_imp: "P \<Longrightarrow> P" by assumption declare refl_imp[sep_cancel] declare sep_conj_empty[sep_cancel] lemmas sep_conj_empty' = sep_conj_empty[simplified sep_conj_commute[symmetric]] declare sep_conj_empty'[sep_cancel] end
[GOAL] R : Type u S✝ : Type v A : Type w B : Type u₁ C : Type u_1 D : Type u_2 E : Type u_3 inst✝⁶ : CommSemiring C inst✝⁵ : CommSemiring D inst✝⁴ : CommSemiring E inst✝³ : Algebra C D inst✝² : Algebra C E inst✝¹ : Algebra D E inst✝ : IsScalarTower C D E S : Set E ⊢ Subalgebra.restrictScalars C (adjoin D S) = Subalgebra.restrictScalars C (adjoin { x // x ∈ Subalgebra.map (IsScalarTower.toAlgHom C D E) ⊤ } S) [PROOFSTEP] suffices Set.range (algebraMap D E) = Set.range (algebraMap ((⊤ : Subalgebra C D).map (IsScalarTower.toAlgHom C D E)) E) by ext x change x ∈ Subsemiring.closure (_ ∪ S) ↔ x ∈ Subsemiring.closure (_ ∪ S) rw [this] [GOAL] R : Type u S✝ : Type v A : Type w B : Type u₁ C : Type u_1 D : Type u_2 E : Type u_3 inst✝⁶ : CommSemiring C inst✝⁵ : CommSemiring D inst✝⁴ : CommSemiring E inst✝³ : Algebra C D inst✝² : Algebra C E inst✝¹ : Algebra D E inst✝ : IsScalarTower C D E S : Set E this : Set.range ↑(algebraMap D E) = Set.range ↑(algebraMap { x // x ∈ Subalgebra.map (IsScalarTower.toAlgHom C D E) ⊤ } E) ⊢ Subalgebra.restrictScalars C (adjoin D S) = Subalgebra.restrictScalars C (adjoin { x // x ∈ Subalgebra.map (IsScalarTower.toAlgHom C D E) ⊤ } S) [PROOFSTEP] ext x [GOAL] case h R : Type u S✝ : Type v A : Type w B : Type u₁ C : Type u_1 D : Type u_2 E : Type u_3 inst✝⁶ : CommSemiring C inst✝⁵ : CommSemiring D inst✝⁴ : CommSemiring E inst✝³ : Algebra C D inst✝² : Algebra C E inst✝¹ : Algebra D E inst✝ : IsScalarTower C D E S : Set E this : Set.range ↑(algebraMap D E) = Set.range ↑(algebraMap { x // x ∈ Subalgebra.map (IsScalarTower.toAlgHom C D E) ⊤ } E) x : E ⊢ x ∈ Subalgebra.restrictScalars C (adjoin D S) ↔ x ∈ Subalgebra.restrictScalars C (adjoin { x // x ∈ Subalgebra.map (IsScalarTower.toAlgHom C D E) ⊤ } S) [PROOFSTEP] change x ∈ Subsemiring.closure (_ ∪ S) ↔ x ∈ Subsemiring.closure (_ ∪ S) [GOAL] case h R : Type u S✝ : Type v A : Type w B : Type u₁ C : Type u_1 D : Type u_2 E : Type u_3 inst✝⁶ : CommSemiring C inst✝⁵ : CommSemiring D inst✝⁴ : CommSemiring E inst✝³ : Algebra C D inst✝² : Algebra C E inst✝¹ : Algebra D E inst✝ : IsScalarTower C D E S : Set E this : Set.range ↑(algebraMap D E) = Set.range ↑(algebraMap { x // x ∈ Subalgebra.map (IsScalarTower.toAlgHom C D E) ⊤ } E) x : E ⊢ x ∈ Subsemiring.closure (Set.range ↑(algebraMap D E) ∪ S) ↔ x ∈ Subsemiring.closure (Set.range ↑(algebraMap { x // x ∈ Subalgebra.map (IsScalarTower.toAlgHom C D E) ⊤ } E) ∪ S) [PROOFSTEP] rw [this] [GOAL] R : Type u S✝ : Type v A : Type w B : Type u₁ C : Type u_1 D : Type u_2 E : Type u_3 inst✝⁶ : CommSemiring C inst✝⁵ : CommSemiring D inst✝⁴ : CommSemiring E inst✝³ : Algebra C D inst✝² : Algebra C E inst✝¹ : Algebra D E inst✝ : IsScalarTower C D E S : Set E ⊢ Set.range ↑(algebraMap D E) = Set.range ↑(algebraMap { x // x ∈ Subalgebra.map (IsScalarTower.toAlgHom C D E) ⊤ } E) [PROOFSTEP] ext x [GOAL] case h R : Type u S✝ : Type v A : Type w B : Type u₁ C : Type u_1 D : Type u_2 E : Type u_3 inst✝⁶ : CommSemiring C inst✝⁵ : CommSemiring D inst✝⁴ : CommSemiring E inst✝³ : Algebra C D inst✝² : Algebra C E inst✝¹ : Algebra D E inst✝ : IsScalarTower C D E S : Set E x : E ⊢ x ∈ Set.range ↑(algebraMap D E) ↔ x ∈ Set.range ↑(algebraMap { x // x ∈ Subalgebra.map (IsScalarTower.toAlgHom C D E) ⊤ } E) [PROOFSTEP] constructor [GOAL] case h.mp R : Type u S✝ : Type v A : Type w B : Type u₁ C : Type u_1 D : Type u_2 E : Type u_3 inst✝⁶ : CommSemiring C inst✝⁵ : CommSemiring D inst✝⁴ : CommSemiring E inst✝³ : Algebra C D inst✝² : Algebra C E inst✝¹ : Algebra D E inst✝ : IsScalarTower C D E S : Set E x : E ⊢ x ∈ Set.range ↑(algebraMap D E) → x ∈ Set.range ↑(algebraMap { x // x ∈ Subalgebra.map (IsScalarTower.toAlgHom C D E) ⊤ } E) [PROOFSTEP] rintro ⟨y, hy⟩ [GOAL] case h.mp.intro R : Type u S✝ : Type v A : Type w B : Type u₁ C : Type u_1 D : Type u_2 E : Type u_3 inst✝⁶ : CommSemiring C inst✝⁵ : CommSemiring D inst✝⁴ : CommSemiring E inst✝³ : Algebra C D inst✝² : Algebra C E inst✝¹ : Algebra D E inst✝ : IsScalarTower C D E S : Set E x : E y : D hy : ↑(algebraMap D E) y = x ⊢ x ∈ Set.range ↑(algebraMap { x // x ∈ Subalgebra.map (IsScalarTower.toAlgHom C D E) ⊤ } E) [PROOFSTEP] exact ⟨⟨algebraMap D E y, ⟨y, ⟨Algebra.mem_top, rfl⟩⟩⟩, hy⟩ [GOAL] case h.mpr R : Type u S✝ : Type v A : Type w B : Type u₁ C : Type u_1 D : Type u_2 E : Type u_3 inst✝⁶ : CommSemiring C inst✝⁵ : CommSemiring D inst✝⁴ : CommSemiring E inst✝³ : Algebra C D inst✝² : Algebra C E inst✝¹ : Algebra D E inst✝ : IsScalarTower C D E S : Set E x : E ⊢ x ∈ Set.range ↑(algebraMap { x // x ∈ Subalgebra.map (IsScalarTower.toAlgHom C D E) ⊤ } E) → x ∈ Set.range ↑(algebraMap D E) [PROOFSTEP] rintro ⟨⟨y, ⟨z, ⟨h0, h1⟩⟩⟩, h2⟩ [GOAL] case h.mpr.intro.mk.intro.intro R : Type u S✝ : Type v A : Type w B : Type u₁ C : Type u_1 D : Type u_2 E : Type u_3 inst✝⁶ : CommSemiring C inst✝⁵ : CommSemiring D inst✝⁴ : CommSemiring E inst✝³ : Algebra C D inst✝² : Algebra C E inst✝¹ : Algebra D E inst✝ : IsScalarTower C D E S : Set E x y : E z : D h0 : z ∈ ↑⊤.toSubsemiring h1 : ↑↑(IsScalarTower.toAlgHom C D E) z = y h2 : ↑(algebraMap { x // x ∈ Subalgebra.map (IsScalarTower.toAlgHom C D E) ⊤ } E) { val := y, property := (_ : ∃ a, a ∈ ↑⊤.toSubsemiring ∧ ↑↑(IsScalarTower.toAlgHom C D E) a = y) } = x ⊢ x ∈ Set.range ↑(algebraMap D E) [PROOFSTEP] exact ⟨z, Eq.trans h1 h2⟩ [GOAL] R : Type u S✝ : Type v A : Type w B : Type u₁ C : Type u_1 D : Type u_2 E : Type u_3 F : Type u_4 inst✝¹⁰ : CommSemiring C inst✝⁹ : CommSemiring D inst✝⁸ : CommSemiring E inst✝⁷ : CommSemiring F inst✝⁶ : Algebra C D inst✝⁵ : Algebra C E inst✝⁴ : Algebra C F inst✝³ : Algebra D F inst✝² : Algebra E F inst✝¹ : IsScalarTower C D F inst✝ : IsScalarTower C E F S : Set D T : Set E hS : adjoin C S = ⊤ hT : adjoin C T = ⊤ ⊢ Subalgebra.restrictScalars C (adjoin E (↑(algebraMap D F) '' S)) = Subalgebra.restrictScalars C (adjoin D (↑(algebraMap E F) '' T)) [PROOFSTEP] rw [adjoin_restrictScalars C E, adjoin_restrictScalars C D, ← hS, ← hT, ← Algebra.adjoin_image, ← Algebra.adjoin_image, ← AlgHom.coe_toRingHom, ← AlgHom.coe_toRingHom, IsScalarTower.coe_toAlgHom, IsScalarTower.coe_toAlgHom, ← adjoin_union_eq_adjoin_adjoin, ← adjoin_union_eq_adjoin_adjoin, Set.union_comm] [GOAL] R✝ : Type u S✝ : Type v A✝ : Type w B : Type u₁ R : Type u_1 S : Type u_2 A : Type u_3 inst✝⁶ : CommSemiring R inst✝⁵ : CommSemiring S inst✝⁴ : CommSemiring A inst✝³ : Algebra R S inst✝² : Algebra S A inst✝¹ : Algebra R A inst✝ : IsScalarTower R S A hRS : Subalgebra.FG ⊤ hSA : Subalgebra.FG ⊤ s : Finset S hs : adjoin R ↑s = ⊤ t : Finset A ht : adjoin S ↑t = ⊤ ⊢ adjoin R ↑(Finset.image (↑(algebraMap S A)) s ∪ t) = ⊤ [PROOFSTEP] rw [Finset.coe_union, Finset.coe_image, Algebra.adjoin_union_eq_adjoin_adjoin, Algebra.adjoin_algebraMap, hs, Algebra.map_top, IsScalarTower.adjoin_range_toAlgHom, ht, Subalgebra.restrictScalars_top] [GOAL] R : Type u S : Type v A : Type w B : Type u₁ C : Type u_1 inst✝⁶ : CommSemiring A inst✝⁵ : CommSemiring B inst✝⁴ : Semiring C inst✝³ : Algebra A B inst✝² : Algebra B C inst✝¹ : Algebra A C inst✝ : IsScalarTower A B C hAC : Subalgebra.FG ⊤ hBC : FG ⊤ ⊢ ∃ B₀, Subalgebra.FG B₀ ∧ FG ⊤ [PROOFSTEP] cases' hAC with x hx [GOAL] case intro R : Type u S : Type v A : Type w B : Type u₁ C : Type u_1 inst✝⁶ : CommSemiring A inst✝⁵ : CommSemiring B inst✝⁴ : Semiring C inst✝³ : Algebra A B inst✝² : Algebra B C inst✝¹ : Algebra A C inst✝ : IsScalarTower A B C hBC : FG ⊤ x : Finset C hx : Algebra.adjoin A ↑x = ⊤ ⊢ ∃ B₀, Subalgebra.FG B₀ ∧ FG ⊤ [PROOFSTEP] cases' hBC with y hy [GOAL] case intro.intro R : Type u S : Type v A : Type w B : Type u₁ C : Type u_1 inst✝⁶ : CommSemiring A inst✝⁵ : CommSemiring B inst✝⁴ : Semiring C inst✝³ : Algebra A B inst✝² : Algebra B C inst✝¹ : Algebra A C inst✝ : IsScalarTower A B C x : Finset C hx : Algebra.adjoin A ↑x = ⊤ y : Finset C hy : span B ↑y = ⊤ ⊢ ∃ B₀, Subalgebra.FG B₀ ∧ FG ⊤ [PROOFSTEP] have := hy [GOAL] case intro.intro R : Type u S : Type v A : Type w B : Type u₁ C : Type u_1 inst✝⁶ : CommSemiring A inst✝⁵ : CommSemiring B inst✝⁴ : Semiring C inst✝³ : Algebra A B inst✝² : Algebra B C inst✝¹ : Algebra A C inst✝ : IsScalarTower A B C x : Finset C hx : Algebra.adjoin A ↑x = ⊤ y : Finset C hy this : span B ↑y = ⊤ ⊢ ∃ B₀, Subalgebra.FG B₀ ∧ FG ⊤ [PROOFSTEP] simp_rw [eq_top_iff', mem_span_finset] at this [GOAL] case intro.intro R : Type u S : Type v A : Type w B : Type u₁ C : Type u_1 inst✝⁶ : CommSemiring A inst✝⁵ : CommSemiring B inst✝⁴ : Semiring C inst✝³ : Algebra A B inst✝² : Algebra B C inst✝¹ : Algebra A C inst✝ : IsScalarTower A B C x : Finset C hx : Algebra.adjoin A ↑x = ⊤ y : Finset C hy : span B ↑y = ⊤ this : ∀ (x : C), ∃ f, (Finset.sum y fun i => f i • i) = x ⊢ ∃ B₀, Subalgebra.FG B₀ ∧ FG ⊤ [PROOFSTEP] choose f hf using this [GOAL] case intro.intro R : Type u S : Type v A : Type w B : Type u₁ C : Type u_1 inst✝⁶ : CommSemiring A inst✝⁵ : CommSemiring B inst✝⁴ : Semiring C inst✝³ : Algebra A B inst✝² : Algebra B C inst✝¹ : Algebra A C inst✝ : IsScalarTower A B C x : Finset C hx : Algebra.adjoin A ↑x = ⊤ y : Finset C hy : span B ↑y = ⊤ f : C → C → B hf : ∀ (x : C), (Finset.sum y fun i => f x i • i) = x ⊢ ∃ B₀, Subalgebra.FG B₀ ∧ FG ⊤ [PROOFSTEP] let s : Finset B := Finset.image₂ f (x ∪ y * y) y [GOAL] case intro.intro R : Type u S : Type v A : Type w B : Type u₁ C : Type u_1 inst✝⁶ : CommSemiring A inst✝⁵ : CommSemiring B inst✝⁴ : Semiring C inst✝³ : Algebra A B inst✝² : Algebra B C inst✝¹ : Algebra A C inst✝ : IsScalarTower A B C x : Finset C hx : Algebra.adjoin A ↑x = ⊤ y : Finset C hy : span B ↑y = ⊤ f : C → C → B hf : ∀ (x : C), (Finset.sum y fun i => f x i • i) = x s : Finset B := image₂ f (x ∪ y * y) y ⊢ ∃ B₀, Subalgebra.FG B₀ ∧ FG ⊤ [PROOFSTEP] have hxy : ∀ xi ∈ x, xi ∈ span (Algebra.adjoin A (↑s : Set B)) (↑(insert 1 y : Finset C) : Set C) := fun xi hxi => hf xi ▸ sum_mem fun yj hyj => smul_mem (span (Algebra.adjoin A (↑s : Set B)) (↑(insert 1 y : Finset C) : Set C)) ⟨f xi yj, Algebra.subset_adjoin <| mem_image₂_of_mem (mem_union_left _ hxi) hyj⟩ (subset_span <| mem_insert_of_mem hyj) [GOAL] case intro.intro R : Type u S : Type v A : Type w B : Type u₁ C : Type u_1 inst✝⁶ : CommSemiring A inst✝⁵ : CommSemiring B inst✝⁴ : Semiring C inst✝³ : Algebra A B inst✝² : Algebra B C inst✝¹ : Algebra A C inst✝ : IsScalarTower A B C x : Finset C hx : Algebra.adjoin A ↑x = ⊤ y : Finset C hy : span B ↑y = ⊤ f : C → C → B hf : ∀ (x : C), (Finset.sum y fun i => f x i • i) = x s : Finset B := image₂ f (x ∪ y * y) y hxy : ∀ (xi : C), xi ∈ x → xi ∈ span { x // x ∈ Algebra.adjoin A ↑s } ↑(insert 1 y) ⊢ ∃ B₀, Subalgebra.FG B₀ ∧ FG ⊤ [PROOFSTEP] have hyy : span (Algebra.adjoin A (↑s : Set B)) (↑(insert 1 y : Finset C) : Set C) * span (Algebra.adjoin A (↑s : Set B)) (↑(insert 1 y : Finset C) : Set C) ≤ span (Algebra.adjoin A (↑s : Set B)) (↑(insert 1 y : Finset C) : Set C) := by rw [span_mul_span, span_le, coe_insert] rintro _ ⟨yi, yj, rfl | hyi, rfl | hyj, rfl⟩ <;> dsimp · rw [mul_one] exact subset_span (Set.mem_insert _ _) · rw [one_mul] exact subset_span (Set.mem_insert_of_mem _ hyj) · rw [mul_one] exact subset_span (Set.mem_insert_of_mem _ hyi) · rw [← hf (yi * yj)] exact SetLike.mem_coe.2 (sum_mem fun yk hyk => smul_mem (span (Algebra.adjoin A (↑s : Set B)) (insert 1 ↑y : Set C)) ⟨f (yi * yj) yk, Algebra.subset_adjoin <| mem_image₂_of_mem (mem_union_right _ <| mul_mem_mul hyi hyj) hyk⟩ (subset_span <| Set.mem_insert_of_mem _ hyk : yk ∈ _)) [GOAL] R : Type u S : Type v A : Type w B : Type u₁ C : Type u_1 inst✝⁶ : CommSemiring A inst✝⁵ : CommSemiring B inst✝⁴ : Semiring C inst✝³ : Algebra A B inst✝² : Algebra B C inst✝¹ : Algebra A C inst✝ : IsScalarTower A B C x : Finset C hx : Algebra.adjoin A ↑x = ⊤ y : Finset C hy : span B ↑y = ⊤ f : C → C → B hf : ∀ (x : C), (Finset.sum y fun i => f x i • i) = x s : Finset B := image₂ f (x ∪ y * y) y hxy : ∀ (xi : C), xi ∈ x → xi ∈ span { x // x ∈ Algebra.adjoin A ↑s } ↑(insert 1 y) ⊢ span { x // x ∈ Algebra.adjoin A ↑s } ↑(insert 1 y) * span { x // x ∈ Algebra.adjoin A ↑s } ↑(insert 1 y) ≤ span { x // x ∈ Algebra.adjoin A ↑s } ↑(insert 1 y) [PROOFSTEP] rw [span_mul_span, span_le, coe_insert] [GOAL] R : Type u S : Type v A : Type w B : Type u₁ C : Type u_1 inst✝⁶ : CommSemiring A inst✝⁵ : CommSemiring B inst✝⁴ : Semiring C inst✝³ : Algebra A B inst✝² : Algebra B C inst✝¹ : Algebra A C inst✝ : IsScalarTower A B C x : Finset C hx : Algebra.adjoin A ↑x = ⊤ y : Finset C hy : span B ↑y = ⊤ f : C → C → B hf : ∀ (x : C), (Finset.sum y fun i => f x i • i) = x s : Finset B := image₂ f (x ∪ y * y) y hxy : ∀ (xi : C), xi ∈ x → xi ∈ span { x // x ∈ Algebra.adjoin A ↑s } ↑(insert 1 y) ⊢ insert 1 ↑y * insert 1 ↑y ⊆ ↑(span { x // x ∈ Algebra.adjoin A ↑s } (insert 1 ↑y)) [PROOFSTEP] rintro _ ⟨yi, yj, rfl | hyi, rfl | hyj, rfl⟩ [GOAL] case intro.intro.intro.inl.intro.inl R : Type u S : Type v A : Type w B : Type u₁ C : Type u_1 inst✝⁶ : CommSemiring A inst✝⁵ : CommSemiring B inst✝⁴ : Semiring C inst✝³ : Algebra A B inst✝² : Algebra B C inst✝¹ : Algebra A C inst✝ : IsScalarTower A B C x : Finset C hx : Algebra.adjoin A ↑x = ⊤ y : Finset C hy : span B ↑y = ⊤ f : C → C → B hf : ∀ (x : C), (Finset.sum y fun i => f x i • i) = x s : Finset B := image₂ f (x ∪ y * y) y hxy : ∀ (xi : C), xi ∈ x → xi ∈ span { x // x ∈ Algebra.adjoin A ↑s } ↑(insert 1 y) ⊢ (fun x x_1 => x * x_1) 1 1 ∈ ↑(span { x // x ∈ Algebra.adjoin A ↑s } (insert 1 ↑y)) [PROOFSTEP] dsimp [GOAL] case intro.intro.intro.inl.intro.inr R : Type u S : Type v A : Type w B : Type u₁ C : Type u_1 inst✝⁶ : CommSemiring A inst✝⁵ : CommSemiring B inst✝⁴ : Semiring C inst✝³ : Algebra A B inst✝² : Algebra B C inst✝¹ : Algebra A C inst✝ : IsScalarTower A B C x : Finset C hx : Algebra.adjoin A ↑x = ⊤ y : Finset C hy : span B ↑y = ⊤ f : C → C → B hf : ∀ (x : C), (Finset.sum y fun i => f x i • i) = x s : Finset B := image₂ f (x ∪ y * y) y hxy : ∀ (xi : C), xi ∈ x → xi ∈ span { x // x ∈ Algebra.adjoin A ↑s } ↑(insert 1 y) yj : C hyj : yj ∈ ↑y ⊢ (fun x x_1 => x * x_1) 1 yj ∈ ↑(span { x // x ∈ Algebra.adjoin A ↑s } (insert 1 ↑y)) [PROOFSTEP] dsimp [GOAL] case intro.intro.intro.inr.intro.inl R : Type u S : Type v A : Type w B : Type u₁ C : Type u_1 inst✝⁶ : CommSemiring A inst✝⁵ : CommSemiring B inst✝⁴ : Semiring C inst✝³ : Algebra A B inst✝² : Algebra B C inst✝¹ : Algebra A C inst✝ : IsScalarTower A B C x : Finset C hx : Algebra.adjoin A ↑x = ⊤ y : Finset C hy : span B ↑y = ⊤ f : C → C → B hf : ∀ (x : C), (Finset.sum y fun i => f x i • i) = x s : Finset B := image₂ f (x ∪ y * y) y hxy : ∀ (xi : C), xi ∈ x → xi ∈ span { x // x ∈ Algebra.adjoin A ↑s } ↑(insert 1 y) yi : C hyi : yi ∈ ↑y ⊢ (fun x x_1 => x * x_1) yi 1 ∈ ↑(span { x // x ∈ Algebra.adjoin A ↑s } (insert 1 ↑y)) [PROOFSTEP] dsimp [GOAL] case intro.intro.intro.inr.intro.inr R : Type u S : Type v A : Type w B : Type u₁ C : Type u_1 inst✝⁶ : CommSemiring A inst✝⁵ : CommSemiring B inst✝⁴ : Semiring C inst✝³ : Algebra A B inst✝² : Algebra B C inst✝¹ : Algebra A C inst✝ : IsScalarTower A B C x : Finset C hx : Algebra.adjoin A ↑x = ⊤ y : Finset C hy : span B ↑y = ⊤ f : C → C → B hf : ∀ (x : C), (Finset.sum y fun i => f x i • i) = x s : Finset B := image₂ f (x ∪ y * y) y hxy : ∀ (xi : C), xi ∈ x → xi ∈ span { x // x ∈ Algebra.adjoin A ↑s } ↑(insert 1 y) yi yj : C hyi : yi ∈ ↑y hyj : yj ∈ ↑y ⊢ (fun x x_1 => x * x_1) yi yj ∈ ↑(span { x // x ∈ Algebra.adjoin A ↑s } (insert 1 ↑y)) [PROOFSTEP] dsimp [GOAL] case intro.intro.intro.inl.intro.inl R : Type u S : Type v A : Type w B : Type u₁ C : Type u_1 inst✝⁶ : CommSemiring A inst✝⁵ : CommSemiring B inst✝⁴ : Semiring C inst✝³ : Algebra A B inst✝² : Algebra B C inst✝¹ : Algebra A C inst✝ : IsScalarTower A B C x : Finset C hx : Algebra.adjoin A ↑x = ⊤ y : Finset C hy : span B ↑y = ⊤ f : C → C → B hf : ∀ (x : C), (Finset.sum y fun i => f x i • i) = x s : Finset B := image₂ f (x ∪ y * y) y hxy : ∀ (xi : C), xi ∈ x → xi ∈ span { x // x ∈ Algebra.adjoin A ↑s } ↑(insert 1 y) ⊢ 1 * 1 ∈ ↑(span { x_1 // x_1 ∈ Algebra.adjoin A ↑(image₂ f (x ∪ y * y) y) } (insert 1 ↑y)) [PROOFSTEP] rw [mul_one] [GOAL] case intro.intro.intro.inl.intro.inl R : Type u S : Type v A : Type w B : Type u₁ C : Type u_1 inst✝⁶ : CommSemiring A inst✝⁵ : CommSemiring B inst✝⁴ : Semiring C inst✝³ : Algebra A B inst✝² : Algebra B C inst✝¹ : Algebra A C inst✝ : IsScalarTower A B C x : Finset C hx : Algebra.adjoin A ↑x = ⊤ y : Finset C hy : span B ↑y = ⊤ f : C → C → B hf : ∀ (x : C), (Finset.sum y fun i => f x i • i) = x s : Finset B := image₂ f (x ∪ y * y) y hxy : ∀ (xi : C), xi ∈ x → xi ∈ span { x // x ∈ Algebra.adjoin A ↑s } ↑(insert 1 y) ⊢ 1 ∈ ↑(span { x_1 // x_1 ∈ Algebra.adjoin A ↑(image₂ f (x ∪ y * y) y) } (insert 1 ↑y)) [PROOFSTEP] exact subset_span (Set.mem_insert _ _) [GOAL] case intro.intro.intro.inl.intro.inr R : Type u S : Type v A : Type w B : Type u₁ C : Type u_1 inst✝⁶ : CommSemiring A inst✝⁵ : CommSemiring B inst✝⁴ : Semiring C inst✝³ : Algebra A B inst✝² : Algebra B C inst✝¹ : Algebra A C inst✝ : IsScalarTower A B C x : Finset C hx : Algebra.adjoin A ↑x = ⊤ y : Finset C hy : span B ↑y = ⊤ f : C → C → B hf : ∀ (x : C), (Finset.sum y fun i => f x i • i) = x s : Finset B := image₂ f (x ∪ y * y) y hxy : ∀ (xi : C), xi ∈ x → xi ∈ span { x // x ∈ Algebra.adjoin A ↑s } ↑(insert 1 y) yj : C hyj : yj ∈ ↑y ⊢ 1 * yj ∈ ↑(span { x_1 // x_1 ∈ Algebra.adjoin A ↑(image₂ f (x ∪ y * y) y) } (insert 1 ↑y)) [PROOFSTEP] rw [one_mul] [GOAL] case intro.intro.intro.inl.intro.inr R : Type u S : Type v A : Type w B : Type u₁ C : Type u_1 inst✝⁶ : CommSemiring A inst✝⁵ : CommSemiring B inst✝⁴ : Semiring C inst✝³ : Algebra A B inst✝² : Algebra B C inst✝¹ : Algebra A C inst✝ : IsScalarTower A B C x : Finset C hx : Algebra.adjoin A ↑x = ⊤ y : Finset C hy : span B ↑y = ⊤ f : C → C → B hf : ∀ (x : C), (Finset.sum y fun i => f x i • i) = x s : Finset B := image₂ f (x ∪ y * y) y hxy : ∀ (xi : C), xi ∈ x → xi ∈ span { x // x ∈ Algebra.adjoin A ↑s } ↑(insert 1 y) yj : C hyj : yj ∈ ↑y ⊢ yj ∈ ↑(span { x_1 // x_1 ∈ Algebra.adjoin A ↑(image₂ f (x ∪ y * y) y) } (insert 1 ↑y)) [PROOFSTEP] exact subset_span (Set.mem_insert_of_mem _ hyj) [GOAL] case intro.intro.intro.inr.intro.inl R : Type u S : Type v A : Type w B : Type u₁ C : Type u_1 inst✝⁶ : CommSemiring A inst✝⁵ : CommSemiring B inst✝⁴ : Semiring C inst✝³ : Algebra A B inst✝² : Algebra B C inst✝¹ : Algebra A C inst✝ : IsScalarTower A B C x : Finset C hx : Algebra.adjoin A ↑x = ⊤ y : Finset C hy : span B ↑y = ⊤ f : C → C → B hf : ∀ (x : C), (Finset.sum y fun i => f x i • i) = x s : Finset B := image₂ f (x ∪ y * y) y hxy : ∀ (xi : C), xi ∈ x → xi ∈ span { x // x ∈ Algebra.adjoin A ↑s } ↑(insert 1 y) yi : C hyi : yi ∈ ↑y ⊢ yi * 1 ∈ ↑(span { x_1 // x_1 ∈ Algebra.adjoin A ↑(image₂ f (x ∪ y * y) y) } (insert 1 ↑y)) [PROOFSTEP] rw [mul_one] [GOAL] case intro.intro.intro.inr.intro.inl R : Type u S : Type v A : Type w B : Type u₁ C : Type u_1 inst✝⁶ : CommSemiring A inst✝⁵ : CommSemiring B inst✝⁴ : Semiring C inst✝³ : Algebra A B inst✝² : Algebra B C inst✝¹ : Algebra A C inst✝ : IsScalarTower A B C x : Finset C hx : Algebra.adjoin A ↑x = ⊤ y : Finset C hy : span B ↑y = ⊤ f : C → C → B hf : ∀ (x : C), (Finset.sum y fun i => f x i • i) = x s : Finset B := image₂ f (x ∪ y * y) y hxy : ∀ (xi : C), xi ∈ x → xi ∈ span { x // x ∈ Algebra.adjoin A ↑s } ↑(insert 1 y) yi : C hyi : yi ∈ ↑y ⊢ yi ∈ ↑(span { x_1 // x_1 ∈ Algebra.adjoin A ↑(image₂ f (x ∪ y * y) y) } (insert 1 ↑y)) [PROOFSTEP] exact subset_span (Set.mem_insert_of_mem _ hyi) [GOAL] case intro.intro.intro.inr.intro.inr R : Type u S : Type v A : Type w B : Type u₁ C : Type u_1 inst✝⁶ : CommSemiring A inst✝⁵ : CommSemiring B inst✝⁴ : Semiring C inst✝³ : Algebra A B inst✝² : Algebra B C inst✝¹ : Algebra A C inst✝ : IsScalarTower A B C x : Finset C hx : Algebra.adjoin A ↑x = ⊤ y : Finset C hy : span B ↑y = ⊤ f : C → C → B hf : ∀ (x : C), (Finset.sum y fun i => f x i • i) = x s : Finset B := image₂ f (x ∪ y * y) y hxy : ∀ (xi : C), xi ∈ x → xi ∈ span { x // x ∈ Algebra.adjoin A ↑s } ↑(insert 1 y) yi yj : C hyi : yi ∈ ↑y hyj : yj ∈ ↑y ⊢ yi * yj ∈ ↑(span { x_1 // x_1 ∈ Algebra.adjoin A ↑(image₂ f (x ∪ y * y) y) } (insert 1 ↑y)) [PROOFSTEP] rw [← hf (yi * yj)] [GOAL] case intro.intro.intro.inr.intro.inr R : Type u S : Type v A : Type w B : Type u₁ C : Type u_1 inst✝⁶ : CommSemiring A inst✝⁵ : CommSemiring B inst✝⁴ : Semiring C inst✝³ : Algebra A B inst✝² : Algebra B C inst✝¹ : Algebra A C inst✝ : IsScalarTower A B C x : Finset C hx : Algebra.adjoin A ↑x = ⊤ y : Finset C hy : span B ↑y = ⊤ f : C → C → B hf : ∀ (x : C), (Finset.sum y fun i => f x i • i) = x s : Finset B := image₂ f (x ∪ y * y) y hxy : ∀ (xi : C), xi ∈ x → xi ∈ span { x // x ∈ Algebra.adjoin A ↑s } ↑(insert 1 y) yi yj : C hyi : yi ∈ ↑y hyj : yj ∈ ↑y ⊢ (Finset.sum y fun i => f (yi * yj) i • i) ∈ ↑(span { x_1 // x_1 ∈ Algebra.adjoin A ↑(image₂ f (x ∪ y * y) y) } (insert 1 ↑y)) [PROOFSTEP] exact SetLike.mem_coe.2 (sum_mem fun yk hyk => smul_mem (span (Algebra.adjoin A (↑s : Set B)) (insert 1 ↑y : Set C)) ⟨f (yi * yj) yk, Algebra.subset_adjoin <| mem_image₂_of_mem (mem_union_right _ <| mul_mem_mul hyi hyj) hyk⟩ (subset_span <| Set.mem_insert_of_mem _ hyk : yk ∈ _)) [GOAL] case intro.intro R : Type u S : Type v A : Type w B : Type u₁ C : Type u_1 inst✝⁶ : CommSemiring A inst✝⁵ : CommSemiring B inst✝⁴ : Semiring C inst✝³ : Algebra A B inst✝² : Algebra B C inst✝¹ : Algebra A C inst✝ : IsScalarTower A B C x : Finset C hx : Algebra.adjoin A ↑x = ⊤ y : Finset C hy : span B ↑y = ⊤ f : C → C → B hf : ∀ (x : C), (Finset.sum y fun i => f x i • i) = x s : Finset B := image₂ f (x ∪ y * y) y hxy : ∀ (xi : C), xi ∈ x → xi ∈ span { x // x ∈ Algebra.adjoin A ↑s } ↑(insert 1 y) hyy : span { x // x ∈ Algebra.adjoin A ↑s } ↑(insert 1 y) * span { x // x ∈ Algebra.adjoin A ↑s } ↑(insert 1 y) ≤ span { x // x ∈ Algebra.adjoin A ↑s } ↑(insert 1 y) ⊢ ∃ B₀, Subalgebra.FG B₀ ∧ FG ⊤ [PROOFSTEP] refine' ⟨Algebra.adjoin A (↑s : Set B), Subalgebra.fg_adjoin_finset _, insert 1 y, _⟩ [GOAL] case intro.intro R : Type u S : Type v A : Type w B : Type u₁ C : Type u_1 inst✝⁶ : CommSemiring A inst✝⁵ : CommSemiring B inst✝⁴ : Semiring C inst✝³ : Algebra A B inst✝² : Algebra B C inst✝¹ : Algebra A C inst✝ : IsScalarTower A B C x : Finset C hx : Algebra.adjoin A ↑x = ⊤ y : Finset C hy : span B ↑y = ⊤ f : C → C → B hf : ∀ (x : C), (Finset.sum y fun i => f x i • i) = x s : Finset B := image₂ f (x ∪ y * y) y hxy : ∀ (xi : C), xi ∈ x → xi ∈ span { x // x ∈ Algebra.adjoin A ↑s } ↑(insert 1 y) hyy : span { x // x ∈ Algebra.adjoin A ↑s } ↑(insert 1 y) * span { x // x ∈ Algebra.adjoin A ↑s } ↑(insert 1 y) ≤ span { x // x ∈ Algebra.adjoin A ↑s } ↑(insert 1 y) ⊢ span { x // x ∈ Algebra.adjoin A ↑s } ↑(insert 1 y) = ⊤ [PROOFSTEP] refine' restrictScalars_injective A (Algebra.adjoin A s) C _ [GOAL] case intro.intro R : Type u S : Type v A : Type w B : Type u₁ C : Type u_1 inst✝⁶ : CommSemiring A inst✝⁵ : CommSemiring B inst✝⁴ : Semiring C inst✝³ : Algebra A B inst✝² : Algebra B C inst✝¹ : Algebra A C inst✝ : IsScalarTower A B C x : Finset C hx : Algebra.adjoin A ↑x = ⊤ y : Finset C hy : span B ↑y = ⊤ f : C → C → B hf : ∀ (x : C), (Finset.sum y fun i => f x i • i) = x s : Finset B := image₂ f (x ∪ y * y) y hxy : ∀ (xi : C), xi ∈ x → xi ∈ span { x // x ∈ Algebra.adjoin A ↑s } ↑(insert 1 y) hyy : span { x // x ∈ Algebra.adjoin A ↑s } ↑(insert 1 y) * span { x // x ∈ Algebra.adjoin A ↑s } ↑(insert 1 y) ≤ span { x // x ∈ Algebra.adjoin A ↑s } ↑(insert 1 y) ⊢ restrictScalars A (span { x // x ∈ Algebra.adjoin A ↑s } ↑(insert 1 y)) = restrictScalars A ⊤ [PROOFSTEP] rw [restrictScalars_top, eq_top_iff, ← Algebra.top_toSubmodule, ← hx, Algebra.adjoin_eq_span, span_le] [GOAL] case intro.intro R : Type u S : Type v A : Type w B : Type u₁ C : Type u_1 inst✝⁶ : CommSemiring A inst✝⁵ : CommSemiring B inst✝⁴ : Semiring C inst✝³ : Algebra A B inst✝² : Algebra B C inst✝¹ : Algebra A C inst✝ : IsScalarTower A B C x : Finset C hx : Algebra.adjoin A ↑x = ⊤ y : Finset C hy : span B ↑y = ⊤ f : C → C → B hf : ∀ (x : C), (Finset.sum y fun i => f x i • i) = x s : Finset B := image₂ f (x ∪ y * y) y hxy : ∀ (xi : C), xi ∈ x → xi ∈ span { x // x ∈ Algebra.adjoin A ↑s } ↑(insert 1 y) hyy : span { x // x ∈ Algebra.adjoin A ↑s } ↑(insert 1 y) * span { x // x ∈ Algebra.adjoin A ↑s } ↑(insert 1 y) ≤ span { x // x ∈ Algebra.adjoin A ↑s } ↑(insert 1 y) ⊢ ↑(Submonoid.closure ↑x) ⊆ ↑(restrictScalars A (span { x // x ∈ Algebra.adjoin A ↑s } ↑(insert 1 y))) [PROOFSTEP] refine' fun r hr => Submonoid.closure_induction hr (fun c hc => hxy c hc) (subset_span <| mem_insert_self _ _) fun p q hp hq => hyy <| Submodule.mul_mem_mul hp hq
module Extra.OpenSSL.FFI public export libcrypto : String -> String libcrypto func = "C:" <+> func <+> ",libcrypto"
If the constant coefficient of a polynomial $p$ is nonzero, then the polynomial obtained by reflecting $p$ about the $y$-axis is $p$ itself.
=begin 本文 =end
module SimpleNet where import System.Random import Numeric.LinearAlgebra import NeuralNetwork newtype SimpleNet = SimpleNet { unSimpleNet :: Matrix R } deriving (Eq, Show) makeRandomNet :: Int -> Int -> IO SimpleNet makeRandomNet rows cols = SimpleNet <$> rand rows cols -- | -- >>> net = SimpleNet $ (2 >< 3) [0.47355232, 0.99773930, 0.84668094, 0.85557411, 0.03563661, 0.69422093] -- >>> x = vector [0.6, 0.9] -- >>> predict net x -- [1.054148091,0.630716529,1.132807401] predict :: SimpleNet -> Vector R -> Vector R predict (SimpleNet w) x = x <# w -- | -- >>> net = SimpleNet $ (2 >< 3) [0.47355232, 0.99773930, 0.84668094, 0.85557411, 0.03563661, 0.69422093] -- >>> x = vector [0.6, 0.9] -- >>> t = vector [0, 0, 1] -- >>> loss net x t -- 9.746346258628767 loss :: SimpleNet -> Vector R -> Vector R -> Double loss net@(SimpleNet w) x t = crossEntropyError y t where z = predict net x y = softmax z
= = Third stage = =
Formal statement is: lemma homotopic_with_canon_on_empty [simp]: "homotopic_with_canon (\<lambda>x. True) {} t f g" Informal statement is: The identity map on the empty set is homotopic to any other map.
The set of points in $\mathbb{R}^n$ that are orthogonal to a given basis vector $k$ is the span of the remaining basis vectors.
(* Title: Strong-Security Authors: Sylvia Grewe, Alexander Lux, Heiko Mantel, Jens Sauer *) theory Type_System_example imports Type_System Expr Domain_example begin \<comment> \<open>When interpreting, we have to instantiate the type for domains.\<close> \<comment> \<open>As an example, we take a type containing 'low' and 'high' as domains.\<close> consts DA :: "('id,Dom) DomainAssignment" consts BMap :: "'val \<Rightarrow> bool" abbreviation d_indistinguishable' :: "('id,'val) Expr \<Rightarrow> Dom \<Rightarrow> ('id,'val) Expr \<Rightarrow> bool" ( "(_ \<equiv>\<^bsub>_\<^esub> _)" ) where "e1 \<equiv>\<^bsub>d\<^esub> e2 \<equiv> Strongly_Secure_Programs.d_indistinguishable ExprEval DA d e1 e2" abbreviation relatedbyUSdB' :: "(('id,'val) Expr, 'id) MWLfCom list \<Rightarrow> Dom \<Rightarrow> (('id,'val) Expr, 'id) MWLfCom list \<Rightarrow> bool" (infixr "\<approx>\<^bsub>_\<^esub>" 65) where "V \<approx>\<^bsub>d\<^esub> V' \<equiv> (V,V') \<in> Strong_Security.USdB (MWLf_semantics.MWLfSteps_det ExprEval BMap) DA d" \<comment> \<open>Security typing rules for expressions - will be part of a side condition\<close> inductive ExprSecTyping :: "('id, 'val) Expr \<Rightarrow> Dom set \<Rightarrow> bool" ("\<turnstile>\<^bsub>\<E>\<^esub> _ : _") where Consts: "\<turnstile>\<^bsub>\<E>\<^esub> (Const v) : {d}" | Vars: "\<turnstile>\<^bsub>\<E>\<^esub> (Var x) : {DA x}" | Ops: "\<forall>i < length arglist. \<turnstile>\<^bsub>\<E>\<^esub> (arglist!i) : (dl!i) \<Longrightarrow> \<turnstile>\<^bsub>\<E>\<^esub> (Op f arglist) : (\<Union>{d. (\<exists>i < length arglist. d = (dl!i))})" definition synAssignSC :: "'id \<Rightarrow> ('id, 'val) Expr \<Rightarrow> bool" where "synAssignSC x e \<equiv> \<exists>D. (\<turnstile>\<^bsub>\<E>\<^esub> e : D \<and> (\<forall>d \<in> D. (d \<le> DA x)))" definition synWhileSC :: "('id, 'val) Expr \<Rightarrow> bool" where "synWhileSC e \<equiv> \<exists>D. (\<turnstile>\<^bsub>\<E>\<^esub> e : D \<and> (\<forall>d\<in>D. \<forall>d'. d \<le> d'))" definition synIfSC :: "('id, 'val) Expr \<Rightarrow> (('id, 'val) Expr, 'id) MWLfCom \<Rightarrow> (('id, 'val) Expr, 'id) MWLfCom \<Rightarrow> bool" where "synIfSC e c1 c2 \<equiv> \<forall>d. (\<not> (e \<equiv>\<^bsub>d\<^esub> e) \<longrightarrow> [c1] \<approx>\<^bsub>d\<^esub> [c2])" lemma ExprTypable_with_smallerD_implies_d_indistinguishable: "\<lbrakk> \<turnstile>\<^bsub>\<E>\<^esub> e : D'; \<forall>d' \<in> D'. d' \<le> d \<rbrakk> \<Longrightarrow> e \<equiv>\<^bsub>d\<^esub> e" proof (induct rule: ExprSecTyping.induct, simp_all add: Strongly_Secure_Programs.d_indistinguishable_def Strong_Security.d_equal_def, auto) fix dl and arglist::"(('id, 'val) Expr) list" and f::"'val list \<Rightarrow> 'val" and m1::"('id,'val) State" and m2::"('id,'val) State" assume main: "\<forall>i < length arglist. \<turnstile>\<^bsub>\<E>\<^esub> arglist!i : dl!i \<and> ((\<forall>d' \<in> (dl!i). d' \<le> d) \<longrightarrow> (\<forall>m m'. (\<forall>x. DA x \<le> d \<longrightarrow> m x = m' x) \<longrightarrow> ExprEval (arglist!i) m = ExprEval (arglist!i) m'))" assume smaller: "\<forall>D. (\<exists>i < length arglist. D = (dl!i)) \<longrightarrow> (\<forall>d'\<in>D. d' \<le> d)" assume eqstate: "\<forall>x. DA x \<le> d \<longrightarrow> m1 x = m2 x" from smaller have irangesubst: "\<forall>i < length arglist. \<forall>d' \<in> (dl!i). d' \<le> d" by auto with eqstate main have "\<forall>i < length arglist. ExprEval (arglist!i) m1 = ExprEval (arglist!i) m2" by force hence substmap: "(ExprEvalL arglist m1) = (ExprEvalL arglist m2)" by (induct arglist, auto, force) show "f (ExprEvalL arglist m1) = f (ExprEvalL arglist m2)" by (subst substmap, auto) qed interpretation Type_System_example: Type_System ExprEval BMap DA synAssignSC synWhileSC synIfSC by (unfold_locales, simp add: synAssignSC_def, metis ExprTypable_with_smallerD_implies_d_indistinguishable, simp add: synWhileSC_def, metis ExprTypable_with_smallerD_implies_d_indistinguishable, simp add: synIfSC_def, metis) end