[STATEMENT]
lemma coeff_conv:
fixes f :: "'a qr"
assumes "i<n"
shows "poly.coeff ((of_qr f) * (of_qr g) mod qr_poly) i =
    (\<Sum>j<n. conv_sign ((int i - int j) div n) *
      poly.coeff (of_qr f) j * poly.coeff (of_qr g) (nat ((int i - int j) mod n)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly.coeff (of_qr f * of_qr g mod qr_poly) i = (\<Sum>j<n. conv_sign ((int i - int j) div int n) * poly.coeff (of_qr f) j * poly.coeff (of_qr g) (nat ((int i - int j) mod int n)))
[PROOF STEP]
proof (cases "degree (of_qr f) + degree (of_qr g)<n")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. degree (of_qr f) + degree (of_qr g) < n \<Longrightarrow> poly.coeff (of_qr f * of_qr g mod qr_poly) i = (\<Sum>j<n. conv_sign ((int i - int j) div int n) * poly.coeff (of_qr f) j * poly.coeff (of_qr g) (nat ((int i - int j) mod int n)))
 2. \<not> degree (of_qr f) + degree (of_qr g) < n \<Longrightarrow> poly.coeff (of_qr f * of_qr g mod qr_poly) i = (\<Sum>j<n. conv_sign ((int i - int j) div int n) * poly.coeff (of_qr f) j * poly.coeff (of_qr g) (nat ((int i - int j) mod int n)))
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
degree (of_qr f) + degree (of_qr g) < n

goal (2 subgoals):
 1. degree (of_qr f) + degree (of_qr g) < n \<Longrightarrow> poly.coeff (of_qr f * of_qr g mod qr_poly) i = (\<Sum>j<n. conv_sign ((int i - int j) div int n) * poly.coeff (of_qr f) j * poly.coeff (of_qr g) (nat ((int i - int j) mod int n)))
 2. \<not> degree (of_qr f) + degree (of_qr g) < n \<Longrightarrow> poly.coeff (of_qr f * of_qr g mod qr_poly) i = (\<Sum>j<n. conv_sign ((int i - int j) div int n) * poly.coeff (of_qr f) j * poly.coeff (of_qr g) (nat ((int i - int j) mod int n)))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
degree (of_qr f) + degree (of_qr g) < n
[PROOF STEP]
have True':"degree ((of_qr f) * (of_qr g)) <n"
[PROOF STATE]
proof (prove)
using this:
degree (of_qr f) + degree (of_qr g) < n

goal (1 subgoal):
 1. degree (of_qr f * of_qr g) < n
[PROOF STEP]
using degree_mult_le
[PROOF STATE]
proof (prove)
using this:
degree (of_qr f) + degree (of_qr g) < n
degree (?p * ?q) \<le> degree ?p + degree ?q

goal (1 subgoal):
 1. degree (of_qr f * of_qr g) < n
[PROOF STEP]
using order_le_less_trans
[PROOF STATE]
proof (prove)
using this:
degree (of_qr f) + degree (of_qr g) < n
degree (?p * ?q) \<le> degree ?p + degree ?q
\<lbrakk>?x \<le> ?y; ?y < ?z\<rbrakk> \<Longrightarrow> ?x < ?z

goal (1 subgoal):
 1. degree (of_qr f * of_qr g) < n
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
degree (of_qr f * of_qr g) < n

goal (2 subgoals):
 1. degree (of_qr f) + degree (of_qr g) < n \<Longrightarrow> poly.coeff (of_qr f * of_qr g mod qr_poly) i = (\<Sum>j<n. conv_sign ((int i - int j) div int n) * poly.coeff (of_qr f) j * poly.coeff (of_qr g) (nat ((int i - int j) mod int n)))
 2. \<not> degree (of_qr f) + degree (of_qr g) < n \<Longrightarrow> poly.coeff (of_qr f * of_qr g mod qr_poly) i = (\<Sum>j<n. conv_sign ((int i - int j) div int n) * poly.coeff (of_qr f) j * poly.coeff (of_qr g) (nat ((int i - int j) mod int n)))
[PROOF STEP]
have "poly.coeff ((of_qr f) * (of_qr g) mod qr_poly) i =
    poly.coeff ((of_qr f) * (of_qr g)) i"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly.coeff (of_qr f * of_qr g mod qr_poly) i = poly.coeff (of_qr f * of_qr g) i
[PROOF STEP]
using True'
[PROOF STATE]
proof (prove)
using this:
degree (of_qr f * of_qr g) < n

goal (1 subgoal):
 1. poly.coeff (of_qr f * of_qr g mod qr_poly) i = poly.coeff (of_qr f * of_qr g) i
[PROOF STEP]
by (metis deg_qr_n degree_qr_poly mod_poly_less nat_int)
[PROOF STATE]
proof (state)
this:
poly.coeff (of_qr f * of_qr g mod qr_poly) i = poly.coeff (of_qr f * of_qr g) i

goal (2 subgoals):
 1. degree (of_qr f) + degree (of_qr g) < n \<Longrightarrow> poly.coeff (of_qr f * of_qr g mod qr_poly) i = (\<Sum>j<n. conv_sign ((int i - int j) div int n) * poly.coeff (of_qr f) j * poly.coeff (of_qr g) (nat ((int i - int j) mod int n)))
 2. \<not> degree (of_qr f) + degree (of_qr g) < n \<Longrightarrow> poly.coeff (of_qr f * of_qr g mod qr_poly) i = (\<Sum>j<n. conv_sign ((int i - int j) div int n) * poly.coeff (of_qr f) j * poly.coeff (of_qr g) (nat ((int i - int j) mod int n)))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
poly.coeff (of_qr f * of_qr g mod qr_poly) i = poly.coeff (of_qr f * of_qr g) i

goal (2 subgoals):
 1. degree (of_qr f) + degree (of_qr g) < n \<Longrightarrow> poly.coeff (of_qr f * of_qr g mod qr_poly) i = (\<Sum>j<n. conv_sign ((int i - int j) div int n) * poly.coeff (of_qr f) j * poly.coeff (of_qr g) (nat ((int i - int j) mod int n)))
 2. \<not> degree (of_qr f) + degree (of_qr g) < n \<Longrightarrow> poly.coeff (of_qr f * of_qr g mod qr_poly) i = (\<Sum>j<n. conv_sign ((int i - int j) div int n) * poly.coeff (of_qr f) j * poly.coeff (of_qr g) (nat ((int i - int j) mod int n)))
[PROOF STEP]
have "\<dots> = (\<Sum>ia\<le>i. poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (i - ia))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly.coeff (of_qr f * of_qr g) i = (\<Sum>ia\<le>i. poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (i - ia))
[PROOF STEP]
unfolding coeff_mult
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>ia\<le>i. poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (i - ia)) = (\<Sum>ia\<le>i. poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (i - ia))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
poly.coeff (of_qr f * of_qr g) i = (\<Sum>ia\<le>i. poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (i - ia))

goal (2 subgoals):
 1. degree (of_qr f) + degree (of_qr g) < n \<Longrightarrow> poly.coeff (of_qr f * of_qr g mod qr_poly) i = (\<Sum>j<n. conv_sign ((int i - int j) div int n) * poly.coeff (of_qr f) j * poly.coeff (of_qr g) (nat ((int i - int j) mod int n)))
 2. \<not> degree (of_qr f) + degree (of_qr g) < n \<Longrightarrow> poly.coeff (of_qr f * of_qr g mod qr_poly) i = (\<Sum>j<n. conv_sign ((int i - int j) div int n) * poly.coeff (of_qr f) j * poly.coeff (of_qr g) (nat ((int i - int j) mod int n)))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
poly.coeff (of_qr f * of_qr g) i = (\<Sum>ia\<le>i. poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (i - ia))

goal (2 subgoals):
 1. degree (of_qr f) + degree (of_qr g) < n \<Longrightarrow> poly.coeff (of_qr f * of_qr g mod qr_poly) i = (\<Sum>j<n. conv_sign ((int i - int j) div int n) * poly.coeff (of_qr f) j * poly.coeff (of_qr g) (nat ((int i - int j) mod int n)))
 2. \<not> degree (of_qr f) + degree (of_qr g) < n \<Longrightarrow> poly.coeff (of_qr f * of_qr g mod qr_poly) i = (\<Sum>j<n. conv_sign ((int i - int j) div int n) * poly.coeff (of_qr f) j * poly.coeff (of_qr g) (nat ((int i - int j) mod int n)))
[PROOF STEP]
have "\<dots> = (\<Sum>ia\<le>i. conv_sign ((int i - int ia) div int n) *
    poly.coeff (of_qr f) ia *
    poly.coeff (of_qr g) (nat ((int i - int ia) mod n)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>ia\<le>i. poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (i - ia)) = (\<Sum>ia\<le>i. conv_sign ((int i - int ia) div int n) * poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (nat ((int i - int ia) mod int n)))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<Sum>ia\<le>i. poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (i - ia)) = (\<Sum>ia\<le>i. conv_sign ((int i - int ia) div int n) * poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (nat ((int i - int ia) mod int n)))
[PROOF STEP]
have "i-ia = nat ((int i - int ia) mod n)" if "ia \<le> i" for ia
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. i - ia = nat ((int i - int ia) mod int n)
[PROOF STEP]
using assms that
[PROOF STATE]
proof (prove)
using this:
i < n
ia \<le> i

goal (1 subgoal):
 1. i - ia = nat ((int i - int ia) mod int n)
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
?ia \<le> i \<Longrightarrow> i - ?ia = nat ((int i - int ?ia) mod int n)

goal (1 subgoal):
 1. (\<Sum>ia\<le>i. poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (i - ia)) = (\<Sum>ia\<le>i. conv_sign ((int i - int ia) div int n) * poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (nat ((int i - int ia) mod int n)))
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
?ia \<le> i \<Longrightarrow> i - ?ia = nat ((int i - int ?ia) mod int n)

goal (1 subgoal):
 1. (\<Sum>ia\<le>i. poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (i - ia)) = (\<Sum>ia\<le>i. conv_sign ((int i - int ia) div int n) * poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (nat ((int i - int ia) mod int n)))
[PROOF STEP]
have "conv_sign ((int i - int ia) div int n) = 1"
      if "ia \<le> i" for ia
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. conv_sign ((int i - int ia) div int n) = 1
[PROOF STEP]
unfolding conv_sign_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if (int i - int ia) div int n mod 2 = 0 then 1 else - 1) = 1
[PROOF STEP]
using assms that
[PROOF STATE]
proof (prove)
using this:
i < n
ia \<le> i

goal (1 subgoal):
 1. (if (int i - int ia) div int n mod 2 = 0 then 1 else - 1) = 1
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
?ia \<le> i \<Longrightarrow> conv_sign ((int i - int ?ia) div int n) = 1

goal (1 subgoal):
 1. (\<Sum>ia\<le>i. poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (i - ia)) = (\<Sum>ia\<le>i. conv_sign ((int i - int ia) div int n) * poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (nat ((int i - int ia) mod int n)))
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
?ia \<le> i \<Longrightarrow> i - ?ia = nat ((int i - int ?ia) mod int n)
?ia \<le> i \<Longrightarrow> conv_sign ((int i - int ?ia) div int n) = 1
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
?ia \<le> i \<Longrightarrow> i - ?ia = nat ((int i - int ?ia) mod int n)
?ia \<le> i \<Longrightarrow> conv_sign ((int i - int ?ia) div int n) = 1

goal (1 subgoal):
 1. (\<Sum>ia\<le>i. poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (i - ia)) = (\<Sum>ia\<le>i. conv_sign ((int i - int ia) div int n) * poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (nat ((int i - int ia) mod int n)))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<Sum>ia\<le>i. poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (i - ia)) = (\<Sum>ia\<le>i. conv_sign ((int i - int ia) div int n) * poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (nat ((int i - int ia) mod int n)))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<Sum>ia\<le>i. poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (i - ia)) = (\<Sum>ia\<le>i. conv_sign ((int i - int ia) div int n) * poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (nat ((int i - int ia) mod int n)))

goal (2 subgoals):
 1. degree (of_qr f) + degree (of_qr g) < n \<Longrightarrow> poly.coeff (of_qr f * of_qr g mod qr_poly) i = (\<Sum>j<n. conv_sign ((int i - int j) div int n) * poly.coeff (of_qr f) j * poly.coeff (of_qr g) (nat ((int i - int j) mod int n)))
 2. \<not> degree (of_qr f) + degree (of_qr g) < n \<Longrightarrow> poly.coeff (of_qr f * of_qr g mod qr_poly) i = (\<Sum>j<n. conv_sign ((int i - int j) div int n) * poly.coeff (of_qr f) j * poly.coeff (of_qr g) (nat ((int i - int j) mod int n)))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>ia\<le>i. poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (i - ia)) = (\<Sum>ia\<le>i. conv_sign ((int i - int ia) div int n) * poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (nat ((int i - int ia) mod int n)))

goal (2 subgoals):
 1. degree (of_qr f) + degree (of_qr g) < n \<Longrightarrow> poly.coeff (of_qr f * of_qr g mod qr_poly) i = (\<Sum>j<n. conv_sign ((int i - int j) div int n) * poly.coeff (of_qr f) j * poly.coeff (of_qr g) (nat ((int i - int j) mod int n)))
 2. \<not> degree (of_qr f) + degree (of_qr g) < n \<Longrightarrow> poly.coeff (of_qr f * of_qr g mod qr_poly) i = (\<Sum>j<n. conv_sign ((int i - int j) div int n) * poly.coeff (of_qr f) j * poly.coeff (of_qr g) (nat ((int i - int j) mod int n)))
[PROOF STEP]
have "\<dots> = (\<Sum>ia<n. conv_sign ((int i - int ia) div int n) *
    poly.coeff (of_qr f) ia *
    poly.coeff (of_qr g) (nat ((int i - int ia) mod n)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>ia\<le>i. conv_sign ((int i - int ia) div int n) * poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (nat ((int i - int ia) mod int n))) = (\<Sum>ia<n. conv_sign ((int i - int ia) div int n) * poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (nat ((int i - int ia) mod int n)))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<Sum>ia\<le>i. conv_sign ((int i - int ia) div int n) * poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (nat ((int i - int ia) mod int n))) = (\<Sum>ia<n. conv_sign ((int i - int ia) div int n) * poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (nat ((int i - int ia) mod int n)))
