[STATEMENT]
lemma aligned_inter_non_empty:
  "\<lbrakk> {p..p + (2 ^ n - 1)} \<inter> {p..p + 2 ^ m - 1} = {};
     is_aligned p n; is_aligned p m\<rbrakk> \<Longrightarrow> False"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>{p..p + (2 ^ n - 1)} \<inter> {p..p + 2 ^ m - 1} = {}; is_aligned p n; is_aligned p m\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
apply (clarsimp simp only: range_inter)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<forall>x. \<not> (p \<le> x \<and> x \<le> p + (2 ^ n - 1) \<and> p \<le> x \<and> x \<le> p + 2 ^ m - 1); is_aligned p n; is_aligned p m\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
apply (erule_tac x=p in allE)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>is_aligned p n; is_aligned p m; \<not> (p \<le> p \<and> p \<le> p + (2 ^ n - 1) \<and> p \<le> p \<and> p \<le> p + 2 ^ m - 1)\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>is_aligned p n; is_aligned p m; p \<le> p + (2 ^ n - 1) \<longrightarrow> \<not> p \<le> p + 2 ^ m - 1\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
apply (erule impE)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>is_aligned p n; is_aligned p m\<rbrakk> \<Longrightarrow> p \<le> p + (2 ^ n - 1)
 2. \<lbrakk>is_aligned p n; is_aligned p m; \<not> p \<le> p + 2 ^ m - 1\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
