Datasets:
AI4M
/

text
stringlengths
0
3.34M
module Section_2_5_2 where import Numeric.LinearAlgebra import Section_2_3_3 (and', nand, or') xor :: Double -> Double -> Double xor x1 x2 = let s1 = nand x1 x2 s2 = or' x1 x2 y = and' s1 s2 in y
> module NonNegDouble.Operations > import Data.So > import Double.Predicates > import Double.Postulates > import Double.Properties > import NonNegDouble.NonNegDouble > import NonNegDouble.Predicates > import NonNegDouble.Constants > import NonNegDouble.BasicOperations > import Pairs.Operations > %default total > %access public export > ||| Addition of positive double precision floating point numbers > plus : NonNegDouble -> NonNegDouble -> NonNegDouble > plus (Element x nnx) (Element y nny) = Element (x + y) (plusPreservesNonNegativity nnx nny) > ||| Subtraction of positive double precision floating point numbers > minus : (x : NonNegDouble) -> (y : NonNegDouble) -> {auto prf : y `LTE` x} -> NonNegDouble > minus (Element x nnx) (Element y nny) {prf} = Element (x - y) (minusPreservesNonNegativity nnx nny prf) > (-) : (x : NonNegDouble) -> (y : NonNegDouble) -> {auto prf : y `LTE` x} -> NonNegDouble > (-) = minus > ||| Multiplication of positive double precision floating point numbers > mult : NonNegDouble -> NonNegDouble -> NonNegDouble > mult (Element x nnx) (Element y nny) = Element (x * y) (multPreservesNonNegativity nnx nny) > ||| Division of positive double precision floating point numbers > div : NonNegDouble -> NonNegDouble -> NonNegDouble > div (Element x nnx) (Element y nny) = Element (x / y) (divPreservesNonNegativity nnx nny) > ||| > fromNat : (n : Nat) -> NonNegDouble > fromNat Z = zero > fromNat (S m) = one `plus` (fromNat m) > {- > ---}
function [exp,changed,rules] = exp_replaceall(exp,rules) % Apply substitution rules to some expression. % [Out-Expression,Changed,Remaining-Rules] = exp_replaceall(In-Expression, Rule/Rule-List) % % Each part of the expression receives at most a single replacement, and each rule is used at most % once rules may contain blanks and placeholders. % % In: % In-Expression : some pure expression in which substitution shall take place % Rule-List : cell array of substitution rules % % Out: % Out-Expression : In-Expression with substitutions performed % % Changed : whether a replacement has taken place % Remaining-Rules : the list of rules that have not been applied % % Notes: % Impure expressions degrade into pure expressions, when substitutions are performed on them (i.e. % they lose their attached value). Named patterns inside the right-hand-sides of substitution % rules are treated as if just their symbols were given instead. % % See also: % exp_replacerepeated, exp_match % % Christian Kothe, Swartz Center for Computational Neuroscience, UCSD % 2010-04-19 if ~exp_beginfun('symbolic') return; end [exp,changed,rules] = utl_replaceall(exp,rules); exp_endfun;
Located along the banks of the Chattahoochee River and less than 25 minutes from Atlanta’s Hartsfield-Jackson International Airport, Foxhall Resort offers an unexpectedly unique collection of event venues, including a stately and historic stone stable and a sprawling lakeside event lawn. Featuring beautiful views overlooking polo fields, The Paddock Restaurant is an ideal setting for a banquet, bridal luncheon or rehearsal dinner. Perfect for a company picnic, this open-air pavilion with vaulted ceilings is accented by natural stone and cast iron chandeliers. An exquisite and romantic wedding backdrop, Legacy Lookout features a ballroom with rustic timber and natural stone finishes, as well as flagstone patios and an event lawn. Lushly landscaped, our stately historic stable features East and West ballrooms with vaulted ceilings and a paddock courtyard connected by a stone walkway.
= = = Planning system = = =
(* This file contains the update semantics to C correspondence lemmas for word array functions *) theory SumRandom_UpdCCorres imports SumRandom_UAbsFun begin context SumRandom begin section "Correspondence Lemmas Between Update Semantics and C" subsection "random_seed" thm update_sem_init.abs_rel_def thm afun_corres abs_rel_def thm \<Xi>_def lemma (in update_sem_init) abs_rel_def': "abs_rel \<Xi>' srel afun_name \<xi>' afun_mon = (\<forall>\<sigma> st x x' r' w'. (\<sigma>, st) \<in> srel \<and> val_rel x x' \<and> \<Xi>', \<sigma> \<turnstile> x :u fst (snd (\<Xi>' afun_name)) \<langle>r', w'\<rangle> \<longrightarrow> \<lbrace>\<lambda>s0. s0 = st\<rbrace> afun_mon x' \<lbrace>\<lambda>y' s'. \<exists>\<sigma>' y. \<xi>' afun_name (\<sigma>, x) (\<sigma>', y) \<and> (\<sigma>',s') \<in> srel \<and> val_rel y y'\<rbrace>!)" by (fastforce simp: abs_rel_def validNF_def valid_def no_fail_def) find_theorems name:"rand'_" thm random_aux_Seed_C_def term rand' thm rand_with_seed'_def lemma "\<lbrace> \<lambda>s. True \<rbrace> rand' \<lbrace>\<lambda>r s. True\<rbrace>!" oops lemma rand_with_seed_C_spec: "\<lbrace>\<lambda>h. True \<rbrace> rand_with_seed' x' \<lbrace>\<lambda>r h'. True \<rbrace>!" unfolding rand_with_seed'_def apply wp sorry lemma rand_with_seed_abs_rel_0 : "abs_rel \<Xi> state_rel ''rand_with_seed'' \<xi>u0 rand_with_seed'" apply (clarsimp simp add: abs_rel_def' ) apply wpsimp sorry lemma rand_with_seed_corres_i: "(\<And>i \<gamma> v' \<Gamma>' \<sigma> st. i < length \<gamma> \<Longrightarrow> val_rel (\<gamma> ! i) v' \<Longrightarrow> \<Gamma>' ! i = Some (fst (snd Random_seed_master_TypeProof.rand_with_seed_type)) \<Longrightarrow> update_sem_init.corres seed_abs_typing_u seed_abs_repr state_rel (App (AFun ''rand_with_seed'' []) (Var i)) (do x <- rand_with_seed' v'; gets (\<lambda>s. x) od) \<xi>ui \<gamma> \<Xi> \<Gamma>' \<sigma> st)" apply (rule afun_corres) apply (simp add: abs_rel_def \<Xi>_def) apply clarsimp apply safe lemma rand_with_seed_corres: "\<And>i \<gamma> v' \<Gamma>' \<sigma> st. \<lbrakk> i < length \<gamma>; val_rel (\<gamma> ! i) v'; \<Gamma>' ! i = option.Some (prod.fst (prod.snd (\<Xi> ''random_with_seed''))); \<xi>u ''random_with_seed''= rand_with_seed_u\<rbrakk> \<Longrightarrow> update_sem_init.corres seed_abs_typing_u seed_abs_repr state_rel (App (AFun ''random_with_seed'' []) (Var i)) (do x <- random_seed_master_pp_inferred.rand_with_seed' v'; gets (\<lambda>s. x) od) \<xi>0' \<gamma> \<Xi> \<Gamma>' \<sigma> st " apply (rule afun_corres) lemma upd_C_wordarray_put2_corres_gen: "\<And>i \<gamma> v' \<Gamma>' \<sigma> st. \<lbrakk>i < length \<gamma>; val_rel (\<gamma> ! i) v'; \<Gamma>' ! i = option.Some (prod.fst (prod.snd (\<Xi> ''wordarray_put2_0''))); \<xi>0' ''wordarray_put2_0'' = upd_wa_put2_0\<rbrakk> \<Longrightarrow> update_sem_init.corres wa_abs_typing_u wa_abs_repr (Generated.state_rel wa_abs_repr) (App (AFun ''wordarray_put2_0'' []) (Var i)) (do x <- main_pp_inferred.wordarray_put2_0' v'; gets (\<lambda>s. x) od) \<xi>0' \<gamma> \<Xi> \<Gamma>' \<sigma> st" apply (rule absfun_corres; simp?) apply (thin_tac "\<Gamma>' ! i = _") apply (clarsimp simp: abs_fun_rel_def; rename_tac r w) apply (rotate_tac -1) apply (subst (asm) \<Xi>_def) apply (subst (asm) \<Xi>_def) apply (clarsimp simp: val_rel_simp wordarray_put2_0_type_def abbreviated_type_defs) apply (erule upd.u_t_recE) apply (erule upd.u_t_r_consE; clarsimp)+ apply (erule upd.u_t_primE)+ apply (subst (asm) lit_type.simps)+ apply clarsimp apply (erule upd.u_t_r_emptyE) apply (erule upd.u_t_p_absE; simp) apply (frule wa_abs_typing_u_elims(1); clarsimp; rename_tac len arr) apply (rule conjI) apply (monad_eq simp: wordarray_put2_0'_def) apply (clarsimp simp: state_rel_def heap_rel_def) apply (erule_tac x = "t2_C.arr_C v'" in allE) apply (erule_tac x = "values_C (heap_WordArray_u32_C st (t2_C.arr_C v')) +\<^sub>p uint (t2_C.idx_C v')" in allE) apply (clarsimp simp: heap_rel_ptr_def heap_rel_ptr_w32_def wa_abs_repr_def is_valid_simp type_rel_simp) apply (frule wa_abs_typing_u_elims(5)) apply (erule_tac x = "t2_C.idx_C v'" in allE)+ apply (clarsimp simp: val_rel_simp heap_simp type_rel_simp) apply clarsimp apply (monad_eq simp: upd_wa_put2_0_def) apply (case_tac "idx_C v' < len"; clarsimp) apply (rule conjI) apply (monad_eq simp: wordarray_put2_0'_def) apply (clarsimp simp: state_rel_def heap_rel_def heap_rel_ptr_meta heap_rel_ptr_w32_meta) apply (monad_eq simp: wordarray_put2_0'_def) apply (frule_tac p = "t2_C.arr_C v'" in all_heap_rel_ptrD; simp?) apply (clarsimp simp: type_rel_simp wa_abs_repr_def) apply (clarsimp simp: val_rel_simp heap_simp is_valid_simp) apply (drule wa_abs_typing_u_elims(5)) apply (erule_tac x = "t2_C.idx_C v'" in allE; clarsimp) apply (drule_tac upd_h = "(heap_w32_update (\<lambda>x. x(values_C (heap_WordArray_u32_C st (t2_C.arr_C v')) +\<^sub>p uint (idx_C v') := val_C v')) st)" and x = "(values_C (heap_WordArray_u32_C st (t2_C.arr_C v'))) +\<^sub>p uint (idx_C v')" and uv' = "UPrim (LU32 (val_C v'))" and uv = "UPrim x" in all_heap_rel_updE; simp?; clarsimp?) apply (clarsimp simp: type_rel_simp) apply (drule_tac upd_h = "(heap_w32_update (\<lambda>x. x(values_C (heap_WordArray_u32_C st (t2_C.arr_C v')) +\<^sub>p uint (idx_C v') := val_C v')) st)" and x = "(values_C (heap_WordArray_u32_C st (t2_C.arr_C v'))) +\<^sub>p uint (idx_C v')" and uv' = "UPrim (LU32 (val_C v'))" and uv = "UPrim x" in all_heap_rel_updE; simp?; clarsimp?) apply (rule conjI, clarsimp simp: val_rel_simp) apply clarsimp apply (rule FalseE) apply (cut_tac p = p and q = "((values_C (heap_WordArray_u32_C st (t2_C.arr_C v'))) +\<^sub>p uint (idx_C v'))" in ptr_val_inj) apply (clarsimp simp: ptr_add_def) apply (monad_eq simp: wordarray_put2_0'_def) apply (clarsimp simp: state_rel_def heap_rel_def heap_rel_ptr_meta) apply (frule_tac p = "t2_C.arr_C v'" in all_heap_rel_ptrD; simp?) apply (clarsimp simp: type_rel_simp wa_abs_repr_def) apply (clarsimp simp: val_rel_simp heap_simp is_valid_simp) done lemmas upd_C_wordarray_put2_corres = upd_C_wordarray_put2_corres_gen[rotated -1, of \<xi>0, simplified fun_eq_iff] subsection "wordarray_length" lemma upd_C_wordarray_length_corres_gen: "\<And>i \<gamma> v' \<Gamma>' \<sigma> st. \<lbrakk>i < length \<gamma>; val_rel (\<gamma> ! i) v'; \<Gamma>' ! i = option.Some (prod.fst (prod.snd (\<Xi> ''wordarray_length_0''))); \<xi>0' ''wordarray_length_0''= upd_wa_length_0\<rbrakk> \<Longrightarrow> update_sem_init.corres wa_abs_typing_u wa_abs_repr (Generated.state_rel wa_abs_repr) (App (AFun ''wordarray_length_0'' []) (Var i)) (do x <- main_pp_inferred.wordarray_length_0' v'; gets (\<lambda>s. x) od) \<xi>0' \<gamma> \<Xi> \<Gamma>' \<sigma> st" apply (rule absfun_corres; simp?) apply (clarsimp simp: abs_fun_rel_def; rename_tac r w) apply (thin_tac "\<Gamma>' ! i = _") apply (rotate_tac -1) apply (subst (asm) \<Xi>_def) apply (subst (asm) \<Xi>_def) apply (clarsimp simp: val_rel_simp wordarray_length_0_type_def) apply (erule upd.u_t_p_absE; simp) apply (frule wa_abs_typing_u_elims(1); clarsimp; rename_tac len arr) apply (rule conjI) apply (monad_eq simp: wordarray_length_0'_def) apply (clarsimp simp: state_rel_def heap_rel_def) apply (erule_tac x = v' in allE) apply (clarsimp simp: heap_rel_ptr_def type_rel_simp wa_abs_repr_def is_valid_simp) apply clarsimp apply (rule_tac x = \<sigma> in exI) apply (rule conjI) apply (clarsimp simp: upd_wa_length_0_def) apply (monad_eq simp: wordarray_length_0'_def) apply (clarsimp simp: state_rel_def heap_rel_def) apply (erule_tac x = v' in allE) apply (clarsimp simp: heap_rel_ptr_def type_rel_simp wa_abs_repr_def heap_simp val_rel_simp) apply (monad_eq simp: wordarray_length_0'_def) done lemmas upd_C_wordarray_length_corres = upd_C_wordarray_length_corres_gen[rotated -1, of \<xi>0, simplified fun_eq_iff] subsection "wordarray_get" lemma upd_C_wordarray_get_corres_gen: "\<And>i \<gamma> v' \<Gamma>' \<sigma> st. \<lbrakk>i < length \<gamma>; val_rel (\<gamma> ! i) v'; \<Gamma>' ! i = option.Some (prod.fst (prod.snd (\<Xi> ''wordarray_get_0''))); \<xi>0' ''wordarray_get_0'' = upd_wa_get_0\<rbrakk> \<Longrightarrow> update_sem_init.corres wa_abs_typing_u wa_abs_repr (Generated.state_rel wa_abs_repr) (App (AFun ''wordarray_get_0'' []) (Var i)) (do x <- main_pp_inferred.wordarray_get_0' v'; gets (\<lambda>s. x) od) \<xi>0' \<gamma> \<Xi> \<Gamma>' \<sigma> st" apply (rule absfun_corres; simp?) apply (clarsimp simp: abs_fun_rel_def; rename_tac r w) apply (thin_tac "\<Gamma>' ! i = _") apply (rotate_tac -1) apply (subst (asm) \<Xi>_def) apply (subst (asm) \<Xi>_def) apply (clarsimp simp: val_rel_simp wordarray_get_0_type_def abbreviated_type_defs) apply (erule upd.u_t_recE) apply (erule upd.u_t_r_consE; clarsimp)+ apply (erule upd.u_t_r_emptyE) apply (erule upd.u_t_primE; subst (asm) lit_type.simps; clarsimp) apply (erule upd.u_t_p_absE; simp) apply (frule wa_abs_typing_u_elims(1); clarsimp; rename_tac len arr) apply (rule conjI) apply (monad_eq simp: wordarray_get_0'_def) apply (clarsimp simp: state_rel_def heap_rel_def heap_rel_ptr_meta heap_rel_ptr_w32_meta) apply (drule_tac p = "t1_C.p1_C v'" and uv = "UAbstract (UWA (TPrim (Num U32)) len arr)" in all_heap_rel_ptrD; clarsimp simp: type_rel_simp wa_abs_repr_def val_rel_simp is_valid_simp heap_simp) apply (drule not_le_imp_less) apply (frule wa_abs_typing_u_elims(5)) apply (erule_tac x = "t1_C.p2_C v'" in allE; clarsimp) apply (drule_tac p = "values_C (heap_WordArray_u32_C st (t1_C.p1_C v')) +\<^sub>p uint (t1_C.p2_C v')" and uv = "UPrim x" in all_heap_rel_ptrD; simp add: type_rel_simp) apply clarsimp apply (rule_tac x = \<sigma> in exI) apply (rule conjI) apply (clarsimp simp: upd_wa_get_0_def) apply (frule wa_abs_typing_u_elims(5)) apply (erule_tac x = "t1_C.p2_C v'" in allE) apply (monad_eq simp: wordarray_get_0'_def word_less_nat_alt word_le_nat_alt) apply (clarsimp simp: state_rel_def heap_rel_def heap_rel_ptr_meta heap_rel_ptr_w32_meta) apply (drule_tac p = "t1_C.p1_C v'" and uv = "UAbstract (UWA (TPrim (Num U32)) len arr)" in all_heap_rel_ptrD; clarsimp simp: type_rel_simp wa_abs_repr_def val_rel_simp is_valid_simp heap_simp) apply (drule_tac p = "values_C (heap_WordArray_u32_C st (t1_C.p1_C v')) +\<^sub>p uint (t1_C.p2_C v')" and uv = "UPrim x" in all_heap_rel_ptrD; clarsimp simp: type_rel_simp val_rel_simp) apply (monad_eq simp: wordarray_get_0'_def) apply blast done lemmas upd_C_wordarray_get_corres = upd_C_wordarray_get_corres_gen[rotated -1, of \<xi>0, simplified fun_eq_iff] subsection "Helper lemmas, definitions and abbreviations for second order abstract functions" abbreviation "elem_type x \<equiv> (present_type \<circ> (\<lambda>xs. xs ! 0) \<circ> rec_type_list) x" abbreviation "mk_urecord xs \<equiv> URecord (map (\<lambda>x. (x, upd.uval_repr x)) xs)" definition "foldmap_measure i end \<equiv> unat end - unat i" definition "foldmap_bounds frm to len i e \<equiv> frm \<le> i \<and> e = min to len \<and> (frm < e \<longrightarrow> i \<le> e) \<and> ((\<not>(frm < e)) \<longrightarrow> frm = i)" definition "foldmap_inv foldmap \<xi>' \<sigma> p frm i f acc obsv r \<sigma>' res s' res' \<equiv> foldmap \<xi>' \<sigma> p frm i f acc obsv r (\<sigma>', res) \<and> val_rel res res' \<and> (\<sigma>', s') \<in> state_rel" definition "foldmap_inv_stat obsv obsv' \<equiv> val_rel obsv obsv'" lemma whileLoop_add_invI: assumes "\<lbrace> P \<rbrace> whileLoop_inv c b init I (measure M) \<lbrace> Q \<rbrace>!" shows "\<lbrace> P \<rbrace> whileLoop c b init \<lbrace> Q \<rbrace>!" by (metis assms whileLoop_inv_def) lemma validNF_select_UNIV: "\<lbrace>\<lambda>s. \<forall>x. Q x s\<rbrace> select UNIV \<lbrace>Q\<rbrace>!" apply (subst select_UNIV_unknown) apply (rule validNF_unknown) done subsection "wordarray_fold_no_break" lemma \<Xi>_wordarray_fold_no_break_0: "\<Xi> ''wordarray_fold_no_break_0'' = wordarray_fold_no_break_0_type" by (clarsimp simp: \<Xi>_def) lemma fold_dispatch_wp: "\<lbrakk>proc_ctx_wellformed \<Xi>; upd.proc_env_matches_ptrs \<xi>0' \<Xi>; wa_abs_typing_u (UWA (TPrim (Num num)) len arr) ''WordArray'' [TPrim (Num num)] (Boxed ReadOnly ptrl) r w \<sigma>; \<sigma> p = option.Some (UAbstract (UWA (TPrim (Num num)) len arr)); upd.uval_typing \<Xi> \<sigma> acc (foldmap_acc_type ''wordarray_fold_no_break_0'') ra wa; upd.uval_typing \<Xi> \<sigma> obsv (foldmap_obsv_type ''wordarray_fold_no_break_0'') ro {}; wa \<inter> r = {}; wa \<inter> ro = {}; p \<notin> wa; (\<Xi>, [], [option.Some (foldmap_funarg_type ''wordarray_fold_no_break_0'')] \<turnstile> (App f (Var 0)) : (foldmap_funret_type ''wordarray_fold_no_break_0'')); \<forall>x x' \<sigma> s. val_rel x x' \<longrightarrow> update_sem_init.corres wa_abs_typing_u wa_abs_repr (Generated.state_rel wa_abs_repr) (App f (Var 0)) (do ret <- dispatch f_num x'; gets (\<lambda>s. ret) od) \<xi>0' [x] \<Xi> [option.Some (foldmap_funarg_type ''wordarray_fold_no_break_0'')] \<sigma> s; elem_type (foldmap_funarg_type ''wordarray_fold_no_break_0'') = TPrim (Num num)\<rbrakk> \<Longrightarrow> \<lbrace>\<lambda>sa. (a', n') = (a, n) \<and> n < e \<and> (\<exists>\<sigma>' res x v. args = t3_C.elem_C_update (\<lambda>_. v) a \<and> \<sigma>' (arr + size_of_num_type num * n) = option.Some x \<and> val_rel x v \<and> foldmap_inv upd_wa_foldnb_bod \<xi>0' \<sigma> p frm n f acc obsv (ra \<union> ro) \<sigma>' res sa (t3_C.acc_C args)) \<and> foldmap_bounds frm to len n e \<and> foldmap_inv_stat obsv (t3_C.obsv_C args)\<rbrace> dispatch f_num args \<lbrace>\<lambda>ret sb. (\<exists>\<sigma>' res. foldmap_inv upd_wa_foldnb_bod \<xi>0' \<sigma> p frm (n + 1) f acc obsv (ra \<union> ro) \<sigma>' res sb ret) \<and> foldmap_inv_stat obsv (t3_C.obsv_C args) \<and> foldmap_bounds frm to len (n + 1) e \<and> foldmap_measure (n + 1) to < foldmap_measure n' to\<rbrace>!" apply (subst validNF_def) apply (clarsimp simp: \<Xi>_wordarray_fold_no_break_0 wordarray_fold_no_break_0_type_def abbreviated_type_defs) apply (subst valid_def) apply (subst no_fail_def) apply clarsimp apply (subst all_imp_conj_distrib[symmetric]) apply (clarsimp simp: foldmap_inv_def) apply (rename_tac sa \<sigma>' res x v) apply (erule_tac x = "mk_urecord [x, res, obsv]" in allE) apply (erule_tac x = args in allE) apply (erule impE) apply (subst val_rel_simp; simp add: foldmap_inv_stat_def) apply (erule_tac x = \<sigma>' in allE) apply (erule_tac x = sa in allE) apply (clarsimp simp: corres_def) apply (frule_tac t = "TPrim (Num num)" in upd_wa_foldnb_bod_preservation[rotated 2]; simp?; clarsimp?) apply (rename_tac r' w') apply (subgoal_tac "upd.matches_ptrs \<Xi> \<sigma>' [(mk_urecord [x, res, obsv])] [option.Some (foldmap_funarg_type ''wordarray_fold_no_break_0'')] (r' \<union> ro) w'") apply (clarsimp simp: \<Xi>_wordarray_fold_no_break_0 wordarray_fold_no_break_0_type_def abbreviated_type_defs) apply (erule impE, blast) apply clarsimp apply (rename_tac ret sb) apply (erule_tac x = ret in allE) apply (erule_tac x = sb in allE) apply clarsimp apply (drule upd.preservation[where \<tau>s = "[]" and K = "[]", simplified]; simp?) apply clarsimp apply (rename_tac \<sigma>'' res' rb wb) apply (clarsimp simp: foldmap_bounds_def) apply (case_tac "frm < to \<and> frm < len"; clarsimp) apply (frule wa_abs_typing_u_elims(5)) apply (erule_tac x = n in allE; clarsimp) apply (frule_tac p = "arr + (size_of_num_type num) * n" in valid_ptr_not_in_frame_same; simp?) apply (drule_tac x = "arr + 4 * n" and S' = r in orthD2; simp?) apply (drule_tac wa_abs_typing_u_elims(2)[where \<tau>s = "[_]", simplified]; simp) apply blast apply clarsimp apply (drule_tac t = num and arr = arr and len = len and r' = res' in upd_wa_foldnb_bod_step; simp?; clarsimp?) apply (rule conjI) apply (drule_tac p = p in readonly_not_in_frame; simp?) apply (subst Int_Un_distrib2)+ apply clarsimp apply (rule conjI) apply (rule disjointI) apply (frule_tac p = x and r = ra and w = wa in upd.uval_typing_valid(1)[rotated 1]; simp?) apply clarsimp apply (drule_tac p = y in readonly_not_in_frame; simp?) apply (drule upd.uval_typing_pointers_noalias; blast) apply (rule conjI) apply (rule disjointI) apply (frule_tac p = x and r = ro and w = "{}" in upd.uval_typing_valid(1)[rotated 1]; simp?) apply clarsimp apply (drule_tac p = y in readonly_not_in_frame; simp?) apply blast apply (rule disjointI) apply (frule wa_abs_typing_u_elims(5)) apply clarsimp apply (erule_tac x = i in allE; clarsimp) apply (drule_tac p = "arr + (size_of_num_type num) * i" in readonly_not_in_frame; simp?) apply (drule wa_abs_typing_u_elims(2); clarsimp) apply blast apply (rule conjI) apply (rule_tac x = \<sigma>'' in exI) apply (rule_tac x = res' in exI; simp) apply (frule_tac a = n and k = to in less_is_non_zero_p1) apply (drule unatSuc2; clarsimp simp: word_less_nat_alt word_le_nat_alt foldmap_measure_def) apply linarith apply (clarsimp simp: \<Xi>_wordarray_fold_no_break_0 wordarray_fold_no_break_0_type_def abbreviated_type_defs) apply (rule upd.matches_ptrs_some[where r' = "{}" and w' = "{}", simplified]) apply (rule upd.u_t_struct; simp?) apply (rule upd.u_t_r_cons1[where r = "{}" and w = "{}", simplified]; simp?) apply (subst (asm) val_rel_word; clarsimp) apply (rule upd.u_t_prim'; clarsimp) apply (rule upd.u_t_r_cons1[where r' = ro and w' = "{}", simplified]; simp?) apply (drule_tac u = obsv in upd.uval_typing_frame(1); simp?) apply blast apply (rule upd.u_t_r_cons1[where r' = "{}" and w' = "{}", simplified]; simp?) apply (rule upd.u_t_r_empty) apply (drule_tac v = obsv in upd.type_repr_uval_repr(1); simp) apply (rule disjointI) apply (frule_tac p = y and r = ro in upd.uval_typing_valid(1)[where w = "{}", simplified]; simp?) apply clarsimp apply (drule_tac p = y in readonly_not_in_frame; simp?) apply (drule_tac x = y and S' = ro in orthD2; simp?) apply (drule_tac v = res in upd.type_repr_uval_repr(1); simp) apply (subst (asm) val_rel_word; clarsimp) apply (rule upd.matches_ptrs_empty[where \<tau>s = "[]", simplified]) done lemma upd_C_wordarray_fold_no_break_corres_gen: "\<lbrakk>upd.proc_env_matches_ptrs \<xi>0' \<Xi>; i < length \<gamma>; val_rel (\<gamma> ! i) v'; \<Gamma>' ! i = option.Some (prod.fst (prod.snd (\<Xi> ''wordarray_fold_no_break_0''))); D \<in> k \<or> S \<in> k; K' \<turnstile> (foldmap_obsv_type ''wordarray_fold_no_break_0'') :\<kappa> k; \<gamma> ! i = URecord fs; f = prod.fst (fs ! 3); (\<Xi>, [], [option.Some (foldmap_funarg_type ''wordarray_fold_no_break_0'')] \<turnstile> (App (uvalfun_to_exprfun f) (Var 0)) : (foldmap_funret_type ''wordarray_fold_no_break_0'')); \<forall>x x' \<sigma> s. val_rel x x' \<longrightarrow> update_sem_init.corres wa_abs_typing_u wa_abs_repr (Generated.state_rel wa_abs_repr) (App (uvalfun_to_exprfun f) (Var 0)) (do ret <- dispatch_t4' (t5_C.f_C v') x'; gets (\<lambda>s. ret) od) \<xi>0' [x] \<Xi> [option.Some (foldmap_funarg_type ''wordarray_fold_no_break_0'')] \<sigma> s; \<xi>1' ''wordarray_fold_no_break_0'' = upd_wa_foldnb \<Xi> \<xi>0' (foldmap_funarg_type ''wordarray_fold_no_break_0''); elem_type (foldmap_funarg_type ''wordarray_fold_no_break_0'') = TPrim (Num num)\<rbrakk> \<Longrightarrow> update_sem_init.corres wa_abs_typing_u wa_abs_repr (Generated.state_rel wa_abs_repr) (App (AFun ''wordarray_fold_no_break_0'' []) (Var i)) (do x <- main_pp_inferred.wordarray_fold_no_break_0' v'; gets (\<lambda>s. x) od) \<xi>1' \<gamma> \<Xi> \<Gamma>' \<sigma> s" apply (rule absfun_corres; simp) apply (clarsimp simp: abs_fun_rel_def'; rename_tac r w) apply (thin_tac "\<Gamma>' ! i = _") apply (subst (asm) val_rel_simp; clarsimp) apply (subst (asm) val_rel_ptr_def; clarsimp) apply (subst (asm) val_rel_fun_tag) apply (subst (asm) val_rel_word) apply (subst (asm) val_rel_word) apply (clarsimp simp: upd_wa_foldnb_def wordarray_fold_no_break_0'_def) apply (rename_tac pwa_rep frm_rep to_rep f_rep acc a_rep obsv o_rep wa_rep) apply (erule upd.u_t_recE; clarsimp) apply (clarsimp simp: \<Xi>_wordarray_fold_no_break_0 wordarray_fold_no_break_0_type_def abbreviated_type_defs) apply (erule upd.u_t_r_consE; clarsimp) apply (erule upd.u_t_p_absE; clarsimp) apply (frule wa_abs_typing_u_elims(1); clarsimp) apply (rename_tac r len arr) apply (erule upd.u_t_r_consE; simp) apply (erule upd.u_t_r_consE; simp) apply (erule conjE)+ apply (drule_tac t = "type_repr _" in sym)+ apply clarsimp apply (erule upd.u_t_primE)+ apply (drule_tac t = "lit_type _" in sym)+ apply clarsimp apply (erule upd.u_t_r_consE; clarsimp)+ apply (erule upd.u_t_r_emptyE; clarsimp) apply (frule upd.tfun_no_pointers(1)) apply (frule upd.tfun_no_pointers(2)) apply clarsimp apply (rename_tac acc ra wa obsv ro wo) apply (drule upd.discardable_or_shareable_not_writeable; simp?) apply clarsimp apply (subst unknown_bind_ignore)+ apply (clarsimp simp: join_guards) apply wp apply (clarsimp simp: unknown_bind_ignore split: prod.split) apply (rename_tac var e) apply (rule_tac M = "\<lambda>((_, i), _). foldmap_measure i (t5_C.to_C v')" and I = "\<lambda>(a, b) s. (\<exists>\<sigma>' res. foldmap_inv upd_wa_foldnb_bod \<xi>0' \<sigma> (ptr_val (t5_C.arr_C v')) (t5_C.frm_C v') b (uvalfun_to_exprfun f) acc obsv (ra \<union> ro) \<sigma>' res s (t3_C.acc_C a)) \<and> foldmap_inv_stat obsv (t3_C.obsv_C a) \<and> foldmap_bounds (t5_C.frm_C v') (t5_C.to_C v') len b e" in whileLoop_add_invI; simp?) apply (wp; clarsimp simp: unknown_bind_ignore split: prod.splits) apply (rename_tac sa a n args a' n') apply (rule_tac a = a and wa = wa and ra = ra and ro = ro and w = "{}" and r = r and ptrl = undefined in fold_dispatch_wp[rotated 2]; simp?) apply (clarsimp simp: \<Xi>_wordarray_fold_no_break_0 wordarray_fold_no_break_0_type_def abbreviated_type_defs)+ apply wp apply wp apply clarsimp apply (rename_tac args j \<sigma>' res) apply (clarsimp simp: foldmap_bounds_def foldmap_inv_def) apply (frule wa_abs_typing_u_elims(5)) apply (erule_tac x = j in allE; clarsimp) apply (drule_tac acc = acc and obsv = obsv and rb = ra and wb = wa and rc = ro in upd_wa_foldnb_bod_preservation; simp?; clarsimp?) apply (frule_tac p = "ptr_val (t5_C.arr_C v')" in valid_ptr_not_in_frame_same; simp?) apply (drule_tac p = "arr + (size_of_num_type num) * j" in valid_ptr_not_in_frame_same; simp?) apply (drule_tac x = "arr + (size_of_num_type num) * j" and S = wa and S' = r in orthD2; simp?) apply (drule wa_abs_typing_u_elims(2); clarsimp) apply blast apply (thin_tac "_ \<in> state_rel") apply (rule conjI) apply (rule_tac x = \<sigma>' in exI) apply (rule_tac x = res in exI) apply (rule_tac x = "UPrim x" in exI) apply clarsimp apply (clarsimp simp: state_rel_def heap_rel_def heap_rel_ptr_w32_meta heap_rel_ptr_meta) apply (rotate_tac -1) apply (drule_tac p = "Ptr(arr + (size_of_num_type num) * j)" in all_heap_rel_ptrD; simp?) apply (clarsimp simp: type_rel_simp) apply (rule_tac x = "heap_w32 s (PTR(32 word) (arr + (size_of_num_type num) * j))" in exI) apply (drule_tac p = "t5_C.arr_C v'" in all_heap_rel_ptrD; simp?) apply (clarsimp simp: type_rel_simp wa_abs_repr_def) apply (clarsimp simp: val_rel_WordArray_u32_C_def ptr_add_def heap_simp mult.commute) apply (clarsimp simp: state_rel_def heap_rel_def heap_rel_ptr_w32_meta heap_rel_ptr_meta) apply (rotate_tac -1) apply (drule_tac p = "Ptr(arr + (size_of_num_type num) * j)" in all_heap_rel_ptrD; simp?) apply (clarsimp simp: type_rel_simp) apply (drule_tac p = "t5_C.arr_C v'" in all_heap_rel_ptrD; simp?) apply (clarsimp simp: type_rel_simp wa_abs_repr_def) apply (clarsimp simp: is_valid_simp heap_simp val_rel_WordArray_u32_C_def ptr_add_def mult.commute) apply (rule conjI) apply (erule u_t_primtE; clarsimp) apply (rule conjI) apply (drule_tac v = obsv in upd.type_repr_uval_repr(1); simp?) apply (rule conjI) apply (drule wa_abs_typing_u_elims(5); simp) apply (rule conjI) apply (erule u_t_funafuntE; clarsimp) apply (rename_tac x' j \<sigma>' res) apply (rule_tac x = \<sigma>' in exI) apply (rule_tac x = res in exI) apply (clarsimp simp: foldmap_inv_def) apply (rule_tac x = "foldmap_acc_type ''wordarray_fold_no_break_0''" in exI) apply (rule_tac x = "foldmap_obsv_type ''wordarray_fold_no_break_0''" in exI) apply (rule_tac x = "''elem''" in exI) apply (rule_tac x = "''acc''" in exI) apply (rule_tac x = "''obsv''" in exI) apply (clarsimp simp: \<Xi>_wordarray_fold_no_break_0 wordarray_fold_no_break_0_type_def abbreviated_type_defs) apply (rule_tac x = ra in exI) apply (rule conjI) apply (intro exI, assumption) apply (rule_tac x = ro in exI) apply (rule conjI, simp) apply (unfold foldmap_bounds_def) apply (erule conjE)+ apply (case_tac "t5_C.frm_C v' < e") apply (erule impE, assumption) apply (thin_tac "_ \<longrightarrow> _") apply clarsimp apply (case_tac "j < t5_C.to_C v'"; clarsimp) apply (rule upd_wa_foldnb_bod_to_geq_len; simp?) apply (erule impE, assumption) apply (thin_tac "_ \<longrightarrow> _") apply clarsimp apply (erule upd_wa_foldnb_bod.elims; clarsimp) apply (case_tac "t5_C.frm_C v' < t5_C.to_C v'"; subst upd_wa_foldnb_bod.simps; clarsimp) apply wp apply wp apply (rule validNF_select_UNIV) apply (clarsimp simp: foldmap_inv_stat_def) apply (clarsimp simp: order.strict_implies_order) apply (clarsimp simp: foldmap_inv_def state_rel_def heap_rel_def heap_rel_ptr_meta) apply (frule_tac p = "t5_C.arr_C v'" in all_heap_rel_ptrD; simp?) apply (clarsimp simp: type_rel_simp wa_abs_repr_def) apply (clarsimp simp: is_valid_simp val_rel_WordArray_u32_C_def heap_simp) apply (rule conjI; clarsimp) apply (rule conjI) apply (rule_tac x = \<sigma> in exI) apply (rule_tac x = acc in exI) apply clarsimp apply (drule wa_abs_typing_u_elims(5)) apply (subst upd_wa_foldnb_bod.simps; clarsimp) apply (rule conjI; clarsimp) apply (rename_tac j) apply (erule_tac x = j in allE; clarsimp) apply (subst min_def) apply (subst (asm) not_le[symmetric])+ apply (subst if_not_P; simp?) apply (rule conjI) apply (rule_tac x = \<sigma> in exI) apply (rule_tac x = acc in exI) apply clarsimp apply (drule wa_abs_typing_u_elims(5)) apply (subst upd_wa_foldnb_bod.simps; clarsimp) apply (rule conjI; clarsimp) apply (rename_tac j) apply (erule_tac x = j in allE; clarsimp) apply (subst min_def) apply (clarsimp simp: not_le) done subsection "wordarray_map_no_break" lemma \<Xi>_wordarray_map_no_break_0: "\<Xi> ''wordarray_map_no_break_0'' = wordarray_map_no_break_0_type" by (clarsimp simp: \<Xi>_def) lemma map_dispatch_wp: "\<lbrakk>proc_ctx_wellformed \<Xi>; upd.proc_env_matches_ptrs \<xi>0' \<Xi>; wa_abs_typing_u (UWA (TPrim (Num num)) len arr) ''WordArray'' [TPrim (Num num)] (Boxed Writable ptrl) r w \<sigma>; \<sigma> p = option.Some (UAbstract (UWA (TPrim (Num num)) len arr)); upd.uval_typing \<Xi> \<sigma> acc (foldmap_acc_type ''wordarray_map_no_break_0'') ra wa; upd.uval_typing \<Xi> \<sigma> obsv (foldmap_obsv_type ''wordarray_map_no_break_0'') ro {}; wa \<inter> r = {}; p \<notin> w; p \<notin> r; w \<inter> wa = {}; w \<inter> (ra \<union> ro) = {}; wa \<inter> ro = {}; p \<notin> wa; p \<notin> ra; p \<notin> ro; p = ptr_val p'; (\<Xi>, [], [option.Some (foldmap_funarg_type ''wordarray_map_no_break_0'')] \<turnstile> (App f (Var 0)) : (foldmap_funret_type ''wordarray_map_no_break_0'')); \<forall>x x' \<sigma> s. val_rel x x' \<longrightarrow> update_sem_init.corres wa_abs_typing_u wa_abs_repr (Generated.state_rel wa_abs_repr) (App f (Var 0)) (do ret <- dispatch f_num x'; gets (\<lambda>s. ret) od) \<xi>0' [x] \<Xi> [option.Some (foldmap_funarg_type ''wordarray_map_no_break_0'')] \<sigma> s; elem_type (foldmap_funarg_type ''wordarray_map_no_break_0'') = TPrim (Num num)\<rbrakk> \<Longrightarrow> \<lbrace>\<lambda>sa. (a', n') = (a, n) \<and> n < e \<and> (\<exists>\<sigma>' res x v. args = t6_C.elem_C_update (\<lambda>_. v) a \<and> \<sigma>' (arr + size_of_num_type U32 * n) = option.Some x \<and> val_rel x v \<and> foldmap_inv upd_wa_mapAccumnb_bod \<xi>0' \<sigma> p frm n f acc obsv (ra \<union> ro) \<sigma>' res sa (t10_C p' (t6_C.acc_C args))) \<and> foldmap_bounds frm to len n e \<and> foldmap_inv_stat obsv (t6_C.obsv_C args)\<rbrace> dispatch f_num args \<lbrace>\<lambda>ret sb. (\<exists>\<sigma>' res. foldmap_inv upd_wa_mapAccumnb_bod \<xi>0' \<sigma> p frm (n + 1) f acc obsv (ra \<union> ro) \<sigma>' res (heap_w32_update (\<lambda>x a. if a = values_C (heap_WordArray_u32_C sb p') +\<^sub>p uint n then t7_C.p1_C ret else x a) sb) (t10_C p' (t7_C.p2_C ret))) \<and> foldmap_inv_stat obsv (t6_C.obsv_C args) \<and> foldmap_bounds frm to len (n + 1) e \<and> foldmap_measure (n + 1) to < foldmap_measure n' to \<and> is_valid_WordArray_u32_C sb p' \<and> is_valid_w32 sb (values_C (heap_WordArray_u32_C sb p') +\<^sub>p uint n)\<rbrace>!" apply (subst validNF_def) apply (clarsimp simp: \<Xi>_wordarray_map_no_break_0 wordarray_map_no_break_0_type_def abbreviated_type_defs) apply (subst valid_def) apply (subst no_fail_def) apply clarsimp apply (subst all_imp_conj_distrib[symmetric]) apply (clarsimp simp: foldmap_inv_def) apply (rename_tac sa \<sigma>' res x v) apply (frule upd_wa_mapAccumnb_bod_preservation'; simp?) apply clarsimp apply (rename_tac racc) apply (erule_tac x = "mk_urecord [x, racc, obsv]" in allE) apply (erule_tac x = args in allE) apply clarsimp apply (erule impE) apply (clarsimp simp: val_rel_simp foldmap_inv_stat_def) apply (erule_tac x = \<sigma>' in allE) apply (erule_tac x = sa in allE) apply (clarsimp simp: corres_def) apply (frule_tac t = "TPrim (Num num)" in upd_wa_mapAccumnb_bod_preservation; simp?; clarsimp?) apply (subst Int_Un_distrib2; clarsimp) apply (subst (asm) Int_Un_distrib; clarsimp) apply (subst (asm) Int_Un_distrib; clarsimp) apply (rename_tac r' w') apply (erule upd.u_t_recE; clarsimp) apply (erule upd.u_t_r_consE; simp) apply (erule conjE)+ apply (drule_tac t = "type_repr _" in sym; clarsimp) apply (erule upd.u_t_r_consE; clarsimp) apply (erule upd.u_t_r_emptyE; clarsimp) apply (rename_tac w' rb wb racc rc wc) apply (erule upd.u_t_p_con_wrE) apply (drule_tac t = "RCon _ _" in sym; clarsimp) apply (frule_tac p = p in valid_ptr_not_in_frame_same; simp?) apply clarsimp apply (frule_tac p = p in readonly_not_in_frame; simp?) apply (subst (asm) insert_ident; clarsimp) apply (rename_tac wb) apply (subgoal_tac "upd.matches_ptrs \<Xi> \<sigma>' [(mk_urecord [x, racc, obsv])] [option.Some (foldmap_funarg_type ''wordarray_map_no_break_0'')] (rc \<union> ro) wc") apply (clarsimp simp: \<Xi>_wordarray_map_no_break_0 wordarray_map_no_break_0_type_def abbreviated_type_defs) apply (erule impE, blast) apply clarsimp apply (rename_tac ret sb) apply (erule_tac x = ret in allE) apply (erule_tac x = sb in allE) apply clarsimp apply (drule upd.preservation[where \<tau>s = "[]" and K = "[]", simplified]; simp?) apply clarsimp apply (rename_tac \<sigma>'' res' r' w') apply (erule u_t_rectE; clarsimp) apply (erule u_t_r_contE; clarsimp) apply (erule u_t_r_contE; clarsimp) apply (erule u_t_r_contE; clarsimp) apply (rename_tac x' rd wd racc' r' w') apply (frule_tac v = x' in upd.tprim_no_pointers(1); clarsimp) apply (frule_tac v = x' in upd.tprim_no_pointers(2); clarsimp) apply (clarsimp simp: foldmap_bounds_def) apply (case_tac "frm < to \<and> frm < len"; clarsimp) apply (thin_tac "wa_abs_typing_u _ _ _ _ _ _ _") apply (drule_tac t = num and arr = arr and len = len and v' = x' and r' = racc' in upd_wa_mapAccumnb_bod_step; simp?; clarsimp?) apply (drule wa_abs_typing_u_elims(6); simp?) apply (subst Int_Un_distrib2)+ apply clarsimp apply (rule conjI) apply (rule disjointI) apply (rename_tac y y') apply (frule_tac p = y and r = ra and w = wa in upd.uval_typing_valid(1)[rotated 1]; simp?) apply clarsimp apply (drule_tac p = y' in readonly_not_in_frame; simp?) apply (drule_tac x = y' and S' = "ra \<union> ro" in orthD2; simp?) apply (drule upd.uval_typing_pointers_noalias) apply (drule_tac x = y' and S = ra and S' = wa in orthD1; simp?) apply (rule conjI) apply (rule disjointI) apply (rename_tac y y') apply (frule_tac p = y and r = ro and w = "{}" in upd.uval_typing_valid(1)[rotated 1]; simp?) apply clarsimp apply (drule_tac p = y' in readonly_not_in_frame; simp?) apply blast apply (drule wa_abs_typing_u_elims(3); clarsimp) apply (drule_tac v = x' in upd.type_repr_uval_repr(1); simp) apply (drule_tac v = racc' in upd.type_repr_uval_repr(1); simp) apply (thin_tac "_ \<in> state_rel") apply (clarsimp simp: state_rel_def heap_rel_def heap_rel_ptr_meta heap_rel_ptr_w32_meta) apply (frule_tac p = p and \<sigma> = \<sigma>' in valid_ptr_not_in_frame_same; simp?) apply (drule_tac p = "arr + (size_of_num_type num) * n" and \<sigma> = \<sigma>' in valid_ptr_not_in_frame_same; simp?) apply (drule_tac x = "arr + (size_of_num_type num) * n" and S' = wc in orthD1; simp?) apply (drule wa_abs_typing_u_elims(3); clarsimp) apply (rule_tac x = n in exI; clarsimp) apply (frule_tac p = p' in all_heap_rel_ptrD; simp?) apply (clarsimp simp: type_rel_simp wa_abs_repr_def) apply (frule_tac p = "values_C (heap_WordArray_u32_C sb p') +\<^sub>p uint n" and uv = x in all_heap_rel_ptrD; simp?) apply (clarsimp simp: val_rel_simp heap_simp) apply (clarsimp simp: type_rel_simp val_rel_simp) apply (rule conjI) apply (rule_tac x = "\<sigma>''(arr + (size_of_num_type num) * n \<mapsto> x')" in exI) apply (rule_tac x = "mk_urecord [UPtr (ptr_val p') (RCon ''WordArray'' [RPrim (Num U32)]), racc']" in exI) apply clarsimp apply (rule conjI) apply (clarsimp simp: val_rel_simp) apply (clarsimp simp: heap_simp is_valid_simp) apply (drule_tac upd_h = "(heap_w32_update (\<lambda>x a. if a = values_C (heap_WordArray_u32_C sb p') +\<^sub>p uint n then t7_C.p1_C ret else x a) sb)" and uv = x and uv' = x' and x = "values_C (heap_WordArray_u32_C sb p') +\<^sub>p uint n" in all_heap_rel_updE; simp?; clarsimp?) apply (clarsimp simp: val_rel_simp) apply (drule_tac v = x' in upd.type_repr_uval_repr(1); simp add: val_rel_simp) apply (clarsimp simp: val_rel_simp type_rel_simp) apply (drule_tac upd_h = "(heap_w32_update (\<lambda>x a. if a = values_C (heap_WordArray_u32_C sb p') +\<^sub>p uint n then t7_C.p1_C ret else x a) sb)" and uv = x and uv' = x' and x = "values_C (heap_WordArray_u32_C sb p') +\<^sub>p uint n" in all_heap_rel_updE; simp?; clarsimp?) apply (clarsimp simp: val_rel_simp) apply (drule_tac v = x' in upd.type_repr_uval_repr(1); simp add: val_rel_simp) apply (rule conjI) apply (clarsimp simp: val_rel_simp) apply (cut_tac p = pa and q = "values_C (heap_WordArray_u32_C sb p') +\<^sub>p uint n" in ptr_val_inj) apply clarsimp apply (clarsimp simp: ptr_add_def mult.commute val_rel_simp) apply (clarsimp simp: is_valid_simp) apply (frule_tac a = n and k = to in less_is_non_zero_p1) apply (drule unatSuc2; clarsimp simp: word_less_nat_alt word_le_nat_alt foldmap_measure_def) apply linarith apply (clarsimp simp: \<Xi>_wordarray_map_no_break_0 wordarray_map_no_break_0_type_def abbreviated_type_defs) apply (rule upd.matches_ptrs_some[where r' = "{}" and w' = "{}", simplified]) apply (rule upd.u_t_struct; simp?) apply (rule upd.u_t_r_cons1[where r = "{}" and w = "{}", simplified]; simp?) apply (subst (asm) val_rel_word; clarsimp) apply (rule upd.u_t_prim'; clarsimp) apply (rule upd.u_t_r_cons1[where r' = ro and w' = "{}", simplified]; simp?) apply (drule_tac u = obsv in upd.uval_typing_frame(1); simp?) apply blast apply (rule upd.u_t_r_cons1[where r' = "{}" and w' = "{}", simplified]; simp?) apply (rule upd.u_t_r_empty) apply (drule_tac v = obsv in upd.type_repr_uval_repr(1); simp) apply (rule disjointI) apply (frule_tac p = y and r = ro in upd.uval_typing_valid(1)[where w = "{}", simplified]; simp?) apply clarsimp apply (drule_tac p = y in readonly_not_in_frame; simp?) apply (drule_tac x = y and S' = ro in orthD2; simp?) apply (drule_tac x = y and S' = "ra \<union> ro" in orthD2; simp?) apply (subst (asm) val_rel_word; clarsimp) apply (rule upd.matches_ptrs_empty[where \<tau>s = "[]", simplified]) done lemma upd_C_wordarray_map_no_break_corres_gen: "\<lbrakk>upd.proc_env_matches_ptrs \<xi>0' \<Xi>; i < length \<gamma>; val_rel (\<gamma> ! i) v'; \<Gamma>' ! i = option.Some (prod.fst (prod.snd (\<Xi> ''wordarray_map_no_break_0''))); D \<in> k \<or> S \<in> k; K' \<turnstile> (foldmap_obsv_type ''wordarray_map_no_break_0'') :\<kappa> k; \<gamma> ! i = URecord fs; f = prod.fst (fs ! 3); (\<Xi>, [], [option.Some (foldmap_funarg_type ''wordarray_map_no_break_0'')] \<turnstile> (App (uvalfun_to_exprfun f) (Var 0)) : (foldmap_funret_type ''wordarray_map_no_break_0'')); \<forall>x x' \<sigma> s. val_rel x x' \<longrightarrow> update_sem_init.corres wa_abs_typing_u wa_abs_repr (Generated.state_rel wa_abs_repr) (App (uvalfun_to_exprfun f) (Var 0)) (do ret <- dispatch_t8' (t9_C.f_C v') x'; gets (\<lambda>s. ret) od) \<xi>0' [x] \<Xi> [option.Some (foldmap_funarg_type ''wordarray_map_no_break_0'')] \<sigma> s; \<xi>1' ''wordarray_map_no_break_0'' = upd_wa_mapAccumnb \<Xi> \<xi>0' (foldmap_funarg_type ''wordarray_map_no_break_0'') (foldmap_funret_type ''wordarray_map_no_break_0''); elem_type (foldmap_funarg_type ''wordarray_map_no_break_0'') = TPrim (Num num)\<rbrakk> \<Longrightarrow> update_sem_init.corres wa_abs_typing_u wa_abs_repr (Generated.state_rel wa_abs_repr) (App (AFun ''wordarray_map_no_break_0'' []) (Var i)) (do x <- main_pp_inferred.wordarray_map_no_break_0' v'; gets (\<lambda>s. x) od) \<xi>1' \<gamma> \<Xi> \<Gamma>' \<sigma> s" apply (rule absfun_corres; simp) apply (clarsimp simp: abs_fun_rel_def'; rename_tac r w) apply (thin_tac "\<Gamma>' ! i = _") apply (subst (asm) val_rel_simp; clarsimp) apply (subst (asm) val_rel_ptr_def; clarsimp) apply (subst (asm) val_rel_fun_tag) apply (subst (asm) val_rel_word) apply (subst (asm) val_rel_word) apply (clarsimp simp: upd_wa_mapAccumnb_def wordarray_map_no_break_0'_def) apply (rename_tac pwa_rep frm_rep to_rep f_rep acc a_rep o_rep wa_rep) apply (erule upd.u_t_recE; clarsimp) apply (clarsimp simp: \<Xi>_wordarray_map_no_break_0 wordarray_map_no_break_0_type_def abbreviated_type_defs) apply (erule upd.u_t_r_consE; clarsimp) apply (rename_tac r w r' w') apply (erule upd.u_t_p_absE; clarsimp) apply (rename_tac w) apply (frule wa_abs_typing_u_elims(1); clarsimp) apply (rename_tac len arr) apply (erule upd.u_t_r_consE; simp) apply (erule upd.u_t_r_consE; simp) apply (erule conjE)+ apply (drule_tac t = "type_repr _" in sym)+ apply clarsimp apply (erule upd.u_t_primE)+ apply (drule_tac t = "lit_type _" in sym)+ apply clarsimp apply (erule upd.u_t_r_consE; clarsimp)+ apply (erule upd.u_t_r_emptyE; clarsimp) apply (frule upd.tfun_no_pointers(1)) apply (frule upd.tfun_no_pointers(2)) apply clarsimp apply (rename_tac acc ra wa obsv ro wo) apply (drule_tac v = obsv in upd.discardable_or_shareable_not_writeable(1); simp?) apply (subst unknown_bind_ignore)+ apply (clarsimp simp: join_guards) apply wp apply (clarsimp simp: unknown_bind_ignore split: prod.split) apply (rename_tac var e) apply (rule_tac M = "\<lambda>((_, i), _). foldmap_measure i (t9_C.to_C v')" and I = "\<lambda>(a, b) s. (\<exists>\<sigma>' res. foldmap_inv upd_wa_mapAccumnb_bod \<xi>0' \<sigma> (ptr_val (t9_C.arr_C v')) (t9_C.frm_C v') b (uvalfun_to_exprfun f) acc obsv (ra \<union> ro) \<sigma>' res s (t10_C (t9_C.arr_C v') (t6_C.acc_C a))) \<and> foldmap_inv_stat obsv (t6_C.obsv_C a) \<and> foldmap_bounds (t9_C.frm_C v') (t9_C.to_C v') len b e" in whileLoop_add_invI; simp?) apply (wp; clarsimp simp: unknown_bind_ignore split: prod.splits) apply (rename_tac sa a n args a' n') apply (clarsimp simp: conj_left_commute[of "is_valid_w32 _ _", simplified]) apply (clarsimp simp: conj_commute[of "is_valid_w32 _ _", simplified]) apply (rule_tac a = a and wa = wa and ra = ra and ro = ro and w = w and r = r and ptrl = undefined in map_dispatch_wp; simp?) apply (clarsimp simp: \<Xi>_wordarray_map_no_break_0 wordarray_map_no_break_0_type_def abbreviated_type_defs)+ apply wp apply wp apply clarsimp apply (rename_tac args j \<sigma>' res) apply (clarsimp simp: foldmap_inv_def foldmap_bounds_def) apply (drule upd_wa_mapAccumnb_bod_preservation; simp?; clarsimp?) apply (subst Int_Un_distrib2; clarsimp) apply (cut_tac A = w and B = ra and C = ro in Int_Un_distrib; clarsimp) apply (cut_tac A = w and B = ra and C = ro in Int_Un_distrib; clarsimp) apply (frule_tac p = "ptr_val (t9_C.arr_C v')" in valid_ptr_not_in_frame_same; simp?) apply (thin_tac "_ \<in> state_rel") apply (frule_tac upd_wa_mapAccumnb_bod_preservation'; simp?) apply clarsimp apply (erule upd.u_t_recE; clarsimp) apply (erule upd.u_t_r_consE; simp) apply (erule conjE)+ apply (drule_tac t = "type_repr _" in sym; clarsimp) apply (erule upd.u_t_p_con_wrE) apply (drule_tac t = "RCon _ _" in sym; clarsimp) apply (thin_tac "wa_abs_typing_u _ _ _ _ _ _ _") apply (drule wa_abs_typing_u_elims(5)) apply (erule_tac x = j in allE; clarsimp) apply (clarsimp simp: state_rel_def heap_rel_def heap_rel_ptr_meta heap_rel_ptr_w32_meta) apply (frule_tac p = "t9_C.arr_C v'" in all_heap_rel_ptrD; simp?) apply (clarsimp simp: type_rel_simp wa_abs_repr_def) apply (rotate_tac -2) apply (frule_tac p = "Ptr(arr + (size_of_num_type num) * j)" in all_heap_rel_ptrD; simp?) apply (clarsimp simp: type_rel_simp) apply (rule conjI) apply (rule_tac x = \<sigma>' in exI) apply (rule_tac x = "mk_urecord [UPtr (ptr_val (t9_C.arr_C v')) (RCon ''WordArray'' [RPrim (Num num)]), racc]" in exI) apply (rule_tac x = "UPrim x" in exI) apply (rule_tac x = "heap_w32 s (PTR(32 word) (arr + (size_of_num_type num) * j))" in exI) apply (clarsimp simp: val_rel_WordArray_u32_C_def ptr_add_def heap_simp mult.commute) apply (clarsimp simp: val_rel_WordArray_u32_C_def ptr_add_def is_valid_simp heap_simp mult.commute) apply (rule conjI) apply (drule_tac v = acc in upd.type_repr_uval_repr(1); simp) apply (rule conjI) apply (drule_tac v = obsv in upd.type_repr_uval_repr(1); simp) apply (rule conjI) apply (drule wa_abs_typing_u_elims(5); simp) apply (rule conjI) apply (erule u_t_funafuntE; clarsimp) apply (rule_tac x = \<sigma>' in exI) apply (rule_tac x = res in exI) apply (clarsimp simp: foldmap_inv_def) apply (rule conjI) apply (rule_tac x = "foldmap_acc_type ''wordarray_map_no_break_0''" in exI) apply (rule_tac x = "foldmap_obsv_type ''wordarray_map_no_break_0''" in exI) apply (rule_tac x = "''elem''" in exI) apply (rule_tac x = "''acc''" in exI) apply (rule_tac x = "''obsv''" in exI) apply (rule_tac x = "''p1''" in exI) apply (rule_tac x = "''p2''" in exI) apply (rule_tac x = ra in exI) apply (clarsimp simp: \<Xi>_wordarray_map_no_break_0 wordarray_map_no_break_0_type_def abbreviated_type_defs) apply (rule conjI) apply (intro exI, assumption) apply (rule_tac x = ro in exI) apply clarsimp apply (rename_tac j \<sigma>' res) apply (unfold foldmap_bounds_def) apply (erule conjE)+ apply (case_tac "t9_C.frm_C v' < e") apply (erule impE, assumption) apply (thin_tac "_ \<longrightarrow> _") apply clarsimp apply (case_tac "j < t9_C.to_C v'"; clarsimp) apply (rule upd_wa_mapAccumnb_bod_to_geq_len; simp?) apply (erule impE, assumption) apply (thin_tac "_ \<longrightarrow> _") apply clarsimp apply (erule upd_wa_mapAccumnb_bod.elims; clarsimp) apply (case_tac "t9_C.frm_C v' < t9_C.to_C v'"; subst upd_wa_mapAccumnb_bod.simps; clarsimp) apply (clarsimp simp: val_rel_simp) apply wp apply wp apply (rule validNF_select_UNIV) apply (rule validNF_select_UNIV) apply (clarsimp simp: foldmap_inv_stat_def) apply (clarsimp simp: order.strict_implies_order) apply (clarsimp simp: foldmap_inv_def state_rel_def heap_rel_def heap_rel_ptr_meta) apply (frule_tac p = "t9_C.arr_C v'" in all_heap_rel_ptrD; simp?) apply (clarsimp simp: type_rel_simp wa_abs_repr_def) apply (clarsimp simp: is_valid_simp val_rel_WordArray_u32_C_def heap_simp) apply (rule conjI; clarsimp) apply (rule conjI) apply (rule_tac x = \<sigma> in exI) apply (rule_tac x = "mk_urecord [UPtr (ptr_val (t9_C.arr_C v')) (RCon ''WordArray'' [RPrim (Num num)]), acc]" in exI) apply (subst upd_wa_mapAccumnb_bod.simps; clarsimp) apply (rule conjI) apply (drule wa_abs_typing_u_elims(5); clarsimp) apply (rename_tac j) apply (erule_tac x = j in allE; clarsimp) apply (rule conjI) apply (drule wa_abs_typing_u_elims(3); clarsimp) apply (rule conjI) apply (clarsimp simp: val_rel_simp) apply (rule conjI; clarsimp) apply (subst min_def) apply (subst (asm) not_le[symmetric])+ apply (subst if_not_P; simp?) apply (rule conjI) apply (rule_tac x = \<sigma> in exI) apply (rule_tac x = "mk_urecord [UPtr (ptr_val (t9_C.arr_C v')) (RCon ''WordArray'' [RPrim (Num num)]), acc]" in exI) apply (subst upd_wa_mapAccumnb_bod.simps; clarsimp) apply (rule conjI) apply (drule wa_abs_typing_u_elims(5); clarsimp) apply (rename_tac j) apply (erule_tac x = j in allE; clarsimp) apply (rule conjI) apply (drule wa_abs_typing_u_elims(3); clarsimp) apply (rule conjI) apply (clarsimp simp: val_rel_simp) apply (rule conjI; clarsimp) apply (subst min_def) apply (clarsimp simp: not_le) done end (* of context *) end
The syntax or format of the registry entry is incorrect. Check the registry settings and compare the registry for this extension to other extensions in the registry. To work around this problem, follow these steps.
Recipes to make your own homemade pizza in the NuWave Oven. Whether a small flatbread, 7β€³ or 12β€³. Low carb or not. Easy recipes for them all are here. How to heat Cordon Blue Raw Stuffed Chicken Breasts in the NuWave Oven.
library(caret) library(randomForest) args <- commandArgs(TRUE) trainingDataDir <- "sensor-data" trainingFile <- paste(trainingDataDir, "training.csv", sep = "/") testingFile <- paste(trainingDataDir, "testing.csv", sep = "/") trainingFileUrl <- args[1] testingFileUrl <- args[2] # Number of columns expected in the CSV file numColumns <- 160 # Cross validation ratio for training data trainTestRatio <- 0.75 # Column to start training/testing. By default this skips columns 1..7 startColumn <- 8 if(length(args) < 2) { stop("Please supply training CSV URL as first command argument & testing CSV as second command argument.") } if (!file.exists(trainingDataDir)) { # Create sensor-data directory dir.create(trainingDataDir) } if (!file.exists(trainingFile) || !file.exists(testingFile)) { # Download training & testing data print(paste("Downloading training file:", trainingFileUrl)) print(paste("Downloading testing file:", testingFileUrl)) download.file(trainingFileUrl, destfile = trainingFile) download.file(testingFileUrl, destfile = testingFile) } if (dim(read.csv(trainingFile))[2] != numColumns || dim(read.csv(testingFile))[2] != numColumns) { stop(paste(numColumns, " columns must be present in training and testing CSV")) } # Load the files trainingRaw <- read.csv(trainingFile, na.strings = c("NA", "")) testingRaw <- read.csv(testingFile, na.strings = c("NA", "")) # Remove empty columns trainingEmpty <- apply(trainingRaw, 2, function(x) { sum(is.na(x)) }) trainingProcessed <- trainingRaw[,which(trainingEmpty == 0)] trainingProcessed <- trainingProcessed[startColumn:length(trainingProcessed)] testingEmpty <- apply(testingRaw, 2, function(x) { sum(is.na(x)) }) testingProcessed <- testingRaw[,which(testingEmpty == 0)] testingProcessed <- testingProcessed[startColumn:length(testingProcessed)] # Partition training set trainingPartition <- createDataPartition(y = trainingProcessed$classe, p = trainTestRatio, list = FALSE) training <- trainingProcessed[trainingPartition,] testing <- trainingProcessed[-trainingPartition,] # Train the model with randomForest, y = classe model <- randomForest(classe ~ ., data = training) # Time for cross validation... crossValidationPrediction <- predict(model, testing) confMatrix <- confusionMatrix(testing$classe, crossValidationPrediction) print(paste("======== START CROSS VALIDATION ACCURACY ========")) print(confMatrix) print(paste("======== END CROSS VALIDATION ACCURACY ========")) # Time to test prediction <- predict(model, testingProcessed) # Output results print(paste("======== START PREDICTIONS ========")) prediction print(paste("======== END PREDICTIONS ========"))
> module Rel.TotalPreorderOperations > import Rel.TotalPreorder > %default total > %access public export > {- > ||| R > R : {A : Type} -> {R : A -> A -> Type} -> TotalPreorder R -> (A -> A -> Type) > R (MkTotalPreorder R _ _ _) = R > -} > ||| reflexive > reflexive : {A : Type} -> {R : A -> A -> Type} -> > TotalPreorder R -> > (x : A) -> R x x > reflexive (MkTotalPreorder _ reflexive _ _) = reflexive > ||| transitive > transitive : {A : Type} -> {R : A -> A -> Type} -> > TotalPreorder R -> > (x : A) -> (y : A) -> (z : A) -> R x y -> R y z -> R x z > transitive (MkTotalPreorder _ _ transitive _) = transitive > ||| totalPre > totalPre : {A : Type} -> {R : A -> A -> Type} -> > TotalPreorder R -> > (x : A) -> (y : A) -> Either (R x y) (R y x) > totalPre (MkTotalPreorder _ _ _ totalPre) = totalPre > ||| > extendRight : {A, B : Type} -> > (A -> A -> Type) -> ((A, B) -> (A, B) -> Type) > extendRight R = \ x => \ y => R (fst x) (fst y) > ||| |extendRight| preserves total preorders > extendRightLemma : {A, B : Type} -> {R : A -> A -> Type} -> > TotalPreorder R -> TotalPreorder (extendRight {A} {B} R) > extendRightLemma {A} {B} {R} (MkTotalPreorder R reflexiveR transitiveR totalR) = > MkTotalPreorder S reflexiveS transitiveS totalS where > S : (A, B) -> (A, B) -> Type > S = extendRight R > reflexiveS : (x : (A, B)) -> S x x > reflexiveS = \ x => reflexiveR (fst x) > transitiveS : (x : (A, B)) -> (y : (A, B)) -> (z : (A, B)) -> S x y -> S y z -> S x z > transitiveS = \ x => \ y => \ z => \ xRy => \ yRz => transitiveR (fst x) (fst y) (fst z) xRy yRz > totalS : (x : (A, B)) -> (y : (A, B)) -> Either (S x y) (S y x) > totalS = \ x => \ y => totalR (fst x) (fst y) > ||| > extendLeft : {A, B : Type} -> > (B -> B -> Type) -> ((A, B) -> (A, B) -> Type) > extendLeft R = \ x => \ y => R (snd x) (snd y) > ||| |extendRight| preserves total preorders > extendLeftLemma : {A, B : Type} -> {R : B -> B -> Type} -> > TotalPreorder R -> TotalPreorder (extendLeft {A} {B} R) > extendLeftLemma {A} {B} {R} (MkTotalPreorder R reflexiveR transitiveR totalR) = > MkTotalPreorder S reflexiveS transitiveS totalS where > S : (A, B) -> (A, B) -> Type > S = extendLeft R > reflexiveS : (x : (A, B)) -> S x x > reflexiveS = \ x => reflexiveR (snd x) > transitiveS : (x : (A, B)) -> (y : (A, B)) -> (z : (A, B)) -> S x y -> S y z -> S x z > transitiveS = \ x => \ y => \ z => \ xRy => \ yRz => transitiveR (snd x) (snd y) (snd z) xRy yRz > totalS : (x : (A, B)) -> (y : (A, B)) -> Either (S x y) (S y x) > totalS = \ x => \ y => totalR (snd x) (snd y) > {- > ||| R > R : {A : Type} -> TotalPreorder A -> (A -> A -> Type) > R (MkTotalPreorder R _ _ _) = R > ||| reflexive > reflexive : {A : Type} -> > (tp : TotalPreorder A) -> > (x : A) -> (R tp) x x > reflexive (MkTotalPreorder _ reflexive _ _) = reflexive > ||| transitive > transitive : {A : Type} -> > (tp : TotalPreorder A) -> > (x : A) -> (y : A) -> (z : A) -> (R tp) x y -> (R tp) y z -> (R tp) x z > transitive (MkTotalPreorder _ _ transitive _) = transitive > ||| totalPre > totalPre : {A : Type} -> > (tp : TotalPreorder A) -> > (x : A) -> (y : A) -> Either ((R tp) x y) ((R tp) y x) > totalPre (MkTotalPreorder _ _ _ totalPre) = totalPre > ||| Total preorders on |A| induce total preorders on |(A, B)| > fromTotalPreorder1 : {A, B : Type} -> TotalPreorder A -> TotalPreorder (A, B) > fromTotalPreorder1 (MkTotalPreorder R reflexive transitive totalPre) = > MkTotalPreorder (\ x => \ y => R (fst x) (fst y)) > (\ x => reflexive (fst x)) > (\ x => \ y => \ z => \ xRy => \ yRz => transitive (fst x) (fst y) (fst z) xRy yRz) > (\ x => \ y => totalPre (fst x) (fst y)) > from2 : {A, B : Type} -> (B -> B -> Type) -> (A, B) -> (A, B) -> Type > from2 R x y = R (snd x) (snd y) > ||| Total preorders on |B| induce total preorders on |(A, B)| > fromTotalPreorder2 : {A, B : Type} -> TotalPreorder B -> TotalPreorder (A, B) > fromTotalPreorder2 to = > MkTotalPreorder (from2 (R to)) > (\ x => reflexive to (snd x)) > (\ x => \ y => \ z => \ xRy => \ yRz => transitive to (snd x) (snd y) (snd z) xRy yRz) > (\ x => \ y => totalPre to (snd x) (snd y)) > ---}
main : IO () main = putStr "Hello, World!"
How long does it take the flu to evade a vaccine? With all the recent Presidential attention to the threat from the H5N1 Avian Flu, and the many billions now earmarked for stockpiling vaccines and drugs, it seems like a good idea to ask on what time scale the virus might be able to evade these countermeasures. Vaccination is of particular interest, as it is regarded as by far the best tool to combat viral infection at the population level. Genomic analyses of H5N1 isolates from birds and humans showed 2 distinct clades with a nonoverlapping geographic distribution. All the viral genes were of avian influenza origin, which indicates absence of reassortment with human influenza viruses. Genetic and antigenic analyses have shown that, compared to previous H5N1 isolates, 2004-2005 isolates share several amino acid changes that modulate antigenicity and perhaps other biological function. Furthermore, our molecular analysis of the HA from isolates collected in 2005 suggests that several amino acids located near the receptor-binding site are undergoing change, some of which may affect antigenicity or transmisibility. Despite the recent "Isolation of drug-resistant H5N1 virus," (Nature, 20 October 2005), the WHO Global Influenza team determined that recent isolates are "sensitive to 2 neuraminidase inhibitors that are recommended for prophylactic or therapeutic intervention against human infections." So obviously the specific details of which viral isolate one is working with determine its sensitivity to drugs. In the case of the drug-resistant strain, it was isolated in February 2005 from a Vietnamese girl who may have contracted the virus while she cared for her brother. Human-to-human transmission is supported by the girl's lack of contact with poultry and the fact that the neuraminidase gene from virus isolated from the girl was virtually identical to that isolated from her brother. Thus there are evidently drug resistant strains running around in the wild. As far as I can tell, it just isn't yet clear how fast drug-resistance traits can spread. There is now at least a little data about how long it takes a particular viral strain to find work-arounds for vaccines. A recent initial effort to sequence many flu strains in parallel indicates that mutations that provide ways around vaccines can rapidly dominate a population of flu viruses. Perhaps the most dramatic finding in our data is the discovery of an epidemiologically significant reassortment that explains the appearance, during the 2003-2004 season, of the 'Fujian/411/2002'-like strain, for which the existing vaccine had limited effectiveness. ...Phylogenetic analysis of 156 H3N2 genomes from our project revealed the clear presence of multiple, distinct clades circulating in the population. Through a reassortment event, a minor clade provided the haemagglutinin gene that later became part of the dominant strain after the 2002-2003 season. This finding illustrates not only that the influenza virus population contains multiple lineages at any given time, but also that alternate, minor lineages can contribute genetic variation to the dominant lineage, resulting in epidemiologically significant, antigenically novel strains. It is worth emphasizing that our sequence-based sampling approach--in contrast to traditional serologically based sampling--will reveal co-circulating strains even before they become antigenically novel. In other words, the authors assert that amongst viruses that we give the same name there is considerable variation that may be hard to distinguish using traditional techniques. Sequencing the genomes of many isolates can provide a map of how a population of viruses is changing in response to vaccines. Ghedin, et al., note that their work demonstrates significant change of the dominant flu strain even within the 2003-2004 flu season. That variation appeared to originate and then dominate the population of viruses within 12 months. Which brings me to the core of this post, namely that we now have real-world data demonstrating that flu viruses can escape vaccines in less than a year, far shorter than the time it takes to produce significant quantities of effective vaccines. It is important to note that this is a different problem than producing a new vaccine for new annual flu strains every year. If a pandemic strain emerges, our problem is not planning ahead just far enough to deploy a vaccine for next year's strain, but rather to combat a strain already killing people worldwide. It took most of a year for the CDC and Sanofi to come up with a hypothetical H5N1 vaccine, and the new National Strategy for Pandemic Influenza contains the expectation of years to accumulate enough vaccine to be useful for large populations. Never mind that the existing whole virus vaccine may not be effective against a pandemic strain. The fact that the minor Fujian-like clade has donated its HA to the previously dominant strain rather than itself becoming the dominant circulating virus indicates that there may be important amino acid co-substitutions in the other proteins essential for viral fitness. ...Even within a geographically constrained set of isolates, we have found surprising genetic diversity, indicating that the reservoir of influenza A strains in the human population -- and the concomitant potential for segment exchange between strains -- may be greater than was previously suspected. We cannot think of the H5N1, or any other strain, as either a clonal population experiencing selection or as a bunch of individuals producing descendants that may accumulate mutations leading to a pandemic strain. Rather, flu viruses exists as elements of a population that appear to be constantly innovating and trading parts. This is a critical distinction, particularly in light of rapid human and avian intercontinental travel. Not only have we now learned that there is greater variation in any given set of geographically linked isolates, but because of human travel we can expect all kinds of novel parts to show up in populations that were otherwise isolated and appeared to be of no immediate threat. The Ghedin paper doesn't necessarily teach us directly about the evolution of pandemic flu strains, but it does suggest our current plan for pandemic vaccination is not well suited for the problem at hand. After studying synthetic vaccines for Bio-ERA, amongst other clients, I think DNA vaccines are the best bet for rapid response on a time scale shorter than flu strains seem to evolve. I've a draft paper on synthetic vaccines in for consideration at Biosecurity and Bioterrorism, and will shortly embark on another paper specifically about distributed manufacture of DNA vaccines. PowderMed is waiting for publication of their (already accepted) first paper on their plasmid vaccine for the annual flu and will be starting trials of an H5N1 DNA vaccine early next year. Unfortunately, it seems the folks in DC aren't taking this technology seriously, and instead blowing billions on developing cell culture production of whole virus vaccines. Even the folks who manufacture vaccines in cell culture acknowledge this will only cut a month or two off the response time.
module Main import Types import Lib ---Testcase calculateDeltas--PASS main: IO() main = do let thetas = (0, 0) let alpha = 0.3 let trainingset = [(0.0,50.0), (1.0,60.0), (2.0,70.0)] let iterations = 1 print $ show $ linearRegression thetas alpha trainingset iterations --Results for the test -50.0 --Testcase adjustDeltas -- PASS --main: IO() --main = do -- let deltas = [6.0, 5.2] -- let examples = [(7.0,50.0), (2.0,3.0)] -- print $ adjustDeltas deltas examples
module qmckl_probes_f interface logical(c_bool) function qmckl_probe & (testName, varName, val) & bind(C, name="qmckl_probe_f") use, intrinsic :: iso_c_binding import implicit none character(C_CHAR), dimension(*) :: testName character(C_CHAR), dimension(*) :: varName real(C_DOUBLE) :: val end function qmckl_probe logical(c_bool) function qmckl_probe_check & (testName, varName, val, expectedValue, accuracyTarget) & bind(C, name="qmckl_probe_check_f") use, intrinsic :: iso_c_binding import implicit none character(C_CHAR), dimension(*) :: testName character(C_CHAR), dimension(*) :: varName real(C_DOUBLE) :: val real(C_DOUBLE) :: expectedValue real(C_DOUBLE) :: accuracyTarget end function qmckl_probe_check logical(c_bool) function qmckl_probe_check_relative & (testName, varName, val, expectedValue, accuracyTarget) & bind(C, name="qmckl_probe_check_relative_f") use, intrinsic :: iso_c_binding import implicit none character(C_CHAR), dimension(*) :: testName character(C_CHAR), dimension(*) :: varName real(C_DOUBLE) :: val real(C_DOUBLE) :: expectedValue real(C_DOUBLE) :: accuracyTarget end function qmckl_probe_check_relative end interface end module qmckl_probes_f
//================================================================================================== /*! @file @copyright 2016 NumScale SAS Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ //================================================================================================== #ifndef BOOST_SIMD_FUNCTION_DIV_HPP_INCLUDED #define BOOST_SIMD_FUNCTION_DIV_HPP_INCLUDED #if defined(DOXYGEN_ONLY) namespace boost { namespace simd { /*! @ingroup group-operator This function object computes the quotient of the two parameters of the same type with or without option. @par Header <boost/simd/function/div.hpp> @par Notes For any value @c x and @c y of same type `div({option, }x, y)` returns the quotient of @c x by @c y respecting to the option specified. With no option this function is equivalent to `divides(x, y)` (See @ref divides.) Options may be @ref ceil, @ref floor, @ref fix, @ref round, @ref nearbyint (in the namespace booost::simd) and provides the same result as if the function object whose option is the name was applied to the floating division of the parameters. @see divides, rec @par Example: @snippet div.cpp div @par Possible output: @snippet div.txt div **/ //@{ Value div(Option const&, Value const& x, Value const& y); Value div(Value const& x, Value const& y); //@} } } #endif #include <boost/simd/function/scalar/div.hpp> #include <boost/simd/function/simd/div.hpp> #endif
Require Import Coq.Classes.Morphisms. Require Import Fiat.Computation.Core. Global Instance ret_Proper_eq {A} : Proper (eq ==> eq) (ret (A:=A)). Proof. repeat intro; subst; reflexivity. Qed. Global Instance refine_Proper_eq_iff {A} : Proper (eq ==> eq ==> iff) (@refine A). Proof. repeat intro; subst; reflexivity. Qed. Global Instance refine_Proper_eq_impl {A} : Proper (eq ==> eq ==> Basics.impl) (@refine A) | 1. Proof. repeat (assumption || subst || intro). Qed. Global Instance refine_Proper_eq_flip_impl {A} : Proper (eq ==> eq ==> Basics.flip Basics.impl) (@refine A) | 1. Proof. repeat (assumption || subst || intro). Qed.
[GOAL] R : Type u₁ inst✝¹ : CommRing R p : β„• hp : Fact (Nat.Prime p) inst✝ : CharP R p n : β„• ⊒ (-1) (n + 1) ^ p = (-1) n [PROOFSTEP] simp_rw [← frobenius_def, Pi.neg_apply, Pi.one_apply, RingHom.map_neg, RingHom.map_one] [GOAL] R : Type u₁ inst✝¹ : CommSemiring R p : β„• hp : Fact (Nat.Prime p) inst✝ : CharP R p f : Ring.Perfection R p n : β„• ⊒ ↑(coeff R p (n + 1)) (f ^ p) = ↑(coeff R p n) f [PROOFSTEP] rw [RingHom.map_pow] [GOAL] R : Type u₁ inst✝¹ : CommSemiring R p : β„• hp : Fact (Nat.Prime p) inst✝ : CharP R p f : Ring.Perfection R p n : β„• ⊒ ↑(coeff R p (n + 1)) f ^ p = ↑(coeff R p n) f [PROOFSTEP] exact f.2 n [GOAL] R : Type u₁ inst✝¹ : CommSemiring R p : β„• hp : Fact (Nat.Prime p) inst✝ : CharP R p f : Ring.Perfection R p n : β„• ⊒ ↑(coeff R p (n + 1)) (↑(frobenius (Ring.Perfection R p) p) f) = ↑(coeff R p n) f [PROOFSTEP] apply coeff_pow_p f n [GOAL] R : Type u₁ inst✝¹ : CommSemiring R p : β„• hp : Fact (Nat.Prime p) inst✝ : CharP R p f : Ring.Perfection R p n m✝ m : β„• ih : ↑(coeff R p (n + m)) ((↑(frobenius (Ring.Perfection R p) p))^[m] f) = ↑(coeff R p n) f ⊒ ↑(coeff R p (n + Nat.succ m)) ((↑(frobenius (Ring.Perfection R p) p))^[Nat.succ m] f) = ↑(coeff R p n) f [PROOFSTEP] erw [Function.iterate_succ_apply', coeff_frobenius, ih] [GOAL] R : Type u₁ inst✝¹ : CommSemiring R p : β„• hp : Fact (Nat.Prime p) inst✝ : CharP R p x : Ring.Perfection R p n : β„• ⊒ ↑(coeff R p n) (↑(RingHom.comp (pthRoot R p) (frobenius (Ring.Perfection R p) p)) x) = ↑(coeff R p n) (↑(RingHom.id (Ring.Perfection R p)) x) [PROOFSTEP] rw [RingHom.comp_apply, RingHom.id_apply, coeff_pthRoot, coeff_frobenius] [GOAL] R : Type u₁ inst✝¹ : CommSemiring R p : β„• hp : Fact (Nat.Prime p) inst✝ : CharP R p x : Ring.Perfection R p n : β„• ⊒ ↑(coeff R p n) (↑(RingHom.comp (frobenius (Ring.Perfection R p) p) (pthRoot R p)) x) = ↑(coeff R p n) (↑(RingHom.id (Ring.Perfection R p)) x) [PROOFSTEP] rw [RingHom.comp_apply, RingHom.id_apply, RingHom.map_frobenius, coeff_pthRoot, ← @RingHom.map_frobenius (Ring.Perfection R p) _ R, coeff_frobenius] [GOAL] R : Type u₁ inst✝¹ : CommSemiring R p : β„• hp : Fact (Nat.Prime p) inst✝ : CharP R p f : Ring.Perfection R p n : β„• hfn : ↑(coeff R p n) f β‰  0 k✝ k : β„• ih : ↑(coeff R p (n + k)) f β‰  0 h : ↑(coeff R p (n + Nat.succ k)) f = 0 ⊒ ↑(coeff R p (n + k)) f = 0 [PROOFSTEP] erw [← coeff_pow_p, RingHom.map_pow, h, zero_pow hp.1.pos] [GOAL] R✝ : Type u₁ inst✝⁢ : CommSemiring R✝ p : β„• hp : Fact (Nat.Prime p) inst✝⁡ : CharP R✝ p R : Type u₁ inst✝⁴ : CommSemiring R inst✝³ : CharP R p inst✝² : PerfectRing R p S : Type uβ‚‚ inst✝¹ : CommSemiring S inst✝ : CharP S p f : R β†’+* S r : R n : β„• ⊒ (fun n => ↑f ((↑↑(RingEquiv.symm (frobeniusEquiv R p)))^[n] r)) (n + 1) ^ p = (fun n => ↑f ((↑↑(RingEquiv.symm (frobeniusEquiv R p)))^[n] r)) n [PROOFSTEP] erw [← f.map_pow, Function.iterate_succ_apply', frobeniusEquiv_symm_pow_p] [GOAL] R✝ : Type u₁ inst✝⁢ : CommSemiring R✝ p : β„• hp : Fact (Nat.Prime p) inst✝⁡ : CharP R✝ p R : Type u₁ inst✝⁴ : CommSemiring R inst✝³ : CharP R p inst✝² : PerfectRing R p S : Type uβ‚‚ inst✝¹ : CommSemiring S inst✝ : CharP S p f : R β†’+* Ring.Perfection S p r : R n : β„• ⊒ ↑(coeff S p 0) (↑f ((↑(RingEquiv.symm (frobeniusEquiv R p)))^[n] r)) = ↑(coeff S p n) (↑f r) [PROOFSTEP] rw [← coeff_iterate_frobenius _ 0 n, zero_add, ← RingHom.map_iterate_frobenius, Function.RightInverse.iterate (frobenius_apply_frobeniusEquiv_symm R p) n] [GOAL] R : Type u₁ inst✝³ : CommSemiring R p : β„• hp : Fact (Nat.Prime p) inst✝² : CharP R p S : Type uβ‚‚ inst✝¹ : CommSemiring S inst✝ : CharP S p Ο† : R β†’+* S f : Ring.Perfection R p n : β„• ⊒ (fun n => ↑φ (↑(coeff R p n) f)) (n + 1) ^ p = (fun n => ↑φ (↑(coeff R p n) f)) n [PROOFSTEP] rw [← Ο†.map_pow, coeff_pow_p'] [GOAL] p : β„• inst✝⁡ : Fact (Nat.Prime p) R : Type u₁ inst✝⁴ : CommSemiring R inst✝³ : CharP R p P : Type u₃ inst✝² : CommSemiring P inst✝¹ : CharP P p inst✝ : PerfectRing P p f : P β†’+* R g : P ≃+* Ring.Perfection R p hfg : ↑(Perfection.lift p P R) f = ↑g y : β„• β†’ R hy : βˆ€ (n : β„•), y (n + 1) ^ p = y n x : P hx : ↑g x = { val := y, property := hy } n : β„• ⊒ ↑(Perfection.coeff R p n) (↑(↑(Perfection.lift p P R) f) x) = ↑(Perfection.coeff R p n) { val := y, property := hy } [PROOFSTEP] simp [hfg, hx] [GOAL] p : β„• inst✝⁢ : Fact (Nat.Prime p) R : Type u₁ inst✝⁡ : CommSemiring R inst✝⁴ : CharP R p P : Type u₃ inst✝³ : CommSemiring P inst✝² : CharP P p inst✝¹ : PerfectRing P p inst✝ : PerfectRing R p f : β„• β†’ R hf : βˆ€ (n : β„•), f (n + 1) ^ p = f n n✝ n : β„• ih : (↑(RingEquiv.symm (frobeniusEquiv R p)))^[n] (f 0) = f n ⊒ (↑(RingEquiv.symm (frobeniusEquiv R p)))^[Nat.succ n] (f 0) ^ p = f (Nat.succ n) ^ p [PROOFSTEP] rw [Function.iterate_succ_apply', frobeniusEquiv_symm_pow_p, ih, hf] [GOAL] p : β„• inst✝¹¹ : Fact (Nat.Prime p) R : Type u₁ inst✝¹⁰ : CommSemiring R inst✝⁹ : CharP R p P✝ : Type u₃ inst✝⁸ : CommSemiring P✝ inst✝⁷ : CharP P✝ p inst✝⁢ : PerfectRing P✝ p inst✝⁡ : PerfectRing R p S : Type uβ‚‚ inst✝⁴ : CommSemiring S inst✝³ : CharP S p P : Type u₃ inst✝² : CommSemiring P inst✝¹ : CharP P p inst✝ : PerfectRing P p Ο€ : P β†’+* S m : PerfectionMap p Ο€ f : R β†’+* S ⊒ (fun f => RingHom.comp Ο€ f) ((fun f => RingHom.comp (↑(RingEquiv.symm (equiv m))) (↑(Perfection.lift p R S) f)) f) = f [PROOFSTEP] simp_rw [← RingHom.comp_assoc, comp_symm_equiv'] [GOAL] p : β„• inst✝¹¹ : Fact (Nat.Prime p) R : Type u₁ inst✝¹⁰ : CommSemiring R inst✝⁹ : CharP R p P✝ : Type u₃ inst✝⁸ : CommSemiring P✝ inst✝⁷ : CharP P✝ p inst✝⁢ : PerfectRing P✝ p inst✝⁡ : PerfectRing R p S : Type uβ‚‚ inst✝⁴ : CommSemiring S inst✝³ : CharP S p P : Type u₃ inst✝² : CommSemiring P inst✝¹ : CharP P p inst✝ : PerfectRing P p Ο€ : P β†’+* S m : PerfectionMap p Ο€ f : R β†’+* S ⊒ RingHom.comp (Perfection.coeff S p 0) (↑(Perfection.lift p R S) f) = f [PROOFSTEP] exact (Perfection.lift p R S).symm_apply_apply f [GOAL] p : β„• inst✝¹¹ : Fact (Nat.Prime p) R : Type u₁ inst✝¹⁰ : CommSemiring R inst✝⁹ : CharP R p P✝ : Type u₃ inst✝⁸ : CommSemiring P✝ inst✝⁷ : CharP P✝ p inst✝⁢ : PerfectRing P✝ p inst✝⁡ : PerfectRing R p S : Type uβ‚‚ inst✝⁴ : CommSemiring S inst✝³ : CharP S p P : Type u₃ inst✝² : CommSemiring P inst✝¹ : CharP P p inst✝ : PerfectRing P p Ο€ : P β†’+* S m : PerfectionMap p Ο€ f : R β†’+* P ⊒ (fun f => RingHom.comp (↑(RingEquiv.symm (equiv m))) (↑(Perfection.lift p R S) f)) ((fun f => RingHom.comp Ο€ f) f) = f [PROOFSTEP] exact RingHom.ext fun x => m.equiv.injective <| (m.equiv.apply_symm_apply _).trans <| show Perfection.lift p R S (Ο€.comp f) x = RingHom.comp (↑m.equiv) f x from RingHom.ext_iff.1 (by rw [Equiv.apply_eq_iff_eq_symm_apply]; rfl) _ [GOAL] p : β„• inst✝¹¹ : Fact (Nat.Prime p) R : Type u₁ inst✝¹⁰ : CommSemiring R inst✝⁹ : CharP R p P✝ : Type u₃ inst✝⁸ : CommSemiring P✝ inst✝⁷ : CharP P✝ p inst✝⁢ : PerfectRing P✝ p inst✝⁡ : PerfectRing R p S : Type uβ‚‚ inst✝⁴ : CommSemiring S inst✝³ : CharP S p P : Type u₃ inst✝² : CommSemiring P inst✝¹ : CharP P p inst✝ : PerfectRing P p Ο€ : P β†’+* S m : PerfectionMap p Ο€ f : R β†’+* P x : R ⊒ ↑(Perfection.lift p R S) (RingHom.comp Ο€ f) = RingHom.comp (↑(equiv m)) f [PROOFSTEP] rw [Equiv.apply_eq_iff_eq_symm_apply] [GOAL] p : β„• inst✝¹¹ : Fact (Nat.Prime p) R : Type u₁ inst✝¹⁰ : CommSemiring R inst✝⁹ : CharP R p P✝ : Type u₃ inst✝⁸ : CommSemiring P✝ inst✝⁷ : CharP P✝ p inst✝⁢ : PerfectRing P✝ p inst✝⁡ : PerfectRing R p S : Type uβ‚‚ inst✝⁴ : CommSemiring S inst✝³ : CharP S p P : Type u₃ inst✝² : CommSemiring P inst✝¹ : CharP P p inst✝ : PerfectRing P p Ο€ : P β†’+* S m : PerfectionMap p Ο€ f : R β†’+* P x : R ⊒ RingHom.comp Ο€ f = ↑(Perfection.lift p R S).symm (RingHom.comp (↑(equiv m)) f) [PROOFSTEP] rfl [GOAL] p : β„• inst✝¹⁰ : Fact (Nat.Prime p) R : Type u₁ inst✝⁹ : CommSemiring R inst✝⁸ : CharP R p P : Type u₃ inst✝⁷ : CommSemiring P inst✝⁢ : CharP P p inst✝⁡ : PerfectRing P p S : Type uβ‚‚ inst✝⁴ : CommSemiring S inst✝³ : CharP S p Q : Type uβ‚„ inst✝² : CommSemiring Q inst✝¹ : CharP Q p inst✝ : PerfectRing Q p Ο† : R β†’+* S f : Ring.Perfection R p ⊒ ↑(Perfection.coeff S p 0) (↑(map p (_ : PerfectionMap p (Perfection.coeff R p 0)) (_ : PerfectionMap p (Perfection.coeff S p 0)) Ο†) f) = ↑(Perfection.coeff S p 0) (↑(Perfection.map p Ο†) f) [PROOFSTEP] rw [map_map, Perfection.coeff_map] [GOAL] K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) x : O hx : ↑(Ideal.Quotient.mk (Ideal.span {↑p})) x β‰  0 ⊒ preVal K v O hv p (↑(Ideal.Quotient.mk (Ideal.span {↑p})) x) = ↑v (↑(algebraMap O K) x) [PROOFSTEP] obtain ⟨r, hr⟩ : βˆƒ (a : O), a * (p : O) = (Quotient.mk'' x).out' - x := Ideal.mem_span_singleton'.1 <| Ideal.Quotient.eq.1 <| Quotient.sound' <| Quotient.mk_out' _ [GOAL] case intro K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) x : O hx : ↑(Ideal.Quotient.mk (Ideal.span {↑p})) x β‰  0 r : O hr : r * ↑p = Quotient.out' (Quotient.mk'' x) - x ⊒ preVal K v O hv p (↑(Ideal.Quotient.mk (Ideal.span {↑p})) x) = ↑v (↑(algebraMap O K) x) [PROOFSTEP] refine' (if_neg hx).trans (v.map_eq_of_sub_lt <| lt_of_not_le _) [GOAL] case intro K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) x : O hx : ↑(Ideal.Quotient.mk (Ideal.span {↑p})) x β‰  0 r : O hr : r * ↑p = Quotient.out' (Quotient.mk'' x) - x ⊒ ¬↑v (↑(algebraMap O K) x) ≀ ↑v (↑(algebraMap O K) (Quotient.out' (↑(Ideal.Quotient.mk (Ideal.span {↑p})) x)) - ↑(algebraMap O K) x) [PROOFSTEP] erw [← RingHom.map_sub, ← hr, hv.le_iff_dvd] [GOAL] case intro K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) x : O hx : ↑(Ideal.Quotient.mk (Ideal.span {↑p})) x β‰  0 r : O hr : r * ↑p = Quotient.out' (Quotient.mk'' x) - x ⊒ Β¬r * ↑p ∣ x [PROOFSTEP] exact fun hprx => hx (Ideal.Quotient.eq_zero_iff_mem.2 <| Ideal.mem_span_singleton.2 <| dvd_of_mul_left_dvd hprx) [GOAL] K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) x y : ModP K v O hv p hxy0 : x * y β‰  0 ⊒ preVal K v O hv p (x * y) = preVal K v O hv p x * preVal K v O hv p y [PROOFSTEP] have hx0 : x β‰  0 := mt (by rintro rfl; rw [zero_mul]) hxy0 [GOAL] K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) x y : ModP K v O hv p hxy0 : x * y β‰  0 ⊒ x = 0 β†’ x * y = 0 [PROOFSTEP] rintro rfl [GOAL] K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) y : ModP K v O hv p hxy0 : 0 * y β‰  0 ⊒ 0 * y = 0 [PROOFSTEP] rw [zero_mul] [GOAL] K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) x y : ModP K v O hv p hxy0 : x * y β‰  0 hx0 : x β‰  0 ⊒ preVal K v O hv p (x * y) = preVal K v O hv p x * preVal K v O hv p y [PROOFSTEP] have hy0 : y β‰  0 := mt (by rintro rfl; rw [mul_zero]) hxy0 [GOAL] K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) x y : ModP K v O hv p hxy0 : x * y β‰  0 hx0 : x β‰  0 ⊒ y = 0 β†’ x * y = 0 [PROOFSTEP] rintro rfl [GOAL] K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) x : ModP K v O hv p hx0 : x β‰  0 hxy0 : x * 0 β‰  0 ⊒ x * 0 = 0 [PROOFSTEP] rw [mul_zero] [GOAL] K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) x y : ModP K v O hv p hxy0 : x * y β‰  0 hx0 : x β‰  0 hy0 : y β‰  0 ⊒ preVal K v O hv p (x * y) = preVal K v O hv p x * preVal K v O hv p y [PROOFSTEP] obtain ⟨r, rfl⟩ := Ideal.Quotient.mk_surjective x [GOAL] case intro K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) y : ModP K v O hv p hy0 : y β‰  0 r : O hxy0 : ↑(Ideal.Quotient.mk (Ideal.span {↑p})) r * y β‰  0 hx0 : ↑(Ideal.Quotient.mk (Ideal.span {↑p})) r β‰  0 ⊒ preVal K v O hv p (↑(Ideal.Quotient.mk (Ideal.span {↑p})) r * y) = preVal K v O hv p (↑(Ideal.Quotient.mk (Ideal.span {↑p})) r) * preVal K v O hv p y [PROOFSTEP] obtain ⟨s, rfl⟩ := Ideal.Quotient.mk_surjective y [GOAL] case intro.intro K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) r : O hx0 : ↑(Ideal.Quotient.mk (Ideal.span {↑p})) r β‰  0 s : O hy0 : ↑(Ideal.Quotient.mk (Ideal.span {↑p})) s β‰  0 hxy0 : ↑(Ideal.Quotient.mk (Ideal.span {↑p})) r * ↑(Ideal.Quotient.mk (Ideal.span {↑p})) s β‰  0 ⊒ preVal K v O hv p (↑(Ideal.Quotient.mk (Ideal.span {↑p})) r * ↑(Ideal.Quotient.mk (Ideal.span {↑p})) s) = preVal K v O hv p (↑(Ideal.Quotient.mk (Ideal.span {↑p})) r) * preVal K v O hv p (↑(Ideal.Quotient.mk (Ideal.span {↑p})) s) [PROOFSTEP] rw [← RingHom.map_mul] at hxy0 ⊒ [GOAL] case intro.intro K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) r : O hx0 : ↑(Ideal.Quotient.mk (Ideal.span {↑p})) r β‰  0 s : O hy0 : ↑(Ideal.Quotient.mk (Ideal.span {↑p})) s β‰  0 hxy0 : ↑(Ideal.Quotient.mk (Ideal.span {↑p})) (r * s) β‰  0 ⊒ preVal K v O hv p (↑(Ideal.Quotient.mk (Ideal.span {↑p})) (r * s)) = preVal K v O hv p (↑(Ideal.Quotient.mk (Ideal.span {↑p})) r) * preVal K v O hv p (↑(Ideal.Quotient.mk (Ideal.span {↑p})) s) [PROOFSTEP] rw [preVal_mk hx0, preVal_mk hy0, preVal_mk hxy0, RingHom.map_mul, v.map_mul] [GOAL] K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) x y : ModP K v O hv p ⊒ preVal K v O hv p (x + y) ≀ max (preVal K v O hv p x) (preVal K v O hv p y) [PROOFSTEP] by_cases hx0 : x = 0 [GOAL] case pos K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) x y : ModP K v O hv p hx0 : x = 0 ⊒ preVal K v O hv p (x + y) ≀ max (preVal K v O hv p x) (preVal K v O hv p y) [PROOFSTEP] rw [hx0, zero_add] [GOAL] case pos K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) x y : ModP K v O hv p hx0 : x = 0 ⊒ preVal K v O hv p y ≀ max (preVal K v O hv p 0) (preVal K v O hv p y) [PROOFSTEP] exact le_max_right _ _ [GOAL] case neg K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) x y : ModP K v O hv p hx0 : Β¬x = 0 ⊒ preVal K v O hv p (x + y) ≀ max (preVal K v O hv p x) (preVal K v O hv p y) [PROOFSTEP] by_cases hy0 : y = 0 [GOAL] case pos K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) x y : ModP K v O hv p hx0 : Β¬x = 0 hy0 : y = 0 ⊒ preVal K v O hv p (x + y) ≀ max (preVal K v O hv p x) (preVal K v O hv p y) [PROOFSTEP] rw [hy0, add_zero] [GOAL] case pos K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) x y : ModP K v O hv p hx0 : Β¬x = 0 hy0 : y = 0 ⊒ preVal K v O hv p x ≀ max (preVal K v O hv p x) (preVal K v O hv p 0) [PROOFSTEP] exact le_max_left _ _ [GOAL] case neg K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) x y : ModP K v O hv p hx0 : Β¬x = 0 hy0 : Β¬y = 0 ⊒ preVal K v O hv p (x + y) ≀ max (preVal K v O hv p x) (preVal K v O hv p y) [PROOFSTEP] by_cases hxy0 : x + y = 0 [GOAL] case pos K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) x y : ModP K v O hv p hx0 : Β¬x = 0 hy0 : Β¬y = 0 hxy0 : x + y = 0 ⊒ preVal K v O hv p (x + y) ≀ max (preVal K v O hv p x) (preVal K v O hv p y) [PROOFSTEP] rw [hxy0, preVal_zero] [GOAL] case pos K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) x y : ModP K v O hv p hx0 : Β¬x = 0 hy0 : Β¬y = 0 hxy0 : x + y = 0 ⊒ 0 ≀ max (preVal K v O hv p x) (preVal K v O hv p y) [PROOFSTEP] exact zero_le _ [GOAL] case neg K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) x y : ModP K v O hv p hx0 : Β¬x = 0 hy0 : Β¬y = 0 hxy0 : Β¬x + y = 0 ⊒ preVal K v O hv p (x + y) ≀ max (preVal K v O hv p x) (preVal K v O hv p y) [PROOFSTEP] obtain ⟨r, rfl⟩ := Ideal.Quotient.mk_surjective x [GOAL] case neg.intro K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) y : ModP K v O hv p hy0 : Β¬y = 0 r : O hx0 : ¬↑(Ideal.Quotient.mk (Ideal.span {↑p})) r = 0 hxy0 : ¬↑(Ideal.Quotient.mk (Ideal.span {↑p})) r + y = 0 ⊒ preVal K v O hv p (↑(Ideal.Quotient.mk (Ideal.span {↑p})) r + y) ≀ max (preVal K v O hv p (↑(Ideal.Quotient.mk (Ideal.span {↑p})) r)) (preVal K v O hv p y) [PROOFSTEP] obtain ⟨s, rfl⟩ := Ideal.Quotient.mk_surjective y [GOAL] case neg.intro.intro K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) r : O hx0 : ¬↑(Ideal.Quotient.mk (Ideal.span {↑p})) r = 0 s : O hy0 : ¬↑(Ideal.Quotient.mk (Ideal.span {↑p})) s = 0 hxy0 : ¬↑(Ideal.Quotient.mk (Ideal.span {↑p})) r + ↑(Ideal.Quotient.mk (Ideal.span {↑p})) s = 0 ⊒ preVal K v O hv p (↑(Ideal.Quotient.mk (Ideal.span {↑p})) r + ↑(Ideal.Quotient.mk (Ideal.span {↑p})) s) ≀ max (preVal K v O hv p (↑(Ideal.Quotient.mk (Ideal.span {↑p})) r)) (preVal K v O hv p (↑(Ideal.Quotient.mk (Ideal.span {↑p})) s)) [PROOFSTEP] rw [← RingHom.map_add] at hxy0 ⊒ [GOAL] case neg.intro.intro K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) r : O hx0 : ¬↑(Ideal.Quotient.mk (Ideal.span {↑p})) r = 0 s : O hy0 : ¬↑(Ideal.Quotient.mk (Ideal.span {↑p})) s = 0 hxy0 : ¬↑(Ideal.Quotient.mk (Ideal.span {↑p})) (r + s) = 0 ⊒ preVal K v O hv p (↑(Ideal.Quotient.mk (Ideal.span {↑p})) (r + s)) ≀ max (preVal K v O hv p (↑(Ideal.Quotient.mk (Ideal.span {↑p})) r)) (preVal K v O hv p (↑(Ideal.Quotient.mk (Ideal.span {↑p})) s)) [PROOFSTEP] rw [preVal_mk hx0, preVal_mk hy0, preVal_mk hxy0, RingHom.map_add] [GOAL] case neg.intro.intro K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) r : O hx0 : ¬↑(Ideal.Quotient.mk (Ideal.span {↑p})) r = 0 s : O hy0 : ¬↑(Ideal.Quotient.mk (Ideal.span {↑p})) s = 0 hxy0 : ¬↑(Ideal.Quotient.mk (Ideal.span {↑p})) (r + s) = 0 ⊒ ↑v (↑(algebraMap O K) r + ↑(algebraMap O K) s) ≀ max (↑v (↑(algebraMap O K) r)) (↑v (↑(algebraMap O K) s)) [PROOFSTEP] exact v.map_add _ _ [GOAL] K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) x : ModP K v O hv p ⊒ ↑v ↑p < preVal K v O hv p x ↔ x β‰  0 [PROOFSTEP] refine' ⟨fun h hx => by rw [hx, preVal_zero] at h ; exact not_lt_zero' h, fun h => lt_of_not_le fun hp => h _⟩ [GOAL] K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) x : ModP K v O hv p h : ↑v ↑p < preVal K v O hv p x hx : x = 0 ⊒ False [PROOFSTEP] rw [hx, preVal_zero] at h [GOAL] K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) x : ModP K v O hv p h : ↑v ↑p < 0 hx : x = 0 ⊒ False [PROOFSTEP] exact not_lt_zero' h [GOAL] K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp✝ : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) x : ModP K v O hv p h : x β‰  0 hp : preVal K v O hv p x ≀ ↑v ↑p ⊒ x = 0 [PROOFSTEP] obtain ⟨r, rfl⟩ := Ideal.Quotient.mk_surjective x [GOAL] case intro K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp✝ : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) r : O h : ↑(Ideal.Quotient.mk (Ideal.span {↑p})) r β‰  0 hp : preVal K v O hv p (↑(Ideal.Quotient.mk (Ideal.span {↑p})) r) ≀ ↑v ↑p ⊒ ↑(Ideal.Quotient.mk (Ideal.span {↑p})) r = 0 [PROOFSTEP] rw [preVal_mk h, ← map_natCast (algebraMap O K) p, hv.le_iff_dvd] at hp [GOAL] case intro K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp✝ : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) r : O h : ↑(Ideal.Quotient.mk (Ideal.span {↑p})) r β‰  0 hp : ↑p ∣ r ⊒ ↑(Ideal.Quotient.mk (Ideal.span {↑p})) r = 0 [PROOFSTEP] rw [Ideal.Quotient.eq_zero_iff_mem, Ideal.mem_span_singleton] [GOAL] case intro K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp✝ : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) r : O h : ↑(Ideal.Quotient.mk (Ideal.span {↑p})) r β‰  0 hp : ↑p ∣ r ⊒ ↑p ∣ r [PROOFSTEP] exact hp [GOAL] K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) x : ModP K v O hv p hvx : preVal K v O hv p x = 0 hx0 : x β‰  0 ⊒ False [PROOFSTEP] rw [← v_p_lt_preVal, hvx] at hx0 [GOAL] K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) x : ModP K v O hv p hvx : preVal K v O hv p x = 0 hx0 : ↑v ↑p < 0 ⊒ False [PROOFSTEP] exact not_lt_zero' hx0 [GOAL] K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) x : O ⊒ ↑v ↑p < ↑v (↑(algebraMap O K) x) ↔ ↑(Ideal.Quotient.mk (Ideal.span {↑p})) x β‰  0 [PROOFSTEP] rw [lt_iff_not_le, not_iff_not, ← map_natCast (algebraMap O K) p, hv.le_iff_dvd, Ideal.Quotient.eq_zero_iff_mem, Ideal.mem_span_singleton] [GOAL] K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) x y : ModP K v O hv p hx : x ^ p β‰  0 hy : y ^ p β‰  0 ⊒ x * y β‰  0 [PROOFSTEP] obtain ⟨r, rfl⟩ := Ideal.Quotient.mk_surjective x [GOAL] case intro K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) y : ModP K v O hv p hy : y ^ p β‰  0 r : O hx : ↑(Ideal.Quotient.mk (Ideal.span {↑p})) r ^ p β‰  0 ⊒ ↑(Ideal.Quotient.mk (Ideal.span {↑p})) r * y β‰  0 [PROOFSTEP] obtain ⟨s, rfl⟩ := Ideal.Quotient.mk_surjective y [GOAL] case intro.intro K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) r : O hx : ↑(Ideal.Quotient.mk (Ideal.span {↑p})) r ^ p β‰  0 s : O hy : ↑(Ideal.Quotient.mk (Ideal.span {↑p})) s ^ p β‰  0 ⊒ ↑(Ideal.Quotient.mk (Ideal.span {↑p})) r * ↑(Ideal.Quotient.mk (Ideal.span {↑p})) s β‰  0 [PROOFSTEP] have h1p : (0 : ℝ) < 1 / p := one_div_pos.2 (Nat.cast_pos.2 hp.1.pos) [GOAL] case intro.intro K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) r : O hx : ↑(Ideal.Quotient.mk (Ideal.span {↑p})) r ^ p β‰  0 s : O hy : ↑(Ideal.Quotient.mk (Ideal.span {↑p})) s ^ p β‰  0 h1p : 0 < 1 / ↑p ⊒ ↑(Ideal.Quotient.mk (Ideal.span {↑p})) r * ↑(Ideal.Quotient.mk (Ideal.span {↑p})) s β‰  0 [PROOFSTEP] rw [← RingHom.map_mul] [GOAL] case intro.intro K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) r : O hx : ↑(Ideal.Quotient.mk (Ideal.span {↑p})) r ^ p β‰  0 s : O hy : ↑(Ideal.Quotient.mk (Ideal.span {↑p})) s ^ p β‰  0 h1p : 0 < 1 / ↑p ⊒ ↑(Ideal.Quotient.mk (Ideal.span {↑p})) (r * s) β‰  0 [PROOFSTEP] rw [← RingHom.map_pow] at hx hy [GOAL] case intro.intro K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) r : O hx : ↑(Ideal.Quotient.mk (Ideal.span {↑p})) (r ^ p) β‰  0 s : O hy : ↑(Ideal.Quotient.mk (Ideal.span {↑p})) (s ^ p) β‰  0 h1p : 0 < 1 / ↑p ⊒ ↑(Ideal.Quotient.mk (Ideal.span {↑p})) (r * s) β‰  0 [PROOFSTEP] rw [← v_p_lt_val hv] at hx hy ⊒ [GOAL] case intro.intro K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) r : O hx : ↑v ↑p < ↑v (↑(algebraMap O K) (r ^ p)) s : O hy : ↑v ↑p < ↑v (↑(algebraMap O K) (s ^ p)) h1p : 0 < 1 / ↑p ⊒ ↑v ↑p < ↑v (↑(algebraMap O K) (r * s)) [PROOFSTEP] rw [RingHom.map_pow, v.map_pow, ← rpow_lt_rpow_iff h1p, ← rpow_nat_cast, ← rpow_mul, mul_one_div_cancel (Nat.cast_ne_zero.2 hp.1.ne_zero : (p : ℝ) β‰  0), rpow_one] at hx hy [GOAL] case intro.intro K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) r : O hx : ↑v ↑p ^ (1 / ↑p) < ↑v (↑(algebraMap O K) r) s : O hy : ↑v ↑p ^ (1 / ↑p) < ↑v (↑(algebraMap O K) s) h1p : 0 < 1 / ↑p ⊒ ↑v ↑p < ↑v (↑(algebraMap O K) (r * s)) [PROOFSTEP] rw [RingHom.map_mul, v.map_mul] [GOAL] case intro.intro K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) r : O hx : ↑v ↑p ^ (1 / ↑p) < ↑v (↑(algebraMap O K) r) s : O hy : ↑v ↑p ^ (1 / ↑p) < ↑v (↑(algebraMap O K) s) h1p : 0 < 1 / ↑p ⊒ ↑v ↑p < ↑v (↑(algebraMap O K) r) * ↑v (↑(algebraMap O K) s) [PROOFSTEP] refine' lt_of_le_of_lt _ (mul_lt_mulβ‚€ hx hy) [GOAL] case intro.intro K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) r : O hx : ↑v ↑p ^ (1 / ↑p) < ↑v (↑(algebraMap O K) r) s : O hy : ↑v ↑p ^ (1 / ↑p) < ↑v (↑(algebraMap O K) s) h1p : 0 < 1 / ↑p ⊒ ↑v ↑p ≀ ↑v ↑p ^ (1 / ↑p) * ↑v ↑p ^ (1 / ↑p) [PROOFSTEP] by_cases hvp : v p = 0 [GOAL] case pos K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp✝ : Fact (↑v ↑p β‰  1) r : O hx : ↑v ↑p ^ (1 / ↑p) < ↑v (↑(algebraMap O K) r) s : O hy : ↑v ↑p ^ (1 / ↑p) < ↑v (↑(algebraMap O K) s) h1p : 0 < 1 / ↑p hvp : ↑v ↑p = 0 ⊒ ↑v ↑p ≀ ↑v ↑p ^ (1 / ↑p) * ↑v ↑p ^ (1 / ↑p) [PROOFSTEP] rw [hvp] [GOAL] case pos K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp✝ : Fact (↑v ↑p β‰  1) r : O hx : ↑v ↑p ^ (1 / ↑p) < ↑v (↑(algebraMap O K) r) s : O hy : ↑v ↑p ^ (1 / ↑p) < ↑v (↑(algebraMap O K) s) h1p : 0 < 1 / ↑p hvp : ↑v ↑p = 0 ⊒ 0 ≀ 0 ^ (1 / ↑p) * 0 ^ (1 / ↑p) [PROOFSTEP] exact zero_le _ [GOAL] case neg K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp✝ : Fact (↑v ↑p β‰  1) r : O hx : ↑v ↑p ^ (1 / ↑p) < ↑v (↑(algebraMap O K) r) s : O hy : ↑v ↑p ^ (1 / ↑p) < ↑v (↑(algebraMap O K) s) h1p : 0 < 1 / ↑p hvp : ¬↑v ↑p = 0 ⊒ ↑v ↑p ≀ ↑v ↑p ^ (1 / ↑p) * ↑v ↑p ^ (1 / ↑p) [PROOFSTEP] replace hvp := zero_lt_iff.2 hvp [GOAL] case neg K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp✝ : Fact (↑v ↑p β‰  1) r : O hx : ↑v ↑p ^ (1 / ↑p) < ↑v (↑(algebraMap O K) r) s : O hy : ↑v ↑p ^ (1 / ↑p) < ↑v (↑(algebraMap O K) s) h1p : 0 < 1 / ↑p hvp : 0 < ↑v ↑p ⊒ ↑v ↑p ≀ ↑v ↑p ^ (1 / ↑p) * ↑v ↑p ^ (1 / ↑p) [PROOFSTEP] conv_lhs => rw [← rpow_one (v p)] [GOAL] K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp✝ : Fact (↑v ↑p β‰  1) r : O hx : ↑v ↑p ^ (1 / ↑p) < ↑v (↑(algebraMap O K) r) s : O hy : ↑v ↑p ^ (1 / ↑p) < ↑v (↑(algebraMap O K) s) h1p : 0 < 1 / ↑p hvp : 0 < ↑v ↑p | ↑v ↑p [PROOFSTEP] rw [← rpow_one (v p)] [GOAL] K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp✝ : Fact (↑v ↑p β‰  1) r : O hx : ↑v ↑p ^ (1 / ↑p) < ↑v (↑(algebraMap O K) r) s : O hy : ↑v ↑p ^ (1 / ↑p) < ↑v (↑(algebraMap O K) s) h1p : 0 < 1 / ↑p hvp : 0 < ↑v ↑p | ↑v ↑p [PROOFSTEP] rw [← rpow_one (v p)] [GOAL] K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp✝ : Fact (↑v ↑p β‰  1) r : O hx : ↑v ↑p ^ (1 / ↑p) < ↑v (↑(algebraMap O K) r) s : O hy : ↑v ↑p ^ (1 / ↑p) < ↑v (↑(algebraMap O K) s) h1p : 0 < 1 / ↑p hvp : 0 < ↑v ↑p | ↑v ↑p [PROOFSTEP] rw [← rpow_one (v p)] [GOAL] case neg K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp✝ : Fact (↑v ↑p β‰  1) r : O hx : ↑v ↑p ^ (1 / ↑p) < ↑v (↑(algebraMap O K) r) s : O hy : ↑v ↑p ^ (1 / ↑p) < ↑v (↑(algebraMap O K) s) h1p : 0 < 1 / ↑p hvp : 0 < ↑v ↑p ⊒ ↑v ↑p ^ 1 ≀ ↑v ↑p ^ (1 / ↑p) * ↑v ↑p ^ (1 / ↑p) [PROOFSTEP] rw [← rpow_add (ne_of_gt hvp)] [GOAL] case neg K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp✝ : Fact (↑v ↑p β‰  1) r : O hx : ↑v ↑p ^ (1 / ↑p) < ↑v (↑(algebraMap O K) r) s : O hy : ↑v ↑p ^ (1 / ↑p) < ↑v (↑(algebraMap O K) s) h1p : 0 < 1 / ↑p hvp : 0 < ↑v ↑p ⊒ ↑v ↑p ^ 1 ≀ ↑v ↑p ^ (1 / ↑p + 1 / ↑p) [PROOFSTEP] refine' rpow_le_rpow_of_exponent_ge hvp (map_natCast (algebraMap O K) p β–Έ hv.2 _) _ [GOAL] case neg K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp✝ : Fact (↑v ↑p β‰  1) r : O hx : ↑v ↑p ^ (1 / ↑p) < ↑v (↑(algebraMap O K) r) s : O hy : ↑v ↑p ^ (1 / ↑p) < ↑v (↑(algebraMap O K) s) h1p : 0 < 1 / ↑p hvp : 0 < ↑v ↑p ⊒ 1 / ↑p + 1 / ↑p ≀ 1 [PROOFSTEP] rw [← add_div, div_le_one (Nat.cast_pos.2 hp.1.pos : 0 < (p : ℝ))] [GOAL] case neg K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp✝ : Fact (↑v ↑p β‰  1) r : O hx : ↑v ↑p ^ (1 / ↑p) < ↑v (↑(algebraMap O K) r) s : O hy : ↑v ↑p ^ (1 / ↑p) < ↑v (↑(algebraMap O K) s) h1p : 0 < 1 / ↑p hvp : 0 < ↑v ↑p ⊒ 1 + 1 ≀ ↑p [PROOFSTEP] exact_mod_cast hp.1.two_le [GOAL] K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) f : PreTilt K v O hv p n : β„• hfn : ↑(coeff (ModP K v O hv p) p n) f β‰  0 ⊒ valAux K v O hv p f = ModP.preVal K v O hv p (↑(coeff (ModP K v O hv p) p n) f) ^ p ^ n [PROOFSTEP] have h : βˆƒ n, coeff _ _ n f β‰  0 := ⟨n, hfn⟩ [GOAL] K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) f : PreTilt K v O hv p n : β„• hfn : ↑(coeff (ModP K v O hv p) p n) f β‰  0 h : βˆƒ n, ↑(coeff (ModP K v O hv p) p n) f β‰  0 ⊒ valAux K v O hv p f = ModP.preVal K v O hv p (↑(coeff (ModP K v O hv p) p n) f) ^ p ^ n [PROOFSTEP] rw [valAux, dif_pos h] [GOAL] K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) f : PreTilt K v O hv p n : β„• hfn : ↑(coeff (ModP K v O hv p) p n) f β‰  0 h : βˆƒ n, ↑(coeff (ModP K v O hv p) p n) f β‰  0 ⊒ ModP.preVal K v O hv p (↑(coeff (ModP K v O hv p) p (Nat.find h)) f) ^ p ^ Nat.find h = ModP.preVal K v O hv p (↑(coeff (ModP K v O hv p) p n) f) ^ p ^ n [PROOFSTEP] obtain ⟨k, rfl⟩ := Nat.exists_eq_add_of_le (Nat.find_min' h hfn) [GOAL] case intro K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) f : PreTilt K v O hv p h : βˆƒ n, ↑(coeff (ModP K v O hv p) p n) f β‰  0 k : β„• hfn : ↑(coeff (ModP K v O hv p) p (Nat.find h + k)) f β‰  0 ⊒ ModP.preVal K v O hv p (↑(coeff (ModP K v O hv p) p (Nat.find h)) f) ^ p ^ Nat.find h = ModP.preVal K v O hv p (↑(coeff (ModP K v O hv p) p (Nat.find h + k)) f) ^ p ^ (Nat.find h + k) [PROOFSTEP] induction' k with k ih [GOAL] case intro.zero K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) f : PreTilt K v O hv p h : βˆƒ n, ↑(coeff (ModP K v O hv p) p n) f β‰  0 k : β„• hfn✝ : ↑(coeff (ModP K v O hv p) p (Nat.find h + k)) f β‰  0 hfn : ↑(coeff (ModP K v O hv p) p (Nat.find h + Nat.zero)) f β‰  0 ⊒ ModP.preVal K v O hv p (↑(coeff (ModP K v O hv p) p (Nat.find h)) f) ^ p ^ Nat.find h = ModP.preVal K v O hv p (↑(coeff (ModP K v O hv p) p (Nat.find h + Nat.zero)) f) ^ p ^ (Nat.find h + Nat.zero) [PROOFSTEP] rfl [GOAL] case intro.succ K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) f : PreTilt K v O hv p h : βˆƒ n, ↑(coeff (ModP K v O hv p) p n) f β‰  0 k✝ : β„• hfn✝ : ↑(coeff (ModP K v O hv p) p (Nat.find h + k✝)) f β‰  0 k : β„• ih : ↑(coeff (ModP K v O hv p) p (Nat.find h + k)) f β‰  0 β†’ ModP.preVal K v O hv p (↑(coeff (ModP K v O hv p) p (Nat.find h)) f) ^ p ^ Nat.find h = ModP.preVal K v O hv p (↑(coeff (ModP K v O hv p) p (Nat.find h + k)) f) ^ p ^ (Nat.find h + k) hfn : ↑(coeff (ModP K v O hv p) p (Nat.find h + Nat.succ k)) f β‰  0 ⊒ ModP.preVal K v O hv p (↑(coeff (ModP K v O hv p) p (Nat.find h)) f) ^ p ^ Nat.find h = ModP.preVal K v O hv p (↑(coeff (ModP K v O hv p) p (Nat.find h + Nat.succ k)) f) ^ p ^ (Nat.find h + Nat.succ k) [PROOFSTEP] obtain ⟨x, hx⟩ := Ideal.Quotient.mk_surjective (coeff _ _ (Nat.find h + k + 1) f) [GOAL] case intro.succ.intro K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) f : PreTilt K v O hv p h : βˆƒ n, ↑(coeff (ModP K v O hv p) p n) f β‰  0 k✝ : β„• hfn✝ : ↑(coeff (ModP K v O hv p) p (Nat.find h + k✝)) f β‰  0 k : β„• ih : ↑(coeff (ModP K v O hv p) p (Nat.find h + k)) f β‰  0 β†’ ModP.preVal K v O hv p (↑(coeff (ModP K v O hv p) p (Nat.find h)) f) ^ p ^ Nat.find h = ModP.preVal K v O hv p (↑(coeff (ModP K v O hv p) p (Nat.find h + k)) f) ^ p ^ (Nat.find h + k) hfn : ↑(coeff (ModP K v O hv p) p (Nat.find h + Nat.succ k)) f β‰  0 x : O hx : ↑(Ideal.Quotient.mk (Ideal.span {↑p})) x = ↑(coeff (ModP K v O hv p) p (Nat.find h + k + 1)) f ⊒ ModP.preVal K v O hv p (↑(coeff (ModP K v O hv p) p (Nat.find h)) f) ^ p ^ Nat.find h = ModP.preVal K v O hv p (↑(coeff (ModP K v O hv p) p (Nat.find h + Nat.succ k)) f) ^ p ^ (Nat.find h + Nat.succ k) [PROOFSTEP] have h1 : (Ideal.Quotient.mk _ x : ModP K v O hv p) β‰  0 := hx.symm β–Έ hfn [GOAL] case intro.succ.intro K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) f : PreTilt K v O hv p h : βˆƒ n, ↑(coeff (ModP K v O hv p) p n) f β‰  0 k✝ : β„• hfn✝ : ↑(coeff (ModP K v O hv p) p (Nat.find h + k✝)) f β‰  0 k : β„• ih : ↑(coeff (ModP K v O hv p) p (Nat.find h + k)) f β‰  0 β†’ ModP.preVal K v O hv p (↑(coeff (ModP K v O hv p) p (Nat.find h)) f) ^ p ^ Nat.find h = ModP.preVal K v O hv p (↑(coeff (ModP K v O hv p) p (Nat.find h + k)) f) ^ p ^ (Nat.find h + k) hfn : ↑(coeff (ModP K v O hv p) p (Nat.find h + Nat.succ k)) f β‰  0 x : O hx : ↑(Ideal.Quotient.mk (Ideal.span {↑p})) x = ↑(coeff (ModP K v O hv p) p (Nat.find h + k + 1)) f h1 : ↑(Ideal.Quotient.mk (Ideal.span {↑p})) x β‰  0 ⊒ ModP.preVal K v O hv p (↑(coeff (ModP K v O hv p) p (Nat.find h)) f) ^ p ^ Nat.find h = ModP.preVal K v O hv p (↑(coeff (ModP K v O hv p) p (Nat.find h + Nat.succ k)) f) ^ p ^ (Nat.find h + Nat.succ k) [PROOFSTEP] have h2 : (Ideal.Quotient.mk _ (x ^ p) : ModP K v O hv p) β‰  0 := by erw [RingHom.map_pow, hx, ← RingHom.map_pow, coeff_pow_p] exact coeff_nat_find_add_ne_zero k [GOAL] K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) f : PreTilt K v O hv p h : βˆƒ n, ↑(coeff (ModP K v O hv p) p n) f β‰  0 k✝ : β„• hfn✝ : ↑(coeff (ModP K v O hv p) p (Nat.find h + k✝)) f β‰  0 k : β„• ih : ↑(coeff (ModP K v O hv p) p (Nat.find h + k)) f β‰  0 β†’ ModP.preVal K v O hv p (↑(coeff (ModP K v O hv p) p (Nat.find h)) f) ^ p ^ Nat.find h = ModP.preVal K v O hv p (↑(coeff (ModP K v O hv p) p (Nat.find h + k)) f) ^ p ^ (Nat.find h + k) hfn : ↑(coeff (ModP K v O hv p) p (Nat.find h + Nat.succ k)) f β‰  0 x : O hx : ↑(Ideal.Quotient.mk (Ideal.span {↑p})) x = ↑(coeff (ModP K v O hv p) p (Nat.find h + k + 1)) f h1 : ↑(Ideal.Quotient.mk (Ideal.span {↑p})) x β‰  0 ⊒ ↑(Ideal.Quotient.mk (Ideal.span {↑p})) (x ^ p) β‰  0 [PROOFSTEP] erw [RingHom.map_pow, hx, ← RingHom.map_pow, coeff_pow_p] [GOAL] K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) f : PreTilt K v O hv p h : βˆƒ n, ↑(coeff (ModP K v O hv p) p n) f β‰  0 k✝ : β„• hfn✝ : ↑(coeff (ModP K v O hv p) p (Nat.find h + k✝)) f β‰  0 k : β„• ih : ↑(coeff (ModP K v O hv p) p (Nat.find h + k)) f β‰  0 β†’ ModP.preVal K v O hv p (↑(coeff (ModP K v O hv p) p (Nat.find h)) f) ^ p ^ Nat.find h = ModP.preVal K v O hv p (↑(coeff (ModP K v O hv p) p (Nat.find h + k)) f) ^ p ^ (Nat.find h + k) hfn : ↑(coeff (ModP K v O hv p) p (Nat.find h + Nat.succ k)) f β‰  0 x : O hx : ↑(Ideal.Quotient.mk (Ideal.span {↑p})) x = ↑(coeff (ModP K v O hv p) p (Nat.find h + k + 1)) f h1 : ↑(Ideal.Quotient.mk (Ideal.span {↑p})) x β‰  0 ⊒ ↑(coeff (ModP K v O hv p) p (Nat.find h + k)) f β‰  0 [PROOFSTEP] exact coeff_nat_find_add_ne_zero k [GOAL] case intro.succ.intro K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) f : PreTilt K v O hv p h : βˆƒ n, ↑(coeff (ModP K v O hv p) p n) f β‰  0 k✝ : β„• hfn✝ : ↑(coeff (ModP K v O hv p) p (Nat.find h + k✝)) f β‰  0 k : β„• ih : ↑(coeff (ModP K v O hv p) p (Nat.find h + k)) f β‰  0 β†’ ModP.preVal K v O hv p (↑(coeff (ModP K v O hv p) p (Nat.find h)) f) ^ p ^ Nat.find h = ModP.preVal K v O hv p (↑(coeff (ModP K v O hv p) p (Nat.find h + k)) f) ^ p ^ (Nat.find h + k) hfn : ↑(coeff (ModP K v O hv p) p (Nat.find h + Nat.succ k)) f β‰  0 x : O hx : ↑(Ideal.Quotient.mk (Ideal.span {↑p})) x = ↑(coeff (ModP K v O hv p) p (Nat.find h + k + 1)) f h1 : ↑(Ideal.Quotient.mk (Ideal.span {↑p})) x β‰  0 h2 : ↑(Ideal.Quotient.mk (Ideal.span {↑p})) (x ^ p) β‰  0 ⊒ ModP.preVal K v O hv p (↑(coeff (ModP K v O hv p) p (Nat.find h)) f) ^ p ^ Nat.find h = ModP.preVal K v O hv p (↑(coeff (ModP K v O hv p) p (Nat.find h + Nat.succ k)) f) ^ p ^ (Nat.find h + Nat.succ k) [PROOFSTEP] erw [ih (coeff_nat_find_add_ne_zero k), ← hx, ← coeff_pow_p, RingHom.map_pow, ← hx, ← RingHom.map_pow, ModP.preVal_mk h1, ModP.preVal_mk h2, RingHom.map_pow, v.map_pow, ← pow_mul, pow_succ] [GOAL] case intro.succ.intro K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) f : PreTilt K v O hv p h : βˆƒ n, ↑(coeff (ModP K v O hv p) p n) f β‰  0 k✝ : β„• hfn✝ : ↑(coeff (ModP K v O hv p) p (Nat.find h + k✝)) f β‰  0 k : β„• ih : ↑(coeff (ModP K v O hv p) p (Nat.find h + k)) f β‰  0 β†’ ModP.preVal K v O hv p (↑(coeff (ModP K v O hv p) p (Nat.find h)) f) ^ p ^ Nat.find h = ModP.preVal K v O hv p (↑(coeff (ModP K v O hv p) p (Nat.find h + k)) f) ^ p ^ (Nat.find h + k) hfn : ↑(coeff (ModP K v O hv p) p (Nat.find h + Nat.succ k)) f β‰  0 x : O hx : ↑(Ideal.Quotient.mk (Ideal.span {↑p})) x = ↑(coeff (ModP K v O hv p) p (Nat.find h + k + 1)) f h1 : ↑(Ideal.Quotient.mk (Ideal.span {↑p})) x β‰  0 h2 : ↑(Ideal.Quotient.mk (Ideal.span {↑p})) (x ^ p) β‰  0 ⊒ ↑v (↑(algebraMap O K) x) ^ (p * p ^ (Nat.find h + k)) = ↑v (↑(algebraMap O K) x) ^ (p * p ^ Nat.add (Nat.find h) k) [PROOFSTEP] rfl [GOAL] K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) ⊒ ModP.preVal K v O hv p (↑(coeff (ModP K v O hv p) p 0) 1) ^ p ^ 0 = 1 [PROOFSTEP] rw [pow_zero, pow_one, RingHom.map_one, ← (Ideal.Quotient.mk _).map_one, ModP.preVal_mk, RingHom.map_one, v.map_one] [GOAL] K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) ⊒ ↑(Ideal.Quotient.mk (Ideal.span {↑p})) 1 β‰  0 [PROOFSTEP] change (1 : ModP K v O hv p) β‰  0 [GOAL] K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) ⊒ 1 β‰  0 [PROOFSTEP] exact one_ne_zero [GOAL] K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) f g : PreTilt K v O hv p ⊒ valAux K v O hv p (f * g) = valAux K v O hv p f * valAux K v O hv p g [PROOFSTEP] by_cases hf : f = 0 [GOAL] case pos K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) f g : PreTilt K v O hv p hf : f = 0 ⊒ valAux K v O hv p (f * g) = valAux K v O hv p f * valAux K v O hv p g [PROOFSTEP] rw [hf, zero_mul, valAux_zero, zero_mul] [GOAL] case neg K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) f g : PreTilt K v O hv p hf : Β¬f = 0 ⊒ valAux K v O hv p (f * g) = valAux K v O hv p f * valAux K v O hv p g [PROOFSTEP] by_cases hg : g = 0 [GOAL] case pos K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) f g : PreTilt K v O hv p hf : Β¬f = 0 hg : g = 0 ⊒ valAux K v O hv p (f * g) = valAux K v O hv p f * valAux K v O hv p g [PROOFSTEP] rw [hg, mul_zero, valAux_zero, mul_zero] [GOAL] case neg K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) f g : PreTilt K v O hv p hf : Β¬f = 0 hg : Β¬g = 0 ⊒ valAux K v O hv p (f * g) = valAux K v O hv p f * valAux K v O hv p g [PROOFSTEP] obtain ⟨m, hm⟩ : βˆƒ n, coeff _ _ n f β‰  0 := not_forall.1 fun h => hf <| Perfection.ext h [GOAL] case neg.intro K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) f g : PreTilt K v O hv p hf : Β¬f = 0 hg : Β¬g = 0 m : β„• hm : ↑(coeff (ModP K v O hv p) p m) f β‰  0 ⊒ valAux K v O hv p (f * g) = valAux K v O hv p f * valAux K v O hv p g [PROOFSTEP] obtain ⟨n, hn⟩ : βˆƒ n, coeff _ _ n g β‰  0 := not_forall.1 fun h => hg <| Perfection.ext h [GOAL] case neg.intro.intro K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) f g : PreTilt K v O hv p hf : Β¬f = 0 hg : Β¬g = 0 m : β„• hm : ↑(coeff (ModP K v O hv p) p m) f β‰  0 n : β„• hn : ↑(coeff (ModP K v O hv p) p n) g β‰  0 ⊒ valAux K v O hv p (f * g) = valAux K v O hv p f * valAux K v O hv p g [PROOFSTEP] replace hm := coeff_ne_zero_of_le hm (le_max_left m n) [GOAL] case neg.intro.intro K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) f g : PreTilt K v O hv p hf : Β¬f = 0 hg : Β¬g = 0 m n : β„• hn : ↑(coeff (ModP K v O hv p) p n) g β‰  0 hm : ↑(coeff (ModP K v O hv p) p (max m n)) f β‰  0 ⊒ valAux K v O hv p (f * g) = valAux K v O hv p f * valAux K v O hv p g [PROOFSTEP] replace hn := coeff_ne_zero_of_le hn (le_max_right m n) [GOAL] case neg.intro.intro K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) f g : PreTilt K v O hv p hf : Β¬f = 0 hg : Β¬g = 0 m n : β„• hm : ↑(coeff (ModP K v O hv p) p (max m n)) f β‰  0 hn : ↑(coeff (ModP K v O hv p) p (max m n)) g β‰  0 ⊒ valAux K v O hv p (f * g) = valAux K v O hv p f * valAux K v O hv p g [PROOFSTEP] have hfg : coeff _ _ (max m n + 1) (f * g) β‰  0 := by rw [RingHom.map_mul] refine' ModP.mul_ne_zero_of_pow_p_ne_zero _ _ Β· rw [← RingHom.map_pow, coeff_pow_p f]; assumption Β· rw [← RingHom.map_pow, coeff_pow_p g]; assumption [GOAL] K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) f g : PreTilt K v O hv p hf : Β¬f = 0 hg : Β¬g = 0 m n : β„• hm : ↑(coeff (ModP K v O hv p) p (max m n)) f β‰  0 hn : ↑(coeff (ModP K v O hv p) p (max m n)) g β‰  0 ⊒ ↑(coeff (ModP K v O hv p) p (max m n + 1)) (f * g) β‰  0 [PROOFSTEP] rw [RingHom.map_mul] [GOAL] K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) f g : PreTilt K v O hv p hf : Β¬f = 0 hg : Β¬g = 0 m n : β„• hm : ↑(coeff (ModP K v O hv p) p (max m n)) f β‰  0 hn : ↑(coeff (ModP K v O hv p) p (max m n)) g β‰  0 ⊒ ↑(coeff (ModP K v O hv p) p (max m n + 1)) f * ↑(coeff (ModP K v O hv p) p (max m n + 1)) g β‰  0 [PROOFSTEP] refine' ModP.mul_ne_zero_of_pow_p_ne_zero _ _ [GOAL] case refine'_1 K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) f g : PreTilt K v O hv p hf : Β¬f = 0 hg : Β¬g = 0 m n : β„• hm : ↑(coeff (ModP K v O hv p) p (max m n)) f β‰  0 hn : ↑(coeff (ModP K v O hv p) p (max m n)) g β‰  0 ⊒ ↑(coeff (ModP K v O hv p) p (max m n + 1)) f ^ p β‰  0 [PROOFSTEP] rw [← RingHom.map_pow, coeff_pow_p f] [GOAL] case refine'_1 K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) f g : PreTilt K v O hv p hf : Β¬f = 0 hg : Β¬g = 0 m n : β„• hm : ↑(coeff (ModP K v O hv p) p (max m n)) f β‰  0 hn : ↑(coeff (ModP K v O hv p) p (max m n)) g β‰  0 ⊒ ↑(coeff (ModP K v O hv p) p (max m n)) f β‰  0 [PROOFSTEP] assumption [GOAL] case refine'_2 K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) f g : PreTilt K v O hv p hf : Β¬f = 0 hg : Β¬g = 0 m n : β„• hm : ↑(coeff (ModP K v O hv p) p (max m n)) f β‰  0 hn : ↑(coeff (ModP K v O hv p) p (max m n)) g β‰  0 ⊒ ↑(coeff (ModP K v O hv p) p (max m n + 1)) g ^ p β‰  0 [PROOFSTEP] rw [← RingHom.map_pow, coeff_pow_p g] [GOAL] case refine'_2 K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) f g : PreTilt K v O hv p hf : Β¬f = 0 hg : Β¬g = 0 m n : β„• hm : ↑(coeff (ModP K v O hv p) p (max m n)) f β‰  0 hn : ↑(coeff (ModP K v O hv p) p (max m n)) g β‰  0 ⊒ ↑(coeff (ModP K v O hv p) p (max m n)) g β‰  0 [PROOFSTEP] assumption [GOAL] case neg.intro.intro K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) f g : PreTilt K v O hv p hf : Β¬f = 0 hg : Β¬g = 0 m n : β„• hm : ↑(coeff (ModP K v O hv p) p (max m n)) f β‰  0 hn : ↑(coeff (ModP K v O hv p) p (max m n)) g β‰  0 hfg : ↑(coeff (ModP K v O hv p) p (max m n + 1)) (f * g) β‰  0 ⊒ valAux K v O hv p (f * g) = valAux K v O hv p f * valAux K v O hv p g [PROOFSTEP] rw [valAux_eq (coeff_add_ne_zero hm 1), valAux_eq (coeff_add_ne_zero hn 1), valAux_eq hfg] [GOAL] case neg.intro.intro K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) f g : PreTilt K v O hv p hf : Β¬f = 0 hg : Β¬g = 0 m n : β„• hm : ↑(coeff (ModP K v O hv p) p (max m n)) f β‰  0 hn : ↑(coeff (ModP K v O hv p) p (max m n)) g β‰  0 hfg : ↑(coeff (ModP K v O hv p) p (max m n + 1)) (f * g) β‰  0 ⊒ ModP.preVal K v O hv p (↑(coeff (ModP K v O hv p) p (max m n + 1)) (f * g)) ^ p ^ (max m n + 1) = ModP.preVal K v O hv p (↑(coeff (ModP K v O hv p) p (max m n + 1)) f) ^ p ^ (max m n + 1) * ModP.preVal K v O hv p (↑(coeff (ModP K v O hv p) p (max m n + 1)) g) ^ p ^ (max m n + 1) [PROOFSTEP] rw [RingHom.map_mul] at hfg ⊒ [GOAL] case neg.intro.intro K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) f g : PreTilt K v O hv p hf : Β¬f = 0 hg : Β¬g = 0 m n : β„• hm : ↑(coeff (ModP K v O hv p) p (max m n)) f β‰  0 hn : ↑(coeff (ModP K v O hv p) p (max m n)) g β‰  0 hfg : ↑(coeff (ModP K v O hv p) p (max m n + 1)) f * ↑(coeff (ModP K v O hv p) p (max m n + 1)) g β‰  0 ⊒ ModP.preVal K v O hv p (↑(coeff (ModP K v O hv p) p (max m n + 1)) f * ↑(coeff (ModP K v O hv p) p (max m n + 1)) g) ^ p ^ (max m n + 1) = ModP.preVal K v O hv p (↑(coeff (ModP K v O hv p) p (max m n + 1)) f) ^ p ^ (max m n + 1) * ModP.preVal K v O hv p (↑(coeff (ModP K v O hv p) p (max m n + 1)) g) ^ p ^ (max m n + 1) [PROOFSTEP] rw [ModP.preVal_mul hfg, mul_pow] [GOAL] K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) f g : PreTilt K v O hv p ⊒ valAux K v O hv p (f + g) ≀ max (valAux K v O hv p f) (valAux K v O hv p g) [PROOFSTEP] by_cases hf : f = 0 [GOAL] case pos K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) f g : PreTilt K v O hv p hf : f = 0 ⊒ valAux K v O hv p (f + g) ≀ max (valAux K v O hv p f) (valAux K v O hv p g) [PROOFSTEP] rw [hf, zero_add, valAux_zero, max_eq_right] [GOAL] case pos K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) f g : PreTilt K v O hv p hf : f = 0 ⊒ 0 ≀ valAux K v O hv p g [PROOFSTEP] exact zero_le _ [GOAL] case neg K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) f g : PreTilt K v O hv p hf : Β¬f = 0 ⊒ valAux K v O hv p (f + g) ≀ max (valAux K v O hv p f) (valAux K v O hv p g) [PROOFSTEP] by_cases hg : g = 0 [GOAL] case pos K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) f g : PreTilt K v O hv p hf : Β¬f = 0 hg : g = 0 ⊒ valAux K v O hv p (f + g) ≀ max (valAux K v O hv p f) (valAux K v O hv p g) [PROOFSTEP] rw [hg, add_zero, valAux_zero, max_eq_left] [GOAL] case pos K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) f g : PreTilt K v O hv p hf : Β¬f = 0 hg : g = 0 ⊒ 0 ≀ valAux K v O hv p f [PROOFSTEP] exact zero_le _ [GOAL] case neg K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) f g : PreTilt K v O hv p hf : Β¬f = 0 hg : Β¬g = 0 ⊒ valAux K v O hv p (f + g) ≀ max (valAux K v O hv p f) (valAux K v O hv p g) [PROOFSTEP] by_cases hfg : f + g = 0 [GOAL] case pos K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) f g : PreTilt K v O hv p hf : Β¬f = 0 hg : Β¬g = 0 hfg : f + g = 0 ⊒ valAux K v O hv p (f + g) ≀ max (valAux K v O hv p f) (valAux K v O hv p g) [PROOFSTEP] rw [hfg, valAux_zero] [GOAL] case pos K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) f g : PreTilt K v O hv p hf : Β¬f = 0 hg : Β¬g = 0 hfg : f + g = 0 ⊒ 0 ≀ max (valAux K v O hv p f) (valAux K v O hv p g) [PROOFSTEP] exact zero_le _ [GOAL] case neg K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) f g : PreTilt K v O hv p hf : Β¬f = 0 hg : Β¬g = 0 hfg : Β¬f + g = 0 ⊒ valAux K v O hv p (f + g) ≀ max (valAux K v O hv p f) (valAux K v O hv p g) [PROOFSTEP] replace hf : βˆƒ n, coeff _ _ n f β‰  0 := not_forall.1 fun h => hf <| Perfection.ext h [GOAL] case neg K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) f g : PreTilt K v O hv p hg : Β¬g = 0 hfg : Β¬f + g = 0 hf : βˆƒ n, ↑(coeff (ModP K v O hv p) p n) f β‰  0 ⊒ valAux K v O hv p (f + g) ≀ max (valAux K v O hv p f) (valAux K v O hv p g) [PROOFSTEP] replace hg : βˆƒ n, coeff _ _ n g β‰  0 := not_forall.1 fun h => hg <| Perfection.ext h [GOAL] case neg K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) f g : PreTilt K v O hv p hfg : Β¬f + g = 0 hf : βˆƒ n, ↑(coeff (ModP K v O hv p) p n) f β‰  0 hg : βˆƒ n, ↑(coeff (ModP K v O hv p) p n) g β‰  0 ⊒ valAux K v O hv p (f + g) ≀ max (valAux K v O hv p f) (valAux K v O hv p g) [PROOFSTEP] replace hfg : βˆƒ n, coeff _ _ n (f + g) β‰  0 := not_forall.1 fun h => hfg <| Perfection.ext h [GOAL] case neg K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) f g : PreTilt K v O hv p hf : βˆƒ n, ↑(coeff (ModP K v O hv p) p n) f β‰  0 hg : βˆƒ n, ↑(coeff (ModP K v O hv p) p n) g β‰  0 hfg : βˆƒ n, ↑(coeff (ModP K v O hv p) p n) (f + g) β‰  0 ⊒ valAux K v O hv p (f + g) ≀ max (valAux K v O hv p f) (valAux K v O hv p g) [PROOFSTEP] obtain ⟨m, hm⟩ := hf [GOAL] case neg.intro K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) f g : PreTilt K v O hv p hg : βˆƒ n, ↑(coeff (ModP K v O hv p) p n) g β‰  0 hfg : βˆƒ n, ↑(coeff (ModP K v O hv p) p n) (f + g) β‰  0 m : β„• hm : ↑(coeff (ModP K v O hv p) p m) f β‰  0 ⊒ valAux K v O hv p (f + g) ≀ max (valAux K v O hv p f) (valAux K v O hv p g) [PROOFSTEP] obtain ⟨n, hn⟩ := hg [GOAL] case neg.intro.intro K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) f g : PreTilt K v O hv p hfg : βˆƒ n, ↑(coeff (ModP K v O hv p) p n) (f + g) β‰  0 m : β„• hm : ↑(coeff (ModP K v O hv p) p m) f β‰  0 n : β„• hn : ↑(coeff (ModP K v O hv p) p n) g β‰  0 ⊒ valAux K v O hv p (f + g) ≀ max (valAux K v O hv p f) (valAux K v O hv p g) [PROOFSTEP] obtain ⟨k, hk⟩ := hfg [GOAL] case neg.intro.intro.intro K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) f g : PreTilt K v O hv p m : β„• hm : ↑(coeff (ModP K v O hv p) p m) f β‰  0 n : β„• hn : ↑(coeff (ModP K v O hv p) p n) g β‰  0 k : β„• hk : ↑(coeff (ModP K v O hv p) p k) (f + g) β‰  0 ⊒ valAux K v O hv p (f + g) ≀ max (valAux K v O hv p f) (valAux K v O hv p g) [PROOFSTEP] replace hm := coeff_ne_zero_of_le hm (le_trans (le_max_left m n) (le_max_left _ k)) [GOAL] case neg.intro.intro.intro K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) f g : PreTilt K v O hv p m n : β„• hn : ↑(coeff (ModP K v O hv p) p n) g β‰  0 k : β„• hk : ↑(coeff (ModP K v O hv p) p k) (f + g) β‰  0 hm : ↑(coeff (ModP K v O hv p) p (max (max m n) k)) f β‰  0 ⊒ valAux K v O hv p (f + g) ≀ max (valAux K v O hv p f) (valAux K v O hv p g) [PROOFSTEP] replace hn := coeff_ne_zero_of_le hn (le_trans (le_max_right m n) (le_max_left _ k)) [GOAL] case neg.intro.intro.intro K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) f g : PreTilt K v O hv p m n k : β„• hk : ↑(coeff (ModP K v O hv p) p k) (f + g) β‰  0 hm : ↑(coeff (ModP K v O hv p) p (max (max m n) k)) f β‰  0 hn : ↑(coeff (ModP K v O hv p) p (max (max m n) k)) g β‰  0 ⊒ valAux K v O hv p (f + g) ≀ max (valAux K v O hv p f) (valAux K v O hv p g) [PROOFSTEP] replace hk := coeff_ne_zero_of_le hk (le_max_right (max m n) k) [GOAL] case neg.intro.intro.intro K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) f g : PreTilt K v O hv p m n k : β„• hm : ↑(coeff (ModP K v O hv p) p (max (max m n) k)) f β‰  0 hn : ↑(coeff (ModP K v O hv p) p (max (max m n) k)) g β‰  0 hk : ↑(coeff (ModP K v O hv p) p (max (max m n) k)) (f + g) β‰  0 ⊒ valAux K v O hv p (f + g) ≀ max (valAux K v O hv p f) (valAux K v O hv p g) [PROOFSTEP] rw [valAux_eq hm, valAux_eq hn, valAux_eq hk, RingHom.map_add] [GOAL] case neg.intro.intro.intro K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) f g : PreTilt K v O hv p m n k : β„• hm : ↑(coeff (ModP K v O hv p) p (max (max m n) k)) f β‰  0 hn : ↑(coeff (ModP K v O hv p) p (max (max m n) k)) g β‰  0 hk : ↑(coeff (ModP K v O hv p) p (max (max m n) k)) (f + g) β‰  0 ⊒ ModP.preVal K v O hv p (↑(coeff (ModP K v O hv p) p (max (max m n) k)) f + ↑(coeff (ModP K v O hv p) p (max (max m n) k)) g) ^ p ^ max (max m n) k ≀ max (ModP.preVal K v O hv p (↑(coeff (ModP K v O hv p) p (max (max m n) k)) f) ^ p ^ max (max m n) k) (ModP.preVal K v O hv p (↑(coeff (ModP K v O hv p) p (max (max m n) k)) g) ^ p ^ max (max m n) k) [PROOFSTEP] cases' le_max_iff.1 (ModP.preVal_add (coeff _ _ (max (max m n) k) f) (coeff _ _ (max (max m n) k) g)) with h h [GOAL] case neg.intro.intro.intro.inl K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) f g : PreTilt K v O hv p m n k : β„• hm : ↑(coeff (ModP K v O hv p) p (max (max m n) k)) f β‰  0 hn : ↑(coeff (ModP K v O hv p) p (max (max m n) k)) g β‰  0 hk : ↑(coeff (ModP K v O hv p) p (max (max m n) k)) (f + g) β‰  0 h : ModP.preVal K v O hv p (↑(coeff (ModP K v O hv p) p (max (max m n) k)) f + ↑(coeff (ModP K v O hv p) p (max (max m n) k)) g) ≀ ModP.preVal K v O hv p (↑(coeff (ModP K v O hv p) p (max (max m n) k)) f) ⊒ ModP.preVal K v O hv p (↑(coeff (ModP K v O hv p) p (max (max m n) k)) f + ↑(coeff (ModP K v O hv p) p (max (max m n) k)) g) ^ p ^ max (max m n) k ≀ max (ModP.preVal K v O hv p (↑(coeff (ModP K v O hv p) p (max (max m n) k)) f) ^ p ^ max (max m n) k) (ModP.preVal K v O hv p (↑(coeff (ModP K v O hv p) p (max (max m n) k)) g) ^ p ^ max (max m n) k) [PROOFSTEP] exact le_max_of_le_left (pow_le_pow_of_le_left' h _) [GOAL] case neg.intro.intro.intro.inr K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) f g : PreTilt K v O hv p m n k : β„• hm : ↑(coeff (ModP K v O hv p) p (max (max m n) k)) f β‰  0 hn : ↑(coeff (ModP K v O hv p) p (max (max m n) k)) g β‰  0 hk : ↑(coeff (ModP K v O hv p) p (max (max m n) k)) (f + g) β‰  0 h : ModP.preVal K v O hv p (↑(coeff (ModP K v O hv p) p (max (max m n) k)) f + ↑(coeff (ModP K v O hv p) p (max (max m n) k)) g) ≀ ModP.preVal K v O hv p (↑(coeff (ModP K v O hv p) p (max (max m n) k)) g) ⊒ ModP.preVal K v O hv p (↑(coeff (ModP K v O hv p) p (max (max m n) k)) f + ↑(coeff (ModP K v O hv p) p (max (max m n) k)) g) ^ p ^ max (max m n) k ≀ max (ModP.preVal K v O hv p (↑(coeff (ModP K v O hv p) p (max (max m n) k)) f) ^ p ^ max (max m n) k) (ModP.preVal K v O hv p (↑(coeff (ModP K v O hv p) p (max (max m n) k)) g) ^ p ^ max (max m n) k) [PROOFSTEP] exact le_max_of_le_right (pow_le_pow_of_le_left' h _) [GOAL] K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) f : PreTilt K v O hv p ⊒ ↑(val K v O hv p) f = 0 ↔ f = 0 [PROOFSTEP] by_cases hf0 : f = 0 [GOAL] case pos K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) f : PreTilt K v O hv p hf0 : f = 0 ⊒ ↑(val K v O hv p) f = 0 ↔ f = 0 [PROOFSTEP] rw [hf0] [GOAL] case pos K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) f : PreTilt K v O hv p hf0 : f = 0 ⊒ ↑(val K v O hv p) 0 = 0 ↔ 0 = 0 [PROOFSTEP] exact iff_of_true (Valuation.map_zero _) rfl [GOAL] case neg K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) f : PreTilt K v O hv p hf0 : Β¬f = 0 ⊒ ↑(val K v O hv p) f = 0 ↔ f = 0 [PROOFSTEP] obtain ⟨n, hn⟩ : βˆƒ n, coeff _ _ n f β‰  0 := not_forall.1 fun h => hf0 <| Perfection.ext h [GOAL] case neg.intro K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) f : PreTilt K v O hv p hf0 : Β¬f = 0 n : β„• hn : ↑(coeff (ModP K v O hv p) p n) f β‰  0 ⊒ ↑(val K v O hv p) f = 0 ↔ f = 0 [PROOFSTEP] show valAux K v O hv p f = 0 ↔ f = 0 [GOAL] case neg.intro K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) f : PreTilt K v O hv p hf0 : Β¬f = 0 n : β„• hn : ↑(coeff (ModP K v O hv p) p n) f β‰  0 ⊒ valAux K v O hv p f = 0 ↔ f = 0 [PROOFSTEP] refine' iff_of_false (fun hvf => hn _) hf0 [GOAL] case neg.intro K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) f : PreTilt K v O hv p hf0 : Β¬f = 0 n : β„• hn : ↑(coeff (ModP K v O hv p) p n) f β‰  0 hvf : valAux K v O hv p f = 0 ⊒ ↑(coeff (ModP K v O hv p) p n) f = 0 [PROOFSTEP] rw [valAux_eq hn] at hvf [GOAL] case neg.intro K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) f : PreTilt K v O hv p hf0 : Β¬f = 0 n : β„• hn : ↑(coeff (ModP K v O hv p) p n) f β‰  0 hvf : ModP.preVal K v O hv p (↑(coeff (ModP K v O hv p) p n) f) ^ p ^ n = 0 ⊒ ↑(coeff (ModP K v O hv p) p n) f = 0 [PROOFSTEP] replace hvf := pow_eq_zero hvf [GOAL] case neg.intro K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) f : PreTilt K v O hv p hf0 : Β¬f = 0 n : β„• hn : ↑(coeff (ModP K v O hv p) p n) f β‰  0 hvf : ModP.preVal K v O hv p (↑(coeff (ModP K v O hv p) p n) f) = 0 ⊒ ↑(coeff (ModP K v O hv p) p n) f = 0 [PROOFSTEP] rwa [ModP.preVal_eq_zero] at hvf [GOAL] K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) ⊒ IsDomain (PreTilt K v O hv p) [PROOFSTEP] haveI : Nontrivial (PreTilt K v O hv p) := ⟨(CharP.nontrivial_of_char_ne_one hp.1.ne_one).1⟩ [GOAL] K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) this : Nontrivial (PreTilt K v O hv p) ⊒ IsDomain (PreTilt K v O hv p) [PROOFSTEP] haveI : NoZeroDivisors (PreTilt K v O hv p) := ⟨fun hfg => by simp_rw [← map_eq_zero] at hfg ⊒; contrapose! hfg; rw [Valuation.map_mul] exact mul_ne_zero hfg.1 hfg.2⟩ [GOAL] K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) this : Nontrivial (PreTilt K v O hv p) a✝ b✝ : PreTilt K v O hv p hfg : a✝ * b✝ = 0 ⊒ a✝ = 0 ∨ b✝ = 0 [PROOFSTEP] simp_rw [← map_eq_zero] at hfg ⊒ [GOAL] K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) this : Nontrivial (PreTilt K v O hv p) a✝ b✝ : PreTilt K v O hv p hfg : ↑(val K v O hv p) (a✝ * b✝) = 0 ⊒ ↑(val K v O hv p) a✝ = 0 ∨ ↑(val K v O hv p) b✝ = 0 [PROOFSTEP] contrapose! hfg [GOAL] K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) this : Nontrivial (PreTilt K v O hv p) a✝ b✝ : PreTilt K v O hv p hfg : ↑(val K v O hv p) a✝ β‰  0 ∧ ↑(val K v O hv p) b✝ β‰  0 ⊒ ↑(val K v O hv p) (a✝ * b✝) β‰  0 [PROOFSTEP] rw [Valuation.map_mul] [GOAL] K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) this : Nontrivial (PreTilt K v O hv p) a✝ b✝ : PreTilt K v O hv p hfg : ↑(val K v O hv p) a✝ β‰  0 ∧ ↑(val K v O hv p) b✝ β‰  0 ⊒ ↑(val K v O hv p) a✝ * ↑(val K v O hv p) b✝ β‰  0 [PROOFSTEP] exact mul_ne_zero hfg.1 hfg.2 [GOAL] K : Type u₁ inst✝² : Field K v : Valuation K ℝβ‰₯0 O : Type uβ‚‚ inst✝¹ : CommRing O inst✝ : Algebra O K hv : Valuation.Integers v O p : β„• hp : Fact (Nat.Prime p) hvp : Fact (↑v ↑p β‰  1) this✝ : Nontrivial (PreTilt K v O hv p) this : NoZeroDivisors (PreTilt K v O hv p) ⊒ IsDomain (PreTilt K v O hv p) [PROOFSTEP] exact NoZeroDivisors.to_isDomain _
State Before: x✝ y x : ℝ hx : 0 ≀ x ⊒ 1 + x + x ^ 2 / 2 = βˆ‘ i in range 3, x ^ i / ↑i ! State After: x✝ y x : ℝ hx : 0 ≀ x ⊒ x ^ 2 / 2 = x ^ 2 / (1 + 1) Tactic: simp [Finset.sum_range_succ] State Before: x✝ y x : ℝ hx : 0 ≀ x ⊒ x ^ 2 / 2 = x ^ 2 / (1 + 1) State After: no goals Tactic: ring_nf
[STATEMENT] lemma less_lsum_unique: assumes "\<And> a. a \<in> set al \<Longrightarrow> (0::nat) < f a" and "n1 < length al \<and> j1 < f (al ! n1)" and "n2 < length al \<and> j2 < f (al ! n2)" and "lsum f (take n1 al) + j1 = lsum f (take n2 al) + j2" shows "n1 = n2 \<and> j1 = j2" [PROOF STATE] proof (prove) goal (1 subgoal): 1. n1 = n2 \<and> j1 = j2 [PROOF STEP] using assms [PROOF STATE] proof (prove) using this: ?a \<in> set al \<Longrightarrow> 0 < f ?a n1 < length al \<and> j1 < f (al ! n1) n2 < length al \<and> j2 < f (al ! n2) lsum f (take n1 al) + j1 = lsum f (take n2 al) + j2 goal (1 subgoal): 1. n1 = n2 \<and> j1 = j2 [PROOF STEP] proof(induct al arbitrary: n1 n2 j1 j2 rule: rev_induct) [PROOF STATE] proof (state) goal (2 subgoals): 1. \<And>n1 n2 j1 j2. \<lbrakk>\<And>a. a \<in> set [] \<Longrightarrow> 0 < f a; n1 < length [] \<and> j1 < f ([] ! n1); n2 < length [] \<and> j2 < f ([] ! n2); lsum f (take n1 []) + j1 = lsum f (take n2 []) + j2\<rbrakk> \<Longrightarrow> n1 = n2 \<and> j1 = j2 2. \<And>x xs n1 n2 j1 j2. \<lbrakk>\<And>n1 n2 j1 j2. \<lbrakk>\<And>a. a \<in> set xs \<Longrightarrow> 0 < f a; n1 < length xs \<and> j1 < f (xs ! n1); n2 < length xs \<and> j2 < f (xs ! n2); lsum f (take n1 xs) + j1 = lsum f (take n2 xs) + j2\<rbrakk> \<Longrightarrow> n1 = n2 \<and> j1 = j2; \<And>a. a \<in> set (xs @ [x]) \<Longrightarrow> 0 < f a; n1 < length (xs @ [x]) \<and> j1 < f ((xs @ [x]) ! n1); n2 < length (xs @ [x]) \<and> j2 < f ((xs @ [x]) ! n2); lsum f (take n1 (xs @ [x])) + j1 = lsum f (take n2 (xs @ [x])) + j2\<rbrakk> \<Longrightarrow> n1 = n2 \<and> j1 = j2 [PROOF STEP] case (snoc a al) [PROOF STATE] proof (state) this: \<lbrakk>\<And>a. a \<in> set al \<Longrightarrow> 0 < f a; ?n1.0 < length al \<and> ?j1.0 < f (al ! ?n1.0); ?n2.0 < length al \<and> ?j2.0 < f (al ! ?n2.0); lsum f (take ?n1.0 al) + ?j1.0 = lsum f (take ?n2.0 al) + ?j2.0\<rbrakk> \<Longrightarrow> ?n1.0 = ?n2.0 \<and> ?j1.0 = ?j2.0 ?a \<in> set (al @ [a]) \<Longrightarrow> 0 < f ?a n1 < length (al @ [a]) \<and> j1 < f ((al @ [a]) ! n1) n2 < length (al @ [a]) \<and> j2 < f ((al @ [a]) ! n2) lsum f (take n1 (al @ [a])) + j1 = lsum f (take n2 (al @ [a])) + j2 goal (2 subgoals): 1. \<And>n1 n2 j1 j2. \<lbrakk>\<And>a. a \<in> set [] \<Longrightarrow> 0 < f a; n1 < length [] \<and> j1 < f ([] ! n1); n2 < length [] \<and> j2 < f ([] ! n2); lsum f (take n1 []) + j1 = lsum f (take n2 []) + j2\<rbrakk> \<Longrightarrow> n1 = n2 \<and> j1 = j2 2. \<And>x xs n1 n2 j1 j2. \<lbrakk>\<And>n1 n2 j1 j2. \<lbrakk>\<And>a. a \<in> set xs \<Longrightarrow> 0 < f a; n1 < length xs \<and> j1 < f (xs ! n1); n2 < length xs \<and> j2 < f (xs ! n2); lsum f (take n1 xs) + j1 = lsum f (take n2 xs) + j2\<rbrakk> \<Longrightarrow> n1 = n2 \<and> j1 = j2; \<And>a. a \<in> set (xs @ [x]) \<Longrightarrow> 0 < f a; n1 < length (xs @ [x]) \<and> j1 < f ((xs @ [x]) ! n1); n2 < length (xs @ [x]) \<and> j2 < f ((xs @ [x]) ! n2); lsum f (take n1 (xs @ [x])) + j1 = lsum f (take n2 (xs @ [x])) + j2\<rbrakk> \<Longrightarrow> n1 = n2 \<and> j1 = j2 [PROOF STEP] hence pos: "0 < f a" "\<And> a'. a' \<in> set al \<Longrightarrow> 0 < f a'" and n1: "n1 < length al + 1" and n2: "n2 < length al + 1" [PROOF STATE] proof (prove) using this: \<lbrakk>\<And>a. a \<in> set al \<Longrightarrow> 0 < f a; ?n1.0 < length al \<and> ?j1.0 < f (al ! ?n1.0); ?n2.0 < length al \<and> ?j2.0 < f (al ! ?n2.0); lsum f (take ?n1.0 al) + ?j1.0 = lsum f (take ?n2.0 al) + ?j2.0\<rbrakk> \<Longrightarrow> ?n1.0 = ?n2.0 \<and> ?j1.0 = ?j2.0 ?a \<in> set (al @ [a]) \<Longrightarrow> 0 < f ?a n1 < length (al @ [a]) \<and> j1 < f ((al @ [a]) ! n1) n2 < length (al @ [a]) \<and> j2 < f ((al @ [a]) ! n2) lsum f (take n1 (al @ [a])) + j1 = lsum f (take n2 (al @ [a])) + j2 goal (1 subgoal): 1. (0 < f a &&& (\<And>a'. a' \<in> set al \<Longrightarrow> 0 < f a')) &&& n1 < length al + 1 &&& n2 < length al + 1 [PROOF STEP] by auto [PROOF STATE] proof (state) this: 0 < f a ?a' \<in> set al \<Longrightarrow> 0 < f ?a' n1 < length al + 1 n2 < length al + 1 goal (2 subgoals): 1. \<And>n1 n2 j1 j2. \<lbrakk>\<And>a. a \<in> set [] \<Longrightarrow> 0 < f a; n1 < length [] \<and> j1 < f ([] ! n1); n2 < length [] \<and> j2 < f ([] ! n2); lsum f (take n1 []) + j1 = lsum f (take n2 []) + j2\<rbrakk> \<Longrightarrow> n1 = n2 \<and> j1 = j2 2. \<And>x xs n1 n2 j1 j2. \<lbrakk>\<And>n1 n2 j1 j2. \<lbrakk>\<And>a. a \<in> set xs \<Longrightarrow> 0 < f a; n1 < length xs \<and> j1 < f (xs ! n1); n2 < length xs \<and> j2 < f (xs ! n2); lsum f (take n1 xs) + j1 = lsum f (take n2 xs) + j2\<rbrakk> \<Longrightarrow> n1 = n2 \<and> j1 = j2; \<And>a. a \<in> set (xs @ [x]) \<Longrightarrow> 0 < f a; n1 < length (xs @ [x]) \<and> j1 < f ((xs @ [x]) ! n1); n2 < length (xs @ [x]) \<and> j2 < f ((xs @ [x]) ! n2); lsum f (take n1 (xs @ [x])) + j1 = lsum f (take n2 (xs @ [x])) + j2\<rbrakk> \<Longrightarrow> n1 = n2 \<and> j1 = j2 [PROOF STEP] from n1 [PROOF STATE] proof (chain) picking this: n1 < length al + 1 [PROOF STEP] show ?case [PROOF STATE] proof (prove) using this: n1 < length al + 1 goal (1 subgoal): 1. n1 = n2 \<and> j1 = j2 [PROOF STEP] proof(cases rule: less_plus_elim) [PROOF STATE] proof (state) goal (2 subgoals): 1. n1 < length al \<Longrightarrow> n1 = n2 \<and> j1 = j2 2. \<And>i2. \<lbrakk>i2 < 1; n1 = length al + i2\<rbrakk> \<Longrightarrow> n1 = n2 \<and> j1 = j2 [PROOF STEP] case Left [PROOF STATE] proof (state) this: n1 < length al goal (2 subgoals): 1. n1 < length al \<Longrightarrow> n1 = n2 \<and> j1 = j2 2. \<And>i2. \<lbrakk>i2 < 1; n1 = length al + i2\<rbrakk> \<Longrightarrow> n1 = n2 \<and> j1 = j2 [PROOF STEP] note n1 = Left [PROOF STATE] proof (state) this: n1 < length al goal (2 subgoals): 1. n1 < length al \<Longrightarrow> n1 = n2 \<and> j1 = j2 2. \<And>i2. \<lbrakk>i2 < 1; n1 = length al + i2\<rbrakk> \<Longrightarrow> n1 = n2 \<and> j1 = j2 [PROOF STEP] hence j1: "j1 < f (al ! n1)" [PROOF STATE] proof (prove) using this: n1 < length al goal (1 subgoal): 1. j1 < f (al ! n1) [PROOF STEP] using snoc [PROOF STATE] proof (prove) using this: n1 < length al \<lbrakk>\<And>a. a \<in> set al \<Longrightarrow> 0 < f a; ?n1.0 < length al \<and> ?j1.0 < f (al ! ?n1.0); ?n2.0 < length al \<and> ?j2.0 < f (al ! ?n2.0); lsum f (take ?n1.0 al) + ?j1.0 = lsum f (take ?n2.0 al) + ?j2.0\<rbrakk> \<Longrightarrow> ?n1.0 = ?n2.0 \<and> ?j1.0 = ?j2.0 ?a \<in> set (al @ [a]) \<Longrightarrow> 0 < f ?a n1 < length (al @ [a]) \<and> j1 < f ((al @ [a]) ! n1) n2 < length (al @ [a]) \<and> j2 < f ((al @ [a]) ! n2) lsum f (take n1 (al @ [a])) + j1 = lsum f (take n2 (al @ [a])) + j2 goal (1 subgoal): 1. j1 < f (al ! n1) [PROOF STEP] by auto [PROOF STATE] proof (state) this: j1 < f (al ! n1) goal (2 subgoals): 1. n1 < length al \<Longrightarrow> n1 = n2 \<and> j1 = j2 2. \<And>i2. \<lbrakk>i2 < 1; n1 = length al + i2\<rbrakk> \<Longrightarrow> n1 = n2 \<and> j1 = j2 [PROOF STEP] obtain al' where al: "al = (take n1 al) @ ((al ! n1) # al')" [PROOF STATE] proof (prove) goal (1 subgoal): 1. (\<And>al'. al = take n1 al @ al ! n1 # al' \<Longrightarrow> thesis) \<Longrightarrow> thesis [PROOF STEP] using n1 [PROOF STATE] proof (prove) using this: n1 < length al goal (1 subgoal): 1. (\<And>al'. al = take n1 al @ al ! n1 # al' \<Longrightarrow> thesis) \<Longrightarrow> thesis [PROOF STEP] by (metis append_take_drop_id Cons_nth_drop_Suc) [PROOF STATE] proof (state) this: al = take n1 al @ al ! n1 # al' goal (2 subgoals): 1. n1 < length al \<Longrightarrow> n1 = n2 \<and> j1 = j2 2. \<And>i2. \<lbrakk>i2 < 1; n1 = length al + i2\<rbrakk> \<Longrightarrow> n1 = n2 \<and> j1 = j2 [PROOF STEP] have "j1 < lsum f ((al ! n1) # al')" [PROOF STATE] proof (prove) goal (1 subgoal): 1. j1 < lsum f (al ! n1 # al') [PROOF STEP] using pos j1 [PROOF STATE] proof (prove) using this: 0 < f a ?a' \<in> set al \<Longrightarrow> 0 < f ?a' j1 < f (al ! n1) goal (1 subgoal): 1. j1 < lsum f (al ! n1 # al') [PROOF STEP] unfolding lsum_def [PROOF STATE] proof (prove) using this: 0 < f a ?a' \<in> set al \<Longrightarrow> 0 < f ?a' j1 < f (al ! n1) goal (1 subgoal): 1. j1 < sum_list (map f (al ! n1 # al')) [PROOF STEP] by simp [PROOF STATE] proof (state) this: j1 < lsum f (al ! n1 # al') goal (2 subgoals): 1. n1 < length al \<Longrightarrow> n1 = n2 \<and> j1 = j2 2. \<And>i2. \<lbrakk>i2 < 1; n1 = length al + i2\<rbrakk> \<Longrightarrow> n1 = n2 \<and> j1 = j2 [PROOF STEP] hence "lsum f (take n1 al) + j1 < lsum f (take n1 al) + lsum f ((al ! n1) # al')" [PROOF STATE] proof (prove) using this: j1 < lsum f (al ! n1 # al') goal (1 subgoal): 1. lsum f (take n1 al) + j1 < lsum f (take n1 al) + lsum f (al ! n1 # al') [PROOF STEP] by simp [PROOF STATE] proof (state) this: lsum f (take n1 al) + j1 < lsum f (take n1 al) + lsum f (al ! n1 # al') goal (2 subgoals): 1. n1 < length al \<Longrightarrow> n1 = n2 \<and> j1 = j2 2. \<And>i2. \<lbrakk>i2 < 1; n1 = length al + i2\<rbrakk> \<Longrightarrow> n1 = n2 \<and> j1 = j2 [PROOF STEP] also [PROOF STATE] proof (state) this: lsum f (take n1 al) + j1 < lsum f (take n1 al) + lsum f (al ! n1 # al') goal (2 subgoals): 1. n1 < length al \<Longrightarrow> n1 = n2 \<and> j1 = j2 2. \<And>i2. \<lbrakk>i2 < 1; n1 = length al + i2\<rbrakk> \<Longrightarrow> n1 = n2 \<and> j1 = j2 [PROOF STEP] have "... = lsum f al" [PROOF STATE] proof (prove) goal (1 subgoal): 1. lsum f (take n1 al) + lsum f (al ! n1 # al') = lsum f al [PROOF STEP] unfolding lsum_append[THEN sym] [PROOF STATE] proof (prove) goal (1 subgoal): 1. lsum f (take n1 al @ al ! n1 # al') = lsum f al [PROOF STEP] using al [PROOF STATE] proof (prove) using this: al = take n1 al @ al ! n1 # al' goal (1 subgoal): 1. lsum f (take n1 al @ al ! n1 # al') = lsum f al [PROOF STEP] by simp [PROOF STATE] proof (state) this: lsum f (take n1 al) + lsum f (al ! n1 # al') = lsum f al goal (2 subgoals): 1. n1 < length al \<Longrightarrow> n1 = n2 \<and> j1 = j2 2. \<And>i2. \<lbrakk>i2 < 1; n1 = length al + i2\<rbrakk> \<Longrightarrow> n1 = n2 \<and> j1 = j2 [PROOF STEP] finally [PROOF STATE] proof (chain) picking this: lsum f (take n1 al) + j1 < lsum f al [PROOF STEP] have lsum1: "lsum f (take n1 al) + j1 < lsum f al" [PROOF STATE] proof (prove) using this: lsum f (take n1 al) + j1 < lsum f al goal (1 subgoal): 1. lsum f (take n1 al) + j1 < lsum f al [PROOF STEP] . [PROOF STATE] proof (state) this: lsum f (take n1 al) + j1 < lsum f al goal (2 subgoals): 1. n1 < length al \<Longrightarrow> n1 = n2 \<and> j1 = j2 2. \<And>i2. \<lbrakk>i2 < 1; n1 = length al + i2\<rbrakk> \<Longrightarrow> n1 = n2 \<and> j1 = j2 [PROOF STEP] from n2 [PROOF STATE] proof (chain) picking this: n2 < length al + 1 [PROOF STEP] show ?thesis [PROOF STATE] proof (prove) using this: n2 < length al + 1 goal (1 subgoal): 1. n1 = n2 \<and> j1 = j2 [PROOF STEP] proof(cases rule: less_plus_elim) [PROOF STATE] proof (state) goal (2 subgoals): 1. n2 < length al \<Longrightarrow> n1 = n2 \<and> j1 = j2 2. \<And>i2. \<lbrakk>i2 < 1; n2 = length al + i2\<rbrakk> \<Longrightarrow> n1 = n2 \<and> j1 = j2 [PROOF STEP] case Left [PROOF STATE] proof (state) this: n2 < length al goal (2 subgoals): 1. n2 < length al \<Longrightarrow> n1 = n2 \<and> j1 = j2 2. \<And>i2. \<lbrakk>i2 < 1; n2 = length al + i2\<rbrakk> \<Longrightarrow> n1 = n2 \<and> j1 = j2 [PROOF STEP] note n2 = Left [PROOF STATE] proof (state) this: n2 < length al goal (2 subgoals): 1. n2 < length al \<Longrightarrow> n1 = n2 \<and> j1 = j2 2. \<And>i2. \<lbrakk>i2 < 1; n2 = length al + i2\<rbrakk> \<Longrightarrow> n1 = n2 \<and> j1 = j2 [PROOF STEP] hence j2: "j2 < f (al ! n2)" [PROOF STATE] proof (prove) using this: n2 < length al goal (1 subgoal): 1. j2 < f (al ! n2) [PROOF STEP] using snoc [PROOF STATE] proof (prove) using this: n2 < length al \<lbrakk>\<And>a. a \<in> set al \<Longrightarrow> 0 < f a; ?n1.0 < length al \<and> ?j1.0 < f (al ! ?n1.0); ?n2.0 < length al \<and> ?j2.0 < f (al ! ?n2.0); lsum f (take ?n1.0 al) + ?j1.0 = lsum f (take ?n2.0 al) + ?j2.0\<rbrakk> \<Longrightarrow> ?n1.0 = ?n2.0 \<and> ?j1.0 = ?j2.0 ?a \<in> set (al @ [a]) \<Longrightarrow> 0 < f ?a n1 < length (al @ [a]) \<and> j1 < f ((al @ [a]) ! n1) n2 < length (al @ [a]) \<and> j2 < f ((al @ [a]) ! n2) lsum f (take n1 (al @ [a])) + j1 = lsum f (take n2 (al @ [a])) + j2 goal (1 subgoal): 1. j2 < f (al ! n2) [PROOF STEP] by auto [PROOF STATE] proof (state) this: j2 < f (al ! n2) goal (2 subgoals): 1. n2 < length al \<Longrightarrow> n1 = n2 \<and> j1 = j2 2. \<And>i2. \<lbrakk>i2 < 1; n2 = length al + i2\<rbrakk> \<Longrightarrow> n1 = n2 \<and> j1 = j2 [PROOF STEP] show ?thesis [PROOF STATE] proof (prove) goal (1 subgoal): 1. n1 = n2 \<and> j1 = j2 [PROOF STEP] apply(rule snoc(1)) [PROOF STATE] proof (prove) goal (4 subgoals): 1. \<And>a. a \<in> set al \<Longrightarrow> 0 < f a 2. n1 < length al \<and> j1 < f (al ! n1) 3. n2 < length al \<and> j2 < f (al ! n2) 4. lsum f (take n1 al) + j1 = lsum f (take n2 al) + j2 [PROOF STEP] using snoc [PROOF STATE] proof (prove) using this: \<lbrakk>\<And>a. a \<in> set al \<Longrightarrow> 0 < f a; ?n1.0 < length al \<and> ?j1.0 < f (al ! ?n1.0); ?n2.0 < length al \<and> ?j2.0 < f (al ! ?n2.0); lsum f (take ?n1.0 al) + ?j1.0 = lsum f (take ?n2.0 al) + ?j2.0\<rbrakk> \<Longrightarrow> ?n1.0 = ?n2.0 \<and> ?j1.0 = ?j2.0 ?a \<in> set (al @ [a]) \<Longrightarrow> 0 < f ?a n1 < length (al @ [a]) \<and> j1 < f ((al @ [a]) ! n1) n2 < length (al @ [a]) \<and> j2 < f ((al @ [a]) ! n2) lsum f (take n1 (al @ [a])) + j1 = lsum f (take n2 (al @ [a])) + j2 goal (4 subgoals): 1. \<And>a. a \<in> set al \<Longrightarrow> 0 < f a 2. n1 < length al \<and> j1 < f (al ! n1) 3. n2 < length al \<and> j2 < f (al ! n2) 4. lsum f (take n1 al) + j1 = lsum f (take n2 al) + j2 [PROOF STEP] using pos n1 j1 n2 j2 [PROOF STATE] proof (prove) using this: \<lbrakk>\<And>a. a \<in> set al \<Longrightarrow> 0 < f a; ?n1.0 < length al \<and> ?j1.0 < f (al ! ?n1.0); ?n2.0 < length al \<and> ?j2.0 < f (al ! ?n2.0); lsum f (take ?n1.0 al) + ?j1.0 = lsum f (take ?n2.0 al) + ?j2.0\<rbrakk> \<Longrightarrow> ?n1.0 = ?n2.0 \<and> ?j1.0 = ?j2.0 ?a \<in> set (al @ [a]) \<Longrightarrow> 0 < f ?a n1 < length (al @ [a]) \<and> j1 < f ((al @ [a]) ! n1) n2 < length (al @ [a]) \<and> j2 < f ((al @ [a]) ! n2) lsum f (take n1 (al @ [a])) + j1 = lsum f (take n2 (al @ [a])) + j2 0 < f a ?a' \<in> set al \<Longrightarrow> 0 < f ?a' n1 < length al j1 < f (al ! n1) n2 < length al j2 < f (al ! n2) goal (4 subgoals): 1. \<And>a. a \<in> set al \<Longrightarrow> 0 < f a 2. n1 < length al \<and> j1 < f (al ! n1) 3. n2 < length al \<and> j2 < f (al ! n2) 4. lsum f (take n1 al) + j1 = lsum f (take n2 al) + j2 [PROOF STEP] by auto [PROOF STATE] proof (state) this: n1 = n2 \<and> j1 = j2 goal (1 subgoal): 1. \<And>i2. \<lbrakk>i2 < 1; n2 = length al + i2\<rbrakk> \<Longrightarrow> n1 = n2 \<and> j1 = j2 [PROOF STEP] next [PROOF STATE] proof (state) goal (1 subgoal): 1. \<And>i2. \<lbrakk>i2 < 1; n2 = length al + i2\<rbrakk> \<Longrightarrow> n1 = n2 \<and> j1 = j2 [PROOF STEP] case Right [PROOF STATE] proof (state) this: i2_ < 1 n2 = length al + i2_ goal (1 subgoal): 1. \<And>i2. \<lbrakk>i2 < 1; n2 = length al + i2\<rbrakk> \<Longrightarrow> n1 = n2 \<and> j1 = j2 [PROOF STEP] hence n2: "n2 = length al" [PROOF STATE] proof (prove) using this: i2_ < 1 n2 = length al + i2_ goal (1 subgoal): 1. n2 = length al [PROOF STEP] by simp [PROOF STATE] proof (state) this: n2 = length al goal (1 subgoal): 1. \<And>i2. \<lbrakk>i2 < 1; n2 = length al + i2\<rbrakk> \<Longrightarrow> n1 = n2 \<and> j1 = j2 [PROOF STEP] hence j2: "j2 < f a" [PROOF STATE] proof (prove) using this: n2 = length al goal (1 subgoal): 1. j2 < f a [PROOF STEP] using snoc [PROOF STATE] proof (prove) using this: n2 = length al \<lbrakk>\<And>a. a \<in> set al \<Longrightarrow> 0 < f a; ?n1.0 < length al \<and> ?j1.0 < f (al ! ?n1.0); ?n2.0 < length al \<and> ?j2.0 < f (al ! ?n2.0); lsum f (take ?n1.0 al) + ?j1.0 = lsum f (take ?n2.0 al) + ?j2.0\<rbrakk> \<Longrightarrow> ?n1.0 = ?n2.0 \<and> ?j1.0 = ?j2.0 ?a \<in> set (al @ [a]) \<Longrightarrow> 0 < f ?a n1 < length (al @ [a]) \<and> j1 < f ((al @ [a]) ! n1) n2 < length (al @ [a]) \<and> j2 < f ((al @ [a]) ! n2) lsum f (take n1 (al @ [a])) + j1 = lsum f (take n2 (al @ [a])) + j2 goal (1 subgoal): 1. j2 < f a [PROOF STEP] by simp [PROOF STATE] proof (state) this: j2 < f a goal (1 subgoal): 1. \<And>i2. \<lbrakk>i2 < 1; n2 = length al + i2\<rbrakk> \<Longrightarrow> n1 = n2 \<and> j1 = j2 [PROOF STEP] have "lsum f (take n1 al) + j1 = lsum f al + j2" [PROOF STATE] proof (prove) goal (1 subgoal): 1. lsum f (take n1 al) + j1 = lsum f al + j2 [PROOF STEP] using n1 n2 snoc [PROOF STATE] proof (prove) using this: n1 < length al n2 = length al \<lbrakk>\<And>a. a \<in> set al \<Longrightarrow> 0 < f a; ?n1.0 < length al \<and> ?j1.0 < f (al ! ?n1.0); ?n2.0 < length al \<and> ?j2.0 < f (al ! ?n2.0); lsum f (take ?n1.0 al) + ?j1.0 = lsum f (take ?n2.0 al) + ?j2.0\<rbrakk> \<Longrightarrow> ?n1.0 = ?n2.0 \<and> ?j1.0 = ?j2.0 ?a \<in> set (al @ [a]) \<Longrightarrow> 0 < f ?a n1 < length (al @ [a]) \<and> j1 < f ((al @ [a]) ! n1) n2 < length (al @ [a]) \<and> j2 < f ((al @ [a]) ! n2) lsum f (take n1 (al @ [a])) + j1 = lsum f (take n2 (al @ [a])) + j2 goal (1 subgoal): 1. lsum f (take n1 al) + j1 = lsum f al + j2 [PROOF STEP] by simp [PROOF STATE] proof (state) this: lsum f (take n1 al) + j1 = lsum f al + j2 goal (1 subgoal): 1. \<And>i2. \<lbrakk>i2 < 1; n2 = length al + i2\<rbrakk> \<Longrightarrow> n1 = n2 \<and> j1 = j2 [PROOF STEP] hence False [PROOF STATE] proof (prove) using this: lsum f (take n1 al) + j1 = lsum f al + j2 goal (1 subgoal): 1. False [PROOF STEP] using lsum1 [PROOF STATE] proof (prove) using this: lsum f (take n1 al) + j1 = lsum f al + j2 lsum f (take n1 al) + j1 < lsum f al goal (1 subgoal): 1. False [PROOF STEP] by auto [PROOF STATE] proof (state) this: False goal (1 subgoal): 1. \<And>i2. \<lbrakk>i2 < 1; n2 = length al + i2\<rbrakk> \<Longrightarrow> n1 = n2 \<and> j1 = j2 [PROOF STEP] thus ?thesis [PROOF STATE] proof (prove) using this: False goal (1 subgoal): 1. n1 = n2 \<and> j1 = j2 [PROOF STEP] by simp [PROOF STATE] proof (state) this: n1 = n2 \<and> j1 = j2 goal: No subgoals! [PROOF STEP] qed [PROOF STATE] proof (state) this: n1 = n2 \<and> j1 = j2 goal (1 subgoal): 1. \<And>i2. \<lbrakk>i2 < 1; n1 = length al + i2\<rbrakk> \<Longrightarrow> n1 = n2 \<and> j1 = j2 [PROOF STEP] next [PROOF STATE] proof (state) goal (1 subgoal): 1. \<And>i2. \<lbrakk>i2 < 1; n1 = length al + i2\<rbrakk> \<Longrightarrow> n1 = n2 \<and> j1 = j2 [PROOF STEP] case Right [PROOF STATE] proof (state) this: i2_ < 1 n1 = length al + i2_ goal (1 subgoal): 1. \<And>i2. \<lbrakk>i2 < 1; n1 = length al + i2\<rbrakk> \<Longrightarrow> n1 = n2 \<and> j1 = j2 [PROOF STEP] hence n1: "n1 = length al" [PROOF STATE] proof (prove) using this: i2_ < 1 n1 = length al + i2_ goal (1 subgoal): 1. n1 = length al [PROOF STEP] by simp [PROOF STATE] proof (state) this: n1 = length al goal (1 subgoal): 1. \<And>i2. \<lbrakk>i2 < 1; n1 = length al + i2\<rbrakk> \<Longrightarrow> n1 = n2 \<and> j1 = j2 [PROOF STEP] hence j1: "j1 < f a" [PROOF STATE] proof (prove) using this: n1 = length al goal (1 subgoal): 1. j1 < f a [PROOF STEP] using snoc [PROOF STATE] proof (prove) using this: n1 = length al \<lbrakk>\<And>a. a \<in> set al \<Longrightarrow> 0 < f a; ?n1.0 < length al \<and> ?j1.0 < f (al ! ?n1.0); ?n2.0 < length al \<and> ?j2.0 < f (al ! ?n2.0); lsum f (take ?n1.0 al) + ?j1.0 = lsum f (take ?n2.0 al) + ?j2.0\<rbrakk> \<Longrightarrow> ?n1.0 = ?n2.0 \<and> ?j1.0 = ?j2.0 ?a \<in> set (al @ [a]) \<Longrightarrow> 0 < f ?a n1 < length (al @ [a]) \<and> j1 < f ((al @ [a]) ! n1) n2 < length (al @ [a]) \<and> j2 < f ((al @ [a]) ! n2) lsum f (take n1 (al @ [a])) + j1 = lsum f (take n2 (al @ [a])) + j2 goal (1 subgoal): 1. j1 < f a [PROOF STEP] by simp [PROOF STATE] proof (state) this: j1 < f a goal (1 subgoal): 1. \<And>i2. \<lbrakk>i2 < 1; n1 = length al + i2\<rbrakk> \<Longrightarrow> n1 = n2 \<and> j1 = j2 [PROOF STEP] from n2 [PROOF STATE] proof (chain) picking this: n2 < length al + 1 [PROOF STEP] show ?thesis [PROOF STATE] proof (prove) using this: n2 < length al + 1 goal (1 subgoal): 1. n1 = n2 \<and> j1 = j2 [PROOF STEP] proof(cases rule: less_plus_elim) [PROOF STATE] proof (state) goal (2 subgoals): 1. n2 < length al \<Longrightarrow> n1 = n2 \<and> j1 = j2 2. \<And>i2. \<lbrakk>i2 < 1; n2 = length al + i2\<rbrakk> \<Longrightarrow> n1 = n2 \<and> j1 = j2 [PROOF STEP] case Left [PROOF STATE] proof (state) this: n2 < length al goal (2 subgoals): 1. n2 < length al \<Longrightarrow> n1 = n2 \<and> j1 = j2 2. \<And>i2. \<lbrakk>i2 < 1; n2 = length al + i2\<rbrakk> \<Longrightarrow> n1 = n2 \<and> j1 = j2 [PROOF STEP] note n2 = Left [PROOF STATE] proof (state) this: n2 < length al goal (2 subgoals): 1. n2 < length al \<Longrightarrow> n1 = n2 \<and> j1 = j2 2. \<And>i2. \<lbrakk>i2 < 1; n2 = length al + i2\<rbrakk> \<Longrightarrow> n1 = n2 \<and> j1 = j2 [PROOF STEP] hence j2: "j2 < f (al ! n2)" [PROOF STATE] proof (prove) using this: n2 < length al goal (1 subgoal): 1. j2 < f (al ! n2) [PROOF STEP] using snoc [PROOF STATE] proof (prove) using this: n2 < length al \<lbrakk>\<And>a. a \<in> set al \<Longrightarrow> 0 < f a; ?n1.0 < length al \<and> ?j1.0 < f (al ! ?n1.0); ?n2.0 < length al \<and> ?j2.0 < f (al ! ?n2.0); lsum f (take ?n1.0 al) + ?j1.0 = lsum f (take ?n2.0 al) + ?j2.0\<rbrakk> \<Longrightarrow> ?n1.0 = ?n2.0 \<and> ?j1.0 = ?j2.0 ?a \<in> set (al @ [a]) \<Longrightarrow> 0 < f ?a n1 < length (al @ [a]) \<and> j1 < f ((al @ [a]) ! n1) n2 < length (al @ [a]) \<and> j2 < f ((al @ [a]) ! n2) lsum f (take n1 (al @ [a])) + j1 = lsum f (take n2 (al @ [a])) + j2 goal (1 subgoal): 1. j2 < f (al ! n2) [PROOF STEP] by auto [PROOF STATE] proof (state) this: j2 < f (al ! n2) goal (2 subgoals): 1. n2 < length al \<Longrightarrow> n1 = n2 \<and> j1 = j2 2. \<And>i2. \<lbrakk>i2 < 1; n2 = length al + i2\<rbrakk> \<Longrightarrow> n1 = n2 \<and> j1 = j2 [PROOF STEP] obtain al' where al: "al = (take n2 al) @ ((al ! n2) # al')" [PROOF STATE] proof (prove) goal (1 subgoal): 1. (\<And>al'. al = take n2 al @ al ! n2 # al' \<Longrightarrow> thesis) \<Longrightarrow> thesis [PROOF STEP] using n2 [PROOF STATE] proof (prove) using this: n2 < length al goal (1 subgoal): 1. (\<And>al'. al = take n2 al @ al ! n2 # al' \<Longrightarrow> thesis) \<Longrightarrow> thesis [PROOF STEP] by (metis append_take_drop_id Cons_nth_drop_Suc) [PROOF STATE] proof (state) this: al = take n2 al @ al ! n2 # al' goal (2 subgoals): 1. n2 < length al \<Longrightarrow> n1 = n2 \<and> j1 = j2 2. \<And>i2. \<lbrakk>i2 < 1; n2 = length al + i2\<rbrakk> \<Longrightarrow> n1 = n2 \<and> j1 = j2 [PROOF STEP] have "j2 < lsum f ((al ! n2) # al')" [PROOF STATE] proof (prove) goal (1 subgoal): 1. j2 < lsum f (al ! n2 # al') [PROOF STEP] using pos j2 [PROOF STATE] proof (prove) using this: 0 < f a ?a' \<in> set al \<Longrightarrow> 0 < f ?a' j2 < f (al ! n2) goal (1 subgoal): 1. j2 < lsum f (al ! n2 # al') [PROOF STEP] unfolding lsum_def [PROOF STATE] proof (prove) using this: 0 < f a ?a' \<in> set al \<Longrightarrow> 0 < f ?a' j2 < f (al ! n2) goal (1 subgoal): 1. j2 < sum_list (map f (al ! n2 # al')) [PROOF STEP] by simp [PROOF STATE] proof (state) this: j2 < lsum f (al ! n2 # al') goal (2 subgoals): 1. n2 < length al \<Longrightarrow> n1 = n2 \<and> j1 = j2 2. \<And>i2. \<lbrakk>i2 < 1; n2 = length al + i2\<rbrakk> \<Longrightarrow> n1 = n2 \<and> j1 = j2 [PROOF STEP] hence "lsum f (take n2 al) + j2 < lsum f (take n2 al) + lsum f ((al ! n2) # al')" [PROOF STATE] proof (prove) using this: j2 < lsum f (al ! n2 # al') goal (1 subgoal): 1. lsum f (take n2 al) + j2 < lsum f (take n2 al) + lsum f (al ! n2 # al') [PROOF STEP] by simp [PROOF STATE] proof (state) this: lsum f (take n2 al) + j2 < lsum f (take n2 al) + lsum f (al ! n2 # al') goal (2 subgoals): 1. n2 < length al \<Longrightarrow> n1 = n2 \<and> j1 = j2 2. \<And>i2. \<lbrakk>i2 < 1; n2 = length al + i2\<rbrakk> \<Longrightarrow> n1 = n2 \<and> j1 = j2 [PROOF STEP] also [PROOF STATE] proof (state) this: lsum f (take n2 al) + j2 < lsum f (take n2 al) + lsum f (al ! n2 # al') goal (2 subgoals): 1. n2 < length al \<Longrightarrow> n1 = n2 \<and> j1 = j2 2. \<And>i2. \<lbrakk>i2 < 1; n2 = length al + i2\<rbrakk> \<Longrightarrow> n1 = n2 \<and> j1 = j2 [PROOF STEP] have "... = lsum f al" [PROOF STATE] proof (prove) goal (1 subgoal): 1. lsum f (take n2 al) + lsum f (al ! n2 # al') = lsum f al [PROOF STEP] unfolding lsum_append[THEN sym] [PROOF STATE] proof (prove) goal (1 subgoal): 1. lsum f (take n2 al @ al ! n2 # al') = lsum f al [PROOF STEP] using al [PROOF STATE] proof (prove) using this: al = take n2 al @ al ! n2 # al' goal (1 subgoal): 1. lsum f (take n2 al @ al ! n2 # al') = lsum f al [PROOF STEP] by simp [PROOF STATE] proof (state) this: lsum f (take n2 al) + lsum f (al ! n2 # al') = lsum f al goal (2 subgoals): 1. n2 < length al \<Longrightarrow> n1 = n2 \<and> j1 = j2 2. \<And>i2. \<lbrakk>i2 < 1; n2 = length al + i2\<rbrakk> \<Longrightarrow> n1 = n2 \<and> j1 = j2 [PROOF STEP] finally [PROOF STATE] proof (chain) picking this: lsum f (take n2 al) + j2 < lsum f al [PROOF STEP] have lsum2: "lsum f (take n2 al) + j2 < lsum f al" [PROOF STATE] proof (prove) using this: lsum f (take n2 al) + j2 < lsum f al goal (1 subgoal): 1. lsum f (take n2 al) + j2 < lsum f al [PROOF STEP] . [PROOF STATE] proof (state) this: lsum f (take n2 al) + j2 < lsum f al goal (2 subgoals): 1. n2 < length al \<Longrightarrow> n1 = n2 \<and> j1 = j2 2. \<And>i2. \<lbrakk>i2 < 1; n2 = length al + i2\<rbrakk> \<Longrightarrow> n1 = n2 \<and> j1 = j2 [PROOF STEP] have "lsum f al + j1 = lsum f (take n2 al) + j2" [PROOF STATE] proof (prove) goal (1 subgoal): 1. lsum f al + j1 = lsum f (take n2 al) + j2 [PROOF STEP] using n1 n2 snoc [PROOF STATE] proof (prove) using this: n1 = length al n2 < length al \<lbrakk>\<And>a. a \<in> set al \<Longrightarrow> 0 < f a; ?n1.0 < length al \<and> ?j1.0 < f (al ! ?n1.0); ?n2.0 < length al \<and> ?j2.0 < f (al ! ?n2.0); lsum f (take ?n1.0 al) + ?j1.0 = lsum f (take ?n2.0 al) + ?j2.0\<rbrakk> \<Longrightarrow> ?n1.0 = ?n2.0 \<and> ?j1.0 = ?j2.0 ?a \<in> set (al @ [a]) \<Longrightarrow> 0 < f ?a n1 < length (al @ [a]) \<and> j1 < f ((al @ [a]) ! n1) n2 < length (al @ [a]) \<and> j2 < f ((al @ [a]) ! n2) lsum f (take n1 (al @ [a])) + j1 = lsum f (take n2 (al @ [a])) + j2 goal (1 subgoal): 1. lsum f al + j1 = lsum f (take n2 al) + j2 [PROOF STEP] by simp [PROOF STATE] proof (state) this: lsum f al + j1 = lsum f (take n2 al) + j2 goal (2 subgoals): 1. n2 < length al \<Longrightarrow> n1 = n2 \<and> j1 = j2 2. \<And>i2. \<lbrakk>i2 < 1; n2 = length al + i2\<rbrakk> \<Longrightarrow> n1 = n2 \<and> j1 = j2 [PROOF STEP] hence False [PROOF STATE] proof (prove) using this: lsum f al + j1 = lsum f (take n2 al) + j2 goal (1 subgoal): 1. False [PROOF STEP] using lsum2 [PROOF STATE] proof (prove) using this: lsum f al + j1 = lsum f (take n2 al) + j2 lsum f (take n2 al) + j2 < lsum f al goal (1 subgoal): 1. False [PROOF STEP] by auto [PROOF STATE] proof (state) this: False goal (2 subgoals): 1. n2 < length al \<Longrightarrow> n1 = n2 \<and> j1 = j2 2. \<And>i2. \<lbrakk>i2 < 1; n2 = length al + i2\<rbrakk> \<Longrightarrow> n1 = n2 \<and> j1 = j2 [PROOF STEP] thus ?thesis [PROOF STATE] proof (prove) using this: False goal (1 subgoal): 1. n1 = n2 \<and> j1 = j2 [PROOF STEP] by simp [PROOF STATE] proof (state) this: n1 = n2 \<and> j1 = j2 goal (1 subgoal): 1. \<And>i2. \<lbrakk>i2 < 1; n2 = length al + i2\<rbrakk> \<Longrightarrow> n1 = n2 \<and> j1 = j2 [PROOF STEP] next [PROOF STATE] proof (state) goal (1 subgoal): 1. \<And>i2. \<lbrakk>i2 < 1; n2 = length al + i2\<rbrakk> \<Longrightarrow> n1 = n2 \<and> j1 = j2 [PROOF STEP] case Right [PROOF STATE] proof (state) this: i2_ < 1 n2 = length al + i2_ goal (1 subgoal): 1. \<And>i2. \<lbrakk>i2 < 1; n2 = length al + i2\<rbrakk> \<Longrightarrow> n1 = n2 \<and> j1 = j2 [PROOF STEP] hence n2: "n2 = length al" [PROOF STATE] proof (prove) using this: i2_ < 1 n2 = length al + i2_ goal (1 subgoal): 1. n2 = length al [PROOF STEP] by simp [PROOF STATE] proof (state) this: n2 = length al goal (1 subgoal): 1. \<And>i2. \<lbrakk>i2 < 1; n2 = length al + i2\<rbrakk> \<Longrightarrow> n1 = n2 \<and> j1 = j2 [PROOF STEP] have "j1 = j2" [PROOF STATE] proof (prove) goal (1 subgoal): 1. j1 = j2 [PROOF STEP] using n1 n2 snoc [PROOF STATE] proof (prove) using this: n1 = length al n2 = length al \<lbrakk>\<And>a. a \<in> set al \<Longrightarrow> 0 < f a; ?n1.0 < length al \<and> ?j1.0 < f (al ! ?n1.0); ?n2.0 < length al \<and> ?j2.0 < f (al ! ?n2.0); lsum f (take ?n1.0 al) + ?j1.0 = lsum f (take ?n2.0 al) + ?j2.0\<rbrakk> \<Longrightarrow> ?n1.0 = ?n2.0 \<and> ?j1.0 = ?j2.0 ?a \<in> set (al @ [a]) \<Longrightarrow> 0 < f ?a n1 < length (al @ [a]) \<and> j1 < f ((al @ [a]) ! n1) n2 < length (al @ [a]) \<and> j2 < f ((al @ [a]) ! n2) lsum f (take n1 (al @ [a])) + j1 = lsum f (take n2 (al @ [a])) + j2 goal (1 subgoal): 1. j1 = j2 [PROOF STEP] by simp [PROOF STATE] proof (state) this: j1 = j2 goal (1 subgoal): 1. \<And>i2. \<lbrakk>i2 < 1; n2 = length al + i2\<rbrakk> \<Longrightarrow> n1 = n2 \<and> j1 = j2 [PROOF STEP] thus ?thesis [PROOF STATE] proof (prove) using this: j1 = j2 goal (1 subgoal): 1. n1 = n2 \<and> j1 = j2 [PROOF STEP] using n1 n2 [PROOF STATE] proof (prove) using this: j1 = j2 n1 = length al n2 = length al goal (1 subgoal): 1. n1 = n2 \<and> j1 = j2 [PROOF STEP] by simp [PROOF STATE] proof (state) this: n1 = n2 \<and> j1 = j2 goal: No subgoals! [PROOF STEP] qed [PROOF STATE] proof (state) this: n1 = n2 \<and> j1 = j2 goal: No subgoals! [PROOF STEP] qed [PROOF STATE] proof (state) this: n1 = n2 \<and> j1 = j2 goal (1 subgoal): 1. \<And>n1 n2 j1 j2. \<lbrakk>\<And>a. a \<in> set [] \<Longrightarrow> 0 < f a; n1 < length [] \<and> j1 < f ([] ! n1); n2 < length [] \<and> j2 < f ([] ! n2); lsum f (take n1 []) + j1 = lsum f (take n2 []) + j2\<rbrakk> \<Longrightarrow> n1 = n2 \<and> j1 = j2 [PROOF STEP] qed auto
function triangle_lyness_rule_test02 ( ) %*****************************************************************************80 % %% TRIANGLE_LYNESS_RULE_TEST02 performs the weight sum test on Lyness rules. % % Licensing: % % This code is distributed under the GNU LGPL license. % % Modified: % % 30 September 2010 % % Author: % % John Burkardt % fprintf ( 1, '\n' ); fprintf ( 1, 'TRIANGLE_LYNESS_RULE_TEST02\n' ); fprintf ( 1, ' LYNESS_RULE returns the points and weights\n' ); fprintf ( 1, ' of a Lyness rule for the triangle.\n' ); fprintf ( 1, '\n' ); fprintf ( 1, ' In this test, we simply check that the weights\n' ); fprintf ( 1, ' sum to 1.\n' ); rule_num = lyness_rule_num ( ); fprintf ( 1, '\n' ); fprintf ( 1, ' Number of available rules = %d\n', rule_num ); fprintf ( 1, '\n' ); fprintf ( 1, ' Rule Sum of weights\n' ); fprintf ( 1, '\n' ); for rule = 0 : rule_num order = lyness_order ( rule ); [ w, x ] = lyness_rule ( rule, order ); w_sum = sum ( w(1:order) ); fprintf ( 1, ' %8d %25.16f\n', rule, w_sum ); end return end
Formal statement is: lemma closure_cbox [simp]: "closure (cbox a b) = cbox a b" Informal statement is: The closure of a closed interval is the closed interval.
This is a rare opportunity to purchase a deep-water sound front lot on Bridgers Ave in Topsail Beach. Bridgers is considered THE street to be on in Topsail Beach and this particular lot has never been built upon. Nicely contoured and inviting. Lot is near the end of Bridgers so it is a quiet with very little traffic. Deep water assures good depth for most any boat. Come take a look at this lot build the home of your dreams!
-- Copyright 2016 TensorFlow authors. -- -- 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. {-# LANGUAGE ConstraintKinds #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE ViewPatterns #-} module TensorFlow.Gradient ( GradientCompatible , gradients ) where import Control.Monad (forM, zipWithM) import Control.Monad.State.Strict (State, evalState, gets, modify) import Data.ByteString (ByteString) import Data.Complex (Complex) import Data.Default (def) import Data.Int (Int32, Int64) import Data.Foldable (foldlM) import Data.List (foldl', sortBy) import Data.Map.Strict (Map) import Data.Maybe (fromMaybe, maybeToList, mapMaybe) import Data.Ord (comparing) import Data.ProtoLens.TextFormat (showMessage) import Data.Set (Set) import Data.Text (Text) import Data.Tuple (swap) import Lens.Family2 (Lens', view, (&), (^.), (.~), (%~)) import Lens.Family2.State.Strict (uses) import Lens.Family2.Stock (at, intAt) import Lens.Family2.Unchecked (lens, iso) import Prelude hiding (sum) import Text.Printf (printf) import qualified Data.Graph.Inductive.Basic as FGL import qualified Data.Graph.Inductive.Graph as FGL import qualified Data.Graph.Inductive.PatriciaTree as FGL import qualified Data.Graph.Inductive.Query.DFS as FGL import qualified Data.IntMap.Strict as IntMap import qualified Data.Map.Strict as Map import qualified Data.Set as Set import qualified Data.Text as Text import qualified TensorFlow.GenOps.Core as CoreOps import TensorFlow.Build ( MonadBuild , Build , build , renderedNodeDefs , opDef , opAttr , opInputs ) import TensorFlow.BuildOp import TensorFlow.Ops ( addN , broadcastGradientArgs , expandDims , fill , matMul , matMul' , reducedShape , reluGrad , reshape , scalar , shape , softmaxCrossEntropyWithLogits , sum , scalarize , vector , zerosLike ) import TensorFlow.Output ( NodeName(..) , Output(..) , OutputIx(..) , outputIndex ) import TensorFlow.Tensor ( Tensor(..) , Value , render , expr , Rendered , tensorNodeName , renderedOutput , renderValue , ToTensor(..) ) import TensorFlow.Types (Attribute, OneOf, TensorType, attrLens) import Proto.Tensorflow.Core.Framework.NodeDef (NodeDef, attr, input, op, name) type GradientCompatible a = -- TODO(fmayle): MaxPoolGrad doesn't support Double for some reason. (Num a, OneOf '[ Float, Complex Float, Complex Double ] a) -- TODO(fmayle): Support control flow. -- TODO(fmayle): Support gate_gradients-like option to avoid race conditions. -- TODO(fmayle): Do we need to consider control inputs? See _PendingCount in -- tensorflow/python/ops/gradients.py. -- TODO(fmayle): Maybe store the gradient functions and numOutputs on the OpDef. -- | Gradient of @y@ w.r.t. each element of @xs@. gradients :: forall a v1 t m . ( MonadBuild m , Rendered t , ToTensor t , GradientCompatible a ) => Tensor v1 a -- ^ The output of the graph. -> [t a] -- ^ Tensors for which gradients are computed. -> m [Tensor Value a] gradients y xs = build $ do -- The gradients are computed using "reverse accumulation", similarly to -- what is described here: -- https://en.wikipedia.org/wiki/Automatic_differentiation#The_chain_rule.2C_forward_and_reverse_accumulation -- -- The code is summarised as follows: -- -- 1. Create an fgl graph of the relevant nodes (ops) and edges (tensors). -- 2. Initialize the gradient of y to 1 (βˆ‚y/βˆ‚y = 1) and the rest of tensor's -- gradients to nothing. -- 3. Process the nodes in reverse topological order (i.e. each node comes -- after all of its outputs so that the output gradients for a node have -- been completely calculated before it is processed): -- a. Record the gradient for each of the node's output tensors (βˆ‚y/βˆ‚w -- for each output tensor w). -- b. Calculate the gradient of y w.r.t. each of the node's input -- tensors using the gradients of the node's output tensors. -- -- Written differently, for each output tensor w and input tensor v: -- βˆ‚y/βˆ‚w = ... (calculated in previous steps) -- βˆ‚w/βˆ‚v = ... (op specific) -- βˆ‚y/βˆ‚v = βˆ‚y/βˆ‚w * βˆ‚w/βˆ‚v (technically, if tensor v is an input -- to multiple nodes, then this is only -- part of βˆ‚y/βˆ‚v) -- -- 4. Lookup the recorded gradient for each x in xs. y' <- renderValue y let yName = tensorNodeName y' yOne <- render $ fill (shape y') (scalar 1) -- TODO(fmayle): Move this into Build.hs and call it unsafeNodeDefFromName? nodeDefLookup :: (NodeName -> NodeDef) <- uses renderedNodeDefs $ (\f x -> fromMaybe (error $ "no NodeDef found for " ++ show x) (f x)) . flip Map.lookup let (gr, nodeMap) = createGraph yName nodeDefLookup -- Set gradient of y to one. -- TODO: nicer let initPending :: Map.Map FGL.Node (PendingGradients a) = Map.empty & (at (nodeMap Map.! yName) . nonEmpty . outputIxAt (outputIndex $ renderedOutput y') . nonEmpty .~ [yOne] ) -- Calculate the gradients of y w.r.t. each node in the graph. gradientMap <- graphGrads gr initPending -- Lookup the gradients for each x. forM xs $ \x -> let Output i xName = renderedOutput x in maybe (render $ zerosLike $ toTensor x) return $ do n <- nodeMap ^. at xName gradientMap ^. at n . nonEmpty . outputIxAt i outputIxAt :: OutputIx -> Lens' (IntMap.IntMap v) (Maybe v) outputIxAt = intAt . unOutputIx -- | Incomplete gradients of a node's outputs. -- -- The lists represent partial sums. The key is an OutputIx sans newtype. type PendingGradients a = IntMap.IntMap [Tensor Value a] -- | Gradients of a node's outputs. The key is an OutputIx sans newtype. -- TODO: precache the rendering? type Gradients a = IntMap.IntMap (Tensor Value a) -- | Graph of TensorFlow operations. type Graph = FGL.Gr NodeDef EdgeLabel -- | Data associated with an edge. -- -- Pair of -- 1. Output index of a tensor from the source node. -- 2. Input index that the tensor connects to on the destination node. type EdgeLabel = (OutputIx, OutputIx) -- | State used for calculating gradients. data GradientsState a = GradientsState { _gradientsPending :: !(Map FGL.Node (PendingGradients a)) , _gradientsResult :: !(Map FGL.Node (Gradients a)) } gradientsPending :: Lens' (GradientsState a) (Map FGL.Node (PendingGradients a)) gradientsPending = lens _gradientsPending (\x y -> x { _gradientsPending = y }) gradientsResult :: Lens' (GradientsState a) (Map FGL.Node (Gradients a)) gradientsResult = lens _gradientsResult (\x y -> x { _gradientsResult = y }) -- TODO(fmayle): Use something like Data.List.Safe. -- | Safe version of (!!). safeIndex :: [a] -> Int -> Maybe a _ `safeIndex` n | n < 0 = Nothing [] `safeIndex` _ = Nothing (x:_) `safeIndex` 0 = Just x (_:xs) `safeIndex` n = xs `safeIndex` (n-1) -- Copy of http://hackage.haskell.org/package/lens-3.9.0.2/docs/Control-Lens-Iso.html#v%3anon anon :: a -> (a -> Bool) -> Lens' (Maybe a) a anon a p = iso (fromMaybe a) go where go b | p b = Nothing | otherwise = Just b non :: Eq a => a -> Lens' (Maybe a) a non a = anon a (a==) -- | Lens that defaults Nothing to mempty. nonEmpty :: (Monoid (t v), Foldable t) => Lens' (Maybe (t v)) (t v) nonEmpty = anon mempty null -- TODO: strictness (e.g., foldlM') -- | Calculate the gradients for every node in a graph. graphGrads :: forall a. GradientCompatible a => Graph -> Map FGL.Node (PendingGradients a) -- ^ Initial gradients (usually just 1 for the node of interest). -> Build (Map FGL.Node (Gradients a)) graphGrads gr initPending = view gradientsResult <$> foldlM go initState nodeOrder where initState = GradientsState initPending Map.empty -- Reverse topological sort. -- TODO(fmayle): Filter out nodes that are not successors of any x in xs to -- avoid calculating gradients that won't be used. nodeOrder = FGL.topsort $ FGL.grev gr go :: GradientsState a -> Int -> Build (GradientsState a) go state node = do -- Aggregate the accumulated gradients for this node. outputGrads <- sumPendingGradient (state ^. gradientsPending . at node . nonEmpty) if null outputGrads then pure state else do let ctx = FGL.context gr node inputGrads <- calculateInputGrads ctx outputGrads gr -- Calculate the gradients for each of the node's inputs. let nextState = state & gradientsResult %~ Map.insert node outputGrads pure $ updatePendingGradients ctx inputGrads nextState -- | Reduce accumulated gradients for each output to one Tensor. sumPendingGradient :: GradientCompatible a => PendingGradients a -> Build (Gradients a) sumPendingGradient = sequence . IntMap.mapMaybe f where f [] = Nothing f [x] = Just (pure x) f xs = Just (render $ addN xs) -- | Calculate the gradients of a node's input tensors. -- -- This is mostly just a wrapper around opGrad. calculateInputGrads :: forall a. GradientCompatible a => FGL.Context NodeDef EdgeLabel -> Gradients a -- ^ Output gradients of the node. -> Graph -> Build [Maybe (Tensor Value a)] calculateInputGrads (inputEdges, _, nodeDef, _) outputGrads gr = do fullOutGrads <- fullOutputGrads (numOutputs nodeDef) (nodeDefName nodeDef) outputGrads traverse (traverse render) $ opGrad (nodeDef ^. op) nodeDef inputTensors fullOutGrads where -- Create a tensor from an edge (technically an Output, but it seems less -- confusing to refer to it as a tensor here). edgeToTensor :: (EdgeLabel, FGL.Node) -> Output edgeToTensor ((i, _), n) = case FGL.lab gr n of Just edgeNodeDef -> Output i (NodeName $ edgeNodeDef ^. name) Nothing -> error $ "calculateInputGrads: missing input node for " ++ Text.unpack (nodeDef ^. name) -- Input tensors, sorted by input index. inputTensors = map edgeToTensor $ sortBy (comparing (snd . fst)) inputEdges -- | Convert a Map of gradients to a list, with zeros for missing outputs. fullOutputGrads :: (TensorType a, Num a) => OutputIx -- ^ Number of outputs. -> NodeName -> Gradients a -> Build [Tensor Value a] fullOutputGrads n o gs = mapM (\i -> maybe (render $ zero i) return (gs ^. outputIxAt i)) [0..n-1] where -- A tensor of zeros with the same shape as the i'th output. zero i = zerosLike $ toT (Output i o) -- | Update the pending gradients of a node's inputs. updatePendingGradients :: forall a. (TensorType a, Num a) => FGL.Context NodeDef EdgeLabel -> [Maybe (Tensor Value a)] -- ^ Gradient of each input tensor. -> GradientsState a -> GradientsState a updatePendingGradients (inputEdges, _, nodeDef, _) inputGrads initState = foldl' go initState inputEdges where go :: GradientsState a -> (EdgeLabel, FGL.Node) -> GradientsState a go state ((outIndex, OutputIx inIndex), node) = case maybeGradient of Nothing -> state Just g -> -- Add to the list of pending gradients for this tensor. state & gradientsPending . at node . nonEmpty . outputIxAt outIndex . nonEmpty %~ (g:) where badSizeErr = error $ printf "updatePendingGradients: bad input index \ \%d for inputGrads of length %d in %s" inIndex (length inputGrads) (show (nodeDef ^. name)) maybeGradient = fromMaybe badSizeErr (safeIndex inputGrads inIndex) -- | Create a graph that includes a node and its transitive dependencies. createGraph :: NodeName -> (NodeName -> NodeDef) -> (Graph, Map NodeName FGL.Node) createGraph nodeName nodeDefLookup = (FGL.nmap nodeDefLookup graph, nodeMap) where -- Parse a tensor name. parseTensorName :: Text -> Maybe (NodeName, OutputIx) parseTensorName n | Text.null n = error "parseTensorName: empty name" | Text.head n == '^' = Nothing -- Control edge | otherwise = let (nm, indexStr) = Text.breakOn ":" n index | Text.null indexStr = 0 | otherwise = read $ Text.unpack $ Text.tail indexStr in Just (NodeName nm, OutputIx index) -- Build a map from node name to outward edges. -- -- The state is the set of visited nodes. collect :: Maybe (NodeName, OutputIx, OutputIx) -> NodeName -> State (Set NodeName) (Map NodeName [(NodeName, OutputIx, OutputIx)]) collect outgoingEdge nm = do let nextLookup = Map.singleton nm (maybeToList outgoingEdge) seen <- gets (Set.member nm) modify (Set.insert nm) if seen then pure nextLookup else do let inputs = nodeDefLookup nm ^. input recurse inIndex (parentName, outIndex) = collect (Just (nm, outIndex, inIndex)) parentName subEdgeLookups <- zipWithM recurse [0..] $ mapMaybe parseTensorName inputs pure $ Map.unionsWith (++) (nextLookup:subEdgeLookups) edgeLookup = evalState (collect Nothing nodeName) Set.empty -- Associate an ID with each node name. nodeMap = Map.fromList $ zip (Map.keys edgeLookup) [0..] -- Create the graph. graph = FGL.mkGraph (swap <$> Map.toList nodeMap) [ (nodeMap Map.! n, nodeMap Map.! m, (i, j)) | (n, edges) <- Map.toList edgeLookup , (m, i, j) <- edges ] -- | Function to compute the gradient of y w.r.t. each input. -- -- Let y be an arbitrary tensor -- and [w_0, ..., w_n] be the output tensors of a node -- and [v_0, ..., v_n] be the input tensors of the same node. -- -- Given [βˆ‚y/βˆ‚w_0, ..., βˆ‚y/βˆ‚w_n] and [v_0, ..., v_n], a GradientFunc computes -- [βˆ‚y/βˆ‚v_0, ..., βˆ‚y/βˆ‚v_n] for a particular op type. -- -- A Nothing gradient is equivalent to zero (but allows for short circuiting -- computation when all the gradients for something are Nothing). type GradientFunc a = NodeDef -> [Output] -- ^ Input tensors. -> [Tensor Value a] -- ^ Gradient of y w.r.t. each output tensor. -> [Maybe (Tensor Build a)] -- ^ Gradient of y w.r.t. each input tensor. -- TODO(fmayle): Assert the type is correct. -- | Create a Tensor from an Output. toT :: Output -> Tensor Build a toT = Tensor . pure -- | Wrapper around `TensorFlow.GenOps.Core.slice` that builds vectors from scalars for -- simple slicing operations. flatSlice :: forall v1 t . TensorType t => Tensor v1 t -- ^ __input__ -> Int32 -- ^ __begin__: specifies the offset into the first dimension of -- 'input' to slice from. -> Int32 -- ^ __size__: specifies the number of elements of the first dimension -- of 'input' to slice. If size is -1, all remaining elements in the dimension -- are included in the slice (i.e. this is equivalent to setting -- size = input.dim_size(0) - begin). -> Tensor Build t -- ^ __output__ flatSlice t begin size = CoreOps.slice t (vector [begin]) (vector [size]) nodeDefName :: NodeDef -> NodeName nodeDefName = NodeName . view name -- | Gradient helper for binary component wise operations -- See https://github.com/tensorflow/tensorflow/blob/e9de087fa7f59c39bbe12ac2c83c5547c83f746c/tensorflow/core/ops/math_grad.cc#L329 gradForBinaryCwise :: ( OneOf '[ Int32, Int64, Float, Double, Complex Float, Complex Double ] t ) => (Tensor v1 t, Tensor v1 t) -> (Tensor v1 t, Tensor v1 t) -> [ Maybe (Tensor Build t) ] gradForBinaryCwise (x, gx) (y, gy) = [ Just dx , Just dy ] where dx = reshape (sum gx rx) sx dy = reshape (sum gy ry) sy sx = shape x sy = shape y (rx, ry) = broadcastGradientArgs sx sy -- | The gradient function for an op type. -- -- These implementations should match their python counterparts in: -- third_party/tensorflow/python/ops/*_grad.py opGrad :: forall a . GradientCompatible a => Text -> GradientFunc a opGrad "Abs" _ [toT -> x] [dz] = [Just $ expr dz * signum x] opGrad "Neg" _ [_] [dz] = [Just $ negate $ expr dz] opGrad "Relu" _ [toT -> x] [dz] = [Just $ reluGrad dz x] opGrad "ReluGrad" _ [_, toT -> x ] [dz] = [Just $ reluGrad dz x, Just $ CoreOps.zerosLike x] opGrad "Concat" _ _ix [dy] -- Concat concatenates input tensors -- x1 of shape s1 = [k1, ..., ki_1, ..., kn] -- x2 of shape s2 = [k1, ..., ki_2, ..., kn] -- . . . . . -- . . . . . -- . . . . . -- xm of shape sm = [k1, ..., ki_m, ..., kn] -- along dimension i to an output tensor -- y of shape sy = [k1, ..., k, ..., kn] -- where k = sum ki = sum [ki_1,...,ki_m] -- -- The incoming gradient dy from backpropagation is -- simply forwarded split across input tensors yielding dx. -- Forwarded gradients have shapes s = [s1, ..., sm]. | m == 1 = Nothing : [Just $ expr dy] | otherwise = Nothing : map Just (dx `reshapeZip` s) where reshapeZip = zipWith reshape dx = CoreOps.splitV (fromIntegral m) dy ki _i s :: [Tensor Build Int32] s = map shape x x :: [Tensor Build a] x = map toT $ tail _ix -- i: concat dimension. Adjusted modulo n to handle negative indices. _i = toT (head _ix) `CoreOps.floorMod` n i = reshape _i $ vector [1 :: Int32] -- sizes along concatenated dimension ki :: Tensor Build Int32 ki = CoreOps.concat 0 $ map (\t -> CoreOps.slice t i $ vector [1 :: Int32]) s m = length x n = CoreOps.rank (head x) opGrad "Square" _ [toT -> x] [dz] = -- TODO(fmayle): Handle complex numbers. -- TODO(fmayle): The python code makes dz a control dependency of the 2*x -- (for performance reasons?). Will need to put these functions in the Build -- monad to replicate that. [Just $ dz `CoreOps.mul` (2 * x)] opGrad "Gather" _ [toT -> x, toT -> indices] [dz] = -- TODO(fmayle): The python version uses a better performance implementation -- when the shape is known without having to run the graph. -- TODO(fmayle): We shouldn't convert the result to a dense tensor. Sparse -- tensor support will require some thinking. [ Just $ CoreOps.unsortedSegmentSum values indices' numRows , Nothing ] where -- TODO(gnezdo): Use colocateWith but it requires Build monad. denseShape = shape (x :: Tensor Build a) numRows = scalarize $ flatSlice denseShape 0 1 valuesShape = CoreOps.concat 0 [ allDimensions , flatSlice denseShape 1 (-1) ] values = reshape dz valuesShape -- TODO(fmayle): This could be either Int32 or Int64. indices' = reshape indices allDimensions :: Tensor Build Int32 opGrad "Max" _ [toT -> x, toT -> indices] [dz] = [Just $ indicators `CoreOps.div` numSelected * dz', Nothing] where sx = shape (x :: Tensor Build a) outputShapeKeptDims = reducedShape sx (indices :: Tensor Build Int32) y = CoreOps.max x indices y' = reshape y outputShapeKeptDims dz' = reshape dz outputShapeKeptDims indicators = CoreOps.cast $ CoreOps.equal y' x numSelected = reshape (sum indicators indices) outputShapeKeptDims -- Min and Max have identical gradient implementations. opGrad "Min" u v w = opGrad "Max" u v w -- Element wise maximum gradient -- See https://github.com/tensorflow/tensorflow/blob/e9de087fa7f59c39bbe12ac2c83c5547c83f746c/tensorflow/core/ops/math_grad.cc#L473 opGrad "Maximum" _ [toT -> x, toT -> y] [dz] = gradForBinaryCwise (x, gx) (y, gy) where xmask = CoreOps.greaterEqual x y gx = CoreOps.select xmask dz (CoreOps.zerosLike dz) gy = CoreOps.select (CoreOps.logicalNot xmask) dz (CoreOps.zerosLike dz) opGrad "Sum" _ [toT -> x, toT -> indices] [dz] = [ Just $ CoreOps.tile grad tileScaling, Nothing ] where -- TODO(gnezdo): Implement the fast-path from math_grad._SumGrad. sx = shape (x :: Tensor Build a) outputShapeKeptDims = reducedShape sx (indices :: Tensor Build Int32) tileScaling = safeShapeDiv sx outputShapeKeptDims grad = reshape dz outputShapeKeptDims opGrad "Mean" u v@[toT -> x, _] w = [Just $ dz `CoreOps.div` CoreOps.cast factor, Nothing] where [Just dz, Nothing] = opGrad "Sum" u v w inputShape = shape (x :: Tensor Build a) outputShape = shape (dz :: Tensor Build a) -- TODO(fmayle): Add fast path when shape is known. inputSize = CoreOps.prod inputShape $ rangeOfRank inputShape outputSize = CoreOps.prod outputShape $ rangeOfRank outputShape factor = safeShapeDiv inputSize outputSize opGrad "Add" _ [toT -> x, toT -> y] [dz] = [ Just $ reshape (sum dz rx) sx , Just $ reshape (sum dz ry) sy ] where sx = shape (x :: Tensor Build a) sy = shape (y :: Tensor Build a) (rx, ry) = broadcastGradientArgs sx sy -- Copies the gradients to all inputs -- Not broadcasting opGrad "AddN" _ inputs [dz] = map ((const . Just . expr) dz) inputs opGrad "Sub" u v w = [Just x, Just (-y)] where [Just x, Just y] = opGrad "Add" u v w opGrad "SoftmaxCrossEntropyWithLogits" _ [toT -> x, toT -> y] [dz, _] = [ Just $ expandDims dz (-1) * snd (softmaxCrossEntropyWithLogits x y) , Nothing ] opGrad "Mul" _ [toT -> x, toT -> y] [dz] = -- TODO(fmayle): Handle complex numbers. [ Just $ reshape (sum (dz `CoreOps.mul` y) rx) sx , Just $ reshape (sum (x `CoreOps.mul` dz) ry) sy ] where sx = shape (x :: Tensor Build a) sy = shape (y :: Tensor Build a) (rx, ry) = broadcastGradientArgs sx sy opGrad "Div" _ [toT -> x, toT -> y] [dz] = -- TODO(fmayle): Handle complex numbers. -- TODO(gnezdo): Provide Fractional instance and use '/' instead of div. [ Just $ reshape (sum (dz `CoreOps.div` y) rx) sx , Just $ reshape (sum (dz `CoreOps.mul` (negate x `CoreOps.div` (y * y))) ry) sy ] where sx = shape (x :: Tensor Build a) sy = shape (y :: Tensor Build a) (rx, ry) = broadcastGradientArgs sx sy opGrad "MatMul" nodeDef [toT -> x, toT -> y] [dz] = let transposeA = lookupAttr nodeDef "transpose_a" transposeB = lookupAttr nodeDef "transpose_b" transAttrs a b = (opAttr "transpose_a" .~ a) . (opAttr "transpose_b" .~ b) in case (transposeA, transposeB) of (False, False) -> [ Just $ matMul' (transAttrs False True) dz y , Just $ matMul' (transAttrs True False) x dz] (False, True) -> [ Just $ matMul dz y , Just $ matMul' (transAttrs True False) dz x] (True, False) -> [ Just $ matMul' (transAttrs False True) y dz , Just $ matMul x dz] (True, True) -> [ Just $ matMul' (transAttrs True True) y dz , Just $ matMul' (transAttrs True True) dz x] opGrad "Transpose" _ [_, toT -> p] [dz] = [ Just $ CoreOps.transpose dz (CoreOps.invertPermutation p :: Tensor Build Int32) , Nothing ] opGrad "Conv2D" nodeDef [toT -> x, toT -> y] [dz] = [ Just $ CoreOps.conv2DBackpropInput' ((opAttr "strides" .~ strides) . (opAttr "padding" .~ padding) . (opAttr "use_cudnn_on_gpu" .~ useCudnnOnGpu) . (opAttr "data_format" .~ dataFormat)) (shape x) y dz , Just $ CoreOps.conv2DBackpropFilter' ((opAttr "strides" .~ strides) . (opAttr "padding" .~ padding) . (opAttr "use_cudnn_on_gpu" .~ useCudnnOnGpu) . (opAttr "data_format" .~ dataFormat)) x (shape y) dz ] where strides = lookupAttr nodeDef "strides" :: [Int64] padding = lookupAttr nodeDef "padding" :: ByteString useCudnnOnGpu = lookupAttr nodeDef "use_cudnn_on_gpu" :: Bool dataFormat = lookupAttr nodeDef "data_format" :: ByteString opGrad "Conv2DBackpropInput" nodeDef [_, toT -> x, toT -> y] [dz] = [ Nothing , Just $ CoreOps.conv2DBackpropFilter' ((opAttr "strides" .~ strides) . (opAttr "padding" .~ padding) . (opAttr "use_cudnn_on_gpu" .~ useCudnnOnGpu) . (opAttr "data_format" .~ dataFormat)) dz (shape x) y , Just $ CoreOps.conv2D' ((opAttr "strides" .~ strides) . (opAttr "padding" .~ padding) . (opAttr "use_cudnn_on_gpu" .~ useCudnnOnGpu) . (opAttr "data_format" .~ dataFormat)) dz x ] where strides = lookupAttr nodeDef "strides" :: [Int64] padding = lookupAttr nodeDef "padding" :: ByteString useCudnnOnGpu = lookupAttr nodeDef "use_cudnn_on_gpu" :: Bool dataFormat = lookupAttr nodeDef "data_format" :: ByteString opGrad "MaxPool" nodeDef [toT -> x] [dz] = [ Just $ CoreOps.maxPoolGrad' ((opAttr "ksize" .~ ksize) . (opAttr "strides" .~ strides) . (opAttr "padding" .~ padding) . (opAttr "data_format" .~ dataFormat)) x output dz ] where output :: Tensor Build a output = toT $ Output 0 (nodeDefName nodeDef) ksize = lookupAttr nodeDef "ksize" :: [Int64] strides = lookupAttr nodeDef "strides" :: [Int64] padding = lookupAttr nodeDef "padding" :: ByteString dataFormat = lookupAttr nodeDef "data_format" :: ByteString opGrad "Reshape" _ [toT -> x, _] [dz] = [Just $ reshape dz $ shape (x :: Tensor Build a), Nothing] opGrad "OneHot" _ _ _ = [Nothing, Nothing, Nothing, Nothing] opGrad "TruncatedNormal" _ _ _ = [Nothing] opGrad "RefIdentity" _ _ [dz] = [Just $ expr dz] opGrad "Cast" nodeDef _ [dz] = [Just reverseCast] where -- TODO(gnezdo): too permissive, python only allows float types as src_type. reverseCast = pureOp [] $ pure (opDef "Cast" & opAttr "DstT" .~ (lookupAttr nodeDef "SrcT" :: ByteString) & opAttr "SrcT" .~ (lookupAttr nodeDef "DstT" :: ByteString) & opInputs .~ [renderedOutput dz]) opGrad "DynamicStitch" nodeDef inputs [dz] = replicate halfLen Nothing ++ valuesGrads where halfLen = let len = length inputs half = len `div` 2 in if 2 * half == len then half else error ("Uneven input size " ++ show (len, showMessage nodeDef)) valuesGrads = [ Just $ CoreOps.gather dz (toT idx :: Tensor Build Int32) | idx <- take halfLen inputs ] opGrad "DynamicPartition" nodeDef [toT -> xs, toT -> indices] dz = [ Just reconstructed, Nothing ] where reconstructed = CoreOps.reshape stitched (CoreOps.shape (xs :: Tensor Build a) :: Tensor Build Int32) stitched = CoreOps.dynamicStitch partitionedIndices dz partitionedIndices = CoreOps.dynamicPartition np originalIndices indices np = lookupAttr nodeDef "num_partitions" :: Int64 originalIndices = CoreOps.reshape (CoreOps.range 0 (CoreOps.size indices) 1) prefixShape prefixShape = shapeInt32 indices shapeInt32 t = CoreOps.shape t :: Tensor Build Int32 opGrad "Select" _ [toT -> c, toT -> x, _] [dz] = [ Nothing , Just $ CoreOps.select c dz zeros , Just $ CoreOps.select c zeros dz ] where zeros = CoreOps.zerosLike x -- TODO(gnezdo): Unlike Python, no control dependency on dz. opGrad "Log" _ [toT -> x] [dz] = [ Just $ dz `CoreOps.mul` CoreOps.inv x ] -- TODO(gnezdo): Reuse the output instead of doing another exp, -- though, it is probably CSE'd away anyway. opGrad "Exp" _ [toT -> x] [dz] = [ Just $ dz `CoreOps.mul` CoreOps.exp x ] opGrad "SparseSegmentSum" _ [toT -> x, toT -> y, toT -> t] [dz] = [ Just $ CoreOps.unsortedSegmentSum (CoreOps.gather dz (t :: Tensor Build Int32)) (y :: Tensor Build Int32) inputRows , Nothing , Nothing ] where inputRows = flatSlice (shape (x :: Tensor Build a)) 0 1 opGrad "LabelClasses" _ _ _ = [Nothing, Nothing] opGrad "LabelWeights" _ _ _ = [Nothing] opGrad "Size" _ _ _ = [Nothing] -- TODO (jcberentsen): Python implementation uses set_shape for -- static shape inference, which is unsupported. -- TODO: implement support for static shape inference opGrad "Tile" _ [toT -> x, toT -> multiples] [dz] = [Just inputGrad, Nothing] where inputGrad = sum reshapedDz axes inputShape = shape (x :: Tensor Build a) packed = CoreOps.pack [multiples, inputShape] perm = vector [1, 0 :: Int32] splitShape = CoreOps.reshape (CoreOps.transpose packed perm) allDimensions axes = CoreOps.range 0 (CoreOps.size splitShape) (2 :: Tensor Build Int32) reshapedDz = CoreOps.reshape dz splitShape opGrad "ZerosLike" _ _ _ = [Nothing] opGrad "Fill" _ _ [dz] = [Nothing, Just $ sum dz rx] where rx = rangeOfRank dz -- Treat read ops as an identity function on the variable. This allows us to -- take gradients w.r.t. to the variable handle instead of the result of a read -- op. If a variable is read multiple times, the gradients will propagate back -- through each read. opGrad "ReadVariableOp" _ _ [dz] = [Just $ expr dz] -- TODO(fmayle): These can go away if we properly prune the graph. opGrad "Const" _ _ _ = [Nothing, Nothing] opGrad "Placeholder" _ _ _ = [] opGrad "VarHandleOp" _ _ _ = [] opGrad "Variable" _ _ _ = [] opGrad n nodeDef ins grads = error $ "no gradient implemented for " ++ show (n, length ins, length grads, showMessage nodeDef, ins) -- | The number of outputs for an op type. numOutputs :: NodeDef -> OutputIx numOutputs o = case o ^. op of "Abs" -> 1 "Add" -> 1 "AddN" -> 1 "Cast" -> 1 "Const" -> 1 "Concat" -> 1 "Conv2D" -> 1 "Conv2DBackpropInput" -> 1 "Div" -> 1 "DynamicStitch" -> 1 "DynamicPartition" -> fromIntegral (lookupAttr o "num_partitions" :: Int64) "Exp" -> 1 "Gather" -> 1 "LabelClasses" -> 1 "LabelWeights" -> 1 "Log" -> 1 "MatMul" -> 1 "Max" -> 1 "Maximum" -> 1 "MaxPool" -> 1 "Mean" -> 1 "Min" -> 1 "Mul" -> 1 "Neg" -> 1 "Placeholder" -> 1 "OneHot" -> 1 "ReadVariableOp" -> 1 "RefIdentity" -> 1 "Relu" -> 1 "ReluGrad" -> 1 "Reshape" -> 1 "Select" -> 1 "Size" -> 1 "SoftmaxCrossEntropyWithLogits" -> 2 "Square" -> 1 "SparseSegmentSum" -> 1 "Sub" -> 1 "Sum" -> 1 "Tile" -> 1 "Transpose" -> 1 "TruncatedNormal" -> 1 "VarHandleOp" -> 1 "Variable" -> 1 "ZerosLike" -> 1 "Fill" -> 1 _ -> error $ "numOutputs not implemented for " ++ show (o ^. op) -- Divides `x / y` assuming `x, y >= 0`, treating `0 / 0 = 0` safeShapeDiv :: Tensor v1 Int32 -> Tensor v2 Int32 -> Tensor Build Int32 safeShapeDiv x y = x `CoreOps.div` (CoreOps.maximum y 1) allDimensions :: Tensor Build Int32 allDimensions = vector [-1 :: Int32] rangeOfRank :: forall v1 t. TensorType t => Tensor v1 t -> Tensor Build Int32 rangeOfRank x = CoreOps.range 0 (CoreOps.rank x) 1 lookupAttr :: Attribute a1 => NodeDef -> Text -> a1 lookupAttr nodeDef attrName = nodeDef ^. attr . at attrName . non def . attrLens
/- Copyright (c) 2020 FrΓ©dΓ©ric Dupuis. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: FrΓ©dΓ©ric Dupuis -/ import analysis.convex.function import topology.algebra.affine import topology.local_extr import topology.metric_space.basic /-! # Minima and maxima of convex functions We show that if a function `f : E β†’ Ξ²` is convex, then a local minimum is also a global minimum, and likewise for concave functions. -/ variables {E Ξ² : Type*} [add_comm_group E] [topological_space E] [module ℝ E] [topological_add_group E] [has_continuous_smul ℝ E] [linear_ordered_add_comm_group Ξ²] [module ℝ Ξ²] [ordered_smul ℝ Ξ²] {s : set E} open set filter open_locale classical /-- Helper lemma for the more general case: `is_min_on.of_is_local_min_on_of_convex_on`. -/ lemma is_min_on.of_is_local_min_on_of_convex_on_Icc {f : ℝ β†’ Ξ²} {a b : ℝ} (a_lt_b : a < b) (h_local_min : is_local_min_on f (Icc a b) a) (h_conv : convex_on ℝ (Icc a b) f) : βˆ€ x ∈ Icc a b, f a ≀ f x := begin by_contradiction H_cont, push_neg at H_cont, rcases H_cont with ⟨x, ⟨h_ax, h_xb⟩, fx_lt_fa⟩, obtain ⟨z, hz, ge_on_nhd⟩ : βˆƒ z > a, βˆ€ y ∈ (Icc a z), f y β‰₯ f a, { rcases eventually_iff_exists_mem.mp h_local_min with ⟨U, U_in_nhds_within, fy_ge_fa⟩, rw [nhds_within_Icc_eq_nhds_within_Ici a_lt_b, mem_nhds_within_Ici_iff_exists_Icc_subset] at U_in_nhds_within, rcases U_in_nhds_within with ⟨Ρ, Ξ΅_in_Ioi, Ioc_in_U⟩, exact ⟨Ρ, mem_Ioi.mp Ξ΅_in_Ioi, Ξ» y y_in_Ioc, fy_ge_fa y $ Ioc_in_U y_in_Ioc⟩ }, have a_lt_x : a < x := lt_of_le_of_ne h_ax (Ξ» H, by subst H; exact lt_irrefl (f a) fx_lt_fa), have lt_on_nhd : βˆ€ y ∈ Ioc a x, f y < f a, { intros y y_in_Ioc, rcases (convex.mem_Ioc a_lt_x).mp y_in_Ioc with ⟨ya, yx, ya_pos, yx_pos, yax, y_combo⟩, calc f y = f (ya * a + yx * x) : by rw [y_combo] ... ≀ ya β€’ f a + yx β€’ f x : h_conv.2 (left_mem_Icc.mpr (le_of_lt a_lt_b)) ⟨h_ax, h_xb⟩ (ya_pos) (le_of_lt yx_pos) yax ... < ya β€’ f a + yx β€’ f a : add_lt_add_left (smul_lt_smul_of_pos fx_lt_fa yx_pos) _ ... = f a : by rw [←add_smul, yax, one_smul] }, by_cases h_xz : x ≀ z, { exact not_lt_of_ge (ge_on_nhd x (show x ∈ Icc a z, by exact ⟨h_ax, h_xz⟩)) fx_lt_fa, }, { have h₁ : z ∈ Ioc a x := ⟨hz, le_of_not_ge h_xz⟩, have hβ‚‚ : z ∈ Icc a z := ⟨le_of_lt hz, le_refl z⟩, exact not_lt_of_ge (ge_on_nhd z hβ‚‚) (lt_on_nhd z h₁) } end /-- A local minimum of a convex function is a global minimum, restricted to a set `s`. -/ lemma is_min_on.of_is_local_min_on_of_convex_on {f : E β†’ Ξ²} {a : E} (a_in_s : a ∈ s) (h_localmin : is_local_min_on f s a) (h_conv : convex_on ℝ s f) : βˆ€ x ∈ s, f a ≀ f x := begin by_contradiction H_cont, push_neg at H_cont, rcases H_cont with ⟨x, ⟨x_in_s, fx_lt_fa⟩⟩, let g : ℝ →ᡃ[ℝ] E := affine_map.line_map a x, have hg0 : g 0 = a := affine_map.line_map_apply_zero a x, have hg1 : g 1 = x := affine_map.line_map_apply_one a x, have fg_local_min_on : is_local_min_on (f ∘ g) (g ⁻¹' s) 0, { rw ←hg0 at h_localmin, refine is_local_min_on.comp_continuous_on h_localmin subset.rfl (continuous.continuous_on (affine_map.line_map_continuous)) _, simp [mem_preimage, hg0, a_in_s] }, have fg_min_on : βˆ€ x ∈ (Icc 0 1 : set ℝ), (f ∘ g) 0 ≀ (f ∘ g) x, { have Icc_in_s' : Icc 0 1 βŠ† (g ⁻¹' s), { have h0 : (0 : ℝ) ∈ (g ⁻¹' s) := by simp [mem_preimage, a_in_s], have h1 : (1 : ℝ) ∈ (g ⁻¹' s) := by simp [mem_preimage, hg1, x_in_s], rw ←segment_eq_Icc (show (0 : ℝ) ≀ 1, by linarith), exact (convex.affine_preimage g h_conv.1).segment_subset (by simp [mem_preimage, hg0, a_in_s]) (by simp [mem_preimage, hg1, x_in_s]) }, have fg_local_min_on' : is_local_min_on (f ∘ g) (Icc 0 1) 0 := is_local_min_on.on_subset fg_local_min_on Icc_in_s', refine is_min_on.of_is_local_min_on_of_convex_on_Icc (by linarith) fg_local_min_on' _, exact (convex_on.comp_affine_map g h_conv).subset Icc_in_s' (convex_Icc 0 1) }, have gx_lt_ga : (f ∘ g) 1 < (f ∘ g) 0 := by simp [hg1, fx_lt_fa, hg0], exact not_lt_of_ge (fg_min_on 1 (mem_Icc.mpr ⟨zero_le_one, le_refl 1⟩)) gx_lt_ga, end /-- A local maximum of a concave function is a global maximum, restricted to a set `s`. -/ lemma is_max_on.of_is_local_max_on_of_concave_on {f : E β†’ Ξ²} {a : E} (a_in_s : a ∈ s) (h_localmax: is_local_max_on f s a) (h_conc : concave_on ℝ s f) : βˆ€ x ∈ s, f x ≀ f a := @is_min_on.of_is_local_min_on_of_convex_on _ (order_dual Ξ²) _ _ _ _ _ _ _ _ s f a a_in_s h_localmax h_conc /-- A local minimum of a convex function is a global minimum. -/ lemma is_min_on.of_is_local_min_of_convex_univ {f : E β†’ Ξ²} {a : E} (h_local_min : is_local_min f a) (h_conv : convex_on ℝ univ f) : βˆ€ x, f a ≀ f x := Ξ» x, (is_min_on.of_is_local_min_on_of_convex_on (mem_univ a) (is_local_min.on h_local_min univ) h_conv) x (mem_univ x) /-- A local maximum of a concave function is a global maximum. -/ lemma is_max_on.of_is_local_max_of_convex_univ {f : E β†’ Ξ²} {a : E} (h_local_max : is_local_max f a) (h_conc : concave_on ℝ univ f) : βˆ€ x, f x ≀ f a := @is_min_on.of_is_local_min_of_convex_univ _ (order_dual Ξ²) _ _ _ _ _ _ _ _ f a h_local_max h_conc
(* Default settings (from HsToCoq.Coq.Preamble) *) Generalizable All Variables. Unset Implicit Arguments. Set Maximal Implicit Insertion. Unset Strict Implicit. Unset Printing Implicit Defensive. Require Coq.Program.Tactics. Require Coq.Program.Wf. (* Preamble *) Require Import Data.Monoid. (* Converted imports: *) Require Coq.Program.Basics. Require Data.Either. Require Data.Maybe. Require Data.Monoid. Require Data.Proxy. Require Data.SemigroupInternal. Require GHC.Base. Require GHC.List. Require GHC.Num. Require GHC.Prim. Require GHC.Tuple. Import GHC.Base.Notations. Import GHC.Num.Notations. (* Converted type declarations: *) Record Foldable__Dict t := Foldable__Dict_Build { fold__ : forall {m}, forall `{GHC.Base.Monoid m}, t m -> m ; foldMap__ : forall {m} {a}, forall `{GHC.Base.Monoid m}, (a -> m) -> t a -> m ; foldl__ : forall {b} {a}, (b -> a -> b) -> b -> t a -> b ; foldl'__ : forall {b} {a}, (b -> a -> b) -> b -> t a -> b ; foldr__ : forall {a} {b}, (a -> b -> b) -> b -> t a -> b ; foldr'__ : forall {a} {b}, (a -> b -> b) -> b -> t a -> b ; length__ : forall {a}, t a -> GHC.Num.Int ; null__ : forall {a}, t a -> bool ; product__ : forall {a}, forall `{GHC.Num.Num a}, t a -> a ; sum__ : forall {a}, forall `{GHC.Num.Num a}, t a -> a ; toList__ : forall {a}, t a -> list a }. Definition Foldable t := forall r__, (Foldable__Dict t -> r__) -> r__. Existing Class Foldable. Definition fold `{g__0__ : Foldable t} : forall {m}, forall `{GHC.Base.Monoid m}, t m -> m := g__0__ _ (fold__ t). Definition foldMap `{g__0__ : Foldable t} : forall {m} {a}, forall `{GHC.Base.Monoid m}, (a -> m) -> t a -> m := g__0__ _ (foldMap__ t). Definition foldl `{g__0__ : Foldable t} : forall {b} {a}, (b -> a -> b) -> b -> t a -> b := g__0__ _ (foldl__ t). Definition foldl' `{g__0__ : Foldable t} : forall {b} {a}, (b -> a -> b) -> b -> t a -> b := g__0__ _ (foldl'__ t). Definition foldr `{g__0__ : Foldable t} : forall {a} {b}, (a -> b -> b) -> b -> t a -> b := g__0__ _ (foldr__ t). Definition foldr' `{g__0__ : Foldable t} : forall {a} {b}, (a -> b -> b) -> b -> t a -> b := g__0__ _ (foldr'__ t). Definition length `{g__0__ : Foldable t} : forall {a}, t a -> GHC.Num.Int := g__0__ _ (length__ t). Definition null `{g__0__ : Foldable t} : forall {a}, t a -> bool := g__0__ _ (null__ t). Definition product `{g__0__ : Foldable t} : forall {a}, forall `{GHC.Num.Num a}, t a -> a := g__0__ _ (product__ t). Definition sum `{g__0__ : Foldable t} : forall {a}, forall `{GHC.Num.Num a}, t a -> a := g__0__ _ (sum__ t). Definition toList `{g__0__ : Foldable t} : forall {a}, t a -> list a := g__0__ _ (toList__ t). (* Midamble *) Definition default_foldable {f:Type -> Type} (foldMap : forall m a, forall (S : GHC.Base.Semigroup m) (M : GHC.Base.Monoid m), (a -> m) -> f a -> m) (foldr : forall a b, (a -> b -> b) -> b -> f a -> b):= let foldl : forall b a, (b -> a -> b) -> b -> f a -> b := (fun b a => fun f z t => Data.SemigroupInternal.appEndo (Data.SemigroupInternal.getDual (foldMap _ _ _ _ (Coq.Program.Basics.compose Data.SemigroupInternal.Mk_Dual (Coq.Program.Basics.compose Data.SemigroupInternal.Mk_Endo (GHC.Base.flip f))) t)) z) in let foldl' : forall b a, (b -> a -> b) -> b -> f a -> b := (fun {b} {a} => fun f z0 xs => let f' := fun x k z => GHC.Base.op_zdzn__ k (f z x) in foldr _ _ f' GHC.Base.id xs z0) in Foldable__Dict_Build f (* fold *) (fun m (S : GHC.Base.Semigroup m) (M : GHC.Base.Monoid m) => foldMap _ _ _ _ GHC.Base.id) (* foldMap *) (@foldMap) (* foldl *) (@foldl) (* foldl' *) (@foldl') (* foldr *) (@foldr) (* foldr' *) (fun a b f z0 xs => let f' := fun k x z => GHC.Base.op_zdzn__ k (f x z) in @foldl _ _ f' GHC.Base.id xs z0) (* length *) (fun a => @foldl' _ a (fun c _ => GHC.Num.op_zp__ c (GHC.Num.fromInteger 1)) (GHC.Num.fromInteger 0)) (* null *) (fun a => @foldr _ _ (fun arg_61__ arg_62__ => false) true) (* product *) (fun a `{GHC.Num.Num a} => Coq.Program.Basics.compose Data.SemigroupInternal.getProduct (foldMap _ _ _ _ Data.SemigroupInternal.Mk_Product)) (* sum *) (fun a `{GHC.Num.Num a} => Coq.Program.Basics.compose Data.SemigroupInternal.getSum (foldMap _ _ _ _ Data.SemigroupInternal.Mk_Sum)) (* toList *) (fun a => fun t => GHC.Base.build (fun _ c n => @foldr _ _ c n t)). Definition default_foldable_foldMap {f : Type -> Type} (foldMap : forall {m} {a}, forall `{GHC.Base.Monoid m}, (a -> m) -> f a -> m) := let foldr : forall {a} {b}, (a -> b -> b) -> b -> f a -> b := fun a b f z t => Data.SemigroupInternal.appEndo (foldMap (Coq.Program.Basics.compose Data.SemigroupInternal.Mk_Endo f) t) z in default_foldable (fun {m}{a} `{GHC.Base.Monoid m} => foldMap) foldr. Definition default_foldable_foldr (f : Type -> Type) (foldr : forall {a} {b}, (a -> b -> b) -> b -> f a -> b) := let foldMap : forall {m} {a} `{GHC.Base.Monoid m}, (a -> m) -> f a -> m := fun m a (S : GHC.Base.Semigroup m) (H : GHC.Base.Monoid m) => fun f => foldr (Coq.Program.Basics.compose GHC.Base.mappend f) GHC.Base.mempty in default_foldable foldMap (fun {a} {b} => foldr). (* Converted value declarations: *) Definition traverse_ {t} {f} {a} {b} `{Foldable t} `{GHC.Base.Applicative f} : (a -> f b) -> t a -> f unit := fun f => foldr (_GHC.Base.*>_ GHC.Base.∘ f) (GHC.Base.pure tt). Definition sequence_ {t} {m} {a} `{Foldable t} `{GHC.Base.Monad m} : t (m a) -> m unit := foldr _GHC.Base.>>_ (GHC.Base.return_ tt). Definition sequenceA_ {t} {f} {a} `{Foldable t} `{GHC.Base.Applicative f} : t (f a) -> f unit := foldr _GHC.Base.*>_ (GHC.Base.pure tt). Definition or {t} `{Foldable t} : t bool -> bool := Coq.Program.Basics.compose Data.SemigroupInternal.getAny (foldMap Data.SemigroupInternal.Mk_Any). Definition any {t} {a} `{Foldable t} : (a -> bool) -> t a -> bool := fun p => Coq.Program.Basics.compose Data.SemigroupInternal.getAny (foldMap (Coq.Program.Basics.compose Data.SemigroupInternal.Mk_Any p)). Definition elem {f} `{Foldable f} {a} `{GHC.Base.Eq_ a} : a -> f a -> bool := fun x xs => any (fun y => x GHC.Base.== y) xs. Definition notElem {t} {a} `{Foldable t} `{GHC.Base.Eq_ a} : a -> t a -> bool := fun x => negb GHC.Base.∘ elem x. Definition mapM_ {t} {m} {a} {b} `{Foldable t} `{GHC.Base.Monad m} : (a -> m b) -> t a -> m unit := fun f => foldr (_GHC.Base.>>_ GHC.Base.∘ f) (GHC.Base.return_ tt). Definition for__ {t} {f} {a} {b} `{Foldable t} `{GHC.Base.Applicative f} : t a -> (a -> f b) -> f unit := GHC.Base.flip traverse_. Definition forM_ {t} {m} {a} {b} `{Foldable t} `{GHC.Base.Monad m} : t a -> (a -> m b) -> m unit := GHC.Base.flip mapM_. Definition foldrM {t} {m} {a} {b} `{Foldable t} `{GHC.Base.Monad m} : (a -> b -> m b) -> b -> t a -> m b := fun f z0 xs => let f' := fun k x z => f x z GHC.Base.>>= k in foldl f' GHC.Base.return_ xs z0. Definition foldlM {t} {m} {b} {a} `{Foldable t} `{GHC.Base.Monad m} : (b -> a -> m b) -> b -> t a -> m b := fun f z0 xs => let f' := fun x k z => f z x GHC.Base.>>= k in foldr f' GHC.Base.return_ xs z0. Definition find {t} {a} `{Foldable t} : (a -> bool) -> t a -> option a := fun p => Data.Monoid.getFirst GHC.Base.∘ foldMap (fun x => Data.Monoid.Mk_First (if p x : bool then Some x else None)). Local Definition Foldable__list_foldr : forall {a} {b}, (a -> b -> b) -> b -> list a -> b := fun {a} {b} => GHC.Base.foldr. Local Definition Foldable__list_foldMap : forall {m} {a}, forall `{GHC.Base.Monoid m}, (a -> m) -> list a -> m := fun {m} {a} `{GHC.Base.Monoid m} => fun f => Foldable__list_foldr (GHC.Base.mappend GHC.Base.∘ f) GHC.Base.mempty. Local Definition Foldable__list_fold : forall {m}, forall `{GHC.Base.Monoid m}, list m -> m := fun {m} `{GHC.Base.Monoid m} => Foldable__list_foldMap GHC.Base.id. Local Definition Foldable__list_foldl : forall {b} {a}, (b -> a -> b) -> b -> list a -> b := fun {b} {a} => GHC.Base.foldl. Local Definition Foldable__list_foldl' : forall {b} {a}, (b -> a -> b) -> b -> list a -> b := fun {b} {a} => GHC.Base.foldl'. Local Definition Foldable__list_foldr' : forall {a} {b}, (a -> b -> b) -> b -> list a -> b := fun {a} {b} => fun f z0 xs => let f' := fun k x z => k (f x z) in Foldable__list_foldl f' GHC.Base.id xs z0. Local Definition Foldable__list_length : forall {a}, list a -> GHC.Num.Int := fun {a} => GHC.List.length. Local Definition Foldable__list_null : forall {a}, list a -> bool := fun {a} => GHC.List.null. Local Definition Foldable__list_product : forall {a}, forall `{GHC.Num.Num a}, list a -> a := fun {a} `{GHC.Num.Num a} => GHC.List.product. Local Definition Foldable__list_sum : forall {a}, forall `{GHC.Num.Num a}, list a -> a := fun {a} `{GHC.Num.Num a} => GHC.List.sum. Local Definition Foldable__list_toList : forall {a}, list a -> list a := fun {a} => GHC.Base.id. Program Instance Foldable__list : Foldable list := fun _ k__ => k__ {| fold__ := fun {m} `{GHC.Base.Monoid m} => Foldable__list_fold ; foldMap__ := fun {m} {a} `{GHC.Base.Monoid m} => Foldable__list_foldMap ; foldl__ := fun {b} {a} => Foldable__list_foldl ; foldl'__ := fun {b} {a} => Foldable__list_foldl' ; foldr__ := fun {a} {b} => Foldable__list_foldr ; foldr'__ := fun {a} {b} => Foldable__list_foldr' ; length__ := fun {a} => Foldable__list_length ; null__ := fun {a} => Foldable__list_null ; product__ := fun {a} `{GHC.Num.Num a} => Foldable__list_product ; sum__ := fun {a} `{GHC.Num.Num a} => Foldable__list_sum ; toList__ := fun {a} => Foldable__list_toList |}. Definition concatMap {t} {a} {b} `{Foldable t} : (a -> list b) -> t a -> list b := fun f xs => GHC.Base.build' (fun _ => (fun c n => foldr (fun x b => foldr c b (f x)) n xs)). Definition concat {t} {a} `{Foldable t} : t (list a) -> list a := fun xs => GHC.Base.build' (fun _ => fun c n => foldr (fun x y => (@foldr _ Foldable__list _ _ c y x)) n xs). Definition and {t} `{Foldable t} : t bool -> bool := Coq.Program.Basics.compose Data.SemigroupInternal.getAll (foldMap Data.SemigroupInternal.Mk_All). Definition all {t} {a} `{Foldable t} : (a -> bool) -> t a -> bool := fun p => Coq.Program.Basics.compose Data.SemigroupInternal.getAll (foldMap (Coq.Program.Basics.compose Data.SemigroupInternal.Mk_All p)). (* Skipping instance `Data.Foldable.Foldable__URec__Word' of class `Data.Foldable.Foldable' *) (* Skipping instance `Data.Foldable.Foldable__URec__Int' of class `Data.Foldable.Foldable' *) (* Skipping instance `Data.Foldable.Foldable__URec__Float' of class `Data.Foldable.Foldable' *) (* Skipping instance `Data.Foldable.Foldable__URec__Double' of class `Data.Foldable.Foldable' *) (* Skipping instance `Data.Foldable.Foldable__URec__Char' of class `Data.Foldable.Foldable' *) (* Skipping instance `Data.Foldable.Foldable__URec__Ptr__unit' of class `Data.Foldable.Foldable' *) (* Skipping instance `Data.Foldable.Foldable__op_ZCziZC__' of class `Data.Foldable.Foldable' *) (* Skipping instance `Data.Foldable.Foldable__op_ZCztZC__' of class `Data.Foldable.Foldable' *) (* Skipping instance `Data.Foldable.Foldable__op_ZCzpZC__' of class `Data.Foldable.Foldable' *) (* Skipping instance `Data.Foldable.Foldable__M1' of class `Data.Foldable.Foldable' *) (* Skipping instance `Data.Foldable.Foldable__K1' of class `Data.Foldable.Foldable' *) (* Skipping instance `Data.Foldable.Foldable__Rec1' of class `Data.Foldable.Foldable' *) (* Skipping instance `Data.Foldable.Foldable__Par1' of class `Data.Foldable.Foldable' *) (* Skipping instance `Data.Foldable.Foldable__V1' of class `Data.Foldable.Foldable' *) (* Skipping instance `Data.Foldable.Foldable__U1' of class `Data.Foldable.Foldable' *) (* Skipping instance `Data.Foldable.Foldable__Last' of class `Data.Foldable.Foldable' *) (* Skipping instance `Data.Foldable.Foldable__First' of class `Data.Foldable.Foldable' *) Local Definition Foldable__Product_foldMap : forall {m} {a}, forall `{GHC.Base.Monoid m}, (a -> m) -> Data.SemigroupInternal.Product a -> m := fun {m} {a} `{GHC.Base.Monoid m} => GHC.Prim.coerce. Local Definition Foldable__Product_fold : forall {m}, forall `{GHC.Base.Monoid m}, Data.SemigroupInternal.Product m -> m := fun {m} `{GHC.Base.Monoid m} => Foldable__Product_foldMap GHC.Base.id. Local Definition Foldable__Product_foldl : forall {b} {a}, (b -> a -> b) -> b -> Data.SemigroupInternal.Product a -> b := fun {b} {a} => GHC.Prim.coerce. Local Definition Foldable__Product_foldl' : forall {b} {a}, (b -> a -> b) -> b -> Data.SemigroupInternal.Product a -> b := fun {b} {a} => GHC.Prim.coerce. Local Definition Foldable__Product_foldr : forall {a} {b}, (a -> b -> b) -> b -> Data.SemigroupInternal.Product a -> b := fun {a} {b} => fun arg_0__ arg_1__ arg_2__ => match arg_0__, arg_1__, arg_2__ with | f, z, Data.SemigroupInternal.Mk_Product x => f x z end. Local Definition Foldable__Product_foldr' : forall {a} {b}, (a -> b -> b) -> b -> Data.SemigroupInternal.Product a -> b := fun {a} {b} => Foldable__Product_foldr. Local Definition Foldable__Product_length : forall {a}, Data.SemigroupInternal.Product a -> GHC.Num.Int := fun {a} => fun arg_0__ => #1. Local Definition Foldable__Product_null : forall {a}, Data.SemigroupInternal.Product a -> bool := fun {a} => fun arg_0__ => false. Local Definition Foldable__Product_product : forall {a}, forall `{GHC.Num.Num a}, Data.SemigroupInternal.Product a -> a := fun {a} `{GHC.Num.Num a} => Data.SemigroupInternal.getProduct. Local Definition Foldable__Product_sum : forall {a}, forall `{GHC.Num.Num a}, Data.SemigroupInternal.Product a -> a := fun {a} `{GHC.Num.Num a} => Data.SemigroupInternal.getProduct. Local Definition Foldable__Product_toList : forall {a}, Data.SemigroupInternal.Product a -> list a := fun {a} => fun '(Data.SemigroupInternal.Mk_Product x) => cons x nil. Program Instance Foldable__Product : Foldable Data.SemigroupInternal.Product := fun _ k__ => k__ {| fold__ := fun {m} `{GHC.Base.Monoid m} => Foldable__Product_fold ; foldMap__ := fun {m} {a} `{GHC.Base.Monoid m} => Foldable__Product_foldMap ; foldl__ := fun {b} {a} => Foldable__Product_foldl ; foldl'__ := fun {b} {a} => Foldable__Product_foldl' ; foldr__ := fun {a} {b} => Foldable__Product_foldr ; foldr'__ := fun {a} {b} => Foldable__Product_foldr' ; length__ := fun {a} => Foldable__Product_length ; null__ := fun {a} => Foldable__Product_null ; product__ := fun {a} `{GHC.Num.Num a} => Foldable__Product_product ; sum__ := fun {a} `{GHC.Num.Num a} => Foldable__Product_sum ; toList__ := fun {a} => Foldable__Product_toList |}. Local Definition Foldable__Sum_foldMap : forall {m} {a}, forall `{GHC.Base.Monoid m}, (a -> m) -> Data.SemigroupInternal.Sum a -> m := fun {m} {a} `{GHC.Base.Monoid m} => GHC.Prim.coerce. Local Definition Foldable__Sum_fold : forall {m}, forall `{GHC.Base.Monoid m}, Data.SemigroupInternal.Sum m -> m := fun {m} `{GHC.Base.Monoid m} => Foldable__Sum_foldMap GHC.Base.id. Local Definition Foldable__Sum_foldl : forall {b} {a}, (b -> a -> b) -> b -> Data.SemigroupInternal.Sum a -> b := fun {b} {a} => GHC.Prim.coerce. Local Definition Foldable__Sum_foldl' : forall {b} {a}, (b -> a -> b) -> b -> Data.SemigroupInternal.Sum a -> b := fun {b} {a} => GHC.Prim.coerce. Local Definition Foldable__Sum_foldr : forall {a} {b}, (a -> b -> b) -> b -> Data.SemigroupInternal.Sum a -> b := fun {a} {b} => fun arg_0__ arg_1__ arg_2__ => match arg_0__, arg_1__, arg_2__ with | f, z, Data.SemigroupInternal.Mk_Sum x => f x z end. Local Definition Foldable__Sum_foldr' : forall {a} {b}, (a -> b -> b) -> b -> Data.SemigroupInternal.Sum a -> b := fun {a} {b} => Foldable__Sum_foldr. Local Definition Foldable__Sum_length : forall {a}, Data.SemigroupInternal.Sum a -> GHC.Num.Int := fun {a} => fun arg_0__ => #1. Local Definition Foldable__Sum_null : forall {a}, Data.SemigroupInternal.Sum a -> bool := fun {a} => fun arg_0__ => false. Local Definition Foldable__Sum_product : forall {a}, forall `{GHC.Num.Num a}, Data.SemigroupInternal.Sum a -> a := fun {a} `{GHC.Num.Num a} => Data.SemigroupInternal.getSum. Local Definition Foldable__Sum_sum : forall {a}, forall `{GHC.Num.Num a}, Data.SemigroupInternal.Sum a -> a := fun {a} `{GHC.Num.Num a} => Data.SemigroupInternal.getSum. Local Definition Foldable__Sum_toList : forall {a}, Data.SemigroupInternal.Sum a -> list a := fun {a} => fun '(Data.SemigroupInternal.Mk_Sum x) => cons x nil. Program Instance Foldable__Sum : Foldable Data.SemigroupInternal.Sum := fun _ k__ => k__ {| fold__ := fun {m} `{GHC.Base.Monoid m} => Foldable__Sum_fold ; foldMap__ := fun {m} {a} `{GHC.Base.Monoid m} => Foldable__Sum_foldMap ; foldl__ := fun {b} {a} => Foldable__Sum_foldl ; foldl'__ := fun {b} {a} => Foldable__Sum_foldl' ; foldr__ := fun {a} {b} => Foldable__Sum_foldr ; foldr'__ := fun {a} {b} => Foldable__Sum_foldr' ; length__ := fun {a} => Foldable__Sum_length ; null__ := fun {a} => Foldable__Sum_null ; product__ := fun {a} `{GHC.Num.Num a} => Foldable__Sum_product ; sum__ := fun {a} `{GHC.Num.Num a} => Foldable__Sum_sum ; toList__ := fun {a} => Foldable__Sum_toList |}. Local Definition Foldable__Dual_foldMap : forall {m} {a}, forall `{GHC.Base.Monoid m}, (a -> m) -> Data.SemigroupInternal.Dual a -> m := fun {m} {a} `{GHC.Base.Monoid m} => GHC.Prim.coerce. Local Definition Foldable__Dual_fold : forall {m}, forall `{GHC.Base.Monoid m}, Data.SemigroupInternal.Dual m -> m := fun {m} `{GHC.Base.Monoid m} => Foldable__Dual_foldMap GHC.Base.id. Local Definition Foldable__Dual_foldl : forall {b} {a}, (b -> a -> b) -> b -> Data.SemigroupInternal.Dual a -> b := fun {b} {a} => GHC.Prim.coerce. Local Definition Foldable__Dual_foldl' : forall {b} {a}, (b -> a -> b) -> b -> Data.SemigroupInternal.Dual a -> b := fun {b} {a} => GHC.Prim.coerce. Local Definition Foldable__Dual_foldr : forall {a} {b}, (a -> b -> b) -> b -> Data.SemigroupInternal.Dual a -> b := fun {a} {b} => fun arg_0__ arg_1__ arg_2__ => match arg_0__, arg_1__, arg_2__ with | f, z, Data.SemigroupInternal.Mk_Dual x => f x z end. Local Definition Foldable__Dual_foldr' : forall {a} {b}, (a -> b -> b) -> b -> Data.SemigroupInternal.Dual a -> b := fun {a} {b} => Foldable__Dual_foldr. Local Definition Foldable__Dual_length : forall {a}, Data.SemigroupInternal.Dual a -> GHC.Num.Int := fun {a} => fun arg_0__ => #1. Local Definition Foldable__Dual_null : forall {a}, Data.SemigroupInternal.Dual a -> bool := fun {a} => fun arg_0__ => false. Local Definition Foldable__Dual_product : forall {a}, forall `{GHC.Num.Num a}, Data.SemigroupInternal.Dual a -> a := fun {a} `{GHC.Num.Num a} => Data.SemigroupInternal.getDual. Local Definition Foldable__Dual_sum : forall {a}, forall `{GHC.Num.Num a}, Data.SemigroupInternal.Dual a -> a := fun {a} `{GHC.Num.Num a} => Data.SemigroupInternal.getDual. Local Definition Foldable__Dual_toList : forall {a}, Data.SemigroupInternal.Dual a -> list a := fun {a} => fun '(Data.SemigroupInternal.Mk_Dual x) => cons x nil. Program Instance Foldable__Dual : Foldable Data.SemigroupInternal.Dual := fun _ k__ => k__ {| fold__ := fun {m} `{GHC.Base.Monoid m} => Foldable__Dual_fold ; foldMap__ := fun {m} {a} `{GHC.Base.Monoid m} => Foldable__Dual_foldMap ; foldl__ := fun {b} {a} => Foldable__Dual_foldl ; foldl'__ := fun {b} {a} => Foldable__Dual_foldl' ; foldr__ := fun {a} {b} => Foldable__Dual_foldr ; foldr'__ := fun {a} {b} => Foldable__Dual_foldr' ; length__ := fun {a} => Foldable__Dual_length ; null__ := fun {a} => Foldable__Dual_null ; product__ := fun {a} `{GHC.Num.Num a} => Foldable__Dual_product ; sum__ := fun {a} `{GHC.Num.Num a} => Foldable__Dual_sum ; toList__ := fun {a} => Foldable__Dual_toList |}. Local Definition Foldable__Proxy_fold : forall {m}, forall `{GHC.Base.Monoid m}, Data.Proxy.Proxy m -> m := fun {m} `{GHC.Base.Monoid m} => fun arg_0__ => GHC.Base.mempty. Local Definition Foldable__Proxy_foldMap : forall {m} {a}, forall `{GHC.Base.Monoid m}, (a -> m) -> Data.Proxy.Proxy a -> m := fun {m} {a} `{GHC.Base.Monoid m} => fun arg_0__ arg_1__ => GHC.Base.mempty. Local Definition Foldable__Proxy_foldl : forall {b} {a}, (b -> a -> b) -> b -> Data.Proxy.Proxy a -> b := fun {b} {a} => fun arg_0__ arg_1__ arg_2__ => match arg_0__, arg_1__, arg_2__ with | _, z, _ => z end. Local Definition Foldable__Proxy_foldr : forall {a} {b}, (a -> b -> b) -> b -> Data.Proxy.Proxy a -> b := fun {a} {b} => fun arg_0__ arg_1__ arg_2__ => match arg_0__, arg_1__, arg_2__ with | _, z, _ => z end. Local Definition Foldable__Proxy_foldl' : forall {b} {a}, (b -> a -> b) -> b -> Data.Proxy.Proxy a -> b := fun {b} {a} => fun f z0 xs => let f' := fun x k z => k (f z x) in Foldable__Proxy_foldr f' GHC.Base.id xs z0. Local Definition Foldable__Proxy_foldr' : forall {a} {b}, (a -> b -> b) -> b -> Data.Proxy.Proxy a -> b := fun {a} {b} => fun f z0 xs => let f' := fun k x z => k (f x z) in Foldable__Proxy_foldl f' GHC.Base.id xs z0. Local Definition Foldable__Proxy_length : forall {a}, Data.Proxy.Proxy a -> GHC.Num.Int := fun {a} => fun arg_0__ => #0. Local Definition Foldable__Proxy_null : forall {a}, Data.Proxy.Proxy a -> bool := fun {a} => fun arg_0__ => true. Local Definition Foldable__Proxy_product : forall {a}, forall `{GHC.Num.Num a}, Data.Proxy.Proxy a -> a := fun {a} `{GHC.Num.Num a} => fun arg_0__ => #1. Local Definition Foldable__Proxy_sum : forall {a}, forall `{GHC.Num.Num a}, Data.Proxy.Proxy a -> a := fun {a} `{GHC.Num.Num a} => fun arg_0__ => #0. Local Definition Foldable__Proxy_toList : forall {a}, Data.Proxy.Proxy a -> list a := fun {a} => fun t => GHC.Base.build' (fun _ => (fun c n => Foldable__Proxy_foldr c n t)). Program Instance Foldable__Proxy : Foldable Data.Proxy.Proxy := fun _ k__ => k__ {| fold__ := fun {m} `{GHC.Base.Monoid m} => Foldable__Proxy_fold ; foldMap__ := fun {m} {a} `{GHC.Base.Monoid m} => Foldable__Proxy_foldMap ; foldl__ := fun {b} {a} => Foldable__Proxy_foldl ; foldl'__ := fun {b} {a} => Foldable__Proxy_foldl' ; foldr__ := fun {a} {b} => Foldable__Proxy_foldr ; foldr'__ := fun {a} {b} => Foldable__Proxy_foldr' ; length__ := fun {a} => Foldable__Proxy_length ; null__ := fun {a} => Foldable__Proxy_null ; product__ := fun {a} `{GHC.Num.Num a} => Foldable__Proxy_product ; sum__ := fun {a} `{GHC.Num.Num a} => Foldable__Proxy_sum ; toList__ := fun {a} => Foldable__Proxy_toList |}. (* Skipping instance `Data.Foldable.Foldable__Array' of class `Data.Foldable.Foldable' *) Local Definition Foldable__pair_type_foldMap {inst_a} : forall {m} {a}, forall `{GHC.Base.Monoid m}, (a -> m) -> (GHC.Tuple.pair_type inst_a) a -> m := fun {m} {a} `{GHC.Base.Monoid m} => fun arg_0__ arg_1__ => match arg_0__, arg_1__ with | f, pair _ y => f y end. Local Definition Foldable__pair_type_fold {inst_a} : forall {m}, forall `{GHC.Base.Monoid m}, (GHC.Tuple.pair_type inst_a) m -> m := fun {m} `{GHC.Base.Monoid m} => Foldable__pair_type_foldMap GHC.Base.id. Local Definition Foldable__pair_type_foldl {inst_a} : forall {b} {a}, (b -> a -> b) -> b -> (GHC.Tuple.pair_type inst_a) a -> b := fun {b} {a} => fun f z t => Data.SemigroupInternal.appEndo (Data.SemigroupInternal.getDual (Foldable__pair_type_foldMap (Data.SemigroupInternal.Mk_Dual GHC.Base.∘ (Data.SemigroupInternal.Mk_Endo GHC.Base.∘ GHC.Base.flip f)) t)) z. Local Definition Foldable__pair_type_foldr {inst_a} : forall {a} {b}, (a -> b -> b) -> b -> (GHC.Tuple.pair_type inst_a) a -> b := fun {a} {b} => fun arg_0__ arg_1__ arg_2__ => match arg_0__, arg_1__, arg_2__ with | f, z, pair _ y => f y z end. Local Definition Foldable__pair_type_foldl' {inst_a} : forall {b} {a}, (b -> a -> b) -> b -> (GHC.Tuple.pair_type inst_a) a -> b := fun {b} {a} => fun f z0 xs => let f' := fun x k z => k (f z x) in Foldable__pair_type_foldr f' GHC.Base.id xs z0. Local Definition Foldable__pair_type_foldr' {inst_a} : forall {a} {b}, (a -> b -> b) -> b -> (GHC.Tuple.pair_type inst_a) a -> b := fun {a} {b} => fun f z0 xs => let f' := fun k x z => k (f x z) in Foldable__pair_type_foldl f' GHC.Base.id xs z0. Local Definition Foldable__pair_type_length {inst_a} : forall {a}, (GHC.Tuple.pair_type inst_a) a -> GHC.Num.Int := fun {a} => Foldable__pair_type_foldl' (fun arg_0__ arg_1__ => match arg_0__, arg_1__ with | c, _ => c GHC.Num.+ #1 end) #0. Local Definition Foldable__pair_type_null {inst_a} : forall {a}, (GHC.Tuple.pair_type inst_a) a -> bool := fun {a} => Foldable__pair_type_foldr (fun arg_0__ arg_1__ => false) true. Local Definition Foldable__pair_type_product {inst_a} : forall {a}, forall `{GHC.Num.Num a}, (GHC.Tuple.pair_type inst_a) a -> a := fun {a} `{GHC.Num.Num a} => Coq.Program.Basics.compose Data.SemigroupInternal.getProduct (Foldable__pair_type_foldMap Data.SemigroupInternal.Mk_Product). Local Definition Foldable__pair_type_sum {inst_a} : forall {a}, forall `{GHC.Num.Num a}, (GHC.Tuple.pair_type inst_a) a -> a := fun {a} `{GHC.Num.Num a} => Coq.Program.Basics.compose Data.SemigroupInternal.getSum (Foldable__pair_type_foldMap Data.SemigroupInternal.Mk_Sum). Local Definition Foldable__pair_type_toList {inst_a} : forall {a}, (GHC.Tuple.pair_type inst_a) a -> list a := fun {a} => fun t => GHC.Base.build' (fun _ => (fun c n => Foldable__pair_type_foldr c n t)). Program Instance Foldable__pair_type {a} : Foldable (GHC.Tuple.pair_type a) := fun _ k__ => k__ {| fold__ := fun {m} `{GHC.Base.Monoid m} => Foldable__pair_type_fold ; foldMap__ := fun {m} {a} `{GHC.Base.Monoid m} => Foldable__pair_type_foldMap ; foldl__ := fun {b} {a} => Foldable__pair_type_foldl ; foldl'__ := fun {b} {a} => Foldable__pair_type_foldl' ; foldr__ := fun {a} {b} => Foldable__pair_type_foldr ; foldr'__ := fun {a} {b} => Foldable__pair_type_foldr' ; length__ := fun {a} => Foldable__pair_type_length ; null__ := fun {a} => Foldable__pair_type_null ; product__ := fun {a} `{GHC.Num.Num a} => Foldable__pair_type_product ; sum__ := fun {a} `{GHC.Num.Num a} => Foldable__pair_type_sum ; toList__ := fun {a} => Foldable__pair_type_toList |}. Local Definition Foldable__Either_foldMap {inst_a} : forall {m} {a}, forall `{GHC.Base.Monoid m}, (a -> m) -> (Data.Either.Either inst_a) a -> m := fun {m} {a} `{GHC.Base.Monoid m} => fun arg_0__ arg_1__ => match arg_0__, arg_1__ with | _, Data.Either.Left _ => GHC.Base.mempty | f, Data.Either.Right y => f y end. Local Definition Foldable__Either_fold {inst_a} : forall {m}, forall `{GHC.Base.Monoid m}, (Data.Either.Either inst_a) m -> m := fun {m} `{GHC.Base.Monoid m} => Foldable__Either_foldMap GHC.Base.id. Local Definition Foldable__Either_foldl {inst_a} : forall {b} {a}, (b -> a -> b) -> b -> (Data.Either.Either inst_a) a -> b := fun {b} {a} => fun f z t => Data.SemigroupInternal.appEndo (Data.SemigroupInternal.getDual (Foldable__Either_foldMap (Data.SemigroupInternal.Mk_Dual GHC.Base.∘ (Data.SemigroupInternal.Mk_Endo GHC.Base.∘ GHC.Base.flip f)) t)) z. Local Definition Foldable__Either_foldr {inst_a} : forall {a} {b}, (a -> b -> b) -> b -> (Data.Either.Either inst_a) a -> b := fun {a} {b} => fun arg_0__ arg_1__ arg_2__ => match arg_0__, arg_1__, arg_2__ with | _, z, Data.Either.Left _ => z | f, z, Data.Either.Right y => f y z end. Local Definition Foldable__Either_foldl' {inst_a} : forall {b} {a}, (b -> a -> b) -> b -> (Data.Either.Either inst_a) a -> b := fun {b} {a} => fun f z0 xs => let f' := fun x k z => k (f z x) in Foldable__Either_foldr f' GHC.Base.id xs z0. Local Definition Foldable__Either_foldr' {inst_a} : forall {a} {b}, (a -> b -> b) -> b -> (Data.Either.Either inst_a) a -> b := fun {a} {b} => fun f z0 xs => let f' := fun k x z => k (f x z) in Foldable__Either_foldl f' GHC.Base.id xs z0. Local Definition Foldable__Either_length {inst_a} : forall {a}, (Data.Either.Either inst_a) a -> GHC.Num.Int := fun {a} => fun arg_0__ => match arg_0__ with | Data.Either.Left _ => #0 | Data.Either.Right _ => #1 end. Local Definition Foldable__Either_null {inst_a} : forall {a}, (Data.Either.Either inst_a) a -> bool := fun {a} => Data.Either.isLeft. Local Definition Foldable__Either_product {inst_a} : forall {a}, forall `{GHC.Num.Num a}, (Data.Either.Either inst_a) a -> a := fun {a} `{GHC.Num.Num a} => Coq.Program.Basics.compose Data.SemigroupInternal.getProduct (Foldable__Either_foldMap Data.SemigroupInternal.Mk_Product). Local Definition Foldable__Either_sum {inst_a} : forall {a}, forall `{GHC.Num.Num a}, (Data.Either.Either inst_a) a -> a := fun {a} `{GHC.Num.Num a} => Coq.Program.Basics.compose Data.SemigroupInternal.getSum (Foldable__Either_foldMap Data.SemigroupInternal.Mk_Sum). Local Definition Foldable__Either_toList {inst_a} : forall {a}, (Data.Either.Either inst_a) a -> list a := fun {a} => fun t => GHC.Base.build' (fun _ => (fun c n => Foldable__Either_foldr c n t)). Program Instance Foldable__Either {a} : Foldable (Data.Either.Either a) := fun _ k__ => k__ {| fold__ := fun {m} `{GHC.Base.Monoid m} => Foldable__Either_fold ; foldMap__ := fun {m} {a} `{GHC.Base.Monoid m} => Foldable__Either_foldMap ; foldl__ := fun {b} {a} => Foldable__Either_foldl ; foldl'__ := fun {b} {a} => Foldable__Either_foldl' ; foldr__ := fun {a} {b} => Foldable__Either_foldr ; foldr'__ := fun {a} {b} => Foldable__Either_foldr' ; length__ := fun {a} => Foldable__Either_length ; null__ := fun {a} => Foldable__Either_null ; product__ := fun {a} `{GHC.Num.Num a} => Foldable__Either_product ; sum__ := fun {a} `{GHC.Num.Num a} => Foldable__Either_sum ; toList__ := fun {a} => Foldable__Either_toList |}. Local Definition Foldable__NonEmpty_fold : forall {m}, forall `{GHC.Base.Monoid m}, GHC.Base.NonEmpty m -> m := fun {m} `{GHC.Base.Monoid m} => fun '(GHC.Base.NEcons m ms) => GHC.Base.mappend m (fold ms). Local Definition Foldable__NonEmpty_foldMap : forall {m} {a}, forall `{GHC.Base.Monoid m}, (a -> m) -> GHC.Base.NonEmpty a -> m := fun {m} {a} `{GHC.Base.Monoid m} => fun arg_0__ arg_1__ => match arg_0__, arg_1__ with | f, GHC.Base.NEcons a as_ => GHC.Base.mappend (f a) (foldMap f as_) end. Local Definition Foldable__NonEmpty_foldl : forall {b} {a}, (b -> a -> b) -> b -> GHC.Base.NonEmpty a -> b := fun {b} {a} => fun arg_0__ arg_1__ arg_2__ => match arg_0__, arg_1__, arg_2__ with | f, z, GHC.Base.NEcons a as_ => GHC.Base.foldl f (f z a) as_ end. Local Definition Foldable__NonEmpty_foldr : forall {a} {b}, (a -> b -> b) -> b -> GHC.Base.NonEmpty a -> b := fun {a} {b} => fun arg_0__ arg_1__ arg_2__ => match arg_0__, arg_1__, arg_2__ with | f, z, GHC.Base.NEcons a as_ => f a (GHC.Base.foldr f z as_) end. Local Definition Foldable__NonEmpty_foldl' : forall {b} {a}, (b -> a -> b) -> b -> GHC.Base.NonEmpty a -> b := fun {b} {a} => fun f z0 xs => let f' := fun x k z => k (f z x) in Foldable__NonEmpty_foldr f' GHC.Base.id xs z0. Local Definition Foldable__NonEmpty_foldr' : forall {a} {b}, (a -> b -> b) -> b -> GHC.Base.NonEmpty a -> b := fun {a} {b} => fun f z0 xs => let f' := fun k x z => k (f x z) in Foldable__NonEmpty_foldl f' GHC.Base.id xs z0. Local Definition Foldable__NonEmpty_length : forall {a}, GHC.Base.NonEmpty a -> GHC.Num.Int := fun {a} => fun '(GHC.Base.NEcons _ as_) => #1 GHC.Num.+ GHC.List.length as_. Local Definition Foldable__NonEmpty_null : forall {a}, GHC.Base.NonEmpty a -> bool := fun {a} => Foldable__NonEmpty_foldr (fun arg_0__ arg_1__ => false) true. Local Definition Foldable__NonEmpty_product : forall {a}, forall `{GHC.Num.Num a}, GHC.Base.NonEmpty a -> a := fun {a} `{GHC.Num.Num a} => Coq.Program.Basics.compose Data.SemigroupInternal.getProduct (Foldable__NonEmpty_foldMap Data.SemigroupInternal.Mk_Product). Local Definition Foldable__NonEmpty_sum : forall {a}, forall `{GHC.Num.Num a}, GHC.Base.NonEmpty a -> a := fun {a} `{GHC.Num.Num a} => Coq.Program.Basics.compose Data.SemigroupInternal.getSum (Foldable__NonEmpty_foldMap Data.SemigroupInternal.Mk_Sum). Local Definition Foldable__NonEmpty_toList : forall {a}, GHC.Base.NonEmpty a -> list a := fun {a} => fun '(GHC.Base.NEcons a as_) => cons a as_. Program Instance Foldable__NonEmpty : Foldable GHC.Base.NonEmpty := fun _ k__ => k__ {| fold__ := fun {m} `{GHC.Base.Monoid m} => Foldable__NonEmpty_fold ; foldMap__ := fun {m} {a} `{GHC.Base.Monoid m} => Foldable__NonEmpty_foldMap ; foldl__ := fun {b} {a} => Foldable__NonEmpty_foldl ; foldl'__ := fun {b} {a} => Foldable__NonEmpty_foldl' ; foldr__ := fun {a} {b} => Foldable__NonEmpty_foldr ; foldr'__ := fun {a} {b} => Foldable__NonEmpty_foldr' ; length__ := fun {a} => Foldable__NonEmpty_length ; null__ := fun {a} => Foldable__NonEmpty_null ; product__ := fun {a} `{GHC.Num.Num a} => Foldable__NonEmpty_product ; sum__ := fun {a} `{GHC.Num.Num a} => Foldable__NonEmpty_sum ; toList__ := fun {a} => Foldable__NonEmpty_toList |}. Local Definition Foldable__option_foldMap : forall {m} {a}, forall `{GHC.Base.Monoid m}, (a -> m) -> option a -> m := fun {m} {a} `{GHC.Base.Monoid m} => Data.Maybe.maybe GHC.Base.mempty. Local Definition Foldable__option_fold : forall {m}, forall `{GHC.Base.Monoid m}, option m -> m := fun {m} `{GHC.Base.Monoid m} => Foldable__option_foldMap GHC.Base.id. Local Definition Foldable__option_foldl : forall {b} {a}, (b -> a -> b) -> b -> option a -> b := fun {b} {a} => fun arg_0__ arg_1__ arg_2__ => match arg_0__, arg_1__, arg_2__ with | _, z, None => z | f, z, Some x => f z x end. Local Definition Foldable__option_foldr : forall {a} {b}, (a -> b -> b) -> b -> option a -> b := fun {a} {b} => fun arg_0__ arg_1__ arg_2__ => match arg_0__, arg_1__, arg_2__ with | _, z, None => z | f, z, Some x => f x z end. Local Definition Foldable__option_foldl' : forall {b} {a}, (b -> a -> b) -> b -> option a -> b := fun {b} {a} => fun f z0 xs => let f' := fun x k z => k (f z x) in Foldable__option_foldr f' GHC.Base.id xs z0. Local Definition Foldable__option_foldr' : forall {a} {b}, (a -> b -> b) -> b -> option a -> b := fun {a} {b} => fun f z0 xs => let f' := fun k x z => k (f x z) in Foldable__option_foldl f' GHC.Base.id xs z0. Local Definition Foldable__option_length : forall {a}, option a -> GHC.Num.Int := fun {a} => Foldable__option_foldl' (fun arg_0__ arg_1__ => match arg_0__, arg_1__ with | c, _ => c GHC.Num.+ #1 end) #0. Local Definition Foldable__option_null : forall {a}, option a -> bool := fun {a} => Foldable__option_foldr (fun arg_0__ arg_1__ => false) true. Local Definition Foldable__option_product : forall {a}, forall `{GHC.Num.Num a}, option a -> a := fun {a} `{GHC.Num.Num a} => Coq.Program.Basics.compose Data.SemigroupInternal.getProduct (Foldable__option_foldMap Data.SemigroupInternal.Mk_Product). Local Definition Foldable__option_sum : forall {a}, forall `{GHC.Num.Num a}, option a -> a := fun {a} `{GHC.Num.Num a} => Coq.Program.Basics.compose Data.SemigroupInternal.getSum (Foldable__option_foldMap Data.SemigroupInternal.Mk_Sum). Local Definition Foldable__option_toList : forall {a}, option a -> list a := fun {a} => fun t => GHC.Base.build' (fun _ => (fun c n => Foldable__option_foldr c n t)). Program Instance Foldable__option : Foldable option := fun _ k__ => k__ {| fold__ := fun {m} `{GHC.Base.Monoid m} => Foldable__option_fold ; foldMap__ := fun {m} {a} `{GHC.Base.Monoid m} => Foldable__option_foldMap ; foldl__ := fun {b} {a} => Foldable__option_foldl ; foldl'__ := fun {b} {a} => Foldable__option_foldl' ; foldr__ := fun {a} {b} => Foldable__option_foldr ; foldr'__ := fun {a} {b} => Foldable__option_foldr' ; length__ := fun {a} => Foldable__option_length ; null__ := fun {a} => Foldable__option_null ; product__ := fun {a} `{GHC.Num.Num a} => Foldable__option_product ; sum__ := fun {a} `{GHC.Num.Num a} => Foldable__option_sum ; toList__ := fun {a} => Foldable__option_toList |}. (* External variables: None Some bool cons false list negb nil option pair true tt unit Coq.Program.Basics.compose Data.Either.Either Data.Either.Left Data.Either.Right Data.Either.isLeft Data.Maybe.maybe Data.Monoid.Mk_First Data.Monoid.getFirst Data.Proxy.Proxy Data.SemigroupInternal.Dual Data.SemigroupInternal.Mk_All Data.SemigroupInternal.Mk_Any Data.SemigroupInternal.Mk_Dual Data.SemigroupInternal.Mk_Endo Data.SemigroupInternal.Mk_Product Data.SemigroupInternal.Mk_Sum Data.SemigroupInternal.Product Data.SemigroupInternal.Sum Data.SemigroupInternal.appEndo Data.SemigroupInternal.getAll Data.SemigroupInternal.getAny Data.SemigroupInternal.getDual Data.SemigroupInternal.getProduct Data.SemigroupInternal.getSum GHC.Base.Applicative GHC.Base.Eq_ GHC.Base.Monad GHC.Base.Monoid GHC.Base.NEcons GHC.Base.NonEmpty GHC.Base.build' GHC.Base.flip GHC.Base.foldl GHC.Base.foldl' GHC.Base.foldr GHC.Base.id GHC.Base.mappend GHC.Base.mempty GHC.Base.op_z2218U__ GHC.Base.op_zeze__ GHC.Base.op_zgzg__ GHC.Base.op_zgzgze__ GHC.Base.op_ztzg__ GHC.Base.pure GHC.Base.return_ GHC.List.length GHC.List.null GHC.List.product GHC.List.sum GHC.Num.Int GHC.Num.Num GHC.Num.fromInteger GHC.Num.op_zp__ GHC.Prim.coerce GHC.Tuple.pair_type *)
State Before: p q x y : ℝ r : β„š m : β„€ n : β„• ⊒ LiouvilleWith p (x + ↑n) ↔ LiouvilleWith p x State After: no goals Tactic: rw [← Rat.cast_coe_nat n, add_rat_iff]
State Before: a b c : ℝβ‰₯0 h : a ≀ b * c h0 : c = 0 ⊒ a / c ≀ b State After: no goals Tactic: simp [h0]
hello <- function(r=100) { # version of R print(R.version.string) # timing matrix multiplication ptm <- proc.time() n <- 1000 a <- matrix(runif(n*n),n,n) b <- matrix(runif(n*n),n,n) c <- matrix(runif(n*n),n,n) for (i in 1:r) c = a %*% b print(proc.time() - ptm) } hello()
A set $S$ is a cone if and only if $0 \in S$ and for all $c > 0$, $cS = S$.
open import Common.Prelude open import Common.Equality test : "foo" ≑ "bar" β†’ Set₁ test refl = Set
(* * Copyright 2020, Data61, CSIRO (ABN 41 687 119 230) * * SPDX-License-Identifier: BSD-2-Clause *) theory longlong imports "CParser.CTranslation" begin external_file "longlong.c" install_C_file "longlong.c" ML \<open>NameGeneration.return_var_name (Absyn.Signed Absyn.LongLong)\<close> context longlong begin thm f_body_def thm shifts1_body_def thm shifts2_body_def lemma "(ucast :: 16 word \<Rightarrow> 8 word) 32768 = 0" apply simp done lemma "(scast :: 16 word \<Rightarrow> 8 word) 32768 = 0" by simp lemma "(scast :: 16 word \<Rightarrow> 8 word) 65535 = 255" by simp lemma "(ucast :: 16 word \<Rightarrow> 8 word) 65535 = 255" by simp lemma "(ucast :: 16 word \<Rightarrow> 8 word) 32767 = 255" by simp lemma "(scast :: 16 word \<Rightarrow> 8 word) 32767 = 255" by simp lemma "(scast :: 8 word \<Rightarrow> 16 word) 255 = 65535" by simp lemma "(ucast :: 8 word \<Rightarrow> 16 word) 255 = 255" by simp lemma g_result: "\<Gamma> \<turnstile> \<lbrace> True \<rbrace> \<acute>ret__int :== CALL callg() \<lbrace> \<acute>ret__int = 0 \<rbrace>" apply vcg apply (simp add: max_word_def) done thm literals_body_def lemma literals_result: "\<Gamma> \<turnstile> \<lbrace> True \<rbrace> \<acute>ret__int :== CALL literals() \<lbrace> \<acute>ret__int = 31 \<rbrace>" apply vcg apply simp done end (* context *) end (* theory *)
# Write your k-means unit tests here # Importing Dependencies import pytest from cluster import ( KMeans, Silhouette, make_clusters, plot_clusters, plot_multipanel) import numpy as np def test_kmeans(): """ This method is to test the functionality of the kmeans algorithm """ clusters, labels = make_clusters(k=4, scale=1) km = KMeans(k=4) km.fit(clusters) pred = km.predict(clusters) # checking that there is a label for each row in clusters labels = len(pred) observations = clusters.shape[0] assert labels == observations # checking that the number of unique labels is equal to the number of clusters assert len(set(pred)) == 4
import Data.Complex main :: IO () main = do let res = dft (map (\x -> x :+ 0) [1..10]) putStrLn $ show res dft :: RealFloat a => [Complex a] -> [Complex a] dft x = map (\(_, k) -> singleDFT k idxList) idxList where idxList = zip x [0..] singleDFT :: RealFloat a => Int -> [(Complex a, Int)] -> Complex a singleDFT k x = sum $ map (\(e, n) -> (e *) $ fCoeff k n $ length x) $ x fCoeff :: RealFloat a => Int -> Int -> Int -> Complex a fCoeff k n n_tot = exp (0.0 :+ ((-2.0) * pi * (fromIntegral $ k * n) / (fromIntegral n_tot)))
\section{Traits} \subsection{Linearization} \begin{lstlisting}[language=Scala] trait A { println(">>A") def print = { println("A") } } trait B { println(">>B") def print = { println("B") } } trait C extends A with B { println(">>C") override def print = { println("C"); super.print } } trait D extends B with A { println(">>D") override def print = { println("D"); super.print } } class E extends D with C { println(">>E") override def print = { println("E"); super.print } } \end{lstlisting} \textbf{Which text will be printed if a new instance of class E is created (which implicitly triggers the invocation of the constructors)?} \\ E | C B A | D A B => E C D A B \begin{lstlisting}[language=Scala] scala> val e = new E() >>B >>A >>D >>C >>E \end{lstlisting} \textbf{Which text will be printed if method print is invoked on an instance of class E?} \\ A.print does not perform a super-call \begin{lstlisting}[language=Scala] scala> e.print E C D A \end{lstlisting} \textbf{What is the output when method print is invoked on an instance of class E if class C has been changed as follows:} \begin{lstlisting}[language=Scala] trait C extends A with B { println(">>C") override def print = { println("C"); super[B].print } } \end{lstlisting} \begin{lstlisting}[language=Scala] scala> e.print E C B \end{lstlisting} \clearpage \subsection{Observer Pattern with Traits} \begin{lstlisting} object ObserverTest1 { class Model(private var value: Int) { def getValue = value def setValue(value: Int) = { this.value = value } } trait Observer { def update(subject: Any) } trait Observable { private var observers: List[Observer] = Nil def addObserver(obs: Observer) = { observers = obs :: observers } def removeObserver(obs: Observer) = { bservers = observers.filterNot(_ == obs) } def notifyObservers = observers.foreach(_.update(this)) } class Counter extends Observer { var counter = 0 def update(subject: Any) = { println(s"update called with $subject") counter += 1 } } def main(args: Array[String]): Unit = { val m = new Model(0) with Observable { override def setValue(x: Int) = { super.setValue(x) notifyObservers } } val c = new Counter m.addObserver(c) m.setValue(3); m.setValue(5); println(c.counter) } } \end{lstlisting} \clearpage
-- Issue #80. -- The disjunction data type. data _∨_ (A B : Set) : Set where inj₁ : A β†’ A ∨ B injβ‚‚ : B β†’ A ∨ B -- A different symbol for disjunction. _βŠ•_ : Set β†’ Set β†’ Set P βŠ• Q = P ∨ Q {-# ATP definition _βŠ•_ #-} postulate P Q : Set βŠ•-comm : P βŠ• Q β†’ Q βŠ• P {-# ATP prove βŠ•-comm #-} -- The previous error was: -- $ apia Issue80.agda -- An internal error has occurred. Please report this as a bug. -- Location of the error: src/Apia/Translation/Functions.hs:188 -- The current error is: -- $ apia Issue80.agda -- apia: the translation of β€˜IssueXX._βŠ•_’ failed because it is not a FOL-definition
meffonym.add.model("mdd", c("intercept",rownames(mdd.model)), c(0,mdd.model$effect), "MDD") scores <- sapply(paste("aries", c("15","24","preg","mid"), sep="."), function(ds) { meffonym.score(get(ds)$methylation, "mdd")$score },simplify=F)
[STATEMENT] lemma cf_smcf_op_cf[slicing_commute]: "op_smcf (cf_smcf \<FF>) = cf_smcf (op_cf \<FF>)" [PROOF STATE] proof (prove) goal (1 subgoal): 1. op_smcf (cf_smcf \<FF>) = cf_smcf (op_cf \<FF>) [PROOF STEP] proof(rule vsv_eqI) [PROOF STATE] proof (state) goal (4 subgoals): 1. vsv (op_smcf (cf_smcf \<FF>)) 2. vsv (cf_smcf (op_cf \<FF>)) 3. \<D>\<^sub>\<circ> (op_smcf (cf_smcf \<FF>)) = \<D>\<^sub>\<circ> (cf_smcf (op_cf \<FF>)) 4. \<And>a. a \<in>\<^sub>\<circ> \<D>\<^sub>\<circ> (op_smcf (cf_smcf \<FF>)) \<Longrightarrow> op_smcf (cf_smcf \<FF>)\<lparr>a\<rparr> = cf_smcf (op_cf \<FF>)\<lparr>a\<rparr> [PROOF STEP] have dom_lhs: "\<D>\<^sub>\<circ> (op_smcf (cf_smcf \<FF>)) = 4\<^sub>\<nat>" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<D>\<^sub>\<circ> (op_smcf (cf_smcf \<FF>)) = 4\<^sub>\<nat> [PROOF STEP] unfolding op_smcf_def [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<D>\<^sub>\<circ> [cf_smcf \<FF>\<lparr>ObjMap\<rparr>, cf_smcf \<FF>\<lparr>ArrMap\<rparr>, op_smc (cf_smcf \<FF>\<lparr>HomDom\<rparr>), op_smc (cf_smcf \<FF>\<lparr>HomCod\<rparr>)]\<^sub>\<circ> = 4\<^sub>\<nat> [PROOF STEP] by (auto simp: nat_omega_simps) [PROOF STATE] proof (state) this: \<D>\<^sub>\<circ> (op_smcf (cf_smcf \<FF>)) = 4\<^sub>\<nat> goal (4 subgoals): 1. vsv (op_smcf (cf_smcf \<FF>)) 2. vsv (cf_smcf (op_cf \<FF>)) 3. \<D>\<^sub>\<circ> (op_smcf (cf_smcf \<FF>)) = \<D>\<^sub>\<circ> (cf_smcf (op_cf \<FF>)) 4. \<And>a. a \<in>\<^sub>\<circ> \<D>\<^sub>\<circ> (op_smcf (cf_smcf \<FF>)) \<Longrightarrow> op_smcf (cf_smcf \<FF>)\<lparr>a\<rparr> = cf_smcf (op_cf \<FF>)\<lparr>a\<rparr> [PROOF STEP] have dom_rhs: "\<D>\<^sub>\<circ> (cf_smcf (op_cf \<FF>)) = 4\<^sub>\<nat>" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<D>\<^sub>\<circ> (cf_smcf (op_cf \<FF>)) = 4\<^sub>\<nat> [PROOF STEP] unfolding cf_smcf_def [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<D>\<^sub>\<circ> [op_cf \<FF>\<lparr>ObjMap\<rparr>, op_cf \<FF>\<lparr>ArrMap\<rparr>, cat_smc (op_cf \<FF>\<lparr>HomDom\<rparr>), cat_smc (op_cf \<FF>\<lparr>HomCod\<rparr>)]\<^sub>\<circ> = 4\<^sub>\<nat> [PROOF STEP] by (auto simp: nat_omega_simps) [PROOF STATE] proof (state) this: \<D>\<^sub>\<circ> (cf_smcf (op_cf \<FF>)) = 4\<^sub>\<nat> goal (4 subgoals): 1. vsv (op_smcf (cf_smcf \<FF>)) 2. vsv (cf_smcf (op_cf \<FF>)) 3. \<D>\<^sub>\<circ> (op_smcf (cf_smcf \<FF>)) = \<D>\<^sub>\<circ> (cf_smcf (op_cf \<FF>)) 4. \<And>a. a \<in>\<^sub>\<circ> \<D>\<^sub>\<circ> (op_smcf (cf_smcf \<FF>)) \<Longrightarrow> op_smcf (cf_smcf \<FF>)\<lparr>a\<rparr> = cf_smcf (op_cf \<FF>)\<lparr>a\<rparr> [PROOF STEP] show "\<D>\<^sub>\<circ> (op_smcf (cf_smcf \<FF>)) = \<D>\<^sub>\<circ> (cf_smcf (op_cf \<FF>))" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<D>\<^sub>\<circ> (op_smcf (cf_smcf \<FF>)) = \<D>\<^sub>\<circ> (cf_smcf (op_cf \<FF>)) [PROOF STEP] unfolding dom_lhs dom_rhs [PROOF STATE] proof (prove) goal (1 subgoal): 1. 4\<^sub>\<nat> = 4\<^sub>\<nat> [PROOF STEP] by simp [PROOF STATE] proof (state) this: \<D>\<^sub>\<circ> (op_smcf (cf_smcf \<FF>)) = \<D>\<^sub>\<circ> (cf_smcf (op_cf \<FF>)) goal (3 subgoals): 1. vsv (op_smcf (cf_smcf \<FF>)) 2. vsv (cf_smcf (op_cf \<FF>)) 3. \<And>a. a \<in>\<^sub>\<circ> \<D>\<^sub>\<circ> (op_smcf (cf_smcf \<FF>)) \<Longrightarrow> op_smcf (cf_smcf \<FF>)\<lparr>a\<rparr> = cf_smcf (op_cf \<FF>)\<lparr>a\<rparr> [PROOF STEP] show "a \<in>\<^sub>\<circ> \<D>\<^sub>\<circ> (op_smcf (cf_smcf \<FF>)) \<Longrightarrow> op_smcf (cf_smcf \<FF>)\<lparr>a\<rparr> = cf_smcf (op_cf \<FF>)\<lparr>a\<rparr>" for a [PROOF STATE] proof (prove) goal (1 subgoal): 1. a \<in>\<^sub>\<circ> \<D>\<^sub>\<circ> (op_smcf (cf_smcf \<FF>)) \<Longrightarrow> op_smcf (cf_smcf \<FF>)\<lparr>a\<rparr> = cf_smcf (op_cf \<FF>)\<lparr>a\<rparr> [PROOF STEP] by ( unfold dom_lhs, elim_in_numeral, unfold cf_smcf_def op_cf_def op_smcf_def dghm_field_simps ) (auto simp: nat_omega_simps slicing_commute) [PROOF STATE] proof (state) this: ?a \<in>\<^sub>\<circ> \<D>\<^sub>\<circ> (op_smcf (cf_smcf \<FF>)) \<Longrightarrow> op_smcf (cf_smcf \<FF>)\<lparr>?a\<rparr> = cf_smcf (op_cf \<FF>)\<lparr>?a\<rparr> goal (2 subgoals): 1. vsv (op_smcf (cf_smcf \<FF>)) 2. vsv (cf_smcf (op_cf \<FF>)) [PROOF STEP] qed (auto simp: cf_smcf_def op_smcf_def)
lemma bigthetaI [intro]: "f \<in> O[F](g) \<Longrightarrow> f \<in> \<Omega>[F](g) \<Longrightarrow> f \<in> \<Theta>[F](g)"
lemma poly_cutoff_1 [simp]: "poly_cutoff n 1 = (if n = 0 then 0 else 1)"
/- Copyright (c) 2020 Zhouhang Zhou. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Zhouhang Zhou, Yury Kudryashov -/ import Mathlib.PrePort import Mathlib.Lean3Lib.init.default import Mathlib.data.indicator_function import Mathlib.analysis.normed_space.basic import Mathlib.PostPort universes u_1 u_2 namespace Mathlib /-! # Indicator function and norm This file contains a few simple lemmas about `set.indicator` and `norm`. ## Tags indicator, norm -/ theorem norm_indicator_eq_indicator_norm {Ξ± : Type u_1} {E : Type u_2} [normed_group E] {s : set Ξ±} (f : Ξ± β†’ E) (a : Ξ±) : norm (set.indicator s f a) = set.indicator s (fun (a : Ξ±) => norm (f a)) a := flip congr_fun a (Eq.symm (set.indicator_comp_of_zero norm_zero)) theorem nnnorm_indicator_eq_indicator_nnnorm {Ξ± : Type u_1} {E : Type u_2} [normed_group E] {s : set Ξ±} (f : Ξ± β†’ E) (a : Ξ±) : nnnorm (set.indicator s f a) = set.indicator s (fun (a : Ξ±) => nnnorm (f a)) a := flip congr_fun a (Eq.symm (set.indicator_comp_of_zero nnnorm_zero)) theorem norm_indicator_le_of_subset {Ξ± : Type u_1} {E : Type u_2} [normed_group E] {s : set Ξ±} {t : set Ξ±} (h : s βŠ† t) (f : Ξ± β†’ E) (a : Ξ±) : norm (set.indicator s f a) ≀ norm (set.indicator t f a) := sorry theorem indicator_norm_le_norm_self {Ξ± : Type u_1} {E : Type u_2} [normed_group E] {s : set Ξ±} (f : Ξ± β†’ E) (a : Ξ±) : set.indicator s (fun (a : Ξ±) => norm (f a)) a ≀ norm (f a) := set.indicator_le_self' (fun (_x : Ξ±) (_x : Β¬_x ∈ s) => norm_nonneg (f a)) a theorem norm_indicator_le_norm_self {Ξ± : Type u_1} {E : Type u_2} [normed_group E] {s : set Ξ±} (f : Ξ± β†’ E) (a : Ξ±) : norm (set.indicator s f a) ≀ norm (f a) := eq.mpr (id (Eq._oldrec (Eq.refl (norm (set.indicator s f a) ≀ norm (f a))) (norm_indicator_eq_indicator_norm f a))) (indicator_norm_le_norm_self (fun (a : Ξ±) => f a) a) end Mathlib
lemma simply_connected_eq_homotopic_paths: fixes S :: "_::real_normed_vector set" shows "simply_connected S \<longleftrightarrow> path_connected S \<and> (\<forall>p q. path p \<and> path_image p \<subseteq> S \<and> path q \<and> path_image q \<subseteq> S \<and> pathstart q = pathstart p \<and> pathfinish q = pathfinish p \<longrightarrow> homotopic_paths S p q)" (is "?lhs = ?rhs")
/- Copyright (c) 2021 Jannis Limperg. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jannis Limperg -/ import Aesop import Lean open Aesop open Lean open Lean.Meta open Lean.Elab.Tactic set_option aesop.check.all true /-! # Unit tests for the MetaM tactic that implements forward rules -/ syntax (name := forward) &"forward" ident ("[" ident* "]")? : tactic syntax (name := elim) &"elim" ident ("[" ident* "]")? : tactic def forwardTac (goal : MVarId) (id : Syntax) (immediate : Option (Array Syntax)) (clear : Bool) : MetaM (List MVarId) := do let userName := id.getId let ldecl ← getLocalDeclFromUserName userName let immediate ← RuleBuilder.getImmediatePremises userName ldecl.type (immediate.map (Β·.map (Β·.getId))) let (goal, _) ← RuleTac.applyForwardRule goal (mkFVar ldecl.fvarId) immediate clear (generateScript := false) return [goal] @[tactic forward] def evalForward : Tactic | `(tactic| forward $t:ident $[[ $immediate:ident* ]]?) => liftMetaTactic Ξ» goal => forwardTac goal t immediate (clear := false) | _ => unreachable! @[tactic elim] def evalElim : Tactic | `(tactic| elim $t:ident $[[ $immediate:ident* ]]?) => liftMetaTactic Ξ» goal => forwardTac goal t immediate (clear := true) | _ => unreachable! example (rule : (a : Ξ±) β†’ (b : Ξ²) β†’ Ξ³) (h₁ : Ξ±) (hβ‚‚ : Ξ²) : Ξ³ := by forward rule [a b] assumption set_option linter.unusedVariables false in example {P Q R : Ξ± β†’ Type} (rule : βˆ€ a (p : P a) (q : Q a), R a) (h₁ : P a) (h₁' : P a) (hβ‚‚ : Q a) (h₃ : P b) (hβ‚„ : Q c) : R a := by forward rule [p q] assumption set_option linter.unusedVariables false in example {P Q R : Ξ± β†’ Type} (rule : βˆ€ a (p : P a) (q : Q a), R a) (h₁ : P a) (h₁' : P a) (hβ‚‚ : Q a) (h₃ : P b) (hβ‚„ : Q c) : R a := by forward rule assumption example {P Q R : Ξ± β†’ Type} (rule : βˆ€ a (p : P a) (q : Q a), R a) (h₁ : P a) (hβ‚‚ : P b) : (Q a β†’ R a) Γ— (Q b β†’ R b) := by forward rule [p] exact (by assumption, by assumption) example (rule : βˆ€ Ξ± Ξ², Ξ± ∧ Ξ² β†’ Ξ±) (h : P ∧ Q ∧ R) : P := by elim rule assumption /-! # End-to-end tests -/ example (a : Ξ±) (b : Ξ²) (r₁ : (a : Ξ±) β†’ (b : Ξ²) β†’ γ₁ ∧ Ξ³β‚‚) (rβ‚‚ : (a : Ξ±) β†’ δ₁ ∧ Ξ΄β‚‚) : γ₁ ∧ Ξ³β‚‚ ∧ δ₁ ∧ Ξ΄β‚‚ := by aesop (add safe [forward r₁, (forward (immediate := [a])) rβ‚‚]) example (a : Ξ±) (b : Ξ²) (r₁ : (a : Ξ±) β†’ (b : Ξ²) β†’ γ₁ ∧ Ξ³β‚‚) (rβ‚‚ : (a : Ξ±) β†’ δ₁ ∧ Ξ΄β‚‚) : γ₁ ∧ Ξ³β‚‚ ∧ δ₁ ∧ Ξ΄β‚‚ := by fail_if_success aesop (add safe [destruct r₁, (destruct (immediate := [a])) rβ‚‚]) (options := { terminal := true }) aesop (add safe [forward r₁], 90% destruct rβ‚‚)
Formal statement is: lemma setdist_empty2 [simp]: "setdist t {} = 0" Informal statement is: The distance between a set and the empty set is zero.
/- Copyright (c) 2021 Floris van Doorn. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Floris van Doorn -/ import Mathlib.PrePort import Mathlib.Lean3Lib.init.default import Mathlib.measure_theory.prod import Mathlib.measure_theory.group import Mathlib.PostPort universes u_1 namespace Mathlib /-! # Measure theory in the product of groups In this file we show properties about measure theory in products of topological groups and properties of iterated integrals in topological groups. These lemmas show the uniqueness of left invariant measures on locally compact groups, up to scaling. In this file we follow the proof and refer to the book *Measure Theory* by Paul Halmos. The idea of the proof is to use the translation invariance of measures to prove `ΞΌ(F) = c * ΞΌ(E)` for two sets `E` and `F`, where `c` is a constant that does not depend on `ΞΌ`. Let `e` and `f` be the characteristic functions of `E` and `F`. Assume that `ΞΌ` and `Ξ½` are left-invariant measures. Then the map `(x, y) ↦ (y * x, x⁻¹)` preserves the measure `ΞΌ.prod Ξ½`, which means that ``` ∫ x, ∫ y, h x y βˆ‚Ξ½ βˆ‚ΞΌ = ∫ x, ∫ y, h (y * x) x⁻¹ βˆ‚Ξ½ βˆ‚ΞΌ ``` If we apply this to `h x y := e x * f y⁻¹ / Ξ½ ((Ξ» h, h * y⁻¹) ⁻¹' E)`, we can rewrite the RHS to `ΞΌ(F)`, and the LHS to `c * ΞΌ(E)`, where `c = c(Ξ½)` does not depend on `ΞΌ`. Applying this to `ΞΌ` and to `Ξ½` gives `ΞΌ (F) / ΞΌ (E) = Ξ½ (F) / Ξ½ (E)`, which is the uniqueness up to scalar multiplication. The proof in [Halmos] seems to contain an omission in Β§60 Th. A, see `measure_theory.measure_lintegral_div_measure` and https://math.stackexchange.com/questions/3974485/does-right-translation-preserve-finiteness-for-a-left-invariant-measure -/ namespace measure_theory /-- This condition is part of the definition of a measurable group in [Halmos, Β§59]. There, the map in this lemma is called `S`. -/ theorem map_prod_mul_eq {G : Type u_1} [topological_space G] [measurable_space G] [topological_space.second_countable_topology G] [borel_space G] [group G] [topological_group G] {ΞΌ : measure G} {Ξ½ : measure G} [sigma_finite Ξ½] [sigma_finite ΞΌ] (hΞ½ : is_mul_left_invariant ⇑ν) : coe_fn (measure.map fun (z : G Γ— G) => (prod.fst z, prod.fst z * prod.snd z)) (measure.prod ΞΌ Ξ½) = measure.prod ΞΌ Ξ½ := sorry /-- The function we are mapping along is `SR` in [Halmos, Β§59], where `S` is the map in `map_prod_mul_eq` and `R` is `prod.swap`. -/ theorem map_prod_mul_eq_swap {G : Type u_1} [topological_space G] [measurable_space G] [topological_space.second_countable_topology G] [borel_space G] [group G] [topological_group G] {ΞΌ : measure G} {Ξ½ : measure G} [sigma_finite Ξ½] [sigma_finite ΞΌ] (hΞΌ : is_mul_left_invariant ⇑μ) : coe_fn (measure.map fun (z : G Γ— G) => (prod.snd z, prod.snd z * prod.fst z)) (measure.prod ΞΌ Ξ½) = measure.prod Ξ½ ΞΌ := sorry /-- The function we are mapping along is `S⁻¹` in [Halmos, Β§59], where `S` is the map in `map_prod_mul_eq`. -/ theorem map_prod_inv_mul_eq {G : Type u_1} [topological_space G] [measurable_space G] [topological_space.second_countable_topology G] [borel_space G] [group G] [topological_group G] {ΞΌ : measure G} {Ξ½ : measure G} [sigma_finite Ξ½] [sigma_finite ΞΌ] (hΞ½ : is_mul_left_invariant ⇑ν) : coe_fn (measure.map fun (z : G Γ— G) => (prod.fst z, prod.fst z⁻¹ * prod.snd z)) (measure.prod ΞΌ Ξ½) = measure.prod ΞΌ Ξ½ := iff.mp (measurable_equiv.map_apply_eq_iff_map_symm_apply_eq (homeomorph.to_measurable_equiv (homeomorph.shear_mul_right G))) (map_prod_mul_eq hΞ½) /-- The function we are mapping along is `S⁻¹R` in [Halmos, Β§59], where `S` is the map in `map_prod_mul_eq` and `R` is `prod.swap`. -/ theorem map_prod_inv_mul_eq_swap {G : Type u_1} [topological_space G] [measurable_space G] [topological_space.second_countable_topology G] [borel_space G] [group G] [topological_group G] {ΞΌ : measure G} {Ξ½ : measure G} [sigma_finite Ξ½] [sigma_finite ΞΌ] (hΞΌ : is_mul_left_invariant ⇑μ) : coe_fn (measure.map fun (z : G Γ— G) => (prod.snd z, prod.snd z⁻¹ * prod.fst z)) (measure.prod ΞΌ Ξ½) = measure.prod Ξ½ ΞΌ := sorry /-- The function we are mapping along is `S⁻¹RSR` in [Halmos, Β§59], where `S` is the map in `map_prod_mul_eq` and `R` is `prod.swap`. -/ theorem map_prod_mul_inv_eq {G : Type u_1} [topological_space G] [measurable_space G] [topological_space.second_countable_topology G] [borel_space G] [group G] [topological_group G] {ΞΌ : measure G} {Ξ½ : measure G} [sigma_finite Ξ½] [sigma_finite ΞΌ] (hΞΌ : is_mul_left_invariant ⇑μ) (hΞ½ : is_mul_left_invariant ⇑ν) : coe_fn (measure.map fun (z : G Γ— G) => (prod.snd z * prod.fst z, prod.fst z⁻¹)) (measure.prod ΞΌ Ξ½) = measure.prod ΞΌ Ξ½ := sorry theorem measure_null_of_measure_inv_null {G : Type u_1} [topological_space G] [measurable_space G] [topological_space.second_countable_topology G] [borel_space G] [group G] [topological_group G] {ΞΌ : measure G} [sigma_finite ΞΌ] (hΞΌ : is_mul_left_invariant ⇑μ) {E : set G} (hE : is_measurable E) (h2E : coe_fn ΞΌ ((fun (x : G) => x⁻¹) ⁻¹' E) = 0) : coe_fn ΞΌ E = 0 := sorry theorem measure_inv_null {G : Type u_1} [topological_space G] [measurable_space G] [topological_space.second_countable_topology G] [borel_space G] [group G] [topological_group G] {ΞΌ : measure G} [sigma_finite ΞΌ] (hΞΌ : is_mul_left_invariant ⇑μ) {E : set G} (hE : is_measurable E) : coe_fn ΞΌ ((fun (x : G) => x⁻¹) ⁻¹' E) = 0 ↔ coe_fn ΞΌ E = 0 := sorry theorem measurable_measure_mul_right {G : Type u_1} [topological_space G] [measurable_space G] [topological_space.second_countable_topology G] [borel_space G] [group G] [topological_group G] {ΞΌ : measure G} [sigma_finite ΞΌ] {E : set G} (hE : is_measurable E) : measurable fun (x : G) => coe_fn ΞΌ ((fun (y : G) => y * x) ⁻¹' E) := sorry theorem lintegral_lintegral_mul_inv {G : Type u_1} [topological_space G] [measurable_space G] [topological_space.second_countable_topology G] [borel_space G] [group G] [topological_group G] {ΞΌ : measure G} {Ξ½ : measure G} [sigma_finite Ξ½] [sigma_finite ΞΌ] (hΞΌ : is_mul_left_invariant ⇑μ) (hΞ½ : is_mul_left_invariant ⇑ν) (f : G β†’ G β†’ ennreal) (hf : measurable (function.uncurry f)) : (lintegral ΞΌ fun (x : G) => lintegral Ξ½ fun (y : G) => f (y * x) (x⁻¹)) = lintegral ΞΌ fun (x : G) => lintegral Ξ½ fun (y : G) => f x y := sorry theorem measure_mul_right_null {G : Type u_1} [topological_space G] [measurable_space G] [topological_space.second_countable_topology G] [borel_space G] [group G] [topological_group G] {ΞΌ : measure G} [sigma_finite ΞΌ] (hΞΌ : is_mul_left_invariant ⇑μ) {E : set G} (hE : is_measurable E) (y : G) : coe_fn ΞΌ ((fun (x : G) => x * y) ⁻¹' E) = 0 ↔ coe_fn ΞΌ E = 0 := sorry theorem measure_mul_right_ne_zero {G : Type u_1} [topological_space G] [measurable_space G] [topological_space.second_countable_topology G] [borel_space G] [group G] [topological_group G] {ΞΌ : measure G} [sigma_finite ΞΌ] (hΞΌ : is_mul_left_invariant ⇑μ) {E : set G} (hE : is_measurable E) (h2E : coe_fn ΞΌ E β‰  0) (y : G) : coe_fn ΞΌ ((fun (x : G) => x * y) ⁻¹' E) β‰  0 := iff.mpr (not_iff_not_of_iff (measure_mul_right_null hΞΌ hE y)) h2E /-- A technical lemma relating two different measures. This is basically [Halmos, Β§60 Th. A]. Note that if `f` is the characteristic function of a measurable set `F` this states that `ΞΌ F = c * ΞΌ E` for a constant `c` that does not depend on `ΞΌ`. There seems to be a gap in the last step of the proof in [Halmos]. In the last line, the equality `g(x⁻¹)Ξ½(Ex⁻¹) = f(x)` holds if we can prove that `0 < Ξ½(Ex⁻¹) < ∞`. The first inequality follows from Β§59, Th. D, but I couldn't find the second inequality. For this reason, we use a compact `E` instead of a measurable `E` as in [Halmos], and additionally assume that `Ξ½` is a regular measure (we only need that it is finite on compact sets). -/ theorem measure_lintegral_div_measure {G : Type u_1} [topological_space G] [measurable_space G] [topological_space.second_countable_topology G] [borel_space G] [group G] [topological_group G] {ΞΌ : measure G} {Ξ½ : measure G} [sigma_finite Ξ½] [sigma_finite ΞΌ] [t2_space G] (hΞΌ : is_mul_left_invariant ⇑μ) (hΞ½ : is_mul_left_invariant ⇑ν) (h2Ξ½ : measure.regular Ξ½) {E : set G} (hE : is_compact E) (h2E : coe_fn Ξ½ E β‰  0) (f : G β†’ ennreal) (hf : measurable f) : (coe_fn ΞΌ E * lintegral Ξ½ fun (y : G) => f (y⁻¹) / coe_fn Ξ½ ((fun (h : G) => h * (y⁻¹)) ⁻¹' E)) = lintegral ΞΌ fun (x : G) => f x := sorry /-- This is roughly the uniqueness (up to a scalar) of left invariant Borel measures on a second countable locally compact group. The uniqueness of Haar measure is proven from this in `measure_theory.measure.haar_measure_unique` -/ theorem measure_mul_measure_eq {G : Type u_1} [topological_space G] [measurable_space G] [topological_space.second_countable_topology G] [borel_space G] [group G] [topological_group G] {ΞΌ : measure G} {Ξ½ : measure G} [sigma_finite Ξ½] [sigma_finite ΞΌ] [t2_space G] (hΞΌ : is_mul_left_invariant ⇑μ) (hΞ½ : is_mul_left_invariant ⇑ν) (h2Ξ½ : measure.regular Ξ½) {E : set G} {F : set G} (hE : is_compact E) (hF : is_measurable F) (h2E : coe_fn Ξ½ E β‰  0) : coe_fn ΞΌ E * coe_fn Ξ½ F = coe_fn Ξ½ E * coe_fn ΞΌ F := sorry end Mathlib
{-# OPTIONS --safe --warning=error --without-K #-} open import LogicalFormulae open import Groups.Groups open import Groups.Homomorphisms.Definition open import Groups.Definition open import Numbers.Naturals.Definition open import Numbers.Naturals.Order open import Setoids.Orders open import Setoids.Setoids open import Functions open import Sets.EquivalenceRelations open import Rings.Definition open import Rings.Homomorphisms.Definition open import Groups.Homomorphisms.Lemmas open import Rings.IntegralDomains.Definition open import Rings.IntegralDomains.Examples open import Rings.EuclideanDomains.Definition open import Fields.Fields open import WellFoundedInduction open import Agda.Primitive using (Level; lzero; lsuc; _βŠ”_) module Rings.EuclideanDomains.Lemmas {a b : _} {A : Set a} {S : Setoid {a} {b} A} {_+_ _*_ : A β†’ A β†’ A} {R : Ring S _+_ _*_} (E : EuclideanDomain R) where open import Rings.PrincipalIdealDomains.Definition (EuclideanDomain.isIntegralDomain E) open import Rings.Ideals.Principal.Definition R open import Rings.Divisible.Definition R open Setoid S open Ring R open Equivalence eq euclideanDomainIsPid : {c : _} β†’ PrincipalIdealDomain {c} euclideanDomainIsPid {pred = pred} ideal = {!!} -- We definitely need to be able to decide equality in order to deduce this; otherwise we can't tell the difference -- between "everything is 0" and "something is nonzero", and the proofs are genuinely different in the two cases. where r : A r = {!!} r!=0 : (r ∼ 0R) β†’ False r!=0 = {!!} predR : pred r predR = {!!} sr : (s : A) β†’ r ∣ s sr = EuclideanDomain.divisionAlg r!=0 s!=0 ?
Representative Lontine serves as Vice-Chair of the State, Veterans, and Military affairs Committee and on the Health, Insurance, & Environment and Legislative Council committees. She was elected in 2014 succeeding Jeanne Labuda. Remember THERE WILL BE A SPECIAL MEETING OF HOUSE DISTRICT ONE this coming Saturday A VERY SPECIAL MAN, Gordon Blankensip, will be saying goodbye to us and we want to let him know how much he will be missed. PLEASE JOIN US IN OUR PRAISE OF GORDON. HINT: Don't eat before you come. We will also be having a drawing for a Hillary Clinton yard sign and discuss walking dates in preparation for the November election. Congratulations to Larry Dunn for creating user friendly in depth House District precinct maps and a color coded House District map showing the House District sub district alignment. The Honorable Susan Lontine.HD1's newly elected State Representative. HD1A Congratulations to Deborah Burgess Co-Captain. 2015 November 14th HD1 Meeting.
function [y] = ge(x, val) y = cell(size(x)); for k = 1:numel(x) y{k} = x{k}>=val; end
variables (Ξ± : Type) (p q : Ξ± β†’ Prop) example : (βˆ€ x, p x ∧ q x) ↔ (βˆ€ x, p x) ∧ (βˆ€ x, q x) := ⟨λ h, ⟨λ x, (h x).left, Ξ» x, (h x).right⟩, Ξ» ⟨hup, huq⟩ x, ⟨hup x, huq x⟩⟩ example : (βˆ€ x, p x β†’ q x) β†’ (βˆ€ x, p x) β†’ (βˆ€ x, q x) := assume hpq hp x, hpq x (hp x) example : (βˆ€ x, p x) ∨ (βˆ€ x, q x) β†’ βˆ€ x, p x ∨ q x := assume : (βˆ€ x, p x) ∨ (βˆ€ x, q x), this.elim (assume : βˆ€ x, p x, assume : Ξ±, or.inl (β€Ήβˆ€ x, p xβ€Ί (by assumption))) (assume : βˆ€ x, q x, assume : Ξ±, or.inr (β€Ήβˆ€ x, q xβ€Ί (by assumption)))
(* Copyright (C) 2017 M.A.L. Marques This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. *) (* Equation (7) from the paper *) tpss_p := x -> X2S^2*x^2: tpss_z := (x, t) -> x^2/(8*t): tpss_alpha := (x, t) -> (t - x^2/8)/K_FACTOR_C: tpss_qb := (x, t) -> \ 9/20 * (tpss_alpha(x, t) - 1)/sqrt(1 + params_a_b*tpss_alpha(x, t)*(tpss_alpha(x, t) - 1)) \ + 2*tpss_p(x)/3: (* Equation (10) in all its glory *) tpss_fxnum := (x, t) -> \ + (MU_GE + params_a_c*tpss_z(x, t)^tpss_ff(tpss_z(x, t))/(1 + tpss_z(x, t)^2)^2)*tpss_p(x) \ + 146/2025 * tpss_qb(x, t)^2 \ - 73/405 * tpss_qb(x, t) * sqrt(1/2*(9/25*tpss_z(x, t)^2 + tpss_p(x)^2)) \ + MU_GE^2/tpss_kappa(x, t) * tpss_p(x)^2 \ + 2*sqrt(params_a_e)*MU_GE*9/25*tpss_z(x, t)^2 \ + params_a_e*params_a_mu*tpss_p(x)^3: tpss_fxden := x -> \ (1 + sqrt(params_a_e)*tpss_p(x))^2: tpss_fx := (x, t) -> tpss_fxnum(x, t)/tpss_fxden(x):
SUBROUTINE WF_LOAD c Retrieves the solution vectors P. implicit real*8 (a-h,o-z) real * 8 p sav,a norm,b norm,ht,wfht1,wfht2 complex * 16 m31 sav,m32 sav,m33 sav,ortho common/wf_save/ & p sav(16), & m31 sav,m32 sav,m33 sav,ortho, & a norm,b norm,ht,wfht1,wfht2, & levl & /wf_petc/ & p etc(27,65) if (levl .eq. 0) call LWPC_ERROR ('ERROR','[WF_LOAD]: levl=0') call WF_XFER (p etc(1,levl),p sav,27) levl=levl-1 RETURN END ! WF_LOAD
subroutine p850_to_msl(lon,lat,time,zg_array,ta_array,output_array) implicit none integer, intent(in) :: lon,lat,time integer :: x,y,t double precision, intent(in) :: zg_array(lon,lat,time),ta_array(lon,lat,time) double precision, intent(out) :: output_array(lon,lat,time) do 20,t=1,time do 10, x=1,lon do 5, y=1,lat output_array(x,y,t) = 85000*(1 - ((0.0065* zg_array(x,y,t))& /(ta_array(x,y,t)+(0.0065* zg_array(x,y,t)))))** (-5.257) 5 end do 10 end do 20 end do end subroutine p850_to_msl
= = Reconstruction efforts = =
[STATEMENT] lemma sum_list_replicate_length' [simp]: "sum_list (replicate n (Suc 0)) = n" [PROOF STATE] proof (prove) goal (1 subgoal): 1. sum_list (replicate n (Suc 0)) = n [PROOF STEP] by (induct n) simp_all
module Main tarai : Int -> Int -> Int -> Int tarai x y z = if x <= y then y else tarai (tarai (x - 1) y z) (tarai (y - 1) z x) (tarai (z - 1) x y) main : JS_IO () main = do putStr' $ show (tarai 11 5 0)
[GOAL] G : Type u_1 inst✝⁴ : MeasurableSpace G inst✝³ : Group G inst✝² : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝¹ : SigmaFinite Ξ½ inst✝ : SigmaFinite ΞΌ s : Set G hs : MeasurableSet s ⊒ Measurable fun x => ↑↑μ ((fun y => y * x) ⁻¹' s) [PROOFSTEP] suffices Measurable fun y => ΞΌ ((fun x => (x, y)) ⁻¹' ((fun z : G Γ— G => ((1 : G), z.1 * z.2)) ⁻¹' univ Γ—Λ’ s)) by convert this using 1; ext1 x; congr 1 with y : 1; simp [GOAL] G : Type u_1 inst✝⁴ : MeasurableSpace G inst✝³ : Group G inst✝² : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝¹ : SigmaFinite Ξ½ inst✝ : SigmaFinite ΞΌ s : Set G hs : MeasurableSet s this : Measurable fun y => ↑↑μ ((fun x => (x, y)) ⁻¹' ((fun z => (1, z.fst * z.snd)) ⁻¹' univ Γ—Λ’ s)) ⊒ Measurable fun x => ↑↑μ ((fun y => y * x) ⁻¹' s) [PROOFSTEP] convert this using 1 [GOAL] case h.e'_5 G : Type u_1 inst✝⁴ : MeasurableSpace G inst✝³ : Group G inst✝² : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝¹ : SigmaFinite Ξ½ inst✝ : SigmaFinite ΞΌ s : Set G hs : MeasurableSet s this : Measurable fun y => ↑↑μ ((fun x => (x, y)) ⁻¹' ((fun z => (1, z.fst * z.snd)) ⁻¹' univ Γ—Λ’ s)) ⊒ (fun x => ↑↑μ ((fun y => y * x) ⁻¹' s)) = fun y => ↑↑μ ((fun x => (x, y)) ⁻¹' ((fun z => (1, z.fst * z.snd)) ⁻¹' univ Γ—Λ’ s)) [PROOFSTEP] ext1 x [GOAL] case h.e'_5.h G : Type u_1 inst✝⁴ : MeasurableSpace G inst✝³ : Group G inst✝² : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝¹ : SigmaFinite Ξ½ inst✝ : SigmaFinite ΞΌ s : Set G hs : MeasurableSet s this : Measurable fun y => ↑↑μ ((fun x => (x, y)) ⁻¹' ((fun z => (1, z.fst * z.snd)) ⁻¹' univ Γ—Λ’ s)) x : G ⊒ ↑↑μ ((fun y => y * x) ⁻¹' s) = ↑↑μ ((fun x_1 => (x_1, x)) ⁻¹' ((fun z => (1, z.fst * z.snd)) ⁻¹' univ Γ—Λ’ s)) [PROOFSTEP] congr 1 with y : 1 [GOAL] case h.e'_5.h.e_a.h G : Type u_1 inst✝⁴ : MeasurableSpace G inst✝³ : Group G inst✝² : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝¹ : SigmaFinite Ξ½ inst✝ : SigmaFinite ΞΌ s : Set G hs : MeasurableSet s this : Measurable fun y => ↑↑μ ((fun x => (x, y)) ⁻¹' ((fun z => (1, z.fst * z.snd)) ⁻¹' univ Γ—Λ’ s)) x y : G ⊒ y ∈ (fun y => y * x) ⁻¹' s ↔ y ∈ (fun x_1 => (x_1, x)) ⁻¹' ((fun z => (1, z.fst * z.snd)) ⁻¹' univ Γ—Λ’ s) [PROOFSTEP] simp [GOAL] G : Type u_1 inst✝⁴ : MeasurableSpace G inst✝³ : Group G inst✝² : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝¹ : SigmaFinite Ξ½ inst✝ : SigmaFinite ΞΌ s : Set G hs : MeasurableSet s ⊒ Measurable fun y => ↑↑μ ((fun x => (x, y)) ⁻¹' ((fun z => (1, z.fst * z.snd)) ⁻¹' univ Γ—Λ’ s)) [PROOFSTEP] apply measurable_measure_prod_mk_right [GOAL] case hs G : Type u_1 inst✝⁴ : MeasurableSpace G inst✝³ : Group G inst✝² : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝¹ : SigmaFinite Ξ½ inst✝ : SigmaFinite ΞΌ s : Set G hs : MeasurableSet s ⊒ MeasurableSet ((fun z => (1, z.fst * z.snd)) ⁻¹' univ Γ—Λ’ s) [PROOFSTEP] apply measurable_const.prod_mk measurable_mul (MeasurableSet.univ.prod hs) [GOAL] G : Type u_1 inst✝⁴ : MeasurableSpace G inst✝³ : Group G inst✝² : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝¹ : SigmaFinite Ξ½ inst✝ : SigmaFinite ΞΌ s : Set G hs : MeasurableSet s ⊒ MeasurableSpace G [PROOFSTEP] infer_instance [GOAL] G : Type u_1 inst✝⁷ : MeasurableSpace G inst✝⁢ : Group G inst✝⁡ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝⁴ : SigmaFinite Ξ½ inst✝³ : SigmaFinite ΞΌ s : Set G inst✝² : MeasurableInv G inst✝¹ : IsMulLeftInvariant ΞΌ inst✝ : IsMulLeftInvariant Ξ½ ⊒ MeasurePreserving fun z => (z.snd * z.fst, z.fst⁻¹) [PROOFSTEP] convert (measurePreserving_prod_inv_mul_swap Ξ½ ΞΌ).comp (measurePreserving_prod_mul_swap ΞΌ Ξ½) using 1 [GOAL] case h.e'_5 G : Type u_1 inst✝⁷ : MeasurableSpace G inst✝⁢ : Group G inst✝⁡ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝⁴ : SigmaFinite Ξ½ inst✝³ : SigmaFinite ΞΌ s : Set G inst✝² : MeasurableInv G inst✝¹ : IsMulLeftInvariant ΞΌ inst✝ : IsMulLeftInvariant Ξ½ ⊒ (fun z => (z.snd * z.fst, z.fst⁻¹)) = (fun z => (z.snd, z.snd⁻¹ * z.fst)) ∘ fun z => (z.snd, z.snd * z.fst) [PROOFSTEP] ext1 ⟨x, y⟩ [GOAL] case h.e'_5.h.mk G : Type u_1 inst✝⁷ : MeasurableSpace G inst✝⁢ : Group G inst✝⁡ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝⁴ : SigmaFinite Ξ½ inst✝³ : SigmaFinite ΞΌ s : Set G inst✝² : MeasurableInv G inst✝¹ : IsMulLeftInvariant ΞΌ inst✝ : IsMulLeftInvariant Ξ½ x y : G ⊒ ((x, y).snd * (x, y).fst, (x, y).fst⁻¹) = ((fun z => (z.snd, z.snd⁻¹ * z.fst)) ∘ fun z => (z.snd, z.snd * z.fst)) (x, y) [PROOFSTEP] simp_rw [Function.comp_apply, mul_inv_rev, inv_mul_cancel_right] [GOAL] G : Type u_1 inst✝⁢ : MeasurableSpace G inst✝⁡ : Group G inst✝⁴ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝³ : SigmaFinite Ξ½ inst✝² : SigmaFinite ΞΌ s : Set G inst✝¹ : MeasurableInv G inst✝ : IsMulLeftInvariant ΞΌ ⊒ QuasiMeasurePreserving Inv.inv [PROOFSTEP] refine' ⟨measurable_inv, AbsolutelyContinuous.mk fun s hsm hΞΌs => _⟩ [GOAL] G : Type u_1 inst✝⁢ : MeasurableSpace G inst✝⁡ : Group G inst✝⁴ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝³ : SigmaFinite Ξ½ inst✝² : SigmaFinite ΞΌ s✝ : Set G inst✝¹ : MeasurableInv G inst✝ : IsMulLeftInvariant ΞΌ s : Set G hsm : MeasurableSet s hΞΌs : ↑↑μ s = 0 ⊒ ↑↑(map Inv.inv ΞΌ) s = 0 [PROOFSTEP] rw [map_apply measurable_inv hsm, inv_preimage] [GOAL] G : Type u_1 inst✝⁢ : MeasurableSpace G inst✝⁡ : Group G inst✝⁴ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝³ : SigmaFinite Ξ½ inst✝² : SigmaFinite ΞΌ s✝ : Set G inst✝¹ : MeasurableInv G inst✝ : IsMulLeftInvariant ΞΌ s : Set G hsm : MeasurableSet s hΞΌs : ↑↑μ s = 0 ⊒ ↑↑μ s⁻¹ = 0 [PROOFSTEP] have hf : Measurable fun z : G Γ— G => (z.2 * z.1, z.1⁻¹) := (measurable_snd.mul measurable_fst).prod_mk measurable_fst.inv [GOAL] G : Type u_1 inst✝⁢ : MeasurableSpace G inst✝⁡ : Group G inst✝⁴ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝³ : SigmaFinite Ξ½ inst✝² : SigmaFinite ΞΌ s✝ : Set G inst✝¹ : MeasurableInv G inst✝ : IsMulLeftInvariant ΞΌ s : Set G hsm : MeasurableSet s hΞΌs : ↑↑μ s = 0 hf : Measurable fun z => (z.snd * z.fst, z.fst⁻¹) ⊒ ↑↑μ s⁻¹ = 0 [PROOFSTEP] suffices map (fun z : G Γ— G => (z.2 * z.1, z.1⁻¹)) (ΞΌ.prod ΞΌ) (s⁻¹ Γ—Λ’ s⁻¹) = 0 by simpa only [(measurePreserving_mul_prod_inv ΞΌ ΞΌ).map_eq, prod_prod, mul_eq_zero (Mβ‚€ := ℝβ‰₯0∞), or_self_iff] using this [GOAL] G : Type u_1 inst✝⁢ : MeasurableSpace G inst✝⁡ : Group G inst✝⁴ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝³ : SigmaFinite Ξ½ inst✝² : SigmaFinite ΞΌ s✝ : Set G inst✝¹ : MeasurableInv G inst✝ : IsMulLeftInvariant ΞΌ s : Set G hsm : MeasurableSet s hΞΌs : ↑↑μ s = 0 hf : Measurable fun z => (z.snd * z.fst, z.fst⁻¹) this : ↑↑(map (fun z => (z.snd * z.fst, z.fst⁻¹)) (Measure.prod ΞΌ ΞΌ)) (s⁻¹ Γ—Λ’ s⁻¹) = 0 ⊒ ↑↑μ s⁻¹ = 0 [PROOFSTEP] simpa only [(measurePreserving_mul_prod_inv ΞΌ ΞΌ).map_eq, prod_prod, mul_eq_zero (Mβ‚€ := ℝβ‰₯0∞), or_self_iff] using this [GOAL] G : Type u_1 inst✝⁢ : MeasurableSpace G inst✝⁡ : Group G inst✝⁴ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝³ : SigmaFinite Ξ½ inst✝² : SigmaFinite ΞΌ s✝ : Set G inst✝¹ : MeasurableInv G inst✝ : IsMulLeftInvariant ΞΌ s : Set G hsm : MeasurableSet s hΞΌs : ↑↑μ s = 0 hf : Measurable fun z => (z.snd * z.fst, z.fst⁻¹) ⊒ ↑↑(map (fun z => (z.snd * z.fst, z.fst⁻¹)) (Measure.prod ΞΌ ΞΌ)) (s⁻¹ Γ—Λ’ s⁻¹) = 0 [PROOFSTEP] have hsm' : MeasurableSet (s⁻¹ Γ—Λ’ s⁻¹) := hsm.inv.prod hsm.inv [GOAL] G : Type u_1 inst✝⁢ : MeasurableSpace G inst✝⁡ : Group G inst✝⁴ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝³ : SigmaFinite Ξ½ inst✝² : SigmaFinite ΞΌ s✝ : Set G inst✝¹ : MeasurableInv G inst✝ : IsMulLeftInvariant ΞΌ s : Set G hsm : MeasurableSet s hΞΌs : ↑↑μ s = 0 hf : Measurable fun z => (z.snd * z.fst, z.fst⁻¹) hsm' : MeasurableSet (s⁻¹ Γ—Λ’ s⁻¹) ⊒ ↑↑(map (fun z => (z.snd * z.fst, z.fst⁻¹)) (Measure.prod ΞΌ ΞΌ)) (s⁻¹ Γ—Λ’ s⁻¹) = 0 [PROOFSTEP] simp_rw [map_apply hf hsm', prod_apply_symm (ΞΌ := ΞΌ) (Ξ½ := ΞΌ) (hf hsm'), preimage_preimage, mk_preimage_prod, inv_preimage, inv_inv, measure_mono_null (inter_subset_right _ _) hΞΌs, lintegral_zero] [GOAL] G : Type u_1 inst✝⁢ : MeasurableSpace G inst✝⁡ : Group G inst✝⁴ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝³ : SigmaFinite Ξ½ inst✝² : SigmaFinite ΞΌ s : Set G inst✝¹ : MeasurableInv G inst✝ : IsMulLeftInvariant ΞΌ ⊒ ↑↑μ s⁻¹ = 0 ↔ ↑↑μ s = 0 [PROOFSTEP] refine' ⟨fun hs => _, (quasiMeasurePreserving_inv ΞΌ).preimage_null⟩ [GOAL] G : Type u_1 inst✝⁢ : MeasurableSpace G inst✝⁡ : Group G inst✝⁴ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝³ : SigmaFinite Ξ½ inst✝² : SigmaFinite ΞΌ s : Set G inst✝¹ : MeasurableInv G inst✝ : IsMulLeftInvariant ΞΌ hs : ↑↑μ s⁻¹ = 0 ⊒ ↑↑μ s = 0 [PROOFSTEP] rw [← inv_inv s] [GOAL] G : Type u_1 inst✝⁢ : MeasurableSpace G inst✝⁡ : Group G inst✝⁴ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝³ : SigmaFinite Ξ½ inst✝² : SigmaFinite ΞΌ s : Set G inst✝¹ : MeasurableInv G inst✝ : IsMulLeftInvariant ΞΌ hs : ↑↑μ s⁻¹ = 0 ⊒ ↑↑μ s⁻¹⁻¹ = 0 [PROOFSTEP] exact (quasiMeasurePreserving_inv ΞΌ).preimage_null hs [GOAL] G : Type u_1 inst✝⁢ : MeasurableSpace G inst✝⁡ : Group G inst✝⁴ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝³ : SigmaFinite Ξ½ inst✝² : SigmaFinite ΞΌ s : Set G inst✝¹ : MeasurableInv G inst✝ : IsMulLeftInvariant ΞΌ ⊒ ΞΌ β‰ͺ Measure.inv ΞΌ [PROOFSTEP] refine' AbsolutelyContinuous.mk fun s _ => _ [GOAL] G : Type u_1 inst✝⁢ : MeasurableSpace G inst✝⁡ : Group G inst✝⁴ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝³ : SigmaFinite Ξ½ inst✝² : SigmaFinite ΞΌ s✝ : Set G inst✝¹ : MeasurableInv G inst✝ : IsMulLeftInvariant ΞΌ s : Set G x✝ : MeasurableSet s ⊒ ↑↑(Measure.inv ΞΌ) s = 0 β†’ ↑↑μ s = 0 [PROOFSTEP] simp_rw [inv_apply ΞΌ s, measure_inv_null, imp_self] [GOAL] G : Type u_1 inst✝⁷ : MeasurableSpace G inst✝⁢ : Group G inst✝⁡ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝⁴ : SigmaFinite Ξ½ inst✝³ : SigmaFinite ΞΌ s : Set G inst✝² : MeasurableInv G inst✝¹ : IsMulLeftInvariant ΞΌ inst✝ : IsMulLeftInvariant Ξ½ f : G β†’ G β†’ ℝβ‰₯0∞ hf : AEMeasurable (uncurry f) ⊒ ∫⁻ (x : G), ∫⁻ (y : G), f (y * x) x⁻¹ βˆ‚Ξ½ βˆ‚ΞΌ = ∫⁻ (x : G), ∫⁻ (y : G), f x y βˆ‚Ξ½ βˆ‚ΞΌ [PROOFSTEP] have h : Measurable fun z : G Γ— G => (z.2 * z.1, z.1⁻¹) := (measurable_snd.mul measurable_fst).prod_mk measurable_fst.inv [GOAL] G : Type u_1 inst✝⁷ : MeasurableSpace G inst✝⁢ : Group G inst✝⁡ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝⁴ : SigmaFinite Ξ½ inst✝³ : SigmaFinite ΞΌ s : Set G inst✝² : MeasurableInv G inst✝¹ : IsMulLeftInvariant ΞΌ inst✝ : IsMulLeftInvariant Ξ½ f : G β†’ G β†’ ℝβ‰₯0∞ hf : AEMeasurable (uncurry f) h : Measurable fun z => (z.snd * z.fst, z.fst⁻¹) ⊒ ∫⁻ (x : G), ∫⁻ (y : G), f (y * x) x⁻¹ βˆ‚Ξ½ βˆ‚ΞΌ = ∫⁻ (x : G), ∫⁻ (y : G), f x y βˆ‚Ξ½ βˆ‚ΞΌ [PROOFSTEP] have h2f : AEMeasurable (uncurry fun x y => f (y * x) x⁻¹) (ΞΌ.prod Ξ½) := hf.comp_quasiMeasurePreserving (measurePreserving_mul_prod_inv ΞΌ Ξ½).quasiMeasurePreserving [GOAL] G : Type u_1 inst✝⁷ : MeasurableSpace G inst✝⁢ : Group G inst✝⁡ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝⁴ : SigmaFinite Ξ½ inst✝³ : SigmaFinite ΞΌ s : Set G inst✝² : MeasurableInv G inst✝¹ : IsMulLeftInvariant ΞΌ inst✝ : IsMulLeftInvariant Ξ½ f : G β†’ G β†’ ℝβ‰₯0∞ hf : AEMeasurable (uncurry f) h : Measurable fun z => (z.snd * z.fst, z.fst⁻¹) h2f : AEMeasurable (uncurry fun x y => f (y * x) x⁻¹) ⊒ ∫⁻ (x : G), ∫⁻ (y : G), f (y * x) x⁻¹ βˆ‚Ξ½ βˆ‚ΞΌ = ∫⁻ (x : G), ∫⁻ (y : G), f x y βˆ‚Ξ½ βˆ‚ΞΌ [PROOFSTEP] simp_rw [lintegral_lintegral h2f, lintegral_lintegral hf] [GOAL] G : Type u_1 inst✝⁷ : MeasurableSpace G inst✝⁢ : Group G inst✝⁡ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝⁴ : SigmaFinite Ξ½ inst✝³ : SigmaFinite ΞΌ s : Set G inst✝² : MeasurableInv G inst✝¹ : IsMulLeftInvariant ΞΌ inst✝ : IsMulLeftInvariant Ξ½ f : G β†’ G β†’ ℝβ‰₯0∞ hf : AEMeasurable (uncurry f) h : Measurable fun z => (z.snd * z.fst, z.fst⁻¹) h2f : AEMeasurable (uncurry fun x y => f (y * x) x⁻¹) ⊒ ∫⁻ (z : G Γ— G), f (z.snd * z.fst) z.fst⁻¹ βˆ‚Measure.prod ΞΌ Ξ½ = ∫⁻ (z : G Γ— G), f z.fst z.snd βˆ‚Measure.prod ΞΌ Ξ½ [PROOFSTEP] conv_rhs => rw [← (measurePreserving_mul_prod_inv ΞΌ Ξ½).map_eq] [GOAL] G : Type u_1 inst✝⁷ : MeasurableSpace G inst✝⁢ : Group G inst✝⁡ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝⁴ : SigmaFinite Ξ½ inst✝³ : SigmaFinite ΞΌ s : Set G inst✝² : MeasurableInv G inst✝¹ : IsMulLeftInvariant ΞΌ inst✝ : IsMulLeftInvariant Ξ½ f : G β†’ G β†’ ℝβ‰₯0∞ hf : AEMeasurable (uncurry f) h : Measurable fun z => (z.snd * z.fst, z.fst⁻¹) h2f : AEMeasurable (uncurry fun x y => f (y * x) x⁻¹) | ∫⁻ (z : G Γ— G), f z.fst z.snd βˆ‚Measure.prod ΞΌ Ξ½ [PROOFSTEP] rw [← (measurePreserving_mul_prod_inv ΞΌ Ξ½).map_eq] [GOAL] G : Type u_1 inst✝⁷ : MeasurableSpace G inst✝⁢ : Group G inst✝⁡ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝⁴ : SigmaFinite Ξ½ inst✝³ : SigmaFinite ΞΌ s : Set G inst✝² : MeasurableInv G inst✝¹ : IsMulLeftInvariant ΞΌ inst✝ : IsMulLeftInvariant Ξ½ f : G β†’ G β†’ ℝβ‰₯0∞ hf : AEMeasurable (uncurry f) h : Measurable fun z => (z.snd * z.fst, z.fst⁻¹) h2f : AEMeasurable (uncurry fun x y => f (y * x) x⁻¹) | ∫⁻ (z : G Γ— G), f z.fst z.snd βˆ‚Measure.prod ΞΌ Ξ½ [PROOFSTEP] rw [← (measurePreserving_mul_prod_inv ΞΌ Ξ½).map_eq] [GOAL] G : Type u_1 inst✝⁷ : MeasurableSpace G inst✝⁢ : Group G inst✝⁡ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝⁴ : SigmaFinite Ξ½ inst✝³ : SigmaFinite ΞΌ s : Set G inst✝² : MeasurableInv G inst✝¹ : IsMulLeftInvariant ΞΌ inst✝ : IsMulLeftInvariant Ξ½ f : G β†’ G β†’ ℝβ‰₯0∞ hf : AEMeasurable (uncurry f) h : Measurable fun z => (z.snd * z.fst, z.fst⁻¹) h2f : AEMeasurable (uncurry fun x y => f (y * x) x⁻¹) | ∫⁻ (z : G Γ— G), f z.fst z.snd βˆ‚Measure.prod ΞΌ Ξ½ [PROOFSTEP] rw [← (measurePreserving_mul_prod_inv ΞΌ Ξ½).map_eq] [GOAL] G : Type u_1 inst✝⁷ : MeasurableSpace G inst✝⁢ : Group G inst✝⁡ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝⁴ : SigmaFinite Ξ½ inst✝³ : SigmaFinite ΞΌ s : Set G inst✝² : MeasurableInv G inst✝¹ : IsMulLeftInvariant ΞΌ inst✝ : IsMulLeftInvariant Ξ½ f : G β†’ G β†’ ℝβ‰₯0∞ hf : AEMeasurable (uncurry f) h : Measurable fun z => (z.snd * z.fst, z.fst⁻¹) h2f : AEMeasurable (uncurry fun x y => f (y * x) x⁻¹) ⊒ ∫⁻ (z : G Γ— G), f (z.snd * z.fst) z.fst⁻¹ βˆ‚Measure.prod ΞΌ Ξ½ = ∫⁻ (z : G Γ— G), f z.fst z.snd βˆ‚map (fun z => (z.snd * z.fst, z.fst⁻¹)) (Measure.prod ΞΌ Ξ½) [PROOFSTEP] symm [GOAL] G : Type u_1 inst✝⁷ : MeasurableSpace G inst✝⁢ : Group G inst✝⁡ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝⁴ : SigmaFinite Ξ½ inst✝³ : SigmaFinite ΞΌ s : Set G inst✝² : MeasurableInv G inst✝¹ : IsMulLeftInvariant ΞΌ inst✝ : IsMulLeftInvariant Ξ½ f : G β†’ G β†’ ℝβ‰₯0∞ hf : AEMeasurable (uncurry f) h : Measurable fun z => (z.snd * z.fst, z.fst⁻¹) h2f : AEMeasurable (uncurry fun x y => f (y * x) x⁻¹) ⊒ ∫⁻ (z : G Γ— G), f z.fst z.snd βˆ‚map (fun z => (z.snd * z.fst, z.fst⁻¹)) (Measure.prod ΞΌ Ξ½) = ∫⁻ (z : G Γ— G), f (z.snd * z.fst) z.fst⁻¹ βˆ‚Measure.prod ΞΌ Ξ½ [PROOFSTEP] exact lintegral_map' (hf.mono' (measurePreserving_mul_prod_inv ΞΌ Ξ½).map_eq.absolutelyContinuous) h.aemeasurable [GOAL] G : Type u_1 inst✝⁢ : MeasurableSpace G inst✝⁡ : Group G inst✝⁴ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝³ : SigmaFinite Ξ½ inst✝² : SigmaFinite ΞΌ s : Set G inst✝¹ : MeasurableInv G inst✝ : IsMulLeftInvariant ΞΌ y : G ⊒ ↑↑μ ((fun x => x * y) ⁻¹' s) = 0 ↔ ↑↑μ ((fun x => y⁻¹ * x) ⁻¹' s⁻¹)⁻¹ = 0 [PROOFSTEP] simp_rw [← inv_preimage, preimage_preimage, mul_inv_rev, inv_inv] [GOAL] G : Type u_1 inst✝⁢ : MeasurableSpace G inst✝⁡ : Group G inst✝⁴ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝³ : SigmaFinite Ξ½ inst✝² : SigmaFinite ΞΌ s : Set G inst✝¹ : MeasurableInv G inst✝ : IsMulLeftInvariant ΞΌ y : G ⊒ ↑↑μ ((fun x => y⁻¹ * x) ⁻¹' s⁻¹)⁻¹ = 0 ↔ ↑↑μ s = 0 [PROOFSTEP] simp only [measure_inv_null ΞΌ, measure_preimage_mul] [GOAL] G : Type u_1 inst✝⁢ : MeasurableSpace G inst✝⁡ : Group G inst✝⁴ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝³ : SigmaFinite Ξ½ inst✝² : SigmaFinite ΞΌ s : Set G inst✝¹ : MeasurableInv G inst✝ : IsMulLeftInvariant ΞΌ g : G ⊒ ΞΌ β‰ͺ map (fun x => x * g) ΞΌ [PROOFSTEP] refine' AbsolutelyContinuous.mk fun s hs => _ [GOAL] G : Type u_1 inst✝⁢ : MeasurableSpace G inst✝⁡ : Group G inst✝⁴ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝³ : SigmaFinite Ξ½ inst✝² : SigmaFinite ΞΌ s✝ : Set G inst✝¹ : MeasurableInv G inst✝ : IsMulLeftInvariant ΞΌ g : G s : Set G hs : MeasurableSet s ⊒ ↑↑(map (fun x => x * g) ΞΌ) s = 0 β†’ ↑↑μ s = 0 [PROOFSTEP] rw [map_apply (measurable_mul_const g) hs, measure_mul_right_null] [GOAL] G : Type u_1 inst✝⁢ : MeasurableSpace G inst✝⁡ : Group G inst✝⁴ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝³ : SigmaFinite Ξ½ inst✝² : SigmaFinite ΞΌ s✝ : Set G inst✝¹ : MeasurableInv G inst✝ : IsMulLeftInvariant ΞΌ g : G s : Set G hs : MeasurableSet s ⊒ ↑↑μ s = 0 β†’ ↑↑μ s = 0 [PROOFSTEP] exact id [GOAL] G : Type u_1 inst✝⁢ : MeasurableSpace G inst✝⁡ : Group G inst✝⁴ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝³ : SigmaFinite Ξ½ inst✝² : SigmaFinite ΞΌ s : Set G inst✝¹ : MeasurableInv G inst✝ : IsMulLeftInvariant ΞΌ g : G ⊒ ΞΌ β‰ͺ map (fun h => g / h) ΞΌ [PROOFSTEP] simp_rw [div_eq_mul_inv] [GOAL] G : Type u_1 inst✝⁢ : MeasurableSpace G inst✝⁡ : Group G inst✝⁴ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝³ : SigmaFinite Ξ½ inst✝² : SigmaFinite ΞΌ s : Set G inst✝¹ : MeasurableInv G inst✝ : IsMulLeftInvariant ΞΌ g : G ⊒ ΞΌ β‰ͺ map (fun h => g * h⁻¹) ΞΌ [PROOFSTEP] erw [← map_map (measurable_const_mul g) measurable_inv] [GOAL] G : Type u_1 inst✝⁢ : MeasurableSpace G inst✝⁡ : Group G inst✝⁴ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝³ : SigmaFinite Ξ½ inst✝² : SigmaFinite ΞΌ s : Set G inst✝¹ : MeasurableInv G inst✝ : IsMulLeftInvariant ΞΌ g : G ⊒ ΞΌ β‰ͺ map (fun x => g * x) (map Inv.inv ΞΌ) [PROOFSTEP] conv_lhs => rw [← map_mul_left_eq_self ΞΌ g] [GOAL] G : Type u_1 inst✝⁢ : MeasurableSpace G inst✝⁡ : Group G inst✝⁴ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝³ : SigmaFinite Ξ½ inst✝² : SigmaFinite ΞΌ s : Set G inst✝¹ : MeasurableInv G inst✝ : IsMulLeftInvariant ΞΌ g : G | ΞΌ [PROOFSTEP] rw [← map_mul_left_eq_self ΞΌ g] [GOAL] G : Type u_1 inst✝⁢ : MeasurableSpace G inst✝⁡ : Group G inst✝⁴ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝³ : SigmaFinite Ξ½ inst✝² : SigmaFinite ΞΌ s : Set G inst✝¹ : MeasurableInv G inst✝ : IsMulLeftInvariant ΞΌ g : G | ΞΌ [PROOFSTEP] rw [← map_mul_left_eq_self ΞΌ g] [GOAL] G : Type u_1 inst✝⁢ : MeasurableSpace G inst✝⁡ : Group G inst✝⁴ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝³ : SigmaFinite Ξ½ inst✝² : SigmaFinite ΞΌ s : Set G inst✝¹ : MeasurableInv G inst✝ : IsMulLeftInvariant ΞΌ g : G | ΞΌ [PROOFSTEP] rw [← map_mul_left_eq_self ΞΌ g] [GOAL] G : Type u_1 inst✝⁢ : MeasurableSpace G inst✝⁡ : Group G inst✝⁴ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝³ : SigmaFinite Ξ½ inst✝² : SigmaFinite ΞΌ s : Set G inst✝¹ : MeasurableInv G inst✝ : IsMulLeftInvariant ΞΌ g : G ⊒ map (fun x => g * x) ΞΌ β‰ͺ map (fun x => g * x) (map Inv.inv ΞΌ) [PROOFSTEP] exact (absolutelyContinuous_inv ΞΌ).map (measurable_const_mul g) [GOAL] G : Type u_1 inst✝⁷ : MeasurableSpace G inst✝⁢ : Group G inst✝⁡ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝⁴ : SigmaFinite Ξ½ inst✝³ : SigmaFinite ΞΌ s : Set G inst✝² : MeasurableInv G inst✝¹ : IsMulLeftInvariant ΞΌ inst✝ : IsMulLeftInvariant Ξ½ sm : MeasurableSet s f : G β†’ ℝβ‰₯0∞ hf : Measurable f ⊒ ↑↑μ s * ∫⁻ (y : G), f y βˆ‚Ξ½ = ∫⁻ (x : G), ↑↑ν ((fun z => z * x) ⁻¹' s) * f x⁻¹ βˆ‚ΞΌ [PROOFSTEP] rw [← set_lintegral_one, ← lintegral_indicator _ sm, ← lintegral_lintegral_mul (measurable_const.indicator sm).aemeasurable hf.aemeasurable, ← lintegral_lintegral_mul_inv ΞΌ Ξ½] [GOAL] G : Type u_1 inst✝⁷ : MeasurableSpace G inst✝⁢ : Group G inst✝⁡ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝⁴ : SigmaFinite Ξ½ inst✝³ : SigmaFinite ΞΌ s : Set G inst✝² : MeasurableInv G inst✝¹ : IsMulLeftInvariant ΞΌ inst✝ : IsMulLeftInvariant Ξ½ sm : MeasurableSet s f : G β†’ ℝβ‰₯0∞ hf : Measurable f ⊒ ∫⁻ (x : G), ∫⁻ (y : G), indicator s (fun x => 1) (y * x) * f x⁻¹ βˆ‚Ξ½ βˆ‚ΞΌ = ∫⁻ (x : G), ↑↑ν ((fun z => z * x) ⁻¹' s) * f x⁻¹ βˆ‚ΞΌ case hf G : Type u_1 inst✝⁷ : MeasurableSpace G inst✝⁢ : Group G inst✝⁡ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝⁴ : SigmaFinite Ξ½ inst✝³ : SigmaFinite ΞΌ s : Set G inst✝² : MeasurableInv G inst✝¹ : IsMulLeftInvariant ΞΌ inst✝ : IsMulLeftInvariant Ξ½ sm : MeasurableSet s f : G β†’ ℝβ‰₯0∞ hf : Measurable f ⊒ AEMeasurable (uncurry fun x y => indicator s (fun x => 1) x * f y) [PROOFSTEP] swap [GOAL] case hf G : Type u_1 inst✝⁷ : MeasurableSpace G inst✝⁢ : Group G inst✝⁡ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝⁴ : SigmaFinite Ξ½ inst✝³ : SigmaFinite ΞΌ s : Set G inst✝² : MeasurableInv G inst✝¹ : IsMulLeftInvariant ΞΌ inst✝ : IsMulLeftInvariant Ξ½ sm : MeasurableSet s f : G β†’ ℝβ‰₯0∞ hf : Measurable f ⊒ AEMeasurable (uncurry fun x y => indicator s (fun x => 1) x * f y) [PROOFSTEP] exact (((measurable_const.indicator sm).comp measurable_fst).mul (hf.comp measurable_snd)).aemeasurable [GOAL] G : Type u_1 inst✝⁷ : MeasurableSpace G inst✝⁢ : Group G inst✝⁡ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝⁴ : SigmaFinite Ξ½ inst✝³ : SigmaFinite ΞΌ s : Set G inst✝² : MeasurableInv G inst✝¹ : IsMulLeftInvariant ΞΌ inst✝ : IsMulLeftInvariant Ξ½ sm : MeasurableSet s f : G β†’ ℝβ‰₯0∞ hf : Measurable f ⊒ ∫⁻ (x : G), ∫⁻ (y : G), indicator s (fun x => 1) (y * x) * f x⁻¹ βˆ‚Ξ½ βˆ‚ΞΌ = ∫⁻ (x : G), ↑↑ν ((fun z => z * x) ⁻¹' s) * f x⁻¹ βˆ‚ΞΌ [PROOFSTEP] have ms : βˆ€ x : G, Measurable fun y => ((fun z => z * x) ⁻¹' s).indicator (fun _ => (1 : ℝβ‰₯0∞)) y := fun x => measurable_const.indicator (measurable_mul_const _ sm) [GOAL] G : Type u_1 inst✝⁷ : MeasurableSpace G inst✝⁢ : Group G inst✝⁡ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝⁴ : SigmaFinite Ξ½ inst✝³ : SigmaFinite ΞΌ s : Set G inst✝² : MeasurableInv G inst✝¹ : IsMulLeftInvariant ΞΌ inst✝ : IsMulLeftInvariant Ξ½ sm : MeasurableSet s f : G β†’ ℝβ‰₯0∞ hf : Measurable f ms : βˆ€ (x : G), Measurable fun y => indicator ((fun z => z * x) ⁻¹' s) (fun x => 1) y ⊒ ∫⁻ (x : G), ∫⁻ (y : G), indicator s (fun x => 1) (y * x) * f x⁻¹ βˆ‚Ξ½ βˆ‚ΞΌ = ∫⁻ (x : G), ↑↑ν ((fun z => z * x) ⁻¹' s) * f x⁻¹ βˆ‚ΞΌ [PROOFSTEP] have : βˆ€ x y, s.indicator (fun _ : G => (1 : ℝβ‰₯0∞)) (y * x) = ((fun z => z * x) ⁻¹' s).indicator (fun b : G => 1) y := by intro x y; symm; convert indicator_comp_right (M := ℝβ‰₯0∞) fun y => y * x using 2; ext1; rfl [GOAL] G : Type u_1 inst✝⁷ : MeasurableSpace G inst✝⁢ : Group G inst✝⁡ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝⁴ : SigmaFinite Ξ½ inst✝³ : SigmaFinite ΞΌ s : Set G inst✝² : MeasurableInv G inst✝¹ : IsMulLeftInvariant ΞΌ inst✝ : IsMulLeftInvariant Ξ½ sm : MeasurableSet s f : G β†’ ℝβ‰₯0∞ hf : Measurable f ms : βˆ€ (x : G), Measurable fun y => indicator ((fun z => z * x) ⁻¹' s) (fun x => 1) y ⊒ βˆ€ (x y : G), indicator s (fun x => 1) (y * x) = indicator ((fun z => z * x) ⁻¹' s) (fun b => 1) y [PROOFSTEP] intro x y [GOAL] G : Type u_1 inst✝⁷ : MeasurableSpace G inst✝⁢ : Group G inst✝⁡ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝⁴ : SigmaFinite Ξ½ inst✝³ : SigmaFinite ΞΌ s : Set G inst✝² : MeasurableInv G inst✝¹ : IsMulLeftInvariant ΞΌ inst✝ : IsMulLeftInvariant Ξ½ sm : MeasurableSet s f : G β†’ ℝβ‰₯0∞ hf : Measurable f ms : βˆ€ (x : G), Measurable fun y => indicator ((fun z => z * x) ⁻¹' s) (fun x => 1) y x y : G ⊒ indicator s (fun x => 1) (y * x) = indicator ((fun z => z * x) ⁻¹' s) (fun b => 1) y [PROOFSTEP] symm [GOAL] G : Type u_1 inst✝⁷ : MeasurableSpace G inst✝⁢ : Group G inst✝⁡ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝⁴ : SigmaFinite Ξ½ inst✝³ : SigmaFinite ΞΌ s : Set G inst✝² : MeasurableInv G inst✝¹ : IsMulLeftInvariant ΞΌ inst✝ : IsMulLeftInvariant Ξ½ sm : MeasurableSet s f : G β†’ ℝβ‰₯0∞ hf : Measurable f ms : βˆ€ (x : G), Measurable fun y => indicator ((fun z => z * x) ⁻¹' s) (fun x => 1) y x y : G ⊒ indicator ((fun z => z * x) ⁻¹' s) (fun b => 1) y = indicator s (fun x => 1) (y * x) [PROOFSTEP] convert indicator_comp_right (M := ℝβ‰₯0∞) fun y => y * x using 2 [GOAL] case h.e'_2.h.e'_5 G : Type u_1 inst✝⁷ : MeasurableSpace G inst✝⁢ : Group G inst✝⁡ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝⁴ : SigmaFinite Ξ½ inst✝³ : SigmaFinite ΞΌ s : Set G inst✝² : MeasurableInv G inst✝¹ : IsMulLeftInvariant ΞΌ inst✝ : IsMulLeftInvariant Ξ½ sm : MeasurableSet s f : G β†’ ℝβ‰₯0∞ hf : Measurable f ms : βˆ€ (x : G), Measurable fun y => indicator ((fun z => z * x) ⁻¹' s) (fun x => 1) y x y : G ⊒ (fun b => 1) = (fun x => 1) ∘ fun y => y * x [PROOFSTEP] ext1 [GOAL] case h.e'_2.h.e'_5.h G : Type u_1 inst✝⁷ : MeasurableSpace G inst✝⁢ : Group G inst✝⁡ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝⁴ : SigmaFinite Ξ½ inst✝³ : SigmaFinite ΞΌ s : Set G inst✝² : MeasurableInv G inst✝¹ : IsMulLeftInvariant ΞΌ inst✝ : IsMulLeftInvariant Ξ½ sm : MeasurableSet s f : G β†’ ℝβ‰₯0∞ hf : Measurable f ms : βˆ€ (x : G), Measurable fun y => indicator ((fun z => z * x) ⁻¹' s) (fun x => 1) y x y x✝ : G ⊒ 1 = ((fun x => 1) ∘ fun y => y * x) x✝ [PROOFSTEP] rfl [GOAL] G : Type u_1 inst✝⁷ : MeasurableSpace G inst✝⁢ : Group G inst✝⁡ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝⁴ : SigmaFinite Ξ½ inst✝³ : SigmaFinite ΞΌ s : Set G inst✝² : MeasurableInv G inst✝¹ : IsMulLeftInvariant ΞΌ inst✝ : IsMulLeftInvariant Ξ½ sm : MeasurableSet s f : G β†’ ℝβ‰₯0∞ hf : Measurable f ms : βˆ€ (x : G), Measurable fun y => indicator ((fun z => z * x) ⁻¹' s) (fun x => 1) y this : βˆ€ (x y : G), indicator s (fun x => 1) (y * x) = indicator ((fun z => z * x) ⁻¹' s) (fun b => 1) y ⊒ ∫⁻ (x : G), ∫⁻ (y : G), indicator s (fun x => 1) (y * x) * f x⁻¹ βˆ‚Ξ½ βˆ‚ΞΌ = ∫⁻ (x : G), ↑↑ν ((fun z => z * x) ⁻¹' s) * f x⁻¹ βˆ‚ΞΌ [PROOFSTEP] simp_rw [this, lintegral_mul_const _ (ms _), lintegral_indicator _ (measurable_mul_const _ sm), set_lintegral_one] [GOAL] G : Type u_1 inst✝⁷ : MeasurableSpace G inst✝⁢ : Group G inst✝⁡ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝⁴ : SigmaFinite Ξ½ inst✝³ : SigmaFinite ΞΌ s : Set G inst✝² : MeasurableInv G inst✝¹ : IsMulLeftInvariant ΞΌ inst✝ : IsMulLeftInvariant Ξ½ hΞ½ : Ξ½ β‰  0 ⊒ ΞΌ β‰ͺ Ξ½ [PROOFSTEP] refine' AbsolutelyContinuous.mk fun s sm hΞ½s => _ [GOAL] G : Type u_1 inst✝⁷ : MeasurableSpace G inst✝⁢ : Group G inst✝⁡ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝⁴ : SigmaFinite Ξ½ inst✝³ : SigmaFinite ΞΌ s✝ : Set G inst✝² : MeasurableInv G inst✝¹ : IsMulLeftInvariant ΞΌ inst✝ : IsMulLeftInvariant Ξ½ hΞ½ : Ξ½ β‰  0 s : Set G sm : MeasurableSet s hΞ½s : ↑↑ν s = 0 ⊒ ↑↑μ s = 0 [PROOFSTEP] have h1 := measure_mul_lintegral_eq ΞΌ Ξ½ sm 1 measurable_one [GOAL] G : Type u_1 inst✝⁷ : MeasurableSpace G inst✝⁢ : Group G inst✝⁡ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝⁴ : SigmaFinite Ξ½ inst✝³ : SigmaFinite ΞΌ s✝ : Set G inst✝² : MeasurableInv G inst✝¹ : IsMulLeftInvariant ΞΌ inst✝ : IsMulLeftInvariant Ξ½ hΞ½ : Ξ½ β‰  0 s : Set G sm : MeasurableSet s hΞ½s : ↑↑ν s = 0 h1 : ↑↑μ s * ∫⁻ (y : G), OfNat.ofNat 1 y βˆ‚Ξ½ = ∫⁻ (x : G), ↑↑ν ((fun z => z * x) ⁻¹' s) * OfNat.ofNat 1 x⁻¹ βˆ‚ΞΌ ⊒ ↑↑μ s = 0 [PROOFSTEP] simp_rw [Pi.one_apply, lintegral_one, mul_one, (measure_mul_right_null Ξ½ _).mpr hΞ½s, lintegral_zero, mul_eq_zero (Mβ‚€ := ℝβ‰₯0∞), measure_univ_eq_zero.not.mpr hΞ½, or_false_iff] at h1 [GOAL] G : Type u_1 inst✝⁷ : MeasurableSpace G inst✝⁢ : Group G inst✝⁡ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝⁴ : SigmaFinite Ξ½ inst✝³ : SigmaFinite ΞΌ s✝ : Set G inst✝² : MeasurableInv G inst✝¹ : IsMulLeftInvariant ΞΌ inst✝ : IsMulLeftInvariant Ξ½ hΞ½ : Ξ½ β‰  0 s : Set G sm : MeasurableSet s hΞ½s : ↑↑ν s = 0 h1 : ↑↑μ s = 0 ⊒ ↑↑μ s = 0 [PROOFSTEP] exact h1 [GOAL] G : Type u_1 inst✝⁷ : MeasurableSpace G inst✝⁢ : Group G inst✝⁡ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝⁴ : SigmaFinite Ξ½ inst✝³ : SigmaFinite ΞΌ s : Set G inst✝² : MeasurableInv G inst✝¹ : IsMulLeftInvariant ΞΌ inst✝ : IsMulLeftInvariant Ξ½ sm : MeasurableSet s hΞΌs : ↑↑μ s β‰  ⊀ ⊒ βˆ€α΅ (x : G) βˆ‚ΞΌ, ↑↑ν ((fun y => y * x) ⁻¹' s) < ⊀ [PROOFSTEP] refine' ae_of_forall_measure_lt_top_ae_restrict' Ξ½.inv _ _ [GOAL] G : Type u_1 inst✝⁷ : MeasurableSpace G inst✝⁢ : Group G inst✝⁡ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝⁴ : SigmaFinite Ξ½ inst✝³ : SigmaFinite ΞΌ s : Set G inst✝² : MeasurableInv G inst✝¹ : IsMulLeftInvariant ΞΌ inst✝ : IsMulLeftInvariant Ξ½ sm : MeasurableSet s hΞΌs : ↑↑μ s β‰  ⊀ ⊒ βˆ€ (s_1 : Set G), MeasurableSet s_1 β†’ ↑↑μ s_1 < ⊀ β†’ ↑↑(Measure.inv Ξ½) s_1 < ⊀ β†’ βˆ€α΅ (x : G) βˆ‚Measure.restrict ΞΌ s_1, ↑↑ν ((fun y => y * x) ⁻¹' s) < ⊀ [PROOFSTEP] intro A hA _ h3A [GOAL] G : Type u_1 inst✝⁷ : MeasurableSpace G inst✝⁢ : Group G inst✝⁡ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝⁴ : SigmaFinite Ξ½ inst✝³ : SigmaFinite ΞΌ s : Set G inst✝² : MeasurableInv G inst✝¹ : IsMulLeftInvariant ΞΌ inst✝ : IsMulLeftInvariant Ξ½ sm : MeasurableSet s hΞΌs : ↑↑μ s β‰  ⊀ A : Set G hA : MeasurableSet A a✝ : ↑↑μ A < ⊀ h3A : ↑↑(Measure.inv Ξ½) A < ⊀ ⊒ βˆ€α΅ (x : G) βˆ‚Measure.restrict ΞΌ A, ↑↑ν ((fun y => y * x) ⁻¹' s) < ⊀ [PROOFSTEP] simp only [Ξ½.inv_apply] at h3A [GOAL] G : Type u_1 inst✝⁷ : MeasurableSpace G inst✝⁢ : Group G inst✝⁡ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝⁴ : SigmaFinite Ξ½ inst✝³ : SigmaFinite ΞΌ s : Set G inst✝² : MeasurableInv G inst✝¹ : IsMulLeftInvariant ΞΌ inst✝ : IsMulLeftInvariant Ξ½ sm : MeasurableSet s hΞΌs : ↑↑μ s β‰  ⊀ A : Set G hA : MeasurableSet A a✝ : ↑↑μ A < ⊀ h3A : ↑↑ν A⁻¹ < ⊀ ⊒ βˆ€α΅ (x : G) βˆ‚Measure.restrict ΞΌ A, ↑↑ν ((fun y => y * x) ⁻¹' s) < ⊀ [PROOFSTEP] apply ae_lt_top (measurable_measure_mul_right Ξ½ sm) [GOAL] G : Type u_1 inst✝⁷ : MeasurableSpace G inst✝⁢ : Group G inst✝⁡ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝⁴ : SigmaFinite Ξ½ inst✝³ : SigmaFinite ΞΌ s : Set G inst✝² : MeasurableInv G inst✝¹ : IsMulLeftInvariant ΞΌ inst✝ : IsMulLeftInvariant Ξ½ sm : MeasurableSet s hΞΌs : ↑↑μ s β‰  ⊀ A : Set G hA : MeasurableSet A a✝ : ↑↑μ A < ⊀ h3A : ↑↑ν A⁻¹ < ⊀ ⊒ ∫⁻ (x : G) in A, ↑↑ν ((fun y => y * x) ⁻¹' s) βˆ‚ΞΌ β‰  ⊀ [PROOFSTEP] have h1 := measure_mul_lintegral_eq ΞΌ Ξ½ sm (A⁻¹.indicator 1) (measurable_one.indicator hA.inv) [GOAL] G : Type u_1 inst✝⁷ : MeasurableSpace G inst✝⁢ : Group G inst✝⁡ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝⁴ : SigmaFinite Ξ½ inst✝³ : SigmaFinite ΞΌ s : Set G inst✝² : MeasurableInv G inst✝¹ : IsMulLeftInvariant ΞΌ inst✝ : IsMulLeftInvariant Ξ½ sm : MeasurableSet s hΞΌs : ↑↑μ s β‰  ⊀ A : Set G hA : MeasurableSet A a✝ : ↑↑μ A < ⊀ h3A : ↑↑ν A⁻¹ < ⊀ h1 : ↑↑μ s * ∫⁻ (y : G), indicator A⁻¹ 1 y βˆ‚Ξ½ = ∫⁻ (x : G), ↑↑ν ((fun z => z * x) ⁻¹' s) * indicator A⁻¹ 1 x⁻¹ βˆ‚ΞΌ ⊒ ∫⁻ (x : G) in A, ↑↑ν ((fun y => y * x) ⁻¹' s) βˆ‚ΞΌ β‰  ⊀ [PROOFSTEP] rw [lintegral_indicator _ hA.inv] at h1 [GOAL] G : Type u_1 inst✝⁷ : MeasurableSpace G inst✝⁢ : Group G inst✝⁡ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝⁴ : SigmaFinite Ξ½ inst✝³ : SigmaFinite ΞΌ s : Set G inst✝² : MeasurableInv G inst✝¹ : IsMulLeftInvariant ΞΌ inst✝ : IsMulLeftInvariant Ξ½ sm : MeasurableSet s hΞΌs : ↑↑μ s β‰  ⊀ A : Set G hA : MeasurableSet A a✝ : ↑↑μ A < ⊀ h3A : ↑↑ν A⁻¹ < ⊀ h1 : ↑↑μ s * ∫⁻ (a : G) in A⁻¹, OfNat.ofNat 1 a βˆ‚Ξ½ = ∫⁻ (x : G), ↑↑ν ((fun z => z * x) ⁻¹' s) * indicator A⁻¹ 1 x⁻¹ βˆ‚ΞΌ ⊒ ∫⁻ (x : G) in A, ↑↑ν ((fun y => y * x) ⁻¹' s) βˆ‚ΞΌ β‰  ⊀ [PROOFSTEP] simp_rw [Pi.one_apply, set_lintegral_one, ← image_inv, indicator_image inv_injective, image_inv, ← indicator_mul_right _ fun x => Ξ½ ((fun y => y * x) ⁻¹' s), Function.comp, Pi.one_apply, mul_one] at h1 [GOAL] G : Type u_1 inst✝⁷ : MeasurableSpace G inst✝⁢ : Group G inst✝⁡ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝⁴ : SigmaFinite Ξ½ inst✝³ : SigmaFinite ΞΌ s : Set G inst✝² : MeasurableInv G inst✝¹ : IsMulLeftInvariant ΞΌ inst✝ : IsMulLeftInvariant Ξ½ sm : MeasurableSet s hΞΌs : ↑↑μ s β‰  ⊀ A : Set G hA : MeasurableSet A a✝ : ↑↑μ A < ⊀ h3A : ↑↑ν A⁻¹ < ⊀ h1 : ↑↑μ s * ↑↑ν A⁻¹ = ∫⁻ (x : G), indicator A (fun a => ↑↑ν ((fun y => y * a) ⁻¹' s)) x βˆ‚ΞΌ ⊒ ∫⁻ (x : G) in A, ↑↑ν ((fun y => y * x) ⁻¹' s) βˆ‚ΞΌ β‰  ⊀ [PROOFSTEP] rw [← lintegral_indicator _ hA, ← h1] [GOAL] G : Type u_1 inst✝⁷ : MeasurableSpace G inst✝⁢ : Group G inst✝⁡ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝⁴ : SigmaFinite Ξ½ inst✝³ : SigmaFinite ΞΌ s : Set G inst✝² : MeasurableInv G inst✝¹ : IsMulLeftInvariant ΞΌ inst✝ : IsMulLeftInvariant Ξ½ sm : MeasurableSet s hΞΌs : ↑↑μ s β‰  ⊀ A : Set G hA : MeasurableSet A a✝ : ↑↑μ A < ⊀ h3A : ↑↑ν A⁻¹ < ⊀ h1 : ↑↑μ s * ↑↑ν A⁻¹ = ∫⁻ (x : G), indicator A (fun a => ↑↑ν ((fun y => y * a) ⁻¹' s)) x βˆ‚ΞΌ ⊒ ↑↑μ s * ↑↑ν A⁻¹ β‰  ⊀ [PROOFSTEP] exact ENNReal.mul_ne_top hΞΌs h3A.ne [GOAL] G : Type u_1 inst✝⁷ : MeasurableSpace G inst✝⁢ : Group G inst✝⁡ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝⁴ : SigmaFinite Ξ½ inst✝³ : SigmaFinite ΞΌ s : Set G inst✝² : MeasurableInv G inst✝¹ : IsMulLeftInvariant ΞΌ inst✝ : IsMulLeftInvariant Ξ½ sm : MeasurableSet s h2s : ↑↑ν s β‰  0 h3s : ↑↑ν s β‰  ⊀ ⊒ βˆ€α΅ (x : G) βˆ‚ΞΌ, ↑↑ν ((fun y => y * x) ⁻¹' s) < ⊀ [PROOFSTEP] refine' (ae_measure_preimage_mul_right_lt_top Ξ½ Ξ½ sm h3s).filter_mono _ [GOAL] G : Type u_1 inst✝⁷ : MeasurableSpace G inst✝⁢ : Group G inst✝⁡ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝⁴ : SigmaFinite Ξ½ inst✝³ : SigmaFinite ΞΌ s : Set G inst✝² : MeasurableInv G inst✝¹ : IsMulLeftInvariant ΞΌ inst✝ : IsMulLeftInvariant Ξ½ sm : MeasurableSet s h2s : ↑↑ν s β‰  0 h3s : ↑↑ν s β‰  ⊀ ⊒ ae ΞΌ ≀ ae Ξ½ [PROOFSTEP] refine' (absolutelyContinuous_of_isMulLeftInvariant ΞΌ Ξ½ _).ae_le [GOAL] G : Type u_1 inst✝⁷ : MeasurableSpace G inst✝⁢ : Group G inst✝⁡ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝⁴ : SigmaFinite Ξ½ inst✝³ : SigmaFinite ΞΌ s : Set G inst✝² : MeasurableInv G inst✝¹ : IsMulLeftInvariant ΞΌ inst✝ : IsMulLeftInvariant Ξ½ sm : MeasurableSet s h2s : ↑↑ν s β‰  0 h3s : ↑↑ν s β‰  ⊀ ⊒ Ξ½ β‰  0 [PROOFSTEP] refine' mt _ h2s [GOAL] G : Type u_1 inst✝⁷ : MeasurableSpace G inst✝⁢ : Group G inst✝⁡ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝⁴ : SigmaFinite Ξ½ inst✝³ : SigmaFinite ΞΌ s : Set G inst✝² : MeasurableInv G inst✝¹ : IsMulLeftInvariant ΞΌ inst✝ : IsMulLeftInvariant Ξ½ sm : MeasurableSet s h2s : ↑↑ν s β‰  0 h3s : ↑↑ν s β‰  ⊀ ⊒ Ξ½ = 0 β†’ ↑↑ν s = 0 [PROOFSTEP] intro hΞ½ [GOAL] G : Type u_1 inst✝⁷ : MeasurableSpace G inst✝⁢ : Group G inst✝⁡ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝⁴ : SigmaFinite Ξ½ inst✝³ : SigmaFinite ΞΌ s : Set G inst✝² : MeasurableInv G inst✝¹ : IsMulLeftInvariant ΞΌ inst✝ : IsMulLeftInvariant Ξ½ sm : MeasurableSet s h2s : ↑↑ν s β‰  0 h3s : ↑↑ν s β‰  ⊀ hΞ½ : Ξ½ = 0 ⊒ ↑↑ν s = 0 [PROOFSTEP] rw [hΞ½, Measure.coe_zero, Pi.zero_apply] [GOAL] G : Type u_1 inst✝⁷ : MeasurableSpace G inst✝⁢ : Group G inst✝⁡ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝⁴ : SigmaFinite Ξ½ inst✝³ : SigmaFinite ΞΌ s : Set G inst✝² : MeasurableInv G inst✝¹ : IsMulLeftInvariant ΞΌ inst✝ : IsMulLeftInvariant Ξ½ sm : MeasurableSet s h2s : ↑↑ν s β‰  0 h3s : ↑↑ν s β‰  ⊀ f : G β†’ ℝβ‰₯0∞ hf : Measurable f ⊒ ↑↑μ s * ∫⁻ (y : G), f y⁻¹ / ↑↑ν ((fun x => x * y⁻¹) ⁻¹' s) βˆ‚Ξ½ = ∫⁻ (x : G), f x βˆ‚ΞΌ [PROOFSTEP] set g := fun y => f y⁻¹ / Ξ½ ((fun x => x * y⁻¹) ⁻¹' s) [GOAL] G : Type u_1 inst✝⁷ : MeasurableSpace G inst✝⁢ : Group G inst✝⁡ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝⁴ : SigmaFinite Ξ½ inst✝³ : SigmaFinite ΞΌ s : Set G inst✝² : MeasurableInv G inst✝¹ : IsMulLeftInvariant ΞΌ inst✝ : IsMulLeftInvariant Ξ½ sm : MeasurableSet s h2s : ↑↑ν s β‰  0 h3s : ↑↑ν s β‰  ⊀ f : G β†’ ℝβ‰₯0∞ hf : Measurable f g : G β†’ ℝβ‰₯0∞ := fun y => f y⁻¹ / ↑↑ν ((fun x => x * y⁻¹) ⁻¹' s) ⊒ ↑↑μ s * lintegral Ξ½ g = ∫⁻ (x : G), f x βˆ‚ΞΌ [PROOFSTEP] have hg : Measurable g := (hf.comp measurable_inv).div ((measurable_measure_mul_right Ξ½ sm).comp measurable_inv) [GOAL] G : Type u_1 inst✝⁷ : MeasurableSpace G inst✝⁢ : Group G inst✝⁡ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝⁴ : SigmaFinite Ξ½ inst✝³ : SigmaFinite ΞΌ s : Set G inst✝² : MeasurableInv G inst✝¹ : IsMulLeftInvariant ΞΌ inst✝ : IsMulLeftInvariant Ξ½ sm : MeasurableSet s h2s : ↑↑ν s β‰  0 h3s : ↑↑ν s β‰  ⊀ f : G β†’ ℝβ‰₯0∞ hf : Measurable f g : G β†’ ℝβ‰₯0∞ := fun y => f y⁻¹ / ↑↑ν ((fun x => x * y⁻¹) ⁻¹' s) hg : Measurable g ⊒ ↑↑μ s * lintegral Ξ½ g = ∫⁻ (x : G), f x βˆ‚ΞΌ [PROOFSTEP] simp_rw [measure_mul_lintegral_eq ΞΌ Ξ½ sm g hg, inv_inv] [GOAL] G : Type u_1 inst✝⁷ : MeasurableSpace G inst✝⁢ : Group G inst✝⁡ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝⁴ : SigmaFinite Ξ½ inst✝³ : SigmaFinite ΞΌ s : Set G inst✝² : MeasurableInv G inst✝¹ : IsMulLeftInvariant ΞΌ inst✝ : IsMulLeftInvariant Ξ½ sm : MeasurableSet s h2s : ↑↑ν s β‰  0 h3s : ↑↑ν s β‰  ⊀ f : G β†’ ℝβ‰₯0∞ hf : Measurable f g : G β†’ ℝβ‰₯0∞ := fun y => f y⁻¹ / ↑↑ν ((fun x => x * y⁻¹) ⁻¹' s) hg : Measurable g ⊒ ∫⁻ (x : G), ↑↑ν ((fun z => z * x) ⁻¹' s) * (f x / ↑↑ν ((fun z => z * x) ⁻¹' s)) βˆ‚ΞΌ = ∫⁻ (x : G), f x βˆ‚ΞΌ [PROOFSTEP] refine' lintegral_congr_ae _ [GOAL] G : Type u_1 inst✝⁷ : MeasurableSpace G inst✝⁢ : Group G inst✝⁡ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝⁴ : SigmaFinite Ξ½ inst✝³ : SigmaFinite ΞΌ s : Set G inst✝² : MeasurableInv G inst✝¹ : IsMulLeftInvariant ΞΌ inst✝ : IsMulLeftInvariant Ξ½ sm : MeasurableSet s h2s : ↑↑ν s β‰  0 h3s : ↑↑ν s β‰  ⊀ f : G β†’ ℝβ‰₯0∞ hf : Measurable f g : G β†’ ℝβ‰₯0∞ := fun y => f y⁻¹ / ↑↑ν ((fun x => x * y⁻¹) ⁻¹' s) hg : Measurable g ⊒ (fun x => ↑↑ν ((fun z => z * x) ⁻¹' s) * (f x / ↑↑ν ((fun z => z * x) ⁻¹' s))) =αΆ [ae ΞΌ] fun x => f x [PROOFSTEP] refine' (ae_measure_preimage_mul_right_lt_top_of_ne_zero ΞΌ Ξ½ sm h2s h3s).mono fun x hx => _ [GOAL] G : Type u_1 inst✝⁷ : MeasurableSpace G inst✝⁢ : Group G inst✝⁡ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝⁴ : SigmaFinite Ξ½ inst✝³ : SigmaFinite ΞΌ s : Set G inst✝² : MeasurableInv G inst✝¹ : IsMulLeftInvariant ΞΌ inst✝ : IsMulLeftInvariant Ξ½ sm : MeasurableSet s h2s : ↑↑ν s β‰  0 h3s : ↑↑ν s β‰  ⊀ f : G β†’ ℝβ‰₯0∞ hf : Measurable f g : G β†’ ℝβ‰₯0∞ := fun y => f y⁻¹ / ↑↑ν ((fun x => x * y⁻¹) ⁻¹' s) hg : Measurable g x : G hx : ↑↑ν ((fun y => y * x) ⁻¹' s) < ⊀ ⊒ (fun x => ↑↑ν ((fun z => z * x) ⁻¹' s) * (f x / ↑↑ν ((fun z => z * x) ⁻¹' s))) x = (fun x => f x) x [PROOFSTEP] simp_rw [ENNReal.mul_div_cancel' (measure_mul_right_ne_zero Ξ½ h2s _) hx.ne] [GOAL] G : Type u_1 inst✝⁷ : MeasurableSpace G inst✝⁢ : Group G inst✝⁡ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝⁴ : SigmaFinite Ξ½ inst✝³ : SigmaFinite ΞΌ s✝ : Set G inst✝² : MeasurableInv G inst✝¹ : IsMulLeftInvariant ΞΌ inst✝ : IsMulLeftInvariant Ξ½ s t : Set G hs : MeasurableSet s ht : MeasurableSet t h2s : ↑↑ν s β‰  0 h3s : ↑↑ν s β‰  ⊀ ⊒ ↑↑μ s * ↑↑ν t = ↑↑ν s * ↑↑μ t [PROOFSTEP] have h1 := measure_lintegral_div_measure Ξ½ Ξ½ hs h2s h3s (t.indicator fun _ => 1) (measurable_const.indicator ht) [GOAL] G : Type u_1 inst✝⁷ : MeasurableSpace G inst✝⁢ : Group G inst✝⁡ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝⁴ : SigmaFinite Ξ½ inst✝³ : SigmaFinite ΞΌ s✝ : Set G inst✝² : MeasurableInv G inst✝¹ : IsMulLeftInvariant ΞΌ inst✝ : IsMulLeftInvariant Ξ½ s t : Set G hs : MeasurableSet s ht : MeasurableSet t h2s : ↑↑ν s β‰  0 h3s : ↑↑ν s β‰  ⊀ h1 : ↑↑ν s * ∫⁻ (y : G), indicator t (fun x => 1) y⁻¹ / ↑↑ν ((fun x => x * y⁻¹) ⁻¹' s) βˆ‚Ξ½ = ∫⁻ (x : G), indicator t (fun x => 1) x βˆ‚Ξ½ ⊒ ↑↑μ s * ↑↑ν t = ↑↑ν s * ↑↑μ t [PROOFSTEP] have h2 := measure_lintegral_div_measure ΞΌ Ξ½ hs h2s h3s (t.indicator fun _ => 1) (measurable_const.indicator ht) [GOAL] G : Type u_1 inst✝⁷ : MeasurableSpace G inst✝⁢ : Group G inst✝⁡ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝⁴ : SigmaFinite Ξ½ inst✝³ : SigmaFinite ΞΌ s✝ : Set G inst✝² : MeasurableInv G inst✝¹ : IsMulLeftInvariant ΞΌ inst✝ : IsMulLeftInvariant Ξ½ s t : Set G hs : MeasurableSet s ht : MeasurableSet t h2s : ↑↑ν s β‰  0 h3s : ↑↑ν s β‰  ⊀ h1 : ↑↑ν s * ∫⁻ (y : G), indicator t (fun x => 1) y⁻¹ / ↑↑ν ((fun x => x * y⁻¹) ⁻¹' s) βˆ‚Ξ½ = ∫⁻ (x : G), indicator t (fun x => 1) x βˆ‚Ξ½ h2 : ↑↑μ s * ∫⁻ (y : G), indicator t (fun x => 1) y⁻¹ / ↑↑ν ((fun x => x * y⁻¹) ⁻¹' s) βˆ‚Ξ½ = ∫⁻ (x : G), indicator t (fun x => 1) x βˆ‚ΞΌ ⊒ ↑↑μ s * ↑↑ν t = ↑↑ν s * ↑↑μ t [PROOFSTEP] rw [lintegral_indicator _ ht, set_lintegral_one] at h1 h2 [GOAL] G : Type u_1 inst✝⁷ : MeasurableSpace G inst✝⁢ : Group G inst✝⁡ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝⁴ : SigmaFinite Ξ½ inst✝³ : SigmaFinite ΞΌ s✝ : Set G inst✝² : MeasurableInv G inst✝¹ : IsMulLeftInvariant ΞΌ inst✝ : IsMulLeftInvariant Ξ½ s t : Set G hs : MeasurableSet s ht : MeasurableSet t h2s : ↑↑ν s β‰  0 h3s : ↑↑ν s β‰  ⊀ h1 : ↑↑ν s * ∫⁻ (y : G), indicator t (fun x => 1) y⁻¹ / ↑↑ν ((fun x => x * y⁻¹) ⁻¹' s) βˆ‚Ξ½ = ↑↑ν t h2 : ↑↑μ s * ∫⁻ (y : G), indicator t (fun x => 1) y⁻¹ / ↑↑ν ((fun x => x * y⁻¹) ⁻¹' s) βˆ‚Ξ½ = ↑↑μ t ⊒ ↑↑μ s * ↑↑ν t = ↑↑ν s * ↑↑μ t [PROOFSTEP] rw [← h1, mul_left_comm, h2] [GOAL] G : Type u_1 inst✝⁷ : MeasurableSpace G inst✝⁢ : Group G inst✝⁡ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝⁴ : SigmaFinite Ξ½ inst✝³ : SigmaFinite ΞΌ s : Set G inst✝² : MeasurableInv G inst✝¹ : IsMulLeftInvariant ΞΌ inst✝ : IsMulLeftInvariant Ξ½ hs : MeasurableSet s h2s : ↑↑ν s β‰  0 h3s : ↑↑ν s β‰  ⊀ ⊒ ΞΌ = (↑↑μ s / ↑↑ν s) β€’ Ξ½ [PROOFSTEP] ext1 t ht [GOAL] case h G : Type u_1 inst✝⁷ : MeasurableSpace G inst✝⁢ : Group G inst✝⁡ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝⁴ : SigmaFinite Ξ½ inst✝³ : SigmaFinite ΞΌ s : Set G inst✝² : MeasurableInv G inst✝¹ : IsMulLeftInvariant ΞΌ inst✝ : IsMulLeftInvariant Ξ½ hs : MeasurableSet s h2s : ↑↑ν s β‰  0 h3s : ↑↑ν s β‰  ⊀ t : Set G ht : MeasurableSet t ⊒ ↑↑μ t = ↑↑((↑↑μ s / ↑↑ν s) β€’ Ξ½) t [PROOFSTEP] rw [smul_apply, smul_eq_mul, mul_comm, ← mul_div_assoc, mul_comm, measure_mul_measure_eq ΞΌ Ξ½ hs ht h2s h3s, mul_div_assoc, ENNReal.mul_div_cancel' h2s h3s] [GOAL] G : Type u_1 inst✝⁡ : MeasurableSpace G inst✝⁴ : Group G inst✝³ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝² : SigmaFinite Ξ½ inst✝¹ : SigmaFinite ΞΌ s : Set G inst✝ : IsMulRightInvariant ΞΌ ⊒ MeasurePreserving ?m.111352 [PROOFSTEP] apply measurePreserving_prod_mul_swap_right ΞΌ Ξ½ [GOAL] G : Type u_1 inst✝⁢ : MeasurableSpace G inst✝⁡ : Group G inst✝⁴ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝³ : SigmaFinite Ξ½ inst✝² : SigmaFinite ΞΌ s : Set G inst✝¹ : MeasurableInv G inst✝ : IsMulRightInvariant ΞΌ ⊒ MeasurePreserving ?m.118254 [PROOFSTEP] apply measurePreserving_prod_div_swap ΞΌ Ξ½ [GOAL] G : Type u_1 inst✝⁷ : MeasurableSpace G inst✝⁢ : Group G inst✝⁡ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝⁴ : SigmaFinite Ξ½ inst✝³ : SigmaFinite ΞΌ s : Set G inst✝² : MeasurableInv G inst✝¹ : IsMulRightInvariant ΞΌ inst✝ : IsMulRightInvariant Ξ½ ⊒ MeasurePreserving fun z => (z.fst * z.snd, z.fst⁻¹) [PROOFSTEP] convert (measurePreserving_prod_div_swap Ξ½ ΞΌ).comp (measurePreserving_prod_mul_swap_right ΞΌ Ξ½) using 1 [GOAL] case h.e'_5 G : Type u_1 inst✝⁷ : MeasurableSpace G inst✝⁢ : Group G inst✝⁡ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝⁴ : SigmaFinite Ξ½ inst✝³ : SigmaFinite ΞΌ s : Set G inst✝² : MeasurableInv G inst✝¹ : IsMulRightInvariant ΞΌ inst✝ : IsMulRightInvariant Ξ½ ⊒ (fun z => (z.fst * z.snd, z.fst⁻¹)) = (fun z => (z.snd, z.fst / z.snd)) ∘ fun z => (z.snd, z.fst * z.snd) [PROOFSTEP] ext1 ⟨x, y⟩ [GOAL] case h.e'_5.h.mk G : Type u_1 inst✝⁷ : MeasurableSpace G inst✝⁢ : Group G inst✝⁡ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝⁴ : SigmaFinite Ξ½ inst✝³ : SigmaFinite ΞΌ s : Set G inst✝² : MeasurableInv G inst✝¹ : IsMulRightInvariant ΞΌ inst✝ : IsMulRightInvariant Ξ½ x y : G ⊒ ((x, y).fst * (x, y).snd, (x, y).fst⁻¹) = ((fun z => (z.snd, z.fst / z.snd)) ∘ fun z => (z.snd, z.fst * z.snd)) (x, y) [PROOFSTEP] simp_rw [Function.comp_apply, div_mul_eq_div_div_swap, div_self', one_div] [GOAL] G : Type u_1 inst✝⁢ : MeasurableSpace G inst✝⁡ : Group G inst✝⁴ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝³ : SigmaFinite Ξ½ inst✝² : SigmaFinite ΞΌ s : Set G inst✝¹ : MeasurableInv G inst✝ : IsMulRightInvariant ΞΌ ⊒ QuasiMeasurePreserving Inv.inv [PROOFSTEP] rw [← ΞΌ.inv_inv] [GOAL] G : Type u_1 inst✝⁢ : MeasurableSpace G inst✝⁡ : Group G inst✝⁴ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝³ : SigmaFinite Ξ½ inst✝² : SigmaFinite ΞΌ s : Set G inst✝¹ : MeasurableInv G inst✝ : IsMulRightInvariant ΞΌ ⊒ QuasiMeasurePreserving Inv.inv [PROOFSTEP] exact (quasiMeasurePreserving_inv ΞΌ.inv).mono (inv_absolutelyContinuous ΞΌ.inv) (absolutelyContinuous_inv ΞΌ.inv) [GOAL] G : Type u_1 inst✝⁢ : MeasurableSpace G inst✝⁡ : Group G inst✝⁴ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝³ : SigmaFinite Ξ½ inst✝² : SigmaFinite ΞΌ s : Set G inst✝¹ : MeasurableInv G inst✝ : IsMulLeftInvariant ΞΌ g : G ⊒ QuasiMeasurePreserving fun h => g / h [PROOFSTEP] simp_rw [div_eq_mul_inv] [GOAL] G : Type u_1 inst✝⁢ : MeasurableSpace G inst✝⁡ : Group G inst✝⁴ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝³ : SigmaFinite Ξ½ inst✝² : SigmaFinite ΞΌ s : Set G inst✝¹ : MeasurableInv G inst✝ : IsMulLeftInvariant ΞΌ g : G ⊒ QuasiMeasurePreserving fun h => g * h⁻¹ [PROOFSTEP] exact (measurePreserving_mul_left ΞΌ g).quasiMeasurePreserving.comp (quasiMeasurePreserving_inv ΞΌ) [GOAL] G : Type u_1 inst✝⁢ : MeasurableSpace G inst✝⁡ : Group G inst✝⁴ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝³ : SigmaFinite Ξ½ inst✝² : SigmaFinite ΞΌ s : Set G inst✝¹ : MeasurableInv G inst✝ : IsMulRightInvariant ΞΌ g : G ⊒ QuasiMeasurePreserving fun h => g / h [PROOFSTEP] rw [← ΞΌ.inv_inv] [GOAL] G : Type u_1 inst✝⁢ : MeasurableSpace G inst✝⁡ : Group G inst✝⁴ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝³ : SigmaFinite Ξ½ inst✝² : SigmaFinite ΞΌ s : Set G inst✝¹ : MeasurableInv G inst✝ : IsMulRightInvariant ΞΌ g : G ⊒ QuasiMeasurePreserving fun h => g / h [PROOFSTEP] exact (quasiMeasurePreserving_div_left ΞΌ.inv g).mono (inv_absolutelyContinuous ΞΌ.inv) (absolutelyContinuous_inv ΞΌ.inv) [GOAL] G : Type u_1 inst✝⁢ : MeasurableSpace G inst✝⁡ : Group G inst✝⁴ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝³ : SigmaFinite Ξ½ inst✝² : SigmaFinite ΞΌ s : Set G inst✝¹ : MeasurableInv G inst✝ : IsMulRightInvariant ΞΌ ⊒ QuasiMeasurePreserving fun p => p.fst / p.snd [PROOFSTEP] refine' QuasiMeasurePreserving.prod_of_left measurable_div (eventually_of_forall fun y => _) [GOAL] G : Type u_1 inst✝⁢ : MeasurableSpace G inst✝⁡ : Group G inst✝⁴ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝³ : SigmaFinite Ξ½ inst✝² : SigmaFinite ΞΌ s : Set G inst✝¹ : MeasurableInv G inst✝ : IsMulRightInvariant ΞΌ y : G ⊒ QuasiMeasurePreserving fun x => (x, y).fst / (x, y).snd [PROOFSTEP] exact (measurePreserving_div_right ΞΌ y).quasiMeasurePreserving [GOAL] G : Type u_1 inst✝⁢ : MeasurableSpace G inst✝⁡ : Group G inst✝⁴ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝³ : SigmaFinite Ξ½ inst✝² : SigmaFinite ΞΌ s : Set G inst✝¹ : MeasurableInv G inst✝ : IsMulLeftInvariant ΞΌ g : G ⊒ QuasiMeasurePreserving fun h => h * g [PROOFSTEP] refine' ⟨measurable_mul_const g, AbsolutelyContinuous.mk fun s hs => _⟩ [GOAL] G : Type u_1 inst✝⁢ : MeasurableSpace G inst✝⁡ : Group G inst✝⁴ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝³ : SigmaFinite Ξ½ inst✝² : SigmaFinite ΞΌ s✝ : Set G inst✝¹ : MeasurableInv G inst✝ : IsMulLeftInvariant ΞΌ g : G s : Set G hs : MeasurableSet s ⊒ ↑↑μ s = 0 β†’ ↑↑(map (fun h => h * g) ΞΌ) s = 0 [PROOFSTEP] rw [map_apply (measurable_mul_const g) hs, measure_mul_right_null] [GOAL] G : Type u_1 inst✝⁢ : MeasurableSpace G inst✝⁡ : Group G inst✝⁴ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝³ : SigmaFinite Ξ½ inst✝² : SigmaFinite ΞΌ s✝ : Set G inst✝¹ : MeasurableInv G inst✝ : IsMulLeftInvariant ΞΌ g : G s : Set G hs : MeasurableSet s ⊒ ↑↑μ s = 0 β†’ ↑↑μ s = 0 [PROOFSTEP] exact id [GOAL] G : Type u_1 inst✝⁢ : MeasurableSpace G inst✝⁡ : Group G inst✝⁴ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝³ : SigmaFinite Ξ½ inst✝² : SigmaFinite ΞΌ s : Set G inst✝¹ : MeasurableInv G inst✝ : IsMulRightInvariant ΞΌ g : G ⊒ QuasiMeasurePreserving fun h => g * h [PROOFSTEP] have := (quasiMeasurePreserving_mul_right ΞΌ.inv g⁻¹).mono (inv_absolutelyContinuous ΞΌ.inv) (absolutelyContinuous_inv ΞΌ.inv) [GOAL] G : Type u_1 inst✝⁢ : MeasurableSpace G inst✝⁡ : Group G inst✝⁴ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝³ : SigmaFinite Ξ½ inst✝² : SigmaFinite ΞΌ s : Set G inst✝¹ : MeasurableInv G inst✝ : IsMulRightInvariant ΞΌ g : G this : QuasiMeasurePreserving fun h => h * g⁻¹ ⊒ QuasiMeasurePreserving fun h => g * h [PROOFSTEP] rw [ΞΌ.inv_inv] at this [GOAL] G : Type u_1 inst✝⁢ : MeasurableSpace G inst✝⁡ : Group G inst✝⁴ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝³ : SigmaFinite Ξ½ inst✝² : SigmaFinite ΞΌ s : Set G inst✝¹ : MeasurableInv G inst✝ : IsMulRightInvariant ΞΌ g : G this : QuasiMeasurePreserving fun h => h * g⁻¹ ⊒ QuasiMeasurePreserving fun h => g * h [PROOFSTEP] have := (quasiMeasurePreserving_inv_of_right_invariant ΞΌ).comp (this.comp (quasiMeasurePreserving_inv_of_right_invariant ΞΌ)) [GOAL] G : Type u_1 inst✝⁢ : MeasurableSpace G inst✝⁡ : Group G inst✝⁴ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝³ : SigmaFinite Ξ½ inst✝² : SigmaFinite ΞΌ s : Set G inst✝¹ : MeasurableInv G inst✝ : IsMulRightInvariant ΞΌ g : G this✝ : QuasiMeasurePreserving fun h => h * g⁻¹ this : QuasiMeasurePreserving (Inv.inv ∘ (fun h => h * g⁻¹) ∘ Inv.inv) ⊒ QuasiMeasurePreserving fun h => g * h [PROOFSTEP] simp_rw [Function.comp, mul_inv_rev, inv_inv] at this [GOAL] G : Type u_1 inst✝⁢ : MeasurableSpace G inst✝⁡ : Group G inst✝⁴ : MeasurableMulβ‚‚ G ΞΌ Ξ½ : Measure G inst✝³ : SigmaFinite Ξ½ inst✝² : SigmaFinite ΞΌ s : Set G inst✝¹ : MeasurableInv G inst✝ : IsMulRightInvariant ΞΌ g : G this✝ : QuasiMeasurePreserving fun h => h * g⁻¹ this : QuasiMeasurePreserving fun x => g * x ⊒ QuasiMeasurePreserving fun h => g * h [PROOFSTEP] exact this
State Before: G : Type u_1 inst✝ : Group G H K : Subgroup G S T : Set G f : Quotient (QuotientGroup.rightRel H) β†’ G hf : βˆ€ (q : Quotient (QuotientGroup.rightRel H)), Quotient.mk'' (f q) = q ⊒ Function.Injective (Set.restrict (Set.range f) Quotient.mk'') State After: case mk.intro.mk.intro G : Type u_1 inst✝ : Group G H K : Subgroup G S T : Set G f : Quotient (QuotientGroup.rightRel H) β†’ G hf : βˆ€ (q : Quotient (QuotientGroup.rightRel H)), Quotient.mk'' (f q) = q q₁ qβ‚‚ : Quotient (QuotientGroup.rightRel H) h : Set.restrict (Set.range f) Quotient.mk'' { val := f q₁, property := (_ : βˆƒ y, f y = f q₁) } = Set.restrict (Set.range f) Quotient.mk'' { val := f qβ‚‚, property := (_ : βˆƒ y, f y = f qβ‚‚) } ⊒ { val := f q₁, property := (_ : βˆƒ y, f y = f q₁) } = { val := f qβ‚‚, property := (_ : βˆƒ y, f y = f qβ‚‚) } Tactic: rintro ⟨-, q₁, rfl⟩ ⟨-, qβ‚‚, rfl⟩ h State Before: case mk.intro.mk.intro G : Type u_1 inst✝ : Group G H K : Subgroup G S T : Set G f : Quotient (QuotientGroup.rightRel H) β†’ G hf : βˆ€ (q : Quotient (QuotientGroup.rightRel H)), Quotient.mk'' (f q) = q q₁ qβ‚‚ : Quotient (QuotientGroup.rightRel H) h : Set.restrict (Set.range f) Quotient.mk'' { val := f q₁, property := (_ : βˆƒ y, f y = f q₁) } = Set.restrict (Set.range f) Quotient.mk'' { val := f qβ‚‚, property := (_ : βˆƒ y, f y = f qβ‚‚) } ⊒ { val := f q₁, property := (_ : βˆƒ y, f y = f q₁) } = { val := f qβ‚‚, property := (_ : βˆƒ y, f y = f qβ‚‚) } State After: no goals Tactic: exact Subtype.ext $ congr_arg f $ ((hf q₁).symm.trans h).trans (hf qβ‚‚)
Formal statement is: lemma strip_while_coeffs [simp]: "strip_while (HOL.eq 0) (coeffs p) = coeffs p" Informal statement is: The coefficients of a polynomial are never all zero.
section {* Introduction *} theory Mereology imports Main begin text {* This is a presentation in Isabelle/HOL of \emph{Classical Extensional Mereology}. The presentation is based on those in ``Parts'' by Peter Simons @{cite "simons_parts:_1987"} and ``Parts and Places'' by Roberto Casati and Achille Varzi @{cite "casati_parts_1999"}. Some corrections and important proofs are from @{cite "pontow_note_2004"} *} text {* Please note that this is an extremely ROUGH DRAFT. *} section {* Ground Mereology *} text {* Ground Mereology (M) introduces parthood as a primitive relation amongst individuals. It's assumed that parthood is a partial ordering relation - that is reflexive, symmetric and transitive @{cite "casati_parts_1999"}, p. 36: *} typedecl i -- "the type of individuals" locale M = fixes P:: "i β‡’ i β‡’ bool" ("P") assumes R: "P x x" -- "reflexivity of parthood " and AS: "P x y ⟢ P y x ⟢ x = y" -- "antisymmetry of parthood" and T: "P x y ⟢ P y z ⟢ P x z" -- "transitivity of parthood" begin text {* The following relations are defined in terms of parthood @{cite "casati_parts_1999"}, p. 36-7: *} definition PP:: "i β‡’ i β‡’ bool" ("PP") where "PP x y ≑ P x y ∧ Β¬ (P y x)" -- "proper parthood" definition O:: "i β‡’ i β‡’ bool" ("O") where "O x y ≑ βˆƒ z. P z x ∧ P z y" -- "overlap" definition D:: "i β‡’ i β‡’ bool" ("D") where "D x y ≑ Β¬ O x y" -- "disjointness" definition U:: "i β‡’ i β‡’ bool" ("U") where "U x y ≑ βˆƒ z. P x z ∧ P y z" -- "underlap" text {* As are the following operations on individuals @{cite "casati_parts_1999"}, p. 43-5: *} definition S:: "i β‡’ i β‡’ i" (infix "❙+" 52) where "x ❙+ y ≑ THE z. βˆ€ w. O w z ⟷ O w x ∨ O w y" -- "sum or fusion" definition T:: "i β‡’ i β‡’ i" (infix "❙×" 53) where "x ❙× y ≑ THE z. βˆ€ w. O w z ⟷ O w x ∧ O w y" -- "product or intersection" definition u:: "i" ("u") where "u ≑ THE z. βˆ€ w. P w z" -- "universe" definition M:: "i β‡’ i β‡’ i" (infix "❙-" 51) where "x ❙- y ≑ THE z. βˆ€ w. O w z ⟷ O w x ∧ Β¬ O w y" -- "difference" definition C:: "i β‡’ i" ("❙¬") where "❙¬ x ≑ (u ❙- x)" -- "complement" text {* And the operations of general sum and product @{cite casati_parts_1999}, p. 46: *} definition Οƒ:: "(i β‡’ bool) β‡’ i" ("Οƒ") where "Οƒ F ≑ THE z. (βˆ€ y. O y z ⟷ (βˆƒ x. F x ∧ O x y))" abbreviation Οƒx:: "(i β‡’ bool) β‡’ i" (binder "Οƒ" [8] 9) where "Οƒ x. F x ≑ Οƒ F" -- "general sum or fusion of the Fs" definition Ο€:: "(i β‡’ bool) β‡’ i" ("Ο€") where "Ο€ F ≑ THE z. (βˆ€ x. F x ⟢ P z x)" -- "general products @{cite casati_parts_1999}, p. 46" abbreviation Ο€x:: "(i β‡’ bool) β‡’ i" (binder "Ο€" [8] 9) where "Ο€ x. F x ≑ Ο€ F" -- "general sum or product of the Fs" (* definition OX:: "i β‡’ i β‡’ bool" ("OX") where "OX x y ≑ O x y ∧ Β¬ x ❙≀ y" definition UX:: "i β‡’ i β‡’ bool" ("UX") where "UX x y ≑ U x y ∧ Β¬ y ❙≀ x" definition PO:: "i β‡’ i β‡’ bool" ("PO" ) where "PO x y ≑ OX x y ∧ OX y x" definition PU:: "i β‡’ i β‡’ bool" ("PU") where "PU x y ≑ UX x y ∧ UX y x" *) text {* Note that the symbols for part, proper part, sum, product, difference and complement are distinguished by bold font. *} end section {* Minimal Mereology *} text {* Minimal mereology (MM) adds to ground mereology the axiom of weak supplementation @{cite "casati_parts_1999"}, p. 39: *} locale MM = M + assumes WS: "PP x y ⟢ (βˆƒ z. PP z y ∧ D z x)" -- "weak supplementation" text {* Weak supplementation is sometimes stated with parthood rather than proper parthood in the consequent. The following lemma in ground mereology shows that the two definitions are equivalent, given anti-symmetry: *} lemma (in M) "(PP x y ⟢ (βˆƒ z. PP z y ∧ D z x)) ⟷ (PP x y ⟢ (βˆƒ z. P z y ∧ D z x))" by (metis AS D_def O_def PP_def R) text {* The following two lemmas are weaker supplementation principles taken from Simons @{cite "simons_parts:_1987"}, p. 27. The names \emph{company} and \emph{strong company} are from Varzi's \emph{Stanford Encyclopedia of Philosophy} entry on mereology @{cite "varzi_mereology_2016"}. *} lemma (in MM) C: "PP x y ⟢ (βˆƒ z. z β‰  x ∧ PP z y)" by (metis WS D_def O_def R) -- "company" lemma (in MM) SC: "PP x y ⟢ (βˆƒ z. PP z y ∧ Β¬ P z x)" by (metis WS D_def O_def R) -- "strong company" text {* Minimal Mereology is not strong enough to proved the \emph{Proper Parts Principle}, according to which if x has a proper part, and every proper part of x is a part of y, then x is a part of y @{cite "simons_parts:_1987"} p. 28: *} lemma (in MM) PPP: "βˆƒ z. PP z x ⟹ βˆ€ z. PP z x ⟢ P z y ⟹ P x y" -- "proper parts principle" nitpick [user_axioms] oops text {* The proper parts principle is Simons way of expressing \emph{extensionality}, which is not a theorem of Minimal Mereology either: *} lemma (in M) E: "(βˆƒ z. PP z x ∨ PP z y) ⟢ (βˆ€ z. PP z x ⟷ PP z y) ⟢ x = y" -- "extensionality" nitpick oops text {* The failure of weak supplementation to entail the proper parts principle or extensionality motivates a stronger axiom, to which we turn in the next section. *} (* lemma (in M) assumes PPP: "βˆƒ z. PP z x ⟹ βˆ€ z. PP z x ⟢ P z y ⟹ P x y" shows E: "(βˆƒ z. PP z x ∨ PP z y) ⟢ (βˆ€ z. PP z x ⟷ PP z y) ⟢ x = y" using PPP AS PP_def by blast lemma (in MM) assumes E: "(βˆƒ z. PP z x ∨ PP z y) ⟢ (βˆ€ z. PP z x ⟷ PP z y) ⟢ x = y" shows PPP: "βˆƒ z. PP z x ⟹ βˆ€ z. PP z x ⟢ P z y ⟹ P x y" nitpick oops *) section {* Extensional Mereology *} text {* Extensional Mereology (EM) adds the axiom of strong supplementation @{cite "casati_parts_1999"}, p. 39: *} locale EM = M + assumes SS: "Β¬ (P x y) ⟢ (βˆƒ z. P z x ∧ D z y)" -- "strong supplementation" text {* Extensional Mereology (@{text "EM"} is so called because it entails the proper parts principle @{cite "simons_parts:_1987"} p. 29: *} lemma (in EM) PPP: "βˆƒ z. PP z x ⟹ βˆ€ z. PP z x ⟢ P z y ⟹ P x y" by (metis SS D_def R O_def PP_def T) text {* And thus extensionality proper @{cite "casati_parts_1999"} p. 40: *} lemma (in EM) E: "(βˆƒ z. PP z x ∨ PP z y) ⟢ (βˆ€ z. PP z x ⟷ PP z y) ⟢ x = y" -- "extensionality" by (metis R O_def D_def AS PP_def SS) text {* In the context of the other axioms, strong supplementation entails weak supplementation @{cite "simons_parts:_1987"}, p. 29: *} lemma (in M) SStoWS: assumes SS: "β‹€x. β‹€ y. Β¬ (P x y) ⟢ (βˆƒ z. P z x ∧ D z y)" -- "assumes strong supplementation" shows WS: "β‹€x. β‹€y. PP x y ⟢ (βˆƒ z. PP z y ∧ D z x)" -- "shows weak supplementation" by (metis AS D_def O_def PP_def R assms) text {* But not vice versa: *} lemma (in M) WStoSS: assumes WS: "β‹€x. β‹€y. PP x y ⟢ (βˆƒ z. PP z y ∧ D z x)" -- "assumes weak supplementation" shows SS: "β‹€x. β‹€ y. Β¬ (P x y) ⟢ (βˆƒ z. P z x ∧ D z y)" -- "shows strong supplementation" nitpick oops text {* So Extensional Mereology is stronger than Minimal Mereology @{cite "casati_parts_1999"} p. 43: *} sublocale EM βŠ† MM using T SS SStoWS by (metis MM.intro MM_axioms.intro M_axioms) sublocale MM βŠ† EM nitpick oops lemma (in MM) assumes PPP: "βˆƒ z. PP z x ⟹ βˆ€ z. PP z x ⟢ P z y ⟹ P x y" shows SS: "Β¬ P x y ⟢ (βˆƒ z. P z x ∧ D z y)" nitpick oops (* text {* Two alternative formulations of the strong supplementation axiom, which are equivalent given transitivity are @{cite "pontnow_note_2004"} p. 198: *} lemma (in M) "((βˆ€ z. P z x ⟢ O z y) ⟢ P x y) ⟷ (Β¬ P x y ⟢ (βˆƒ z. P z x ∧ D z y))" using D_def by blast lemma (in M) "((βˆ€ z. O z x ⟢ O z y) ⟢ P x y) ⟷ (Β¬ P x y ⟢ (βˆƒ z. P z x ∧ D z y))" by (metis O_def D_def R T) lemma (in M) assumes SS: "Β¬ P x y ⟢ (βˆƒ z. P z x ∧ D z y)" shows "(βˆ€ z. P z x ⟢ O z y) ⟢ P x y" using D_def SS by blast lemma (in M) assumes "(βˆ€ z. P z x ⟢ O z y) ⟢ P x y" shows "(βˆ€ z. O z x ⟢ O z y) ⟢ P x y" using O_def R assms by blast lemma (in M) assumes "(βˆ€ z. O z x ⟢ O z y) ⟢ P x y" shows SS: "Β¬ P x y ⟢ (βˆƒ z. P z x ∧ D z y)" by (meson D_def O_def T assms) lemma (in EM) "(βˆ€ z. P z x ⟢ O z y) ⟢ P x y" using SS D_def by blast lemma (in EM) "(βˆ€ z. O z x ⟢ O z y) ⟢ P x y" by (metis SS T D_def O_def) *) section {* Closure Mereology *} text {* Closure Mereology adds to Ground Mereology the axioms of sum closure and product closure @{cite "casati_parts_1999"} p. 43: *} locale CM = M + assumes SC: "U x y ⟢ (βˆƒ z. βˆ€ w. O w z ⟷ (O w x ∨ O w y))" -- "sum closure" assumes PC: "O x y ⟢ (βˆƒ z. βˆ€ w. P w z ⟷ (P w x ∧ P w y))" -- "product closure" text {* Combining Closure Mereology with Minimal Mereology yields the theory known as Closure Minimal Mereology @{term "CMM"} whereas combining Closure Mereology with Extensional Mereology obtains \emph{Closed Extensional Mereology} @{term "CEM"} @{cite "casati_parts_1999"} p. 43: *} locale CMM = CM + MM locale CEM = EM + CM text {* In Closed Minimal Mereology, the product closure axiom and weak supplementation jointly entail strong supplementation. The proof verified here is from Pontow @{cite "pontow_note_2004"} p. 200: *} lemma (in CMM) SS: "Β¬ P x y ⟢ (βˆƒ z. P z x ∧ D z y)" proof fix x y assume "Β¬ P x y" show "(βˆƒ z. P z x ∧ D z y)" proof cases assume "D x y" thus "(βˆƒ z. P z x ∧ D z y)" using R by auto next assume "Β¬ D x y" hence "O x y" using D_def by simp hence "βˆƒ z. βˆ€ w. P w z ⟷ (P w x ∧ P w y)" using PC by simp then obtain z where z: "βˆ€ w. P w z ⟷ (P w x ∧ P w y)".. hence "PP z x" using PP_def R β€ΉΒ¬ P x yβ€Ί by auto hence "(βˆƒ w. PP w x ∧ D w z)" using WS by simp then obtain w where "PP w x ∧ D w z".. hence "P w x ∧ D w y" by (meson D_def O_def PP_def T z) thus "(βˆƒ z. P z x ∧ D z y)".. qed qed (* Later I might add here the proof of the proper parts principle from products on @{cite "simons_parts:_1987"} p. 33 *) text {* Because Strong Supplementation is provable in Closed Minimal Mereology, it follows that Closed Extensional Mereology and Closed Minimal Mereology are the same theory @{cite "casati_parts_1999"} p. 44: *} sublocale CEM βŠ† CMM by (simp add: CMM.intro CM_axioms MM_axioms) sublocale CMM βŠ† CEM by (simp add: CEM.intro CM_axioms EM.intro EM_axioms.intro M_axioms SS) text {* Closure Mereology with Universe (CMU) is obtained by adding an axiom ensuring existence of a universe @{cite "casati_parts_1999"} p. 44: *} locale CMU = CM + assumes U: "βˆƒ z. βˆ€ x. P x z" -- "universe" text {* And adding Extensional Mereology (or Minimal Mereology) to this theory results in Closed Extensional Mereology with Universe @{text "CEMU"}: *} locale CEMU = EM + CMU text {* In Closure Extensional Mereology with Universe, it's possible to derive a strengthening of the sum axiom, since everything underlaps everything else: *} lemma (in CEMU) EU: "U x y" using U_def U by auto -- "everything underlaps" lemma (in CEMU) SSC: "(βˆƒ z. βˆ€ w. O w z ⟷ (O w x ∨ O w y))" using EU SC by simp -- "strengthened sum closure" (* text {* Does CEMU entail the existence of differences? I should think yes, since the difference between a and b is the sum of the elements of a that overlap b. However, if a has infinitely many elements, the sum may not be guaranteed to exist by the product axiom. This might explain why nitpick does not find a counterexample: *} lemma (in CEMU) D: "(βˆƒ w. P w x ∧ Β¬ O w y) ⟢ (βˆƒ z. βˆ€ w. P w z ⟷ (P w x ∧ Β¬ O w y))" oops *) section {* General Mereology *} text {* General Mereology is obtained from Ground Mereology by adding the axiom of fusion or unrestricted composition @{cite "casati_parts_1999"} p. 46: *} locale GM = M + assumes F: "(βˆƒ x. F x) ⟢ (βˆƒ z. βˆ€ y. O y z ⟷ (βˆƒ x. F x ∧ O x y))" -- "fusion or unrestricted composition" text {* Substituting @{text "x = a ∨ x = b"} for @{text "F x"} in the fusion axiom allows the derivation of an unrestricted version of sum closure @{text "GS"}, and so of course sum closure itself, as follows: *} lemma (in GM) FS: "(βˆƒ x. (x = a ∨ x = b)) ⟢ (βˆƒ z. βˆ€ y. O y z ⟷ (βˆƒ x. (x = a ∨ x = b) ∧ O x y))" using F solve_direct. lemma (in GM) GFS: "(βˆƒ z. βˆ€ y. O y z ⟷ (βˆƒ x. (x = a ∨ x = b) ∧ O x y))" using FS by blast lemma (in M) GFStoGS: assumes GFS: "(βˆƒ z. βˆ€ y. O y z ⟷ (βˆƒ x. (x = a ∨ x = b) ∧ O x y))" shows "(βˆƒz. βˆ€w. O w z ⟷ (O w a ∨ O w b))" by (metis O_def GFS) lemma (in GM) GS: "(βˆƒz. βˆ€w. O w z ⟷ (O w x ∨ O w y))" using GFS GFStoGS by simp lemma (in GM) S: "U x y ⟢ (βˆƒz. βˆ€w. O w z ⟷ (O w x ∨ O w y))" using GS by simp text {* But product closure cannot be derived: *} lemma (in GM) T: "O x y ⟢ (βˆƒ z. βˆ€ w. P w z ⟷ (P w x ∧ P w y))" nitpick [show_all] oops text {* It follows that General Mereology does not encompass Closure Mereology, contrary to Simons @{cite "simons_parts:_1987"} p. 36 and Casati and Varzi @{cite "casati_parts_1999"} p. 46 (this point is discussed in detail by Pontow @{cite "pontow_note_2004"}: *} sublocale GM βŠ† CM nitpick [show_all] oops text {* It's possible to prove from fusion in General Mereology that there is something that overlaps everything: *} lemma (in GM) "βˆƒ z. βˆ€ x. O x z" -- "something overlaps everything" proof - have "(βˆƒ x. x = x) ⟢ (βˆƒ z. βˆ€ y. O y z ⟷ (βˆƒ x. x = x ∧ O x y))" using F by fast hence "βˆƒ z. βˆ€ y. O y z ⟷ (βˆƒ x. x = x ∧ O x y)" by simp hence "βˆƒ z. βˆ€ y. O y z ⟷ (βˆƒ x. O x y)" by simp thus ?thesis by (metis O_def R) qed text {* But it doesn't follow that there is a universe, let alone a unique universe. If for example, there is just an infinite ascending chain, then everything overlaps everything else, but there isn't a particular thing which everything is a part of, since for anything in particular, the things above it are not part of the chain: *} lemma (in GM) U: "βˆƒ z. βˆ€ x. P x z" nitpick oops text {* The existence of differences is not guaranteed either: *} lemma (in GM) D: "(βˆƒ w. P w x ∧ Β¬ O w y) ⟢ (βˆƒ z. βˆ€ w. P w z ⟷ (P w x ∧ Β¬ O w y))" nitpick oops text {* Call the combination of General Mereology with weak supplementation General Minimal Mereology, or @{term "GMM"}: *} locale GMM = MM + GM -- "General Minimal Mereology" text {* Although Strong Supplementation can be derived from Weak Supplementation in Closed Minimal Mereology via the product axioms, it cannot be derived in General Minimal Mereology, since the product axiom itself still cannot be derived in General Minimal Mereology: *} lemma (in GMM) SS: "Β¬ P x y ⟢ (βˆƒ z. P z x ∧ D z y)" nitpick oops lemma (in GMM) T: "O x y ⟢ (βˆƒ z. βˆ€ w. P w z ⟷ (P w x ∧ P w y))" nitpick [show_all] oops text {* Nor can the existence of a universe or differences be proved in General Minimal Mereology: *} lemma (in GMM) U: "βˆƒ z. βˆ€ x. x z" nitpick oops lemma (in GMM) D: "(βˆƒ w. P w x ∧ Β¬ O w y) ⟢ (βˆƒ z. βˆ€ w. P w z ⟷ (P w x ∧ Β¬ O w y))" nitpick oops section {* Classical Extensional Mereology *} text {* Classical Extensional Mereology @{text "GEM"} is simply Extensional Mereology combined with General Mereology @{cite "casati_parts_1999"} p. 46: *} locale GEM = EM + GM text {* The presence of strong supplementation in Classical Extensional Mereology enables the derivation of product closure from fusion. The following proof is from Pontow @{cite "pontow_note_2004"} pp. 202-3. *} text {* The proof begins by substitutions @{text "z ❙≀ a ∧ z ❙≀ b"} for @{text "F"} in the fusion axiom, to give the existence of a sum of all the parts of @{text "a"} and @{text "b"}: *} lemma (in GM) FP: "(βˆƒ z. (P z a ∧ P z b)) ⟢ (βˆƒ z. βˆ€ w. O w z ⟷ (βˆƒ x. (P x a ∧ P x b) ∧ O x w))" using F solve_direct. text {* Three lemmas are helpful before proceeding with the proof proper. First, strong supplementation is needed to proceed from the fact that z is \emph{a} sum of the Fs to the fact that z is \emph{the} sum of the Fs: *} lemma (in EM) atothesum: assumes asum: "βˆ€ y. O y z ⟷ (βˆƒ x. F x ∧ O x y)" shows thesum: "(THE v. βˆ€ y. O y v ⟷ (βˆƒ x. F x ∧ O x y)) = z" proof (rule the_equality) show "βˆ€ y. O y z ⟷ (βˆƒ x. F x ∧ O x y)" using asum. show "β‹€v. βˆ€y. O y v = (βˆƒx. F x ∧ O x y) ⟹ v = z" by (metis SS AS D_def O_def R asum) qed text {* Using this lemma, we can show that if something overlaps z just in case it overlaps an F, then it is the sum of the Fs: *} lemma (in EM) UGS: "(βˆ€ y. O y z ⟷ (βˆƒ x. F x ∧ O x y)) ⟢ (Οƒ x. F x) = z" proof assume "(βˆ€ y. O y z ⟷ (βˆƒ x. F x ∧ O x y))" hence "(THE v. βˆ€ y. O y v ⟷ (βˆƒ x. F x ∧ O x y)) = z" using atothesum by simp thus "(Οƒ v. F v) = z" using Οƒ_def by blast qed text {* With this lemma in hand, we can proceed with a final lemma the proof from Pontow @{cite "pontow_note_2004"} pp. 202-3, according to which if there is an F, then everything is part of the sum of the Fs just in case every part of it overlaps with an F. *} lemma (in GEM) PS: "(βˆƒ x. F x) ⟢ (βˆ€ y. P y (Οƒ v. F v) ⟷ (βˆ€ w. P w y ⟢ (βˆƒ v. F v ∧ O v w)))" proof assume "(βˆƒ x. F x)" hence "βˆƒ z. βˆ€ y. O y z ⟷ (βˆƒ x. F x ∧ O x y)" using F by simp then obtain z where z: "βˆ€ y. O y z ⟷ (βˆƒ x. F x ∧ O x y)".. hence Οƒ: "(Οƒ v. F v) = z " using UGS by simp show "βˆ€ y. P y (Οƒ v. F v) ⟷ (βˆ€ w. P w y ⟢ (βˆƒ v. F v ∧ O v w))" proof fix y show "P y (Οƒ v. F v) ⟷ (βˆ€ w. P w y ⟢ (βˆƒ v. F v ∧ O v w))" proof assume "P y (Οƒ v. F v)" hence "P y z" using Οƒ by simp hence "O y z" using O_def R by auto hence "(βˆƒ x. F x ∧ O x y)" using z by simp thus "(βˆ€ w. P w y ⟢ (βˆƒ v. F v ∧ O v w))" by (metis O_def R T β€ΉP y zβ€Ί z) next assume "(βˆ€ w. P w y ⟢ (βˆƒ v. F v ∧ O v w))" hence "P y z" using z by (meson D_def SS) thus "P y (Οƒ v. F v)" using Οƒ by simp qed qed qed text {* Continuing to follow the proof from @{cite "pontow_note_2004"} pp. 204, we can prove the Product Axiom proper: *} lemma (in GEM) T: "O x y ⟢ (βˆƒ z. βˆ€ w. P w z ⟷ (P w x ∧ P w y))" proof assume "O x y" hence ez: "(βˆƒ z. (P z x ∧ P z y))" using O_def by simp hence "(βˆƒ z. βˆ€ w. O w z ⟷ (βˆƒ v. (P v x ∧ P v y) ∧ O v w))" using FP by simp then obtain z where "(βˆ€ w. O w z ⟷ (βˆƒ v. (P v x ∧ P v y) ∧ O v w))".. hence Οƒzxy: "(Οƒ v. P v x ∧ P v y) = z" using UGS by simp have gragra: "(βˆ€ s. P s (Οƒ v. P v x ∧ P v y) ⟷ (βˆ€ w. P w s ⟢ (βˆƒ v. P v x ∧ P v y ∧ O v w)))" using PS ez by simp have "βˆ€ w. P w z ⟷ (P w x ∧ P w y)" proof fix w show "P w z ⟷ (P w x ∧ P w y)" proof assume "P w z" hence "P w (Οƒ v. P v x ∧ P v y)" using Οƒzxy by simp hence dadada: "(βˆ€ t. P t w ⟢ (βˆƒ v. P v x ∧ P v y ∧ O v t))" using gragra by simp have "βˆ€ t. P t w ⟢ (O t x ∧ O t y)" proof fix t show "P t w ⟢ (O t x ∧ O t y)" proof assume "P t w" hence "(βˆƒ v. P v x ∧ P v y ∧ O v t)" using dadada by simp thus "O t x ∧ O t y" using O_def T by blast qed qed thus "P w x ∧ P w y" using SS T D_def by meson next assume "P w x ∧ P w y" thus "P w z" using O_def R Οƒzxy gragra by fastforce qed qed thus "(βˆƒ z. βˆ€ w. P w z ⟷ (P w x ∧ P w y))".. qed (* Naming of sentences in this proof need to be tidied up. *) text {* It follows that General Extensional Mereology is stronger than Closed Extensional Mereology *} sublocale GEM βŠ† CEM using CEM.intro CM.intro CM_axioms_def EM_axioms M_axioms S T by blast text {* Likewise, substituting @{text "x = x"} for @{text "F x"} in fusion allows the derivation of the existence of a universe: *} lemma (in GM) selfidentity: "(βˆƒ x. x = x) ⟢ (βˆƒ z. βˆ€ y. O y z ⟷ (βˆƒ x. x = x ∧ O x y))" using F by fast lemma (in GM) "(βˆƒ z. βˆ€ y. O y z ⟷ (βˆƒ x. O x y))" using selfidentity by simp lemma (in GEM) U: "βˆƒ z. βˆ€ x. P x z" using selfidentity by (metis D_def O_def SS) text {* It follows that Classical Extensional Mereology is also stronger than Closed Extensional Mereology with Universe: *} sublocale GEM βŠ† CEMU proof show "βˆƒz. βˆ€x. P x z" using U by simp qed text {* The existence of differences is also derivable in General Extensional Mereology. Like, the proof of the product axiom, the proof of the existence of differences is quite involved. It can be found in Pontow @{cite "pontow_note_2004"} p. 209. *} lemma (in GM) FD: "(βˆƒ x. P x a ∧ Β¬ O x b) ⟢ (βˆƒ z. βˆ€ y. O y z ⟷ (βˆƒ x. (P x a ∧ Β¬ O x b) ∧ O x y))" using F solve_direct. lemma (in GEM) D: "(βˆƒ w. P w x ∧ Β¬ O w y) ⟢ (βˆƒ z. βˆ€ w. P w z ⟷ (P w x ∧ Β¬ O w y))" proof assume "(βˆƒ w. P w x ∧ Β¬ O w y)" hence "(βˆƒ z. βˆ€ w. O w z ⟷ (βˆƒ v. (P v x ∧ Β¬ O v y) ∧ O v w))" using FD by simp then obtain Ξ£ where Ξ£: "βˆ€ w. O w Ξ£ ⟷ (βˆƒ v. (P v x ∧ Β¬ O v y) ∧ O v w)".. have "βˆ€ w. P w Ξ£ ⟷ (P w x ∧ Β¬ O w y)" proof fix w show "P w Ξ£ ⟷ (P w x ∧ Β¬ O w y)" proof assume "P w Ξ£" have "βˆ€ z. P z w ⟢ O z x" proof fix z show "P z w ⟢ O z x" proof assume "P z w" hence "βˆƒ s0. (P s0 x ∧ Β¬ O s0 y) ∧ O s0 z" using M.T M_axioms O_def R Ξ£ β€Ήw ❙≀ Ξ£β€Ί by blast thus "O z x" using M.T M_axioms O_def by blast qed qed hence "P w x" using SS D_def by blast have "βˆ€ v. P v w ⟢ Β¬ P v y" by (metis O_def M.T M_axioms Ξ£ β€ΉP w Ξ£β€Ί) hence "Β¬ O w y" using O_def by simp thus "P w x ∧ Β¬ O w y" using β€ΉP w xβ€Ί by blast next assume "P w x ∧ Β¬ O w y" show "P w Ξ£" by (meson D_def O_def R SS Ξ£ β€ΉP w x ∧ Β¬ O w yβ€Ί) qed qed thus "(βˆƒ z. βˆ€ w. P w z ⟷ (P w x ∧ Β¬ O w y))".. qed section {* Atomism *} text {* An atom is an individual with no proper parts: *} definition (in M) A:: "i β‡’ bool" ("A") where "A x ≑ Β¬ (βˆƒ y. PP y x)" text {* Each theory discussed above can be augmented with an axiom stating that everything has an atom as a part, viz. @{cite "casati_parts_1999"}, p. 48: *} locale AM = M + assumes A: "βˆ€ x. βˆƒ y. A y ∧ P y x" -- "atomicity" locale AMM = AM + MM locale AEM = AM + EM locale ACM = AM + CM locale ACEM = AM + CEM locale AGM = AM + GM locale AGEM = AM + GEM text {* It follows in @{text "AEM"} that if something is not part of another, there is an atom which is part of the former but not part of the later: *} lemma (in AEM) ASS: "Β¬ P x y ⟢ (βˆƒ z. A z ∧ (P z x ∧ Β¬ O z y))" proof assume "Β¬ P x y" hence "(βˆƒ w. P w x ∧ D w y)" using SS by simp then obtain w where w: "P w x ∧ D w y".. hence "βˆƒ z. A z ∧ P z w" using A by simp then obtain z where z: "A z ∧ P z w".. hence "A z ∧ (P z x ∧ Β¬ O z y)" by (meson D_def O_def T w) thus "βˆƒ z. A z ∧ (P z x ∧ Β¬ O z y)".. qed text {* Moreover, in Minimal Mereology this lemma entails both strong supplementation and atomism, so it serves as an alternative characterisation of Atomistic Extensional Mereology: *} lemma (in MM) assumes ASS: "Β¬ P x y ⟢ (βˆƒ z. A z ∧ (P z x ∧ Β¬ O z y))" shows SS: "Β¬ P x y ⟢ (βˆƒ z. P z x ∧ D z y)" using D_def assms by blast lemma (in M) assumes ASS: "βˆ€ x. βˆ€ y. Β¬ P x y ⟢ (βˆƒ z. A z ∧ (P z x ∧ Β¬ O z y))" shows A: "βˆ€ x. βˆƒ y. A y ∧ P y x" proof fix x show "βˆƒ y. A y ∧ P y x" proof cases assume "A x" hence "A x ∧ P x x" using R by simp thus "βˆƒ y. A y ∧ P y x".. next assume "Β¬ A x" hence "βˆƒ y. PP y x" using A_def by simp then obtain y where y: "PP y x".. hence "Β¬ P x y" using PP_def by simp hence "βˆƒ z. A z ∧ (P z x ∧ Β¬ O z y)" using ASS by blast thus "βˆƒ y. A y ∧ P y x" by blast qed qed text {* So the axiom of Atomistic Strong Supplementation could be used in place of the two axioms of Atomicity and Strong Supplementation @{cite "casati_parts_1999"} *} text {* For the same reason that the Product axiom and Strong Supplementation do not follow from the Fusion Axiom in General Mereology, and so General Mereology is strictly weaker than Classical Extensional Mereology, the Product Axiom and Strong Supplementation still do not follow from the Fusion Axiom in Atomistic General Mereology, and so Atomistic General Mereology is also strictly weaker than Atomistic Classical Extensional Mereology @{cite "pontow_note_2004"}, p. 206: *} lemma (in AGM) T: "O x y ⟢ (βˆƒ z. βˆ€ w. P w z ⟷ (P w x ∧ P w y))" nitpick [user_axioms] oops lemma (in AGM) SS: "Β¬ P x y ⟢ (βˆƒ z. P z x ∧ D z y)" nitpick [user_axioms] oops text {* Alternatively, each theory discussed above can be augmented with an axiom stating that there are no atoms, viz.: *} locale XAM = M + assumes XA: "Β¬ (βˆƒ x. A x)" -- "atomlessness" locale XAMM = XAM + MM locale XAEM = XAM + EM locale XACM = XAM + CM locale XACEM = XAM + CEM locale XAGM = XAM + GM locale XAGEM = XAM + GEM text {* Pontow notes that the question of whether the Fusion Axiom entails the Product and Strong Supplementation axioms in Atomless General Mereology is open @{cite "pontow_note_2004"}. Nitpick does not find a countermodel (since an infinite countermodel is needed?) and sledgehammer fails to find a proof, so this problem remains open for now: *} lemma (in XAGM) T: "O x y ⟢ (βˆƒ z. βˆ€ w. P w z ⟷ (P w x ∧ P w y))" oops lemma (in XAGM) SS: "Β¬ P x y ⟢ (βˆƒ z. P z x ∧ D z y)" oops section {* Consistency *} text {* I conclude by proving the consistency of all the theories mentioned. *} lemma (in M) "False" nitpick [show_all] oops lemma (in MM) "False" nitpick [show_all] oops lemma (in EM) "False" nitpick [show_all] oops lemma (in CM) "False" nitpick [show_all] oops lemma (in CEM) "False" nitpick [show_all] oops lemma (in CMU) "False" nitpick [show_all] oops lemma (in CEMU) "False" nitpick [show_all] oops lemma (in GM) "False" nitpick [show_all] oops lemma (in GEM) "False" nitpick [show_all] oops end
= = Preparation = =
Formal statement is: lemma is_interval_neg_translationI: assumes "is_interval X" shows "is_interval ((-) x ` X)" Informal statement is: If $X$ is an interval, then so is $-x + X$.
subsection \<open>ConditionalNode Phase\<close> theory ConditionalPhase imports Common Proofs.StampEvalThms begin phase ConditionalNode terminating size begin lemma negates: "\<exists>v b. e = IntVal b v \<and> b > 0 \<Longrightarrow> val_to_bool (val[e]) \<longleftrightarrow> \<not>(val_to_bool (val[!e]))" unfolding intval_logic_negation.simps by (metis (mono_tags, lifting) intval_logic_negation.simps(1) logic_negate_def new_int.simps of_bool_eq(2) one_neq_zero take_bit_of_0 take_bit_of_1 val_to_bool.simps(1)) lemma negation_condition_intval: assumes "e = IntVal b ie" assumes "0 < b" shows "val[(!e) ? x : y] = val[e ? y : x]" using assms by (cases e; auto simp: negates logic_negate_def) lemma negation_preserve_eval: assumes "[m, p] \<turnstile> exp[!e] \<mapsto> v" shows "\<exists>v'. ([m, p] \<turnstile> exp[e] \<mapsto> v') \<and> v = val[!v']" using assms by auto lemma negation_preserve_eval_intval: assumes "[m, p] \<turnstile> exp[!e] \<mapsto> v" shows "\<exists>v' b vv. ([m, p] \<turnstile> exp[e] \<mapsto> v') \<and> v' = IntVal b vv \<and> b > 0" using assms by (metis eval_bits_1_64 intval_logic_negation.elims negation_preserve_eval unfold_unary) optimization NegateConditionFlipBranches: "((!e) ? x : y) \<longmapsto> (e ? y : x)" apply simp using negation_condition_intval negation_preserve_eval_intval by (smt (verit, best) ConditionalExpr ConditionalExprE Value.distinct(1) evalDet negates negation_preserve_eval) optimization DefaultTrueBranch: "(true ? x : y) \<longmapsto> x" . optimization DefaultFalseBranch: "(false ? x : y) \<longmapsto> y" . optimization ConditionalEqualBranches: "(e ? x : x) \<longmapsto> x" . optimization condition_bounds_x: "((u < v) ? x : y) \<longmapsto> x when (stamp_under (stamp_expr u) (stamp_expr v) \<and> wf_stamp u \<and> wf_stamp v)" using stamp_under_defn by fastforce optimization condition_bounds_y: "((u < v) ? x : y) \<longmapsto> y when (stamp_under (stamp_expr v) (stamp_expr u) \<and> wf_stamp u \<and> wf_stamp v)" using stamp_under_defn_inverse by fastforce (** Start of new proofs **) (* Value-level proofs *) lemma val_optimise_integer_test: assumes "\<exists>v. x = IntVal 32 v" shows "val[((x & (IntVal 32 1)) eq (IntVal 32 0)) ? (IntVal 32 0) : (IntVal 32 1)] = val[x & IntVal 32 1]" using assms apply auto apply (metis (full_types) bool_to_val.simps(2) val_to_bool.simps(1)) by (metis (mono_tags, lifting) and_one_eq bool_to_val.simps(1) even_iff_mod_2_eq_zero odd_iff_mod_2_eq_one val_to_bool.simps(1)) optimization ConditionalEliminateKnownLess: "((x < y) ? x : y) \<longmapsto> x when (stamp_under (stamp_expr x) (stamp_expr y) \<and> wf_stamp x \<and> wf_stamp y)" using stamp_under_defn by fastforce (* Optimisations *) optimization ConditionalEqualIsRHS: "((x eq y) ? x : y) \<longmapsto> y" apply auto by (smt (verit) Value.inject(1) bool_to_val.simps(2) bool_to_val_bin.simps evalDet intval_equals.elims val_to_bool.elims(1)) (* todo not sure if this is done properly *) optimization normalizeX: "((x eq const (IntVal 32 0)) ? (const (IntVal 32 0)) : (const (IntVal 32 1))) \<longmapsto> x when (IRExpr_up x = 1) \<and> stamp_expr x = IntegerStamp b 0 1" apply auto subgoal premises p for m p v xa proof - obtain xa where xa: "[m,p] \<turnstile> x \<mapsto> xa" using p by blast have 3: "[m,p] \<turnstile> if val_to_bool (intval_equals xa (IntVal (32::nat) (0::64 word))) then ConstantExpr (IntVal (32::nat) (0::64 word)) else ConstantExpr (IntVal (32::nat) (1::64 word)) \<mapsto> v" using evalDet p(3) p(5) xa using p(4) p(6) by blast then have 4: "xa = IntVal 32 0 | xa = IntVal 32 1" sorry then have 6: "v = xa" sorry then show ?thesis using xa by auto qed done (* todo not sure if this is done properly *) optimization normalizeX2: "((x eq (const (IntVal 32 1))) ? (const (IntVal 32 1)) : (const (IntVal 32 0))) \<longmapsto> x when (x = ConstantExpr (IntVal 32 0) | (x = ConstantExpr (IntVal 32 1)))" . (* todo not sure if this is done properly *) optimization flipX: "((x eq (const (IntVal 32 0))) ? (const (IntVal 32 1)) : (const (IntVal 32 0))) \<longmapsto> x \<oplus> (const (IntVal 32 1)) when (x = ConstantExpr (IntVal 32 0) | (x = ConstantExpr (IntVal 32 1)))" . (* todo not sure if this is done properly *) optimization flipX2: "((x eq (const (IntVal 32 1))) ? (const (IntVal 32 0)) : (const (IntVal 32 1))) \<longmapsto> x \<oplus> (const (IntVal 32 1)) when (x = ConstantExpr (IntVal 32 0) | (x = ConstantExpr (IntVal 32 1)))" . lemma stamp_of_default: assumes "stamp_expr x = default_stamp" assumes "wf_stamp x" shows "([m, p] \<turnstile> x \<mapsto> v) \<longrightarrow> (\<exists>vv. v = IntVal 32 vv)" using assms by (metis default_stamp valid_value_elims(3) wf_stamp_def) optimization OptimiseIntegerTest: "(((x & (const (IntVal 32 1))) eq (const (IntVal 32 0))) ? (const (IntVal 32 0)) : (const (IntVal 32 1))) \<longmapsto> x & (const (IntVal 32 1)) when (stamp_expr x = default_stamp \<and> wf_stamp x)" apply simp apply (rule impI; (rule allI)+; rule impI) subgoal premises eval for m p v proof - obtain xv where xv: "[m, p] \<turnstile> x \<mapsto> xv" using eval by fast then have x32: "\<exists>v. xv = IntVal 32 v" using stamp_of_default eval by auto obtain lhs where lhs: "[m, p] \<turnstile> exp[(((x & (const (IntVal 32 1))) eq (const (IntVal 32 0))) ? (const (IntVal 32 0)) : (const (IntVal 32 1)))] \<mapsto> lhs" using eval(2) by auto then have lhsV: "lhs = val[((xv & (IntVal 32 1)) eq (IntVal 32 0)) ? (IntVal 32 0) : (IntVal 32 1)]" using xv evaltree.BinaryExpr evaltree.ConstantExpr evaltree.ConditionalExpr by (smt (verit) ConditionalExprE ConstantExprE bin_eval.simps(11) bin_eval.simps(4) evalDet intval_conditional.simps unfold_binary) obtain rhs where rhs: "[m, p] \<turnstile> exp[x & (const (IntVal 32 1))] \<mapsto> rhs" using eval(2) by blast then have rhsV: "rhs = val[xv & IntVal 32 1]" by (metis BinaryExprE ConstantExprE bin_eval.simps(4) evalDet xv) have "lhs = rhs" using val_optimise_integer_test x32 using lhsV rhsV by presburger then show ?thesis by (metis eval(2) evalDet lhs rhs) qed done (* todo not sure if this is done properly *) optimization opt_optimise_integer_test_2: "(((x & (const (IntVal 32 1))) eq (const (IntVal 32 0))) ? (const (IntVal 32 0)) : (const (IntVal 32 1))) \<longmapsto> x when (x = ConstantExpr (IntVal 32 0) | (x = ConstantExpr (IntVal 32 1)))" . (* optimization opt_conditional_eliminate_known_less: "((x < y) ? x : y) \<longmapsto> x when (((stamp_under (stamp_expr x) (stamp_expr y)) | ((stpi_upper (stamp_expr x)) = (stpi_lower (stamp_expr y)))) \<and> wf_stamp x \<and> wf_stamp y)" apply auto using stamp_under_defn apply simp sorry *) (* optimization opt_normalize_x_original: "((BinaryExpr BinIntegerEquals x (ConstantExpr (IntVal32 0))) ? (ConstantExpr (IntVal32 0)) : (ConstantExpr (IntVal32 1))) \<longmapsto> x when (stamp_expr x = IntegerStamp 32 0 1 \<and> wf_stamp x)" apply unfold_optimization apply simp_all using wf_stamp_def apply (cases x; simp) sorry *) (** End of new proofs **) end end
[STATEMENT] lemma "c \<noteq> 0 \<Longrightarrow> D (\<lambda>t. exp (a * sin (cos (t^4) / c))) = (\<lambda>t. - 4 * a * t^3 * sin (t^4) / c * cos (cos (t^4) / c) * exp (a * sin (cos (t^4) / c))) on T" [PROOF STATE] proof (prove) goal (1 subgoal): 1. c \<noteq> 0 \<Longrightarrow> D (\<lambda>t. exp (a * sin (cos (t ^ 4) / c))) = (\<lambda>t. - 4 * a * t ^ 3 * sin (t ^ 4) / c * cos (cos (t ^ 4) / c) * exp (a * sin (cos (t ^ 4) / c))) on T [PROOF STEP] by (intro poly_derivatives) (auto intro!: poly_derivatives simp: power2_eq_square)
module Issue835 where data _≑_ {A : Set} (x : A) : A β†’ Set where refl : x ≑ x postulate A : Set x y : A F : x ≑ y β†’ Set F ()
Require Import ClassicalRealizability.Kbase. Require Import ClassicalRealizability.Rationals. Require Import ClassicalRealizability.Real_definitions. Require Import ClassicalRealizability.Real_relations. Require Import ClassicalRealizability.Real_operations. Definition non_trivial := Ξ»"f" Qq 1 @ (Qq 0 @ (Qq (1/3) @ Ξ»"1/3" "f" @ "1/3" @ "1/3" @ "1/3")) @ Id @ Id. Theorem non_trivial_realizer : forall e, non_trivial↓e ⊩ (0 << 1)%Re. Proof. intro e. start. apply Qq_realizer. eexists (_ β†’ _ β†’ _). find; repeat (start; apply Qq_realizer; find); [Ksolve |..]; find; try apply prop_realizer1; now split || compute. Qed. (** ** Archimed axiom **) Definition Archimedℝ := Ξ»"Tx" Ξ»"Cx" Ξ»"f" Qq 1 @ "Tx" @ (Ξ»"q" Ξ»"X" Qq 1 @ (β„šadd @ "q") @ "f" @ Ξ»"Ρ₁" Ξ»"Ξ΅β‚‚" Ξ»"q₁" Ξ»"qβ‚‚" Ξ»"X'" Ξ»"eqq" "eqq" @ Qq 1 @ ("Cx" @ "Ρ₁") @ "q₁" @ "q" @ "X'" @ "X"). Theorem Archimed : forall e, Archimedℝ↓e ⊩ βˆ€β‚xβˆˆβ„, βˆƒβ‚qβˆˆβ„š, (x <= q)%Re. Proof. intro e. start. (* Getting one value q ∈ x[Ξ΅] *) apply Qq_realizer. find. start. apply Ht. find. now compute. find. (* The bound is q + 1 *) start. apply Qq_realizer. find. start. apply β„šadd_realizer. find. find. Ksolve. find. (* Guard condition *) start. apply (prop_guard Ht4). intros [_ ?]. subst. (* Using Cauchy property of x *) apply Qq_realizer. find. Kmove. exists Ρ₁, 1. find. now compute. find. apply (prop_subst_stack HΟ€). (* Arithmetical proof *) clear -Hc0. rewrite Qcabs_minus, Qcabs_diff_le_condition. intros [_ ?]. rewrite <- Qcplus_0_r at 1. apply Qcplus_le_compat. rewrite <- Qcplus_assoc. now setoid_rewrite Qcplus_comm at 2. assumption. Qed.
(** * Classical reasoning on decidable propositions. There are two principal type classes used here: - Computable P means that we can decide {P} + {~P}, - Decidable P is the same thing in Prop (P \/ ~P). Given an instance of Decidable P we can transform a goal T |- P into T, ~P |- False and use tauto to get a complete decision procedure for classical logic by Glivenko's theorem. This is implemented in the dtauto tactic. Furthermore there are two tactics dleft, dright which correspond to classical_left and classical_right. *) Require Extraction. Require Import Coq.Program.Tactics. Require Export Bool. Class Computable (P : Prop) := decision_procedure : { P } + { ~P }. Opaque decision_procedure. Arguments decision_procedure P {Computable}. Local Obligation Tactic := firstorder. (** Propositional formulas over computable atoms are computable. *) Section ComputableInstances. Global Program Instance inst_true_cm : Computable True. Global Program Instance inst_false_cm : Computable False. Variable P : Prop. Variable H : Computable P. Global Program Instance inst_not_cm : Computable (~P). Variable Q : Prop. Variable H' : Computable Q. Global Program Instance inst_and_cm : Computable (P /\ Q). Global Program Instance inst_or_cm : Computable (P \/ Q). Global Program Instance inst_impl_cm : Computable (P -> Q). Global Program Instance inst_iff_cm : Computable (P <-> Q). End ComputableInstances. Extraction Inline inst_true_cm_obligation_1 inst_false_cm_obligation_1 inst_not_cm_obligation_1 inst_and_cm_obligation_1 inst_or_cm_obligation_1 inst_impl_cm_obligation_1 inst_iff_cm_obligation_1 inst_and_cm inst_or_cm inst_impl_cm inst_iff_cm. (** Lift boolean predicates to computable Props. *) Coercion Is_true : bool >-> Sortclass. Global Instance inst_Is_true_cm (b : bool) : Computable (Is_true b). destruct b; simpl; firstorder. Defined. Extraction Inline inst_Is_true_cm. (** Classical axioms for decidable predicates. *) Lemma decidable_xm P `(Computable P) : P \/ ~P. destruct H; tauto. Qed. Lemma decidable_dn P `(Computable P) : ~~P -> P. destruct H; tauto. Qed. Lemma dleft (P Q : Prop) `(Computable Q) : (~Q -> P) -> P \/ Q. Proof. destruct H; tauto. Qed. Lemma dright (P Q : Prop) `(Computable P) : (~P -> Q) -> P \/ Q. Proof. destruct H; tauto. Qed. (** dcontra applies double negation to the current goal if it is decidable. *) Ltac dcontra := (match goal with | |- ?H => apply (decidable_dn H _) end) || fail "Could not prove that the goal is a decidable proposition.". (** dtauto does the same thing as tauto with classical the goal is decidable. *) Ltac dtauto := tauto || (intros; dcontra; tauto) || fail "dtauto failed". (** Similarly, dleft and dright are the analogs to classical_left/right. *) Ltac dleft := match goal with | |- ?P \/ ?Q => apply (dleft P Q _) end. Ltac dright := match goal with | |- ?P \/ ?Q => apply (dright P Q _) end. (** destruct [P] does case analysis on decidable propositions. *) (* More concretely, if the goal is in Prop then P has to be decidable, otherwise P should be computable. *) Ltac decide_tac P := match goal with | |- ?H => match type of H with | _ => destruct (@decision_procedure P _) || fail 2 "not a computable proposition." end end. Tactic Notation "decide" constr(P) := decide_tac P. Tactic Notation "decide_goal" := match goal with [ |- ?s ] => decide s end. (** Programming with computable Props. *) Notation "'if' [ P ] 'then' s 'else' t" := (if (@decision_procedure P _) then s else t) (at level 200, right associativity, format "'if' [ P ] 'then' s 'else' t"). Extraction Inline decision_procedure. Instance computable_if (A B C:Prop) `{Computable A} `{Computable B} `{Computable C} : Computable (if [A] then B else C). Proof. destruct (@decision_procedure A _); eauto. Qed.
module UnknownImplicitInstance where ⟨⟩ : {A : Set} {{a : A}} β†’ A ⟨⟩ {{a}} = a postulate B : Set instance b : B f : {A : Set₁} {{a : A}} β†’ A x : Set x = f
lemma pCons_eq_0_iff [simp]: "pCons a p = 0 \<longleftrightarrow> a = 0 \<and> p = 0"
-- %logging compile.casetree 5 -- %logging eval.casetree 5 -- %logging declare.def.lhs 5 bad : (a : Type) -> (x : a) -> String bad String "good" = "good" bad (List Nat) [1,2] = "good" bad Char 'c' = "good" bad _ _ = "bad"
[STATEMENT] lemma (in field) isin_correct: assumes "in_carrier xs" and "isin e n e' m = Some (p, e'')" shows "peval xs (PExpr2 (PPow e' m)) = peval xs (PExpr2 (PMul (PExpr2 (PPow e (n - p))) e''))" and "p \<le> n" [PROOF STATE] proof (prove) goal (1 subgoal): 1. peval xs (PExpr2 (PPow e' m)) = peval xs (PExpr2 (PMul (PExpr2 (PPow e (n - p))) e'')) &&& p \<le> n [PROOF STEP] using assms [PROOF STATE] proof (prove) using this: in_carrier xs isin e n e' m = Some (p, e'') goal (1 subgoal): 1. peval xs (PExpr2 (PPow e' m)) = peval xs (PExpr2 (PMul (PExpr2 (PPow e (n - p))) e'')) &&& p \<le> n [PROOF STEP] by (induct e n e' m arbitrary: p e'' rule: isin.induct) (force simp add: nat_pow_distrib nat_pow_pow nat_pow_mult m_ac npemul_correct npepow_correct split: option.split_asm prod.split_asm if_split_asm)+
## Linear independence ```python import numpy as np from sympy.solvers import solve from sympy import Symbol x = Symbol('x') y = Symbol('y') z = Symbol('z') ``` The set of vectors are called linearly independent because each of the vectors in the set {V0, V1, …, Vnβˆ’1} cannot be written as a combination of the others in the set. ### Linear Independent Arrays ```python A = np.array([1,1,1]) B = np.array([0,1,1]) C = np.array([0,0,1]) Z = np.array([0,0,0]) ``` ```python np.array_equal( Z, 0*A + 0*B + 0*C ) ``` True ```python solve(x*A + y*B + z*C) ``` {z: 0, y: 0, x: 0} ### Linear Dependent Arrays ```python A = np.array([1,1,1]) B = np.array([0,0,1]) C = np.array([1,1,0]) ``` ```python 1*A + -1*B + -1*C ``` array([0, 0, 0]) ```python solve(x*A + y*B + z*C) ``` {y: z, x: -z} ```python A = np.array([1,2,3]) B = np.array([1,-4,-4]) C = np.array([3,0,2]) ``` ```python 2*A + 1*B + -C ``` array([0, 0, 0]) ```python solve(x*A + y*B + z*C) ``` {y: -z, x: -2*z}
State Before: x : ℝβ‰₯0∞ y : ℝ ⊒ x ^ (-y) = (x ^ y)⁻¹ State After: case none y : ℝ ⊒ none ^ (-y) = (none ^ y)⁻¹ case some y : ℝ x : ℝβ‰₯0 ⊒ Option.some x ^ (-y) = (Option.some x ^ y)⁻¹ Tactic: cases' x with x State Before: case none y : ℝ ⊒ none ^ (-y) = (none ^ y)⁻¹ State After: no goals Tactic: rcases lt_trichotomy y 0 with (H | H | H) <;> simp [top_rpow_of_pos, top_rpow_of_neg, H, neg_pos.mpr] State Before: case some y : ℝ x : ℝβ‰₯0 ⊒ Option.some x ^ (-y) = (Option.some x ^ y)⁻¹ State After: case pos y : ℝ x : ℝβ‰₯0 h : x = 0 ⊒ Option.some x ^ (-y) = (Option.some x ^ y)⁻¹ case neg y : ℝ x : ℝβ‰₯0 h : Β¬x = 0 ⊒ Option.some x ^ (-y) = (Option.some x ^ y)⁻¹ Tactic: by_cases h : x = 0 State Before: case pos y : ℝ x : ℝβ‰₯0 h : x = 0 ⊒ Option.some x ^ (-y) = (Option.some x ^ y)⁻¹ State After: no goals Tactic: rcases lt_trichotomy y 0 with (H | H | H) <;> simp [h, zero_rpow_of_pos, zero_rpow_of_neg, H, neg_pos.mpr] State Before: case neg y : ℝ x : ℝβ‰₯0 h : Β¬x = 0 ⊒ Option.some x ^ (-y) = (Option.some x ^ y)⁻¹ State After: case neg y : ℝ x : ℝβ‰₯0 h : Β¬x = 0 A : x ^ y β‰  0 ⊒ Option.some x ^ (-y) = (Option.some x ^ y)⁻¹ Tactic: have A : x ^ y β‰  0 := by simp [h] State Before: case neg y : ℝ x : ℝβ‰₯0 h : Β¬x = 0 A : x ^ y β‰  0 ⊒ Option.some x ^ (-y) = (Option.some x ^ y)⁻¹ State After: no goals Tactic: simp [coe_rpow_of_ne_zero h, ← coe_inv A, NNReal.rpow_neg] State Before: y : ℝ x : ℝβ‰₯0 h : Β¬x = 0 ⊒ x ^ y β‰  0 State After: no goals Tactic: simp [h]
The sector was estimated to employ nearly 12 @,@ 000 people and directly contribute Β£ 1 @.@ 4 billion to the UK economy in 2005 , making it roughly seven per cent of the size of the CAT industry . Nearly half of the economic contribution was generated by business aviation .
theory SINVAR_CommunicationPartners imports "../TopoS_Helper" begin subsection \<open>SecurityInvariant CommunicationPartners\<close> text\<open> Idea of this securityinvariant: Only some nodes can communicate with Master nodes. It constrains who may access master nodes, Master nodes can access the world (except other prohibited master nodes). A node configured as Master has a list of nodes that can access it. Also, in order to be able to access a Master node, the sender must be denoted as a node we Care about. By default, all nodes are set to DontCare, thus they cannot access Master nodes. But they can access all other DontCare nodes and Care nodes. TL;DR: An access control list determines who can access a master node. \<close> datatype 'v node_config = DontCare | Care | Master "'v list" definition default_node_properties :: "'v node_config" where "default_node_properties = DontCare" text\<open>Unrestricted accesses among DontCare nodes!\<close> fun allowed_flow :: "'v node_config \<Rightarrow> 'v \<Rightarrow> 'v node_config \<Rightarrow> 'v \<Rightarrow> bool" where "allowed_flow DontCare _ DontCare _ = True" | "allowed_flow DontCare _ Care _ = True" | "allowed_flow DontCare _ (Master _) _ = False" | "allowed_flow Care _ Care _ = True" | "allowed_flow Care _ DontCare _ = True" | "allowed_flow Care s (Master M) r = (s \<in> set M)" | "allowed_flow (Master _) s (Master M) r = (s \<in> set M)" | "allowed_flow (Master _) _ Care _ = True" | "allowed_flow (Master _) _ DontCare _ = True" fun sinvar :: "'v graph \<Rightarrow> ('v \<Rightarrow> 'v node_config) \<Rightarrow> bool" where "sinvar G nP = (\<forall> (s,r) \<in> edges G. s \<noteq> r \<longrightarrow> allowed_flow (nP s) s (nP r) r)" definition receiver_violation :: "bool" where "receiver_violation = False" subsubsection \<open>Preliminaries\<close> subsubsection \<open>ENRnr\<close> lemma CommunicationPartners_ENRnrSR: "SecurityInvariant_withOffendingFlows.sinvar_all_edges_normal_form_not_refl_SR sinvar allowed_flow" by(simp add: SecurityInvariant_withOffendingFlows.sinvar_all_edges_normal_form_not_refl_SR_def) lemma Unassigned_weakrefl: "\<forall> s r. allowed_flow DontCare s DontCare r" by(simp) lemma Unassigned_botdefault: "\<forall> s r. (nP r) \<noteq> DontCare \<longrightarrow> \<not> allowed_flow (nP s) s (nP r) r \<longrightarrow> \<not> allowed_flow DontCare s (nP r) r" apply(rule allI)+ apply(case_tac "nP r") apply(simp_all) apply(case_tac "nP s") apply(simp_all) done lemma "\<not> allowed_flow DontCare s (Master M) r" by(simp) lemma "\<not> allowed_flow any s (Master []) r" by(cases any, simp_all) lemma All_to_Unassigned: "\<forall> s r. allowed_flow (nP s) s DontCare r" by (rule allI, rule allI, case_tac "nP s", simp_all) lemma Unassigned_default_candidate: "\<forall> s r. \<not> allowed_flow (nP s) s (nP r) r \<longrightarrow> \<not> allowed_flow DontCare s (nP r) r" apply(intro allI, rename_tac s r)+ apply(case_tac "nP s") apply(simp_all) apply(case_tac "nP r") apply(simp_all) apply(case_tac "nP r") apply(simp_all) done definition CommunicationPartners_offending_set:: "'v graph \<Rightarrow> ('v \<Rightarrow> 'v node_config) \<Rightarrow> ('v \<times> 'v) set set" where "CommunicationPartners_offending_set G nP = (if sinvar G nP then {} else { {e \<in> edges G. case e of (e1,e2) \<Rightarrow> e1 \<noteq> e2 \<and> \<not> allowed_flow (nP e1) e1 (nP e2) e2} })" lemma CommunicationPartners_offending_set: "SecurityInvariant_withOffendingFlows.set_offending_flows sinvar = CommunicationPartners_offending_set" apply(simp only: fun_eq_iff ENFnrSR_offending_set[OF CommunicationPartners_ENRnrSR] CommunicationPartners_offending_set_def) apply(rule allI)+ apply(rename_tac G nP) apply(auto) done interpretation CommunicationPartners: SecurityInvariant_ACS where default_node_properties = default_node_properties and sinvar = sinvar rewrites "SecurityInvariant_withOffendingFlows.set_offending_flows sinvar = CommunicationPartners_offending_set" unfolding receiver_violation_def unfolding default_node_properties_def apply unfold_locales apply(rule ballI) apply (rule_tac f="f" in SecurityInvariant_withOffendingFlows.ENFnrSR_fsts_weakrefl_instance[OF CommunicationPartners_ENRnrSR Unassigned_weakrefl Unassigned_botdefault All_to_Unassigned]) apply(simp) apply(simp) apply(erule default_uniqueness_by_counterexample_ACS) apply(rule_tac x="\<lparr> nodes={vertex_1,vertex_2}, edges = {(vertex_1,vertex_2)} \<rparr>" in exI, simp) apply(rule conjI) apply(simp add: wf_graph_def) apply(simp add: CommunicationPartners_offending_set CommunicationPartners_offending_set_def delete_edges_simp2) apply(case_tac otherbot, simp_all) apply(rule_tac x="(\<lambda> x. DontCare)(vertex_1 := DontCare, vertex_2 := Master [vertex_1])" in exI, simp) apply(rule_tac x="vertex_1" in exI, simp) apply(simp split: prod.split) apply(clarify) apply force apply(rename_tac M) (*case Master M*) apply(rule_tac x="(\<lambda> x. DontCare)(vertex_1 := DontCare, vertex_2 := (Master (vertex_1#M')))" in exI, simp) apply(simp split: prod.split) apply(clarify) apply force apply(fact CommunicationPartners_offending_set) done lemma TopoS_SubnetsInGW: "SecurityInvariant sinvar default_node_properties receiver_violation" unfolding receiver_violation_def by unfold_locales text\<open>Example:\<close> lemma "sinvar \<lparr>nodes = {''db1'', ''db2'', ''h1'', ''h2'', ''foo'', ''bar''}, edges = {(''h1'', ''db1''), (''h2'', ''db1''), (''h1'', ''h2''), (''db1'', ''h1''), (''db1'', ''foo''), (''db1'', ''db2''), (''db1'', ''db1''), (''h1'', ''foo''), (''foo'', ''h1''), (''foo'', ''bar'')}\<rparr> (((((\<lambda>h. default_node_properties)(''h1'' := Care))(''h2'' := Care)) (''db1'' := Master [''h1'', ''h2'']))(''db2'' := Master [''db1'']))" by eval hide_fact (open) sinvar_mono hide_const (open) sinvar receiver_violation default_node_properties end
Ysabel ( March 7 , 2003 ) daughter
""" HyperRectangle{N,T} Hyperrectangle in `N` dimensions given by `low_corner::SVector{N,T}` and `high_corner::SVector{N,T}` """ struct HyperRectangle{N,T} low_corner::SVector{N,T} high_corner::SVector{N,T} end # promote HyperRectangle(l::Tuple,h::Tuple) = HyperRectangle(SVector(l),SVector(h)) HyperRectangle(l::SVector,h::SVector) = HyperRectangle(promote(l,h)...) # 1d case HyperRectangle(a::Number,b::Number) = HyperRectangle(SVector(a),SVector(b)) Base.:(==)(h1::HyperRectangle, h2::HyperRectangle) = (h1.low_corner == h2.low_corner) && (h1.high_corner == h2.high_corner) Base.isapprox(h1::HyperRectangle,h2::HyperRectangle) = isapprox(h1.low_corner,h2.low_corner) && isapprox(h1.high_corner,h2.high_corner) Base.in(point,h::HyperRectangle) = all(h.low_corner .<= point .<= h.high_corner) Base.eltype(h::HyperRectangle{N,T}) where {N,T} = T ambient_dimension(h::HyperRectangle{N}) where {N} = N geometric_dimension(h::HyperRectangle{N}) where {N} = N low_corner(r::HyperRectangle) = r.low_corner high_corner(r::HyperRectangle) = r.high_corner diameter(cub::HyperRectangle) = norm(cub.high_corner .- cub.low_corner,2) function bounding_box(data) low_corner = first(data) high_corner = first(data) for pt in data low_corner = min.(low_corner,pt) high_corner = max.(high_corner,pt) end return HyperRectangle(low_corner,high_corner) end center(rec::HyperRectangle) = (rec.low_corner + rec.high_corner) / 2 radius(rec::HyperRectangle) = diameter(rec) / 2
# Takes two groups, and builds the pregroup underlying the free product of # these two groups # # don't try using this on large groups. # InstallMethod(PregroupOfFreeProduct, "for two finite groups", [IsGroup and IsFinite, IsGroup and IsFinite], function(G, H) local i, j, size, table, eltn; size := Size(G) + Size(H) - 1; table := NullMat(size,size); table{[2..Size(G)]}{[2..Size(G)]} := MultiplicationTable(G){[2..Size(G)]}{[2..Size(G)]}; table{[Size(G)+1..size]}{[Size(G)+1..size]} := Size(G) - 1 + MultiplicationTable(H){[2..Size(H)]}{[2..Size(H)]}; for i in [Size(G) + 1 .. size ] do for j in [Size(G) + 1 .. size ] do if table[i][j] = Size(G) then table[i][j] := 1; fi; od; od; for i in [1..size] do table[1][i] := i; table[i][1] := i; od; eltn := List([1..size], String); return PregroupByTable(eltn, table); end); # Pregroup of free product of entered groups InstallGlobalFunction(PregroupOfFreeProductList, function(l) local r; r.groups := l; return Objectify(PregroupOfFreeProductType, r); end); InstallMethod(PregroupByRedRelators, "for a free group, and a list of words of length 3", [ IsFreeGroup, IsList, IsList ], function(F, rred, inv) local rkF, n, enams, table, i, j, r, pg, convert, ic; rkF := Length(GeneratorsOfGroup(F)); if ForAny(rred, x -> not ( (x in F) and ( Length(x) = 3 ) ) ) then Error("rred has to be a list of words of length 3 over F"); fi; ic := Length(inv); n := 1 + 2 * rkF; enams := Concatenation(["1"] , Concatenation( List([1..rkF], x -> [ Concatenation("x", String(x)) , Concatenation("X", String(x)) ] ))); table := NullMat(n, n); # Multiplication by 1 for i in [1..n] do table[1,i] := i; table[i,1] := i; od; # Multiplication of mutual inverse generators in # Free group for i in [2, 4..2 * rkF] do table[i, i+1] := 1; table[i+1, i] := 1; od; for i in inv do table[ 2*i, 2*i] := 1; table[ 2*i, 2*i + 1] := 0; table[ 2*i + 1, 2*i] := 0; table[ 2*i+1 , 2*i+1] := 1; od; convert := function(x) if x > 0 then return 2 * x; else # involution if -x in inv then return 2 * (-x); else return 2 * (-x) + 1; fi; fi; end; # Enter red relators # for r = x * y * z we get # - x * y = z^-1 # - x = z^-1 * y^-1 # - y * z = x ^ -1 # - z = y^-1 * x^-1 # - y = x^-1 * z^-1 # - y^-1 = z * x for r in List(rred, LetterRepAssocWord) do table[ convert(r[1]), convert(r[2]) ] := convert(-r[3]); table[ convert(-r[3]), convert(-r[2]) ] := convert(r[1]); table[ convert(r[2]), convert(r[3]) ] := convert(-r[1]); table[ convert(-r[2]), convert(-r[1]) ] := convert(r[3]); table[ convert(-r[1]), convert(-r[3]) ] := convert(r[2]); table[ convert(r[3]), convert(r[1]) ] := convert(-r[2]); od; pg := PregroupByTable(enams, table); pg!.freegroup := F; pg!.convert_word := w -> List(LetterRepAssocWord(w), l -> pg[convert(l)]); return pg; end);
open import Common.Prelude open import Common.Reflection module TermSplicing1 where x = unquote (give Set)
[STATEMENT] lemma interaction_bounded_by_bind_PauseI [interaction_bound]: "(\<And>input. interaction_bounded_by consider (c input \<bind> f) (n input)) \<Longrightarrow> interaction_bounded_by consider (Pause out c \<bind> f) (if consider out then SUP input. n input + 1 else SUP input. n input)" [PROOF STATE] proof (prove) goal (1 subgoal): 1. (\<And>input. interaction_bounded_by consider (c input \<bind> f) (n input)) \<Longrightarrow> interaction_bounded_by consider (Generative_Probabilistic_Value.Pause out c \<bind> f) (if consider out then \<Squnion>input. n input + 1 else \<Squnion> range n) [PROOF STEP] by(auto 4 3 simp add: interaction_bounded_by.simps SUP_enat_add_left eSuc_plus_1 intro: SUP_least SUP_upper2)
/- Copyright (c) 2022 Henrik BΓΆving. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Henrik BΓΆving, Simon Hudon -/ import Mathlib.Testing.SlimCheck.Gen /-! # `SampleableExt` Class This class permits the creation samples of a given type controlling the size of those values using the `Gen` monad`. # `Shrinkable` Class This class helps minimize examples by creating smaller versions of given values. When testing a proposition like `βˆ€ n : β„•, prime n β†’ n ≀ 100`, `SlimCheck` requires that `β„•` have an instance of `SampleableExt` and for `prime n` to be decidable. `SlimCheck` will then use the instance of `SampleableExt` to generate small examples of β„• and progressively increase in size. For each example `n`, `prime n` is tested. If it is false, the example will be rejected (not a test success nor a failure) and `SlimCheck` will move on to other examples. If `prime n` is true, `n ≀ 100` will be tested. If it is false, `n` is a counter-example of `βˆ€ n : β„•, prime n β†’ n ≀ 100` and the test fails. If `n ≀ 100` is true, the test passes and `SlimCheck` moves on to trying more examples. This is a port of the Haskell QuickCheck library. ## Main definitions * `SampleableExt` class * `Shrinkable` class ### `SampleableExt` `SampleableExt` can be used in two ways. The first (and most common) is to simply generate values of a type directly using the `Gen` monad, if this is what you want to do then `SampleableExt.mkSelfContained` is the way to go. Furthermore it makes it possible to express generators for types that do not lend themselves to introspection, such as `β„• β†’ β„•`. If we test a quantification over functions the counter-examples cannot be shrunken or printed meaningfully. For that purpose, `SampleableExt` provides a proxy representation `proxy` that can be printed and shrunken as well as interpreted (using `interp`) as an object of the right type. If you are using it in the first way, this proxy type will simply be the type itself and the `interp` function `id`. ### `Shrinkable Given an example `x : Ξ±`, `Shrinkable Ξ±` gives us a way to shrink it and suggest simpler examples. ## Shrinking Shrinking happens when `SlimCheck` find a counter-example to a property. It is likely that the example will be more complicated than necessary so `SlimCheck` proceeds to shrink it as much as possible. Although equally valid, a smaller counter-example is easier for a user to understand and use. The `Shrinkable` class, , has a `shrink` function so that we can use specialized knowledge while shrinking a value. It is not responsible for the whole shrinking process however. It only has to take one step in the shrinking process. `SlimCheck` will repeatedly call `shrink` until no more steps can be taken. Because `shrink` guarantees that the size of the candidates it produces is strictly smaller than the argument, we know that `SlimCheck` is guaranteed to terminate. ## Tags random testing ## References * https://hackage.haskell.org/package/QuickCheck -/ namespace SlimCheck open Random Gen /-- Given an example `x : Ξ±`, `Shrinkable Ξ±` gives us a way to shrink it and suggest simpler examples. -/ class Shrinkable (Ξ± : Type u) extends WellFoundedRelation Ξ± where shrink : (x : Ξ±) β†’ List { y : Ξ± // WellFoundedRelation.rel y x } := Ξ» _ => [] /-- `SampleableExt` can be used in two ways. The first (and most common) is to simply generate values of a type directly using the `Gen` monad, if this is what you want to do then `SampleableExt.mkSelfContained` is the way to go. Furthermore it makes it possible to express generators for types that do not lend themselves to introspection, such as `β„• β†’ β„•`. If we test a quantification over functions the counter-examples cannot be shrunken or printed meaningfully. For that purpose, `SampleableExt` provides a proxy representation `proxy` that can be printed and shrunken as well as interpreted (using `interp`) as an object of the right type. -/ class SampleableExt (Ξ± : Sort u) where proxy : Type v [proxyRepr : Repr proxy] [shrink : Shrinkable proxy] sample : Gen proxy interp : proxy β†’ Ξ± attribute [instance] SampleableExt.proxyRepr attribute [instance] SampleableExt.shrink namespace SampleableExt /-- Use to generate instance whose purpose is to simply generate values of a type directly using the `Gen` monad -/ def mkSelfContained [Repr Ξ±] [Shrinkable Ξ±] (sample : Gen Ξ±) : SampleableExt Ξ± where proxy := Ξ± proxyRepr := inferInstance shrink := inferInstance sample := sample interp := id /-- First samples a proxy value and interprets it. Especially useful if the proxy and target type are the same. -/ def interpSample (Ξ± : Type u) [SampleableExt Ξ±] : Gen Ξ± := SampleableExt.interp <$> SampleableExt.sample end SampleableExt section Shrinkers /-- `Nat.shrink' n` creates a list of smaller natural numbers by successively dividing `n` by 2 . For example, `Nat.shrink 5 = [2, 1, 0]`. -/ def Nat.shrink (n : Nat) : List { y : Nat // WellFoundedRelation.rel y n } := if h : 0 < n then let m := n/2 have h : m < n := by apply Nat.div_lt_self h decide let rest := shrink m let current := ⟨m, h⟩ current :: rest.map (Ξ» x => {x with property := Nat.lt_trans x.property h}) else [] instance Nat.shrinkable : Shrinkable Nat where shrink := Nat.shrink /-- `Fin.shrink` works like `Nat.shrink` but instead operates on `Fin`. -/ def Fin.shrink {n : Nat} (m : Fin n.succ) : List { y : Fin n.succ // WellFoundedRelation.rel y m } := let shrinks := Nat.shrink m.val shrinks.map (Ξ» x => { x with property := (by simp_wf exact lt_of_le_of_lt (Nat.mod_le _ _) x.property) }) instance Fin.shrinkable {n : Nat} : Shrinkable (Fin n.succ) where shrink := Fin.shrink local instance Int_sizeOfAbs : SizeOf Int := ⟨Int.natAbs⟩ /-- `Int.shrinkable` operates like `Nat.shrinkable` but also includes the negative variants. -/ instance Int.shrinkable : Shrinkable Int where shrink n := Nat.shrink n.natAbs |>.map Ξ» ⟨x, h⟩ => ⟨-x, (by simp_wf; simp only [SizeOf.sizeOf]; rw [Int.natAbs_neg]; exact h)⟩ instance Bool.shrinkable : Shrinkable Bool := {} instance Char.shrinkable : Shrinkable Char := {} instance Prod.shrinkable [shrA : Shrinkable Ξ±] [shrB : Shrinkable Ξ²] : Shrinkable (Prod Ξ± Ξ²) where shrink := Ξ» (fst,snd) => let shrink1 := shrA.shrink fst |>.map fun ⟨x, _⟩ ↦ ⟨(x, snd), by simp_wf; apply Prod.Lex.left; simp_all_arith⟩ let shrink2 := shrB.shrink snd |>.map fun ⟨x, _⟩ ↦ ⟨(fst, x), by simp_wf; apply Prod.Lex.right; simp_all_arith⟩ shrink1 ++ shrink2 end Shrinkers section Samplers open SampleableExt instance Nat.sampleableExt : SampleableExt Nat := mkSelfContained (do choose Nat 0 (←getSize) (Nat.zero_le _)) instance Fin.sampleableExt {n : Nat} : SampleableExt (Fin (n.succ)) := mkSelfContained (do choose (Fin n.succ) (Fin.ofNat 0) (Fin.ofNat (←getSize)) (by simp [Fin.ofNat, LE.le] exact Nat.zero_le _ )) instance Int.sampleableExt : SampleableExt Int := mkSelfContained (do choose Int (-(←getSize)) (←getSize) (le_trans (Int.neg_nonpos_of_nonneg (Int.ofNat_zero_le _)) (Int.ofNat_zero_le _))) instance Bool.sampleableExt : SampleableExt Bool := mkSelfContained $ chooseAny Bool /-- This can be specialized into customized `SampleableExt Char` instances. The resulting instance has `1 / length` chances of making an unrestricted choice of characters and it otherwise chooses a character from `chars` with uniform probabilities. -/ def Char.sampleable (length : Nat) (chars : List Char) (pos : 0 < chars.length) : SampleableExt Char := mkSelfContained do let x ← choose Nat 0 length (Nat.zero_le _) if x.val == 0 then let n ← interpSample Nat pure $ Char.ofNat n else elements chars pos instance Char.sampleableDefault : SampleableExt Char := Char.sampleable 3 " 0123abcABC:,;`\\/".toList (by decide) instance Prod.sampleableExt {Ξ± Ξ² : Type u} [SampleableExt Ξ±] [SampleableExt Ξ²] : SampleableExt (Ξ± Γ— Ξ²) where proxy := Prod (proxy Ξ±) (proxy Ξ²) proxyRepr := inferInstance shrink := inferInstance sample := prodOf sample sample interp := Prod.map interp interp instance Prop.sampleableExt : SampleableExt Prop where proxy := Bool proxyRepr := inferInstance sample := interpSample Bool shrink := inferInstance interp := Coe.coe end Samplers /-- An annotation for values that should never get shrinked. -/ def NoShrink (Ξ± : Type u) := Ξ± namespace NoShrink def mk (x : Ξ±) : NoShrink Ξ± := x def get (x : NoShrink Ξ±) : Ξ± := x instance inhabited [inst : Inhabited Ξ±] : Inhabited (NoShrink Ξ±) := inst instance repr [inst : Repr Ξ±] : Repr (NoShrink Ξ±) := inst instance shrinkable : Shrinkable (NoShrink Ξ±) where shrink := Ξ» _ => [] instance sampleableExt [SampleableExt Ξ±] [Repr Ξ±] : SampleableExt (NoShrink Ξ±) := SampleableExt.mkSelfContained $ (NoShrink.mk ∘ SampleableExt.interp) <$> SampleableExt.sample end NoShrink end SlimCheck
/- Copyright (c) 2021 Oliver Nash. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Oliver Nash -/ import algebra.lie.nilpotent import algebra.lie.tensor_product import algebra.lie.character import algebra.lie.cartan_subalgebra import linear_algebra.eigenspace import ring_theory.tensor_product /-! # Weights and roots of Lie modules and Lie algebras Just as a key tool when studying the behaviour of a linear operator is to decompose the space on which it acts into a sum of (generalised) eigenspaces, a key tool when studying a representation `M` of Lie algebra `L` is to decompose `M` into a sum of simultaneous eigenspaces of `x` as `x` ranges over `L`. These simultaneous generalised eigenspaces are known as the weight spaces of `M`. When `L` is nilpotent, it follows from the binomial theorem that weight spaces are Lie submodules. Even when `L` is not nilpotent, it may be useful to study its representations by restricting them to a nilpotent subalgebra (e.g., a Cartan subalgebra). In the particular case when we view `L` as a module over itself via the adjoint action, the weight spaces of `L` restricted to a nilpotent subalgebra are known as root spaces. Basic definitions and properties of the above ideas are provided in this file. ## Main definitions * `lie_module.weight_space` * `lie_module.is_weight` * `lie_algebra.root_space` * `lie_algebra.is_root` * `lie_algebra.root_space_weight_space_product` * `lie_algebra.root_space_product` ## References * [N. Bourbaki, *Lie Groups and Lie Algebras, Chapters 7--9*](bourbaki1975b) ## Tags lie character, eigenvalue, eigenspace, weight, weight vector, root, root vector -/ universes u v w w₁ wβ‚‚ w₃ variables {R : Type u} {L : Type v} [comm_ring R] [lie_ring L] [lie_algebra R L] variables (H : lie_subalgebra R L) [lie_algebra.is_nilpotent R H] variables (M : Type w) [add_comm_group M] [module R M] [lie_ring_module L M] [lie_module R L M] namespace lie_module open lie_algebra open tensor_product open tensor_product.lie_module open_locale big_operators open_locale tensor_product /-- Given a Lie module `M` over a Lie algebra `L`, the pre-weight space of `M` with respect to a map `Ο‡ : L β†’ R` is the simultaneous generalized eigenspace of the action of all `x : L` on `M`, with eigenvalues `Ο‡ x`. See also `lie_module.weight_space`. -/ def pre_weight_space (Ο‡ : L β†’ R) : submodule R M := β¨… (x : L), (to_endomorphism R L M x).maximal_generalized_eigenspace (Ο‡ x) lemma mem_pre_weight_space (Ο‡ : L β†’ R) (m : M) : m ∈ pre_weight_space M Ο‡ ↔ βˆ€ x, βˆƒ (k : β„•), ((to_endomorphism R L M x - (Ο‡ x) β€’ 1)^k) m = 0 := by simp [pre_weight_space, -linear_map.pow_apply] variables (L) /-- See also `bourbaki1975b` Chapter VII Β§1.1, Proposition 2 (ii). -/ protected lemma weight_vector_multiplication (M₁ : Type w₁) (Mβ‚‚ : Type wβ‚‚) (M₃ : Type w₃) [add_comm_group M₁] [module R M₁] [lie_ring_module L M₁] [lie_module R L M₁] [add_comm_group Mβ‚‚] [module R Mβ‚‚] [lie_ring_module L Mβ‚‚] [lie_module R L Mβ‚‚] [add_comm_group M₃] [module R M₃] [lie_ring_module L M₃] [lie_module R L M₃] (g : M₁ βŠ—[R] Mβ‚‚ →ₗ⁅R,L⁆ M₃) (χ₁ Ο‡β‚‚ : L β†’ R) : ((g : M₁ βŠ—[R] Mβ‚‚ β†’β‚—[R] M₃).comp (map_incl (pre_weight_space M₁ χ₁) (pre_weight_space Mβ‚‚ Ο‡β‚‚))).range ≀ pre_weight_space M₃ (χ₁ + Ο‡β‚‚) := begin /- Unpack the statement of the goal. -/ intros m₃, simp only [lie_module_hom.coe_to_linear_map, pi.add_apply, function.comp_app, mem_pre_weight_space, linear_map.coe_comp, tensor_product.map_incl, exists_imp_distrib, linear_map.mem_range], rintros t rfl x, /- Set up some notation. -/ let F : module.End R M₃ := (to_endomorphism R L M₃ x) - (χ₁ x + Ο‡β‚‚ x) β€’ 1, change βˆƒ k, (F^k) (g _) = 0, /- The goal is linear in `t` so use induction to reduce to the case that `t` is a pure tensor. -/ apply t.induction_on, { use 0, simp only [linear_map.map_zero, lie_module_hom.map_zero], }, swap, { rintros t₁ tβ‚‚ ⟨k₁, hkβ‚βŸ© ⟨kβ‚‚, hkβ‚‚βŸ©, use max k₁ kβ‚‚, simp only [lie_module_hom.map_add, linear_map.map_add, linear_map.pow_map_zero_of_le (le_max_left k₁ kβ‚‚) hk₁, linear_map.pow_map_zero_of_le (le_max_right k₁ kβ‚‚) hkβ‚‚, add_zero], }, /- Now the main argument: pure tensors. -/ rintros ⟨m₁, hmβ‚βŸ© ⟨mβ‚‚, hmβ‚‚βŸ©, change βˆƒ k, (F^k) ((g : M₁ βŠ—[R] Mβ‚‚ β†’β‚—[R] M₃) (m₁ βŠ—β‚œ mβ‚‚)) = 0, /- Eliminate `g` from the picture. -/ let f₁ : module.End R (M₁ βŠ—[R] Mβ‚‚) := (to_endomorphism R L M₁ x - (χ₁ x) β€’ 1).rtensor Mβ‚‚, let fβ‚‚ : module.End R (M₁ βŠ—[R] Mβ‚‚) := (to_endomorphism R L Mβ‚‚ x - (Ο‡β‚‚ x) β€’ 1).ltensor M₁, have h_comm_square : F βˆ˜β‚— ↑g = (g : M₁ βŠ—[R] Mβ‚‚ β†’β‚—[R] M₃).comp (f₁ + fβ‚‚), { ext m₁ mβ‚‚, simp only [← g.map_lie x (m₁ βŠ—β‚œ mβ‚‚), add_smul, sub_tmul, tmul_sub, smul_tmul, lie_tmul_right, tmul_smul, to_endomorphism_apply_apply, lie_module_hom.map_smul, linear_map.one_apply, lie_module_hom.coe_to_linear_map, linear_map.smul_apply, function.comp_app, linear_map.coe_comp, linear_map.rtensor_tmul, lie_module_hom.map_add, linear_map.add_apply, lie_module_hom.map_sub, linear_map.sub_apply, linear_map.ltensor_tmul, algebra_tensor_module.curry_apply, curry_apply, linear_map.to_fun_eq_coe, linear_map.coe_restrict_scalars_eq_coe], abel, }, suffices : βˆƒ k, ((f₁ + fβ‚‚)^k) (m₁ βŠ—β‚œ mβ‚‚) = 0, { obtain ⟨k, hk⟩ := this, use k, rw [← linear_map.comp_apply, linear_map.commute_pow_left_of_commute h_comm_square, linear_map.comp_apply, hk, linear_map.map_zero], }, /- Unpack the information we have about `m₁`, `mβ‚‚`. -/ simp only [mem_pre_weight_space] at hm₁ hmβ‚‚, obtain ⟨k₁, hkβ‚βŸ© := hm₁ x, obtain ⟨kβ‚‚, hkβ‚‚βŸ© := hmβ‚‚ x, have hf₁ : (f₁^k₁) (m₁ βŠ—β‚œ mβ‚‚) = 0, { simp only [hk₁, zero_tmul, linear_map.rtensor_tmul, linear_map.rtensor_pow], }, have hfβ‚‚ : (fβ‚‚^kβ‚‚) (m₁ βŠ—β‚œ mβ‚‚) = 0, { simp only [hkβ‚‚, tmul_zero, linear_map.ltensor_tmul, linear_map.ltensor_pow], }, /- It's now just an application of the binomial theorem. -/ use k₁ + kβ‚‚ - 1, have hf_comm : commute f₁ fβ‚‚, { ext m₁ mβ‚‚, simp only [linear_map.mul_apply, linear_map.rtensor_tmul, linear_map.ltensor_tmul, algebra_tensor_module.curry_apply, linear_map.to_fun_eq_coe, linear_map.ltensor_tmul, curry_apply, linear_map.coe_restrict_scalars_eq_coe], }, rw hf_comm.add_pow', simp only [tensor_product.map_incl, submodule.subtype_apply, finset.sum_apply, submodule.coe_mk, linear_map.coe_fn_sum, tensor_product.map_tmul, linear_map.smul_apply], /- The required sum is zero because each individual term is zero. -/ apply finset.sum_eq_zero, rintros ⟨i, j⟩ hij, /- Eliminate the binomial coefficients from the picture. -/ suffices : (f₁^i * fβ‚‚^j) (m₁ βŠ—β‚œ mβ‚‚) = 0, { rw this, apply smul_zero, }, /- Finish off with appropriate case analysis. -/ cases nat.le_or_le_of_add_eq_add_pred (finset.nat.mem_antidiagonal.mp hij) with hi hj, { rw [(hf_comm.pow_pow i j).eq, linear_map.mul_apply, linear_map.pow_map_zero_of_le hi hf₁, linear_map.map_zero], }, { rw [linear_map.mul_apply, linear_map.pow_map_zero_of_le hj hfβ‚‚, linear_map.map_zero], }, end variables {L M} lemma lie_mem_pre_weight_space_of_mem_pre_weight_space {χ₁ Ο‡β‚‚ : L β†’ R} {x : L} {m : M} (hx : x ∈ pre_weight_space L χ₁) (hm : m ∈ pre_weight_space M Ο‡β‚‚) : ⁅x, m⁆ ∈ pre_weight_space M (χ₁ + Ο‡β‚‚) := begin apply lie_module.weight_vector_multiplication L L M M (to_module_hom R L M) χ₁ Ο‡β‚‚, simp only [lie_module_hom.coe_to_linear_map, function.comp_app, linear_map.coe_comp, tensor_product.map_incl, linear_map.mem_range], use [⟨x, hx⟩ βŠ—β‚œ ⟨m, hm⟩], simp only [submodule.subtype_apply, to_module_hom_apply, tensor_product.map_tmul], refl, end variables (M) /-- If a Lie algebra is nilpotent, then pre-weight spaces are Lie submodules. -/ def weight_space [lie_algebra.is_nilpotent R L] (Ο‡ : L β†’ R) : lie_submodule R L M := { lie_mem := Ξ» x m hm, begin rw ← zero_add Ο‡, refine lie_mem_pre_weight_space_of_mem_pre_weight_space _ hm, suffices : pre_weight_space L (0 : L β†’ R) = ⊀, { simp only [this, submodule.mem_top], }, exact lie_algebra.infi_max_gen_zero_eigenspace_eq_top_of_nilpotent R L, end, .. pre_weight_space M Ο‡ } lemma mem_weight_space [lie_algebra.is_nilpotent R L] (Ο‡ : L β†’ R) (m : M) : m ∈ weight_space M Ο‡ ↔ m ∈ pre_weight_space M Ο‡ := iff.rfl /-- See also the more useful form `lie_module.zero_weight_space_eq_top_of_nilpotent`. -/ @[simp] lemma zero_weight_space_eq_top_of_nilpotent' [lie_algebra.is_nilpotent R L] [is_nilpotent R L M] : weight_space M (0 : L β†’ R) = ⊀ := begin rw [← lie_submodule.coe_to_submodule_eq_iff, lie_submodule.top_coe_submodule], exact infi_max_gen_zero_eigenspace_eq_top_of_nilpotent R L M, end lemma coe_weight_space_of_top [lie_algebra.is_nilpotent R L] (Ο‡ : L β†’ R) : (weight_space M (Ο‡ ∘ (⊀ : lie_subalgebra R L).incl) : submodule R M) = weight_space M Ο‡ := begin ext m, simp only [weight_space, lie_submodule.coe_to_submodule_mk, lie_subalgebra.coe_bracket_of_module, function.comp_app, mem_pre_weight_space], split; intros h x, { obtain ⟨k, hk⟩ := h ⟨x, set.mem_univ x⟩, use k, exact hk, }, { obtain ⟨k, hk⟩ := h x, use k, exact hk, }, end @[simp] lemma zero_weight_space_eq_top_of_nilpotent [lie_algebra.is_nilpotent R L] [is_nilpotent R L M] : weight_space M (0 : (⊀ : lie_subalgebra R L) β†’ R) = ⊀ := begin /- We use `coe_weight_space_of_top` as a trick to circumvent the fact that we don't (yet) know `is_nilpotent R (⊀ : lie_subalgebra R L) M` is equivalent to `is_nilpotent R L M`. -/ have hβ‚€ : (0 : L β†’ R) ∘ (⊀ : lie_subalgebra R L).incl = 0, { ext, refl, }, rw [← lie_submodule.coe_to_submodule_eq_iff, lie_submodule.top_coe_submodule, ← hβ‚€, coe_weight_space_of_top, ← infi_max_gen_zero_eigenspace_eq_top_of_nilpotent R L M], refl, end /-- Given a Lie module `M` of a Lie algebra `L`, a weight of `M` with respect to a nilpotent subalgebra `H βŠ† L` is a Lie character whose corresponding weight space is non-empty. -/ def is_weight (Ο‡ : lie_character R H) : Prop := weight_space M Ο‡ β‰  βŠ₯ /-- For a non-trivial nilpotent Lie module over a nilpotent Lie algebra, the zero character is a weight with respect to the `⊀` Lie subalgebra. -/ lemma is_weight_zero_of_nilpotent [nontrivial M] [lie_algebra.is_nilpotent R L] [is_nilpotent R L M] : is_weight (⊀ : lie_subalgebra R L) M 0 := by { rw [is_weight, lie_hom.coe_zero, zero_weight_space_eq_top_of_nilpotent], exact top_ne_bot, } end lie_module namespace lie_algebra open_locale tensor_product open tensor_product.lie_module open lie_module /-- Given a nilpotent Lie subalgebra `H βŠ† L`, the root space of a map `Ο‡ : H β†’ R` is the weight space of `L` regarded as a module of `H` via the adjoint action. -/ abbreviation root_space (Ο‡ : H β†’ R) : lie_submodule R H L := weight_space L Ο‡ @[simp] /-- A root of a Lie algebra `L` with respect to a nilpotent subalgebra `H βŠ† L` is a weight of `L`, regarded as a module of `H` via the adjoint action. -/ abbreviation is_root := is_weight H L @[simp] lemma root_space_comap_eq_weight_space (Ο‡ : H β†’ R) : (root_space H Ο‡).comap H.incl' = weight_space H Ο‡ := begin ext x, let f : H β†’ module.End R L := Ξ» y, to_endomorphism R H L y - (Ο‡ y) β€’ 1, let g : H β†’ module.End R H := Ξ» y, to_endomorphism R H H y - (Ο‡ y) β€’ 1, suffices : (βˆ€ (y : H), βˆƒ (k : β„•), ((f y)^k).comp (H.incl : H β†’β‚—[R] L) x = 0) ↔ βˆ€ (y : H), βˆƒ (k : β„•), (H.incl : H β†’β‚—[R] L).comp ((g y)^k) x = 0, { simp only [lie_hom.coe_to_linear_map, lie_subalgebra.coe_incl, function.comp_app, linear_map.coe_comp, submodule.coe_eq_zero] at this, simp only [mem_weight_space, mem_pre_weight_space, lie_subalgebra.coe_incl', lie_submodule.mem_comap, this], }, have hfg : βˆ€ (y : H), (f y).comp (H.incl : H β†’β‚—[R] L) = (H.incl : H β†’β‚—[R] L).comp (g y), { rintros ⟨y, hy⟩, ext ⟨z, hz⟩, simp only [submodule.coe_sub, to_endomorphism_apply_apply, lie_hom.coe_to_linear_map, linear_map.one_apply, lie_subalgebra.coe_incl, lie_subalgebra.coe_bracket_of_module, lie_subalgebra.coe_bracket, linear_map.smul_apply, function.comp_app, submodule.coe_smul_of_tower, linear_map.coe_comp, linear_map.sub_apply], }, simp_rw [linear_map.commute_pow_left_of_commute (hfg _)], end variables {H M} lemma lie_mem_weight_space_of_mem_weight_space {χ₁ Ο‡β‚‚ : H β†’ R} {x : L} {m : M} (hx : x ∈ root_space H χ₁) (hm : m ∈ weight_space M Ο‡β‚‚) : ⁅x, m⁆ ∈ weight_space M (χ₁ + Ο‡β‚‚) := begin apply lie_module.weight_vector_multiplication H L M M ((to_module_hom R L M).restrict_lie H) χ₁ Ο‡β‚‚, simp only [lie_module_hom.coe_to_linear_map, function.comp_app, linear_map.coe_comp, tensor_product.map_incl, linear_map.mem_range], use [⟨x, hx⟩ βŠ—β‚œ ⟨m, hm⟩], simp only [submodule.subtype_apply, to_module_hom_apply, submodule.coe_mk, lie_module_hom.coe_restrict_lie, tensor_product.map_tmul], end variables (R L H M) /-- Auxiliary definition for `root_space_weight_space_product`, which is close to the deterministic timeout limit. -/ def root_space_weight_space_product_aux {χ₁ Ο‡β‚‚ χ₃ : H β†’ R} (hΟ‡ : χ₁ + Ο‡β‚‚ = χ₃) : (root_space H χ₁) β†’β‚—[R] (weight_space M Ο‡β‚‚) β†’β‚—[R] (weight_space M χ₃) := { to_fun := Ξ» x, { to_fun := Ξ» m, βŸ¨β…(x : L), (m : M)⁆, hΟ‡ β–Έ (lie_mem_weight_space_of_mem_weight_space x.property m.property) ⟩, map_add' := Ξ» m n, by { simp only [lie_submodule.coe_add, lie_add], refl, }, map_smul' := Ξ» t m, by { conv_lhs { congr, rw [lie_submodule.coe_smul, lie_smul], }, refl, }, }, map_add' := Ξ» x y, by ext m; rw [linear_map.add_apply, linear_map.coe_mk, linear_map.coe_mk, linear_map.coe_mk, subtype.coe_mk, lie_submodule.coe_add, lie_submodule.coe_add, add_lie, subtype.coe_mk, subtype.coe_mk], map_smul' := Ξ» t x, begin simp only [ring_hom.id_apply], ext m, rw [linear_map.smul_apply, linear_map.coe_mk, linear_map.coe_mk, subtype.coe_mk, lie_submodule.coe_smul, smul_lie, lie_submodule.coe_smul, subtype.coe_mk], end, } /-- Given a nilpotent Lie subalgebra `H βŠ† L` together with `χ₁ Ο‡β‚‚ : H β†’ R`, there is a natural `R`-bilinear product of root vectors and weight vectors, compatible with the actions of `H`. -/ def root_space_weight_space_product (χ₁ Ο‡β‚‚ χ₃ : H β†’ R) (hΟ‡ : χ₁ + Ο‡β‚‚ = χ₃) : (root_space H χ₁) βŠ—[R] (weight_space M Ο‡β‚‚) →ₗ⁅R,H⁆ weight_space M χ₃ := lift_lie R H (root_space H χ₁) (weight_space M Ο‡β‚‚) (weight_space M χ₃) { to_linear_map := root_space_weight_space_product_aux R L H M hΟ‡, map_lie' := Ξ» x y, by ext m; rw [root_space_weight_space_product_aux, lie_hom.lie_apply, lie_submodule.coe_sub, linear_map.coe_mk, linear_map.coe_mk, subtype.coe_mk, subtype.coe_mk, lie_submodule.coe_bracket, lie_submodule.coe_bracket, subtype.coe_mk, lie_subalgebra.coe_bracket_of_module, lie_subalgebra.coe_bracket_of_module, lie_submodule.coe_bracket, lie_subalgebra.coe_bracket_of_module, lie_lie], } @[simp] lemma coe_root_space_weight_space_product_tmul (χ₁ Ο‡β‚‚ χ₃ : H β†’ R) (hΟ‡ : χ₁ + Ο‡β‚‚ = χ₃) (x : root_space H χ₁) (m : weight_space M Ο‡β‚‚) : (root_space_weight_space_product R L H M χ₁ Ο‡β‚‚ χ₃ hΟ‡ (x βŠ—β‚œ m) : M) = ⁅(x : L), (m : M)⁆ := by simp only [root_space_weight_space_product, root_space_weight_space_product_aux, lift_apply, lie_module_hom.coe_to_linear_map, coe_lift_lie_eq_lift_coe, submodule.coe_mk, linear_map.coe_mk, lie_module_hom.coe_mk] /-- Given a nilpotent Lie subalgebra `H βŠ† L` together with `χ₁ Ο‡β‚‚ : H β†’ R`, there is a natural `R`-bilinear product of root vectors, compatible with the actions of `H`. -/ def root_space_product (χ₁ Ο‡β‚‚ χ₃ : H β†’ R) (hΟ‡ : χ₁ + Ο‡β‚‚ = χ₃) : (root_space H χ₁) βŠ—[R] (root_space H Ο‡β‚‚) →ₗ⁅R,H⁆ root_space H χ₃ := root_space_weight_space_product R L H L χ₁ Ο‡β‚‚ χ₃ hΟ‡ @[simp] lemma root_space_product_def : root_space_product R L H = root_space_weight_space_product R L H L := rfl lemma root_space_product_tmul (χ₁ Ο‡β‚‚ χ₃ : H β†’ R) (hΟ‡ : χ₁ + Ο‡β‚‚ = χ₃) (x : root_space H χ₁) (y : root_space H Ο‡β‚‚) : (root_space_product R L H χ₁ Ο‡β‚‚ χ₃ hΟ‡ (x βŠ—β‚œ y) : L) = ⁅(x : L), (y : L)⁆ := by simp only [root_space_product_def, coe_root_space_weight_space_product_tmul] /-- Given a nilpotent Lie subalgebra `H βŠ† L`, the root space of the zero map `0 : H β†’ R` is a Lie subalgebra of `L`. -/ def zero_root_subalgebra : lie_subalgebra R L := { lie_mem' := Ξ» x y hx hy, by { let xy : (root_space H 0) βŠ—[R] (root_space H 0) := ⟨x, hx⟩ βŠ—β‚œ ⟨y, hy⟩, suffices : (root_space_product R L H 0 0 0 (add_zero 0) xy : L) ∈ root_space H 0, { rwa [root_space_product_tmul, subtype.coe_mk, subtype.coe_mk] at this, }, exact (root_space_product R L H 0 0 0 (add_zero 0) xy).property, }, .. (root_space H 0 : submodule R L) } @[simp] lemma coe_zero_root_subalgebra : (zero_root_subalgebra R L H : submodule R L) = root_space H 0 := rfl lemma mem_zero_root_subalgebra (x : L) : x ∈ zero_root_subalgebra R L H ↔ βˆ€ (y : H), βˆƒ (k : β„•), ((to_endomorphism R H L y)^k) x = 0 := by simp only [zero_root_subalgebra, mem_weight_space, mem_pre_weight_space, pi.zero_apply, sub_zero, set_like.mem_coe, zero_smul, lie_submodule.mem_coe_submodule, submodule.mem_carrier, lie_subalgebra.mem_mk_iff] lemma to_lie_submodule_le_root_space_zero : H.to_lie_submodule ≀ root_space H 0 := begin intros x hx, simp only [lie_subalgebra.mem_to_lie_submodule] at hx, simp only [mem_weight_space, mem_pre_weight_space, pi.zero_apply, sub_zero, zero_smul], intros y, unfreezingI { obtain ⟨k, hk⟩ := (infer_instance : is_nilpotent R H) }, use k, let f : module.End R H := to_endomorphism R H H y, let g : module.End R L := to_endomorphism R H L y, have hfg : g.comp (H : submodule R L).subtype = (H : submodule R L).subtype.comp f, { ext z, simp only [to_endomorphism_apply_apply, submodule.subtype_apply, lie_subalgebra.coe_bracket_of_module, lie_subalgebra.coe_bracket, function.comp_app, linear_map.coe_comp], }, change (g^k).comp (H : submodule R L).subtype ⟨x, hx⟩ = 0, rw linear_map.commute_pow_left_of_commute hfg k, have h := iterate_to_endomorphism_mem_lower_central_series R H H y ⟨x, hx⟩ k, rw [hk, lie_submodule.mem_bot] at h, simp only [submodule.subtype_apply, function.comp_app, linear_map.pow_apply, linear_map.coe_comp, submodule.coe_eq_zero], exact h, end lemma le_zero_root_subalgebra : H ≀ zero_root_subalgebra R L H := begin rw [← lie_subalgebra.coe_submodule_le_coe_submodule, ← H.coe_to_lie_submodule, coe_zero_root_subalgebra, lie_submodule.coe_submodule_le_coe_submodule], exact to_lie_submodule_le_root_space_zero R L H, end @[simp] lemma zero_root_subalgebra_normalizer_eq_self : (zero_root_subalgebra R L H).normalizer = zero_root_subalgebra R L H := begin refine le_antisymm _ (lie_subalgebra.le_normalizer _), intros x hx, rw lie_subalgebra.mem_normalizer_iff at hx, rw mem_zero_root_subalgebra, rintros ⟨y, hy⟩, specialize hx y (le_zero_root_subalgebra R L H hy), rw mem_zero_root_subalgebra at hx, obtain ⟨k, hk⟩ := hx ⟨y, hy⟩, rw [← lie_skew, linear_map.map_neg, neg_eq_zero] at hk, use k + 1, rw [linear_map.iterate_succ, linear_map.coe_comp, function.comp_app, to_endomorphism_apply_apply, lie_subalgebra.coe_bracket_of_module, submodule.coe_mk, hk], end /-- In finite dimensions over a field (and possibly more generally) Engel's theorem shows that the converse of this is also true, i.e., `zero_root_subalgebra R L H = H ↔ lie_subalgebra.is_cartan_subalgebra H`. -/ lemma zero_root_subalgebra_is_cartan_of_eq (h : zero_root_subalgebra R L H = H) : lie_subalgebra.is_cartan_subalgebra H := { nilpotent := infer_instance, self_normalizing := by { rw ← h, exact zero_root_subalgebra_normalizer_eq_self R L H, } } end lie_algebra namespace lie_module open lie_algebra variables {R L H} /-- A priori, weight spaces are Lie submodules over the Lie subalgebra `H` used to define them. However they are naturally Lie submodules over the (in general larger) Lie subalgebra `zero_root_subalgebra R L H`. Even though it is often the case that `zero_root_subalgebra R L H = H`, it is likely to be useful to have the flexibility not to have to invoke this equality (as well as to work more generally). -/ def weight_space' (Ο‡ : H β†’ R) : lie_submodule R (zero_root_subalgebra R L H) M := { lie_mem := Ξ» x m hm, by { have hx : (x : L) ∈ root_space H 0, { rw [← lie_submodule.mem_coe_submodule, ← coe_zero_root_subalgebra], exact x.property, }, rw ← zero_add Ο‡, exact lie_mem_weight_space_of_mem_weight_space hx hm, }, .. (weight_space M Ο‡ : submodule R M) } @[simp] lemma coe_weight_space' (Ο‡ : H β†’ R) : (weight_space' M Ο‡ : submodule R M) = weight_space M Ο‡ := rfl end lie_module
function write_tsurf_to_gltf(filename, tsh) drawnow; % Check that plot is set up for per-vertex data assert(strcmp(tsh.FaceColor,'interp')); % Even though you may pass it with 'CData' seems it gets moved to % 'FaceVertexCData' assert(size(tsh.FaceVertexCData,2) == 1); assert(size(tsh.FaceVertexCData,1) == size(tsh.Vertices,1)); % get color map CM = tsh.Parent.Colormap; CA = caxis(tsh.Parent); % pad colormap to power of 2 pad = 2^ceil(log2(size(CM,1))) - size(CM,1); CA = [CA(1) CA(1) + (CA(2)-CA(1)) * (size(CM,1)+pad)/size(CM,1)]; CM(end+(1:pad),:) = repmat(CM(end,:),pad,1); im = permute(flipud(CM),[1 3 2]); D = (tsh.FaceVertexCData-CA(1))/(CA(2)-CA(1)); R = axisangle2matrix([1 0 0],pi/2); VN = -tsh.VertexNormals; if ~isempty(VN); VN = VN*R; end writeGLTF_and_validate( ... filename, ... tsh.Vertices * R , ... tsh.Faces, ... 'Normals',VN, ... 'MagFilter','NEAREST', ... 'MinFilter','NEAREST', ... 'TextureCoordinates',[D D], ... 'TextureImage',im); end
using Plots using ImplicitEquations using ForwardDiff a, b = 1 / √2, 1 / √2 f(x, y) = x^2 + y^2 - 1 f(xy) = f(xy[1], xy[2]) g = xy -> ForwardDiff.gradient(f, xy) """ x' = x-a y' = y-b """ function shift(f::Function, a, b) t = [ 1 0 a; 0 1 b; 0 0 1 ] function tf(xy) x, y = xy tx, ty, tz = t * [x, y, 1] txy = [tx, ty] return f(txy) end tf(x, y) = tf([x, y]) return tf end """ x'' = x' y'' = f_x(a,b)*x' + f_y(a,b)*y' """ function cvt(f, a, b) fx, fy = g([a, b]) t = [ 1 0 0; -fx / fy 1 / fy 0; 0 0 1 ] t = t / fy function tf(xy) x, y = xy tx, ty, tz = t * [x, y, 1] txy = [tx, ty] return f(txy) end tf(x, y) = tf([x, y]) return tf end plot(aspect_ratio = :equal) plot!(Eq(f, 0)) sf = shift(f, a, b) plot!(Eq(sf, 0)) plot!(Eq(cvt(sf, a, b), 0))
module Numeral.Natural.Oper.Proofs.Multiplication where open import Logic.Propositional open import Numeral.Natural open import Numeral.Natural.Oper open import Numeral.Natural.Oper.Proofs open import Numeral.Natural.Oper.Proofs.Order open import Numeral.Natural.Relation open import Numeral.Natural.Relation.Order open import Numeral.Natural.Relation.Order.Classical open import Numeral.Natural.Relation.Order.Proofs open import Relator.Equals open import Relator.Equals.Proofs open import Structure.Operator import Structure.Operator.Names as Names open import Structure.Operator.Properties open import Structure.Relator.Properties open import Syntax.Transitivity instance [β‹…][βˆ’β‚€]-distributivityα΅£ : Distributivityα΅£(_β‹…_)(_βˆ’β‚€_) Distributivityα΅£.proof([β‹…][βˆ’β‚€]-distributivityα΅£) {x}{y}{z} = p{x}{y}{z} where p : βˆ€{x y z : β„•} β†’ ((x βˆ’β‚€ y) β‹… z) ≑ (x β‹… z) βˆ’β‚€ (y β‹… z) p {x} {y} {𝟎} = [≑]-intro p {x} {y} {𝐒 z} with [β‰₯]-or-[<] {x}{y} ... | [∨]-introβ‚— gt = (x βˆ’β‚€ y) β‹… 𝐒(z) πŸ–[ _≑_ ]-[] (x βˆ’β‚€ y) + ((x βˆ’β‚€ y) β‹… z) πŸ–[ _≑_ ]-[ congruenceβ‚‚α΅£(_+_)(x βˆ’β‚€ y) (p {x}{y}{z}) ] (x βˆ’β‚€ y) + ((x β‹… z) βˆ’β‚€ (y β‹… z)) πŸ–[ _≑_ ]-[ [+][βˆ’β‚€]-almost-associativity {x βˆ’β‚€ y} ([≀]-with-[β‹…]α΅£ {c = z} gt) ]-sym ((x βˆ’β‚€ y) + (x β‹… z)) βˆ’β‚€ (y β‹… z) πŸ–[ _≑_ ]-[ congruenceβ‚‚β‚—(_βˆ’β‚€_)(y β‹… z) (commutativity(_+_) {x βˆ’β‚€ y}{x β‹… z}) ] ((x β‹… z) + (x βˆ’β‚€ y)) βˆ’β‚€ (y β‹… z) πŸ–[ _≑_ ]-[ congruenceβ‚‚β‚—(_βˆ’β‚€_)(y β‹… z) ([+][βˆ’β‚€]-almost-associativity {x β‹… z} gt) ]-sym (((x β‹… z) + x) βˆ’β‚€ y) βˆ’β‚€ (y β‹… z) πŸ–[ _≑_ ]-[ congruenceβ‚‚β‚—(_βˆ’β‚€_)(y β‹… z) (congruenceβ‚‚β‚—(_βˆ’β‚€_)(y) (commutativity(_+_) {x β‹… z}{x})) ] ((x + (x β‹… z)) βˆ’β‚€ y) βˆ’β‚€ (y β‹… z) πŸ–[ _≑_ ]-[ [βˆ’β‚€][βˆ’β‚€]-to-[βˆ’β‚€][+] {x + (x β‹… z)}{y}{y β‹… z} ] (x + (x β‹… z)) βˆ’β‚€ (y + (y β‹… z)) πŸ–[ _≑_ ]-[] (x β‹… 𝐒(z)) βˆ’β‚€ (y β‹… 𝐒(z)) πŸ–-end ... | [∨]-introα΅£ lt = (x βˆ’β‚€ y) β‹… 𝐒(z) πŸ–[ _≑_ ]-[ congruenceβ‚‚β‚—(_β‹…_)(𝐒(z)) ([↔]-to-[β†’] [βˆ’β‚€]-when-0 (subβ‚‚(_<_)(_≀_) lt)) ] 𝟎 β‹… 𝐒(z) πŸ–[ _≑_ ]-[ absorberβ‚—(_β‹…_)(𝟎) {𝐒(z)} ] 𝟎 πŸ–[ _≑_ ]-[ [↔]-to-[β†’] [βˆ’β‚€]-when-0 ([≀]-with-[+] ⦃ subβ‚‚(_<_)(_≀_) lt ⦄ ⦃ [≀]-with-[β‹…]α΅£ {c = z} (subβ‚‚(_<_)(_≀_) lt) ⦄) ]-sym (x + (x β‹… z)) βˆ’β‚€ (y + (y β‹… z)) πŸ–-end -- TODO: This is a specialized distributivity-equivalence-by-commutativity instance [β‹…][βˆ’β‚€]-distributivityβ‚— : Distributivityβ‚—(_β‹…_)(_βˆ’β‚€_) Distributivityβ‚—.proof([β‹…][βˆ’β‚€]-distributivityβ‚—) {x}{y}{z} = p{x}{y}{z} where p : βˆ€{x y z : β„•} β†’ (x β‹… (y βˆ’β‚€ z)) ≑ (x β‹… y) βˆ’β‚€ (x β‹… z) p{x}{y}{z} = x β‹… (y βˆ’β‚€ z) πŸ–[ _≑_ ]-[ commutativity(_β‹…_) {x}{y βˆ’β‚€ z} ] (y βˆ’β‚€ z) β‹… x πŸ–[ _≑_ ]-[ distributivityα΅£(_β‹…_)(_βˆ’β‚€_) {y}{z}{x} ] (y β‹… x) βˆ’β‚€ (z β‹… x) πŸ–[ _≑_ ]-[ congruenceβ‚‚(_βˆ’β‚€_) (commutativity(_β‹…_) {y}{x}) (commutativity(_β‹…_) {z}{x}) ] (x β‹… y) βˆ’β‚€ (x β‹… z) πŸ–-end [β‹…]-cancellationβ‚— : βˆ€{x} β†’ ⦃ pos : Positive(x) ⦄ β†’ (Names.CancellationOnβ‚—(_β‹…_)(x)) [β‹…]-cancellationβ‚— {𝐒 a}{b}{c} p with [<]-trichotomy {b}{c} ... | [∨]-introβ‚— ([∨]-introβ‚— lt) with () ← [<]-to-[β‰’] ([<]-with-[β‹…]β‚— {a = a} lt) p ... | [∨]-introβ‚— ([∨]-introα΅£ eq) = eq ... | [∨]-introα΅£ gt with () ← [>]-to-[β‰’] ([<]-with-[β‹…]β‚— {a = a} gt) p [β‹…]-cancellationα΅£ : βˆ€{x} β†’ ⦃ pos : Positive(x) ⦄ β†’ (Names.CancellationOnα΅£(_β‹…_)(x)) [β‹…]-cancellationα΅£ {𝐒 c}{a}{b} p with [<]-trichotomy {a}{b} ... | [∨]-introβ‚— ([∨]-introβ‚— lt) with () ← [<]-to-[β‰’] ([<]-with-[β‹…]α΅£ {c = c} lt) p ... | [∨]-introβ‚— ([∨]-introα΅£ eq) = eq ... | [∨]-introα΅£ gt with () ← [>]-to-[β‰’] ([<]-with-[β‹…]α΅£ {c = c} gt) p
This is the fourth post in the series β€œ5 Reasons Why a Change Management Strategy Mattersβ€œ A client once implemented a new operating and management philosophy across the entire organization.... Regardless of the extent of the organizational change, it is critical that organizational impact and risk assessments be performed to allow sponsor executives to identify the resources necessary to successfully implement the change effort and to determine the impact of the change on the organization. Learn what you can do to help an organization implement changes after the restructure, or to assess the scope of change as the restructuring initiative is being planned. Learn how to lead and/or support new initiatives through our Collaborative Project Management training .... This often means that organizational reward systems must be altered in some way to support the change that you want to implement. The change does not have to always be major or costly. The change does not have to always be major or costly. Explore these 4 key inter-related components of successful change implementation in organizations. In all organizations, change only happens if and when it is initiated. Successful change implementation cannot happen without these 4 key components. Miss any of these 4 components from the onset of a major change and the change efforts will fail. how to cancel an unpaid item case This often means that organizational reward systems must be altered in some way to support the change that you want to implement. The change does not have to always be major or costly. The change does not have to always be major or costly. Explore these 4 key inter-related components of successful change implementation in organizations. In all organizations, change only happens if and when it is initiated. Successful change implementation cannot happen without these 4 key components. Miss any of these 4 components from the onset of a major change and the change efforts will fail. how to change name of megaboom Learn what you can do to help an organization implement changes after the restructure, or to assess the scope of change as the restructuring initiative is being planned. Learn how to lead and/or support new initiatives through our Collaborative Project Management training . Learn what you can do to help an organization implement changes after the restructure, or to assess the scope of change as the restructuring initiative is being planned. Learn how to lead and/or support new initiatives through our Collaborative Project Management training . This is the fourth post in the series β€œ5 Reasons Why a Change Management Strategy Mattersβ€œ A client once implemented a new operating and management philosophy across the entire organization. Regardless of the extent of the organizational change, it is critical that organizational impact and risk assessments be performed to allow sponsor executives to identify the resources necessary to successfully implement the change effort and to determine the impact of the change on the organization.
TITLE DakotaModel_deterministic; ! Objective value 4165.0 ! line 23 has a syntax error INDEX PRODUCTS := (Desk, Table, Chair); RESOURCES := (Lumber, Finishing, Carpentry); DATA Price[PRODUCTS] := (60, 40, 10); Cost[RESOURCES] := (2, 4, 5.2); Consumption[RESOURCES, PRODUCTS] := (8, 6, 1 4, 2, 1.5 2, 1.5, .5); Demand[PRODUCTS] := (150, 125, 300); INTEGER VARIABLES ProductionPRODUCTS]; VARIABLES Purchase[RESOURCES]; MAX Profit = sum(PRODUCTS: Price * Production) - sum(RESOURCES: Cost * Purchase); SUBJECT TO ResourceConstraint[RESOURCES]: sum(PRODUCTS: Consumption * Production) <= Purchase; DemandConstraint[PRODUCTS]: Production <= Demand; END
lemma smult_content_normalize_primitive_part [simp]: fixes p :: "'a :: {normalization_semidom_multiplicative, semiring_gcd, idom_divide} poly" shows "smult (content p) (normalize (primitive_part p)) = normalize p"
@testset "Controller: MPC flamingo" begin # ## Simulation s = get_simulation("flamingo", "flat_2D_lc", "flat") model = s.model env = s.env # ## Reference Trajectory ref_traj = deepcopy(get_trajectory(s.model, s.env, joinpath(module_dir(), "src/dynamics/flamingo/gaits/gait_forward_36_4.jld2"), load_type = :split_traj_alt)); H = ref_traj.H h = ref_traj.h # ## MPC setup N_sample = 5 H_mpc = 15 h_sim = h / N_sample H_sim = 1000 ΞΊ_mpc = 2.0e-4 obj = TrackingVelocityObjective(model, env, H_mpc, v = [Diagonal(1e-3 * [1e0,1,1e4,1,1,1,1,1e4,1e4]) for t = 1:H_mpc], q = [Diagonal(1e-1 * [3e2, 1e-6, 3e2, 1, 1, 1, 1, 0.1, 0.1]) for t = 1:H_mpc], u = [Diagonal(3e-1 * [0.1; 0.1; 0.3; 0.3; ones(model.nu-6); 2; 2]) for t = 1:H_mpc], Ξ³ = [Diagonal(1.0e-100 * ones(model.nc)) for t = 1:H_mpc], b = [Diagonal(1.0e-100 * ones(model.nc * friction_dim(env))) for t = 1:H_mpc]); p = ci_mpc_policy(deepcopy(ref_traj), s, obj, H_mpc = H_mpc, N_sample = N_sample, ΞΊ_mpc = ΞΊ_mpc, ip_opts = InteriorPointOptions( undercut = 5.0, ΞΊ_tol = ΞΊ_mpc, r_tol = 1.0e-8, diff_sol = true, solver=:empty_solver, max_time = 1e5), n_opts = NewtonOptions( r_tol = 3e-4, max_iter = 5), mpc_opts = CIMPCOptions( altitude_update=false, altitude_impact_threshold=0.02 )); # ## Initial conditions q1_sim, v1_sim = initial_conditions(deepcopy(ref_traj)); # ## Simulator sim = simulator(s, H_sim, h=h_sim, policy=p, solver_opts=InteriorPointOptions( undercut=Inf, Ξ³_reg=0.0, r_tol=1e-8, ΞΊ_tol=1e-8, Ο΅_min=0.05, diff_sol=false, verbose=false)); # ## Simulate status = simulate!(sim, q1_sim, v1_sim); @test status @test norm(sim.traj.q[1] - ref_traj.q[2]*(1-1/N_sample) - ref_traj.q[1]/N_sample) < 1e-8 @test norm(sim.traj.q[2] - ref_traj.q[2]) < 1e-8 @test norm(ref_traj.q[1][2:end] - ref_traj.q[end-1][2:end]) < 1e-8 @test norm(ref_traj.q[2][2:end] - ref_traj.q[end-0][2:end]) < 1e-8 qerr, uerr, Ξ³err, berr = ContactImplicitMPC.tracking_error(deepcopy(ref_traj), sim.traj, N_sample, idx_shift=[1]) @test qerr < 0.0154 * 1.5 # 0.0154 @test uerr < 0.0829 * 1.5 # 0.0829 @test Ξ³err < 0.444 * 1.5 # 0.444 @test berr < 0.0169 * 1.5 # 0.0169 qerr > 0.0154 * 1.2 && @warn "mild regression on q tracking: current tracking error = $qerr, nominal tracking error = 0.0154" uerr > 0.0829 * 1.2 && @warn "mild regression on u tracking: current tracking error = $uerr, nominal tracking error = 0.0829" Ξ³err > 0.4440 * 1.2 && @warn "mild regression on Ξ³ tracking: current tracking error = $Ξ³err, nominal tracking error = 0.444" berr > 0.0169 * 1.2 && @warn "mild regression on b tracking: current tracking error = $berr, nominal tracking error = 0.0169" end
{-# LANGUAGE ApplicativeDo #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE EmptyCase #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE KindSignatures #-} {-# LANGUAGE LambdaCase #-} {-# LANGUAGE PartialTypeSignatures #-} {-# LANGUAGE QuantifiedConstraints #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TupleSections #-} {-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeInType #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE ViewPatterns #-} {-# OPTIONS_GHC -fno-warn-partial-type-signatures #-} {-# OPTIONS_GHC -fplugin GHC.TypeLits.Extra.Solver #-} {-# OPTIONS_GHC -fplugin GHC.TypeLits.KnownNat.Solver #-} import Backprop.Learn import Control.Applicative import Control.DeepSeq import Control.Exception import Control.Monad import Control.Monad.IO.Class import Control.Monad.Primitive import Control.Monad.Trans.Class import Control.Monad.Trans.State import Data.Char import Data.Conduit import Data.Default import Data.Kind import Data.Proxy import Data.Singletons import Data.Singletons.TypeLits import Data.Time import Data.Type.Equality import Data.Type.Tuple import GHC.TypeLits.Compare import GHC.TypeNats import Numeric.LinearAlgebra.Static.Backprop hiding ((<>)) import Numeric.Natural import Numeric.Opto import Options.Applicative import Statistics.Distribution import Statistics.Distribution.Normal import Text.Printf import qualified Data.Conduit.Combinators as C import qualified Data.Vector.Sized as SV import qualified System.Random.MWC as MWC data Mode = CSimulate (Maybe Int) | forall s p. ( Floating s , Floating p , NFData s , NFData p , Metric Double s , Metric Double p , Show s , Show p , Initialize p , Initialize s , Backprop p , Backprop s , forall m. PrimMonad m => LinearInPlace m Double p , forall m. PrimMonad m => LinearInPlace m Double s ) => CLearn (ModelPick p s) data ModelPick :: Type -> Type -> Type where MARIMA :: Sing p -> Sing d -> Sing q -> ModelPick (ARIMAp p q) (ARIMAs p d q) MFCRNN :: Sing h -> ModelPick (LRp h 1 :# LRp (1 + h) h) (R h) MLSTM :: Sing h -> ModelPick (LRp h 1 :# LSTMp 1 h) (R h :# R h) MGRU :: Sing h -> ModelPick (LRp h 1 :# GRUp 1 h) (R h) data Process = PSin modelLearn :: ModelPick p s -> Model ('Just p) ('Just s) Double Double modelLearn = \case MARIMA (SNat :: Sing pp) (SNat :: Sing d) (SNat :: Sing q) -> arima @pp @d @q MFCRNN (SNat :: Sing h) -> funcD sumElements <~ fc <~ fcra logistic logistic <~ funcD konst MLSTM (SNat :: Sing h) -> funcD sumElements <~ fc <~ lstm <~ funcD konst MGRU (SNat :: Sing h) -> funcD sumElements <~ fc <~ gru <~ funcD konst data Options = O { oMode :: Mode , oProcess :: Process , oNoise :: Double , oInterval :: Int , oLookback :: Natural } processConduit :: PrimMonad m => Process -> MWC.Gen (PrimState m) -> ConduitT i Double m () processConduit = \case PSin -> \g -> void . flip (foldr (>=>) pure) (0, 1) . repeat $ \(t, v) -> do dv <- genContVar (normalDistr 0 0.025) g let v' = min 2 . max 0.5 $ v + dv t' = t + v' yield (sin (2 * pi * (1/25) * t)) return (t', v') noisyConduit :: PrimMonad m => Double -> MWC.Gen (PrimState m) -> ConduitT Double Double m () noisyConduit Οƒ g = C.mapM $ \x -> (x + ) <$> genContVar (normalDistr 0 Οƒ) g -- type Context = ConduitT (Vector) main :: IO () main = MWC.withSystemRandom @IO $ \g -> do O{..} <- execParser $ info (parseOpt <**> helper) ( fullDesc <> progDesc "Learning ARIMA" <> header "backprop-learn-arima - backprop-learn demo" ) SomeNat (Proxy :: Proxy n) <- pure $ someNatVal oLookback Just Refl <- pure $ Proxy @1 `isLE` Proxy @n let generator = processConduit oProcess g .| noisyConduit oNoise g case oMode of CSimulate lim -> runConduit $ generator .| maybe (C.map id) C.take lim .| C.mapM_ print .| C.sinkNull CLearn (modelLearn->model) -> do let unrolled = trainState . unrollFinal @(SV.Vector n) $ model p0 <- initParamNormal unrolled 0.2 g let report n b = do liftIO $ printf "(Batch %d)\n" (b :: Int) t0 <- liftIO getCurrentTime C.drop (n - 1) mp <- mapM (liftIO . evaluate . force) =<< await t1 <- liftIO getCurrentTime case mp of Nothing -> liftIO $ putStrLn "Done!" Just p -> do chnk <- lift . state $ (,[]) liftIO $ do printf "Trained on %d points in %s.\n" (length chnk) (show (t1 `diffUTCTime` t0)) let trainScore = testModelAll absErrorTest unrolled (TJust p) chnk printf "Training error: %.8f\n" trainScore report n (b + 1) flip evalStateT [] . runConduit $ transPipe lift generator .| leadings .| skipSampling 0.05 g .| C.iterM (modify . (:)) .| optoConduit def p0 (adam def (modelGrad squaredError noReg unrolled)) .| report oInterval 0 .| C.sinkNull parseOpt :: Parser Options parseOpt = O <$> subparser ( command "simulate" (info (parseSim <**> helper) (progDesc "Simulate ARIMA only")) <> command "learn" (info (parseLearn <**> helper) (progDesc "Simulate and learn model")) ) <*> option (maybeReader parseProcess) ( long "process" <> help "Process to learn" <> showDefaultWith showProcess <> value PSin <> metavar "PROCESS" ) <*> option auto ( short 'e' <> help "Standard deviation of noise term" <> showDefault <> value 0.05 <> metavar "DOUBLE" ) <*> option auto ( long "interval" <> short 'i' <> help "Report interval" <> showDefault <> value 5000 <> metavar "INT" ) <*> option auto ( long "lookback" <> short 'l' <> help "Learn lookback" <> showDefault <> value 10 <> metavar "INT" ) where parseSim :: Parser Mode parseSim = CSimulate <$> optional (option auto ( short 'n' <> help "Number of items to generate (infinite, if none given)" <> metavar "INT" ) ) parseLearn :: Parser Mode parseLearn = subparser ( command "arima" (info parseARIMA (progDesc "Learn ARIMA(p,d,q) model")) <> command "fcrnn" (info parseFCRNN (progDesc "Learn Fully Connected RNN model")) <> command "lstm" (info parseLSTM (progDesc "Learn LSTM model")) <> command "gru" (info parseGRU (progDesc "Learn GRU model")) ) parseARIMA :: Parser Mode parseARIMA = do p <- argument auto ( help "AR(p): Autoregressive lookback" <> metavar "INT" ) d <- argument auto ( help "I(d): Differencing degree" <> metavar "INT" ) q <- argument auto ( help "MA(q): Moving average lookback" <> metavar "INT" ) pure $ withSomeSing @Nat p $ \sp@SNat -> withSomeSing @Nat d $ \sd@SNat -> withSomeSing @Nat q $ \sq@SNat -> CLearn (MARIMA sp sd sq) parseFCRNN :: Parser Mode parseFCRNN = do h <- argument auto ( help "Hidden layer size" <> metavar "INT" <> showDefault <> value 10 ) pure $ withSomeSing @Nat h $ \sh@SNat -> CLearn (MFCRNN sh) parseLSTM :: Parser Mode parseLSTM = do h <- argument auto ( help "Hidden layer size" <> metavar "INT" <> showDefault <> value 10 ) pure $ withSomeSing @Nat h $ \sh@SNat -> CLearn (MLSTM sh) parseGRU :: Parser Mode parseGRU = do h <- argument auto ( help "Hidden layer size" <> metavar "INT" <> showDefault <> value 10 ) pure $ withSomeSing @Nat h $ \sh@SNat -> CLearn (MGRU sh) showProcess :: Process -> String showProcess PSin = "sin" parseProcess :: String -> Maybe Process parseProcess s = case map toLower s of "sin" -> Just PSin _ -> Nothing
ProductionMode <- TRUE ## conditional calculated field: mutate and ddply; see documentation for ddply ## groups: use selectInput with multiple=TRUE and selectize = FALSE ## http://stackoverflow.com/questions/3418128/how-to-convert-a-factor-to-an-integer-numeric-without-a-loss-of-information ## GitHub Hosting example: https://gist.github.com/mattbrehmer/5645155 ## Alternative to ggplot2: https://github.com/ramnathv/rCharts #options(error = browser) # NULL, browser, etc. #options(shiny.error=NULL) if(ProductionMode){ options(shiny.error=NULL) } else { options(shiny.error=function() { ## skip validation errors if(!inherits(eval.parent(expression(e)), "validation")) browser() }) } #options(shiny.trace = FALSE) # change to TRUE for trace #options(shiny.reactlog=TRUE) options(shiny.maxRequestSize = 100*1024^2) # Set the upload limit to 100MB ## see https://groups.google.com/forum/#!topic/shiny-discuss/2wgIG3dOEZI library(grid); library(shiny); library(ggplot2); library(Hmisc); library(uuid); library(tables); library(tools); library(png); library(data.table); library(shinysky); library(shinyBS); require(Cairo) library(knitr); library(rmarkdown); library(shinyAce); library(shinyTree) options(shiny.usecairo=TRUE) MoltenMeasuresName <- 'value' lengthUnique <<- function(x) { length(unique(x)) } YFunChoices <- c('Sum'='sum','Mean'='mean','Median'='median','Min'='min','Max'='max', 'Standard Deviation'='sd','Variance'='var','Count'='length', 'Count (Distinct)'='lengthUnique') AggFunChoicesDimension <- c('Min'='min','Max'='max', 'Count'='length', 'Count (Distinct)'='lengthUnique') InternalY <- '..y..' GeomChoices <- c('Text'='text', 'Bar'='bar','Line'='line', 'Area'='area', 'Point'='point', 'Path'='path', 'Polygon'='polygon', 'Boxplot'='boxplot', 'Density Curve'='density', 'Smoother'='smooth') StatChoices <- c('Identity'='identity','Count'='bin','Summary'='summary','Boxplot'='boxplot','Density'='density', 'Smoother'='smooth') UnitChoices <- c('Normalized Parent Coordinates'='npc', 'Centimeters'='cm', 'Inches'='inches', 'Millimeters'='mm', 'Points'='points', 'Lines of Text'='lines', 'Font Height'='char') getAesChoices <- function(geom, stat='identity'){ switch(geom, 'text'=switch(stat, 'bin'=list('Coordinates'=c('X'='aesX'), 'Common'=c('Label'='aesLabel','Color'='aesColor','Size'='aesSize', 'Shape'='aesShape','Line Type'='aesLineType','Angle'='aesAngle'), 'Color'=c('Alpha'='aesAlpha'), 'Label'=c('Font Family'='aesFamily','Font Face'='aesFontface','Line Height'='aesLineheight'), 'Justification'=c('Horizontal Adjustment'='aesHjust','Vertical Adjustment'='aesVjust') ), 'identity'=list('Coordinates'=c('X'='aesX','Y'='aesY'), 'Common'=c('Label'='aesLabel','Color'='aesColor','Size'='aesSize', 'Shape'='aesShape','Line Type'='aesLineType','Angle'='aesAngle'), 'Color'=c('Alpha'='aesAlpha'), 'Label'=c('Font Family'='aesFamily','Font Face'='aesFontface','Line Height'='aesLineheight'), 'Justification'=c('Horizontal Adjustment'='aesHjust','Vertical Adjustment'='aesVjust') ) ), 'bar'=switch(stat, 'bin'=list('Coordinates'=c('X'='aesX'), 'Common'=c('Color'='aesColor','Size'='aesSize', 'Line Type'='aesLineType','Weight'='aesWeight'), 'Color'=c('Border Color'='aesBorderColor', 'Alpha'='aesAlpha') ), 'identity'=list('Coordinates'=c('X'='aesX','Y'='aesY'), 'Common'=c('Color'='aesColor','Size'='aesSize', 'Line Type'='aesLineType','Weight'='aesWeight'), 'Color'=c('Border Color'='aesBorderColor', 'Alpha'='aesAlpha') ) ), 'line'=switch(stat, 'bin'=list('Coordinates'=c('X'='aesX'), 'Common'=c('Color'='aesColor','Size'='aesSize', 'Line Type'='aesLineType', 'Grouping'='aesGroup'), 'Color'=c('Alpha'='aesAlpha') ), 'identity'=list('Coordinates'=c('X'='aesX','Y'='aesY'), 'Common'=c('Color'='aesColor','Size'='aesSize', 'Line Type'='aesLineType', 'Grouping'='aesGroup'), 'Color'=c('Alpha'='aesAlpha') ), 'density'=list('Coordinates'=c('X'='aesX'), 'Common'=c('Color'='aesColor','Size'='aesSize', 'Line Type'='aesLineType', 'Grouping'='aesGroup'), 'Color'=c('Alpha'='aesAlpha') ) ), 'area'=switch(stat, 'bin'=list('Coordinates'=c('X'='aesX'), 'Common'=c('Color'='aesColor','Size'='aesSize', 'Line Type'='aesLineType'), 'Color'=c('Border Color'='aesBorderColor', 'Alpha'='aesAlpha') ), 'identity'=list('Coordinates'=c('X'='aesX','Y'='aesY'), 'Common'=c('Color'='aesColor','Size'='aesSize', 'Line Type'='aesLineType'), 'Color'=c('Border Color'='aesBorderColor', 'Alpha'='aesAlpha') ), 'density'=list('Coordinates'=c('X'='aesX'), 'Common'=c('Color'='aesColor','Size'='aesSize', 'Line Type'='aesLineType'), 'Color'=c('Border Color'='aesBorderColor', 'Alpha'='aesAlpha') ) ), 'point'=switch(stat, 'bin'=list('Coordinates'=c('X'='aesX'), 'Common'=c('Color'='aesColor','Size'='aesSize', 'Shape'='aesShape'), 'Color'=c('Border Color'='aesBorderColor','Alpha'='aesAlpha') ), 'identity'=list('Coordinates'=c('X'='aesX','Y'='aesY'), 'Common'=c('Color'='aesColor','Size'='aesSize', 'Shape'='aesShape'), 'Color'=c('Border Color'='aesBorderColor','Alpha'='aesAlpha') ) ), 'boxplot'=switch(stat, 'boxplot'=list('Coordinates'=c('X'='aesX','Y'='aesY'), 'Common'=c('Color'='aesColor','Size'='aesSize', 'Shape'='aesShape','Line Type'='aesLineType','Weight'='aesWeight'), 'Color'=c('Border Color'='aesBorderColor', 'Alpha'='aesAlpha') ), 'identity'=list('Coordinates'=c('X'='aesX','Y Middle'='aesMiddle', 'Y Lower'='aesLower','Y Upper'='aesUpper', 'Y Min'='aesYmin','Y Max'='aesYmax'), 'Common'=c('Color'='aesColor','Size'='aesSize', 'Shape'='aesShape','Line Type'='aesLineType','Weight'='aesWeight'), 'Color'=c('Border Color'='aesBorderColor', 'Alpha'='aesAlpha') ) ), 'density'=switch(stat, 'density'=list('Coordinates'=c('X'='aesX'), 'Common'=c('Color'='aesColor','Size'='aesSize', 'Line Type'='aesLineType'), 'Color'=c('Border Color'='aesBorderColor', 'Alpha'='aesAlpha') ) ), 'smooth'=switch(stat, 'smooth'=list('Coordinates'=c('X'='aesX','Y'='aesY'), 'Common'=c('Color'='aesColor','Size'='aesSize', 'Line Type'='aesLineType','Grouping'='aesGroup'), 'Color'=c('Border Color'='aesBorderColor', 'Alpha'='aesAlpha') ) ) ) } AesChoicesSimpleList <- unique(unlist(lapply(GeomChoices, getAesChoices), use.names=FALSE)) extrafontsImported <- (system.file("fontmap/fonttable.csv", package = "extrafontdb")!="") FontFamilyChoices <- c("AvantGarde", "Bookman", "Courier", "Helvetica", "Helvetica-Narrow", "NewCenturySchoolbook", "Palatino", "Times") if(extrafontsImported) FontFamilyChoices <- extrafont::fonts() FontFamilyChoices <- c('Choose'='', FontFamilyChoices) FontFaceChoices <- c('Choose'='', "Plain"="plain","Bold"="bold","Italic"="italic","Bold & Italic"="bold.italic") getLegendLabelPositionChoices <- function(legend.layout.direction){ if(!is.null(legend.layout.direction) && legend.layout.direction=='horizontal') { c('Default'='', 'Top'='top', 'Bottom'='bottom') } else { c('Default'='', 'Left'='left', 'Right'='right') } } brewer.mat <- RColorBrewer::brewer.pal.info palettes.all <- rownames(brewer.mat) BrewerPaletteChoices <- list('Choose'='', 'Sequential'=palettes.all[brewer.mat[,'category']=='seq'], 'Diverging'=palettes.all[brewer.mat[,'category']=='div'], 'Qualitative'=palettes.all[brewer.mat[,'category']=='qual']) source('color.r', local=TRUE)
theory prop_17 imports Main "$HIPSTER_HOME/IsaHipster" begin datatype Nat = Z | S "Nat" fun le :: "Nat => Nat => bool" where "le (Z) y = True" | "le (S z) (Z) = False" | "le (S z) (S x2) = le z x2" fun equal2 :: "Nat => Nat => bool" where "equal2 (Z) (Z) = True" | "equal2 (Z) (S z) = False" | "equal2 (S x2) (Z) = False" | "equal2 (S x2) (S y2) = equal2 x2 y2" (*hipster le equal2 *) theorem x0 : "(le n Z) = (equal2 n Z)" by (tactic \<open>Subgoal.FOCUS_PARAMS (K (Tactic_Data.hard_tac @{context})) @{context} 1\<close>) end
clear all; close all; I=zeros(200, 200); I(50:150, 50:150)=1; theta=0:10:180; [R, xp]=radon(I, theta); figure; subplot(121); imshow(I); subplot(122); imagesc(theta, xp, R); colormap(hot); colorbar;
[STATEMENT] lemma sum_mat_mono_gt: assumes "sd \<le> n" and A: "A \<in> carrier_mat n n" and B: "B \<in> carrier_mat n n" and AB: "mat_gt (\<succ>) sd A (B :: 'a mat)" shows "sum_mat A \<succ> sum_mat B" [PROOF STATE] proof (prove) goal (1 subgoal): 1. sum_mat A \<succ> sum_mat B [PROOF STEP] proof - [PROOF STATE] proof (state) goal (1 subgoal): 1. sum_mat A \<succ> sum_mat B [PROOF STEP] from A B [PROOF STATE] proof (chain) picking this: A \<in> carrier_mat n n B \<in> carrier_mat n n [PROOF STEP] have id: "dim_row B = dim_row A" "dim_col B = dim_col A" [PROOF STATE] proof (prove) using this: A \<in> carrier_mat n n B \<in> carrier_mat n n goal (1 subgoal): 1. dim_row B = dim_row A &&& dim_col B = dim_col A [PROOF STEP] by auto [PROOF STATE] proof (state) this: dim_row B = dim_row A dim_col B = dim_col A goal (1 subgoal): 1. sum_mat A \<succ> sum_mat B [PROOF STEP] from mat_gtD[OF AB] [PROOF STATE] proof (chain) picking this: A \<ge>\<^sub>m B \<exists>i<sd. \<exists>j<sd. A $$ (i, j) \<succ> B $$ (i, j) [PROOF STEP] obtain i j where AB: "A \<ge>\<^sub>m B" and ij: "i < sd" "j < sd" and gt: "A $$ (i,j) \<succ> B $$ (i,j)" [PROOF STATE] proof (prove) using this: A \<ge>\<^sub>m B \<exists>i<sd. \<exists>j<sd. A $$ (i, j) \<succ> B $$ (i, j) goal (1 subgoal): 1. (\<And>i j. \<lbrakk>A \<ge>\<^sub>m B; i < sd; j < sd; A $$ (i, j) \<succ> B $$ (i, j)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis [PROOF STEP] by auto [PROOF STATE] proof (state) this: A \<ge>\<^sub>m B i < sd j < sd A $$ (i, j) \<succ> B $$ (i, j) goal (1 subgoal): 1. sum_mat A \<succ> sum_mat B [PROOF STEP] show ?thesis [PROOF STATE] proof (prove) goal (1 subgoal): 1. sum_mat A \<succ> sum_mat B [PROOF STEP] unfolding sum_mat_def id [PROOF STATE] proof (prove) goal (1 subgoal): 1. sum (($$) A) ({0..<dim_row A} \<times> {0..<dim_col A}) \<succ> sum (($$) B) ({0..<dim_row A} \<times> {0..<dim_col A}) [PROOF STEP] by (rule sum_mono_gt[of _ _ _ "(i,j)"], insert ij gt mat_geD[OF AB] A B \<open>sd \<le> n\<close>, auto) [PROOF STATE] proof (state) this: sum_mat A \<succ> sum_mat B goal: No subgoals! [PROOF STEP] qed
\chapter{TODO APPENDIX NAME} \label{app:} Appendix body
[STATEMENT] lemma combine_lists_notP: assumes "asi rank r cost" and "b \<noteq> []" and "r \<notin> set U" and "U \<noteq> []" and "set (as@U@bs@cs) = \<Union>(set ` Y)" and "distinct (as@U@bs@cs)" and "take 1 (as@U@bs@cs) = [r]" and "forward (as@U@bs@cs)" and "concat (rev ys @ [b]) = bs" and "(\<forall>xs \<in> Y. sublist xs as \<or> sublist xs U \<or> (\<exists>x \<in> set (ys @ [b]). sublist xs x) \<or> sublist xs cs)" and "rank (rev V) \<le> rank (rev U)" and "\<not>(\<exists>x \<in> set U. \<exists>y \<in> set b. x \<rightarrow>\<^sup>+\<^bsub>T\<^esub> y)" and "rank (rev b) < rank (rev V)" and "P = (\<lambda>x. rank (rev x) < rank (rev V))" and "\<forall>x\<in>set ys. \<not>P x" and "\<forall>xs. fwd_sub r Y xs \<longrightarrow> cost (rev (as@U@bs@cs)) \<le> cost (rev xs)" and "\<forall>x \<in> set ys. x \<noteq> []" and "\<forall>x \<in> set ys. forward x" and "forward b" shows "\<forall>x\<in>set (combine_lists_P P b ys). \<not>P x \<and> forward x" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<forall>x\<in>set (combine_lists_P P b ys). \<not> P x \<and> forward x [PROOF STEP] using assms [PROOF STATE] proof (prove) using this: asi rank r cost b \<noteq> [] r \<notin> set U U \<noteq> [] set (as @ U @ bs @ cs) = \<Union> (set ` Y) distinct (as @ U @ bs @ cs) take 1 (as @ U @ bs @ cs) = [r] forward (as @ U @ bs @ cs) concat (rev ys @ [b]) = bs \<forall>xs\<in>Y. sublist xs as \<or> sublist xs U \<or> (\<exists>x\<in>set (ys @ [b]). sublist xs x) \<or> sublist xs cs rank (rev V) \<le> rank (rev U) \<not> (\<exists>x\<in>set U. \<exists>y\<in>set b. x \<rightarrow>\<^sup>+\<^bsub>T\<^esub> y) rank (rev b) < rank (rev V) P = (\<lambda>x. rank (rev x) < rank (rev V)) \<forall>x\<in>set ys. \<not> P x \<forall>xs. fwd_sub r Y xs \<longrightarrow> cost (rev (as @ U @ bs @ cs)) \<le> cost (rev xs) \<forall>x\<in>set ys. x \<noteq> [] Ball (set ys) forward forward b goal (1 subgoal): 1. \<forall>x\<in>set (combine_lists_P P b ys). \<not> P x \<and> forward x [PROOF STEP] proof(induction P b ys rule: combine_lists_P.induct) [PROOF STATE] proof (state) goal (2 subgoals): 1. \<And>uu_ y. \<lbrakk>asi rank r cost; y \<noteq> []; r \<notin> set U; U \<noteq> []; set (as @ U @ bs @ cs) = \<Union> (set ` Y); distinct (as @ U @ bs @ cs); take 1 (as @ U @ bs @ cs) = [r]; forward (as @ U @ bs @ cs); concat (rev [] @ [y]) = bs; \<forall>xs\<in>Y. sublist xs as \<or> sublist xs U \<or> Bex (set ([] @ [y])) (sublist xs) \<or> sublist xs cs; rank (rev V) \<le> rank (rev U); \<not> (\<exists>x\<in>set U. \<exists>y\<in>set y. x \<rightarrow>\<^sup>+\<^bsub>T\<^esub> y); rank (rev y) < rank (rev V); uu_ = (\<lambda>x. rank (rev x) < rank (rev V)); \<forall>x\<in>set []. \<not> uu_ x; \<forall>xs. fwd_sub r Y xs \<longrightarrow> cost (rev (as @ U @ bs @ cs)) \<le> cost (rev xs); \<forall>x\<in>set []. x \<noteq> []; Ball (set []) forward; forward y\<rbrakk> \<Longrightarrow> \<forall>x\<in>set (combine_lists_P uu_ y []). \<not> uu_ x \<and> forward x 2. \<And>P y x xs. \<lbrakk>\<lbrakk>P (x @ y); asi rank r cost; x @ y \<noteq> []; r \<notin> set U; U \<noteq> []; set (as @ U @ bs @ cs) = \<Union> (set ` Y); distinct (as @ U @ bs @ cs); take 1 (as @ U @ bs @ cs) = [r]; forward (as @ U @ bs @ cs); concat (rev xs @ [x @ y]) = bs; \<forall>xsa\<in>Y. sublist xsa as \<or> sublist xsa U \<or> Bex (set (xs @ [x @ y])) (sublist xsa) \<or> sublist xsa cs; rank (rev V) \<le> rank (rev U); \<not> (\<exists>xa\<in>set U. \<exists>y\<in>set (x @ y). xa \<rightarrow>\<^sup>+\<^bsub>T\<^esub> y); rank (rev (x @ y)) < rank (rev V); P = (\<lambda>x. rank (rev x) < rank (rev V)); \<forall>x\<in>set xs. \<not> P x; \<forall>xs. fwd_sub r Y xs \<longrightarrow> cost (rev (as @ U @ bs @ cs)) \<le> cost (rev xs); \<forall>x\<in>set xs. x \<noteq> []; Ball (set xs) forward; forward (x @ y)\<rbrakk> \<Longrightarrow> \<forall>x\<in>set (combine_lists_P P (x @ y) xs). \<not> P x \<and> forward x; asi rank r cost; y \<noteq> []; r \<notin> set U; U \<noteq> []; set (as @ U @ bs @ cs) = \<Union> (set ` Y); distinct (as @ U @ bs @ cs); take 1 (as @ U @ bs @ cs) = [r]; forward (as @ U @ bs @ cs); concat (rev (x # xs) @ [y]) = bs; \<forall>xsa\<in>Y. sublist xsa as \<or> sublist xsa U \<or> Bex (set ((x # xs) @ [y])) (sublist xsa) \<or> sublist xsa cs; rank (rev V) \<le> rank (rev U); \<not> (\<exists>x\<in>set U. \<exists>y\<in>set y. x \<rightarrow>\<^sup>+\<^bsub>T\<^esub> y); rank (rev y) < rank (rev V); P = (\<lambda>x. rank (rev x) < rank (rev V)); \<forall>x\<in>set (x # xs). \<not> P x; \<forall>xs. fwd_sub r Y xs \<longrightarrow> cost (rev (as @ U @ bs @ cs)) \<le> cost (rev xs); \<forall>x\<in>set (x # xs). x \<noteq> []; Ball (set (x # xs)) forward; forward y\<rbrakk> \<Longrightarrow> \<forall>x\<in>set (combine_lists_P P y (x # xs)). \<not> P x \<and> forward x [PROOF STEP] case (1 P b) [PROOF STATE] proof (state) this: asi rank r cost b \<noteq> [] r \<notin> set U U \<noteq> [] set (as @ U @ bs @ cs) = \<Union> (set ` Y) distinct (as @ U @ bs @ cs) take 1 (as @ U @ bs @ cs) = [r] forward (as @ U @ bs @ cs) concat (rev [] @ [b]) = bs \<forall>xs\<in>Y. sublist xs as \<or> sublist xs U \<or> (\<exists>a\<in>set ([] @ [b]). sublist xs a) \<or> sublist xs cs rank (rev V) \<le> rank (rev U) \<not> (\<exists>x\<in>set U. \<exists>y\<in>set b. x \<rightarrow>\<^sup>+\<^bsub>T\<^esub> y) rank (rev b) < rank (rev V) P = (\<lambda>x. rank (rev x) < rank (rev V)) \<forall>x\<in>set []. \<not> P x \<forall>xs. fwd_sub r Y xs \<longrightarrow> cost (rev (as @ U @ bs @ cs)) \<le> cost (rev xs) \<forall>x\<in>set []. x \<noteq> [] Ball (set []) forward forward b goal (2 subgoals): 1. \<And>uu_ y. \<lbrakk>asi rank r cost; y \<noteq> []; r \<notin> set U; U \<noteq> []; set (as @ U @ bs @ cs) = \<Union> (set ` Y); distinct (as @ U @ bs @ cs); take 1 (as @ U @ bs @ cs) = [r]; forward (as @ U @ bs @ cs); concat (rev [] @ [y]) = bs; \<forall>xs\<in>Y. sublist xs as \<or> sublist xs U \<or> Bex (set ([] @ [y])) (sublist xs) \<or> sublist xs cs; rank (rev V) \<le> rank (rev U); \<not> (\<exists>x\<in>set U. \<exists>y\<in>set y. x \<rightarrow>\<^sup>+\<^bsub>T\<^esub> y); rank (rev y) < rank (rev V); uu_ = (\<lambda>x. rank (rev x) < rank (rev V)); \<forall>x\<in>set []. \<not> uu_ x; \<forall>xs. fwd_sub r Y xs \<longrightarrow> cost (rev (as @ U @ bs @ cs)) \<le> cost (rev xs); \<forall>x\<in>set []. x \<noteq> []; Ball (set []) forward; forward y\<rbrakk> \<Longrightarrow> \<forall>x\<in>set (combine_lists_P uu_ y []). \<not> uu_ x \<and> forward x 2. \<And>P y x xs. \<lbrakk>\<lbrakk>P (x @ y); asi rank r cost; x @ y \<noteq> []; r \<notin> set U; U \<noteq> []; set (as @ U @ bs @ cs) = \<Union> (set ` Y); distinct (as @ U @ bs @ cs); take 1 (as @ U @ bs @ cs) = [r]; forward (as @ U @ bs @ cs); concat (rev xs @ [x @ y]) = bs; \<forall>xsa\<in>Y. sublist xsa as \<or> sublist xsa U \<or> Bex (set (xs @ [x @ y])) (sublist xsa) \<or> sublist xsa cs; rank (rev V) \<le> rank (rev U); \<not> (\<exists>xa\<in>set U. \<exists>y\<in>set (x @ y). xa \<rightarrow>\<^sup>+\<^bsub>T\<^esub> y); rank (rev (x @ y)) < rank (rev V); P = (\<lambda>x. rank (rev x) < rank (rev V)); \<forall>x\<in>set xs. \<not> P x; \<forall>xs. fwd_sub r Y xs \<longrightarrow> cost (rev (as @ U @ bs @ cs)) \<le> cost (rev xs); \<forall>x\<in>set xs. x \<noteq> []; Ball (set xs) forward; forward (x @ y)\<rbrakk> \<Longrightarrow> \<forall>x\<in>set (combine_lists_P P (x @ y) xs). \<not> P x \<and> forward x; asi rank r cost; y \<noteq> []; r \<notin> set U; U \<noteq> []; set (as @ U @ bs @ cs) = \<Union> (set ` Y); distinct (as @ U @ bs @ cs); take 1 (as @ U @ bs @ cs) = [r]; forward (as @ U @ bs @ cs); concat (rev (x # xs) @ [y]) = bs; \<forall>xsa\<in>Y. sublist xsa as \<or> sublist xsa U \<or> Bex (set ((x # xs) @ [y])) (sublist xsa) \<or> sublist xsa cs; rank (rev V) \<le> rank (rev U); \<not> (\<exists>x\<in>set U. \<exists>y\<in>set y. x \<rightarrow>\<^sup>+\<^bsub>T\<^esub> y); rank (rev y) < rank (rev V); P = (\<lambda>x. rank (rev x) < rank (rev V)); \<forall>x\<in>set (x # xs). \<not> P x; \<forall>xs. fwd_sub r Y xs \<longrightarrow> cost (rev (as @ U @ bs @ cs)) \<le> cost (rev xs); \<forall>x\<in>set (x # xs). x \<noteq> []; Ball (set (x # xs)) forward; forward y\<rbrakk> \<Longrightarrow> \<forall>x\<in>set (combine_lists_P P y (x # xs)). \<not> P x \<and> forward x [PROOF STEP] have 0: "concat (b#[]) = bs" [PROOF STATE] proof (prove) goal (1 subgoal): 1. concat [b] = bs [PROOF STEP] using "1.prems"(9) [PROOF STATE] proof (prove) using this: concat (rev [] @ [b]) = bs goal (1 subgoal): 1. concat [b] = bs [PROOF STEP] by simp [PROOF STATE] proof (state) this: concat [b] = bs goal (2 subgoals): 1. \<And>uu_ y. \<lbrakk>asi rank r cost; y \<noteq> []; r \<notin> set U; U \<noteq> []; set (as @ U @ bs @ cs) = \<Union> (set ` Y); distinct (as @ U @ bs @ cs); take 1 (as @ U @ bs @ cs) = [r]; forward (as @ U @ bs @ cs); concat (rev [] @ [y]) = bs; \<forall>xs\<in>Y. sublist xs as \<or> sublist xs U \<or> Bex (set ([] @ [y])) (sublist xs) \<or> sublist xs cs; rank (rev V) \<le> rank (rev U); \<not> (\<exists>x\<in>set U. \<exists>y\<in>set y. x \<rightarrow>\<^sup>+\<^bsub>T\<^esub> y); rank (rev y) < rank (rev V); uu_ = (\<lambda>x. rank (rev x) < rank (rev V)); \<forall>x\<in>set []. \<not> uu_ x; \<forall>xs. fwd_sub r Y xs \<longrightarrow> cost (rev (as @ U @ bs @ cs)) \<le> cost (rev xs); \<forall>x\<in>set []. x \<noteq> []; Ball (set []) forward; forward y\<rbrakk> \<Longrightarrow> \<forall>x\<in>set (combine_lists_P uu_ y []). \<not> uu_ x \<and> forward x 2. \<And>P y x xs. \<lbrakk>\<lbrakk>P (x @ y); asi rank r cost; x @ y \<noteq> []; r \<notin> set U; U \<noteq> []; set (as @ U @ bs @ cs) = \<Union> (set ` Y); distinct (as @ U @ bs @ cs); take 1 (as @ U @ bs @ cs) = [r]; forward (as @ U @ bs @ cs); concat (rev xs @ [x @ y]) = bs; \<forall>xsa\<in>Y. sublist xsa as \<or> sublist xsa U \<or> Bex (set (xs @ [x @ y])) (sublist xsa) \<or> sublist xsa cs; rank (rev V) \<le> rank (rev U); \<not> (\<exists>xa\<in>set U. \<exists>y\<in>set (x @ y). xa \<rightarrow>\<^sup>+\<^bsub>T\<^esub> y); rank (rev (x @ y)) < rank (rev V); P = (\<lambda>x. rank (rev x) < rank (rev V)); \<forall>x\<in>set xs. \<not> P x; \<forall>xs. fwd_sub r Y xs \<longrightarrow> cost (rev (as @ U @ bs @ cs)) \<le> cost (rev xs); \<forall>x\<in>set xs. x \<noteq> []; Ball (set xs) forward; forward (x @ y)\<rbrakk> \<Longrightarrow> \<forall>x\<in>set (combine_lists_P P (x @ y) xs). \<not> P x \<and> forward x; asi rank r cost; y \<noteq> []; r \<notin> set U; U \<noteq> []; set (as @ U @ bs @ cs) = \<Union> (set ` Y); distinct (as @ U @ bs @ cs); take 1 (as @ U @ bs @ cs) = [r]; forward (as @ U @ bs @ cs); concat (rev (x # xs) @ [y]) = bs; \<forall>xsa\<in>Y. sublist xsa as \<or> sublist xsa U \<or> Bex (set ((x # xs) @ [y])) (sublist xsa) \<or> sublist xsa cs; rank (rev V) \<le> rank (rev U); \<not> (\<exists>x\<in>set U. \<exists>y\<in>set y. x \<rightarrow>\<^sup>+\<^bsub>T\<^esub> y); rank (rev y) < rank (rev V); P = (\<lambda>x. rank (rev x) < rank (rev V)); \<forall>x\<in>set (x # xs). \<not> P x; \<forall>xs. fwd_sub r Y xs \<longrightarrow> cost (rev (as @ U @ bs @ cs)) \<le> cost (rev xs); \<forall>x\<in>set (x # xs). x \<noteq> []; Ball (set (x # xs)) forward; forward y\<rbrakk> \<Longrightarrow> \<forall>x\<in>set (combine_lists_P P y (x # xs)). \<not> P x \<and> forward x [PROOF STEP] have 2: "(\<forall>xs \<in> Y. sublist xs as \<or> sublist xs U \<or> (\<exists>x \<in> set ([b]). sublist xs x) \<or> sublist xs cs)" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<forall>xs\<in>Y. sublist xs as \<or> sublist xs U \<or> (\<exists>x\<in>set [b]. sublist xs x) \<or> sublist xs cs [PROOF STEP] using "1.prems"(10) [PROOF STATE] proof (prove) using this: \<forall>xs\<in>Y. sublist xs as \<or> sublist xs U \<or> (\<exists>a\<in>set ([] @ [b]). sublist xs a) \<or> sublist xs cs goal (1 subgoal): 1. \<forall>xs\<in>Y. sublist xs as \<or> sublist xs U \<or> (\<exists>x\<in>set [b]. sublist xs x) \<or> sublist xs cs [PROOF STEP] by simp [PROOF STATE] proof (state) this: \<forall>xs\<in>Y. sublist xs as \<or> sublist xs U \<or> (\<exists>x\<in>set [b]. sublist xs x) \<or> sublist xs cs goal (2 subgoals): 1. \<And>uu_ y. \<lbrakk>asi rank r cost; y \<noteq> []; r \<notin> set U; U \<noteq> []; set (as @ U @ bs @ cs) = \<Union> (set ` Y); distinct (as @ U @ bs @ cs); take 1 (as @ U @ bs @ cs) = [r]; forward (as @ U @ bs @ cs); concat (rev [] @ [y]) = bs; \<forall>xs\<in>Y. sublist xs as \<or> sublist xs U \<or> Bex (set ([] @ [y])) (sublist xs) \<or> sublist xs cs; rank (rev V) \<le> rank (rev U); \<not> (\<exists>x\<in>set U. \<exists>y\<in>set y. x \<rightarrow>\<^sup>+\<^bsub>T\<^esub> y); rank (rev y) < rank (rev V); uu_ = (\<lambda>x. rank (rev x) < rank (rev V)); \<forall>x\<in>set []. \<not> uu_ x; \<forall>xs. fwd_sub r Y xs \<longrightarrow> cost (rev (as @ U @ bs @ cs)) \<le> cost (rev xs); \<forall>x\<in>set []. x \<noteq> []; Ball (set []) forward; forward y\<rbrakk> \<Longrightarrow> \<forall>x\<in>set (combine_lists_P uu_ y []). \<not> uu_ x \<and> forward x 2. \<And>P y x xs. \<lbrakk>\<lbrakk>P (x @ y); asi rank r cost; x @ y \<noteq> []; r \<notin> set U; U \<noteq> []; set (as @ U @ bs @ cs) = \<Union> (set ` Y); distinct (as @ U @ bs @ cs); take 1 (as @ U @ bs @ cs) = [r]; forward (as @ U @ bs @ cs); concat (rev xs @ [x @ y]) = bs; \<forall>xsa\<in>Y. sublist xsa as \<or> sublist xsa U \<or> Bex (set (xs @ [x @ y])) (sublist xsa) \<or> sublist xsa cs; rank (rev V) \<le> rank (rev U); \<not> (\<exists>xa\<in>set U. \<exists>y\<in>set (x @ y). xa \<rightarrow>\<^sup>+\<^bsub>T\<^esub> y); rank (rev (x @ y)) < rank (rev V); P = (\<lambda>x. rank (rev x) < rank (rev V)); \<forall>x\<in>set xs. \<not> P x; \<forall>xs. fwd_sub r Y xs \<longrightarrow> cost (rev (as @ U @ bs @ cs)) \<le> cost (rev xs); \<forall>x\<in>set xs. x \<noteq> []; Ball (set xs) forward; forward (x @ y)\<rbrakk> \<Longrightarrow> \<forall>x\<in>set (combine_lists_P P (x @ y) xs). \<not> P x \<and> forward x; asi rank r cost; y \<noteq> []; r \<notin> set U; U \<noteq> []; set (as @ U @ bs @ cs) = \<Union> (set ` Y); distinct (as @ U @ bs @ cs); take 1 (as @ U @ bs @ cs) = [r]; forward (as @ U @ bs @ cs); concat (rev (x # xs) @ [y]) = bs; \<forall>xsa\<in>Y. sublist xsa as \<or> sublist xsa U \<or> Bex (set ((x # xs) @ [y])) (sublist xsa) \<or> sublist xsa cs; rank (rev V) \<le> rank (rev U); \<not> (\<exists>x\<in>set U. \<exists>y\<in>set y. x \<rightarrow>\<^sup>+\<^bsub>T\<^esub> y); rank (rev y) < rank (rev V); P = (\<lambda>x. rank (rev x) < rank (rev V)); \<forall>x\<in>set (x # xs). \<not> P x; \<forall>xs. fwd_sub r Y xs \<longrightarrow> cost (rev (as @ U @ bs @ cs)) \<le> cost (rev xs); \<forall>x\<in>set (x # xs). x \<noteq> []; Ball (set (x # xs)) forward; forward y\<rbrakk> \<Longrightarrow> \<forall>x\<in>set (combine_lists_P P y (x # xs)). \<not> P x \<and> forward x [PROOF STEP] have 3: "\<not> (\<exists>x\<in>set U. \<exists>y\<in>set b. x \<rightarrow>\<^bsub>T\<^esub> y)" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<not> (\<exists>x\<in>set U. \<exists>y\<in>set b. x \<rightarrow>\<^bsub>T\<^esub> y) [PROOF STEP] using "1.prems"(12) [PROOF STATE] proof (prove) using this: \<not> (\<exists>x\<in>set U. \<exists>y\<in>set b. x \<rightarrow>\<^sup>+\<^bsub>T\<^esub> y) goal (1 subgoal): 1. \<not> (\<exists>x\<in>set U. \<exists>y\<in>set b. x \<rightarrow>\<^bsub>T\<^esub> y) [PROOF STEP] by blast [PROOF STATE] proof (state) this: \<not> (\<exists>x\<in>set U. \<exists>y\<in>set b. x \<rightarrow>\<^bsub>T\<^esub> y) goal (2 subgoals): 1. \<And>uu_ y. \<lbrakk>asi rank r cost; y \<noteq> []; r \<notin> set U; U \<noteq> []; set (as @ U @ bs @ cs) = \<Union> (set ` Y); distinct (as @ U @ bs @ cs); take 1 (as @ U @ bs @ cs) = [r]; forward (as @ U @ bs @ cs); concat (rev [] @ [y]) = bs; \<forall>xs\<in>Y. sublist xs as \<or> sublist xs U \<or> Bex (set ([] @ [y])) (sublist xs) \<or> sublist xs cs; rank (rev V) \<le> rank (rev U); \<not> (\<exists>x\<in>set U. \<exists>y\<in>set y. x \<rightarrow>\<^sup>+\<^bsub>T\<^esub> y); rank (rev y) < rank (rev V); uu_ = (\<lambda>x. rank (rev x) < rank (rev V)); \<forall>x\<in>set []. \<not> uu_ x; \<forall>xs. fwd_sub r Y xs \<longrightarrow> cost (rev (as @ U @ bs @ cs)) \<le> cost (rev xs); \<forall>x\<in>set []. x \<noteq> []; Ball (set []) forward; forward y\<rbrakk> \<Longrightarrow> \<forall>x\<in>set (combine_lists_P uu_ y []). \<not> uu_ x \<and> forward x 2. \<And>P y x xs. \<lbrakk>\<lbrakk>P (x @ y); asi rank r cost; x @ y \<noteq> []; r \<notin> set U; U \<noteq> []; set (as @ U @ bs @ cs) = \<Union> (set ` Y); distinct (as @ U @ bs @ cs); take 1 (as @ U @ bs @ cs) = [r]; forward (as @ U @ bs @ cs); concat (rev xs @ [x @ y]) = bs; \<forall>xsa\<in>Y. sublist xsa as \<or> sublist xsa U \<or> Bex (set (xs @ [x @ y])) (sublist xsa) \<or> sublist xsa cs; rank (rev V) \<le> rank (rev U); \<not> (\<exists>xa\<in>set U. \<exists>y\<in>set (x @ y). xa \<rightarrow>\<^sup>+\<^bsub>T\<^esub> y); rank (rev (x @ y)) < rank (rev V); P = (\<lambda>x. rank (rev x) < rank (rev V)); \<forall>x\<in>set xs. \<not> P x; \<forall>xs. fwd_sub r Y xs \<longrightarrow> cost (rev (as @ U @ bs @ cs)) \<le> cost (rev xs); \<forall>x\<in>set xs. x \<noteq> []; Ball (set xs) forward; forward (x @ y)\<rbrakk> \<Longrightarrow> \<forall>x\<in>set (combine_lists_P P (x @ y) xs). \<not> P x \<and> forward x; asi rank r cost; y \<noteq> []; r \<notin> set U; U \<noteq> []; set (as @ U @ bs @ cs) = \<Union> (set ` Y); distinct (as @ U @ bs @ cs); take 1 (as @ U @ bs @ cs) = [r]; forward (as @ U @ bs @ cs); concat (rev (x # xs) @ [y]) = bs; \<forall>xsa\<in>Y. sublist xsa as \<or> sublist xsa U \<or> Bex (set ((x # xs) @ [y])) (sublist xsa) \<or> sublist xsa cs; rank (rev V) \<le> rank (rev U); \<not> (\<exists>x\<in>set U. \<exists>y\<in>set y. x \<rightarrow>\<^sup>+\<^bsub>T\<^esub> y); rank (rev y) < rank (rev V); P = (\<lambda>x. rank (rev x) < rank (rev V)); \<forall>x\<in>set (x # xs). \<not> P x; \<forall>xs. fwd_sub r Y xs \<longrightarrow> cost (rev (as @ U @ bs @ cs)) \<le> cost (rev xs); \<forall>x\<in>set (x # xs). x \<noteq> []; Ball (set (x # xs)) forward; forward y\<rbrakk> \<Longrightarrow> \<forall>x\<in>set (combine_lists_P P y (x # xs)). \<not> P x \<and> forward x [PROOF STEP] show ?case [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<forall>x\<in>set (combine_lists_P P b []). \<not> P x \<and> forward x [PROOF STEP] using cost_decr_if_noarc_lessrank'[OF 1(1-8) 0 2 3 1(13,11)] 1(16) [PROOF STATE] proof (prove) using this: fwd_sub r Y (as @ b @ U @ concat [] @ cs) \<and> cost (rev (as @ b @ U @ concat [] @ cs)) < cost (rev (as @ U @ bs @ cs)) \<forall>xs. fwd_sub r Y xs \<longrightarrow> cost (rev (as @ U @ bs @ cs)) \<le> cost (rev xs) goal (1 subgoal): 1. \<forall>x\<in>set (combine_lists_P P b []). \<not> P x \<and> forward x [PROOF STEP] by auto [PROOF STATE] proof (state) this: \<forall>x\<in>set (combine_lists_P P b []). \<not> P x \<and> forward x goal (1 subgoal): 1. \<And>P y x xs. \<lbrakk>\<lbrakk>P (x @ y); asi rank r cost; x @ y \<noteq> []; r \<notin> set U; U \<noteq> []; set (as @ U @ bs @ cs) = \<Union> (set ` Y); distinct (as @ U @ bs @ cs); take 1 (as @ U @ bs @ cs) = [r]; forward (as @ U @ bs @ cs); concat (rev xs @ [x @ y]) = bs; \<forall>xsa\<in>Y. sublist xsa as \<or> sublist xsa U \<or> Bex (set (xs @ [x @ y])) (sublist xsa) \<or> sublist xsa cs; rank (rev V) \<le> rank (rev U); \<not> (\<exists>xa\<in>set U. \<exists>y\<in>set (x @ y). xa \<rightarrow>\<^sup>+\<^bsub>T\<^esub> y); rank (rev (x @ y)) < rank (rev V); P = (\<lambda>x. rank (rev x) < rank (rev V)); \<forall>x\<in>set xs. \<not> P x; \<forall>xs. fwd_sub r Y xs \<longrightarrow> cost (rev (as @ U @ bs @ cs)) \<le> cost (rev xs); \<forall>x\<in>set xs. x \<noteq> []; Ball (set xs) forward; forward (x @ y)\<rbrakk> \<Longrightarrow> \<forall>x\<in>set (combine_lists_P P (x @ y) xs). \<not> P x \<and> forward x; asi rank r cost; y \<noteq> []; r \<notin> set U; U \<noteq> []; set (as @ U @ bs @ cs) = \<Union> (set ` Y); distinct (as @ U @ bs @ cs); take 1 (as @ U @ bs @ cs) = [r]; forward (as @ U @ bs @ cs); concat (rev (x # xs) @ [y]) = bs; \<forall>xsa\<in>Y. sublist xsa as \<or> sublist xsa U \<or> Bex (set ((x # xs) @ [y])) (sublist xsa) \<or> sublist xsa cs; rank (rev V) \<le> rank (rev U); \<not> (\<exists>x\<in>set U. \<exists>y\<in>set y. x \<rightarrow>\<^sup>+\<^bsub>T\<^esub> y); rank (rev y) < rank (rev V); P = (\<lambda>x. rank (rev x) < rank (rev V)); \<forall>x\<in>set (x # xs). \<not> P x; \<forall>xs. fwd_sub r Y xs \<longrightarrow> cost (rev (as @ U @ bs @ cs)) \<le> cost (rev xs); \<forall>x\<in>set (x # xs). x \<noteq> []; Ball (set (x # xs)) forward; forward y\<rbrakk> \<Longrightarrow> \<forall>x\<in>set (combine_lists_P P y (x # xs)). \<not> P x \<and> forward x [PROOF STEP] next [PROOF STATE] proof (state) goal (1 subgoal): 1. \<And>P y x xs. \<lbrakk>\<lbrakk>P (x @ y); asi rank r cost; x @ y \<noteq> []; r \<notin> set U; U \<noteq> []; set (as @ U @ bs @ cs) = \<Union> (set ` Y); distinct (as @ U @ bs @ cs); take 1 (as @ U @ bs @ cs) = [r]; forward (as @ U @ bs @ cs); concat (rev xs @ [x @ y]) = bs; \<forall>xsa\<in>Y. sublist xsa as \<or> sublist xsa U \<or> Bex (set (xs @ [x @ y])) (sublist xsa) \<or> sublist xsa cs; rank (rev V) \<le> rank (rev U); \<not> (\<exists>xa\<in>set U. \<exists>y\<in>set (x @ y). xa \<rightarrow>\<^sup>+\<^bsub>T\<^esub> y); rank (rev (x @ y)) < rank (rev V); P = (\<lambda>x. rank (rev x) < rank (rev V)); \<forall>x\<in>set xs. \<not> P x; \<forall>xs. fwd_sub r Y xs \<longrightarrow> cost (rev (as @ U @ bs @ cs)) \<le> cost (rev xs); \<forall>x\<in>set xs. x \<noteq> []; Ball (set xs) forward; forward (x @ y)\<rbrakk> \<Longrightarrow> \<forall>x\<in>set (combine_lists_P P (x @ y) xs). \<not> P x \<and> forward x; asi rank r cost; y \<noteq> []; r \<notin> set U; U \<noteq> []; set (as @ U @ bs @ cs) = \<Union> (set ` Y); distinct (as @ U @ bs @ cs); take 1 (as @ U @ bs @ cs) = [r]; forward (as @ U @ bs @ cs); concat (rev (x # xs) @ [y]) = bs; \<forall>xsa\<in>Y. sublist xsa as \<or> sublist xsa U \<or> Bex (set ((x # xs) @ [y])) (sublist xsa) \<or> sublist xsa cs; rank (rev V) \<le> rank (rev U); \<not> (\<exists>x\<in>set U. \<exists>y\<in>set y. x \<rightarrow>\<^sup>+\<^bsub>T\<^esub> y); rank (rev y) < rank (rev V); P = (\<lambda>x. rank (rev x) < rank (rev V)); \<forall>x\<in>set (x # xs). \<not> P x; \<forall>xs. fwd_sub r Y xs \<longrightarrow> cost (rev (as @ U @ bs @ cs)) \<le> cost (rev xs); \<forall>x\<in>set (x # xs). x \<noteq> []; Ball (set (x # xs)) forward; forward y\<rbrakk> \<Longrightarrow> \<forall>x\<in>set (combine_lists_P P y (x # xs)). \<not> P x \<and> forward x [PROOF STEP] case (2 P b x xs) [PROOF STATE] proof (state) this: \<lbrakk>P (x @ b); asi rank r cost; x @ b \<noteq> []; r \<notin> set U; U \<noteq> []; set (as @ U @ bs @ cs) = \<Union> (set ` Y); distinct (as @ U @ bs @ cs); take 1 (as @ U @ bs @ cs) = [r]; forward (as @ U @ bs @ cs); concat (rev xs @ [x @ b]) = bs; \<forall>xsa\<in>Y. sublist xsa as \<or> sublist xsa U \<or> (\<exists>a\<in>set (xs @ [x @ b]). sublist xsa a) \<or> sublist xsa cs; rank (rev V) \<le> rank (rev U); \<not> (\<exists>xa\<in>set U. \<exists>y\<in>set (x @ b). xa \<rightarrow>\<^sup>+\<^bsub>T\<^esub> y); rank (rev (x @ b)) < rank (rev V); P = (\<lambda>x. rank (rev x) < rank (rev V)); \<forall>x\<in>set xs. \<not> P x; \<forall>xs. fwd_sub r Y xs \<longrightarrow> cost (rev (as @ U @ bs @ cs)) \<le> cost (rev xs); \<forall>x\<in>set xs. x \<noteq> []; Ball (set xs) forward; forward (x @ b)\<rbrakk> \<Longrightarrow> \<forall>x\<in>set (combine_lists_P P (x @ b) xs). \<not> P x \<and> forward x asi rank r cost b \<noteq> [] r \<notin> set U U \<noteq> [] set (as @ U @ bs @ cs) = \<Union> (set ` Y) distinct (as @ U @ bs @ cs) take 1 (as @ U @ bs @ cs) = [r] forward (as @ U @ bs @ cs) concat (rev (x # xs) @ [b]) = bs \<forall>xsa\<in>Y. sublist xsa as \<or> sublist xsa U \<or> (\<exists>a\<in>set ((x # xs) @ [b]). sublist xsa a) \<or> sublist xsa cs rank (rev V) \<le> rank (rev U) \<not> (\<exists>x\<in>set U. \<exists>y\<in>set b. x \<rightarrow>\<^sup>+\<^bsub>T\<^esub> y) rank (rev b) < rank (rev V) P = (\<lambda>x. rank (rev x) < rank (rev V)) \<forall>x\<in>set (x # xs). \<not> P x \<forall>xs. fwd_sub r Y xs \<longrightarrow> cost (rev (as @ U @ bs @ cs)) \<le> cost (rev xs) \<forall>x\<in>set (x # xs). x \<noteq> [] Ball (set (x # xs)) forward forward b goal (1 subgoal): 1. \<And>P y x xs. \<lbrakk>\<lbrakk>P (x @ y); asi rank r cost; x @ y \<noteq> []; r \<notin> set U; U \<noteq> []; set (as @ U @ bs @ cs) = \<Union> (set ` Y); distinct (as @ U @ bs @ cs); take 1 (as @ U @ bs @ cs) = [r]; forward (as @ U @ bs @ cs); concat (rev xs @ [x @ y]) = bs; \<forall>xsa\<in>Y. sublist xsa as \<or> sublist xsa U \<or> Bex (set (xs @ [x @ y])) (sublist xsa) \<or> sublist xsa cs; rank (rev V) \<le> rank (rev U); \<not> (\<exists>xa\<in>set U. \<exists>y\<in>set (x @ y). xa \<rightarrow>\<^sup>+\<^bsub>T\<^esub> y); rank (rev (x @ y)) < rank (rev V); P = (\<lambda>x. rank (rev x) < rank (rev V)); \<forall>x\<in>set xs. \<not> P x; \<forall>xs. fwd_sub r Y xs \<longrightarrow> cost (rev (as @ U @ bs @ cs)) \<le> cost (rev xs); \<forall>x\<in>set xs. x \<noteq> []; Ball (set xs) forward; forward (x @ y)\<rbrakk> \<Longrightarrow> \<forall>x\<in>set (combine_lists_P P (x @ y) xs). \<not> P x \<and> forward x; asi rank r cost; y \<noteq> []; r \<notin> set U; U \<noteq> []; set (as @ U @ bs @ cs) = \<Union> (set ` Y); distinct (as @ U @ bs @ cs); take 1 (as @ U @ bs @ cs) = [r]; forward (as @ U @ bs @ cs); concat (rev (x # xs) @ [y]) = bs; \<forall>xsa\<in>Y. sublist xsa as \<or> sublist xsa U \<or> Bex (set ((x # xs) @ [y])) (sublist xsa) \<or> sublist xsa cs; rank (rev V) \<le> rank (rev U); \<not> (\<exists>x\<in>set U. \<exists>y\<in>set y. x \<rightarrow>\<^sup>+\<^bsub>T\<^esub> y); rank (rev y) < rank (rev V); P = (\<lambda>x. rank (rev x) < rank (rev V)); \<forall>x\<in>set (x # xs). \<not> P x; \<forall>xs. fwd_sub r Y xs \<longrightarrow> cost (rev (as @ U @ bs @ cs)) \<le> cost (rev xs); \<forall>x\<in>set (x # xs). x \<noteq> []; Ball (set (x # xs)) forward; forward y\<rbrakk> \<Longrightarrow> \<forall>x\<in>set (combine_lists_P P y (x # xs)). \<not> P x \<and> forward x [PROOF STEP] have "take 1 as = [r]" [PROOF STATE] proof (prove) goal (1 subgoal): 1. take 1 as = [r] [PROOF STEP] using "2.prems"(3,4,7) take1_split_nelem_nempty [PROOF STATE] proof (prove) using this: r \<notin> set U U \<noteq> [] take 1 (as @ U @ bs @ cs) = [r] \<lbrakk>take 1 (?xs @ ?ys @ ?zs) = [?r]; ?ys \<noteq> []; ?r \<notin> set ?ys\<rbrakk> \<Longrightarrow> take 1 ?xs = [?r] goal (1 subgoal): 1. take 1 as = [r] [PROOF STEP] by fast [PROOF STATE] proof (state) this: take 1 as = [r] goal (1 subgoal): 1. \<And>P y x xs. \<lbrakk>\<lbrakk>P (x @ y); asi rank r cost; x @ y \<noteq> []; r \<notin> set U; U \<noteq> []; set (as @ U @ bs @ cs) = \<Union> (set ` Y); distinct (as @ U @ bs @ cs); take 1 (as @ U @ bs @ cs) = [r]; forward (as @ U @ bs @ cs); concat (rev xs @ [x @ y]) = bs; \<forall>xsa\<in>Y. sublist xsa as \<or> sublist xsa U \<or> Bex (set (xs @ [x @ y])) (sublist xsa) \<or> sublist xsa cs; rank (rev V) \<le> rank (rev U); \<not> (\<exists>xa\<in>set U. \<exists>y\<in>set (x @ y). xa \<rightarrow>\<^sup>+\<^bsub>T\<^esub> y); rank (rev (x @ y)) < rank (rev V); P = (\<lambda>x. rank (rev x) < rank (rev V)); \<forall>x\<in>set xs. \<not> P x; \<forall>xs. fwd_sub r Y xs \<longrightarrow> cost (rev (as @ U @ bs @ cs)) \<le> cost (rev xs); \<forall>x\<in>set xs. x \<noteq> []; Ball (set xs) forward; forward (x @ y)\<rbrakk> \<Longrightarrow> \<forall>x\<in>set (combine_lists_P P (x @ y) xs). \<not> P x \<and> forward x; asi rank r cost; y \<noteq> []; r \<notin> set U; U \<noteq> []; set (as @ U @ bs @ cs) = \<Union> (set ` Y); distinct (as @ U @ bs @ cs); take 1 (as @ U @ bs @ cs) = [r]; forward (as @ U @ bs @ cs); concat (rev (x # xs) @ [y]) = bs; \<forall>xsa\<in>Y. sublist xsa as \<or> sublist xsa U \<or> Bex (set ((x # xs) @ [y])) (sublist xsa) \<or> sublist xsa cs; rank (rev V) \<le> rank (rev U); \<not> (\<exists>x\<in>set U. \<exists>y\<in>set y. x \<rightarrow>\<^sup>+\<^bsub>T\<^esub> y); rank (rev y) < rank (rev V); P = (\<lambda>x. rank (rev x) < rank (rev V)); \<forall>x\<in>set (x # xs). \<not> P x; \<forall>xs. fwd_sub r Y xs \<longrightarrow> cost (rev (as @ U @ bs @ cs)) \<le> cost (rev xs); \<forall>x\<in>set (x # xs). x \<noteq> []; Ball (set (x # xs)) forward; forward y\<rbrakk> \<Longrightarrow> \<forall>x\<in>set (combine_lists_P P y (x # xs)). \<not> P x \<and> forward x [PROOF STEP] then [PROOF STATE] proof (chain) picking this: take 1 as = [r] [PROOF STEP] have "r \<in> set as" [PROOF STATE] proof (prove) using this: take 1 as = [r] goal (1 subgoal): 1. r \<in> set as [PROOF STEP] using in_set_takeD[of r 1] [PROOF STATE] proof (prove) using this: take 1 as = [r] r \<in> set (take 1 ?xs) \<Longrightarrow> r \<in> set ?xs goal (1 subgoal): 1. r \<in> set as [PROOF STEP] by simp [PROOF STATE] proof (state) this: r \<in> set as goal (1 subgoal): 1. \<And>P y x xs. \<lbrakk>\<lbrakk>P (x @ y); asi rank r cost; x @ y \<noteq> []; r \<notin> set U; U \<noteq> []; set (as @ U @ bs @ cs) = \<Union> (set ` Y); distinct (as @ U @ bs @ cs); take 1 (as @ U @ bs @ cs) = [r]; forward (as @ U @ bs @ cs); concat (rev xs @ [x @ y]) = bs; \<forall>xsa\<in>Y. sublist xsa as \<or> sublist xsa U \<or> Bex (set (xs @ [x @ y])) (sublist xsa) \<or> sublist xsa cs; rank (rev V) \<le> rank (rev U); \<not> (\<exists>xa\<in>set U. \<exists>y\<in>set (x @ y). xa \<rightarrow>\<^sup>+\<^bsub>T\<^esub> y); rank (rev (x @ y)) < rank (rev V); P = (\<lambda>x. rank (rev x) < rank (rev V)); \<forall>x\<in>set xs. \<not> P x; \<forall>xs. fwd_sub r Y xs \<longrightarrow> cost (rev (as @ U @ bs @ cs)) \<le> cost (rev xs); \<forall>x\<in>set xs. x \<noteq> []; Ball (set xs) forward; forward (x @ y)\<rbrakk> \<Longrightarrow> \<forall>x\<in>set (combine_lists_P P (x @ y) xs). \<not> P x \<and> forward x; asi rank r cost; y \<noteq> []; r \<notin> set U; U \<noteq> []; set (as @ U @ bs @ cs) = \<Union> (set ` Y); distinct (as @ U @ bs @ cs); take 1 (as @ U @ bs @ cs) = [r]; forward (as @ U @ bs @ cs); concat (rev (x # xs) @ [y]) = bs; \<forall>xsa\<in>Y. sublist xsa as \<or> sublist xsa U \<or> Bex (set ((x # xs) @ [y])) (sublist xsa) \<or> sublist xsa cs; rank (rev V) \<le> rank (rev U); \<not> (\<exists>x\<in>set U. \<exists>y\<in>set y. x \<rightarrow>\<^sup>+\<^bsub>T\<^esub> y); rank (rev y) < rank (rev V); P = (\<lambda>x. rank (rev x) < rank (rev V)); \<forall>x\<in>set (x # xs). \<not> P x; \<forall>xs. fwd_sub r Y xs \<longrightarrow> cost (rev (as @ U @ bs @ cs)) \<le> cost (rev xs); \<forall>x\<in>set (x # xs). x \<noteq> []; Ball (set (x # xs)) forward; forward y\<rbrakk> \<Longrightarrow> \<forall>x\<in>set (combine_lists_P P y (x # xs)). \<not> P x \<and> forward x [PROOF STEP] then [PROOF STATE] proof (chain) picking this: r \<in> set as [PROOF STEP] have "r \<notin> set x" [PROOF STATE] proof (prove) using this: r \<in> set as goal (1 subgoal): 1. r \<notin> set x [PROOF STEP] using "2.prems"(6,9) [PROOF STATE] proof (prove) using this: r \<in> set as distinct (as @ U @ bs @ cs) concat (rev (x # xs) @ [b]) = bs goal (1 subgoal): 1. r \<notin> set x [PROOF STEP] by force [PROOF STATE] proof (state) this: r \<notin> set x goal (1 subgoal): 1. \<And>P y x xs. \<lbrakk>\<lbrakk>P (x @ y); asi rank r cost; x @ y \<noteq> []; r \<notin> set U; U \<noteq> []; set (as @ U @ bs @ cs) = \<Union> (set ` Y); distinct (as @ U @ bs @ cs); take 1 (as @ U @ bs @ cs) = [r]; forward (as @ U @ bs @ cs); concat (rev xs @ [x @ y]) = bs; \<forall>xsa\<in>Y. sublist xsa as \<or> sublist xsa U \<or> Bex (set (xs @ [x @ y])) (sublist xsa) \<or> sublist xsa cs; rank (rev V) \<le> rank (rev U); \<not> (\<exists>xa\<in>set U. \<exists>y\<in>set (x @ y). xa \<rightarrow>\<^sup>+\<^bsub>T\<^esub> y); rank (rev (x @ y)) < rank (rev V); P = (\<lambda>x. rank (rev x) < rank (rev V)); \<forall>x\<in>set xs. \<not> P x; \<forall>xs. fwd_sub r Y xs \<longrightarrow> cost (rev (as @ U @ bs @ cs)) \<le> cost (rev xs); \<forall>x\<in>set xs. x \<noteq> []; Ball (set xs) forward; forward (x @ y)\<rbrakk> \<Longrightarrow> \<forall>x\<in>set (combine_lists_P P (x @ y) xs). \<not> P x \<and> forward x; asi rank r cost; y \<noteq> []; r \<notin> set U; U \<noteq> []; set (as @ U @ bs @ cs) = \<Union> (set ` Y); distinct (as @ U @ bs @ cs); take 1 (as @ U @ bs @ cs) = [r]; forward (as @ U @ bs @ cs); concat (rev (x # xs) @ [y]) = bs; \<forall>xsa\<in>Y. sublist xsa as \<or> sublist xsa U \<or> Bex (set ((x # xs) @ [y])) (sublist xsa) \<or> sublist xsa cs; rank (rev V) \<le> rank (rev U); \<not> (\<exists>x\<in>set U. \<exists>y\<in>set y. x \<rightarrow>\<^sup>+\<^bsub>T\<^esub> y); rank (rev y) < rank (rev V); P = (\<lambda>x. rank (rev x) < rank (rev V)); \<forall>x\<in>set (x # xs). \<not> P x; \<forall>xs. fwd_sub r Y xs \<longrightarrow> cost (rev (as @ U @ bs @ cs)) \<le> cost (rev xs); \<forall>x\<in>set (x # xs). x \<noteq> []; Ball (set (x # xs)) forward; forward y\<rbrakk> \<Longrightarrow> \<forall>x\<in>set (combine_lists_P P y (x # xs)). \<not> P x \<and> forward x [PROOF STEP] then [PROOF STATE] proof (chain) picking this: r \<notin> set x [PROOF STEP] have "x \<noteq> []" [PROOF STATE] proof (prove) using this: r \<notin> set x goal (1 subgoal): 1. x \<noteq> [] [PROOF STEP] using "2.prems"(17) [PROOF STATE] proof (prove) using this: r \<notin> set x \<forall>x\<in>set (x # xs). x \<noteq> [] goal (1 subgoal): 1. x \<noteq> [] [PROOF STEP] by simp [PROOF STATE] proof (state) this: x \<noteq> [] goal (1 subgoal): 1. \<And>P y x xs. \<lbrakk>\<lbrakk>P (x @ y); asi rank r cost; x @ y \<noteq> []; r \<notin> set U; U \<noteq> []; set (as @ U @ bs @ cs) = \<Union> (set ` Y); distinct (as @ U @ bs @ cs); take 1 (as @ U @ bs @ cs) = [r]; forward (as @ U @ bs @ cs); concat (rev xs @ [x @ y]) = bs; \<forall>xsa\<in>Y. sublist xsa as \<or> sublist xsa U \<or> Bex (set (xs @ [x @ y])) (sublist xsa) \<or> sublist xsa cs; rank (rev V) \<le> rank (rev U); \<not> (\<exists>xa\<in>set U. \<exists>y\<in>set (x @ y). xa \<rightarrow>\<^sup>+\<^bsub>T\<^esub> y); rank (rev (x @ y)) < rank (rev V); P = (\<lambda>x. rank (rev x) < rank (rev V)); \<forall>x\<in>set xs. \<not> P x; \<forall>xs. fwd_sub r Y xs \<longrightarrow> cost (rev (as @ U @ bs @ cs)) \<le> cost (rev xs); \<forall>x\<in>set xs. x \<noteq> []; Ball (set xs) forward; forward (x @ y)\<rbrakk> \<Longrightarrow> \<forall>x\<in>set (combine_lists_P P (x @ y) xs). \<not> P x \<and> forward x; asi rank r cost; y \<noteq> []; r \<notin> set U; U \<noteq> []; set (as @ U @ bs @ cs) = \<Union> (set ` Y); distinct (as @ U @ bs @ cs); take 1 (as @ U @ bs @ cs) = [r]; forward (as @ U @ bs @ cs); concat (rev (x # xs) @ [y]) = bs; \<forall>xsa\<in>Y. sublist xsa as \<or> sublist xsa U \<or> Bex (set ((x # xs) @ [y])) (sublist xsa) \<or> sublist xsa cs; rank (rev V) \<le> rank (rev U); \<not> (\<exists>x\<in>set U. \<exists>y\<in>set y. x \<rightarrow>\<^sup>+\<^bsub>T\<^esub> y); rank (rev y) < rank (rev V); P = (\<lambda>x. rank (rev x) < rank (rev V)); \<forall>x\<in>set (x # xs). \<not> P x; \<forall>xs. fwd_sub r Y xs \<longrightarrow> cost (rev (as @ U @ bs @ cs)) \<le> cost (rev xs); \<forall>x\<in>set (x # xs). x \<noteq> []; Ball (set (x # xs)) forward; forward y\<rbrakk> \<Longrightarrow> \<forall>x\<in>set (combine_lists_P P y (x # xs)). \<not> P x \<and> forward x [PROOF STEP] text \<open>Arc between x and b otherwise not optimal.\<close> [PROOF STATE] proof (state) this: x \<noteq> [] goal (1 subgoal): 1. \<And>P y x xs. \<lbrakk>\<lbrakk>P (x @ y); asi rank r cost; x @ y \<noteq> []; r \<notin> set U; U \<noteq> []; set (as @ U @ bs @ cs) = \<Union> (set ` Y); distinct (as @ U @ bs @ cs); take 1 (as @ U @ bs @ cs) = [r]; forward (as @ U @ bs @ cs); concat (rev xs @ [x @ y]) = bs; \<forall>xsa\<in>Y. sublist xsa as \<or> sublist xsa U \<or> Bex (set (xs @ [x @ y])) (sublist xsa) \<or> sublist xsa cs; rank (rev V) \<le> rank (rev U); \<not> (\<exists>xa\<in>set U. \<exists>y\<in>set (x @ y). xa \<rightarrow>\<^sup>+\<^bsub>T\<^esub> y); rank (rev (x @ y)) < rank (rev V); P = (\<lambda>x. rank (rev x) < rank (rev V)); \<forall>x\<in>set xs. \<not> P x; \<forall>xs. fwd_sub r Y xs \<longrightarrow> cost (rev (as @ U @ bs @ cs)) \<le> cost (rev xs); \<forall>x\<in>set xs. x \<noteq> []; Ball (set xs) forward; forward (x @ y)\<rbrakk> \<Longrightarrow> \<forall>x\<in>set (combine_lists_P P (x @ y) xs). \<not> P x \<and> forward x; asi rank r cost; y \<noteq> []; r \<notin> set U; U \<noteq> []; set (as @ U @ bs @ cs) = \<Union> (set ` Y); distinct (as @ U @ bs @ cs); take 1 (as @ U @ bs @ cs) = [r]; forward (as @ U @ bs @ cs); concat (rev (x # xs) @ [y]) = bs; \<forall>xsa\<in>Y. sublist xsa as \<or> sublist xsa U \<or> Bex (set ((x # xs) @ [y])) (sublist xsa) \<or> sublist xsa cs; rank (rev V) \<le> rank (rev U); \<not> (\<exists>x\<in>set U. \<exists>y\<in>set y. x \<rightarrow>\<^sup>+\<^bsub>T\<^esub> y); rank (rev y) < rank (rev V); P = (\<lambda>x. rank (rev x) < rank (rev V)); \<forall>x\<in>set (x # xs). \<not> P x; \<forall>xs. fwd_sub r Y xs \<longrightarrow> cost (rev (as @ U @ bs @ cs)) \<le> cost (rev xs); \<forall>x\<in>set (x # xs). x \<noteq> []; Ball (set (x # xs)) forward; forward y\<rbrakk> \<Longrightarrow> \<forall>x\<in>set (combine_lists_P P y (x # xs)). \<not> P x \<and> forward x [PROOF STEP] have 4: "as@U@bs@cs = (as@U@concat (rev xs)) @ x @ b @ cs" [PROOF STATE] proof (prove) goal (1 subgoal): 1. as @ U @ bs @ cs = (as @ U @ concat (rev xs)) @ x @ b @ cs [PROOF STEP] using "2.prems"(9) [PROOF STATE] proof (prove) using this: concat (rev (x # xs) @ [b]) = bs goal (1 subgoal): 1. as @ U @ bs @ cs = (as @ U @ concat (rev xs)) @ x @ b @ cs [PROOF STEP] by simp [PROOF STATE] proof (state) this: as @ U @ bs @ cs = (as @ U @ concat (rev xs)) @ x @ b @ cs goal (1 subgoal): 1. \<And>P y x xs. \<lbrakk>\<lbrakk>P (x @ y); asi rank r cost; x @ y \<noteq> []; r \<notin> set U; U \<noteq> []; set (as @ U @ bs @ cs) = \<Union> (set ` Y); distinct (as @ U @ bs @ cs); take 1 (as @ U @ bs @ cs) = [r]; forward (as @ U @ bs @ cs); concat (rev xs @ [x @ y]) = bs; \<forall>xsa\<in>Y. sublist xsa as \<or> sublist xsa U \<or> Bex (set (xs @ [x @ y])) (sublist xsa) \<or> sublist xsa cs; rank (rev V) \<le> rank (rev U); \<not> (\<exists>xa\<in>set U. \<exists>y\<in>set (x @ y). xa \<rightarrow>\<^sup>+\<^bsub>T\<^esub> y); rank (rev (x @ y)) < rank (rev V); P = (\<lambda>x. rank (rev x) < rank (rev V)); \<forall>x\<in>set xs. \<not> P x; \<forall>xs. fwd_sub r Y xs \<longrightarrow> cost (rev (as @ U @ bs @ cs)) \<le> cost (rev xs); \<forall>x\<in>set xs. x \<noteq> []; Ball (set xs) forward; forward (x @ y)\<rbrakk> \<Longrightarrow> \<forall>x\<in>set (combine_lists_P P (x @ y) xs). \<not> P x \<and> forward x; asi rank r cost; y \<noteq> []; r \<notin> set U; U \<noteq> []; set (as @ U @ bs @ cs) = \<Union> (set ` Y); distinct (as @ U @ bs @ cs); take 1 (as @ U @ bs @ cs) = [r]; forward (as @ U @ bs @ cs); concat (rev (x # xs) @ [y]) = bs; \<forall>xsa\<in>Y. sublist xsa as \<or> sublist xsa U \<or> Bex (set ((x # xs) @ [y])) (sublist xsa) \<or> sublist xsa cs; rank (rev V) \<le> rank (rev U); \<not> (\<exists>x\<in>set U. \<exists>y\<in>set y. x \<rightarrow>\<^sup>+\<^bsub>T\<^esub> y); rank (rev y) < rank (rev V); P = (\<lambda>x. rank (rev x) < rank (rev V)); \<forall>x\<in>set (x # xs). \<not> P x; \<forall>xs. fwd_sub r Y xs \<longrightarrow> cost (rev (as @ U @ bs @ cs)) \<le> cost (rev xs); \<forall>x\<in>set (x # xs). x \<noteq> []; Ball (set (x # xs)) forward; forward y\<rbrakk> \<Longrightarrow> \<forall>x\<in>set (combine_lists_P P y (x # xs)). \<not> P x \<and> forward x [PROOF STEP] have set: "set ((as@U@concat (rev xs)) @ x @ b @ cs) = \<Union> (set ` Y)" [PROOF STATE] proof (prove) goal (1 subgoal): 1. set ((as @ U @ concat (rev xs)) @ x @ b @ cs) = \<Union> (set ` Y) [PROOF STEP] using "2.prems"(5) 4 [PROOF STATE] proof (prove) using this: set (as @ U @ bs @ cs) = \<Union> (set ` Y) as @ U @ bs @ cs = (as @ U @ concat (rev xs)) @ x @ b @ cs goal (1 subgoal): 1. set ((as @ U @ concat (rev xs)) @ x @ b @ cs) = \<Union> (set ` Y) [PROOF STEP] by simp [PROOF STATE] proof (state) this: set ((as @ U @ concat (rev xs)) @ x @ b @ cs) = \<Union> (set ` Y) goal (1 subgoal): 1. \<And>P y x xs. \<lbrakk>\<lbrakk>P (x @ y); asi rank r cost; x @ y \<noteq> []; r \<notin> set U; U \<noteq> []; set (as @ U @ bs @ cs) = \<Union> (set ` Y); distinct (as @ U @ bs @ cs); take 1 (as @ U @ bs @ cs) = [r]; forward (as @ U @ bs @ cs); concat (rev xs @ [x @ y]) = bs; \<forall>xsa\<in>Y. sublist xsa as \<or> sublist xsa U \<or> Bex (set (xs @ [x @ y])) (sublist xsa) \<or> sublist xsa cs; rank (rev V) \<le> rank (rev U); \<not> (\<exists>xa\<in>set U. \<exists>y\<in>set (x @ y). xa \<rightarrow>\<^sup>+\<^bsub>T\<^esub> y); rank (rev (x @ y)) < rank (rev V); P = (\<lambda>x. rank (rev x) < rank (rev V)); \<forall>x\<in>set xs. \<not> P x; \<forall>xs. fwd_sub r Y xs \<longrightarrow> cost (rev (as @ U @ bs @ cs)) \<le> cost (rev xs); \<forall>x\<in>set xs. x \<noteq> []; Ball (set xs) forward; forward (x @ y)\<rbrakk> \<Longrightarrow> \<forall>x\<in>set (combine_lists_P P (x @ y) xs). \<not> P x \<and> forward x; asi rank r cost; y \<noteq> []; r \<notin> set U; U \<noteq> []; set (as @ U @ bs @ cs) = \<Union> (set ` Y); distinct (as @ U @ bs @ cs); take 1 (as @ U @ bs @ cs) = [r]; forward (as @ U @ bs @ cs); concat (rev (x # xs) @ [y]) = bs; \<forall>xsa\<in>Y. sublist xsa as \<or> sublist xsa U \<or> Bex (set ((x # xs) @ [y])) (sublist xsa) \<or> sublist xsa cs; rank (rev V) \<le> rank (rev U); \<not> (\<exists>x\<in>set U. \<exists>y\<in>set y. x \<rightarrow>\<^sup>+\<^bsub>T\<^esub> y); rank (rev y) < rank (rev V); P = (\<lambda>x. rank (rev x) < rank (rev V)); \<forall>x\<in>set (x # xs). \<not> P x; \<forall>xs. fwd_sub r Y xs \<longrightarrow> cost (rev (as @ U @ bs @ cs)) \<le> cost (rev xs); \<forall>x\<in>set (x # xs). x \<noteq> []; Ball (set (x # xs)) forward; forward y\<rbrakk> \<Longrightarrow> \<forall>x\<in>set (combine_lists_P P y (x # xs)). \<not> P x \<and> forward x [PROOF STEP] have dst: "distinct ((as@U@concat (rev xs)) @ x @ b @ cs)" [PROOF STATE] proof (prove) goal (1 subgoal): 1. distinct ((as @ U @ concat (rev xs)) @ x @ b @ cs) [PROOF STEP] using "2.prems"(6) 4 [PROOF STATE] proof (prove) using this: distinct (as @ U @ bs @ cs) as @ U @ bs @ cs = (as @ U @ concat (rev xs)) @ x @ b @ cs goal (1 subgoal): 1. distinct ((as @ U @ concat (rev xs)) @ x @ b @ cs) [PROOF STEP] by simp [PROOF STATE] proof (state) this: distinct ((as @ U @ concat (rev xs)) @ x @ b @ cs) goal (1 subgoal): 1. \<And>P y x xs. \<lbrakk>\<lbrakk>P (x @ y); asi rank r cost; x @ y \<noteq> []; r \<notin> set U; U \<noteq> []; set (as @ U @ bs @ cs) = \<Union> (set ` Y); distinct (as @ U @ bs @ cs); take 1 (as @ U @ bs @ cs) = [r]; forward (as @ U @ bs @ cs); concat (rev xs @ [x @ y]) = bs; \<forall>xsa\<in>Y. sublist xsa as \<or> sublist xsa U \<or> Bex (set (xs @ [x @ y])) (sublist xsa) \<or> sublist xsa cs; rank (rev V) \<le> rank (rev U); \<not> (\<exists>xa\<in>set U. \<exists>y\<in>set (x @ y). xa \<rightarrow>\<^sup>+\<^bsub>T\<^esub> y); rank (rev (x @ y)) < rank (rev V); P = (\<lambda>x. rank (rev x) < rank (rev V)); \<forall>x\<in>set xs. \<not> P x; \<forall>xs. fwd_sub r Y xs \<longrightarrow> cost (rev (as @ U @ bs @ cs)) \<le> cost (rev xs); \<forall>x\<in>set xs. x \<noteq> []; Ball (set xs) forward; forward (x @ y)\<rbrakk> \<Longrightarrow> \<forall>x\<in>set (combine_lists_P P (x @ y) xs). \<not> P x \<and> forward x; asi rank r cost; y \<noteq> []; r \<notin> set U; U \<noteq> []; set (as @ U @ bs @ cs) = \<Union> (set ` Y); distinct (as @ U @ bs @ cs); take 1 (as @ U @ bs @ cs) = [r]; forward (as @ U @ bs @ cs); concat (rev (x # xs) @ [y]) = bs; \<forall>xsa\<in>Y. sublist xsa as \<or> sublist xsa U \<or> Bex (set ((x # xs) @ [y])) (sublist xsa) \<or> sublist xsa cs; rank (rev V) \<le> rank (rev U); \<not> (\<exists>x\<in>set U. \<exists>y\<in>set y. x \<rightarrow>\<^sup>+\<^bsub>T\<^esub> y); rank (rev y) < rank (rev V); P = (\<lambda>x. rank (rev x) < rank (rev V)); \<forall>x\<in>set (x # xs). \<not> P x; \<forall>xs. fwd_sub r Y xs \<longrightarrow> cost (rev (as @ U @ bs @ cs)) \<le> cost (rev xs); \<forall>x\<in>set (x # xs). x \<noteq> []; Ball (set (x # xs)) forward; forward y\<rbrakk> \<Longrightarrow> \<forall>x\<in>set (combine_lists_P P y (x # xs)). \<not> P x \<and> forward x [PROOF STEP] have tk1: "take 1 ((as@U@concat (rev xs)) @ x @ b @ cs) = [r]" [PROOF STATE] proof (prove) goal (1 subgoal): 1. take 1 ((as @ U @ concat (rev xs)) @ x @ b @ cs) = [r] [PROOF STEP] using "2.prems"(7) 4 [PROOF STATE] proof (prove) using this: take 1 (as @ U @ bs @ cs) = [r] as @ U @ bs @ cs = (as @ U @ concat (rev xs)) @ x @ b @ cs goal (1 subgoal): 1. take 1 ((as @ U @ concat (rev xs)) @ x @ b @ cs) = [r] [PROOF STEP] by simp [PROOF STATE] proof (state) this: take 1 ((as @ U @ concat (rev xs)) @ x @ b @ cs) = [r] goal (1 subgoal): 1. \<And>P y x xs. \<lbrakk>\<lbrakk>P (x @ y); asi rank r cost; x @ y \<noteq> []; r \<notin> set U; U \<noteq> []; set (as @ U @ bs @ cs) = \<Union> (set ` Y); distinct (as @ U @ bs @ cs); take 1 (as @ U @ bs @ cs) = [r]; forward (as @ U @ bs @ cs); concat (rev xs @ [x @ y]) = bs; \<forall>xsa\<in>Y. sublist xsa as \<or> sublist xsa U \<or> Bex (set (xs @ [x @ y])) (sublist xsa) \<or> sublist xsa cs; rank (rev V) \<le> rank (rev U); \<not> (\<exists>xa\<in>set U. \<exists>y\<in>set (x @ y). xa \<rightarrow>\<^sup>+\<^bsub>T\<^esub> y); rank (rev (x @ y)) < rank (rev V); P = (\<lambda>x. rank (rev x) < rank (rev V)); \<forall>x\<in>set xs. \<not> P x; \<forall>xs. fwd_sub r Y xs \<longrightarrow> cost (rev (as @ U @ bs @ cs)) \<le> cost (rev xs); \<forall>x\<in>set xs. x \<noteq> []; Ball (set xs) forward; forward (x @ y)\<rbrakk> \<Longrightarrow> \<forall>x\<in>set (combine_lists_P P (x @ y) xs). \<not> P x \<and> forward x; asi rank r cost; y \<noteq> []; r \<notin> set U; U \<noteq> []; set (as @ U @ bs @ cs) = \<Union> (set ` Y); distinct (as @ U @ bs @ cs); take 1 (as @ U @ bs @ cs) = [r]; forward (as @ U @ bs @ cs); concat (rev (x # xs) @ [y]) = bs; \<forall>xsa\<in>Y. sublist xsa as \<or> sublist xsa U \<or> Bex (set ((x # xs) @ [y])) (sublist xsa) \<or> sublist xsa cs; rank (rev V) \<le> rank (rev U); \<not> (\<exists>x\<in>set U. \<exists>y\<in>set y. x \<rightarrow>\<^sup>+\<^bsub>T\<^esub> y); rank (rev y) < rank (rev V); P = (\<lambda>x. rank (rev x) < rank (rev V)); \<forall>x\<in>set (x # xs). \<not> P x; \<forall>xs. fwd_sub r Y xs \<longrightarrow> cost (rev (as @ U @ bs @ cs)) \<le> cost (rev xs); \<forall>x\<in>set (x # xs). x \<noteq> []; Ball (set (x # xs)) forward; forward y\<rbrakk> \<Longrightarrow> \<forall>x\<in>set (combine_lists_P P y (x # xs)). \<not> P x \<and> forward x [PROOF STEP] have fwd: "forward ((as@U@concat (rev xs)) @ x @ b @ cs)" [PROOF STATE] proof (prove) goal (1 subgoal): 1. forward ((as @ U @ concat (rev xs)) @ x @ b @ cs) [PROOF STEP] using "2.prems"(8) 4 [PROOF STATE] proof (prove) using this: forward (as @ U @ bs @ cs) as @ U @ bs @ cs = (as @ U @ concat (rev xs)) @ x @ b @ cs goal (1 subgoal): 1. forward ((as @ U @ concat (rev xs)) @ x @ b @ cs) [PROOF STEP] by simp [PROOF STATE] proof (state) this: forward ((as @ U @ concat (rev xs)) @ x @ b @ cs) goal (1 subgoal): 1. \<And>P y x xs. \<lbrakk>\<lbrakk>P (x @ y); asi rank r cost; x @ y \<noteq> []; r \<notin> set U; U \<noteq> []; set (as @ U @ bs @ cs) = \<Union> (set ` Y); distinct (as @ U @ bs @ cs); take 1 (as @ U @ bs @ cs) = [r]; forward (as @ U @ bs @ cs); concat (rev xs @ [x @ y]) = bs; \<forall>xsa\<in>Y. sublist xsa as \<or> sublist xsa U \<or> Bex (set (xs @ [x @ y])) (sublist xsa) \<or> sublist xsa cs; rank (rev V) \<le> rank (rev U); \<not> (\<exists>xa\<in>set U. \<exists>y\<in>set (x @ y). xa \<rightarrow>\<^sup>+\<^bsub>T\<^esub> y); rank (rev (x @ y)) < rank (rev V); P = (\<lambda>x. rank (rev x) < rank (rev V)); \<forall>x\<in>set xs. \<not> P x; \<forall>xs. fwd_sub r Y xs \<longrightarrow> cost (rev (as @ U @ bs @ cs)) \<le> cost (rev xs); \<forall>x\<in>set xs. x \<noteq> []; Ball (set xs) forward; forward (x @ y)\<rbrakk> \<Longrightarrow> \<forall>x\<in>set (combine_lists_P P (x @ y) xs). \<not> P x \<and> forward x; asi rank r cost; y \<noteq> []; r \<notin> set U; U \<noteq> []; set (as @ U @ bs @ cs) = \<Union> (set ` Y); distinct (as @ U @ bs @ cs); take 1 (as @ U @ bs @ cs) = [r]; forward (as @ U @ bs @ cs); concat (rev (x # xs) @ [y]) = bs; \<forall>xsa\<in>Y. sublist xsa as \<or> sublist xsa U \<or> Bex (set ((x # xs) @ [y])) (sublist xsa) \<or> sublist xsa cs; rank (rev V) \<le> rank (rev U); \<not> (\<exists>x\<in>set U. \<exists>y\<in>set y. x \<rightarrow>\<^sup>+\<^bsub>T\<^esub> y); rank (rev y) < rank (rev V); P = (\<lambda>x. rank (rev x) < rank (rev V)); \<forall>x\<in>set (x # xs). \<not> P x; \<forall>xs. fwd_sub r Y xs \<longrightarrow> cost (rev (as @ U @ bs @ cs)) \<le> cost (rev xs); \<forall>x\<in>set (x # xs). x \<noteq> []; Ball (set (x # xs)) forward; forward y\<rbrakk> \<Longrightarrow> \<forall>x\<in>set (combine_lists_P P y (x # xs)). \<not> P x \<and> forward x [PROOF STEP] have cnct: "concat (b # []) = b" [PROOF STATE] proof (prove) goal (1 subgoal): 1. concat [b] = b [PROOF STEP] by simp [PROOF STATE] proof (state) this: concat [b] = b goal (1 subgoal): 1. \<And>P y x xs. \<lbrakk>\<lbrakk>P (x @ y); asi rank r cost; x @ y \<noteq> []; r \<notin> set U; U \<noteq> []; set (as @ U @ bs @ cs) = \<Union> (set ` Y); distinct (as @ U @ bs @ cs); take 1 (as @ U @ bs @ cs) = [r]; forward (as @ U @ bs @ cs); concat (rev xs @ [x @ y]) = bs; \<forall>xsa\<in>Y. sublist xsa as \<or> sublist xsa U \<or> Bex (set (xs @ [x @ y])) (sublist xsa) \<or> sublist xsa cs; rank (rev V) \<le> rank (rev U); \<not> (\<exists>xa\<in>set U. \<exists>y\<in>set (x @ y). xa \<rightarrow>\<^sup>+\<^bsub>T\<^esub> y); rank (rev (x @ y)) < rank (rev V); P = (\<lambda>x. rank (rev x) < rank (rev V)); \<forall>x\<in>set xs. \<not> P x; \<forall>xs. fwd_sub r Y xs \<longrightarrow> cost (rev (as @ U @ bs @ cs)) \<le> cost (rev xs); \<forall>x\<in>set xs. x \<noteq> []; Ball (set xs) forward; forward (x @ y)\<rbrakk> \<Longrightarrow> \<forall>x\<in>set (combine_lists_P P (x @ y) xs). \<not> P x \<and> forward x; asi rank r cost; y \<noteq> []; r \<notin> set U; U \<noteq> []; set (as @ U @ bs @ cs) = \<Union> (set ` Y); distinct (as @ U @ bs @ cs); take 1 (as @ U @ bs @ cs) = [r]; forward (as @ U @ bs @ cs); concat (rev (x # xs) @ [y]) = bs; \<forall>xsa\<in>Y. sublist xsa as \<or> sublist xsa U \<or> Bex (set ((x # xs) @ [y])) (sublist xsa) \<or> sublist xsa cs; rank (rev V) \<le> rank (rev U); \<not> (\<exists>x\<in>set U. \<exists>y\<in>set y. x \<rightarrow>\<^sup>+\<^bsub>T\<^esub> y); rank (rev y) < rank (rev V); P = (\<lambda>x. rank (rev x) < rank (rev V)); \<forall>x\<in>set (x # xs). \<not> P x; \<forall>xs. fwd_sub r Y xs \<longrightarrow> cost (rev (as @ U @ bs @ cs)) \<le> cost (rev xs); \<forall>x\<in>set (x # xs). x \<noteq> []; Ball (set (x # xs)) forward; forward y\<rbrakk> \<Longrightarrow> \<forall>x\<in>set (combine_lists_P P y (x # xs)). \<not> P x \<and> forward x [PROOF STEP] have sblst: "\<forall>xs' \<in> Y. sublist xs' (as @ U @ concat (rev xs)) \<or> sublist xs' x \<or> (\<exists>a\<in>set [b]. sublist xs' a) \<or> sublist xs' cs" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<forall>xs'\<in>Y. sublist xs' (as @ U @ concat (rev xs)) \<or> sublist xs' x \<or> (\<exists>a\<in>set [b]. sublist xs' a) \<or> sublist xs' cs [PROOF STEP] using "2.prems"(10) sublist_set_concat_or_cases[where as = as] [PROOF STATE] proof (prove) using this: \<forall>xsa\<in>Y. sublist xsa as \<or> sublist xsa U \<or> (\<exists>a\<in>set ((x # xs) @ [b]). sublist xsa a) \<or> sublist xsa cs sublist ?ys as \<or> sublist ?ys ?U \<or> (\<exists>a\<in>set ((?x # ?xs) @ [?b]). sublist ?ys a) \<or> sublist ?ys ?cs \<Longrightarrow> sublist ?ys (as @ ?U @ concat (rev ?xs)) \<or> sublist ?ys ?x \<or> (\<exists>a\<in>set [?b]. sublist ?ys a) \<or> sublist ?ys ?cs goal (1 subgoal): 1. \<forall>xs'\<in>Y. sublist xs' (as @ U @ concat (rev xs)) \<or> sublist xs' x \<or> (\<exists>a\<in>set [b]. sublist xs' a) \<or> sublist xs' cs [PROOF STEP] by simp [PROOF STATE] proof (state) this: \<forall>xs'\<in>Y. sublist xs' (as @ U @ concat (rev xs)) \<or> sublist xs' x \<or> (\<exists>a\<in>set [b]. sublist xs' a) \<or> sublist xs' cs goal (1 subgoal): 1. \<And>P y x xs. \<lbrakk>\<lbrakk>P (x @ y); asi rank r cost; x @ y \<noteq> []; r \<notin> set U; U \<noteq> []; set (as @ U @ bs @ cs) = \<Union> (set ` Y); distinct (as @ U @ bs @ cs); take 1 (as @ U @ bs @ cs) = [r]; forward (as @ U @ bs @ cs); concat (rev xs @ [x @ y]) = bs; \<forall>xsa\<in>Y. sublist xsa as \<or> sublist xsa U \<or> Bex (set (xs @ [x @ y])) (sublist xsa) \<or> sublist xsa cs; rank (rev V) \<le> rank (rev U); \<not> (\<exists>xa\<in>set U. \<exists>y\<in>set (x @ y). xa \<rightarrow>\<^sup>+\<^bsub>T\<^esub> y); rank (rev (x @ y)) < rank (rev V); P = (\<lambda>x. rank (rev x) < rank (rev V)); \<forall>x\<in>set xs. \<not> P x; \<forall>xs. fwd_sub r Y xs \<longrightarrow> cost (rev (as @ U @ bs @ cs)) \<le> cost (rev xs); \<forall>x\<in>set xs. x \<noteq> []; Ball (set xs) forward; forward (x @ y)\<rbrakk> \<Longrightarrow> \<forall>x\<in>set (combine_lists_P P (x @ y) xs). \<not> P x \<and> forward x; asi rank r cost; y \<noteq> []; r \<notin> set U; U \<noteq> []; set (as @ U @ bs @ cs) = \<Union> (set ` Y); distinct (as @ U @ bs @ cs); take 1 (as @ U @ bs @ cs) = [r]; forward (as @ U @ bs @ cs); concat (rev (x # xs) @ [y]) = bs; \<forall>xsa\<in>Y. sublist xsa as \<or> sublist xsa U \<or> Bex (set ((x # xs) @ [y])) (sublist xsa) \<or> sublist xsa cs; rank (rev V) \<le> rank (rev U); \<not> (\<exists>x\<in>set U. \<exists>y\<in>set y. x \<rightarrow>\<^sup>+\<^bsub>T\<^esub> y); rank (rev y) < rank (rev V); P = (\<lambda>x. rank (rev x) < rank (rev V)); \<forall>x\<in>set (x # xs). \<not> P x; \<forall>xs. fwd_sub r Y xs \<longrightarrow> cost (rev (as @ U @ bs @ cs)) \<le> cost (rev xs); \<forall>x\<in>set (x # xs). x \<noteq> []; Ball (set (x # xs)) forward; forward y\<rbrakk> \<Longrightarrow> \<forall>x\<in>set (combine_lists_P P y (x # xs)). \<not> P x \<and> forward x [PROOF STEP] have "rank (rev b) < rank (rev x)" [PROOF STATE] proof (prove) goal (1 subgoal): 1. rank (rev b) < rank (rev x) [PROOF STEP] using "2.prems"(13-15) [PROOF STATE] proof (prove) using this: rank (rev b) < rank (rev V) P = (\<lambda>x. rank (rev x) < rank (rev V)) \<forall>x\<in>set (x # xs). \<not> P x goal (1 subgoal): 1. rank (rev b) < rank (rev x) [PROOF STEP] by simp [PROOF STATE] proof (state) this: rank (rev b) < rank (rev x) goal (1 subgoal): 1. \<And>P y x xs. \<lbrakk>\<lbrakk>P (x @ y); asi rank r cost; x @ y \<noteq> []; r \<notin> set U; U \<noteq> []; set (as @ U @ bs @ cs) = \<Union> (set ` Y); distinct (as @ U @ bs @ cs); take 1 (as @ U @ bs @ cs) = [r]; forward (as @ U @ bs @ cs); concat (rev xs @ [x @ y]) = bs; \<forall>xsa\<in>Y. sublist xsa as \<or> sublist xsa U \<or> Bex (set (xs @ [x @ y])) (sublist xsa) \<or> sublist xsa cs; rank (rev V) \<le> rank (rev U); \<not> (\<exists>xa\<in>set U. \<exists>y\<in>set (x @ y). xa \<rightarrow>\<^sup>+\<^bsub>T\<^esub> y); rank (rev (x @ y)) < rank (rev V); P = (\<lambda>x. rank (rev x) < rank (rev V)); \<forall>x\<in>set xs. \<not> P x; \<forall>xs. fwd_sub r Y xs \<longrightarrow> cost (rev (as @ U @ bs @ cs)) \<le> cost (rev xs); \<forall>x\<in>set xs. x \<noteq> []; Ball (set xs) forward; forward (x @ y)\<rbrakk> \<Longrightarrow> \<forall>x\<in>set (combine_lists_P P (x @ y) xs). \<not> P x \<and> forward x; asi rank r cost; y \<noteq> []; r \<notin> set U; U \<noteq> []; set (as @ U @ bs @ cs) = \<Union> (set ` Y); distinct (as @ U @ bs @ cs); take 1 (as @ U @ bs @ cs) = [r]; forward (as @ U @ bs @ cs); concat (rev (x # xs) @ [y]) = bs; \<forall>xsa\<in>Y. sublist xsa as \<or> sublist xsa U \<or> Bex (set ((x # xs) @ [y])) (sublist xsa) \<or> sublist xsa cs; rank (rev V) \<le> rank (rev U); \<not> (\<exists>x\<in>set U. \<exists>y\<in>set y. x \<rightarrow>\<^sup>+\<^bsub>T\<^esub> y); rank (rev y) < rank (rev V); P = (\<lambda>x. rank (rev x) < rank (rev V)); \<forall>x\<in>set (x # xs). \<not> P x; \<forall>xs. fwd_sub r Y xs \<longrightarrow> cost (rev (as @ U @ bs @ cs)) \<le> cost (rev xs); \<forall>x\<in>set (x # xs). x \<noteq> []; Ball (set (x # xs)) forward; forward y\<rbrakk> \<Longrightarrow> \<forall>x\<in>set (combine_lists_P P y (x # xs)). \<not> P x \<and> forward x [PROOF STEP] then [PROOF STATE] proof (chain) picking this: rank (rev b) < rank (rev x) [PROOF STEP] have arc_xb: "\<exists>z\<in>set x. \<exists>y\<in>set b. z \<rightarrow>\<^bsub>T\<^esub> y" [PROOF STATE] proof (prove) using this: rank (rev b) < rank (rev x) goal (1 subgoal): 1. \<exists>z\<in>set x. \<exists>y\<in>set b. z \<rightarrow>\<^bsub>T\<^esub> y [PROOF STEP] using "2.prems"(16) 4 cost_decr_if_noarc_lessrank[OF 2(2,3) \<open>r\<notin>set x\<close> \<open>x\<noteq>[]\<close> set dst tk1 fwd cnct sblst] [PROOF STATE] proof (prove) using this: rank (rev b) < rank (rev x) \<forall>xs. fwd_sub r Y xs \<longrightarrow> cost (rev (as @ U @ bs @ cs)) \<le> cost (rev xs) as @ U @ bs @ cs = (as @ U @ concat (rev xs)) @ x @ b @ cs \<lbrakk>\<not> (\<exists>x\<in>set x. \<exists>y\<in>set b. x \<rightarrow>\<^bsub>T\<^esub> y); rank (rev b) < rank (rev x)\<rbrakk> \<Longrightarrow> fwd_sub r Y ((as @ U @ concat (rev xs)) @ b @ x @ concat [] @ cs) \<and> cost (rev ((as @ U @ concat (rev xs)) @ b @ x @ concat [] @ cs)) < cost (rev ((as @ U @ concat (rev xs)) @ x @ b @ cs)) goal (1 subgoal): 1. \<exists>z\<in>set x. \<exists>y\<in>set b. z \<rightarrow>\<^bsub>T\<^esub> y [PROOF STEP] by fastforce [PROOF STATE] proof (state) this: \<exists>z\<in>set x. \<exists>y\<in>set b. z \<rightarrow>\<^bsub>T\<^esub> y goal (1 subgoal): 1. \<And>P y x xs. \<lbrakk>\<lbrakk>P (x @ y); asi rank r cost; x @ y \<noteq> []; r \<notin> set U; U \<noteq> []; set (as @ U @ bs @ cs) = \<Union> (set ` Y); distinct (as @ U @ bs @ cs); take 1 (as @ U @ bs @ cs) = [r]; forward (as @ U @ bs @ cs); concat (rev xs @ [x @ y]) = bs; \<forall>xsa\<in>Y. sublist xsa as \<or> sublist xsa U \<or> Bex (set (xs @ [x @ y])) (sublist xsa) \<or> sublist xsa cs; rank (rev V) \<le> rank (rev U); \<not> (\<exists>xa\<in>set U. \<exists>y\<in>set (x @ y). xa \<rightarrow>\<^sup>+\<^bsub>T\<^esub> y); rank (rev (x @ y)) < rank (rev V); P = (\<lambda>x. rank (rev x) < rank (rev V)); \<forall>x\<in>set xs. \<not> P x; \<forall>xs. fwd_sub r Y xs \<longrightarrow> cost (rev (as @ U @ bs @ cs)) \<le> cost (rev xs); \<forall>x\<in>set xs. x \<noteq> []; Ball (set xs) forward; forward (x @ y)\<rbrakk> \<Longrightarrow> \<forall>x\<in>set (combine_lists_P P (x @ y) xs). \<not> P x \<and> forward x; asi rank r cost; y \<noteq> []; r \<notin> set U; U \<noteq> []; set (as @ U @ bs @ cs) = \<Union> (set ` Y); distinct (as @ U @ bs @ cs); take 1 (as @ U @ bs @ cs) = [r]; forward (as @ U @ bs @ cs); concat (rev (x # xs) @ [y]) = bs; \<forall>xsa\<in>Y. sublist xsa as \<or> sublist xsa U \<or> Bex (set ((x # xs) @ [y])) (sublist xsa) \<or> sublist xsa cs; rank (rev V) \<le> rank (rev U); \<not> (\<exists>x\<in>set U. \<exists>y\<in>set y. x \<rightarrow>\<^sup>+\<^bsub>T\<^esub> y); rank (rev y) < rank (rev V); P = (\<lambda>x. rank (rev x) < rank (rev V)); \<forall>x\<in>set (x # xs). \<not> P x; \<forall>xs. fwd_sub r Y xs \<longrightarrow> cost (rev (as @ U @ bs @ cs)) \<le> cost (rev xs); \<forall>x\<in>set (x # xs). x \<noteq> []; Ball (set (x # xs)) forward; forward y\<rbrakk> \<Longrightarrow> \<forall>x\<in>set (combine_lists_P P y (x # xs)). \<not> P x \<and> forward x [PROOF STEP] have "set x \<inter> set b = {}" [PROOF STATE] proof (prove) goal (1 subgoal): 1. set x \<inter> set b = {} [PROOF STEP] using dst [PROOF STATE] proof (prove) using this: distinct ((as @ U @ concat (rev xs)) @ x @ b @ cs) goal (1 subgoal): 1. set x \<inter> set b = {} [PROOF STEP] by auto [PROOF STATE] proof (state) this: set x \<inter> set b = {} goal (1 subgoal): 1. \<And>P y x xs. \<lbrakk>\<lbrakk>P (x @ y); asi rank r cost; x @ y \<noteq> []; r \<notin> set U; U \<noteq> []; set (as @ U @ bs @ cs) = \<Union> (set ` Y); distinct (as @ U @ bs @ cs); take 1 (as @ U @ bs @ cs) = [r]; forward (as @ U @ bs @ cs); concat (rev xs @ [x @ y]) = bs; \<forall>xsa\<in>Y. sublist xsa as \<or> sublist xsa U \<or> Bex (set (xs @ [x @ y])) (sublist xsa) \<or> sublist xsa cs; rank (rev V) \<le> rank (rev U); \<not> (\<exists>xa\<in>set U. \<exists>y\<in>set (x @ y). xa \<rightarrow>\<^sup>+\<^bsub>T\<^esub> y); rank (rev (x @ y)) < rank (rev V); P = (\<lambda>x. rank (rev x) < rank (rev V)); \<forall>x\<in>set xs. \<not> P x; \<forall>xs. fwd_sub r Y xs \<longrightarrow> cost (rev (as @ U @ bs @ cs)) \<le> cost (rev xs); \<forall>x\<in>set xs. x \<noteq> []; Ball (set xs) forward; forward (x @ y)\<rbrakk> \<Longrightarrow> \<forall>x\<in>set (combine_lists_P P (x @ y) xs). \<not> P x \<and> forward x; asi rank r cost; y \<noteq> []; r \<notin> set U; U \<noteq> []; set (as @ U @ bs @ cs) = \<Union> (set ` Y); distinct (as @ U @ bs @ cs); take 1 (as @ U @ bs @ cs) = [r]; forward (as @ U @ bs @ cs); concat (rev (x # xs) @ [y]) = bs; \<forall>xsa\<in>Y. sublist xsa as \<or> sublist xsa U \<or> Bex (set ((x # xs) @ [y])) (sublist xsa) \<or> sublist xsa cs; rank (rev V) \<le> rank (rev U); \<not> (\<exists>x\<in>set U. \<exists>y\<in>set y. x \<rightarrow>\<^sup>+\<^bsub>T\<^esub> y); rank (rev y) < rank (rev V); P = (\<lambda>x. rank (rev x) < rank (rev V)); \<forall>x\<in>set (x # xs). \<not> P x; \<forall>xs. fwd_sub r Y xs \<longrightarrow> cost (rev (as @ U @ bs @ cs)) \<le> cost (rev xs); \<forall>x\<in>set (x # xs). x \<noteq> []; Ball (set (x # xs)) forward; forward y\<rbrakk> \<Longrightarrow> \<forall>x\<in>set (combine_lists_P P y (x # xs)). \<not> P x \<and> forward x [PROOF STEP] then [PROOF STATE] proof (chain) picking this: set x \<inter> set b = {} [PROOF STEP] have fwd: "forward (x@b)" [PROOF STATE] proof (prove) using this: set x \<inter> set b = {} goal (1 subgoal): 1. forward (x @ b) [PROOF STEP] using forward_app' arc_xb "2.prems"(18,19) [PROOF STATE] proof (prove) using this: set x \<inter> set b = {} \<lbrakk>forward ?s1.0; forward ?s2.0; set ?s1.0 \<inter> set ?s2.0 = {}; \<exists>x\<in>set ?s1.0. \<exists>y\<in>set ?s2.0. x \<rightarrow>\<^bsub>T\<^esub> y\<rbrakk> \<Longrightarrow> forward (?s1.0 @ ?s2.0) \<exists>z\<in>set x. \<exists>y\<in>set b. z \<rightarrow>\<^bsub>T\<^esub> y Ball (set (x # xs)) forward forward b goal (1 subgoal): 1. forward (x @ b) [PROOF STEP] by simp [PROOF STATE] proof (state) this: forward (x @ b) goal (1 subgoal): 1. \<And>P y x xs. \<lbrakk>\<lbrakk>P (x @ y); asi rank r cost; x @ y \<noteq> []; r \<notin> set U; U \<noteq> []; set (as @ U @ bs @ cs) = \<Union> (set ` Y); distinct (as @ U @ bs @ cs); take 1 (as @ U @ bs @ cs) = [r]; forward (as @ U @ bs @ cs); concat (rev xs @ [x @ y]) = bs; \<forall>xsa\<in>Y. sublist xsa as \<or> sublist xsa U \<or> Bex (set (xs @ [x @ y])) (sublist xsa) \<or> sublist xsa cs; rank (rev V) \<le> rank (rev U); \<not> (\<exists>xa\<in>set U. \<exists>y\<in>set (x @ y). xa \<rightarrow>\<^sup>+\<^bsub>T\<^esub> y); rank (rev (x @ y)) < rank (rev V); P = (\<lambda>x. rank (rev x) < rank (rev V)); \<forall>x\<in>set xs. \<not> P x; \<forall>xs. fwd_sub r Y xs \<longrightarrow> cost (rev (as @ U @ bs @ cs)) \<le> cost (rev xs); \<forall>x\<in>set xs. x \<noteq> []; Ball (set xs) forward; forward (x @ y)\<rbrakk> \<Longrightarrow> \<forall>x\<in>set (combine_lists_P P (x @ y) xs). \<not> P x \<and> forward x; asi rank r cost; y \<noteq> []; r \<notin> set U; U \<noteq> []; set (as @ U @ bs @ cs) = \<Union> (set ` Y); distinct (as @ U @ bs @ cs); take 1 (as @ U @ bs @ cs) = [r]; forward (as @ U @ bs @ cs); concat (rev (x # xs) @ [y]) = bs; \<forall>xsa\<in>Y. sublist xsa as \<or> sublist xsa U \<or> Bex (set ((x # xs) @ [y])) (sublist xsa) \<or> sublist xsa cs; rank (rev V) \<le> rank (rev U); \<not> (\<exists>x\<in>set U. \<exists>y\<in>set y. x \<rightarrow>\<^sup>+\<^bsub>T\<^esub> y); rank (rev y) < rank (rev V); P = (\<lambda>x. rank (rev x) < rank (rev V)); \<forall>x\<in>set (x # xs). \<not> P x; \<forall>xs. fwd_sub r Y xs \<longrightarrow> cost (rev (as @ U @ bs @ cs)) \<le> cost (rev xs); \<forall>x\<in>set (x # xs). x \<noteq> []; Ball (set (x # xs)) forward; forward y\<rbrakk> \<Longrightarrow> \<forall>x\<in>set (combine_lists_P P y (x # xs)). \<not> P x \<and> forward x [PROOF STEP] show ?case [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<forall>x\<in>set (combine_lists_P P b (x # xs)). \<not> P x \<and> forward x [PROOF STEP] proof(cases "P (x @ b)") [PROOF STATE] proof (state) goal (2 subgoals): 1. P (x @ b) \<Longrightarrow> \<forall>x\<in>set (combine_lists_P P b (x # xs)). \<not> P x \<and> forward x 2. \<not> P (x @ b) \<Longrightarrow> \<forall>x\<in>set (combine_lists_P P b (x # xs)). \<not> P x \<and> forward x [PROOF STEP] case True [PROOF STATE] proof (state) this: P (x @ b) goal (2 subgoals): 1. P (x @ b) \<Longrightarrow> \<forall>x\<in>set (combine_lists_P P b (x # xs)). \<not> P x \<and> forward x 2. \<not> P (x @ b) \<Longrightarrow> \<forall>x\<in>set (combine_lists_P P b (x # xs)). \<not> P x \<and> forward x [PROOF STEP] have 0: "x @ b \<noteq> []" [PROOF STATE] proof (prove) goal (1 subgoal): 1. x @ b \<noteq> [] [PROOF STEP] using "2.prems"(2) [PROOF STATE] proof (prove) using this: b \<noteq> [] goal (1 subgoal): 1. x @ b \<noteq> [] [PROOF STEP] by blast [PROOF STATE] proof (state) this: x @ b \<noteq> [] goal (2 subgoals): 1. P (x @ b) \<Longrightarrow> \<forall>x\<in>set (combine_lists_P P b (x # xs)). \<not> P x \<and> forward x 2. \<not> P (x @ b) \<Longrightarrow> \<forall>x\<in>set (combine_lists_P P b (x # xs)). \<not> P x \<and> forward x [PROOF STEP] have 1: "concat (rev xs @ [x @ b]) = bs" [PROOF STATE] proof (prove) goal (1 subgoal): 1. concat (rev xs @ [x @ b]) = bs [PROOF STEP] using "2.prems"(9) [PROOF STATE] proof (prove) using this: concat (rev (x # xs) @ [b]) = bs goal (1 subgoal): 1. concat (rev xs @ [x @ b]) = bs [PROOF STEP] by simp [PROOF STATE] proof (state) this: concat (rev xs @ [x @ b]) = bs goal (2 subgoals): 1. P (x @ b) \<Longrightarrow> \<forall>x\<in>set (combine_lists_P P b (x # xs)). \<not> P x \<and> forward x 2. \<not> P (x @ b) \<Longrightarrow> \<forall>x\<in>set (combine_lists_P P b (x # xs)). \<not> P x \<and> forward x [PROOF STEP] have 3: "\<forall>xs' \<in> Y. sublist xs' as \<or> sublist xs' U \<or> (\<exists>a\<in>set (xs @ [x @ b]). sublist xs' a) \<or> sublist xs' cs" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<forall>xs'\<in>Y. sublist xs' as \<or> sublist xs' U \<or> (\<exists>a\<in>set (xs @ [x @ b]). sublist xs' a) \<or> sublist xs' cs [PROOF STEP] using "2.prems"(10) sublist_exists_append [PROOF STATE] proof (prove) using this: \<forall>xsa\<in>Y. sublist xsa as \<or> sublist xsa U \<or> (\<exists>a\<in>set ((x # xs) @ [b]). sublist xsa a) \<or> sublist xsa cs \<exists>a\<in>set ((?x # ?xs) @ [?b]). sublist ?ys a \<Longrightarrow> \<exists>a\<in>set (?xs @ [?x @ ?b]). sublist ?ys a goal (1 subgoal): 1. \<forall>xs'\<in>Y. sublist xs' as \<or> sublist xs' U \<or> (\<exists>a\<in>set (xs @ [x @ b]). sublist xs' a) \<or> sublist xs' cs [PROOF STEP] by fast [PROOF STATE] proof (state) this: \<forall>xs'\<in>Y. sublist xs' as \<or> sublist xs' U \<or> (\<exists>a\<in>set (xs @ [x @ b]). sublist xs' a) \<or> sublist xs' cs goal (2 subgoals): 1. P (x @ b) \<Longrightarrow> \<forall>x\<in>set (combine_lists_P P b (x # xs)). \<not> P x \<and> forward x 2. \<not> P (x @ b) \<Longrightarrow> \<forall>x\<in>set (combine_lists_P P b (x # xs)). \<not> P x \<and> forward x [PROOF STEP] have "set U \<inter> set x = {}" [PROOF STATE] proof (prove) goal (1 subgoal): 1. set U \<inter> set x = {} [PROOF STEP] using 4 "2.prems"(6) [PROOF STATE] proof (prove) using this: as @ U @ bs @ cs = (as @ U @ concat (rev xs)) @ x @ b @ cs distinct (as @ U @ bs @ cs) goal (1 subgoal): 1. set U \<inter> set x = {} [PROOF STEP] by force [PROOF STATE] proof (state) this: set U \<inter> set x = {} goal (2 subgoals): 1. P (x @ b) \<Longrightarrow> \<forall>x\<in>set (combine_lists_P P b (x # xs)). \<not> P x \<and> forward x 2. \<not> P (x @ b) \<Longrightarrow> \<forall>x\<in>set (combine_lists_P P b (x # xs)). \<not> P x \<and> forward x [PROOF STEP] then [PROOF STATE] proof (chain) picking this: set U \<inter> set x = {} [PROOF STEP] have 4: "\<not> (\<exists>z\<in>set U. \<exists>y\<in>set (x @ b). z \<rightarrow>\<^sup>+\<^bsub>T\<^esub> y)" [PROOF STATE] proof (prove) using this: set U \<inter> set x = {} goal (1 subgoal): 1. \<not> (\<exists>z\<in>set U. \<exists>y\<in>set (x @ b). z \<rightarrow>\<^sup>+\<^bsub>T\<^esub> y) [PROOF STEP] using not_reachable1_append_if_not_old[OF "2.prems"(12)] "2.prems"(18) arc_xb [PROOF STATE] proof (prove) using this: set U \<inter> set x = {} \<lbrakk>set U \<inter> set ?x = {}; forward ?x; \<exists>z\<in>set ?x. \<exists>y\<in>set b. z \<rightarrow>\<^bsub>T\<^esub> y\<rbrakk> \<Longrightarrow> \<not> (\<exists>z\<in>set U. \<exists>y\<in>set (?x @ b). z \<rightarrow>\<^sup>+\<^bsub>T\<^esub> y) Ball (set (x # xs)) forward \<exists>z\<in>set x. \<exists>y\<in>set b. z \<rightarrow>\<^bsub>T\<^esub> y goal (1 subgoal): 1. \<not> (\<exists>z\<in>set U. \<exists>y\<in>set (x @ b). z \<rightarrow>\<^sup>+\<^bsub>T\<^esub> y) [PROOF STEP] by simp [PROOF STATE] proof (state) this: \<not> (\<exists>z\<in>set U. \<exists>y\<in>set (x @ b). z \<rightarrow>\<^sup>+\<^bsub>T\<^esub> y) goal (2 subgoals): 1. P (x @ b) \<Longrightarrow> \<forall>x\<in>set (combine_lists_P P b (x # xs)). \<not> P x \<and> forward x 2. \<not> P (x @ b) \<Longrightarrow> \<forall>x\<in>set (combine_lists_P P b (x # xs)). \<not> P x \<and> forward x [PROOF STEP] have 5: "rank (rev (x @ b)) < rank (rev V)" [PROOF STATE] proof (prove) goal (1 subgoal): 1. rank (rev (x @ b)) < rank (rev V) [PROOF STEP] using True "2.prems"(14) [PROOF STATE] proof (prove) using this: P (x @ b) P = (\<lambda>x. rank (rev x) < rank (rev V)) goal (1 subgoal): 1. rank (rev (x @ b)) < rank (rev V) [PROOF STEP] by simp [PROOF STATE] proof (state) this: rank (rev (x @ b)) < rank (rev V) goal (2 subgoals): 1. P (x @ b) \<Longrightarrow> \<forall>x\<in>set (combine_lists_P P b (x # xs)). \<not> P x \<and> forward x 2. \<not> P (x @ b) \<Longrightarrow> \<forall>x\<in>set (combine_lists_P P b (x # xs)). \<not> P x \<and> forward x [PROOF STEP] show ?thesis [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<forall>x\<in>set (combine_lists_P P b (x # xs)). \<not> P x \<and> forward x [PROOF STEP] using "2.IH"[OF True 2(2) 0 2(4-9) 1 3 2(12) 4 5 2(15)] 2(16-19) fwd [PROOF STATE] proof (prove) using this: \<lbrakk>\<forall>x\<in>set xs. \<not> P x; \<forall>xs. fwd_sub r Y xs \<longrightarrow> cost (rev (as @ U @ bs @ cs)) \<le> cost (rev xs); \<forall>x\<in>set xs. x \<noteq> []; Ball (set xs) forward; forward (x @ b)\<rbrakk> \<Longrightarrow> \<forall>x\<in>set (combine_lists_P P (x @ b) xs). \<not> P x \<and> forward x \<forall>x\<in>set (x # xs). \<not> P x \<forall>xs. fwd_sub r Y xs \<longrightarrow> cost (rev (as @ U @ bs @ cs)) \<le> cost (rev xs) \<forall>x\<in>set (x # xs). x \<noteq> [] Ball (set (x # xs)) forward forward (x @ b) goal (1 subgoal): 1. \<forall>x\<in>set (combine_lists_P P b (x # xs)). \<not> P x \<and> forward x [PROOF STEP] by auto [PROOF STATE] proof (state) this: \<forall>x\<in>set (combine_lists_P P b (x # xs)). \<not> P x \<and> forward x goal (1 subgoal): 1. \<not> P (x @ b) \<Longrightarrow> \<forall>x\<in>set (combine_lists_P P b (x # xs)). \<not> P x \<and> forward x [PROOF STEP] next [PROOF STATE] proof (state) goal (1 subgoal): 1. \<not> P (x @ b) \<Longrightarrow> \<forall>x\<in>set (combine_lists_P P b (x # xs)). \<not> P x \<and> forward x [PROOF STEP] case False [PROOF STATE] proof (state) this: \<not> P (x @ b) goal (1 subgoal): 1. \<not> P (x @ b) \<Longrightarrow> \<forall>x\<in>set (combine_lists_P P b (x # xs)). \<not> P x \<and> forward x [PROOF STEP] then [PROOF STATE] proof (chain) picking this: \<not> P (x @ b) [PROOF STEP] show ?thesis [PROOF STATE] proof (prove) using this: \<not> P (x @ b) goal (1 subgoal): 1. \<forall>x\<in>set (combine_lists_P P b (x # xs)). \<not> P x \<and> forward x [PROOF STEP] using "2.prems"(15,18) fwd [PROOF STATE] proof (prove) using this: \<not> P (x @ b) \<forall>x\<in>set (x # xs). \<not> P x Ball (set (x # xs)) forward forward (x @ b) goal (1 subgoal): 1. \<forall>x\<in>set (combine_lists_P P b (x # xs)). \<not> P x \<and> forward x [PROOF STEP] by simp [PROOF STATE] proof (state) this: \<forall>x\<in>set (combine_lists_P P b (x # xs)). \<not> P x \<and> forward x goal: No subgoals! [PROOF STEP] qed [PROOF STATE] proof (state) this: \<forall>x\<in>set (combine_lists_P P b (x # xs)). \<not> P x \<and> forward x goal: No subgoals! [PROOF STEP] qed
/- Author: E.W.Ayers Β© 2019 -/ import .table .rule .rule_table .tree namespace robot @[derive decidable_eq] meta inductive task : Type |CreateAll : expr β†’ task |Create : β„• β†’ expr β†’ task /- Use a term annihilation move. For example `X * X⁻¹ = e` annihilates anything in X. -/ |Annihilate : expr β†’ task /- passes when we remove the given term from the CE. Generally this is only used when a variable appears in the CE but not in the target and there are no rules explicitly removing the variable. -/ |Destroy : expr.zipper β†’ task |Merge : expr β†’ task namespace task protected meta def code : task β†’ β„• |(Create _ _) := 0 |(CreateAll _) := 1 |(Annihilate _) := 2 |(Merge _) := 3 |(Destroy _) := 4 protected meta def lt : task β†’ task β†’ bool |(Create n₁ e₁) (Create nβ‚‚ eβ‚‚) := (n₁,e₁) < (nβ‚‚,eβ‚‚) |(CreateAll e₁) (CreateAll eβ‚‚) := e₁ < eβ‚‚ |(Annihilate e₁) (Annihilate eβ‚‚) := e₁ < eβ‚‚ |(Merge e₁) (Merge eβ‚‚) := e₁ < eβ‚‚ |x y := task.code x < task.code y meta instance has_lt : has_lt task := ⟨λ x y, task.lt x y⟩ meta instance decidable_lt : decidable_rel ((<) : task β†’ task β†’ Prop) := by apply_instance meta instance : has_to_tactic_format task := ⟨λ t, match t with |(Create n x) := if n = 0 then notimpl /- should not happen -/ else if n = 1 then pure ((++) "Create ") <*> tactic.pp x else pure (Ξ» ppn ppx, "Create(Γ—" ++ ppn ++ ") " ++ ppx) <*> tactic.pp n <*> tactic.pp x |(CreateAll x) := pure (Ξ» x, "CreateAll " ++ x) <*> tactic.pp x |(Annihilate x) := pure ((++) "Annihilate ") <*> tactic.pp x |(Destroy x) := pure ((++) "Destroy ") <*> tactic.pp x |(Merge x) := pure ((++) "Merge ") <*> tactic.pp x end⟩ meta def is_def_eq : task β†’ task β†’ tactic bool |(Create n₁ x) (Create nβ‚‚ y) := if n₁ β‰  nβ‚‚ then pure ff else tactic.is_success $ tactic.is_def_eq x y |(CreateAll x) (CreateAll y) := tactic.is_success $ tactic.is_def_eq x y |(Annihilate x) (Annihilate y) := tactic.is_success $ tactic.is_def_eq x y |(Merge x) (Merge y) := tactic.is_success $ tactic.is_def_eq x y |_ _ := pure ff end task open task @[derive decidable_eq] meta inductive strategy : Type |Use : rule_app β†’ strategy |ReduceDistance : expr β†’ expr β†’ strategy open strategy namespace strategy meta def code : strategy β†’ β„• |(Use _) := 0 |(ReduceDistance _ _) := 1 meta def lt : strategy β†’ strategy β†’ bool |(Use r₁) (Use rβ‚‚) := r₁ < rβ‚‚ |(ReduceDistance a b) (ReduceDistance a' b') := (a,b) < (a',b') |s₁ sβ‚‚ := s₁.code < sβ‚‚.code meta instance has_lt : has_lt strategy := ⟨λ x y, lt x y⟩ meta instance decidable_lt : decidable_rel ((<) : strategy β†’ strategy β†’ Prop) := by apply_instance meta instance : has_to_tactic_format robot.strategy := ⟨λ s, match s with | (Use x) := do x ← tactic.pp x, pure $ "Use " ++ x | (ReduceDistance x y) := pure (Ξ» x y, "ReduceDistance " ++ x ++ " " ++ y) <*> tactic.pp x <*> tactic.pp y end⟩ meta def is_def_eq : strategy β†’ strategy β†’ tactic bool |(Use r₁) (Use rβ‚‚) := rule_app.is_def_eq r₁ rβ‚‚ |(ReduceDistance a b) (ReduceDistance c d) := tactic.is_success $ (do tactic.is_def_eq a c, tactic.is_def_eq b d) |_ _ := pure ff end strategy meta inductive tree_entry : Type |task (t : task) (achieved : list task) |strat (s : strategy) (achieved : list task) namespace tree_entry meta def code : tree_entry β†’ β„• |(task _ _) := 0 | (strat _ _) := 1 meta def lt : tree_entry β†’ tree_entry β†’ bool |(task t₁ a₁) (task tβ‚‚ aβ‚‚) := t₁ < tβ‚‚ |(strat s₁ _) (strat sβ‚‚ _) := s₁ < sβ‚‚ |x y := x.code < y.code meta instance has_lt : has_lt tree_entry := ⟨λ x y, lt x y⟩ meta instance decidable_lt : decidable_rel ((<) : tree_entry β†’ tree_entry β†’ Prop) := by apply_instance meta def of_task : robot.task β†’ tree_entry := Ξ» t, tree_entry.task t [] meta def as_task : tree_entry β†’ option robot.task |(tree_entry.task t _) := some t | _ := none meta def of_strat : robot.strategy β†’ tree_entry := Ξ» t, tree_entry.strat t [] meta def as_strat : tree_entry β†’ option robot.strategy |(tree_entry.strat t _) := some t | _ := none meta def is_strat : tree_entry β†’ bool := option.is_some ∘ as_strat /-- Get the achieved child subtasks for this entry. -/ meta def achieved : tree_entry β†’ list robot.task | (tree_entry.strat _ a) := a | (tree_entry.task _ a) := a meta def map_achieved (f : list robot.task β†’ list robot.task) : tree_entry β†’ tree_entry | (tree_entry.strat s a) := (tree_entry.strat s $ f a) | (tree_entry.task t a) := tree_entry.task t $ f a meta def push_achieved (t : robot.task) : tree_entry β†’ tree_entry := map_achieved ((::) t) meta instance : has_to_tactic_format tree_entry := ⟨λ x, match x with |(task t _ ) := tactic.pp t | (strat s _ ) := tactic.pp s end⟩ meta def is_def_eq : tree_entry β†’ tree_entry β†’ tactic bool |(task a _) (task b _) := task.is_def_eq a b |(strat a _) (strat b _) := strategy.is_def_eq a b |_ _ := pure ff meta def is_eq : tree_entry β†’ tree_entry β†’ tactic bool |(task a _) (task b _) := pure $ a = b |(strat a _) (strat b _) := pure $ a = b |_ _ := pure ff end tree_entry meta def task_tree := tree tree_entry meta def task_zipper := tree.zipper tree_entry notation `Z` := task_zipper meta structure state := (lookahead : list rule_app) (path : list expr) (rt : rule_table) meta def refinement := list task Γ— list strategy meta instance : has_append refinement := ⟨λ ⟨ts₁,ssβ‚βŸ© ⟨tsβ‚‚,ssβ‚‚βŸ©, ⟨ts₁ ++ tsβ‚‚, ss₁ ++ ssβ‚‚βŸ©βŸ© meta instance : has_emptyc refinement := ⟨⟨[],[]⟩⟩ meta def action := (strategy Γ— Z) meta instance : has_to_tactic_format action := ⟨λ ⟨s,_⟩, tactic.pp s⟩ meta def as_action : Z β†’ option action := Ξ» z, z.item.as_strat >>= Ξ» s, pure (s,z) end robot
[STATEMENT] lemma thm_relation_negation_10[PLM]: "[((p::\<o>) \<^bold>= q) \<^bold>\<rightarrow> ((p\<^sup>-) \<^bold>= (q\<^sup>-)) in v]" [PROOF STATE] proof (prove) goal (1 subgoal): 1. [p \<^bold>= q \<^bold>\<rightarrow> p\<^sup>- \<^bold>= q\<^sup>- in v] [PROOF STEP] using l_identity[where \<alpha>="p" and \<beta>="q" and \<phi>="\<lambda> x . (p\<^sup>-) \<^bold>= (x\<^sup>-)", axiom_instance, deduction] id_eq_prop_prop_7_b [PROOF STATE] proof (prove) using this: [p \<^bold>= q in ?v] \<Longrightarrow> [p\<^sup>- \<^bold>= p\<^sup>- \<^bold>\<rightarrow> p\<^sup>- \<^bold>= q\<^sup>- in ?v] [?p \<^bold>= ?p in ?v] goal (1 subgoal): 1. [p \<^bold>= q \<^bold>\<rightarrow> p\<^sup>- \<^bold>= q\<^sup>- in v] [PROOF STEP] using CP modus_ponens [PROOF STATE] proof (prove) using this: [p \<^bold>= q in ?v] \<Longrightarrow> [p\<^sup>- \<^bold>= p\<^sup>- \<^bold>\<rightarrow> p\<^sup>- \<^bold>= q\<^sup>- in ?v] [?p \<^bold>= ?p in ?v] ([?\<phi> in ?v] \<Longrightarrow> [?\<psi> in ?v]) \<Longrightarrow> [?\<phi> \<^bold>\<rightarrow> ?\<psi> in ?v] \<lbrakk>[?\<phi> in ?v]; [?\<phi> \<^bold>\<rightarrow> ?\<psi> in ?v]\<rbrakk> \<Longrightarrow> [?\<psi> in ?v] goal (1 subgoal): 1. [p \<^bold>= q \<^bold>\<rightarrow> p\<^sup>- \<^bold>= q\<^sup>- in v] [PROOF STEP] by blast
program ifst; {sample25} var ch : char; begin readln(ch); if ch = 'a' then writeln('It is ''a'' '); else writeln('It is not ''a'' ') end.
[STATEMENT] theorem Lambert_W'_asymp_equiv_at_left_0: "(\<lambda>x. Lambert_W' x - ln (-x)) \<sim>[at_left 0] (\<lambda>x. -ln (-ln (-x)))" [PROOF STATE] proof (prove) goal (1 subgoal): 1. (\<lambda>x. Lambert_W' x - ln (- x)) \<sim>[at_left 0] (\<lambda>x. - ln (- ln (- x))) [PROOF STEP] proof - [PROOF STATE] proof (state) goal (1 subgoal): 1. (\<lambda>x. Lambert_W' x - ln (- x)) \<sim>[at_left 0] (\<lambda>x. - ln (- ln (- x))) [PROOF STEP] have "(\<lambda>x. Lambert_W' x - ln (-x)) \<sim>[at_left 0] (\<lambda>x. (-1) * ln (-ln (-x)))" [PROOF STATE] proof (prove) goal (1 subgoal): 1. (\<lambda>x. Lambert_W' x - ln (- x)) \<sim>[at_left 0] (\<lambda>x. - 1 * ln (- ln (- x))) [PROOF STEP] proof (rule asymp_equiv_sandwich') [PROOF STATE] proof (state) goal (5 subgoals): 1. \<And>c'. c' \<in> {?l<..<- 1} \<Longrightarrow> \<forall>\<^sub>F x in at_left 0. c' * ln (- ln (- x)) \<le> Lambert_W' x - ln (- x) 2. \<And>c'. c' \<in> {- 1<..<?u} \<Longrightarrow> \<forall>\<^sub>F x in at_left 0. Lambert_W' x - ln (- x) \<le> c' * ln (- ln (- x)) 3. ?l < - 1 4. - 1 < ?u 5. - 1 \<noteq> 0 [PROOF STEP] fix c' :: real [PROOF STATE] proof (state) goal (5 subgoals): 1. \<And>c'. c' \<in> {?l<..<- 1} \<Longrightarrow> \<forall>\<^sub>F x in at_left 0. c' * ln (- ln (- x)) \<le> Lambert_W' x - ln (- x) 2. \<And>c'. c' \<in> {- 1<..<?u} \<Longrightarrow> \<forall>\<^sub>F x in at_left 0. Lambert_W' x - ln (- x) \<le> c' * ln (- ln (- x)) 3. ?l < - 1 4. - 1 < ?u 5. - 1 \<noteq> 0 [PROOF STEP] assume c': "c' \<in> {-2<..<-1}" [PROOF STATE] proof (state) this: c' \<in> {- 2<..<- 1} goal (5 subgoals): 1. \<And>c'. c' \<in> {?l<..<- 1} \<Longrightarrow> \<forall>\<^sub>F x in at_left 0. c' * ln (- ln (- x)) \<le> Lambert_W' x - ln (- x) 2. \<And>c'. c' \<in> {- 1<..<?u} \<Longrightarrow> \<forall>\<^sub>F x in at_left 0. Lambert_W' x - ln (- x) \<le> c' * ln (- ln (- x)) 3. ?l < - 1 4. - 1 < ?u 5. - 1 \<noteq> 0 [PROOF STEP] have "eventually (\<lambda>x. x \<le> (ln (-x) + c' * ln (-ln (-x))) * exp (ln (-x) + c' * ln (-ln (-x)))) (at_left 0)" "eventually (\<lambda>x::real. ln (-x) + c' * ln (-ln (-x)) \<le> -1) (at_left 0)" "eventually (\<lambda>x::real. -exp (-1) \<le> x) (at_left 0)" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<forall>\<^sub>F x in at_left 0. x \<le> (ln (- x) + c' * ln (- ln (- x))) * exp (ln (- x) + c' * ln (- ln (- x))) &&& \<forall>\<^sub>F x in at_left 0. ln (- x) + c' * ln (- ln (- x)) \<le> - 1 &&& eventually ((\<le>) (- exp (- 1))) (at_left 0) [PROOF STEP] using c' [PROOF STATE] proof (prove) using this: c' \<in> {- 2<..<- 1} goal (1 subgoal): 1. \<forall>\<^sub>F x in at_left 0. x \<le> (ln (- x) + c' * ln (- ln (- x))) * exp (ln (- x) + c' * ln (- ln (- x))) &&& \<forall>\<^sub>F x in at_left 0. ln (- x) + c' * ln (- ln (- x)) \<le> - 1 &&& eventually ((\<le>) (- exp (- 1))) (at_left 0) [PROOF STEP] by real_asymp+ [PROOF STATE] proof (state) this: \<forall>\<^sub>F x in at_left 0. x \<le> (ln (- x) + c' * ln (- ln (- x))) * exp (ln (- x) + c' * ln (- ln (- x))) \<forall>\<^sub>F x in at_left 0. ln (- x) + c' * ln (- ln (- x)) \<le> - 1 eventually ((\<le>) (- exp (- 1))) (at_left 0) goal (5 subgoals): 1. \<And>c'. c' \<in> {?l<..<- 1} \<Longrightarrow> \<forall>\<^sub>F x in at_left 0. c' * ln (- ln (- x)) \<le> Lambert_W' x - ln (- x) 2. \<And>c'. c' \<in> {- 1<..<?u} \<Longrightarrow> \<forall>\<^sub>F x in at_left 0. Lambert_W' x - ln (- x) \<le> c' * ln (- ln (- x)) 3. ?l < - 1 4. - 1 < ?u 5. - 1 \<noteq> 0 [PROOF STEP] thus "eventually (\<lambda>x. Lambert_W' x - ln (-x) \<ge> c' * ln (-ln (-x))) (at_left 0)" [PROOF STATE] proof (prove) using this: \<forall>\<^sub>F x in at_left 0. x \<le> (ln (- x) + c' * ln (- ln (- x))) * exp (ln (- x) + c' * ln (- ln (- x))) \<forall>\<^sub>F x in at_left 0. ln (- x) + c' * ln (- ln (- x)) \<le> - 1 eventually ((\<le>) (- exp (- 1))) (at_left 0) goal (1 subgoal): 1. \<forall>\<^sub>F x in at_left 0. c' * ln (- ln (- x)) \<le> Lambert_W' x - ln (- x) [PROOF STEP] proof eventually_elim [PROOF STATE] proof (state) goal (1 subgoal): 1. \<And>x. \<lbrakk>x \<le> (ln (- x) + c' * ln (- ln (- x))) * exp (ln (- x) + c' * ln (- ln (- x))); ln (- x) + c' * ln (- ln (- x)) \<le> - 1; - exp (- 1) \<le> x\<rbrakk> \<Longrightarrow> c' * ln (- ln (- x)) \<le> Lambert_W' x - ln (- x) [PROOF STEP] case (elim x) [PROOF STATE] proof (state) this: x \<le> (ln (- x) + c' * ln (- ln (- x))) * exp (ln (- x) + c' * ln (- ln (- x))) ln (- x) + c' * ln (- ln (- x)) \<le> - 1 - exp (- 1) \<le> x goal (1 subgoal): 1. \<And>x. \<lbrakk>x \<le> (ln (- x) + c' * ln (- ln (- x))) * exp (ln (- x) + c' * ln (- ln (- x))); ln (- x) + c' * ln (- ln (- x)) \<le> - 1; - exp (- 1) \<le> x\<rbrakk> \<Longrightarrow> c' * ln (- ln (- x)) \<le> Lambert_W' x - ln (- x) [PROOF STEP] hence "Lambert_W' x \<ge> ln (-x) + c' * ln (-ln (-x))" [PROOF STATE] proof (prove) using this: x \<le> (ln (- x) + c' * ln (- ln (- x))) * exp (ln (- x) + c' * ln (- ln (- x))) ln (- x) + c' * ln (- ln (- x)) \<le> - 1 - exp (- 1) \<le> x goal (1 subgoal): 1. ln (- x) + c' * ln (- ln (- x)) \<le> Lambert_W' x [PROOF STEP] by (intro Lambert_W'_geI) [PROOF STATE] proof (state) this: ln (- x) + c' * ln (- ln (- x)) \<le> Lambert_W' x goal (1 subgoal): 1. \<And>x. \<lbrakk>x \<le> (ln (- x) + c' * ln (- ln (- x))) * exp (ln (- x) + c' * ln (- ln (- x))); ln (- x) + c' * ln (- ln (- x)) \<le> - 1; - exp (- 1) \<le> x\<rbrakk> \<Longrightarrow> c' * ln (- ln (- x)) \<le> Lambert_W' x - ln (- x) [PROOF STEP] thus ?case [PROOF STATE] proof (prove) using this: ln (- x) + c' * ln (- ln (- x)) \<le> Lambert_W' x goal (1 subgoal): 1. c' * ln (- ln (- x)) \<le> Lambert_W' x - ln (- x) [PROOF STEP] by simp [PROOF STATE] proof (state) this: c' * ln (- ln (- x)) \<le> Lambert_W' x - ln (- x) goal: No subgoals! [PROOF STEP] qed [PROOF STATE] proof (state) this: \<forall>\<^sub>F x in at_left 0. c' * ln (- ln (- x)) \<le> Lambert_W' x - ln (- x) goal (4 subgoals): 1. \<And>c'. c' \<in> {- 1<..<?u} \<Longrightarrow> \<forall>\<^sub>F x in at_left 0. Lambert_W' x - ln (- x) \<le> c' * ln (- ln (- x)) 2. - 2 < - 1 3. - 1 < ?u 4. - 1 \<noteq> 0 [PROOF STEP] next [PROOF STATE] proof (state) goal (4 subgoals): 1. \<And>c'. c' \<in> {- 1<..<?u} \<Longrightarrow> \<forall>\<^sub>F x in at_left 0. Lambert_W' x - ln (- x) \<le> c' * ln (- ln (- x)) 2. - 2 < - 1 3. - 1 < ?u 4. - 1 \<noteq> 0 [PROOF STEP] fix c' :: real [PROOF STATE] proof (state) goal (4 subgoals): 1. \<And>c'. c' \<in> {- 1<..<?u} \<Longrightarrow> \<forall>\<^sub>F x in at_left 0. Lambert_W' x - ln (- x) \<le> c' * ln (- ln (- x)) 2. - 2 < - 1 3. - 1 < ?u 4. - 1 \<noteq> 0 [PROOF STEP] assume c': "c' \<in> {-1<..<0}" [PROOF STATE] proof (state) this: c' \<in> {- 1<..<0} goal (4 subgoals): 1. \<And>c'. c' \<in> {- 1<..<?u} \<Longrightarrow> \<forall>\<^sub>F x in at_left 0. Lambert_W' x - ln (- x) \<le> c' * ln (- ln (- x)) 2. - 2 < - 1 3. - 1 < ?u 4. - 1 \<noteq> 0 [PROOF STEP] have "eventually (\<lambda>x. x \<ge> (ln (-x) + c' * ln (-ln (-x))) * exp (ln (-x) + c' * ln (-ln (-x)))) (at_left 0)" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<forall>\<^sub>F x in at_left 0. (ln (- x) + c' * ln (- ln (- x))) * exp (ln (- x) + c' * ln (- ln (- x))) \<le> x [PROOF STEP] using c' [PROOF STATE] proof (prove) using this: c' \<in> {- 1<..<0} goal (1 subgoal): 1. \<forall>\<^sub>F x in at_left 0. (ln (- x) + c' * ln (- ln (- x))) * exp (ln (- x) + c' * ln (- ln (- x))) \<le> x [PROOF STEP] by real_asymp [PROOF STATE] proof (state) this: \<forall>\<^sub>F x in at_left 0. (ln (- x) + c' * ln (- ln (- x))) * exp (ln (- x) + c' * ln (- ln (- x))) \<le> x goal (4 subgoals): 1. \<And>c'. c' \<in> {- 1<..<?u} \<Longrightarrow> \<forall>\<^sub>F x in at_left 0. Lambert_W' x - ln (- x) \<le> c' * ln (- ln (- x)) 2. - 2 < - 1 3. - 1 < ?u 4. - 1 \<noteq> 0 [PROOF STEP] moreover [PROOF STATE] proof (state) this: \<forall>\<^sub>F x in at_left 0. (ln (- x) + c' * ln (- ln (- x))) * exp (ln (- x) + c' * ln (- ln (- x))) \<le> x goal (4 subgoals): 1. \<And>c'. c' \<in> {- 1<..<?u} \<Longrightarrow> \<forall>\<^sub>F x in at_left 0. Lambert_W' x - ln (- x) \<le> c' * ln (- ln (- x)) 2. - 2 < - 1 3. - 1 < ?u 4. - 1 \<noteq> 0 [PROOF STEP] have "eventually (\<lambda>x::real. x < 0) (at_left 0)" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<forall>\<^sub>F x in at_left 0. x < 0 [PROOF STEP] by (auto simp: eventually_at intro: exI[of _ 1]) [PROOF STATE] proof (state) this: \<forall>\<^sub>F x in at_left 0. x < 0 goal (4 subgoals): 1. \<And>c'. c' \<in> {- 1<..<?u} \<Longrightarrow> \<forall>\<^sub>F x in at_left 0. Lambert_W' x - ln (- x) \<le> c' * ln (- ln (- x)) 2. - 2 < - 1 3. - 1 < ?u 4. - 1 \<noteq> 0 [PROOF STEP] ultimately [PROOF STATE] proof (chain) picking this: \<forall>\<^sub>F x in at_left 0. (ln (- x) + c' * ln (- ln (- x))) * exp (ln (- x) + c' * ln (- ln (- x))) \<le> x \<forall>\<^sub>F x in at_left 0. x < 0 [PROOF STEP] show "eventually (\<lambda>x. Lambert_W' x - ln (-x) \<le> c' * ln (-ln (-x))) (at_left 0)" [PROOF STATE] proof (prove) using this: \<forall>\<^sub>F x in at_left 0. (ln (- x) + c' * ln (- ln (- x))) * exp (ln (- x) + c' * ln (- ln (- x))) \<le> x \<forall>\<^sub>F x in at_left 0. x < 0 goal (1 subgoal): 1. \<forall>\<^sub>F x in at_left 0. Lambert_W' x - ln (- x) \<le> c' * ln (- ln (- x)) [PROOF STEP] proof eventually_elim [PROOF STATE] proof (state) goal (1 subgoal): 1. \<And>x. \<lbrakk>(ln (- x) + c' * ln (- ln (- x))) * exp (ln (- x) + c' * ln (- ln (- x))) \<le> x; x < 0\<rbrakk> \<Longrightarrow> Lambert_W' x - ln (- x) \<le> c' * ln (- ln (- x)) [PROOF STEP] case (elim x) [PROOF STATE] proof (state) this: (ln (- x) + c' * ln (- ln (- x))) * exp (ln (- x) + c' * ln (- ln (- x))) \<le> x x < 0 goal (1 subgoal): 1. \<And>x. \<lbrakk>(ln (- x) + c' * ln (- ln (- x))) * exp (ln (- x) + c' * ln (- ln (- x))) \<le> x; x < 0\<rbrakk> \<Longrightarrow> Lambert_W' x - ln (- x) \<le> c' * ln (- ln (- x)) [PROOF STEP] hence "Lambert_W' x \<le> ln (-x) + c' * ln (-ln (-x))" [PROOF STATE] proof (prove) using this: (ln (- x) + c' * ln (- ln (- x))) * exp (ln (- x) + c' * ln (- ln (- x))) \<le> x x < 0 goal (1 subgoal): 1. Lambert_W' x \<le> ln (- x) + c' * ln (- ln (- x)) [PROOF STEP] by (intro Lambert_W'_leI) [PROOF STATE] proof (state) this: Lambert_W' x \<le> ln (- x) + c' * ln (- ln (- x)) goal (1 subgoal): 1. \<And>x. \<lbrakk>(ln (- x) + c' * ln (- ln (- x))) * exp (ln (- x) + c' * ln (- ln (- x))) \<le> x; x < 0\<rbrakk> \<Longrightarrow> Lambert_W' x - ln (- x) \<le> c' * ln (- ln (- x)) [PROOF STEP] thus ?case [PROOF STATE] proof (prove) using this: Lambert_W' x \<le> ln (- x) + c' * ln (- ln (- x)) goal (1 subgoal): 1. Lambert_W' x - ln (- x) \<le> c' * ln (- ln (- x)) [PROOF STEP] by simp [PROOF STATE] proof (state) this: Lambert_W' x - ln (- x) \<le> c' * ln (- ln (- x)) goal: No subgoals! [PROOF STEP] qed [PROOF STATE] proof (state) this: \<forall>\<^sub>F x in at_left 0. Lambert_W' x - ln (- x) \<le> c' * ln (- ln (- x)) goal (3 subgoals): 1. - 2 < - 1 2. - 1 < 0 3. - 1 \<noteq> 0 [PROOF STEP] qed auto [PROOF STATE] proof (state) this: (\<lambda>x. Lambert_W' x - ln (- x)) \<sim>[at_left 0] (\<lambda>x. - 1 * ln (- ln (- x))) goal (1 subgoal): 1. (\<lambda>x. Lambert_W' x - ln (- x)) \<sim>[at_left 0] (\<lambda>x. - ln (- ln (- x))) [PROOF STEP] thus ?thesis [PROOF STATE] proof (prove) using this: (\<lambda>x. Lambert_W' x - ln (- x)) \<sim>[at_left 0] (\<lambda>x. - 1 * ln (- ln (- x))) goal (1 subgoal): 1. (\<lambda>x. Lambert_W' x - ln (- x)) \<sim>[at_left 0] (\<lambda>x. - ln (- ln (- x))) [PROOF STEP] by simp [PROOF STATE] proof (state) this: (\<lambda>x. Lambert_W' x - ln (- x)) \<sim>[at_left 0] (\<lambda>x. - ln (- ln (- x))) goal: No subgoals! [PROOF STEP] qed
{-# OPTIONS --without-K --rewriting #-} open import HoTT module homotopy.AnyUniversalCoverIsPathSet {i} (X : Ptd i) where private a₁ = pt X path-set-is-universal : is-universal (path-set-cover X) path-set-is-universal = has-level-in ([ pt X , idpβ‚€ ] , Trunc-elim {P = Ξ» xpβ‚€ β†’ [ pt X , idpβ‚€ ] == xpβ‚€} (Ξ»{(x , pβ‚€) β†’ Trunc-elim {P = Ξ» pβ‚€ β†’ [ pt X , idpβ‚€ ] == [ x , pβ‚€ ]} (Ξ» p β†’ ap [_] $ pair= p (lemma p)) pβ‚€ })) where lemma : βˆ€ {x} (p : pt X == x) β†’ idpβ‚€ == [ p ] [ (pt X =β‚€_) ↓ p ] lemma idp = idp module _ {j} (univ-cov : βŠ™UniversalCover X j) where private module univ-cov = βŠ™UniversalCover univ-cov instance _ = univ-cov.is-univ -- One-to-one mapping between the universal cover -- and the truncated path spaces from one point. [path] : βˆ€ (a⇑₁ a⇑₂ : univ-cov.TotalSpace) β†’ a⇑₁ =β‚€ a⇑₂ [path] a⇑₁ a⇑₂ = –> (Trunc=-equiv [ a⇑₁ ] [ a⇑₂ ]) (contr-has-all-paths [ a⇑₁ ] [ a⇑₂ ]) abstract [path]-has-all-paths : βˆ€ {a⇑₁ a⇑₂ : univ-cov.TotalSpace} β†’ has-all-paths (a⇑₁ =β‚€ a⇑₂) [path]-has-all-paths {a⇑₁} {a⇑₂} = transport has-all-paths (ua (Trunc=-equiv [ a⇑₁ ] [ a⇑₂ ])) $ contr-has-all-paths {{has-level-apply (raise-level -2 univ-cov.is-univ) [ a⇑₁ ] [ a⇑₂ ]}} to : βˆ€ {aβ‚‚} β†’ univ-cov.Fiber aβ‚‚ β†’ a₁ =β‚€ aβ‚‚ to {aβ‚‚} a⇑₂ = apβ‚€ fst ([path] (a₁ , univ-cov.pt) (aβ‚‚ , a⇑₂)) from : βˆ€ {aβ‚‚} β†’ a₁ =β‚€ aβ‚‚ β†’ univ-cov.Fiber aβ‚‚ from p = cover-trace univ-cov.cov univ-cov.pt p abstract to-from : βˆ€ {aβ‚‚} (p : a₁ =β‚€ aβ‚‚) β†’ to (from p) == p to-from = Trunc-elim (Ξ» p β†’ lemma p) where lemma : βˆ€ {aβ‚‚} (p : a₁ == aβ‚‚) β†’ to (from [ p ]) == [ p ] lemma idp = apβ‚€ fst ([path] (a₁ , univ-cov.pt) (a₁ , univ-cov.pt)) =⟨ ap (apβ‚€ fst) $ [path]-has-all-paths ([path] (a₁ , univ-cov.pt) (a₁ , univ-cov.pt)) (idpβ‚€ :> ((a₁ , univ-cov.pt) =β‚€ (a₁ , univ-cov.pt))) ⟩ (idpβ‚€ :> (a₁ =β‚€ a₁)) ∎ from-to : βˆ€ {aβ‚‚} (a⇑₂ : univ-cov.Fiber aβ‚‚) β†’ from (to a⇑₂) == a⇑₂ from-to {aβ‚‚} a⇑₂ = Trunc-elim {{Ξ» p β†’ =-preserves-level {x = from (apβ‚€ fst p)} {y = a⇑₂} univ-cov.Fiber-is-set}} (Ξ» p β†’ to-transp $ snd= p) ([path] (a₁ , univ-cov.pt) (aβ‚‚ , a⇑₂)) theorem : βˆ€ aβ‚‚ β†’ univ-cov.Fiber aβ‚‚ ≃ (a₁ =β‚€ aβ‚‚) theorem aβ‚‚ = to , is-eq _ from to-from from-to
function res = TTeMPS_op_laplace_to_TTeMPS_op( A ) %TTeMPS_op_laplace_to_TTeMPS Convert to TT_op_laplace to TTeMPS_op format. % % See also TTeMPS_to_TT, TTeMPS_op_to_TT, TTeMPS_op_laplace_to_TTeMPS_op. % TTeMPS Toolbox. % Michael Steinlechner, 2013-2016 % Questions and contact: [email protected] % BSD 2-clause license, see LICENSE.txt C = cell(1, A.order); for i = 1:A.order % make a 4D tensor out of it again tmp = reshape( full(A.U{i}), [A.rank(i), A.rank(i+1), A.size_col(i), A.size_row(i)] ); % inverse permute the indices C{i} = ipermute( tmp, [1 4 2 3] ); end res = TTeMPS_op(C); end