[STATEMENT]
lemma real_polynomial_function_imp_sum:
  assumes "real_polynomial_function f"
    shows "\<exists>a n::nat. f = (\<lambda>x. \<Sum>i\<le>n. a i * x^i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>a n. f = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
real_polynomial_function f

goal (1 subgoal):
 1. \<exists>a n. f = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)
[PROOF STEP]
proof (induct f)
[PROOF STATE]
proof (state)
goal (4 subgoals):
 1. \<And>f. bounded_linear f \<Longrightarrow> \<exists>a n. f = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)
 2. \<And>c. \<exists>a n. (\<lambda>a. c) = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)
 3. \<And>f g. \<lbrakk>real_polynomial_function f; \<exists>a n. f = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i); real_polynomial_function g; \<exists>a n. g = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)\<rbrakk> \<Longrightarrow> \<exists>a n. (\<lambda>a. f a + g a) = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)
 4. \<And>f g. \<lbrakk>real_polynomial_function f; \<exists>a n. f = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i); real_polynomial_function g; \<exists>a n. g = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)\<rbrakk> \<Longrightarrow> \<exists>a n. (\<lambda>a. f a * g a) = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)
[PROOF STEP]
case (linear f)
[PROOF STATE]
proof (state)
this:
bounded_linear f

goal (4 subgoals):
 1. \<And>f. bounded_linear f \<Longrightarrow> \<exists>a n. f = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)
 2. \<And>c. \<exists>a n. (\<lambda>a. c) = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)
 3. \<And>f g. \<lbrakk>real_polynomial_function f; \<exists>a n. f = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i); real_polynomial_function g; \<exists>a n. g = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)\<rbrakk> \<Longrightarrow> \<exists>a n. (\<lambda>a. f a + g a) = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)
 4. \<And>f g. \<lbrakk>real_polynomial_function f; \<exists>a n. f = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i); real_polynomial_function g; \<exists>a n. g = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)\<rbrakk> \<Longrightarrow> \<exists>a n. (\<lambda>a. f a * g a) = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
bounded_linear f
[PROOF STEP]
obtain c where f: "f = (\<lambda>x. x * c)"
[PROOF STATE]
proof (prove)
using this:
bounded_linear f

goal (1 subgoal):
 1. (\<And>c. f = (\<lambda>x. x * c) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (auto simp add: real_bounded_linear)
[PROOF STATE]
proof (state)
this:
f = (\<lambda>x. x * c)

goal (4 subgoals):
 1. \<And>f. bounded_linear f \<Longrightarrow> \<exists>a n. f = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)
 2. \<And>c. \<exists>a n. (\<lambda>a. c) = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)
 3. \<And>f g. \<lbrakk>real_polynomial_function f; \<exists>a n. f = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i); real_polynomial_function g; \<exists>a n. g = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)\<rbrakk> \<Longrightarrow> \<exists>a n. (\<lambda>a. f a + g a) = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)
 4. \<And>f g. \<lbrakk>real_polynomial_function f; \<exists>a n. f = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i); real_polynomial_function g; \<exists>a n. g = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)\<rbrakk> \<Longrightarrow> \<exists>a n. (\<lambda>a. f a * g a) = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)
[PROOF STEP]
have "x * c = (\<Sum>i\<le>1. (if i = 0 then 0 else c) * x^i)" for x
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x * c = (\<Sum>i\<le>1. (if i = 0 then 0 else c) * x ^ i)
[PROOF STEP]
by (simp add: mult_ac)
[PROOF STATE]
proof (state)
this:
?x * c = (\<Sum>i\<le>1. (if i = 0 then 0 else c) * ?x ^ i)

goal (4 subgoals):
 1. \<And>f. bounded_linear f \<Longrightarrow> \<exists>a n. f = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)
 2. \<And>c. \<exists>a n. (\<lambda>a. c) = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)
 3. \<And>f g. \<lbrakk>real_polynomial_function f; \<exists>a n. f = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i); real_polynomial_function g; \<exists>a n. g = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)\<rbrakk> \<Longrightarrow> \<exists>a n. (\<lambda>a. f a + g a) = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)
 4. \<And>f g. \<lbrakk>real_polynomial_function f; \<exists>a n. f = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i); real_polynomial_function g; \<exists>a n. g = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)\<rbrakk> \<Longrightarrow> \<exists>a n. (\<lambda>a. f a * g a) = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)
[PROOF STEP]
with f
[PROOF STATE]
proof (chain)
picking this:
f = (\<lambda>x. x * c)
?x * c = (\<Sum>i\<le>1. (if i = 0 then 0 else c) * ?x ^ i)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
f = (\<lambda>x. x * c)
?x * c = (\<Sum>i\<le>1. (if i = 0 then 0 else c) * ?x ^ i)

goal (1 subgoal):
 1. \<exists>a n. f = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
\<exists>a n. f = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)

goal (3 subgoals):
 1. \<And>c. \<exists>a n. (\<lambda>a. c) = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)
 2. \<And>f g. \<lbrakk>real_polynomial_function f; \<exists>a n. f = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i); real_polynomial_function g; \<exists>a n. g = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)\<rbrakk> \<Longrightarrow> \<exists>a n. (\<lambda>a. f a + g a) = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)
 3. \<And>f g. \<lbrakk>real_polynomial_function f; \<exists>a n. f = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i); real_polynomial_function g; \<exists>a n. g = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)\<rbrakk> \<Longrightarrow> \<exists>a n. (\<lambda>a. f a * g a) = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. \<And>c. \<exists>a n. (\<lambda>a. c) = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)
 2. \<And>f g. \<lbrakk>real_polynomial_function f; \<exists>a n. f = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i); real_polynomial_function g; \<exists>a n. g = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)\<rbrakk> \<Longrightarrow> \<exists>a n. (\<lambda>a. f a + g a) = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)
 3. \<And>f g. \<lbrakk>real_polynomial_function f; \<exists>a n. f = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i); real_polynomial_function g; \<exists>a n. g = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)\<rbrakk> \<Longrightarrow> \<exists>a n. (\<lambda>a. f a * g a) = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)
[PROOF STEP]
case (const c)
[PROOF STATE]
proof (state)
this:

goal (3 subgoals):
 1. \<And>c. \<exists>a n. (\<lambda>a. c) = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)
 2. \<And>f g. \<lbrakk>real_polynomial_function f; \<exists>a n. f = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i); real_polynomial_function g; \<exists>a n. g = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)\<rbrakk> \<Longrightarrow> \<exists>a n. (\<lambda>a. f a + g a) = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)
 3. \<And>f g. \<lbrakk>real_polynomial_function f; \<exists>a n. f = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i); real_polynomial_function g; \<exists>a n. g = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)\<rbrakk> \<Longrightarrow> \<exists>a n. (\<lambda>a. f a * g a) = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)
[PROOF STEP]
have "c = (\<Sum>i\<le>0. c * x^i)" for x
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. c = (\<Sum>i\<le>0. c * x ^ i)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
c = (\<Sum>i\<le>0. c * ?x ^ i)

goal (3 subgoals):
 1. \<And>c. \<exists>a n. (\<lambda>a. c) = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)
 2. \<And>f g. \<lbrakk>real_polynomial_function f; \<exists>a n. f = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i); real_polynomial_function g; \<exists>a n. g = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)\<rbrakk> \<Longrightarrow> \<exists>a n. (\<lambda>a. f a + g a) = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)
 3. \<And>f g. \<lbrakk>real_polynomial_function f; \<exists>a n. f = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i); real_polynomial_function g; \<exists>a n. g = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)\<rbrakk> \<Longrightarrow> \<exists>a n. (\<lambda>a. f a * g a) = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
c = (\<Sum>i\<le>0. c * ?x ^ i)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
c = (\<Sum>i\<le>0. c * ?x ^ i)

goal (1 subgoal):
 1. \<exists>a n. (\<lambda>a. c) = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
\<exists>a n. (\<lambda>a. c) = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)

goal (2 subgoals):
 1. \<And>f g. \<lbrakk>real_polynomial_function f; \<exists>a n. f = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i); real_polynomial_function g; \<exists>a n. g = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)\<rbrakk> \<Longrightarrow> \<exists>a n. (\<lambda>a. f a + g a) = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)
 2. \<And>f g. \<lbrakk>real_polynomial_function f; \<exists>a n. f = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i); real_polynomial_function g; \<exists>a n. g = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)\<rbrakk> \<Longrightarrow> \<exists>a n. (\<lambda>a. f a * g a) = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)
[PROOF STEP]
case (add f1 f2)
[PROOF STATE]
proof (state)
this:
real_polynomial_function f1
\<exists>a n. f1 = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)
real_polynomial_function f2
\<exists>a n. f2 = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)

goal (2 subgoals):
 1. \<And>f g. \<lbrakk>real_polynomial_function f; \<exists>a n. f = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i); real_polynomial_function g; \<exists>a n. g = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)\<rbrakk> \<Longrightarrow> \<exists>a n. (\<lambda>a. f a + g a) = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)
 2. \<And>f g. \<lbrakk>real_polynomial_function f; \<exists>a n. f = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i); real_polynomial_function g; \<exists>a n. g = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)\<rbrakk> \<Longrightarrow> \<exists>a n. (\<lambda>a. f a * g a) = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
real_polynomial_function f1
\<exists>a n. f1 = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)
real_polynomial_function f2
\<exists>a n. f2 = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)
[PROOF STEP]
obtain a1 n1 a2 n2 where
    "f1 = (\<lambda>x. \<Sum>i\<le>n1. a1 i * x^i)" "f2 = (\<lambda>x. \<Sum>i\<le>n2. a2 i * x^i)"
