[STATEMENT]
lemma higher_differentiable_on_Pair:
  "higher_differentiable_on S f k \<Longrightarrow> higher_differentiable_on S g k \<Longrightarrow>
   higher_differentiable_on S (\<lambda>x. (f x, g x)) k"
  if "open S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>higher_differentiable_on S f k; higher_differentiable_on S g k\<rbrakk> \<Longrightarrow> higher_differentiable_on S (\<lambda>x. (f x, g x)) k
[PROOF STEP]
proof (induction k arbitrary: f g)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>f g. \<lbrakk>higher_differentiable_on S f 0; higher_differentiable_on S g 0\<rbrakk> \<Longrightarrow> higher_differentiable_on S (\<lambda>x. (f x, g x)) 0
 2. \<And>k f g. \<lbrakk>\<And>f g. \<lbrakk>higher_differentiable_on S f k; higher_differentiable_on S g k\<rbrakk> \<Longrightarrow> higher_differentiable_on S (\<lambda>x. (f x, g x)) k; higher_differentiable_on S f (Suc k); higher_differentiable_on S g (Suc k)\<rbrakk> \<Longrightarrow> higher_differentiable_on S (\<lambda>x. (f x, g x)) (Suc k)
[PROOF STEP]
case 0
[PROOF STATE]
proof (state)
this:
higher_differentiable_on S f 0
higher_differentiable_on S g 0

goal (2 subgoals):
 1. \<And>f g. \<lbrakk>higher_differentiable_on S f 0; higher_differentiable_on S g 0\<rbrakk> \<Longrightarrow> higher_differentiable_on S (\<lambda>x. (f x, g x)) 0
 2. \<And>k f g. \<lbrakk>\<And>f g. \<lbrakk>higher_differentiable_on S f k; higher_differentiable_on S g k\<rbrakk> \<Longrightarrow> higher_differentiable_on S (\<lambda>x. (f x, g x)) k; higher_differentiable_on S f (Suc k); higher_differentiable_on S g (Suc k)\<rbrakk> \<Longrightarrow> higher_differentiable_on S (\<lambda>x. (f x, g x)) (Suc k)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
higher_differentiable_on S f 0
higher_differentiable_on S g 0
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
higher_differentiable_on S f 0
higher_differentiable_on S g 0

goal (1 subgoal):
 1. higher_differentiable_on S (\<lambda>x. (f x, g x)) 0
[PROOF STEP]
unfolding higher_differentiable_on.simps
[PROOF STATE]
proof (prove)
using this:
continuous_on S f
continuous_on S g

goal (1 subgoal):
 1. continuous_on S (\<lambda>x. (f x, g x))
[PROOF STEP]
by (auto intro!: continuous_intros)
[PROOF STATE]
proof (state)
this:
higher_differentiable_on S (\<lambda>x. (f x, g x)) 0

goal (1 subgoal):
 1. \<And>k f g. \<lbrakk>\<And>f g. \<lbrakk>higher_differentiable_on S f k; higher_differentiable_on S g k\<rbrakk> \<Longrightarrow> higher_differentiable_on S (\<lambda>x. (f x, g x)) k; higher_differentiable_on S f (Suc k); higher_differentiable_on S g (Suc k)\<rbrakk> \<Longrightarrow> higher_differentiable_on S (\<lambda>x. (f x, g x)) (Suc k)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>k f g. \<lbrakk>\<And>f g. \<lbrakk>higher_differentiable_on S f k; higher_differentiable_on S g k\<rbrakk> \<Longrightarrow> higher_differentiable_on S (\<lambda>x. (f x, g x)) k; higher_differentiable_on S f (Suc k); higher_differentiable_on S g (Suc k)\<rbrakk> \<Longrightarrow> higher_differentiable_on S (\<lambda>x. (f x, g x)) (Suc k)
[PROOF STEP]
case (Suc k)
[PROOF STATE]
proof (state)
this:
\<lbrakk>higher_differentiable_on S ?f k; higher_differentiable_on S ?g k\<rbrakk> \<Longrightarrow> higher_differentiable_on S (\<lambda>x. (?f x, ?g x)) k
higher_differentiable_on S f (Suc k)
higher_differentiable_on S g (Suc k)

goal (1 subgoal):
 1. \<And>k f g. \<lbrakk>\<And>f g. \<lbrakk>higher_differentiable_on S f k; higher_differentiable_on S g k\<rbrakk> \<Longrightarrow> higher_differentiable_on S (\<lambda>x. (f x, g x)) k; higher_differentiable_on S f (Suc k); higher_differentiable_on S g (Suc k)\<rbrakk> \<Longrightarrow> higher_differentiable_on S (\<lambda>x. (f x, g x)) (Suc k)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>higher_differentiable_on S ?f k; higher_differentiable_on S ?g k\<rbrakk> \<Longrightarrow> higher_differentiable_on S (\<lambda>x. (?f x, ?g x)) k
higher_differentiable_on S f (Suc k)
higher_differentiable_on S g (Suc k)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>higher_differentiable_on S ?f k; higher_differentiable_on S ?g k\<rbrakk> \<Longrightarrow> higher_differentiable_on S (\<lambda>x. (?f x, ?g x)) k
higher_differentiable_on S f (Suc k)
higher_differentiable_on S g (Suc k)

goal (1 subgoal):
 1. higher_differentiable_on S (\<lambda>x. (f x, g x)) (Suc k)
[PROOF STEP]
using that
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>higher_differentiable_on S ?f k; higher_differentiable_on S ?g k\<rbrakk> \<Longrightarrow> higher_differentiable_on S (\<lambda>x. (?f x, ?g x)) k
higher_differentiable_on S f (Suc k)
higher_differentiable_on S g (Suc k)
open S

goal (1 subgoal):
 1. higher_differentiable_on S (\<lambda>x. (f x, g x)) (Suc k)
[PROOF STEP]
unfolding higher_differentiable_on.simps
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>higher_differentiable_on S ?f k; higher_differentiable_on S ?g k\<rbrakk> \<Longrightarrow> higher_differentiable_on S (\<lambda>x. (?f x, ?g x)) k
(\<forall>x\<in>S. f differentiable at x) \<and> (\<forall>v. higher_differentiable_on S (\<lambda>x. frechet_derivative f (at x) v) k)
(\<forall>x\<in>S. g differentiable at x) \<and> (\<forall>v. higher_differentiable_on S (\<lambda>x. frechet_derivative g (at x) v) k)
open S

goal (1 subgoal):
 1. (\<forall>x\<in>S. (\<lambda>x. (f x, g x)) differentiable at x) \<and> (\<forall>v. higher_differentiable_on S (\<lambda>x. frechet_derivative (\<lambda>x. (f x, g x)) (at x) v) k)
[PROOF STEP]
by (auto simp: frechet_derivative_pair[of f _ g] cong: higher_differentiable_on_cong)
[PROOF STATE]
proof (state)
this:
higher_differentiable_on S (\<lambda>x. (f x, g x)) (Suc k)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma Max_image_pair:
  assumes "finite S" "finite T" "T \<noteq> {}"
  shows "(MAX s \<in> S. MAX t \<in> T. f s t) = (MAX (s, t) \<in> S \<times> T. f s t)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (MAX s\<in>S. Max (f s ` T)) = (MAX (s, t)\<in>S \<times> T. f s t)
[PROOF STEP]
proof ((rule Max_eq_image_if; clarsimp?), goal_cases)
[PROOF STATE]
proof (state)
goal (4 subgoals):
 1. finite S
 2. finite (S \<times> T)
 3. \<And>x. x \<in> S \<Longrightarrow> \<exists>xa\<in>S. \<exists>y\<in>T. Max (f x ` T) \<le> f xa y
 4. \<And>x y. \<lbrakk>x \<in> S; y \<in> T\<rbrakk> \<Longrightarrow> \<exists>ya\<in>S. f x y \<le> Max (f ya ` T)
[PROOF STEP]
case (3 x)
[PROOF STATE]
proof (state)
this:
x \<in> S

goal (4 subgoals):
 1. finite S
 2. finite (S \<times> T)
 3. \<And>x. x \<in> S \<Longrightarrow> \<exists>xa\<in>S. \<exists>y\<in>T. Max (f x ` T) \<le> f xa y
 4. \<And>x y. \<lbrakk>x \<in> S; y \<in> T\<rbrakk> \<Longrightarrow> \<exists>ya\<in>S. f x y \<le> Max (f ya ` T)
[PROOF STEP]
from \<open>finite T\<close> \<open>T \<noteq> {}\<close>
[PROOF STATE]
proof (chain)
picking this:
finite T
T \<noteq> {}
[PROOF STEP]
obtain y where "y \<in> T" and "Max (f x ` T) = f x y"
[PROOF STATE]
proof (prove)
using this:
finite T
T \<noteq> {}