[PROOF STEP]
have "poly.coeff (of_qr f) ia *
       poly.coeff (of_qr g) (nat ((int i - int ia) mod int n)) = 0"
      if "ia \<in> {i<..<n}" for ia
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (nat ((int i - int ia) mod int n)) = 0
[PROOF STEP]
proof (subst mult_eq_0_iff, safe, goal_cases)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. poly.coeff (of_qr g) (nat ((int i - int ia) mod int n)) \<noteq> 0 \<Longrightarrow> poly.coeff (of_qr f) ia = 0
[PROOF STEP]
case 1
[PROOF STATE]
proof (state)
this:
poly.coeff (of_qr g) (nat ((int i - int ia) mod int n)) \<noteq> 0

goal (1 subgoal):
 1. poly.coeff (of_qr g) (nat ((int i - int ia) mod int n)) \<noteq> 0 \<Longrightarrow> poly.coeff (of_qr f) ia = 0
[PROOF STEP]
have deg_g: "nat ((int i - int ia) mod int n) \<le> degree (of_qr g)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. nat ((int i - int ia) mod int n) \<le> degree (of_qr g)
[PROOF STEP]
using le_degree[OF 1]
[PROOF STATE]
proof (prove)
using this:
nat ((int i - int ia) mod int n) \<le> degree (of_qr g)

goal (1 subgoal):
 1. nat ((int i - int ia) mod int n) \<le> degree (of_qr g)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
nat ((int i - int ia) mod int n) \<le> degree (of_qr g)

goal (1 subgoal):
 1. poly.coeff (of_qr g) (nat ((int i - int ia) mod int n)) \<noteq> 0 \<Longrightarrow> poly.coeff (of_qr f) ia = 0
[PROOF STEP]
have "ia > degree (of_qr f)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. degree (of_qr f) < ia
[PROOF STEP]
proof (rule ccontr)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> degree (of_qr f) < ia \<Longrightarrow> False
[PROOF STEP]
assume "\<not> degree (of_qr f) < ia"
[PROOF STATE]
proof (state)
this:
\<not> degree (of_qr f) < ia

goal (1 subgoal):
 1. \<not> degree (of_qr f) < ia \<Longrightarrow> False
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<not> degree (of_qr f) < ia
[PROOF STEP]
have as: "ia \<le> degree (of_qr f)"
[PROOF STATE]
proof (prove)
using this:
\<not> degree (of_qr f) < ia

goal (1 subgoal):
 1. ia \<le> degree (of_qr f)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
ia \<le> degree (of_qr f)

goal (1 subgoal):
 1. \<not> degree (of_qr f) < ia \<Longrightarrow> False
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
ia \<le> degree (of_qr f)
[PROOF STEP]
have ni: "nat ((int i - int ia) mod int n) + ia = n + i"
[PROOF STATE]
proof (prove)
using this:
ia \<le> degree (of_qr f)

goal (1 subgoal):
 1. nat ((int i - int ia) mod int n) + ia = n + i
[PROOF STEP]
using that
[PROOF STATE]
proof (prove)
using this:
ia \<le> degree (of_qr f)
ia \<in> {i<..<n}

goal (1 subgoal):
 1. nat ((int i - int ia) mod int n) + ia = n + i
[PROOF STEP]
by (smt (verit, ccfv_threshold) True deg_g
          greaterThanLessThan_iff int_nat_eq less_imp_of_nat_less
          mod_add_self1 mod_pos_pos_trivial of_nat_0_le_iff of_nat_add
          of_nat_mono)
[PROOF STATE]
proof (state)
this:
nat ((int i - int ia) mod int n) + ia = n + i

goal (1 subgoal):
 1. \<not> degree (of_qr f) < ia \<Longrightarrow> False
[PROOF STEP]
have "n + i \<le> degree (of_qr f) + degree (of_qr g)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n + i \<le> degree (of_qr f) + degree (of_qr g)
[PROOF STEP]
unfolding ni[symmetric]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. nat ((int i - int ia) mod int n) + ia \<le> degree (of_qr f) + degree (of_qr g)
[PROOF STEP]
using as deg_g
[PROOF STATE]
proof (prove)
using this:
ia \<le> degree (of_qr f)
nat ((int i - int ia) mod int n) \<le> degree (of_qr g)

goal (1 subgoal):
 1. nat ((int i - int ia) mod int n) + ia \<le> degree (of_qr f) + degree (of_qr g)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
n + i \<le> degree (of_qr f) + degree (of_qr g)

goal (1 subgoal):
 1. \<not> degree (of_qr f) < ia \<Longrightarrow> False
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
n + i \<le> degree (of_qr f) + degree (of_qr g)
[PROOF STEP]
show False
[PROOF STATE]
proof (prove)
using this:
n + i \<le> degree (of_qr f) + degree (of_qr g)

goal (1 subgoal):
 1. False
[PROOF STEP]
using True
[PROOF STATE]
proof (prove)
using this:
n + i \<le> degree (of_qr f) + degree (of_qr g)
degree (of_qr f) + degree (of_qr g) < n

goal (1 subgoal):
 1. False
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
False

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
degree (of_qr f) < ia

goal (1 subgoal):
 1. poly.coeff (of_qr g) (nat ((int i - int ia) mod int n)) \<noteq> 0 \<Longrightarrow> poly.coeff (of_qr f) ia = 0
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
degree (of_qr f) < ia
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
degree (of_qr f) < ia

goal (1 subgoal):
 1. poly.coeff (of_qr f) ia = 0
[PROOF STEP]
using coeff_eq_0
[PROOF STATE]
proof (prove)
using this:
degree (of_qr f) < ia
degree ?p < ?n \<Longrightarrow> poly.coeff ?p ?n = (0::?'a)

goal (1 subgoal):
 1. poly.coeff (of_qr f) ia = 0
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
poly.coeff (of_qr f) ia = 0

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
?ia \<in> {i<..<n} \<Longrightarrow> poly.coeff (of_qr f) ?ia * poly.coeff (of_qr g) (nat ((int i - int ?ia) mod int n)) = 0

goal (1 subgoal):
 1. (\<Sum>ia\<le>i. conv_sign ((int i - int ia) div int n) * poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (nat ((int i - int ia) mod int n))) = (\<Sum>ia<n. conv_sign ((int i - int ia) div int n) * poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (nat ((int i - int ia) mod int n)))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
?ia \<in> {i<..<n} \<Longrightarrow> poly.coeff (of_qr f) ?ia * poly.coeff (of_qr g) (nat ((int i - int ?ia) mod int n)) = 0
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
?ia \<in> {i<..<n} \<Longrightarrow> poly.coeff (of_qr f) ?ia * poly.coeff (of_qr g) (nat ((int i - int ?ia) mod int n)) = 0

goal (1 subgoal):
 1. (\<Sum>ia\<le>i. conv_sign ((int i - int ia) div int n) * poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (nat ((int i - int ia) mod int n))) = (\<Sum>ia<n. conv_sign ((int i - int ia) div int n) * poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (nat ((int i - int ia) mod int n)))
[PROOF STEP]
by (subst sum_less_split[OF \<open>i<n\<close>]) (simp add: sum.neutral)
[PROOF STATE]
proof (state)
this:
(\<Sum>ia\<le>i. conv_sign ((int i - int ia) div int n) * poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (nat ((int i - int ia) mod int n))) = (\<Sum>ia<n. conv_sign ((int i - int ia) div int n) * poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (nat ((int i - int ia) mod int n)))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<Sum>ia\<le>i. conv_sign ((int i - int ia) div int n) * poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (nat ((int i - int ia) mod int n))) = (\<Sum>ia<n. conv_sign ((int i - int ia) div int n) * poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (nat ((int i - int ia) mod int n)))

goal (2 subgoals):
 1. degree (of_qr f) + degree (of_qr g) < n \<Longrightarrow> poly.coeff (of_qr f * of_qr g mod qr_poly) i = (\<Sum>j<n. conv_sign ((int i - int j) div int n) * poly.coeff (of_qr f) j * poly.coeff (of_qr g) (nat ((int i - int j) mod int n)))
 2. \<not> degree (of_qr f) + degree (of_qr g) < n \<Longrightarrow> poly.coeff (of_qr f * of_qr g mod qr_poly) i = (\<Sum>j<n. conv_sign ((int i - int j) div int n) * poly.coeff (of_qr f) j * poly.coeff (of_qr g) (nat ((int i - int j) mod int n)))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
poly.coeff (of_qr f * of_qr g mod qr_poly) i = (\<Sum>ia<n. conv_sign ((int i - int ia) div int n) * poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (nat ((int i - int ia) mod int n)))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
poly.coeff (of_qr f * of_qr g mod qr_poly) i = (\<Sum>ia<n. conv_sign ((int i - int ia) div int n) * poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (nat ((int i - int ia) mod int n)))

goal (1 subgoal):
 1. poly.coeff (of_qr f * of_qr g mod qr_poly) i = (\<Sum>j<n. conv_sign ((int i - int j) div int n) * poly.coeff (of_qr f) j * poly.coeff (of_qr g) (nat ((int i - int j) mod int n)))
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
poly.coeff (of_qr f * of_qr g mod qr_poly) i = (\<Sum>j<n. conv_sign ((int i - int j) div int n) * poly.coeff (of_qr f) j * poly.coeff (of_qr g) (nat ((int i - int j) mod int n)))

goal (1 subgoal):
 1. \<not> degree (of_qr f) + degree (of_qr g) < n \<Longrightarrow> poly.coeff (of_qr f * of_qr g mod qr_poly) i = (\<Sum>j<n. conv_sign ((int i - int j) div int n) * poly.coeff (of_qr f) j * poly.coeff (of_qr g) (nat ((int i - int j) mod int n)))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> degree (of_qr f) + degree (of_qr g) < n \<Longrightarrow> poly.coeff (of_qr f * of_qr g mod qr_poly) i = (\<Sum>j<n. conv_sign ((int i - int j) div int n) * poly.coeff (of_qr f) j * poly.coeff (of_qr g) (nat ((int i - int j) mod int n)))
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> degree (of_qr f) + degree (of_qr g) < n

goal (1 subgoal):
 1. \<not> degree (of_qr f) + degree (of_qr g) < n \<Longrightarrow> poly.coeff (of_qr f * of_qr g mod qr_poly) i = (\<Sum>j<n. conv_sign ((int i - int j) div int n) * poly.coeff (of_qr f) j * poly.coeff (of_qr g) (nat ((int i - int j) mod int n)))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<not> degree (of_qr f) + degree (of_qr g) < n
[PROOF STEP]
have *: "degree (of_qr f * of_qr g) \<ge> n"
[PROOF STATE]
proof (prove)
using this:
\<not> degree (of_qr f) + degree (of_qr g) < n

goal (1 subgoal):
 1. n \<le> degree (of_qr f * of_qr g)
[PROOF STEP]
by (metis add.right_neutral add_0 deg_of_qr deg_qr_n degree_0 degree_mult_eq
      linorder_not_le nat_int)
[PROOF STATE]
proof (state)
this:
n \<le> degree (of_qr f * of_qr g)

goal (1 subgoal):
 1. \<not> degree (of_qr f) + degree (of_qr g) < n \<Longrightarrow> poly.coeff (of_qr f * of_qr g mod qr_poly) i = (\<Sum>j<n. conv_sign ((int i - int j) div int n) * poly.coeff (of_qr f) j * poly.coeff (of_qr g) (nat ((int i - int j) mod int n)))
[PROOF STEP]
have "poly.coeff (of_qr f * of_qr g) (i + n) = (\<Sum>ia<n.
        poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (i + n - ia))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly.coeff (of_qr f * of_qr g) (i + n) = (\<Sum>ia<n. poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (i + n - ia))
[PROOF STEP]
unfolding coeff_mult
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>ia\<le>i + n. poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (i + n - ia)) = (\<Sum>ia<n. poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (i + n - ia))
[PROOF STEP]
using coeff_of_qr_zero
[PROOF STATE]
proof (prove)
using this:
n \<le> ?i \<Longrightarrow> poly.coeff (of_qr ?f) ?i = 0

goal (1 subgoal):
 1. (\<Sum>ia\<le>i + n. poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (i + n - ia)) = (\<Sum>ia<n. poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (i + n - ia))
[PROOF STEP]
by (subst sum_leq_split[of _ i]) (auto)
[PROOF STATE]
proof (state)
this:
poly.coeff (of_qr f * of_qr g) (i + n) = (\<Sum>ia<n. poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (i + n - ia))

goal (1 subgoal):
 1. \<not> degree (of_qr f) + degree (of_qr g) < n \<Longrightarrow> poly.coeff (of_qr f * of_qr g mod qr_poly) i = (\<Sum>j<n. conv_sign ((int i - int j) div int n) * poly.coeff (of_qr f) j * poly.coeff (of_qr g) (nat ((int i - int j) mod int n)))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
poly.coeff (of_qr f * of_qr g) (i + n) = (\<Sum>ia<n. poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (i + n - ia))

goal (1 subgoal):
 1. \<not> degree (of_qr f) + degree (of_qr g) < n \<Longrightarrow> poly.coeff (of_qr f * of_qr g mod qr_poly) i = (\<Sum>j<n. conv_sign ((int i - int j) div int n) * poly.coeff (of_qr f) j * poly.coeff (of_qr g) (nat ((int i - int j) mod int n)))
[PROOF STEP]
have "\<dots> = (\<Sum>ia\<in>{i<..<n}.
        poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (i + n - ia))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>ia<n. poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (i + n - ia)) = (\<Sum>ia\<in>{i<..<n}. poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (i + n - ia))
[PROOF STEP]
using coeff_of_qr_zero
[PROOF STATE]
proof (prove)
using this:
n \<le> ?i \<Longrightarrow> poly.coeff (of_qr ?f) ?i = 0

goal (1 subgoal):
 1. (\<Sum>ia<n. poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (i + n - ia)) = (\<Sum>ia\<in>{i<..<n}. poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (i + n - ia))
[PROOF STEP]
by (subst sum_less_split[OF \<open>i<n\<close>]) auto
[PROOF STATE]
proof (state)
this:
(\<Sum>ia<n. poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (i + n - ia)) = (\<Sum>ia\<in>{i<..<n}. poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (i + n - ia))

goal (1 subgoal):
 1. \<not> degree (of_qr f) + degree (of_qr g) < n \<Longrightarrow> poly.coeff (of_qr f * of_qr g mod qr_poly) i = (\<Sum>j<n. conv_sign ((int i - int j) div int n) * poly.coeff (of_qr f) j * poly.coeff (of_qr g) (nat ((int i - int j) mod int n)))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>ia<n. poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (i + n - ia)) = (\<Sum>ia\<in>{i<..<n}. poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (i + n - ia))

