[STATEMENT]
lemma eval_fds_at_top_tail_bound:
  fixes f :: "'a :: dirichlet_series fds"
  assumes c: "ereal c > abs_conv_abscissa f"
  defines "B \<equiv> (\<Sum>n. norm (fds_nth f (n+2)) / real (n+2) powr c) * 2 powr c"
  assumes s: "s \<bullet> 1 \<ge> c"
  shows   "norm (eval_fds f s - fds_nth f 1) \<le> B / 2 powr (s \<bullet> 1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. norm (eval_fds f s - fds_nth f 1) \<le> B / 2 powr (s \<bullet> (1::'a))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. norm (eval_fds f s - fds_nth f 1) \<le> B / 2 powr (s \<bullet> (1::'a))
[PROOF STEP]
from c
[PROOF STATE]
proof (chain)
picking this:
abs_conv_abscissa f < ereal c
[PROOF STEP]
have "fds_abs_converges f (of_real c)"
[PROOF STATE]
proof (prove)
using this:
abs_conv_abscissa f < ereal c

goal (1 subgoal):
 1. fds_abs_converges f (of_real c)
[PROOF STEP]
by (intro fds_abs_converges) simp_all
[PROOF STATE]
proof (state)
this:
fds_abs_converges f (of_real c)

goal (1 subgoal):
 1. norm (eval_fds f s - fds_nth f 1) \<le> B / 2 powr (s \<bullet> (1::'a))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
fds_abs_converges f (of_real c)

goal (1 subgoal):
 1. norm (eval_fds f s - fds_nth f 1) \<le> B / 2 powr (s \<bullet> (1::'a))
[PROOF STEP]
have "?this \<longleftrightarrow> summable (\<lambda>n. norm (fds_nth f n) / real n powr c)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fds_abs_converges f (of_real c) = summable (\<lambda>n. norm (fds_nth f n) / real n powr c)
[PROOF STEP]
unfolding fds_abs_converges_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. summable (\<lambda>n. norm (fds_nth f n / nat_power n (of_real c))) = summable (\<lambda>n. norm (fds_nth f n) / real n powr c)
[PROOF STEP]
by (intro summable_cong eventually_mono[OF eventually_gt_at_top[of "0::nat"]])
       (auto simp: norm_divide norm_nat_power norm_powr_real_powr)
[PROOF STATE]
proof (state)
this:
fds_abs_converges f (of_real c) = summable (\<lambda>n. norm (fds_nth f n) / real n powr c)

goal (1 subgoal):
 1. norm (eval_fds f s - fds_nth f 1) \<le> B / 2 powr (s \<bullet> (1::'a))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
summable (\<lambda>n. norm (fds_nth f n) / real n powr c)
[PROOF STEP]
have summable_c: \<dots>
[PROOF STATE]
proof (prove)
using this:
summable (\<lambda>n. norm (fds_nth f n) / real n powr c)

goal (1 subgoal):
 1. summable (\<lambda>n. norm (fds_nth f n) / real n powr c)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
summable (\<lambda>n. norm (fds_nth f n) / real n powr c)

goal (1 subgoal):
 1. norm (eval_fds f s - fds_nth f 1) \<le> B / 2 powr (s \<bullet> (1::'a))
[PROOF STEP]
note c
[PROOF STATE]
proof (state)
this:
abs_conv_abscissa f < ereal c

goal (1 subgoal):
 1. norm (eval_fds f s - fds_nth f 1) \<le> B / 2 powr (s \<bullet> (1::'a))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
abs_conv_abscissa f < ereal c

goal (1 subgoal):
 1. norm (eval_fds f s - fds_nth f 1) \<le> B / 2 powr (s \<bullet> (1::'a))
[PROOF STEP]
from s
[PROOF STATE]
proof (chain)
picking this:
c \<le> s \<bullet> (1::'a)
[PROOF STEP]
have "ereal c \<le> ereal (s \<bullet> 1)"
[PROOF STATE]
proof (prove)
using this:
c \<le> s \<bullet> (1::'a)

goal (1 subgoal):
 1. ereal c \<le> ereal (s \<bullet> (1::'a))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
ereal c \<le> ereal (s \<bullet> (1::'a))

goal (1 subgoal):
 1. norm (eval_fds f s - fds_nth f 1) \<le> B / 2 powr (s \<bullet> (1::'a))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
abs_conv_abscissa f < ereal (s \<bullet> (1::'a))
[PROOF STEP]
have "fds_abs_converges f s"
[PROOF STATE]
proof (prove)
using this:
abs_conv_abscissa f < ereal (s \<bullet> (1::'a))

goal (1 subgoal):
 1. fds_abs_converges f s
[PROOF STEP]
by (intro fds_abs_converges) auto
[PROOF STATE]
proof (state)
this:
fds_abs_converges f s

goal (1 subgoal):
 1. norm (eval_fds f s - fds_nth f 1) \<le> B / 2 powr (s \<bullet> (1::'a))
[PROOF STEP]
hence summable: "summable (\<lambda>n. norm (fds_nth f n / nat_power n s))"
[PROOF STATE]
proof (prove)
using this:
fds_abs_converges f s

goal (1 subgoal):
 1. summable (\<lambda>n. norm (fds_nth f n / nat_power n s))
[PROOF STEP]
by (simp add: fds_abs_converges_def)
[PROOF STATE]
proof (state)
this:
summable (\<lambda>n. norm (fds_nth f n / nat_power n s))

goal (1 subgoal):
 1. norm (eval_fds f s - fds_nth f 1) \<le> B / 2 powr (s \<bullet> (1::'a))
[PROOF STEP]
from summable_norm_cancel[OF this]
[PROOF STATE]
proof (chain)
picking this:
summable (\<lambda>n. fds_nth f n / nat_power n s)
[PROOF STEP]
have "(\<lambda>n. fds_nth f n / nat_power n s) sums eval_fds f s"
[PROOF STATE]
proof (prove)
using this:
summable (\<lambda>n. fds_nth f n / nat_power n s)

goal (1 subgoal):
 1. (\<lambda>n. fds_nth f n / nat_power n s) sums eval_fds f s
[PROOF STEP]
by (simp add: eval_fds_def sums_iff)
[PROOF STATE]
proof (state)
this:
(\<lambda>n. fds_nth f n / nat_power n s) sums eval_fds f s

goal (1 subgoal):
 1. norm (eval_fds f s - fds_nth f 1) \<le> B / 2 powr (s \<bullet> (1::'a))
[PROOF STEP]
from sums_split_initial_segment[OF this, of "Suc (Suc 0)"]
[PROOF STATE]
proof (chain)
picking this:
(\<lambda>i. fds_nth f (i + Suc (Suc 0)) / nat_power (i + Suc (Suc 0)) s) sums (eval_fds f s - (\<Sum>i<Suc (Suc 0). fds_nth f i / nat_power i s))
[PROOF STEP]
have "norm (eval_fds f s - fds_nth f 1) = norm (\<Sum>n. fds_nth f (n+2) / nat_power (n+2) s)"
[PROOF STATE]
proof (prove)
using this:
(\<lambda>i. fds_nth f (i + Suc (Suc 0)) / nat_power (i + Suc (Suc 0)) s) sums (eval_fds f s - (\<Sum>i<Suc (Suc 0). fds_nth f i / nat_power i s))

goal (1 subgoal):
 1. norm (eval_fds f s - fds_nth f 1) = norm (\<Sum>n. fds_nth f (n + 2) / nat_power (n + 2) s)
[PROOF STEP]
by (auto simp: sums_iff)
[PROOF STATE]
proof (state)
this:
norm (eval_fds f s - fds_nth f 1) = norm (\<Sum>n. fds_nth f (n + 2) / nat_power (n + 2) s)

goal (1 subgoal):
 1. norm (eval_fds f s - fds_nth f 1) \<le> B / 2 powr (s \<bullet> (1::'a))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
norm (eval_fds f s - fds_nth f 1) = norm (\<Sum>n. fds_nth f (n + 2) / nat_power (n + 2) s)

goal (1 subgoal):
 1. norm (eval_fds f s - fds_nth f 1) \<le> B / 2 powr (s \<bullet> (1::'a))
[PROOF STEP]
have "\<dots> \<le> (\<Sum>n. norm (fds_nth f (n+2) / nat_power (n+2) s))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. norm (\<Sum>n. fds_nth f (n + 2) / nat_power (n + 2) s) \<le> (\<Sum>n. norm (fds_nth f (n + 2) / nat_power (n + 2) s))
[PROOF STEP]
by (intro summable_norm summable_ignore_initial_segment summable)
[PROOF STATE]
proof (state)
this:
norm (\<Sum>n. fds_nth f (n + 2) / nat_power (n + 2) s) \<le> (\<Sum>n. norm (fds_nth f (n + 2) / nat_power (n + 2) s))

goal (1 subgoal):
 1. norm (eval_fds f s - fds_nth f 1) \<le> B / 2 powr (s \<bullet> (1::'a))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
norm (\<Sum>n. fds_nth f (n + 2) / nat_power (n + 2) s) \<le> (\<Sum>n. norm (fds_nth f (n + 2) / nat_power (n + 2) s))

goal (1 subgoal):
 1. norm (eval_fds f s - fds_nth f 1) \<le> B / 2 powr (s \<bullet> (1::'a))
[PROOF STEP]
have "\<dots> \<le> (\<Sum>n. norm (fds_nth f (n+2)) / real (n+2) powr c / 2 powr (s \<bullet> 1 - c))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>n. norm (fds_nth f (n + 2) / nat_power (n + 2) s)) \<le> (\<Sum>n. norm (fds_nth f (n + 2)) / real (n + 2) powr c / 2 powr (s \<bullet> (1::'a) - c))
[PROOF STEP]
proof (intro suminf_le allI)
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. \<And>n. norm (fds_nth f (n + 2) / nat_power (n + 2) s) \<le> norm (fds_nth f (n + 2)) / real (n + 2) powr c / 2 powr (s \<bullet> (1::'a) - c)
 2. summable (\<lambda>n. norm (fds_nth f (n + 2) / nat_power (n + 2) s))
 3. summable (\<lambda>n. norm (fds_nth f (n + 2)) / real (n + 2) powr c / 2 powr (s \<bullet> (1::'a) - c))
[PROOF STEP]
fix n :: nat
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. \<And>n. norm (fds_nth f (n + 2) / nat_power (n + 2) s) \<le> norm (fds_nth f (n + 2)) / real (n + 2) powr c / 2 powr (s \<bullet> (1::'a) - c)
 2. summable (\<lambda>n. norm (fds_nth f (n + 2) / nat_power (n + 2) s))
 3. summable (\<lambda>n. norm (fds_nth f (n + 2)) / real (n + 2) powr c / 2 powr (s \<bullet> (1::'a) - c))
[PROOF STEP]
have "norm (fds_nth f (n + 2) / nat_power (n + 2) s) =
            norm (fds_nth f (n + 2)) / real (n+2) powr c / real (n+2) powr (s \<bullet> 1 - c)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. norm (fds_nth f (n + 2) / nat_power (n + 2) s) = norm (fds_nth f (n + 2)) / real (n + 2) powr c / real (n + 2) powr (s \<bullet> (1::'a) - c)
[PROOF STEP]
by (simp add: field_simps powr_diff norm_divide norm_nat_power)
[PROOF STATE]
proof (state)
this:
norm (fds_nth f (n + 2) / nat_power (n + 2) s) = norm (fds_nth f (n + 2)) / real (n + 2) powr c / real (n + 2) powr (s \<bullet> (1::'a) - c)

goal (3 subgoals):
 1. \<And>n. norm (fds_nth f (n + 2) / nat_power (n + 2) s) \<le> norm (fds_nth f (n + 2)) / real (n + 2) powr c / 2 powr (s \<bullet> (1::'a) - c)
 2. summable (\<lambda>n. norm (fds_nth f (n + 2) / nat_power (n + 2) s))
 3. summable (\<lambda>n. norm (fds_nth f (n + 2)) / real (n + 2) powr c / 2 powr (s \<bullet> (1::'a) - c))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
norm (fds_nth f (n + 2) / nat_power (n + 2) s) = norm (fds_nth f (n + 2)) / real (n + 2) powr c / real (n + 2) powr (s \<bullet> (1::'a) - c)

goal (3 subgoals):
 1. \<And>n. norm (fds_nth f (n + 2) / nat_power (n + 2) s) \<le> norm (fds_nth f (n + 2)) / real (n + 2) powr c / 2 powr (s \<bullet> (1::'a) - c)
 2. summable (\<lambda>n. norm (fds_nth f (n + 2) / nat_power (n + 2) s))
 3. summable (\<lambda>n. norm (fds_nth f (n + 2)) / real (n + 2) powr c / 2 powr (s \<bullet> (1::'a) - c))
[PROOF STEP]
have "\<dots> \<le> norm (fds_nth f (n + 2)) / real (n+2) powr c / 2 powr (s \<bullet> 1 - c)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. norm (fds_nth f (n + 2)) / real (n + 2) powr c / real (n + 2) powr (s \<bullet> (1::'a) - c) \<le> norm (fds_nth f (n + 2)) / real (n + 2) powr c / 2 powr (s \<bullet> (1::'a) - c)
[PROOF STEP]
using s
[PROOF STATE]
proof (prove)
using this:
c \<le> s \<bullet> (1::'a)

goal (1 subgoal):
 1. norm (fds_nth f (n + 2)) / real (n + 2) powr c / real (n + 2) powr (s \<bullet> (1::'a) - c) \<le> norm (fds_nth f (n + 2)) / real (n + 2) powr c / 2 powr (s \<bullet> (1::'a) - c)
[PROOF STEP]
by (intro divide_left_mono divide_nonneg_pos powr_mono2 mult_pos_pos) simp_all
[PROOF STATE]
proof (state)
this:
norm (fds_nth f (n + 2)) / real (n + 2) powr c / real (n + 2) powr (s \<bullet> (1::'a) - c) \<le> norm (fds_nth f (n + 2)) / real (n + 2) powr c / 2 powr (s \<bullet> (1::'a) - c)

goal (3 subgoals):
 1. \<And>n. norm (fds_nth f (n + 2) / nat_power (n + 2) s) \<le> norm (fds_nth f (n + 2)) / real (n + 2) powr c / 2 powr (s \<bullet> (1::'a) - c)
 2. summable (\<lambda>n. norm (fds_nth f (n + 2) / nat_power (n + 2) s))
 3. summable (\<lambda>n. norm (fds_nth f (n + 2)) / real (n + 2) powr c / 2 powr (s \<bullet> (1::'a) - c))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
norm (fds_nth f (n + 2) / nat_power (n + 2) s) \<le> norm (fds_nth f (n + 2)) / real (n + 2) powr c / 2 powr (s \<bullet> (1::'a) - c)
[PROOF STEP]
show "norm (fds_nth f (n + 2) / nat_power (n + 2) s) \<le> \<dots>"
[PROOF STATE]
proof (prove)
using this:
norm (fds_nth f (n + 2) / nat_power (n + 2) s) \<le> norm (fds_nth f (n + 2)) / real (n + 2) powr c / 2 powr (s \<bullet> (1::'a) - c)

goal (1 subgoal):
 1. norm (fds_nth f (n + 2) / nat_power (n + 2) s) \<le> norm (fds_nth f (n + 2)) / real (n + 2) powr c / 2 powr (s \<bullet> (1::'a) - c)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
norm (fds_nth f (n + 2) / nat_power (n + 2) s) \<le> norm (fds_nth f (n + 2)) / real (n + 2) powr c / 2 powr (s \<bullet> (1::'a) - c)

goal (2 subgoals):
 1. summable (\<lambda>n. norm (fds_nth f (n + 2) / nat_power (n + 2) s))
 2. summable (\<lambda>n. norm (fds_nth f (n + 2)) / real (n + 2) powr c / 2 powr (s \<bullet> (1::'a) - c))
[PROOF STEP]
qed (intro summable_ignore_initial_segment summable summable_divide summable_c)+
[PROOF STATE]
proof (state)
this:
(\<Sum>n. norm (fds_nth f (n + 2) / nat_power (n + 2) s)) \<le> (\<Sum>n. norm (fds_nth f (n + 2)) / real (n + 2) powr c / 2 powr (s \<bullet> (1::'a) - c))

goal (1 subgoal):
 1. norm (eval_fds f s - fds_nth f 1) \<le> B / 2 powr (s \<bullet> (1::'a))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>n. norm (fds_nth f (n + 2) / nat_power (n + 2) s)) \<le> (\<Sum>n. norm (fds_nth f (n + 2)) / real (n + 2) powr c / 2 powr (s \<bullet> (1::'a) - c))

goal (1 subgoal):
 1. norm (eval_fds f s - fds_nth f 1) \<le> B / 2 powr (s \<bullet> (1::'a))
[PROOF STEP]
have "\<dots> = (\<Sum>n. norm (fds_nth f (n+2)) / real (n+2) powr c) / 2 powr (s \<bullet> 1 - c)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>n. norm (fds_nth f (n + 2)) / real (n + 2) powr c / 2 powr (s \<bullet> (1::'a) - c)) = (\<Sum>n. norm (fds_nth f (n + 2)) / real (n + 2) powr c) / 2 powr (s \<bullet> (1::'a) - c)
[PROOF STEP]
by (intro suminf_divide summable_ignore_initial_segment summable_c)
[PROOF STATE]
proof (state)
this:
(\<Sum>n. norm (fds_nth f (n + 2)) / real (n + 2) powr c / 2 powr (s \<bullet> (1::'a) - c)) = (\<Sum>n. norm (fds_nth f (n + 2)) / real (n + 2) powr c) / 2 powr (s \<bullet> (1::'a) - c)

goal (1 subgoal):
 1. norm (eval_fds f s - fds_nth f 1) \<le> B / 2 powr (s \<bullet> (1::'a))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>n. norm (fds_nth f (n + 2)) / real (n + 2) powr c / 2 powr (s \<bullet> (1::'a) - c)) = (\<Sum>n. norm (fds_nth f (n + 2)) / real (n + 2) powr c) / 2 powr (s \<bullet> (1::'a) - c)

goal (1 subgoal):
 1. norm (eval_fds f s - fds_nth f 1) \<le> B / 2 powr (s \<bullet> (1::'a))
[PROOF STEP]
have "\<dots> = B / 2 powr (s \<bullet> 1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>n. norm (fds_nth f (n + 2)) / real (n + 2) powr c) / 2 powr (s \<bullet> (1::'a) - c) = B / 2 powr (s \<bullet> (1::'a))
[PROOF STEP]
by (simp add: B_def powr_diff)
[PROOF STATE]
proof (state)
this:
(\<Sum>n. norm (fds_nth f (n + 2)) / real (n + 2) powr c) / 2 powr (s \<bullet> (1::'a) - c) = B / 2 powr (s \<bullet> (1::'a))

goal (1 subgoal):
 1. norm (eval_fds f s - fds_nth f 1) \<le> B / 2 powr (s \<bullet> (1::'a))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
norm (eval_fds f s - fds_nth f 1) \<le> B / 2 powr (s \<bullet> (1::'a))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
norm (eval_fds f s - fds_nth f 1) \<le> B / 2 powr (s \<bullet> (1::'a))

goal (1 subgoal):
 1. norm (eval_fds f s - fds_nth f 1) \<le> B / 2 powr (s \<bullet> (1::'a))
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
norm (eval_fds f s - fds_nth f 1) \<le> B / 2 powr (s \<bullet> (1::'a))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma col_cong2_bet2:
  assumes "Col A B D" and
    "Bet A C B" and
    "Cong A B C D" and
    "Cong A D B C"
  shows "Bet C A D"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Bet C A D
[PROOF STEP]
by (metis assms(1) assms(2) assms(3) assms(4) bet_cong_eq col_cong_bet cong_identity not_bet_distincts not_cong_3421 outer_transitivity_between2)


[STATEMENT]
lemma lists_accD: "listsp (Wellfounded.accp r) xs ==> Wellfounded.accp (step1 r) xs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. listsp (Wellfounded.accp r) xs \<Longrightarrow> Wellfounded.accp (step1 r) xs
[PROOF STEP]
apply (induct set: listsp)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. Wellfounded.accp (step1 r) []
 2. \<And>a l. \<lbrakk>Wellfounded.accp r a; listsp (Wellfounded.accp r) l; Wellfounded.accp (step1 r) l\<rbrakk> \<Longrightarrow> Wellfounded.accp (step1 r) (a # l)
[PROOF STEP]
apply (rule accp.accI)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>y. step1 r y [] \<Longrightarrow> Wellfounded.accp (step1 r) y
 2. \<And>a l. \<lbrakk>Wellfounded.accp r a; listsp (Wellfounded.accp r) l; Wellfounded.accp (step1 r) l\<rbrakk> \<Longrightarrow> Wellfounded.accp (step1 r) (a # l)
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>a l. \<lbrakk>Wellfounded.accp r a; listsp (Wellfounded.accp r) l; Wellfounded.accp (step1 r) l\<rbrakk> \<Longrightarrow> Wellfounded.accp (step1 r) (a # l)
[PROOF STEP]
apply (rule accp.accI)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>a l y. \<lbrakk>Wellfounded.accp r a; listsp (Wellfounded.accp r) l; Wellfounded.accp (step1 r) l; step1 r y (a # l)\<rbrakk> \<Longrightarrow> Wellfounded.accp (step1 r) y
[PROOF STEP]
apply (fast dest: accp_downward)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma between_last: "\<lbrakk> distinct(vertices f); u \<in> \<V> f \<rbrakk> \<Longrightarrow>
   between (vertices f) u (last (verticesFrom f u)) =
   butlast(tl(verticesFrom f u))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>distinct (vertices f); u \<in> \<V> f\<rbrakk> \<Longrightarrow> between (vertices f) u (last (verticesFrom f u)) = butlast (tl (verticesFrom f u))
[PROOF STEP]
apply(drule split_list)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>distinct (vertices f); \<exists>ys zs. vertices f = ys @ u # zs\<rbrakk> \<Longrightarrow> between (vertices f) u (last (verticesFrom f u)) = butlast (tl (verticesFrom f u))
[PROOF STEP]
apply (fastforce dest: last_in_set
  simp: between_def verticesFrom_Def split_def
       last_append butlast_append fst_splitAt_last)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma (in comm_monoid) mult_cong_l:
  assumes "a \<sim> a'" "a \<in> carrier G"  "a' \<in> carrier G"  "b \<in> carrier G"
  shows "a \<otimes> b \<sim> a' \<otimes> b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a \<otimes> b \<sim> a' \<otimes> b
[PROOF STEP]
using assms m_comm mult_cong_r
[PROOF STATE]
proof (prove)
using this:
a \<sim> a'
a \<in> carrier G
a' \<in> carrier G
b \<in> carrier G
\<lbrakk>?x \<in> carrier G; ?y \<in> carrier G\<rbrakk> \<Longrightarrow> ?x \<otimes> ?y = ?y \<otimes> ?x
\<lbrakk>?b \<sim> ?b'; ?a \<in> carrier G; ?b \<in> carrier G; ?b' \<in> carrier G\<rbrakk> \<Longrightarrow> ?a \<otimes> ?b \<sim> ?a \<otimes> ?b'

goal (1 subgoal):
 1. a \<otimes> b \<sim> a' \<otimes> b
[PROOF STEP]
by auto


[STATEMENT]
lemma mset_link[simp]: "(tree_to_multiset (link t1 t2))
  = (tree_to_multiset t1) + (tree_to_multiset t2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. tree_to_multiset (link t1 t2) = tree_to_multiset t1 + tree_to_multiset t2
[PROOF STEP]
by(cases t1, cases t2, auto simp add: union_ac)


[STATEMENT]
lemma count_image_mset_lt_imp_lt:
  assumes cnt_b: "count (image_mset f M) b < count (image_mset f N) b"
  shows "\<exists>x. f x = b \<and> count M x < count N x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>x. f x = b \<and> count M x < count N x
[PROOF STEP]
by (rule count_image_mset_lt_imp_lt_raw[of "set_mset M \<union> set_mset N", OF _ refl cnt_b]) auto


[STATEMENT]
lemma bounded_suc_ind:
  assumes \<open>\<And>k. k < m \<Longrightarrow> P (Suc (z + k)) = P (z + k)\<close>
    shows \<open>k < m \<Longrightarrow> P (Suc (z + k)) = P z\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. k < m \<Longrightarrow> P (Suc (z + k)) = P z
[PROOF STEP]
proof (induction k)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. 0 < m \<Longrightarrow> P (Suc (z + 0)) = P z
 2. \<And>k. \<lbrakk>k < m \<Longrightarrow> P (Suc (z + k)) = P z; Suc k < m\<rbrakk> \<Longrightarrow> P (Suc (z + Suc k)) = P z
[PROOF STEP]
case 0
[PROOF STATE]
proof (state)
this:
0 < m

goal (2 subgoals):
 1. 0 < m \<Longrightarrow> P (Suc (z + 0)) = P z
 2. \<And>k. \<lbrakk>k < m \<Longrightarrow> P (Suc (z + k)) = P z; Suc k < m\<rbrakk> \<Longrightarrow> P (Suc (z + Suc k)) = P z
[PROOF STEP]
with assms(1)[of 0]
[PROOF STATE]
proof (chain)
picking this:
0 < m \<Longrightarrow> P (Suc (z + 0)) = P (z + 0)
0 < m
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
0 < m \<Longrightarrow> P (Suc (z + 0)) = P (z + 0)
0 < m

goal (1 subgoal):
 1. P (Suc (z + 0)) = P z
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
P (Suc (z + 0)) = P z

goal (1 subgoal):
 1. \<And>k. \<lbrakk>k < m \<Longrightarrow> P (Suc (z + k)) = P z; Suc k < m\<rbrakk> \<Longrightarrow> P (Suc (z + Suc k)) = P z
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>k. \<lbrakk>k < m \<Longrightarrow> P (Suc (z + k)) = P z; Suc k < m\<rbrakk> \<Longrightarrow> P (Suc (z + Suc k)) = P z
[PROOF STEP]
case (Suc k')
[PROOF STATE]
proof (state)
this:
k' < m \<Longrightarrow> P (Suc (z + k')) = P z
Suc k' < m

goal (1 subgoal):
 1. \<And>k. \<lbrakk>k < m \<Longrightarrow> P (Suc (z + k)) = P z; Suc k < m\<rbrakk> \<Longrightarrow> P (Suc (z + Suc k)) = P z
[PROOF STEP]
with assms[of \<open>Suc k'\<close>]
[PROOF STATE]
proof (chain)
picking this:
Suc k' < m \<Longrightarrow> P (Suc (z + Suc k')) = P (z + Suc k')
k' < m \<Longrightarrow> P (Suc (z + k')) = P z
Suc k' < m
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
Suc k' < m \<Longrightarrow> P (Suc (z + Suc k')) = P (z + Suc k')
k' < m \<Longrightarrow> P (Suc (z + k')) = P z
Suc k' < m

goal (1 subgoal):
 1. P (Suc (z + Suc k')) = P z
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
P (Suc (z + Suc k')) = P z

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma Follows_trans:
     "[| F \<in> f Fols g;  F \<in> g Fols h |] ==> F \<in> f Fols h"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>F \<in> f Fols g; F \<in> g Fols h\<rbrakk> \<Longrightarrow> F \<in> f Fols h
[PROOF STEP]
apply (simp add: Follows_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>F \<in> Increasing g \<and> F \<in> Increasing f \<and> F \<in> Always {s. f s \<le> g s} \<and> (\<forall>x. F \<in> {s. x \<le> g s} \<longmapsto>w {s. x \<le> f s}); F \<in> Increasing h \<and> F \<in> Always {s. g s \<le> h s} \<and> (\<forall>x. F \<in> {s. x \<le> h s} \<longmapsto>w {s. x \<le> g s})\<rbrakk> \<Longrightarrow> F \<in> Always {s. f s \<le> h s} \<and> (\<forall>x. F \<in> {s. x \<le> h s} \<longmapsto>w {s. x \<le> f s})
[PROOF STEP]
apply (simp add: Always_eq_includes_reachable)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>F \<in> Increasing g \<and> F \<in> Increasing f \<and> reachable F \<subseteq> {s. f s \<le> g s} \<and> (\<forall>x. F \<in> {s. x \<le> g s} \<longmapsto>w {s. x \<le> f s}); F \<in> Increasing h \<and> reachable F \<subseteq> {s. g s \<le> h s} \<and> (\<forall>x. F \<in> {s. x \<le> h s} \<longmapsto>w {s. x \<le> g s})\<rbrakk> \<Longrightarrow> reachable F \<subseteq> {s. f s \<le> h s} \<and> (\<forall>x. F \<in> {s. x \<le> h s} \<longmapsto>w {s. x \<le> f s})
[PROOF STEP]
apply (blast intro: order_trans LeadsTo_Trans)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
theorem gauss_int_prime_classification:
  fixes x :: gauss_int
  assumes "prime x"
  obtains
    (one_plus_i) "x = 1 + \<i>\<^sub>\<int>"
  | (cong_3_mod_4) p where "x = of_nat p" "prime p" "[p = 3] (mod 4)"
  | (cong_1_mod_4) "prime (gauss_int_norm x)" "[gauss_int_norm x = 1] (mod 4)"
                   "ReZ x > 0" "ImZ x > 0" "ReZ x \<noteq> ImZ x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>x = 1 + \<i>\<^sub>\<int> \<Longrightarrow> thesis; \<And>p. \<lbrakk>x = of_nat p; prime p; [p = 3] (mod 4)\<rbrakk> \<Longrightarrow> thesis; \<lbrakk>prime (gauss_int_norm x); [gauss_int_norm x = 1] (mod 4); 0 < ReZ x; 0 < ImZ x; ReZ x \<noteq> ImZ x\<rbrakk> \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<lbrakk>x = 1 + \<i>\<^sub>\<int> \<Longrightarrow> thesis; \<And>p. \<lbrakk>x = of_nat p; prime p; [p = 3] (mod 4)\<rbrakk> \<Longrightarrow> thesis; \<lbrakk>prime (gauss_int_norm x); [gauss_int_norm x = 1] (mod 4); 0 < ReZ x; 0 < ImZ x; ReZ x \<noteq> ImZ x\<rbrakk> \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
define N where "N = gauss_int_norm x"
[PROOF STATE]
proof (state)
this:
N = gauss_int_norm x

goal (1 subgoal):
 1. \<lbrakk>x = 1 + \<i>\<^sub>\<int> \<Longrightarrow> thesis; \<And>p. \<lbrakk>x = of_nat p; prime p; [p = 3] (mod 4)\<rbrakk> \<Longrightarrow> thesis; \<lbrakk>prime (gauss_int_norm x); [gauss_int_norm x = 1] (mod 4); 0 < ReZ x; 0 < ImZ x; ReZ x \<noteq> ImZ x\<rbrakk> \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
have "x dvd x * gauss_cnj x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x dvd x * gauss_cnj x
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
x dvd x * gauss_cnj x

goal (1 subgoal):
 1. \<lbrakk>x = 1 + \<i>\<^sub>\<int> \<Longrightarrow> thesis; \<And>p. \<lbrakk>x = of_nat p; prime p; [p = 3] (mod 4)\<rbrakk> \<Longrightarrow> thesis; \<lbrakk>prime (gauss_int_norm x); [gauss_int_norm x = 1] (mod 4); 0 < ReZ x; 0 < ImZ x; ReZ x \<noteq> ImZ x\<rbrakk> \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
x dvd x * gauss_cnj x

goal (1 subgoal):
 1. \<lbrakk>x = 1 + \<i>\<^sub>\<int> \<Longrightarrow> thesis; \<And>p. \<lbrakk>x = of_nat p; prime p; [p = 3] (mod 4)\<rbrakk> \<Longrightarrow> thesis; \<lbrakk>prime (gauss_int_norm x); [gauss_int_norm x = 1] (mod 4); 0 < ReZ x; 0 < ImZ x; ReZ x \<noteq> ImZ x\<rbrakk> \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
have "\<dots> = of_nat (gauss_int_norm x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x * gauss_cnj x = of_nat (gauss_int_norm x)
[PROOF STEP]
by (simp add: self_mult_gauss_cnj)
[PROOF STATE]
proof (state)
this:
x * gauss_cnj x = of_nat (gauss_int_norm x)

goal (1 subgoal):
 1. \<lbrakk>x = 1 + \<i>\<^sub>\<int> \<Longrightarrow> thesis; \<And>p. \<lbrakk>x = of_nat p; prime p; [p = 3] (mod 4)\<rbrakk> \<Longrightarrow> thesis; \<lbrakk>prime (gauss_int_norm x); [gauss_int_norm x = 1] (mod 4); 0 < ReZ x; 0 < ImZ x; ReZ x \<noteq> ImZ x\<rbrakk> \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
x dvd of_nat (gauss_int_norm x)
[PROOF STEP]
have "x \<in> prime_factors (of_nat N)"
[PROOF STATE]
proof (prove)
using this:
x dvd of_nat (gauss_int_norm x)

goal (1 subgoal):
 1. x \<in># prime_factorization (of_nat N)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
x dvd of_nat (gauss_int_norm x)
prime x

goal (1 subgoal):
 1. x \<in># prime_factorization (of_nat N)
[PROOF STEP]
by (auto simp: in_prime_factors_iff N_def)
[PROOF STATE]
proof (state)
this:
x \<in># prime_factorization (of_nat N)

goal (1 subgoal):
 1. \<lbrakk>x = 1 + \<i>\<^sub>\<int> \<Longrightarrow> thesis; \<And>p. \<lbrakk>x = of_nat p; prime p; [p = 3] (mod 4)\<rbrakk> \<Longrightarrow> thesis; \<lbrakk>prime (gauss_int_norm x); [gauss_int_norm x = 1] (mod 4); 0 < ReZ x; 0 < ImZ x; ReZ x \<noteq> ImZ x\<rbrakk> \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
x \<in># prime_factorization (of_nat N)

goal (1 subgoal):
 1. \<lbrakk>x = 1 + \<i>\<^sub>\<int> \<Longrightarrow> thesis; \<And>p. \<lbrakk>x = of_nat p; prime p; [p = 3] (mod 4)\<rbrakk> \<Longrightarrow> thesis; \<lbrakk>prime (gauss_int_norm x); [gauss_int_norm x = 1] (mod 4); 0 < ReZ x; 0 < ImZ x; ReZ x \<noteq> ImZ x\<rbrakk> \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
have "N = prod_mset (prime_factorization N)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. N = \<Prod>\<^sub># (prime_factorization N)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
prime x

goal (1 subgoal):
 1. N = \<Prod>\<^sub># (prime_factorization N)
[PROOF STEP]
unfolding N_def
[PROOF STATE]
proof (prove)
using this:
prime x

goal (1 subgoal):
 1. gauss_int_norm x = \<Prod>\<^sub># (prime_factorization (gauss_int_norm x))
[PROOF STEP]
by (subst prod_mset_prime_factorization_nat) auto
[PROOF STATE]
proof (state)
this:
N = \<Prod>\<^sub># (prime_factorization N)

goal (1 subgoal):
 1. \<lbrakk>x = 1 + \<i>\<^sub>\<int> \<Longrightarrow> thesis; \<And>p. \<lbrakk>x = of_nat p; prime p; [p = 3] (mod 4)\<rbrakk> \<Longrightarrow> thesis; \<lbrakk>prime (gauss_int_norm x); [gauss_int_norm x = 1] (mod 4); 0 < ReZ x; 0 < ImZ x; ReZ x \<noteq> ImZ x\<rbrakk> \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
N = \<Prod>\<^sub># (prime_factorization N)

goal (1 subgoal):
 1. \<lbrakk>x = 1 + \<i>\<^sub>\<int> \<Longrightarrow> thesis; \<And>p. \<lbrakk>x = of_nat p; prime p; [p = 3] (mod 4)\<rbrakk> \<Longrightarrow> thesis; \<lbrakk>prime (gauss_int_norm x); [gauss_int_norm x = 1] (mod 4); 0 < ReZ x; 0 < ImZ x; ReZ x \<noteq> ImZ x\<rbrakk> \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
have "(of_nat \<dots> :: gauss_int) =
               prod_mset (image_mset of_nat (prime_factorization N))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. of_nat (\<Prod>\<^sub># (prime_factorization N)) = \<Prod>\<^sub># (image_mset of_nat (prime_factorization N))
[PROOF STEP]
by (subst of_nat_prod_mset) auto
[PROOF STATE]
proof (state)
this:
of_nat (\<Prod>\<^sub># (prime_factorization N)) = \<Prod>\<^sub># (image_mset of_nat (prime_factorization N))

goal (1 subgoal):
 1. \<lbrakk>x = 1 + \<i>\<^sub>\<int> \<Longrightarrow> thesis; \<And>p. \<lbrakk>x = of_nat p; prime p; [p = 3] (mod 4)\<rbrakk> \<Longrightarrow> thesis; \<lbrakk>prime (gauss_int_norm x); [gauss_int_norm x = 1] (mod 4); 0 < ReZ x; 0 < ImZ x; ReZ x \<noteq> ImZ x\<rbrakk> \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
of_nat (\<Prod>\<^sub># (prime_factorization N)) = \<Prod>\<^sub># (image_mset of_nat (prime_factorization N))

goal (1 subgoal):
 1. \<lbrakk>x = 1 + \<i>\<^sub>\<int> \<Longrightarrow> thesis; \<And>p. \<lbrakk>x = of_nat p; prime p; [p = 3] (mod 4)\<rbrakk> \<Longrightarrow> thesis; \<lbrakk>prime (gauss_int_norm x); [gauss_int_norm x = 1] (mod 4); 0 < ReZ x; 0 < ImZ x; ReZ x \<noteq> ImZ x\<rbrakk> \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
have "prime_factors \<dots> = (\<Union>p\<in>prime_factors N. prime_factors (of_nat p))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. prime_factors (\<Prod>\<^sub># (image_mset of_nat (prime_factorization N))) = (\<Union>p\<in>prime_factors N. prime_factors (of_nat p))
[PROOF STEP]
by (subst prime_factorization_prod_mset) auto
[PROOF STATE]
proof (state)
this:
prime_factors (\<Prod>\<^sub># (image_mset of_nat (prime_factorization N))) = (\<Union>p\<in>prime_factors N. prime_factors (of_nat p))

goal (1 subgoal):
 1. \<lbrakk>x = 1 + \<i>\<^sub>\<int> \<Longrightarrow> thesis; \<And>p. \<lbrakk>x = of_nat p; prime p; [p = 3] (mod 4)\<rbrakk> \<Longrightarrow> thesis; \<lbrakk>prime (gauss_int_norm x); [gauss_int_norm x = 1] (mod 4); 0 < ReZ x; 0 < ImZ x; ReZ x \<noteq> ImZ x\<rbrakk> \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
x \<in> (\<Union>p\<in>prime_factors N. prime_factors (of_nat p))
[PROOF STEP]
obtain p where p: "p \<in> prime_factors N" "x \<in> prime_factors (of_nat p)"
[PROOF STATE]
proof (prove)
using this:
x \<in> (\<Union>p\<in>prime_factors N. prime_factors (of_nat p))

goal (1 subgoal):
 1. (\<And>p. \<lbrakk>p \<in># prime_factorization N; x \<in># prime_factorization (of_nat p)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
p \<in># prime_factorization N
x \<in># prime_factorization (of_nat p)

goal (1 subgoal):
 1. \<lbrakk>x = 1 + \<i>\<^sub>\<int> \<Longrightarrow> thesis; \<And>p. \<lbrakk>x = of_nat p; prime p; [p = 3] (mod 4)\<rbrakk> \<Longrightarrow> thesis; \<lbrakk>prime (gauss_int_norm x); [gauss_int_norm x = 1] (mod 4); 0 < ReZ x; 0 < ImZ x; ReZ x \<noteq> ImZ x\<rbrakk> \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
have "prime p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. prime p
[PROOF STEP]
using p
[PROOF STATE]
proof (prove)
using this:
p \<in># prime_factorization N
x \<in># prime_factorization (of_nat p)

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

goal (1 subgoal):
 1. \<lbrakk>x = 1 + \<i>\<^sub>\<int> \<Longrightarrow> thesis; \<And>p. \<lbrakk>x = of_nat p; prime p; [p = 3] (mod 4)\<rbrakk> \<Longrightarrow> thesis; \<lbrakk>prime (gauss_int_norm x); [gauss_int_norm x = 1] (mod 4); 0 < ReZ x; 0 < ImZ x; ReZ x \<noteq> ImZ x\<rbrakk> \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
hence "\<not>(2 * 2) dvd p"
[PROOF STATE]
proof (prove)
using this:
prime p

goal (1 subgoal):
 1. \<not> 2 * 2 dvd p
[PROOF STEP]
using product_dvd_irreducibleD[of p 2 2]
[PROOF STATE]
proof (prove)
using this:
prime p
\<lbrakk>irreducible p; 2 * 2 dvd p\<rbrakk> \<Longrightarrow> is_unit 2 \<or> is_unit 2

goal (1 subgoal):
 1. \<not> 2 * 2 dvd p
[PROOF STEP]
by (auto simp flip: prime_elem_iff_irreducible)
[PROOF STATE]
proof (state)
this:
\<not> 2 * 2 dvd p

goal (1 subgoal):
 1. \<lbrakk>x = 1 + \<i>\<^sub>\<int> \<Longrightarrow> thesis; \<And>p. \<lbrakk>x = of_nat p; prime p; [p = 3] (mod 4)\<rbrakk> \<Longrightarrow> thesis; \<lbrakk>prime (gauss_int_norm x); [gauss_int_norm x = 1] (mod 4); 0 < ReZ x; 0 < ImZ x; ReZ x \<noteq> ImZ x\<rbrakk> \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
hence "[p \<noteq> 0] (mod 4)"
[PROOF STATE]
proof (prove)
using this:
\<not> 2 * 2 dvd p

goal (1 subgoal):
 1. [p \<noteq> 0] (mod 4)
[PROOF STEP]
using p
[PROOF STATE]
proof (prove)
using this:
\<not> 2 * 2 dvd p
p \<in># prime_factorization N
x \<in># prime_factorization (of_nat p)

goal (1 subgoal):
 1. [p \<noteq> 0] (mod 4)
[PROOF STEP]
by (auto simp: cong_0_iff in_prime_factors_iff)
[PROOF STATE]
proof (state)
this:
[p \<noteq> 0] (mod 4)

goal (1 subgoal):
 1. \<lbrakk>x = 1 + \<i>\<^sub>\<int> \<Longrightarrow> thesis; \<And>p. \<lbrakk>x = of_nat p; prime p; [p = 3] (mod 4)\<rbrakk> \<Longrightarrow> thesis; \<lbrakk>prime (gauss_int_norm x); [gauss_int_norm x = 1] (mod 4); 0 < ReZ x; 0 < ImZ x; ReZ x \<noteq> ImZ x\<rbrakk> \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
hence "p mod 4 \<in> {1,2,3}"
[PROOF STATE]
proof (prove)
using this:
[p \<noteq> 0] (mod 4)

goal (1 subgoal):
 1. p mod 4 \<in> {1, 2, 3}
[PROOF STEP]
by (auto simp: cong_def)
[PROOF STATE]
proof (state)
this:
p mod 4 \<in> {1, 2, 3}

goal (1 subgoal):
 1. \<lbrakk>x = 1 + \<i>\<^sub>\<int> \<Longrightarrow> thesis; \<And>p. \<lbrakk>x = of_nat p; prime p; [p = 3] (mod 4)\<rbrakk> \<Longrightarrow> thesis; \<lbrakk>prime (gauss_int_norm x); [gauss_int_norm x = 1] (mod 4); 0 < ReZ x; 0 < ImZ x; ReZ x \<noteq> ImZ x\<rbrakk> \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
p mod 4 \<in> {1, 2, 3}

goal (1 subgoal):
 1. thesis
[PROOF STEP]
proof (elim singletonE insertE)
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. p mod 4 = 1 \<Longrightarrow> thesis
 2. p mod 4 = 2 \<Longrightarrow> thesis
 3. p mod 4 = 3 \<Longrightarrow> thesis
[PROOF STEP]
assume "p mod 4 = 2"
[PROOF STATE]
proof (state)
this:
p mod 4 = 2

goal (3 subgoals):
 1. p mod 4 = 1 \<Longrightarrow> thesis
 2. p mod 4 = 2 \<Longrightarrow> thesis
 3. p mod 4 = 3 \<Longrightarrow> thesis
[PROOF STEP]
hence "p mod 4 mod 2 = 0"
[PROOF STATE]
proof (prove)
using this:
p mod 4 = 2

goal (1 subgoal):
 1. p mod 4 mod 2 = 0
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
p mod 4 mod 2 = 0

goal (3 subgoals):
 1. p mod 4 = 1 \<Longrightarrow> thesis
 2. p mod 4 = 2 \<Longrightarrow> thesis
 3. p mod 4 = 3 \<Longrightarrow> thesis
[PROOF STEP]
hence "p mod 2 = 0"
[PROOF STATE]
proof (prove)
using this:
p mod 4 mod 2 = 0

goal (1 subgoal):
 1. p mod 2 = 0
[PROOF STEP]
by (simp add: mod_mod_cancel)
[PROOF STATE]
proof (state)
this:
p mod 2 = 0

goal (3 subgoals):
 1. p mod 4 = 1 \<Longrightarrow> thesis
 2. p mod 4 = 2 \<Longrightarrow> thesis
 3. p mod 4 = 3 \<Longrightarrow> thesis
[PROOF STEP]
with \<open>prime p\<close>
[PROOF STATE]
proof (chain)
picking this:
prime p
p mod 2 = 0
[PROOF STEP]
have [simp]: "p = 2"
[PROOF STATE]
proof (prove)
using this:
prime p
p mod 2 = 0

goal (1 subgoal):
 1. p = 2
[PROOF STEP]
using prime_prime_factor two_is_prime_nat
[PROOF STATE]
proof (prove)
using this:
prime p
p mod 2 = 0
prime ?n = (?n \<noteq> 1 \<and> (\<forall>p. prime p \<and> p dvd ?n \<longrightarrow> p = ?n))
prime 2

goal (1 subgoal):
 1. p = 2
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
p = 2

goal (3 subgoals):
 1. p mod 4 = 1 \<Longrightarrow> thesis
 2. p mod 4 = 2 \<Longrightarrow> thesis
 3. p mod 4 = 3 \<Longrightarrow> thesis
[PROOF STEP]
have "prime_factors (of_nat p) = {1 + \<i>\<^sub>\<int> :: gauss_int}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. prime_factors (of_nat p) = {1 + \<i>\<^sub>\<int>}
[PROOF STEP]
by (simp add: prime_factorization_2_gauss_int)
[PROOF STATE]
proof (state)
this:
prime_factors (of_nat p) = {1 + \<i>\<^sub>\<int>}

goal (3 subgoals):
 1. p mod 4 = 1 \<Longrightarrow> thesis
 2. p mod 4 = 2 \<Longrightarrow> thesis
 3. p mod 4 = 3 \<Longrightarrow> thesis
[PROOF STEP]
with p
[PROOF STATE]
proof (chain)
picking this:
p \<in># prime_factorization N
x \<in># prime_factorization (of_nat p)
prime_factors (of_nat p) = {1 + \<i>\<^sub>\<int>}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
p \<in># prime_factorization N
x \<in># prime_factorization (of_nat p)
prime_factors (of_nat p) = {1 + \<i>\<^sub>\<int>}

goal (1 subgoal):
 1. thesis
[PROOF STEP]
using that(1)
[PROOF STATE]
proof (prove)
using this:
p \<in># prime_factorization N
x \<in># prime_factorization (of_nat p)
prime_factors (of_nat p) = {1 + \<i>\<^sub>\<int>}
x = 1 + \<i>\<^sub>\<int> \<Longrightarrow> thesis

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

goal (2 subgoals):
 1. p mod 4 = 1 \<Longrightarrow> thesis
 2. p mod 4 = 3 \<Longrightarrow> thesis
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. p mod 4 = 1 \<Longrightarrow> thesis
 2. p mod 4 = 3 \<Longrightarrow> thesis
[PROOF STEP]
assume *: "p mod 4 = 3"
[PROOF STATE]
proof (state)
this:
p mod 4 = 3

goal (2 subgoals):
 1. p mod 4 = 1 \<Longrightarrow> thesis
 2. p mod 4 = 3 \<Longrightarrow> thesis
[PROOF STEP]
hence "prime_factors (of_nat p) = {of_nat p :: gauss_int}"
[PROOF STATE]
proof (prove)
using this:
p mod 4 = 3

goal (1 subgoal):
 1. prime_factors (of_nat p) = {of_nat p}
[PROOF STEP]
using prime_gauss_int_of_nat[of p] \<open>prime p\<close>
[PROOF STATE]
proof (prove)
using this:
p mod 4 = 3
\<lbrakk>prime p; [p = 3] (mod 4)\<rbrakk> \<Longrightarrow> prime (of_nat p)
prime p

goal (1 subgoal):
 1. prime_factors (of_nat p) = {of_nat p}
[PROOF STEP]
by (subst prime_factorization_prime) (auto simp: cong_def)
[PROOF STATE]
proof (state)
this:
prime_factors (of_nat p) = {of_nat p}

goal (2 subgoals):
 1. p mod 4 = 1 \<Longrightarrow> thesis
 2. p mod 4 = 3 \<Longrightarrow> thesis
[PROOF STEP]
with p
[PROOF STATE]
proof (chain)
picking this:
p \<in># prime_factorization N
x \<in># prime_factorization (of_nat p)
prime_factors (of_nat p) = {of_nat p}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
p \<in># prime_factorization N
x \<in># prime_factorization (of_nat p)
prime_factors (of_nat p) = {of_nat p}

goal (1 subgoal):
 1. thesis
[PROOF STEP]
using that(2)[of p] *
[PROOF STATE]
proof (prove)
using this:
p \<in># prime_factorization N
x \<in># prime_factorization (of_nat p)
prime_factors (of_nat p) = {of_nat p}
\<lbrakk>x = of_nat p; prime p; [p = 3] (mod 4)\<rbrakk> \<Longrightarrow> thesis
p mod 4 = 3

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

goal (1 subgoal):
 1. p mod 4 = 1 \<Longrightarrow> thesis
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. p mod 4 = 1 \<Longrightarrow> thesis
[PROOF STEP]
assume *: "p mod 4 = 1"
[PROOF STATE]
proof (state)
this:
p mod 4 = 1

goal (1 subgoal):
 1. p mod 4 = 1 \<Longrightarrow> thesis
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
p mod 4 = 1
[PROOF STEP]
interpret noninert_gauss_int_prime p
[PROOF STATE]
proof (prove)
using this:
p mod 4 = 1

goal (1 subgoal):
 1. noninert_gauss_int_prime p
[PROOF STEP]
by unfold_locales (use \<open>prime p\<close> in \<open>auto simp: cong_def\<close>)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. p mod 4 = 1 \<Longrightarrow> thesis
[PROOF STEP]
obtain q1 q2 :: gauss_int where q12:
      "prime q1" "prime q2" "prime_factorization (of_nat p) = {#q1, q2#}"
      "gauss_int_norm q1 = p" "gauss_int_norm q2 = p" "q2 = \<i>\<^sub>\<int> * gauss_cnj q1"
      "ReZ q1 > 0" "ImZ q1 > 0" "ReZ q1 > 0" "ImZ q2 > 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>q1 q2. \<lbrakk>prime q1; prime q2; prime_factorization (of_nat p) = {#q1, q2#}; gauss_int_norm q1 = p; gauss_int_norm q2 = p; q2 = \<i>\<^sub>\<int> * gauss_cnj q1; 0 < ReZ q1; 0 < ImZ q1; 0 < ReZ q1; 0 < ImZ q2\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using prime_factorization
[PROOF STATE]
proof (prove)
using this:
(\<And>q1 q2. \<lbrakk>prime q1; prime q2; prime_factorization (of_nat p) = {#q1, q2#}; gauss_int_norm q1 = p; gauss_int_norm q2 = p; q2 = \<i>\<^sub>\<int> * gauss_cnj q1; 0 < ReZ q1; 0 < ImZ q1; 0 < ReZ q1; 0 < ImZ q2\<rbrakk> \<Longrightarrow> ?thesis) \<Longrightarrow> ?thesis

goal (1 subgoal):
 1. (\<And>q1 q2. \<lbrakk>prime q1; prime q2; prime_factorization (of_nat p) = {#q1, q2#}; gauss_int_norm q1 = p; gauss_int_norm q2 = p; q2 = \<i>\<^sub>\<int> * gauss_cnj q1; 0 < ReZ q1; 0 < ImZ q1; 0 < ReZ q1; 0 < ImZ q2\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
prime q1
prime q2
prime_factorization (of_nat p) = {#q1, q2#}
gauss_int_norm q1 = p
gauss_int_norm q2 = p
q2 = \<i>\<^sub>\<int> * gauss_cnj q1
0 < ReZ q1
0 < ImZ q1
0 < ReZ q1
0 < ImZ q2

goal (1 subgoal):
 1. p mod 4 = 1 \<Longrightarrow> thesis
[PROOF STEP]
from p q12
[PROOF STATE]
proof (chain)
picking this:
p \<in># prime_factorization N
x \<in># prime_factorization (of_nat p)
prime q1
prime q2
prime_factorization (of_nat p) = {#q1, q2#}
gauss_int_norm q1 = p
gauss_int_norm q2 = p
q2 = \<i>\<^sub>\<int> * gauss_cnj q1
0 < ReZ q1
0 < ImZ q1
0 < ReZ q1
0 < ImZ q2
[PROOF STEP]
have "x = q1 \<or> x = q2"
[PROOF STATE]
proof (prove)
using this:
p \<in># prime_factorization N
x \<in># prime_factorization (of_nat p)
prime q1
prime q2
prime_factorization (of_nat p) = {#q1, q2#}
gauss_int_norm q1 = p
gauss_int_norm q2 = p
q2 = \<i>\<^sub>\<int> * gauss_cnj q1
0 < ReZ q1
0 < ImZ q1
0 < ReZ q1
0 < ImZ q2

goal (1 subgoal):
 1. x = q1 \<or> x = q2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
x = q1 \<or> x = q2

goal (1 subgoal):
 1. p mod 4 = 1 \<Longrightarrow> thesis
[PROOF STEP]
with q12
[PROOF STATE]
proof (chain)
picking this:
prime q1
prime q2
prime_factorization (of_nat p) = {#q1, q2#}
gauss_int_norm q1 = p
gauss_int_norm q2 = p
q2 = \<i>\<^sub>\<int> * gauss_cnj q1
0 < ReZ q1
0 < ImZ q1
0 < ReZ q1
0 < ImZ q2
x = q1 \<or> x = q2
[PROOF STEP]
have **: "gauss_int_norm x = p" "ReZ x > 0" "ImZ x > 0"
[PROOF STATE]
proof (prove)
using this:
prime q1
prime q2
prime_factorization (of_nat p) = {#q1, q2#}
gauss_int_norm q1 = p
gauss_int_norm q2 = p
q2 = \<i>\<^sub>\<int> * gauss_cnj q1
0 < ReZ q1
0 < ImZ q1
0 < ReZ q1
0 < ImZ q2
x = q1 \<or> x = q2

goal (1 subgoal):
 1. gauss_int_norm x = p &&& 0 < ReZ x &&& 0 < ImZ x
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
gauss_int_norm x = p
0 < ReZ x
0 < ImZ x

goal (1 subgoal):
 1. p mod 4 = 1 \<Longrightarrow> thesis
[PROOF STEP]
have "ReZ x \<noteq> ImZ x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ReZ x \<noteq> ImZ x
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. ReZ x = ImZ x \<Longrightarrow> False
[PROOF STEP]
assume "ReZ x = ImZ x"
[PROOF STATE]
proof (state)
this:
ReZ x = ImZ x

goal (1 subgoal):
 1. ReZ x = ImZ x \<Longrightarrow> False
[PROOF STEP]
hence "even (gauss_int_norm x)"
[PROOF STATE]
proof (prove)
using this:
ReZ x = ImZ x

goal (1 subgoal):
 1. even (gauss_int_norm x)
[PROOF STEP]
by (auto simp: gauss_int_norm_def nat_mult_distrib)
[PROOF STATE]
proof (state)
this:
even (gauss_int_norm x)

goal (1 subgoal):
 1. ReZ x = ImZ x \<Longrightarrow> False
[PROOF STEP]
hence "even p"
[PROOF STATE]
proof (prove)
using this:
even (gauss_int_norm x)

goal (1 subgoal):
 1. even p
[PROOF STEP]
using \<open>gauss_int_norm x = p\<close>
[PROOF STATE]
proof (prove)
using this:
even (gauss_int_norm x)
gauss_int_norm x = p

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

goal (1 subgoal):
 1. ReZ x = ImZ x \<Longrightarrow> False
[PROOF STEP]
with \<open>p mod 4 = 1\<close>
[PROOF STATE]
proof (chain)
picking this:
p mod 4 = 1
even p
[PROOF STEP]
show False
[PROOF STATE]
proof (prove)
using this:
p mod 4 = 1
even p

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

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
ReZ x \<noteq> ImZ x

goal (1 subgoal):
 1. p mod 4 = 1 \<Longrightarrow> thesis
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
ReZ x \<noteq> ImZ x

goal (1 subgoal):
 1. thesis
[PROOF STEP]
using that(3) \<open>prime p\<close> * **
[PROOF STATE]
proof (prove)
using this:
ReZ x \<noteq> ImZ x
\<lbrakk>prime (gauss_int_norm x); [gauss_int_norm x = 1] (mod 4); 0 < ReZ x; 0 < ImZ x; ReZ x \<noteq> ImZ x\<rbrakk> \<Longrightarrow> thesis
prime p
p mod 4 = 1
gauss_int_norm x = p
0 < ReZ x
0 < ImZ x

goal (1 subgoal):
 1. thesis
[PROOF STEP]
by (simp add: cong_def)
[PROOF STATE]
proof (state)
this:
thesis

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
thesis

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma [simp]:
  "(binop_Mod v1 v2 = Some va) \<longleftrightarrow>
   (\<exists>i1 i2. v1 = Intg i1 \<and> v2 = Intg i2 \<and>
      va = (if i2 = 0 then Inr (addr_of_sys_xcpt ArithmeticException) else Inl (Intg(i1 smod i2))))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (binop_Mod v1 v2 = \<lfloor>va\<rfloor>) = (\<exists>i1 i2. v1 = Intg i1 \<and> v2 = Intg i2 \<and> va = (if i2 = 0 then Inr (addr_of_sys_xcpt ArithmeticException) else Inl (Intg (i1 smod i2))))
[PROOF STEP]
by(cases "(v1, v2)" rule: binop_Mod.cases) auto


[STATEMENT]
lemma consistent_signs_at_roots_eq:
  assumes "p \<noteq> 0"
  shows "consistent_signs_at_roots p qs =
         set (characterize_consistent_signs_at_roots p qs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. consistent_signs_at_roots p qs = set (characterize_consistent_signs_at_roots p qs)
[PROOF STEP]
unfolding consistent_signs_at_roots_def characterize_consistent_signs_at_roots_def
    characterize_root_list_p_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sgn_vec qs ` roots p = set (remdups (map (signs_at qs) (sorted_list_of_set {x. poly p x = 0})))
[PROOF STEP]
apply auto
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>xa. xa \<in> roots p \<Longrightarrow> sgn_vec qs xa \<in> signs_at qs ` set (sorted_list_of_set {x. poly p x = 0})
 2. \<And>xa. xa \<in> set (sorted_list_of_set {x. poly p x = 0}) \<Longrightarrow> signs_at qs xa \<in> sgn_vec qs ` roots p
[PROOF STEP]
apply (subst set_sorted_list_of_set)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. \<And>xa. xa \<in> roots p \<Longrightarrow> finite {x. poly p x = 0}
 2. \<And>xa. xa \<in> roots p \<Longrightarrow> sgn_vec qs xa \<in> signs_at qs ` {x. poly p x = 0}
 3. \<And>xa. xa \<in> set (sorted_list_of_set {x. poly p x = 0}) \<Longrightarrow> signs_at qs xa \<in> sgn_vec qs ` roots p
[PROOF STEP]
using assms poly_roots_finite
[PROOF STATE]
proof (prove)
using this:
p \<noteq> 0
?p \<noteq> 0 \<Longrightarrow> finite {x. poly ?p x = (0::?'a)}

goal (3 subgoals):
 1. \<And>xa. xa \<in> roots p \<Longrightarrow> finite {x. poly p x = 0}
 2. \<And>xa. xa \<in> roots p \<Longrightarrow> sgn_vec qs xa \<in> signs_at qs ` {x. poly p x = 0}
 3. \<And>xa. xa \<in> set (sorted_list_of_set {x. poly p x = 0}) \<Longrightarrow> signs_at qs xa \<in> sgn_vec qs ` roots p
[PROOF STEP]
apply blast
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>xa. xa \<in> roots p \<Longrightarrow> sgn_vec qs xa \<in> signs_at qs ` {x. poly p x = 0}
 2. \<And>xa. xa \<in> set (sorted_list_of_set {x. poly p x = 0}) \<Longrightarrow> signs_at qs xa \<in> sgn_vec qs ` roots p
[PROOF STEP]
unfolding sgn_vec_def sgn_def signs_at_def squash_def o_def
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>xa. xa \<in> roots p \<Longrightarrow> map (\<lambda>x. if 0 < poly x xa then 1 else if poly x xa < 0 then - 1 else 0) qs \<in> (\<lambda>x. map (\<lambda>xa. if 0 < poly xa x then 1 else if poly xa x < 0 then - 1 else 0) qs) ` {x. poly p x = 0}
 2. \<And>xa. xa \<in> set (sorted_list_of_set {x. poly p x = 0}) \<Longrightarrow> map (\<lambda>x. if 0 < poly x xa then 1 else if poly x xa < 0 then - 1 else 0) qs \<in> (\<lambda>x. map (\<lambda>xa. if 0 < poly xa x then 1 else if poly xa x < 0 then - 1 else 0) qs) ` roots p
[PROOF STEP]
using roots_def
[PROOF STATE]
proof (prove)
using this:
roots ?p = {x. poly ?p x = 0}

goal (2 subgoals):
 1. \<And>xa. xa \<in> roots p \<Longrightarrow> map (\<lambda>x. if 0 < poly x xa then 1 else if poly x xa < 0 then - 1 else 0) qs \<in> (\<lambda>x. map (\<lambda>xa. if 0 < poly xa x then 1 else if poly xa x < 0 then - 1 else 0) qs) ` {x. poly p x = 0}
 2. \<And>xa. xa \<in> set (sorted_list_of_set {x. poly p x = 0}) \<Longrightarrow> map (\<lambda>x. if 0 < poly x xa then 1 else if poly x xa < 0 then - 1 else 0) qs \<in> (\<lambda>x. map (\<lambda>xa. if 0 < poly xa x then 1 else if poly xa x < 0 then - 1 else 0) qs) ` roots p
[PROOF STEP]
apply auto[1]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>xa. xa \<in> set (sorted_list_of_set {x. poly p x = 0}) \<Longrightarrow> map (\<lambda>x. if 0 < poly x xa then 1 else if poly x xa < 0 then - 1 else 0) qs \<in> (\<lambda>x. map (\<lambda>xa. if 0 < poly xa x then 1 else if poly xa x < 0 then - 1 else 0) qs) ` roots p
[PROOF STEP]
by (smt Collect_cong assms image_iff poly_roots_finite roots_def sorted_list_of_set(1))


[STATEMENT]
lemma count_replicate_zmset[simp]:
  "zcount (replicate_zmset n x) y = (if y = x then of_nat n else 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. zcount (replicate_zmset n x) y = (if y = x then int n else 0)
[PROOF STEP]
unfolding replicate_zmset_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. zcount ((add_zmset x ^^ n) {#}\<^sub>z) y = (if y = x then int n else 0)
[PROOF STEP]
by (induct n) auto


[STATEMENT]
lemma outside_of_col_range_is_0:
  assumes "i < dim_row A" and "j \<ge> dim_col A"
  shows "coeff ((matrix_to_lpolies A)!i) j = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Abstract_Linear_Poly.coeff (matrix_to_lpolies A ! i) j = 0
[PROOF STEP]
using outside_list_coeff0[of "col A i" j]
[PROOF STATE]
proof (prove)
using this:
dim_vec (col A i) \<le> j \<Longrightarrow> Abstract_Linear_Poly.coeff (vec_to_lpoly (col A i)) j = 0

goal (1 subgoal):
 1. Abstract_Linear_Poly.coeff (matrix_to_lpolies A ! i) j = 0
[PROOF STEP]
by (metis assms(1) assms(2) index_row(2) length_rows matrix_to_lpolies.simps nth_map nth_rows outside_list_coeff0)


[STATEMENT]
lemma mat_of_cblinfun_plus:
  "mat_of_cblinfun (F + G) = mat_of_cblinfun F + mat_of_cblinfun G"
  for F G::"'a::{basis_enum,complex_normed_vector} \<Rightarrow>\<^sub>C\<^sub>L'b::{basis_enum,complex_normed_vector}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mat_of_cblinfun (F + G) = mat_of_cblinfun F + mat_of_cblinfun G
[PROOF STEP]
by (auto simp add: mat_of_cblinfun_def cblinfun.add_left complex_vector.representation_add)


[STATEMENT]
lemma fds_divisor_count: "fds divisor_count = fds_zeta ^ 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fds divisor_count = fds_zeta\<^sup>2
[PROOF STEP]
by (rule fds_eqI)
     (simp add: fds_nth_mult dirichlet_prod_altdef1 divisor_count_def power2_eq_square)


[STATEMENT]
lemma eval_fm_Iff [simp]: "eval_fm e (Iff A B) \<longleftrightarrow> (eval_fm e A  \<longleftrightarrow>  eval_fm e B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. eval_fm e (A IFF B) = (eval_fm e A = eval_fm e B)
[PROOF STEP]
by (auto simp: Iff_def)


[STATEMENT]
lemma is_unit_gcd_iff [simp]:
  "is_unit (gcd a b) \<longleftrightarrow> gcd a b = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. is_unit (gcd a b) = (gcd a b = (1::'a))
[PROOF STEP]
by (cases "a = 0 \<and> b = 0") (auto simp: unit_factor_gcd dest: is_unit_unit_factor)


[STATEMENT]
lemma (in finite) just_cash_summation:
  fixes A :: "'a set"
  assumes "\<forall> a \<in> A. \<exists> c . \<L> a = just_cash c"
  shows "\<exists> c . (\<Sum> a \<in> A . \<L> a) = just_cash c"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>c. sum \<L> A = just_cash c
[PROOF STEP]
using finite assms
[PROOF STATE]
proof (prove)
using this:
finite ?A
\<forall>a\<in>A. \<exists>c. \<L> a = just_cash c

goal (1 subgoal):
 1. \<exists>c. sum \<L> A = just_cash c
[PROOF STEP]
by (induct A rule: finite_induct, auto, metis zero_account_alt_def)


[STATEMENT]
lemma iMODb_singleton_subset_conv: "
  ([r, mod m, c] \<subseteq> {a}) = (r = a \<and> (m = 0 \<or> c = 0))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ([ r, mod m, c ] \<subseteq> {a}) = (r = a \<and> (m = 0 \<or> c = 0))
[PROOF STEP]
apply (rule iffI)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. [ r, mod m, c ] \<subseteq> {a} \<Longrightarrow> r = a \<and> (m = 0 \<or> c = 0)
 2. r = a \<and> (m = 0 \<or> c = 0) \<Longrightarrow> [ r, mod m, c ] \<subseteq> {a}
[PROOF STEP]
apply (simp add: subset_singleton_conv iT_not_empty)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. [ r, mod m, c ] = {a} \<Longrightarrow> r = a \<and> (m = 0 \<or> c = 0)
 2. r = a \<and> (m = 0 \<or> c = 0) \<Longrightarrow> [ r, mod m, c ] \<subseteq> {a}
[PROOF STEP]
apply (simp add: set_eq_iff iT_iff)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<forall>x. (x mod m = r mod m \<and> r \<le> x \<and> x \<le> r + m * c) = (x = a) \<Longrightarrow> r = a \<and> (m = 0 \<or> c = 0)
 2. r = a \<and> (m = 0 \<or> c = 0) \<Longrightarrow> [ r, mod m, c ] \<subseteq> {a}
[PROOF STEP]
apply (frule_tac x=r in spec, drule_tac x="r+m" in spec)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>(r mod m = r mod m \<and> r \<le> r \<and> r \<le> r + m * c) = (r = a); ((r + m) mod m = r mod m \<and> r \<le> r + m \<and> r + m \<le> r + m * c) = (r + m = a)\<rbrakk> \<Longrightarrow> r = a \<and> (m = 0 \<or> c = 0)
 2. r = a \<and> (m = 0 \<or> c = 0) \<Longrightarrow> [ r, mod m, c ] \<subseteq> {a}
[PROOF STEP]
apply clarsimp
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. r = a \<and> (m = 0 \<or> c = 0) \<Longrightarrow> [ r, mod m, c ] \<subseteq> {a}
[PROOF STEP]
apply (fastforce simp: iMODb_0 iMODb_mod_0 iIN_0)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma setdist_eq_0_sing_2:
  "setdist S {x} = 0 \<longleftrightarrow> S = {} \<or> x \<in> closure S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (setdist S {x} = 0) = (S = {} \<or> x \<in> closure S)
[PROOF STEP]
by (metis setdist_eq_0_sing_1 setdist_sym)


[STATEMENT]
lemma "quotient V Id = {{v}|v. v\<in>V}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. V // Id = {{v} |v. v \<in> V}
[PROOF STEP]
unfolding quotient_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Union>x\<in>V. {Id `` {x}}) = {{v} |v. v \<in> V}
[PROOF STEP]
by auto


[STATEMENT]
lemma card_of_Un_Plus_ordIso:
assumes "A Int B = {}"
shows "|A \<union> B| =o |A <+> B|"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. |A \<union> B| =o |A <+> B|
[PROOF STEP]
using assms card_of_ordIso[of "A \<union> B"] Un_Plus_bij_betw[of A B]
[PROOF STATE]
proof (prove)
using this:
A \<inter> B = {}
(\<exists>f. bij_betw f (A \<union> B) ?B) = (|A \<union> B| =o |?B|)
A \<inter> B = {} \<Longrightarrow> \<exists>f. bij_betw f (A \<union> B) (A <+> B)

goal (1 subgoal):
 1. |A \<union> B| =o |A <+> B|
[PROOF STEP]
by auto


[STATEMENT]
lemma padic_one_id:
assumes "prime p"
assumes "x \<in> carrier (padic_int p)"
shows  "\<one>\<^bsub>padic_int p\<^esub> \<otimes>\<^bsub>padic_int p\<^esub> x = x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<one>\<^bsub>padic_int p\<^esub> \<otimes>\<^bsub>padic_int p\<^esub> x = x
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>xa. (\<one>\<^bsub>padic_int p\<^esub> \<otimes>\<^bsub>padic_int p\<^esub> x) xa = x xa
[PROOF STEP]
fix n
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>xa. (\<one>\<^bsub>padic_int p\<^esub> \<otimes>\<^bsub>padic_int p\<^esub> x) xa = x xa
[PROOF STEP]
show "(\<one>\<^bsub>padic_int p\<^esub> \<otimes>\<^bsub>padic_int p\<^esub> x) n = x n "
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<one>\<^bsub>padic_int p\<^esub> \<otimes>\<^bsub>padic_int p\<^esub> x) n = x n
[PROOF STEP]
proof(cases "n=0")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. n = 0 \<Longrightarrow> (\<one>\<^bsub>padic_int p\<^esub> \<otimes>\<^bsub>padic_int p\<^esub> x) n = x n
 2. n \<noteq> 0 \<Longrightarrow> (\<one>\<^bsub>padic_int p\<^esub> \<otimes>\<^bsub>padic_int p\<^esub> x) n = x n
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
n = 0

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> (\<one>\<^bsub>padic_int p\<^esub> \<otimes>\<^bsub>padic_int p\<^esub> x) n = x n
 2. n \<noteq> 0 \<Longrightarrow> (\<one>\<^bsub>padic_int p\<^esub> \<otimes>\<^bsub>padic_int p\<^esub> x) n = x n
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
n = 0
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
n = 0

goal (1 subgoal):
 1. (\<one>\<^bsub>padic_int p\<^esub> \<otimes>\<^bsub>padic_int p\<^esub> x) n = x n
[PROOF STEP]
by (metis padic_int_simps(1,4,5) assms(1) assms(2) padic_mult_in_padic_set padic_one_in_padic_set padic_set_zero_res)
[PROOF STATE]
proof (state)
this:
(\<one>\<^bsub>padic_int p\<^esub> \<otimes>\<^bsub>padic_int p\<^esub> x) n = x n

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> (\<one>\<^bsub>padic_int p\<^esub> \<otimes>\<^bsub>padic_int p\<^esub> x) n = x n
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> (\<one>\<^bsub>padic_int p\<^esub> \<otimes>\<^bsub>padic_int p\<^esub> x) n = x n
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
n \<noteq> 0

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> (\<one>\<^bsub>padic_int p\<^esub> \<otimes>\<^bsub>padic_int p\<^esub> x) n = x n
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
n \<noteq> 0
[PROOF STEP]
have "residues (p^n)"
[PROOF STATE]
proof (prove)
using this:
n \<noteq> 0

goal (1 subgoal):
 1. residues (p ^ n)
[PROOF STEP]
by (simp add: assms(1) residues_n)
[PROOF STATE]
proof (state)
this:
residues (p ^ n)

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> (\<one>\<^bsub>padic_int p\<^esub> \<otimes>\<^bsub>padic_int p\<^esub> x) n = x n
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
residues (p ^ n)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
residues (p ^ n)

goal (1 subgoal):
 1. (\<one>\<^bsub>padic_int p\<^esub> \<otimes>\<^bsub>padic_int p\<^esub> x) n = x n
[PROOF STEP]
using False assms(2) cring.cring_simprules(12) padic_int_simps
        padic_mult_res padic_one_simp padic_set_res_closed residues.cring
[PROOF STATE]
proof (prove)
using this:
residues (p ^ n)
n \<noteq> 0
x \<in> carrier (padic_int p)
\<lbrakk>cring ?R; ?x \<in> carrier ?R\<rbrakk> \<Longrightarrow> \<one>\<^bsub>?R\<^esub> \<otimes>\<^bsub>?R\<^esub> ?x = ?x
\<one>\<^bsub>padic_int ?p\<^esub> = padic_one ?p
\<zero>\<^bsub>padic_int ?p\<^esub> = padic_zero ?p
(\<oplus>\<^bsub>padic_int ?p\<^esub>) = padic_add ?p
(\<otimes>\<^bsub>padic_int ?p\<^esub>) = padic_mult ?p
carrier (padic_int ?p) = padic_set ?p
padic_mult ?p ?f ?g ?n = ?f ?n \<otimes>\<^bsub>residue_ring (?p ^ ?n)\<^esub> ?g ?n
0 < ?n \<Longrightarrow> padic_one ?p ?n = \<one>\<^bsub>residue_ring (?p ^ ?n)\<^esub>
0 < ?n \<Longrightarrow> padic_one ?p ?n = 1
?f \<in> padic_set ?p \<Longrightarrow> ?f ?m \<in> carrier (residue_ring (?p ^ ?m))
residues ?m \<Longrightarrow> cring (residue_ring ?m)

goal (1 subgoal):
 1. (\<one>\<^bsub>padic_int p\<^esub> \<otimes>\<^bsub>padic_int p\<^esub> x) n = x n
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
(\<one>\<^bsub>padic_int p\<^esub> \<otimes>\<^bsub>padic_int p\<^esub> x) n = x n

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<one>\<^bsub>padic_int p\<^esub> \<otimes>\<^bsub>padic_int p\<^esub> x) n = x n

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma Ide_append_iff\<^sub>P:
    shows "\<lbrakk>T \<noteq> []; U \<noteq> []\<rbrakk> \<Longrightarrow> Ide (T @ U) \<longleftrightarrow> Ide T \<and> Ide U \<and> Trgs T \<subseteq> Srcs U"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>T \<noteq> []; U \<noteq> []\<rbrakk> \<Longrightarrow> Ide (T @ U) = (Ide T \<and> Ide U \<and> Trgs T \<subseteq> Srcs U)
[PROOF STEP]
using Ide_char
[PROOF STATE]
proof (prove)
using this:
Ide ?T = (Arr ?T \<and> set ?T \<subseteq> Collect R.ide)

goal (1 subgoal):
 1. \<lbrakk>T \<noteq> []; U \<noteq> []\<rbrakk> \<Longrightarrow> Ide (T @ U) = (Ide T \<and> Ide U \<and> Trgs T \<subseteq> Srcs U)
[PROOF STEP]
by auto


[STATEMENT]
lemma subst_ML_coincidence:
  "closed\<^sub>M\<^sub>L k v \<Longrightarrow> \<forall>i<k. \<sigma> i = \<sigma>' i \<Longrightarrow> subst\<^sub>M\<^sub>L \<sigma> v = subst\<^sub>M\<^sub>L \<sigma>' v"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>closed\<^sub>M\<^sub>L k v; \<forall>i<k. \<sigma> i = \<sigma>' i\<rbrakk> \<Longrightarrow> subst\<^sub>M\<^sub>L \<sigma> v = subst\<^sub>M\<^sub>L \<sigma>' v
[PROOF STEP]
by (induct \<sigma> v arbitrary: k \<sigma>' rule: subst_ML.induct) auto


[STATEMENT]
lemma finite_before[simp]: "finite (before x xs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite (before x xs)
[PROOF STEP]
apply(rule finite_subset[where B = "set xs"])
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. before x xs \<subseteq> set xs
 2. finite (set xs)
[PROOF STEP]
apply (auto dest: before_in_setD1)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma inj_on_pairself:
  assumes "inj_on f S" and "T \<subseteq> S \<times> S"
  shows "inj_on (pairself f) T"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inj_on (pairself f) T
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
inj_on f S
T \<subseteq> S \<times> S

goal (1 subgoal):
 1. inj_on (pairself f) T
[PROOF STEP]
unfolding pairself_def
[PROOF STATE]
proof (prove)
using this:
inj_on f S
T \<subseteq> S \<times> S

goal (1 subgoal):
 1. inj_on (\<lambda>x. case x of (u, v) \<Rightarrow> (f u, f v)) T
[PROOF STEP]
by (rule inj_onI_pair)


[STATEMENT]
lemma reflect_poly_monom: "reflect_poly (monom n i) = monom n 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. reflect_poly (monom n i) = monom n 0
[PROOF STEP]
apply (induction i)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. reflect_poly (monom n 0) = monom n 0
 2. \<And>i. reflect_poly (monom n i) = monom n 0 \<Longrightarrow> reflect_poly (monom n (Suc i)) = monom n 0
[PROOF STEP]
by (auto simp: coeffs_eq_iff coeffs_monom coeffs_reflect_poly)


[STATEMENT]
lemma omap_eq_append_conv[simp]: "omap f xs = Some (ys\<^sub>1@ys\<^sub>2) \<longleftrightarrow> (\<exists>xs\<^sub>1 xs\<^sub>2. xs=xs\<^sub>1@xs\<^sub>2 \<and> omap f xs\<^sub>1 = Some ys\<^sub>1 \<and> omap f xs\<^sub>2 = Some ys\<^sub>2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (omap f xs = Some (ys\<^sub>1 @ ys\<^sub>2)) = (\<exists>xs\<^sub>1 xs\<^sub>2. xs = xs\<^sub>1 @ xs\<^sub>2 \<and> omap f xs\<^sub>1 = Some ys\<^sub>1 \<and> omap f xs\<^sub>2 = Some ys\<^sub>2)
[PROOF STEP]
apply (induction ys\<^sub>1 arbitrary: xs)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>xs. (omap f xs = Some ([] @ ys\<^sub>2)) = (\<exists>xs\<^sub>1 xs\<^sub>2. xs = xs\<^sub>1 @ xs\<^sub>2 \<and> omap f xs\<^sub>1 = Some [] \<and> omap f xs\<^sub>2 = Some ys\<^sub>2)
 2. \<And>a ys\<^sub>1 xs. (\<And>xs. (omap f xs = Some (ys\<^sub>1 @ ys\<^sub>2)) = (\<exists>xs\<^sub>1 xs\<^sub>2. xs = xs\<^sub>1 @ xs\<^sub>2 \<and> omap f xs\<^sub>1 = Some ys\<^sub>1 \<and> omap f xs\<^sub>2 = Some ys\<^sub>2)) \<Longrightarrow> (omap f xs = Some ((a # ys\<^sub>1) @ ys\<^sub>2)) = (\<exists>xs\<^sub>1 xs\<^sub>2. xs = xs\<^sub>1 @ xs\<^sub>2 \<and> omap f xs\<^sub>1 = Some (a # ys\<^sub>1) \<and> omap f xs\<^sub>2 = Some ys\<^sub>2)
[PROOF STEP]
apply (auto 0 3 split: Option.bind_splits)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>a ys\<^sub>1 x xs\<^sub>1 xs\<^sub>2. \<lbrakk>\<And>xs. (omap f xs = Some (ys\<^sub>1 @ ys\<^sub>2)) = (\<exists>xs\<^sub>1 xs\<^sub>2. xs = xs\<^sub>1 @ xs\<^sub>2 \<and> omap f xs\<^sub>1 = Some ys\<^sub>1 \<and> omap f xs\<^sub>2 = Some ys\<^sub>2); f x = Some a; omap f xs\<^sub>1 = Some ys\<^sub>1; omap f xs\<^sub>2 = Some ys\<^sub>2\<rbrakk> \<Longrightarrow> \<exists>xs\<^sub>1' xs\<^sub>2'. x # xs\<^sub>1 @ xs\<^sub>2 = xs\<^sub>1' @ xs\<^sub>2' \<and> (\<exists>x xs'. xs\<^sub>1' = x # xs' \<and> f x = Some a \<and> omap f xs' = Some ys\<^sub>1) \<and> omap f xs\<^sub>2' = Some ys\<^sub>2
[PROOF STEP]
apply (metis append_Cons)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma is_orthogonal_cspan:
  assumes a1: "\<And>s. s \<in> S \<Longrightarrow> is_orthogonal a s" and a3: "x \<in> cspan S"
  shows "is_orthogonal a x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. is_orthogonal a x
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. is_orthogonal a x
[PROOF STEP]
have "\<exists>t r. finite t \<and> t \<subseteq> S \<and> (\<Sum>a\<in>t. r a *\<^sub>C a) = x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>t r. finite t \<and> t \<subseteq> S \<and> (\<Sum>a\<in>t. r a *\<^sub>C a) = x
[PROOF STEP]
using complex_vector.span_explicit
[PROOF STATE]
proof (prove)
using this:
cspan ?b = {\<Sum>a\<in>t. r a *\<^sub>C a |t r. finite t \<and> t \<subseteq> ?b}

goal (1 subgoal):
 1. \<exists>t r. finite t \<and> t \<subseteq> S \<and> (\<Sum>a\<in>t. r a *\<^sub>C a) = x
[PROOF STEP]
by (smt a3 mem_Collect_eq)
[PROOF STATE]
proof (state)
this:
\<exists>t r. finite t \<and> t \<subseteq> S \<and> (\<Sum>a\<in>t. r a *\<^sub>C a) = x

goal (1 subgoal):
 1. is_orthogonal a x
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<exists>t r. finite t \<and> t \<subseteq> S \<and> (\<Sum>a\<in>t. r a *\<^sub>C a) = x
[PROOF STEP]
obtain t r where b1: "finite t" and b2: "t \<subseteq> S" and b3: "(\<Sum>a\<in>t. r a *\<^sub>C a) = x"
[PROOF STATE]
proof (prove)
using this:
\<exists>t r. finite t \<and> t \<subseteq> S \<and> (\<Sum>a\<in>t. r a *\<^sub>C a) = x

goal (1 subgoal):
 1. (\<And>t r. \<lbrakk>finite t; t \<subseteq> S; (\<Sum>a\<in>t. r a *\<^sub>C a) = x\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
finite t
t \<subseteq> S
(\<Sum>a\<in>t. r a *\<^sub>C a) = x

goal (1 subgoal):
 1. is_orthogonal a x
[PROOF STEP]
have x1: "is_orthogonal a i"
    if "i\<in>t" for i
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. is_orthogonal a i
[PROOF STEP]
using b2 a1 that
[PROOF STATE]
proof (prove)
using this:
t \<subseteq> S
?s \<in> S \<Longrightarrow> is_orthogonal a ?s
i \<in> t

goal (1 subgoal):
 1. is_orthogonal a i
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
?i \<in> t \<Longrightarrow> is_orthogonal a ?i

goal (1 subgoal):
 1. is_orthogonal a x
[PROOF STEP]
have  "a \<bullet>\<^sub>C x = a \<bullet>\<^sub>C (\<Sum>i\<in>t. r i *\<^sub>C i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a \<bullet>\<^sub>C x = a \<bullet>\<^sub>C (\<Sum>i\<in>t. r i *\<^sub>C i)
[PROOF STEP]
by (simp add: b3)
[PROOF STATE]
proof (state)
this:
a \<bullet>\<^sub>C x = a \<bullet>\<^sub>C (\<Sum>i\<in>t. r i *\<^sub>C i)

goal (1 subgoal):
 1. is_orthogonal a x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
a \<bullet>\<^sub>C x = a \<bullet>\<^sub>C (\<Sum>i\<in>t. r i *\<^sub>C i)

goal (1 subgoal):
 1. is_orthogonal a x
[PROOF STEP]
have  "\<dots> = (\<Sum>i\<in>t. r i *\<^sub>C (a \<bullet>\<^sub>C i))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a \<bullet>\<^sub>C (\<Sum>i\<in>t. r i *\<^sub>C i) = (\<Sum>i\<in>t. r i *\<^sub>C (a \<bullet>\<^sub>C i))
[PROOF STEP]
by (simp add: cinner_sum_right)
[PROOF STATE]
proof (state)
this:
a \<bullet>\<^sub>C (\<Sum>i\<in>t. r i *\<^sub>C i) = (\<Sum>i\<in>t. r i *\<^sub>C (a \<bullet>\<^sub>C i))

goal (1 subgoal):
 1. is_orthogonal a x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
a \<bullet>\<^sub>C (\<Sum>i\<in>t. r i *\<^sub>C i) = (\<Sum>i\<in>t. r i *\<^sub>C (a \<bullet>\<^sub>C i))

goal (1 subgoal):
 1. is_orthogonal a x
[PROOF STEP]
have  "\<dots> = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i\<in>t. r i *\<^sub>C (a \<bullet>\<^sub>C i)) = 0
[PROOF STEP]
using x1
[PROOF STATE]
proof (prove)
using this:
?i \<in> t \<Longrightarrow> is_orthogonal a ?i

goal (1 subgoal):
 1. (\<Sum>i\<in>t. r i *\<^sub>C (a \<bullet>\<^sub>C i)) = 0
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<in>t. r i *\<^sub>C (a \<bullet>\<^sub>C i)) = 0

goal (1 subgoal):
 1. is_orthogonal a x
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
is_orthogonal a x
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
is_orthogonal a x

goal (1 subgoal):
 1. is_orthogonal a x
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
is_orthogonal a x

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma valid_index_append:
assumes is1_valid:"is1 \<lhd> ds1" and is2_valid:"is2 \<lhd> ds2"
shows "is1 @ is2 \<lhd> ds1 @ ds2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. is1 @ is2 \<lhd> ds1 @ ds2
[PROOF STEP]
apply (rule valid_indexI[of "is1 @ is2" "ds1 @ ds2"])
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. length (is1 @ is2) = length (ds1 @ ds2)
 2. \<And>m. m < length (ds1 @ ds2) \<Longrightarrow> (is1 @ is2) ! m < (ds1 @ ds2) ! m
[PROOF STEP]
unfolding nth_append
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. length (is1 @ is2) = length (ds1 @ ds2)
 2. \<And>m. m < length (ds1 @ ds2) \<Longrightarrow> (if m < length is1 then is1 ! m else is2 ! (m - length is1)) < (if m < length ds1 then ds1 ! m else ds2 ! (m - length ds1))
[PROOF STEP]
using valid_index_lt[OF is2_valid] valid_index_lt[OF is1_valid] valid_index_length[OF is1_valid] valid_index_length[OF is2_valid] length_append
[PROOF STATE]
proof (prove)
using this:
?m < length ds2 \<Longrightarrow> is2 ! ?m < ds2 ! ?m
?m < length ds1 \<Longrightarrow> is1 ! ?m < ds1 ! ?m
length is1 = length ds1
length is2 = length ds2
length (?xs @ ?ys) = length ?xs + length ?ys

goal (2 subgoals):
 1. length (is1 @ is2) = length (ds1 @ ds2)
 2. \<And>m. m < length (ds1 @ ds2) \<Longrightarrow> (if m < length is1 then is1 ! m else is2 ! (m - length is1)) < (if m < length ds1 then ds1 ! m else ds2 ! (m - length ds1))
[PROOF STEP]
by (auto simp add: \<open>length is1 = length ds1\<close>)


[STATEMENT]
lemma power_sub:
  fixes a :: nat
  assumes lt: "n \<le> m"
  and     av: "0 < a"
  shows "a ^ (m - n) = a ^ m div a ^ n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a ^ (m - n) = a ^ m div a ^ n
[PROOF STEP]
proof (subst nat_mult_eq_cancel1 [symmetric])
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. 0 < ?k
 2. ?k * a ^ (m - n) = ?k * (a ^ m div a ^ n)
[PROOF STEP]
show "(0::nat) < a ^ n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < a ^ n
[PROOF STEP]
using av
[PROOF STATE]
proof (prove)
using this:
0 < a

goal (1 subgoal):
 1. 0 < a ^ n
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
0 < a ^ n

goal (1 subgoal):
 1. a ^ n * a ^ (m - n) = a ^ n * (a ^ m div a ^ n)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. a ^ n * a ^ (m - n) = a ^ n * (a ^ m div a ^ n)
[PROOF STEP]
from lt
[PROOF STATE]
proof (chain)
picking this:
n \<le> m
[PROOF STEP]
obtain q where mv: "n + q = m"
[PROOF STATE]
proof (prove)
using this:
n \<le> m

goal (1 subgoal):
 1. (\<And>q. n + q = m \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (auto simp: le_iff_add)
[PROOF STATE]
proof (state)
this:
n + q = m

goal (1 subgoal):
 1. a ^ n * a ^ (m - n) = a ^ n * (a ^ m div a ^ n)
[PROOF STEP]
have "a ^ n * (a ^ m div a ^ n) = a ^ m"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a ^ n * (a ^ m div a ^ n) = a ^ m
[PROOF STEP]
proof (subst mult.commute)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. a ^ m div a ^ n * a ^ n = a ^ m
[PROOF STEP]
have "a ^ m = (a ^ m div a ^ n) * a ^ n + a ^ m mod a ^ n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a ^ m = a ^ m div a ^ n * a ^ n + a ^ m mod a ^ n
[PROOF STEP]
by (rule  div_mult_mod_eq [symmetric])
[PROOF STATE]
proof (state)
this:
a ^ m = a ^ m div a ^ n * a ^ n + a ^ m mod a ^ n

goal (1 subgoal):
 1. a ^ m div a ^ n * a ^ n = a ^ m
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
a ^ m = a ^ m div a ^ n * a ^ n + a ^ m mod a ^ n

goal (1 subgoal):
 1. a ^ m div a ^ n * a ^ n = a ^ m
[PROOF STEP]
have "a ^ m mod a ^ n = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a ^ m mod a ^ n = 0
[PROOF STEP]
by (subst mod_eq_0_iff_dvd, subst dvd_def, rule exI [where x = "a ^ q"],
      (subst power_add [symmetric] mv)+, rule refl)
[PROOF STATE]
proof (state)
this:
a ^ m mod a ^ n = 0

goal (1 subgoal):
 1. a ^ m div a ^ n * a ^ n = a ^ m
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
a ^ m = a ^ m div a ^ n * a ^ n + a ^ m mod a ^ n
a ^ m mod a ^ n = 0
[PROOF STEP]
show "(a ^ m div a ^ n) * a ^ n = a ^ m"
[PROOF STATE]
proof (prove)
using this:
a ^ m = a ^ m div a ^ n * a ^ n + a ^ m mod a ^ n
a ^ m mod a ^ n = 0

goal (1 subgoal):
 1. a ^ m div a ^ n * a ^ n = a ^ m
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
a ^ m div a ^ n * a ^ n = a ^ m

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
a ^ n * (a ^ m div a ^ n) = a ^ m

goal (1 subgoal):
 1. a ^ n * a ^ (m - n) = a ^ n * (a ^ m div a ^ n)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
a ^ n * (a ^ m div a ^ n) = a ^ m
[PROOF STEP]
show "a ^ n * a ^ (m - n) = a ^ n * (a ^ m div a ^ n)"
[PROOF STATE]
proof (prove)
using this:
a ^ n * (a ^ m div a ^ n) = a ^ m

goal (1 subgoal):
 1. a ^ n * a ^ (m - n) = a ^ n * (a ^ m div a ^ n)
[PROOF STEP]
using lt
[PROOF STATE]
proof (prove)
using this:
a ^ n * (a ^ m div a ^ n) = a ^ m
n \<le> m

goal (1 subgoal):
 1. a ^ n * a ^ (m - n) = a ^ n * (a ^ m div a ^ n)
[PROOF STEP]
by (simp add: power_add [symmetric])
[PROOF STATE]
proof (state)
this:
a ^ n * a ^ (m - n) = a ^ n * (a ^ m div a ^ n)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma [code abstract]:
  "linear_poly_map (r *R p) = scale r (linear_poly_map p)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. linear_poly_map (r *R p) = scale r (linear_poly_map p)
[PROOF STEP]
proof (cases "r = 0")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. r = 0 \<Longrightarrow> linear_poly_map (r *R p) = scale r (linear_poly_map p)
 2. r \<noteq> 0 \<Longrightarrow> linear_poly_map (r *R p) = scale r (linear_poly_map p)
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
r = 0

goal (2 subgoals):
 1. r = 0 \<Longrightarrow> linear_poly_map (r *R p) = scale r (linear_poly_map p)
 2. r \<noteq> 0 \<Longrightarrow> linear_poly_map (r *R p) = scale r (linear_poly_map p)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
r = 0
[PROOF STEP]
have *: "(r = 0) = True"
[PROOF STATE]
proof (prove)
using this:
r = 0

goal (1 subgoal):
 1. (r = 0) = True
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(r = 0) = True

goal (2 subgoals):
 1. r = 0 \<Longrightarrow> linear_poly_map (r *R p) = scale r (linear_poly_map p)
 2. r \<noteq> 0 \<Longrightarrow> linear_poly_map (r *R p) = scale r (linear_poly_map p)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. linear_poly_map (r *R p) = scale r (linear_poly_map p)
[PROOF STEP]
unfolding scale_def * if_True
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. linear_poly_map (r *R p) = fmempty
[PROOF STEP]
using True
[PROOF STATE]
proof (prove)
using this:
r = 0

goal (1 subgoal):
 1. linear_poly_map (r *R p) = fmempty
[PROOF STEP]
by (transfer, auto)
[PROOF STATE]
proof (state)
this:
linear_poly_map (r *R p) = scale r (linear_poly_map p)

goal (1 subgoal):
 1. r \<noteq> 0 \<Longrightarrow> linear_poly_map (r *R p) = scale r (linear_poly_map p)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. r \<noteq> 0 \<Longrightarrow> linear_poly_map (r *R p) = scale r (linear_poly_map p)
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
r \<noteq> 0

goal (1 subgoal):
 1. r \<noteq> 0 \<Longrightarrow> linear_poly_map (r *R p) = scale r (linear_poly_map p)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
r \<noteq> 0
[PROOF STEP]
have *: "(r = 0) = False"
[PROOF STATE]
proof (prove)
using this:
r \<noteq> 0

goal (1 subgoal):
 1. (r = 0) = False
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(r = 0) = False

goal (1 subgoal):
 1. r \<noteq> 0 \<Longrightarrow> linear_poly_map (r *R p) = scale r (linear_poly_map p)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. linear_poly_map (r *R p) = scale r (linear_poly_map p)
[PROOF STEP]
unfolding scale_def * if_False
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. linear_poly_map (r *R p) = fmmap ((*) r) (linear_poly_map p)
[PROOF STEP]
using False
[PROOF STATE]
proof (prove)
using this:
r \<noteq> 0

goal (1 subgoal):
 1. linear_poly_map (r *R p) = fmmap ((*) r) (linear_poly_map p)
[PROOF STEP]
by (transfer, auto)
[PROOF STATE]
proof (state)
this:
linear_poly_map (r *R p) = scale r (linear_poly_map p)

goal:
No subgoals!
[PROOF STEP]
qed