[STATEMENT]
lemma qtable_union: "qtable n A P Q1 X \<Longrightarrow> qtable n A P Q2 Y \<Longrightarrow>
  (\<And>x. wf_tuple n A x \<Longrightarrow> P x \<Longrightarrow> Q x \<longleftrightarrow> Q1 x \<or> Q2 x) \<Longrightarrow> qtable n A P Q (X \<union> Y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>qtable n A P Q1 X; qtable n A P Q2 Y; \<And>x. \<lbrakk>wf_tuple n A x; P x\<rbrakk> \<Longrightarrow> Q x = (Q1 x \<or> Q2 x)\<rbrakk> \<Longrightarrow> qtable n A P Q (X \<union> Y)
[PROOF STEP]
unfolding qtable_def table_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>Ball X (wf_tuple n A) \<and> (\<forall>x. (x \<in> X \<and> P x \<longrightarrow> Q1 x) \<and> (wf_tuple n A x \<and> P x \<and> Q1 x \<longrightarrow> x \<in> X)); Ball Y (wf_tuple n A) \<and> (\<forall>x. (x \<in> Y \<and> P x \<longrightarrow> Q2 x) \<and> (wf_tuple n A x \<and> P x \<and> Q2 x \<longrightarrow> x \<in> Y)); \<And>x. \<lbrakk>wf_tuple n A x; P x\<rbrakk> \<Longrightarrow> Q x = (Q1 x \<or> Q2 x)\<rbrakk> \<Longrightarrow> Ball (X \<union> Y) (wf_tuple n A) \<and> (\<forall>x. (x \<in> X \<union> Y \<and> P x \<longrightarrow> Q x) \<and> (wf_tuple n A x \<and> P x \<and> Q x \<longrightarrow> x \<in> X \<union> Y))
[PROOF STEP]
by blast


[STATEMENT]
lemma mult_ceiling_le:
  assumes "0 \<le> a" and "0 \<le> b"
  shows "\<lceil>a * b\<rceil> \<le> \<lceil>a\<rceil> * \<lceil>b\<rceil>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lceil>a * b\<rceil> \<le> \<lceil>a\<rceil> * \<lceil>b\<rceil>
[PROOF STEP]
by (metis assms ceiling_le_iff ceiling_mono le_of_int_ceiling mult_mono of_int_mult)


[STATEMENT]
lemma lower_asymptotic_density_infinite_interval [simp]:
  "lower_asymptotic_density {N..} = 1"
  "lower_asymptotic_density {N<..} = 1"
  "lower_asymptotic_density UNIV = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. lower_asymptotic_density {N..} = 1 &&& lower_asymptotic_density {N<..} = 1 &&& lower_asymptotic_density UNIV = 1
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. lower_asymptotic_density {N..} = 1
 2. lower_asymptotic_density {N<..} = 1
 3. lower_asymptotic_density UNIV = 1
[PROOF STEP]
have "UNIV - {N..} = {..<N}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. UNIV - {N..} = {..<N}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
UNIV - {N..} = {..<N}

goal (3 subgoals):
 1. lower_asymptotic_density {N..} = 1
 2. lower_asymptotic_density {N<..} = 1
 3. lower_asymptotic_density UNIV = 1
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
UNIV - {N..} = {..<N}
[PROOF STEP]
show "lower_asymptotic_density {N..} = 1"
[PROOF STATE]
proof (prove)
using this:
UNIV - {N..} = {..<N}

goal (1 subgoal):
 1. lower_asymptotic_density {N..} = 1
[PROOF STEP]
by (auto simp add: lower_upper_asymptotic_density_complement)
[PROOF STATE]
proof (state)
this:
lower_asymptotic_density {N..} = 1

goal (2 subgoals):
 1. lower_asymptotic_density {N<..} = 1
 2. lower_asymptotic_density UNIV = 1
[PROOF STEP]
have "UNIV - {N<..} = {..N}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. UNIV - {N<..} = {..N}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
UNIV - {N<..} = {..N}

goal (2 subgoals):
 1. lower_asymptotic_density {N<..} = 1
 2. lower_asymptotic_density UNIV = 1
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
UNIV - {N<..} = {..N}
[PROOF STEP]
show "lower_asymptotic_density {N<..} = 1"
[PROOF STATE]
proof (prove)
using this:
UNIV - {N<..} = {..N}

goal (1 subgoal):
 1. lower_asymptotic_density {N<..} = 1
[PROOF STEP]
by (auto simp add: lower_upper_asymptotic_density_complement)
[PROOF STATE]
proof (state)
this:
lower_asymptotic_density {N<..} = 1

goal (1 subgoal):
 1. lower_asymptotic_density UNIV = 1
[PROOF STEP]
show "lower_asymptotic_density UNIV = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. lower_asymptotic_density UNIV = 1
[PROOF STEP]
by (auto simp add: lower_upper_asymptotic_density_complement)
[PROOF STATE]
proof (state)
this:
lower_asymptotic_density UNIV = 1

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma is_sorted_list_of_set_alt_def:
  "is_sorted_list_of_set A xs \<longleftrightarrow> sorted (xs) \<and> distinct (xs) \<and> set(xs) = A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. is_sorted_list_of_set A xs = (sorted xs \<and> distinct xs \<and> set xs = A)
[PROOF STEP]
apply (auto intro: sorted_is_sorted_list_of_set)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. \<And>x. \<lbrakk>is_sorted_list_of_set A xs; x \<in> set xs\<rbrakk> \<Longrightarrow> x \<in> A
 2. \<And>x. \<lbrakk>is_sorted_list_of_set A xs; x \<in> A\<rbrakk> \<Longrightarrow> x \<in> set xs
 3. \<lbrakk>sorted xs; distinct xs; A = set xs\<rbrakk> \<Longrightarrow> is_sorted_list_of_set (set xs) xs
[PROOF STEP]
apply (auto simp add: is_sorted_list_of_set_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>i. \<lbrakk>sorted xs; distinct xs; A = set xs; i < length xs - Suc 0\<rbrakk> \<Longrightarrow> xs ! i < xs ! Suc i
[PROOF STEP]
apply (metis Nat.add_0_right One_nat_def add_Suc_right sorted_distinct)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma vectorize_minus: "vectorize_poly (p - q) = vectorize_poly p - vectorize_poly q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vectorize_poly (p - q) = vectorize_poly p - vectorize_poly q
[PROOF STEP]
by (rule poly_mapping_eqI, simp add: lookup_vectorize_poly lookup_minus proj_minus)


[STATEMENT]
lemma scalar_prod_Cauchy:
  fixes u v::"'a :: {trivial_conjugatable_linordered_field} Matrix.vec"
  assumes "u \<in> carrier_vec n" "v \<in> carrier_vec n"
  shows "(u \<bullet> v)\<^sup>2 \<le> \<parallel>u\<parallel>\<^sup>2 * \<parallel>v\<parallel>\<^sup>2 "
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (u \<bullet> v)\<^sup>2 \<le> \<parallel>u\<parallel>\<^sup>2 * \<parallel>v\<parallel>\<^sup>2
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (u \<bullet> v)\<^sup>2 \<le> \<parallel>u\<parallel>\<^sup>2 * \<parallel>v\<parallel>\<^sup>2
[PROOF STEP]
{
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (u \<bullet> v)\<^sup>2 \<le> \<parallel>u\<parallel>\<^sup>2 * \<parallel>v\<parallel>\<^sup>2
[PROOF STEP]
assume v_0: "v \<noteq> 0\<^sub>v n"
[PROOF STATE]
proof (state)
this:
v \<noteq> 0\<^sub>v n

goal (1 subgoal):
 1. (u \<bullet> v)\<^sup>2 \<le> \<parallel>u\<parallel>\<^sup>2 * \<parallel>v\<parallel>\<^sup>2
[PROOF STEP]
have "0 \<le> (u - r \<cdot>\<^sub>v v) \<bullet> (u - r \<cdot>\<^sub>v v)" for r
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (0::'a) \<le> (u - r \<cdot>\<^sub>v v) \<bullet> (u - r \<cdot>\<^sub>v v)
[PROOF STEP]
by (simp add: scalar_prod_ge_0)
[PROOF STATE]
proof (state)
this:
(0::'a) \<le> (u - ?r \<cdot>\<^sub>v v) \<bullet> (u - ?r \<cdot>\<^sub>v v)

goal (1 subgoal):
 1. (u \<bullet> v)\<^sup>2 \<le> \<parallel>u\<parallel>\<^sup>2 * \<parallel>v\<parallel>\<^sup>2
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(0::'a) \<le> (u - ?r \<cdot>\<^sub>v v) \<bullet> (u - ?r \<cdot>\<^sub>v v)

goal (1 subgoal):
 1. (u \<bullet> v)\<^sup>2 \<le> \<parallel>u\<parallel>\<^sup>2 * \<parallel>v\<parallel>\<^sup>2
[PROOF STEP]
have "(u - r \<cdot>\<^sub>v v) \<bullet> (u - r \<cdot>\<^sub>v v) = u \<bullet> u - r * (u \<bullet> v) - r * (u \<bullet> v) + r * r * (v \<bullet> v)" for r::'a
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (u - r \<cdot>\<^sub>v v) \<bullet> (u - r \<cdot>\<^sub>v v) = u \<bullet> u - r * (u \<bullet> v) - r * (u \<bullet> v) + r * r * (v \<bullet> v)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (u - r \<cdot>\<^sub>v v) \<bullet> (u - r \<cdot>\<^sub>v v) = u \<bullet> u - r * (u \<bullet> v) - r * (u \<bullet> v) + r * r * (v \<bullet> v)
[PROOF STEP]
have "(u - r \<cdot>\<^sub>v v) \<bullet> (u - r \<cdot>\<^sub>v v) = (u - r \<cdot>\<^sub>v v) \<bullet> u - (u - r \<cdot>\<^sub>v v) \<bullet> (r \<cdot>\<^sub>v v)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (u - r \<cdot>\<^sub>v v) \<bullet> (u - r \<cdot>\<^sub>v v) = (u - r \<cdot>\<^sub>v v) \<bullet> u - (u - r \<cdot>\<^sub>v v) \<bullet> (r \<cdot>\<^sub>v v)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
u \<in> carrier_vec n
v \<in> carrier_vec n

goal (1 subgoal):
 1. (u - r \<cdot>\<^sub>v v) \<bullet> (u - r \<cdot>\<^sub>v v) = (u - r \<cdot>\<^sub>v v) \<bullet> u - (u - r \<cdot>\<^sub>v v) \<bullet> (r \<cdot>\<^sub>v v)
[PROOF STEP]
by (subst scalar_prod_minus_distrib) auto
[PROOF STATE]
proof (state)
this:
(u - r \<cdot>\<^sub>v v) \<bullet> (u - r \<cdot>\<^sub>v v) = (u - r \<cdot>\<^sub>v v) \<bullet> u - (u - r \<cdot>\<^sub>v v) \<bullet> (r \<cdot>\<^sub>v v)

goal (1 subgoal):
 1. (u - r \<cdot>\<^sub>v v) \<bullet> (u - r \<cdot>\<^sub>v v) = u \<bullet> u - r * (u \<bullet> v) - r * (u \<bullet> v) + r * r * (v \<bullet> v)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(u - r \<cdot>\<^sub>v v) \<bullet> (u - r \<cdot>\<^sub>v v) = (u - r \<cdot>\<^sub>v v) \<bullet> u - (u - r \<cdot>\<^sub>v v) \<bullet> (r \<cdot>\<^sub>v v)

goal (1 subgoal):
 1. (u - r \<cdot>\<^sub>v v) \<bullet> (u - r \<cdot>\<^sub>v v) = u \<bullet> u - r * (u \<bullet> v) - r * (u \<bullet> v) + r * r * (v \<bullet> v)
[PROOF STEP]
have "\<dots> = u \<bullet> u - (r \<cdot>\<^sub>v v) \<bullet> u - r * ((u - r \<cdot>\<^sub>v v) \<bullet> v)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (u - r \<cdot>\<^sub>v v) \<bullet> u - (u - r \<cdot>\<^sub>v v) \<bullet> (r \<cdot>\<^sub>v v) = u \<bullet> u - (r \<cdot>\<^sub>v v) \<bullet> u - r * ((u - r \<cdot>\<^sub>v v) \<bullet> v)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
u \<in> carrier_vec n
v \<in> carrier_vec n

goal (1 subgoal):
 1. (u - r \<cdot>\<^sub>v v) \<bullet> u - (u - r \<cdot>\<^sub>v v) \<bullet> (r \<cdot>\<^sub>v v) = u \<bullet> u - (r \<cdot>\<^sub>v v) \<bullet> u - r * ((u - r \<cdot>\<^sub>v v) \<bullet> v)
[PROOF STEP]
by (subst minus_scalar_prod_distrib) auto
[PROOF STATE]
proof (state)
this:
(u - r \<cdot>\<^sub>v v) \<bullet> u - (u - r \<cdot>\<^sub>v v) \<bullet> (r \<cdot>\<^sub>v v) = u \<bullet> u - (r \<cdot>\<^sub>v v) \<bullet> u - r * ((u - r \<cdot>\<^sub>v v) \<bullet> v)

goal (1 subgoal):
 1. (u - r \<cdot>\<^sub>v v) \<bullet> (u - r \<cdot>\<^sub>v v) = u \<bullet> u - r * (u \<bullet> v) - r * (u \<bullet> v) + r * r * (v \<bullet> v)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(u - r \<cdot>\<^sub>v v) \<bullet> u - (u - r \<cdot>\<^sub>v v) \<bullet> (r \<cdot>\<^sub>v v) = u \<bullet> u - (r \<cdot>\<^sub>v v) \<bullet> u - r * ((u - r \<cdot>\<^sub>v v) \<bullet> v)

goal (1 subgoal):
 1. (u - r \<cdot>\<^sub>v v) \<bullet> (u - r \<cdot>\<^sub>v v) = u \<bullet> u - r * (u \<bullet> v) - r * (u \<bullet> v) + r * r * (v \<bullet> v)
[PROOF STEP]
have "\<dots> = u \<bullet> u - r * (v \<bullet> u) - r * (u \<bullet> v - r * (v \<bullet> v))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. u \<bullet> u - (r \<cdot>\<^sub>v v) \<bullet> u - r * ((u - r \<cdot>\<^sub>v v) \<bullet> v) = u \<bullet> u - r * (v \<bullet> u) - r * (u \<bullet> v - r * (v \<bullet> v))
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
u \<in> carrier_vec n
v \<in> carrier_vec n

goal (1 subgoal):
 1. u \<bullet> u - (r \<cdot>\<^sub>v v) \<bullet> u - r * ((u - r \<cdot>\<^sub>v v) \<bullet> v) = u \<bullet> u - r * (v \<bullet> u) - r * (u \<bullet> v - r * (v \<bullet> v))
[PROOF STEP]
by (subst minus_scalar_prod_distrib) auto
[PROOF STATE]
proof (state)
this:
u \<bullet> u - (r \<cdot>\<^sub>v v) \<bullet> u - r * ((u - r \<cdot>\<^sub>v v) \<bullet> v) = u \<bullet> u - r * (v \<bullet> u) - r * (u \<bullet> v - r * (v \<bullet> v))

goal (1 subgoal):
 1. (u - r \<cdot>\<^sub>v v) \<bullet> (u - r \<cdot>\<^sub>v v) = u \<bullet> u - r * (u \<bullet> v) - r * (u \<bullet> v) + r * r * (v \<bullet> v)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
u \<bullet> u - (r \<cdot>\<^sub>v v) \<bullet> u - r * ((u - r \<cdot>\<^sub>v v) \<bullet> v) = u \<bullet> u - r * (v \<bullet> u) - r * (u \<bullet> v - r * (v \<bullet> v))

goal (1 subgoal):
 1. (u - r \<cdot>\<^sub>v v) \<bullet> (u - r \<cdot>\<^sub>v v) = u \<bullet> u - r * (u \<bullet> v) - r * (u \<bullet> v) + r * r * (v \<bullet> v)
[PROOF STEP]
have "\<dots> = u \<bullet> u - r * (u \<bullet> v) - r * (u \<bullet> v) + r * r * (v \<bullet> v)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. u \<bullet> u - r * (v \<bullet> u) - r * (u \<bullet> v - r * (v \<bullet> v)) = u \<bullet> u - r * (u \<bullet> v) - r * (u \<bullet> v) + r * r * (v \<bullet> v)
[PROOF STEP]
using assms comm_scalar_prod
[PROOF STATE]
proof (prove)
using this:
u \<in> carrier_vec n
v \<in> carrier_vec n
\<lbrakk>?v\<^sub>1 \<in> carrier_vec ?n; ?v\<^sub>2 \<in> carrier_vec ?n\<rbrakk> \<Longrightarrow> ?v\<^sub>1 \<bullet> ?v\<^sub>2 = ?v\<^sub>2 \<bullet> ?v\<^sub>1

goal (1 subgoal):
 1. u \<bullet> u - r * (v \<bullet> u) - r * (u \<bullet> v - r * (v \<bullet> v)) = u \<bullet> u - r * (u \<bullet> v) - r * (u \<bullet> v) + r * r * (v \<bullet> v)
[PROOF STEP]
by (auto simp add: field_simps)
[PROOF STATE]
proof (state)
this:
u \<bullet> u - r * (v \<bullet> u) - r * (u \<bullet> v - r * (v \<bullet> v)) = u \<bullet> u - r * (u \<bullet> v) - r * (u \<bullet> v) + r * r * (v \<bullet> v)

goal (1 subgoal):
 1. (u - r \<cdot>\<^sub>v v) \<bullet> (u - r \<cdot>\<^sub>v v) = u \<bullet> u - r * (u \<bullet> v) - r * (u \<bullet> v) + r * r * (v \<bullet> v)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(u - r \<cdot>\<^sub>v v) \<bullet> (u - r \<cdot>\<^sub>v v) = u \<bullet> u - r * (u \<bullet> v) - r * (u \<bullet> v) + r * r * (v \<bullet> v)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(u - r \<cdot>\<^sub>v v) \<bullet> (u - r \<cdot>\<^sub>v v) = u \<bullet> u - r * (u \<bullet> v) - r * (u \<bullet> v) + r * r * (v \<bullet> v)

goal (1 subgoal):
 1. (u - r \<cdot>\<^sub>v v) \<bullet> (u - r \<cdot>\<^sub>v v) = u \<bullet> u - r * (u \<bullet> v) - r * (u \<bullet> v) + r * r * (v \<bullet> v)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(u - r \<cdot>\<^sub>v v) \<bullet> (u - r \<cdot>\<^sub>v v) = u \<bullet> u - r * (u \<bullet> v) - r * (u \<bullet> v) + r * r * (v \<bullet> v)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(u - ?r \<cdot>\<^sub>v v) \<bullet> (u - ?r \<cdot>\<^sub>v v) = u \<bullet> u - ?r * (u \<bullet> v) - ?r * (u \<bullet> v) + ?r * ?r * (v \<bullet> v)

goal (1 subgoal):
 1. (u \<bullet> v)\<^sup>2 \<le> \<parallel>u\<parallel>\<^sup>2 * \<parallel>v\<parallel>\<^sup>2
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(u - ?r \<cdot>\<^sub>v v) \<bullet> (u - ?r \<cdot>\<^sub>v v) = u \<bullet> u - ?r * (u \<bullet> v) - ?r * (u \<bullet> v) + ?r * ?r * (v \<bullet> v)

goal (1 subgoal):
 1. (u \<bullet> v)\<^sup>2 \<le> \<parallel>u\<parallel>\<^sup>2 * \<parallel>v\<parallel>\<^sup>2
[PROOF STEP]
have "u \<bullet> u - r * (u \<bullet> v) - r * (u \<bullet> v) + r * r * (v \<bullet> v) = sq_norm u - (u \<bullet> v)\<^sup>2 / sq_norm v"
      if "r = (u \<bullet> v) / (v \<bullet> v)" for r
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. u \<bullet> u - r * (u \<bullet> v) - r * (u \<bullet> v) + r * r * (v \<bullet> v) = \<parallel>u\<parallel>\<^sup>2 - (u \<bullet> v)\<^sup>2 / \<parallel>v\<parallel>\<^sup>2
[PROOF STEP]
unfolding that
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. u \<bullet> u - u \<bullet> v / (v \<bullet> v) * (u \<bullet> v) - u \<bullet> v / (v \<bullet> v) * (u \<bullet> v) + u \<bullet> v / (v \<bullet> v) * (u \<bullet> v / (v \<bullet> v)) * (v \<bullet> v) = \<parallel>u\<parallel>\<^sup>2 - (u \<bullet> v)\<^sup>2 / \<parallel>v\<parallel>\<^sup>2
[PROOF STEP]
by (auto simp add: sq_norm_vec_as_cscalar_prod power2_eq_square)
[PROOF STATE]
proof (state)
this:
?r = u \<bullet> v / (v \<bullet> v) \<Longrightarrow> u \<bullet> u - ?r * (u \<bullet> v) - ?r * (u \<bullet> v) + ?r * ?r * (v \<bullet> v) = \<parallel>u\<parallel>\<^sup>2 - (u \<bullet> v)\<^sup>2 / \<parallel>v\<parallel>\<^sup>2

goal (1 subgoal):
 1. (u \<bullet> v)\<^sup>2 \<le> \<parallel>u\<parallel>\<^sup>2 * \<parallel>v\<parallel>\<^sup>2
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
?r1 = u \<bullet> v / (v \<bullet> v) \<Longrightarrow> (0::'a) \<le> \<parallel>u\<parallel>\<^sup>2 - (u \<bullet> v)\<^sup>2 / \<parallel>v\<parallel>\<^sup>2
[PROOF STEP]
have "0 \<le> \<parallel>u\<parallel>\<^sup>2 - (u \<bullet> v)\<^sup>2 / \<parallel>v\<parallel>\<^sup>2"
[PROOF STATE]
proof (prove)
using this:
?r1 = u \<bullet> v / (v \<bullet> v) \<Longrightarrow> (0::'a) \<le> \<parallel>u\<parallel>\<^sup>2 - (u \<bullet> v)\<^sup>2 / \<parallel>v\<parallel>\<^sup>2

goal (1 subgoal):
 1. (0::'a) \<le> \<parallel>u\<parallel>\<^sup>2 - (u \<bullet> v)\<^sup>2 / \<parallel>v\<parallel>\<^sup>2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(0::'a) \<le> \<parallel>u\<parallel>\<^sup>2 - (u \<bullet> v)\<^sup>2 / \<parallel>v\<parallel>\<^sup>2

goal (1 subgoal):
 1. (u \<bullet> v)\<^sup>2 \<le> \<parallel>u\<parallel>\<^sup>2 * \<parallel>v\<parallel>\<^sup>2
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(0::'a) \<le> \<parallel>u\<parallel>\<^sup>2 - (u \<bullet> v)\<^sup>2 / \<parallel>v\<parallel>\<^sup>2
[PROOF STEP]
have "(u \<bullet> v)\<^sup>2 / \<parallel>v\<parallel>\<^sup>2 \<le> \<parallel>u\<parallel>\<^sup>2"
[PROOF STATE]
proof (prove)
using this:
(0::'a) \<le> \<parallel>u\<parallel>\<^sup>2 - (u \<bullet> v)\<^sup>2 / \<parallel>v\<parallel>\<^sup>2

goal (1 subgoal):
 1. (u \<bullet> v)\<^sup>2 / \<parallel>v\<parallel>\<^sup>2 \<le> \<parallel>u\<parallel>\<^sup>2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(u \<bullet> v)\<^sup>2 / \<parallel>v\<parallel>\<^sup>2 \<le> \<parallel>u\<parallel>\<^sup>2

goal (1 subgoal):
 1. (u \<bullet> v)\<^sup>2 \<le> \<parallel>u\<parallel>\<^sup>2 * \<parallel>v\<parallel>\<^sup>2
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(u \<bullet> v)\<^sup>2 / \<parallel>v\<parallel>\<^sup>2 \<le> \<parallel>u\<parallel>\<^sup>2
[PROOF STEP]
have "(u \<bullet> v)\<^sup>2 \<le> \<parallel>u\<parallel>\<^sup>2 * \<parallel>v\<parallel>\<^sup>2"
[PROOF STATE]
proof (prove)
using this:
(u \<bullet> v)\<^sup>2 / \<parallel>v\<parallel>\<^sup>2 \<le> \<parallel>u\<parallel>\<^sup>2

goal (1 subgoal):
 1. (u \<bullet> v)\<^sup>2 \<le> \<parallel>u\<parallel>\<^sup>2 * \<parallel>v\<parallel>\<^sup>2
[PROOF STEP]
using pos_divide_le_eq[of "\<parallel>v\<parallel>\<^sup>2"] v_0 assms
[PROOF STATE]
proof (prove)
using this:
(u \<bullet> v)\<^sup>2 / \<parallel>v\<parallel>\<^sup>2 \<le> \<parallel>u\<parallel>\<^sup>2
(0::'a) < \<parallel>v\<parallel>\<^sup>2 \<Longrightarrow> (?b / \<parallel>v\<parallel>\<^sup>2 \<le> ?a) = (?b \<le> ?a * \<parallel>v\<parallel>\<^sup>2)
v \<noteq> 0\<^sub>v n
u \<in> carrier_vec n
v \<in> carrier_vec n

goal (1 subgoal):
 1. (u \<bullet> v)\<^sup>2 \<le> \<parallel>u\<parallel>\<^sup>2 * \<parallel>v\<parallel>\<^sup>2
[PROOF STEP]
by (auto)
[PROOF STATE]
proof (state)
this:
(u \<bullet> v)\<^sup>2 \<le> \<parallel>u\<parallel>\<^sup>2 * \<parallel>v\<parallel>\<^sup>2

goal (1 subgoal):
 1. (u \<bullet> v)\<^sup>2 \<le> \<parallel>u\<parallel>\<^sup>2 * \<parallel>v\<parallel>\<^sup>2
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
v \<noteq> 0\<^sub>v n \<Longrightarrow> (u \<bullet> v)\<^sup>2 \<le> \<parallel>u\<parallel>\<^sup>2 * \<parallel>v\<parallel>\<^sup>2

goal (1 subgoal):
 1. (u \<bullet> v)\<^sup>2 \<le> \<parallel>u\<parallel>\<^sup>2 * \<parallel>v\<parallel>\<^sup>2
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
v \<noteq> 0\<^sub>v n \<Longrightarrow> (u \<bullet> v)\<^sup>2 \<le> \<parallel>u\<parallel>\<^sup>2 * \<parallel>v\<parallel>\<^sup>2
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
v \<noteq> 0\<^sub>v n \<Longrightarrow> (u \<bullet> v)\<^sup>2 \<le> \<parallel>u\<parallel>\<^sup>2 * \<parallel>v\<parallel>\<^sup>2

goal (1 subgoal):
 1. (u \<bullet> v)\<^sup>2 \<le> \<parallel>u\<parallel>\<^sup>2 * \<parallel>v\<parallel>\<^sup>2
[PROOF STEP]
by (fastforce simp add: assms)
[PROOF STATE]
proof (state)
this:
(u \<bullet> v)\<^sup>2 \<le> \<parallel>u\<parallel>\<^sup>2 * \<parallel>v\<parallel>\<^sup>2

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma finite_permutations:
  assumes "finite S"
  shows "finite {p. p permutes S}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite {p. p permutes S}
[PROOF STEP]
using card_permutations[OF refl assms]
[PROOF STATE]
proof (prove)
using this:
card {p. p permutes S} = fact (card S)

goal (1 subgoal):
 1. finite {p. p permutes S}
[PROOF STEP]
by (auto intro: card_ge_0_finite)


[STATEMENT]
lemma fekete:
  fixes u::"nat \<Rightarrow> real"
  assumes "\<And>n m. u (m+n) \<le> u m + u n"
          "bdd_below {u n/n | n. n>0}"
  shows "(\<lambda>n. u n/n) \<longlonglongrightarrow> Inf {u n/n | n. n>0}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>n. u n / real n) \<longlonglongrightarrow> Inf {u n / real n |n. 0 < n}
[PROOF STEP]
apply (rule subadditive_converges_bounded)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. subadditive u
 2. bdd_below {u n / real n |n. 0 < n}
[PROOF STEP]
unfolding subadditive_def
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<forall>m n. u (m + n) \<le> u m + u n
 2. bdd_below {u n / real n |n. 0 < n}
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
u (?m + ?n) \<le> u ?m + u ?n
bdd_below {u n / real n |n. 0 < n}

goal (2 subgoals):
 1. \<forall>m n. u (m + n) \<le> u m + u n
 2. bdd_below {u n / real n |n. 0 < n}
[PROOF STEP]
by auto


[STATEMENT]
lemma ang_vec_sym_pi:
  assumes "\<angle> z1 z2 = pi"
  shows "\<angle> z1 z2 = \<angle> z2 z1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<angle> z1 z2 = \<angle> z2 z1
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
\<angle> z1 z2 = pi

goal (1 subgoal):
 1. \<angle> z1 z2 = \<angle> z2 z1
[PROOF STEP]
unfolding ang_vec_def
[PROOF STATE]
proof (prove)
using this:
\<downharpoonright>Arg z2 - Arg z1\<downharpoonleft> = pi

goal (1 subgoal):
 1. \<downharpoonright>Arg z2 - Arg z1\<downharpoonleft> = \<downharpoonright>Arg z1 - Arg z2\<downharpoonleft>
[PROOF STEP]
using canon_ang_uminus_pi[of "Arg z2 - Arg z1"]
[PROOF STATE]
proof (prove)
using this:
\<downharpoonright>Arg z2 - Arg z1\<downharpoonleft> = pi
\<downharpoonright>Arg z2 - Arg z1\<downharpoonleft> = pi \<Longrightarrow> \<downharpoonright>- (Arg z2 - Arg z1)\<downharpoonleft> = \<downharpoonright>Arg z2 - Arg z1\<downharpoonleft>

goal (1 subgoal):
 1. \<downharpoonright>Arg z2 - Arg z1\<downharpoonleft> = \<downharpoonright>Arg z1 - Arg z2\<downharpoonleft>
[PROOF STEP]
by simp


[STATEMENT]
lemma cardofpairs: "S \<noteq> [] \<Longrightarrow> sorted S \<Longrightarrow> distinct S \<Longrightarrow> card {(x,y). x \<in> set S \<and> y\<in>set S \<and> x<y} = ((length S)*(length S-1)) / 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>S \<noteq> []; sorted S; distinct S\<rbrakk> \<Longrightarrow> real (card {(x, y). x \<in> set S \<and> y \<in> set S \<and> x < y}) = real (length S * (length S - 1)) / 2
[PROOF STEP]
proof (induct S rule: list_nonempty_induct)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>x. \<lbrakk>sorted [x]; distinct [x]\<rbrakk> \<Longrightarrow> real (card {(xa, y). xa \<in> set [x] \<and> y \<in> set [x] \<and> xa < y}) = real (length [x] * (length [x] - 1)) / 2
 2. \<And>x xs. \<lbrakk>xs \<noteq> []; \<lbrakk>sorted xs; distinct xs\<rbrakk> \<Longrightarrow> real (card {(x, y). x \<in> set xs \<and> y \<in> set xs \<and> x < y}) = real (length xs * (length xs - 1)) / 2; sorted (x # xs); distinct (x # xs)\<rbrakk> \<Longrightarrow> real (card {(xa, y). xa \<in> set (x # xs) \<and> y \<in> set (x # xs) \<and> xa < y}) = real (length (x # xs) * (length (x # xs) - 1)) / 2
[PROOF STEP]
case (cons s ss)
[PROOF STATE]
proof (state)
this:
ss \<noteq> []
\<lbrakk>sorted ss; distinct ss\<rbrakk> \<Longrightarrow> real (card {a. case a of (x, y) \<Rightarrow> x \<in> set ss \<and> y \<in> set ss \<and> x < y}) = real (length ss * (length ss - 1)) / 2
sorted (s # ss)
distinct (s # ss)

goal (2 subgoals):
 1. \<And>x. \<lbrakk>sorted [x]; distinct [x]\<rbrakk> \<Longrightarrow> real (card {(xa, y). xa \<in> set [x] \<and> y \<in> set [x] \<and> xa < y}) = real (length [x] * (length [x] - 1)) / 2
 2. \<And>x xs. \<lbrakk>xs \<noteq> []; \<lbrakk>sorted xs; distinct xs\<rbrakk> \<Longrightarrow> real (card {(x, y). x \<in> set xs \<and> y \<in> set xs \<and> x < y}) = real (length xs * (length xs - 1)) / 2; sorted (x # xs); distinct (x # xs)\<rbrakk> \<Longrightarrow> real (card {(xa, y). xa \<in> set (x # xs) \<and> y \<in> set (x # xs) \<and> xa < y}) = real (length (x # xs) * (length (x # xs) - 1)) / 2
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
ss \<noteq> []
\<lbrakk>sorted ss; distinct ss\<rbrakk> \<Longrightarrow> real (card {a. case a of (x, y) \<Rightarrow> x \<in> set ss \<and> y \<in> set ss \<and> x < y}) = real (length ss * (length ss - 1)) / 2
sorted (s # ss)
distinct (s # ss)
[PROOF STEP]
have "sorted ss" "distinct ss"
[PROOF STATE]
proof (prove)
using this:
ss \<noteq> []
\<lbrakk>sorted ss; distinct ss\<rbrakk> \<Longrightarrow> real (card {a. case a of (x, y) \<Rightarrow> x \<in> set ss \<and> y \<in> set ss \<and> x < y}) = real (length ss * (length ss - 1)) / 2
sorted (s # ss)
distinct (s # ss)

goal (1 subgoal):
 1. sorted ss &&& distinct ss
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
sorted ss
distinct ss

goal (2 subgoals):
 1. \<And>x. \<lbrakk>sorted [x]; distinct [x]\<rbrakk> \<Longrightarrow> real (card {(xa, y). xa \<in> set [x] \<and> y \<in> set [x] \<and> xa < y}) = real (length [x] * (length [x] - 1)) / 2
 2. \<And>x xs. \<lbrakk>xs \<noteq> []; \<lbrakk>sorted xs; distinct xs\<rbrakk> \<Longrightarrow> real (card {(x, y). x \<in> set xs \<and> y \<in> set xs \<and> x < y}) = real (length xs * (length xs - 1)) / 2; sorted (x # xs); distinct (x # xs)\<rbrakk> \<Longrightarrow> real (card {(xa, y). xa \<in> set (x # xs) \<and> y \<in> set (x # xs) \<and> xa < y}) = real (length (x # xs) * (length (x # xs) - 1)) / 2
[PROOF STEP]
from cons(2)[OF this(1) this(2)]
[PROOF STATE]
proof (chain)
picking this:
real (card {a. case a of (x, y) \<Rightarrow> x \<in> set ss \<and> y \<in> set ss \<and> x < y}) = real (length ss * (length ss - 1)) / 2
[PROOF STEP]
have iH: "card {(x, y) . x \<in> set ss \<and> y \<in> set ss \<and> x < y}
    = (length ss * (length ss-1)) / 2"
[PROOF STATE]
proof (prove)
using this:
real (card {a. case a of (x, y) \<Rightarrow> x \<in> set ss \<and> y \<in> set ss \<and> x < y}) = real (length ss * (length ss - 1)) / 2

goal (1 subgoal):
 1. real (card {(x, y). x \<in> set ss \<and> y \<in> set ss \<and> x < y}) = real (length ss * (length ss - 1)) / 2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
real (card {(x, y). x \<in> set ss \<and> y \<in> set ss \<and> x < y}) = real (length ss * (length ss - 1)) / 2

goal (2 subgoals):
 1. \<And>x. \<lbrakk>sorted [x]; distinct [x]\<rbrakk> \<Longrightarrow> real (card {(xa, y). xa \<in> set [x] \<and> y \<in> set [x] \<and> xa < y}) = real (length [x] * (length [x] - 1)) / 2
 2. \<And>x xs. \<lbrakk>xs \<noteq> []; \<lbrakk>sorted xs; distinct xs\<rbrakk> \<Longrightarrow> real (card {(x, y). x \<in> set xs \<and> y \<in> set xs \<and> x < y}) = real (length xs * (length xs - 1)) / 2; sorted (x # xs); distinct (x # xs)\<rbrakk> \<Longrightarrow> real (card {(xa, y). xa \<in> set (x # xs) \<and> y \<in> set (x # xs) \<and> xa < y}) = real (length (x # xs) * (length (x # xs) - 1)) / 2
[PROOF STEP]
from cons
[PROOF STATE]
proof (chain)
picking this:
ss \<noteq> []
\<lbrakk>sorted ss; distinct ss\<rbrakk> \<Longrightarrow> real (card {a. case a of (x, y) \<Rightarrow> x \<in> set ss \<and> y \<in> set ss \<and> x < y}) = real (length ss * (length ss - 1)) / 2
sorted (s # ss)
distinct (s # ss)
[PROOF STEP]
have sss: "s \<notin> set ss"
[PROOF STATE]
proof (prove)
using this:
ss \<noteq> []
\<lbrakk>sorted ss; distinct ss\<rbrakk> \<Longrightarrow> real (card {a. case a of (x, y) \<Rightarrow> x \<in> set ss \<and> y \<in> set ss \<and> x < y}) = real (length ss * (length ss - 1)) / 2
sorted (s # ss)
distinct (s # ss)

goal (1 subgoal):
 1. s \<notin> set ss
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
s \<notin> set ss

goal (2 subgoals):
 1. \<And>x. \<lbrakk>sorted [x]; distinct [x]\<rbrakk> \<Longrightarrow> real (card {(xa, y). xa \<in> set [x] \<and> y \<in> set [x] \<and> xa < y}) = real (length [x] * (length [x] - 1)) / 2
 2. \<And>x xs. \<lbrakk>xs \<noteq> []; \<lbrakk>sorted xs; distinct xs\<rbrakk> \<Longrightarrow> real (card {(x, y). x \<in> set xs \<and> y \<in> set xs \<and> x < y}) = real (length xs * (length xs - 1)) / 2; sorted (x # xs); distinct (x # xs)\<rbrakk> \<Longrightarrow> real (card {(xa, y). xa \<in> set (x # xs) \<and> y \<in> set (x # xs) \<and> xa < y}) = real (length (x # xs) * (length (x # xs) - 1)) / 2
[PROOF STEP]
from cons
[PROOF STATE]
proof (chain)
picking this:
ss \<noteq> []
\<lbrakk>sorted ss; distinct ss\<rbrakk> \<Longrightarrow> real (card {a. case a of (x, y) \<Rightarrow> x \<in> set ss \<and> y \<in> set ss \<and> x < y}) = real (length ss * (length ss - 1)) / 2
sorted (s # ss)
distinct (s # ss)
[PROOF STEP]
have tt: "(\<forall>y\<in>set (s#ss). s \<le> y)"
[PROOF STATE]
proof (prove)
using this:
ss \<noteq> []
\<lbrakk>sorted ss; distinct ss\<rbrakk> \<Longrightarrow> real (card {a. case a of (x, y) \<Rightarrow> x \<in> set ss \<and> y \<in> set ss \<and> x < y}) = real (length ss * (length ss - 1)) / 2
sorted (s # ss)
distinct (s # ss)

goal (1 subgoal):
 1. \<forall>y\<in>set (s # ss). s \<le> y
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<forall>y\<in>set (s # ss). s \<le> y

goal (2 subgoals):
 1. \<And>x. \<lbrakk>sorted [x]; distinct [x]\<rbrakk> \<Longrightarrow> real (card {(xa, y). xa \<in> set [x] \<and> y \<in> set [x] \<and> xa < y}) = real (length [x] * (length [x] - 1)) / 2
 2. \<And>x xs. \<lbrakk>xs \<noteq> []; \<lbrakk>sorted xs; distinct xs\<rbrakk> \<Longrightarrow> real (card {(x, y). x \<in> set xs \<and> y \<in> set xs \<and> x < y}) = real (length xs * (length xs - 1)) / 2; sorted (x # xs); distinct (x # xs)\<rbrakk> \<Longrightarrow> real (card {(xa, y). xa \<in> set (x # xs) \<and> y \<in> set (x # xs) \<and> xa < y}) = real (length (x # xs) * (length (x # xs) - 1)) / 2
[PROOF STEP]
with cons
[PROOF STATE]
proof (chain)
picking this:
ss \<noteq> []
\<lbrakk>sorted ss; distinct ss\<rbrakk> \<Longrightarrow> real (card {a. case a of (x, y) \<Rightarrow> x \<in> set ss \<and> y \<in> set ss \<and> x < y}) = real (length ss * (length ss - 1)) / 2
sorted (s # ss)
distinct (s # ss)
\<forall>y\<in>set (s # ss). s \<le> y
[PROOF STEP]
have tt': "(\<forall>y\<in>set ss. s < y)"
[PROOF STATE]
proof (prove)
using this:
ss \<noteq> []
\<lbrakk>sorted ss; distinct ss\<rbrakk> \<Longrightarrow> real (card {a. case a of (x, y) \<Rightarrow> x \<in> set ss \<and> y \<in> set ss \<and> x < y}) = real (length ss * (length ss - 1)) / 2
sorted (s # ss)
distinct (s # ss)
\<forall>y\<in>set (s # ss). s \<le> y

goal (1 subgoal):
 1. \<forall>y\<in>set ss. s < y
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<lbrakk>ss \<noteq> []; \<lbrakk>sorted ss; distinct ss\<rbrakk> \<Longrightarrow> real (card {a. case a of (x, y) \<Rightarrow> x \<in> set ss \<and> y \<in> set ss \<and> x < y}) = real (length ss * (length ss - 1)) / 2; sorted (s # ss); distinct (s # ss); \<forall>y\<in>set (s # ss). s \<le> y\<rbrakk> \<Longrightarrow> \<forall>y\<in>set ss. s < y
[PROOF STEP]
from sss
[PROOF STATE]
proof (chain)
picking this:
s \<notin> set ss
[PROOF STEP]
have "(\<forall>y\<in>set ss. s \<noteq> y)"
[PROOF STATE]
proof (prove)
using this:
s \<notin> set ss

goal (1 subgoal):
 1. \<forall>y\<in>set ss. s \<noteq> y
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<forall>y\<in>set ss. s \<noteq> y

goal (1 subgoal):
 1. \<lbrakk>ss \<noteq> []; \<lbrakk>sorted ss; distinct ss\<rbrakk> \<Longrightarrow> real (card {a. case a of (x, y) \<Rightarrow> x \<in> set ss \<and> y \<in> set ss \<and> x < y}) = real (length ss * (length ss - 1)) / 2; sorted (s # ss); distinct (s # ss); \<forall>y\<in>set (s # ss). s \<le> y\<rbrakk> \<Longrightarrow> \<forall>y\<in>set ss. s < y
[PROOF STEP]
with tt
[PROOF STATE]
proof (chain)
picking this:
\<forall>y\<in>set (s # ss). s \<le> y
\<forall>y\<in>set ss. s \<noteq> y
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<forall>y\<in>set (s # ss). s \<le> y
\<forall>y\<in>set ss. s \<noteq> y

goal (1 subgoal):
 1. \<forall>y\<in>set ss. s < y
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
\<forall>y\<in>set ss. s < y

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<forall>y\<in>set ss. s < y

goal (2 subgoals):
 1. \<And>x. \<lbrakk>sorted [x]; distinct [x]\<rbrakk> \<Longrightarrow> real (card {(xa, y). xa \<in> set [x] \<and> y \<in> set [x] \<and> xa < y}) = real (length [x] * (length [x] - 1)) / 2
 2. \<And>x xs. \<lbrakk>xs \<noteq> []; \<lbrakk>sorted xs; distinct xs\<rbrakk> \<Longrightarrow> real (card {(x, y). x \<in> set xs \<and> y \<in> set xs \<and> x < y}) = real (length xs * (length xs - 1)) / 2; sorted (x # xs); distinct (x # xs)\<rbrakk> \<Longrightarrow> real (card {(xa, y). xa \<in> set (x # xs) \<and> y \<in> set (x # xs) \<and> xa < y}) = real (length (x # xs) * (length (x # xs) - 1)) / 2
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<forall>y\<in>set ss. s < y
[PROOF STEP]
have "{(x, y) . x = s \<and> y \<in> set ss \<and> x < y}
          = {(x, y) . x = s \<and> y \<in> set ss}"
[PROOF STATE]
proof (prove)
using this:
\<forall>y\<in>set ss. s < y

goal (1 subgoal):
 1. {(x, y). x = s \<and> y \<in> set ss \<and> x < y} = {(x, y). x = s \<and> y \<in> set ss}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
{(x, y). x = s \<and> y \<in> set ss \<and> x < y} = {(x, y). x = s \<and> y \<in> set ss}

goal (2 subgoals):
 1. \<And>x. \<lbrakk>sorted [x]; distinct [x]\<rbrakk> \<Longrightarrow> real (card {(xa, y). xa \<in> set [x] \<and> y \<in> set [x] \<and> xa < y}) = real (length [x] * (length [x] - 1)) / 2
 2. \<And>x xs. \<lbrakk>xs \<noteq> []; \<lbrakk>sorted xs; distinct xs\<rbrakk> \<Longrightarrow> real (card {(x, y). x \<in> set xs \<and> y \<in> set xs \<and> x < y}) = real (length xs * (length xs - 1)) / 2; sorted (x # xs); distinct (x # xs)\<rbrakk> \<Longrightarrow> real (card {(xa, y). xa \<in> set (x # xs) \<and> y \<in> set (x # xs) \<and> xa < y}) = real (length (x # xs) * (length (x # xs) - 1)) / 2
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
{(x, y). x = s \<and> y \<in> set ss \<and> x < y} = {(x, y). x = s \<and> y \<in> set ss}

goal (2 subgoals):
 1. \<And>x. \<lbrakk>sorted [x]; distinct [x]\<rbrakk> \<Longrightarrow> real (card {(xa, y). xa \<in> set [x] \<and> y \<in> set [x] \<and> xa < y}) = real (length [x] * (length [x] - 1)) / 2
 2. \<And>x xs. \<lbrakk>xs \<noteq> []; \<lbrakk>sorted xs; distinct xs\<rbrakk> \<Longrightarrow> real (card {(x, y). x \<in> set xs \<and> y \<in> set xs \<and> x < y}) = real (length xs * (length xs - 1)) / 2; sorted (x # xs); distinct (x # xs)\<rbrakk> \<Longrightarrow> real (card {(xa, y). xa \<in> set (x # xs) \<and> y \<in> set (x # xs) \<and> xa < y}) = real (length (x # xs) * (length (x # xs) - 1)) / 2
[PROOF STEP]
have "\<dots> = {s}\<times>(set ss)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {(x, y). x = s \<and> y \<in> set ss} = {s} \<times> set ss
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
{(x, y). x = s \<and> y \<in> set ss} = {s} \<times> set ss

goal (2 subgoals):
 1. \<And>x. \<lbrakk>sorted [x]; distinct [x]\<rbrakk> \<Longrightarrow> real (card {(xa, y). xa \<in> set [x] \<and> y \<in> set [x] \<and> xa < y}) = real (length [x] * (length [x] - 1)) / 2
 2. \<And>x xs. \<lbrakk>xs \<noteq> []; \<lbrakk>sorted xs; distinct xs\<rbrakk> \<Longrightarrow> real (card {(x, y). x \<in> set xs \<and> y \<in> set xs \<and> x < y}) = real (length xs * (length xs - 1)) / 2; sorted (x # xs); distinct (x # xs)\<rbrakk> \<Longrightarrow> real (card {(xa, y). xa \<in> set (x # xs) \<and> y \<in> set (x # xs) \<and> xa < y}) = real (length (x # xs) * (length (x # xs) - 1)) / 2
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
{(x, y). x = s \<and> y \<in> set ss \<and> x < y} = {s} \<times> set ss
[PROOF STEP]
have "{(x, y) . x = s \<and> y \<in> set ss \<and> x < y} = {s}\<times>(set ss)"
[PROOF STATE]
proof (prove)
using this:
{(x, y). x = s \<and> y \<in> set ss \<and> x < y} = {s} \<times> set ss

goal (1 subgoal):
 1. {(x, y). x = s \<and> y \<in> set ss \<and> x < y} = {s} \<times> set ss
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
{(x, y). x = s \<and> y \<in> set ss \<and> x < y} = {s} \<times> set ss

goal (2 subgoals):
 1. \<And>x. \<lbrakk>sorted [x]; distinct [x]\<rbrakk> \<Longrightarrow> real (card {(xa, y). xa \<in> set [x] \<and> y \<in> set [x] \<and> xa < y}) = real (length [x] * (length [x] - 1)) / 2
 2. \<And>x xs. \<lbrakk>xs \<noteq> []; \<lbrakk>sorted xs; distinct xs\<rbrakk> \<Longrightarrow> real (card {(x, y). x \<in> set xs \<and> y \<in> set xs \<and> x < y}) = real (length xs * (length xs - 1)) / 2; sorted (x # xs); distinct (x # xs)\<rbrakk> \<Longrightarrow> real (card {(xa, y). xa \<in> set (x # xs) \<and> y \<in> set (x # xs) \<and> xa < y}) = real (length (x # xs) * (length (x # xs) - 1)) / 2
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
{(x, y). x = s \<and> y \<in> set ss \<and> x < y} = {s} \<times> set ss
[PROOF STEP]
have "card {(x, y) . x = s \<and> y \<in> set ss \<and> x < y}
          = card (set ss)"
[PROOF STATE]
proof (prove)
using this:
{(x, y). x = s \<and> y \<in> set ss \<and> x < y} = {s} \<times> set ss

goal (1 subgoal):
 1. card {(x, y). x = s \<and> y \<in> set ss \<and> x < y} = card (set ss)
[PROOF STEP]
by(auto)
[PROOF STATE]
proof (state)
this:
card {(x, y). x = s \<and> y \<in> set ss \<and> x < y} = card (set ss)

goal (2 subgoals):
 1. \<And>x. \<lbrakk>sorted [x]; distinct [x]\<rbrakk> \<Longrightarrow> real (card {(xa, y). xa \<in> set [x] \<and> y \<in> set [x] \<and> xa < y}) = real (length [x] * (length [x] - 1)) / 2
 2. \<And>x xs. \<lbrakk>xs \<noteq> []; \<lbrakk>sorted xs; distinct xs\<rbrakk> \<Longrightarrow> real (card {(x, y). x \<in> set xs \<and> y \<in> set xs \<and> x < y}) = real (length xs * (length xs - 1)) / 2; sorted (x # xs); distinct (x # xs)\<rbrakk> \<Longrightarrow> real (card {(xa, y). xa \<in> set (x # xs) \<and> y \<in> set (x # xs) \<and> xa < y}) = real (length (x # xs) * (length (x # xs) - 1)) / 2
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
card {(x, y). x = s \<and> y \<in> set ss \<and> x < y} = card (set ss)

goal (2 subgoals):
 1. \<And>x. \<lbrakk>sorted [x]; distinct [x]\<rbrakk> \<Longrightarrow> real (card {(xa, y). xa \<in> set [x] \<and> y \<in> set [x] \<and> xa < y}) = real (length [x] * (length [x] - 1)) / 2
 2. \<And>x xs. \<lbrakk>xs \<noteq> []; \<lbrakk>sorted xs; distinct xs\<rbrakk> \<Longrightarrow> real (card {(x, y). x \<in> set xs \<and> y \<in> set xs \<and> x < y}) = real (length xs * (length xs - 1)) / 2; sorted (x # xs); distinct (x # xs)\<rbrakk> \<Longrightarrow> real (card {(xa, y). xa \<in> set (x # xs) \<and> y \<in> set (x # xs) \<and> xa < y}) = real (length (x # xs) * (length (x # xs) - 1)) / 2
[PROOF STEP]
from cons distinct_card
[PROOF STATE]
proof (chain)
picking this:
ss \<noteq> []
\<lbrakk>sorted ss; distinct ss\<rbrakk> \<Longrightarrow> real (card {a. case a of (x, y) \<Rightarrow> x \<in> set ss \<and> y \<in> set ss \<and> x < y}) = real (length ss * (length ss - 1)) / 2
sorted (s # ss)
distinct (s # ss)
distinct ?xs \<Longrightarrow> card (set ?xs) = length ?xs
[PROOF STEP]
have "\<dots> = length ss"
[PROOF STATE]
proof (prove)
using this:
ss \<noteq> []
\<lbrakk>sorted ss; distinct ss\<rbrakk> \<Longrightarrow> real (card {a. case a of (x, y) \<Rightarrow> x \<in> set ss \<and> y \<in> set ss \<and> x < y}) = real (length ss * (length ss - 1)) / 2
sorted (s # ss)
distinct (s # ss)
distinct ?xs \<Longrightarrow> card (set ?xs) = length ?xs

goal (1 subgoal):
 1. card (set ss) = length ss
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
card (set ss) = length ss

goal (2 subgoals):
 1. \<And>x. \<lbrakk>sorted [x]; distinct [x]\<rbrakk> \<Longrightarrow> real (card {(xa, y). xa \<in> set [x] \<and> y \<in> set [x] \<and> xa < y}) = real (length [x] * (length [x] - 1)) / 2
 2. \<And>x xs. \<lbrakk>xs \<noteq> []; \<lbrakk>sorted xs; distinct xs\<rbrakk> \<Longrightarrow> real (card {(x, y). x \<in> set xs \<and> y \<in> set xs \<and> x < y}) = real (length xs * (length xs - 1)) / 2; sorted (x # xs); distinct (x # xs)\<rbrakk> \<Longrightarrow> real (card {(xa, y). xa \<in> set (x # xs) \<and> y \<in> set (x # xs) \<and> xa < y}) = real (length (x # xs) * (length (x # xs) - 1)) / 2
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
card {(x, y). x = s \<and> y \<in> set ss \<and> x < y} = length ss
[PROOF STEP]
have step: "card {(x, y) . x = s \<and> y \<in> set ss \<and> x < y} =
            length ss"
[PROOF STATE]
proof (prove)
using this:
card {(x, y). x = s \<and> y \<in> set ss \<and> x < y} = length ss

goal (1 subgoal):
 1. card {(x, y). x = s \<and> y \<in> set ss \<and> x < y} = length ss
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
card {(x, y). x = s \<and> y \<in> set ss \<and> x < y} = length ss

goal (2 subgoals):
 1. \<And>x. \<lbrakk>sorted [x]; distinct [x]\<rbrakk> \<Longrightarrow> real (card {(xa, y). xa \<in> set [x] \<and> y \<in> set [x] \<and> xa < y}) = real (length [x] * (length [x] - 1)) / 2
 2. \<And>x xs. \<lbrakk>xs \<noteq> []; \<lbrakk>sorted xs; distinct xs\<rbrakk> \<Longrightarrow> real (card {(x, y). x \<in> set xs \<and> y \<in> set xs \<and> x < y}) = real (length xs * (length xs - 1)) / 2; sorted (x # xs); distinct (x # xs)\<rbrakk> \<Longrightarrow> real (card {(xa, y). xa \<in> set (x # xs) \<and> y \<in> set (x # xs) \<and> xa < y}) = real (length (x # xs) * (length (x # xs) - 1)) / 2
[PROOF STEP]
have uni: "{(x, y) . x \<in> set (s # ss) \<and> y \<in> set (s # ss) \<and> x < y}
      = {(x, y) . x \<in> set ss \<and> y \<in> set ss \<and> x < y}
        \<union> {(x, y) . x = s \<and> y \<in> set ss \<and> x < y}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {(x, y). x \<in> set (s # ss) \<and> y \<in> set (s # ss) \<and> x < y} = {(x, y). x \<in> set ss \<and> y \<in> set ss \<and> x < y} \<union> {(x, y). x = s \<and> y \<in> set ss \<and> x < y}
[PROOF STEP]
using tt
[PROOF STATE]
proof (prove)
using this:
\<forall>y\<in>set (s # ss). s \<le> y

goal (1 subgoal):
 1. {(x, y). x \<in> set (s # ss) \<and> y \<in> set (s # ss) \<and> x < y} = {(x, y). x \<in> set ss \<and> y \<in> set ss \<and> x < y} \<union> {(x, y). x = s \<and> y \<in> set ss \<and> x < y}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
{(x, y). x \<in> set (s # ss) \<and> y \<in> set (s # ss) \<and> x < y} = {(x, y). x \<in> set ss \<and> y \<in> set ss \<and> x < y} \<union> {(x, y). x = s \<and> y \<in> set ss \<and> x < y}

goal (2 subgoals):
 1. \<And>x. \<lbrakk>sorted [x]; distinct [x]\<rbrakk> \<Longrightarrow> real (card {(xa, y). xa \<in> set [x] \<and> y \<in> set [x] \<and> xa < y}) = real (length [x] * (length [x] - 1)) / 2
 2. \<And>x xs. \<lbrakk>xs \<noteq> []; \<lbrakk>sorted xs; distinct xs\<rbrakk> \<Longrightarrow> real (card {(x, y). x \<in> set xs \<and> y \<in> set xs \<and> x < y}) = real (length xs * (length xs - 1)) / 2; sorted (x # xs); distinct (x # xs)\<rbrakk> \<Longrightarrow> real (card {(xa, y). xa \<in> set (x # xs) \<and> y \<in> set (x # xs) \<and> xa < y}) = real (length (x # xs) * (length (x # xs) - 1)) / 2
[PROOF STEP]
have disj: "{(x, y) . x \<in> set ss \<and> y \<in> set ss \<and> x < y}
        \<inter> {(x, y) . x = s \<and> y \<in> set ss \<and> x < y} = {}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {(x, y). x \<in> set ss \<and> y \<in> set ss \<and> x < y} \<inter> {(x, y). x = s \<and> y \<in> set ss \<and> x < y} = {}
[PROOF STEP]
using sss
[PROOF STATE]
proof (prove)
using this:
s \<notin> set ss

goal (1 subgoal):
 1. {(x, y). x \<in> set ss \<and> y \<in> set ss \<and> x < y} \<inter> {(x, y). x = s \<and> y \<in> set ss \<and> x < y} = {}
[PROOF STEP]
by(auto)
[PROOF STATE]
proof (state)
this:
{(x, y). x \<in> set ss \<and> y \<in> set ss \<and> x < y} \<inter> {(x, y). x = s \<and> y \<in> set ss \<and> x < y} = {}

goal (2 subgoals):
 1. \<And>x. \<lbrakk>sorted [x]; distinct [x]\<rbrakk> \<Longrightarrow> real (card {(xa, y). xa \<in> set [x] \<and> y \<in> set [x] \<and> xa < y}) = real (length [x] * (length [x] - 1)) / 2
 2. \<And>x xs. \<lbrakk>xs \<noteq> []; \<lbrakk>sorted xs; distinct xs\<rbrakk> \<Longrightarrow> real (card {(x, y). x \<in> set xs \<and> y \<in> set xs \<and> x < y}) = real (length xs * (length xs - 1)) / 2; sorted (x # xs); distinct (x # xs)\<rbrakk> \<Longrightarrow> real (card {(xa, y). xa \<in> set (x # xs) \<and> y \<in> set (x # xs) \<and> xa < y}) = real (length (x # xs) * (length (x # xs) - 1)) / 2
[PROOF STEP]
have "card {(x, y) . x \<in> set (s # ss) \<and> y \<in> set (s # ss) \<and> x < y}
    = card ({(x, y) . x \<in> set ss \<and> y \<in> set ss \<and> x < y}
        \<union> {(x, y) . x = s \<and> y \<in> set ss \<and> x < y})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card {(x, y). x \<in> set (s # ss) \<and> y \<in> set (s # ss) \<and> x < y} = card ({(x, y). x \<in> set ss \<and> y \<in> set ss \<and> x < y} \<union> {(x, y). x = s \<and> y \<in> set ss \<and> x < y})
[PROOF STEP]
using uni
[PROOF STATE]
proof (prove)
using this:
{(x, y). x \<in> set (s # ss) \<and> y \<in> set (s # ss) \<and> x < y} = {(x, y). x \<in> set ss \<and> y \<in> set ss \<and> x < y} \<union> {(x, y). x = s \<and> y \<in> set ss \<and> x < y}

goal (1 subgoal):
 1. card {(x, y). x \<in> set (s # ss) \<and> y \<in> set (s # ss) \<and> x < y} = card ({(x, y). x \<in> set ss \<and> y \<in> set ss \<and> x < y} \<union> {(x, y). x = s \<and> y \<in> set ss \<and> x < y})
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
card {(x, y). x \<in> set (s # ss) \<and> y \<in> set (s # ss) \<and> x < y} = card ({(x, y). x \<in> set ss \<and> y \<in> set ss \<and> x < y} \<union> {(x, y). x = s \<and> y \<in> set ss \<and> x < y})

goal (2 subgoals):
 1. \<And>x. \<lbrakk>sorted [x]; distinct [x]\<rbrakk> \<Longrightarrow> real (card {(xa, y). xa \<in> set [x] \<and> y \<in> set [x] \<and> xa < y}) = real (length [x] * (length [x] - 1)) / 2
 2. \<And>x xs. \<lbrakk>xs \<noteq> []; \<lbrakk>sorted xs; distinct xs\<rbrakk> \<Longrightarrow> real (card {(x, y). x \<in> set xs \<and> y \<in> set xs \<and> x < y}) = real (length xs * (length xs - 1)) / 2; sorted (x # xs); distinct (x # xs)\<rbrakk> \<Longrightarrow> real (card {(xa, y). xa \<in> set (x # xs) \<and> y \<in> set (x # xs) \<and> xa < y}) = real (length (x # xs) * (length (x # xs) - 1)) / 2
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
card {(x, y). x \<in> set (s # ss) \<and> y \<in> set (s # ss) \<and> x < y} = card ({(x, y). x \<in> set ss \<and> y \<in> set ss \<and> x < y} \<union> {(x, y). x = s \<and> y \<in> set ss \<and> x < y})

goal (2 subgoals):
 1. \<And>x. \<lbrakk>sorted [x]; distinct [x]\<rbrakk> \<Longrightarrow> real (card {(xa, y). xa \<in> set [x] \<and> y \<in> set [x] \<and> xa < y}) = real (length [x] * (length [x] - 1)) / 2
 2. \<And>x xs. \<lbrakk>xs \<noteq> []; \<lbrakk>sorted xs; distinct xs\<rbrakk> \<Longrightarrow> real (card {(x, y). x \<in> set xs \<and> y \<in> set xs \<and> x < y}) = real (length xs * (length xs - 1)) / 2; sorted (x # xs); distinct (x # xs)\<rbrakk> \<Longrightarrow> real (card {(xa, y). xa \<in> set (x # xs) \<and> y \<in> set (x # xs) \<and> xa < y}) = real (length (x # xs) * (length (x # xs) - 1)) / 2
[PROOF STEP]
have "\<dots> = card {(x, y) . x \<in> set ss \<and> y \<in> set ss \<and> x < y}
          + card {(x, y) . x = s \<and> y \<in> set ss \<and> x < y}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card ({(x, y). x \<in> set ss \<and> y \<in> set ss \<and> x < y} \<union> {(x, y). x = s \<and> y \<in> set ss \<and> x < y}) = card {(x, y). x \<in> set ss \<and> y \<in> set ss \<and> x < y} + card {(x, y). x = s \<and> y \<in> set ss \<and> x < y}
[PROOF STEP]
apply(rule card_Un_disjoint)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. finite {(x, y). x \<in> set ss \<and> y \<in> set ss \<and> x < y}
 2. finite {(x, y). x = s \<and> y \<in> set ss \<and> x < y}
 3. {(x, y). x \<in> set ss \<and> y \<in> set ss \<and> x < y} \<inter> {(x, y). x = s \<and> y \<in> set ss \<and> x < y} = {}
[PROOF STEP]
apply(rule finite_subset[where B="(set ss) \<times> (set ss)"])
[PROOF STATE]
proof (prove)
goal (4 subgoals):
 1. {(x, y). x \<in> set ss \<and> y \<in> set ss \<and> x < y} \<subseteq> set ss \<times> set ss
 2. finite (set ss \<times> set ss)
 3. finite {(x, y). x = s \<and> y \<in> set ss \<and> x < y}
 4. {(x, y). x \<in> set ss \<and> y \<in> set ss \<and> x < y} \<inter> {(x, y). x = s \<and> y \<in> set ss \<and> x < y} = {}
[PROOF STEP]
apply(force)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. finite (set ss \<times> set ss)
 2. finite {(x, y). x = s \<and> y \<in> set ss \<and> x < y}
 3. {(x, y). x \<in> set ss \<and> y \<in> set ss \<and> x < y} \<inter> {(x, y). x = s \<and> y \<in> set ss \<and> x < y} = {}
[PROOF STEP]
apply(simp)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. finite {(x, y). x = s \<and> y \<in> set ss \<and> x < y}
 2. {(x, y). x \<in> set ss \<and> y \<in> set ss \<and> x < y} \<inter> {(x, y). x = s \<and> y \<in> set ss \<and> x < y} = {}
[PROOF STEP]
apply(rule finite_subset[where B="{s} \<times> (set ss)"])
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. {(x, y). x = s \<and> y \<in> set ss \<and> x < y} \<subseteq> {s} \<times> set ss
 2. finite ({s} \<times> set ss)
 3. {(x, y). x \<in> set ss \<and> y \<in> set ss \<and> x < y} \<inter> {(x, y). x = s \<and> y \<in> set ss \<and> x < y} = {}
[PROOF STEP]
apply(force)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. finite ({s} \<times> set ss)
 2. {(x, y). x \<in> set ss \<and> y \<in> set ss \<and> x < y} \<inter> {(x, y). x = s \<and> y \<in> set ss \<and> x < y} = {}
[PROOF STEP]
apply(simp)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {(x, y). x \<in> set ss \<and> y \<in> set ss \<and> x < y} \<inter> {(x, y). x = s \<and> y \<in> set ss \<and> x < y} = {}
[PROOF STEP]
using disj
[PROOF STATE]
proof (prove)
using this:
{(x, y). x \<in> set ss \<and> y \<in> set ss \<and> x < y} \<inter> {(x, y). x = s \<and> y \<in> set ss \<and> x < y} = {}

goal (1 subgoal):
 1. {(x, y). x \<in> set ss \<and> y \<in> set ss \<and> x < y} \<inter> {(x, y). x = s \<and> y \<in> set ss \<and> x < y} = {}
[PROOF STEP]
apply(simp)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
card ({(x, y). x \<in> set ss \<and> y \<in> set ss \<and> x < y} \<union> {(x, y). x = s \<and> y \<in> set ss \<and> x < y}) = card {(x, y). x \<in> set ss \<and> y \<in> set ss \<and> x < y} + card {(x, y). x = s \<and> y \<in> set ss \<and> x < y}

goal (2 subgoals):
 1. \<And>x. \<lbrakk>sorted [x]; distinct [x]\<rbrakk> \<Longrightarrow> real (card {(xa, y). xa \<in> set [x] \<and> y \<in> set [x] \<and> xa < y}) = real (length [x] * (length [x] - 1)) / 2
 2. \<And>x xs. \<lbrakk>xs \<noteq> []; \<lbrakk>sorted xs; distinct xs\<rbrakk> \<Longrightarrow> real (card {(x, y). x \<in> set xs \<and> y \<in> set xs \<and> x < y}) = real (length xs * (length xs - 1)) / 2; sorted (x # xs); distinct (x # xs)\<rbrakk> \<Longrightarrow> real (card {(xa, y). xa \<in> set (x # xs) \<and> y \<in> set (x # xs) \<and> xa < y}) = real (length (x # xs) * (length (x # xs) - 1)) / 2
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
card ({(x, y). x \<in> set ss \<and> y \<in> set ss \<and> x < y} \<union> {(x, y). x = s \<and> y \<in> set ss \<and> x < y}) = card {(x, y). x \<in> set ss \<and> y \<in> set ss \<and> x < y} + card {(x, y). x = s \<and> y \<in> set ss \<and> x < y}

goal (2 subgoals):
 1. \<And>x. \<lbrakk>sorted [x]; distinct [x]\<rbrakk> \<Longrightarrow> real (card {(xa, y). xa \<in> set [x] \<and> y \<in> set [x] \<and> xa < y}) = real (length [x] * (length [x] - 1)) / 2
 2. \<And>x xs. \<lbrakk>xs \<noteq> []; \<lbrakk>sorted xs; distinct xs\<rbrakk> \<Longrightarrow> real (card {(x, y). x \<in> set xs \<and> y \<in> set xs \<and> x < y}) = real (length xs * (length xs - 1)) / 2; sorted (x # xs); distinct (x # xs)\<rbrakk> \<Longrightarrow> real (card {(xa, y). xa \<in> set (x # xs) \<and> y \<in> set (x # xs) \<and> xa < y}) = real (length (x # xs) * (length (x # xs) - 1)) / 2
[PROOF STEP]
have "\<dots> = (length ss * (length ss-1)) / 2
                  + length ss"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real (card {(x, y). x \<in> set ss \<and> y \<in> set ss \<and> x < y} + card {(x, y). x = s \<and> y \<in> set ss \<and> x < y}) = real (length ss * (length ss - 1)) / 2 + real (length ss)
[PROOF STEP]
using iH step
[PROOF STATE]
proof (prove)
using this:
real (card {(x, y). x \<in> set ss \<and> y \<in> set ss \<and> x < y}) = real (length ss * (length ss - 1)) / 2
card {(x, y). x = s \<and> y \<in> set ss \<and> x < y} = length ss

goal (1 subgoal):
 1. real (card {(x, y). x \<in> set ss \<and> y \<in> set ss \<and> x < y} + card {(x, y). x = s \<and> y \<in> set ss \<and> x < y}) = real (length ss * (length ss - 1)) / 2 + real (length ss)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
real (card {(x, y). x \<in> set ss \<and> y \<in> set ss \<and> x < y} + card {(x, y). x = s \<and> y \<in> set ss \<and> x < y}) = real (length ss * (length ss - 1)) / 2 + real (length ss)

goal (2 subgoals):
 1. \<And>x. \<lbrakk>sorted [x]; distinct [x]\<rbrakk> \<Longrightarrow> real (card {(xa, y). xa \<in> set [x] \<and> y \<in> set [x] \<and> xa < y}) = real (length [x] * (length [x] - 1)) / 2
 2. \<And>x xs. \<lbrakk>xs \<noteq> []; \<lbrakk>sorted xs; distinct xs\<rbrakk> \<Longrightarrow> real (card {(x, y). x \<in> set xs \<and> y \<in> set xs \<and> x < y}) = real (length xs * (length xs - 1)) / 2; sorted (x # xs); distinct (x # xs)\<rbrakk> \<Longrightarrow> real (card {(xa, y). xa \<in> set (x # xs) \<and> y \<in> set (x # xs) \<and> xa < y}) = real (length (x # xs) * (length (x # xs) - 1)) / 2
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
real (card {(x, y). x \<in> set ss \<and> y \<in> set ss \<and> x < y} + card {(x, y). x = s \<and> y \<in> set ss \<and> x < y}) = real (length ss * (length ss - 1)) / 2 + real (length ss)

goal (2 subgoals):
 1. \<And>x. \<lbrakk>sorted [x]; distinct [x]\<rbrakk> \<Longrightarrow> real (card {(xa, y). xa \<in> set [x] \<and> y \<in> set [x] \<and> xa < y}) = real (length [x] * (length [x] - 1)) / 2
 2. \<And>x xs. \<lbrakk>xs \<noteq> []; \<lbrakk>sorted xs; distinct xs\<rbrakk> \<Longrightarrow> real (card {(x, y). x \<in> set xs \<and> y \<in> set xs \<and> x < y}) = real (length xs * (length xs - 1)) / 2; sorted (x # xs); distinct (x # xs)\<rbrakk> \<Longrightarrow> real (card {(xa, y). xa \<in> set (x # xs) \<and> y \<in> set (x # xs) \<and> xa < y}) = real (length (x # xs) * (length (x # xs) - 1)) / 2
[PROOF STEP]
have "\<dots> = (length ss * (length ss-1) + 2*length ss) / 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real (length ss * (length ss - 1)) / 2 + real (length ss) = real (length ss * (length ss - 1) + 2 * length ss) / 2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
real (length ss * (length ss - 1)) / 2 + real (length ss) = real (length ss * (length ss - 1) + 2 * length ss) / 2

goal (2 subgoals):
 1. \<And>x. \<lbrakk>sorted [x]; distinct [x]\<rbrakk> \<Longrightarrow> real (card {(xa, y). xa \<in> set [x] \<and> y \<in> set [x] \<and> xa < y}) = real (length [x] * (length [x] - 1)) / 2
 2. \<And>x xs. \<lbrakk>xs \<noteq> []; \<lbrakk>sorted xs; distinct xs\<rbrakk> \<Longrightarrow> real (card {(x, y). x \<in> set xs \<and> y \<in> set xs \<and> x < y}) = real (length xs * (length xs - 1)) / 2; sorted (x # xs); distinct (x # xs)\<rbrakk> \<Longrightarrow> real (card {(xa, y). xa \<in> set (x # xs) \<and> y \<in> set (x # xs) \<and> xa < y}) = real (length (x # xs) * (length (x # xs) - 1)) / 2
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
real (length ss * (length ss - 1)) / 2 + real (length ss) = real (length ss * (length ss - 1) + 2 * length ss) / 2

goal (2 subgoals):
 1. \<And>x. \<lbrakk>sorted [x]; distinct [x]\<rbrakk> \<Longrightarrow> real (card {(xa, y). xa \<in> set [x] \<and> y \<in> set [x] \<and> xa < y}) = real (length [x] * (length [x] - 1)) / 2
 2. \<And>x xs. \<lbrakk>xs \<noteq> []; \<lbrakk>sorted xs; distinct xs\<rbrakk> \<Longrightarrow> real (card {(x, y). x \<in> set xs \<and> y \<in> set xs \<and> x < y}) = real (length xs * (length xs - 1)) / 2; sorted (x # xs); distinct (x # xs)\<rbrakk> \<Longrightarrow> real (card {(xa, y). xa \<in> set (x # xs) \<and> y \<in> set (x # xs) \<and> xa < y}) = real (length (x # xs) * (length (x # xs) - 1)) / 2
[PROOF STEP]
have "\<dots> = (length ss * (length ss-1) + length ss * 2) / 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real (length ss * (length ss - 1) + 2 * length ss) / 2 = real (length ss * (length ss - 1) + length ss * 2) / 2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
real (length ss * (length ss - 1) + 2 * length ss) / 2 = real (length ss * (length ss - 1) + length ss * 2) / 2

goal (2 subgoals):
 1. \<And>x. \<lbrakk>sorted [x]; distinct [x]\<rbrakk> \<Longrightarrow> real (card {(xa, y). xa \<in> set [x] \<and> y \<in> set [x] \<and> xa < y}) = real (length [x] * (length [x] - 1)) / 2
 2. \<And>x xs. \<lbrakk>xs \<noteq> []; \<lbrakk>sorted xs; distinct xs\<rbrakk> \<Longrightarrow> real (card {(x, y). x \<in> set xs \<and> y \<in> set xs \<and> x < y}) = real (length xs * (length xs - 1)) / 2; sorted (x # xs); distinct (x # xs)\<rbrakk> \<Longrightarrow> real (card {(xa, y). xa \<in> set (x # xs) \<and> y \<in> set (x # xs) \<and> xa < y}) = real (length (x # xs) * (length (x # xs) - 1)) / 2
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
real (length ss * (length ss - 1) + 2 * length ss) / 2 = real (length ss * (length ss - 1) + length ss * 2) / 2

goal (2 subgoals):
 1. \<And>x. \<lbrakk>sorted [x]; distinct [x]\<rbrakk> \<Longrightarrow> real (card {(xa, y). xa \<in> set [x] \<and> y \<in> set [x] \<and> xa < y}) = real (length [x] * (length [x] - 1)) / 2
 2. \<And>x xs. \<lbrakk>xs \<noteq> []; \<lbrakk>sorted xs; distinct xs\<rbrakk> \<Longrightarrow> real (card {(x, y). x \<in> set xs \<and> y \<in> set xs \<and> x < y}) = real (length xs * (length xs - 1)) / 2; sorted (x # xs); distinct (x # xs)\<rbrakk> \<Longrightarrow> real (card {(xa, y). xa \<in> set (x # xs) \<and> y \<in> set (x # xs) \<and> xa < y}) = real (length (x # xs) * (length (x # xs) - 1)) / 2
[PROOF STEP]
have "\<dots> = (length ss * (length ss-1+2)) / 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real (length ss * (length ss - 1) + length ss * 2) / 2 = real (length ss * (length ss - 1 + 2)) / 2
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
real (length ss * (length ss - 1) + length ss * 2) / 2 = real (length ss * (length ss - 1 + 2)) / 2

goal (2 subgoals):
 1. \<And>x. \<lbrakk>sorted [x]; distinct [x]\<rbrakk> \<Longrightarrow> real (card {(xa, y). xa \<in> set [x] \<and> y \<in> set [x] \<and> xa < y}) = real (length [x] * (length [x] - 1)) / 2
 2. \<And>x xs. \<lbrakk>xs \<noteq> []; \<lbrakk>sorted xs; distinct xs\<rbrakk> \<Longrightarrow> real (card {(x, y). x \<in> set xs \<and> y \<in> set xs \<and> x < y}) = real (length xs * (length xs - 1)) / 2; sorted (x # xs); distinct (x # xs)\<rbrakk> \<Longrightarrow> real (card {(xa, y). xa \<in> set (x # xs) \<and> y \<in> set (x # xs) \<and> xa < y}) = real (length (x # xs) * (length (x # xs) - 1)) / 2
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
real (length ss * (length ss - 1) + length ss * 2) / 2 = real (length ss * (length ss - 1 + 2)) / 2

goal (2 subgoals):
 1. \<And>x. \<lbrakk>sorted [x]; distinct [x]\<rbrakk> \<Longrightarrow> real (card {(xa, y). xa \<in> set [x] \<and> y \<in> set [x] \<and> xa < y}) = real (length [x] * (length [x] - 1)) / 2
 2. \<And>x xs. \<lbrakk>xs \<noteq> []; \<lbrakk>sorted xs; distinct xs\<rbrakk> \<Longrightarrow> real (card {(x, y). x \<in> set xs \<and> y \<in> set xs \<and> x < y}) = real (length xs * (length xs - 1)) / 2; sorted (x # xs); distinct (x # xs)\<rbrakk> \<Longrightarrow> real (card {(xa, y). xa \<in> set (x # xs) \<and> y \<in> set (x # xs) \<and> xa < y}) = real (length (x # xs) * (length (x # xs) - 1)) / 2
[PROOF STEP]
have "\<dots> = (length ss * (length ss+1)) / 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real (length ss * (length ss - 1 + 2)) / 2 = real (length ss * (length ss + 1)) / 2
[PROOF STEP]
using cons(1)
[PROOF STATE]
proof (prove)
using this:
ss \<noteq> []

goal (1 subgoal):
 1. real (length ss * (length ss - 1 + 2)) / 2 = real (length ss * (length ss + 1)) / 2
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
real (length ss * (length ss - 1 + 2)) / 2 = real (length ss * (length ss + 1)) / 2

goal (2 subgoals):
 1. \<And>x. \<lbrakk>sorted [x]; distinct [x]\<rbrakk> \<Longrightarrow> real (card {(xa, y). xa \<in> set [x] \<and> y \<in> set [x] \<and> xa < y}) = real (length [x] * (length [x] - 1)) / 2
 2. \<And>x xs. \<lbrakk>xs \<noteq> []; \<lbrakk>sorted xs; distinct xs\<rbrakk> \<Longrightarrow> real (card {(x, y). x \<in> set xs \<and> y \<in> set xs \<and> x < y}) = real (length xs * (length xs - 1)) / 2; sorted (x # xs); distinct (x # xs)\<rbrakk> \<Longrightarrow> real (card {(xa, y). xa \<in> set (x # xs) \<and> y \<in> set (x # xs) \<and> xa < y}) = real (length (x # xs) * (length (x # xs) - 1)) / 2
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
real (length ss * (length ss - 1 + 2)) / 2 = real (length ss * (length ss + 1)) / 2

goal (2 subgoals):
 1. \<And>x. \<lbrakk>sorted [x]; distinct [x]\<rbrakk> \<Longrightarrow> real (card {(xa, y). xa \<in> set [x] \<and> y \<in> set [x] \<and> xa < y}) = real (length [x] * (length [x] - 1)) / 2
 2. \<And>x xs. \<lbrakk>xs \<noteq> []; \<lbrakk>sorted xs; distinct xs\<rbrakk> \<Longrightarrow> real (card {(x, y). x \<in> set xs \<and> y \<in> set xs \<and> x < y}) = real (length xs * (length xs - 1)) / 2; sorted (x # xs); distinct (x # xs)\<rbrakk> \<Longrightarrow> real (card {(xa, y). xa \<in> set (x # xs) \<and> y \<in> set (x # xs) \<and> xa < y}) = real (length (x # xs) * (length (x # xs) - 1)) / 2
[PROOF STEP]
have "\<dots> = ((length ss+1) * length ss) / 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real (length ss * (length ss + 1)) / 2 = real ((length ss + 1) * length ss) / 2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
real (length ss * (length ss + 1)) / 2 = real ((length ss + 1) * length ss) / 2

goal (2 subgoals):
 1. \<And>x. \<lbrakk>sorted [x]; distinct [x]\<rbrakk> \<Longrightarrow> real (card {(xa, y). xa \<in> set [x] \<and> y \<in> set [x] \<and> xa < y}) = real (length [x] * (length [x] - 1)) / 2
 2. \<And>x xs. \<lbrakk>xs \<noteq> []; \<lbrakk>sorted xs; distinct xs\<rbrakk> \<Longrightarrow> real (card {(x, y). x \<in> set xs \<and> y \<in> set xs \<and> x < y}) = real (length xs * (length xs - 1)) / 2; sorted (x # xs); distinct (x # xs)\<rbrakk> \<Longrightarrow> real (card {(xa, y). xa \<in> set (x # xs) \<and> y \<in> set (x # xs) \<and> xa < y}) = real (length (x # xs) * (length (x # xs) - 1)) / 2
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
real (length ss * (length ss + 1)) / 2 = real ((length ss + 1) * length ss) / 2

goal (2 subgoals):
 1. \<And>x. \<lbrakk>sorted [x]; distinct [x]\<rbrakk> \<Longrightarrow> real (card {(xa, y). xa \<in> set [x] \<and> y \<in> set [x] \<and> xa < y}) = real (length [x] * (length [x] - 1)) / 2
 2. \<And>x xs. \<lbrakk>xs \<noteq> []; \<lbrakk>sorted xs; distinct xs\<rbrakk> \<Longrightarrow> real (card {(x, y). x \<in> set xs \<and> y \<in> set xs \<and> x < y}) = real (length xs * (length xs - 1)) / 2; sorted (x # xs); distinct (x # xs)\<rbrakk> \<Longrightarrow> real (card {(xa, y). xa \<in> set (x # xs) \<and> y \<in> set (x # xs) \<and> xa < y}) = real (length (x # xs) * (length (x # xs) - 1)) / 2
[PROOF STEP]
have "\<dots> = (length (s#ss) * (length (s#ss)-1)) / 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real ((length ss + 1) * length ss) / 2 = real (length (s # ss) * (length (s # ss) - 1)) / 2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
real ((length ss + 1) * length ss) / 2 = real (length (s # ss) * (length (s # ss) - 1)) / 2

goal (2 subgoals):
 1. \<And>x. \<lbrakk>sorted [x]; distinct [x]\<rbrakk> \<Longrightarrow> real (card {(xa, y). xa \<in> set [x] \<and> y \<in> set [x] \<and> xa < y}) = real (length [x] * (length [x] - 1)) / 2
 2. \<And>x xs. \<lbrakk>xs \<noteq> []; \<lbrakk>sorted xs; distinct xs\<rbrakk> \<Longrightarrow> real (card {(x, y). x \<in> set xs \<and> y \<in> set xs \<and> x < y}) = real (length xs * (length xs - 1)) / 2; sorted (x # xs); distinct (x # xs)\<rbrakk> \<Longrightarrow> real (card {(xa, y). xa \<in> set (x # xs) \<and> y \<in> set (x # xs) \<and> xa < y}) = real (length (x # xs) * (length (x # xs) - 1)) / 2
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
real (card {(x, y). x \<in> set (s # ss) \<and> y \<in> set (s # ss) \<and> x < y}) = real (length (s # ss) * (length (s # ss) - 1)) / 2
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
real (card {(x, y). x \<in> set (s # ss) \<and> y \<in> set (s # ss) \<and> x < y}) = real (length (s # ss) * (length (s # ss) - 1)) / 2

goal (1 subgoal):
 1. real (card {a. case a of (x, y) \<Rightarrow> x \<in> set (s # ss) \<and> y \<in> set (s # ss) \<and> x < y}) = real (length (s # ss) * (length (s # ss) - 1)) / 2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
real (card {a. case a of (x, y) \<Rightarrow> x \<in> set (s # ss) \<and> y \<in> set (s # ss) \<and> x < y}) = real (length (s # ss) * (length (s # ss) - 1)) / 2

goal (1 subgoal):
 1. \<And>x. \<lbrakk>sorted [x]; distinct [x]\<rbrakk> \<Longrightarrow> real (card {(xa, y). xa \<in> set [x] \<and> y \<in> set [x] \<and> xa < y}) = real (length [x] * (length [x] - 1)) / 2
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. \<lbrakk>sorted [x]; distinct [x]\<rbrakk> \<Longrightarrow> real (card {(xa, y). xa \<in> set [x] \<and> y \<in> set [x] \<and> xa < y}) = real (length [x] * (length [x] - 1)) / 2
[PROOF STEP]
case single
[PROOF STATE]
proof (state)
this:
sorted [x_]
distinct [x_]

goal (1 subgoal):
 1. \<And>x. \<lbrakk>sorted [x]; distinct [x]\<rbrakk> \<Longrightarrow> real (card {(xa, y). xa \<in> set [x] \<and> y \<in> set [x] \<and> xa < y}) = real (length [x] * (length [x] - 1)) / 2
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
using this:
sorted [x_]
distinct [x_]

goal (1 subgoal):
 1. real (card {a. case a of (xa, y) \<Rightarrow> xa \<in> set [x_] \<and> y \<in> set [x_] \<and> xa < y}) = real (length [x_] * (length [x_] - 1)) / 2
[PROOF STEP]
by(simp cong: conj_cong)
[PROOF STATE]
proof (state)
this:
real (card {a. case a of (xa, y) \<Rightarrow> xa \<in> set [x_] \<and> y \<in> set [x_] \<and> xa < y}) = real (length [x_] * (length [x_] - 1)) / 2

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma list_add_assoc: fixes xs :: "'a::monoid_add list"
shows "(xs+ys)+zs = xs+(ys+zs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. xs + ys + zs = xs + (ys + zs)
[PROOF STEP]
apply(induct xs arbitrary: ys zs)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>ys zs. [] + ys + zs = [] + (ys + zs)
 2. \<And>a xs ys zs. (\<And>ys zs. xs + ys + zs = xs + (ys + zs)) \<Longrightarrow> a # xs + ys + zs = a # xs + (ys + zs)
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>a xs ys zs. (\<And>ys zs. xs + ys + zs = xs + (ys + zs)) \<Longrightarrow> a # xs + ys + zs = a # xs + (ys + zs)
[PROOF STEP]
apply(case_tac ys)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>a xs ys zs. \<lbrakk>\<And>ys zs. xs + ys + zs = xs + (ys + zs); ys = []\<rbrakk> \<Longrightarrow> a # xs + ys + zs = a # xs + (ys + zs)
 2. \<And>a xs ys zs aa list. \<lbrakk>\<And>ys zs. xs + ys + zs = xs + (ys + zs); ys = aa # list\<rbrakk> \<Longrightarrow> a # xs + ys + zs = a # xs + (ys + zs)
[PROOF STEP]
apply(simp)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>a xs ys zs aa list. \<lbrakk>\<And>ys zs. xs + ys + zs = xs + (ys + zs); ys = aa # list\<rbrakk> \<Longrightarrow> a # xs + ys + zs = a # xs + (ys + zs)
[PROOF STEP]
apply(simp)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>a xs ys zs aa list. \<lbrakk>\<And>ys zs. xs + ys + zs = xs + (ys + zs); ys = aa # list\<rbrakk> \<Longrightarrow> (a + aa) # xs + list + zs = a # xs + (aa # list + zs)
[PROOF STEP]
apply(case_tac zs)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>a xs ys zs aa list. \<lbrakk>\<And>ys zs. xs + ys + zs = xs + (ys + zs); ys = aa # list; zs = []\<rbrakk> \<Longrightarrow> (a + aa) # xs + list + zs = a # xs + (aa # list + zs)
 2. \<And>a xs ys zs aa list ab lista. \<lbrakk>\<And>ys zs. xs + ys + zs = xs + (ys + zs); ys = aa # list; zs = ab # lista\<rbrakk> \<Longrightarrow> (a + aa) # xs + list + zs = a # xs + (aa # list + zs)
[PROOF STEP]
apply(simp)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>a xs ys zs aa list ab lista. \<lbrakk>\<And>ys zs. xs + ys + zs = xs + (ys + zs); ys = aa # list; zs = ab # lista\<rbrakk> \<Longrightarrow> (a + aa) # xs + list + zs = a # xs + (aa # list + zs)
[PROOF STEP]
apply(simp add: add.assoc)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma homotopic_nearby_loops:
  fixes g h :: "real \<Rightarrow> 'a::euclidean_space"
  assumes "path g" "open S" "path_image g \<subseteq> S" "pathfinish g = pathstart g"
    shows "\<exists>e. 0 < e \<and>
               (\<forall>h. path h \<and> pathfinish h = pathstart h \<and>
                    (\<forall>t \<in> {0..1}. norm(h t - g t) < e) \<longrightarrow> homotopic_loops S g h)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>e>0. \<forall>h. path h \<and> pathfinish h = pathstart h \<and> (\<forall>t\<in>{0..1}. norm (h t - g t) < e) \<longrightarrow> homotopic_loops S g h
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>e>0. \<forall>h. path h \<and> pathfinish h = pathstart h \<and> (\<forall>t\<in>{0..1}. norm (h t - g t) < e) \<longrightarrow> homotopic_loops S g h
[PROOF STEP]
obtain e where "e > 0" and e: "\<And>x y. x \<in> path_image g \<Longrightarrow> y \<in> - S \<Longrightarrow> e \<le> dist x y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>e. \<lbrakk>0 < e; \<And>x y. \<lbrakk>x \<in> path_image g; y \<in> - S\<rbrakk> \<Longrightarrow> e \<le> dist x y\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using separate_compact_closed [of "path_image g" "-S"] assms
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>compact (path_image g); closed (- S); path_image g \<inter> - S = {}\<rbrakk> \<Longrightarrow> \<exists>d>0. \<forall>x\<in>path_image g. \<forall>y\<in>- S. d \<le> dist x y
path g
open S
path_image g \<subseteq> S
pathfinish g = pathstart g

goal (1 subgoal):
 1. (\<And>e. \<lbrakk>0 < e; \<And>x y. \<lbrakk>x \<in> path_image g; y \<in> - S\<rbrakk> \<Longrightarrow> e \<le> dist x y\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
0 < e
\<lbrakk>?x \<in> path_image g; ?y \<in> - S\<rbrakk> \<Longrightarrow> e \<le> dist ?x ?y

goal (1 subgoal):
 1. \<exists>e>0. \<forall>h. path h \<and> pathfinish h = pathstart h \<and> (\<forall>t\<in>{0..1}. norm (h t - g t) < e) \<longrightarrow> homotopic_loops S g h
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>e>0. \<forall>h. path h \<and> pathfinish h = pathstart h \<and> (\<forall>t\<in>{0..1}. norm (h t - g t) < e) \<longrightarrow> homotopic_loops S g h
[PROOF STEP]
using e [unfolded dist_norm] \<open>e > 0\<close>
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?x \<in> path_image g; ?y \<in> - S\<rbrakk> \<Longrightarrow> e \<le> norm (?x - ?y)
0 < e

goal (1 subgoal):
 1. \<exists>e>0. \<forall>h. path h \<and> pathfinish h = pathstart h \<and> (\<forall>t\<in>{0..1}. norm (h t - g t) < e) \<longrightarrow> homotopic_loops S g h
[PROOF STEP]
by (fastforce simp: path_image_def intro!: homotopic_loops_nearby_explicit assms exI)
[PROOF STATE]
proof (state)
this:
\<exists>e>0. \<forall>h. path h \<and> pathfinish h = pathstart h \<and> (\<forall>t\<in>{0..1}. norm (h t - g t) < e) \<longrightarrow> homotopic_loops S g h

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma norm_blinfun_of_list:
  "norm (blinfun_of_list xs::'a::executable_euclidean_space\<Rightarrow>\<^sub>L'a) \<le> (\<Sum>x\<leftarrow>xs. abs x)"
  if "length xs = DIM('a)*DIM('a)"\<comment> \<open>should work for all lists\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. norm (blinfun_of_list xs) \<le> sum_list (map abs xs)
[PROOF STEP]
unfolding blinfun_of_list_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. norm (blinfun_of_matrix (\<lambda>i j. xs ! (index Basis_list i * DIM('a) + index Basis_list j))) \<le> sum_list (map abs xs)
[PROOF STEP]
apply (rule norm_blinfun_of_matrix[le])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i\<in>Basis. \<Sum>j\<in>Basis. \<bar>xs ! (index Basis_list i * DIM('a) + index Basis_list j)\<bar>) \<le> sum_list (map abs xs)
[PROOF STEP]
apply (auto simp: sum_Basis_sum_nth_Basis_list)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i<DIM('a). \<Sum>j<DIM('a). \<bar>xs ! (i * DIM('a) + j)\<bar>) \<le> sum_list (map abs xs)
[PROOF STEP]
apply (subst add.commute)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i<DIM('a). \<Sum>j<DIM('a). \<bar>xs ! (j + i * DIM('a))\<bar>) \<le> sum_list (map abs xs)
[PROOF STEP]
apply (subst sum_mult_product[symmetric])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>a<DIM('a) * DIM('a). \<bar>xs ! a\<bar>) \<le> sum_list (map abs xs)
[PROOF STEP]
by (auto simp: sum_list_sum_nth that atLeast0LessThan)


[STATEMENT]
lemma deriv_inverse [simp]:
  "\<lbrakk>f field_differentiable at z; f z \<noteq> 0\<rbrakk>
   \<Longrightarrow> deriv (\<lambda>w. inverse (f w)) z = - deriv f z / f z ^ 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>f field_differentiable at z; f z \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> deriv (\<lambda>w. inverse (f w)) z = - deriv f z / (f z)\<^sup>2
[PROOF STEP]
unfolding DERIV_deriv_iff_field_differentiable[symmetric]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>(f has_field_derivative deriv f z) (at z); f z \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> deriv (\<lambda>w. inverse (f w)) z = - deriv f z / (f z)\<^sup>2
[PROOF STEP]
by (safe intro!: DERIV_imp_deriv derivative_eq_intros) (auto simp: field_split_simps power2_eq_square)


[STATEMENT]
lemma unity_root_add: "unity_root k (m + n) = unity_root k m * unity_root k n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. unity_root k (m + n) = unity_root k m * unity_root k n
[PROOF STEP]
by (simp add: unity_root_conv_exp add_divide_distrib algebra_simps exp_add)


[STATEMENT]
lemma makespan_correct:
  "\<forall>x \<in> {1..m}. T x \<le> makespan T"
  "\<exists>x \<in> {1..m}. T x = makespan T"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>x\<in>{1..m}. T x \<le> makespan T &&& \<exists>x\<in>{1..m}. T x = makespan T
[PROOF STEP]
using f_Max\<^sub>0_correct m_gt_0
[PROOF STATE]
proof (prove)
using this:
\<forall>x\<in>{1..?m}. ?T x \<le> f_Max\<^sub>0 ?T ?m
0 < ?m \<Longrightarrow> \<exists>x\<in>{1..?m}. ?T x = f_Max\<^sub>0 ?T ?m
0 < m

goal (1 subgoal):
 1. \<forall>x\<in>{1..m}. T x \<le> makespan T &&& \<exists>x\<in>{1..m}. T x = makespan T
[PROOF STEP]
by auto


[STATEMENT]
lemma iso_onto_image:
  assumes "group G" "group H"
  shows
   "f \<in> iso G (subgroup_generated H (f ` carrier G)) \<longleftrightarrow> f \<in> hom G H \<and> inj_on f (carrier G)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (f \<in> Group.iso G (subgroup_generated H (f ` carrier G))) = (f \<in> hom G H \<and> inj_on f (carrier G))
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
Group.group G
Group.group H

goal (1 subgoal):
 1. (f \<in> Group.iso G (subgroup_generated H (f ` carrier G))) = (f \<in> hom G H \<and> inj_on f (carrier G))
[PROOF STEP]
apply (auto simp: iso_def bij_betw_def hom_into_subgroup_eq_gen carrier_subgroup_generated hom_carrier generate.incl Int_absorb1 Int_absorb2)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. \<lbrakk>Group.group G; Group.group H; f \<in> hom G H; inj_on f (carrier G); x \<in> generate H (f ` carrier G)\<rbrakk> \<Longrightarrow> x \<in> f ` carrier G
[PROOF STEP]
by (metis group.generateI group.subgroupE(1) group.subgroup_self group_hom.generate_img group_hom.intro group_hom_axioms.intro)


[STATEMENT]
lemma two_pow_r_le_1: "0 < 1 - 2 powr - real r"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < 1 - 2 powr - real r
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. 0 < 1 - 2 powr - real r
[PROOF STEP]
have a: "2 powr (0::real) = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 powr 0 = 1
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
2 powr 0 = 1

goal (1 subgoal):
 1. 0 < 1 - 2 powr - real r
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < 1 - 2 powr - real r
[PROOF STEP]
using r_ge_23
[PROOF STATE]
proof (prove)
using this:
23 \<le> r

goal (1 subgoal):
 1. 0 < 1 - 2 powr - real r
[PROOF STEP]
by (simp, subst a[symmetric], intro powr_less_mono, auto)
[PROOF STATE]
proof (state)
this:
0 < 1 - 2 powr - real r

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma homeomorphic_open_imp_same_dimension:
  fixes S :: "'a::euclidean_space set" and T :: "'b::euclidean_space set"
  assumes "S homeomorphic T" "open S" "S \<noteq> {}" "open T" "T \<noteq> {}"
  shows "DIM('a) = DIM('b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. DIM('a) = DIM('b)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
S homeomorphic T
open S
S \<noteq> {}
open T
T \<noteq> {}

goal (1 subgoal):
 1. DIM('a) = DIM('b)
[PROOF STEP]
apply (simp add: homeomorphic_minimal)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<exists>f g. (\<forall>x\<in>S. f x \<in> T \<and> g (f x) = x) \<and> (\<forall>y\<in>T. g y \<in> S \<and> f (g y) = y) \<and> continuous_on S f \<and> continuous_on T g; open S; S \<noteq> {}; open T; T \<noteq> {}\<rbrakk> \<Longrightarrow> DIM('a) = DIM('b)
[PROOF STEP]
apply (rule order_antisym; metis inj_onI invariance_of_dimension)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma vangle_eqI:
  assumes "u \<noteq> 0" "v \<noteq> 0" "w \<noteq> 0" "x \<noteq> 0"
  assumes "(u \<bullet> v) * norm w * norm x = (w \<bullet> x) * norm u * norm v"
  shows   "vangle u v = vangle w x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vangle u v = vangle w x
[PROOF STEP]
using assms Cauchy_Schwarz_ineq2[of u v] Cauchy_Schwarz_ineq2[of w x]
[PROOF STATE]
proof (prove)
using this:
u \<noteq> (0::'a)
v \<noteq> (0::'a)
w \<noteq> (0::'b)
x \<noteq> (0::'b)
u \<bullet> v * norm w * norm x = w \<bullet> x * norm u * norm v
\<bar>u \<bullet> v\<bar> \<le> norm u * norm v
\<bar>w \<bullet> x\<bar> \<le> norm w * norm x

goal (1 subgoal):
 1. vangle u v = vangle w x
[PROOF STEP]
unfolding vangle_def
[PROOF STATE]
proof (prove)
using this:
u \<noteq> (0::'a)
v \<noteq> (0::'a)
w \<noteq> (0::'b)
x \<noteq> (0::'b)
u \<bullet> v * norm w * norm x = w \<bullet> x * norm u * norm v
\<bar>u \<bullet> v\<bar> \<le> norm u * norm v
\<bar>w \<bullet> x\<bar> \<le> norm w * norm x

goal (1 subgoal):
 1. (if u = (0::'a) \<or> v = (0::'a) then pi / 2 else arccos (u \<bullet> v / (norm u * norm v))) = (if w = (0::'b) \<or> x = (0::'b) then pi / 2 else arccos (w \<bullet> x / (norm w * norm x)))
[PROOF STEP]
by (auto simp: arccos_eq_iff field_simps)


[STATEMENT]
lemma linear_bij_rank_eq_ncols:
  fixes f::"('a::{field}^'n::{mod_type})=>('a::{field}^'n::{mod_type})"
  assumes lf: "linear ((*s)) ((*s)) f"
  shows "bij f \<longleftrightarrow> rank (matrix f) = ncols (matrix f)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bij f = (rank (matrix f) = ncols (matrix f))
[PROOF STEP]
unfolding bij_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (inj f \<and> surj f) = (rank (matrix f) = ncols (matrix f))
[PROOF STEP]
using lf linear_injective_rank_eq_ncols vec.linear_inj_imp_surj
[PROOF STATE]
proof (prove)
using this:
linear (*s) (*s) f
linear (*s) (*s) ?f \<Longrightarrow> inj ?f = (rank (matrix ?f) = ncols (matrix ?f))
\<lbrakk>linear (*s) (*s) ?f; inj ?f\<rbrakk> \<Longrightarrow> surj ?f

goal (1 subgoal):
 1. (inj f \<and> surj f) = (rank (matrix f) = ncols (matrix f))
[PROOF STEP]
by auto


[STATEMENT]
lemma bij_betw_nth_root_unity:
  fixes c :: complex and n :: nat
  assumes c: "c \<noteq> 0" and n: "n > 0"
  defines "c' \<equiv> root n (norm c) * cis (Arg c / n)"
  shows "bij_betw (\<lambda>z. c' * z) {z. z ^ n = 1} {z. z ^ n = c}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bij_betw ((*) c') {z. z ^ n = 1} {z. z ^ n = c}
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. bij_betw ((*) c') {z. z ^ n = 1} {z. z ^ n = c}
[PROOF STEP]
have "c' ^ n = of_real (root n (norm c) ^ n) * cis (Arg c)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. c' ^ n = complex_of_real (root n (cmod c) ^ n) * cis (Arg c)
[PROOF STEP]
unfolding of_real_power
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. c' ^ n = complex_of_real (root n (cmod c)) ^ n * cis (Arg c)
[PROOF STEP]
using n
[PROOF STATE]
proof (prove)
using this:
0 < n

goal (1 subgoal):
 1. c' ^ n = complex_of_real (root n (cmod c)) ^ n * cis (Arg c)
[PROOF STEP]
by (simp add: c'_def power_mult_distrib DeMoivre)
[PROOF STATE]
proof (state)
this:
c' ^ n = complex_of_real (root n (cmod c) ^ n) * cis (Arg c)

goal (1 subgoal):
 1. bij_betw ((*) c') {z. z ^ n = 1} {z. z ^ n = c}
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
c' ^ n = complex_of_real (root n (cmod c) ^ n) * cis (Arg c)

goal (1 subgoal):
 1. bij_betw ((*) c') {z. z ^ n = 1} {z. z ^ n = c}
[PROOF STEP]
from n
[PROOF STATE]
proof (chain)
picking this:
0 < n
[PROOF STEP]
have "root n (norm c) ^ n = norm c"
[PROOF STATE]
proof (prove)
using this:
0 < n

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

goal (1 subgoal):
 1. bij_betw ((*) c') {z. z ^ n = 1} {z. z ^ n = c}
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
root n (cmod c) ^ n = cmod c

goal (1 subgoal):
 1. bij_betw ((*) c') {z. z ^ n = 1} {z. z ^ n = c}
[PROOF STEP]
from c
[PROOF STATE]
proof (chain)
picking this:
c \<noteq> 0
[PROOF STEP]
have "of_real \<dots> * cis (Arg c) = c"
[PROOF STATE]
proof (prove)
using this:
c \<noteq> 0

goal (1 subgoal):
 1. complex_of_real (cmod c) * cis (Arg c) = c
[PROOF STEP]
by (simp add: cis_Arg Complex.sgn_eq)
[PROOF STATE]
proof (state)
this:
complex_of_real (cmod c) * cis (Arg c) = c

goal (1 subgoal):
 1. bij_betw ((*) c') {z. z ^ n = 1} {z. z ^ n = c}
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
c' ^ n = c
[PROOF STEP]
have [simp]: "c' ^ n = c"
[PROOF STATE]
proof (prove)
using this:
c' ^ n = c

goal (1 subgoal):
 1. c' ^ n = c
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
c' ^ n = c

goal (1 subgoal):
 1. bij_betw ((*) c') {z. z ^ n = 1} {z. z ^ n = c}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bij_betw ((*) c') {z. z ^ n = 1} {z. z ^ n = c}
[PROOF STEP]
unfolding bij_betw_def inj_on_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<forall>x\<in>{z. z ^ n = 1}. \<forall>y\<in>{z. z ^ n = 1}. c' * x = c' * y \<longrightarrow> x = y) \<and> (*) c' ` {z. z ^ n = 1} = {z. z ^ n = c}
[PROOF STEP]
proof safe
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. \<And>x y. \<lbrakk>x ^ n = 1; y ^ n = 1; c' * x = c' * y\<rbrakk> \<Longrightarrow> x = y
 2. \<And>x xa. xa ^ n = 1 \<Longrightarrow> (c' * xa) ^ n = c
 3. \<And>x. c = x ^ n \<Longrightarrow> x \<in> (*) c' ` {z. z ^ n = 1}
[PROOF STEP]
fix z :: complex
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. \<And>x y. \<lbrakk>x ^ n = 1; y ^ n = 1; c' * x = c' * y\<rbrakk> \<Longrightarrow> x = y
 2. \<And>x xa. xa ^ n = 1 \<Longrightarrow> (c' * xa) ^ n = c
 3. \<And>x. c = x ^ n \<Longrightarrow> x \<in> (*) c' ` {z. z ^ n = 1}
[PROOF STEP]
assume "z ^ n = 1"
[PROOF STATE]
proof (state)
this:
z ^ n = 1

goal (3 subgoals):
 1. \<And>x y. \<lbrakk>x ^ n = 1; y ^ n = 1; c' * x = c' * y\<rbrakk> \<Longrightarrow> x = y
 2. \<And>x xa. xa ^ n = 1 \<Longrightarrow> (c' * xa) ^ n = c
 3. \<And>x. c = x ^ n \<Longrightarrow> x \<in> (*) c' ` {z. z ^ n = 1}
[PROOF STEP]
hence "(c' * z) ^ n = c' ^ n"
[PROOF STATE]
proof (prove)
using this:
z ^ n = 1

goal (1 subgoal):
 1. (c' * z) ^ n = c' ^ n
[PROOF STEP]
by (simp add: power_mult_distrib)
[PROOF STATE]
proof (state)
this:
(c' * z) ^ n = c' ^ n

goal (3 subgoals):
 1. \<And>x y. \<lbrakk>x ^ n = 1; y ^ n = 1; c' * x = c' * y\<rbrakk> \<Longrightarrow> x = y
 2. \<And>x xa. xa ^ n = 1 \<Longrightarrow> (c' * xa) ^ n = c
 3. \<And>x. c = x ^ n \<Longrightarrow> x \<in> (*) c' ` {z. z ^ n = 1}
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(c' * z) ^ n = c' ^ n

goal (3 subgoals):
 1. \<And>x y. \<lbrakk>x ^ n = 1; y ^ n = 1; c' * x = c' * y\<rbrakk> \<Longrightarrow> x = y
 2. \<And>x xa. xa ^ n = 1 \<Longrightarrow> (c' * xa) ^ n = c
 3. \<And>x. c = x ^ n \<Longrightarrow> x \<in> (*) c' ` {z. z ^ n = 1}
[PROOF STEP]
have "c' ^ n = of_real (root n (norm c) ^ n) * cis (Arg c)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. c' ^ n = complex_of_real (root n (cmod c) ^ n) * cis (Arg c)
[PROOF STEP]
unfolding of_real_power
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. c' ^ n = complex_of_real (root n (cmod c)) ^ n * cis (Arg c)
[PROOF STEP]
using n
[PROOF STATE]
proof (prove)
using this:
0 < n

goal (1 subgoal):
 1. c' ^ n = complex_of_real (root n (cmod c)) ^ n * cis (Arg c)
[PROOF STEP]
by (simp add: c'_def power_mult_distrib DeMoivre)
[PROOF STATE]
proof (state)
this:
c' ^ n = complex_of_real (root n (cmod c) ^ n) * cis (Arg c)

goal (3 subgoals):
 1. \<And>x y. \<lbrakk>x ^ n = 1; y ^ n = 1; c' * x = c' * y\<rbrakk> \<Longrightarrow> x = y
 2. \<And>x xa. xa ^ n = 1 \<Longrightarrow> (c' * xa) ^ n = c
 3. \<And>x. c = x ^ n \<Longrightarrow> x \<in> (*) c' ` {z. z ^ n = 1}
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
c' ^ n = complex_of_real (root n (cmod c) ^ n) * cis (Arg c)

goal (3 subgoals):
 1. \<And>x y. \<lbrakk>x ^ n = 1; y ^ n = 1; c' * x = c' * y\<rbrakk> \<Longrightarrow> x = y
 2. \<And>x xa. xa ^ n = 1 \<Longrightarrow> (c' * xa) ^ n = c
 3. \<And>x. c = x ^ n \<Longrightarrow> x \<in> (*) c' ` {z. z ^ n = 1}
[PROOF STEP]
from n
[PROOF STATE]
proof (chain)
picking this:
0 < n
[PROOF STEP]
have "root n (norm c) ^ n = norm c"
[PROOF STATE]
proof (prove)
using this:
0 < n

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

goal (3 subgoals):
 1. \<And>x y. \<lbrakk>x ^ n = 1; y ^ n = 1; c' * x = c' * y\<rbrakk> \<Longrightarrow> x = y
 2. \<And>x xa. xa ^ n = 1 \<Longrightarrow> (c' * xa) ^ n = c
 3. \<And>x. c = x ^ n \<Longrightarrow> x \<in> (*) c' ` {z. z ^ n = 1}
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
root n (cmod c) ^ n = cmod c

goal (3 subgoals):
 1. \<And>x y. \<lbrakk>x ^ n = 1; y ^ n = 1; c' * x = c' * y\<rbrakk> \<Longrightarrow> x = y
 2. \<And>x xa. xa ^ n = 1 \<Longrightarrow> (c' * xa) ^ n = c
 3. \<And>x. c = x ^ n \<Longrightarrow> x \<in> (*) c' ` {z. z ^ n = 1}
[PROOF STEP]
from c
[PROOF STATE]
proof (chain)
picking this:
c \<noteq> 0
[PROOF STEP]
have "\<dots> * cis (Arg c) = c"
[PROOF STATE]
proof (prove)
using this:
c \<noteq> 0

goal (1 subgoal):
 1. complex_of_real (cmod c) * cis (Arg c) = c
[PROOF STEP]
by (simp add: cis_Arg Complex.sgn_eq)
[PROOF STATE]
proof (state)
this:
complex_of_real (cmod c) * cis (Arg c) = c

goal (3 subgoals):
 1. \<And>x y. \<lbrakk>x ^ n = 1; y ^ n = 1; c' * x = c' * y\<rbrakk> \<Longrightarrow> x = y
 2. \<And>x xa. xa ^ n = 1 \<Longrightarrow> (c' * xa) ^ n = c
 3. \<And>x. c = x ^ n \<Longrightarrow> x \<in> (*) c' ` {z. z ^ n = 1}
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(c' * z) ^ n = c
[PROOF STEP]
show "(c' * z) ^ n = c"
[PROOF STATE]
proof (prove)
using this:
(c' * z) ^ n = c

goal (1 subgoal):
 1. (c' * z) ^ n = c
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
(c' * z) ^ n = c

goal (2 subgoals):
 1. \<And>x y. \<lbrakk>x ^ n = 1; y ^ n = 1; c' * x = c' * y\<rbrakk> \<Longrightarrow> x = y
 2. \<And>x. c = x ^ n \<Longrightarrow> x \<in> (*) c' ` {z. z ^ n = 1}
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>x y. \<lbrakk>x ^ n = 1; y ^ n = 1; c' * x = c' * y\<rbrakk> \<Longrightarrow> x = y
 2. \<And>x. c = x ^ n \<Longrightarrow> x \<in> (*) c' ` {z. z ^ n = 1}
[PROOF STEP]
fix z
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>x y. \<lbrakk>x ^ n = 1; y ^ n = 1; c' * x = c' * y\<rbrakk> \<Longrightarrow> x = y
 2. \<And>x. c = x ^ n \<Longrightarrow> x \<in> (*) c' ` {z. z ^ n = 1}
[PROOF STEP]
assume z: "c = z ^ n"
[PROOF STATE]
proof (state)
this:
c = z ^ n

goal (2 subgoals):
 1. \<And>x y. \<lbrakk>x ^ n = 1; y ^ n = 1; c' * x = c' * y\<rbrakk> \<Longrightarrow> x = y
 2. \<And>x. c = x ^ n \<Longrightarrow> x \<in> (*) c' ` {z. z ^ n = 1}
[PROOF STEP]
define z' where "z' = z / c'"
[PROOF STATE]
proof (state)
this:
z' = z / c'

goal (2 subgoals):
 1. \<And>x y. \<lbrakk>x ^ n = 1; y ^ n = 1; c' * x = c' * y\<rbrakk> \<Longrightarrow> x = y
 2. \<And>x. c = x ^ n \<Longrightarrow> x \<in> (*) c' ` {z. z ^ n = 1}
[PROOF STEP]
from c and n
[PROOF STATE]
proof (chain)
picking this:
c \<noteq> 0
0 < n
[PROOF STEP]
have "c' \<noteq> 0"
[PROOF STATE]
proof (prove)
using this:
c \<noteq> 0
0 < n

goal (1 subgoal):
 1. c' \<noteq> 0
[PROOF STEP]
by (auto simp: c'_def)
[PROOF STATE]
proof (state)
this:
c' \<noteq> 0

goal (2 subgoals):
 1. \<And>x y. \<lbrakk>x ^ n = 1; y ^ n = 1; c' * x = c' * y\<rbrakk> \<Longrightarrow> x = y
 2. \<And>x. c = x ^ n \<Longrightarrow> x \<in> (*) c' ` {z. z ^ n = 1}
[PROOF STEP]
with n c
[PROOF STATE]
proof (chain)
picking this:
0 < n
c \<noteq> 0
c' \<noteq> 0
[PROOF STEP]
have "z = c' * z'" and "z' ^ n = 1"
[PROOF STATE]
proof (prove)
using this:
0 < n
c \<noteq> 0
c' \<noteq> 0

goal (1 subgoal):
 1. z = c' * z' &&& z' ^ n = 1
[PROOF STEP]
by (auto simp: z'_def power_divide z)
[PROOF STATE]
proof (state)
this:
z = c' * z'
z' ^ n = 1

goal (2 subgoals):
 1. \<And>x y. \<lbrakk>x ^ n = 1; y ^ n = 1; c' * x = c' * y\<rbrakk> \<Longrightarrow> x = y
 2. \<And>x. c = x ^ n \<Longrightarrow> x \<in> (*) c' ` {z. z ^ n = 1}
[PROOF STEP]
thus "z \<in> (\<lambda>z. c' * z) ` {z. z ^ n = 1}"
[PROOF STATE]
proof (prove)
using this:
z = c' * z'
z' ^ n = 1

goal (1 subgoal):
 1. z \<in> (*) c' ` {z. z ^ n = 1}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
z \<in> (*) c' ` {z. z ^ n = 1}

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x ^ n = 1; y ^ n = 1; c' * x = c' * y\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
qed (insert c n, auto simp: c'_def)
[PROOF STATE]
proof (state)
this:
bij_betw ((*) c') {z. z ^ n = 1} {z. z ^ n = c}

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma is_det_bound_ge_zero: assumes "is_det_bound f"
  and "x \<ge> 0"
  shows "f n x \<ge> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (0::'a) \<le> f n x
[PROOF STEP]
using assms(1)[unfolded is_det_bound_def, rule_format, of "0\<^sub>m n n" n x]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>0\<^sub>m n n \<in> carrier_mat n n; 0\<^sub>m n n \<in> Bounded_mat x\<rbrakk> \<Longrightarrow> \<bar>det (0\<^sub>m n n)\<bar> \<le> f n x

goal (1 subgoal):
 1. (0::'a) \<le> f n x
[PROOF STEP]
using assms(2)
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>0\<^sub>m n n \<in> carrier_mat n n; 0\<^sub>m n n \<in> Bounded_mat x\<rbrakk> \<Longrightarrow> \<bar>det (0\<^sub>m n n)\<bar> \<le> f n x
(0::'a) \<le> x

goal (1 subgoal):
 1. (0::'a) \<le> f n x
[PROOF STEP]
unfolding Bounded_mat_def
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>0\<^sub>m n n \<in> carrier_mat n n; 0\<^sub>m n n \<in> {A. \<forall>i<dim_row A. \<forall>j<dim_col A. \<bar>A $$ (i, j)\<bar> \<le> x}\<rbrakk> \<Longrightarrow> \<bar>det (0\<^sub>m n n)\<bar> \<le> f n x
(0::'a) \<le> x

goal (1 subgoal):
 1. (0::'a) \<le> f n x
[PROOF STEP]
by auto


[STATEMENT]
lemma pell_power_add: "pell_power z (m + n) = pell_mul (pell_power z m) (pell_power z n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. pell_power z (m + n) = pell_mul (pell_power z m) (pell_power z n)
[PROOF STEP]
by (induction m arbitrary: z )
     (simp_all add: funpow_add o_def pell_power_Suc pell_mul_assoc)


[STATEMENT]
lemma strict_SD_iff:
  assumes "p \<in> lotteries_on carrier" "q \<in> lotteries_on carrier"
  shows   "(p \<prec>[SD(le)] q) \<longleftrightarrow>
             (\<forall>u. is_vnm_utility u \<longrightarrow> measure_pmf.expectation p u < measure_pmf.expectation q u)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. p \<prec>[SD le] q = (\<forall>u. is_vnm_utility u \<longrightarrow> measure_pmf.expectation p u < measure_pmf.expectation q u)
[PROOF STEP]
using not_strict_SD_iff[OF assms]
[PROOF STATE]
proof (prove)
using this:
(\<not> p \<prec>[SD le] q) = (\<exists>u. is_vnm_utility u \<and> measure_pmf.expectation q u \<le> measure_pmf.expectation p u)

goal (1 subgoal):
 1. p \<prec>[SD le] q = (\<forall>u. is_vnm_utility u \<longrightarrow> measure_pmf.expectation p u < measure_pmf.expectation q u)
[PROOF STEP]
by auto