goal (1 subgoal):
 1. \<not> degree (of_qr f) + degree (of_qr g) < n \<Longrightarrow> poly.coeff (of_qr f * of_qr g mod qr_poly) i = (\<Sum>j<n. conv_sign ((int i - int j) div int n) * poly.coeff (of_qr f) j * poly.coeff (of_qr g) (nat ((int i - int j) mod int n)))
[PROOF STEP]
have "\<dots> = (\<Sum>ia\<in>{i<..<n}.
        poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (nat ((int i - ia) mod n)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>ia\<in>{i<..<n}. poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (i + n - ia)) = (\<Sum>ia\<in>{i<..<n}. poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (nat ((int i - int ia) mod int n)))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<Sum>ia\<in>{i<..<n}. poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (i + n - ia)) = (\<Sum>ia\<in>{i<..<n}. poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (nat ((int i - int ia) mod int n)))
[PROOF STEP]
have "int i - int ia + int n \<in>{0..<n}" if "ia \<in> {i<..<n}" for ia
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. int i - int ia + int n \<in> {0..<int n}
[PROOF STEP]
using assms that
[PROOF STATE]
proof (prove)
using this:
i < n
ia \<in> {i<..<n}

goal (1 subgoal):
 1. int i - int ia + int n \<in> {0..<int n}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
?ia \<in> {i<..<n} \<Longrightarrow> int i - int ?ia + int n \<in> {0..<int n}

goal (1 subgoal):
 1. (\<Sum>ia\<in>{i<..<n}. poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (i + n - ia)) = (\<Sum>ia\<in>{i<..<n}. poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (nat ((int i - int ia) mod int n)))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
?ia \<in> {i<..<n} \<Longrightarrow> int i - int ?ia + int n \<in> {0..<int n}
[PROOF STEP]
have "int i + n-ia = (int i-ia) mod n" if "ia\<in>{i<..<n}" for ia
[PROOF STATE]
proof (prove)
using this:
?ia \<in> {i<..<n} \<Longrightarrow> int i - int ?ia + int n \<in> {0..<int n}

goal (1 subgoal):
 1. int i + int n - int ia = (int i - int ia) mod int n
[PROOF STEP]
using \<open>i<n\<close> that
[PROOF STATE]
proof (prove)
using this:
?ia \<in> {i<..<n} \<Longrightarrow> int i - int ?ia + int n \<in> {0..<int n}
i < n
ia \<in> {i<..<n}

goal (1 subgoal):
 1. int i + int n - int ia = (int i - int ia) mod int n
[PROOF STEP]
by (smt (verit, best) mod_add_self1 mod_rangeE)
[PROOF STATE]
proof (state)
this:
?ia \<in> {i<..<n} \<Longrightarrow> int i + int n - int ?ia = (int i - int ?ia) mod int n

goal (1 subgoal):
 1. (\<Sum>ia\<in>{i<..<n}. poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (i + n - ia)) = (\<Sum>ia\<in>{i<..<n}. poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (nat ((int i - int ia) mod int n)))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
?ia \<in> {i<..<n} \<Longrightarrow> int i + int n - int ?ia = (int i - int ?ia) mod int n
[PROOF STEP]
have "i+n-ia = nat ((int i - ia) mod n)" if "ia\<in>{i<..<n}" for ia
[PROOF STATE]
proof (prove)
using this:
?ia \<in> {i<..<n} \<Longrightarrow> int i + int n - int ?ia = (int i - int ?ia) mod int n

goal (1 subgoal):
 1. i + n - ia = nat ((int i - int ia) mod int n)
[PROOF STEP]
by (metis int_minus nat_int of_nat_add that)
[PROOF STATE]
proof (state)
this:
?ia \<in> {i<..<n} \<Longrightarrow> i + n - ?ia = nat ((int i - int ?ia) mod int n)

goal (1 subgoal):
 1. (\<Sum>ia\<in>{i<..<n}. poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (i + n - ia)) = (\<Sum>ia\<in>{i<..<n}. poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (nat ((int i - int ia) mod int n)))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
?ia \<in> {i<..<n} \<Longrightarrow> i + n - ?ia = nat ((int i - int ?ia) mod int n)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
?ia \<in> {i<..<n} \<Longrightarrow> i + n - ?ia = nat ((int i - int ?ia) mod int n)

goal (1 subgoal):
 1. (\<Sum>ia\<in>{i<..<n}. poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (i + n - ia)) = (\<Sum>ia\<in>{i<..<n}. poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (nat ((int i - int ia) mod int n)))
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
(\<Sum>ia\<in>{i<..<n}. poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (i + n - ia)) = (\<Sum>ia\<in>{i<..<n}. poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (nat ((int i - int ia) mod int n)))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<Sum>ia\<in>{i<..<n}. poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (i + n - ia)) = (\<Sum>ia\<in>{i<..<n}. poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (nat ((int i - int ia) mod int n)))

goal (1 subgoal):
 1. \<not> degree (of_qr f) + degree (of_qr g) < n \<Longrightarrow> poly.coeff (of_qr f * of_qr g mod qr_poly) i = (\<Sum>j<n. conv_sign ((int i - int j) div int n) * poly.coeff (of_qr f) j * poly.coeff (of_qr g) (nat ((int i - int j) mod int n)))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>ia\<in>{i<..<n}. poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (i + n - ia)) = (\<Sum>ia\<in>{i<..<n}. poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (nat ((int i - int ia) mod int n)))

goal (1 subgoal):
 1. \<not> degree (of_qr f) + degree (of_qr g) < n \<Longrightarrow> poly.coeff (of_qr f * of_qr g mod qr_poly) i = (\<Sum>j<n. conv_sign ((int i - int j) div int n) * poly.coeff (of_qr f) j * poly.coeff (of_qr g) (nat ((int i - int j) mod int n)))
[PROOF STEP]
have "\<dots> = - (\<Sum>ia\<in>{i<..<n}. conv_sign ((int i - int ia) div n) *
        poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (nat ((int i - ia) mod n)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>ia\<in>{i<..<n}. poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (nat ((int i - int ia) mod int n))) = - (\<Sum>ia\<in>{i<..<n}. conv_sign ((int i - int ia) div int n) * poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (nat ((int i - int ia) mod int n)))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<Sum>ia\<in>{i<..<n}. poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (nat ((int i - int ia) mod int n))) = - (\<Sum>ia\<in>{i<..<n}. conv_sign ((int i - int ia) div int n) * poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (nat ((int i - int ia) mod int n)))
[PROOF STEP]
have negative:"(int i - int ia) \<in> {-n..<0}" if "ia \<in>{i<..<n}" for ia
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. int i - int ia \<in> {- int n..<0}
[PROOF STEP]
using that
[PROOF STATE]
proof (prove)
using this:
ia \<in> {i<..<n}

goal (1 subgoal):
 1. int i - int ia \<in> {- int n..<0}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
?ia \<in> {i<..<n} \<Longrightarrow> int i - int ?ia \<in> {- int n..<0}

goal (1 subgoal):
 1. (\<Sum>ia\<in>{i<..<n}. poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (nat ((int i - int ia) mod int n))) = - (\<Sum>ia\<in>{i<..<n}. conv_sign ((int i - int ia) div int n) * poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (nat ((int i - int ia) mod int n)))
[PROOF STEP]
have "(int i - int ia) div n = -1" if "ia \<in>{i<..<n}" for ia
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (int i - int ia) div int n = - 1
[PROOF STEP]
using div_minus_1[OF negative[OF that]]
[PROOF STATE]
proof (prove)
using this:
(int i - int ia) div int n = - 1

goal (1 subgoal):
 1. (int i - int ia) div int n = - 1
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
?ia \<in> {i<..<n} \<Longrightarrow> (int i - int ?ia) div int n = - 1

goal (1 subgoal):
 1. (\<Sum>ia\<in>{i<..<n}. poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (nat ((int i - int ia) mod int n))) = - (\<Sum>ia\<in>{i<..<n}. conv_sign ((int i - int ia) div int n) * poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (nat ((int i - int ia) mod int n)))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
?ia \<in> {i<..<n} \<Longrightarrow> (int i - int ?ia) div int n = - 1
[PROOF STEP]
have "conv_sign ((int i - int ia) div n) = -1" if "ia \<in>{i<..<n}" for ia
[PROOF STATE]
proof (prove)
using this:
?ia \<in> {i<..<n} \<Longrightarrow> (int i - int ?ia) div int n = - 1

goal (1 subgoal):
 1. conv_sign ((int i - int ia) div int n) = - 1
[PROOF STEP]
unfolding conv_sign_def
[PROOF STATE]
proof (prove)
using this:
?ia \<in> {i<..<n} \<Longrightarrow> (int i - int ?ia) div int n = - 1

goal (1 subgoal):
 1. (if (int i - int ia) div int n mod 2 = 0 then 1 else - 1) = - 1
[PROOF STEP]
using that
[PROOF STATE]
proof (prove)
using this:
?ia \<in> {i<..<n} \<Longrightarrow> (int i - int ?ia) div int n = - 1
ia \<in> {i<..<n}

goal (1 subgoal):
 1. (if (int i - int ia) div int n mod 2 = 0 then 1 else - 1) = - 1
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
?ia \<in> {i<..<n} \<Longrightarrow> conv_sign ((int i - int ?ia) div int n) = - 1

goal (1 subgoal):
 1. (\<Sum>ia\<in>{i<..<n}. poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (nat ((int i - int ia) mod int n))) = - (\<Sum>ia\<in>{i<..<n}. conv_sign ((int i - int ia) div int n) * poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (nat ((int i - int ia) mod int n)))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
?ia \<in> {i<..<n} \<Longrightarrow> conv_sign ((int i - int ?ia) div int n) = - 1
[PROOF STEP]
have *: "(\<Sum>ia\<in>{i<..<n}. foo ia) =
      (\<Sum>x\<in>{i<..<n}. - (conv_sign ((int i - int x) div int n) * foo x))"
    for foo
[PROOF STATE]
proof (prove)
using this:
?ia \<in> {i<..<n} \<Longrightarrow> conv_sign ((int i - int ?ia) div int n) = - 1

goal (1 subgoal):
 1. sum foo {i<..<n} = (\<Sum>x\<in>{i<..<n}. - (conv_sign ((int i - int x) div int n) * foo x))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
sum ?foo {i<..<n} = (\<Sum>x\<in>{i<..<n}. - (conv_sign ((int i - int x) div int n) * ?foo x))

goal (1 subgoal):
 1. (\<Sum>ia\<in>{i<..<n}. poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (nat ((int i - int ia) mod int n))) = - (\<Sum>ia\<in>{i<..<n}. conv_sign ((int i - int ia) div int n) * poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (nat ((int i - int ia) mod int n)))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>ia\<in>{i<..<n}. poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (nat ((int i - int ia) mod int n))) = - (\<Sum>ia\<in>{i<..<n}. conv_sign ((int i - int ia) div int n) * poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (nat ((int i - int ia) mod int n)))
[PROOF STEP]
by (subst sum_negf[symmetric], subst *) (simp add: mult.assoc)
[PROOF STATE]
proof (state)
this:
(\<Sum>ia\<in>{i<..<n}. poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (nat ((int i - int ia) mod int n))) = - (\<Sum>ia\<in>{i<..<n}. conv_sign ((int i - int ia) div int n) * poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (nat ((int i - int ia) mod int n)))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<Sum>ia\<in>{i<..<n}. poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (nat ((int i - int ia) mod int n))) = - (\<Sum>ia\<in>{i<..<n}. conv_sign ((int i - int ia) div int n) * poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (nat ((int i - int ia) mod int n)))

goal (1 subgoal):
 1. \<not> degree (of_qr f) + degree (of_qr g) < n \<Longrightarrow> poly.coeff (of_qr f * of_qr g mod qr_poly) i = (\<Sum>j<n. conv_sign ((int i - int j) div int n) * poly.coeff (of_qr f) j * poly.coeff (of_qr g) (nat ((int i - int j) mod int n)))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
poly.coeff (of_qr f * of_qr g) (i + n) = - (\<Sum>ia\<in>{i<..<n}. conv_sign ((int i - int ia) div int n) * poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (nat ((int i - int ia) mod int n)))
[PROOF STEP]
have i_n: "poly.coeff (of_qr f * of_qr g) (i + n) =
    - (\<Sum>ia\<in>{i<..<n}. conv_sign ((int i - int ia) div n) *
        poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (nat ((int i - ia) mod n)))"
[PROOF STATE]
proof (prove)
using this:
poly.coeff (of_qr f * of_qr g) (i + n) = - (\<Sum>ia\<in>{i<..<n}. conv_sign ((int i - int ia) div int n) * poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (nat ((int i - int ia) mod int n)))

goal (1 subgoal):
 1. poly.coeff (of_qr f * of_qr g) (i + n) = - (\<Sum>ia\<in>{i<..<n}. conv_sign ((int i - int ia) div int n) * poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (nat ((int i - int ia) mod int n)))
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
poly.coeff (of_qr f * of_qr g) (i + n) = - (\<Sum>ia\<in>{i<..<n}. conv_sign ((int i - int ia) div int n) * poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (nat ((int i - int ia) mod int n)))

goal (1 subgoal):
 1. \<not> degree (of_qr f) + degree (of_qr g) < n \<Longrightarrow> poly.coeff (of_qr f * of_qr g mod qr_poly) i = (\<Sum>j<n. conv_sign ((int i - int j) div int n) * poly.coeff (of_qr f) j * poly.coeff (of_qr g) (nat ((int i - int j) mod int n)))