goal (1 subgoal):
 1. (\<And>y. \<lbrakk>y \<in> T; Max (f x ` T) = f x y\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (rule Max_in_image)
[PROOF STATE]
proof (state)
this:
y \<in> T
Max (f x ` T) = f x y

goal (4 subgoals):
 1. finite S
 2. finite (S \<times> T)
 3. \<And>x. x \<in> S \<Longrightarrow> \<exists>xa\<in>S. \<exists>y\<in>T. Max (f x ` T) \<le> f xa y
 4. \<And>x y. \<lbrakk>x \<in> S; y \<in> T\<rbrakk> \<Longrightarrow> \<exists>ya\<in>S. f x y \<le> Max (f ya ` T)
[PROOF STEP]
with \<open>x \<in> S\<close>
[PROOF STATE]
proof (chain)
picking this:
x \<in> S
y \<in> T
Max (f x ` T) = f x y
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
x \<in> S
y \<in> T
Max (f x ` T) = f x y

goal (1 subgoal):
 1. \<exists>xa\<in>S. \<exists>y\<in>T. Max (f x ` T) \<le> f xa y
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<exists>xa\<in>S. \<exists>y\<in>T. Max (f x ` T) \<le> f xa y

goal (3 subgoals):
 1. finite S
 2. finite (S \<times> T)
 3. \<And>x y. \<lbrakk>x \<in> S; y \<in> T\<rbrakk> \<Longrightarrow> \<exists>ya\<in>S. f x y \<le> Max (f ya ` T)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. finite S
 2. finite (S \<times> T)
 3. \<And>x y. \<lbrakk>x \<in> S; y \<in> T\<rbrakk> \<Longrightarrow> \<exists>ya\<in>S. f x y \<le> Max (f ya ` T)
[PROOF STEP]
case (4 a b)
[PROOF STATE]
proof (state)
this:
a \<in> S
b \<in> T

goal (3 subgoals):
 1. finite S
 2. finite (S \<times> T)
 3. \<And>x y. \<lbrakk>x \<in> S; y \<in> T\<rbrakk> \<Longrightarrow> \<exists>ya\<in>S. f x y \<le> Max (f ya ` T)
[PROOF STEP]
with \<open>finite T\<close>
[PROOF STATE]
proof (chain)
picking this:
finite T
a \<in> S
b \<in> T
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
finite T
a \<in> S
b \<in> T

goal (1 subgoal):
 1. \<exists>y\<in>S. f a b \<le> Max (f y ` T)
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
\<exists>y\<in>S. f a b \<le> Max (f y ` T)

goal (2 subgoals):
 1. finite S
 2. finite (S \<times> T)
[PROOF STEP]
qed (use assms in auto)


[STATEMENT]
lemma reachable_closed_dfs: "reachable g xs \<subseteq> set(dfs g xs [])"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. reachable g xs \<subseteq> set (dfs g xs [])
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. reachable g xs \<subseteq> set (dfs g xs [])
[PROOF STEP]
have "reachable g xs \<subseteq> reachable g (dfs g xs [])"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. reachable g xs \<subseteq> reachable g (dfs g xs [])
[PROOF STEP]
unfolding reachable_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (set g)\<^sup>* `` set xs \<subseteq> (set g)\<^sup>* `` set (dfs g xs [])
[PROOF STEP]
by (rule Image_mono) (auto simp add: next_subset_dfs)
[PROOF STATE]
proof (state)
this:
reachable g xs \<subseteq> reachable g (dfs g xs [])

goal (1 subgoal):
 1. reachable g xs \<subseteq> set (dfs g xs [])
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
reachable g xs \<subseteq> reachable g (dfs g xs [])

goal (1 subgoal):
 1. reachable g xs \<subseteq> set (dfs g xs [])
[PROOF STEP]
have "\<dots> = set(dfs g xs [])"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. reachable g (dfs g xs []) = set (dfs g xs [])
[PROOF STEP]
unfolding reachable_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (set g)\<^sup>* `` set (dfs g xs []) = set (dfs g xs [])
[PROOF STEP]
proof (rule Image_closed_trancl)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. set g `` set (dfs g xs []) \<subseteq> set (dfs g xs [])
[PROOF STEP]
from nextss_closed_dfs
[PROOF STATE]
proof (chain)
picking this:
nextss ?g (dfs ?g ?xs []) \<subseteq> set (dfs ?g ?xs [])
[PROOF STEP]
show "set g `` set (dfs g xs []) \<subseteq> set (dfs g xs [])"
[PROOF STATE]
proof (prove)
using this:
nextss ?g (dfs ?g ?xs []) \<subseteq> set (dfs ?g ?xs [])

goal (1 subgoal):
 1. set g `` set (dfs g xs []) \<subseteq> set (dfs g xs [])
[PROOF STEP]
by (simp add: nextss_def)
[PROOF STATE]
proof (state)
this:
set g `` set (dfs g xs []) \<subseteq> set (dfs g xs [])

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
reachable g (dfs g xs []) = set (dfs g xs [])

goal (1 subgoal):
 1. reachable g xs \<subseteq> set (dfs g xs [])
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
reachable g xs \<subseteq> set (dfs g xs [])
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
reachable g xs \<subseteq> set (dfs g xs [])

goal (1 subgoal):
 1. reachable g xs \<subseteq> set (dfs g xs [])
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
reachable g xs \<subseteq> set (dfs g xs [])

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma base_summation_bound:
  fixes c q :: nat
    and f :: "(nat \<Rightarrow> nat)"

defines b: "b \<equiv> B c"
assumes bound: "\<forall>t. f t < 2 ^ Suc c - (1::nat)"

shows "(\<Sum>t = 0..q. f t * b^t) < b^(Suc q)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>t = 0..q. f t * b ^ t) < b ^ Suc q
[PROOF STEP]
proof (induction q)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. (\<Sum>t = 0..0. f t * b ^ t) < b ^ Suc 0
 2. \<And>q. (\<Sum>t = 0..q. f t * b ^ t) < b ^ Suc q \<Longrightarrow> (\<Sum>t = 0..Suc q. f t * b ^ t) < b ^ Suc (Suc q)
[PROOF STEP]
case 0
[PROOF STATE]
proof (state)
this:

goal (2 subgoals):
 1. (\<Sum>t = 0..0. f t * b ^ t) < b ^ Suc 0
 2. \<And>q. (\<Sum>t = 0..q. f t * b ^ t) < b ^ Suc q \<Longrightarrow> (\<Sum>t = 0..Suc q. f t * b ^ t) < b ^ Suc (Suc q)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>t = 0..0. f t * b ^ t) < b ^ Suc 0
[PROOF STEP]
using B_def b bound less_imp_diff_less not_less_eq
[PROOF STATE]
proof (prove)
using this:
B ?c = 2 ^ Suc ?c
b \<equiv> B c
\<forall>t. f t < 2 ^ Suc c - 1
?j < ?k \<Longrightarrow> ?j - ?n < ?k
(\<not> ?m < ?n) = (?n < Suc ?m)

goal (1 subgoal):
 1. (\<Sum>t = 0..0. f t * b ^ t) < b ^ Suc 0
[PROOF STEP]
by auto blast
[PROOF STATE]
proof (state)
this:
(\<Sum>t = 0..0. f t * b ^ t) < b ^ Suc 0

goal (1 subgoal):
 1. \<And>q. (\<Sum>t = 0..q. f t * b ^ t) < b ^ Suc q \<Longrightarrow> (\<Sum>t = 0..Suc q. f t * b ^ t) < b ^ Suc (Suc q)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>q. (\<Sum>t = 0..q. f t * b ^ t) < b ^ Suc q \<Longrightarrow> (\<Sum>t = 0..Suc q. f t * b ^ t) < b ^ Suc (Suc q)
[PROOF STEP]
case (Suc q)
[PROOF STATE]
proof (state)
this:
(\<Sum>t = 0..q. f t * b ^ t) < b ^ Suc q

goal (1 subgoal):
 1. \<And>q. (\<Sum>t = 0..q. f t * b ^ t) < b ^ Suc q \<Longrightarrow> (\<Sum>t = 0..Suc q. f t * b ^ t) < b ^ Suc (Suc q)
[PROOF STEP]
have "(\<Sum>t = 0..Suc q. f t * b ^ t) = f (Suc q) * b ^ (Suc q) + (\<Sum>t = 0..q. f t * b ^ t)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>t = 0..Suc q. f t * b ^ t) = f (Suc q) * b ^ Suc q + (\<Sum>t = 0..q. f t * b ^ t)
[PROOF STEP]
by (auto cong: sum.cong)
[PROOF STATE]
proof (state)
this:
(\<Sum>t = 0..Suc q. f t * b ^ t) = f (Suc q) * b ^ Suc q + (\<Sum>t = 0..q. f t * b ^ t)

goal (1 subgoal):
 1. \<And>q. (\<Sum>t = 0..q. f t * b ^ t) < b ^ Suc q \<Longrightarrow> (\<Sum>t = 0..Suc q. f t * b ^ t) < b ^ Suc (Suc q)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>t = 0..Suc q. f t * b ^ t) = f (Suc q) * b ^ Suc q + (\<Sum>t = 0..q. f t * b ^ t)

goal (1 subgoal):
 1. \<And>q. (\<Sum>t = 0..q. f t * b ^ t) < b ^ Suc q \<Longrightarrow> (\<Sum>t = 0..Suc q. f t * b ^ t) < b ^ Suc (Suc q)
[PROOF STEP]
have "... < (f (Suc q) + 1) * b ^ (Suc q)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f (Suc q) * b ^ Suc q + (\<Sum>t = 0..q. f t * b ^ t) < (f (Suc q) + 1) * b ^ Suc q
[PROOF STEP]
using Suc.IH
[PROOF STATE]
proof (prove)
using this:
(\<Sum>t = 0..q. f t * b ^ t) < b ^ Suc q

goal (1 subgoal):
 1. f (Suc q) * b ^ Suc q + (\<Sum>t = 0..q. f t * b ^ t) < (f (Suc q) + 1) * b ^ Suc q
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
f (Suc q) * b ^ Suc q + (\<Sum>t = 0..q. f t * b ^ t) < (f (Suc q) + 1) * b ^ Suc q

goal (1 subgoal):
 1. \<And>q. (\<Sum>t = 0..q. f t * b ^ t) < b ^ Suc q \<Longrightarrow> (\<Sum>t = 0..Suc q. f t * b ^ t) < b ^ Suc (Suc q)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
f (Suc q) * b ^ Suc q + (\<Sum>t = 0..q. f t * b ^ t) < (f (Suc q) + 1) * b ^ Suc q

goal (1 subgoal):
 1. \<And>q. (\<Sum>t = 0..q. f t * b ^ t) < b ^ Suc q \<Longrightarrow> (\<Sum>t = 0..Suc q. f t * b ^ t) < b ^ Suc (Suc q)
[PROOF STEP]
have "... < b * b ^ (Suc q)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (f (Suc q) + 1) * b ^ Suc q < b * b ^ Suc q
[PROOF STEP]
by (metis bound b less_diff_conv B_def mult_less_cancel2 zero_less_numeral zero_less_power)
[PROOF STATE]
proof (state)
this:
(f (Suc q) + 1) * b ^ Suc q < b * b ^ Suc q

goal (1 subgoal):
 1. \<And>q. (\<Sum>t = 0..q. f t * b ^ t) < b ^ Suc q \<Longrightarrow> (\<Sum>t = 0..Suc q. f t * b ^ t) < b ^ Suc (Suc q)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(\<Sum>t = 0..Suc q. f t * b ^ t) < b * b ^ Suc q
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
(\<Sum>t = 0..Suc q. f t * b ^ t) < b * b ^ Suc q

goal (1 subgoal):
 1. (\<Sum>t = 0..Suc q. f t * b ^ t) < b ^ Suc (Suc q)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<Sum>t = 0..Suc q. f t * b ^ t) < b ^ Suc (Suc q)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma is_K5_inner_last:
  assumes "l = ig_verts_cnt G"
  shows "is_K5_inner_inv G k l \<longleftrightarrow> (\<forall>v \<in> set (ig_verts G). ig_verts G ! k \<noteq> v
    \<longleftrightarrow> (ig_verts G ! k, v) \<in> set (ig_arcs G))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. is_K5_inner_inv G k l = (\<forall>v\<in>set (ig_verts G). (ig_verts G ! k \<noteq> v) = ((ig_verts G ! k, v) \<in> set (ig_arcs G)))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. is_K5_inner_inv G k l = (\<forall>v\<in>set (ig_verts G). (ig_verts G ! k \<noteq> v) = ((ig_verts G ! k, v) \<in> set (ig_arcs G)))
[PROOF STEP]
have "\<And>v. v \<in> set (ig_verts G) \<Longrightarrow> \<exists>j<ig_verts_cnt G. ig_verts G ! j = v"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>v. v \<in> set (ig_verts G) \<Longrightarrow> \<exists>j<ig_verts_cnt G. ig_verts G ! j = v
[PROOF STEP]
by (auto simp: in_set_conv_nth)
[PROOF STATE]
proof (state)
this:
?v \<in> set (ig_verts G) \<Longrightarrow> \<exists>j<ig_verts_cnt G. ig_verts G ! j = ?v

goal (1 subgoal):
 1. is_K5_inner_inv G k l = (\<forall>v\<in>set (ig_verts G). (ig_verts G ! k \<noteq> v) = ((ig_verts G ! k, v) \<in> set (ig_arcs G)))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
?v \<in> set (ig_verts G) \<Longrightarrow> \<exists>j<ig_verts_cnt G. ig_verts G ! j = ?v
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
?v \<in> set (ig_verts G) \<Longrightarrow> \<exists>j<ig_verts_cnt G. ig_verts G ! j = ?v

goal (1 subgoal):
 1. is_K5_inner_inv G k l = (\<forall>v\<in>set (ig_verts G). (ig_verts G ! k \<noteq> v) = ((ig_verts G ! k, v) \<in> set (ig_arcs G)))
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
?v \<in> set (ig_verts G) \<Longrightarrow> \<exists>j<ig_verts_cnt G. ig_verts G ! j = ?v
l = ig_verts_cnt G

goal (1 subgoal):
 1. is_K5_inner_inv G k l = (\<forall>v\<in>set (ig_verts G). (ig_verts G ! k \<noteq> v) = ((ig_verts G ! k, v) \<in> set (ig_arcs G)))
[PROOF STEP]
unfolding is_K5_inner_inv_def
[PROOF STATE]
proof (prove)
using this:
?v \<in> set (ig_verts G) \<Longrightarrow> \<exists>j<ig_verts_cnt G. ig_verts G ! j = ?v
l = ig_verts_cnt G

goal (1 subgoal):
 1. (\<forall>j<l. (ig_verts G ! k \<noteq> ig_verts G ! j) = ((ig_verts G ! k, ig_verts G ! j) \<in> set (ig_arcs G))) = (\<forall>v\<in>set (ig_verts G). (ig_verts G ! k \<noteq> v) = ((ig_verts G ! k, v) \<in> set (ig_arcs G)))
[PROOF STEP]
by auto metis
[PROOF STATE]
proof (state)
this:
is_K5_inner_inv G k l = (\<forall>v\<in>set (ig_verts G). (ig_verts G ! k \<noteq> v) = ((ig_verts G ! k, v) \<in> set (ig_arcs G)))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma unstream_Cons_trans_False: "unstream (Cons_trans x g) (False, s) = unstream g s"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. unstream (Cons_trans x g) (False, s) = unstream g s
[PROOF STEP]
proof(induction s taking: g rule: unstream.induct)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>s. \<lbrakk>\<And>x2. generator g s = Skip x2 \<Longrightarrow> unstream (Cons_trans x g) (False, x2) = unstream g x2; \<And>x31 x32. generator g s = Yield x31 x32 \<Longrightarrow> unstream (Cons_trans x g) (False, x32) = unstream g x32\<rbrakk> \<Longrightarrow> unstream (Cons_trans x g) (False, s) = unstream g s
[PROOF STEP]
case (1 s)
[PROOF STATE]
proof (state)
this:
generator g s = Skip ?x2.0 \<Longrightarrow> unstream (Cons_trans x g) (False, ?x2.0) = unstream g ?x2.0
generator g s = Yield ?x31.0 ?x32.0 \<Longrightarrow> unstream (Cons_trans x g) (False, ?x32.0) = unstream g ?x32.0

goal (1 subgoal):
 1. \<And>s. \<lbrakk>\<And>x2. generator g s = Skip x2 \<Longrightarrow> unstream (Cons_trans x g) (False, x2) = unstream g x2; \<And>x31 x32. generator g s = Yield x31 x32 \<Longrightarrow> unstream (Cons_trans x g) (False, x32) = unstream g x32\<rbrakk> \<Longrightarrow> unstream (Cons_trans x g) (False, s) = unstream g s
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
generator g s = Skip ?x2.0 \<Longrightarrow> unstream (Cons_trans x g) (False, ?x2.0) = unstream g ?x2.0
generator g s = Yield ?x31.0 ?x32.0 \<Longrightarrow> unstream (Cons_trans x g) (False, ?x32.0) = unstream g ?x32.0
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
generator g s = Skip ?x2.0 \<Longrightarrow> unstream (Cons_trans x g) (False, ?x2.0) = unstream g ?x2.0
generator g s = Yield ?x31.0 ?x32.0 \<Longrightarrow> unstream (Cons_trans x g) (False, ?x32.0) = unstream g ?x32.0

goal (1 subgoal):
 1. unstream (Cons_trans x g) (False, s) = unstream g s
[PROOF STEP]
by(cases "generator g s")(auto simp add: Cons_trans.rep_eq)
[PROOF STATE]
proof (state)
this:
unstream (Cons_trans x g) (False, s) = unstream g s

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma ipoly_min_int_poly [simp]:
  "algebraic x \<Longrightarrow> ipoly (min_int_poly x) (x :: 'a :: {field_gcd, field_char_0}) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. algebraic x \<Longrightarrow> ipoly (min_int_poly x) x = (0::'a)
[PROOF STEP]
using min_int_poly_represents[of x]
[PROOF STATE]
proof (prove)
using this:
algebraic x \<Longrightarrow> min_int_poly x represents x

goal (1 subgoal):
 1. algebraic x \<Longrightarrow> ipoly (min_int_poly x) x = (0::'a)
[PROOF STEP]
by (auto simp: represents_def)


[STATEMENT]
lemma proots_half_empty:
  assumes "a=b"
  shows "proots_half p a b = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. proots_half p a b = 0
[PROOF STEP]
unfolding proots_half_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. proots_count p {w. 0 < Im ((w - a) / (b - a))} = 0
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
a = b

goal (1 subgoal):
 1. proots_count p {w. 0 < Im ((w - a) / (b - a))} = 0
[PROOF STEP]
by auto


[STATEMENT]
lemma subdegree_fps_of_poly:
  assumes "p \<noteq> 0"
  defines "n \<equiv> Polynomial.order 0 p"
  shows   "subdegree (fps_of_poly p) = n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. subdegree (fps_of_poly p) = n
[PROOF STEP]
proof (rule subdegreeI)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. fps_of_poly p $ n \<noteq> (0::'a)
 2. \<And>i. i < n \<Longrightarrow> fps_of_poly p $ i = (0::'a)
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
p \<noteq> 0
n \<equiv> order (0::'a) p
[PROOF STEP]
have "monom 1 n dvd p"
[PROOF STATE]
proof (prove)
using this:
p \<noteq> 0
n \<equiv> order (0::'a) p

goal (1 subgoal):
 1. monom (1::'a) n dvd p
[PROOF STEP]
by (simp add: monom_1_dvd_iff)
[PROOF STATE]
proof (state)
this:
monom (1::'a) n dvd p

goal (2 subgoals):
 1. fps_of_poly p $ n \<noteq> (0::'a)
 2. \<And>i. i < n \<Longrightarrow> fps_of_poly p $ i = (0::'a)
[PROOF STEP]
thus zero: "fps_of_poly p $ i = 0" if "i < n" for i
[PROOF STATE]
proof (prove)
using this:
monom (1::'a) n dvd p

goal (1 subgoal):
 1. fps_of_poly p $ i = (0::'a)
[PROOF STEP]
using that
[PROOF STATE]
proof (prove)
using this:
monom (1::'a) n dvd p
i < n

goal (1 subgoal):
 1. fps_of_poly p $ i = (0::'a)
[PROOF STEP]
by (simp add: monom_1_dvd_iff')
[PROOF STATE]
proof (state)
this:
?i < n \<Longrightarrow> fps_of_poly p $ ?i = (0::'a)

goal (1 subgoal):
 1. fps_of_poly p $ n \<noteq> (0::'a)
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
p \<noteq> 0
n \<equiv> order (0::'a) p
[PROOF STEP]
have "\<not>monom 1 (Suc n) dvd p"
[PROOF STATE]
proof (prove)
using this:
p \<noteq> 0
n \<equiv> order (0::'a) p

goal (1 subgoal):
 1. \<not> monom (1::'a) (Suc n) dvd p
[PROOF STEP]
by (auto simp: monom_1_dvd_iff simp del: power_Suc)
[PROOF STATE]
proof (state)
this:
\<not> monom (1::'a) (Suc n) dvd p

goal (1 subgoal):
 1. fps_of_poly p $ n \<noteq> (0::'a)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<not> monom (1::'a) (Suc n) dvd p
[PROOF STEP]
obtain k where k: "k \<le> n" "fps_of_poly p $ k \<noteq> 0"
[PROOF STATE]
proof (prove)
using this:
\<not> monom (1::'a) (Suc n) dvd p

goal (1 subgoal):
 1. (\<And>k. \<lbrakk>k \<le> n; fps_of_poly p $ k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (auto simp: monom_1_dvd_iff' less_Suc_eq_le)
[PROOF STATE]
proof (state)
this:
k \<le> n
fps_of_poly p $ k \<noteq> (0::'a)

goal (1 subgoal):
 1. fps_of_poly p $ n \<noteq> (0::'a)
[PROOF STEP]
with zero[of k]
[PROOF STATE]
proof (chain)
picking this:
k < n \<Longrightarrow> fps_of_poly p $ k = (0::'a)
k \<le> n
fps_of_poly p $ k \<noteq> (0::'a)
[PROOF STEP]
have "k = n"
[PROOF STATE]
proof (prove)
using this:
k < n \<Longrightarrow> fps_of_poly p $ k = (0::'a)
k \<le> n
fps_of_poly p $ k \<noteq> (0::'a)

goal (1 subgoal):
 1. k = n
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
k = n

goal (1 subgoal):
 1. fps_of_poly p $ n \<noteq> (0::'a)
[PROOF STEP]
with k
[PROOF STATE]
proof (chain)
picking this:
k \<le> n
fps_of_poly p $ k \<noteq> (0::'a)
k = n
[PROOF STEP]
show "fps_of_poly p $ n \<noteq> 0"
[PROOF STATE]
proof (prove)
using this:
k \<le> n
fps_of_poly p $ k \<noteq> (0::'a)
k = n

goal (1 subgoal):
 1. fps_of_poly p $ n \<noteq> (0::'a)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
fps_of_poly p $ n \<noteq> (0::'a)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma emeasure_pmf_UNIV [simp]: "emeasure (measure_pmf M) UNIV = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. emeasure (measure_pmf M) UNIV = 1
[PROOF STEP]
using measure_pmf.emeasure_space_1[of M]
[PROOF STATE]
proof (prove)
using this:
emeasure (measure_pmf M) (space (measure_pmf M)) = 1

goal (1 subgoal):
 1. emeasure (measure_pmf M) UNIV = 1
[PROOF STEP]
by simp


[STATEMENT]
lemma in_enum_image: "A \<subseteq> {.. n} \<Longrightarrow> i \<le> n \<Longrightarrow> enum i \<in> enum ` A \<longleftrightarrow> i \<in> A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>A \<subseteq> {..n}; i \<le> n\<rbrakk> \<Longrightarrow> (enum i \<in> enum ` A) = (i \<in> A)
[PROOF STEP]
using inj_on_image_mem_iff[OF inj_enum]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?a \<in> {..n}; ?A \<subseteq> {..n}\<rbrakk> \<Longrightarrow> (enum ?a \<in> enum ` ?A) = (?a \<in> ?A)

goal (1 subgoal):
 1. \<lbrakk>A \<subseteq> {..n}; i \<le> n\<rbrakk> \<Longrightarrow> (enum i \<in> enum ` A) = (i \<in> A)
[PROOF STEP]
by auto


[STATEMENT]
lemma relto_fun_trans: assumes ab: "relto_fun A B n1 as1 sel1 m1 (a,b)"
  and bc: "relto_fun A B n2 as2 sel2 m2 (b,c)"
  shows "\<exists> as sel. relto_fun A B (n1 + n2) as sel (m1 + m2) (a,c)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>as sel. relto_fun A B (n1 + n2) as sel (m1 + m2) (a, c)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>as sel. relto_fun A B (n1 + n2) as sel (m1 + m2) (a, c)
[PROOF STEP]
from relto_funD[OF ab]
[PROOF STATE]
proof (chain)
picking this:
as1 0 = a
as1 m1 = b
\<lbrakk>?i < m1; sel1 ?i\<rbrakk> \<Longrightarrow> (as1 ?i, as1 (Suc ?i)) \<in> A
\<lbrakk>?i < m1; \<not> sel1 ?i\<rbrakk> \<Longrightarrow> (as1 ?i, as1 (Suc ?i)) \<in> B
n1 = card {i. i < m1 \<and> sel1 i}
(n1 = 0) = (m1 = 0)
[PROOF STEP]
have 1: "as1 0 = a" "as1 m1 = b"
    "\<And> i. i < m1 \<Longrightarrow> (sel1 i \<longrightarrow> (as1 i, as1 (Suc i)) \<in> A) \<and> (\<not> sel1 i \<longrightarrow> (as1 i, as1 (Suc i)) \<in> B)"
    "n1 = 0 \<longleftrightarrow> m1 = 0" and card1: "n1 = card {i. i < m1 \<and> sel1 i}"
[PROOF STATE]
proof (prove)
using this:
as1 0 = a
as1 m1 = b
\<lbrakk>?i < m1; sel1 ?i\<rbrakk> \<Longrightarrow> (as1 ?i, as1 (Suc ?i)) \<in> A
\<lbrakk>?i < m1; \<not> sel1 ?i\<rbrakk> \<Longrightarrow> (as1 ?i, as1 (Suc ?i)) \<in> B
n1 = card {i. i < m1 \<and> sel1 i}
(n1 = 0) = (m1 = 0)

goal (1 subgoal):
 1. ((as1 0 = a &&& as1 m1 = b) &&& (\<And>i. i < m1 \<Longrightarrow> (sel1 i \<longrightarrow> (as1 i, as1 (Suc i)) \<in> A) \<and> (\<not> sel1 i \<longrightarrow> (as1 i, as1 (Suc i)) \<in> B)) &&& (n1 = 0) = (m1 = 0)) &&& n1 = card {i. i < m1 \<and> sel1 i}
[PROOF STEP]
by blast+
[PROOF STATE]
proof (state)
this:
as1 0 = a
as1 m1 = b
?i < m1 \<Longrightarrow> (sel1 ?i \<longrightarrow> (as1 ?i, as1 (Suc ?i)) \<in> A) \<and> (\<not> sel1 ?i \<longrightarrow> (as1 ?i, as1 (Suc ?i)) \<in> B)
(n1 = 0) = (m1 = 0)
n1 = card {i. i < m1 \<and> sel1 i}

goal (1 subgoal):
 1. \<exists>as sel. relto_fun A B (n1 + n2) as sel (m1 + m2) (a, c)
[PROOF STEP]
from relto_funD[OF bc]
[PROOF STATE]
proof (chain)
picking this:
as2 0 = b
as2 m2 = c
\<lbrakk>?i < m2; sel2 ?i\<rbrakk> \<Longrightarrow> (as2 ?i, as2 (Suc ?i)) \<in> A
\<lbrakk>?i < m2; \<not> sel2 ?i\<rbrakk> \<Longrightarrow> (as2 ?i, as2 (Suc ?i)) \<in> B
n2 = card {i. i < m2 \<and> sel2 i}
(n2 = 0) = (m2 = 0)
[PROOF STEP]
have 2: "as2 0 = b" "as2 m2 = c"
    "\<And> i. i < m2 \<Longrightarrow> (sel2 i \<longrightarrow> (as2 i, as2 (Suc i)) \<in> A) \<and> (\<not> sel2 i \<longrightarrow> (as2 i, as2 (Suc i)) \<in> B)"
    "n2 = 0 \<longleftrightarrow> m2 = 0" and card2: "n2 = card {i. i < m2 \<and> sel2 i}"
[PROOF STATE]
proof (prove)
using this:
as2 0 = b
as2 m2 = c
\<lbrakk>?i < m2; sel2 ?i\<rbrakk> \<Longrightarrow> (as2 ?i, as2 (Suc ?i)) \<in> A
\<lbrakk>?i < m2; \<not> sel2 ?i\<rbrakk> \<Longrightarrow> (as2 ?i, as2 (Suc ?i)) \<in> B
n2 = card {i. i < m2 \<and> sel2 i}
(n2 = 0) = (m2 = 0)

goal (1 subgoal):
 1. ((as2 0 = b &&& as2 m2 = c) &&& (\<And>i. i < m2 \<Longrightarrow> (sel2 i \<longrightarrow> (as2 i, as2 (Suc i)) \<in> A) \<and> (\<not> sel2 i \<longrightarrow> (as2 i, as2 (Suc i)) \<in> B)) &&& (n2 = 0) = (m2 = 0)) &&& n2 = card {i. i < m2 \<and> sel2 i}
[PROOF STEP]
by blast+
[PROOF STATE]
proof (state)
this:
as2 0 = b
as2 m2 = c
?i < m2 \<Longrightarrow> (sel2 ?i \<longrightarrow> (as2 ?i, as2 (Suc ?i)) \<in> A) \<and> (\<not> sel2 ?i \<longrightarrow> (as2 ?i, as2 (Suc ?i)) \<in> B)
(n2 = 0) = (m2 = 0)
n2 = card {i. i < m2 \<and> sel2 i}

goal (1 subgoal):
 1. \<exists>as sel. relto_fun A B (n1 + n2) as sel (m1 + m2) (a, c)
[PROOF STEP]
let ?as = "\<lambda> i. if i < m1 then as1 i else as2 (i - m1)"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>as sel. relto_fun A B (n1 + n2) as sel (m1 + m2) (a, c)
[PROOF STEP]
let ?sel = "\<lambda> i. if i < m1 then sel1 i else sel2 (i - m1)"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>as sel. relto_fun A B (n1 + n2) as sel (m1 + m2) (a, c)
[PROOF STEP]
let ?m = "m1 + m2"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>as sel. relto_fun A B (n1 + n2) as sel (m1 + m2) (a, c)
[PROOF STEP]
let ?n = "n1 + n2"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>as sel. relto_fun A B (n1 + n2) as sel (m1 + m2) (a, c)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>as sel. relto_fun A B (n1 + n2) as sel (m1 + m2) (a, c)
[PROOF STEP]
proof (rule exI[of _ ?as], rule exI[of _ ?sel], rule relto_fun)
[PROOF STATE]
proof (state)
goal (5 subgoals):
 1. (if 0 < m1 then as1 0 else as2 (0 - m1)) = a
 2. (if m1 + m2 < m1 then as1 (m1 + m2) else as2 (m1 + m2 - m1)) = c
 3. \<And>i. i < m1 + m2 \<Longrightarrow> ((if i < m1 then sel1 i else sel2 (i - m1)) \<longrightarrow> (if i < m1 then as1 i else as2 (i - m1), if Suc i < m1 then as1 (Suc i) else as2 (Suc i - m1)) \<in> A) \<and> (\<not> (if i < m1 then sel1 i else sel2 (i - m1)) \<longrightarrow> (if i < m1 then as1 i else as2 (i - m1), if Suc i < m1 then as1 (Suc i) else as2 (Suc i - m1)) \<in> B)
 4. n1 + n2 = card {i. i < m1 + m2 \<and> (if i < m1 then sel1 i else sel2 (i - m1))}
 5. (n1 + n2 = 0) = (m1 + m2 = 0)
[PROOF STEP]
have id: "{ i . i < ?m \<and> ?sel i} = { i . i < m1 \<and> sel1 i} \<union> ((+) m1) ` { i. i < m2 \<and> sel2 i}"
      (is "_ = ?A \<union> ?f ` ?B")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {i. i < m1 + m2 \<and> (if i < m1 then sel1 i else sel2 (i - m1))} = {i. i < m1 \<and> sel1 i} \<union> (+) m1 ` {i. i < m2 \<and> sel2 i}
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
{i. i < m1 + m2 \<and> (if i < m1 then sel1 i else sel2 (i - m1))} = {i. i < m1 \<and> sel1 i} \<union> (+) m1 ` {i. i < m2 \<and> sel2 i}

goal (5 subgoals):
 1. (if 0 < m1 then as1 0 else as2 (0 - m1)) = a
 2. (if m1 + m2 < m1 then as1 (m1 + m2) else as2 (m1 + m2 - m1)) = c
 3. \<And>i. i < m1 + m2 \<Longrightarrow> ((if i < m1 then sel1 i else sel2 (i - m1)) \<longrightarrow> (if i < m1 then as1 i else as2 (i - m1), if Suc i < m1 then as1 (Suc i) else as2 (Suc i - m1)) \<in> A) \<and> (\<not> (if i < m1 then sel1 i else sel2 (i - m1)) \<longrightarrow> (if i < m1 then as1 i else as2 (i - m1), if Suc i < m1 then as1 (Suc i) else as2 (Suc i - m1)) \<in> B)
 4. n1 + n2 = card {i. i < m1 + m2 \<and> (if i < m1 then sel1 i else sel2 (i - m1))}
 5. (n1 + n2 = 0) = (m1 + m2 = 0)
[PROOF STEP]
have "card (?A \<union> ?f ` ?B) = card ?A + card (?f ` ?B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card ({i. i < m1 \<and> sel1 i} \<union> (+) m1 ` {i. i < m2 \<and> sel2 i}) = card {i. i < m1 \<and> sel1 i} + card ((+) m1 ` {i. i < m2 \<and> sel2 i})
[PROOF STEP]
by (rule card_Un_disjoint, auto)
[PROOF STATE]
proof (state)
this:
card ({i. i < m1 \<and> sel1 i} \<union> (+) m1 ` {i. i < m2 \<and> sel2 i}) = card {i. i < m1 \<and> sel1 i} + card ((+) m1 ` {i. i < m2 \<and> sel2 i})

goal (5 subgoals):
 1. (if 0 < m1 then as1 0 else as2 (0 - m1)) = a
 2. (if m1 + m2 < m1 then as1 (m1 + m2) else as2 (m1 + m2 - m1)) = c
 3. \<And>i. i < m1 + m2 \<Longrightarrow> ((if i < m1 then sel1 i else sel2 (i - m1)) \<longrightarrow> (if i < m1 then as1 i else as2 (i - m1), if Suc i < m1 then as1 (Suc i) else as2 (Suc i - m1)) \<in> A) \<and> (\<not> (if i < m1 then sel1 i else sel2 (i - m1)) \<longrightarrow> (if i < m1 then as1 i else as2 (i - m1), if Suc i < m1 then as1 (Suc i) else as2 (Suc i - m1)) \<in> B)
 4. n1 + n2 = card {i. i < m1 + m2 \<and> (if i < m1 then sel1 i else sel2 (i - m1))}
 5. (n1 + n2 = 0) = (m1 + m2 = 0)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
card ({i. i < m1 \<and> sel1 i} \<union> (+) m1 ` {i. i < m2 \<and> sel2 i}) = card {i. i < m1 \<and> sel1 i} + card ((+) m1 ` {i. i < m2 \<and> sel2 i})

goal (5 subgoals):
 1. (if 0 < m1 then as1 0 else as2 (0 - m1)) = a
 2. (if m1 + m2 < m1 then as1 (m1 + m2) else as2 (m1 + m2 - m1)) = c
 3. \<And>i. i < m1 + m2 \<Longrightarrow> ((if i < m1 then sel1 i else sel2 (i - m1)) \<longrightarrow> (if i < m1 then as1 i else as2 (i - m1), if Suc i < m1 then as1 (Suc i) else as2 (Suc i - m1)) \<in> A) \<and> (\<not> (if i < m1 then sel1 i else sel2 (i - m1)) \<longrightarrow> (if i < m1 then as1 i else as2 (i - m1), if Suc i < m1 then as1 (Suc i) else as2 (Suc i - m1)) \<in> B)
 4. n1 + n2 = card {i. i < m1 + m2 \<and> (if i < m1 then sel1 i else sel2 (i - m1))}
 5. (n1 + n2 = 0) = (m1 + m2 = 0)
[PROOF STEP]
have "card (?f ` ?B) = card ?B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card ((+) m1 ` {i. i < m2 \<and> sel2 i}) = card {i. i < m2 \<and> sel2 i}
[PROOF STEP]
by (rule card_image, auto simp: inj_on_def)
[PROOF STATE]
proof (state)
this:
card ((+) m1 ` {i. i < m2 \<and> sel2 i}) = card {i. i < m2 \<and> sel2 i}

goal (5 subgoals):
 1. (if 0 < m1 then as1 0 else as2 (0 - m1)) = a
 2. (if m1 + m2 < m1 then as1 (m1 + m2) else as2 (m1 + m2 - m1)) = c
 3. \<And>i. i < m1 + m2 \<Longrightarrow> ((if i < m1 then sel1 i else sel2 (i - m1)) \<longrightarrow> (if i < m1 then as1 i else as2 (i - m1), if Suc i < m1 then as1 (Suc i) else as2 (Suc i - m1)) \<in> A) \<and> (\<not> (if i < m1 then sel1 i else sel2 (i - m1)) \<longrightarrow> (if i < m1 then as1 i else as2 (i - m1), if Suc i < m1 then as1 (Suc i) else as2 (Suc i - m1)) \<in> B)
 4. n1 + n2 = card {i. i < m1 + m2 \<and> (if i < m1 then sel1 i else sel2 (i - m1))}
 5. (n1 + n2 = 0) = (m1 + m2 = 0)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
card ({i. i < m1 \<and> sel1 i} \<union> (+) m1 ` {i. i < m2 \<and> sel2 i}) = card {i. i < m1 \<and> sel1 i} + card {i. i < m2 \<and> sel2 i}
[PROOF STEP]
show "?n = card { i . i < ?m \<and> ?sel i}"
[PROOF STATE]
proof (prove)
using this:
card ({i. i < m1 \<and> sel1 i} \<union> (+) m1 ` {i. i < m2 \<and> sel2 i}) = card {i. i < m1 \<and> sel1 i} + card {i. i < m2 \<and> sel2 i}

goal (1 subgoal):
 1. n1 + n2 = card {i. i < m1 + m2 \<and> (if i < m1 then sel1 i else sel2 (i - m1))}
[PROOF STEP]
unfolding card1 card2 id
[PROOF STATE]
proof (prove)
using this:
card ({i. i < m1 \<and> sel1 i} \<union> (+) m1 ` {i. i < m2 \<and> sel2 i}) = card {i. i < m1 \<and> sel1 i} + card {i. i < m2 \<and> sel2 i}

goal (1 subgoal):
 1. card {i. i < m1 \<and> sel1 i} + card {i. i < m2 \<and> sel2 i} = card ({i. i < m1 \<and> sel1 i} \<union> (+) m1 ` {i. i < m2 \<and> sel2 i})
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
n1 + n2 = card {i. i < m1 + m2 \<and> (if i < m1 then sel1 i else sel2 (i - m1))}

goal (4 subgoals):
 1. (if 0 < m1 then as1 0 else as2 (0 - m1)) = a
 2. (if m1 + m2 < m1 then as1 (m1 + m2) else as2 (m1 + m2 - m1)) = c
 3. \<And>i. i < m1 + m2 \<Longrightarrow> ((if i < m1 then sel1 i else sel2 (i - m1)) \<longrightarrow> (if i < m1 then as1 i else as2 (i - m1), if Suc i < m1 then as1 (Suc i) else as2 (Suc i - m1)) \<in> A) \<and> (\<not> (if i < m1 then sel1 i else sel2 (i - m1)) \<longrightarrow> (if i < m1 then as1 i else as2 (i - m1), if Suc i < m1 then as1 (Suc i) else as2 (Suc i - m1)) \<in> B)
 4. (n1 + n2 = 0) = (m1 + m2 = 0)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (4 subgoals):
 1. (if 0 < m1 then as1 0 else as2 (0 - m1)) = a
 2. (if m1 + m2 < m1 then as1 (m1 + m2) else as2 (m1 + m2 - m1)) = c
 3. \<And>i. i < m1 + m2 \<Longrightarrow> ((if i < m1 then sel1 i else sel2 (i - m1)) \<longrightarrow> (if i < m1 then as1 i else as2 (i - m1), if Suc i < m1 then as1 (Suc i) else as2 (Suc i - m1)) \<in> A) \<and> (\<not> (if i < m1 then sel1 i else sel2 (i - m1)) \<longrightarrow> (if i < m1 then as1 i else as2 (i - m1), if Suc i < m1 then as1 (Suc i) else as2 (Suc i - m1)) \<in> B)
 4. (n1 + n2 = 0) = (m1 + m2 = 0)
[PROOF STEP]
fix i
[PROOF STATE]
proof (state)
goal (4 subgoals):
 1. (if 0 < m1 then as1 0 else as2 (0 - m1)) = a
 2. (if m1 + m2 < m1 then as1 (m1 + m2) else as2 (m1 + m2 - m1)) = c
 3. \<And>i. i < m1 + m2 \<Longrightarrow> ((if i < m1 then sel1 i else sel2 (i - m1)) \<longrightarrow> (if i < m1 then as1 i else as2 (i - m1), if Suc i < m1 then as1 (Suc i) else as2 (Suc i - m1)) \<in> A) \<and> (\<not> (if i < m1 then sel1 i else sel2 (i - m1)) \<longrightarrow> (if i < m1 then as1 i else as2 (i - m1), if Suc i < m1 then as1 (Suc i) else as2 (Suc i - m1)) \<in> B)
 4. (n1 + n2 = 0) = (m1 + m2 = 0)
[PROOF STEP]
assume i: "i < ?m"
[PROOF STATE]
proof (state)
this:
i < m1 + m2

goal (4 subgoals):
 1. (if 0 < m1 then as1 0 else as2 (0 - m1)) = a
 2. (if m1 + m2 < m1 then as1 (m1 + m2) else as2 (m1 + m2 - m1)) = c
 3. \<And>i. i < m1 + m2 \<Longrightarrow> ((if i < m1 then sel1 i else sel2 (i - m1)) \<longrightarrow> (if i < m1 then as1 i else as2 (i - m1), if Suc i < m1 then as1 (Suc i) else as2 (Suc i - m1)) \<in> A) \<and> (\<not> (if i < m1 then sel1 i else sel2 (i - m1)) \<longrightarrow> (if i < m1 then as1 i else as2 (i - m1), if Suc i < m1 then as1 (Suc i) else as2 (Suc i - m1)) \<in> B)
 4. (n1 + n2 = 0) = (m1 + m2 = 0)
[PROOF STEP]
show "(?sel i \<longrightarrow> (?as i, ?as (Suc i)) \<in> A) \<and> (\<not> ?sel i \<longrightarrow> (?as i, ?as (Suc i)) \<in> B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((if i < m1 then sel1 i else sel2 (i - m1)) \<longrightarrow> (if i < m1 then as1 i else as2 (i - m1), if Suc i < m1 then as1 (Suc i) else as2 (Suc i - m1)) \<in> A) \<and> (\<not> (if i < m1 then sel1 i else sel2 (i - m1)) \<longrightarrow> (if i < m1 then as1 i else as2 (i - m1), if Suc i < m1 then as1 (Suc i) else as2 (Suc i - m1)) \<in> B)
[PROOF STEP]
proof (cases "i < m1")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. i < m1 \<Longrightarrow> ((if i < m1 then sel1 i else sel2 (i - m1)) \<longrightarrow> (if i < m1 then as1 i else as2 (i - m1), if Suc i < m1 then as1 (Suc i) else as2 (Suc i - m1)) \<in> A) \<and> (\<not> (if i < m1 then sel1 i else sel2 (i - m1)) \<longrightarrow> (if i < m1 then as1 i else as2 (i - m1), if Suc i < m1 then as1 (Suc i) else as2 (Suc i - m1)) \<in> B)
 2. \<not> i < m1 \<Longrightarrow> ((if i < m1 then sel1 i else sel2 (i - m1)) \<longrightarrow> (if i < m1 then as1 i else as2 (i - m1), if Suc i < m1 then as1 (Suc i) else as2 (Suc i - m1)) \<in> A) \<and> (\<not> (if i < m1 then sel1 i else sel2 (i - m1)) \<longrightarrow> (if i < m1 then as1 i else as2 (i - m1), if Suc i < m1 then as1 (Suc i) else as2 (Suc i - m1)) \<in> B)
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
i < m1

goal (2 subgoals):
 1. i < m1 \<Longrightarrow> ((if i < m1 then sel1 i else sel2 (i - m1)) \<longrightarrow> (if i < m1 then as1 i else as2 (i - m1), if Suc i < m1 then as1 (Suc i) else as2 (Suc i - m1)) \<in> A) \<and> (\<not> (if i < m1 then sel1 i else sel2 (i - m1)) \<longrightarrow> (if i < m1 then as1 i else as2 (i - m1), if Suc i < m1 then as1 (Suc i) else as2 (Suc i - m1)) \<in> B)
 2. \<not> i < m1 \<Longrightarrow> ((if i < m1 then sel1 i else sel2 (i - m1)) \<longrightarrow> (if i < m1 then as1 i else as2 (i - m1), if Suc i < m1 then as1 (Suc i) else as2 (Suc i - m1)) \<in> A) \<and> (\<not> (if i < m1 then sel1 i else sel2 (i - m1)) \<longrightarrow> (if i < m1 then as1 i else as2 (i - m1), if Suc i < m1 then as1 (Suc i) else as2 (Suc i - m1)) \<in> B)
[PROOF STEP]
from 1 2
[PROOF STATE]
proof (chain)
picking this:
as1 0 = a
as1 m1 = b
?i < m1 \<Longrightarrow> (sel1 ?i \<longrightarrow> (as1 ?i, as1 (Suc ?i)) \<in> A) \<and> (\<not> sel1 ?i \<longrightarrow> (as1 ?i, as1 (Suc ?i)) \<in> B)
(n1 = 0) = (m1 = 0)
as2 0 = b
as2 m2 = c
?i < m2 \<Longrightarrow> (sel2 ?i \<longrightarrow> (as2 ?i, as2 (Suc ?i)) \<in> A) \<and> (\<not> sel2 ?i \<longrightarrow> (as2 ?i, as2 (Suc ?i)) \<in> B)
(n2 = 0) = (m2 = 0)
[PROOF STEP]
have [simp]: "as2 0 = as1 m1"
[PROOF STATE]
proof (prove)
using this:
as1 0 = a
as1 m1 = b
?i < m1 \<Longrightarrow> (sel1 ?i \<longrightarrow> (as1 ?i, as1 (Suc ?i)) \<in> A) \<and> (\<not> sel1 ?i \<longrightarrow> (as1 ?i, as1 (Suc ?i)) \<in> B)
(n1 = 0) = (m1 = 0)
as2 0 = b
as2 m2 = c
?i < m2 \<Longrightarrow> (sel2 ?i \<longrightarrow> (as2 ?i, as2 (Suc ?i)) \<in> A) \<and> (\<not> sel2 ?i \<longrightarrow> (as2 ?i, as2 (Suc ?i)) \<in> B)
(n2 = 0) = (m2 = 0)

goal (1 subgoal):
 1. as2 0 = as1 m1
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
as2 0 = as1 m1

goal (2 subgoals):
 1. i < m1 \<Longrightarrow> ((if i < m1 then sel1 i else sel2 (i - m1)) \<longrightarrow> (if i < m1 then as1 i else as2 (i - m1), if Suc i < m1 then as1 (Suc i) else as2 (Suc i - m1)) \<in> A) \<and> (\<not> (if i < m1 then sel1 i else sel2 (i - m1)) \<longrightarrow> (if i < m1 then as1 i else as2 (i - m1), if Suc i < m1 then as1 (Suc i) else as2 (Suc i - m1)) \<in> B)
 2. \<not> i < m1 \<Longrightarrow> ((if i < m1 then sel1 i else sel2 (i - m1)) \<longrightarrow> (if i < m1 then as1 i else as2 (i - m1), if Suc i < m1 then as1 (Suc i) else as2 (Suc i - m1)) \<in> A) \<and> (\<not> (if i < m1 then sel1 i else sel2 (i - m1)) \<longrightarrow> (if i < m1 then as1 i else as2 (i - m1), if Suc i < m1 then as1 (Suc i) else as2 (Suc i - m1)) \<in> B)
[PROOF STEP]
from True 1(3)[of i] 1(2)
[PROOF STATE]
proof (chain)
picking this:
i < m1
i < m1 \<Longrightarrow> (sel1 i \<longrightarrow> (as1 i, as1 (Suc i)) \<in> A) \<and> (\<not> sel1 i \<longrightarrow> (as1 i, as1 (Suc i)) \<in> B)
as1 m1 = b
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
i < m1
i < m1 \<Longrightarrow> (sel1 i \<longrightarrow> (as1 i, as1 (Suc i)) \<in> A) \<and> (\<not> sel1 i \<longrightarrow> (as1 i, as1 (Suc i)) \<in> B)
as1 m1 = b

goal (1 subgoal):
 1. ((if i < m1 then sel1 i else sel2 (i - m1)) \<longrightarrow> (if i < m1 then as1 i else as2 (i - m1), if Suc i < m1 then as1 (Suc i) else as2 (Suc i - m1)) \<in> A) \<and> (\<not> (if i < m1 then sel1 i else sel2 (i - m1)) \<longrightarrow> (if i < m1 then as1 i else as2 (i - m1), if Suc i < m1 then as1 (Suc i) else as2 (Suc i - m1)) \<in> B)
[PROOF STEP]
by (cases "Suc i = m1", auto)
[PROOF STATE]
proof (state)
this:
((if i < m1 then sel1 i else sel2 (i - m1)) \<longrightarrow> (if i < m1 then as1 i else as2 (i - m1), if Suc i < m1 then as1 (Suc i) else as2 (Suc i - m1)) \<in> A) \<and> (\<not> (if i < m1 then sel1 i else sel2 (i - m1)) \<longrightarrow> (if i < m1 then as1 i else as2 (i - m1), if Suc i < m1 then as1 (Suc i) else as2 (Suc i - m1)) \<in> B)

goal (1 subgoal):
 1. \<not> i < m1 \<Longrightarrow> ((if i < m1 then sel1 i else sel2 (i - m1)) \<longrightarrow> (if i < m1 then as1 i else as2 (i - m1), if Suc i < m1 then as1 (Suc i) else as2 (Suc i - m1)) \<in> A) \<and> (\<not> (if i < m1 then sel1 i else sel2 (i - m1)) \<longrightarrow> (if i < m1 then as1 i else as2 (i - m1), if Suc i < m1 then as1 (Suc i) else as2 (Suc i - m1)) \<in> B)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> i < m1 \<Longrightarrow> ((if i < m1 then sel1 i else sel2 (i - m1)) \<longrightarrow> (if i < m1 then as1 i else as2 (i - m1), if Suc i < m1 then as1 (Suc i) else as2 (Suc i - m1)) \<in> A) \<and> (\<not> (if i < m1 then sel1 i else sel2 (i - m1)) \<longrightarrow> (if i < m1 then as1 i else as2 (i - m1), if Suc i < m1 then as1 (Suc i) else as2 (Suc i - m1)) \<in> B)
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> i < m1

goal (1 subgoal):
 1. \<not> i < m1 \<Longrightarrow> ((if i < m1 then sel1 i else sel2 (i - m1)) \<longrightarrow> (if i < m1 then as1 i else as2 (i - m1), if Suc i < m1 then as1 (Suc i) else as2 (Suc i - m1)) \<in> A) \<and> (\<not> (if i < m1 then sel1 i else sel2 (i - m1)) \<longrightarrow> (if i < m1 then as1 i else as2 (i - m1), if Suc i < m1 then as1 (Suc i) else as2 (Suc i - m1)) \<in> B)
[PROOF STEP]
define j where "j = i - m1"
[PROOF STATE]
proof (state)
this:
j = i - m1

goal (1 subgoal):
 1. \<not> i < m1 \<Longrightarrow> ((if i < m1 then sel1 i else sel2 (i - m1)) \<longrightarrow> (if i < m1 then as1 i else as2 (i - m1), if Suc i < m1 then as1 (Suc i) else as2 (Suc i - m1)) \<in> A) \<and> (\<not> (if i < m1 then sel1 i else sel2 (i - m1)) \<longrightarrow> (if i < m1 then as1 i else as2 (i - m1), if Suc i < m1 then as1 (Suc i) else as2 (Suc i - m1)) \<in> B)
[PROOF STEP]
have i: "i = m1 + j" and j: "j < m2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. i = m1 + j &&& j < m2
[PROOF STEP]
using i False
[PROOF STATE]
proof (prove)
using this:
i < m1 + m2
\<not> i < m1

goal (1 subgoal):
 1. i = m1 + j &&& j < m2
[PROOF STEP]
unfolding j_def
[PROOF STATE]
proof (prove)
using this:
i < m1 + m2
\<not> i < m1

goal (1 subgoal):
 1. i = m1 + (i - m1) &&& i - m1 < m2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
i = m1 + j
j < m2

goal (1 subgoal):
 1. \<not> i < m1 \<Longrightarrow> ((if i < m1 then sel1 i else sel2 (i - m1)) \<longrightarrow> (if i < m1 then as1 i else as2 (i - m1), if Suc i < m1 then as1 (Suc i) else as2 (Suc i - m1)) \<in> A) \<and> (\<not> (if i < m1 then sel1 i else sel2 (i - m1)) \<longrightarrow> (if i < m1 then as1 i else as2 (i - m1), if Suc i < m1 then as1 (Suc i) else as2 (Suc i - m1)) \<in> B)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
i = m1 + j
j < m2

goal (1 subgoal):
 1. ((if i < m1 then sel1 i else sel2 (i - m1)) \<longrightarrow> (if i < m1 then as1 i else as2 (i - m1), if Suc i < m1 then as1 (Suc i) else as2 (Suc i - m1)) \<in> A) \<and> (\<not> (if i < m1 then sel1 i else sel2 (i - m1)) \<longrightarrow> (if i < m1 then as1 i else as2 (i - m1), if Suc i < m1 then as1 (Suc i) else as2 (Suc i - m1)) \<in> B)
[PROOF STEP]
using False 2(3)[of j]
[PROOF STATE]
proof (prove)
using this:
i = m1 + j
j < m2
\<not> i < m1
j < m2 \<Longrightarrow> (sel2 j \<longrightarrow> (as2 j, as2 (Suc j)) \<in> A) \<and> (\<not> sel2 j \<longrightarrow> (as2 j, as2 (Suc j)) \<in> B)

goal (1 subgoal):
 1. ((if i < m1 then sel1 i else sel2 (i - m1)) \<longrightarrow> (if i < m1 then as1 i else as2 (i - m1), if Suc i < m1 then as1 (Suc i) else as2 (Suc i - m1)) \<in> A) \<and> (\<not> (if i < m1 then sel1 i else sel2 (i - m1)) \<longrightarrow> (if i < m1 then as1 i else as2 (i - m1), if Suc i < m1 then as1 (Suc i) else as2 (Suc i - m1)) \<in> B)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
((if i < m1 then sel1 i else sel2 (i - m1)) \<longrightarrow> (if i < m1 then as1 i else as2 (i - m1), if Suc i < m1 then as1 (Suc i) else as2 (Suc i - m1)) \<in> A) \<and> (\<not> (if i < m1 then sel1 i else sel2 (i - m1)) \<longrightarrow> (if i < m1 then as1 i else as2 (i - m1), if Suc i < m1 then as1 (Suc i) else as2 (Suc i - m1)) \<in> B)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
((if i < m1 then sel1 i else sel2 (i - m1)) \<longrightarrow> (if i < m1 then as1 i else as2 (i - m1), if Suc i < m1 then as1 (Suc i) else as2 (Suc i - m1)) \<in> A) \<and> (\<not> (if i < m1 then sel1 i else sel2 (i - m1)) \<longrightarrow> (if i < m1 then as1 i else as2 (i - m1), if Suc i < m1 then as1 (Suc i) else as2 (Suc i - m1)) \<in> B)

goal (3 subgoals):
 1. (if 0 < m1 then as1 0 else as2 (0 - m1)) = a
 2. (if m1 + m2 < m1 then as1 (m1 + m2) else as2 (m1 + m2 - m1)) = c
 3. (n1 + n2 = 0) = (m1 + m2 = 0)
[PROOF STEP]
qed (insert 1 2, auto)
[PROOF STATE]
proof (state)
this:
\<exists>as sel. relto_fun A B (n1 + n2) as sel (m1 + m2) (a, c)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma dist_increases_online:
  fixes a b d :: "'a::real_inner"
  assumes "d \<noteq> 0"
  shows "dist a (b + d) > dist a b \<or> dist a (b - d) > dist a b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dist a b < dist a (b + d) \<or> dist a b < dist a (b - d)
[PROOF STEP]
proof (cases "inner a d - inner b d > 0")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. 0 < a \<bullet> d - b \<bullet> d \<Longrightarrow> dist a b < dist a (b + d) \<or> dist a b < dist a (b - d)
 2. \<not> 0 < a \<bullet> d - b \<bullet> d \<Longrightarrow> dist a b < dist a (b + d) \<or> dist a b < dist a (b - d)
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
0 < a \<bullet> d - b \<bullet> d

goal (2 subgoals):
 1. 0 < a \<bullet> d - b \<bullet> d \<Longrightarrow> dist a b < dist a (b + d) \<or> dist a b < dist a (b - d)
 2. \<not> 0 < a \<bullet> d - b \<bullet> d \<Longrightarrow> dist a b < dist a (b + d) \<or> dist a b < dist a (b - d)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
0 < a \<bullet> d - b \<bullet> d
[PROOF STEP]
have "0 < inner d d + (inner a d * 2 - inner b d * 2)"
[PROOF STATE]
proof (prove)
using this:
0 < a \<bullet> d - b \<bullet> d

goal (1 subgoal):
 1. 0 < d \<bullet> d + (a \<bullet> d * 2 - b \<bullet> d * 2)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
0 < a \<bullet> d - b \<bullet> d
d \<noteq> (0::'a)

goal (1 subgoal):
 1. 0 < d \<bullet> d + (a \<bullet> d * 2 - b \<bullet> d * 2)
[PROOF STEP]
by (intro add_pos_pos) auto
[PROOF STATE]
proof (state)
this:
0 < d \<bullet> d + (a \<bullet> d * 2 - b \<bullet> d * 2)

goal (2 subgoals):
 1. 0 < a \<bullet> d - b \<bullet> d \<Longrightarrow> dist a b < dist a (b + d) \<or> dist a b < dist a (b - d)
 2. \<not> 0 < a \<bullet> d - b \<bullet> d \<Longrightarrow> dist a b < dist a (b + d) \<or> dist a b < dist a (b - d)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
0 < d \<bullet> d + (a \<bullet> d * 2 - b \<bullet> d * 2)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
0 < d \<bullet> d + (a \<bullet> d * 2 - b \<bullet> d * 2)

goal (1 subgoal):
 1. dist a b < dist a (b + d) \<or> dist a b < dist a (b - d)
[PROOF STEP]
unfolding dist_norm and norm_eq_sqrt_inner and real_sqrt_less_iff
[PROOF STATE]
proof (prove)
using this:
0 < d \<bullet> d + (a \<bullet> d * 2 - b \<bullet> d * 2)

goal (1 subgoal):
 1. (a - b) \<bullet> (a - b) < (a - (b + d)) \<bullet> (a - (b + d)) \<or> (a - b) \<bullet> (a - b) < (a - (b - d)) \<bullet> (a - (b - d))
[PROOF STEP]
by (simp add: algebra_simps inner_commute)
[PROOF STATE]
proof (state)
this:
dist a b < dist a (b + d) \<or> dist a b < dist a (b - d)

goal (1 subgoal):
 1. \<not> 0 < a \<bullet> d - b \<bullet> d \<Longrightarrow> dist a b < dist a (b + d) \<or> dist a b < dist a (b - d)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> 0 < a \<bullet> d - b \<bullet> d \<Longrightarrow> dist a b < dist a (b + d) \<or> dist a b < dist a (b - d)
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> 0 < a \<bullet> d - b \<bullet> d

goal (1 subgoal):
 1. \<not> 0 < a \<bullet> d - b \<bullet> d \<Longrightarrow> dist a b < dist a (b + d) \<or> dist a b < dist a (b - d)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<not> 0 < a \<bullet> d - b \<bullet> d
[PROOF STEP]
have "0 < inner d d + (inner b d * 2 - inner a d * 2)"
[PROOF STATE]
proof (prove)
using this:
\<not> 0 < a \<bullet> d - b \<bullet> d

goal (1 subgoal):
 1. 0 < d \<bullet> d + (b \<bullet> d * 2 - a \<bullet> d * 2)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
\<not> 0 < a \<bullet> d - b \<bullet> d
d \<noteq> (0::'a)

goal (1 subgoal):
 1. 0 < d \<bullet> d + (b \<bullet> d * 2 - a \<bullet> d * 2)
[PROOF STEP]
by (intro add_pos_nonneg) auto
[PROOF STATE]
proof (state)
this:
0 < d \<bullet> d + (b \<bullet> d * 2 - a \<bullet> d * 2)

goal (1 subgoal):
 1. \<not> 0 < a \<bullet> d - b \<bullet> d \<Longrightarrow> dist a b < dist a (b + d) \<or> dist a b < dist a (b - d)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
0 < d \<bullet> d + (b \<bullet> d * 2 - a \<bullet> d * 2)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
0 < d \<bullet> d + (b \<bullet> d * 2 - a \<bullet> d * 2)

goal (1 subgoal):
 1. dist a b < dist a (b + d) \<or> dist a b < dist a (b - d)
[PROOF STEP]
unfolding dist_norm and norm_eq_sqrt_inner and real_sqrt_less_iff
[PROOF STATE]
proof (prove)
using this:
0 < d \<bullet> d + (b \<bullet> d * 2 - a \<bullet> d * 2)

goal (1 subgoal):
 1. (a - b) \<bullet> (a - b) < (a - (b + d)) \<bullet> (a - (b + d)) \<or> (a - b) \<bullet> (a - b) < (a - (b - d)) \<bullet> (a - (b - d))
[PROOF STEP]
by (simp add: algebra_simps inner_commute)
[PROOF STATE]
proof (state)
this:
dist a b < dist a (b + d) \<or> dist a b < dist a (b - d)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma sums_def_le: "f sums s \<longleftrightarrow> (\<lambda>n. \<Sum>i\<le>n. f i) \<longlonglongrightarrow> s"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f sums s = (\<lambda>n. sum f {..n}) \<longlonglongrightarrow> s
[PROOF STEP]
by (simp add: sums_def' atMost_atLeast0)


[STATEMENT]
lemma gbinomial_int_Suc_n [simp]: "(1 + int n) gchoose n = 1 + int n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 + int n gchoose n = 1 + int n
[PROOF STEP]
proof (induct n)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. 1 + int 0 gchoose 0 = 1 + int 0
 2. \<And>n. 1 + int n gchoose n = 1 + int n \<Longrightarrow> 1 + int (Suc n) gchoose Suc n = 1 + int (Suc n)
[PROOF STEP]
case 0
[PROOF STATE]
proof (state)
this:

goal (2 subgoals):
 1. 1 + int 0 gchoose 0 = 1 + int 0
 2. \<And>n. 1 + int n gchoose n = 1 + int n \<Longrightarrow> 1 + int (Suc n) gchoose Suc n = 1 + int (Suc n)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 + int 0 gchoose 0 = 1 + int 0
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
1 + int 0 gchoose 0 = 1 + int 0

goal (1 subgoal):
 1. \<And>n. 1 + int n gchoose n = 1 + int n \<Longrightarrow> 1 + int (Suc n) gchoose Suc n = 1 + int (Suc n)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n. 1 + int n gchoose n = 1 + int n \<Longrightarrow> 1 + int (Suc n) gchoose Suc n = 1 + int (Suc n)
[PROOF STEP]
case (Suc n)
[PROOF STATE]
proof (state)
this:
1 + int n gchoose n = 1 + int n

goal (1 subgoal):
 1. \<And>n. 1 + int n gchoose n = 1 + int n \<Longrightarrow> 1 + int (Suc n) gchoose Suc n = 1 + int (Suc n)
[PROOF STEP]
have "1 + int (Suc n) gchoose Suc n = (1 + int n) + 1 gchoose Suc n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 + int (Suc n) gchoose Suc n = 1 + int n + 1 gchoose Suc n
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
1 + int (Suc n) gchoose Suc n = 1 + int n + 1 gchoose Suc n

goal (1 subgoal):
 1. \<And>n. 1 + int n gchoose n = 1 + int n \<Longrightarrow> 1 + int (Suc n) gchoose Suc n = 1 + int (Suc n)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
1 + int (Suc n) gchoose Suc n = 1 + int n + 1 gchoose Suc n

goal (1 subgoal):
 1. \<And>n. 1 + int n gchoose n = 1 + int n \<Longrightarrow> 1 + int (Suc n) gchoose Suc n = 1 + int (Suc n)
[PROOF STEP]
have "\<dots> = (1 + int n gchoose n) + (1 + int n gchoose (Suc n))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 + int n + 1 gchoose Suc n = 1 + int n gchoose n + (1 + int n gchoose Suc n)
[PROOF STEP]
by (fact gbinomial_int_Suc_Suc)
[PROOF STATE]
proof (state)
this:
1 + int n + 1 gchoose Suc n = 1 + int n gchoose n + (1 + int n gchoose Suc n)

goal (1 subgoal):
 1. \<And>n. 1 + int n gchoose n = 1 + int n \<Longrightarrow> 1 + int (Suc n) gchoose Suc n = 1 + int (Suc n)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
1 + int n + 1 gchoose Suc n = 1 + int n gchoose n + (1 + int n gchoose Suc n)

goal (1 subgoal):
 1. \<And>n. 1 + int n gchoose n = 1 + int n \<Longrightarrow> 1 + int (Suc n) gchoose Suc n = 1 + int (Suc n)
[PROOF STEP]
have "\<dots> = 1 + int n + (int (Suc n) gchoose (Suc n))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 + int n gchoose n + (1 + int n gchoose Suc n) = 1 + int n + (int (Suc n) gchoose Suc n)
[PROOF STEP]
by (simp add: Suc)
[PROOF STATE]
proof (state)
this:
1 + int n gchoose n + (1 + int n gchoose Suc n) = 1 + int n + (int (Suc n) gchoose Suc n)

goal (1 subgoal):
 1. \<And>n. 1 + int n gchoose n = 1 + int n \<Longrightarrow> 1 + int (Suc n) gchoose Suc n = 1 + int (Suc n)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
1 + int n gchoose n + (1 + int n gchoose Suc n) = 1 + int n + (int (Suc n) gchoose Suc n)

goal (1 subgoal):
 1. \<And>n. 1 + int n gchoose n = 1 + int n \<Longrightarrow> 1 + int (Suc n) gchoose Suc n = 1 + int (Suc n)
[PROOF STEP]
have "\<dots> = 1 + int (Suc n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 + int n + (int (Suc n) gchoose Suc n) = 1 + int (Suc n)
[PROOF STEP]
by (simp only: gbinomial_int_n_n)
[PROOF STATE]
proof (state)
this:
1 + int n + (int (Suc n) gchoose Suc n) = 1 + int (Suc n)

goal (1 subgoal):
 1. \<And>n. 1 + int n gchoose n = 1 + int n \<Longrightarrow> 1 + int (Suc n) gchoose Suc n = 1 + int (Suc n)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
1 + int (Suc n) gchoose Suc n = 1 + int (Suc n)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
1 + int (Suc n) gchoose Suc n = 1 + int (Suc n)

goal (1 subgoal):
 1. 1 + int (Suc n) gchoose Suc n = 1 + int (Suc n)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
1 + int (Suc n) gchoose Suc n = 1 + int (Suc n)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma border_example: "{b. border b ''aabaabaa''} = {'''', ''a'', ''aa'', ''aabaa'', ''aabaabaa''}"
  (is "{b. border b ?l} = {?take0, ?take1, ?take2, ?take5, ?l}")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {b. border b ''aabaabaa''} = {[], ''a'', ''aa'', ''aabaa'', ''aabaabaa''}
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. {b. border b ''aabaabaa''} \<subseteq> {[], ''a'', ''aa'', ''aabaa'', ''aabaabaa''}
 2. {[], ''a'', ''aa'', ''aabaa'', ''aabaabaa''} \<subseteq> {b. border b ''aabaabaa''}
[PROOF STEP]
show "{?take0, ?take1, ?take2, ?take5, ?l} \<subseteq> {b. border b ?l}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {[], ''a'', ''aa'', ''aabaa'', ''aabaabaa''} \<subseteq> {b. border b ''aabaabaa''}
[PROOF STEP]
by simp eval
[PROOF STATE]
proof (state)
this:
{[], ''a'', ''aa'', ''aabaa'', ''aabaabaa''} \<subseteq> {b. border b ''aabaabaa''}

goal (1 subgoal):
 1. {b. border b ''aabaabaa''} \<subseteq> {[], ''a'', ''aa'', ''aabaa'', ''aabaabaa''}
[PROOF STEP]
have "\<not>border ''aab'' ?l" "\<not>border ''aaba'' ?l" "\<not>border ''aabaab'' ?l" "\<not>border ''aabaaba'' ?l"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<not> border ''aab'' ''aabaabaa'' &&& \<not> border ''aaba'' ''aabaabaa'') &&& \<not> border ''aabaab'' ''aabaabaa'' &&& \<not> border ''aabaaba'' ''aabaabaa''
[PROOF STEP]
by eval+
[PROOF STATE]
proof (state)
this:
\<not> border ''aab'' ''aabaabaa''
\<not> border ''aaba'' ''aabaabaa''
\<not> border ''aabaab'' ''aabaabaa''
\<not> border ''aabaaba'' ''aabaabaa''

goal (1 subgoal):
 1. {b. border b ''aabaabaa''} \<subseteq> {[], ''a'', ''aa'', ''aabaa'', ''aabaabaa''}
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
\<not> border ''aab'' ''aabaabaa''
\<not> border ''aaba'' ''aabaabaa''
\<not> border ''aabaab'' ''aabaabaa''
\<not> border ''aabaaba'' ''aabaabaa''

goal (1 subgoal):
 1. {b. border b ''aabaabaa''} \<subseteq> {[], ''a'', ''aa'', ''aabaa'', ''aabaabaa''}
[PROOF STEP]
have "{b. border b ?l} \<subseteq> set (prefixes ?l)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {b. border b ''aabaabaa''} \<subseteq> set (prefixes ''aabaabaa'')
[PROOF STEP]
using border_def in_set_prefixes
[PROOF STATE]
proof (prove)
using this:
border ?xs ?ys = (prefix ?xs ?ys \<and> suffix ?xs ?ys)
(?xs \<in> set (prefixes ?ys)) = prefix ?xs ?ys

goal (1 subgoal):
 1. {b. border b ''aabaabaa''} \<subseteq> set (prefixes ''aabaabaa'')
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
{b. border b ''aabaabaa''} \<subseteq> set (prefixes ''aabaabaa'')

goal (1 subgoal):
 1. {b. border b ''aabaabaa''} \<subseteq> {[], ''a'', ''aa'', ''aabaa'', ''aabaabaa''}
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
\<not> border ''aab'' ''aabaabaa''
\<not> border ''aaba'' ''aabaabaa''
\<not> border ''aabaab'' ''aabaabaa''
\<not> border ''aabaaba'' ''aabaabaa''
{b. border b ''aabaabaa''} \<subseteq> set (prefixes ''aabaabaa'')
[PROOF STEP]
show "{b. border b ?l} \<subseteq> {?take0, ?take1, ?take2, ?take5, ?l}"
[PROOF STATE]
proof (prove)
using this:
\<not> border ''aab'' ''aabaabaa''
\<not> border ''aaba'' ''aabaabaa''
\<not> border ''aabaab'' ''aabaabaa''
\<not> border ''aabaaba'' ''aabaabaa''
{b. border b ''aabaabaa''} \<subseteq> set (prefixes ''aabaabaa'')

goal (1 subgoal):
 1. {b. border b ''aabaabaa''} \<subseteq> {[], ''a'', ''aa'', ''aabaa'', ''aabaabaa''}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
{b. border b ''aabaabaa''} \<subseteq> {[], ''a'', ''aa'', ''aabaa'', ''aabaabaa''}

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma valuate_update_x_lemma:
  fixes v1 v2 :: "'a::rational_vector valuation"
  assumes
    "\<forall>y. f y \<noteq> 0 \<longrightarrow> y \<noteq> x \<longrightarrow> v1 y = v2 y"
    "finite {v. f v \<noteq> 0}"
  shows
    "(\<Sum>x\<in>{v. f v \<noteq> 0}. f x *R v1 x) + f x *R (v2 x - v1 x) = (\<Sum>x\<in>{v. f v \<noteq> 0}. f x *R v2 x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>x\<in>{v. f v \<noteq> 0}. f x *R v1 x) + f x *R (v2 x - v1 x) = (\<Sum>x\<in>{v. f v \<noteq> 0}. f x *R v2 x)
[PROOF STEP]
proof (cases "f x = 0")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. f x = 0 \<Longrightarrow> (\<Sum>x\<in>{v. f v \<noteq> 0}. f x *R v1 x) + f x *R (v2 x - v1 x) = (\<Sum>x\<in>{v. f v \<noteq> 0}. f x *R v2 x)
 2. f x \<noteq> 0 \<Longrightarrow> (\<Sum>x\<in>{v. f v \<noteq> 0}. f x *R v1 x) + f x *R (v2 x - v1 x) = (\<Sum>x\<in>{v. f v \<noteq> 0}. f x *R v2 x)
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
f x = 0

goal (2 subgoals):
 1. f x = 0 \<Longrightarrow> (\<Sum>x\<in>{v. f v \<noteq> 0}. f x *R v1 x) + f x *R (v2 x - v1 x) = (\<Sum>x\<in>{v. f v \<noteq> 0}. f x *R v2 x)
 2. f x \<noteq> 0 \<Longrightarrow> (\<Sum>x\<in>{v. f v \<noteq> 0}. f x *R v1 x) + f x *R (v2 x - v1 x) = (\<Sum>x\<in>{v. f v \<noteq> 0}. f x *R v2 x)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
f x = 0
[PROOF STEP]
have "\<forall>y. f y \<noteq> 0 \<longrightarrow> v1 y = v2 y"
[PROOF STATE]
proof (prove)
using this:
f x = 0

goal (1 subgoal):
 1. \<forall>y. f y \<noteq> 0 \<longrightarrow> v1 y = v2 y
[PROOF STEP]
using assms(1)
[PROOF STATE]
proof (prove)
using this:
f x = 0
\<forall>y. f y \<noteq> 0 \<longrightarrow> y \<noteq> x \<longrightarrow> v1 y = v2 y

goal (1 subgoal):
 1. \<forall>y. f y \<noteq> 0 \<longrightarrow> v1 y = v2 y
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<forall>y. f y \<noteq> 0 \<longrightarrow> v1 y = v2 y

goal (2 subgoals):
 1. f x = 0 \<Longrightarrow> (\<Sum>x\<in>{v. f v \<noteq> 0}. f x *R v1 x) + f x *R (v2 x - v1 x) = (\<Sum>x\<in>{v. f v \<noteq> 0}. f x *R v2 x)
 2. f x \<noteq> 0 \<Longrightarrow> (\<Sum>x\<in>{v. f v \<noteq> 0}. f x *R v1 x) + f x *R (v2 x - v1 x) = (\<Sum>x\<in>{v. f v \<noteq> 0}. f x *R v2 x)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<forall>y. f y \<noteq> 0 \<longrightarrow> v1 y = v2 y
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<forall>y. f y \<noteq> 0 \<longrightarrow> v1 y = v2 y

goal (1 subgoal):
 1. (\<Sum>x\<in>{v. f v \<noteq> 0}. f x *R v1 x) + f x *R (v2 x - v1 x) = (\<Sum>x\<in>{v. f v \<noteq> 0}. f x *R v2 x)
[PROOF STEP]
using \<open>f x = 0\<close>
[PROOF STATE]
proof (prove)
using this:
\<forall>y. f y \<noteq> 0 \<longrightarrow> v1 y = v2 y
f x = 0

goal (1 subgoal):
 1. (\<Sum>x\<in>{v. f v \<noteq> 0}. f x *R v1 x) + f x *R (v2 x - v1 x) = (\<Sum>x\<in>{v. f v \<noteq> 0}. f x *R v2 x)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<Sum>x\<in>{v. f v \<noteq> 0}. f x *R v1 x) + f x *R (v2 x - v1 x) = (\<Sum>x\<in>{v. f v \<noteq> 0}. f x *R v2 x)

goal (1 subgoal):
 1. f x \<noteq> 0 \<Longrightarrow> (\<Sum>x\<in>{v. f v \<noteq> 0}. f x *R v1 x) + f x *R (v2 x - v1 x) = (\<Sum>x\<in>{v. f v \<noteq> 0}. f x *R v2 x)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. f x \<noteq> 0 \<Longrightarrow> (\<Sum>x\<in>{v. f v \<noteq> 0}. f x *R v1 x) + f x *R (v2 x - v1 x) = (\<Sum>x\<in>{v. f v \<noteq> 0}. f x *R v2 x)
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
f x \<noteq> 0

goal (1 subgoal):
 1. f x \<noteq> 0 \<Longrightarrow> (\<Sum>x\<in>{v. f v \<noteq> 0}. f x *R v1 x) + f x *R (v2 x - v1 x) = (\<Sum>x\<in>{v. f v \<noteq> 0}. f x *R v2 x)
[PROOF STEP]
let ?A = "{v. f v \<noteq> 0}" and ?Ax = "{v. v \<noteq> x \<and> f v \<noteq> 0}"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. f x \<noteq> 0 \<Longrightarrow> (\<Sum>x\<in>{v. f v \<noteq> 0}. f x *R v1 x) + f x *R (v2 x - v1 x) = (\<Sum>x\<in>{v. f v \<noteq> 0}. f x *R v2 x)
[PROOF STEP]
have "?A = ?Ax \<union> {x}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {v. f v \<noteq> 0} = {v. v \<noteq> x \<and> f v \<noteq> 0} \<union> {x}
[PROOF STEP]
using \<open>f x \<noteq> 0\<close>
[PROOF STATE]
proof (prove)
using this:
f x \<noteq> 0

goal (1 subgoal):
 1. {v. f v \<noteq> 0} = {v. v \<noteq> x \<and> f v \<noteq> 0} \<union> {x}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
{v. f v \<noteq> 0} = {v. v \<noteq> x \<and> f v \<noteq> 0} \<union> {x}

goal (1 subgoal):
 1. f x \<noteq> 0 \<Longrightarrow> (\<Sum>x\<in>{v. f v \<noteq> 0}. f x *R v1 x) + f x *R (v2 x - v1 x) = (\<Sum>x\<in>{v. f v \<noteq> 0}. f x *R v2 x)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
{v. f v \<noteq> 0} = {v. v \<noteq> x \<and> f v \<noteq> 0} \<union> {x}
[PROOF STEP]
have "(\<Sum>x\<in>?A. f x *R v1 x) = f x *R v1 x + (\<Sum>x\<in>?Ax. f x *R v1 x)"
    "(\<Sum>x\<in>?A. f x *R v2 x) = f x *R v2 x + (\<Sum>x\<in>?Ax. f x *R v2 x)"
[PROOF STATE]
proof (prove)
using this:
{v. f v \<noteq> 0} = {v. v \<noteq> x \<and> f v \<noteq> 0} \<union> {x}

goal (1 subgoal):
 1. (\<Sum>x\<in>{v. f v \<noteq> 0}. f x *R v1 x) = f x *R v1 x + (\<Sum>x\<in>{v. v \<noteq> x \<and> f v \<noteq> 0}. f x *R v1 x) &&& (\<Sum>x\<in>{v. f v \<noteq> 0}. f x *R v2 x) = f x *R v2 x + (\<Sum>x\<in>{v. v \<noteq> x \<and> f v \<noteq> 0}. f x *R v2 x)
[PROOF STEP]
using assms(2)
[PROOF STATE]
proof (prove)
using this:
{v. f v \<noteq> 0} = {v. v \<noteq> x \<and> f v \<noteq> 0} \<union> {x}
finite {v. f v \<noteq> 0}

goal (1 subgoal):
 1. (\<Sum>x\<in>{v. f v \<noteq> 0}. f x *R v1 x) = f x *R v1 x + (\<Sum>x\<in>{v. v \<noteq> x \<and> f v \<noteq> 0}. f x *R v1 x) &&& (\<Sum>x\<in>{v. f v \<noteq> 0}. f x *R v2 x) = f x *R v2 x + (\<Sum>x\<in>{v. v \<noteq> x \<and> f v \<noteq> 0}. f x *R v2 x)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<Sum>x\<in>{v. f v \<noteq> 0}. f x *R v1 x) = f x *R v1 x + (\<Sum>x\<in>{v. v \<noteq> x \<and> f v \<noteq> 0}. f x *R v1 x)
(\<Sum>x\<in>{v. f v \<noteq> 0}. f x *R v2 x) = f x *R v2 x + (\<Sum>x\<in>{v. v \<noteq> x \<and> f v \<noteq> 0}. f x *R v2 x)

goal (1 subgoal):
 1. f x \<noteq> 0 \<Longrightarrow> (\<Sum>x\<in>{v. f v \<noteq> 0}. f x *R v1 x) + f x *R (v2 x - v1 x) = (\<Sum>x\<in>{v. f v \<noteq> 0}. f x *R v2 x)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
(\<Sum>x\<in>{v. f v \<noteq> 0}. f x *R v1 x) = f x *R v1 x + (\<Sum>x\<in>{v. v \<noteq> x \<and> f v \<noteq> 0}. f x *R v1 x)
(\<Sum>x\<in>{v. f v \<noteq> 0}. f x *R v2 x) = f x *R v2 x + (\<Sum>x\<in>{v. v \<noteq> x \<and> f v \<noteq> 0}. f x *R v2 x)

goal (1 subgoal):
 1. f x \<noteq> 0 \<Longrightarrow> (\<Sum>x\<in>{v. f v \<noteq> 0}. f x *R v1 x) + f x *R (v2 x - v1 x) = (\<Sum>x\<in>{v. f v \<noteq> 0}. f x *R v2 x)
[PROOF STEP]
have "\<forall> y \<in> ?Ax. v1 y = v2 y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>y\<in>{v. v \<noteq> x \<and> f v \<noteq> 0}. v1 y = v2 y
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
\<forall>y. f y \<noteq> 0 \<longrightarrow> y \<noteq> x \<longrightarrow> v1 y = v2 y
finite {v. f v \<noteq> 0}

goal (1 subgoal):
 1. \<forall>y\<in>{v. v \<noteq> x \<and> f v \<noteq> 0}. v1 y = v2 y
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<forall>y\<in>{v. v \<noteq> x \<and> f v \<noteq> 0}. v1 y = v2 y

goal (1 subgoal):
 1. f x \<noteq> 0 \<Longrightarrow> (\<Sum>x\<in>{v. f v \<noteq> 0}. f x *R v1 x) + f x *R (v2 x - v1 x) = (\<Sum>x\<in>{v. f v \<noteq> 0}. f x *R v2 x)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
\<forall>y\<in>{v. v \<noteq> x \<and> f v \<noteq> 0}. v1 y = v2 y

goal (1 subgoal):
 1. f x \<noteq> 0 \<Longrightarrow> (\<Sum>x\<in>{v. f v \<noteq> 0}. f x *R v1 x) + f x *R (v2 x - v1 x) = (\<Sum>x\<in>{v. f v \<noteq> 0}. f x *R v2 x)
[PROOF STEP]
have "f x *R v1 x + f x *R (v2 x - v1 x) = f x *R v2 x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f x *R v1 x + f x *R (v2 x - v1 x) = f x *R v2 x
[PROOF STEP]
by (subst rational_vector.scale_right_diff_distrib) auto
[PROOF STATE]
proof (state)
this:
f x *R v1 x + f x *R (v2 x - v1 x) = f x *R v2 x

goal (1 subgoal):
 1. f x \<noteq> 0 \<Longrightarrow> (\<Sum>x\<in>{v. f v \<noteq> 0}. f x *R v1 x) + f x *R (v2 x - v1 x) = (\<Sum>x\<in>{v. f v \<noteq> 0}. f x *R v2 x)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
(\<Sum>x\<in>{v. f v \<noteq> 0}. f x *R v1 x) = f x *R v1 x + (\<Sum>x\<in>{v. v \<noteq> x \<and> f v \<noteq> 0}. f x *R v1 x)
(\<Sum>x\<in>{v. f v \<noteq> 0}. f x *R v2 x) = f x *R v2 x + (\<Sum>x\<in>{v. v \<noteq> x \<and> f v \<noteq> 0}. f x *R v2 x)
\<forall>y\<in>{v. v \<noteq> x \<and> f v \<noteq> 0}. v1 y = v2 y
f x *R v1 x + f x *R (v2 x - v1 x) = f x *R v2 x
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(\<Sum>x\<in>{v. f v \<noteq> 0}. f x *R v1 x) = f x *R v1 x + (\<Sum>x\<in>{v. v \<noteq> x \<and> f v \<noteq> 0}. f x *R v1 x)
(\<Sum>x\<in>{v. f v \<noteq> 0}. f x *R v2 x) = f x *R v2 x + (\<Sum>x\<in>{v. v \<noteq> x \<and> f v \<noteq> 0}. f x *R v2 x)
\<forall>y\<in>{v. v \<noteq> x \<and> f v \<noteq> 0}. v1 y = v2 y
f x *R v1 x + f x *R (v2 x - v1 x) = f x *R v2 x

goal (1 subgoal):
 1. (\<Sum>x\<in>{v. f v \<noteq> 0}. f x *R v1 x) + f x *R (v2 x - v1 x) = (\<Sum>x\<in>{v. f v \<noteq> 0}. f x *R v2 x)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<Sum>x\<in>{v. f v \<noteq> 0}. f x *R v1 x) + f x *R (v2 x - v1 x) = (\<Sum>x\<in>{v. f v \<noteq> 0}. f x *R v2 x)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma ket_zero_dim:
  "ket_zero \<in> carrier_vec 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ket_zero \<in> carrier_vec 2
[PROOF STEP]
unfolding ket_zero_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Matrix.vec 2 (\<lambda>k. if k = 0 then 1 else 0) \<in> carrier_vec 2
[PROOF STEP]
by auto


[STATEMENT]
lemma Red_term_pres_no_match_it:
  "\<lbrakk> \<forall> i < length ts. (ts ! i, ts' ! i) : Red_term ^^ (ns!i);
    size ts' = size ts; size ns = size ts;
    no_match ps (map dterm ts)\<rbrakk>
   \<Longrightarrow> no_match ps (map dterm ts')"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<forall>i<length ts. (ts ! i, ts' ! i) \<in> Red_term ^^ ns ! i; length ts' = length ts; length ns = length ts; no_match ps (map dterm ts)\<rbrakk> \<Longrightarrow> no_match ps (map dterm ts')
[PROOF STEP]
proof(induct "sum_list ns" arbitrary: ts ns)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>ns ts. \<lbrakk>0 = sum_list ns; \<forall>i<length ts. (ts ! i, ts' ! i) \<in> Red_term ^^ ns ! i; length ts' = length ts; length ns = length ts; no_match ps (map dterm ts)\<rbrakk> \<Longrightarrow> no_match ps (map dterm ts')
 2. \<And>x ns ts. \<lbrakk>\<And>ns ts. \<lbrakk>x = sum_list ns; \<forall>i<length ts. (ts ! i, ts' ! i) \<in> Red_term ^^ ns ! i; length ts' = length ts; length ns = length ts; no_match ps (map dterm ts)\<rbrakk> \<Longrightarrow> no_match ps (map dterm ts'); Suc x = sum_list ns; \<forall>i<length ts. (ts ! i, ts' ! i) \<in> Red_term ^^ ns ! i; length ts' = length ts; length ns = length ts; no_match ps (map dterm ts)\<rbrakk> \<Longrightarrow> no_match ps (map dterm ts')
[PROOF STEP]
case 0
[PROOF STATE]
proof (state)
this:
0 = sum_list ns
\<forall>i<length ts. (ts ! i, ts' ! i) \<in> Red_term ^^ ns ! i
length ts' = length ts
length ns = length ts
no_match ps (map dterm ts)

goal (2 subgoals):
 1. \<And>ns ts. \<lbrakk>0 = sum_list ns; \<forall>i<length ts. (ts ! i, ts' ! i) \<in> Red_term ^^ ns ! i; length ts' = length ts; length ns = length ts; no_match ps (map dterm ts)\<rbrakk> \<Longrightarrow> no_match ps (map dterm ts')
 2. \<And>x ns ts. \<lbrakk>\<And>ns ts. \<lbrakk>x = sum_list ns; \<forall>i<length ts. (ts ! i, ts' ! i) \<in> Red_term ^^ ns ! i; length ts' = length ts; length ns = length ts; no_match ps (map dterm ts)\<rbrakk> \<Longrightarrow> no_match ps (map dterm ts'); Suc x = sum_list ns; \<forall>i<length ts. (ts ! i, ts' ! i) \<in> Red_term ^^ ns ! i; length ts' = length ts; length ns = length ts; no_match ps (map dterm ts)\<rbrakk> \<Longrightarrow> no_match ps (map dterm ts')
[PROOF STEP]
hence "\<forall>i < size ts. ns!i = 0"
[PROOF STATE]
proof (prove)
using this:
0 = sum_list ns
\<forall>i<length ts. (ts ! i, ts' ! i) \<in> Red_term ^^ ns ! i
length ts' = length ts
length ns = length ts
no_match ps (map dterm ts)

goal (1 subgoal):
 1. \<forall>i<length ts. ns ! i = 0
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<forall>i<length ts. ns ! i = 0

goal (2 subgoals):
 1. \<And>ns ts. \<lbrakk>0 = sum_list ns; \<forall>i<length ts. (ts ! i, ts' ! i) \<in> Red_term ^^ ns ! i; length ts' = length ts; length ns = length ts; no_match ps (map dterm ts)\<rbrakk> \<Longrightarrow> no_match ps (map dterm ts')
 2. \<And>x ns ts. \<lbrakk>\<And>ns ts. \<lbrakk>x = sum_list ns; \<forall>i<length ts. (ts ! i, ts' ! i) \<in> Red_term ^^ ns ! i; length ts' = length ts; length ns = length ts; no_match ps (map dterm ts)\<rbrakk> \<Longrightarrow> no_match ps (map dterm ts'); Suc x = sum_list ns; \<forall>i<length ts. (ts ! i, ts' ! i) \<in> Red_term ^^ ns ! i; length ts' = length ts; length ns = length ts; no_match ps (map dterm ts)\<rbrakk> \<Longrightarrow> no_match ps (map dterm ts')
[PROOF STEP]
with 0
[PROOF STATE]
proof (chain)
picking this:
0 = sum_list ns
\<forall>i<length ts. (ts ! i, ts' ! i) \<in> Red_term ^^ ns ! i
length ts' = length ts
length ns = length ts
no_match ps (map dterm ts)
\<forall>i<length ts. ns ! i = 0
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
0 = sum_list ns
\<forall>i<length ts. (ts ! i, ts' ! i) \<in> Red_term ^^ ns ! i
length ts' = length ts
length ns = length ts
no_match ps (map dterm ts)
\<forall>i<length ts. ns ! i = 0

goal (1 subgoal):
 1. no_match ps (map dterm ts')
[PROOF STEP]
by simp (metis nth_equalityI)
[PROOF STATE]
proof (state)
this:
no_match ps (map dterm ts')

goal (1 subgoal):
 1. \<And>x ns ts. \<lbrakk>\<And>ns ts. \<lbrakk>x = sum_list ns; \<forall>i<length ts. (ts ! i, ts' ! i) \<in> Red_term ^^ ns ! i; length ts' = length ts; length ns = length ts; no_match ps (map dterm ts)\<rbrakk> \<Longrightarrow> no_match ps (map dterm ts'); Suc x = sum_list ns; \<forall>i<length ts. (ts ! i, ts' ! i) \<in> Red_term ^^ ns ! i; length ts' = length ts; length ns = length ts; no_match ps (map dterm ts)\<rbrakk> \<Longrightarrow> no_match ps (map dterm ts')
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x ns ts. \<lbrakk>\<And>ns ts. \<lbrakk>x = sum_list ns; \<forall>i<length ts. (ts ! i, ts' ! i) \<in> Red_term ^^ ns ! i; length ts' = length ts; length ns = length ts; no_match ps (map dterm ts)\<rbrakk> \<Longrightarrow> no_match ps (map dterm ts'); Suc x = sum_list ns; \<forall>i<length ts. (ts ! i, ts' ! i) \<in> Red_term ^^ ns ! i; length ts' = length ts; length ns = length ts; no_match ps (map dterm ts)\<rbrakk> \<Longrightarrow> no_match ps (map dterm ts')
[PROOF STEP]
case (Suc n)
[PROOF STATE]
proof (state)
this:
\<lbrakk>n = sum_list ?ns; \<forall>i<length ?ts. (?ts ! i, ts' ! i) \<in> Red_term ^^ ?ns ! i; length ts' = length ?ts; length ?ns = length ?ts; no_match ps (map dterm ?ts)\<rbrakk> \<Longrightarrow> no_match ps (map dterm ts')
Suc n = sum_list ns
\<forall>i<length ts. (ts ! i, ts' ! i) \<in> Red_term ^^ ns ! i
length ts' = length ts
length ns = length ts
no_match ps (map dterm ts)

goal (1 subgoal):
 1. \<And>x ns ts. \<lbrakk>\<And>ns ts. \<lbrakk>x = sum_list ns; \<forall>i<length ts. (ts ! i, ts' ! i) \<in> Red_term ^^ ns ! i; length ts' = length ts; length ns = length ts; no_match ps (map dterm ts)\<rbrakk> \<Longrightarrow> no_match ps (map dterm ts'); Suc x = sum_list ns; \<forall>i<length ts. (ts ! i, ts' ! i) \<in> Red_term ^^ ns ! i; length ts' = length ts; length ns = length ts; no_match ps (map dterm ts)\<rbrakk> \<Longrightarrow> no_match ps (map dterm ts')
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>n = sum_list ?ns; \<forall>i<length ?ts. (?ts ! i, ts' ! i) \<in> Red_term ^^ ?ns ! i; length ts' = length ?ts; length ?ns = length ?ts; no_match ps (map dterm ?ts)\<rbrakk> \<Longrightarrow> no_match ps (map dterm ts')
Suc n = sum_list ns
\<forall>i<length ts. (ts ! i, ts' ! i) \<in> Red_term ^^ ns ! i
length ts' = length ts
length ns = length ts
no_match ps (map dterm ts)
[PROOF STEP]
have "sum_list ns \<noteq> 0"
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>n = sum_list ?ns; \<forall>i<length ?ts. (?ts ! i, ts' ! i) \<in> Red_term ^^ ?ns ! i; length ts' = length ?ts; length ?ns = length ?ts; no_match ps (map dterm ?ts)\<rbrakk> \<Longrightarrow> no_match ps (map dterm ts')
Suc n = sum_list ns
\<forall>i<length ts. (ts ! i, ts' ! i) \<in> Red_term ^^ ns ! i
length ts' = length ts
length ns = length ts
no_match ps (map dterm ts)

goal (1 subgoal):
 1. sum_list ns \<noteq> 0
[PROOF STEP]
by arith
[PROOF STATE]
proof (state)
this:
sum_list ns \<noteq> 0

goal (1 subgoal):
 1. \<And>x ns ts. \<lbrakk>\<And>ns ts. \<lbrakk>x = sum_list ns; \<forall>i<length ts. (ts ! i, ts' ! i) \<in> Red_term ^^ ns ! i; length ts' = length ts; length ns = length ts; no_match ps (map dterm ts)\<rbrakk> \<Longrightarrow> no_match ps (map dterm ts'); Suc x = sum_list ns; \<forall>i<length ts. (ts ! i, ts' ! i) \<in> Red_term ^^ ns ! i; length ts' = length ts; length ns = length ts; no_match ps (map dterm ts)\<rbrakk> \<Longrightarrow> no_match ps (map dterm ts')
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
sum_list ns \<noteq> 0
[PROOF STEP]
obtain k l where "k<size ts" and [simp]: "ns!k = Suc l"
[PROOF STATE]
proof (prove)
using this:
sum_list ns \<noteq> 0

goal (1 subgoal):
 1. (\<And>k l. \<lbrakk>k < length ts; ns ! k = Suc l\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by simp (metis \<open>length ns = length ts\<close> gr0_implies_Suc in_set_conv_nth)
[PROOF STATE]
proof (state)
this:
k < length ts
ns ! k = Suc l

goal (1 subgoal):
 1. \<And>x ns ts. \<lbrakk>\<And>ns ts. \<lbrakk>x = sum_list ns; \<forall>i<length ts. (ts ! i, ts' ! i) \<in> Red_term ^^ ns ! i; length ts' = length ts; length ns = length ts; no_match ps (map dterm ts)\<rbrakk> \<Longrightarrow> no_match ps (map dterm ts'); Suc x = sum_list ns; \<forall>i<length ts. (ts ! i, ts' ! i) \<in> Red_term ^^ ns ! i; length ts' = length ts; length ns = length ts; no_match ps (map dterm ts)\<rbrakk> \<Longrightarrow> no_match ps (map dterm ts')
[PROOF STEP]
let ?ns = "ns[k := l]"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x ns ts. \<lbrakk>\<And>ns ts. \<lbrakk>x = sum_list ns; \<forall>i<length ts. (ts ! i, ts' ! i) \<in> Red_term ^^ ns ! i; length ts' = length ts; length ns = length ts; no_match ps (map dterm ts)\<rbrakk> \<Longrightarrow> no_match ps (map dterm ts'); Suc x = sum_list ns; \<forall>i<length ts. (ts ! i, ts' ! i) \<in> Red_term ^^ ns ! i; length ts' = length ts; length ns = length ts; no_match ps (map dterm ts)\<rbrakk> \<Longrightarrow> no_match ps (map dterm ts')
[PROOF STEP]
have "n = sum_list ?ns"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n = sum_list (ns[k := l])
[PROOF STEP]
using \<open>Suc n = sum_list ns\<close> \<open>k<size ts\<close> \<open>size ns = size ts\<close>
[PROOF STATE]
proof (prove)
using this:
Suc n = sum_list ns
k < length ts
length ns = length ts

goal (1 subgoal):
 1. n = sum_list (ns[k := l])
[PROOF STEP]
by (simp add:sum_list_update)
[PROOF STATE]
proof (state)
this:
n = sum_list (ns[k := l])

goal (1 subgoal):
 1. \<And>x ns ts. \<lbrakk>\<And>ns ts. \<lbrakk>x = sum_list ns; \<forall>i<length ts. (ts ! i, ts' ! i) \<in> Red_term ^^ ns ! i; length ts' = length ts; length ns = length ts; no_match ps (map dterm ts)\<rbrakk> \<Longrightarrow> no_match ps (map dterm ts'); Suc x = sum_list ns; \<forall>i<length ts. (ts ! i, ts' ! i) \<in> Red_term ^^ ns ! i; length ts' = length ts; length ns = length ts; no_match ps (map dterm ts)\<rbrakk> \<Longrightarrow> no_match ps (map dterm ts')
[PROOF STEP]
obtain t' where "ts!k \<Rightarrow> t'" "(t', ts'!k) : Red_term^^l"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>t'. \<lbrakk>ts ! k \<Rightarrow> t'; (t', ts' ! k) \<in> Red_term ^^ l\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using Suc(3) \<open>k<size ts\<close> \<open>size ns = size ts\<close> \<open>ns!k = Suc l\<close>
[PROOF STATE]
proof (prove)
using this:
\<forall>i<length ts. (ts ! i, ts' ! i) \<in> Red_term ^^ ns ! i
k < length ts
length ns = length ts
ns ! k = Suc l

goal (1 subgoal):
 1. (\<And>t'. \<lbrakk>ts ! k \<Rightarrow> t'; (t', ts' ! k) \<in> Red_term ^^ l\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (metis relpow_Suc_E2)
[PROOF STATE]
proof (state)
this:
ts ! k \<Rightarrow> t'
(t', ts' ! k) \<in> Red_term ^^ l

goal (1 subgoal):
 1. \<And>x ns ts. \<lbrakk>\<And>ns ts. \<lbrakk>x = sum_list ns; \<forall>i<length ts. (ts ! i, ts' ! i) \<in> Red_term ^^ ns ! i; length ts' = length ts; length ns = length ts; no_match ps (map dterm ts)\<rbrakk> \<Longrightarrow> no_match ps (map dterm ts'); Suc x = sum_list ns; \<forall>i<length ts. (ts ! i, ts' ! i) \<in> Red_term ^^ ns ! i; length ts' = length ts; length ns = length ts; no_match ps (map dterm ts)\<rbrakk> \<Longrightarrow> no_match ps (map dterm ts')
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
ts ! k \<Rightarrow> t'
(t', ts' ! k) \<in> Red_term ^^ l
[PROOF STEP]
have 1: "\<forall>i<size(ts[k:=t']). (ts[k:=t']!i, ts'!i) : Red_term^^(?ns!i)"
[PROOF STATE]
proof (prove)
using this:
ts ! k \<Rightarrow> t'
(t', ts' ! k) \<in> Red_term ^^ l

goal (1 subgoal):
 1. \<forall>i<length (ts[k := t']). (ts[k := t'] ! i, ts' ! i) \<in> Red_term ^^ ns[k := l] ! i
[PROOF STEP]
using Suc(3) \<open>k<size ts\<close> \<open>size ns = size ts\<close>
[PROOF STATE]
proof (prove)
using this:
ts ! k \<Rightarrow> t'
(t', ts' ! k) \<in> Red_term ^^ l
\<forall>i<length ts. (ts ! i, ts' ! i) \<in> Red_term ^^ ns ! i
k < length ts
length ns = length ts

goal (1 subgoal):
 1. \<forall>i<length (ts[k := t']). (ts[k := t'] ! i, ts' ! i) \<in> Red_term ^^ ns[k := l] ! i
[PROOF STEP]
by (auto simp add:nth_list_update)
[PROOF STATE]
proof (state)
this:
\<forall>i<length (ts[k := t']). (ts[k := t'] ! i, ts' ! i) \<in> Red_term ^^ ns[k := l] ! i

goal (1 subgoal):
 1. \<And>x ns ts. \<lbrakk>\<And>ns ts. \<lbrakk>x = sum_list ns; \<forall>i<length ts. (ts ! i, ts' ! i) \<in> Red_term ^^ ns ! i; length ts' = length ts; length ns = length ts; no_match ps (map dterm ts)\<rbrakk> \<Longrightarrow> no_match ps (map dterm ts'); Suc x = sum_list ns; \<forall>i<length ts. (ts ! i, ts' ! i) \<in> Red_term ^^ ns ! i; length ts' = length ts; length ns = length ts; no_match ps (map dterm ts)\<rbrakk> \<Longrightarrow> no_match ps (map dterm ts')
[PROOF STEP]
note nm1 = Red_term_pres_no_match[OF \<open>k<size ts\<close> \<open>ts!k \<Rightarrow> t'\<close> \<open>no_match ps (map dterm ts)\<close>]
[PROOF STATE]
proof (state)
this:
map dterm ts = map dterm ts \<Longrightarrow> no_match ps (map dterm (ts[k := t']))

goal (1 subgoal):
 1. \<And>x ns ts. \<lbrakk>\<And>ns ts. \<lbrakk>x = sum_list ns; \<forall>i<length ts. (ts ! i, ts' ! i) \<in> Red_term ^^ ns ! i; length ts' = length ts; length ns = length ts; no_match ps (map dterm ts)\<rbrakk> \<Longrightarrow> no_match ps (map dterm ts'); Suc x = sum_list ns; \<forall>i<length ts. (ts ! i, ts' ! i) \<in> Red_term ^^ ns ! i; length ts' = length ts; length ns = length ts; no_match ps (map dterm ts)\<rbrakk> \<Longrightarrow> no_match ps (map dterm ts')
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. no_match ps (map dterm ts')
[PROOF STEP]
by(rule Suc(1)[OF \<open>n = sum_list ?ns\<close> 1 _ _ nm1])
               (simp_all add: \<open>size ts' = size ts\<close> \<open>size ns = size ts\<close>)
[PROOF STATE]
proof (state)
this:
no_match ps (map dterm ts')

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma deg_add [simp]:
  "p \<in> carrier P \<Longrightarrow> q \<in> carrier P \<Longrightarrow>
  deg R (p \<oplus>\<^bsub>P\<^esub> q) \<le> max (deg R p) (deg R q)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>p \<in> carrier P; q \<in> carrier P\<rbrakk> \<Longrightarrow> deg R (p \<oplus>\<^bsub>P\<^esub> q) \<le> max (deg R p) (deg R q)
[PROOF STEP]
by(rule deg_aboveI)(simp_all add: deg_aboveD)


[STATEMENT]
lemma mult_ge_zero[intro]: "(a :: 'a :: ordered_semiring_1) \<ge> 0 \<Longrightarrow> b \<ge> 0 \<Longrightarrow> a * b \<ge> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>(0::'a) \<le> a; (0::'a) \<le> b\<rbrakk> \<Longrightarrow> (0::'a) \<le> a * b
[PROOF STEP]
using times_left_mono[of b 0 a]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>(0::'a) \<le> b; (0::'a) \<le> a\<rbrakk> \<Longrightarrow> (0::'a) * b \<le> a * b

goal (1 subgoal):
 1. \<lbrakk>(0::'a) \<le> a; (0::'a) \<le> b\<rbrakk> \<Longrightarrow> (0::'a) \<le> a * b
[PROOF STEP]
by auto


[STATEMENT]
lemma fps_conv_radius_uminus [simp]:
  "fps_conv_radius (-f) = fps_conv_radius f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fps_conv_radius (- f) = fps_conv_radius f
[PROOF STEP]
using fps_conv_radius_cmult_left[of "-1" f]
[PROOF STATE]
proof (prove)
using this:
- (1::'a) \<noteq> (0::'a) \<Longrightarrow> fps_conv_radius (fps_const (- (1::'a)) * f) = fps_conv_radius f

goal (1 subgoal):
 1. fps_conv_radius (- f) = fps_conv_radius f
[PROOF STEP]
by (simp flip: fps_const_neg)


[STATEMENT]
lemma sign_changes_Cons_ge: "sign_changes (x # xs) \<ge> sign_changes xs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sign_changes xs \<le> sign_changes (x # xs)
[PROOF STEP]
unfolding sign_changes_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (remdups_adj (filter (\<lambda>x. x \<noteq> (0::'a)) (map sgn xs))) - 1 \<le> length (remdups_adj (filter (\<lambda>x. x \<noteq> (0::'a)) (map sgn (x # xs)))) - 1
[PROOF STEP]
by (simp add: remdups_adj_Cons split: list.split)


[STATEMENT]
lemma slo_linorder: "strict_linear_order r \<Longrightarrow> class.linorder (\<lambda> a b. (a,b) \<in> r\<^sup>=) (\<lambda> a b. (a,b) \<in> r)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. strict_linear_order r \<Longrightarrow> class.linorder (\<lambda>a b. (a, b) \<in> r\<^sup>=) (\<lambda>a b. (a, b) \<in> r)
[PROOF STEP]
unfolding strict_linear_order_on_def strict_partial_order_def irrefl_def trans_def total_on_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<forall>x y z. (x, y) \<in> r \<longrightarrow> (y, z) \<in> r \<longrightarrow> (x, z) \<in> r) \<and> (\<forall>a. (a, a) \<notin> r) \<and> (\<forall>x\<in>UNIV. \<forall>y\<in>UNIV. x \<noteq> y \<longrightarrow> (x, y) \<in> r \<or> (y, x) \<in> r) \<Longrightarrow> class.linorder (\<lambda>a b. (a, b) \<in> r\<^sup>=) (\<lambda>a b. (a, b) \<in> r)
[PROOF STEP]
by unfold_locales blast+


[STATEMENT]
lemma is_Arg_eqI:
  assumes r: "is_Arg z r" and s: "is_Arg z s" and rs: "abs (r-s) < 2*pi" and "z \<noteq> 0"
  shows "r = s"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. r = s
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. r = s
[PROOF STEP]
have zr: "z = (cmod z) * exp (\<i> * r)" and zs: "z = (cmod z) * exp (\<i> * s)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. z = complex_of_real (cmod z) * exp (\<i> * complex_of_real r) &&& z = complex_of_real (cmod z) * exp (\<i> * complex_of_real s)
[PROOF STEP]
using r s
[PROOF STATE]
proof (prove)
using this:
is_Arg z r
is_Arg z s

goal (1 subgoal):
 1. z = complex_of_real (cmod z) * exp (\<i> * complex_of_real r) &&& z = complex_of_real (cmod z) * exp (\<i> * complex_of_real s)
[PROOF STEP]
by (auto simp: is_Arg_def)
[PROOF STATE]
proof (state)
this:
z = complex_of_real (cmod z) * exp (\<i> * complex_of_real r)
z = complex_of_real (cmod z) * exp (\<i> * complex_of_real s)

goal (1 subgoal):
 1. r = s
[PROOF STEP]
with \<open>z \<noteq> 0\<close>
[PROOF STATE]
proof (chain)
picking this:
z \<noteq> 0
z = complex_of_real (cmod z) * exp (\<i> * complex_of_real r)
z = complex_of_real (cmod z) * exp (\<i> * complex_of_real s)
[PROOF STEP]
have eq: "exp (\<i> * r) = exp (\<i> * s)"
[PROOF STATE]
proof (prove)
using this:
z \<noteq> 0
z = complex_of_real (cmod z) * exp (\<i> * complex_of_real r)
z = complex_of_real (cmod z) * exp (\<i> * complex_of_real s)

goal (1 subgoal):
 1. exp (\<i> * complex_of_real r) = exp (\<i> * complex_of_real s)
[PROOF STEP]
by (metis mult_eq_0_iff mult_left_cancel)
[PROOF STATE]
proof (state)
this:
exp (\<i> * complex_of_real r) = exp (\<i> * complex_of_real s)

goal (1 subgoal):
 1. r = s
[PROOF STEP]
have  "\<i> * r = \<i> * s"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<i> * complex_of_real r = \<i> * complex_of_real s
[PROOF STEP]
by (rule exp_complex_eqI) (use rs in \<open>auto simp: eq exp_complex_eqI\<close>)
[PROOF STATE]
proof (state)
this:
\<i> * complex_of_real r = \<i> * complex_of_real s

goal (1 subgoal):
 1. r = s
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<i> * complex_of_real r = \<i> * complex_of_real s
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<i> * complex_of_real r = \<i> * complex_of_real s

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

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma ZFfunCompAppZFfun:
  assumes "isZFfun f" and "isZFfun g" and "|dom|g = |cod|f"
  shows   "isZFfun (f |o| g)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. isZFfun (f |o| g)
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. isZFfun (f |o| g)
[PROOF STEP]
have "f |o| g = ZFfun ( |dom| f) ( |cod| g) (\<lambda> x . g |@| (f |@| x))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f |o| g = ZFfun (|dom|f) (|cod|g) (\<lambda>x. g |@| (f |@| x))
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
isZFfun f
isZFfun g
|dom|g = |cod|f

goal (1 subgoal):
 1. f |o| g = ZFfun (|dom|f) (|cod|g) (\<lambda>x. g |@| (f |@| x))
[PROOF STEP]
by (simp add: ZFfunCompApp)
[PROOF STATE]
proof (state)
this:
f |o| g = ZFfun (|dom|f) (|cod|g) (\<lambda>x. g |@| (f |@| x))

goal (1 subgoal):
 1. isZFfun (f |o| g)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
f |o| g = ZFfun (|dom|f) (|cod|g) (\<lambda>x. g |@| (f |@| x))

goal (1 subgoal):
 1. isZFfun (f |o| g)
[PROOF STEP]
have "\<forall> x . x |\<in>| |dom|f \<longrightarrow> ((\<lambda> x . g |@| (f |@| x)) x) |\<in>| |cod|g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>x. x |\<in>| |dom|f \<longrightarrow> g |@| (f |@| x) |\<in>| |cod|g
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
isZFfun f
isZFfun g
|dom|g = |cod|f

goal (1 subgoal):
 1. \<forall>x. x |\<in>| |dom|f \<longrightarrow> g |@| (f |@| x) |\<in>| |cod|g
[PROOF STEP]
by (simp add: ZFfunDomAppCod)
[PROOF STATE]
proof (state)
this:
\<forall>x. x |\<in>| |dom|f \<longrightarrow> g |@| (f |@| x) |\<in>| |cod|g

goal (1 subgoal):
 1. isZFfun (f |o| g)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
f |o| g = ZFfun (|dom|f) (|cod|g) (\<lambda>x. g |@| (f |@| x))
\<forall>x. x |\<in>| |dom|f \<longrightarrow> g |@| (f |@| x) |\<in>| |cod|g
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
f |o| g = ZFfun (|dom|f) (|cod|g) (\<lambda>x. g |@| (f |@| x))
\<forall>x. x |\<in>| |dom|f \<longrightarrow> g |@| (f |@| x) |\<in>| |cod|g

goal (1 subgoal):
 1. isZFfun (f |o| g)
[PROOF STEP]
by (simp add: SETfun)
[PROOF STATE]
proof (state)
this:
isZFfun (f |o| g)

goal:
No subgoals!
[PROOF STEP]
qed