[PROOF STATE]
proof (prove)
using this:
real_polynomial_function f1
\<exists>a n. f1 = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)
real_polynomial_function f2
\<exists>a n. f2 = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)

goal (1 subgoal):
 1. (\<And>a1 n1 a2 n2. \<lbrakk>f1 = (\<lambda>x. \<Sum>i\<le>n1. a1 i * x ^ i); f2 = (\<lambda>x. \<Sum>i\<le>n2. a2 i * x ^ i)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
f1 = (\<lambda>x. \<Sum>i\<le>n1. a1 i * x ^ i)
f2 = (\<lambda>x. \<Sum>i\<le>n2. a2 i * x ^ i)

goal (2 subgoals):
 1. \<And>f g. \<lbrakk>real_polynomial_function f; \<exists>a n. f = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i); real_polynomial_function g; \<exists>a n. g = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)\<rbrakk> \<Longrightarrow> \<exists>a n. (\<lambda>a. f a + g a) = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)
 2. \<And>f g. \<lbrakk>real_polynomial_function f; \<exists>a n. f = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i); real_polynomial_function g; \<exists>a n. g = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)\<rbrakk> \<Longrightarrow> \<exists>a n. (\<lambda>a. f a * g a) = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
f1 = (\<lambda>x. \<Sum>i\<le>n1. a1 i * x ^ i)
f2 = (\<lambda>x. \<Sum>i\<le>n2. a2 i * x ^ i)
[PROOF STEP]
have "f1 x + f2 x = (\<Sum>i\<le>max n1 n2. ((if i \<le> n1 then a1 i else 0) + (if i \<le> n2 then a2 i else 0)) * x^i)"
      for x
[PROOF STATE]
proof (prove)
using this:
f1 = (\<lambda>x. \<Sum>i\<le>n1. a1 i * x ^ i)
f2 = (\<lambda>x. \<Sum>i\<le>n2. a2 i * x ^ i)

goal (1 subgoal):
 1. f1 x + f2 x = (\<Sum>i\<le>max n1 n2. ((if i \<le> n1 then a1 i else 0) + (if i \<le> n2 then a2 i else 0)) * x ^ i)
[PROOF STEP]
using sum_max_0 [where m=n1 and n=n2] sum_max_0 [where m=n2 and n=n1]
[PROOF STATE]
proof (prove)
using this:
f1 = (\<lambda>x. \<Sum>i\<le>n1. a1 i * x ^ i)
f2 = (\<lambda>x. \<Sum>i\<le>n2. a2 i * x ^ i)
(\<Sum>i\<le>max n1 n2. ?x ^ i * (if i \<le> n1 then ?a i else 0)) = (\<Sum>i\<le>n1. ?x ^ i * ?a i)
(\<Sum>i\<le>max n2 n1. ?x ^ i * (if i \<le> n2 then ?a i else 0)) = (\<Sum>i\<le>n2. ?x ^ i * ?a i)

goal (1 subgoal):
 1. f1 x + f2 x = (\<Sum>i\<le>max n1 n2. ((if i \<le> n1 then a1 i else 0) + (if i \<le> n2 then a2 i else 0)) * x ^ i)
[PROOF STEP]
by (simp add: sum.distrib algebra_simps max.commute)
[PROOF STATE]
proof (state)
this:
f1 ?x + f2 ?x = (\<Sum>i\<le>max n1 n2. ((if i \<le> n1 then a1 i else 0) + (if i \<le> n2 then a2 i else 0)) * ?x ^ i)

goal (2 subgoals):
 1. \<And>f g. \<lbrakk>real_polynomial_function f; \<exists>a n. f = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i); real_polynomial_function g; \<exists>a n. g = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)\<rbrakk> \<Longrightarrow> \<exists>a n. (\<lambda>a. f a + g a) = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)
 2. \<And>f g. \<lbrakk>real_polynomial_function f; \<exists>a n. f = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i); real_polynomial_function g; \<exists>a n. g = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)\<rbrakk> \<Longrightarrow> \<exists>a n. (\<lambda>a. f a * g a) = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
f1 ?x + f2 ?x = (\<Sum>i\<le>max n1 n2. ((if i \<le> n1 then a1 i else 0) + (if i \<le> n2 then a2 i else 0)) * ?x ^ i)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
f1 ?x + f2 ?x = (\<Sum>i\<le>max n1 n2. ((if i \<le> n1 then a1 i else 0) + (if i \<le> n2 then a2 i else 0)) * ?x ^ i)

goal (1 subgoal):
 1. \<exists>a n. (\<lambda>a. f1 a + f2 a) = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
\<exists>a n. (\<lambda>a. f1 a + f2 a) = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)

goal (1 subgoal):
 1. \<And>f g. \<lbrakk>real_polynomial_function f; \<exists>a n. f = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i); real_polynomial_function g; \<exists>a n. g = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)\<rbrakk> \<Longrightarrow> \<exists>a n. (\<lambda>a. f a * g a) = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)
[PROOF STEP]
case (mult f1 f2)
[PROOF STATE]
proof (state)
this:
real_polynomial_function f1
\<exists>a n. f1 = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)
real_polynomial_function f2
\<exists>a n. f2 = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)

goal (1 subgoal):
 1. \<And>f g. \<lbrakk>real_polynomial_function f; \<exists>a n. f = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i); real_polynomial_function g; \<exists>a n. g = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)\<rbrakk> \<Longrightarrow> \<exists>a n. (\<lambda>a. f a * g a) = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
real_polynomial_function f1
\<exists>a n. f1 = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)
real_polynomial_function f2
\<exists>a n. f2 = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)
[PROOF STEP]
obtain a1 n1 a2 n2 where
    "f1 = (\<lambda>x. \<Sum>i\<le>n1. a1 i * x^i)" "f2 = (\<lambda>x. \<Sum>i\<le>n2. a2 i * x^i)"
[PROOF STATE]
proof (prove)
using this:
real_polynomial_function f1
\<exists>a n. f1 = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)
real_polynomial_function f2
\<exists>a n. f2 = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)

goal (1 subgoal):
 1. (\<And>a1 n1 a2 n2. \<lbrakk>f1 = (\<lambda>x. \<Sum>i\<le>n1. a1 i * x ^ i); f2 = (\<lambda>x. \<Sum>i\<le>n2. a2 i * x ^ i)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
f1 = (\<lambda>x. \<Sum>i\<le>n1. a1 i * x ^ i)
f2 = (\<lambda>x. \<Sum>i\<le>n2. a2 i * x ^ i)

goal (1 subgoal):
 1. \<And>f g. \<lbrakk>real_polynomial_function f; \<exists>a n. f = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i); real_polynomial_function g; \<exists>a n. g = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)\<rbrakk> \<Longrightarrow> \<exists>a n. (\<lambda>a. f a * g a) = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
f1 = (\<lambda>x. \<Sum>i\<le>n1. a1 i * x ^ i)
f2 = (\<lambda>x. \<Sum>i\<le>n2. a2 i * x ^ i)
[PROOF STEP]
obtain b1 b2 where
    "f1 = (\<lambda>x. \<Sum>i\<le>n1. b1 i * x^i)" "f2 = (\<lambda>x. \<Sum>i\<le>n2. b2 i * x^i)"
    "b1 = (\<lambda>i. if i\<le>n1 then a1 i else 0)" "b2 = (\<lambda>i. if i\<le>n2 then a2 i else 0)"
[PROOF STATE]
proof (prove)
using this:
f1 = (\<lambda>x. \<Sum>i\<le>n1. a1 i * x ^ i)
f2 = (\<lambda>x. \<Sum>i\<le>n2. a2 i * x ^ i)

goal (1 subgoal):
 1. (\<And>b1 b2. \<lbrakk>f1 = (\<lambda>x. \<Sum>i\<le>n1. b1 i * x ^ i); f2 = (\<lambda>x. \<Sum>i\<le>n2. b2 i * x ^ i); b1 = (\<lambda>i. if i \<le> n1 then a1 i else 0); b2 = (\<lambda>i. if i \<le> n2 then a2 i else 0)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
f1 = (\<lambda>x. \<Sum>i\<le>n1. b1 i * x ^ i)
f2 = (\<lambda>x. \<Sum>i\<le>n2. b2 i * x ^ i)
b1 = (\<lambda>i. if i \<le> n1 then a1 i else 0)
b2 = (\<lambda>i. if i \<le> n2 then a2 i else 0)

goal (1 subgoal):
 1. \<And>f g. \<lbrakk>real_polynomial_function f; \<exists>a n. f = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i); real_polynomial_function g; \<exists>a n. g = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)\<rbrakk> \<Longrightarrow> \<exists>a n. (\<lambda>a. f a * g a) = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
f1 = (\<lambda>x. \<Sum>i\<le>n1. b1 i * x ^ i)
f2 = (\<lambda>x. \<Sum>i\<le>n2. b2 i * x ^ i)
b1 = (\<lambda>i. if i \<le> n1 then a1 i else 0)
b2 = (\<lambda>i. if i \<le> n2 then a2 i else 0)
[PROOF STEP]
have "f1 x * f2 x = (\<Sum>i\<le>n1 + n2. (\<Sum>k\<le>i. b1 k * b2 (i - k)) * x ^ i)" for x
[PROOF STATE]
proof (prove)
using this:
f1 = (\<lambda>x. \<Sum>i\<le>n1. b1 i * x ^ i)
f2 = (\<lambda>x. \<Sum>i\<le>n2. b2 i * x ^ i)
b1 = (\<lambda>i. if i \<le> n1 then a1 i else 0)
b2 = (\<lambda>i. if i \<le> n2 then a2 i else 0)

