[STATEMENT]
lemma pos_prod_sum_lt:
  fixes c :: "'a::linordered_field"
  assumes "c > 0"
  shows "c * x + t < 0 \<equiv> x < (- 1 / c) * t"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. c * x + t < (0::'a) \<equiv> x < - (1::'a) / c * t
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. c * x + t < (0::'a) \<equiv> x < - (1::'a) / c * t
[PROOF STEP]
have "c * x + t < 0 \<longleftrightarrow> c * x < - t"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (c * x + t < (0::'a)) = (c * x < - t)
[PROOF STEP]
by (subst less_iff_diff_less_0 [of "c * x" "- t"]) simp
[PROOF STATE]
proof (state)
this:
(c * x + t < (0::'a)) = (c * x < - t)

goal (1 subgoal):
 1. c * x + t < (0::'a) \<equiv> x < - (1::'a) / c * t
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(c * x + t < (0::'a)) = (c * x < - t)

goal (1 subgoal):
 1. c * x + t < (0::'a) \<equiv> x < - (1::'a) / c * t
[PROOF STEP]
have "\<dots> \<longleftrightarrow> - t / c > x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (c * x < - t) = (x < - t / c)
[PROOF STEP]
by (simp only: pos_less_divide_eq[OF \<open>c > 0\<close>] algebra_simps)
[PROOF STATE]
proof (state)
this:
(c * x < - t) = (x < - t / c)

goal (1 subgoal):
 1. c * x + t < (0::'a) \<equiv> x < - (1::'a) / c * t
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(c * x < - t) = (x < - t / c)

goal (1 subgoal):
 1. c * x + t < (0::'a) \<equiv> x < - (1::'a) / c * t
[PROOF STEP]
have "\<dots> \<longleftrightarrow> (- 1 / c) * t > x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (x < - t / c) = (x < - (1::'a) / c * t)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(x < - t / c) = (x < - (1::'a) / c * t)

goal (1 subgoal):
 1. c * x + t < (0::'a) \<equiv> x < - (1::'a) / c * t
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(c * x + t < (0::'a)) = (x < - (1::'a) / c * t)
[PROOF STEP]
show "PROP ?thesis"
[PROOF STATE]
proof (prove)
using this:
(c * x + t < (0::'a)) = (x < - (1::'a) / c * t)

goal (1 subgoal):
 1. c * x + t < (0::'a) \<equiv> x < - (1::'a) / c * t
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
c * x + t < (0::'a) \<equiv> x < - (1::'a) / c * t

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma ket_psim_norm:
  shows "\<parallel>ket_psim\<parallel> = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<parallel>ket_psim\<parallel> = 1
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<parallel>ket_psim\<parallel> = 1
[PROOF STEP]
have "dim_vec ket_psim = 2\<^sup>2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_vec ket_psim = 2\<^sup>2
[PROOF STEP]
unfolding ket_psim_def ket_01_def ket_10_def ket_0_def ket_1_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_vec (complex_of_real (1 / sqrt 2) \<cdot>\<^sub>v ((unit_vec 2 0 \<otimes> unit_vec 2 1) - (unit_vec 2 1 \<otimes> unit_vec 2 0))) = 2\<^sup>2
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
dim_vec ket_psim = 2\<^sup>2

goal (1 subgoal):
 1. \<parallel>ket_psim\<parallel> = 1
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
dim_vec ket_psim = 2\<^sup>2

goal (1 subgoal):
 1. \<parallel>ket_psim\<parallel> = 1
[PROOF STEP]
have "(\<Sum>i<4. (cmod (vec_index ket_psim i))\<^sup>2) = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i<4. (cmod (ket_psim $ i))\<^sup>2) = 1
[PROOF STEP]
apply (auto simp add: ket_psim_def ket_01_def ket_10_def ket_0_def ket_1_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i<4. (cmod (((if i div 2 = 0 then 1 else 0) * (if i mod 2 = Suc 0 then 1 else 0) - (if i div 2 = Suc 0 then 1 else 0) * (if i mod 2 = 0 then 1 else 0)) / complex_of_real (sqrt 2)))\<^sup>2) = 1
[PROOF STEP]
apply (simp add: sum_4_elems)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
(\<Sum>i<4. (cmod (ket_psim $ i))\<^sup>2) = 1

goal (1 subgoal):
 1. \<parallel>ket_psim\<parallel> = 1
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
dim_vec ket_psim = 2\<^sup>2
(\<Sum>i<4. (cmod (ket_psim $ i))\<^sup>2) = 1
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
dim_vec ket_psim = 2\<^sup>2
(\<Sum>i<4. (cmod (ket_psim $ i))\<^sup>2) = 1

goal (1 subgoal):
 1. \<parallel>ket_psim\<parallel> = 1
[PROOF STEP]
by (simp add: cpx_vec_length_def)
[PROOF STATE]
proof (state)
this:
\<parallel>ket_psim\<parallel> = 1

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma sum_squared: "(\<Sum>i=0..n. i)^2 = (\<Sum>i=0..n. i^3)" for n :: nat
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum> {0..n})\<^sup>2 = (\<Sum>i = 0..n. i ^ 3)
[PROOF STEP]
proof (induct n)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. (\<Sum> {0..0})\<^sup>2 = (\<Sum>i = 0..0. i ^ 3)
 2. \<And>n. (\<Sum> {0..n})\<^sup>2 = (\<Sum>i = 0..n. i ^ 3) \<Longrightarrow> (\<Sum> {0..Suc n})\<^sup>2 = (\<Sum>i = 0..Suc n. i ^ 3)
[PROOF STEP]
case 0
[PROOF STATE]
proof (state)
this:

goal (2 subgoals):
 1. (\<Sum> {0..0})\<^sup>2 = (\<Sum>i = 0..0. i ^ 3)
 2. \<And>n. (\<Sum> {0..n})\<^sup>2 = (\<Sum>i = 0..n. i ^ 3) \<Longrightarrow> (\<Sum> {0..Suc n})\<^sup>2 = (\<Sum>i = 0..Suc n. i ^ 3)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum> {0..0})\<^sup>2 = (\<Sum>i = 0..0. i ^ 3)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<Sum> {0..0})\<^sup>2 = (\<Sum>i = 0..0. i ^ 3)

goal (1 subgoal):
 1. \<And>n. (\<Sum> {0..n})\<^sup>2 = (\<Sum>i = 0..n. i ^ 3) \<Longrightarrow> (\<Sum> {0..Suc n})\<^sup>2 = (\<Sum>i = 0..Suc n. i ^ 3)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n. (\<Sum> {0..n})\<^sup>2 = (\<Sum>i = 0..n. i ^ 3) \<Longrightarrow> (\<Sum> {0..Suc n})\<^sup>2 = (\<Sum>i = 0..Suc n. i ^ 3)
[PROOF STEP]
case (Suc n)
[PROOF STATE]
proof (state)
this:
(\<Sum> {0..n})\<^sup>2 = (\<Sum>i = 0..n. i ^ 3)

goal (1 subgoal):
 1. \<And>n. (\<Sum> {0..n})\<^sup>2 = (\<Sum>i = 0..n. i ^ 3) \<Longrightarrow> (\<Sum> {0..Suc n})\<^sup>2 = (\<Sum>i = 0..Suc n. i ^ 3)
[PROOF STEP]
have "(\<Sum>i = 0..Suc n. i)^2 =
        (\<Sum>i = 0..n. i^3) + (2*(\<Sum>i = 0..n. i)*(n+1) + (n+1)^2)"
    (is "_ = ?A + ?B")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum> {0..Suc n})\<^sup>2 = (\<Sum>i = 0..n. i ^ 3) + (2 * \<Sum> {0..n} * (n + 1) + (n + 1)\<^sup>2)
[PROOF STEP]
using Suc
[PROOF STATE]
proof (prove)
using this:
(\<Sum> {0..n})\<^sup>2 = (\<Sum>i = 0..n. i ^ 3)

goal (1 subgoal):
 1. (\<Sum> {0..Suc n})\<^sup>2 = (\<Sum>i = 0..n. i ^ 3) + (2 * \<Sum> {0..n} * (n + 1) + (n + 1)\<^sup>2)
[PROOF STEP]
by (simp add: eval_nat_numeral)
[PROOF STATE]
proof (state)
this:
(\<Sum> {0..Suc n})\<^sup>2 = (\<Sum>i = 0..n. i ^ 3) + (2 * \<Sum> {0..n} * (n + 1) + (n + 1)\<^sup>2)

goal (1 subgoal):
 1. \<And>n. (\<Sum> {0..n})\<^sup>2 = (\<Sum>i = 0..n. i ^ 3) \<Longrightarrow> (\<Sum> {0..Suc n})\<^sup>2 = (\<Sum>i = 0..Suc n. i ^ 3)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum> {0..Suc n})\<^sup>2 = (\<Sum>i = 0..n. i ^ 3) + (2 * \<Sum> {0..n} * (n + 1) + (n + 1)\<^sup>2)

goal (1 subgoal):
 1. \<And>n. (\<Sum> {0..n})\<^sup>2 = (\<Sum>i = 0..n. i ^ 3) \<Longrightarrow> (\<Sum> {0..Suc n})\<^sup>2 = (\<Sum>i = 0..Suc n. i ^ 3)
[PROOF STEP]
have "?B = (n+1)^3"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 * \<Sum> {0..n} * (n + 1) + (n + 1)\<^sup>2 = (n + 1) ^ 3
[PROOF STEP]
using sum_of_naturals
[PROOF STATE]
proof (prove)
using this:
2 * \<Sum> {0..?n} = ?n * Suc ?n

goal (1 subgoal):
 1. 2 * \<Sum> {0..n} * (n + 1) + (n + 1)\<^sup>2 = (n + 1) ^ 3
[PROOF STEP]
by (simp add: eval_nat_numeral)
[PROOF STATE]
proof (state)
this:
2 * \<Sum> {0..n} * (n + 1) + (n + 1)\<^sup>2 = (n + 1) ^ 3

goal (1 subgoal):
 1. \<And>n. (\<Sum> {0..n})\<^sup>2 = (\<Sum>i = 0..n. i ^ 3) \<Longrightarrow> (\<Sum> {0..Suc n})\<^sup>2 = (\<Sum>i = 0..Suc n. i ^ 3)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
2 * \<Sum> {0..n} * (n + 1) + (n + 1)\<^sup>2 = (n + 1) ^ 3

goal (1 subgoal):
 1. \<And>n. (\<Sum> {0..n})\<^sup>2 = (\<Sum>i = 0..n. i ^ 3) \<Longrightarrow> (\<Sum> {0..Suc n})\<^sup>2 = (\<Sum>i = 0..Suc n. i ^ 3)
[PROOF STEP]
have "?A + (n+1)^3 = (\<Sum>i=0..Suc n. i^3)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i = 0..n. i ^ 3) + (n + 1) ^ 3 = (\<Sum>i = 0..Suc n. i ^ 3)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<Sum>i = 0..n. i ^ 3) + (n + 1) ^ 3 = (\<Sum>i = 0..Suc n. i ^ 3)

goal (1 subgoal):
 1. \<And>n. (\<Sum> {0..n})\<^sup>2 = (\<Sum>i = 0..n. i ^ 3) \<Longrightarrow> (\<Sum> {0..Suc n})\<^sup>2 = (\<Sum>i = 0..Suc n. i ^ 3)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(\<Sum> {0..Suc n})\<^sup>2 = (\<Sum>i = 0..Suc n. i ^ 3)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
(\<Sum> {0..Suc n})\<^sup>2 = (\<Sum>i = 0..Suc n. i ^ 3)

goal (1 subgoal):
 1. (\<Sum> {0..Suc n})\<^sup>2 = (\<Sum>i = 0..Suc n. i ^ 3)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
(\<Sum> {0..Suc n})\<^sup>2 = (\<Sum>i = 0..Suc n. i ^ 3)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma rank_mat_mult_lt_min_rank_factor:
  fixes A :: "'a::{conjugatable_ordered_field} mat"
  assumes "A \<in> carrier_mat n m"
  assumes "B \<in> carrier_mat m nc"
  shows "rank n (A * B) \<le> min (rank n A) (rank m B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rank n (A * B) \<le> min (rank n A) (rank m B)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. rank n (A * B) \<le> min (rank n A) (rank m B)
[PROOF STEP]
have 1: "rank n (A * B) \<le> (rank n A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rank n (A * B) \<le> rank n A
[PROOF STEP]
using assms(1) assms(2) vec_space.rank_mat_mul_right
[PROOF STATE]
proof (prove)
using this:
A \<in> carrier_mat n m
B \<in> carrier_mat m nc
\<lbrakk>?A \<in> carrier_mat ?n ?d; ?B \<in> carrier_mat ?d ?nc\<rbrakk> \<Longrightarrow> rank ?n (?A * ?B) \<le> rank ?n ?A

goal (1 subgoal):
 1. rank n (A * B) \<le> rank n A
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
rank n (A * B) \<le> rank n A

goal (1 subgoal):
 1. rank n (A * B) \<le> min (rank n A) (rank m B)
[PROOF STEP]
have "rank n (A* B) \<le> rank m B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rank n (A * B) \<le> rank m B
[PROOF STEP]
by (meson assms(1) assms(2) rank_mat_mul_left)
[PROOF STATE]
proof (state)
this:
rank n (A * B) \<le> rank m B

goal (1 subgoal):
 1. rank n (A * B) \<le> min (rank n A) (rank m B)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
rank n (A * B) \<le> rank m B

goal (1 subgoal):
 1. rank n (A * B) \<le> min (rank n A) (rank m B)
[PROOF STEP]
using 1
[PROOF STATE]
proof (prove)
using this:
rank n (A * B) \<le> rank m B
rank n (A * B) \<le> rank n A

goal (1 subgoal):
 1. rank n (A * B) \<le> min (rank n A) (rank m B)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
rank n (A * B) \<le> min (rank n A) (rank m B)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma horner_schema':
  fixes x :: real and a :: "nat \<Rightarrow> real"
  shows "a 0 - x * (\<Sum> i=0..<n. (-1)^i * a (Suc i) * x^i) = (\<Sum> i=0..<Suc n. (-1)^i * a i * x^i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a 0 - x * (\<Sum>i = 0..<n. (- 1) ^ i * a (Suc i) * x ^ i) = (\<Sum>i = 0..<Suc n. (- 1) ^ i * a i * x ^ i)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. a 0 - x * (\<Sum>i = 0..<n. (- 1) ^ i * a (Suc i) * x ^ i) = (\<Sum>i = 0..<Suc n. (- 1) ^ i * a i * x ^ i)
[PROOF STEP]
have shift_pow: "\<And>i. - (x * ((-1)^i * a (Suc i) * x ^ i)) = (-1)^(Suc i) * a (Suc i) * x ^ (Suc i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>i. - (x * ((- 1) ^ i * a (Suc i) * x ^ i)) = (- 1) ^ Suc i * a (Suc i) * x ^ Suc i
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
- (x * ((- 1) ^ ?i * a (Suc ?i) * x ^ ?i)) = (- 1) ^ Suc ?i * a (Suc ?i) * x ^ Suc ?i

goal (1 subgoal):
 1. a 0 - x * (\<Sum>i = 0..<n. (- 1) ^ i * a (Suc i) * x ^ i) = (\<Sum>i = 0..<Suc n. (- 1) ^ i * a i * x ^ i)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a 0 - x * (\<Sum>i = 0..<n. (- 1) ^ i * a (Suc i) * x ^ i) = (\<Sum>i = 0..<Suc n. (- 1) ^ i * a i * x ^ i)
[PROOF STEP]
unfolding sum_distrib_left shift_pow uminus_add_conv_diff [symmetric] sum_negf[symmetric]
    sum.atLeast_Suc_lessThan[OF zero_less_Suc]
    sum.reindex[OF inj_Suc, unfolded comp_def, symmetric, of "\<lambda> n. (-1)^n  *a n * x^n"]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>n\<in>Suc ` {0..<n}. (- 1) ^ n * a n * x ^ n) + a 0 = (- 1) ^ 0 * a 0 * x ^ 0 + (\<Sum>i = Suc 0..<Suc n. (- 1) ^ i * a i * x ^ i)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
a 0 - x * (\<Sum>i = 0..<n. (- 1) ^ i * a (Suc i) * x ^ i) = (\<Sum>i = 0..<Suc n. (- 1) ^ i * a i * x ^ i)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma transpose_minus_1:
  assumes "dim_row Q = dim_col Q"
  shows "transpose_mat (Q - (1\<^sub>m (dim_row Q))) =  (transpose_mat Q - (1\<^sub>m (dim_row Q)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (Q - 1\<^sub>m (dim_row Q))\<^sup>T = Q\<^sup>T - 1\<^sub>m (dim_row Q)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
dim_row Q = dim_col Q

goal (1 subgoal):
 1. (Q - 1\<^sub>m (dim_row Q))\<^sup>T = Q\<^sup>T - 1\<^sub>m (dim_row Q)
[PROOF STEP]
unfolding mat_eq_iff
[PROOF STATE]
proof (prove)
using this:
dim_row Q = dim_col Q

goal (1 subgoal):
 1. dim_row (Q - 1\<^sub>m (dim_row Q))\<^sup>T = dim_row (Q\<^sup>T - 1\<^sub>m (dim_row Q)) \<and> dim_col (Q - 1\<^sub>m (dim_row Q))\<^sup>T = dim_col (Q\<^sup>T - 1\<^sub>m (dim_row Q)) \<and> (\<forall>i j. i < dim_row (Q\<^sup>T - 1\<^sub>m (dim_row Q)) \<longrightarrow> j < dim_col (Q\<^sup>T - 1\<^sub>m (dim_row Q)) \<longrightarrow> (Q - 1\<^sub>m (dim_row Q))\<^sup>T $$ (i, j) = (Q\<^sup>T - 1\<^sub>m (dim_row Q)) $$ (i, j))
[PROOF STEP]
by auto


[STATEMENT]
lemma arcsin_lt_bounded:
  assumes "- 1 < y" "y < 1"
  shows  "- (pi/2) < arcsin y \<and> arcsin y < pi/2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. - (pi / 2) < arcsin y \<and> arcsin y < pi / 2
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. - (pi / 2) < arcsin y \<and> arcsin y < pi / 2
[PROOF STEP]
have "arcsin y \<noteq> pi/2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. arcsin y \<noteq> pi / 2
[PROOF STEP]
by (metis arcsin assms not_less not_less_iff_gr_or_eq sin_pi_half)
[PROOF STATE]
proof (state)
this:
arcsin y \<noteq> pi / 2

goal (1 subgoal):
 1. - (pi / 2) < arcsin y \<and> arcsin y < pi / 2
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
arcsin y \<noteq> pi / 2

goal (1 subgoal):
 1. - (pi / 2) < arcsin y \<and> arcsin y < pi / 2
[PROOF STEP]
have "arcsin y \<noteq> - pi/2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. arcsin y \<noteq> - pi / 2
[PROOF STEP]
by (metis arcsin assms minus_divide_left not_less not_less_iff_gr_or_eq sin_minus sin_pi_half)
[PROOF STATE]
proof (state)
this:
arcsin y \<noteq> - pi / 2

goal (1 subgoal):
 1. - (pi / 2) < arcsin y \<and> arcsin y < pi / 2
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
arcsin y \<noteq> pi / 2
arcsin y \<noteq> - pi / 2
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
arcsin y \<noteq> pi / 2
arcsin y \<noteq> - pi / 2

goal (1 subgoal):
 1. - (pi / 2) < arcsin y \<and> arcsin y < pi / 2
[PROOF STEP]
using arcsin_bounded [of y] assms
[PROOF STATE]
proof (prove)
using this:
arcsin y \<noteq> pi / 2
arcsin y \<noteq> - pi / 2
\<lbrakk>- 1 \<le> y; y \<le> 1\<rbrakk> \<Longrightarrow> - (pi / 2) \<le> arcsin y \<and> arcsin y \<le> pi / 2
- 1 < y
y < 1

goal (1 subgoal):
 1. - (pi / 2) < arcsin y \<and> arcsin y < pi / 2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
- (pi / 2) < arcsin y \<and> arcsin y < pi / 2

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma of_nat_binomial_Suc:
  assumes "k \<le> n"
  shows   "(of_nat (Suc n choose k) :: 'a :: field_char_0) =
             of_nat (Suc n) / of_nat (Suc n - k) * of_nat (n choose k)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. of_nat (Suc n choose k) = of_nat (Suc n) / of_nat (Suc n - k) * of_nat (n choose k)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
k \<le> n

goal (1 subgoal):
 1. of_nat (Suc n choose k) = of_nat (Suc n) / of_nat (Suc n - k) * of_nat (n choose k)
[PROOF STEP]
by (simp add: binomial_fact divide_simps fact_diff_Suc of_nat_diff del: of_nat_Suc)


[STATEMENT]
lemma poincare_distance_ge0:
  assumes "u \<in> unit_disc" and "v \<in> unit_disc"
  shows "poincare_distance u v \<ge> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 \<le> poincare_distance u v
[PROOF STEP]
using poincare_distance_formula'_ge_1
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?u \<in> unit_disc; ?v \<in> unit_disc\<rbrakk> \<Longrightarrow> 1 \<le> poincare_distance_formula' (to_complex ?u) (to_complex ?v)

goal (1 subgoal):
 1. 0 \<le> poincare_distance u v
[PROOF STEP]
unfolding poincare_distance_formula[OF assms(1) assms(2)]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?u \<in> unit_disc; ?v \<in> unit_disc\<rbrakk> \<Longrightarrow> 1 \<le> poincare_distance_formula' (to_complex ?u) (to_complex ?v)

goal (1 subgoal):
 1. 0 \<le> poincare_distance_formula (to_complex u) (to_complex v)
[PROOF STEP]
unfolding poincare_distance_formula_def
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?u \<in> unit_disc; ?v \<in> unit_disc\<rbrakk> \<Longrightarrow> 1 \<le> poincare_distance_formula' (to_complex ?u) (to_complex ?v)

goal (1 subgoal):
 1. 0 \<le> arcosh (poincare_distance_formula' (to_complex u) (to_complex v))
[PROOF STEP]
unfolding poincare_distance_formula'_def
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?u \<in> unit_disc; ?v \<in> unit_disc\<rbrakk> \<Longrightarrow> 1 \<le> 1 + 2 * ((cmod (to_complex ?u - to_complex ?v))\<^sup>2 / ((1 - (cmod (to_complex ?u))\<^sup>2) * (1 - (cmod (to_complex ?v))\<^sup>2)))

goal (1 subgoal):
 1. 0 \<le> arcosh (1 + 2 * ((cmod (to_complex u - to_complex v))\<^sup>2 / ((1 - (cmod (to_complex u))\<^sup>2) * (1 - (cmod (to_complex v))\<^sup>2))))
[PROOF STEP]
by (rule arcosh_ge_0, simp_all add: assms)


[STATEMENT]
lemma effective_matrix_match_condn_2:
 assumes "(matrix_match A1 A2 B1 B2) "
 shows "\<forall>i j.((i<(row_length A1)*(row_length B1))
         \<and>(j<(length A2)*(length B2))
            \<longrightarrow> ((A1 \<otimes> B1)\<circ>(A2 \<otimes> B2))!j!i
           =  scalar_product
                  (vec_vec_Tensor
                           (row A1 (i div row_length B1))
                           (row B1 (i mod row_length B1)))
                  (vec_vec_Tensor
                           (col A2 (j div length B2))
                           (col B2 (j mod length B2))))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>i j. i < row_length A1 * row_length B1 \<and> j < length A2 * length B2 \<longrightarrow> ((A1 \<otimes> B1) \<circ> (A2 \<otimes> B2)) ! j ! i = scalar_product (vec_vec_Tensor (row A1 (i div row_length B1)) (row B1 (i mod row_length B1))) (vec_vec_Tensor (col A2 (j div length B2)) (col B2 (j mod length B2)))
[PROOF STEP]
using assms matrix_match_condn_2
[PROOF STATE]
proof (prove)
using this:
matrix_match A1 A2 B1 B2
matrix_match ?A1.0 ?A2.0 ?B1.0 ?B2.0 \<and> ?i < row_length ?A1.0 * row_length ?B1.0 \<and> ?j < length ?A2.0 * length ?B2.0 \<Longrightarrow> ((?A1.0 \<otimes> ?B1.0) \<circ> (?A2.0 \<otimes> ?B2.0)) ! ?j ! ?i = scalar_product (vec_vec_Tensor (row ?A1.0 (?i div row_length ?B1.0)) (row ?B1.0 (?i mod row_length ?B1.0))) (vec_vec_Tensor (col ?A2.0 (?j div length ?B2.0)) (col ?B2.0 (?j mod length ?B2.0)))

goal (1 subgoal):
 1. \<forall>i j. i < row_length A1 * row_length B1 \<and> j < length A2 * length B2 \<longrightarrow> ((A1 \<otimes> B1) \<circ> (A2 \<otimes> B2)) ! j ! i = scalar_product (vec_vec_Tensor (row A1 (i div row_length B1)) (row B1 (i mod row_length B1))) (vec_vec_Tensor (col A2 (j div length B2)) (col B2 (j mod length B2)))
[PROOF STEP]
unfolding matrix_match_def
[PROOF STATE]
proof (prove)
using this:
mat (row_length A1) (length A1) A1 \<and> mat (row_length A2) (length A2) A2 \<and> mat (row_length B1) (length B1) B1 \<and> mat (row_length B2) (length B2) B2 \<and> length A1 = row_length A2 \<and> length B1 = row_length B2 \<and> A1 \<noteq> [] \<and> A2 \<noteq> [] \<and> B1 \<noteq> [] \<and> B2 \<noteq> []
(mat (row_length ?A1.0) (length ?A1.0) ?A1.0 \<and> mat (row_length ?A2.0) (length ?A2.0) ?A2.0 \<and> mat (row_length ?B1.0) (length ?B1.0) ?B1.0 \<and> mat (row_length ?B2.0) (length ?B2.0) ?B2.0 \<and> length ?A1.0 = row_length ?A2.0 \<and> length ?B1.0 = row_length ?B2.0 \<and> ?A1.0 \<noteq> [] \<and> ?A2.0 \<noteq> [] \<and> ?B1.0 \<noteq> [] \<and> ?B2.0 \<noteq> []) \<and> ?i < row_length ?A1.0 * row_length ?B1.0 \<and> ?j < length ?A2.0 * length ?B2.0 \<Longrightarrow> ((?A1.0 \<otimes> ?B1.0) \<circ> (?A2.0 \<otimes> ?B2.0)) ! ?j ! ?i = scalar_product (vec_vec_Tensor (row ?A1.0 (?i div row_length ?B1.0)) (row ?B1.0 (?i mod row_length ?B1.0))) (vec_vec_Tensor (col ?A2.0 (?j div length ?B2.0)) (col ?B2.0 (?j mod length ?B2.0)))

goal (1 subgoal):
 1. \<forall>i j. i < row_length A1 * row_length B1 \<and> j < length A2 * length B2 \<longrightarrow> ((A1 \<otimes> B1) \<circ> (A2 \<otimes> B2)) ! j ! i = scalar_product (vec_vec_Tensor (row A1 (i div row_length B1)) (row B1 (i mod row_length B1))) (vec_vec_Tensor (col A2 (j div length B2)) (col B2 (j mod length B2)))
[PROOF STEP]
by auto


[STATEMENT]
lemma odd_round_up:
assumes "odd x"
shows "round (real_of_int x / 2) = (x+1) div 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. round (real_of_int x / 2) = (x + 1) div 2
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. round (real_of_int x / 2) = (x + 1) div 2
[PROOF STEP]
have "round (real_of_int x / 2) = round (real_of_int (x+1) /2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. round (real_of_int x / 2) = round (real_of_int (x + 1) / 2)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
odd x

goal (1 subgoal):
 1. round (real_of_int x / 2) = round (real_of_int (x + 1) / 2)
[PROOF STEP]
unfolding round_def
[PROOF STATE]
proof (prove)
using this:
odd x

goal (1 subgoal):
 1. \<lfloor>real_of_int x / 2 + 1 / 2\<rfloor> = \<lfloor>real_of_int (x + 1) / 2 + 1 / 2\<rfloor>
[PROOF STEP]
by (metis (no_types, opaque_lifting) add.commute
      add_divide_distrib even_add even_succ_div_2
      floor_divide_of_int_eq odd_one of_int_add
      of_int_hom.hom_one of_int_numeral)
[PROOF STATE]
proof (state)
this:
round (real_of_int x / 2) = round (real_of_int (x + 1) / 2)

goal (1 subgoal):
 1. round (real_of_int x / 2) = (x + 1) div 2
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
round (real_of_int x / 2) = round (real_of_int (x + 1) / 2)

goal (1 subgoal):
 1. round (real_of_int x / 2) = (x + 1) div 2
[PROOF STEP]
have "\<dots> = (x+1) div 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. round (real_of_int (x + 1) / 2) = (x + 1) div 2
[PROOF STEP]
by (metis add_divide_distrib calculation
    floor_divide_of_int_eq of_int_add of_int_hom.hom_one
    of_int_numeral round_def)
[PROOF STATE]
proof (state)
this:
round (real_of_int (x + 1) / 2) = (x + 1) div 2

goal (1 subgoal):
 1. round (real_of_int x / 2) = (x + 1) div 2
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
round (real_of_int x / 2) = (x + 1) div 2
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
round (real_of_int x / 2) = (x + 1) div 2

goal (1 subgoal):
 1. round (real_of_int x / 2) = (x + 1) div 2
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
round (real_of_int x / 2) = (x + 1) div 2

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma poly_mult_degree_eq:
  assumes "subring K R" "polynomial K p1" "polynomial K p2"
  shows "degree (poly_mult p1 p2) = (if p1 = [] \<or> p2 = [] then 0 else (degree p1) + (degree p2))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. degree (poly_mult p1 p2) = (if p1 = [] \<or> p2 = [] then 0 else degree p1 + degree p2)
[PROOF STEP]
proof (cases p1)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. p1 = [] \<Longrightarrow> degree (poly_mult p1 p2) = (if p1 = [] \<or> p2 = [] then 0 else degree p1 + degree p2)
 2. \<And>a list. p1 = a # list \<Longrightarrow> degree (poly_mult p1 p2) = (if p1 = [] \<or> p2 = [] then 0 else degree p1 + degree p2)
[PROOF STEP]
case Nil
[PROOF STATE]
proof (state)
this:
p1 = []

goal (2 subgoals):
 1. p1 = [] \<Longrightarrow> degree (poly_mult p1 p2) = (if p1 = [] \<or> p2 = [] then 0 else degree p1 + degree p2)
 2. \<And>a list. p1 = a # list \<Longrightarrow> degree (poly_mult p1 p2) = (if p1 = [] \<or> p2 = [] then 0 else degree p1 + degree p2)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
p1 = []

goal (1 subgoal):
 1. degree (poly_mult p1 p2) = (if p1 = [] \<or> p2 = [] then 0 else degree p1 + degree p2)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
degree (poly_mult p1 p2) = (if p1 = [] \<or> p2 = [] then 0 else degree p1 + degree p2)

goal (1 subgoal):
 1. \<And>a list. p1 = a # list \<Longrightarrow> degree (poly_mult p1 p2) = (if p1 = [] \<or> p2 = [] then 0 else degree p1 + degree p2)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a list. p1 = a # list \<Longrightarrow> degree (poly_mult p1 p2) = (if p1 = [] \<or> p2 = [] then 0 else degree p1 + degree p2)
[PROOF STEP]
case (Cons a p1')
[PROOF STATE]
proof (state)
this:
p1 = a # p1'

goal (1 subgoal):
 1. \<And>a list. p1 = a # list \<Longrightarrow> degree (poly_mult p1 p2) = (if p1 = [] \<or> p2 = [] then 0 else degree p1 + degree p2)
[PROOF STEP]
note p1 = Cons
[PROOF STATE]
proof (state)
this:
p1 = a # p1'

goal (1 subgoal):
 1. \<And>a list. p1 = a # list \<Longrightarrow> degree (poly_mult p1 p2) = (if p1 = [] \<or> p2 = [] then 0 else degree p1 + degree p2)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. degree (poly_mult p1 p2) = (if p1 = [] \<or> p2 = [] then 0 else degree p1 + degree p2)
[PROOF STEP]
proof (cases p2)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. p2 = [] \<Longrightarrow> degree (poly_mult p1 p2) = (if p1 = [] \<or> p2 = [] then 0 else degree p1 + degree p2)
 2. \<And>a list. p2 = a # list \<Longrightarrow> degree (poly_mult p1 p2) = (if p1 = [] \<or> p2 = [] then 0 else degree p1 + degree p2)
[PROOF STEP]
case Nil
[PROOF STATE]
proof (state)
this:
p2 = []

goal (2 subgoals):
 1. p2 = [] \<Longrightarrow> degree (poly_mult p1 p2) = (if p1 = [] \<or> p2 = [] then 0 else degree p1 + degree p2)
 2. \<And>a list. p2 = a # list \<Longrightarrow> degree (poly_mult p1 p2) = (if p1 = [] \<or> p2 = [] then 0 else degree p1 + degree p2)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
p2 = []

goal (1 subgoal):
 1. degree (poly_mult p1 p2) = (if p1 = [] \<or> p2 = [] then 0 else degree p1 + degree p2)
[PROOF STEP]
using poly_mult_zero(2)[OF polynomial_in_carrier[OF assms(1-2)]]
[PROOF STATE]
proof (prove)
using this:
p2 = []
poly_mult p1 [] = []

goal (1 subgoal):
 1. degree (poly_mult p1 p2) = (if p1 = [] \<or> p2 = [] then 0 else degree p1 + degree p2)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
degree (poly_mult p1 p2) = (if p1 = [] \<or> p2 = [] then 0 else degree p1 + degree p2)

goal (1 subgoal):
 1. \<And>a list. p2 = a # list \<Longrightarrow> degree (poly_mult p1 p2) = (if p1 = [] \<or> p2 = [] then 0 else degree p1 + degree p2)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a list. p2 = a # list \<Longrightarrow> degree (poly_mult p1 p2) = (if p1 = [] \<or> p2 = [] then 0 else degree p1 + degree p2)
[PROOF STEP]
case (Cons b p2')
[PROOF STATE]
proof (state)
this:
p2 = b # p2'

goal (1 subgoal):
 1. \<And>a list. p2 = a # list \<Longrightarrow> degree (poly_mult p1 p2) = (if p1 = [] \<or> p2 = [] then 0 else degree p1 + degree p2)
[PROOF STEP]
note p2 = Cons
[PROOF STATE]
proof (state)
this:
p2 = b # p2'

goal (1 subgoal):
 1. \<And>a list. p2 = a # list \<Longrightarrow> degree (poly_mult p1 p2) = (if p1 = [] \<or> p2 = [] then 0 else degree p1 + degree p2)
[PROOF STEP]
have a: "a \<in> carrier R" and b: "b \<in> carrier R"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a \<in> carrier R &&& b \<in> carrier R
[PROOF STEP]
using p1 p2 polynomial_in_carrier[OF assms(1-2)] polynomial_in_carrier[OF assms(1,3)]
[PROOF STATE]
proof (prove)
using this:
p1 = a # p1'
p2 = b # p2'
set p1 \<subseteq> carrier R
set p2 \<subseteq> carrier R

goal (1 subgoal):
 1. a \<in> carrier R &&& b \<in> carrier R
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
a \<in> carrier R
b \<in> carrier R

goal (1 subgoal):
 1. \<And>a list. p2 = a # list \<Longrightarrow> degree (poly_mult p1 p2) = (if p1 = [] \<or> p2 = [] then 0 else degree p1 + degree p2)
[PROOF STEP]
have "(coeff (poly_mult p1 p2)) ((degree p1) + (degree p2)) = a \<otimes> b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. local.coeff (poly_mult p1 p2) (degree p1 + degree p2) = a \<otimes> b
[PROOF STEP]
using poly_mult_lead_coeff_aux[OF assms] p1 p2
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>p1 \<noteq> []; p2 \<noteq> []\<rbrakk> \<Longrightarrow> local.coeff (poly_mult p1 p2) (degree p1 + degree p2) = lead_coeff p1 \<otimes> lead_coeff p2
p1 = a # p1'
p2 = b # p2'

goal (1 subgoal):
 1. local.coeff (poly_mult p1 p2) (degree p1 + degree p2) = a \<otimes> b
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
local.coeff (poly_mult p1 p2) (degree p1 + degree p2) = a \<otimes> b

goal (1 subgoal):
 1. \<And>a list. p2 = a # list \<Longrightarrow> degree (poly_mult p1 p2) = (if p1 = [] \<or> p2 = [] then 0 else degree p1 + degree p2)
[PROOF STEP]
hence neq0: "(coeff (poly_mult p1 p2)) ((degree p1) + (degree p2)) \<noteq> \<zero>"
[PROOF STATE]
proof (prove)
using this:
local.coeff (poly_mult p1 p2) (degree p1 + degree p2) = a \<otimes> b

goal (1 subgoal):
 1. local.coeff (poly_mult p1 p2) (degree p1 + degree p2) \<noteq> \<zero>
[PROOF STEP]
using assms(2-3) integral[of a b] lead_coeff_in_carrier[OF assms(1)] p1 p2
[PROOF STATE]
proof (prove)
using this:
local.coeff (poly_mult p1 p2) (degree p1 + degree p2) = a \<otimes> b
polynomial K p1
polynomial K p2
\<lbrakk>a \<otimes> b = \<zero>; a \<in> carrier R; b \<in> carrier R\<rbrakk> \<Longrightarrow> a = \<zero> \<or> b = \<zero>
polynomial K (?a # ?p) \<Longrightarrow> ?a \<in> carrier R - {\<zero>}
p1 = a # p1'
p2 = b # p2'

goal (1 subgoal):
 1. local.coeff (poly_mult p1 p2) (degree p1 + degree p2) \<noteq> \<zero>
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
local.coeff (poly_mult p1 p2) (degree p1 + degree p2) \<noteq> \<zero>

goal (1 subgoal):
 1. \<And>a list. p2 = a # list \<Longrightarrow> degree (poly_mult p1 p2) = (if p1 = [] \<or> p2 = [] then 0 else degree p1 + degree p2)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
local.coeff (poly_mult p1 p2) (degree p1 + degree p2) \<noteq> \<zero>

goal (1 subgoal):
 1. \<And>a list. p2 = a # list \<Longrightarrow> degree (poly_mult p1 p2) = (if p1 = [] \<or> p2 = [] then 0 else degree p1 + degree p2)
[PROOF STEP]
have eq0: "\<And>i. i > (degree p1) + (degree p2) \<Longrightarrow> (coeff (poly_mult p1 p2)) i = \<zero>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>i. degree p1 + degree p2 < i \<Longrightarrow> local.coeff (poly_mult p1 p2) i = \<zero>
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i. degree p1 + degree p2 < i \<Longrightarrow> local.coeff (poly_mult p1 p2) i = \<zero>
[PROOF STEP]
have aux_lemma: "degree (poly_mult p1 p2) \<le> (degree p1) + (degree p2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. degree (poly_mult p1 p2) \<le> degree p1 + degree p2
[PROOF STEP]
proof (induct p1)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. degree (poly_mult [] p2) \<le> degree [] + degree p2
 2. \<And>a p1. degree (poly_mult p1 p2) \<le> degree p1 + degree p2 \<Longrightarrow> degree (poly_mult (a # p1) p2) \<le> degree (a # p1) + degree p2
[PROOF STEP]
case Nil
[PROOF STATE]
proof (state)
this:

goal (2 subgoals):
 1. degree (poly_mult [] p2) \<le> degree [] + degree p2
 2. \<And>a p1. degree (poly_mult p1 p2) \<le> degree p1 + degree p2 \<Longrightarrow> degree (poly_mult (a # p1) p2) \<le> degree (a # p1) + degree p2
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. degree (poly_mult [] p2) \<le> degree [] + degree p2
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
degree (poly_mult [] p2) \<le> degree [] + degree p2

goal (1 subgoal):
 1. \<And>a p1. degree (poly_mult p1 p2) \<le> degree p1 + degree p2 \<Longrightarrow> degree (poly_mult (a # p1) p2) \<le> degree (a # p1) + degree p2
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a p1. degree (poly_mult p1 p2) \<le> degree p1 + degree p2 \<Longrightarrow> degree (poly_mult (a # p1) p2) \<le> degree (a # p1) + degree p2
[PROOF STEP]
case (Cons a p1)
[PROOF STATE]
proof (state)
this:
degree (poly_mult p1 p2) \<le> degree p1 + degree p2

goal (1 subgoal):
 1. \<And>a p1. degree (poly_mult p1 p2) \<le> degree p1 + degree p2 \<Longrightarrow> degree (poly_mult (a # p1) p2) \<le> degree (a # p1) + degree p2
[PROOF STEP]
let ?a_p2 = "(map (\<lambda>b. a \<otimes> b) p2) @ (replicate (degree (a # p1)) \<zero>)"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a p1. degree (poly_mult p1 p2) \<le> degree p1 + degree p2 \<Longrightarrow> degree (poly_mult (a # p1) p2) \<le> degree (a # p1) + degree p2
[PROOF STEP]
have "poly_mult (a # p1) p2 = poly_add ?a_p2 (poly_mult p1 p2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly_mult (a # p1) p2 = poly_add (map ((\<otimes>) a) p2 @ replicate (degree (a # p1)) \<zero>) (poly_mult p1 p2)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
poly_mult (a # p1) p2 = poly_add (map ((\<otimes>) a) p2 @ replicate (degree (a # p1)) \<zero>) (poly_mult p1 p2)

goal (1 subgoal):
 1. \<And>a p1. degree (poly_mult p1 p2) \<le> degree p1 + degree p2 \<Longrightarrow> degree (poly_mult (a # p1) p2) \<le> degree (a # p1) + degree p2
[PROOF STEP]
hence "degree (poly_mult (a # p1) p2) \<le> max (degree ?a_p2) (degree (poly_mult p1 p2))"
[PROOF STATE]
proof (prove)
using this:
poly_mult (a # p1) p2 = poly_add (map ((\<otimes>) a) p2 @ replicate (degree (a # p1)) \<zero>) (poly_mult p1 p2)

goal (1 subgoal):
 1. degree (poly_mult (a # p1) p2) \<le> max (degree (map ((\<otimes>) a) p2 @ replicate (degree (a # p1)) \<zero>)) (degree (poly_mult p1 p2))
[PROOF STEP]
using poly_add_degree[of ?a_p2 "poly_mult p1 p2"]
[PROOF STATE]
proof (prove)
using this:
poly_mult (a # p1) p2 = poly_add (map ((\<otimes>) a) p2 @ replicate (degree (a # p1)) \<zero>) (poly_mult p1 p2)
degree (poly_add (map ((\<otimes>) a) p2 @ replicate (degree (a # p1)) \<zero>) (poly_mult p1 p2)) \<le> max (degree (map ((\<otimes>) a) p2 @ replicate (degree (a # p1)) \<zero>)) (degree (poly_mult p1 p2))

goal (1 subgoal):
 1. degree (poly_mult (a # p1) p2) \<le> max (degree (map ((\<otimes>) a) p2 @ replicate (degree (a # p1)) \<zero>)) (degree (poly_mult p1 p2))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
degree (poly_mult (a # p1) p2) \<le> max (degree (map ((\<otimes>) a) p2 @ replicate (degree (a # p1)) \<zero>)) (degree (poly_mult p1 p2))

goal (1 subgoal):
 1. \<And>a p1. degree (poly_mult p1 p2) \<le> degree p1 + degree p2 \<Longrightarrow> degree (poly_mult (a # p1) p2) \<le> degree (a # p1) + degree p2
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
degree (poly_mult (a # p1) p2) \<le> max (degree (map ((\<otimes>) a) p2 @ replicate (degree (a # p1)) \<zero>)) (degree (poly_mult p1 p2))

goal (1 subgoal):
 1. \<And>a p1. degree (poly_mult p1 p2) \<le> degree p1 + degree p2 \<Longrightarrow> degree (poly_mult (a # p1) p2) \<le> degree (a # p1) + degree p2
[PROOF STEP]
have " ... \<le> max ((degree (a # p1)) + (degree p2)) (degree (poly_mult p1 p2))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. max (degree (map ((\<otimes>) a) p2 @ replicate (degree (a # p1)) \<zero>)) (degree (poly_mult p1 p2)) \<le> max (degree (a # p1) + degree p2) (degree (poly_mult p1 p2))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
max (degree (map ((\<otimes>) a) p2 @ replicate (degree (a # p1)) \<zero>)) (degree (poly_mult p1 p2)) \<le> max (degree (a # p1) + degree p2) (degree (poly_mult p1 p2))

goal (1 subgoal):
 1. \<And>a p1. degree (poly_mult p1 p2) \<le> degree p1 + degree p2 \<Longrightarrow> degree (poly_mult (a # p1) p2) \<le> degree (a # p1) + degree p2
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
max (degree (map ((\<otimes>) a) p2 @ replicate (degree (a # p1)) \<zero>)) (degree (poly_mult p1 p2)) \<le> max (degree (a # p1) + degree p2) (degree (poly_mult p1 p2))

goal (1 subgoal):
 1. \<And>a p1. degree (poly_mult p1 p2) \<le> degree p1 + degree p2 \<Longrightarrow> degree (poly_mult (a # p1) p2) \<le> degree (a # p1) + degree p2
[PROOF STEP]
have " ... \<le> max ((degree (a # p1)) + (degree p2)) ((degree p1) + (degree p2))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. max (degree (a # p1) + degree p2) (degree (poly_mult p1 p2)) \<le> max (degree (a # p1) + degree p2) (degree p1 + degree p2)
[PROOF STEP]
using Cons
[PROOF STATE]
proof (prove)
using this:
degree (poly_mult p1 p2) \<le> degree p1 + degree p2

goal (1 subgoal):
 1. max (degree (a # p1) + degree p2) (degree (poly_mult p1 p2)) \<le> max (degree (a # p1) + degree p2) (degree p1 + degree p2)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
max (degree (a # p1) + degree p2) (degree (poly_mult p1 p2)) \<le> max (degree (a # p1) + degree p2) (degree p1 + degree p2)

goal (1 subgoal):
 1. \<And>a p1. degree (poly_mult p1 p2) \<le> degree p1 + degree p2 \<Longrightarrow> degree (poly_mult (a # p1) p2) \<le> degree (a # p1) + degree p2
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
max (degree (a # p1) + degree p2) (degree (poly_mult p1 p2)) \<le> max (degree (a # p1) + degree p2) (degree p1 + degree p2)

goal (1 subgoal):
 1. \<And>a p1. degree (poly_mult p1 p2) \<le> degree p1 + degree p2 \<Longrightarrow> degree (poly_mult (a # p1) p2) \<le> degree (a # p1) + degree p2
[PROOF STEP]
have " ... \<le> (degree (a # p1)) + (degree p2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. max (degree (a # p1) + degree p2) (degree p1 + degree p2) \<le> degree (a # p1) + degree p2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
max (degree (a # p1) + degree p2) (degree p1 + degree p2) \<le> degree (a # p1) + degree p2

goal (1 subgoal):
 1. \<And>a p1. degree (poly_mult p1 p2) \<le> degree p1 + degree p2 \<Longrightarrow> degree (poly_mult (a # p1) p2) \<le> degree (a # p1) + degree p2
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
degree (poly_mult (a # p1) p2) \<le> degree (a # p1) + degree p2
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
degree (poly_mult (a # p1) p2) \<le> degree (a # p1) + degree p2

goal (1 subgoal):
 1. degree (poly_mult (a # p1) p2) \<le> degree (a # p1) + degree p2
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
degree (poly_mult (a # p1) p2) \<le> degree (a # p1) + degree p2

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
degree (poly_mult p1 p2) \<le> degree p1 + degree p2

goal (1 subgoal):
 1. \<And>i. degree p1 + degree p2 < i \<Longrightarrow> local.coeff (poly_mult p1 p2) i = \<zero>
[PROOF STEP]
fix i
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i. degree p1 + degree p2 < i \<Longrightarrow> local.coeff (poly_mult p1 p2) i = \<zero>
[PROOF STEP]
show "i > (degree p1) + (degree p2) \<Longrightarrow> (coeff (poly_mult p1 p2)) i = \<zero>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. degree p1 + degree p2 < i \<Longrightarrow> local.coeff (poly_mult p1 p2) i = \<zero>
[PROOF STEP]
using coeff_degree aux_lemma
[PROOF STATE]
proof (prove)
using this:
degree ?p < ?i \<Longrightarrow> local.coeff ?p ?i = \<zero>
degree (poly_mult p1 p2) \<le> degree p1 + degree p2

goal (1 subgoal):
 1. degree p1 + degree p2 < i \<Longrightarrow> local.coeff (poly_mult p1 p2) i = \<zero>
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
degree p1 + degree p2 < i \<Longrightarrow> local.coeff (poly_mult p1 p2) i = \<zero>

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
degree p1 + degree p2 < ?i \<Longrightarrow> local.coeff (poly_mult p1 p2) ?i = \<zero>

goal (1 subgoal):
 1. \<And>a list. p2 = a # list \<Longrightarrow> degree (poly_mult p1 p2) = (if p1 = [] \<or> p2 = [] then 0 else degree p1 + degree p2)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
degree p1 + degree p2 < ?i \<Longrightarrow> local.coeff (poly_mult p1 p2) ?i = \<zero>

goal (1 subgoal):
 1. \<And>a list. p2 = a # list \<Longrightarrow> degree (poly_mult p1 p2) = (if p1 = [] \<or> p2 = [] then 0 else degree p1 + degree p2)
[PROOF STEP]
have "polynomial K (poly_mult p1 p2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. polynomial K (poly_mult p1 p2)
[PROOF STEP]
by (simp add: assms poly_mult_closed)
[PROOF STATE]
proof (state)
this:
polynomial K (poly_mult p1 p2)

goal (1 subgoal):
 1. \<And>a list. p2 = a # list \<Longrightarrow> degree (poly_mult p1 p2) = (if p1 = [] \<or> p2 = [] then 0 else degree p1 + degree p2)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
local.coeff (poly_mult p1 p2) (degree p1 + degree p2) \<noteq> \<zero>
degree p1 + degree p2 < ?i \<Longrightarrow> local.coeff (poly_mult p1 p2) ?i = \<zero>
polynomial K (poly_mult p1 p2)
[PROOF STEP]
have "degree (poly_mult p1 p2) = degree p1 + degree p2"
[PROOF STATE]
proof (prove)
using this:
local.coeff (poly_mult p1 p2) (degree p1 + degree p2) \<noteq> \<zero>
degree p1 + degree p2 < ?i \<Longrightarrow> local.coeff (poly_mult p1 p2) ?i = \<zero>
polynomial K (poly_mult p1 p2)

goal (1 subgoal):
 1. degree (poly_mult p1 p2) = degree p1 + degree p2
[PROOF STEP]
by (metis (no_types) assms(1) coeff.simps(1) coeff_degree domain.poly_mult_one(1) domain_axioms eq0 lead_coeff_simp length_greater_0_conv neq0 normalize_length_lt not_less_iff_gr_or_eq poly_mult_one'(1) polynomial_in_carrier)
[PROOF STATE]
proof (state)
this:
degree (poly_mult p1 p2) = degree p1 + degree p2

goal (1 subgoal):
 1. \<And>a list. p2 = a # list \<Longrightarrow> degree (poly_mult p1 p2) = (if p1 = [] \<or> p2 = [] then 0 else degree p1 + degree p2)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
degree (poly_mult p1 p2) = degree p1 + degree p2

goal (1 subgoal):
 1. degree (poly_mult p1 p2) = (if p1 = [] \<or> p2 = [] then 0 else degree p1 + degree p2)
[PROOF STEP]
using p1 p2
[PROOF STATE]
proof (prove)
using this:
degree (poly_mult p1 p2) = degree p1 + degree p2
p1 = a # p1'
p2 = b # p2'

goal (1 subgoal):
 1. degree (poly_mult p1 p2) = (if p1 = [] \<or> p2 = [] then 0 else degree p1 + degree p2)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
degree (poly_mult p1 p2) = (if p1 = [] \<or> p2 = [] then 0 else degree p1 + degree p2)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
degree (poly_mult p1 p2) = (if p1 = [] \<or> p2 = [] then 0 else degree p1 + degree p2)

goal:
No subgoals!
[PROOF STEP]
qed