469 |
469 |
470 lemma ball_in_set_sublist'_conv: "(\<forall>j \<in> set (sublist' l r xs). P j) = (\<forall>k. l \<le> k \<and> k < r \<and> k < List.length xs \<longrightarrow> P (xs ! k))" |
470 lemma ball_in_set_sublist'_conv: "(\<forall>j \<in> set (sublist' l r xs). P j) = (\<forall>k. l \<le> k \<and> k < r \<and> k < List.length xs \<longrightarrow> P (xs ! k))" |
471 unfolding set_sublist' by blast |
471 unfolding set_sublist' by blast |
472 |
472 |
473 |
473 |
474 lemma multiset_of_sublist: |
474 lemma mset_sublist: |
475 assumes l_r: "l \<le> r \<and> r \<le> List.length xs" |
475 assumes l_r: "l \<le> r \<and> r \<le> List.length xs" |
476 assumes left: "\<forall> i. i < l \<longrightarrow> (xs::'a list) ! i = ys ! i" |
476 assumes left: "\<forall> i. i < l \<longrightarrow> (xs::'a list) ! i = ys ! i" |
477 assumes right: "\<forall> i. i \<ge> r \<longrightarrow> (xs::'a list) ! i = ys ! i" |
477 assumes right: "\<forall> i. i \<ge> r \<longrightarrow> (xs::'a list) ! i = ys ! i" |
478 assumes multiset: "multiset_of xs = multiset_of ys" |
478 assumes multiset: "mset xs = mset ys" |
479 shows "multiset_of (sublist' l r xs) = multiset_of (sublist' l r ys)" |
479 shows "mset (sublist' l r xs) = mset (sublist' l r ys)" |
480 proof - |
480 proof - |
481 from l_r have xs_def: "xs = (sublist' 0 l xs) @ (sublist' l r xs) @ (sublist' r (List.length xs) xs)" (is "_ = ?xs_long") |
481 from l_r have xs_def: "xs = (sublist' 0 l xs) @ (sublist' l r xs) @ (sublist' r (List.length xs) xs)" (is "_ = ?xs_long") |
482 by (simp add: sublist'_append) |
482 by (simp add: sublist'_append) |
483 from multiset have length_eq: "List.length xs = List.length ys" by (rule multiset_of_eq_length) |
483 from multiset have length_eq: "List.length xs = List.length ys" by (rule mset_eq_length) |
484 with l_r have ys_def: "ys = (sublist' 0 l ys) @ (sublist' l r ys) @ (sublist' r (List.length ys) ys)" (is "_ = ?ys_long") |
484 with l_r have ys_def: "ys = (sublist' 0 l ys) @ (sublist' l r ys) @ (sublist' r (List.length ys) ys)" (is "_ = ?ys_long") |
485 by (simp add: sublist'_append) |
485 by (simp add: sublist'_append) |
486 from xs_def ys_def multiset have "multiset_of ?xs_long = multiset_of ?ys_long" by simp |
486 from xs_def ys_def multiset have "mset ?xs_long = mset ?ys_long" by simp |
487 moreover |
487 moreover |
488 from left l_r length_eq have "sublist' 0 l xs = sublist' 0 l ys" |
488 from left l_r length_eq have "sublist' 0 l xs = sublist' 0 l ys" |
489 by (auto simp add: length_sublist' nth_sublist' intro!: nth_equalityI) |
489 by (auto simp add: length_sublist' nth_sublist' intro!: nth_equalityI) |
490 moreover |
490 moreover |
491 from right l_r length_eq have "sublist' r (List.length xs) xs = sublist' r (List.length ys) ys" |
491 from right l_r length_eq have "sublist' r (List.length xs) xs = sublist' r (List.length ys) ys" |
492 by (auto simp add: length_sublist' nth_sublist' intro!: nth_equalityI) |
492 by (auto simp add: length_sublist' nth_sublist' intro!: nth_equalityI) |
493 ultimately show ?thesis by (simp add: multiset_of_append) |
493 ultimately show ?thesis by (simp add: mset_append) |
494 qed |
494 qed |
495 |
495 |
496 |
496 |
497 end |
497 end |