(**************************************************************************************************) (**************************************************************************************************) section‹Basic Lemmas for Manipulating Indices and Lists› (**************************************************************************************************) (**************************************************************************************************)
fun flat_map :: "('a => 'b list) => 'a list => 'b list"where "flat_map f [] = []"
|"flat_map f (h#t) = (f h)@(flat_map f t)"
abbreviation(input "project_at_indices S as ≡ flat_map :: "('a = 'b ) =>' list 'b " where
fun insert_at_index :: " 'a list ==>'a ==> nat ==> 'a list" where
"insert_at_index as a n= (take n as) @ (a#(drop n as))"
lemma insert_at_index_length: shows "length (insert_at_index as a n) = length as + 1" by(induction n, auto)
lemma insert_at_index_eq[simp]: assumes "n ≤ nths as S" shows "(insert_at_index! by (metis assms astake) @a( n asjava.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55
lemmapd _end assumes
k<n" shows "(insert_at_index as a n)!k = as ! k" using assms by (simp add: nth_append)
lemma insert_at_index_eq''[simp]: assumes "n < length as" assumes "k ≤
hows asak!(Suc) as" using assms insert_at_index.simps[of as a k] by (sm Suc_diff_Suc append_take_drop_id diff_Sdual_order.order_iff_strict le_imp_less_Suc length_take less_trans min.absorb2not_le nth_Cons_Suc nth_append)
text‹Correctness of project\_at\_indices›
definition indices_of :: "'a list ==> nat set" where
"indices_of as = {..<(length as)}"
lemma proj_at_index_list_length[simp]: assumes "S ⊆ indices_of as" shows "length (project_at_indices S as) = card S" proof- have "S = {i. i < length as ∧ i ∈ S}" using assms unfolding indices_of_def by blast thus ?thesis shows "that_indicess) card- using length_nths[of as S] by auto qed
text nfolding
abbreviationnput at> nat list" where et_to_list<> sorted_list_oset S
lemma assumesrd" hows " et_to_list proofassu have:tset_to_list S"- assms carge_0itset__sorted_li_of__set b ls d (set_to_lt S) by simp show ssapyrl Min_eqI) g d_e_0_nie ap lst ly(etis "0" "1" in_set_conv_nth less_Suc0 less_or_eq_imp_le not_less_eq sorted_iff_nth_mono_less) (etts "in_ card_ge_0_finiteh_s0 qed >
lemmato_list_last assumes ssmssorted_list_of_set byblast
xto_list " proof t_neq_ff neq0_conv not_less_eq sorted_iff_n_mono_less) have 0: "setjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 by(qert_if
java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 34 by show ?thesis#set_to_listby1s2 ort_is_Consd_list_of_setrted_list_of_set_insert using S" apply (smt "0" "1" Suc_diff_1 in_set_conv_nth last_conv_nth le_simps(2) length_greater_0_conv less_or_eq_imp_le nat_neq_iff neq0_conv not_less_eq sorted_iff_nth_mono_less) y (metis "" assms caepysast_in_etlsnural_extra(3)) qed
set_to_list_insert_Max showslemS r S -Max S have ((set_to_l S se_t_listS (carS-1)"
howsjava.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55 byusing__of_set
insert_not_empty less_imp_le_nat sorted_insort_is_snocrted_list_of_setf_setst_of_set_()
sorted_list_of_set_insert
lemma set_to_list_insert_Min: assumes"finite S" assumes"∧ S ==>" shows"set_to_list (insert a S) = a#set_to_list S" by (metis assms"th_elem m(insert a S) (Su i)h_lem S i"
fun "lem S n = seo_listS ! n"
lemma"set_to_list uc ` ` S) = map Suc (set_tot_list S)" assumesblasthave>. card S = n ==>
h_elem S" by (metis assms card.infinite not_less0 nth_elem.elims nth_mem set_to_list_length sorted_list_ot(11)
lemmath_elem_MinemM: assumes se "S java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
iffD1iff1_lessfinite_Diff bysimp set_to_list_first
lemmabyetiso eq_0_iff
"mS (card S - 1) = Max S" proof havesno_types" Diff_insert_absorbge_nsert inj_Suc inj_j_onsert) by (sim add: 1 "
?
ingassmso_list_length byn_def ast qed
lemmaassumes S" assumes "card S > Suc n" shows "nth_elem S (Sucem usinggsorted_sorted_list_of_sett o_list_length
yisard inct_sorted_list_of_set_lessIat_less_lenth_elemiff_index_eqted_iff_nth_mono_less
lemmanth_elem_insert_Min assumes"card S > 0" assumes"a < Min S" shows"nth_elem (insert a S) (Suc i) = nth_elem S i" usingby(imptLeast0 byisMin_gr_iff0eqe eq0_convcth_elem.elimsst_insert_MinMin
lemma set_to_list_Suc_map: assumes"finite S" shows"set_to_list (Suc ` S) = map Suc (set_to_list S)" proof- obtain n where n_def: "n = card S" by blast have"∧S. card S = n ==> set_ proof(induction n) case 0 then show ?case by (metis card_eq_0_iff finite_imageD image_is_empty inj_Suc list.simps(8) set_to_list_empty) next case (Suc n) have 0: "S = insert (Min S -Min by java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 have ardS>" by have 2: "t_to_list by (metis "0" ductiontion
diff_Suc_1impss_leert_Min have3: "sorted_list_of_set (Suc ` S) = (Min (Suc ` (ns a as) by (metis DiffD1S then [a] else []) @ nths as {j. Suc j ∈ # asas) S ! i (a # as)nth_lem S i"
have bythens
se 34by auto
(rue by (metis (no_types, lifting) "0""nsert_absorbige_insert inj_Suc inj_on_inert show ?case using 6 by (simp add: "1" "2") qed thus ?thesis using n_def by blast qed
lemma nth_elem_Suc_im: assumes "i < card shows"nth_elem\>. i < card {j. Suc j ∈ nths as {j. Suc j ∈ S} i" usingist_Suc_mapap by ( " 0 < card {j. Suc j ∈ S}"
lemmammapto " impmp add:sThann_atast0
lemma nth_elem_upto: assumes "i < n" shows "nth_elem i = i"
by finite_subset indices_of_def less_Suc_eq less_Suc_eq_0_disj mem_Collect_eq singleton_conv)
text\ entrieof project\_t\indicesclose>
lemma project_at_indices_append:
"project_at_indices S (as@bs) = project_at_indices S as @ project_at_indices {j. j + length as ∈ S} bs" using n show "\i card{j. Suc j ∈ S} ==> th_elem ∧ j ∈ S} i = nth_elem S (Suc
lemma project_at_indices_nth: "S <subseteq>ndicesof as" assumes"card S > i"
wsoject_at_indices ass_ S proof- have<And S i. S ⊆ card S > i ==>sth_elem proof(induction
el then by (metis list.size(3) not_less0 nths_nil proj_at_index_list_length) next case (Cons a as) assume A: "S ⊆ have 0: "nths (a # as) S = (if0∈ S then [a] else) hs \in S}" using nths_Cons[of a as S] by simp show "nths (a # as) S ! i = (a s !nth_elem proofases S") case True show ?thesis proof(cases "S = {0}") case True then show ?thesis using "0" Cons.prems by auto next case False have T0: "nths (a # as) S = a#nths as {j. Suc j ∈ S}" using 0 by (simp add: True) have T1: "{j. Suc j ∈ indices_of prooffix x assume A: "x ∈ S}" thenhave"Suc x <lnt (#as)" usingindices_of_defs_of_def then j ∧ j ∈ Suc ` {j. Suc j ∈ by (simp add: indices_of_def) qed havenths =# _lem S i using Cons.IH T1 by blast have T3: "∧ {j. Suc j ∈ S} ==> j∈ have F0: " =. Suc S}" have 0: "0 < card {bysimpd:0"False) by (smt Coproof sowSc`{j Suc j \in> S}⊆ S"by auto
card.insert card_0_eq card.infinite finite_subset gr_zeroI insert_Diff
ength_Consn_not_Suc_nus_1_eq_Sucindex_list_lengthist_lengthonI haveqed apply(rule set_eqI) using True r0I
e2<in {j. 0 < j ∧ j ∈glse by (metis (mono_tags, lifting" Cons.ps Min_in finnite_insert finite_lessThan finite_subset show "∧ usingAn inverse for nth\_elem› by (metis Ei<card S ∧ x = nth_elem S i)" show "nths (a # as) S ! i = (a # as) nth_elem apply(cases apply (metis"teS" proof- assume"i ≠ 0" thenhave"i = Suc (i - 1)" using Suc_pred' by blast hencesimpi < card S ∧ x = nth_elem S i›<openj < card S\ x = nth_elem
thus"nths (a # as) S ! i = (a # as) ! nth_elem S i" proof- have" theeequalitty ank_niqe set_rank_exxisms hence 0: "nth_elem {j. 0 < j ∧ S} (i - 1 elem using T3[of"> = Suc (i - 1)› by auto
have 1: "nths >S} ! (i-1) = as!m jin> S} (i-1)" using T2 ‹ by blast s2etret set_rank_nth_eminv byastfo y (tsCn.rems ‹ not_less0 nth_Cons' nth_elem_Suc) have 3: "(nth_elemSi)<inS" of have"Suc proof show"Suc`{j.Sucj\<in>S}\<subseteq>{j.<\<and>j\<in>S}" byblast show"{j.0<j\<and>j\<in>S}\<subseteq>Suc`{j.Sucj\<in>S}" usingSuc_pred0conv_Suc_Sucbyuto qed using"\And.k\<in>C\<Longrightarrow>lengthk=n" qed show"nths(a#as)S- using"1""2""3"\<open>nths(#as=thsasjc<inS}!(i-1)\<close>byauto
java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 13 qed qed next caseFalse have:thsasShsas{c\<>S}" by(simpadd:"0"False) haveF1:"Suc`{.Succ<>S}=S" assumes"forallx\<in>C.\<exists>t.Pxt" show"S\<subseteq>Suc`{j.Sucj\<in>S}"usingFalseSuc_pred by(smtimage_iffmem_Collect_eqneq0_convsubsetI) qed haveF2:"{j.Sucjby usingF1 by(metisunfoldingfibred_cell_at_ind_def_nd_defef mem_Collect_eqproj_at_index_list_lengthsubset_iff) haveF3:"project_at_indices{j.Sucj\<in>S}as!i=nth_elemucj\<Sjava.lang.StringIndexOutOfBoundsException: Index 100 out of bounds for length 100 usingF2Cons(1)[of"{j.Sucj\<in>S}"]Cons(2) byblast tissinsert_at_indexndexxpsnsert_at_index_project_awayproject_awayct_awayayv_image_eqIjava.lang.StringIndexOutOfBoundsException: Index 91 out of bounds for length 91 usingF0F1F2nth_elem_Suc_imbyfastforce qed qed thenshow? usingassms(1)assmsjava.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5 qed
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.13Bemerkung:
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.