[STATEMENT]
lemma outside_frontier_misses_closure:
    fixes S :: "'a::real_normed_vector set"
    assumes "bounded S"
    shows  "outside(frontier S) \<subseteq> - closure S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. outside (frontier S) \<subseteq> - closure S
[PROOF STEP]
unfolding outside_inside boolean_algebra_class.compl_le_compl_iff
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. closure S \<subseteq> frontier S \<union> inside (frontier S)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. closure S \<subseteq> frontier S \<union> inside (frontier S)
[PROOF STEP]
{
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. closure S \<subseteq> frontier S \<union> inside (frontier S)
[PROOF STEP]
assume "interior S \<subseteq> inside (frontier S)"
[PROOF STATE]
proof (state)
this:
interior S \<subseteq> inside (frontier S)

goal (1 subgoal):
 1. closure S \<subseteq> frontier S \<union> inside (frontier S)
[PROOF STEP]
hence "interior S \<union> inside (frontier S) = inside (frontier S)"
[PROOF STATE]
proof (prove)
using this:
interior S \<subseteq> inside (frontier S)

goal (1 subgoal):
 1. interior S \<union> inside (frontier S) = inside (frontier S)
[PROOF STEP]
by (simp add: subset_Un_eq)
[PROOF STATE]
proof (state)
this:
interior S \<union> inside (frontier S) = inside (frontier S)

goal (1 subgoal):
 1. closure S \<subseteq> frontier S \<union> inside (frontier S)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
interior S \<union> inside (frontier S) = inside (frontier S)
[PROOF STEP]
have "closure S \<subseteq> frontier S \<union> inside (frontier S)"
[PROOF STATE]
proof (prove)
using this:
interior S \<union> inside (frontier S) = inside (frontier S)

goal (1 subgoal):
 1. closure S \<subseteq> frontier S \<union> inside (frontier S)
[PROOF STEP]
using frontier_def
[PROOF STATE]
proof (prove)
using this:
interior S \<union> inside (frontier S) = inside (frontier S)
frontier ?S = closure ?S - interior ?S

goal (1 subgoal):
 1. closure S \<subseteq> frontier S \<union> inside (frontier S)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
closure S \<subseteq> frontier S \<union> inside (frontier S)

goal (1 subgoal):
 1. closure S \<subseteq> frontier S \<union> inside (frontier S)
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
interior S \<subseteq> inside (frontier S) \<Longrightarrow> closure S \<subseteq> frontier S \<union> inside (frontier S)

goal (1 subgoal):
 1. closure S \<subseteq> frontier S \<union> inside (frontier S)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
interior S \<subseteq> inside (frontier S) \<Longrightarrow> closure S \<subseteq> frontier S \<union> inside (frontier S)
[PROOF STEP]
show "closure S \<subseteq> frontier S \<union> inside (frontier S)"
[PROOF STATE]
proof (prove)
using this:
interior S \<subseteq> inside (frontier S) \<Longrightarrow> closure S \<subseteq> frontier S \<union> inside (frontier S)

goal (1 subgoal):
 1. closure S \<subseteq> frontier S \<union> inside (frontier S)
[PROOF STEP]
using interior_inside_frontier [OF assms]
[PROOF STATE]
proof (prove)
using this:
interior S \<subseteq> inside (frontier S) \<Longrightarrow> closure S \<subseteq> frontier S \<union> inside (frontier S)
interior S \<subseteq> inside (frontier S)

goal (1 subgoal):
 1. closure S \<subseteq> frontier S \<union> inside (frontier S)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
closure S \<subseteq> frontier S \<union> inside (frontier S)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma seq_monosub:
  fixes s :: "nat \<Rightarrow> 'a::linorder"
  shows "\<exists>f. strict_mono f \<and> monoseq (\<lambda>n. (s (f n)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>f. strict_mono f \<and> monoseq (\<lambda>n. s (f n))
[PROOF STEP]
proof (cases "\<forall>n. \<exists>p>n. \<forall>m\<ge>p. s m \<le> s p")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<forall>n. \<exists>p>n. \<forall>m\<ge>p. s m \<le> s p \<Longrightarrow> \<exists>f. strict_mono f \<and> monoseq (\<lambda>n. s (f n))
 2. \<not> (\<forall>n. \<exists>p>n. \<forall>m\<ge>p. s m \<le> s p) \<Longrightarrow> \<exists>f. strict_mono f \<and> monoseq (\<lambda>n. s (f n))
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
\<forall>n. \<exists>p>n. \<forall>m\<ge>p. s m \<le> s p

goal (2 subgoals):
 1. \<forall>n. \<exists>p>n. \<forall>m\<ge>p. s m \<le> s p \<Longrightarrow> \<exists>f. strict_mono f \<and> monoseq (\<lambda>n. s (f n))
 2. \<not> (\<forall>n. \<exists>p>n. \<forall>m\<ge>p. s m \<le> s p) \<Longrightarrow> \<exists>f. strict_mono f \<and> monoseq (\<lambda>n. s (f n))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<forall>n. \<exists>p>n. \<forall>m\<ge>p. s m \<le> s p
[PROOF STEP]
have "\<exists>f. \<forall>n. (\<forall>m\<ge>f n. s m \<le> s (f n)) \<and> f n < f (Suc n)"
[PROOF STATE]
proof (prove)
using this:
\<forall>n. \<exists>p>n. \<forall>m\<ge>p. s m \<le> s p

goal (1 subgoal):
 1. \<exists>f. \<forall>n. (\<forall>m\<ge>f n. s m \<le> s (f n)) \<and> f n < f (Suc n)
[PROOF STEP]
by (intro dependent_nat_choice) (auto simp: conj_commute)
[PROOF STATE]
proof (state)
this:
\<exists>f. \<forall>n. (\<forall>m\<ge>f n. s m \<le> s (f n)) \<and> f n < f (Suc n)

goal (2 subgoals):
 1. \<forall>n. \<exists>p>n. \<forall>m\<ge>p. s m \<le> s p \<Longrightarrow> \<exists>f. strict_mono f \<and> monoseq (\<lambda>n. s (f n))
 2. \<not> (\<forall>n. \<exists>p>n. \<forall>m\<ge>p. s m \<le> s p) \<Longrightarrow> \<exists>f. strict_mono f \<and> monoseq (\<lambda>n. s (f n))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<exists>f. \<forall>n. (\<forall>m\<ge>f n. s m \<le> s (f n)) \<and> f n < f (Suc n)
[PROOF STEP]
obtain f :: "nat \<Rightarrow> nat"
    where f: "strict_mono f" and mono: "\<And>n m. f n \<le> m \<Longrightarrow> s m \<le> s (f n)"
[PROOF STATE]
proof (prove)
using this:
\<exists>f. \<forall>n. (\<forall>m\<ge>f n. s m \<le> s (f n)) \<and> f n < f (Suc n)

goal (1 subgoal):
 1. (\<And>f. \<lbrakk>strict_mono f; \<And>n m. f n \<le> m \<Longrightarrow> s m \<le> s (f n)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (auto simp: strict_mono_Suc_iff)
[PROOF STATE]
proof (state)
this:
strict_mono f
f ?n \<le> ?m \<Longrightarrow> s ?m \<le> s (f ?n)

goal (2 subgoals):
 1. \<forall>n. \<exists>p>n. \<forall>m\<ge>p. s m \<le> s p \<Longrightarrow> \<exists>f. strict_mono f \<and> monoseq (\<lambda>n. s (f n))
 2. \<not> (\<forall>n. \<exists>p>n. \<forall>m\<ge>p. s m \<le> s p) \<Longrightarrow> \<exists>f. strict_mono f \<and> monoseq (\<lambda>n. s (f n))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
strict_mono f
f ?n \<le> ?m \<Longrightarrow> s ?m \<le> s (f ?n)
[PROOF STEP]
have "incseq f"
[PROOF STATE]
proof (prove)
using this:
strict_mono f
f ?n \<le> ?m \<Longrightarrow> s ?m \<le> s (f ?n)

goal (1 subgoal):
 1. incseq f
[PROOF STEP]
unfolding strict_mono_Suc_iff incseq_Suc_iff
[PROOF STATE]
proof (prove)
using this:
\<forall>n. f n < f (Suc n)
f ?n \<le> ?m \<Longrightarrow> s ?m \<le> s (f ?n)

goal (1 subgoal):
 1. \<forall>n. f n \<le> f (Suc n)
[PROOF STEP]
by (auto intro: less_imp_le)
[PROOF STATE]
proof (state)
this:
incseq f

goal (2 subgoals):
 1. \<forall>n. \<exists>p>n. \<forall>m\<ge>p. s m \<le> s p \<Longrightarrow> \<exists>f. strict_mono f \<and> monoseq (\<lambda>n. s (f n))
 2. \<not> (\<forall>n. \<exists>p>n. \<forall>m\<ge>p. s m \<le> s p) \<Longrightarrow> \<exists>f. strict_mono f \<and> monoseq (\<lambda>n. s (f n))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
incseq f
[PROOF STEP]
have "monoseq (\<lambda>n. s (f n))"
[PROOF STATE]
proof (prove)
using this:
incseq f

goal (1 subgoal):
 1. monoseq (\<lambda>n. s (f n))
[PROOF STEP]
by (auto simp add: incseq_def intro!: mono monoI2)
[PROOF STATE]
proof (state)
this:
monoseq (\<lambda>n. s (f n))

goal (2 subgoals):
 1. \<forall>n. \<exists>p>n. \<forall>m\<ge>p. s m \<le> s p \<Longrightarrow> \<exists>f. strict_mono f \<and> monoseq (\<lambda>n. s (f n))
 2. \<not> (\<forall>n. \<exists>p>n. \<forall>m\<ge>p. s m \<le> s p) \<Longrightarrow> \<exists>f. strict_mono f \<and> monoseq (\<lambda>n. s (f n))
[PROOF STEP]
with f
[PROOF STATE]
proof (chain)
picking this:
strict_mono f
monoseq (\<lambda>n. s (f n))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
strict_mono f
monoseq (\<lambda>n. s (f n))

goal (1 subgoal):
 1. \<exists>f. strict_mono f \<and> monoseq (\<lambda>n. s (f n))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<exists>f. strict_mono f \<and> monoseq (\<lambda>n. s (f n))

goal (1 subgoal):
 1. \<not> (\<forall>n. \<exists>p>n. \<forall>m\<ge>p. s m \<le> s p) \<Longrightarrow> \<exists>f. strict_mono f \<and> monoseq (\<lambda>n. s (f n))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> (\<forall>n. \<exists>p>n. \<forall>m\<ge>p. s m \<le> s p) \<Longrightarrow> \<exists>f. strict_mono f \<and> monoseq (\<lambda>n. s (f n))
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> (\<forall>n. \<exists>p>n. \<forall>m\<ge>p. s m \<le> s p)

goal (1 subgoal):
 1. \<not> (\<forall>n. \<exists>p>n. \<forall>m\<ge>p. s m \<le> s p) \<Longrightarrow> \<exists>f. strict_mono f \<and> monoseq (\<lambda>n. s (f n))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<not> (\<forall>n. \<exists>p>n. \<forall>m\<ge>p. s m \<le> s p)
[PROOF STEP]
obtain N where N: "p > N \<Longrightarrow> \<exists>m>p. s p < s m" for p
[PROOF STATE]
proof (prove)
using this:
\<not> (\<forall>n. \<exists>p>n. \<forall>m\<ge>p. s m \<le> s p)

goal (1 subgoal):
 1. (\<And>N. (\<And>p. N < p \<Longrightarrow> \<exists>m>p. s p < s m) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (force simp: not_le le_less)
[PROOF STATE]
proof (state)
this:
N < ?p \<Longrightarrow> \<exists>m>?p. s ?p < s m

goal (1 subgoal):
 1. \<not> (\<forall>n. \<exists>p>n. \<forall>m\<ge>p. s m \<le> s p) \<Longrightarrow> \<exists>f. strict_mono f \<and> monoseq (\<lambda>n. s (f n))
[PROOF STEP]
have "\<exists>f. \<forall>n. N < f n \<and> f n < f (Suc n) \<and> s (f n) \<le> s (f (Suc n))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>f. \<forall>n. N < f n \<and> f n < f (Suc n) \<and> s (f n) \<le> s (f (Suc n))
[PROOF STEP]
proof (intro dependent_nat_choice)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<exists>x. N < x
 2. \<And>x n. N < x \<Longrightarrow> \<exists>y>N. x < y \<and> s x \<le> s y
[PROOF STEP]
fix x
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<exists>x. N < x
 2. \<And>x n. N < x \<Longrightarrow> \<exists>y>N. x < y \<and> s x \<le> s y
[PROOF STEP]
assume "N < x"
[PROOF STATE]
proof (state)
this:
N < x

goal (2 subgoals):
 1. \<exists>x. N < x
 2. \<And>x n. N < x \<Longrightarrow> \<exists>y>N. x < y \<and> s x \<le> s y
[PROOF STEP]
with N[of x]
[PROOF STATE]
proof (chain)
picking this:
N < x \<Longrightarrow> \<exists>m>x. s x < s m
N < x
[PROOF STEP]
show "\<exists>y>N. x < y \<and> s x \<le> s y"
[PROOF STATE]
proof (prove)
using this:
N < x \<Longrightarrow> \<exists>m>x. s x < s m
N < x

goal (1 subgoal):
 1. \<exists>y>N. x < y \<and> s x \<le> s y
[PROOF STEP]
by (auto intro: less_trans)
[PROOF STATE]
proof (state)
this:
\<exists>y>N. x < y \<and> s x \<le> s y

goal (1 subgoal):
 1. \<exists>x. N < x
[PROOF STEP]
qed auto
[PROOF STATE]
proof (state)
this:
\<exists>f. \<forall>n. N < f n \<and> f n < f (Suc n) \<and> s (f n) \<le> s (f (Suc n))

goal (1 subgoal):
 1. \<not> (\<forall>n. \<exists>p>n. \<forall>m\<ge>p. s m \<le> s p) \<Longrightarrow> \<exists>f. strict_mono f \<and> monoseq (\<lambda>n. s (f n))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<exists>f. \<forall>n. N < f n \<and> f n < f (Suc n) \<and> s (f n) \<le> s (f (Suc n))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<exists>f. \<forall>n. N < f n \<and> f n < f (Suc n) \<and> s (f n) \<le> s (f (Suc n))

goal (1 subgoal):
 1. \<exists>f. strict_mono f \<and> monoseq (\<lambda>n. s (f n))
[PROOF STEP]
by (auto simp: monoseq_iff incseq_Suc_iff strict_mono_Suc_iff)
[PROOF STATE]
proof (state)
this:
\<exists>f. strict_mono f \<and> monoseq (\<lambda>n. s (f n))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma range_uint: \<open>range (uint :: 'a word \<Rightarrow> int) = {0..<2 ^ LENGTH('a::len)}\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. range uint = {0..<2 ^ LENGTH('a)}
[PROOF STEP]
apply transfer
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. range (take_bit LENGTH('a)) = {0..<2 ^ LENGTH('a)}
[PROOF STEP]
apply (auto simp add: image_iff)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. \<lbrakk>0 \<le> x; x < 2 ^ LENGTH('a)\<rbrakk> \<Longrightarrow> \<exists>xa. x = take_bit LENGTH('a) xa
[PROOF STEP]
apply (metis take_bit_int_eq_self_iff)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma bigo_bounded_alt: "\<forall>x. 0 \<le> f x \<Longrightarrow> \<forall>x. f x \<le> c * g x \<Longrightarrow> f \<in> O(g)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<forall>x. (0::'b) \<le> f x; \<forall>x. f x \<le> c * g x\<rbrakk> \<Longrightarrow> f \<in> O(g)
[PROOF STEP]
apply (auto simp add: bigo_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<forall>x. (0::'b) \<le> f x; \<forall>x. f x \<le> c * g x\<rbrakk> \<Longrightarrow> \<exists>c. \<forall>x. f x \<le> c * \<bar>g x\<bar>
[PROOF STEP]
by (metis abs_le_D1 linorder_class.not_less order_less_le Orderings.xt1(12) abs_mult)


[STATEMENT]
lemma prob_range:
  assumes [simp]:"x \<in> carrier R"
  shows "prob {\<omega>. hash x \<omega> \<in> A} = card (A \<inter> carrier R) / field_size"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. prob {\<omega>. hash x \<omega> \<in> A} = real (card (A \<inter> carrier R)) / real field_size
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. prob {\<omega>. hash x \<omega> \<in> A} = real (card (A \<inter> carrier R)) / real field_size
[PROOF STEP]
have "prob {\<omega>. hash x \<omega> \<in> A} = prob (\<Union>a \<in> A \<inter> carrier R. {\<omega>. hash x \<omega> = a})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. prob {\<omega>. hash x \<omega> \<in> A} = prob (\<Union>a\<in>A \<inter> carrier R. {\<omega>. hash x \<omega> = a})
[PROOF STEP]
by (rule measure_pmf_eq, auto simp:M_def)
[PROOF STATE]
proof (state)
this:
prob {\<omega>. hash x \<omega> \<in> A} = prob (\<Union>a\<in>A \<inter> carrier R. {\<omega>. hash x \<omega> = a})

goal (1 subgoal):
 1. prob {\<omega>. hash x \<omega> \<in> A} = real (card (A \<inter> carrier R)) / real field_size
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
prob {\<omega>. hash x \<omega> \<in> A} = prob (\<Union>a\<in>A \<inter> carrier R. {\<omega>. hash x \<omega> = a})

goal (1 subgoal):
 1. prob {\<omega>. hash x \<omega> \<in> A} = real (card (A \<inter> carrier R)) / real field_size
[PROOF STEP]
have "... = (\<Sum> a \<in> (A \<inter> carrier R). prob {\<omega>. hash x \<omega> = a})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. prob (\<Union>a\<in>A \<inter> carrier R. {\<omega>. hash x \<omega> = a}) = (\<Sum>a\<in>A \<inter> carrier R. prob {\<omega>. hash x \<omega> = a})
[PROOF STEP]
by (rule measure_finite_Union, auto simp:M_def disjoint_family_on_def)
[PROOF STATE]
proof (state)
this:
prob (\<Union>a\<in>A \<inter> carrier R. {\<omega>. hash x \<omega> = a}) = (\<Sum>a\<in>A \<inter> carrier R. prob {\<omega>. hash x \<omega> = a})

goal (1 subgoal):
 1. prob {\<omega>. hash x \<omega> \<in> A} = real (card (A \<inter> carrier R)) / real field_size
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
prob (\<Union>a\<in>A \<inter> carrier R. {\<omega>. hash x \<omega> = a}) = (\<Sum>a\<in>A \<inter> carrier R. prob {\<omega>. hash x \<omega> = a})

goal (1 subgoal):
 1. prob {\<omega>. hash x \<omega> \<in> A} = real (card (A \<inter> carrier R)) / real field_size
[PROOF STEP]
have "... = (\<Sum> a \<in> (A \<inter> carrier R). 1/(real field_size))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>a\<in>A \<inter> carrier R. prob {\<omega>. hash x \<omega> = a}) = (\<Sum>a\<in>A \<inter> carrier R. 1 / real field_size)
[PROOF STEP]
by (rule sum.cong, auto simp:prob_single)
[PROOF STATE]
proof (state)
this:
(\<Sum>a\<in>A \<inter> carrier R. prob {\<omega>. hash x \<omega> = a}) = (\<Sum>a\<in>A \<inter> carrier R. 1 / real field_size)

goal (1 subgoal):
 1. prob {\<omega>. hash x \<omega> \<in> A} = real (card (A \<inter> carrier R)) / real field_size
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>a\<in>A \<inter> carrier R. prob {\<omega>. hash x \<omega> = a}) = (\<Sum>a\<in>A \<inter> carrier R. 1 / real field_size)

goal (1 subgoal):
 1. prob {\<omega>. hash x \<omega> \<in> A} = real (card (A \<inter> carrier R)) / real field_size
[PROOF STEP]
have "... = card (A \<inter> carrier R) / field_size"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>a\<in>A \<inter> carrier R. 1 / real field_size) = real (card (A \<inter> carrier R)) / real field_size
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<Sum>a\<in>A \<inter> carrier R. 1 / real field_size) = real (card (A \<inter> carrier R)) / real field_size

goal (1 subgoal):
 1. prob {\<omega>. hash x \<omega> \<in> A} = real (card (A \<inter> carrier R)) / real field_size
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
prob {\<omega>. hash x \<omega> \<in> A} = real (card (A \<inter> carrier R)) / real field_size
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
prob {\<omega>. hash x \<omega> \<in> A} = real (card (A \<inter> carrier R)) / real field_size

goal (1 subgoal):
 1. prob {\<omega>. hash x \<omega> \<in> A} = real (card (A \<inter> carrier R)) / real field_size
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
prob {\<omega>. hash x \<omega> \<in> A} = real (card (A \<inter> carrier R)) / real field_size

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma (in domain) finprod_zero_iff:
  assumes "finite A"
  assumes "\<And>a. a \<in> A \<Longrightarrow> f a \<in> carrier R"
  shows "finprod R f A = \<zero> \<longleftrightarrow> (\<exists>x \<in> A. f x = \<zero>)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (finprod R f A = \<zero>) = (\<exists>x\<in>A. f x = \<zero>)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
finite A
?a \<in> A \<Longrightarrow> f ?a \<in> carrier R

goal (1 subgoal):
 1. (finprod R f A = \<zero>) = (\<exists>x\<in>A. f x = \<zero>)
[PROOF STEP]
proof (induct A rule: finite_induct)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. (\<And>a. a \<in> {} \<Longrightarrow> f a \<in> carrier R) \<Longrightarrow> (finprod R f {} = \<zero>) = (\<exists>x\<in>{}. f x = \<zero>)
 2. \<And>x F. \<lbrakk>finite F; x \<notin> F; (\<And>a. a \<in> F \<Longrightarrow> f a \<in> carrier R) \<Longrightarrow> (finprod R f F = \<zero>) = (\<exists>x\<in>F. f x = \<zero>); \<And>a. a \<in> insert x F \<Longrightarrow> f a \<in> carrier R\<rbrakk> \<Longrightarrow> (finprod R f (insert x F) = \<zero>) = (\<exists>x\<in>insert x F. f x = \<zero>)
[PROOF STEP]
case empty
[PROOF STATE]
proof (state)
this:
?a \<in> {} \<Longrightarrow> f ?a \<in> carrier R

goal (2 subgoals):
 1. (\<And>a. a \<in> {} \<Longrightarrow> f a \<in> carrier R) \<Longrightarrow> (finprod R f {} = \<zero>) = (\<exists>x\<in>{}. f x = \<zero>)
 2. \<And>x F. \<lbrakk>finite F; x \<notin> F; (\<And>a. a \<in> F \<Longrightarrow> f a \<in> carrier R) \<Longrightarrow> (finprod R f F = \<zero>) = (\<exists>x\<in>F. f x = \<zero>); \<And>a. a \<in> insert x F \<Longrightarrow> f a \<in> carrier R\<rbrakk> \<Longrightarrow> (finprod R f (insert x F) = \<zero>) = (\<exists>x\<in>insert x F. f x = \<zero>)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
?a \<in> {} \<Longrightarrow> f ?a \<in> carrier R
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
?a \<in> {} \<Longrightarrow> f ?a \<in> carrier R

goal (1 subgoal):
 1. (finprod R f {} = \<zero>) = (\<exists>x\<in>{}. f x = \<zero>)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(finprod R f {} = \<zero>) = (\<exists>x\<in>{}. f x = \<zero>)

goal (1 subgoal):
 1. \<And>x F. \<lbrakk>finite F; x \<notin> F; (\<And>a. a \<in> F \<Longrightarrow> f a \<in> carrier R) \<Longrightarrow> (finprod R f F = \<zero>) = (\<exists>x\<in>F. f x = \<zero>); \<And>a. a \<in> insert x F \<Longrightarrow> f a \<in> carrier R\<rbrakk> \<Longrightarrow> (finprod R f (insert x F) = \<zero>) = (\<exists>x\<in>insert x F. f x = \<zero>)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x F. \<lbrakk>finite F; x \<notin> F; (\<And>a. a \<in> F \<Longrightarrow> f a \<in> carrier R) \<Longrightarrow> (finprod R f F = \<zero>) = (\<exists>x\<in>F. f x = \<zero>); \<And>a. a \<in> insert x F \<Longrightarrow> f a \<in> carrier R\<rbrakk> \<Longrightarrow> (finprod R f (insert x F) = \<zero>) = (\<exists>x\<in>insert x F. f x = \<zero>)
[PROOF STEP]
case (insert y F)
[PROOF STATE]
proof (state)
this:
finite F
y \<notin> F
(\<And>a. a \<in> F \<Longrightarrow> f a \<in> carrier R) \<Longrightarrow> (finprod R f F = \<zero>) = (\<exists>x\<in>F. f x = \<zero>)
?a \<in> insert y F \<Longrightarrow> f ?a \<in> carrier R

goal (1 subgoal):
 1. \<And>x F. \<lbrakk>finite F; x \<notin> F; (\<And>a. a \<in> F \<Longrightarrow> f a \<in> carrier R) \<Longrightarrow> (finprod R f F = \<zero>) = (\<exists>x\<in>F. f x = \<zero>); \<And>a. a \<in> insert x F \<Longrightarrow> f a \<in> carrier R\<rbrakk> \<Longrightarrow> (finprod R f (insert x F) = \<zero>) = (\<exists>x\<in>insert x F. f x = \<zero>)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
finite F
y \<notin> F
(\<And>a. a \<in> F \<Longrightarrow> f a \<in> carrier R) \<Longrightarrow> (finprod R f F = \<zero>) = (\<exists>x\<in>F. f x = \<zero>)
?a \<in> insert y F \<Longrightarrow> f ?a \<in> carrier R

goal (1 subgoal):
 1. \<And>x F. \<lbrakk>finite F; x \<notin> F; (\<And>a. a \<in> F \<Longrightarrow> f a \<in> carrier R) \<Longrightarrow> (finprod R f F = \<zero>) = (\<exists>x\<in>F. f x = \<zero>); \<And>a. a \<in> insert x F \<Longrightarrow> f a \<in> carrier R\<rbrakk> \<Longrightarrow> (finprod R f (insert x F) = \<zero>) = (\<exists>x\<in>insert x F. f x = \<zero>)
[PROOF STEP]
have "f \<in> F \<rightarrow> carrier R"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f \<in> F \<rightarrow> carrier R
[PROOF STEP]
using insert
[PROOF STATE]
proof (prove)
using this:
finite F
y \<notin> F
(\<And>a. a \<in> F \<Longrightarrow> f a \<in> carrier R) \<Longrightarrow> (finprod R f F = \<zero>) = (\<exists>x\<in>F. f x = \<zero>)
?a \<in> insert y F \<Longrightarrow> f ?a \<in> carrier R

goal (1 subgoal):
 1. f \<in> F \<rightarrow> carrier R
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
f \<in> F \<rightarrow> carrier R

goal (1 subgoal):
 1. \<And>x F. \<lbrakk>finite F; x \<notin> F; (\<And>a. a \<in> F \<Longrightarrow> f a \<in> carrier R) \<Longrightarrow> (finprod R f F = \<zero>) = (\<exists>x\<in>F. f x = \<zero>); \<And>a. a \<in> insert x F \<Longrightarrow> f a \<in> carrier R\<rbrakk> \<Longrightarrow> (finprod R f (insert x F) = \<zero>) = (\<exists>x\<in>insert x F. f x = \<zero>)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
finite F
y \<notin> F
(\<And>a. a \<in> F \<Longrightarrow> f a \<in> carrier R) \<Longrightarrow> (finprod R f F = \<zero>) = (\<exists>x\<in>F. f x = \<zero>)
?a \<in> insert y F \<Longrightarrow> f ?a \<in> carrier R
f \<in> F \<rightarrow> carrier R
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
finite F
y \<notin> F
(\<And>a. a \<in> F \<Longrightarrow> f a \<in> carrier R) \<Longrightarrow> (finprod R f F = \<zero>) = (\<exists>x\<in>F. f x = \<zero>)
?a \<in> insert y F \<Longrightarrow> f ?a \<in> carrier R
f \<in> F \<rightarrow> carrier R

goal (1 subgoal):
 1. (finprod R f (insert y F) = \<zero>) = (\<exists>x\<in>insert y F. f x = \<zero>)
[PROOF STEP]
by (simp add:integral_iff)
[PROOF STATE]
proof (state)
this:
(finprod R f (insert y F) = \<zero>) = (\<exists>x\<in>insert y F. f x = \<zero>)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma rel_list_all2_update_cong:
  "\<lbrakk> i<size xs; list_all2 (fun_of S) xs ys; (x,y) \<in> S \<rbrakk>
  \<Longrightarrow> list_all2 (fun_of S) (xs[i:=x]) (ys[i:=y])"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>i < length xs; list_all2 (fun_of S) xs ys; (x, y) \<in> S\<rbrakk> \<Longrightarrow> list_all2 (fun_of S) (xs[i := x]) (ys[i := y])
[PROOF STEP]
(*<*)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>i < length xs; list_all2 (fun_of S) xs ys; (x, y) \<in> S\<rbrakk> \<Longrightarrow> list_all2 (fun_of S) (xs[i := x]) (ys[i := y])
[PROOF STEP]
by (simp add: list_all2_update_cong)


[STATEMENT]
lemma finsum_scalar_prod_sum':
  assumes f: "f \<in> U \<rightarrow> carrier_vec n"
    and w: "w \<in> carrier_vec n"
  shows "w \<bullet> finsum V f U = sum (\<lambda>u. w \<bullet> f u) U"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. w \<bullet> finsum V f U = (\<Sum>u\<in>U. w \<bullet> f u)
[PROOF STEP]
by (subst comm_scalar_prod[OF w], (insert f, auto)[1],
      subst finsum_scalar_prod_sum[OF f w],
      insert f, intro sum.cong[OF refl] comm_scalar_prod[OF _ w], auto)


[STATEMENT]
lemma rfn_tool1:"\<lbrakk> 0 < (r::nat); (k::nat) = i * r + j; j < r \<rbrakk>
                                                  \<Longrightarrow> (k div r) = i"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < r; k = i * r + j; j < r\<rbrakk> \<Longrightarrow> k div r = i
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<lbrakk>0 < r; k = i * r + j; j < r\<rbrakk> \<Longrightarrow> k div r = i
[PROOF STEP]
assume p1: "0 < r" and p2: "k = i * r + j" and p3: "j < r"
[PROOF STATE]
proof (state)
this:
0 < r
k = i * r + j
j < r

goal (1 subgoal):
 1. \<lbrakk>0 < r; k = i * r + j; j < r\<rbrakk> \<Longrightarrow> k div r = i
[PROOF STEP]
from p1 and p2
[PROOF STATE]
proof (chain)
picking this:
0 < r
k = i * r + j
[PROOF STEP]
have q1: "(j + i * r) div r = i + j div r"
[PROOF STATE]
proof (prove)
using this:
0 < r
k = i * r + j

goal (1 subgoal):
 1. (j + i * r) div r = i + j div r
[PROOF STEP]
apply (simp add:div_mult_self1 [of "r" "j" "i" ])
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
(j + i * r) div r = i + j div r

goal (1 subgoal):
 1. \<lbrakk>0 < r; k = i * r + j; j < r\<rbrakk> \<Longrightarrow> k div r = i
[PROOF STEP]
from p1 and p3
[PROOF STATE]
proof (chain)
picking this:
0 < r
j < r
[PROOF STEP]
have q2: "j div r = 0"
[PROOF STATE]
proof (prove)
using this:
0 < r
j < r

goal (1 subgoal):
 1. j div r = 0
[PROOF STEP]
apply (simp add:div_if)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
j div r = 0

goal (1 subgoal):
 1. \<lbrakk>0 < r; k = i * r + j; j < r\<rbrakk> \<Longrightarrow> k div r = i
[PROOF STEP]
from q1 and q2
[PROOF STATE]
proof (chain)
picking this:
(j + i * r) div r = i + j div r
j div r = 0
[PROOF STEP]
have q3:"(j + i * r) div r = i"
[PROOF STATE]
proof (prove)
using this:
(j + i * r) div r = i + j div r
j div r = 0

goal (1 subgoal):
 1. (j + i * r) div r = i
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
(j + i * r) div r = i

goal (1 subgoal):
 1. \<lbrakk>0 < r; k = i * r + j; j < r\<rbrakk> \<Longrightarrow> k div r = i
[PROOF STEP]
from q3
[PROOF STATE]
proof (chain)
picking this:
(j + i * r) div r = i
[PROOF STEP]
have q4: "(i * r + j) div r = i"
[PROOF STATE]
proof (prove)
using this:
(j + i * r) div r = i

goal (1 subgoal):
 1. (i * r + j) div r = i
[PROOF STEP]
apply (simp add:add.commute)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
(i * r + j) div r = i

goal (1 subgoal):
 1. \<lbrakk>0 < r; k = i * r + j; j < r\<rbrakk> \<Longrightarrow> k div r = i
[PROOF STEP]
from p2 and q4
[PROOF STATE]
proof (chain)
picking this:
k = i * r + j
(i * r + j) div r = i
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
k = i * r + j
(i * r + j) div r = i

goal (1 subgoal):
 1. k div r = i
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
k div r = i

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma surj_on_imageI: "surj_on (g \<circ> f) A B \<Longrightarrow> surj_on g (f ` A) B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. surj_on (g \<circ> f) A B \<Longrightarrow> surj_on g (f ` A) B
[PROOF STEP]
unfolding surj_on_conv
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>b\<in>B. \<exists>a\<in>A. b = (g \<circ> f) a \<Longrightarrow> \<forall>b\<in>B. \<exists>a\<in>f ` A. b = g a
[PROOF STEP]
by fastforce


[STATEMENT]
lemma lincomb_as_lincomb_list:
  fixes ws f
  assumes s: "set ws \<subseteq> carrier_vec n"
  shows "lincomb f (set ws) = lincomb_list (\<lambda>i. if \<exists>j<i. ws!i = ws!j then 0 else f (ws ! i)) ws"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. lincomb f (set ws) = lincomb_list (\<lambda>i. if \<exists>j<i. ws ! i = ws ! j then 0::'a else f (ws ! i)) ws
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
set ws \<subseteq> carrier_vec n

goal (1 subgoal):
 1. lincomb f (set ws) = lincomb_list (\<lambda>i. if \<exists>j<i. ws ! i = ws ! j then 0::'a else f (ws ! i)) ws
[PROOF STEP]
proof (induct ws rule: rev_induct)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. set [] \<subseteq> carrier_vec n \<Longrightarrow> lincomb f (set []) = lincomb_list (\<lambda>i. if \<exists>j<i. [] ! i = [] ! j then 0::'a else f ([] ! i)) []
 2. \<And>x xs. \<lbrakk>set xs \<subseteq> carrier_vec n \<Longrightarrow> lincomb f (set xs) = lincomb_list (\<lambda>i. if \<exists>j<i. xs ! i = xs ! j then 0::'a else f (xs ! i)) xs; set (xs @ [x]) \<subseteq> carrier_vec n\<rbrakk> \<Longrightarrow> lincomb f (set (xs @ [x])) = lincomb_list (\<lambda>i. if \<exists>j<i. (xs @ [x]) ! i = (xs @ [x]) ! j then 0::'a else f ((xs @ [x]) ! i)) (xs @ [x])
[PROOF STEP]
case (snoc a ws)
[PROOF STATE]
proof (state)
this:
set ws \<subseteq> carrier_vec n \<Longrightarrow> lincomb f (set ws) = lincomb_list (\<lambda>i. if \<exists>j<i. ws ! i = ws ! j then 0::'a else f (ws ! i)) ws
set (ws @ [a]) \<subseteq> carrier_vec n

goal (2 subgoals):
 1. set [] \<subseteq> carrier_vec n \<Longrightarrow> lincomb f (set []) = lincomb_list (\<lambda>i. if \<exists>j<i. [] ! i = [] ! j then 0::'a else f ([] ! i)) []
 2. \<And>x xs. \<lbrakk>set xs \<subseteq> carrier_vec n \<Longrightarrow> lincomb f (set xs) = lincomb_list (\<lambda>i. if \<exists>j<i. xs ! i = xs ! j then 0::'a else f (xs ! i)) xs; set (xs @ [x]) \<subseteq> carrier_vec n\<rbrakk> \<Longrightarrow> lincomb f (set (xs @ [x])) = lincomb_list (\<lambda>i. if \<exists>j<i. (xs @ [x]) ! i = (xs @ [x]) ! j then 0::'a else f ((xs @ [x]) ! i)) (xs @ [x])
[PROOF STEP]
let ?f = "\<lambda>i. if \<exists>j<i. ws ! i = ws ! j then 0 else f (ws ! i)"
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. set [] \<subseteq> carrier_vec n \<Longrightarrow> lincomb f (set []) = lincomb_list (\<lambda>i. if \<exists>j<i. [] ! i = [] ! j then 0::'a else f ([] ! i)) []
 2. \<And>x xs. \<lbrakk>set xs \<subseteq> carrier_vec n \<Longrightarrow> lincomb f (set xs) = lincomb_list (\<lambda>i. if \<exists>j<i. xs ! i = xs ! j then 0::'a else f (xs ! i)) xs; set (xs @ [x]) \<subseteq> carrier_vec n\<rbrakk> \<Longrightarrow> lincomb f (set (xs @ [x])) = lincomb_list (\<lambda>i. if \<exists>j<i. (xs @ [x]) ! i = (xs @ [x]) ! j then 0::'a else f ((xs @ [x]) ! i)) (xs @ [x])
[PROOF STEP]
let ?g = "\<lambda>i. (if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0 else f ((ws @ [a]) ! i)) \<cdot>\<^sub>v (ws @ [a]) ! i"
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. set [] \<subseteq> carrier_vec n \<Longrightarrow> lincomb f (set []) = lincomb_list (\<lambda>i. if \<exists>j<i. [] ! i = [] ! j then 0::'a else f ([] ! i)) []
 2. \<And>x xs. \<lbrakk>set xs \<subseteq> carrier_vec n \<Longrightarrow> lincomb f (set xs) = lincomb_list (\<lambda>i. if \<exists>j<i. xs ! i = xs ! j then 0::'a else f (xs ! i)) xs; set (xs @ [x]) \<subseteq> carrier_vec n\<rbrakk> \<Longrightarrow> lincomb f (set (xs @ [x])) = lincomb_list (\<lambda>i. if \<exists>j<i. (xs @ [x]) ! i = (xs @ [x]) ! j then 0::'a else f ((xs @ [x]) ! i)) (xs @ [x])
[PROOF STEP]
let ?g2= "(\<lambda>i. (if \<exists>j<i. ws ! i = ws ! j then 0 else f (ws ! i)) \<cdot>\<^sub>v ws ! i)"
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. set [] \<subseteq> carrier_vec n \<Longrightarrow> lincomb f (set []) = lincomb_list (\<lambda>i. if \<exists>j<i. [] ! i = [] ! j then 0::'a else f ([] ! i)) []
 2. \<And>x xs. \<lbrakk>set xs \<subseteq> carrier_vec n \<Longrightarrow> lincomb f (set xs) = lincomb_list (\<lambda>i. if \<exists>j<i. xs ! i = xs ! j then 0::'a else f (xs ! i)) xs; set (xs @ [x]) \<subseteq> carrier_vec n\<rbrakk> \<Longrightarrow> lincomb f (set (xs @ [x])) = lincomb_list (\<lambda>i. if \<exists>j<i. (xs @ [x]) ! i = (xs @ [x]) ! j then 0::'a else f ((xs @ [x]) ! i)) (xs @ [x])
[PROOF STEP]
have [simp]: "\<And>v. v \<in> set ws \<Longrightarrow> v \<in> carrier_vec n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>v. v \<in> set ws \<Longrightarrow> v \<in> carrier_vec n
[PROOF STEP]
using snoc.prems(1)
[PROOF STATE]
proof (prove)
using this:
set (ws @ [a]) \<subseteq> carrier_vec n

goal (1 subgoal):
 1. \<And>v. v \<in> set ws \<Longrightarrow> v \<in> carrier_vec n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
?v1 \<in> set ws \<Longrightarrow> ?v1 \<in> carrier_vec n

goal (2 subgoals):
 1. set [] \<subseteq> carrier_vec n \<Longrightarrow> lincomb f (set []) = lincomb_list (\<lambda>i. if \<exists>j<i. [] ! i = [] ! j then 0::'a else f ([] ! i)) []
 2. \<And>x xs. \<lbrakk>set xs \<subseteq> carrier_vec n \<Longrightarrow> lincomb f (set xs) = lincomb_list (\<lambda>i. if \<exists>j<i. xs ! i = xs ! j then 0::'a else f (xs ! i)) xs; set (xs @ [x]) \<subseteq> carrier_vec n\<rbrakk> \<Longrightarrow> lincomb f (set (xs @ [x])) = lincomb_list (\<lambda>i. if \<exists>j<i. (xs @ [x]) ! i = (xs @ [x]) ! j then 0::'a else f ((xs @ [x]) ! i)) (xs @ [x])
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
?v1 \<in> set ws \<Longrightarrow> ?v1 \<in> carrier_vec n
[PROOF STEP]
have ws: "set ws \<subseteq> carrier_vec n"
[PROOF STATE]
proof (prove)
using this:
?v1 \<in> set ws \<Longrightarrow> ?v1 \<in> carrier_vec n

goal (1 subgoal):
 1. set ws \<subseteq> carrier_vec n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
set ws \<subseteq> carrier_vec n

goal (2 subgoals):
 1. set [] \<subseteq> carrier_vec n \<Longrightarrow> lincomb f (set []) = lincomb_list (\<lambda>i. if \<exists>j<i. [] ! i = [] ! j then 0::'a else f ([] ! i)) []
 2. \<And>x xs. \<lbrakk>set xs \<subseteq> carrier_vec n \<Longrightarrow> lincomb f (set xs) = lincomb_list (\<lambda>i. if \<exists>j<i. xs ! i = xs ! j then 0::'a else f (xs ! i)) xs; set (xs @ [x]) \<subseteq> carrier_vec n\<rbrakk> \<Longrightarrow> lincomb f (set (xs @ [x])) = lincomb_list (\<lambda>i. if \<exists>j<i. (xs @ [x]) ! i = (xs @ [x]) ! j then 0::'a else f ((xs @ [x]) ! i)) (xs @ [x])
[PROOF STEP]
have hyp: "lincomb f (set ws) = lincomb_list ?f ws"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. lincomb f (set ws) = lincomb_list (\<lambda>i. if \<exists>j<i. ws ! i = ws ! j then 0::'a else f (ws ! i)) ws
[PROOF STEP]
by (intro snoc.hyps ws)
[PROOF STATE]
proof (state)
this:
lincomb f (set ws) = lincomb_list (\<lambda>i. if \<exists>j<i. ws ! i = ws ! j then 0::'a else f (ws ! i)) ws

goal (2 subgoals):
 1. set [] \<subseteq> carrier_vec n \<Longrightarrow> lincomb f (set []) = lincomb_list (\<lambda>i. if \<exists>j<i. [] ! i = [] ! j then 0::'a else f ([] ! i)) []
 2. \<And>x xs. \<lbrakk>set xs \<subseteq> carrier_vec n \<Longrightarrow> lincomb f (set xs) = lincomb_list (\<lambda>i. if \<exists>j<i. xs ! i = xs ! j then 0::'a else f (xs ! i)) xs; set (xs @ [x]) \<subseteq> carrier_vec n\<rbrakk> \<Longrightarrow> lincomb f (set (xs @ [x])) = lincomb_list (\<lambda>i. if \<exists>j<i. (xs @ [x]) ! i = (xs @ [x]) ! j then 0::'a else f ((xs @ [x]) ! i)) (xs @ [x])
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. lincomb f (set (ws @ [a])) = lincomb_list (\<lambda>i. if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) (ws @ [a])
[PROOF STEP]
proof (cases "a\<in>set ws")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. a \<in> set ws \<Longrightarrow> lincomb f (set (ws @ [a])) = lincomb_list (\<lambda>i. if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) (ws @ [a])
 2. a \<notin> set ws \<Longrightarrow> lincomb f (set (ws @ [a])) = lincomb_list (\<lambda>i. if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) (ws @ [a])
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
a \<in> set ws

goal (2 subgoals):
 1. a \<in> set ws \<Longrightarrow> lincomb f (set (ws @ [a])) = lincomb_list (\<lambda>i. if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) (ws @ [a])
 2. a \<notin> set ws \<Longrightarrow> lincomb f (set (ws @ [a])) = lincomb_list (\<lambda>i. if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) (ws @ [a])
[PROOF STEP]
have g_length: "?g (length ws) = 0\<^sub>v n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if \<exists>j<length ws. (ws @ [a]) ! length ws = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! length ws)) \<cdot>\<^sub>v (ws @ [a]) ! length ws = 0\<^sub>v n
[PROOF STEP]
using True
[PROOF STATE]
proof (prove)
using this:
a \<in> set ws

goal (1 subgoal):
 1. (if \<exists>j<length ws. (ws @ [a]) ! length ws = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! length ws)) \<cdot>\<^sub>v (ws @ [a]) ! length ws = 0\<^sub>v n
[PROOF STEP]
by (auto, metis in_set_conv_nth nth_append)
[PROOF STATE]
proof (state)
this:
(if \<exists>j<length ws. (ws @ [a]) ! length ws = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! length ws)) \<cdot>\<^sub>v (ws @ [a]) ! length ws = 0\<^sub>v n

goal (2 subgoals):
 1. a \<in> set ws \<Longrightarrow> lincomb f (set (ws @ [a])) = lincomb_list (\<lambda>i. if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) (ws @ [a])
 2. a \<notin> set ws \<Longrightarrow> lincomb f (set (ws @ [a])) = lincomb_list (\<lambda>i. if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) (ws @ [a])
[PROOF STEP]
have "(map ?g [0..<length (ws @ [a])]) = (map ?g [0..<length ws]) @ [?g (length ws)]"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map (\<lambda>i. (if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) \<cdot>\<^sub>v (ws @ [a]) ! i) [0..<length (ws @ [a])] = map (\<lambda>i. (if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) \<cdot>\<^sub>v (ws @ [a]) ! i) [0..<length ws] @ [(if \<exists>j<length ws. (ws @ [a]) ! length ws = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! length ws)) \<cdot>\<^sub>v (ws @ [a]) ! length ws]
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
map (\<lambda>i. (if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) \<cdot>\<^sub>v (ws @ [a]) ! i) [0..<length (ws @ [a])] = map (\<lambda>i. (if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) \<cdot>\<^sub>v (ws @ [a]) ! i) [0..<length ws] @ [(if \<exists>j<length ws. (ws @ [a]) ! length ws = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! length ws)) \<cdot>\<^sub>v (ws @ [a]) ! length ws]

goal (2 subgoals):
 1. a \<in> set ws \<Longrightarrow> lincomb f (set (ws @ [a])) = lincomb_list (\<lambda>i. if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) (ws @ [a])
 2. a \<notin> set ws \<Longrightarrow> lincomb f (set (ws @ [a])) = lincomb_list (\<lambda>i. if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) (ws @ [a])
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
map (\<lambda>i. (if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) \<cdot>\<^sub>v (ws @ [a]) ! i) [0..<length (ws @ [a])] = map (\<lambda>i. (if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) \<cdot>\<^sub>v (ws @ [a]) ! i) [0..<length ws] @ [(if \<exists>j<length ws. (ws @ [a]) ! length ws = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! length ws)) \<cdot>\<^sub>v (ws @ [a]) ! length ws]

goal (2 subgoals):
 1. a \<in> set ws \<Longrightarrow> lincomb f (set (ws @ [a])) = lincomb_list (\<lambda>i. if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) (ws @ [a])
 2. a \<notin> set ws \<Longrightarrow> lincomb f (set (ws @ [a])) = lincomb_list (\<lambda>i. if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) (ws @ [a])
[PROOF STEP]
have "... = (map ?g [0..<length ws]) @ [0\<^sub>v n]"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map (\<lambda>i. (if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) \<cdot>\<^sub>v (ws @ [a]) ! i) [0..<length ws] @ [(if \<exists>j<length ws. (ws @ [a]) ! length ws = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! length ws)) \<cdot>\<^sub>v (ws @ [a]) ! length ws] = map (\<lambda>i. (if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) \<cdot>\<^sub>v (ws @ [a]) ! i) [0..<length ws] @ [0\<^sub>v n]
[PROOF STEP]
using g_length
[PROOF STATE]
proof (prove)
using this:
(if \<exists>j<length ws. (ws @ [a]) ! length ws = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! length ws)) \<cdot>\<^sub>v (ws @ [a]) ! length ws = 0\<^sub>v n

goal (1 subgoal):
 1. map (\<lambda>i. (if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) \<cdot>\<^sub>v (ws @ [a]) ! i) [0..<length ws] @ [(if \<exists>j<length ws. (ws @ [a]) ! length ws = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! length ws)) \<cdot>\<^sub>v (ws @ [a]) ! length ws] = map (\<lambda>i. (if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) \<cdot>\<^sub>v (ws @ [a]) ! i) [0..<length ws] @ [0\<^sub>v n]
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
map (\<lambda>i. (if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) \<cdot>\<^sub>v (ws @ [a]) ! i) [0..<length ws] @ [(if \<exists>j<length ws. (ws @ [a]) ! length ws = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! length ws)) \<cdot>\<^sub>v (ws @ [a]) ! length ws] = map (\<lambda>i. (if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) \<cdot>\<^sub>v (ws @ [a]) ! i) [0..<length ws] @ [0\<^sub>v n]

goal (2 subgoals):
 1. a \<in> set ws \<Longrightarrow> lincomb f (set (ws @ [a])) = lincomb_list (\<lambda>i. if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) (ws @ [a])
 2. a \<notin> set ws \<Longrightarrow> lincomb f (set (ws @ [a])) = lincomb_list (\<lambda>i. if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) (ws @ [a])
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
map (\<lambda>i. (if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) \<cdot>\<^sub>v (ws @ [a]) ! i) [0..<length (ws @ [a])] = map (\<lambda>i. (if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) \<cdot>\<^sub>v (ws @ [a]) ! i) [0..<length ws] @ [0\<^sub>v n]
[PROOF STEP]
have map_rw: "(map ?g [0..<length (ws @ [a])]) = (map ?g [0..<length ws]) @ [0\<^sub>v n]"
[PROOF STATE]
proof (prove)
using this:
map (\<lambda>i. (if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) \<cdot>\<^sub>v (ws @ [a]) ! i) [0..<length (ws @ [a])] = map (\<lambda>i. (if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) \<cdot>\<^sub>v (ws @ [a]) ! i) [0..<length ws] @ [0\<^sub>v n]

goal (1 subgoal):
 1. map (\<lambda>i. (if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) \<cdot>\<^sub>v (ws @ [a]) ! i) [0..<length (ws @ [a])] = map (\<lambda>i. (if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) \<cdot>\<^sub>v (ws @ [a]) ! i) [0..<length ws] @ [0\<^sub>v n]
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
map (\<lambda>i. (if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) \<cdot>\<^sub>v (ws @ [a]) ! i) [0..<length (ws @ [a])] = map (\<lambda>i. (if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) \<cdot>\<^sub>v (ws @ [a]) ! i) [0..<length ws] @ [0\<^sub>v n]

goal (2 subgoals):
 1. a \<in> set ws \<Longrightarrow> lincomb f (set (ws @ [a])) = lincomb_list (\<lambda>i. if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) (ws @ [a])
 2. a \<notin> set ws \<Longrightarrow> lincomb f (set (ws @ [a])) = lincomb_list (\<lambda>i. if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) (ws @ [a])
[PROOF STEP]
have "M.sumlist (map ?g2 [0..<length ws]) = M.sumlist (map ?g [0..<length ws])"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. M.sumlist (map (\<lambda>i. (if \<exists>j<i. ws ! i = ws ! j then 0::'a else f (ws ! i)) \<cdot>\<^sub>v ws ! i) [0..<length ws]) = M.sumlist (map (\<lambda>i. (if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) \<cdot>\<^sub>v (ws @ [a]) ! i) [0..<length ws])
[PROOF STEP]
by (rule arg_cong[of _ _ "M.sumlist"], intro nth_equalityI, auto simp add: nth_append)
[PROOF STATE]
proof (state)
this:
M.sumlist (map (\<lambda>i. (if \<exists>j<i. ws ! i = ws ! j then 0::'a else f (ws ! i)) \<cdot>\<^sub>v ws ! i) [0..<length ws]) = M.sumlist (map (\<lambda>i. (if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) \<cdot>\<^sub>v (ws @ [a]) ! i) [0..<length ws])

goal (2 subgoals):
 1. a \<in> set ws \<Longrightarrow> lincomb f (set (ws @ [a])) = lincomb_list (\<lambda>i. if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) (ws @ [a])
 2. a \<notin> set ws \<Longrightarrow> lincomb f (set (ws @ [a])) = lincomb_list (\<lambda>i. if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) (ws @ [a])
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
M.sumlist (map (\<lambda>i. (if \<exists>j<i. ws ! i = ws ! j then 0::'a else f (ws ! i)) \<cdot>\<^sub>v ws ! i) [0..<length ws]) = M.sumlist (map (\<lambda>i. (if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) \<cdot>\<^sub>v (ws @ [a]) ! i) [0..<length ws])

goal (2 subgoals):
 1. a \<in> set ws \<Longrightarrow> lincomb f (set (ws @ [a])) = lincomb_list (\<lambda>i. if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) (ws @ [a])
 2. a \<notin> set ws \<Longrightarrow> lincomb f (set (ws @ [a])) = lincomb_list (\<lambda>i. if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) (ws @ [a])
[PROOF STEP]
have "... =  M.sumlist (map ?g [0..<length ws]) + 0\<^sub>v n "
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. M.sumlist (map (\<lambda>i. (if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) \<cdot>\<^sub>v (ws @ [a]) ! i) [0..<length ws]) = M.sumlist (map (\<lambda>i. (if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) \<cdot>\<^sub>v (ws @ [a]) ! i) [0..<length ws]) + 0\<^sub>v n
[PROOF STEP]
by (metis M.r_zero calculation hyp lincomb_closed lincomb_list_def ws)
[PROOF STATE]
proof (state)
this:
M.sumlist (map (\<lambda>i. (if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) \<cdot>\<^sub>v (ws @ [a]) ! i) [0..<length ws]) = M.sumlist (map (\<lambda>i. (if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) \<cdot>\<^sub>v (ws @ [a]) ! i) [0..<length ws]) + 0\<^sub>v n

goal (2 subgoals):
 1. a \<in> set ws \<Longrightarrow> lincomb f (set (ws @ [a])) = lincomb_list (\<lambda>i. if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) (ws @ [a])
 2. a \<notin> set ws \<Longrightarrow> lincomb f (set (ws @ [a])) = lincomb_list (\<lambda>i. if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) (ws @ [a])
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
M.sumlist (map (\<lambda>i. (if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) \<cdot>\<^sub>v (ws @ [a]) ! i) [0..<length ws]) = M.sumlist (map (\<lambda>i. (if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) \<cdot>\<^sub>v (ws @ [a]) ! i) [0..<length ws]) + 0\<^sub>v n

goal (2 subgoals):
 1. a \<in> set ws \<Longrightarrow> lincomb f (set (ws @ [a])) = lincomb_list (\<lambda>i. if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) (ws @ [a])
 2. a \<notin> set ws \<Longrightarrow> lincomb f (set (ws @ [a])) = lincomb_list (\<lambda>i. if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) (ws @ [a])
[PROOF STEP]
have "... = M.sumlist (map ?g [0..<length ws] @ [0\<^sub>v n])"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. M.sumlist (map (\<lambda>i. (if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) \<cdot>\<^sub>v (ws @ [a]) ! i) [0..<length ws]) + 0\<^sub>v n = M.sumlist (map (\<lambda>i. (if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) \<cdot>\<^sub>v (ws @ [a]) ! i) [0..<length ws] @ [0\<^sub>v n])
[PROOF STEP]
by (rule M.sumlist_snoc[symmetric], auto simp add: nth_append)
[PROOF STATE]
proof (state)
this:
M.sumlist (map (\<lambda>i. (if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) \<cdot>\<^sub>v (ws @ [a]) ! i) [0..<length ws]) + 0\<^sub>v n = M.sumlist (map (\<lambda>i. (if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) \<cdot>\<^sub>v (ws @ [a]) ! i) [0..<length ws] @ [0\<^sub>v n])

goal (2 subgoals):
 1. a \<in> set ws \<Longrightarrow> lincomb f (set (ws @ [a])) = lincomb_list (\<lambda>i. if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) (ws @ [a])
 2. a \<notin> set ws \<Longrightarrow> lincomb f (set (ws @ [a])) = lincomb_list (\<lambda>i. if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) (ws @ [a])
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
M.sumlist (map (\<lambda>i. (if \<exists>j<i. ws ! i = ws ! j then 0::'a else f (ws ! i)) \<cdot>\<^sub>v ws ! i) [0..<length ws]) = M.sumlist (map (\<lambda>i. (if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) \<cdot>\<^sub>v (ws @ [a]) ! i) [0..<length ws] @ [0\<^sub>v n])
[PROOF STEP]
have summlist_rw: "M.sumlist (map ?g2 [0..<length ws])
      = M.sumlist (map ?g [0..<length ws] @ [0\<^sub>v n])"
[PROOF STATE]
proof (prove)
using this:
M.sumlist (map (\<lambda>i. (if \<exists>j<i. ws ! i = ws ! j then 0::'a else f (ws ! i)) \<cdot>\<^sub>v ws ! i) [0..<length ws]) = M.sumlist (map (\<lambda>i. (if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) \<cdot>\<^sub>v (ws @ [a]) ! i) [0..<length ws] @ [0\<^sub>v n])

goal (1 subgoal):
 1. M.sumlist (map (\<lambda>i. (if \<exists>j<i. ws ! i = ws ! j then 0::'a else f (ws ! i)) \<cdot>\<^sub>v ws ! i) [0..<length ws]) = M.sumlist (map (\<lambda>i. (if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) \<cdot>\<^sub>v (ws @ [a]) ! i) [0..<length ws] @ [0\<^sub>v n])
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
M.sumlist (map (\<lambda>i. (if \<exists>j<i. ws ! i = ws ! j then 0::'a else f (ws ! i)) \<cdot>\<^sub>v ws ! i) [0..<length ws]) = M.sumlist (map (\<lambda>i. (if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) \<cdot>\<^sub>v (ws @ [a]) ! i) [0..<length ws] @ [0\<^sub>v n])

goal (2 subgoals):
 1. a \<in> set ws \<Longrightarrow> lincomb f (set (ws @ [a])) = lincomb_list (\<lambda>i. if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) (ws @ [a])
 2. a \<notin> set ws \<Longrightarrow> lincomb f (set (ws @ [a])) = lincomb_list (\<lambda>i. if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) (ws @ [a])
[PROOF STEP]
have "lincomb f (set (ws @ [a])) = lincomb f (set ws)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. lincomb f (set (ws @ [a])) = lincomb f (set ws)
[PROOF STEP]
using True
[PROOF STATE]
proof (prove)
using this:
a \<in> set ws

goal (1 subgoal):
 1. lincomb f (set (ws @ [a])) = lincomb f (set ws)
[PROOF STEP]
unfolding lincomb_def
[PROOF STATE]
proof (prove)
using this:
a \<in> set ws

goal (1 subgoal):
 1. (\<Oplus>\<^bsub>V\<^esub>v\<in>set (ws @ [a]). f v \<cdot>\<^sub>v v) = (\<Oplus>\<^bsub>V\<^esub>v\<in>set ws. f v \<cdot>\<^sub>v v)
[PROOF STEP]
by (simp add: insert_absorb)
[PROOF STATE]
proof (state)
this:
lincomb f (set (ws @ [a])) = lincomb f (set ws)

goal (2 subgoals):
 1. a \<in> set ws \<Longrightarrow> lincomb f (set (ws @ [a])) = lincomb_list (\<lambda>i. if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) (ws @ [a])
 2. a \<notin> set ws \<Longrightarrow> lincomb f (set (ws @ [a])) = lincomb_list (\<lambda>i. if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) (ws @ [a])
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
lincomb f (set (ws @ [a])) = lincomb f (set ws)

goal (1 subgoal):
 1. lincomb f (set (ws @ [a])) = lincomb_list (\<lambda>i. if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) (ws @ [a])
[PROOF STEP]
unfolding hyp lincomb_list_def map_rw summlist_rw
[PROOF STATE]
proof (prove)
using this:
lincomb f (set (ws @ [a])) = M.sumlist (map (\<lambda>i. (if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) \<cdot>\<^sub>v (ws @ [a]) ! i) [0..<length ws] @ [0\<^sub>v n])

goal (1 subgoal):
 1. lincomb f (set (ws @ [a])) = M.sumlist (map (\<lambda>i. (if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) \<cdot>\<^sub>v (ws @ [a]) ! i) [0..<length ws] @ [0\<^sub>v n])
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
lincomb f (set (ws @ [a])) = lincomb_list (\<lambda>i. if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) (ws @ [a])

goal (1 subgoal):
 1. a \<notin> set ws \<Longrightarrow> lincomb f (set (ws @ [a])) = lincomb_list (\<lambda>i. if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) (ws @ [a])
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. a \<notin> set ws \<Longrightarrow> lincomb f (set (ws @ [a])) = lincomb_list (\<lambda>i. if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) (ws @ [a])
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
a \<notin> set ws

goal (1 subgoal):
 1. a \<notin> set ws \<Longrightarrow> lincomb f (set (ws @ [a])) = lincomb_list (\<lambda>i. if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) (ws @ [a])
[PROOF STEP]
have g_length: "?g (length ws) = f a \<cdot>\<^sub>v a"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if \<exists>j<length ws. (ws @ [a]) ! length ws = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! length ws)) \<cdot>\<^sub>v (ws @ [a]) ! length ws = f a \<cdot>\<^sub>v a
[PROOF STEP]
using False
[PROOF STATE]
proof (prove)
using this:
a \<notin> set ws

goal (1 subgoal):
 1. (if \<exists>j<length ws. (ws @ [a]) ! length ws = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! length ws)) \<cdot>\<^sub>v (ws @ [a]) ! length ws = f a \<cdot>\<^sub>v a
[PROOF STEP]
by (auto simp add: nth_append)
[PROOF STATE]
proof (state)
this:
(if \<exists>j<length ws. (ws @ [a]) ! length ws = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! length ws)) \<cdot>\<^sub>v (ws @ [a]) ! length ws = f a \<cdot>\<^sub>v a

goal (1 subgoal):
 1. a \<notin> set ws \<Longrightarrow> lincomb f (set (ws @ [a])) = lincomb_list (\<lambda>i. if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) (ws @ [a])
[PROOF STEP]
have "(map ?g [0..<length (ws @ [a])]) = (map ?g [0..<length ws]) @ [?g (length ws)]"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map (\<lambda>i. (if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) \<cdot>\<^sub>v (ws @ [a]) ! i) [0..<length (ws @ [a])] = map (\<lambda>i. (if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) \<cdot>\<^sub>v (ws @ [a]) ! i) [0..<length ws] @ [(if \<exists>j<length ws. (ws @ [a]) ! length ws = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! length ws)) \<cdot>\<^sub>v (ws @ [a]) ! length ws]
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
map (\<lambda>i. (if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) \<cdot>\<^sub>v (ws @ [a]) ! i) [0..<length (ws @ [a])] = map (\<lambda>i. (if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) \<cdot>\<^sub>v (ws @ [a]) ! i) [0..<length ws] @ [(if \<exists>j<length ws. (ws @ [a]) ! length ws = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! length ws)) \<cdot>\<^sub>v (ws @ [a]) ! length ws]

goal (1 subgoal):
 1. a \<notin> set ws \<Longrightarrow> lincomb f (set (ws @ [a])) = lincomb_list (\<lambda>i. if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) (ws @ [a])
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
map (\<lambda>i. (if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) \<cdot>\<^sub>v (ws @ [a]) ! i) [0..<length (ws @ [a])] = map (\<lambda>i. (if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) \<cdot>\<^sub>v (ws @ [a]) ! i) [0..<length ws] @ [(if \<exists>j<length ws. (ws @ [a]) ! length ws = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! length ws)) \<cdot>\<^sub>v (ws @ [a]) ! length ws]

goal (1 subgoal):
 1. a \<notin> set ws \<Longrightarrow> lincomb f (set (ws @ [a])) = lincomb_list (\<lambda>i. if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) (ws @ [a])
[PROOF STEP]
have "... = (map ?g [0..<length ws]) @ [(f a \<cdot>\<^sub>v a)]"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map (\<lambda>i. (if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) \<cdot>\<^sub>v (ws @ [a]) ! i) [0..<length ws] @ [(if \<exists>j<length ws. (ws @ [a]) ! length ws = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! length ws)) \<cdot>\<^sub>v (ws @ [a]) ! length ws] = map (\<lambda>i. (if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) \<cdot>\<^sub>v (ws @ [a]) ! i) [0..<length ws] @ [f a \<cdot>\<^sub>v a]
[PROOF STEP]
using g_length
[PROOF STATE]
proof (prove)
using this:
(if \<exists>j<length ws. (ws @ [a]) ! length ws = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! length ws)) \<cdot>\<^sub>v (ws @ [a]) ! length ws = f a \<cdot>\<^sub>v a

goal (1 subgoal):
 1. map (\<lambda>i. (if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) \<cdot>\<^sub>v (ws @ [a]) ! i) [0..<length ws] @ [(if \<exists>j<length ws. (ws @ [a]) ! length ws = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! length ws)) \<cdot>\<^sub>v (ws @ [a]) ! length ws] = map (\<lambda>i. (if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) \<cdot>\<^sub>v (ws @ [a]) ! i) [0..<length ws] @ [f a \<cdot>\<^sub>v a]
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
map (\<lambda>i. (if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) \<cdot>\<^sub>v (ws @ [a]) ! i) [0..<length ws] @ [(if \<exists>j<length ws. (ws @ [a]) ! length ws = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! length ws)) \<cdot>\<^sub>v (ws @ [a]) ! length ws] = map (\<lambda>i. (if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) \<cdot>\<^sub>v (ws @ [a]) ! i) [0..<length ws] @ [f a \<cdot>\<^sub>v a]

goal (1 subgoal):
 1. a \<notin> set ws \<Longrightarrow> lincomb f (set (ws @ [a])) = lincomb_list (\<lambda>i. if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) (ws @ [a])
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
map (\<lambda>i. (if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) \<cdot>\<^sub>v (ws @ [a]) ! i) [0..<length (ws @ [a])] = map (\<lambda>i. (if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) \<cdot>\<^sub>v (ws @ [a]) ! i) [0..<length ws] @ [f a \<cdot>\<^sub>v a]
[PROOF STEP]
have map_rw: "(map ?g [0..<length (ws @ [a])]) = (map ?g [0..<length ws]) @ [(f a \<cdot>\<^sub>v a)]"
[PROOF STATE]
proof (prove)
using this:
map (\<lambda>i. (if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) \<cdot>\<^sub>v (ws @ [a]) ! i) [0..<length (ws @ [a])] = map (\<lambda>i. (if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) \<cdot>\<^sub>v (ws @ [a]) ! i) [0..<length ws] @ [f a \<cdot>\<^sub>v a]

goal (1 subgoal):
 1. map (\<lambda>i. (if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) \<cdot>\<^sub>v (ws @ [a]) ! i) [0..<length (ws @ [a])] = map (\<lambda>i. (if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) \<cdot>\<^sub>v (ws @ [a]) ! i) [0..<length ws] @ [f a \<cdot>\<^sub>v a]
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
map (\<lambda>i. (if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) \<cdot>\<^sub>v (ws @ [a]) ! i) [0..<length (ws @ [a])] = map (\<lambda>i. (if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) \<cdot>\<^sub>v (ws @ [a]) ! i) [0..<length ws] @ [f a \<cdot>\<^sub>v a]

goal (1 subgoal):
 1. a \<notin> set ws \<Longrightarrow> lincomb f (set (ws @ [a])) = lincomb_list (\<lambda>i. if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) (ws @ [a])
[PROOF STEP]
have summlist_rw: "M.sumlist (map ?g2 [0..<length ws]) = M.sumlist (map ?g [0..<length ws])"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. M.sumlist (map (\<lambda>i. (if \<exists>j<i. ws ! i = ws ! j then 0::'a else f (ws ! i)) \<cdot>\<^sub>v ws ! i) [0..<length ws]) = M.sumlist (map (\<lambda>i. (if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) \<cdot>\<^sub>v (ws @ [a]) ! i) [0..<length ws])
[PROOF STEP]
by (rule arg_cong[of _ _ "M.sumlist"], intro nth_equalityI, auto simp add: nth_append)
[PROOF STATE]
proof (state)
this:
M.sumlist (map (\<lambda>i. (if \<exists>j<i. ws ! i = ws ! j then 0::'a else f (ws ! i)) \<cdot>\<^sub>v ws ! i) [0..<length ws]) = M.sumlist (map (\<lambda>i. (if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) \<cdot>\<^sub>v (ws @ [a]) ! i) [0..<length ws])

goal (1 subgoal):
 1. a \<notin> set ws \<Longrightarrow> lincomb f (set (ws @ [a])) = lincomb_list (\<lambda>i. if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) (ws @ [a])
[PROOF STEP]
have "lincomb f (set (ws @ [a])) = lincomb f (set (a # ws))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. lincomb f (set (ws @ [a])) = lincomb f (set (a # ws))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
lincomb f (set (ws @ [a])) = lincomb f (set (a # ws))

goal (1 subgoal):
 1. a \<notin> set ws \<Longrightarrow> lincomb f (set (ws @ [a])) = lincomb_list (\<lambda>i. if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) (ws @ [a])
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
lincomb f (set (ws @ [a])) = lincomb f (set (a # ws))

goal (1 subgoal):
 1. a \<notin> set ws \<Longrightarrow> lincomb f (set (ws @ [a])) = lincomb_list (\<lambda>i. if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) (ws @ [a])
[PROOF STEP]
have "... = (\<Oplus>\<^bsub>V\<^esub>v\<in>set (a # ws). f v \<cdot>\<^sub>v v)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. lincomb f (set (a # ws)) = (\<Oplus>\<^bsub>V\<^esub>v\<in>set (a # ws). f v \<cdot>\<^sub>v v)
[PROOF STEP]
unfolding lincomb_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Oplus>\<^bsub>V\<^esub>v\<in>set (a # ws). f v \<cdot>\<^sub>v v) = (\<Oplus>\<^bsub>V\<^esub>v\<in>set (a # ws). f v \<cdot>\<^sub>v v)
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
lincomb f (set (a # ws)) = (\<Oplus>\<^bsub>V\<^esub>v\<in>set (a # ws). f v \<cdot>\<^sub>v v)

goal (1 subgoal):
 1. a \<notin> set ws \<Longrightarrow> lincomb f (set (ws @ [a])) = lincomb_list (\<lambda>i. if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) (ws @ [a])
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
lincomb f (set (a # ws)) = (\<Oplus>\<^bsub>V\<^esub>v\<in>set (a # ws). f v \<cdot>\<^sub>v v)

goal (1 subgoal):
 1. a \<notin> set ws \<Longrightarrow> lincomb f (set (ws @ [a])) = lincomb_list (\<lambda>i. if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) (ws @ [a])
[PROOF STEP]
have "... = (\<Oplus>\<^bsub>V\<^esub>v\<in> insert a (set ws). f v \<cdot>\<^sub>v v)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Oplus>\<^bsub>V\<^esub>v\<in>set (a # ws). f v \<cdot>\<^sub>v v) = (\<Oplus>\<^bsub>V\<^esub>v\<in>insert a (set ws). f v \<cdot>\<^sub>v v)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<Oplus>\<^bsub>V\<^esub>v\<in>set (a # ws). f v \<cdot>\<^sub>v v) = (\<Oplus>\<^bsub>V\<^esub>v\<in>insert a (set ws). f v \<cdot>\<^sub>v v)

goal (1 subgoal):
 1. a \<notin> set ws \<Longrightarrow> lincomb f (set (ws @ [a])) = lincomb_list (\<lambda>i. if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) (ws @ [a])
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Oplus>\<^bsub>V\<^esub>v\<in>set (a # ws). f v \<cdot>\<^sub>v v) = (\<Oplus>\<^bsub>V\<^esub>v\<in>insert a (set ws). f v \<cdot>\<^sub>v v)

goal (1 subgoal):
 1. a \<notin> set ws \<Longrightarrow> lincomb f (set (ws @ [a])) = lincomb_list (\<lambda>i. if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) (ws @ [a])
[PROOF STEP]
have "... = (f a \<cdot>\<^sub>v a) + (\<Oplus>\<^bsub>V\<^esub>v\<in> (set ws). f v \<cdot>\<^sub>v v)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Oplus>\<^bsub>V\<^esub>v\<in>insert a (set ws). f v \<cdot>\<^sub>v v) = f a \<cdot>\<^sub>v a + (\<Oplus>\<^bsub>V\<^esub>v\<in>set ws. f v \<cdot>\<^sub>v v)
[PROOF STEP]
proof (rule finsum_insert)
[PROOF STATE]
proof (state)
goal (4 subgoals):
 1. finite (set ws)
 2. a \<notin> set ws
 3. (\<lambda>v. f v \<cdot>\<^sub>v v) \<in> set ws \<rightarrow> carrier_vec n
 4. f a \<cdot>\<^sub>v a \<in> carrier_vec n
[PROOF STEP]
show "finite (set ws)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite (set ws)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
finite (set ws)

goal (3 subgoals):
 1. a \<notin> set ws
 2. (\<lambda>v. f v \<cdot>\<^sub>v v) \<in> set ws \<rightarrow> carrier_vec n
 3. f a \<cdot>\<^sub>v a \<in> carrier_vec n
[PROOF STEP]
show "a \<notin> set ws"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a \<notin> set ws
[PROOF STEP]
using False
[PROOF STATE]
proof (prove)
using this:
a \<notin> set ws

goal (1 subgoal):
 1. a \<notin> set ws
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
a \<notin> set ws

goal (2 subgoals):
 1. (\<lambda>v. f v \<cdot>\<^sub>v v) \<in> set ws \<rightarrow> carrier_vec n
 2. f a \<cdot>\<^sub>v a \<in> carrier_vec n
[PROOF STEP]
show "(\<lambda>v. f v \<cdot>\<^sub>v v) \<in> set ws \<rightarrow> carrier_vec n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>v. f v \<cdot>\<^sub>v v) \<in> set ws \<rightarrow> carrier_vec n
[PROOF STEP]
using snoc.prems(1)
[PROOF STATE]
proof (prove)
using this:
set (ws @ [a]) \<subseteq> carrier_vec n

goal (1 subgoal):
 1. (\<lambda>v. f v \<cdot>\<^sub>v v) \<in> set ws \<rightarrow> carrier_vec n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<lambda>v. f v \<cdot>\<^sub>v v) \<in> set ws \<rightarrow> carrier_vec n

goal (1 subgoal):
 1. f a \<cdot>\<^sub>v a \<in> carrier_vec n
[PROOF STEP]
show "f a \<cdot>\<^sub>v a \<in> carrier_vec n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f a \<cdot>\<^sub>v a \<in> carrier_vec n
[PROOF STEP]
using snoc.prems
[PROOF STATE]
proof (prove)
using this:
set (ws @ [a]) \<subseteq> carrier_vec n

goal (1 subgoal):
 1. f a \<cdot>\<^sub>v a \<in> carrier_vec n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
f a \<cdot>\<^sub>v a \<in> carrier_vec n

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<Oplus>\<^bsub>V\<^esub>v\<in>insert a (set ws). f v \<cdot>\<^sub>v v) = f a \<cdot>\<^sub>v a + (\<Oplus>\<^bsub>V\<^esub>v\<in>set ws. f v \<cdot>\<^sub>v v)

goal (1 subgoal):
 1. a \<notin> set ws \<Longrightarrow> lincomb f (set (ws @ [a])) = lincomb_list (\<lambda>i. if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) (ws @ [a])
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Oplus>\<^bsub>V\<^esub>v\<in>insert a (set ws). f v \<cdot>\<^sub>v v) = f a \<cdot>\<^sub>v a + (\<Oplus>\<^bsub>V\<^esub>v\<in>set ws. f v \<cdot>\<^sub>v v)

goal (1 subgoal):
 1. a \<notin> set ws \<Longrightarrow> lincomb f (set (ws @ [a])) = lincomb_list (\<lambda>i. if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) (ws @ [a])
[PROOF STEP]
have "... = (f a \<cdot>\<^sub>v a) + lincomb f (set ws)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f a \<cdot>\<^sub>v a + (\<Oplus>\<^bsub>V\<^esub>v\<in>set ws. f v \<cdot>\<^sub>v v) = f a \<cdot>\<^sub>v a + lincomb f (set ws)
[PROOF STEP]
unfolding lincomb_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f a \<cdot>\<^sub>v a + (\<Oplus>\<^bsub>V\<^esub>v\<in>set ws. f v \<cdot>\<^sub>v v) = f a \<cdot>\<^sub>v a + (\<Oplus>\<^bsub>V\<^esub>v\<in>set ws. f v \<cdot>\<^sub>v v)
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
f a \<cdot>\<^sub>v a + (\<Oplus>\<^bsub>V\<^esub>v\<in>set ws. f v \<cdot>\<^sub>v v) = f a \<cdot>\<^sub>v a + lincomb f (set ws)

goal (1 subgoal):
 1. a \<notin> set ws \<Longrightarrow> lincomb f (set (ws @ [a])) = lincomb_list (\<lambda>i. if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) (ws @ [a])
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
f a \<cdot>\<^sub>v a + (\<Oplus>\<^bsub>V\<^esub>v\<in>set ws. f v \<cdot>\<^sub>v v) = f a \<cdot>\<^sub>v a + lincomb f (set ws)

goal (1 subgoal):
 1. a \<notin> set ws \<Longrightarrow> lincomb f (set (ws @ [a])) = lincomb_list (\<lambda>i. if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) (ws @ [a])
[PROOF STEP]
have "... = (f a \<cdot>\<^sub>v a) + lincomb_list ?f ws"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f a \<cdot>\<^sub>v a + lincomb f (set ws) = f a \<cdot>\<^sub>v a + lincomb_list (\<lambda>i. if \<exists>j<i. ws ! i = ws ! j then 0::'a else f (ws ! i)) ws
[PROOF STEP]
using hyp
[PROOF STATE]
proof (prove)
using this:
lincomb f (set ws) = lincomb_list (\<lambda>i. if \<exists>j<i. ws ! i = ws ! j then 0::'a else f (ws ! i)) ws

goal (1 subgoal):
 1. f a \<cdot>\<^sub>v a + lincomb f (set ws) = f a \<cdot>\<^sub>v a + lincomb_list (\<lambda>i. if \<exists>j<i. ws ! i = ws ! j then 0::'a else f (ws ! i)) ws
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
f a \<cdot>\<^sub>v a + lincomb f (set ws) = f a \<cdot>\<^sub>v a + lincomb_list (\<lambda>i. if \<exists>j<i. ws ! i = ws ! j then 0::'a else f (ws ! i)) ws

goal (1 subgoal):
 1. a \<notin> set ws \<Longrightarrow> lincomb f (set (ws @ [a])) = lincomb_list (\<lambda>i. if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) (ws @ [a])
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
f a \<cdot>\<^sub>v a + lincomb f (set ws) = f a \<cdot>\<^sub>v a + lincomb_list (\<lambda>i. if \<exists>j<i. ws ! i = ws ! j then 0::'a else f (ws ! i)) ws

goal (1 subgoal):
 1. a \<notin> set ws \<Longrightarrow> lincomb f (set (ws @ [a])) = lincomb_list (\<lambda>i. if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) (ws @ [a])
[PROOF STEP]
have "... =  lincomb_list ?f ws  + (f a \<cdot>\<^sub>v a)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f a \<cdot>\<^sub>v a + lincomb_list (\<lambda>i. if \<exists>j<i. ws ! i = ws ! j then 0::'a else f (ws ! i)) ws = lincomb_list (\<lambda>i. if \<exists>j<i. ws ! i = ws ! j then 0::'a else f (ws ! i)) ws + f a \<cdot>\<^sub>v a
[PROOF STEP]
using M.add.m_comm lincomb_list_carrier snoc.prems
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?x \<in> carrier_vec n; ?y \<in> carrier_vec n\<rbrakk> \<Longrightarrow> ?x + ?y = ?y + ?x
set ?vs \<subseteq> carrier_vec n \<Longrightarrow> lincomb_list ?c ?vs \<in> carrier_vec n
set (ws @ [a]) \<subseteq> carrier_vec n

goal (1 subgoal):
 1. f a \<cdot>\<^sub>v a + lincomb_list (\<lambda>i. if \<exists>j<i. ws ! i = ws ! j then 0::'a else f (ws ! i)) ws = lincomb_list (\<lambda>i. if \<exists>j<i. ws ! i = ws ! j then 0::'a else f (ws ! i)) ws + f a \<cdot>\<^sub>v a
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
f a \<cdot>\<^sub>v a + lincomb_list (\<lambda>i. if \<exists>j<i. ws ! i = ws ! j then 0::'a else f (ws ! i)) ws = lincomb_list (\<lambda>i. if \<exists>j<i. ws ! i = ws ! j then 0::'a else f (ws ! i)) ws + f a \<cdot>\<^sub>v a

goal (1 subgoal):
 1. a \<notin> set ws \<Longrightarrow> lincomb f (set (ws @ [a])) = lincomb_list (\<lambda>i. if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) (ws @ [a])
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
f a \<cdot>\<^sub>v a + lincomb_list (\<lambda>i. if \<exists>j<i. ws ! i = ws ! j then 0::'a else f (ws ! i)) ws = lincomb_list (\<lambda>i. if \<exists>j<i. ws ! i = ws ! j then 0::'a else f (ws ! i)) ws + f a \<cdot>\<^sub>v a

goal (1 subgoal):
 1. a \<notin> set ws \<Longrightarrow> lincomb f (set (ws @ [a])) = lincomb_list (\<lambda>i. if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) (ws @ [a])
[PROOF STEP]
have "... = lincomb_list (\<lambda>i. if \<exists>j<i. (ws @ [a]) ! i
      = (ws @ [a]) ! j then 0 else f ((ws @ [a]) ! i)) (ws @ [a])"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. lincomb_list (\<lambda>i. if \<exists>j<i. ws ! i = ws ! j then 0::'a else f (ws ! i)) ws + f a \<cdot>\<^sub>v a = lincomb_list (\<lambda>i. if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) (ws @ [a])
[PROOF STEP]
proof (unfold lincomb_list_def map_rw summlist_rw, rule M.sumlist_snoc[symmetric])
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. set (map (\<lambda>i. (if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) \<cdot>\<^sub>v (ws @ [a]) ! i) [0..<length ws]) \<subseteq> carrier_vec n
 2. f a \<cdot>\<^sub>v a \<in> carrier_vec n
[PROOF STEP]
show "set (map ?g [0..<length ws]) \<subseteq> carrier_vec n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set (map (\<lambda>i. (if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) \<cdot>\<^sub>v (ws @ [a]) ! i) [0..<length ws]) \<subseteq> carrier_vec n
[PROOF STEP]
using snoc.prems
[PROOF STATE]
proof (prove)
using this:
set (ws @ [a]) \<subseteq> carrier_vec n

goal (1 subgoal):
 1. set (map (\<lambda>i. (if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) \<cdot>\<^sub>v (ws @ [a]) ! i) [0..<length ws]) \<subseteq> carrier_vec n
[PROOF STEP]
by (auto simp add: nth_append)
[PROOF STATE]
proof (state)
this:
set (map (\<lambda>i. (if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) \<cdot>\<^sub>v (ws @ [a]) ! i) [0..<length ws]) \<subseteq> carrier_vec n

goal (1 subgoal):
 1. f a \<cdot>\<^sub>v a \<in> carrier_vec n
[PROOF STEP]
show "f a \<cdot>\<^sub>v a \<in> carrier_vec n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f a \<cdot>\<^sub>v a \<in> carrier_vec n
[PROOF STEP]
using snoc.prems
[PROOF STATE]
proof (prove)
using this:
set (ws @ [a]) \<subseteq> carrier_vec n

goal (1 subgoal):
 1. f a \<cdot>\<^sub>v a \<in> carrier_vec n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
f a \<cdot>\<^sub>v a \<in> carrier_vec n

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
lincomb_list (\<lambda>i. if \<exists>j<i. ws ! i = ws ! j then 0::'a else f (ws ! i)) ws + f a \<cdot>\<^sub>v a = lincomb_list (\<lambda>i. if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) (ws @ [a])

goal (1 subgoal):
 1. a \<notin> set ws \<Longrightarrow> lincomb f (set (ws @ [a])) = lincomb_list (\<lambda>i. if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) (ws @ [a])
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
lincomb f (set (ws @ [a])) = lincomb_list (\<lambda>i. if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) (ws @ [a])
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
lincomb f (set (ws @ [a])) = lincomb_list (\<lambda>i. if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) (ws @ [a])

goal (1 subgoal):
 1. lincomb f (set (ws @ [a])) = lincomb_list (\<lambda>i. if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) (ws @ [a])
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
lincomb f (set (ws @ [a])) = lincomb_list (\<lambda>i. if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) (ws @ [a])

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
lincomb f (set (ws @ [a])) = lincomb_list (\<lambda>i. if \<exists>j<i. (ws @ [a]) ! i = (ws @ [a]) ! j then 0::'a else f ((ws @ [a]) ! i)) (ws @ [a])

goal (1 subgoal):
 1. set [] \<subseteq> carrier_vec n \<Longrightarrow> lincomb f (set []) = lincomb_list (\<lambda>i. if \<exists>j<i. [] ! i = [] ! j then 0::'a else f ([] ! i)) []
[PROOF STEP]
qed auto


[STATEMENT]
lemma ceiling_le_neg_numeral [simp]: "\<lceil>x\<rceil> \<le> - numeral v \<longleftrightarrow> x \<le> - numeral v"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lceil>x\<rceil> \<le> - numeral v) = (x \<le> - numeral v)
[PROOF STEP]
by (simp add: ceiling_le_iff)


[STATEMENT]
lemma product_nth:
  assumes "n < length xs * length ys"
  shows "List.product xs ys ! n = (xs ! (n div length ys), ys ! (n mod length ys))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. List.product xs ys ! n = (xs ! (n div length ys), ys ! (n mod length ys))
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
n < length xs * length ys

goal (1 subgoal):
 1. List.product xs ys ! n = (xs ! (n div length ys), ys ! (n mod length ys))
[PROOF STEP]
proof (induct xs arbitrary: n)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>n. n < length [] * length ys \<Longrightarrow> List.product [] ys ! n = ([] ! (n div length ys), ys ! (n mod length ys))
 2. \<And>a xs n. \<lbrakk>\<And>n. n < length xs * length ys \<Longrightarrow> List.product xs ys ! n = (xs ! (n div length ys), ys ! (n mod length ys)); n < length (a # xs) * length ys\<rbrakk> \<Longrightarrow> List.product (a # xs) ys ! n = ((a # xs) ! (n div length ys), ys ! (n mod length ys))
[PROOF STEP]
case Nil
[PROOF STATE]
proof (state)
this:
n < length [] * length ys

goal (2 subgoals):
 1. \<And>n. n < length [] * length ys \<Longrightarrow> List.product [] ys ! n = ([] ! (n div length ys), ys ! (n mod length ys))
 2. \<And>a xs n. \<lbrakk>\<And>n. n < length xs * length ys \<Longrightarrow> List.product xs ys ! n = (xs ! (n div length ys), ys ! (n mod length ys)); n < length (a # xs) * length ys\<rbrakk> \<Longrightarrow> List.product (a # xs) ys ! n = ((a # xs) ! (n div length ys), ys ! (n mod length ys))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
n < length [] * length ys
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
n < length [] * length ys

goal (1 subgoal):
 1. List.product [] ys ! n = ([] ! (n div length ys), ys ! (n mod length ys))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
List.product [] ys ! n = ([] ! (n div length ys), ys ! (n mod length ys))

goal (1 subgoal):
 1. \<And>a xs n. \<lbrakk>\<And>n. n < length xs * length ys \<Longrightarrow> List.product xs ys ! n = (xs ! (n div length ys), ys ! (n mod length ys)); n < length (a # xs) * length ys\<rbrakk> \<Longrightarrow> List.product (a # xs) ys ! n = ((a # xs) ! (n div length ys), ys ! (n mod length ys))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a xs n. \<lbrakk>\<And>n. n < length xs * length ys \<Longrightarrow> List.product xs ys ! n = (xs ! (n div length ys), ys ! (n mod length ys)); n < length (a # xs) * length ys\<rbrakk> \<Longrightarrow> List.product (a # xs) ys ! n = ((a # xs) ! (n div length ys), ys ! (n mod length ys))
[PROOF STEP]
case (Cons x xs n)
[PROOF STATE]
proof (state)
this:
?n < length xs * length ys \<Longrightarrow> List.product xs ys ! ?n = (xs ! (?n div length ys), ys ! (?n mod length ys))
n < length (x # xs) * length ys

goal (1 subgoal):
 1. \<And>a xs n. \<lbrakk>\<And>n. n < length xs * length ys \<Longrightarrow> List.product xs ys ! n = (xs ! (n div length ys), ys ! (n mod length ys)); n < length (a # xs) * length ys\<rbrakk> \<Longrightarrow> List.product (a # xs) ys ! n = ((a # xs) ! (n div length ys), ys ! (n mod length ys))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
?n < length xs * length ys \<Longrightarrow> List.product xs ys ! ?n = (xs ! (?n div length ys), ys ! (?n mod length ys))
n < length (x # xs) * length ys
[PROOF STEP]
have "length ys > 0"
[PROOF STATE]
proof (prove)
using this:
?n < length xs * length ys \<Longrightarrow> List.product xs ys ! ?n = (xs ! (?n div length ys), ys ! (?n mod length ys))
n < length (x # xs) * length ys

goal (1 subgoal):
 1. 0 < length ys
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
0 < length ys

goal (1 subgoal):
 1. \<And>a xs n. \<lbrakk>\<And>n. n < length xs * length ys \<Longrightarrow> List.product xs ys ! n = (xs ! (n div length ys), ys ! (n mod length ys)); n < length (a # xs) * length ys\<rbrakk> \<Longrightarrow> List.product (a # xs) ys ! n = ((a # xs) ! (n div length ys), ys ! (n mod length ys))
[PROOF STEP]
with Cons
[PROOF STATE]
proof (chain)
picking this:
?n < length xs * length ys \<Longrightarrow> List.product xs ys ! ?n = (xs ! (?n div length ys), ys ! (?n mod length ys))
n < length (x # xs) * length ys
0 < length ys
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
?n < length xs * length ys \<Longrightarrow> List.product xs ys ! ?n = (xs ! (?n div length ys), ys ! (?n mod length ys))
n < length (x # xs) * length ys
0 < length ys

goal (1 subgoal):
 1. List.product (x # xs) ys ! n = ((x # xs) ! (n div length ys), ys ! (n mod length ys))
[PROOF STEP]
by (auto simp add: nth_append not_less le_mod_geq le_div_geq)
[PROOF STATE]
proof (state)
this:
List.product (x # xs) ys ! n = ((x # xs) ! (n div length ys), ys ! (n mod length ys))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma Markov_inequality:
  fixes a :: real and X :: "uedge set \<Rightarrow> real"
  assumes "0 < c" "\<And>x. 0 \<le> f x"
  shows "prob {x \<in> space P. c \<le> f x} \<le> (\<integral>x. f x \<partial> P) / c"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. prob {x \<in> space P. c \<le> f x} \<le> expectation f / c
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. prob {x \<in> space P. c \<le> f x} \<le> expectation f / c
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
0 < c
0 \<le> f ?x1
[PROOF STEP]
have "(\<integral>\<^sup>+ x. ennreal (f x) \<partial>P) = (\<integral>x. f x \<partial>P)"
[PROOF STATE]
proof (prove)
using this:
0 < c
0 \<le> f ?x1

goal (1 subgoal):
 1. \<integral>\<^sup>+ x. ennreal (f x) \<partial>P = ennreal (expectation f)
[PROOF STEP]
by (intro nn_integral_eq_integral) auto
[PROOF STATE]
proof (state)
this:
\<integral>\<^sup>+ x. ennreal (f x) \<partial>P = ennreal (expectation f)

goal (1 subgoal):
 1. prob {x \<in> space P. c \<le> f x} \<le> expectation f / c
[PROOF STEP]
with assms
[PROOF STATE]
proof (chain)
picking this:
0 < c
0 \<le> f ?x1
\<integral>\<^sup>+ x. ennreal (f x) \<partial>P = ennreal (expectation f)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
0 < c
0 \<le> f ?x1
\<integral>\<^sup>+ x. ennreal (f x) \<partial>P = ennreal (expectation f)

goal (1 subgoal):
 1. prob {x \<in> space P. c \<le> f x} \<le> expectation f / c
[PROOF STEP]
using nn_integral_Markov_inequality[of f "space P" P "1 / c"]
[PROOF STATE]
proof (prove)
using this:
0 < c
0 \<le> f ?x1
\<integral>\<^sup>+ x. ennreal (f x) \<partial>P = ennreal (expectation f)
\<lbrakk>random_variable borel (\<lambda>x. ennreal (f x) * indicator (space P) x); space P \<in> events\<rbrakk> \<Longrightarrow> emeasure P {x \<in> space P. 1 \<le> ennreal (1 / c) * ennreal (f x)} \<le> ennreal (1 / c) * (\<integral>\<^sup>+x\<in>space P. ennreal (f x)\<partial>P)

goal (1 subgoal):
 1. prob {x \<in> space P. c \<le> f x} \<le> expectation f / c
[PROOF STEP]
by (simp cong: nn_integral_cong add: emeasure_eq_measure ennreal_mult[symmetric])
[PROOF STATE]
proof (state)
this:
prob {x \<in> space P. c \<le> f x} \<le> expectation f / c

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma sorted_distinct_ffold_ord: assumes "sorted l"
      and "distinct l"
    shows "ffold_ord f (fset_of_list l) b = fold f l b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ffold_ord f (fset_of_list l) b = fold f l b
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
sorted l
distinct l

goal (1 subgoal):
 1. ffold_ord f (fset_of_list l) b = fold f l b
[PROOF STEP]
apply (induct l arbitrary: b)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>b. \<lbrakk>sorted []; distinct []\<rbrakk> \<Longrightarrow> ffold_ord f (fset_of_list []) b = fold f [] b
 2. \<And>a l b. \<lbrakk>\<And>b. \<lbrakk>sorted l; distinct l\<rbrakk> \<Longrightarrow> ffold_ord f (fset_of_list l) b = fold f l b; sorted (a # l); distinct (a # l)\<rbrakk> \<Longrightarrow> ffold_ord f (fset_of_list (a # l)) b = fold f (a # l) b
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>a l b. \<lbrakk>\<And>b. \<lbrakk>sorted l; distinct l\<rbrakk> \<Longrightarrow> ffold_ord f (fset_of_list l) b = fold f l b; sorted (a # l); distinct (a # l)\<rbrakk> \<Longrightarrow> ffold_ord f (fset_of_list (a # l)) b = fold f (a # l) b
[PROOF STEP]
by (metis distinct.simps(2) ffold_ord_cons fold_simps(2) sorted_simps(2))


[STATEMENT]
lemma sublists_fin: "finite {t. \<exists>t1 t2. x = t1 @ t @ t2}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite {t. \<exists>t1 t2. x = t1 @ t @ t2}
[PROOF STEP]
proof(induct x, simp)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a x. finite {t. \<exists>t1 t2. x = t1 @ t @ t2} \<Longrightarrow> finite {t. \<exists>t1 t2. a # x = t1 @ t @ t2}
[PROOF STEP]
case (Cons a x)
[PROOF STATE]
proof (state)
this:
finite {t. \<exists>t1 t2. x = t1 @ t @ t2}

goal (1 subgoal):
 1. \<And>a x. finite {t. \<exists>t1 t2. x = t1 @ t @ t2} \<Longrightarrow> finite {t. \<exists>t1 t2. a # x = t1 @ t @ t2}
[PROOF STEP]
have "{t. \<exists>t1 t2. a # x = t1 @ t @ t2} \<subseteq> {t. \<exists>t1 t2. x = t1 @ t @ t2} \<union> {t. \<exists>t2. a#x = t @ t2}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {t. \<exists>t1 t2. a # x = t1 @ t @ t2} \<subseteq> {t. \<exists>t1 t2. x = t1 @ t @ t2} \<union> {t. \<exists>t2. a # x = t @ t2}
[PROOF STEP]
apply(auto)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x t1 t2. \<lbrakk>\<forall>t2a. t1 @ x @ t2 \<noteq> x @ t2a; a # x = t1 @ x @ t2\<rbrakk> \<Longrightarrow> \<exists>t1 t2. x = t1 @ x @ t2
[PROOF STEP]
by (metis Cons_eq_append_conv)
[PROOF STATE]
proof (state)
this:
{t. \<exists>t1 t2. a # x = t1 @ t @ t2} \<subseteq> {t. \<exists>t1 t2. x = t1 @ t @ t2} \<union> {t. \<exists>t2. a # x = t @ t2}

goal (1 subgoal):
 1. \<And>a x. finite {t. \<exists>t1 t2. x = t1 @ t @ t2} \<Longrightarrow> finite {t. \<exists>t1 t2. a # x = t1 @ t @ t2}
[PROOF STEP]
with Cons prefixes_fin[of "a#x"]
[PROOF STATE]
proof (chain)
picking this:
finite {t. \<exists>t1 t2. x = t1 @ t @ t2}
let prefixes = {t. \<exists>t2. a # x = t @ t2} in finite prefixes \<and> card prefixes = length (a # x) + 1
{t. \<exists>t1 t2. a # x = t1 @ t @ t2} \<subseteq> {t. \<exists>t1 t2. x = t1 @ t @ t2} \<union> {t. \<exists>t2. a # x = t @ t2}
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
finite {t. \<exists>t1 t2. x = t1 @ t @ t2}
let prefixes = {t. \<exists>t2. a # x = t @ t2} in finite prefixes \<and> card prefixes = length (a # x) + 1
{t. \<exists>t1 t2. a # x = t1 @ t @ t2} \<subseteq> {t. \<exists>t1 t2. x = t1 @ t @ t2} \<union> {t. \<exists>t2. a # x = t @ t2}

goal (1 subgoal):
 1. finite {t. \<exists>t1 t2. a # x = t1 @ t @ t2}
[PROOF STEP]
by (meson finite_UnI finite_subset)
[PROOF STATE]
proof (state)
this:
finite {t. \<exists>t1 t2. a # x = t1 @ t @ t2}

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma CCs_empty_card: "card (CCs {}) = card V"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card (CCs {}) = card V
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. card (CCs {}) = card V
[PROOF STEP]
have i: "{{v}|v. v\<in>V} = (\<lambda>v. {v})`V"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {{v} |v. v \<in> V} = (\<lambda>v. {v}) ` V
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
{{v} |v. v \<in> V} = (\<lambda>v. {v}) ` V

goal (1 subgoal):
 1. card (CCs {}) = card V
[PROOF STEP]
have "card (CCs {}) = card {{v}|v. v\<in>V}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card (CCs {}) = card {{v} |v. v \<in> V}
[PROOF STEP]
using CCs_empty
[PROOF STATE]
proof (prove)
using this:
CCs {} = {{v} |v. v \<in> V}

goal (1 subgoal):
 1. card (CCs {}) = card {{v} |v. v \<in> V}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
card (CCs {}) = card {{v} |v. v \<in> V}

goal (1 subgoal):
 1. card (CCs {}) = card V
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
card (CCs {}) = card {{v} |v. v \<in> V}

goal (1 subgoal):
 1. card (CCs {}) = card V
[PROOF STEP]
have "\<dots> = card ((\<lambda>v. {v})`V)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card {{v} |v. v \<in> V} = card ((\<lambda>v. {v}) ` V)
[PROOF STEP]
by(simp only: i)
[PROOF STATE]
proof (state)
this:
card {{v} |v. v \<in> V} = card ((\<lambda>v. {v}) ` V)

goal (1 subgoal):
 1. card (CCs {}) = card V
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
card {{v} |v. v \<in> V} = card ((\<lambda>v. {v}) ` V)

goal (1 subgoal):
 1. card (CCs {}) = card V
[PROOF STEP]
have "\<dots> = card V"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card ((\<lambda>v. {v}) ` V) = card V
[PROOF STEP]
apply(rule card_image)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inj_on (\<lambda>v. {v}) V
[PROOF STEP]
unfolding inj_on_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>x\<in>V. \<forall>y\<in>V. {x} = {y} \<longrightarrow> x = y
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
card ((\<lambda>v. {v}) ` V) = card V

goal (1 subgoal):
 1. card (CCs {}) = card V
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
card (CCs {}) = card V
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
card (CCs {}) = card V

goal (1 subgoal):
 1. card (CCs {}) = card V
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
card (CCs {}) = card V

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma strict_prefix_eq_exists:
  "strict_prefix s t \<longleftrightarrow> (\<exists>xs . s @ xs = t \<and> (length xs) > 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. strict_prefix s t = (\<exists>xs. s @ xs = t \<and> 0 < length xs)
[PROOF STEP]
using prefix_def strict_prefix_def
[PROOF STATE]
proof (prove)
using this:
prefix ?xs ?ys = (\<exists>zs. ?ys = ?xs @ zs)
strict_prefix ?xs ?ys = (prefix ?xs ?ys \<and> ?xs \<noteq> ?ys)

goal (1 subgoal):
 1. strict_prefix s t = (\<exists>xs. s @ xs = t \<and> 0 < length xs)
[PROOF STEP]
by auto


[STATEMENT]
lemma group_eq_aux: "a + (b - a) = (b::'a::ab_group_add)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a + (b - a) = b
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. a + (b - a) = b
[PROOF STEP]
have "a + (b - a) = b - a + a"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a + (b - a) = b - a + a
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
a + (b - a) = b - a + a

goal (1 subgoal):
 1. a + (b - a) = b
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
a + (b - a) = b - a + a

goal (1 subgoal):
 1. a + (b - a) = b
[PROOF STEP]
have "... = b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. b - a + a = b
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
b - a + a = b

goal (1 subgoal):
 1. a + (b - a) = b
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
a + (b - a) = b
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
a + (b - a) = b

goal (1 subgoal):
 1. a + (b - a) = b
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
a + (b - a) = b

goal:
No subgoals!
[PROOF STEP]
qed