goal (1 subgoal):
 1. f1 x * f2 x = (\<Sum>i\<le>n1 + n2. (\<Sum>k\<le>i. b1 k * b2 (i - k)) * x ^ i)
[PROOF STEP]
using polynomial_product [of n1 b1 n2 b2]
[PROOF STATE]
proof (prove)
using this:
f1 = (\<lambda>x. \<Sum>i\<le>n1. b1 i * x ^ i)
f2 = (\<lambda>x. \<Sum>i\<le>n2. b2 i * x ^ i)
b1 = (\<lambda>i. if i \<le> n1 then a1 i else 0)
b2 = (\<lambda>i. if i \<le> n2 then a2 i else 0)
\<lbrakk>\<And>i. n1 < i \<Longrightarrow> b1 i = 0; \<And>j. n2 < j \<Longrightarrow> b2 j = 0\<rbrakk> \<Longrightarrow> (\<Sum>i\<le>n1. b1 i * ?x ^ i) * (\<Sum>j\<le>n2. b2 j * ?x ^ j) = (\<Sum>r\<le>n1 + n2. (\<Sum>k\<le>r. b1 k * b2 (r - k)) * ?x ^ r)

goal (1 subgoal):
 1. f1 x * f2 x = (\<Sum>i\<le>n1 + n2. (\<Sum>k\<le>i. b1 k * b2 (i - k)) * x ^ i)
[PROOF STEP]
by (simp add: Set_Interval.atLeast0AtMost)
[PROOF STATE]
proof (state)
this:
f1 ?x * f2 ?x = (\<Sum>i\<le>n1 + n2. (\<Sum>k\<le>i. b1 k * b2 (i - k)) * ?x ^ i)

goal (1 subgoal):
 1. \<And>f g. \<lbrakk>real_polynomial_function f; \<exists>a n. f = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i); real_polynomial_function g; \<exists>a n. g = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)\<rbrakk> \<Longrightarrow> \<exists>a n. (\<lambda>a. f a * g a) = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
f1 ?x * f2 ?x = (\<Sum>i\<le>n1 + n2. (\<Sum>k\<le>i. b1 k * b2 (i - k)) * ?x ^ i)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
f1 ?x * f2 ?x = (\<Sum>i\<le>n1 + n2. (\<Sum>k\<le>i. b1 k * b2 (i - k)) * ?x ^ i)

goal (1 subgoal):
 1. \<exists>a n. (\<lambda>a. f1 a * f2 a) = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
\<exists>a n. (\<lambda>a. f1 a * f2 a) = (\<lambda>x. \<Sum>i\<le>n. a i * x ^ i)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma lastMarkedIsMemberOfItsMarkedElementsTo:
  assumes
  "uniq (elements M)" and "markedElements M \<noteq> []"
  shows
  "lastMarked M \<in> set (markedElementsTo (lastMarked M) M)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. lastMarked M \<in> set (markedElementsTo (lastMarked M) M)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
uniq (elements M)
markedElements M \<noteq> []

goal (1 subgoal):
 1. lastMarked M \<in> set (markedElementsTo (lastMarked M) M)
[PROOF STEP]
using markedElementsToLastMarkedAreAllMarkedElements [of "M"]
[PROOF STATE]
proof (prove)
using this:
uniq (elements M)
markedElements M \<noteq> []
\<lbrakk>uniq (elements M); markedElements M \<noteq> []\<rbrakk> \<Longrightarrow> markedElementsTo (lastMarked M) M = markedElements M

goal (1 subgoal):
 1. lastMarked M \<in> set (markedElementsTo (lastMarked M) M)
[PROOF STEP]
using lastMarkedIsMarkedElement [of "M"]
[PROOF STATE]
proof (prove)
using this:
uniq (elements M)
markedElements M \<noteq> []
\<lbrakk>uniq (elements M); markedElements M \<noteq> []\<rbrakk> \<Longrightarrow> markedElementsTo (lastMarked M) M = markedElements M
markedElements M \<noteq> [] \<Longrightarrow> lastMarked M \<in> set (markedElements M)

goal (1 subgoal):
 1. lastMarked M \<in> set (markedElementsTo (lastMarked M) M)
[PROOF STEP]
by auto


[STATEMENT]
lemma llength_ltakeWhile_lt_iff: "llength (ltakeWhile P xs) < llength xs \<longleftrightarrow> (\<exists>x\<in>lset xs. \<not> P x)"
  (is "?lhs \<longleftrightarrow> ?rhs")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (llength (ltakeWhile P xs) < llength xs) = (\<exists>x\<in>lset xs. \<not> P x)
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. llength (ltakeWhile P xs) < llength xs \<Longrightarrow> \<exists>x\<in>lset xs. \<not> P x
 2. \<exists>x\<in>lset xs. \<not> P x \<Longrightarrow> llength (ltakeWhile P xs) < llength xs
[PROOF STEP]
assume ?lhs
[PROOF STATE]
proof (state)
this:
llength (ltakeWhile P xs) < llength xs

goal (2 subgoals):
 1. llength (ltakeWhile P xs) < llength xs \<Longrightarrow> \<exists>x\<in>lset xs. \<not> P x
 2. \<exists>x\<in>lset xs. \<not> P x \<Longrightarrow> llength (ltakeWhile P xs) < llength xs
[PROOF STEP]
hence "ltakeWhile P xs \<noteq> xs"
[PROOF STATE]
proof (prove)
using this:
llength (ltakeWhile P xs) < llength xs

goal (1 subgoal):
 1. ltakeWhile P xs \<noteq> xs
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
ltakeWhile P xs \<noteq> xs

goal (2 subgoals):
 1. llength (ltakeWhile P xs) < llength xs \<Longrightarrow> \<exists>x\<in>lset xs. \<not> P x
 2. \<exists>x\<in>lset xs. \<not> P x \<Longrightarrow> llength (ltakeWhile P xs) < llength xs
[PROOF STEP]
thus ?rhs
[PROOF STATE]
proof (prove)
using this:
ltakeWhile P xs \<noteq> xs

goal (1 subgoal):
 1. \<exists>x\<in>lset xs. \<not> P x
[PROOF STEP]
by(auto simp add: ltakeWhile_all_conv)
[PROOF STATE]
proof (state)
this:
\<exists>x\<in>lset xs. \<not> P x

goal (1 subgoal):
 1. \<exists>x\<in>lset xs. \<not> P x \<Longrightarrow> llength (ltakeWhile P xs) < llength xs
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>x\<in>lset xs. \<not> P x \<Longrightarrow> llength (ltakeWhile P xs) < llength xs
[PROOF STEP]
assume ?rhs
[PROOF STATE]
proof (state)
this:
\<exists>x\<in>lset xs. \<not> P x

goal (1 subgoal):
 1. \<exists>x\<in>lset xs. \<not> P x \<Longrightarrow> llength (ltakeWhile P xs) < llength xs
[PROOF STEP]
hence "ltakeWhile P xs \<noteq> xs"
[PROOF STATE]
proof (prove)
using this:
\<exists>x\<in>lset xs. \<not> P x

goal (1 subgoal):
 1. ltakeWhile P xs \<noteq> xs
[PROOF STEP]
by(auto simp add: ltakeWhile_all_conv)
[PROOF STATE]
proof (state)
this:
ltakeWhile P xs \<noteq> xs

goal (1 subgoal):
 1. \<exists>x\<in>lset xs. \<not> P x \<Longrightarrow> llength (ltakeWhile P xs) < llength xs
[PROOF STEP]
thus ?lhs
[PROOF STATE]
proof (prove)
using this:
ltakeWhile P xs \<noteq> xs

goal (1 subgoal):
 1. llength (ltakeWhile P xs) < llength xs
[PROOF STEP]
unfolding llength_ltakeWhile_all[symmetric]
[PROOF STATE]
proof (prove)
using this:
llength (ltakeWhile P xs) \<noteq> llength xs

goal (1 subgoal):
 1. llength (ltakeWhile P xs) < llength xs
[PROOF STEP]
using llength_ltakeWhile_le[of P xs]
[PROOF STATE]
proof (prove)
using this:
llength (ltakeWhile P xs) \<noteq> llength xs
llength (ltakeWhile P xs) \<le> llength xs

goal (1 subgoal):
 1. llength (ltakeWhile P xs) < llength xs
[PROOF STEP]
by(auto)
[PROOF STATE]
proof (state)
this:
llength (ltakeWhile P xs) < llength xs

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma least_squares_approximation:
  fixes X::"'a::{euclidean_space} set"
  assumes subspace_S: "subspace S"
  and ind_X: "independent X"
  and X: "X \<subseteq> S"
  and span_X: "S \<subseteq> span X"
  and o: "pairwise orthogonal X"
  and not_eq: "proj_onto v X \<noteq> y"
  and y: "y \<in> S"
  shows "norm (v - proj_onto v X) < norm (v - y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. norm (v - proj_onto v X) < norm (v - y)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. norm (v - proj_onto v X) < norm (v - y)
[PROOF STEP]
have S_eq_spanX: "S = span X"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. S = span X
[PROOF STEP]
using X span_X span_subspace subspace_S
[PROOF STATE]
proof (prove)
using this:
X \<subseteq> S
S \<subseteq> span X
\<lbrakk>?A \<subseteq> ?B; ?B \<subseteq> span ?A; subspace ?B\<rbrakk> \<Longrightarrow> span ?A = ?B
subspace S