apply (erule is_aligned_no_overflow')
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>is_aligned p n; is_aligned p m; \<not> p \<le> p + 2 ^ m - 1\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
apply (erule notE)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>is_aligned p n; is_aligned p m\<rbrakk> \<Longrightarrow> p \<le> p + 2 ^ m - 1
[PROOF STEP]
apply (erule is_aligned_no_overflow)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma mahler_landau_graeffe_approximation_core:
  assumes g: "g = graeffe_poly_impl f k"
  shows "mahler_measure f \<le> root (2 ^ Suc k) (real_of_int (\<Sum>a\<leftarrow>coeffs g. a * a))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mahler_measure f \<le> root (2 ^ Suc k) (real_of_int (\<Sum>a\<leftarrow>coeffs g. a * a))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. mahler_measure f \<le> root (2 ^ Suc k) (real_of_int (\<Sum>a\<leftarrow>coeffs g. a * a))
[PROOF STEP]
have "mahler_measure f = root (2^k) (mahler_measure f ^ (2^k))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mahler_measure f = root (2 ^ k) (mahler_measure f ^ 2 ^ k)
[PROOF STEP]
by (simp add: real_root_power_cancel mahler_measure_ge_0)
[PROOF STATE]
proof (state)
this:
mahler_measure f = root (2 ^ k) (mahler_measure f ^ 2 ^ k)

goal (1 subgoal):
 1. mahler_measure f \<le> root (2 ^ Suc k) (real_of_int (\<Sum>a\<leftarrow>coeffs g. a * a))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
mahler_measure f = root (2 ^ k) (mahler_measure f ^ 2 ^ k)

goal (1 subgoal):
 1. mahler_measure f \<le> root (2 ^ Suc k) (real_of_int (\<Sum>a\<leftarrow>coeffs g. a * a))
[PROOF STEP]
have "\<dots> = root (2^k) (mahler_measure g)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. root (2 ^ k) (mahler_measure f ^ 2 ^ k) = root (2 ^ k) (mahler_measure g)
[PROOF STEP]
unfolding graeffe_poly_impl_mahler g
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. root (2 ^ k) (mahler_measure f ^ 2 ^ k) = root (2 ^ k) (mahler_measure f ^ 2 ^ k)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
root (2 ^ k) (mahler_measure f ^ 2 ^ k) = root (2 ^ k) (mahler_measure g)

goal (1 subgoal):
 1. mahler_measure f \<le> root (2 ^ Suc k) (real_of_int (\<Sum>a\<leftarrow>coeffs g. a * a))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
root (2 ^ k) (mahler_measure f ^ 2 ^ k) = root (2 ^ k) (mahler_measure g)

goal (1 subgoal):
 1. mahler_measure f \<le> root (2 ^ Suc k) (real_of_int (\<Sum>a\<leftarrow>coeffs g. a * a))
[PROOF STEP]
have "\<dots> = root (2^k) (root 2 (((mahler_measure g)^2)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. root (2 ^ k) (mahler_measure g) = root (2 ^ k) (root 2 ((mahler_measure g)\<^sup>2))
[PROOF STEP]
by (simp add: real_root_power_cancel mahler_measure_ge_0)
[PROOF STATE]
proof (state)
this:
root (2 ^ k) (mahler_measure g) = root (2 ^ k) (root 2 ((mahler_measure g)\<^sup>2))

goal (1 subgoal):
 1. mahler_measure f \<le> root (2 ^ Suc k) (real_of_int (\<Sum>a\<leftarrow>coeffs g. a * a))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
root (2 ^ k) (mahler_measure g) = root (2 ^ k) (root 2 ((mahler_measure g)\<^sup>2))

goal (1 subgoal):
 1. mahler_measure f \<le> root (2 ^ Suc k) (real_of_int (\<Sum>a\<leftarrow>coeffs g. a * a))
[PROOF STEP]
have "\<dots> = root (2^Suc k) (((mahler_measure g)^2))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. root (2 ^ k) (root 2 ((mahler_measure g)\<^sup>2)) = root (2 ^ Suc k) ((mahler_measure g)\<^sup>2)
[PROOF STEP]
by (metis power_Suc2 real_root_mult_exp)
[PROOF STATE]
proof (state)
this:
root (2 ^ k) (root 2 ((mahler_measure g)\<^sup>2)) = root (2 ^ Suc k) ((mahler_measure g)\<^sup>2)

goal (1 subgoal):
 1. mahler_measure f \<le> root (2 ^ Suc k) (real_of_int (\<Sum>a\<leftarrow>coeffs g. a * a))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
root (2 ^ k) (root 2 ((mahler_measure g)\<^sup>2)) = root (2 ^ Suc k) ((mahler_measure g)\<^sup>2)

goal (1 subgoal):
 1. mahler_measure f \<le> root (2 ^ Suc k) (real_of_int (\<Sum>a\<leftarrow>coeffs g. a * a))
[PROOF STEP]
have "\<dots> \<le> root (2 ^ Suc k) (real_of_int (\<Sum>a\<leftarrow>coeffs g. a * a))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. root (2 ^ Suc k) ((mahler_measure g)\<^sup>2) \<le> root (2 ^ Suc k) (real_of_int (\<Sum>a\<leftarrow>coeffs g. a * a))
[PROOF STEP]
proof (rule real_root_le_mono, force)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (mahler_measure g)\<^sup>2 \<le> real_of_int (\<Sum>a\<leftarrow>coeffs g. a * a)
[PROOF STEP]
have square_mono: "0 \<le> (x :: real) \<Longrightarrow> x \<le> y \<Longrightarrow> x * x \<le> y * y" for x y
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 \<le> x; x \<le> y\<rbrakk> \<Longrightarrow> x * x \<le> y * y
[PROOF STEP]
by (simp add: mult_mono')
[PROOF STATE]
proof (state)
this:
\<lbrakk>0 \<le> ?x; ?x \<le> ?y\<rbrakk> \<Longrightarrow> ?x * ?x \<le> ?y * ?y

goal (1 subgoal):
 1. (mahler_measure g)\<^sup>2 \<le> real_of_int (\<Sum>a\<leftarrow>coeffs g. a * a)
[PROOF STEP]
obtain gs where gs: "coeffs g = gs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>gs. coeffs g = gs \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
coeffs g = gs

goal (1 subgoal):
 1. (mahler_measure g)\<^sup>2 \<le> real_of_int (\<Sum>a\<leftarrow>coeffs g. a * a)
[PROOF STEP]
have "(mahler_measure g)\<^sup>2 \<le> real_of_int \<bar>\<Sum>a\<leftarrow>coeffs g. a * a\<bar>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (mahler_measure g)\<^sup>2 \<le> real_of_int \<bar>\<Sum>a\<leftarrow>coeffs g. a * a\<bar>
[PROOF STEP]
using square_mono[OF mahler_measure_ge_0 Landau_inequality[of "of_int_poly g", folded mahler_measure_def]]
[PROOF STATE]
proof (prove)
using this:
mahler_measure g * mahler_measure g \<le> l2norm_complex (of_int_poly g) * l2norm_complex (of_int_poly g)

goal (1 subgoal):
 1. (mahler_measure g)\<^sup>2 \<le> real_of_int \<bar>\<Sum>a\<leftarrow>coeffs g. a * a\<bar>
[PROOF STEP]
by (auto simp: power2_eq_square coeffs_map_poly o_def of_int_hom.hom_sum_list)
[PROOF STATE]
proof (state)
this:
(mahler_measure g)\<^sup>2 \<le> real_of_int \<bar>\<Sum>a\<leftarrow>coeffs g. a * a\<bar>

goal (1 subgoal):
 1. (mahler_measure g)\<^sup>2 \<le> real_of_int (\<Sum>a\<leftarrow>coeffs g. a * a)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(mahler_measure g)\<^sup>2 \<le> real_of_int \<bar>\<Sum>a\<leftarrow>coeffs g. a * a\<bar>

goal (1 subgoal):
 1. (mahler_measure g)\<^sup>2 \<le> real_of_int (\<Sum>a\<leftarrow>coeffs g. a * a)
[PROOF STEP]
have "\<bar>\<Sum>a\<leftarrow>coeffs g. a * a\<bar> = (\<Sum>a\<leftarrow>coeffs g. a * a)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<bar>\<Sum>a\<leftarrow>coeffs g. a * a\<bar> = (\<Sum>a\<leftarrow>coeffs g. a * a)
[PROOF STEP]
unfolding gs
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<bar>\<Sum>a\<leftarrow>gs. a * a\<bar> = (\<Sum>a\<leftarrow>gs. a * a)
[PROOF STEP]
by (induct gs, auto)
[PROOF STATE]
proof (state)
this:
\<bar>\<Sum>a\<leftarrow>coeffs g. a * a\<bar> = (\<Sum>a\<leftarrow>coeffs g. a * a)

goal (1 subgoal):
 1. (mahler_measure g)\<^sup>2 \<le> real_of_int (\<Sum>a\<leftarrow>coeffs g. a * a)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(mahler_measure g)\<^sup>2 \<le> real_of_int (\<Sum>a\<leftarrow>coeffs g. a * a)
[PROOF STEP]
show "(mahler_measure g)\<^sup>2 \<le> real_of_int (\<Sum>a\<leftarrow>coeffs g. a * a)"
[PROOF STATE]
proof (prove)
using this:
(mahler_measure g)\<^sup>2 \<le> real_of_int (\<Sum>a\<leftarrow>coeffs g. a * a)

goal (1 subgoal):
 1. (mahler_measure g)\<^sup>2 \<le> real_of_int (\<Sum>a\<leftarrow>coeffs g. a * a)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
(mahler_measure g)\<^sup>2 \<le> real_of_int (\<Sum>a\<leftarrow>coeffs g. a * a)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
root (2 ^ Suc k) ((mahler_measure g)\<^sup>2) \<le> root (2 ^ Suc k) (real_of_int (\<Sum>a\<leftarrow>coeffs g. a * a))

goal (1 subgoal):
 1. mahler_measure f \<le> root (2 ^ Suc k) (real_of_int (\<Sum>a\<leftarrow>coeffs g. a * a))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
mahler_measure f \<le> root (2 ^ Suc k) (real_of_int (\<Sum>a\<leftarrow>coeffs g. a * a))
[PROOF STEP]
show "mahler_measure f \<le> root (2 ^ Suc k) (real_of_int (\<Sum>a\<leftarrow>coeffs g. a * a))"
[PROOF STATE]
proof (prove)
using this:
mahler_measure f \<le> root (2 ^ Suc k) (real_of_int (\<Sum>a\<leftarrow>coeffs g. a * a))

goal (1 subgoal):
 1. mahler_measure f \<le> root (2 ^ Suc k) (real_of_int (\<Sum>a\<leftarrow>coeffs g. a * a))
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
mahler_measure f \<le> root (2 ^ Suc k) (real_of_int (\<Sum>a\<leftarrow>coeffs g. a * a))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma cos_angle_eqD: "cos (angle a b c) = cos (angle d e f) \<Longrightarrow> angle a b c = angle d e f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cos (angle a b c) = cos (angle d e f) \<Longrightarrow> angle a b c = angle d e f
[PROOF STEP]
unfolding angle_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cos (vangle (a - b) (c - b)) = cos (vangle (d - e) (f - e)) \<Longrightarrow> vangle (a - b) (c - b) = vangle (d - e) (f - e)
[PROOF STEP]
by (rule cos_vangle_eqD)


[STATEMENT]
lemma stermsl_idem [simp]:
  "(\<Union>q\<in>stermsl p. stermsl q) = stermsl p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<Union> (stermsl ` stermsl p) = stermsl p
[PROOF STEP]
by (induct p) simp_all


[STATEMENT]
lemma negate_negate_dfa: "negate_dfa (negate_dfa A) = A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. negate_dfa (negate_dfa A) = A
[PROOF STEP]
proof (induct A)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a b. negate_dfa (negate_dfa (a, b)) = (a, b)
[PROOF STEP]
case (Pair t a)
[PROOF STATE]
proof (state)
this:

goal (1 subgoal):
 1. \<And>a b. negate_dfa (negate_dfa (a, b)) = (a, b)
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. negate_dfa (negate_dfa (t, a)) = (t, a)
[PROOF STEP]
by (induct a) (simp add: negate_dfa_def)+
[PROOF STATE]
proof (state)
this:
negate_dfa (negate_dfa (t, a)) = (t, a)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma equiv_funI:
  assumes "\<exists>c\<^sub>1>0. \<exists>c\<^sub>2>0. \<exists>n. \<forall>m>n. f m \<le> c\<^sub>1 * g m \<and> g m \<le> c\<^sub>2 * f m"
  shows "f \<cong> g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f \<cong> g
[PROOF STEP]
unfolding equiv_fun_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>c\<^sub>1>0. \<exists>c\<^sub>2>0. \<exists>n. \<forall>m>n. f m \<le> c\<^sub>1 * g m \<and> g m \<le> c\<^sub>2 * f m
[PROOF STEP]
by (rule assms)


[STATEMENT]
lemma lemmaA_3_8:  "(M + N) -s S = (M -s S) + (N -s S)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (M + N) -s S = M -s S + N -s S
[PROOF STEP]
unfolding diff_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {#x \<in># M + N. x \<notin> S#} = {#x \<in># M. x \<notin> S#} + {#x \<in># N. x \<notin> S#}
[PROOF STEP]
by (rule multiset_eqI) simp


[STATEMENT]
lemma reduce_system_matrix_signs_helper_aux:
  fixes p:: "real poly"
  fixes qs :: "real poly list"
  fixes subsets :: "nat list list"
  fixes signs :: "rat list list"
  fixes S:: "nat list"
  assumes well_def_h: "\<forall>x. List.member S x \<longrightarrow> x < length signs"
  assumes nonzero: "p \<noteq> 0"
  shows "alt_matrix_A (take_indices signs S) subsets = take_cols_from_matrix (alt_matrix_A signs subsets) S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. alt_matrix_A (take_indices signs S) subsets = take_cols_from_matrix (alt_matrix_A signs subsets) S
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. alt_matrix_A (take_indices signs S) subsets = take_cols_from_matrix (alt_matrix_A signs subsets) S
[PROOF STEP]
have h0a: "dim_col (take_cols_from_matrix (alt_matrix_A signs subsets) S) = length (take_indices signs S)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_col (take_cols_from_matrix (alt_matrix_A signs subsets) S) = length (take_indices signs S)
[PROOF STEP]
unfolding take_cols_from_matrix_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_col (mat_of_cols (dim_row (alt_matrix_A signs subsets)) (take_indices (cols (alt_matrix_A signs subsets)) S)) = length (take_indices signs S)
[PROOF STEP]
apply (auto)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (take_indices (cols (alt_matrix_A signs subsets)) S) = length (take_indices signs S)
[PROOF STEP]
unfolding take_indices_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (map ((!) (cols (alt_matrix_A signs subsets))) S) = length (map ((!) signs) S)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
dim_col (take_cols_from_matrix (alt_matrix_A signs subsets) S) = length (take_indices signs S)

goal (1 subgoal):
 1. alt_matrix_A (take_indices signs S) subsets = take_cols_from_matrix (alt_matrix_A signs subsets) S
[PROOF STEP]
have h0: "\<forall>i < length (take_indices signs S). (col (alt_matrix_A (take_indices signs S) subsets ) i =
col (take_cols_from_matrix (alt_matrix_A signs subsets) S) i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>i<length (take_indices signs S). col (alt_matrix_A (take_indices signs S) subsets) i = col (take_cols_from_matrix (alt_matrix_A signs subsets) S) i
[PROOF STEP]
proof clarsimp
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i. i < length (take_indices signs S) \<Longrightarrow> col (alt_matrix_A (take_indices signs S) subsets) i = col (take_cols_from_matrix (alt_matrix_A signs subsets) S) i
[PROOF STEP]
fix i
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i. i < length (take_indices signs S) \<Longrightarrow> col (alt_matrix_A (take_indices signs S) subsets) i = col (take_cols_from_matrix (alt_matrix_A signs subsets) S) i
[PROOF STEP]
assume asm: "i < length (take_indices signs S)"
[PROOF STATE]
proof (state)
this:
i < length (take_indices signs S)

goal (1 subgoal):
 1. \<And>i. i < length (take_indices signs S) \<Longrightarrow> col (alt_matrix_A (take_indices signs S) subsets) i = col (take_cols_from_matrix (alt_matrix_A signs subsets) S) i
[PROOF STEP]
have i_lt: "i < length (map ((!) (cols (alt_matrix_A signs subsets))) S)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. i < length (map ((!) (cols (alt_matrix_A signs subsets))) S)
[PROOF STEP]
using asm
[PROOF STATE]
proof (prove)
using this:
i < length (take_indices signs S)

goal (1 subgoal):
 1. i < length (map ((!) (cols (alt_matrix_A signs subsets))) S)
[PROOF STEP]
apply (auto)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. i < length (take_indices signs S) \<Longrightarrow> i < length S
[PROOF STEP]
unfolding take_indices_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. i < length (map ((!) signs) S) \<Longrightarrow> i < length S
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
i < length (map ((!) (cols (alt_matrix_A signs subsets))) S)

goal (1 subgoal):
 1. \<And>i. i < length (take_indices signs S) \<Longrightarrow> col (alt_matrix_A (take_indices signs S) subsets) i = col (take_cols_from_matrix (alt_matrix_A signs subsets) S) i
[PROOF STEP]
have h0: " vec (length subsets) (\<lambda>j. z (subsets ! j) (map ((!) signs) S ! i)) =
      vec (length subsets) (\<lambda>j. z (subsets ! j) (signs ! (S ! i)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vec (length subsets) (\<lambda>j. z (subsets ! j) (map ((!) signs) S ! i)) = vec (length subsets) (\<lambda>j. z (subsets ! j) (signs ! (S ! i)))
[PROOF STEP]
using nth_map
[PROOF STATE]
proof (prove)
using this:
?n < length ?xs \<Longrightarrow> map ?f ?xs ! ?n = ?f (?xs ! ?n)

goal (1 subgoal):
 1. vec (length subsets) (\<lambda>j. z (subsets ! j) (map ((!) signs) S ! i)) = vec (length subsets) (\<lambda>j. z (subsets ! j) (signs ! (S ! i)))
[PROOF STEP]
by (metis \<open>i < length (take_indices signs S)\<close> length_map take_indices_def)
[PROOF STATE]
proof (state)
this:
vec (length subsets) (\<lambda>j. z (subsets ! j) (map ((!) signs) S ! i)) = vec (length subsets) (\<lambda>j. z (subsets ! j) (signs ! (S ! i)))

goal (1 subgoal):
 1. \<And>i. i < length (take_indices signs S) \<Longrightarrow> col (alt_matrix_A (take_indices signs S) subsets) i = col (take_cols_from_matrix (alt_matrix_A signs subsets) S) i
[PROOF STEP]
have dim: "(map ((!) (cols (alt_matrix_A signs subsets))) S) ! i \<in> carrier_vec (dim_row (alt_matrix_A signs subsets))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map ((!) (cols (alt_matrix_A signs subsets))) S ! i \<in> carrier_vec (dim_row (alt_matrix_A signs subsets))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. map ((!) (cols (alt_matrix_A signs subsets))) S ! i \<in> carrier_vec (dim_row (alt_matrix_A signs subsets))
[PROOF STEP]
have "dim_col (alt_matrix_A signs subsets) = length (signs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_col (alt_matrix_A signs subsets) = length signs
[PROOF STEP]
by (simp add: alt_matrix_A_def)
[PROOF STATE]
proof (state)
this:
dim_col (alt_matrix_A signs subsets) = length signs

goal (1 subgoal):
 1. map ((!) (cols (alt_matrix_A signs subsets))) S ! i \<in> carrier_vec (dim_row (alt_matrix_A signs subsets))
[PROOF STEP]
have well_d: "S ! i < length (signs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. S ! i < length signs
[PROOF STEP]
using well_def_h
[PROOF STATE]
proof (prove)
using this:
\<forall>x. List.member S x \<longrightarrow> x < length signs

goal (1 subgoal):
 1. S ! i < length signs
[PROOF STEP]
using i_lt in_set_member
[PROOF STATE]
proof (prove)
using this:
\<forall>x. List.member S x \<longrightarrow> x < length signs
i < length (map ((!) (cols (alt_matrix_A signs subsets))) S)
(?x \<in> set ?xs) = List.member ?xs ?x

goal (1 subgoal):
 1. S ! i < length signs
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
S ! i < length signs

goal (1 subgoal):
 1. map ((!) (cols (alt_matrix_A signs subsets))) S ! i \<in> carrier_vec (dim_row (alt_matrix_A signs subsets))
[PROOF STEP]
have
        map_eq: "(map ((!) (cols (alt_matrix_A signs subsets))) S) ! i  = nth (cols (alt_matrix_A signs subsets))  (S ! i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map ((!) (cols (alt_matrix_A signs subsets))) S ! i = cols (alt_matrix_A signs subsets) ! (S ! i)
[PROOF STEP]
using i_lt
[PROOF STATE]
proof (prove)
using this:
i < length (map ((!) (cols (alt_matrix_A signs subsets))) S)

goal (1 subgoal):
 1. map ((!) (cols (alt_matrix_A signs subsets))) S ! i = cols (alt_matrix_A signs subsets) ! (S ! i)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
map ((!) (cols (alt_matrix_A signs subsets))) S ! i = cols (alt_matrix_A signs subsets) ! (S ! i)

goal (1 subgoal):
 1. map ((!) (cols (alt_matrix_A signs subsets))) S ! i \<in> carrier_vec (dim_row (alt_matrix_A signs subsets))
[PROOF STEP]
have "nth (cols (alt_matrix_A signs subsets))  (S ! i) \<in> carrier_vec (dim_row (alt_matrix_A signs subsets))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cols (alt_matrix_A signs subsets) ! (S ! i) \<in> carrier_vec (dim_row (alt_matrix_A signs subsets))
[PROOF STEP]
using col_dim
[PROOF STATE]
proof (prove)
using this:
col ?A ?i \<in> carrier_vec (dim_row ?A)

goal (1 subgoal):
 1. cols (alt_matrix_A signs subsets) ! (S ! i) \<in> carrier_vec (dim_row (alt_matrix_A signs subsets))
[PROOF STEP]
unfolding cols_def
[PROOF STATE]
proof (prove)
using this:
col ?A ?i \<in> carrier_vec (dim_row ?A)

goal (1 subgoal):
 1. map (col (alt_matrix_A signs subsets)) [0..<dim_col (alt_matrix_A signs subsets)] ! (S ! i) \<in> carrier_vec (dim_row (alt_matrix_A signs subsets))
[PROOF STEP]
using nth_map well_d
[PROOF STATE]
proof (prove)
using this:
col ?A ?i \<in> carrier_vec (dim_row ?A)
?n < length ?xs \<Longrightarrow> map ?f ?xs ! ?n = ?f (?xs ! ?n)
S ! i < length signs

goal (1 subgoal):
 1. map (col (alt_matrix_A signs subsets)) [0..<dim_col (alt_matrix_A signs subsets)] ! (S ! i) \<in> carrier_vec (dim_row (alt_matrix_A signs subsets))
[PROOF STEP]
by (simp add: \<open>dim_col (alt_matrix_A signs subsets) = length signs\<close>)
[PROOF STATE]
proof (state)
this:
cols (alt_matrix_A signs subsets) ! (S ! i) \<in> carrier_vec (dim_row (alt_matrix_A signs subsets))

goal (1 subgoal):
 1. map ((!) (cols (alt_matrix_A signs subsets))) S ! i \<in> carrier_vec (dim_row (alt_matrix_A signs subsets))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
cols (alt_matrix_A signs subsets) ! (S ! i) \<in> carrier_vec (dim_row (alt_matrix_A signs subsets))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
cols (alt_matrix_A signs subsets) ! (S ! i) \<in> carrier_vec (dim_row (alt_matrix_A signs subsets))

goal (1 subgoal):
 1. map ((!) (cols (alt_matrix_A signs subsets))) S ! i \<in> carrier_vec (dim_row (alt_matrix_A signs subsets))
[PROOF STEP]
using map_eq
[PROOF STATE]
proof (prove)
using this:
cols (alt_matrix_A signs subsets) ! (S ! i) \<in> carrier_vec (dim_row (alt_matrix_A signs subsets))
map ((!) (cols (alt_matrix_A signs subsets))) S ! i = cols (alt_matrix_A signs subsets) ! (S ! i)

goal (1 subgoal):
 1. map ((!) (cols (alt_matrix_A signs subsets))) S ! i \<in> carrier_vec (dim_row (alt_matrix_A signs subsets))
[PROOF STEP]
unfolding alt_matrix_A_def
[PROOF STATE]
proof (prove)
using this:
cols (mat (length subsets) (length signs) (\<lambda>(i, j). z (subsets ! i) (signs ! j))) ! (S ! i) \<in> carrier_vec (dim_row (mat (length subsets) (length signs) (\<lambda>(i, j). z (subsets ! i) (signs ! j))))
map ((!) (cols (mat (length subsets) (length signs) (\<lambda>(i, j). z (subsets ! i) (signs ! j))))) S ! i = cols (mat (length subsets) (length signs) (\<lambda>(i, j). z (subsets ! i) (signs ! j))) ! (S ! i)

goal (1 subgoal):
 1. map ((!) (cols (mat (length subsets) (length signs) (\<lambda>(i, j). z (subsets ! i) (signs ! j))))) S ! i \<in> carrier_vec (dim_row (mat (length subsets) (length signs) (\<lambda>(i, j). z (subsets ! i) (signs ! j))))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
map ((!) (cols (alt_matrix_A signs subsets))) S ! i \<in> carrier_vec (dim_row (alt_matrix_A signs subsets))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
map ((!) (cols (alt_matrix_A signs subsets))) S ! i \<in> carrier_vec (dim_row (alt_matrix_A signs subsets))

goal (1 subgoal):
 1. \<And>i. i < length (take_indices signs S) \<Longrightarrow> col (alt_matrix_A (take_indices signs S) subsets) i = col (take_cols_from_matrix (alt_matrix_A signs subsets) S) i
[PROOF STEP]
have h1: "col (take_cols_from_matrix (alt_matrix_A signs subsets) S) i =
      col (mat_of_cols (dim_row (alt_matrix_A signs subsets)) (map ((!) (cols (alt_matrix_A signs subsets))) S)) i "
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. col (take_cols_from_matrix (alt_matrix_A signs subsets) S) i = col (mat_of_cols (dim_row (alt_matrix_A signs subsets)) (map ((!) (cols (alt_matrix_A signs subsets))) S)) i
[PROOF STEP]
by (simp add: take_cols_from_matrix_def take_indices_def)
[PROOF STATE]
proof (state)
this:
col (take_cols_from_matrix (alt_matrix_A signs subsets) S) i = col (mat_of_cols (dim_row (alt_matrix_A signs subsets)) (map ((!) (cols (alt_matrix_A signs subsets))) S)) i

goal (1 subgoal):
 1. \<And>i. i < length (take_indices signs S) \<Longrightarrow> col (alt_matrix_A (take_indices signs S) subsets) i = col (take_cols_from_matrix (alt_matrix_A signs subsets) S) i
[PROOF STEP]
have h2: "col (mat_of_cols (dim_row (alt_matrix_A signs subsets)) (map ((!) (cols (alt_matrix_A signs subsets))) S)) i
      = nth (map ((!) (cols (alt_matrix_A signs subsets))) S) i "
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. col (mat_of_cols (dim_row (alt_matrix_A signs subsets)) (map ((!) (cols (alt_matrix_A signs subsets))) S)) i = map ((!) (cols (alt_matrix_A signs subsets))) S ! i
[PROOF STEP]
using dim i_lt asm col_mat_of_cols[where j = "i", where n = "(dim_row (alt_matrix_A signs subsets))",
          where vs = "(map ((!) (cols (alt_matrix_A signs subsets))) S)"]
[PROOF STATE]
proof (prove)
using this:
map ((!) (cols (alt_matrix_A signs subsets))) S ! i \<in> carrier_vec (dim_row (alt_matrix_A signs subsets))
i < length (map ((!) (cols (alt_matrix_A signs subsets))) S)
i < length (take_indices signs S)
\<lbrakk>i < length (map ((!) (cols (alt_matrix_A signs subsets))) S); map ((!) (cols (alt_matrix_A signs subsets))) S ! i \<in> carrier_vec (dim_row (alt_matrix_A signs subsets))\<rbrakk> \<Longrightarrow> col (mat_of_cols (dim_row (alt_matrix_A signs subsets)) (map ((!) (cols (alt_matrix_A signs subsets))) S)) i = map ((!) (cols (alt_matrix_A signs subsets))) S ! i

goal (1 subgoal):
 1. col (mat_of_cols (dim_row (alt_matrix_A signs subsets)) (map ((!) (cols (alt_matrix_A signs subsets))) S)) i = map ((!) (cols (alt_matrix_A signs subsets))) S ! i
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
col (mat_of_cols (dim_row (alt_matrix_A signs subsets)) (map ((!) (cols (alt_matrix_A signs subsets))) S)) i = map ((!) (cols (alt_matrix_A signs subsets))) S ! i

goal (1 subgoal):
 1. \<And>i. i < length (take_indices signs S) \<Longrightarrow> col (alt_matrix_A (take_indices signs S) subsets) i = col (take_cols_from_matrix (alt_matrix_A signs subsets) S) i
[PROOF STEP]
have h3: "col (take_cols_from_matrix (alt_matrix_A signs subsets) S) i = (col (alt_matrix_A signs subsets) (S !i))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. col (take_cols_from_matrix (alt_matrix_A signs subsets) S) i = col (alt_matrix_A signs subsets) (S ! i)
[PROOF STEP]
using h1 h2
[PROOF STATE]
proof (prove)
using this:
col (take_cols_from_matrix (alt_matrix_A signs subsets) S) i = col (mat_of_cols (dim_row (alt_matrix_A signs subsets)) (map ((!) (cols (alt_matrix_A signs subsets))) S)) i
col (mat_of_cols (dim_row (alt_matrix_A signs subsets)) (map ((!) (cols (alt_matrix_A signs subsets))) S)) i = map ((!) (cols (alt_matrix_A signs subsets))) S ! i

goal (1 subgoal):
 1. col (take_cols_from_matrix (alt_matrix_A signs subsets) S) i = col (alt_matrix_A signs subsets) (S ! i)
[PROOF STEP]
apply (auto)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>col (take_cols_from_matrix (alt_matrix_A signs subsets) S) i = map ((!) (cols (alt_matrix_A signs subsets))) S ! i; col (mat_of_cols (dim_row (alt_matrix_A signs subsets)) (map ((!) (cols (alt_matrix_A signs subsets))) S)) i = map ((!) (cols (alt_matrix_A signs subsets))) S ! i\<rbrakk> \<Longrightarrow> map ((!) (cols (alt_matrix_A signs subsets))) S ! i = col (alt_matrix_A signs subsets) (S ! i)
[PROOF STEP]
by (metis alt_matrix_char asm cols_nth dim_col_mat(1) in_set_member length_map mat_of_rows_list_def matrix_A_def nth_map nth_mem take_indices_def well_def_h)
[PROOF STATE]
proof (state)
this:
col (take_cols_from_matrix (alt_matrix_A signs subsets) S) i = col (alt_matrix_A signs subsets) (S ! i)

goal (1 subgoal):
 1. \<And>i. i < length (take_indices signs S) \<Longrightarrow> col (alt_matrix_A (take_indices signs S) subsets) i = col (take_cols_from_matrix (alt_matrix_A signs subsets) S) i
[PROOF STEP]
have "vec (length subsets) (\<lambda>j. z (subsets ! j) (signs ! (S ! i))) = (col (alt_matrix_A signs subsets) (S !i))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vec (length subsets) (\<lambda>j. z (subsets ! j) (signs ! (S ! i))) = col (alt_matrix_A signs subsets) (S ! i)
[PROOF STEP]
by (metis asm in_set_member length_map nth_mem signs_are_cols take_indices_def well_def_h)
[PROOF STATE]
proof (state)
this:
vec (length subsets) (\<lambda>j. z (subsets ! j) (signs ! (S ! i))) = col (alt_matrix_A signs subsets) (S ! i)

goal (1 subgoal):
 1. \<And>i. i < length (take_indices signs S) \<Longrightarrow> col (alt_matrix_A (take_indices signs S) subsets) i = col (take_cols_from_matrix (alt_matrix_A signs subsets) S) i
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
vec (length subsets) (\<lambda>j. z (subsets ! j) (signs ! (S ! i))) = col (alt_matrix_A signs subsets) (S ! i)
[PROOF STEP]
have "vec (length subsets) (\<lambda>j. z (subsets ! j) (take_indices signs S ! i)) =
      col (take_cols_from_matrix (alt_matrix_A signs subsets) S) i "
[PROOF STATE]
proof (prove)
using this:
vec (length subsets) (\<lambda>j. z (subsets ! j) (signs ! (S ! i))) = col (alt_matrix_A signs subsets) (S ! i)

goal (1 subgoal):
 1. vec (length subsets) (\<lambda>j. z (subsets ! j) (take_indices signs S ! i)) = col (take_cols_from_matrix (alt_matrix_A signs subsets) S) i
[PROOF STEP]
using h0 h3
[PROOF STATE]
proof (prove)
using this:
vec (length subsets) (\<lambda>j. z (subsets ! j) (signs ! (S ! i))) = col (alt_matrix_A signs subsets) (S ! i)
vec (length subsets) (\<lambda>j. z (subsets ! j) (map ((!) signs) S ! i)) = vec (length subsets) (\<lambda>j. z (subsets ! j) (signs ! (S ! i)))
col (take_cols_from_matrix (alt_matrix_A signs subsets) S) i = col (alt_matrix_A signs subsets) (S ! i)

goal (1 subgoal):
 1. vec (length subsets) (\<lambda>j. z (subsets ! j) (take_indices signs S ! i)) = col (take_cols_from_matrix (alt_matrix_A signs subsets) S) i
[PROOF STEP]
by (simp add: take_indices_def)
[PROOF STATE]
proof (state)
this:
vec (length subsets) (\<lambda>j. z (subsets ! j) (take_indices signs S ! i)) = col (take_cols_from_matrix (alt_matrix_A signs subsets) S) i

goal (1 subgoal):
 1. \<And>i. i < length (take_indices signs S) \<Longrightarrow> col (alt_matrix_A (take_indices signs S) subsets) i = col (take_cols_from_matrix (alt_matrix_A signs subsets) S) i
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
vec (length subsets) (\<lambda>j. z (subsets ! j) (take_indices signs S ! i)) = col (take_cols_from_matrix (alt_matrix_A signs subsets) S) i
[PROOF STEP]
show "col (alt_matrix_A (take_indices signs S) subsets) i =
         col (take_cols_from_matrix (alt_matrix_A signs subsets) S) i "
[PROOF STATE]
proof (prove)
using this:
vec (length subsets) (\<lambda>j. z (subsets ! j) (take_indices signs S ! i)) = col (take_cols_from_matrix (alt_matrix_A signs subsets) S) i

goal (1 subgoal):
 1. col (alt_matrix_A (take_indices signs S) subsets) i = col (take_cols_from_matrix (alt_matrix_A signs subsets) S) i
[PROOF STEP]
using asm signs_are_cols[where signs = "(take_indices signs S)", where subsets = "subsets"]
[PROOF STATE]
proof (prove)
using this:
vec (length subsets) (\<lambda>j. z (subsets ! j) (take_indices signs S ! i)) = col (take_cols_from_matrix (alt_matrix_A signs subsets) S) i
i < length (take_indices signs S)
\<forall>i<length (take_indices signs S). col (alt_matrix_A (take_indices signs S) subsets) i = vec (length subsets) (\<lambda>j. z (subsets ! j) (take_indices signs S ! i))

goal (1 subgoal):
 1. col (alt_matrix_A (take_indices signs S) subsets) i = col (take_cols_from_matrix (alt_matrix_A signs subsets) S) i
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
col (alt_matrix_A (take_indices signs S) subsets) i = col (take_cols_from_matrix (alt_matrix_A signs subsets) S) i

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<forall>i<length (take_indices signs S). col (alt_matrix_A (take_indices signs S) subsets) i = col (take_cols_from_matrix (alt_matrix_A signs subsets) S) i

goal (1 subgoal):
 1. alt_matrix_A (take_indices signs S) subsets = take_cols_from_matrix (alt_matrix_A signs subsets) S
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<forall>i<length (take_indices signs S). col (alt_matrix_A (take_indices signs S) subsets) i = col (take_cols_from_matrix (alt_matrix_A signs subsets) S) i
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<forall>i<length (take_indices signs S). col (alt_matrix_A (take_indices signs S) subsets) i = col (take_cols_from_matrix (alt_matrix_A signs subsets) S) i

goal (1 subgoal):
 1. alt_matrix_A (take_indices signs S) subsets = take_cols_from_matrix (alt_matrix_A signs subsets) S
[PROOF STEP]
unfolding alt_matrix_A_def take_cols_from_matrix_def
[PROOF STATE]
proof (prove)
using this:
\<forall>i<length (take_indices signs S). col (mat (length subsets) (length (take_indices signs S)) (\<lambda>(i, j). z (subsets ! i) (take_indices signs S ! j))) i = col (mat_of_cols (dim_row (mat (length subsets) (length signs) (\<lambda>(i, j). z (subsets ! i) (signs ! j)))) (take_indices (cols (mat (length subsets) (length signs) (\<lambda>(i, j). z (subsets ! i) (signs ! j)))) S)) i

goal (1 subgoal):
 1. mat (length subsets) (length (take_indices signs S)) (\<lambda>(i, j). z (subsets ! i) (take_indices signs S ! j)) = mat_of_cols (dim_row (mat (length subsets) (length signs) (\<lambda>(i, j). z (subsets ! i) (signs ! j)))) (take_indices (cols (mat (length subsets) (length signs) (\<lambda>(i, j). z (subsets ! i) (signs ! j)))) S)
[PROOF STEP]
apply (auto)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>i<length (take_indices signs S). vec (length subsets) (\<lambda>ia. z (subsets ! ia) (take_indices signs S ! i)) = col (mat_of_cols (length subsets) (take_indices (cols (mat (length subsets) (length signs) (\<lambda>(i, j). z (subsets ! i) (signs ! j)))) S)) i \<Longrightarrow> mat (length subsets) (length (take_indices signs S)) (\<lambda>(i, j). z (subsets ! i) (take_indices signs S ! j)) = mat_of_cols (length subsets) (take_indices (cols (mat (length subsets) (length signs) (\<lambda>(i, j). z (subsets ! i) (signs ! j)))) S)
[PROOF STEP]
using h0a mat_col_eqI
[PROOF STATE]
proof (prove)
using this:
dim_col (take_cols_from_matrix (alt_matrix_A signs subsets) S) = length (take_indices signs S)
\<lbrakk>\<And>i. i < dim_col ?B \<Longrightarrow> col ?A i = col ?B i; dim_row ?A = dim_row ?B; dim_col ?A = dim_col ?B\<rbrakk> \<Longrightarrow> ?A = ?B

goal (1 subgoal):
 1. \<forall>i<length (take_indices signs S). vec (length subsets) (\<lambda>ia. z (subsets ! ia) (take_indices signs S ! i)) = col (mat_of_cols (length subsets) (take_indices (cols (mat (length subsets) (length signs) (\<lambda>(i, j). z (subsets ! i) (signs ! j)))) S)) i \<Longrightarrow> mat (length subsets) (length (take_indices signs S)) (\<lambda>(i, j). z (subsets ! i) (take_indices signs S ! j)) = mat_of_cols (length subsets) (take_indices (cols (mat (length subsets) (length signs) (\<lambda>(i, j). z (subsets ! i) (signs ! j)))) S)
[PROOF STEP]
by (metis alt_matrix_A_def dim_col_mat(1) dim_row_mat(1) h0 mat_of_cols_def take_cols_from_matrix_def)
[PROOF STATE]
proof (state)
this:
alt_matrix_A (take_indices signs S) subsets = take_cols_from_matrix (alt_matrix_A signs subsets) S

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma Longest_common_prefix_unique:
  \<open>\<exists>! ps. (\<forall>xs \<in> L. prefix ps xs) \<and> (\<forall>qs. (\<forall>xs \<in> L. prefix qs xs) \<longrightarrow> length qs \<le> length ps)\<close>
  if \<open>L \<noteq> {}\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>!ps. (\<forall>xs\<in>L. prefix ps xs) \<and> (\<forall>qs. (\<forall>xs\<in>L. prefix qs xs) \<longrightarrow> length qs \<le> length ps)
[PROOF STEP]
using that
[PROOF STATE]
proof (prove)
using this:
L \<noteq> {}

goal (1 subgoal):
 1. \<exists>!ps. (\<forall>xs\<in>L. prefix ps xs) \<and> (\<forall>qs. (\<forall>xs\<in>L. prefix qs xs) \<longrightarrow> length qs \<le> length ps)
[PROOF STEP]
apply (rule ex_ex1I[OF Longest_common_prefix_ex])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>ps y. \<lbrakk>(\<forall>xs\<in>L. prefix ps xs) \<and> (\<forall>qs. (\<forall>xs\<in>L. prefix qs xs) \<longrightarrow> length qs \<le> length ps); (\<forall>xs\<in>L. prefix y xs) \<and> (\<forall>qs. (\<forall>xs\<in>L. prefix qs xs) \<longrightarrow> length qs \<le> length y)\<rbrakk> \<Longrightarrow> ps = y
[PROOF STEP]
using that
[PROOF STATE]
proof (prove)
using this:
L \<noteq> {}

goal (1 subgoal):
 1. \<And>ps y. \<lbrakk>(\<forall>xs\<in>L. prefix ps xs) \<and> (\<forall>qs. (\<forall>xs\<in>L. prefix qs xs) \<longrightarrow> length qs \<le> length ps); (\<forall>xs\<in>L. prefix y xs) \<and> (\<forall>qs. (\<forall>xs\<in>L. prefix qs xs) \<longrightarrow> length qs \<le> length y)\<rbrakk> \<Longrightarrow> ps = y
[PROOF STEP]
apply (auto simp add: prefix_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>ps y x. \<lbrakk>\<forall>xs\<in>L. \<exists>zs. xs = ps @ zs; \<forall>qs. (\<forall>xs\<in>L. \<exists>zs. xs = qs @ zs) \<longrightarrow> length qs \<le> length ps; \<forall>xs\<in>L. \<exists>zs. xs = y @ zs; \<forall>qs. (\<forall>xs\<in>L. \<exists>zs. xs = qs @ zs) \<longrightarrow> length qs \<le> length y; ps \<noteq> y; x \<in> L\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
apply (metis append_eq_append_conv_if order.antisym)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma Id_on_union: "Id_on (A \<union> B) = Id_on A \<union> Id_on B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Id_on (A \<union> B) = Id_on A \<union> Id_on B
[PROOF STEP]
unfolding Id_on_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Union>x\<in>A \<union> B. {(x, x)}) = (\<Union>x\<in>A. {(x, x)}) \<union> (\<Union>x\<in>B. {(x, x)})
[PROOF STEP]
by auto


[STATEMENT]
lemma finite_map_to_set:
"finite (map_to_set m) = finite (dom m)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite (map_to_set m) = finite (dom m)
[PROOF STEP]
unfolding map_to_set_def map_to_set_dom
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite {(k, v). m k = Some v} = finite (fst ` {(k, v). m k = Some v})
[PROOF STEP]
apply (intro iffI finite_imageI)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. finite {(k, v). m k = Some v} \<Longrightarrow> finite {(k, v). m k = Some v}
 2. finite (fst ` {(k, v). m k = Some v}) \<Longrightarrow> finite {(k, v). m k = Some v}
[PROOF STEP]
apply assumption
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite (fst ` {(k, v). m k = Some v}) \<Longrightarrow> finite {(k, v). m k = Some v}
[PROOF STEP]
apply (rule finite_imageD[of fst])
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. finite (fst ` {(k, v). m k = Some v}) \<Longrightarrow> finite (fst ` {(k, v). m k = Some v})
 2. finite (fst ` {(k, v). m k = Some v}) \<Longrightarrow> inj_on fst {(k, v). m k = Some v}
[PROOF STEP]
apply assumption
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite (fst ` {(k, v). m k = Some v}) \<Longrightarrow> inj_on fst {(k, v). m k = Some v}
[PROOF STEP]
apply (simp add: inj_on_def)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
theorem finite_reach_simple_product:
  assumes "finite (reach \<Sigma> \<delta>\<^sub>1 q\<^sub>1)"
  assumes "finite (reach \<Sigma> \<delta>\<^sub>2 q\<^sub>2)"
  shows "finite (reach \<Sigma> (\<delta>\<^sub>1 \<times> \<delta>\<^sub>2) (q\<^sub>1, q\<^sub>2))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite (reach \<Sigma> \<delta>\<^sub>1 \<times> \<delta>\<^sub>2 (q\<^sub>1, q\<^sub>2))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. finite (reach \<Sigma> \<delta>\<^sub>1 \<times> \<delta>\<^sub>2 (q\<^sub>1, q\<^sub>2))
[PROOF STEP]
have "reach \<Sigma> (\<delta>\<^sub>1 \<times> \<delta>\<^sub>2) (q\<^sub>1, q\<^sub>2) \<subseteq> reach \<Sigma> \<delta>\<^sub>1 q\<^sub>1 \<times> reach \<Sigma> \<delta>\<^sub>2 q\<^sub>2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. reach \<Sigma> \<delta>\<^sub>1 \<times> \<delta>\<^sub>2 (q\<^sub>1, q\<^sub>2) \<subseteq> reach \<Sigma> \<delta>\<^sub>1 q\<^sub>1 \<times> reach \<Sigma> \<delta>\<^sub>2 q\<^sub>2
[PROOF STEP]
unfolding reach_def simple_product_run
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {(run \<delta>\<^sub>1 q\<^sub>1 w n, run \<delta>\<^sub>2 q\<^sub>2 w n) |w n. range w \<subseteq> \<Sigma>} \<subseteq> {run \<delta>\<^sub>1 q\<^sub>1 w n |w n. range w \<subseteq> \<Sigma>} \<times> {run \<delta>\<^sub>2 q\<^sub>2 w n |w n. range w \<subseteq> \<Sigma>}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
reach \<Sigma> \<delta>\<^sub>1 \<times> \<delta>\<^sub>2 (q\<^sub>1, q\<^sub>2) \<subseteq> reach \<Sigma> \<delta>\<^sub>1 q\<^sub>1 \<times> reach \<Sigma> \<delta>\<^sub>2 q\<^sub>2

goal (1 subgoal):
 1. finite (reach \<Sigma> \<delta>\<^sub>1 \<times> \<delta>\<^sub>2 (q\<^sub>1, q\<^sub>2))
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
reach \<Sigma> \<delta>\<^sub>1 \<times> \<delta>\<^sub>2 (q\<^sub>1, q\<^sub>2) \<subseteq> reach \<Sigma> \<delta>\<^sub>1 q\<^sub>1 \<times> reach \<Sigma> \<delta>\<^sub>2 q\<^sub>2

goal (1 subgoal):
 1. finite (reach \<Sigma> \<delta>\<^sub>1 \<times> \<delta>\<^sub>2 (q\<^sub>1, q\<^sub>2))
[PROOF STEP]
using assms finite_subset
[PROOF STATE]
proof (prove)
using this:
reach \<Sigma> \<delta>\<^sub>1 \<times> \<delta>\<^sub>2 (q\<^sub>1, q\<^sub>2) \<subseteq> reach \<Sigma> \<delta>\<^sub>1 q\<^sub>1 \<times> reach \<Sigma> \<delta>\<^sub>2 q\<^sub>2
finite (reach \<Sigma> \<delta>\<^sub>1 q\<^sub>1)
finite (reach \<Sigma> \<delta>\<^sub>2 q\<^sub>2)
\<lbrakk>?A \<subseteq> ?B; finite ?B\<rbrakk> \<Longrightarrow> finite ?A

goal (1 subgoal):
 1. finite (reach \<Sigma> \<delta>\<^sub>1 \<times> \<delta>\<^sub>2 (q\<^sub>1, q\<^sub>2))
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
finite (reach \<Sigma> \<delta>\<^sub>1 \<times> \<delta>\<^sub>2 (q\<^sub>1, q\<^sub>2))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
theorem "\<not> (\<exists>(x::int) (y::int) (z::int). 4*x + (-6::int)*y = 1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<nexists>x y z. 4 * x + - 6 * y = 1
[PROOF STEP]
by cooper


[STATEMENT]
lemma mult_monom: "monom x a * monom y b = monom (x + y) (a * b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. monom x a * monom y b = monom (x + y) (a * b)
[PROOF STEP]
by transfer' (simp add: Poly_Mapping.mult_single)


[STATEMENT]
lemma "((\<lambda>x::real. ((x + 1) powr (1 + 1/x) - x powr (1 + 1 / (x + a)))) \<longlongrightarrow> 1) at_top"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>x. (x + 1) powr (1 + 1 / x) - x powr (1 + 1 / (x + a))) \<longlongrightarrow> 1) at_top
[PROOF STEP]
by real_asymp


[STATEMENT]
lemma trees_of_size_Suc:
  "trees_of_size (Suc n) = (\<lambda>(l,r). Node l r) ` (\<Union>k\<le>n. trees_of_size k \<times> trees_of_size (n - k))"
    (is "?lhs = ?rhs")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. trees_of_size (Suc n) = (\<lambda>(l, r). Node l r) ` (\<Union>k\<le>n. trees_of_size k \<times> trees_of_size (n - k))
[PROOF STEP]
proof (rule set_eqI)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. (x \<in> trees_of_size (Suc n)) = (x \<in> (\<lambda>(l, r). Node l r) ` (\<Union>k\<le>n. trees_of_size k \<times> trees_of_size (n - k)))
[PROOF STEP]
fix t
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. (x \<in> trees_of_size (Suc n)) = (x \<in> (\<lambda>(l, r). Node l r) ` (\<Union>k\<le>n. trees_of_size k \<times> trees_of_size (n - k)))
[PROOF STEP]
show "t \<in> ?lhs \<longleftrightarrow> t \<in> ?rhs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (t \<in> trees_of_size (Suc n)) = (t \<in> (\<lambda>(l, r). Node l r) ` (\<Union>k\<le>n. trees_of_size k \<times> trees_of_size (n - k)))
[PROOF STEP]
by (cases t) (auto simp: trees_of_size_def)
[PROOF STATE]
proof (state)
this:
(t \<in> trees_of_size (Suc n)) = (t \<in> (\<lambda>(l, r). Node l r) ` (\<Union>k\<le>n. trees_of_size k \<times> trees_of_size (n - k)))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma product_nodes_finite_strong[iff]:
      assumes "alphabet\<^sub>1 A = alphabet\<^sub>2 B"
      shows "finite (c.nodes (product A B)) \<longleftrightarrow> finite (a.nodes A) \<and> finite (b.nodes B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite (c.nodes' (product A B)) = (finite (a.nodes' A) \<and> finite (b.nodes' B))
[PROOF STEP]
proof safe
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. finite (c.nodes' (product A B)) \<Longrightarrow> finite (a.nodes' A)
 2. finite (c.nodes' (product A B)) \<Longrightarrow> finite (b.nodes' B)
 3. \<lbrakk>finite (a.nodes' A); finite (b.nodes' B)\<rbrakk> \<Longrightarrow> finite (c.nodes' (product A B))
[PROOF STEP]
show "finite (a.nodes A)" if "finite (c.nodes (product A B))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite (a.nodes' A)
[PROOF STEP]
using product_nodes_fst assms that
[PROOF STATE]
proof (prove)
using this:
alphabet\<^sub>1 ?A \<subseteq> alphabet\<^sub>2 ?B \<Longrightarrow> fst ` c.nodes' (product ?A ?B) = a.nodes' ?A
alphabet\<^sub>1 A = alphabet\<^sub>2 B
finite (c.nodes' (product A B))

goal (1 subgoal):
 1. finite (a.nodes' A)
[PROOF STEP]
by (metis finite_imageI equalityD1)
[PROOF STATE]
proof (state)
this:
finite (c.nodes' (product A B)) \<Longrightarrow> finite (a.nodes' A)

goal (2 subgoals):
 1. finite (c.nodes' (product A B)) \<Longrightarrow> finite (b.nodes' B)
 2. \<lbrakk>finite (a.nodes' A); finite (b.nodes' B)\<rbrakk> \<Longrightarrow> finite (c.nodes' (product A B))
[PROOF STEP]
show "finite (b.nodes B)" if "finite (c.nodes (product A B))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite (b.nodes' B)
[PROOF STEP]
using product_nodes_snd assms that
[PROOF STATE]
proof (prove)
using this:
alphabet\<^sub>2 ?B \<subseteq> alphabet\<^sub>1 ?A \<Longrightarrow> snd ` c.nodes' (product ?A ?B) = b.nodes' ?B
alphabet\<^sub>1 A = alphabet\<^sub>2 B
finite (c.nodes' (product A B))

goal (1 subgoal):
 1. finite (b.nodes' B)
[PROOF STEP]
by (metis finite_imageI equalityD2)
[PROOF STATE]
proof (state)
this:
finite (c.nodes' (product A B)) \<Longrightarrow> finite (b.nodes' B)

goal (1 subgoal):
 1. \<lbrakk>finite (a.nodes' A); finite (b.nodes' B)\<rbrakk> \<Longrightarrow> finite (c.nodes' (product A B))
[PROOF STEP]
show "finite (c.nodes (product A B))" if "finite (a.nodes A)" "finite (b.nodes B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite (c.nodes' (product A B))
[PROOF STEP]
using that
[PROOF STATE]
proof (prove)
using this:
finite (a.nodes' A)
finite (b.nodes' B)

goal (1 subgoal):
 1. finite (c.nodes' (product A B))
[PROOF STEP]
by rule
[PROOF STATE]
proof (state)
this:
\<lbrakk>finite (a.nodes' A); finite (b.nodes' B)\<rbrakk> \<Longrightarrow> finite (c.nodes' (product A B))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma r01_r01_to_r01_image:
  assumes "0 < r1" "r1 < 1"
    shows "r01_r01_to_r01 (r1,r2) \<in> {0<..<1}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. r01_r01_to_r01 (r1, r2) \<in> {0<..<1}
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. r01_r01_to_r01 (r1, r2) \<in> {0<..<1}
[PROOF STEP]
obtain i where "r01_binary_expansion' r1 i = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>i. r01_binary_expansion' r1 i = 1 \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using r01_binary_expression_ex1[of r1] assms(1,2)
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>0 < r1; r1 < 1\<rbrakk> \<Longrightarrow> \<exists>i. r01_binary_expansion' r1 i = 1
0 < r1
r1 < 1

goal (1 subgoal):
 1. (\<And>i. r01_binary_expansion' r1 i = 1 \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
r01_binary_expansion' r1 i = 1

goal (1 subgoal):
 1. r01_r01_to_r01 (r1, r2) \<in> {0<..<1}
[PROOF STEP]
hence hi:"r01_r01_to_r01' (r1,r2) (2*i) = 1"
[PROOF STATE]
proof (prove)
using this:
r01_binary_expansion' r1 i = 1

goal (1 subgoal):
 1. r01_r01_to_r01' (r1, r2) (2 * i) = 1
[PROOF STEP]
by(simp add: r01_r01_to_r01'_def)
[PROOF STATE]
proof (state)
this:
r01_r01_to_r01' (r1, r2) (2 * i) = 1

goal (1 subgoal):
 1. r01_r01_to_r01 (r1, r2) \<in> {0<..<1}
[PROOF STEP]
obtain j where "r01_binary_expansion' r1 j = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>j. r01_binary_expansion' r1 j = 0 \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using r01_binary_expression_ex0[of r1] assms(1,2)
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>0 < r1; r1 < 1\<rbrakk> \<Longrightarrow> \<exists>i. r01_binary_expansion' r1 i = 0
0 < r1
r1 < 1

goal (1 subgoal):
 1. (\<And>j. r01_binary_expansion' r1 j = 0 \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
r01_binary_expansion' r1 j = 0

goal (1 subgoal):
 1. r01_r01_to_r01 (r1, r2) \<in> {0<..<1}
[PROOF STEP]
hence hj:"r01_r01_to_r01' (r1,r2) (2*j) = 0"
[PROOF STATE]
proof (prove)
using this:
r01_binary_expansion' r1 j = 0

goal (1 subgoal):
 1. r01_r01_to_r01' (r1, r2) (2 * j) = 0
[PROOF STEP]
by(simp add: r01_r01_to_r01'_def)
[PROOF STATE]
proof (state)
this:
r01_r01_to_r01' (r1, r2) (2 * j) = 0

goal (1 subgoal):
 1. r01_r01_to_r01 (r1, r2) \<in> {0<..<1}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. r01_r01_to_r01 (r1, r2) \<in> {0<..<1}
[PROOF STEP]
using ai_exists1_gt0[of "r01_r01_to_r01' (r1,r2)"] ai_exists0_less_than1[of "r01_r01_to_r01' (r1,r2)"] r01_r01_to_r01'in01[of "(r1,r2)"] r01_r01_to_r01_def'[of r1 r2] hi hj
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>\<And>n. r01_r01_to_r01' (r1, r2) n \<in> {0, 1}; \<exists>i. r01_r01_to_r01' (r1, r2) i = 1\<rbrakk> \<Longrightarrow> 0 < (\<Sum>n. real (r01_r01_to_r01' (r1, r2) n) * (1 / 2) ^ Suc n)
\<lbrakk>\<And>n. r01_r01_to_r01' (r1, r2) n \<in> {0, 1}; \<exists>i. r01_r01_to_r01' (r1, r2) i = 0\<rbrakk> \<Longrightarrow> (\<Sum>n. real (r01_r01_to_r01' (r1, r2) n) * (1 / 2) ^ Suc n) < 1
r01_r01_to_r01' (r1, r2) ?n \<in> {0, 1}
r01_r01_to_r01 (r1, r2) = (\<Sum>n. real (r01_r01_to_r01' (r1, r2) n) * (1 / 2) ^ (n + 1))
r01_r01_to_r01' (r1, r2) (2 * i) = 1
r01_r01_to_r01' (r1, r2) (2 * j) = 0

goal (1 subgoal):
 1. r01_r01_to_r01 (r1, r2) \<in> {0<..<1}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
r01_r01_to_r01 (r1, r2) \<in> {0<..<1}

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma (in deutsch) prob0_deutsch_algo_const:
  assumes "is_const"
  shows "prob0 2 deutsch_algo 0 = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. prob0 2 deutsch_algo 0 = 1
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. prob0 2 deutsch_algo 0 = 1
[PROOF STEP]
have "{k| k::nat. (k < 4) \<and> \<not> select_index 2 0 k} = {0,1}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {k |k. k < 4 \<and> \<not> select_index 2 0 k} = {0, 1}
[PROOF STEP]
using select_index_def
[PROOF STATE]
proof (prove)
using this:
select_index ?n ?i ?j \<equiv> ?i \<le> ?n - 1 \<and> ?j \<le> 2 ^ ?n - 1 \<and> 2 ^ (?n - 1 - ?i) \<le> ?j mod 2 ^ (?n - ?i)

goal (1 subgoal):
 1. {k |k. k < 4 \<and> \<not> select_index 2 0 k} = {0, 1}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
{k |k. k < 4 \<and> \<not> select_index 2 0 k} = {0, 1}

goal (1 subgoal):
 1. prob0 2 deutsch_algo 0 = 1
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
{k |k. k < 4 \<and> \<not> select_index 2 0 k} = {0, 1}
[PROOF STEP]
have "prob0 2 deutsch_algo 0 = (\<Sum>j\<in>{0,1}. (cmod(deutsch_algo $$ (j,0)))\<^sup>2)"
[PROOF STATE]
proof (prove)
using this:
{k |k. k < 4 \<and> \<not> select_index 2 0 k} = {0, 1}

goal (1 subgoal):
 1. prob0 2 deutsch_algo 0 = (\<Sum>j\<in>{0, 1}. (cmod (deutsch_algo $$ (j, 0)))\<^sup>2)
[PROOF STEP]
using deutsch_algo_result_is_state prob0_def
[PROOF STATE]
proof (prove)
using this:
{k |k. k < 4 \<and> \<not> select_index 2 0 k} = {0, 1}
state 2 deutsch_algo
prob0 ?n ?v ?i \<equiv> \<Sum>j\<in>{k |k. k < 2 ^ ?n \<and> \<not> select_index ?n ?i k}. (cmod (?v $$ (j, 0)))\<^sup>2

goal (1 subgoal):
 1. prob0 2 deutsch_algo 0 = (\<Sum>j\<in>{0, 1}. (cmod (deutsch_algo $$ (j, 0)))\<^sup>2)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
prob0 2 deutsch_algo 0 = (\<Sum>j\<in>{0, 1}. (cmod (deutsch_algo $$ (j, 0)))\<^sup>2)

goal (1 subgoal):
 1. prob0 2 deutsch_algo 0 = 1
[PROOF STEP]
thus "prob0 2 deutsch_algo 0 = 1"
[PROOF STATE]
proof (prove)
using this:
prob0 2 deutsch_algo 0 = (\<Sum>j\<in>{0, 1}. (cmod (deutsch_algo $$ (j, 0)))\<^sup>2)

goal (1 subgoal):
 1. prob0 2 deutsch_algo 0 = 1
[PROOF STEP]
using assms is_const_def const_def
[PROOF STATE]
proof (prove)
using this:
prob0 2 deutsch_algo 0 = (\<Sum>j\<in>{0, 1}. (cmod (deutsch_algo $$ (j, 0)))\<^sup>2)
is_const
is_const \<equiv> const 0 \<or> const 1
const ?n = (\<forall>x\<in>{0, 1}. f x = ?n)

goal (1 subgoal):
 1. prob0 2 deutsch_algo 0 = 1
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
prob0 2 deutsch_algo 0 = 1

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma ln_one_plus_pos_lower_bound:
  fixes x :: real
  assumes a: "0 \<le> x" and b: "x \<le> 1"
  shows "x - x\<^sup>2 \<le> ln (1 + x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x - x\<^sup>2 \<le> ln (1 + x)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. x - x\<^sup>2 \<le> ln (1 + x)
[PROOF STEP]
have "exp (x - x\<^sup>2) = exp x / exp (x\<^sup>2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. exp (x - x\<^sup>2) = exp x / exp (x\<^sup>2)
[PROOF STEP]
by (rule exp_diff)
[PROOF STATE]
proof (state)
this:
exp (x - x\<^sup>2) = exp x / exp (x\<^sup>2)

goal (1 subgoal):
 1. x - x\<^sup>2 \<le> ln (1 + x)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
exp (x - x\<^sup>2) = exp x / exp (x\<^sup>2)

goal (1 subgoal):
 1. x - x\<^sup>2 \<le> ln (1 + x)
[PROOF STEP]
have "\<dots> \<le> (1 + x + x\<^sup>2) / exp (x \<^sup>2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. exp x / exp (x\<^sup>2) \<le> (1 + x + x\<^sup>2) / exp (x\<^sup>2)
[PROOF STEP]
by (metis a b divide_right_mono exp_bound exp_ge_zero)
[PROOF STATE]
proof (state)
this:
exp x / exp (x\<^sup>2) \<le> (1 + x + x\<^sup>2) / exp (x\<^sup>2)

goal (1 subgoal):
 1. x - x\<^sup>2 \<le> ln (1 + x)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
exp x / exp (x\<^sup>2) \<le> (1 + x + x\<^sup>2) / exp (x\<^sup>2)

goal (1 subgoal):
 1. x - x\<^sup>2 \<le> ln (1 + x)
[PROOF STEP]
have "\<dots> \<le> (1 + x + x\<^sup>2) / (1 + x\<^sup>2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (1 + x + x\<^sup>2) / exp (x\<^sup>2) \<le> (1 + x + x\<^sup>2) / (1 + x\<^sup>2)
[PROOF STEP]
by (simp add: a divide_left_mono add_pos_nonneg)
[PROOF STATE]
proof (state)
this:
(1 + x + x\<^sup>2) / exp (x\<^sup>2) \<le> (1 + x + x\<^sup>2) / (1 + x\<^sup>2)

goal (1 subgoal):
 1. x - x\<^sup>2 \<le> ln (1 + x)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(1 + x + x\<^sup>2) / exp (x\<^sup>2) \<le> (1 + x + x\<^sup>2) / (1 + x\<^sup>2)

goal (1 subgoal):
 1. x - x\<^sup>2 \<le> ln (1 + x)
[PROOF STEP]
from a
[PROOF STATE]
proof (chain)
picking this:
0 \<le> x
[PROOF STEP]
have "\<dots> \<le> 1 + x"
[PROOF STATE]
proof (prove)
using this:
0 \<le> x

goal (1 subgoal):
 1. (1 + x + x\<^sup>2) / (1 + x\<^sup>2) \<le> 1 + x
[PROOF STEP]
by (simp add: field_simps add_strict_increasing zero_le_mult_iff)
[PROOF STATE]
proof (state)
this:
(1 + x + x\<^sup>2) / (1 + x\<^sup>2) \<le> 1 + x

goal (1 subgoal):
 1. x - x\<^sup>2 \<le> ln (1 + x)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
exp (x - x\<^sup>2) \<le> 1 + x
[PROOF STEP]
have "exp (x - x\<^sup>2) \<le> 1 + x"
[PROOF STATE]
proof (prove)
using this:
exp (x - x\<^sup>2) \<le> 1 + x

goal (1 subgoal):
 1. exp (x - x\<^sup>2) \<le> 1 + x
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
exp (x - x\<^sup>2) \<le> 1 + x

goal (1 subgoal):
 1. x - x\<^sup>2 \<le> ln (1 + x)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
exp (x - x\<^sup>2) \<le> 1 + x

goal (1 subgoal):
 1. x - x\<^sup>2 \<le> ln (1 + x)
[PROOF STEP]
have "\<dots> = exp (ln (1 + x))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 + x = exp (ln (1 + x))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. 1 + x = exp (ln (1 + x))
[PROOF STEP]
from a
[PROOF STATE]
proof (chain)
picking this:
0 \<le> x
[PROOF STEP]
have "0 < 1 + x"
[PROOF STATE]
proof (prove)
using this:
0 \<le> x

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

goal (1 subgoal):
 1. 1 + x = exp (ln (1 + x))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
0 < 1 + x
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
0 < 1 + x

goal (1 subgoal):
 1. 1 + x = exp (ln (1 + x))
[PROOF STEP]
by (auto simp only: exp_ln_iff [THEN sym])
[PROOF STATE]
proof (state)
this:
1 + x = exp (ln (1 + x))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
1 + x = exp (ln (1 + x))

goal (1 subgoal):
 1. x - x\<^sup>2 \<le> ln (1 + x)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
exp (x - x\<^sup>2) \<le> exp (ln (1 + x))
[PROOF STEP]
have "exp (x - x\<^sup>2) \<le> exp (ln (1 + x))"
[PROOF STATE]
proof (prove)
using this:
exp (x - x\<^sup>2) \<le> exp (ln (1 + x))

goal (1 subgoal):
 1. exp (x - x\<^sup>2) \<le> exp (ln (1 + x))
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
exp (x - x\<^sup>2) \<le> exp (ln (1 + x))

goal (1 subgoal):
 1. x - x\<^sup>2 \<le> ln (1 + x)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
exp (x - x\<^sup>2) \<le> exp (ln (1 + x))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
exp (x - x\<^sup>2) \<le> exp (ln (1 + x))

goal (1 subgoal):
 1. x - x\<^sup>2 \<le> ln (1 + x)
[PROOF STEP]
by (metis exp_le_cancel_iff)
[PROOF STATE]
proof (state)
this:
x - x\<^sup>2 \<le> ln (1 + x)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma rev_take: "rev (take i xs) = drop (length xs - i) (rev xs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rev (take i xs) = drop (length xs - i) (rev xs)
[PROOF STEP]
proof (induct xs arbitrary: i)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>i. rev (take i []) = drop (length [] - i) (rev [])
 2. \<And>a xs i. (\<And>i. rev (take i xs) = drop (length xs - i) (rev xs)) \<Longrightarrow> rev (take i (a # xs)) = drop (length (a # xs) - i) (rev (a # xs))
[PROOF STEP]
case Nil
[PROOF STATE]
proof (state)
this:

goal (2 subgoals):
 1. \<And>i. rev (take i []) = drop (length [] - i) (rev [])
 2. \<And>a xs i. (\<And>i. rev (take i xs) = drop (length xs - i) (rev xs)) \<Longrightarrow> rev (take i (a # xs)) = drop (length (a # xs) - i) (rev (a # xs))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rev (take i []) = drop (length [] - i) (rev [])
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
rev (take i []) = drop (length [] - i) (rev [])

goal (1 subgoal):
 1. \<And>a xs i. (\<And>i. rev (take i xs) = drop (length xs - i) (rev xs)) \<Longrightarrow> rev (take i (a # xs)) = drop (length (a # xs) - i) (rev (a # xs))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a xs i. (\<And>i. rev (take i xs) = drop (length xs - i) (rev xs)) \<Longrightarrow> rev (take i (a # xs)) = drop (length (a # xs) - i) (rev (a # xs))
[PROOF STEP]
case Cons
[PROOF STATE]
proof (state)
this:
rev (take ?i xs_) = drop (length xs_ - ?i) (rev xs_)

goal (1 subgoal):
 1. \<And>a xs i. (\<And>i. rev (take i xs) = drop (length xs - i) (rev xs)) \<Longrightarrow> rev (take i (a # xs)) = drop (length (a # xs) - i) (rev (a # xs))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
rev (take ?i xs_) = drop (length xs_ - ?i) (rev xs_)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
rev (take ?i xs_) = drop (length xs_ - ?i) (rev xs_)

goal (1 subgoal):
 1. rev (take i (a_ # xs_)) = drop (length (a_ # xs_) - i) (rev (a_ # xs_))
[PROOF STEP]
by (cases i) auto
[PROOF STATE]
proof (state)
this:
rev (take i (a_ # xs_)) = drop (length (a_ # xs_) - i) (rev (a_ # xs_))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma mset_sub_decompose: "mset ds \<subseteq># mset bs + as \<Longrightarrow> length ds < length bs \<Longrightarrow> \<exists> b1 b b2.
   bs = b1 @ b # b2 \<and> mset ds \<subseteq># mset (b1 @ b2) + as"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>mset ds \<subseteq># mset bs + as; length ds < length bs\<rbrakk> \<Longrightarrow> \<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset ds \<subseteq># mset (b1 @ b2) + as
[PROOF STEP]
proof (induct ds arbitrary: bs as)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>bs as. \<lbrakk>mset [] \<subseteq># mset bs + as; length [] < length bs\<rbrakk> \<Longrightarrow> \<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset [] \<subseteq># mset (b1 @ b2) + as
 2. \<And>a ds bs as. \<lbrakk>\<And>bs as. \<lbrakk>mset ds \<subseteq># mset bs + as; length ds < length bs\<rbrakk> \<Longrightarrow> \<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset ds \<subseteq># mset (b1 @ b2) + as; mset (a # ds) \<subseteq># mset bs + as; length (a # ds) < length bs\<rbrakk> \<Longrightarrow> \<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset (a # ds) \<subseteq># mset (b1 @ b2) + as
[PROOF STEP]
case Nil
[PROOF STATE]
proof (state)
this:
mset [] \<subseteq># mset bs + as
length [] < length bs

goal (2 subgoals):
 1. \<And>bs as. \<lbrakk>mset [] \<subseteq># mset bs + as; length [] < length bs\<rbrakk> \<Longrightarrow> \<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset [] \<subseteq># mset (b1 @ b2) + as
 2. \<And>a ds bs as. \<lbrakk>\<And>bs as. \<lbrakk>mset ds \<subseteq># mset bs + as; length ds < length bs\<rbrakk> \<Longrightarrow> \<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset ds \<subseteq># mset (b1 @ b2) + as; mset (a # ds) \<subseteq># mset bs + as; length (a # ds) < length bs\<rbrakk> \<Longrightarrow> \<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset (a # ds) \<subseteq># mset (b1 @ b2) + as
[PROOF STEP]
hence "bs = [] @ hd bs # tl bs"
[PROOF STATE]
proof (prove)
using this:
mset [] \<subseteq># mset bs + as
length [] < length bs

goal (1 subgoal):
 1. bs = [] @ hd bs # tl bs
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
bs = [] @ hd bs # tl bs

goal (2 subgoals):
 1. \<And>bs as. \<lbrakk>mset [] \<subseteq># mset bs + as; length [] < length bs\<rbrakk> \<Longrightarrow> \<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset [] \<subseteq># mset (b1 @ b2) + as
 2. \<And>a ds bs as. \<lbrakk>\<And>bs as. \<lbrakk>mset ds \<subseteq># mset bs + as; length ds < length bs\<rbrakk> \<Longrightarrow> \<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset ds \<subseteq># mset (b1 @ b2) + as; mset (a # ds) \<subseteq># mset bs + as; length (a # ds) < length bs\<rbrakk> \<Longrightarrow> \<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset (a # ds) \<subseteq># mset (b1 @ b2) + as
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
using this:
bs = [] @ hd bs # tl bs

goal (1 subgoal):
 1. \<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset [] \<subseteq># mset (b1 @ b2) + as
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
\<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset [] \<subseteq># mset (b1 @ b2) + as

goal (1 subgoal):
 1. \<And>a ds bs as. \<lbrakk>\<And>bs as. \<lbrakk>mset ds \<subseteq># mset bs + as; length ds < length bs\<rbrakk> \<Longrightarrow> \<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset ds \<subseteq># mset (b1 @ b2) + as; mset (a # ds) \<subseteq># mset bs + as; length (a # ds) < length bs\<rbrakk> \<Longrightarrow> \<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset (a # ds) \<subseteq># mset (b1 @ b2) + as
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a ds bs as. \<lbrakk>\<And>bs as. \<lbrakk>mset ds \<subseteq># mset bs + as; length ds < length bs\<rbrakk> \<Longrightarrow> \<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset ds \<subseteq># mset (b1 @ b2) + as; mset (a # ds) \<subseteq># mset bs + as; length (a # ds) < length bs\<rbrakk> \<Longrightarrow> \<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset (a # ds) \<subseteq># mset (b1 @ b2) + as
[PROOF STEP]
case (Cons d ds bs as)
[PROOF STATE]
proof (state)
this:
\<lbrakk>mset ds \<subseteq># mset ?bs + ?as; length ds < length ?bs\<rbrakk> \<Longrightarrow> \<exists>b1 b b2. ?bs = b1 @ b # b2 \<and> mset ds \<subseteq># mset (b1 @ b2) + ?as
mset (d # ds) \<subseteq># mset bs + as
length (d # ds) < length bs

goal (1 subgoal):
 1. \<And>a ds bs as. \<lbrakk>\<And>bs as. \<lbrakk>mset ds \<subseteq># mset bs + as; length ds < length bs\<rbrakk> \<Longrightarrow> \<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset ds \<subseteq># mset (b1 @ b2) + as; mset (a # ds) \<subseteq># mset bs + as; length (a # ds) < length bs\<rbrakk> \<Longrightarrow> \<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset (a # ds) \<subseteq># mset (b1 @ b2) + as
[PROOF STEP]
have "d \<in># mset (d # ds)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. d \<in># mset (d # ds)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
d \<in># mset (d # ds)

goal (1 subgoal):
 1. \<And>a ds bs as. \<lbrakk>\<And>bs as. \<lbrakk>mset ds \<subseteq># mset bs + as; length ds < length bs\<rbrakk> \<Longrightarrow> \<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset ds \<subseteq># mset (b1 @ b2) + as; mset (a # ds) \<subseteq># mset bs + as; length (a # ds) < length bs\<rbrakk> \<Longrightarrow> \<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset (a # ds) \<subseteq># mset (b1 @ b2) + as
[PROOF STEP]
with Cons(2)
[PROOF STATE]
proof (chain)
picking this:
mset (d # ds) \<subseteq># mset bs + as
d \<in># mset (d # ds)
[PROOF STEP]
have d: "d \<in># mset bs + as"
[PROOF STATE]
proof (prove)
using this:
mset (d # ds) \<subseteq># mset bs + as
d \<in># mset (d # ds)

goal (1 subgoal):
 1. d \<in># mset bs + as
[PROOF STEP]
by (rule mset_subset_eqD)
[PROOF STATE]
proof (state)
this:
d \<in># mset bs + as

goal (1 subgoal):
 1. \<And>a ds bs as. \<lbrakk>\<And>bs as. \<lbrakk>mset ds \<subseteq># mset bs + as; length ds < length bs\<rbrakk> \<Longrightarrow> \<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset ds \<subseteq># mset (b1 @ b2) + as; mset (a # ds) \<subseteq># mset bs + as; length (a # ds) < length bs\<rbrakk> \<Longrightarrow> \<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset (a # ds) \<subseteq># mset (b1 @ b2) + as
[PROOF STEP]
hence "d \<in> set bs \<or> d \<in># as"
[PROOF STATE]
proof (prove)
using this:
d \<in># mset bs + as

goal (1 subgoal):
 1. d \<in> set bs \<or> d \<in># as
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
d \<in> set bs \<or> d \<in># as

goal (1 subgoal):
 1. \<And>a ds bs as. \<lbrakk>\<And>bs as. \<lbrakk>mset ds \<subseteq># mset bs + as; length ds < length bs\<rbrakk> \<Longrightarrow> \<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset ds \<subseteq># mset (b1 @ b2) + as; mset (a # ds) \<subseteq># mset bs + as; length (a # ds) < length bs\<rbrakk> \<Longrightarrow> \<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset (a # ds) \<subseteq># mset (b1 @ b2) + as
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
using this:
d \<in> set bs \<or> d \<in># as

goal (1 subgoal):
 1. \<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset (d # ds) \<subseteq># mset (b1 @ b2) + as
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. d \<in> set bs \<Longrightarrow> \<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset (d # ds) \<subseteq># mset (b1 @ b2) + as
 2. d \<in># as \<Longrightarrow> \<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset (d # ds) \<subseteq># mset (b1 @ b2) + as
[PROOF STEP]
assume "d \<in> set bs"
[PROOF STATE]
proof (state)
this:
d \<in> set bs

goal (2 subgoals):
 1. d \<in> set bs \<Longrightarrow> \<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset (d # ds) \<subseteq># mset (b1 @ b2) + as
 2. d \<in># as \<Longrightarrow> \<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset (d # ds) \<subseteq># mset (b1 @ b2) + as
[PROOF STEP]
from this[unfolded in_set_conv_decomp]
[PROOF STATE]
proof (chain)
picking this:
\<exists>ys zs. bs = ys @ d # zs
[PROOF STEP]
obtain b1 b2 where bs: "bs = b1 @ d # b2"
[PROOF STATE]
proof (prove)
using this:
\<exists>ys zs. bs = ys @ d # zs

goal (1 subgoal):
 1. (\<And>b1 b2. bs = b1 @ d # b2 \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
bs = b1 @ d # b2

goal (2 subgoals):
 1. d \<in> set bs \<Longrightarrow> \<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset (d # ds) \<subseteq># mset (b1 @ b2) + as
 2. d \<in># as \<Longrightarrow> \<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset (d # ds) \<subseteq># mset (b1 @ b2) + as
[PROOF STEP]
from Cons(2) Cons(3)
[PROOF STATE]
proof (chain)
picking this:
mset (d # ds) \<subseteq># mset bs + as
length (d # ds) < length bs
[PROOF STEP]
have "mset ds \<subseteq># mset (b1 @ b2) + as" "length ds < length (b1 @ b2)"
[PROOF STATE]
proof (prove)
using this:
mset (d # ds) \<subseteq># mset bs + as
length (d # ds) < length bs

goal (1 subgoal):
 1. mset ds \<subseteq># mset (b1 @ b2) + as &&& length ds < length (b1 @ b2)
[PROOF STEP]
by (auto simp: ac_simps bs)
[PROOF STATE]
proof (state)
this:
mset ds \<subseteq># mset (b1 @ b2) + as
length ds < length (b1 @ b2)

goal (2 subgoals):
 1. d \<in> set bs \<Longrightarrow> \<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset (d # ds) \<subseteq># mset (b1 @ b2) + as
 2. d \<in># as \<Longrightarrow> \<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset (d # ds) \<subseteq># mset (b1 @ b2) + as
[PROOF STEP]
from Cons(1)[OF this]
[PROOF STATE]
proof (chain)
picking this:
\<exists>b1a b b2a. b1 @ b2 = b1a @ b # b2a \<and> mset ds \<subseteq># mset (b1a @ b2a) + as
[PROOF STEP]
obtain b1' b b2' where split: "b1 @ b2 = b1' @ b # b2'"
      and sub: "mset ds \<subseteq># mset (b1' @ b2') + as"
[PROOF STATE]
proof (prove)
using this:
\<exists>b1a b b2a. b1 @ b2 = b1a @ b # b2a \<and> mset ds \<subseteq># mset (b1a @ b2a) + as

goal (1 subgoal):
 1. (\<And>b1' b b2'. \<lbrakk>b1 @ b2 = b1' @ b # b2'; mset ds \<subseteq># mset (b1' @ b2') + as\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
b1 @ b2 = b1' @ b # b2'
mset ds \<subseteq># mset (b1' @ b2') + as

goal (2 subgoals):
 1. d \<in> set bs \<Longrightarrow> \<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset (d # ds) \<subseteq># mset (b1 @ b2) + as
 2. d \<in># as \<Longrightarrow> \<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset (d # ds) \<subseteq># mset (b1 @ b2) + as
[PROOF STEP]
from split[unfolded append_eq_append_conv2]
[PROOF STATE]
proof (chain)
picking this:
\<exists>us. b1 = b1' @ us \<and> us @ b2 = b # b2' \<or> b1 @ us = b1' \<and> b2 = us @ b # b2'
[PROOF STEP]
obtain us where "b1 = b1' @ us \<and> us @ b2 = b # b2' \<or> b1 @ us = b1' \<and> b2 = us @ b # b2'"
[PROOF STATE]
proof (prove)
using this:
\<exists>us. b1 = b1' @ us \<and> us @ b2 = b # b2' \<or> b1 @ us = b1' \<and> b2 = us @ b # b2'

goal (1 subgoal):
 1. (\<And>us. b1 = b1' @ us \<and> us @ b2 = b # b2' \<or> b1 @ us = b1' \<and> b2 = us @ b # b2' \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
b1 = b1' @ us \<and> us @ b2 = b # b2' \<or> b1 @ us = b1' \<and> b2 = us @ b # b2'

goal (2 subgoals):
 1. d \<in> set bs \<Longrightarrow> \<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset (d # ds) \<subseteq># mset (b1 @ b2) + as
 2. d \<in># as \<Longrightarrow> \<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset (d # ds) \<subseteq># mset (b1 @ b2) + as
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
b1 = b1' @ us \<and> us @ b2 = b # b2' \<or> b1 @ us = b1' \<and> b2 = us @ b # b2'

goal (1 subgoal):
 1. \<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset (d # ds) \<subseteq># mset (b1 @ b2) + as
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. b1 = b1' @ us \<and> us @ b2 = b # b2' \<Longrightarrow> \<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset (d # ds) \<subseteq># mset (b1 @ b2) + as
 2. b1 @ us = b1' \<and> b2 = us @ b # b2' \<Longrightarrow> \<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset (d # ds) \<subseteq># mset (b1 @ b2) + as
[PROOF STEP]
assume "b1 @ us = b1' \<and> b2 = us @ b # b2'"
[PROOF STATE]
proof (state)
this:
b1 @ us = b1' \<and> b2 = us @ b # b2'

goal (2 subgoals):
 1. b1 = b1' @ us \<and> us @ b2 = b # b2' \<Longrightarrow> \<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset (d # ds) \<subseteq># mset (b1 @ b2) + as
 2. b1 @ us = b1' \<and> b2 = us @ b # b2' \<Longrightarrow> \<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset (d # ds) \<subseteq># mset (b1 @ b2) + as
[PROOF STEP]
hence *: "b1 @ us = b1'" "b2 = us @ b # b2'"
[PROOF STATE]
proof (prove)
using this:
b1 @ us = b1' \<and> b2 = us @ b # b2'

goal (1 subgoal):
 1. b1 @ us = b1' &&& b2 = us @ b # b2'
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
b1 @ us = b1'
b2 = us @ b # b2'

goal (2 subgoals):
 1. b1 = b1' @ us \<and> us @ b2 = b # b2' \<Longrightarrow> \<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset (d # ds) \<subseteq># mset (b1 @ b2) + as
 2. b1 @ us = b1' \<and> b2 = us @ b # b2' \<Longrightarrow> \<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset (d # ds) \<subseteq># mset (b1 @ b2) + as
[PROOF STEP]
hence bs: "bs = (b1 @ d # us) @ b # b2'"
[PROOF STATE]
proof (prove)
using this:
b1 @ us = b1'
b2 = us @ b # b2'

goal (1 subgoal):
 1. bs = (b1 @ d # us) @ b # b2'
[PROOF STEP]
unfolding bs
[PROOF STATE]
proof (prove)
using this:
b1 @ us = b1'
b2 = us @ b # b2'

goal (1 subgoal):
 1. b1 @ d # b2 = (b1 @ d # us) @ b # b2'
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
bs = (b1 @ d # us) @ b # b2'

goal (2 subgoals):
 1. b1 = b1' @ us \<and> us @ b2 = b # b2' \<Longrightarrow> \<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset (d # ds) \<subseteq># mset (b1 @ b2) + as
 2. b1 @ us = b1' \<and> b2 = us @ b # b2' \<Longrightarrow> \<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset (d # ds) \<subseteq># mset (b1 @ b2) + as
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset (d # ds) \<subseteq># mset (b1 @ b2) + as
[PROOF STEP]
by (intro exI conjI, rule bs, insert * sub, auto simp: ac_simps)
[PROOF STATE]
proof (state)
this:
\<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset (d # ds) \<subseteq># mset (b1 @ b2) + as

goal (1 subgoal):
 1. b1 = b1' @ us \<and> us @ b2 = b # b2' \<Longrightarrow> \<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset (d # ds) \<subseteq># mset (b1 @ b2) + as
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. b1 = b1' @ us \<and> us @ b2 = b # b2' \<Longrightarrow> \<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset (d # ds) \<subseteq># mset (b1 @ b2) + as
[PROOF STEP]
assume "b1 = b1' @ us \<and> us @ b2 = b # b2'"
[PROOF STATE]
proof (state)
this:
b1 = b1' @ us \<and> us @ b2 = b # b2'

goal (1 subgoal):
 1. b1 = b1' @ us \<and> us @ b2 = b # b2' \<Longrightarrow> \<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset (d # ds) \<subseteq># mset (b1 @ b2) + as
[PROOF STEP]
hence *: "b1 = b1' @ us" "us @ b2 = b # b2'"
[PROOF STATE]
proof (prove)
using this:
b1 = b1' @ us \<and> us @ b2 = b # b2'

goal (1 subgoal):
 1. b1 = b1' @ us &&& us @ b2 = b # b2'
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
b1 = b1' @ us
us @ b2 = b # b2'

goal (1 subgoal):
 1. b1 = b1' @ us \<and> us @ b2 = b # b2' \<Longrightarrow> \<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset (d # ds) \<subseteq># mset (b1 @ b2) + as
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset (d # ds) \<subseteq># mset (b1 @ b2) + as
[PROOF STEP]
proof (cases us)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. us = [] \<Longrightarrow> \<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset (d # ds) \<subseteq># mset (b1 @ b2) + as
 2. \<And>a list. us = a # list \<Longrightarrow> \<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset (d # ds) \<subseteq># mset (b1 @ b2) + as
[PROOF STEP]
case Nil
[PROOF STATE]
proof (state)
this:
us = []

goal (2 subgoals):
 1. us = [] \<Longrightarrow> \<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset (d # ds) \<subseteq># mset (b1 @ b2) + as
 2. \<And>a list. us = a # list \<Longrightarrow> \<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset (d # ds) \<subseteq># mset (b1 @ b2) + as
[PROOF STEP]
with *
[PROOF STATE]
proof (chain)
picking this:
b1 = b1' @ us
us @ b2 = b # b2'
us = []
[PROOF STEP]
have *: "b1 = b1'" "b2 = b # b2'"
[PROOF STATE]
proof (prove)
using this:
b1 = b1' @ us
us @ b2 = b # b2'
us = []

goal (1 subgoal):
 1. b1 = b1' &&& b2 = b # b2'
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
b1 = b1'
b2 = b # b2'

goal (2 subgoals):
 1. us = [] \<Longrightarrow> \<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset (d # ds) \<subseteq># mset (b1 @ b2) + as
 2. \<And>a list. us = a # list \<Longrightarrow> \<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset (d # ds) \<subseteq># mset (b1 @ b2) + as
[PROOF STEP]
hence bs: "bs = (b1' @ [d]) @ b # b2'"
[PROOF STATE]
proof (prove)
using this:
b1 = b1'
b2 = b # b2'

goal (1 subgoal):
 1. bs = (b1' @ [d]) @ b # b2'
[PROOF STEP]
unfolding bs
[PROOF STATE]
proof (prove)
using this:
b1 = b1'
b2 = b # b2'

goal (1 subgoal):
 1. b1 @ d # b2 = (b1' @ [d]) @ b # b2'
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
bs = (b1' @ [d]) @ b # b2'

goal (2 subgoals):
 1. us = [] \<Longrightarrow> \<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset (d # ds) \<subseteq># mset (b1 @ b2) + as
 2. \<And>a list. us = a # list \<Longrightarrow> \<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset (d # ds) \<subseteq># mset (b1 @ b2) + as
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset (d # ds) \<subseteq># mset (b1 @ b2) + as
[PROOF STEP]
by (intro exI conjI, rule bs, insert * sub, auto simp: ac_simps)
[PROOF STATE]
proof (state)
this:
\<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset (d # ds) \<subseteq># mset (b1 @ b2) + as

goal (1 subgoal):
 1. \<And>a list. us = a # list \<Longrightarrow> \<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset (d # ds) \<subseteq># mset (b1 @ b2) + as
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a list. us = a # list \<Longrightarrow> \<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset (d # ds) \<subseteq># mset (b1 @ b2) + as
[PROOF STEP]
case (Cons u vs)
[PROOF STATE]
proof (state)
this:
us = u # vs

goal (1 subgoal):
 1. \<And>a list. us = a # list \<Longrightarrow> \<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset (d # ds) \<subseteq># mset (b1 @ b2) + as
[PROOF STEP]
with *
[PROOF STATE]
proof (chain)
picking this:
b1 = b1' @ us
us @ b2 = b # b2'
us = u # vs
[PROOF STEP]
have *: "b1 = b1' @ b # vs" "vs @ b2 = b2'"
[PROOF STATE]
proof (prove)
using this:
b1 = b1' @ us
us @ b2 = b # b2'
us = u # vs

goal (1 subgoal):
 1. b1 = b1' @ b # vs &&& vs @ b2 = b2'
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
b1 = b1' @ b # vs
vs @ b2 = b2'

goal (1 subgoal):
 1. \<And>a list. us = a # list \<Longrightarrow> \<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset (d # ds) \<subseteq># mset (b1 @ b2) + as
[PROOF STEP]
hence bs: "bs = b1' @ b # (vs @ d # b2)"
[PROOF STATE]
proof (prove)
using this:
b1 = b1' @ b # vs
vs @ b2 = b2'

goal (1 subgoal):
 1. bs = b1' @ b # vs @ d # b2
[PROOF STEP]
unfolding bs
[PROOF STATE]
proof (prove)
using this:
b1 = b1' @ b # vs
vs @ b2 = b2'

goal (1 subgoal):
 1. b1 @ d # b2 = b1' @ b # vs @ d # b2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
bs = b1' @ b # vs @ d # b2

goal (1 subgoal):
 1. \<And>a list. us = a # list \<Longrightarrow> \<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset (d # ds) \<subseteq># mset (b1 @ b2) + as
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset (d # ds) \<subseteq># mset (b1 @ b2) + as
[PROOF STEP]
by (intro exI conjI, rule bs, insert * sub, auto simp: ac_simps)
[PROOF STATE]
proof (state)
this:
\<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset (d # ds) \<subseteq># mset (b1 @ b2) + as

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset (d # ds) \<subseteq># mset (b1 @ b2) + as

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset (d # ds) \<subseteq># mset (b1 @ b2) + as

goal (1 subgoal):
 1. d \<in># as \<Longrightarrow> \<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset (d # ds) \<subseteq># mset (b1 @ b2) + as
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. d \<in># as \<Longrightarrow> \<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset (d # ds) \<subseteq># mset (b1 @ b2) + as
[PROOF STEP]
define as' where "as' = as - {#d#}"
[PROOF STATE]
proof (state)
this:
as' = as - {#d#}

goal (1 subgoal):
 1. d \<in># as \<Longrightarrow> \<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset (d # ds) \<subseteq># mset (b1 @ b2) + as
[PROOF STEP]
assume "d \<in># as"
[PROOF STATE]
proof (state)
this:
d \<in># as

goal (1 subgoal):
 1. d \<in># as \<Longrightarrow> \<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset (d # ds) \<subseteq># mset (b1 @ b2) + as
[PROOF STEP]
hence as': "as = {#d#} + as'"
[PROOF STATE]
proof (prove)
using this:
d \<in># as

goal (1 subgoal):
 1. as = {#d#} + as'
[PROOF STEP]
unfolding as'_def
[PROOF STATE]
proof (prove)
using this:
d \<in># as

goal (1 subgoal):
 1. as = {#d#} + (as - {#d#})
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
as = {#d#} + as'

goal (1 subgoal):
 1. d \<in># as \<Longrightarrow> \<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset (d # ds) \<subseteq># mset (b1 @ b2) + as
[PROOF STEP]
from Cons(2)[unfolded as'] Cons(3)
[PROOF STATE]
proof (chain)
picking this:
mset (d # ds) \<subseteq># mset bs + ({#d#} + as')
length (d # ds) < length bs
[PROOF STEP]
have "mset ds \<subseteq># mset bs + as'" "length ds < length bs"
[PROOF STATE]
proof (prove)
using this:
mset (d # ds) \<subseteq># mset bs + ({#d#} + as')
length (d # ds) < length bs

goal (1 subgoal):
 1. mset ds \<subseteq># mset bs + as' &&& length ds < length bs
[PROOF STEP]
by (auto simp: ac_simps)
[PROOF STATE]
proof (state)
this:
mset ds \<subseteq># mset bs + as'
length ds < length bs

goal (1 subgoal):
 1. d \<in># as \<Longrightarrow> \<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset (d # ds) \<subseteq># mset (b1 @ b2) + as
[PROOF STEP]
from Cons(1)[OF this]
[PROOF STATE]
proof (chain)
picking this:
\<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset ds \<subseteq># mset (b1 @ b2) + as'
[PROOF STEP]
obtain b1 b b2 where bs: "bs = b1 @ b # b2" and
      sub: "mset ds \<subseteq># mset (b1 @ b2) + as'"
[PROOF STATE]
proof (prove)
using this:
\<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset ds \<subseteq># mset (b1 @ b2) + as'

goal (1 subgoal):
 1. (\<And>b1 b b2. \<lbrakk>bs = b1 @ b # b2; mset ds \<subseteq># mset (b1 @ b2) + as'\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
bs = b1 @ b # b2
mset ds \<subseteq># mset (b1 @ b2) + as'

goal (1 subgoal):
 1. d \<in># as \<Longrightarrow> \<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset (d # ds) \<subseteq># mset (b1 @ b2) + as
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset (d # ds) \<subseteq># mset (b1 @ b2) + as
[PROOF STEP]
by (intro exI conjI, rule bs, insert sub, auto simp: as' ac_simps)
[PROOF STATE]
proof (state)
this:
\<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset (d # ds) \<subseteq># mset (b1 @ b2) + as

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<exists>b1 b b2. bs = b1 @ b # b2 \<and> mset (d # ds) \<subseteq># mset (b1 @ b2) + as

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma ceiling_diff_numeral [simp]: "\<lceil>x - numeral v\<rceil> = \<lceil>x\<rceil> - numeral v"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lceil>x - numeral v\<rceil> = \<lceil>x\<rceil> - numeral v
[PROOF STEP]
using ceiling_diff_of_int [of x "numeral v"]
[PROOF STATE]
proof (prove)
using this:
\<lceil>x - of_int (numeral v)\<rceil> = \<lceil>x\<rceil> - numeral v

goal (1 subgoal):
 1. \<lceil>x - numeral v\<rceil> = \<lceil>x\<rceil> - numeral v
[PROOF STEP]
by simp


[STATEMENT]
lemma has_field_derivative_cong_eventually:
  assumes "eventually (\<lambda>x. f x = g x) (at x within S)" "f x = g x"
  shows "(f has_field_derivative u) (at x within S) = (g has_field_derivative u) (at x within S)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (f has_field_derivative u) (at x within S) = (g has_field_derivative u) (at x within S)
[PROOF STEP]
unfolding has_field_derivative_iff
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>y. (f y - f x) / (y - x)) \<longlongrightarrow> u) (at x within S) = ((\<lambda>y. (g y - g x) / (y - x)) \<longlongrightarrow> u) (at x within S)
[PROOF STEP]
proof (rule tendsto_cong)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<forall>\<^sub>F xa in at x within S. (f xa - f x) / (xa - x) = (g xa - g x) / (xa - x)
[PROOF STEP]
show "\<forall>\<^sub>F y in at x within S. (f y - f x) / (y - x) = (g y - g x) / (y - x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>\<^sub>F y in at x within S. (f y - f x) / (y - x) = (g y - g x) / (y - x)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
\<forall>\<^sub>F x in at x within S. f x = g x
f x = g x

goal (1 subgoal):
 1. \<forall>\<^sub>F y in at x within S. (f y - f x) / (y - x) = (g y - g x) / (y - x)
[PROOF STEP]
by (auto elim: eventually_mono)
[PROOF STATE]
proof (state)
this:
\<forall>\<^sub>F y in at x within S. (f y - f x) / (y - x) = (g y - g x) / (y - x)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma Re_winding_number_half_left:
  assumes neg_img:"\<forall>p\<in>path_image \<gamma>. Re p \<le> Re z" and "valid_path \<gamma>" and "z\<notin>path_image \<gamma>"
  shows "Re(winding_number \<gamma> z) = (Im (Ln (z - pathfinish \<gamma>)) - Im (Ln (z - pathstart \<gamma> )))/(2*pi)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Re (winding_number \<gamma> z) = (Im (Ln (z - pathfinish \<gamma>)) - Im (Ln (z - pathstart \<gamma>))) / (2 * pi)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. Re (winding_number \<gamma> z) = (Im (Ln (z - pathfinish \<gamma>)) - Im (Ln (z - pathstart \<gamma>))) / (2 * pi)
[PROOF STEP]
define \<gamma>' where "\<gamma>'\<equiv>(\<lambda>t. 2*z - \<gamma> t)"
[PROOF STATE]
proof (state)
this:
\<gamma>' \<equiv> \<lambda>t. 2 * z - \<gamma> t

goal (1 subgoal):
 1. Re (winding_number \<gamma> z) = (Im (Ln (z - pathfinish \<gamma>)) - Im (Ln (z - pathstart \<gamma>))) / (2 * pi)
[PROOF STEP]
have "Re (winding_number \<gamma>' z) = (Im (Ln (pathfinish \<gamma>' - z)) - Im (Ln (pathstart \<gamma>' - z))) / (2 * pi)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Re (winding_number \<gamma>' z) = (Im (Ln (pathfinish \<gamma>' - z)) - Im (Ln (pathstart \<gamma>' - z))) / (2 * pi)
[PROOF STEP]
unfolding \<gamma>'_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Re (winding_number (\<lambda>t. 2 * z - \<gamma> t) z) = (Im (Ln (pathfinish (\<lambda>t. 2 * z - \<gamma> t) - z)) - Im (Ln (pathstart (\<lambda>t. 2 * z - \<gamma> t) - z))) / (2 * pi)
[PROOF STEP]
apply (rule Re_winding_number_half_right)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. \<forall>p\<in>path_image (\<lambda>t. 2 * z - \<gamma> t). Re z \<le> Re p
 2. valid_path (\<lambda>t. 2 * z - \<gamma> t)
 3. z \<notin> path_image (\<lambda>t. 2 * z - \<gamma> t)
[PROOF STEP]
subgoal
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>p\<in>path_image (\<lambda>t. 2 * z - \<gamma> t). Re z \<le> Re p
[PROOF STEP]
using neg_img
[PROOF STATE]
proof (prove)
using this:
\<forall>p\<in>path_image \<gamma>. Re p \<le> Re z

goal (1 subgoal):
 1. \<forall>p\<in>path_image (\<lambda>t. 2 * z - \<gamma> t). Re z \<le> Re p
[PROOF STEP]
unfolding path_image_def
[PROOF STATE]
proof (prove)
using this:
\<forall>p\<in>\<gamma> ` {0..1}. Re p \<le> Re z

goal (1 subgoal):
 1. \<forall>p\<in>(\<lambda>t. 2 * z - \<gamma> t) ` {0..1}. Re z \<le> Re p
[PROOF STEP]
by auto
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. valid_path (\<lambda>t. 2 * z - \<gamma> t)
 2. z \<notin> path_image (\<lambda>t. 2 * z - \<gamma> t)
[PROOF STEP]
subgoal
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. valid_path (\<lambda>t. 2 * z - \<gamma> t)
[PROOF STEP]
apply (rule valid_path_compose_holomorphic[OF \<open>valid_path \<gamma>\<close>,of "\<lambda>t. 2*z-t" UNIV,
            unfolded comp_def])
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. (-) (2 * z) holomorphic_on UNIV
 2. open UNIV
 3. path_image \<gamma> \<subseteq> UNIV
[PROOF STEP]
by (auto intro:holomorphic_intros)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. z \<notin> path_image (\<lambda>t. 2 * z - \<gamma> t)
[PROOF STEP]
subgoal
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. z \<notin> path_image (\<lambda>t. 2 * z - \<gamma> t)
[PROOF STEP]
using \<open>z\<notin>path_image \<gamma>\<close>
[PROOF STATE]
proof (prove)
using this:
z \<notin> path_image \<gamma>

goal (1 subgoal):
 1. z \<notin> path_image (\<lambda>t. 2 * z - \<gamma> t)
[PROOF STEP]
unfolding path_image_def
[PROOF STATE]
proof (prove)
using this:
z \<notin> \<gamma> ` {0..1}

goal (1 subgoal):
 1. z \<notin> (\<lambda>t. 2 * z - \<gamma> t) ` {0..1}
[PROOF STEP]
by auto
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
Re (winding_number \<gamma>' z) = (Im (Ln (pathfinish \<gamma>' - z)) - Im (Ln (pathstart \<gamma>' - z))) / (2 * pi)

goal (1 subgoal):
 1. Re (winding_number \<gamma> z) = (Im (Ln (z - pathfinish \<gamma>)) - Im (Ln (z - pathstart \<gamma>))) / (2 * pi)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
Re (winding_number \<gamma>' z) = (Im (Ln (pathfinish \<gamma>' - z)) - Im (Ln (pathstart \<gamma>' - z))) / (2 * pi)

goal (1 subgoal):
 1. Re (winding_number \<gamma> z) = (Im (Ln (z - pathfinish \<gamma>)) - Im (Ln (z - pathstart \<gamma>))) / (2 * pi)
[PROOF STEP]
have "winding_number \<gamma>' z = winding_number \<gamma> z"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. winding_number \<gamma>' z = winding_number \<gamma> z
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. winding_number \<gamma>' z = winding_number \<gamma> z
[PROOF STEP]
define f where "f=(\<lambda>t. 2*z-t)"
[PROOF STATE]
proof (state)
this:
f = (-) (2 * z)

goal (1 subgoal):
 1. winding_number \<gamma>' z = winding_number \<gamma> z
[PROOF STEP]
define c where "c= 1 / (complex_of_real (2 * pi) * \<i>)"
[PROOF STATE]
proof (state)
this:
c = 1 / (complex_of_real (2 * pi) * \<i>)

goal (1 subgoal):
 1. winding_number \<gamma>' z = winding_number \<gamma> z
[PROOF STEP]
have "winding_number \<gamma>' z = winding_number (f o \<gamma>) z"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. winding_number \<gamma>' z = winding_number (f \<circ> \<gamma>) z
[PROOF STEP]
unfolding \<gamma>'_def comp_def f_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. winding_number (\<lambda>t. 2 * z - \<gamma> t) z = winding_number (\<lambda>x. 2 * z - \<gamma> x) z
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
winding_number \<gamma>' z = winding_number (f \<circ> \<gamma>) z

goal (1 subgoal):
 1. winding_number \<gamma>' z = winding_number \<gamma> z
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
winding_number \<gamma>' z = winding_number (f \<circ> \<gamma>) z

goal (1 subgoal):
 1. winding_number \<gamma>' z = winding_number \<gamma> z
[PROOF STEP]
have "... = c * contour_integral \<gamma> (\<lambda>w. deriv f w / (f w - z))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. winding_number (f \<circ> \<gamma>) z = c * contour_integral \<gamma> (\<lambda>w. deriv f w / (f w - z))
[PROOF STEP]
unfolding c_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. winding_number (f \<circ> \<gamma>) z = 1 / (complex_of_real (2 * pi) * \<i>) * contour_integral \<gamma> (\<lambda>w. deriv f w / (f w - z))
[PROOF STEP]
proof (rule winding_number_comp[of UNIV])
[PROOF STATE]
proof (state)
goal (5 subgoals):
 1. open UNIV
 2. f holomorphic_on UNIV
 3. path_image \<gamma> \<subseteq> UNIV
 4. valid_path \<gamma>
 5. z \<notin> path_image (f \<circ> \<gamma>)
[PROOF STEP]
show "z \<notin> path_image (f \<circ> \<gamma>)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. z \<notin> path_image (f \<circ> \<gamma>)
[PROOF STEP]
using \<open>z\<notin>path_image \<gamma>\<close>
[PROOF STATE]
proof (prove)
using this:
z \<notin> path_image \<gamma>

goal (1 subgoal):
 1. z \<notin> path_image (f \<circ> \<gamma>)
[PROOF STEP]
unfolding f_def path_image_def
[PROOF STATE]
proof (prove)
using this:
z \<notin> \<gamma> ` {0..1}

goal (1 subgoal):
 1. z \<notin> ((-) (2 * z) \<circ> \<gamma>) ` {0..1}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
z \<notin> path_image (f \<circ> \<gamma>)

goal (4 subgoals):
 1. open UNIV
 2. f holomorphic_on UNIV
 3. path_image \<gamma> \<subseteq> UNIV
 4. valid_path \<gamma>
[PROOF STEP]
qed (auto simp add:f_def \<open>valid_path \<gamma>\<close> intro:holomorphic_intros)
[PROOF STATE]
proof (state)
this:
winding_number (f \<circ> \<gamma>) z = c * contour_integral \<gamma> (\<lambda>w. deriv f w / (f w - z))

goal (1 subgoal):
 1. winding_number \<gamma>' z = winding_number \<gamma> z
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
winding_number (f \<circ> \<gamma>) z = c * contour_integral \<gamma> (\<lambda>w. deriv f w / (f w - z))

goal (1 subgoal):
 1. winding_number \<gamma>' z = winding_number \<gamma> z
[PROOF STEP]
have "... = c * contour_integral \<gamma> (\<lambda>w.  1 / (w - z))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. c * contour_integral \<gamma> (\<lambda>w. deriv f w / (f w - z)) = c * contour_integral \<gamma> (\<lambda>w. 1 / (w - z))
[PROOF STEP]
unfolding f_def c_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 / (complex_of_real (2 * pi) * \<i>) * contour_integral \<gamma> (\<lambda>w. deriv ((-) (2 * z)) w / (2 * z - w - z)) = 1 / (complex_of_real (2 * pi) * \<i>) * contour_integral \<gamma> (\<lambda>w. 1 / (w - z))
[PROOF STEP]
by (auto simp add:field_simps divide_simps intro!:arg_cong2[where f=contour_integral])
[PROOF STATE]
proof (state)
this:
c * contour_integral \<gamma> (\<lambda>w. deriv f w / (f w - z)) = c * contour_integral \<gamma> (\<lambda>w. 1 / (w - z))

goal (1 subgoal):
 1. winding_number \<gamma>' z = winding_number \<gamma> z
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
c * contour_integral \<gamma> (\<lambda>w. deriv f w / (f w - z)) = c * contour_integral \<gamma> (\<lambda>w. 1 / (w - z))

goal (1 subgoal):
 1. winding_number \<gamma>' z = winding_number \<gamma> z
[PROOF STEP]
have "... = winding_number \<gamma> z"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. c * contour_integral \<gamma> (\<lambda>w. 1 / (w - z)) = winding_number \<gamma> z
[PROOF STEP]
using winding_number_valid_path[OF \<open>valid_path \<gamma>\<close> \<open>z\<notin>path_image \<gamma>\<close>,folded c_def]
[PROOF STATE]
proof (prove)
using this:
winding_number \<gamma> z = c * contour_integral \<gamma> (\<lambda>w. 1 / (w - z))

goal (1 subgoal):
 1. c * contour_integral \<gamma> (\<lambda>w. 1 / (w - z)) = winding_number \<gamma> z
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
c * contour_integral \<gamma> (\<lambda>w. 1 / (w - z)) = winding_number \<gamma> z

goal (1 subgoal):
 1. winding_number \<gamma>' z = winding_number \<gamma> z
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
winding_number \<gamma>' z = winding_number \<gamma> z
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
winding_number \<gamma>' z = winding_number \<gamma> z

goal (1 subgoal):
 1. winding_number \<gamma>' z = winding_number \<gamma> z
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
winding_number \<gamma>' z = winding_number \<gamma> z

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
winding_number \<gamma>' z = winding_number \<gamma> z

goal (1 subgoal):
 1. Re (winding_number \<gamma> z) = (Im (Ln (z - pathfinish \<gamma>)) - Im (Ln (z - pathstart \<gamma>))) / (2 * pi)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
winding_number \<gamma>' z = winding_number \<gamma> z

goal (1 subgoal):
 1. Re (winding_number \<gamma> z) = (Im (Ln (z - pathfinish \<gamma>)) - Im (Ln (z - pathstart \<gamma>))) / (2 * pi)
[PROOF STEP]
have "pathfinish \<gamma>' = 2*z - pathfinish \<gamma>" "pathstart \<gamma>' = 2*z - pathstart \<gamma>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. pathfinish \<gamma>' = 2 * z - pathfinish \<gamma> &&& pathstart \<gamma>' = 2 * z - pathstart \<gamma>
[PROOF STEP]
unfolding \<gamma>'_def path_defs
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 * z - \<gamma> 1 = 2 * z - \<gamma> 1 &&& 2 * z - \<gamma> 0 = 2 * z - \<gamma> 0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
pathfinish \<gamma>' = 2 * z - pathfinish \<gamma>
pathstart \<gamma>' = 2 * z - pathstart \<gamma>

goal (1 subgoal):
 1. Re (winding_number \<gamma> z) = (Im (Ln (z - pathfinish \<gamma>)) - Im (Ln (z - pathstart \<gamma>))) / (2 * pi)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
Re (winding_number \<gamma>' z) = (Im (Ln (pathfinish \<gamma>' - z)) - Im (Ln (pathstart \<gamma>' - z))) / (2 * pi)
winding_number \<gamma>' z = winding_number \<gamma> z
pathfinish \<gamma>' = 2 * z - pathfinish \<gamma>
pathstart \<gamma>' = 2 * z - pathstart \<gamma>
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
Re (winding_number \<gamma>' z) = (Im (Ln (pathfinish \<gamma>' - z)) - Im (Ln (pathstart \<gamma>' - z))) / (2 * pi)
winding_number \<gamma>' z = winding_number \<gamma> z
pathfinish \<gamma>' = 2 * z - pathfinish \<gamma>
pathstart \<gamma>' = 2 * z - pathstart \<gamma>

goal (1 subgoal):
 1. Re (winding_number \<gamma> z) = (Im (Ln (z - pathfinish \<gamma>)) - Im (Ln (z - pathstart \<gamma>))) / (2 * pi)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
Re (winding_number \<gamma> z) = (Im (Ln (z - pathfinish \<gamma>)) - Im (Ln (z - pathstart \<gamma>))) / (2 * pi)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma Max_mono':
  assumes "\<forall>x. f x \<le> g x"
          "finite (range f)"
          "finite (range g)"
  shows "(MAX x. f x) \<le> (MAX x. g x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Max (range f) \<le> Max (range g)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
\<forall>x. f x \<le> g x
finite (range f)
finite (range g)

goal (1 subgoal):
 1. Max (range f) \<le> Max (range g)
[PROOF STEP]
by (metis (no_types, lifting) Max_ge_iff Max_in UNIV_not_empty
  image_is_empty rangeE rangeI)