[PROOF STEP]
have i_n': "poly.coeff (of_qr f * of_qr g) i =
      (\<Sum>ia\<le>i. conv_sign ((int i - int ia) div n) *
        poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (nat ((int i - ia) mod n)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly.coeff (of_qr f * of_qr g) i = (\<Sum>ia\<le>i. conv_sign ((int i - int ia) div int n) * poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (nat ((int i - int ia) mod int n)))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. poly.coeff (of_qr f * of_qr g) i = (\<Sum>ia\<le>i. conv_sign ((int i - int ia) div int n) * poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (nat ((int i - int ia) mod int n)))
[PROOF STEP]
have "conv_sign ((int i - int ia) div n) = 1" if "ia \<le>i" for ia
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. conv_sign ((int i - int ia) div int n) = 1
[PROOF STEP]
using that assms conv_sign_def
[PROOF STATE]
proof (prove)
using this:
ia \<le> i
i < n
conv_sign ?x = (if ?x mod 2 = 0 then 1 else - 1)

goal (1 subgoal):
 1. conv_sign ((int i - int ia) div int n) = 1
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
?ia \<le> i \<Longrightarrow> conv_sign ((int i - int ?ia) div int n) = 1

goal (1 subgoal):
 1. poly.coeff (of_qr f * of_qr g) i = (\<Sum>ia\<le>i. conv_sign ((int i - int ia) div int n) * poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (nat ((int i - int ia) mod int n)))
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
?ia \<le> i \<Longrightarrow> conv_sign ((int i - int ?ia) div int n) = 1

goal (1 subgoal):
 1. poly.coeff (of_qr f * of_qr g) i = (\<Sum>ia\<le>i. conv_sign ((int i - int ia) div int n) * poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (nat ((int i - int ia) mod int n)))
[PROOF STEP]
have "i-ia \<in>{0..<n}" if "ia \<le>i" for ia
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. i - ia \<in> {0..<n}
[PROOF STEP]
using that assms
[PROOF STATE]
proof (prove)
using this:
ia \<le> i
i < n

goal (1 subgoal):
 1. i - ia \<in> {0..<n}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
?ia \<le> i \<Longrightarrow> i - ?ia \<in> {0..<n}

goal (1 subgoal):
 1. poly.coeff (of_qr f * of_qr g) i = (\<Sum>ia\<le>i. conv_sign ((int i - int ia) div int n) * poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (nat ((int i - int ia) mod int n)))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
?ia \<le> i \<Longrightarrow> i - ?ia \<in> {0..<n}
[PROOF STEP]
have "i-ia = (nat ((int i - ia) mod n))" if "ia\<le>i" for ia
[PROOF STATE]
proof (prove)
using this:
?ia \<le> i \<Longrightarrow> i - ?ia \<in> {0..<n}

goal (1 subgoal):
 1. i - ia = nat ((int i - int ia) mod int n)
[PROOF STEP]
using assms that
[PROOF STATE]
proof (prove)
using this:
?ia \<le> i \<Longrightarrow> i - ?ia \<in> {0..<n}
i < n
ia \<le> i

goal (1 subgoal):
 1. i - ia = nat ((int i - int ia) mod int n)
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
?ia \<le> i \<Longrightarrow> i - ?ia = nat ((int i - int ?ia) mod int n)

goal (1 subgoal):
 1. poly.coeff (of_qr f * of_qr g) i = (\<Sum>ia\<le>i. conv_sign ((int i - int ia) div int n) * poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (nat ((int i - int ia) mod int n)))
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
?ia \<le> i \<Longrightarrow> conv_sign ((int i - int ?ia) div int n) = 1
?ia \<le> i \<Longrightarrow> i - ?ia = nat ((int i - int ?ia) mod int n)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
?ia \<le> i \<Longrightarrow> conv_sign ((int i - int ?ia) div int n) = 1
?ia \<le> i \<Longrightarrow> i - ?ia = nat ((int i - int ?ia) mod int n)

goal (1 subgoal):
 1. poly.coeff (of_qr f * of_qr g) i = (\<Sum>ia\<le>i. conv_sign ((int i - int ia) div int n) * poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (nat ((int i - int ia) mod int n)))
[PROOF STEP]
unfolding coeff_mult
[PROOF STATE]
proof (prove)
using this:
?ia \<le> i \<Longrightarrow> conv_sign ((int i - int ?ia) div int n) = 1
?ia \<le> i \<Longrightarrow> i - ?ia = nat ((int i - int ?ia) mod int n)

goal (1 subgoal):
 1. (\<Sum>ia\<le>i. poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (i - ia)) = (\<Sum>ia\<le>i. conv_sign ((int i - int ia) div int n) * poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (nat ((int i - int ia) mod int n)))
[PROOF STEP]
using assms less_imp_diff_less mod_less
[PROOF STATE]
proof (prove)
using this:
?ia \<le> i \<Longrightarrow> conv_sign ((int i - int ?ia) div int n) = 1
?ia \<le> i \<Longrightarrow> i - ?ia = nat ((int i - int ?ia) mod int n)
i < n
?j < ?k \<Longrightarrow> ?j - ?n < ?k
?m < ?n \<Longrightarrow> ?m mod ?n = ?m

goal (1 subgoal):
 1. (\<Sum>ia\<le>i. poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (i - ia)) = (\<Sum>ia\<le>i. conv_sign ((int i - int ia) div int n) * poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (nat ((int i - int ia) mod int n)))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
poly.coeff (of_qr f * of_qr g) i = (\<Sum>ia\<le>i. conv_sign ((int i - int ia) div int n) * poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (nat ((int i - int ia) mod int n)))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
poly.coeff (of_qr f * of_qr g) i = (\<Sum>ia\<le>i. conv_sign ((int i - int ia) div int n) * poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (nat ((int i - int ia) mod int n)))

goal (1 subgoal):
 1. \<not> degree (of_qr f) + degree (of_qr g) < n \<Longrightarrow> poly.coeff (of_qr f * of_qr g mod qr_poly) i = (\<Sum>j<n. conv_sign ((int i - int j) div int n) * poly.coeff (of_qr f) j * poly.coeff (of_qr g) (nat ((int i - int j) mod int n)))
[PROOF STEP]
have calc: "poly.coeff (of_qr f * of_qr g) i - poly.coeff (of_qr f * of_qr g) (i + n) =
    (\<Sum>ia<n. conv_sign ((int i - int ia) div n) *
        poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (nat ((int i - ia) mod n)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly.coeff (of_qr f * of_qr g) i - poly.coeff (of_qr f * of_qr g) (i + n) = (\<Sum>ia<n. conv_sign ((int i - int ia) div int n) * poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (nat ((int i - int ia) mod int n)))
[PROOF STEP]
by (subst i_n, subst i_n')
       (metis (no_types, lifting) assms diff_minus_eq_add sum_less_split)
[PROOF STATE]
proof (state)
this:
poly.coeff (of_qr f * of_qr g) i - poly.coeff (of_qr f * of_qr g) (i + n) = (\<Sum>ia<n. conv_sign ((int i - int ia) div int n) * poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (nat ((int i - int ia) mod int n)))

goal (1 subgoal):
 1. \<not> degree (of_qr f) + degree (of_qr g) < n \<Longrightarrow> poly.coeff (of_qr f * of_qr g mod qr_poly) i = (\<Sum>j<n. conv_sign ((int i - int j) div int n) * poly.coeff (of_qr f) j * poly.coeff (of_qr g) (nat ((int i - int j) mod int n)))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly.coeff (of_qr f * of_qr g mod qr_poly) i = (\<Sum>j<n. conv_sign ((int i - int j) div int n) * poly.coeff (of_qr f) j * poly.coeff (of_qr g) (nat ((int i - int j) mod int n)))
[PROOF STEP]
unfolding coeff_mod_qr_poly[OF * deg_mult_of_qr assms] calc
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>ia<n. conv_sign ((int i - int ia) div int n) * poly.coeff (of_qr f) ia * poly.coeff (of_qr g) (nat ((int i - int ia) mod int n))) = (\<Sum>j<n. conv_sign ((int i - int j) div int n) * poly.coeff (of_qr f) j * poly.coeff (of_qr g) (nat ((int i - int j) mod int n)))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
poly.coeff (of_qr f * of_qr g mod qr_poly) i = (\<Sum>j<n. conv_sign ((int i - int j) div int n) * poly.coeff (of_qr f) j * poly.coeff (of_qr g) (nat ((int i - int j) mod int n)))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma inorder_delete: "\<lbrakk> complete t ; sorted(inorder t) \<rbrakk> \<Longrightarrow>
  inorder(delete x t) = del_list x (inorder t)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>complete t; Sorted_Less.sorted (inorder t)\<rbrakk> \<Longrightarrow> inorder (delete x t) = del_list x (inorder t)
[PROOF STEP]
by(simp add: delete_def inorder_del)


[STATEMENT]
lemma graeffe_poly_impl_hom:
  "map_poly hom (graeffe_poly_impl f m) = graeffe_poly_impl (map_poly hom f) m"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map_poly hom (graeffe_poly_impl f m) = graeffe_poly_impl (map_poly hom f) m
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. map_poly hom (graeffe_poly_impl f m) = graeffe_poly_impl (map_poly hom f) m
[PROOF STEP]
interpret mh: map_poly_inj_idom_hom
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map_poly_inj_idom_hom hom
[PROOF STEP]
..
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. map_poly hom (graeffe_poly_impl f m) = graeffe_poly_impl (map_poly hom f) m
[PROOF STEP]
obtain c where c: "(((- 1) ^ degree f) :: 'a) = c"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>c. (- (1::'a)) ^ degree f = c \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(- (1::'a)) ^ degree f = c

goal (1 subgoal):
 1. map_poly hom (graeffe_poly_impl f m) = graeffe_poly_impl (map_poly hom f) m
[PROOF STEP]
have c': "(((- 1) ^ degree f) :: 'b) = hom c"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (- (1::'b)) ^ degree f = hom c
[PROOF STEP]
unfolding c[symmetric]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (- (1::'b)) ^ degree f = hom ((- (1::'a)) ^ degree f)
[PROOF STEP]
by (simp add:hom_distribs)
[PROOF STATE]
proof (state)
this:
(- (1::'b)) ^ degree f = hom c

goal (1 subgoal):
 1. map_poly hom (graeffe_poly_impl f m) = graeffe_poly_impl (map_poly hom f) m
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map_poly hom (graeffe_poly_impl f m) = graeffe_poly_impl (map_poly hom f) m
[PROOF STEP]
unfolding graeffe_poly_impl_def degree_map_poly_hom c c'
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map_poly hom (graeffe_poly_impl_main c f m) = graeffe_poly_impl_main (hom c) (map_poly hom f) m
[PROOF STEP]
apply (induct m arbitrary: f; simp)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>m f. (\<And>f. map_poly hom (graeffe_poly_impl_main c f m) = graeffe_poly_impl_main (hom c) (map_poly hom f) m) \<Longrightarrow> map_poly hom (graeffe_one_step c (graeffe_poly_impl_main c f m)) = graeffe_one_step (hom c) (graeffe_poly_impl_main (hom c) (map_poly hom f) m)
[PROOF STEP]
by (unfold graeffe_one_step_def hom_distribs map_poly_poly_square_subst map_poly_pcompose,simp)
[PROOF STATE]
proof (state)
this:
map_poly hom (graeffe_poly_impl f m) = graeffe_poly_impl (map_poly hom f) m

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma permutation_insert_bij_betw:
  assumes q: "q permutes {0..<n}" and i: "i < Suc n" and j: "j < Suc n"
  shows "bij_betw (permutation_insert i j q) {0..<Suc n} {0..<Suc n}"
    (is "bij_betw ?q ?N _")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bij_betw (permutation_insert i j q) {0..<Suc n} {0..<Suc n}
[PROOF STEP]
proof (rule bij_betw_imageI)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. inj_on (permutation_insert i j q) {0..<Suc n}
 2. permutation_insert i j q ` {0..<Suc n} = {0..<Suc n}
[PROOF STEP]
have img: "q ` {0..<n} = {0..<n}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. q ` {0..<n} = {0..<n}
[PROOF STEP]
using permutes_image[OF q]
[PROOF STATE]
proof (prove)
using this:
q ` {0..<n} = {0..<n}

goal (1 subgoal):
 1. q ` {0..<n} = {0..<n}
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
q ` {0..<n} = {0..<n}

goal (2 subgoals):
 1. inj_on (permutation_insert i j q) {0..<Suc n}
 2. permutation_insert i j q ` {0..<Suc n} = {0..<Suc n}
[PROOF STEP]
show "?q ` ?N = ?N"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. permutation_insert i j q ` {0..<Suc n} = {0..<Suc n}
[PROOF STEP]
unfolding permutation_insert_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. insert_dom (insert_ran q j) i j ` {0..<Suc n} = {0..<Suc n}
[PROOF STEP]
using insert_dom_image[OF i j insert_ran_image[OF j permutes_image[OF q]]]
[PROOF STATE]
proof (prove)
using this:
insert_dom (insert_ran q j) i j ` {0..<Suc n} = {0..<Suc n}

goal (1 subgoal):
 1. insert_dom (insert_ran q j) i j ` {0..<Suc n} = {0..<Suc n}
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
permutation_insert i j q ` {0..<Suc n} = {0..<Suc n}

goal (1 subgoal):
 1. inj_on (permutation_insert i j q) {0..<Suc n}
[PROOF STEP]
have inj: "inj_on q {0..<n}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inj_on q {0..<n}
[PROOF STEP]
apply(rule subset_inj_on)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. inj_on q ?B
 2. {0..<n} \<subseteq> ?B
[PROOF STEP]
using permutes_inj[OF q]
[PROOF STATE]
proof (prove)
using this:
inj q

goal (2 subgoals):
 1. inj_on q ?B
 2. {0..<n} \<subseteq> ?B
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
inj_on q {0..<n}

goal (1 subgoal):
 1. inj_on (permutation_insert i j q) {0..<Suc n}
[PROOF STEP]
show "inj_on ?q ?N"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inj_on (permutation_insert i j q) {0..<Suc n}
[PROOF STEP]
unfolding permutation_insert_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inj_on (insert_dom (insert_ran q j) i j) {0..<Suc n}
[PROOF STEP]
using insert_dom_inj_on[OF _ i j]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>inj_on ?f {0..<n}; ?f ` {0..<n} = {0..<Suc n} - {j}\<rbrakk> \<Longrightarrow> inj_on (insert_dom ?f i j) {0..<Suc n}

goal (1 subgoal):
 1. inj_on (insert_dom (insert_ran q j) i j) {0..<Suc n}
[PROOF STEP]
using insert_ran_inj_on[OF inj j] insert_ran_image[OF j img]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>inj_on ?f {0..<n}; ?f ` {0..<n} = {0..<Suc n} - {j}\<rbrakk> \<Longrightarrow> inj_on (insert_dom ?f i j) {0..<Suc n}
inj_on (insert_ran q j) {0..<n}
insert_ran q j ` {0..<n} = {0..<Suc n} - {j}

goal (1 subgoal):
 1. inj_on (insert_dom (insert_ran q j) i j) {0..<Suc n}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
inj_on (permutation_insert i j q) {0..<Suc n}

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma bound_Cauchy_to_lim:
  assumes \<open>y \<longlonglongrightarrow> x\<close> and \<open>\<And>n. \<parallel>y (Suc n) - y n\<parallel> \<le> c^n\<close> and \<open>y 0 = 0\<close> and \<open>c < 1\<close>
  shows \<open>\<parallel>x - y (Suc n)\<parallel> \<le> (c / (1 - c)) * c ^ n\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<parallel>x - y (Suc n)\<parallel> \<le> c / (1 - c) * c ^ n
[PROOF STEP]
text\<open>
  Inequality about a sequence of approximations assuming that the sequence of differences is bounded
  by a geometric progression.
  Explanation: Let \<^term>\<open>y\<close> be a sequence converging to \<^term>\<open>x\<close>.
  If \<^term>\<open>y\<close> satisfies the inequality \<open>\<parallel>y (Suc n) - y n\<parallel> \<le> c ^ n\<close> for some \<^term>\<open>c < 1\<close> and
  assuming \<^term>\<open>y 0 = 0\<close> then the inequality \<open>\<parallel>x - y (Suc n)\<parallel> \<le> (c / (1 - c)) * c ^ n\<close> holds.
\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<parallel>x - y (Suc n)\<parallel> \<le> c / (1 - c) * c ^ n
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<parallel>x - y (Suc n)\<parallel> \<le> c / (1 - c) * c ^ n
[PROOF STEP]
have \<open>c \<ge> 0\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 \<le> c
[PROOF STEP]
using \<open>\<And> n. \<parallel>y (Suc n) - y n\<parallel> \<le> c^n\<close>
[PROOF STATE]
proof (prove)
using this:
\<parallel>y (Suc ?n) - y ?n\<parallel> \<le> c ^ ?n

goal (1 subgoal):
 1. 0 \<le> c
[PROOF STEP]
by (smt norm_imp_pos_and_ge power_Suc0_right)
[PROOF STATE]
proof (state)
this:
0 \<le> c

goal (1 subgoal):
 1. \<parallel>x - y (Suc n)\<parallel> \<le> c / (1 - c) * c ^ n
[PROOF STEP]
have norm_1: \<open>norm (\<Sum>k = Suc n..N. y (Suc k) - y k) \<le> (c ^ Suc n)/(1 - c)\<close> for N
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<parallel>\<Sum>k = Suc n..N. y (Suc k) - y k\<parallel> \<le> c ^ Suc n / (1 - c)
[PROOF STEP]
proof(cases \<open>N < Suc n\<close>)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. N < Suc n \<Longrightarrow> \<parallel>\<Sum>k = Suc n..N. y (Suc k) - y k\<parallel> \<le> c ^ Suc n / (1 - c)
 2. \<not> N < Suc n \<Longrightarrow> \<parallel>\<Sum>k = Suc n..N. y (Suc k) - y k\<parallel> \<le> c ^ Suc n / (1 - c)
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
N < Suc n

goal (2 subgoals):
 1. N < Suc n \<Longrightarrow> \<parallel>\<Sum>k = Suc n..N. y (Suc k) - y k\<parallel> \<le> c ^ Suc n / (1 - c)
 2. \<not> N < Suc n \<Longrightarrow> \<parallel>\<Sum>k = Suc n..N. y (Suc k) - y k\<parallel> \<le> c ^ Suc n / (1 - c)
[PROOF STEP]
hence \<open>\<parallel>sum (\<lambda>k. y (Suc k) - y k) {Suc n .. N}\<parallel> = 0\<close>
[PROOF STATE]
proof (prove)
using this:
N < Suc n

goal (1 subgoal):
 1. \<parallel>\<Sum>k = Suc n..N. y (Suc k) - y k\<parallel> = 0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<parallel>\<Sum>k = Suc n..N. y (Suc k) - y k\<parallel> = 0

goal (2 subgoals):
 1. N < Suc n \<Longrightarrow> \<parallel>\<Sum>k = Suc n..N. y (Suc k) - y k\<parallel> \<le> c ^ Suc n / (1 - c)
 2. \<not> N < Suc n \<Longrightarrow> \<parallel>\<Sum>k = Suc n..N. y (Suc k) - y k\<parallel> \<le> c ^ Suc n / (1 - c)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
\<parallel>\<Sum>k = Suc n..N. y (Suc k) - y k\<parallel> = 0

goal (1 subgoal):
 1. \<parallel>\<Sum>k = Suc n..N. y (Suc k) - y k\<parallel> \<le> c ^ Suc n / (1 - c)
[PROOF STEP]
using  \<open>c \<ge> 0\<close> \<open>c < 1\<close>
[PROOF STATE]
proof (prove)
using this:
\<parallel>\<Sum>k = Suc n..N. y (Suc k) - y k\<parallel> = 0
0 \<le> c
c < 1

goal (1 subgoal):
 1. \<parallel>\<Sum>k = Suc n..N. y (Suc k) - y k\<parallel> \<le> c ^ Suc n / (1 - c)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<parallel>\<Sum>k = Suc n..N. y (Suc k) - y k\<parallel> \<le> c ^ Suc n / (1 - c)

goal (1 subgoal):
 1. \<not> N < Suc n \<Longrightarrow> \<parallel>\<Sum>k = Suc n..N. y (Suc k) - y k\<parallel> \<le> c ^ Suc n / (1 - c)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> N < Suc n \<Longrightarrow> \<parallel>\<Sum>k = Suc n..N. y (Suc k) - y k\<parallel> \<le> c ^ Suc n / (1 - c)
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> N < Suc n

goal (1 subgoal):
 1. \<not> N < Suc n \<Longrightarrow> \<parallel>\<Sum>k = Suc n..N. y (Suc k) - y k\<parallel> \<le> c ^ Suc n / (1 - c)
[PROOF STEP]
hence \<open>N \<ge> Suc n\<close>
[PROOF STATE]
proof (prove)
using this:
\<not> N < Suc n

goal (1 subgoal):
 1. Suc n \<le> N
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
Suc n \<le> N

goal (1 subgoal):
 1. \<not> N < Suc n \<Longrightarrow> \<parallel>\<Sum>k = Suc n..N. y (Suc k) - y k\<parallel> \<le> c ^ Suc n / (1 - c)
[PROOF STEP]
have \<open>c^(Suc N) \<ge> 0\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 \<le> c ^ Suc N
[PROOF STEP]
using \<open>c \<ge> 0\<close>
[PROOF STATE]
proof (prove)
using this:
0 \<le> c

goal (1 subgoal):
 1. 0 \<le> c ^ Suc N
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
0 \<le> c ^ Suc N

goal (1 subgoal):
 1. \<not> N < Suc n \<Longrightarrow> \<parallel>\<Sum>k = Suc n..N. y (Suc k) - y k\<parallel> \<le> c ^ Suc n / (1 - c)
[PROOF STEP]
have \<open>1 - c > 0\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < 1 - c
[PROOF STEP]
by (simp add: \<open>c < 1\<close>)
[PROOF STATE]
proof (state)
this:
0 < 1 - c

goal (1 subgoal):
 1. \<not> N < Suc n \<Longrightarrow> \<parallel>\<Sum>k = Suc n..N. y (Suc k) - y k\<parallel> \<le> c ^ Suc n / (1 - c)
[PROOF STEP]
hence \<open>(1 - c)/(1 - c) = 1\<close>
[PROOF STATE]
proof (prove)
using this:
0 < 1 - c

goal (1 subgoal):
 1. (1 - c) / (1 - c) = 1
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(1 - c) / (1 - c) = 1

goal (1 subgoal):
 1. \<not> N < Suc n \<Longrightarrow> \<parallel>\<Sum>k = Suc n..N. y (Suc k) - y k\<parallel> \<le> c ^ Suc n / (1 - c)
[PROOF STEP]
have \<open>\<parallel>sum (\<lambda>k. y (Suc k) - y k) {Suc n .. N}\<parallel> \<le> (sum (\<lambda>k. \<parallel>y (Suc k) - y k\<parallel>) {Suc n .. N})\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<parallel>\<Sum>k = Suc n..N. y (Suc k) - y k\<parallel> \<le> (\<Sum>k = Suc n..N. \<parallel>y (Suc k) - y k\<parallel>)
[PROOF STEP]
by (simp add: sum_norm_le)
[PROOF STATE]
proof (state)
this:
\<parallel>\<Sum>k = Suc n..N. y (Suc k) - y k\<parallel> \<le> (\<Sum>k = Suc n..N. \<parallel>y (Suc k) - y k\<parallel>)

goal (1 subgoal):
 1. \<not> N < Suc n \<Longrightarrow> \<parallel>\<Sum>k = Suc n..N. y (Suc k) - y k\<parallel> \<le> c ^ Suc n / (1 - c)
[PROOF STEP]
hence \<open>\<parallel>sum (\<lambda>k. y (Suc k) - y k) {Suc n .. N}\<parallel> \<le> (sum (power c) {Suc n .. N})\<close>
[PROOF STATE]
proof (prove)
using this:
\<parallel>\<Sum>k = Suc n..N. y (Suc k) - y k\<parallel> \<le> (\<Sum>k = Suc n..N. \<parallel>y (Suc k) - y k\<parallel>)

goal (1 subgoal):
 1. \<parallel>\<Sum>k = Suc n..N. y (Suc k) - y k\<parallel> \<le> sum ((^) c) {Suc n..N}
[PROOF STEP]
by (simp add: assms(2) sum_norm_le)
[PROOF STATE]
proof (state)
this:
\<parallel>\<Sum>k = Suc n..N. y (Suc k) - y k\<parallel> \<le> sum ((^) c) {Suc n..N}

goal (1 subgoal):
 1. \<not> N < Suc n \<Longrightarrow> \<parallel>\<Sum>k = Suc n..N. y (Suc k) - y k\<parallel> \<le> c ^ Suc n / (1 - c)
[PROOF STEP]
hence \<open>(1 - c) * \<parallel>sum (\<lambda>k. y (Suc k) - y k) {Suc n .. N}\<parallel>
                   \<le> (1 - c) * (sum (power c) {Suc n .. N})\<close>
[PROOF STATE]
proof (prove)
using this:
\<parallel>\<Sum>k = Suc n..N. y (Suc k) - y k\<parallel> \<le> sum ((^) c) {Suc n..N}

goal (1 subgoal):
 1. (1 - c) * \<parallel>\<Sum>k = Suc n..N. y (Suc k) - y k\<parallel> \<le> (1 - c) * sum ((^) c) {Suc n..N}
[PROOF STEP]
using \<open>0 < 1 - c\<close> mult_le_cancel_iff2
[PROOF STATE]
proof (prove)
using this:
\<parallel>\<Sum>k = Suc n..N. y (Suc k) - y k\<parallel> \<le> sum ((^) c) {Suc n..N}
0 < 1 - c
(0::?'a) < ?z \<Longrightarrow> (?z * ?x \<le> ?z * ?y) = (?x \<le> ?y)

goal (1 subgoal):
 1. (1 - c) * \<parallel>\<Sum>k = Suc n..N. y (Suc k) - y k\<parallel> \<le> (1 - c) * sum ((^) c) {Suc n..N}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
(1 - c) * \<parallel>\<Sum>k = Suc n..N. y (Suc k) - y k\<parallel> \<le> (1 - c) * sum ((^) c) {Suc n..N}

goal (1 subgoal):
 1. \<not> N < Suc n \<Longrightarrow> \<parallel>\<Sum>k = Suc n..N. y (Suc k) - y k\<parallel> \<le> c ^ Suc n / (1 - c)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(1 - c) * \<parallel>\<Sum>k = Suc n..N. y (Suc k) - y k\<parallel> \<le> (1 - c) * sum ((^) c) {Suc n..N}

goal (1 subgoal):
 1. \<not> N < Suc n \<Longrightarrow> \<parallel>\<Sum>k = Suc n..N. y (Suc k) - y k\<parallel> \<le> c ^ Suc n / (1 - c)
[PROOF STEP]
have \<open>\<dots> = c^(Suc n) - c^(Suc N)\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (1 - c) * sum ((^) c) {Suc n..N} = c ^ Suc n - c ^ Suc N
[PROOF STEP]
using Set_Interval.sum_gp_multiplied \<open>Suc n \<le> N\<close>
[PROOF STATE]
proof (prove)
using this:
?m \<le> ?n \<Longrightarrow> ((1::?'a) - ?x) * sum ((^) ?x) {?m..?n} = ?x ^ ?m - ?x ^ Suc ?n
Suc n \<le> N

goal (1 subgoal):
 1. (1 - c) * sum ((^) c) {Suc n..N} = c ^ Suc n - c ^ Suc N
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
(1 - c) * sum ((^) c) {Suc n..N} = c ^ Suc n - c ^ Suc N

goal (1 subgoal):
 1. \<not> N < Suc n \<Longrightarrow> \<parallel>\<Sum>k = Suc n..N. y (Suc k) - y k\<parallel> \<le> c ^ Suc n / (1 - c)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(1 - c) * sum ((^) c) {Suc n..N} = c ^ Suc n - c ^ Suc N

goal (1 subgoal):
 1. \<not> N < Suc n \<Longrightarrow> \<parallel>\<Sum>k = Suc n..N. y (Suc k) - y k\<parallel> \<le> c ^ Suc n / (1 - c)
[PROOF STEP]
have \<open>\<dots> \<le> c^(Suc n)\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. c ^ Suc n - c ^ Suc N \<le> c ^ Suc n
[PROOF STEP]
using \<open>c^(Suc N) \<ge> 0\<close>
[PROOF STATE]
proof (prove)
using this:
0 \<le> c ^ Suc N

goal (1 subgoal):
 1. c ^ Suc n - c ^ Suc N \<le> c ^ Suc n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
c ^ Suc n - c ^ Suc N \<le> c ^ Suc n

goal (1 subgoal):
 1. \<not> N < Suc n \<Longrightarrow> \<parallel>\<Sum>k = Suc n..N. y (Suc k) - y k\<parallel> \<le> c ^ Suc n / (1 - c)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(1 - c) * \<parallel>\<Sum>k = Suc n..N. y (Suc k) - y k\<parallel> \<le> c ^ Suc n
[PROOF STEP]
have \<open>(1 - c) * \<parallel>\<Sum>k = Suc n..N. y (Suc k) - y k\<parallel> \<le> c ^ Suc n\<close>
[PROOF STATE]
proof (prove)
using this:
(1 - c) * \<parallel>\<Sum>k = Suc n..N. y (Suc k) - y k\<parallel> \<le> c ^ Suc n

goal (1 subgoal):
 1. (1 - c) * \<parallel>\<Sum>k = Suc n..N. y (Suc k) - y k\<parallel> \<le> c ^ Suc n
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
(1 - c) * \<parallel>\<Sum>k = Suc n..N. y (Suc k) - y k\<parallel> \<le> c ^ Suc n

goal (1 subgoal):
 1. \<not> N < Suc n \<Longrightarrow> \<parallel>\<Sum>k = Suc n..N. y (Suc k) - y k\<parallel> \<le> c ^ Suc n / (1 - c)
[PROOF STEP]
hence \<open>((1 - c) * \<parallel>\<Sum>k = Suc n..N. y (Suc k) - y k\<parallel>)/(1 - c)
                   \<le> (c ^ Suc n)/(1 - c)\<close>
[PROOF STATE]
proof (prove)
using this:
(1 - c) * \<parallel>\<Sum>k = Suc n..N. y (Suc k) - y k\<parallel> \<le> c ^ Suc n

goal (1 subgoal):
 1. (1 - c) * \<parallel>\<Sum>k = Suc n..N. y (Suc k) - y k\<parallel> / (1 - c) \<le> c ^ Suc n / (1 - c)
[PROOF STEP]
using \<open>0 < 1 - c\<close>
[PROOF STATE]
proof (prove)
using this:
(1 - c) * \<parallel>\<Sum>k = Suc n..N. y (Suc k) - y k\<parallel> \<le> c ^ Suc n
0 < 1 - c

goal (1 subgoal):
 1. (1 - c) * \<parallel>\<Sum>k = Suc n..N. y (Suc k) - y k\<parallel> / (1 - c) \<le> c ^ Suc n / (1 - c)
[PROOF STEP]
by (smt divide_right_mono)
[PROOF STATE]
proof (state)
this:
(1 - c) * \<parallel>\<Sum>k = Suc n..N. y (Suc k) - y k\<parallel> / (1 - c) \<le> c ^ Suc n / (1 - c)

goal (1 subgoal):
 1. \<not> N < Suc n \<Longrightarrow> \<parallel>\<Sum>k = Suc n..N. y (Suc k) - y k\<parallel> \<le> c ^ Suc n / (1 - c)
[PROOF STEP]
thus \<open>\<parallel>\<Sum>k = Suc n..N. y (Suc k) - y k\<parallel> \<le> (c ^ Suc n)/(1 - c)\<close>
[PROOF STATE]
proof (prove)
using this:
(1 - c) * \<parallel>\<Sum>k = Suc n..N. y (Suc k) - y k\<parallel> / (1 - c) \<le> c ^ Suc n / (1 - c)

goal (1 subgoal):
 1. \<parallel>\<Sum>k = Suc n..N. y (Suc k) - y k\<parallel> \<le> c ^ Suc n / (1 - c)
[PROOF STEP]
using \<open>0 < 1 - c\<close>
[PROOF STATE]
proof (prove)
using this:
(1 - c) * \<parallel>\<Sum>k = Suc n..N. y (Suc k) - y k\<parallel> / (1 - c) \<le> c ^ Suc n / (1 - c)
0 < 1 - c

goal (1 subgoal):
 1. \<parallel>\<Sum>k = Suc n..N. y (Suc k) - y k\<parallel> \<le> c ^ Suc n / (1 - c)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<parallel>\<Sum>k = Suc n..N. y (Suc k) - y k\<parallel> \<le> c ^ Suc n / (1 - c)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<parallel>\<Sum>k = Suc n..?N. y (Suc k) - y k\<parallel> \<le> c ^ Suc n / (1 - c)

goal (1 subgoal):
 1. \<parallel>x - y (Suc n)\<parallel> \<le> c / (1 - c) * c ^ n
[PROOF STEP]
have \<open>(\<lambda> N. (sum (\<lambda>k. y (Suc k) - y k) {Suc n .. N})) \<longlonglongrightarrow> x - y (Suc n)\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>N. \<Sum>k = Suc n..N. y (Suc k) - y k) \<longlonglongrightarrow> x - y (Suc n)
[PROOF STEP]
by (metis (no_types) \<open>y \<longlonglongrightarrow> x\<close> identity_telescopic)
[PROOF STATE]
proof (state)
this:
(\<lambda>N. \<Sum>k = Suc n..N. y (Suc k) - y k) \<longlonglongrightarrow> x - y (Suc n)

goal (1 subgoal):
 1. \<parallel>x - y (Suc n)\<parallel> \<le> c / (1 - c) * c ^ n
[PROOF STEP]
hence \<open>(\<lambda> N. \<parallel>sum (\<lambda>k. y (Suc k) - y k) {Suc n .. N}\<parallel>) \<longlonglongrightarrow> \<parallel>x - y (Suc n)\<parallel>\<close>
[PROOF STATE]
proof (prove)
using this:
(\<lambda>N. \<Sum>k = Suc n..N. y (Suc k) - y k) \<longlonglongrightarrow> x - y (Suc n)

goal (1 subgoal):
 1. (\<lambda>N. \<parallel>\<Sum>k = Suc n..N. y (Suc k) - y k\<parallel>) \<longlonglongrightarrow> \<parallel>x - y (Suc n)\<parallel>
[PROOF STEP]
using tendsto_norm
[PROOF STATE]
proof (prove)
using this:
(\<lambda>N. \<Sum>k = Suc n..N. y (Suc k) - y k) \<longlonglongrightarrow> x - y (Suc n)
(?f \<longlongrightarrow> ?a) ?F \<Longrightarrow> ((\<lambda>x. \<parallel>?f x\<parallel>) \<longlongrightarrow> \<parallel>?a\<parallel>) ?F

goal (1 subgoal):
 1. (\<lambda>N. \<parallel>\<Sum>k = Suc n..N. y (Suc k) - y k\<parallel>) \<longlonglongrightarrow> \<parallel>x - y (Suc n)\<parallel>
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
(\<lambda>N. \<parallel>\<Sum>k = Suc n..N. y (Suc k) - y k\<parallel>) \<longlonglongrightarrow> \<parallel>x - y (Suc n)\<parallel>

goal (1 subgoal):
 1. \<parallel>x - y (Suc n)\<parallel> \<le> c / (1 - c) * c ^ n
[PROOF STEP]
hence \<open>\<parallel>x - y (Suc n)\<parallel> \<le> (c ^ Suc n)/(1 - c)\<close>
[PROOF STATE]
proof (prove)
using this:
(\<lambda>N. \<parallel>\<Sum>k = Suc n..N. y (Suc k) - y k\<parallel>) \<longlonglongrightarrow> \<parallel>x - y (Suc n)\<parallel>

goal (1 subgoal):
 1. \<parallel>x - y (Suc n)\<parallel> \<le> c ^ Suc n / (1 - c)
[PROOF STEP]
using norm_1 Lim_bounded
[PROOF STATE]
proof (prove)
using this:
(\<lambda>N. \<parallel>\<Sum>k = Suc n..N. y (Suc k) - y k\<parallel>) \<longlonglongrightarrow> \<parallel>x - y (Suc n)\<parallel>
\<parallel>\<Sum>k = Suc n..?N. y (Suc k) - y k\<parallel> \<le> c ^ Suc n / (1 - c)
\<lbrakk>?f \<longlonglongrightarrow> ?l; \<forall>n\<ge>?M. ?f n \<le> ?C\<rbrakk> \<Longrightarrow> ?l \<le> ?C

goal (1 subgoal):
 1. \<parallel>x - y (Suc n)\<parallel> \<le> c ^ Suc n / (1 - c)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
\<parallel>x - y (Suc n)\<parallel> \<le> c ^ Suc n / (1 - c)

goal (1 subgoal):
 1. \<parallel>x - y (Suc n)\<parallel> \<le> c / (1 - c) * c ^ n
[PROOF STEP]
hence  \<open>\<parallel>x - y (Suc n)\<parallel> \<le> (c ^ Suc n)/(1 - c)\<close>
[PROOF STATE]
proof (prove)
using this:
\<parallel>x - y (Suc n)\<parallel> \<le> c ^ Suc n / (1 - c)

goal (1 subgoal):
 1. \<parallel>x - y (Suc n)\<parallel> \<le> c ^ Suc n / (1 - c)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<parallel>x - y (Suc n)\<parallel> \<le> c ^ Suc n / (1 - c)

goal (1 subgoal):
 1. \<parallel>x - y (Suc n)\<parallel> \<le> c / (1 - c) * c ^ n
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
\<parallel>x - y (Suc n)\<parallel> \<le> c ^ Suc n / (1 - c)

goal (1 subgoal):
 1. \<parallel>x - y (Suc n)\<parallel> \<le> c / (1 - c) * c ^ n
[PROOF STEP]
have \<open>(c ^ Suc n)/(1 - c) = (c / (1 - c)) * (c ^ n)\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. c ^ Suc n / (1 - c) = c / (1 - c) * c ^ n
[PROOF STEP]
by (simp add: divide_inverse_commute)
[PROOF STATE]
proof (state)
this:
c ^ Suc n / (1 - c) = c / (1 - c) * c ^ n

goal (1 subgoal):
 1. \<parallel>x - y (Suc n)\<parallel> \<le> c / (1 - c) * c ^ n
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
\<parallel>x - y (Suc n)\<parallel> \<le> c ^ Suc n / (1 - c)
c ^ Suc n / (1 - c) = c / (1 - c) * c ^ n
[PROOF STEP]
show \<open>\<parallel>x - y (Suc n)\<parallel> \<le> (c / (1 - c)) * (c ^ n)\<close>
[PROOF STATE]
proof (prove)
using this:
\<parallel>x - y (Suc n)\<parallel> \<le> c ^ Suc n / (1 - c)
c ^ Suc n / (1 - c) = c / (1 - c) * c ^ n

goal (1 subgoal):
 1. \<parallel>x - y (Suc n)\<parallel> \<le> c / (1 - c) * c ^ n
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
\<parallel>x - y (Suc n)\<parallel> \<le> c / (1 - c) * c ^ n

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma L_mono: "S1 \<subseteq> S2 \<Longrightarrow> L S1 \<subseteq> L S2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. S1 \<subseteq> S2 \<Longrightarrow> L S1 \<subseteq> L S2
[PROOF STEP]
apply(simp)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. S1 \<subseteq> S2 \<Longrightarrow> \<Union> (lang ` S1) \<subseteq> \<Union> (lang ` S2)
[PROOF STEP]
by blast


[STATEMENT]
lemma c_f_list_at_Suc: "c_f_list f (Suc y) x = c_cons (f (Suc y) x) (c_f_list f y x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. c_f_list f (Suc y) x = c_cons (f (Suc y) x) (c_f_list f y x)
[PROOF STEP]
by ((simp add: c_f_list_def Let_def))


[STATEMENT]
lemma fun_sum_commute:
  assumes "f 0 = 0" and "\<And>x y. f (x + y) = f x + f y"
  shows "f (sum g A) = (\<Sum>a\<in>A. f (g a))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f (sum g A) = (\<Sum>a\<in>A. f (g a))
[PROOF STEP]
proof (cases "finite A")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. finite A \<Longrightarrow> f (sum g A) = (\<Sum>a\<in>A. f (g a))
 2. infinite A \<Longrightarrow> f (sum g A) = (\<Sum>a\<in>A. f (g a))
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
finite A

goal (2 subgoals):
 1. finite A \<Longrightarrow> f (sum g A) = (\<Sum>a\<in>A. f (g a))
 2. infinite A \<Longrightarrow> f (sum g A) = (\<Sum>a\<in>A. f (g a))
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
finite A

goal (1 subgoal):
 1. f (sum g A) = (\<Sum>a\<in>A. f (g a))
[PROOF STEP]
proof (induct A)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. f (sum g {}) = (\<Sum>a\<in>{}. f (g a))
 2. \<And>x F. \<lbrakk>finite F; x \<notin> F; f (sum g F) = (\<Sum>a\<in>F. f (g a))\<rbrakk> \<Longrightarrow> f (sum g (insert x F)) = (\<Sum>a\<in>insert x F. f (g a))
[PROOF STEP]
case empty
[PROOF STATE]
proof (state)
this:

goal (2 subgoals):
 1. f (sum g {}) = (\<Sum>a\<in>{}. f (g a))
 2. \<And>x F. \<lbrakk>finite F; x \<notin> F; f (sum g F) = (\<Sum>a\<in>F. f (g a))\<rbrakk> \<Longrightarrow> f (sum g (insert x F)) = (\<Sum>a\<in>insert x F. f (g a))
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f (sum g {}) = (\<Sum>a\<in>{}. f (g a))
[PROOF STEP]
by (simp add: assms(1))
[PROOF STATE]
proof (state)
this:
f (sum g {}) = (\<Sum>a\<in>{}. f (g a))

goal (1 subgoal):
 1. \<And>x F. \<lbrakk>finite F; x \<notin> F; f (sum g F) = (\<Sum>a\<in>F. f (g a))\<rbrakk> \<Longrightarrow> f (sum g (insert x F)) = (\<Sum>a\<in>insert x F. f (g a))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x F. \<lbrakk>finite F; x \<notin> F; f (sum g F) = (\<Sum>a\<in>F. f (g a))\<rbrakk> \<Longrightarrow> f (sum g (insert x F)) = (\<Sum>a\<in>insert x F. f (g a))
[PROOF STEP]
case step: (insert a A)
[PROOF STATE]
proof (state)
this:
finite A
a \<notin> A
f (sum g A) = (\<Sum>a\<in>A. f (g a))

goal (1 subgoal):
 1. \<And>x F. \<lbrakk>finite F; x \<notin> F; f (sum g F) = (\<Sum>a\<in>F. f (g a))\<rbrakk> \<Longrightarrow> f (sum g (insert x F)) = (\<Sum>a\<in>insert x F. f (g a))
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f (sum g (insert a A)) = (\<Sum>a\<in>insert a A. f (g a))
[PROOF STEP]
by (simp add: sum.insert[OF step(1) step(2)] assms(2) step(3))
[PROOF STATE]
proof (state)
this:
f (sum g (insert a A)) = (\<Sum>a\<in>insert a A. f (g a))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
f (sum g A) = (\<Sum>a\<in>A. f (g a))

goal (1 subgoal):
 1. infinite A \<Longrightarrow> f (sum g A) = (\<Sum>a\<in>A. f (g a))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. infinite A \<Longrightarrow> f (sum g A) = (\<Sum>a\<in>A. f (g a))
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
infinite A

goal (1 subgoal):
 1. infinite A \<Longrightarrow> f (sum g A) = (\<Sum>a\<in>A. f (g a))
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
infinite A

goal (1 subgoal):
 1. f (sum g A) = (\<Sum>a\<in>A. f (g a))
[PROOF STEP]
by (simp add: assms(1))
[PROOF STATE]
proof (state)
this:
f (sum g A) = (\<Sum>a\<in>A. f (g a))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma sets_sup_measure_F:
  "finite I \<Longrightarrow> I \<noteq> {} \<Longrightarrow> (\<And>i. i \<in> I \<Longrightarrow> sets i = sets M) \<Longrightarrow> sets (sup_measure.F id I) = sets M"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>finite I; I \<noteq> {}; \<And>i. i \<in> I \<Longrightarrow> sets i = sets M\<rbrakk> \<Longrightarrow> sets (sup_measure.F id I) = sets M
[PROOF STEP]
by (induction I rule: finite_ne_induct) (simp_all add: sets_sup)


[STATEMENT]
lemma tensor_unpack_bound2[simp]: "i < A * B \<Longrightarrow> snd (tensor_unpack A B i) < B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. i < A * B \<Longrightarrow> snd (tensor_unpack A B i) < B
[PROOF STEP]
unfolding tensor_unpack_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. i < A * B \<Longrightarrow> snd (i div B, i mod B) < B
[PROOF STEP]
apply auto
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. i < A * B \<Longrightarrow> i mod B < B
[PROOF STEP]
by (metis mod_less_divisor mult.commute mult_zero_left nat_neq_iff not_less0)


[STATEMENT]
lemma (in complete_lattice) Sup_set_fold:
  "Sup (set xs) = fold sup xs bot"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<Squnion> set xs = fold (\<squnion>) xs \<bottom>
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<Squnion> set xs = fold (\<squnion>) xs \<bottom>
[PROOF STEP]
interpret comp_fun_idem "sup :: 'a \<Rightarrow> 'a \<Rightarrow> 'a"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. comp_fun_idem (\<squnion>)
[PROOF STEP]
by (fact comp_fun_idem_sup)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<Squnion> set xs = fold (\<squnion>) xs \<bottom>
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<Squnion> set xs = fold (\<squnion>) xs \<bottom>
[PROOF STEP]
by (simp add: Sup_fold_sup fold_set_fold sup_commute)
[PROOF STATE]
proof (state)
this:
\<Squnion> set xs = fold (\<squnion>) xs \<bottom>

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma reflexive_linorder_matrix_1:
  fixes f :: "('a::finite,'b::linorder_stone_relation_algebra_expansion) square"
  assumes "matrix_idempotent_semiring.reflexive f"
    shows "f (i,i) = top"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f (i, i) = top
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. f (i, i) = top
[PROOF STEP]
have "(top::'b) = mone (i,i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. top = mone (i, i)
[PROOF STEP]
by (simp add: one_matrix_def)
[PROOF STATE]
proof (state)
this:
top = mone (i, i)

goal (1 subgoal):
 1. f (i, i) = top
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
top = mone (i, i)

goal (1 subgoal):
 1. f (i, i) = top
[PROOF STEP]
have "... \<le> f (i,i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mone (i, i) \<le> f (i, i)
[PROOF STEP]
using assms less_eq_matrix_def
[PROOF STATE]
proof (prove)
using this:
matrix_idempotent_semiring.reflexive f
(?f \<preceq> ?g) = (\<forall>e. ?f e \<le> ?g e)

goal (1 subgoal):
 1. mone (i, i) \<le> f (i, i)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
mone (i, i) \<le> f (i, i)

goal (1 subgoal):
 1. f (i, i) = top
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
comp_inf.reflexive (f (i, i))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
comp_inf.reflexive (f (i, i))

goal (1 subgoal):
 1. f (i, i) = top
[PROOF STEP]
by (simp add: top.extremum_unique)
[PROOF STATE]
proof (state)
this:
f (i, i) = top

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
theorem weak_equivalence_implies_weak_bisimilarity: assumes "P \<equiv>\<cdot> Q" shows "P \<approx>\<cdot> Q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. P \<approx>\<cdot> Q
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
P \<equiv>\<cdot> Q

goal (1 subgoal):
 1. P \<approx>\<cdot> Q
[PROOF STEP]
by (metis weakly_bisimilar_def weak_equivalence_is_weak_bisimulation)


[STATEMENT]
lemma dX_range:
  shows "\<forall>d. dX X d \<subseteq> {x. Xd x = d}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>d. dX X d \<subseteq> {x. Xd x = d}
[PROOF STEP]
unfolding dX_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>d. {x \<in> X. Xd x = d} \<subseteq> {x. Xd x = d}
[PROOF STEP]
by clarsimp


[STATEMENT]
lemma ord_embed_inj: "ord_embed f \<Longrightarrow> inj f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ord_embed f \<Longrightarrow> inj f
[PROOF STEP]
unfolding ord_embed_def inj_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>x y. (f x \<le> f y) = (x \<le> y) \<Longrightarrow> \<forall>x y. f x = f y \<longrightarrow> x = y
[PROOF STEP]
by (simp add: eq_iff)


[STATEMENT]
lemma derives1_is_word_is_prefix_drop:
  assumes w: "is_word w"
  assumes w_a: "is_prefix w a"
  assumes ab: "derives1 a b"
  shows "derives1 (drop (length w) a) (drop (length w) b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. derives1 (drop (length w) a) (drop (length w) b)
[PROOF STEP]
by (metis ab append_take_drop_id derives1_drop_prefixword take_prefix w w_a)


[STATEMENT]
lemma Join_increasing [simp]:
     "(F\<squnion>G \<in> increasing f) =
      (F \<in> increasing f & G \<in> increasing f)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (F \<squnion> G \<in> increasing f) = (F \<in> increasing f \<and> G \<in> increasing f)
[PROOF STEP]
by (auto simp add: increasing_def)


[STATEMENT]
lemma flow_avoids_surface_eventually_at_right_neg:
  assumes "s x < 0 \<or> s x = 0 \<and> blinfun_apply (Ds x) (f x) < 0"
  assumes x: "x \<in> X"
  assumes Ds: "\<And>x. (s has_derivative Ds x) (at x)"
  assumes DsC: "\<And>x. isCont Ds x"
  shows "\<forall>\<^sub>F t in at_right 0. s (flow0 x t) < (0::real)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>\<^sub>F t in at_right 0. s (flow0 x t) < 0
[PROOF STEP]
apply (rule flow_avoids_surface_eventually_at_right_pos[of "-s" x "-Ds", simplified])
[PROOF STATE]
proof (prove)
goal (4 subgoals):
 1. s x < 0 \<or> s x = 0 \<and> 0 < blinfun_apply (- Ds x) (f x)
 2. x \<in> X
 3. \<And>x. (- s has_derivative blinfun_apply (- Ds x)) (at x)
 4. \<And>x. isCont (- Ds) x
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
s x < 0 \<or> s x = 0 \<and> blinfun_apply (Ds x) (f x) < 0
x \<in> X
(s has_derivative blinfun_apply (Ds ?x)) (at ?x)
isCont Ds ?x

goal (4 subgoals):
 1. s x < 0 \<or> s x = 0 \<and> 0 < blinfun_apply (- Ds x) (f x)
 2. x \<in> X
 3. \<And>x. (- s has_derivative blinfun_apply (- Ds x)) (at x)
 4. \<And>x. isCont (- Ds) x
[PROOF STEP]
by (auto intro!: derivative_eq_intros simp: blinfun.bilinear_simps fun_Compl_def)


[STATEMENT]
lemma double_dual_iso_eq_iff [simp]:
  "x \<in> carrier G \<Longrightarrow> y \<in> carrier G \<Longrightarrow> double_dual_iso x = double_dual_iso y \<longleftrightarrow> x = y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>x \<in> carrier G; y \<in> carrier G\<rbrakk> \<Longrightarrow> (double_dual_iso x = double_dual_iso y) = (x = y)
[PROOF STEP]
by (auto dest: inj_onD[OF inj_double_dual_iso])


[STATEMENT]
lemma bv_leqs_antisym:"\<lbrakk>xs \<preceq>\<^sub>b ys; ys \<preceq>\<^sub>b xs\<rbrakk> \<Longrightarrow> xs = ys"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>xs \<preceq>\<^sub>b ys; ys \<preceq>\<^sub>b xs\<rbrakk> \<Longrightarrow> xs = ys
[PROOF STEP]
by(induct xs ys rule:bv_leqs.induct)auto


[STATEMENT]
lemma functionEquivalenceOnSets:
  assumes "\<forall>x \<in> X. f x = g x"
  shows "f`X = g`X"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f ` X = g ` X
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
\<forall>x\<in>X. f x = g x

goal (1 subgoal):
 1. f ` X = g ` X
[PROOF STEP]
by (metis image_cong)


[STATEMENT]
lemma news_compl: \<open>news n G \<Longrightarrow> news n (map compl G)\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. news n G \<Longrightarrow> news n (map compl G)
[PROOF STEP]
using new_compl
[PROOF STATE]
proof (prove)
using this:
new ?n ?p \<Longrightarrow> new ?n (compl ?p)

goal (1 subgoal):
 1. news n G \<Longrightarrow> news n (map compl G)
[PROOF STEP]
by (induct G) fastforce+


[STATEMENT]
lemma sin_of_real_pi [simp]: "sin (of_real pi) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sin (of_real pi) = (0::'a)
[PROOF STEP]
using sin_add [where x = "pi/2" and y = "pi/2"]
[PROOF STATE]
proof (prove)
using this:
sin (pi / 2 + pi / 2) = sin (pi / 2) * cos (pi / 2) + cos (pi / 2) * sin (pi / 2)

goal (1 subgoal):
 1. sin (of_real pi) = (0::'a)
[PROOF STEP]
by (simp add: sin_of_real)


[STATEMENT]
lemma add_rat [simp]:
  assumes "b \<noteq> 0" and "d \<noteq> 0"
  shows "Fract a b + Fract c d = Fract (a * d + c * b) (b * d)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Fract a b + Fract c d = Fract (a * d + c * b) (b * d)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
b \<noteq> 0
d \<noteq> 0

goal (1 subgoal):
 1. Fract a b + Fract c d = Fract (a * d + c * b) (b * d)
[PROOF STEP]
by transfer simp


[STATEMENT]
lemma atc_to_io_set_code :
  assumes "acyclic A"
  shows "atc_to_io_set M A = acyclic_language_intersection M A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. atc_to_io_set M A = acyclic_language_intersection M A
[PROOF STEP]
using acyclic_language_intersection_completeness[OF assms]
[PROOF STATE]
proof (prove)
using this:
acyclic_language_intersection ?M A = L ?M \<inter> L A

goal (1 subgoal):
 1. atc_to_io_set M A = acyclic_language_intersection M A
[PROOF STEP]
unfolding atc_to_io_set.simps
[PROOF STATE]
proof (prove)
using this:
acyclic_language_intersection ?M A = L ?M \<inter> L A

goal (1 subgoal):
 1. L M \<inter> L A = acyclic_language_intersection M A
[PROOF STEP]
by blast


[STATEMENT]
lemma vars_resultant: "vars (resultant p q) \<subseteq> \<Union> (vars ` (range (coeff p) \<union> range (coeff q)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vars (resultant p q) \<subseteq> \<Union> (vars ` (range (coeff p) \<union> range (coeff q)))
[PROOF STEP]
unfolding resultant_def det_def sylvester_mat_def sylvester_mat_sub_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vars (if dim_row (mat (degree p + degree q) (degree p + degree q) (\<lambda>(i, j). if i < degree q then if i \<le> j \<and> j - i \<le> degree p then coeff p (degree p + i - j) else 0 else if i - degree q \<le> j \<and> j \<le> i then coeff q (i - j) else 0)) = dim_col (mat (degree p + degree q) (degree p + degree q) (\<lambda>(i, j). if i < degree q then if i \<le> j \<and> j - i \<le> degree p then coeff p (degree p + i - j) else 0 else if i - degree q \<le> j \<and> j \<le> i then coeff q (i - j) else 0)) then \<Sum>p | p permutes {0..<dim_row (mat (degree p + degree q) (degree p + degree q) (\<lambda>(i, j). if i < degree q then if i \<le> j \<and> j - i \<le> degree p then coeff p (degree p + i - j) else 0 else if i - degree q \<le> j \<and> j \<le> i then coeff q (i - j) else 0))}. of_int (sign p) * (\<Prod>i = 0..<dim_row (mat (degree p + degree q) (degree p + degree q) (\<lambda>(i, j). if i < degree q then if i \<le> j \<and> j - i \<le> degree p then coeff p (degree p + i - j) else 0 else if i - degree q \<le> j \<and> j \<le> i then coeff q (i - j) else 0)). mat (degree p + degree q) (degree p + degree q) (\<lambda>(i, j). if i < degree q then if i \<le> j \<and> j - i \<le> degree p then coeff p (degree p + i - j) else 0 else if i - degree q \<le> j \<and> j \<le> i then coeff q (i - j) else 0) $$ (i, p i)) else 0) \<subseteq> \<Union> (vars ` (range (coeff p) \<union> range (coeff q)))
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vars (\<Sum>p | p permutes {0..<degree p + degree q}. of_int (sign p) * (\<Prod>i = 0..<degree p + degree q. if i < degree q then if i \<le> p i \<and> p i - i \<le> degree p then coeff p (degree p + i - p i) else 0 else if i - degree q \<le> p i \<and> p i \<le> i then coeff q (i - p i) else 0)) \<subseteq> (\<Union>a. vars (coeff p a)) \<union> (\<Union>a. vars (coeff q a))
[PROOF STEP]
apply (rule order.trans[OF vars_setsum])
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. finite {pa. pa permutes {0..<degree p + degree q}}
 2. (\<Union>pa\<in>{pa. pa permutes {0..<degree p + degree q}}. vars (of_int (sign pa) * (\<Prod>i = 0..<degree p + degree q. if i < degree q then if i \<le> pa i \<and> pa i - i \<le> degree p then coeff p (degree p + i - pa i) else 0 else if i - degree q \<le> pa i \<and> pa i \<le> i then coeff q (i - pa i) else 0))) \<subseteq> (\<Union>a. vars (coeff p a)) \<union> (\<Union>a. vars (coeff q a))
[PROOF STEP]
subgoal
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite {pa. pa permutes {0..<degree p + degree q}}
[PROOF STEP]
using finite_permutations
[PROOF STATE]
proof (prove)
using this:
finite ?S \<Longrightarrow> finite {p. p permutes ?S}

goal (1 subgoal):
 1. finite {pa. pa permutes {0..<degree p + degree q}}
[PROOF STEP]
by blast
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Union>pa\<in>{pa. pa permutes {0..<degree p + degree q}}. vars (of_int (sign pa) * (\<Prod>i = 0..<degree p + degree q. if i < degree q then if i \<le> pa i \<and> pa i - i \<le> degree p then coeff p (degree p + i - pa i) else 0 else if i - degree q \<le> pa i \<and> pa i \<le> i then coeff q (i - pa i) else 0))) \<subseteq> (\<Union>a. vars (coeff p a)) \<union> (\<Union>a. vars (coeff q a))
[PROOF STEP]
apply (rule UN_least)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>pa. pa \<in> {pa. pa permutes {0..<degree p + degree q}} \<Longrightarrow> vars (of_int (sign pa) * (\<Prod>i = 0..<degree p + degree q. if i < degree q then if i \<le> pa i \<and> pa i - i \<le> degree p then coeff p (degree p + i - pa i) else 0 else if i - degree q \<le> pa i \<and> pa i \<le> i then coeff q (i - pa i) else 0)) \<subseteq> (\<Union>a. vars (coeff p a)) \<union> (\<Union>a. vars (coeff q a))
[PROOF STEP]
apply (rule order.trans[OF vars_mult])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>pa. pa \<in> {pa. pa permutes {0..<degree p + degree q}} \<Longrightarrow> vars (of_int (sign pa)) \<union> vars (\<Prod>i = 0..<degree p + degree q. if i < degree q then if i \<le> pa i \<and> pa i - i \<le> degree p then coeff p (degree p + i - pa i) else 0 else if i - degree q \<le> pa i \<and> pa i \<le> i then coeff q (i - pa i) else 0) \<subseteq> (\<Union>a. vars (coeff p a)) \<union> (\<Union>a. vars (coeff q a))
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>pa. pa permutes {0..<degree p + degree q} \<Longrightarrow> vars (\<Prod>i = 0..<degree p + degree q. if i < degree q then if i \<le> pa i \<and> pa i - i \<le> degree p then coeff p (degree p + i - pa i) else 0 else if i - degree q \<le> pa i \<and> pa i \<le> i then coeff q (i - pa i) else 0) \<subseteq> (\<Union>a. vars (coeff p a)) \<union> (\<Union>a. vars (coeff q a))
[PROOF STEP]
apply (rule order.trans[OF vars_prod])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>pa. pa permutes {0..<degree p + degree q} \<Longrightarrow> (\<Union>x\<in>{0..<degree p + degree q}. vars (if x < degree q then if x \<le> pa x \<and> pa x - x \<le> degree p then coeff p (degree p + x - pa x) else 0 else if x - degree q \<le> pa x \<and> pa x \<le> x then coeff q (x - pa x) else 0)) \<subseteq> (\<Union>a. vars (coeff p a)) \<union> (\<Union>a. vars (coeff q a))
[PROOF STEP]
apply (rule UN_least)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>pa x. \<lbrakk>pa permutes {0..<degree p + degree q}; x \<in> {0..<degree p + degree q}\<rbrakk> \<Longrightarrow> vars (if x < degree q then if x \<le> pa x \<and> pa x - x \<le> degree p then coeff p (degree p + x - pa x) else 0 else if x - degree q \<le> pa x \<and> pa x \<le> x then coeff q (x - pa x) else 0) \<subseteq> (\<Union>a. vars (coeff p a)) \<union> (\<Union>a. vars (coeff q a))
[PROOF STEP]
by auto


[STATEMENT]
lemma D_gt_1: "D > 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 < D
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. 1 < D
[PROOF STEP]
from nonsquare_D
[PROOF STATE]
proof (chain)
picking this:
\<not> is_square D
[PROOF STEP]
have "D \<noteq> 0" "D \<noteq> 1"
[PROOF STATE]
proof (prove)
using this:
\<not> is_square D

goal (1 subgoal):
 1. D \<noteq> 0 &&& D \<noteq> 1
[PROOF STEP]
by (auto intro!: Nat.gr0I)
[PROOF STATE]
proof (state)
this:
D \<noteq> 0
D \<noteq> 1

goal (1 subgoal):
 1. 1 < D
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
D \<noteq> 0
D \<noteq> 1

goal (1 subgoal):
 1. 1 < D
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
1 < D

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma nonneg_Reals_sum: "(\<And>x. x \<in> A \<Longrightarrow> f x \<in> \<real>\<^sub>\<ge>\<^sub>0) \<Longrightarrow> sum f A \<in> \<real>\<^sub>\<ge>\<^sub>0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>x. x \<in> A \<Longrightarrow> f x \<in> \<real>\<^sub>\<ge>\<^sub>0) \<Longrightarrow> sum f A \<in> \<real>\<^sub>\<ge>\<^sub>0
[PROOF STEP]
by (induction A rule: infinite_finite_induct) auto


[STATEMENT]
lemma qtable_cong: "qtable n A P Q X \<Longrightarrow> A = B \<Longrightarrow> (\<And>v. P v \<Longrightarrow> Q v \<longleftrightarrow> Q' v) \<Longrightarrow> qtable n B P Q' X"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>qtable n A P Q X; A = B; \<And>v. P v \<Longrightarrow> Q v = Q' v\<rbrakk> \<Longrightarrow> qtable n B P Q' X
[PROOF STEP]
by (auto simp: qtable_def)


[STATEMENT]
lemma compute_pdevs_of_list[code]: "pdevs_of_list xs = Pdevs (slist_of_list xs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. pdevs_of_list xs = Pdevs (slist_of_list xs)
[PROOF STEP]
by (rule pdevs_eqI)
    (auto simp: compute_pdevs_apply slist_apply_slist_of_list pdevs_apply_pdevs_of_list)


[STATEMENT]
lemma AE_add:
  assumes "AE w in M. f w = g w"
  and "AE w in M. f' w = g' w"
shows "AE w in M. f w + f' w = g w + g' w"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. AEeq M (\<lambda>w. f w + f' w) (\<lambda>w. g w + g' w)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
AEeq M f g
AEeq M f' g'

goal (1 subgoal):
 1. AEeq M (\<lambda>w. f w + f' w) (\<lambda>w. g w + g' w)
[PROOF STEP]
by auto


[STATEMENT]
lemma gt_antisym: "t >\<^sub>t s \<Longrightarrow> \<not> s >\<^sub>t t"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. t >\<^sub>t s \<Longrightarrow> \<not> s >\<^sub>t t
[PROOF STEP]
using gt_irrefl gt_trans
[PROOF STATE]
proof (prove)
using this:
\<not> ?s >\<^sub>t ?s
\<lbrakk>?u >\<^sub>t ?t; ?t >\<^sub>t ?s\<rbrakk> \<Longrightarrow> ?u >\<^sub>t ?s

goal (1 subgoal):
 1. t >\<^sub>t s \<Longrightarrow> \<not> s >\<^sub>t t
[PROOF STEP]
by blast


[STATEMENT]
lemma dvdm_iff_pdivmod0:
  assumes f: "(F :: 'a mod_ring poly) = of_int_poly f"
  and g: "(G :: 'a mod_ring poly) = of_int_poly g"
  shows "g dvdm f = (snd (pdivmod F G) = 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (g dvdm f) = (snd (pdivmod F G) = 0)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (g dvdm f) = (snd (pdivmod F G) = 0)
[PROOF STEP]
have [transfer_rule]: "MP_Rel f F"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. MP_Rel f F
[PROOF STEP]
unfolding MP_Rel_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Mp f = to_int_poly F
[PROOF STEP]
by (simp add: Mp_f_representative f)
[PROOF STATE]
proof (state)
this:
MP_Rel f F

goal (1 subgoal):
 1. (g dvdm f) = (snd (pdivmod F G) = 0)
[PROOF STEP]
have [transfer_rule]: "MP_Rel g G"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. MP_Rel g G
[PROOF STEP]
unfolding MP_Rel_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Mp g = to_int_poly G
[PROOF STEP]
by (simp add: Mp_f_representative g)
[PROOF STATE]
proof (state)
this:
MP_Rel g G

goal (1 subgoal):
 1. (g dvdm f) = (snd (pdivmod F G) = 0)
[PROOF STEP]
have "(snd (pdivmod F G) = 0) = (G dvd F)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (snd (pdivmod F G) = 0) = (G dvd F)
[PROOF STEP]
unfolding dvd_eq_mod_eq_0
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (snd (pdivmod F G) = 0) = (F mod G = 0)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(snd (pdivmod F G) = 0) = (G dvd F)

goal (1 subgoal):
 1. (g dvdm f) = (snd (pdivmod F G) = 0)
[PROOF STEP]
from this [untransferred]
[PROOF STATE]
proof (chain)
picking this:
(snd (pdivmod F G) = 0) = (g dvdm f)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(snd (pdivmod F G) = 0) = (g dvdm f)

goal (1 subgoal):
 1. (g dvdm f) = (snd (pdivmod F G) = 0)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(g dvdm f) = (snd (pdivmod F G) = 0)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma fls_X_power_base_factor_to_fps: "fls_base_factor_to_fps (fls_X ^ n) = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fls_base_factor_to_fps (fls_X ^ n) = 1
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. fls_base_factor_to_fps (fls_X ^ n) = 1
[PROOF STEP]
define X where "X \<equiv> fls_X :: 'a::semiring_1 fls"
[PROOF STATE]
proof (state)
this:
X \<equiv> fls_X

goal (1 subgoal):
 1. fls_base_factor_to_fps (fls_X ^ n) = 1
[PROOF STEP]
hence "fls_base_factor (X ^ n) = 1"
[PROOF STATE]
proof (prove)
using this:
X \<equiv> fls_X

goal (1 subgoal):
 1. fls_base_factor (X ^ n) = 1
[PROOF STEP]
using fls_X_power_base_factor
[PROOF STATE]
proof (prove)
using this:
X \<equiv> fls_X
fls_base_factor (fls_X ^ ?n) = 1

goal (1 subgoal):
 1. fls_base_factor (X ^ n) = 1
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
fls_base_factor (X ^ n) = 1

goal (1 subgoal):
 1. fls_base_factor_to_fps (fls_X ^ n) = 1
[PROOF STEP]
thus "fls_base_factor_to_fps (X^n) = 1"
[PROOF STATE]
proof (prove)
using this:
fls_base_factor (X ^ n) = 1

goal (1 subgoal):
 1. fls_base_factor_to_fps (X ^ n) = 1
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
fls_base_factor_to_fps (X ^ n) = 1

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma boolfun_cases[case_names False Id True Neg]: "\<lbrakk>g=(\<lambda>x. False) \<Longrightarrow> P; g=(\<lambda>x. x) \<Longrightarrow> P; g=(\<lambda>x. True) \<Longrightarrow> P; g=(\<lambda>x. \<not>x) \<Longrightarrow> P\<rbrakk> \<Longrightarrow> P"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>g = (\<lambda>x. False) \<Longrightarrow> P; g = (\<lambda>x. x) \<Longrightarrow> P; g = (\<lambda>x. True) \<Longrightarrow> P; g = Not \<Longrightarrow> P\<rbrakk> \<Longrightarrow> P
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<lbrakk>g = (\<lambda>x. False) \<Longrightarrow> P; g = (\<lambda>x. x) \<Longrightarrow> P; g = (\<lambda>x. True) \<Longrightarrow> P; g = Not \<Longrightarrow> P\<rbrakk> \<Longrightarrow> P
[PROOF STEP]
note boolfun_cases_helper[of g]
[PROOF STATE]
proof (state)
this:
g = (\<lambda>x. False) \<or> g = (\<lambda>x. x) \<or> g = (\<lambda>x. True) \<or> g = Not

goal (1 subgoal):
 1. \<lbrakk>g = (\<lambda>x. False) \<Longrightarrow> P; g = (\<lambda>x. x) \<Longrightarrow> P; g = (\<lambda>x. True) \<Longrightarrow> P; g = Not \<Longrightarrow> P\<rbrakk> \<Longrightarrow> P
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
g = (\<lambda>x. False) \<or> g = (\<lambda>x. x) \<or> g = (\<lambda>x. True) \<or> g = Not

goal (1 subgoal):
 1. \<lbrakk>g = (\<lambda>x. False) \<Longrightarrow> P; g = (\<lambda>x. x) \<Longrightarrow> P; g = (\<lambda>x. True) \<Longrightarrow> P; g = Not \<Longrightarrow> P\<rbrakk> \<Longrightarrow> P
[PROOF STEP]
assume "g=(\<lambda>x. False) \<Longrightarrow> P" "g=(\<lambda>x. x) \<Longrightarrow> P" "g=(\<lambda>x. True) \<Longrightarrow> P" "g=(\<lambda>x. \<not>x) \<Longrightarrow> P"
[PROOF STATE]
proof (state)
this:
g = (\<lambda>x. False) \<Longrightarrow> P
g = (\<lambda>x. x) \<Longrightarrow> P
g = (\<lambda>x. True) \<Longrightarrow> P
g = Not \<Longrightarrow> P

goal (1 subgoal):
 1. \<lbrakk>g = (\<lambda>x. False) \<Longrightarrow> P; g = (\<lambda>x. x) \<Longrightarrow> P; g = (\<lambda>x. True) \<Longrightarrow> P; g = Not \<Longrightarrow> P\<rbrakk> \<Longrightarrow> P
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
g = (\<lambda>x. False) \<or> g = (\<lambda>x. x) \<or> g = (\<lambda>x. True) \<or> g = Not
g = (\<lambda>x. False) \<Longrightarrow> P
g = (\<lambda>x. x) \<Longrightarrow> P
g = (\<lambda>x. True) \<Longrightarrow> P
g = Not \<Longrightarrow> P
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
g = (\<lambda>x. False) \<or> g = (\<lambda>x. x) \<or> g = (\<lambda>x. True) \<or> g = Not
g = (\<lambda>x. False) \<Longrightarrow> P
g = (\<lambda>x. x) \<Longrightarrow> P
g = (\<lambda>x. True) \<Longrightarrow> P
g = Not \<Longrightarrow> P

goal (1 subgoal):
 1. P
[PROOF STEP]
by fast
[PROOF STATE]
proof (state)
this:
P

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma nth_fls_subdegree_nonzero [simp]: "f \<noteq> 0 \<Longrightarrow> f $$ fls_subdegree f \<noteq> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f \<noteq> 0 \<Longrightarrow> f $$ fls_subdegree f \<noteq> (0::'a)
[PROOF STEP]
using Least1I[OF unique_fls_subdegree]
[PROOF STATE]
proof (prove)
using this:
?f1 \<noteq> 0 \<Longrightarrow> ?f1 $$ (LEAST n. ?f1 $$ n \<noteq> (0::?'a1)) \<noteq> (0::?'a1)

goal (1 subgoal):
 1. f \<noteq> 0 \<Longrightarrow> f $$ fls_subdegree f \<noteq> (0::'a)
[PROOF STEP]
by (simp add: fls_subdegree_def)