goal (1 subgoal):
 1. S = span X
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
S = span X

goal (1 subgoal):
 1. norm (v - proj_onto v X) < norm (v - y)
[PROOF STEP]
let ?p="proj_onto v X"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. norm (v - proj_onto v X) < norm (v - y)
[PROOF STEP]
have not_0: "(norm(?p - y))^2 \<noteq> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (norm (proj_onto v X - y))\<^sup>2 \<noteq> 0
[PROOF STEP]
by (metis (lifting) eq_iff_diff_eq_0 norm_eq_zero not_eq power_eq_0_iff)
[PROOF STATE]
proof (state)
this:
(norm (proj_onto v X - y))\<^sup>2 \<noteq> 0

goal (1 subgoal):
 1. norm (v - proj_onto v X) < norm (v - y)
[PROOF STEP]
have "norm (v-y)^2 = norm (v - ?p + ?p - y)^2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (norm (v - y))\<^sup>2 = (norm (v - proj_onto v X + proj_onto v X - y))\<^sup>2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(norm (v - y))\<^sup>2 = (norm (v - proj_onto v X + proj_onto v X - y))\<^sup>2

goal (1 subgoal):
 1. norm (v - proj_onto v X) < norm (v - y)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(norm (v - y))\<^sup>2 = (norm (v - proj_onto v X + proj_onto v X - y))\<^sup>2

goal (1 subgoal):
 1. norm (v - proj_onto v X) < norm (v - y)
[PROOF STEP]
have "... = norm ((v - ?p) + (?p - y))^2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (norm (v - proj_onto v X + proj_onto v X - y))\<^sup>2 = (norm (v - proj_onto v X + (proj_onto v X - y)))\<^sup>2
[PROOF STEP]
unfolding add.assoc[symmetric]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (norm (v - proj_onto v X + proj_onto v X - y))\<^sup>2 = (norm (v - proj_onto v X + (proj_onto v X - y)))\<^sup>2
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(norm (v - proj_onto v X + proj_onto v X - y))\<^sup>2 = (norm (v - proj_onto v X + (proj_onto v X - y)))\<^sup>2

goal (1 subgoal):
 1. norm (v - proj_onto v X) < norm (v - y)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(norm (v - proj_onto v X + proj_onto v X - y))\<^sup>2 = (norm (v - proj_onto v X + (proj_onto v X - y)))\<^sup>2

goal (1 subgoal):
 1. norm (v - proj_onto v X) < norm (v - y)
[PROOF STEP]
have "... = (norm (v - ?p))^2 + (norm(?p - y))^2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (norm (v - proj_onto v X + (proj_onto v X - y)))\<^sup>2 = (norm (v - proj_onto v X))\<^sup>2 + (norm (proj_onto v X - y))\<^sup>2
[PROOF STEP]
proof (rule phytagorean_theorem_norm, rule in_orthogonal_complement_imp_orthogonal)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. proj_onto v X - y \<in> ?S2
 2. v - proj_onto v X \<in> orthogonal_complement ?S2
[PROOF STEP]
show "?p - y \<in> S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. proj_onto v X - y \<in> S
[PROOF STEP]
unfolding proj_onto_def proj_def[abs_def]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>u\<in>X. (v \<bullet> u / (u \<bullet> u)) *\<^sub>R u) - y \<in> S
[PROOF STEP]
proof (rule subspace_diff[OF subspace_S _ y],
        rule subspace_sum[OF subspace_S])
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> X \<Longrightarrow> (v \<bullet> x / (x \<bullet> x)) *\<^sub>R x \<in> S
[PROOF STEP]
show "x \<in> X \<Longrightarrow> (v \<bullet> x / (x \<bullet> x)) *\<^sub>R x \<in> S" for x
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<in> X \<Longrightarrow> (v \<bullet> x / (x \<bullet> x)) *\<^sub>R x \<in> S
[PROOF STEP]
by (metis S_eq_spanX X rev_subsetD span_mul)
[PROOF STATE]
proof (state)
this:
?x \<in> X \<Longrightarrow> (v \<bullet> ?x / (?x \<bullet> ?x)) *\<^sub>R ?x \<in> S

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
proj_onto v X - y \<in> S

goal (1 subgoal):
 1. v - proj_onto v X \<in> orthogonal_complement S
[PROOF STEP]
show "v - ?p \<in> orthogonal_complement S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. v - proj_onto v X \<in> orthogonal_complement S
[PROOF STEP]
using v_minus_p_orthogonal_complement assms
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>subspace ?S; independent ?X; ?X \<subseteq> ?S; ?S \<subseteq> span ?X; pairwise orthogonal ?X\<rbrakk> \<Longrightarrow> ?v - proj_onto ?v ?X \<in> orthogonal_complement ?S
subspace S
independent X
X \<subseteq> S
S \<subseteq> span X
pairwise orthogonal X
proj_onto v X \<noteq> y
y \<in> S

goal (1 subgoal):
 1. v - proj_onto v X \<in> orthogonal_complement S
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
v - proj_onto v X \<in> orthogonal_complement S

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(norm (v - proj_onto v X + (proj_onto v X - y)))\<^sup>2 = (norm (v - proj_onto v X))\<^sup>2 + (norm (proj_onto v X - y))\<^sup>2

goal (1 subgoal):
 1. norm (v - proj_onto v X) < norm (v - y)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(norm (v - y))\<^sup>2 = (norm (v - proj_onto v X))\<^sup>2 + (norm (proj_onto v X - y))\<^sup>2
[PROOF STEP]
have "norm (v-?p)^2 < norm (v-y)^2"
[PROOF STATE]
proof (prove)
using this:
(norm (v - y))\<^sup>2 = (norm (v - proj_onto v X))\<^sup>2 + (norm (proj_onto v X - y))\<^sup>2

goal (1 subgoal):
 1. (norm (v - proj_onto v X))\<^sup>2 < (norm (v - y))\<^sup>2
[PROOF STEP]
using not_0
[PROOF STATE]
proof (prove)
using this:
(norm (v - y))\<^sup>2 = (norm (v - proj_onto v X))\<^sup>2 + (norm (proj_onto v X - y))\<^sup>2
(norm (proj_onto v X - y))\<^sup>2 \<noteq> 0

goal (1 subgoal):
 1. (norm (v - proj_onto v X))\<^sup>2 < (norm (v - y))\<^sup>2
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
(norm (v - proj_onto v X))\<^sup>2 < (norm (v - y))\<^sup>2

goal (1 subgoal):
 1. norm (v - proj_onto v X) < norm (v - y)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
(norm (v - proj_onto v X))\<^sup>2 < (norm (v - y))\<^sup>2

goal (1 subgoal):
 1. norm (v - proj_onto v X) < norm (v - y)
[PROOF STEP]
by (metis (full_types) norm_gt_square power2_norm_eq_inner)
[PROOF STATE]
proof (state)
this:
norm (v - proj_onto v X) < norm (v - y)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma cong_sum_mono_neutral_right:
  assumes "finite T"
  assumes "S \<subseteq> T"
  assumes zeros: "\<forall>i \<in> T - S. [g i = 0] (mod n)"
  shows "[sum g T = sum g S] (mod n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [sum g T = sum g S] (mod n)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. [sum g T = sum g S] (mod n)
