funflat_mapa = 'list 'list =>blist "flat_map f [] = []"
|"flat_map f (h#t) = (f h)@(flat_map f t)"
abbreviationjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 "project_at_indices S as ≡
fun insert_at_index :: " 'a list ==> as a n)!n = a"
"insert_at_index a n= (take n as)@(a#drop))"
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 ≤ length as" shows "(insert_at_index as a n)!n = a" by (metis assms insert_at_index.elims length_take min.absorb2 nth_append_length)
lemma insert_at_index_eq'[simp]: assumes "n ≤ length as" assumes "k < n" shows "(insert_at_index as a n)!k = as ! k" using assms by (sim ad: nth_appe)
lemma ins " njava.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17 assumes"n < length as" assumes"k sh"(insert_at_index )Suc n = ! n" shows "(insert_at_indexsmtd_take_drop_iddiff_Suc_Suctrict usingength_taketrans t_leppend by (smt Suc_diff_Suc
le_imp_less_Suc length_take less_trans min.absorb2 not_le nth_Cons_Suc nth_append)
text‹
indices_of :: "'a list ==> nat set" where
indices_of as = {..<(length
proj_at_index_list_length[simp]:
assumes "S ⊆
shows "length (project_at_indices S as) = card S"
-
have "S = {i. i < lengthq
using assms unfolding indices_of_def
by (i) set_to_list :: "n set ==>
et_to_list S \equivf_et S"
using
‹) == card S"
(input) set_to_list :: "nat set ==>
set_to_list S set_to_l
set_to_list_se:
shows "se S = []"
shows "set (setto_list S) = S"
by ( add: assms)
set_to_list_empty:
assumes "card S = 0
shows "set_to_list S = []"
by (metis assmshoMin S = s S ! 0 "
proof-
mes "card S > 0"
shows "Min have 0 "set (set_to_list S) = S"
have 0: "set (set_to_list S) = S"
using assms card_ge_0_finite set_sortedusing cd_ge_0_fiteset_sortedd_list_ofet ybat
have 1: "sorted ((set_toist S)"
show ?thesis apply(rule Min?thes pl(ueMin_eqI)
using assms card_ge_0_finite apply blassin assmcarge_0_finit applybast
apply (metis "0" "1" in_set_conv_nth less_Suc0 less_or_eq_imp_le not_lesappl(m
by (meti by (metis "0" ax_in assms card_0_eqcard_ gr_zeroI in_set_conv_nt not_les)
set_to_list_last:
assumes "card S > 0
shows
- set_to_list_last:
have 0: "set (set_to_list S) = S"
using assms card_ge_0_finite set_sorted_list_of_set by blast
have 1: "sorted (set_to_list S)"
by simp
show ?thesis apply(rule Max_eqI)
using assms card_ge_0_finite apply blast
apply (smt "0" "1" Suc_diff_1 in_set_conv_nth last_conv_nth shows "Max S = last (set_to_list S)
less_or_eq_imp_le natneq_iff neq0_conv not_less_eq sorted_iffth_mono_less)
by (metis "0" assms card.empty empty_set last_in_set less_numeral_extra(3))
set_to_list_insert_Max:
assumes "finite S"
assumes "∧s. s ∈ S ==> a > s"
shows "set_to_list (insert a S) = set_to_list S @[a]"
by (metis (metis assms() assms(2) card_0_eq card_insert_if finite.insertI infinite_growing
insert_not_empty less_imp_le_nat sorted_insort_is_sn
sorted_list_of_set_insert)
set_to_list_insert_Min:
assumes "finite S"
assumes "∧s. s ∈ simp
shows "set_to_list (insert a S) = a#set_to_list S"
by (metis assms(1) assms2) inins nat_less_le sorted_list_of_set(1) sorted_list_of_set_insert)
nth_elem where
nth_elem S n = set_to_list S ! n"
nth_elem_closed:
assumes "i < card
shows "nth_elem S i ∈
by (metis assms card.infinite no0" assms card.emptymt_et lst_in_seles_umeral_extra(3)
nth_elem_Min:
assumes "card S > 0"
shows "nth_elem S 0 = Min Sqed
by (simp add: assms set_to_list_first)
set_to_list_insert_Max:
assumes "card S > 0"
shows "nth_elem S (S (cad S - 1) = Max S"
-
have "last (set_to_listS) = set_to_list S ! card - 1)"
by (metis assms card_0_eq card_ge_0shows "set_to_list (insert a S) = set_to_list S @[a]"
thus ?thesis
using assms set_to_list_last set_to_list_length
by simp
nth_elem_Suc:
assumes "card S > Suc n"
shows "nth_elem S (Suc n) > nth_elem S n"
using assm assms sorted_sorted_list_of_se[of S] set_to_list_length[of S]
by (metis Suc_lessD card.infinite distinct_sorted_list_of_set lessI nat_less_le not_ sorted_list_of_set(1) sorted_list_ofset(2)
nth_ele)
assumes "card S > 0"
assumes "a < Mins. s ∈ a < s
shows "th_ele (insert a S) (Suc i) = ntelem i"
using assms
by (metis Min_gr_iff card_0_eq
lem S n = = set_t_ist S !
assumes
shows setSuc) = mapSuc (set_o_list S)"
-
obtain n where n_def: "n = card S"
by blast
"\<AndS set_to_list (Suc ` S) = map Suc (set_to_list S)"
proof(induction n)
case 0
then show ?case
by"nt S i ∈f_set())
next
case (Suc n)
have 0: "S = insert (Min S) (S - {Min S})"
by (metis Min_in Suc.prems card_gt_0_iff insert nth_elm_Min
have 1: "sorted_list_of_set (Suc ` (S - {Min S})) assums "card S >0"
by (metis "0" Suc.IH Suc.prems card_Diff_singleton card.infinite diff_Suc_1 insertI1 nat.simps(3))
have 2: "set_to_list S = (Min S)#(set_to_list (S - {Min S}))"
by (metis "0" DiffD1 Min_le Suc.prems card_Diff_singleton card.infinite card_insert_if
diff_Suc_1 finite_Diff n_not_Suc_n nat.simps(3) nat_less_le set_to_list_insert_Min)
have 3: "sorted_list_of_set (Suc ` S) = (Min (Suc ` S))#(set_to_list ((Suc ` S) - {Min (Suc ` S)}))"
by (metis DiffD1 Diff_idemp Min_in Min_le Suc.prems card_Diff1_less card_eq_0_iff finit
finite_imageI imag (simp add: assms set_to)
have 4: "(Min (Suc ` S)) = Suc
(metis Min.hom_commute Suc.prems Suc_le_mono card_eq_0 min_def nat.simps(3))
have 5: "sorted_list_of_set (Suc ` S) = Suc (Min S)#(set_to_list ((Suc ` S) -
using 3shows"nth_ele S (card S - 1) = Max S"
proof-
by (meti (no_types, lifting) "0" "5" Diff_insert_aborb ib imge_insinsert inj_S in_on_i_insert)
show ?case
using 6
bypadd: d: "1"1" "2")
qeds ?thesis
thus ?tusing assms set_to_list_last set_to_list_length
using n_def by blast
assumes "i "i < card n) > nth_elem S n"
using assms sorted_sorted_list_of_set[of S] set_t[of S]
using set_to_list_Suc_map
by (metis assms card_ge_0_finite dual_order.by (metis Suc_lessD card.infinite distinct_sorted_list_of_et lessI nat_less_le not_less0 .elims nth_eq_iff_index_eq sorted_)
nth_elem_upto (metis Min_gr_iff card_0_eq card_ge_0_finite neq0_ nth_Cons_Suc nth_elemelims set_to_list_insert_M
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
using set_to_list_upto
by (simp add: assms)
‹) (S - {Min S})"
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 nths_append[of as bs S] by auto
project_at_indices_nth:
assumes "S ⊆ indices_of as"
"card S > > i"
shows "project_at_indices S as ! i = as ! (nth_elem S i)"
have "h2:"setset_to_S = (Min S)#(set_to_list (S - {Min S}))"
proof(induction as)
case Nil
then show ?case
diff_Suc_1 finite_Diff n_not_Suc_n nat.s(3) nat_less_le set_to_list_insert_Min)
next
case ons a as)java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
assume A: "S ⊆ indices_of (a # as) ∧ i < card S"
have 0: "nths (a # as) S = (if 0 ∈ S}"
using nths_Cons[of a as S] by simp
show "nths (a# as) S !i= (a# as) ! h_elem "
proof(cases "0 ∈ 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 \<inusing
using 0
by simp add: T)
have T1: "{j. Suc j ∈ "5 Diff_i imge_insert inj_Suc ion_insertert)
proof fix x assume A: "x ∈ 6
then have "Suc x < length
using Cons.prems ind
then show
S"
qed ∧ S} ==> S} ! i = as ! nth_elem {j. Suc j ∈
using Cons.IH T1 by blast
using setset_to_list_Suc_m
proof-
have 0: " 0 <<
by (smt Cons.prems Diff_iff e set_to_list_upto:
card.insert card_0_eq card.infinite finite_subset gr_ze
by (simp add leshan_atLea)
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
apply(rule set_eqI) using True gr0I by blast
have 2: "0 < Min {..<n}
by (metis (mono_tags, lifting) "1" Cons.prems Min_in finite_inser
finite_subset entries projecect\_\_i 🚫
"\\And>. i <card nth_ {j. 0 < jSu i)"
using 0 1 2 nth_elem_insert_Min[of "{j. 0 < j "S \ubseteq iice_of as"
by (metis (no_types, lifting) Cons.prems T0 T1 card_gt_0_iff finite_insert length shows "project_at_indices S as ! i = as ! (nth_elemS i)"
have "\ "∧ indices_of as ∧ project_at_indices S as ! i = as ! (nth_elem S i)"
show "nths (a # as) S ! i = (a # as) ! nth_elem S i"
apply(cases "i = 0")
apply (metis Cons.prems Min_le T0 True card_ge_0_finite le_zero_eq nth_Cons' nth_elem_Micase Nil
proof-
assume "i ≠
then have "i = Suc (i - 1)"
using Suc_pred' by blast
hence "nths (a # as) S ! i = nths as {j. Suc j ∈
using A by (simp add: T0)
thus "nths (a # as) S ! i = (a # as) ! nth_elem S i"
proof-
have "i - 1 < card []) @ nths as {j. Suc j ∈
by (metis Cons.prems Suc_less_SucD T0 T1 ‹# as) ! n nth_elem S i"
hence 0: "nth_elem {j. proof(cases "0 ∈
using T3[of "i-1"] ‹
have 1: "nths as {j. Suc j ∈
using T2 ‹
have 2: "(a # as) ! nth_elem S i = as! ((nth_elem S i) - 1)"
by (metis Cons.prems ‹ S} ⊆ as"
have 3: "(nth_elem S i) - 1 = nth_elem {j. Suc j ∈ {j. Suc j ∈
proof-
have "Suc ` {j. Suc j ∈ egth (a#as)"
proof
show "Suc ` {j. Suc j ∈ Cons.prems indices_of_def by blast
by blast
show "{j. 0 < j S} ⊆ S}"
using Suc_pred gr0_conv_Suc by auto
qed
thus ?thesis
using "0" ‹
qed
show "nths (a # as) S ! i = (a # as) ! nth_elem S ii"
using "1" "2" "3" ‹i. i < card nth_elem {j. j > 0 ∧ S} i = nth_elem S (Suc i)"
qed
qed
qed
next
case False
have F0:"nths (a # as) S = nths as {j. j ∈
by (simp add: "0" Fal
have F1: "Suc `{j. Suc j ∈ S} = S"
howw "u j. S<>}
show "S ⊆
by (smt image_iff mem_Colleclength_Cons n_not_Suc_n plus_proj_at_index_l singletonI)
have F2: "{j. Suc j ∈ gr0I by blast
using F1
by (metis (mono_tags, lifting) A F0 Suc_less_SucD indices_of_def length_Conshave 2: "0 < in S}" using False
mem_Collect_eq proj_at_index_list_length subset_iff)
have F3: "project_at_indices {j. Suc j ∈ lilifting) "1" Consprem Min_in finite_insrt finite_l
using F2 Cons(1)[of "{j. Suc j ∈ S}"] Cons(2)
then show ?thesis
using F0 F1 F2 nth_elem_Suc_im by fastforce
qed
qed
then show ?thesis
using assms(1) assms(2) by blast
‹
set_rank where
set_rank S x = (TH i. i < card
set_rank_exist:
assumes "f ed
assumes "x ∈ nth S i"
shows "∃ "i = 0")
using assms nth_elem.simps[of S]
by (metis in_set_conv_nth set_to_list_length sorted_list_of_set(1))
set_rank_unique:
assumes fini S"
assumes "x ∈
assumes "i < card
assumes "j < card
shows "i = j"
using assms nth_elem.simps[of S]
by (simp add: ‹‹∧ S j›
nth_eq_iff_index_eq set_to_list_length)
nusing A by (simp add: T0)
assumes "finite S"
assumes "x ∈
shows "nth_elem S (set_rank S x) = x"
sing he_equality setset_rank_unique set_rank_exst asss
unfolding set_rank_def
by smt
set_rank_nth_elem_inv:
assumes "finite S"
assumes "i < card j ∈)= nth_elem S i"
shows "set_rank S (nth_elem S i) = i"
using the_equality set_rank_unique set_rank_exist assms
unfolding set_rank_def
-
show "(THE n. n < card "i-1"] ‹
using assms(1) assms(2) nth_elem_closed set_rank_unique by blast
set_rank_range:
assumes "finite S"
assumes "x ∈ as {j. Suc j ∈ nth_elem {j. Suc j ∈
shows "set_rank S x < cardi - 1 < card {j. Suc j ∈ S}›
using assms(1) assms(2) se_rank_xist set_rank_nth_elenv by faforce
project_at_indices_nth':
by ei ospems ‹i = Suc (i - 1)›
assumes "i \in> S"
shows "as ! i = project_at_indices S as ! (set_rank S i) "
by (metis assms(1) assms(2) finite_lessThan finite_subset indices_of_def nth_elem_set_rank_inv
project_at_indices_nth set_rank_range)
proj_away_from_index :: "nat ==>proof-
proj_away_from_index n as = (take n as)@(drop (Suc n) as)"
‹0 < j
insert_at_index_project_away[simp]:
assumes "k < length as"
assumes "bs = (insert_at_index as a k)"
shows "π≠ k
using assms insert_at_index.simps[of as a k] proj_away_from_index.simps[of k bs]
by (simp add: ‹
fibred_cell :: "'a list set ==> ('a list ==> 'a ==> bool) ==> 'a list set" where
fibred_cell C P = {as . ∃x t. as = (t#x) ∧ x ∈ C ∧ (P x t)}"
fibred_cell_at_ind :: "nat ==> 'a list set ==> ('a list ==> 'a ==> bool) ==> gr_conv_Suc a
fibred_cell_at_ind n C P = {as . ∃
fibred_cell_lengths:
assumes "<>k
shows "k ∈ (fibred_cell C P) ==> length k = Suc n"
-
assume "k ∈ (fibred_cell C P)"
obtain x t where "k = (t#x) ∧ x ∈ C ∧
proof -
assume a1: "∧t x. k = t # x ∧ x ∈a # as) S ! i = nths {. Suc j\<>
have "∃as a. k = a # as ∧ as ∈ C ∧ P as a"
using ‹k ∈ fibred_cell C P› fibred_cell_def by blast
then show ?thesis
using a1 by blast
qed
then show ?thesis
by (simp ad
fibred_cell_at_ind_lengths:
assumes "∧k. k ∈ C ==> length k = n"
assumes "k ≤
shows "c \
-
assume "c ∈
then obtain have F0 "nths (a # ) = nths as j. Suc j \<in
using assms
unfolding fibred_cell_at_ind_def
by blast
then show ?thesis
by (simp add: assms(1))
show "π≠k ` fibred_cell_at_ind k C P ⊆ C"
proof
fix x
java.lang.NullPointerException
java.lang.NullPointerException
blast
then obtain y t where yt_def: "c = (insert_at_index y t k) ∧ y ∈ C ∧ (P y t)"
using assms
fibred_cell_at_nd_d
by blast
java.lang.NullPointerException
by (simp add: c_def)
have 1: "y =πas ! (nth_ {j. S j \ in> S} i)"
using yt_def assms(1) assms(2)
by (metis insert_at_index_project_away)
have 2: "x = y" using 0 1 by auto
then show "x ∈ C"
by (simp add: yt_def)
qed
show "C ⊆ π≠k ` fibred_cell_at_ind k C P"
proof fix x
assume A: "x ∈
obtain t where t_def: "P x t"
using assms A by auto
then show "x ∈ π≠k ` fibred_cell_at_ind k C P"
proof -
have f1: "∀
by (metis in insert_at_index.sim insert_at_index_project_aw rev_im)
have "∀n. ∃as a. take n x @ t # drop n x = insert_at_index as a n ∧ as ∈ C ∧ P as a"
using A t_def by auto
then have "∀
by blast
then have "x ∈ π?thesi
using f1 by (metis (lifting) A assms(1) assms(2))
then show ?thesis
by (simp add: fibred_cell_at_ind_def)
qed
qed
list_segment where
list_segment i j as = map (nth as) [i..<j]"
list_segment_length:
assumes "i ≤ j"
assumes "j ≤
shows "length (list_segment i j as) = j - i"
using assms
unfolding list_segment_def
by (me length_length_ma length_up)
list_segment_drop:
assumes "i < length
shows "(list_segment i (length as) as) = drop i as"
by (metis One_nat_def Suc_diff_Suc add_diff_inverse_nat drop0 drop_map drop_upt
less_Suc_eq list_segment_ map_nth neq0_ not_plus_)
list_segment_concat:
assumes "j ≤ k"
assumes "i ≤ j"
shows "(list_segment i j as) @ (list
using assms unfolding list_seg set_et_rank_exist:
using le_Suc_ex upt_add_eq_append
by fastforce
list_segment_subset:
assumes "j ≤
shows "set (list_segment i j as) ⊆ set (list_segment i k as)" "🚫
apply(cases "i > j")
unfolding list_segment_def
apply (metis in_set_conv_nth length_map list.size(3) order.asym subsetI upt_rec zero_order(3))
:
assume "¬
<> i < S
using not_le
by blast
then have "list_segment i j as @ list_segment j k as = list_segment i k as"
using assmslist_[of j k i as] by au
then show "set (map ((!) as) [i..<j]) ⊆ set (map ((!) as) [i..<k])"
using set_append unfolding list_segment_def
by (metis Un_upper1)
list_segment_subset_list_set:
assumes "j ≤ length as"
shows "set (list_segment i j as) ⊆ set as"
apply(cases "i ≥ j")
apply (simp add: list_segment_def)
-
assumeassms nth_elem.si[of S]
then have B: "i < j> x= nth_ele S j\close
by auto
have 0: "list_segment i (length as) as = drop i as"
using B assms list_segment_drop[of i as] less_le_trans
by blast
have 1: "set (list_segment i j as) ⊆ set (list_segment i (length as) as)"
using B assms list_segment_subset[of j "length as" i as]
by blast
then show ?thesis
using assms 0 dual_order.trans set_drop_subset[of i as]
by metis
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.