[PROOF STEP]
have "[sum g T = (\<Sum>x\<in>T. if x \<in> S then g x else 0)] (mod n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [sum g T = \<Sum>x\<in>T. if x \<in> S then g x else (0::'b)] (mod n)
[PROOF STEP]
using zeros
[PROOF STATE]
proof (prove)
using this:
\<forall>i\<in>T - S. [g i = 0::'b] (mod n)

goal (1 subgoal):
 1. [sum g T = \<Sum>x\<in>T. if x \<in> S then g x else (0::'b)] (mod n)
[PROOF STEP]
by (auto intro: cong_sum)
[PROOF STATE]
proof (state)
this:
[sum g T = \<Sum>x\<in>T. if x \<in> S then g x else (0::'b)] (mod n)

goal (1 subgoal):
 1. [sum g T = sum g S] (mod n)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
[sum g T = \<Sum>x\<in>T. if x \<in> S then g x else (0::'b)] (mod n)

goal (1 subgoal):
 1. [sum g T = sum g S] (mod n)
[PROOF STEP]
have "(\<Sum>x\<in>T. if x \<in> S then g x else 0) = (\<Sum>x\<in>S. if x \<in> S then g x else 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>x\<in>T. if x \<in> S then g x else (0::'b)) = (\<Sum>x\<in>S. if x \<in> S then g x else (0::'b))
[PROOF STEP]
by (intro sum.mono_neutral_right; fact?; auto)
[PROOF STATE]
proof (state)
this:
(\<Sum>x\<in>T. if x \<in> S then g x else (0::'b)) = (\<Sum>x\<in>S. if x \<in> S then g x else (0::'b))

goal (1 subgoal):
 1. [sum g T = sum g S] (mod n)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>x\<in>T. if x \<in> S then g x else (0::'b)) = (\<Sum>x\<in>S. if x \<in> S then g x else (0::'b))

goal (1 subgoal):
 1. [sum g T = sum g S] (mod n)
[PROOF STEP]
have "... = sum g S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>x\<in>S. if x \<in> S then g x else (0::'b)) = sum g S
[PROOF STEP]
by (auto intro: sum.cong)
[PROOF STATE]
proof (state)
this:
(\<Sum>x\<in>S. if x \<in> S then g x else (0::'b)) = sum g S

goal (1 subgoal):
 1. [sum g T = sum g S] (mod n)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
[sum g T = sum g S] (mod n)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
[sum g T = sum g S] (mod n)

goal (1 subgoal):
 1. [sum g T = sum g S] (mod n)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
[sum g T = sum g S] (mod n)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma coin_coin': "map_spmf (\<lambda> S3. S0 \<oplus> S3 \<oplus> m1) coin_spmf = coin_spmf"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map_spmf (\<lambda>S3. S0 \<oplus> S3 \<oplus> m1) coin_spmf = coin_spmf
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. map_spmf (\<lambda>S3. S0 \<oplus> S3 \<oplus> m1) coin_spmf = coin_spmf
[PROOF STEP]
have "map_spmf (\<lambda> S3. S0 \<oplus> S3 \<oplus> m1) coin_spmf = map_spmf (\<lambda> S3. S3 \<oplus> S0 \<oplus> m1) coin_spmf"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map_spmf (\<lambda>S3. S0 \<oplus> S3 \<oplus> m1) coin_spmf = map_spmf (\<lambda>S3. S3 \<oplus> S0 \<oplus> m1) coin_spmf
[PROOF STEP]
by (metis xor_left_commute)
[PROOF STATE]
proof (state)
this:
map_spmf (\<lambda>S3. S0 \<oplus> S3 \<oplus> m1) coin_spmf = map_spmf (\<lambda>S3. S3 \<oplus> S0 \<oplus> m1) coin_spmf

goal (1 subgoal):
 1. map_spmf (\<lambda>S3. S0 \<oplus> S3 \<oplus> m1) coin_spmf = coin_spmf
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
map_spmf (\<lambda>S3. S0 \<oplus> S3 \<oplus> m1) coin_spmf = map_spmf (\<lambda>S3. S3 \<oplus> S0 \<oplus> m1) coin_spmf

goal (1 subgoal):
 1. map_spmf (\<lambda>S3. S0 \<oplus> S3 \<oplus> m1) coin_spmf = coin_spmf
[PROOF STEP]
using coin_coin
[PROOF STATE]
proof (prove)
using this:
map_spmf (\<lambda>S3. S0 \<oplus> S3 \<oplus> m1) coin_spmf = map_spmf (\<lambda>S3. S3 \<oplus> S0 \<oplus> m1) coin_spmf
map_spmf (\<lambda>S0. S0 \<oplus> ?S3.0 \<oplus> ?m1.0) coin_spmf = coin_spmf

goal (1 subgoal):
 1. map_spmf (\<lambda>S3. S0 \<oplus> S3 \<oplus> m1) coin_spmf = coin_spmf
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
map_spmf (\<lambda>S3. S0 \<oplus> S3 \<oplus> m1) coin_spmf = coin_spmf

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma card_nset:"i < (j :: nat) \<Longrightarrow> card (nset i j) = Suc (j - i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. i < j \<Longrightarrow> card (nset i j) = Suc (j - i)
[PROOF STEP]
apply (frule slide_inj [of "i" "j"])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>i < j; inj_on (slide i) {k. k \<le> j - i}\<rbrakk> \<Longrightarrow> card (nset i j) = Suc (j - i)
[PROOF STEP]
apply (frule card_image [of "slide i" "{k. k \<le> (j - i)}"])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>i < j; inj_on (slide i) {k. k \<le> j - i}; card (slide i ` {k. k \<le> j - i}) = card {k. k \<le> j - i}\<rbrakk> \<Longrightarrow> card (nset i j) = Suc (j - i)
[PROOF STEP]
apply (simp, frule slide_surj [of "i" "j"], simp add:surj_to_def)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma ennreal_Inf_countable_INF:
  "A \<noteq> {} \<Longrightarrow> \<exists>f::nat \<Rightarrow> ennreal. decseq f \<and> range f \<subseteq> A \<and> Inf A = (INF i. f i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A \<noteq> {} \<Longrightarrow> \<exists>f. decseq f \<and> range f \<subseteq> A \<and> Inf A = Inf (range f)
[PROOF STEP]
unfolding decseq_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A \<noteq> {} \<Longrightarrow> \<exists>f. (\<forall>m n. m \<le> n \<longrightarrow> f n \<le> f m) \<and> range f \<subseteq> A \<and> Inf A = Inf (range f)
[PROOF STEP]
apply transfer
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>A. \<lbrakk>Ball A ((\<le>) 0); A \<noteq> {}\<rbrakk> \<Longrightarrow> \<exists>f\<in>Collect (pred_fun top ((\<le>) 0)). (\<forall>m n. m \<le> n \<longrightarrow> f n \<le> f m) \<and> range f \<subseteq> A \<and> Inf A = Inf (range f)
[PROOF STEP]
subgoal for A
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>Ball A ((\<le>) 0); A \<noteq> {}\<rbrakk> \<Longrightarrow> \<exists>f\<in>Collect (pred_fun top ((\<le>) 0)). (\<forall>m n. m \<le> n \<longrightarrow> f n \<le> f m) \<and> range f \<subseteq> A \<and> Inf A = Inf (range f)
[PROOF STEP]
using Inf_countable_INF[of A]
[PROOF STATE]
proof (prove)
using this:
A \<noteq> {} \<Longrightarrow> \<exists>f. decseq f \<and> range f \<subseteq> A \<and> Inf A = Inf (range f)

goal (1 subgoal):
 1. \<lbrakk>Ball A ((\<le>) 0); A \<noteq> {}\<rbrakk> \<Longrightarrow> \<exists>f\<in>Collect (pred_fun top ((\<le>) 0)). (\<forall>m n. m \<le> n \<longrightarrow> f n \<le> f m) \<and> range f \<subseteq> A \<and> Inf A = Inf (range f)
[PROOF STEP]
apply (clarsimp simp flip: decseq_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>f. \<lbrakk>\<forall>x\<in>A. 0 \<le> x; A \<noteq> {}; decseq f; range f \<subseteq> A; Inf A = Inf (range f)\<rbrakk> \<Longrightarrow> \<exists>fa. (\<forall>x. 0 \<le> fa x) \<and> decseq fa \<and> range fa \<subseteq> A \<and> Inf (range f) = Inf (range fa)
[PROOF STEP]
subgoal for f
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<forall>x\<in>A. 0 \<le> x; A \<noteq> {}; decseq f; range f \<subseteq> A; Inf A = Inf (range f)\<rbrakk> \<Longrightarrow> \<exists>fa. (\<forall>x. 0 \<le> fa x) \<and> decseq fa \<and> range fa \<subseteq> A \<and> Inf (range f) = Inf (range fa)
[PROOF STEP]
by (intro exI[of _ f]) auto
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma uniformly_convergent_mult:
  "uniformly_convergent_on A f \<Longrightarrow>
      uniformly_convergent_on A (\<lambda>k x. c * f k x :: 'a :: {real_normed_algebra})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. uniformly_convergent_on A f \<Longrightarrow> uniformly_convergent_on A (\<lambda>k x. c * f k x)
[PROOF STEP]
unfolding uniformly_convergent_on_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>l. uniform_limit A f l sequentially \<Longrightarrow> \<exists>l. uniform_limit A (\<lambda>k x. c * f k x) l sequentially
[PROOF STEP]
by (blast dest: bounded_linear_uniform_limit_intros(13))


[STATEMENT]
lemma remove_comp_cls_val_process0:
  assumes "portfolio pf1"
  shows "\<forall>w. cls_val_process Mkt (qty_rem_comp pf1 y) 0 w =
  ((cls_val_process Mkt pf1) 0 w) - (prices Mkt y 0 w)* (pf1 y (Suc 0) w)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>w. cls_val_process Mkt (qty_rem_comp pf1 y) 0 w = cls_val_process Mkt pf1 0 w - prices Mkt y 0 w * pf1 y (Suc 0) w
[PROOF STEP]
unfolding cls_val_process_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>w. (if \<not> portfolio (qty_rem_comp pf1 y) then \<lambda>n w. 0 else up_cl_proc Mkt (qty_rem_comp pf1 y)) 0 w = (if \<not> portfolio pf1 then \<lambda>n w. 0 else up_cl_proc Mkt pf1) 0 w - prices Mkt y 0 w * pf1 y (Suc 0) w
[PROOF STEP]
by (simp add: assms remove_comp_portfolio remove_comp_val_process)


[STATEMENT]
lemma exp_conj_o_distrib[simp]:
  "(P && Q) o f = (P o f) && (Q o f)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. P && Q \<circ> f = (P \<circ> f) && (Q \<circ> f)
[PROOF STEP]
unfolding exp_conj_def o_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. P (f x) .& Q (f x)) = (\<lambda>s. P (f s) .& Q (f s))
[PROOF STEP]
by(simp)


[STATEMENT]
lemma Graph13: "\<lbrakk>a\<subset> Blacks M;j<length M\<rbrakk> \<Longrightarrow> a \<subset> Blacks (M[j := Black])"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>a \<subset> Blacks M; j < length M\<rbrakk> \<Longrightarrow> a \<subset> Blacks (M[j := Black])
[PROOF STEP]
apply (unfold Blacks_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>a \<subset> {i. i < length M \<and> M ! i = Black}; j < length M\<rbrakk> \<Longrightarrow> a \<subset> {i. i < length (M[j := Black]) \<and> M[j := Black] ! i = Black}
[PROOF STEP]
apply(erule psubset_subset_trans)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. j < length M \<Longrightarrow> {i. i < length M \<and> M ! i = Black} \<subseteq> {i. i < length (M[j := Black]) \<and> M[j := Black] ! i = Black}
[PROOF STEP]
apply(force simp add: nth_list_update)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma wnf_lemma_1:
  "((-x \<squnion> -y) \<sqinter> (--x \<squnion> -z)) \<squnion> -x = -x \<squnion> -y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (- x \<squnion> - y) \<sqinter> (- - x \<squnion> - z) \<squnion> - x = - x \<squnion> - y
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (- x \<squnion> - y) \<sqinter> (- - x \<squnion> - z) \<squnion> - x = - x \<squnion> - y
[PROOF STEP]
have "\<forall>u v w. (-u \<sqinter> (-v \<squnion> --w)) \<squnion> -w = -u \<squnion> -w"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>u v w. - u \<sqinter> (- v \<squnion> - - w) \<squnion> - w = - u \<squnion> - w
[PROOF STEP]
by (metis inf_right_zero sub_associative sub_sup_closed sup_complement sup_idempotent sup_right_dist_inf)
[PROOF STATE]
proof (state)
this:
\<forall>u v w. - u \<sqinter> (- v \<squnion> - - w) \<squnion> - w = - u \<squnion> - w

goal (1 subgoal):
 1. (- x \<squnion> - y) \<sqinter> (- - x \<squnion> - z) \<squnion> - x = - x \<squnion> - y
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
\<forall>u v w. - u \<sqinter> (- v \<squnion> - - w) \<squnion> - w = - u \<squnion> - w

goal (1 subgoal):
 1. (- x \<squnion> - y) \<sqinter> (- - x \<squnion> - z) \<squnion> - x = - x \<squnion> - y
[PROOF STEP]
by (metis (no_types) sub_associative sub_commutative sub_sup_closed sup_idempotent)
[PROOF STATE]
proof (state)
this:
(- x \<squnion> - y) \<sqinter> (- - x \<squnion> - z) \<squnion> - x = - x \<squnion> - y

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma map_aux_AboveS_not_empty:
  assumes "map_aux`S \<subseteq> Field wo_aux"
  shows "wo_aux.AboveS (map_aux`S) \<noteq> {}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. AboveS wo_aux (map_aux ` S) \<noteq> {}
[PROOF STEP]
apply (rule AboveS_not_empty_in_regularCard'[of S])
[PROOF STATE]
proof (prove)
goal (6 subgoals):
 1. |S| <o wo_aux
 2. map_aux ` S \<subseteq> Field wo_aux
 3. S \<subseteq> S
 4. Card_order wo_aux
 5. regularCard wo_aux
 6. infinite (Field wo_aux)
[PROOF STEP]
using wo_aux_exists assms
[PROOF STATE]
proof (prove)
using this:
Card_order wo_aux \<and> infinite (Field wo_aux) \<and> regularCard wo_aux \<and> |UNIV| <o wo_aux
map_aux ` S \<subseteq> Field wo_aux

goal (6 subgoals):
 1. |S| <o wo_aux
 2. map_aux ` S \<subseteq> Field wo_aux
 3. S \<subseteq> S
 4. Card_order wo_aux
 5. regularCard wo_aux
 6. infinite (Field wo_aux)
[PROOF STEP]
apply auto
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>map_aux ` S \<subseteq> Field wo_aux; Card_order wo_aux; infinite (Field wo_aux); regularCard wo_aux; |UNIV| <o wo_aux\<rbrakk> \<Longrightarrow> |S| <o wo_aux
[PROOF STEP]
using card_of_UNIV ordLeq_ordLess_trans
[PROOF STATE]
proof (prove)
using this:
|?A| \<le>o |UNIV|
\<lbrakk>?r \<le>o ?r'; ?r' <o ?r''\<rbrakk> \<Longrightarrow> ?r <o ?r''

goal (1 subgoal):
 1. \<lbrakk>map_aux ` S \<subseteq> Field wo_aux; Card_order wo_aux; infinite (Field wo_aux); regularCard wo_aux; |UNIV| <o wo_aux\<rbrakk> \<Longrightarrow> |S| <o wo_aux
[PROOF STEP]
by blast


[STATEMENT]
lemma (in sigma_algebra) sigma_sets_eq:
     "sigma_sets \<Omega> M = M"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sigma_sets \<Omega> M = M
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. sigma_sets \<Omega> M \<subseteq> M
 2. M \<subseteq> sigma_sets \<Omega> M
[PROOF STEP]
show "M \<subseteq> sigma_sets \<Omega> M"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. M \<subseteq> sigma_sets \<Omega> M
[PROOF STEP]
by (metis Set.subsetI sigma_sets.Basic)
[PROOF STATE]
proof (state)
this:
M \<subseteq> sigma_sets \<Omega> M

goal (1 subgoal):
 1. sigma_sets \<Omega> M \<subseteq> M
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. sigma_sets \<Omega> M \<subseteq> M
[PROOF STEP]
show "sigma_sets \<Omega> M \<subseteq> M"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sigma_sets \<Omega> M \<subseteq> M
[PROOF STEP]
by (metis sigma_sets_subset subset_refl)
[PROOF STATE]
proof (state)
this:
sigma_sets \<Omega> M \<subseteq> M

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma (in cpx_sq_mat) sum_qt_expect_trace:
  assumes "lhv M A B R XA XB"
  shows "(\<Sum> a \<in> spectrum A. f a * (\<Sum> b \<in> spectrum B. g b * integral\<^sup>L M (\<lambda>w. XA a w * XB b w))) =
    (\<Sum> a \<in> spectrum A. f a * (\<Sum> b \<in> spectrum B. g b *
    Re (Complex_Matrix.trace(eigen_projector A a * (eigen_projector B b) * R))))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>a\<in>spectrum A. f a * (\<Sum>b\<in>spectrum B. g b * (LINT w|M. XA a w * XB b w))) = (\<Sum>a\<in>spectrum A. f a * (\<Sum>b\<in>spectrum B. g b * Re (Complex_Matrix.trace (eigen_projector A a * eigen_projector B b * R))))
[PROOF STEP]
proof (rule sum.cong, simp)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> spectrum A \<Longrightarrow> f x * (\<Sum>b\<in>spectrum B. g b * (LINT w|M. XA x w * XB b w)) = f x * (\<Sum>b\<in>spectrum B. g b * Re (Complex_Matrix.trace (eigen_projector A x * eigen_projector B b * R)))
[PROOF STEP]
fix a
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> spectrum A \<Longrightarrow> f x * (\<Sum>b\<in>spectrum B. g b * (LINT w|M. XA x w * XB b w)) = f x * (\<Sum>b\<in>spectrum B. g b * Re (Complex_Matrix.trace (eigen_projector A x * eigen_projector B b * R)))
[PROOF STEP]
assume "a\<in> spectrum A"
[PROOF STATE]
proof (state)
this:
a \<in> spectrum A

goal (1 subgoal):
 1. \<And>x. x \<in> spectrum A \<Longrightarrow> f x * (\<Sum>b\<in>spectrum B. g b * (LINT w|M. XA x w * XB b w)) = f x * (\<Sum>b\<in>spectrum B. g b * Re (Complex_Matrix.trace (eigen_projector A x * eigen_projector B b * R)))
[PROOF STEP]
have "(\<Sum>b\<in>spectrum B. g b * (LINT w|M. XA a w * XB b w)) =
       (\<Sum>b\<in>spectrum B. g b *
        Re (Complex_Matrix.trace (eigen_projector A a * eigen_projector B b * R)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>b\<in>spectrum B. g b * (LINT w|M. XA a w * XB b w)) = (\<Sum>b\<in>spectrum B. g b * Re (Complex_Matrix.trace (eigen_projector A a * eigen_projector B b * R)))
[PROOF STEP]
proof (rule sum.cong, simp)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> spectrum B \<Longrightarrow> g x * (LINT w|M. XA a w * XB x w) = g x * Re (Complex_Matrix.trace (eigen_projector A a * eigen_projector B x * R))
[PROOF STEP]
fix b
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> spectrum B \<Longrightarrow> g x * (LINT w|M. XA a w * XB x w) = g x * Re (Complex_Matrix.trace (eigen_projector A a * eigen_projector B x * R))
[PROOF STEP]
assume "b\<in> spectrum B"
[PROOF STATE]
proof (state)
this:
b \<in> spectrum B

goal (1 subgoal):
 1. \<And>x. x \<in> spectrum B \<Longrightarrow> g x * (LINT w|M. XA a w * XB x w) = g x * Re (Complex_Matrix.trace (eigen_projector A a * eigen_projector B x * R))
[PROOF STEP]
show "g b * (LINT w|M. XA a w * XB b w) =
      g b * Re (Complex_Matrix.trace (eigen_projector A a * eigen_projector B b * R))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. g b * (LINT w|M. XA a w * XB b w) = g b * Re (Complex_Matrix.trace (eigen_projector A a * eigen_projector B b * R))
[PROOF STEP]
using lhv_integral_eq[of M] assms \<open>a \<in> spectrum A\<close> \<open>b \<in> spectrum B\<close>
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>lhv M ?A ?B ?R ?XA ?XB; ?a \<in> spectrum ?A; ?b \<in> spectrum ?B\<rbrakk> \<Longrightarrow> LINT w|M. ?XA ?a w * ?XB ?b w = Re (Complex_Matrix.trace (eigen_projector ?A ?a * eigen_projector ?B ?b * ?R))
lhv M A B R XA XB
a \<in> spectrum A
b \<in> spectrum B

goal (1 subgoal):
 1. g b * (LINT w|M. XA a w * XB b w) = g b * Re (Complex_Matrix.trace (eigen_projector A a * eigen_projector B b * R))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
g b * (LINT w|M. XA a w * XB b w) = g b * Re (Complex_Matrix.trace (eigen_projector A a * eigen_projector B b * R))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<Sum>b\<in>spectrum B. g b * (LINT w|M. XA a w * XB b w)) = (\<Sum>b\<in>spectrum B. g b * Re (Complex_Matrix.trace (eigen_projector A a * eigen_projector B b * R)))

goal (1 subgoal):
 1. \<And>x. x \<in> spectrum A \<Longrightarrow> f x * (\<Sum>b\<in>spectrum B. g b * (LINT w|M. XA x w * XB b w)) = f x * (\<Sum>b\<in>spectrum B. g b * Re (Complex_Matrix.trace (eigen_projector A x * eigen_projector B b * R)))
[PROOF STEP]
thus "f a * (\<Sum>b\<in>spectrum B. g b * (LINT w|M. XA a w * XB b w)) =
        f a * (\<Sum>b\<in>spectrum B. g b *
        Re (Complex_Matrix.trace (eigen_projector A a * eigen_projector B b * R)))"
[PROOF STATE]
proof (prove)
using this:
(\<Sum>b\<in>spectrum B. g b * (LINT w|M. XA a w * XB b w)) = (\<Sum>b\<in>spectrum B. g b * Re (Complex_Matrix.trace (eigen_projector A a * eigen_projector B b * R)))

goal (1 subgoal):
 1. f a * (\<Sum>b\<in>spectrum B. g b * (LINT w|M. XA a w * XB b w)) = f a * (\<Sum>b\<in>spectrum B. g b * Re (Complex_Matrix.trace (eigen_projector A a * eigen_projector B b * R)))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
f a * (\<Sum>b\<in>spectrum B. g b * (LINT w|M. XA a w * XB b w)) = f a * (\<Sum>b\<in>spectrum B. g b * Re (Complex_Matrix.trace (eigen_projector A a * eigen_projector B b * R)))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma Affine_zero_pdevs[simp]: "Affine (0, zero_pdevs) = {0}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Affine (0::'a, zero_pdevs) = {0::'a}
[PROOF STEP]
by (force simp: Affine_def valuate_def aform_val_def)


[STATEMENT]
lemma is_lbI: "(!!x. x \<in> S ==> l \<sqsubseteq> x) ==> S >| l"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>x. x \<in> S \<Longrightarrow> l \<sqsubseteq> x) \<Longrightarrow> S >| l
[PROOF STEP]
by (simp add: is_lb_def)


[STATEMENT]
theorem TESL_interp_homo_append:
  \<open>\<lbrakk>\<lbrakk> \<Phi>\<^sub>1 @ \<Phi>\<^sub>2 \<rbrakk>\<rbrakk>\<^sub>T\<^sub>E\<^sub>S\<^sub>L = \<lbrakk>\<lbrakk> \<Phi>\<^sub>1 \<rbrakk>\<rbrakk>\<^sub>T\<^sub>E\<^sub>S\<^sub>L \<inter> \<lbrakk>\<lbrakk> \<Phi>\<^sub>2 \<rbrakk>\<rbrakk>\<^sub>T\<^sub>E\<^sub>S\<^sub>L\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<lbrakk> \<Phi>\<^sub>1 @ \<Phi>\<^sub>2 \<rbrakk>\<rbrakk>\<^sub>T\<^sub>E\<^sub>S\<^sub>L = \<lbrakk>\<lbrakk> \<Phi>\<^sub>1 \<rbrakk>\<rbrakk>\<^sub>T\<^sub>E\<^sub>S\<^sub>L \<inter> \<lbrakk>\<lbrakk> \<Phi>\<^sub>2 \<rbrakk>\<rbrakk>\<^sub>T\<^sub>E\<^sub>S\<^sub>L
[PROOF STEP]
by (induction \<Phi>\<^sub>1, simp, auto)


[STATEMENT]
lemma triangle_free_graph_empty: "uedges G = {} \<Longrightarrow> triangle_free_graph G"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. uedges G = {} \<Longrightarrow> triangle_free_graph G
[PROOF STEP]
by (simp add: triangle_free_graph_def triangle_in_graph_def)


[STATEMENT]
lemma r_mod2 [simp]: "eval r_mod2 [n] \<down>= n mod 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. eval r_mod2 [n] \<down>= n mod 2
[PROOF STEP]
unfolding r_mod2_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. eval (Cn 1 r_sub [recf.Id 1 0, Cn 1 r_mul [r_const 2, r_div2]]) [n] \<down>= n mod 2
[PROOF STEP]
using Rings.semiring_modulo_class.minus_mult_div_eq_mod
[PROOF STATE]
proof (prove)
using this:
?a - ?b * (?a div ?b) = ?a mod ?b

goal (1 subgoal):
 1. eval (Cn 1 r_sub [recf.Id 1 0, Cn 1 r_mul [r_const 2, r_div2]]) [n] \<down>= n mod 2
[PROOF STEP]
by auto


[STATEMENT]
lemma wf_nodes_le_auxi: "wf {(y, x). (sorted (rev y) \<and> sorted (rev x) \<and> set y \<subset> set x) \<and> x \<noteq> y}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. wf {(y, x). (Sorted_Less.sorted (rev y) \<and> Sorted_Less.sorted (rev x) \<and> set y \<subset> set x) \<and> x \<noteq> y}
[PROOF STEP]
apply(rule wf_measure [THEN wf_subset])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {(y, x). (Sorted_Less.sorted (rev y) \<and> Sorted_Less.sorted (rev x) \<and> set y \<subset> set x) \<and> x \<noteq> y} \<subseteq> measure ?f1
[PROOF STEP]
apply(simp only: measure_def inv_image_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {(y, x). (Sorted_Less.sorted (rev y) \<and> Sorted_Less.sorted (rev x) \<and> set y \<subset> set x) \<and> x \<noteq> y} \<subseteq> {(x, y). (?f1 x, ?f1 y) \<in> less_than}
[PROOF STEP]
apply clarify
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>a b x. \<lbrakk>b \<noteq> a; Sorted_Less.sorted (rev a); Sorted_Less.sorted (rev b); set a \<subseteq> set b; \<not> ?f1 a < ?f1 b; x \<in> set b\<rbrakk> \<Longrightarrow> x \<in> set a
[PROOF STEP]
apply(frule sorted_rev_subset_len_lt)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. \<And>a b x. \<lbrakk>b \<noteq> a; Sorted_Less.sorted (rev a); Sorted_Less.sorted (rev b); set a \<subseteq> set b; \<not> ?f1 a < ?f1 b; x \<in> set b\<rbrakk> \<Longrightarrow> Sorted_Less.sorted (rev (?b13 a b x))
 2. \<And>a b x. \<lbrakk>b \<noteq> a; Sorted_Less.sorted (rev a); Sorted_Less.sorted (rev b); set a \<subseteq> set b; \<not> ?f1 a < ?f1 b; x \<in> set b\<rbrakk> \<Longrightarrow> set a \<subset> set (?b13 a b x)
 3. \<And>a b x. \<lbrakk>b \<noteq> a; Sorted_Less.sorted (rev a); Sorted_Less.sorted (rev b); set a \<subseteq> set b; \<not> ?f1 a < ?f1 b; x \<in> set b; length a < length (?b13 a b x)\<rbrakk> \<Longrightarrow> x \<in> set a
[PROOF STEP]
defer
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. \<And>a b x. \<lbrakk>b \<noteq> a; Sorted_Less.sorted (rev a); Sorted_Less.sorted (rev b); set a \<subseteq> set b; \<not> ?f1 a < ?f1 b; x \<in> set b\<rbrakk> \<Longrightarrow> set a \<subset> set (?b13 a b x)
 2. \<And>a b x. \<lbrakk>b \<noteq> a; Sorted_Less.sorted (rev a); Sorted_Less.sorted (rev b); set a \<subseteq> set b; \<not> ?f1 a < ?f1 b; x \<in> set b; length a < length (?b13 a b x)\<rbrakk> \<Longrightarrow> x \<in> set a
 3. \<And>a b x. \<lbrakk>b \<noteq> a; Sorted_Less.sorted (rev a); Sorted_Less.sorted (rev b); set a \<subseteq> set b; \<not> ?f1 a < ?f1 b; x \<in> set b\<rbrakk> \<Longrightarrow> Sorted_Less.sorted (rev (?b13 a b x))
[PROOF STEP]
defer
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. \<And>a b x. \<lbrakk>b \<noteq> a; Sorted_Less.sorted (rev a); Sorted_Less.sorted (rev b); set a \<subseteq> set b; \<not> ?f1 a < ?f1 b; x \<in> set b; length a < length (?b13 a b x)\<rbrakk> \<Longrightarrow> x \<in> set a
 2. \<And>a b x. \<lbrakk>b \<noteq> a; Sorted_Less.sorted (rev a); Sorted_Less.sorted (rev b); set a \<subseteq> set b; \<not> ?f1 a < ?f1 b; x \<in> set b\<rbrakk> \<Longrightarrow> Sorted_Less.sorted (rev (?b13 a b x))
 3. \<And>a b x. \<lbrakk>b \<noteq> a; Sorted_Less.sorted (rev a); Sorted_Less.sorted (rev b); set a \<subseteq> set b; \<not> ?f1 a < ?f1 b; x \<in> set b\<rbrakk> \<Longrightarrow> set a \<subset> set (?b13 a b x)
[PROOF STEP]
apply fastforce
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>a b x. \<lbrakk>b \<noteq> a; Sorted_Less.sorted (rev a); Sorted_Less.sorted (rev b); set a \<subseteq> set b; \<not> length a < length b; x \<in> set b\<rbrakk> \<Longrightarrow> Sorted_Less.sorted (rev b)
 2. \<And>a b x. \<lbrakk>b \<noteq> a; Sorted_Less.sorted (rev a); Sorted_Less.sorted (rev b); set a \<subseteq> set b; \<not> length a < length b; x \<in> set b\<rbrakk> \<Longrightarrow> set a \<subset> set b
[PROOF STEP]
by (auto intro:sorted_less_rev_set_unique)


[STATEMENT]
lemma and_mask_cases:
  fixes x :: "'a :: len word"
  assumes len: "n < LENGTH('a)"
  shows "x AND mask n \<in> of_nat ` set [0 ..< 2 ^ n]"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x AND mask n \<in> word_of_nat ` set [0..<2 ^ n]
[PROOF STEP]
apply (simp flip: take_bit_eq_mask)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. take_bit n x \<in> word_of_nat ` {0..<2 ^ n}
[PROOF STEP]
apply (rule image_eqI [of _ _ \<open>unat (take_bit n x)\<close>])
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. take_bit n x = word_of_nat (unat (take_bit n x))
 2. unat (take_bit n x) \<in> {0..<2 ^ n}
[PROOF STEP]
using len
[PROOF STATE]
proof (prove)
using this:
n < LENGTH('a)

goal (2 subgoals):
 1. take_bit n x = word_of_nat (unat (take_bit n x))
 2. unat (take_bit n x) \<in> {0..<2 ^ n}
[PROOF STEP]
apply simp_all
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n < LENGTH('a) \<Longrightarrow> unat (take_bit n x) < 2 ^ n
[PROOF STEP]
apply transfer
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>n x. n < LENGTH('a) \<Longrightarrow> (nat \<circ> take_bit LENGTH('a)) (take_bit (min LENGTH('a) n) x) < 2 ^ n
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma odd_mul_odd: "\<lbrakk>~(2::nat) dvd p; ~2 dvd q\<rbrakk> \<Longrightarrow> ~2 dvd p*q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>odd p; odd q\<rbrakk> \<Longrightarrow> odd (p * q)
[PROOF STEP]
by simp


[STATEMENT]
lemma rtranclp_mult_poly_p_mult_ideal:
  \<open>(mult_poly_p q)\<^sup>*\<^sup>* (p, r) (p', r') \<Longrightarrow>
     (polynomial_of_mset p' * polynomial_of_mset q + polynomial_of_mset r') - (polynomial_of_mset p * polynomial_of_mset q + polynomial_of_mset r)
       \<in> ideal polynomial_bool\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (mult_poly_p q)\<^sup>*\<^sup>* (p, r) (p', r') \<Longrightarrow> polynomial_of_mset p' * polynomial_of_mset q + polynomial_of_mset r' - (polynomial_of_mset p * polynomial_of_mset q + polynomial_of_mset r) \<in> More_Modules.ideal polynomial_bool
[PROOF STEP]
apply (induction p' r' rule: rtranclp_induct[of \<open>mult_poly_p q\<close> \<open>(p, r)\<close> \<open>(p', q')\<close> for p' q', split_format(complete)])
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. polynomial_of_mset p * polynomial_of_mset q + polynomial_of_mset r - (polynomial_of_mset p * polynomial_of_mset q + polynomial_of_mset r) \<in> More_Modules.ideal polynomial_bool
 2. \<And>a b aa ba. \<lbrakk>(mult_poly_p q)\<^sup>*\<^sup>* (p, r) (a, b); mult_poly_p q (a, b) (aa, ba); polynomial_of_mset a * polynomial_of_mset q + polynomial_of_mset b - (polynomial_of_mset p * polynomial_of_mset q + polynomial_of_mset r) \<in> More_Modules.ideal polynomial_bool\<rbrakk> \<Longrightarrow> polynomial_of_mset aa * polynomial_of_mset q + polynomial_of_mset ba - (polynomial_of_mset p * polynomial_of_mset q + polynomial_of_mset r) \<in> More_Modules.ideal polynomial_bool
[PROOF STEP]
subgoal
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. polynomial_of_mset p * polynomial_of_mset q + polynomial_of_mset r - (polynomial_of_mset p * polynomial_of_mset q + polynomial_of_mset r) \<in> More_Modules.ideal polynomial_bool
[PROOF STEP]
by (auto simp: ideal.span_zero)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>a b aa ba. \<lbrakk>(mult_poly_p q)\<^sup>*\<^sup>* (p, r) (a, b); mult_poly_p q (a, b) (aa, ba); polynomial_of_mset a * polynomial_of_mset q + polynomial_of_mset b - (polynomial_of_mset p * polynomial_of_mset q + polynomial_of_mset r) \<in> More_Modules.ideal polynomial_bool\<rbrakk> \<Longrightarrow> polynomial_of_mset aa * polynomial_of_mset q + polynomial_of_mset ba - (polynomial_of_mset p * polynomial_of_mset q + polynomial_of_mset r) \<in> More_Modules.ideal polynomial_bool
[PROOF STEP]
subgoal for a b aa ba
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>(mult_poly_p q)\<^sup>*\<^sup>* (p, r) (a, b); mult_poly_p q (a, b) (aa, ba); polynomial_of_mset a * polynomial_of_mset q + polynomial_of_mset b - (polynomial_of_mset p * polynomial_of_mset q + polynomial_of_mset r) \<in> More_Modules.ideal polynomial_bool\<rbrakk> \<Longrightarrow> polynomial_of_mset aa * polynomial_of_mset q + polynomial_of_mset ba - (polynomial_of_mset p * polynomial_of_mset q + polynomial_of_mset r) \<in> More_Modules.ideal polynomial_bool
[PROOF STEP]
apply (drule mult_poly_p_mult_ideal)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>(mult_poly_p q)\<^sup>*\<^sup>* (p, r) (a, b); polynomial_of_mset a * polynomial_of_mset q + polynomial_of_mset b - (polynomial_of_mset p * polynomial_of_mset q + polynomial_of_mset r) \<in> More_Modules.ideal polynomial_bool; polynomial_of_mset aa * polynomial_of_mset q + polynomial_of_mset ba - (polynomial_of_mset a * polynomial_of_mset q + polynomial_of_mset b) \<in> More_Modules.ideal polynomial_bool\<rbrakk> \<Longrightarrow> polynomial_of_mset aa * polynomial_of_mset q + polynomial_of_mset ba - (polynomial_of_mset p * polynomial_of_mset q + polynomial_of_mset r) \<in> More_Modules.ideal polynomial_bool
[PROOF STEP]
apply (drule ideal.span_add)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>(mult_poly_p q)\<^sup>*\<^sup>* (p, r) (a, b); polynomial_of_mset aa * polynomial_of_mset q + polynomial_of_mset ba - (polynomial_of_mset a * polynomial_of_mset q + polynomial_of_mset b) \<in> More_Modules.ideal polynomial_bool\<rbrakk> \<Longrightarrow> ?y2 \<in> More_Modules.ideal polynomial_bool
 2. \<lbrakk>(mult_poly_p q)\<^sup>*\<^sup>* (p, r) (a, b); polynomial_of_mset aa * polynomial_of_mset q + polynomial_of_mset ba - (polynomial_of_mset a * polynomial_of_mset q + polynomial_of_mset b) \<in> More_Modules.ideal polynomial_bool; polynomial_of_mset a * polynomial_of_mset q + polynomial_of_mset b - (polynomial_of_mset p * polynomial_of_mset q + polynomial_of_mset r) + ?y2 \<in> More_Modules.ideal polynomial_bool\<rbrakk> \<Longrightarrow> polynomial_of_mset aa * polynomial_of_mset q + polynomial_of_mset ba - (polynomial_of_mset p * polynomial_of_mset q + polynomial_of_mset r) \<in> More_Modules.ideal polynomial_bool
[PROOF STEP]
apply assumption
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>(mult_poly_p q)\<^sup>*\<^sup>* (p, r) (a, b); polynomial_of_mset aa * polynomial_of_mset q + polynomial_of_mset ba - (polynomial_of_mset a * polynomial_of_mset q + polynomial_of_mset b) \<in> More_Modules.ideal polynomial_bool; polynomial_of_mset a * polynomial_of_mset q + polynomial_of_mset b - (polynomial_of_mset p * polynomial_of_mset q + polynomial_of_mset r) + (polynomial_of_mset aa * polynomial_of_mset q + polynomial_of_mset ba - (polynomial_of_mset a * polynomial_of_mset q + polynomial_of_mset b)) \<in> More_Modules.ideal polynomial_bool\<rbrakk> \<Longrightarrow> polynomial_of_mset aa * polynomial_of_mset q + polynomial_of_mset ba - (polynomial_of_mset p * polynomial_of_mset q + polynomial_of_mset r) \<in> More_Modules.ideal polynomial_bool
[PROOF STEP]
by (auto simp: group_add_class.diff_add_eq_diff_diff_swap
        add.inverse_distrib_swap ac_simps add_diff_eq
      simp flip:  diff_add_eq_diff_diff_swap)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done