[STATEMENT]
lemma sum_partition_le:
  assumes "finite_graph_partition V P k" "finite V"
  shows "(\<Sum>R\<in>P. \<Sum>S\<in>P. real (card R * card S)) \<le> (real(card V))\<^sup>2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>R\<in>P. \<Sum>S\<in>P. real (card R * card S)) \<le> (real (card V))\<^sup>2
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<Sum>R\<in>P. \<Sum>S\<in>P. real (card R * card S)) \<le> (real (card V))\<^sup>2
[PROOF STEP]
have "finite P"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite P
[PROOF STEP]
using assms finite_graph_partition_def
[PROOF STATE]
proof (prove)
using this:
finite_graph_partition V P k
finite V
finite_graph_partition ?V ?P ?n \<equiv> partition_on ?V ?P \<and> finite ?P \<and> card ?P = ?n

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

goal (1 subgoal):
 1. (\<Sum>R\<in>P. \<Sum>S\<in>P. real (card R * card S)) \<le> (real (card V))\<^sup>2
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
finite P
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
finite P

goal (1 subgoal):
 1. (\<Sum>R\<in>P. \<Sum>S\<in>P. real (card R * card S)) \<le> (real (card V))\<^sup>2
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
finite P
finite_graph_partition V P k
finite V

goal (1 subgoal):
 1. (\<Sum>R\<in>P. \<Sum>S\<in>P. real (card R * card S)) \<le> (real (card V))\<^sup>2
[PROOF STEP]
proof (induction P arbitrary: V k)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>V k. \<lbrakk>finite_graph_partition V {} k; finite V\<rbrakk> \<Longrightarrow> (\<Sum>R\<in>{}. \<Sum>S\<in>{}. real (card R * card S)) \<le> (real (card V))\<^sup>2
 2. \<And>x F V k. \<lbrakk>finite F; x \<notin> F; \<And>V k. \<lbrakk>finite_graph_partition V F k; finite V\<rbrakk> \<Longrightarrow> (\<Sum>R\<in>F. \<Sum>S\<in>F. real (card R * card S)) \<le> (real (card V))\<^sup>2; finite_graph_partition V (insert x F) k; finite V\<rbrakk> \<Longrightarrow> (\<Sum>R\<in>insert x F. \<Sum>S\<in>insert x F. real (card R * card S)) \<le> (real (card V))\<^sup>2
[PROOF STEP]
case (insert X P)
[PROOF STATE]
proof (state)
this:
finite P
X \<notin> P
\<lbrakk>finite_graph_partition ?V P ?k; finite ?V\<rbrakk> \<Longrightarrow> (\<Sum>R\<in>P. \<Sum>S\<in>P. real (card R * card S)) \<le> (real (card ?V))\<^sup>2
finite_graph_partition V (insert X P) k
finite V

goal (2 subgoals):
 1. \<And>V k. \<lbrakk>finite_graph_partition V {} k; finite V\<rbrakk> \<Longrightarrow> (\<Sum>R\<in>{}. \<Sum>S\<in>{}. real (card R * card S)) \<le> (real (card V))\<^sup>2
 2. \<And>x F V k. \<lbrakk>finite F; x \<notin> F; \<And>V k. \<lbrakk>finite_graph_partition V F k; finite V\<rbrakk> \<Longrightarrow> (\<Sum>R\<in>F. \<Sum>S\<in>F. real (card R * card S)) \<le> (real (card V))\<^sup>2; finite_graph_partition V (insert x F) k; finite V\<rbrakk> \<Longrightarrow> (\<Sum>R\<in>insert x F. \<Sum>S\<in>insert x F. real (card R * card S)) \<le> (real (card V))\<^sup>2
[PROOF STEP]
have [simp]: "finite Y" if "Y \<in> insert X P" for Y
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite Y
[PROOF STEP]
by (meson finite_graph_partition_finite insert.prems that)
[PROOF STATE]
proof (state)
this:
?Y \<in> insert X P \<Longrightarrow> finite ?Y

goal (2 subgoals):
 1. \<And>V k. \<lbrakk>finite_graph_partition V {} k; finite V\<rbrakk> \<Longrightarrow> (\<Sum>R\<in>{}. \<Sum>S\<in>{}. real (card R * card S)) \<le> (real (card V))\<^sup>2
 2. \<And>x F V k. \<lbrakk>finite F; x \<notin> F; \<And>V k. \<lbrakk>finite_graph_partition V F k; finite V\<rbrakk> \<Longrightarrow> (\<Sum>R\<in>F. \<Sum>S\<in>F. real (card R * card S)) \<le> (real (card V))\<^sup>2; finite_graph_partition V (insert x F) k; finite V\<rbrakk> \<Longrightarrow> (\<Sum>R\<in>insert x F. \<Sum>S\<in>insert x F. real (card R * card S)) \<le> (real (card V))\<^sup>2
[PROOF STEP]
have C: "card Y \<le> card V" if"Y \<in> insert X P" for Y
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card Y \<le> card V
[PROOF STEP]
by (meson card_mono finite_graph_partition_subset insert.prems that)
[PROOF STATE]
proof (state)
this:
?Y \<in> insert X P \<Longrightarrow> card ?Y \<le> card V

goal (2 subgoals):
 1. \<And>V k. \<lbrakk>finite_graph_partition V {} k; finite V\<rbrakk> \<Longrightarrow> (\<Sum>R\<in>{}. \<Sum>S\<in>{}. real (card R * card S)) \<le> (real (card V))\<^sup>2
 2. \<And>x F V k. \<lbrakk>finite F; x \<notin> F; \<And>V k. \<lbrakk>finite_graph_partition V F k; finite V\<rbrakk> \<Longrightarrow> (\<Sum>R\<in>F. \<Sum>S\<in>F. real (card R * card S)) \<le> (real (card V))\<^sup>2; finite_graph_partition V (insert x F) k; finite V\<rbrakk> \<Longrightarrow> (\<Sum>R\<in>insert x F. \<Sum>S\<in>insert x F. real (card R * card S)) \<le> (real (card V))\<^sup>2
[PROOF STEP]
have D [simp]: "(\<Sum>Y\<in>P. real (card Y)) = real (card V) - real (card X)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>Y\<in>P. real (card Y)) = real (card V) - real (card X)
[PROOF STEP]
by (smt (verit) card_finite_graph_partition insert.hyps insert.prems of_nat_sum sum.cong sum.insert)
[PROOF STATE]
proof (state)
this:
(\<Sum>Y\<in>P. real (card Y)) = real (card V) - real (card X)

goal (2 subgoals):
 1. \<And>V k. \<lbrakk>finite_graph_partition V {} k; finite V\<rbrakk> \<Longrightarrow> (\<Sum>R\<in>{}. \<Sum>S\<in>{}. real (card R * card S)) \<le> (real (card V))\<^sup>2
 2. \<And>x F V k. \<lbrakk>finite F; x \<notin> F; \<And>V k. \<lbrakk>finite_graph_partition V F k; finite V\<rbrakk> \<Longrightarrow> (\<Sum>R\<in>F. \<Sum>S\<in>F. real (card R * card S)) \<le> (real (card V))\<^sup>2; finite_graph_partition V (insert x F) k; finite V\<rbrakk> \<Longrightarrow> (\<Sum>R\<in>insert x F. \<Sum>S\<in>insert x F. real (card R * card S)) \<le> (real (card V))\<^sup>2
[PROOF STEP]
have "disjnt X (\<Union>P)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. disjnt X (\<Union> P)
[PROOF STEP]
using insert.prems insert.hyps
[PROOF STATE]
proof (prove)
using this:
finite_graph_partition V (insert X P) k
finite V
finite P
X \<notin> P

goal (1 subgoal):
 1. disjnt X (\<Union> P)
[PROOF STEP]
by (auto simp add: finite_graph_partition_def disjnt_iff pairwise_insert partition_on_def)
[PROOF STATE]
proof (state)
this:
disjnt X (\<Union> P)

goal (2 subgoals):
 1. \<And>V k. \<lbrakk>finite_graph_partition V {} k; finite V\<rbrakk> \<Longrightarrow> (\<Sum>R\<in>{}. \<Sum>S\<in>{}. real (card R * card S)) \<le> (real (card V))\<^sup>2
 2. \<And>x F V k. \<lbrakk>finite F; x \<notin> F; \<And>V k. \<lbrakk>finite_graph_partition V F k; finite V\<rbrakk> \<Longrightarrow> (\<Sum>R\<in>F. \<Sum>S\<in>F. real (card R * card S)) \<le> (real (card V))\<^sup>2; finite_graph_partition V (insert x F) k; finite V\<rbrakk> \<Longrightarrow> (\<Sum>R\<in>insert x F. \<Sum>S\<in>insert x F. real (card R * card S)) \<le> (real (card V))\<^sup>2
[PROOF STEP]
with insert
[PROOF STATE]
proof (chain)
picking this:
finite P
X \<notin> P
\<lbrakk>finite_graph_partition ?V P ?k; finite ?V\<rbrakk> \<Longrightarrow> (\<Sum>R\<in>P. \<Sum>S\<in>P. real (card R * card S)) \<le> (real (card ?V))\<^sup>2
finite_graph_partition V (insert X P) k
finite V
disjnt X (\<Union> P)
[PROOF STEP]
have *: "(\<Sum>R\<in>P. \<Sum>S\<in>P. real (card R * card S)) \<le> (real (card (V - X)))\<^sup>2"
[PROOF STATE]
proof (prove)
using this:
finite P
X \<notin> P
\<lbrakk>finite_graph_partition ?V P ?k; finite ?V\<rbrakk> \<Longrightarrow> (\<Sum>R\<in>P. \<Sum>S\<in>P. real (card R * card S)) \<le> (real (card ?V))\<^sup>2
finite_graph_partition V (insert X P) k
finite V
disjnt X (\<Union> P)

goal (1 subgoal):
 1. (\<Sum>R\<in>P. \<Sum>S\<in>P. real (card R * card S)) \<le> (real (card (V - X)))\<^sup>2
[PROOF STEP]
unfolding finite_graph_partition_def
[PROOF STATE]
proof (prove)
using this:
finite P
X \<notin> P
\<lbrakk>partition_on ?V P \<and> finite P \<and> card P = ?k; finite ?V\<rbrakk> \<Longrightarrow> (\<Sum>R\<in>P. \<Sum>S\<in>P. real (card R * card S)) \<le> (real (card ?V))\<^sup>2
partition_on V (insert X P) \<and> finite (insert X P) \<and> card (insert X P) = k
finite V
disjnt X (\<Union> P)

goal (1 subgoal):
 1. (\<Sum>R\<in>P. \<Sum>S\<in>P. real (card R * card S)) \<le> (real (card (V - X)))\<^sup>2
[PROOF STEP]
by (simp add: lessThan_Suc partition_on_insert disjoint_family_on_insert sum.distrib)
[PROOF STATE]
proof (state)
this:
(\<Sum>R\<in>P. \<Sum>S\<in>P. real (card R * card S)) \<le> (real (card (V - X)))\<^sup>2

goal (2 subgoals):
 1. \<And>V k. \<lbrakk>finite_graph_partition V {} k; finite V\<rbrakk> \<Longrightarrow> (\<Sum>R\<in>{}. \<Sum>S\<in>{}. real (card R * card S)) \<le> (real (card V))\<^sup>2
 2. \<And>x F V k. \<lbrakk>finite F; x \<notin> F; \<And>V k. \<lbrakk>finite_graph_partition V F k; finite V\<rbrakk> \<Longrightarrow> (\<Sum>R\<in>F. \<Sum>S\<in>F. real (card R * card S)) \<le> (real (card V))\<^sup>2; finite_graph_partition V (insert x F) k; finite V\<rbrakk> \<Longrightarrow> (\<Sum>R\<in>insert x F. \<Sum>S\<in>insert x F. real (card R * card S)) \<le> (real (card V))\<^sup>2
[PROOF STEP]
have [simp]: "V \<inter>X = X"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. V \<inter> X = X
[PROOF STEP]
using finite_graph_partition_equals insert.prems
[PROOF STATE]
proof (prove)
using this:
finite_graph_partition ?V ?P ?n \<Longrightarrow> \<Union> ?P = ?V
finite_graph_partition V (insert X P) k
finite V

goal (1 subgoal):
 1. V \<inter> X = X
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
V \<inter> X = X

goal (2 subgoals):
 1. \<And>V k. \<lbrakk>finite_graph_partition V {} k; finite V\<rbrakk> \<Longrightarrow> (\<Sum>R\<in>{}. \<Sum>S\<in>{}. real (card R * card S)) \<le> (real (card V))\<^sup>2
 2. \<And>x F V k. \<lbrakk>finite F; x \<notin> F; \<And>V k. \<lbrakk>finite_graph_partition V F k; finite V\<rbrakk> \<Longrightarrow> (\<Sum>R\<in>F. \<Sum>S\<in>F. real (card R * card S)) \<le> (real (card V))\<^sup>2; finite_graph_partition V (insert x F) k; finite V\<rbrakk> \<Longrightarrow> (\<Sum>R\<in>insert x F. \<Sum>S\<in>insert x F. real (card R * card S)) \<le> (real (card V))\<^sup>2
[PROOF STEP]
have "(\<Sum>R \<in> insert X P. \<Sum>S \<in> insert X P. real (card R * card S))
      = real (card X * card X) + 2 * (card V - card X) * card X
        + (\<Sum>R\<in>P. \<Sum>S\<in>P. real (card R * card S))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>R\<in>insert X P. \<Sum>S\<in>insert X P. real (card R * card S)) = real (card X * card X) + real (2 * (card V - card X) * card X) + (\<Sum>R\<in>P. \<Sum>S\<in>P. real (card R * card S))
[PROOF STEP]
using \<open>X \<notin> P\<close> \<open>finite P\<close>
[PROOF STATE]
proof (prove)
using this:
X \<notin> P
finite P

goal (1 subgoal):
 1. (\<Sum>R\<in>insert X P. \<Sum>S\<in>insert X P. real (card R * card S)) = real (card X * card X) + real (2 * (card V - card X) * card X) + (\<Sum>R\<in>P. \<Sum>S\<in>P. real (card R * card S))
[PROOF STEP]
by (simp add: C of_nat_diff sum.distrib algebra_simps flip: sum_distrib_right)
[PROOF STATE]
proof (state)
this:
(\<Sum>R\<in>insert X P. \<Sum>S\<in>insert X P. real (card R * card S)) = real (card X * card X) + real (2 * (card V - card X) * card X) + (\<Sum>R\<in>P. \<Sum>S\<in>P. real (card R * card S))

goal (2 subgoals):
 1. \<And>V k. \<lbrakk>finite_graph_partition V {} k; finite V\<rbrakk> \<Longrightarrow> (\<Sum>R\<in>{}. \<Sum>S\<in>{}. real (card R * card S)) \<le> (real (card V))\<^sup>2
 2. \<And>x F V k. \<lbrakk>finite F; x \<notin> F; \<And>V k. \<lbrakk>finite_graph_partition V F k; finite V\<rbrakk> \<Longrightarrow> (\<Sum>R\<in>F. \<Sum>S\<in>F. real (card R * card S)) \<le> (real (card V))\<^sup>2; finite_graph_partition V (insert x F) k; finite V\<rbrakk> \<Longrightarrow> (\<Sum>R\<in>insert x F. \<Sum>S\<in>insert x F. real (card R * card S)) \<le> (real (card V))\<^sup>2
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>R\<in>insert X P. \<Sum>S\<in>insert X P. real (card R * card S)) = real (card X * card X) + real (2 * (card V - card X) * card X) + (\<Sum>R\<in>P. \<Sum>S\<in>P. real (card R * card S))

goal (2 subgoals):
 1. \<And>V k. \<lbrakk>finite_graph_partition V {} k; finite V\<rbrakk> \<Longrightarrow> (\<Sum>R\<in>{}. \<Sum>S\<in>{}. real (card R * card S)) \<le> (real (card V))\<^sup>2
 2. \<And>x F V k. \<lbrakk>finite F; x \<notin> F; \<And>V k. \<lbrakk>finite_graph_partition V F k; finite V\<rbrakk> \<Longrightarrow> (\<Sum>R\<in>F. \<Sum>S\<in>F. real (card R * card S)) \<le> (real (card V))\<^sup>2; finite_graph_partition V (insert x F) k; finite V\<rbrakk> \<Longrightarrow> (\<Sum>R\<in>insert x F. \<Sum>S\<in>insert x F. real (card R * card S)) \<le> (real (card V))\<^sup>2
[PROOF STEP]
have "\<dots> \<le> real (card X * card X) + 2 * (card V - card X) * card X + (real (card (V - X)))\<^sup>2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real (card X * card X) + real (2 * (card V - card X) * card X) + (\<Sum>R\<in>P. \<Sum>S\<in>P. real (card R * card S)) \<le> real (card X * card X) + real (2 * (card V - card X) * card X) + (real (card (V - X)))\<^sup>2
[PROOF STEP]
using *
[PROOF STATE]
proof (prove)
using this:
(\<Sum>R\<in>P. \<Sum>S\<in>P. real (card R * card S)) \<le> (real (card (V - X)))\<^sup>2

goal (1 subgoal):
 1. real (card X * card X) + real (2 * (card V - card X) * card X) + (\<Sum>R\<in>P. \<Sum>S\<in>P. real (card R * card S)) \<le> real (card X * card X) + real (2 * (card V - card X) * card X) + (real (card (V - X)))\<^sup>2
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
real (card X * card X) + real (2 * (card V - card X) * card X) + (\<Sum>R\<in>P. \<Sum>S\<in>P. real (card R * card S)) \<le> real (card X * card X) + real (2 * (card V - card X) * card X) + (real (card (V - X)))\<^sup>2

goal (2 subgoals):
 1. \<And>V k. \<lbrakk>finite_graph_partition V {} k; finite V\<rbrakk> \<Longrightarrow> (\<Sum>R\<in>{}. \<Sum>S\<in>{}. real (card R * card S)) \<le> (real (card V))\<^sup>2
 2. \<And>x F V k. \<lbrakk>finite F; x \<notin> F; \<And>V k. \<lbrakk>finite_graph_partition V F k; finite V\<rbrakk> \<Longrightarrow> (\<Sum>R\<in>F. \<Sum>S\<in>F. real (card R * card S)) \<le> (real (card V))\<^sup>2; finite_graph_partition V (insert x F) k; finite V\<rbrakk> \<Longrightarrow> (\<Sum>R\<in>insert x F. \<Sum>S\<in>insert x F. real (card R * card S)) \<le> (real (card V))\<^sup>2
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
real (card X * card X) + real (2 * (card V - card X) * card X) + (\<Sum>R\<in>P. \<Sum>S\<in>P. real (card R * card S)) \<le> real (card X * card X) + real (2 * (card V - card X) * card X) + (real (card (V - X)))\<^sup>2

goal (2 subgoals):
 1. \<And>V k. \<lbrakk>finite_graph_partition V {} k; finite V\<rbrakk> \<Longrightarrow> (\<Sum>R\<in>{}. \<Sum>S\<in>{}. real (card R * card S)) \<le> (real (card V))\<^sup>2
 2. \<And>x F V k. \<lbrakk>finite F; x \<notin> F; \<And>V k. \<lbrakk>finite_graph_partition V F k; finite V\<rbrakk> \<Longrightarrow> (\<Sum>R\<in>F. \<Sum>S\<in>F. real (card R * card S)) \<le> (real (card V))\<^sup>2; finite_graph_partition V (insert x F) k; finite V\<rbrakk> \<Longrightarrow> (\<Sum>R\<in>insert x F. \<Sum>S\<in>insert x F. real (card R * card S)) \<le> (real (card V))\<^sup>2
[PROOF STEP]
have "\<dots> \<le> (real (card V))\<^sup>2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real (card X * card X) + real (2 * (card V - card X) * card X) + (real (card (V - X)))\<^sup>2 \<le> (real (card V))\<^sup>2
[PROOF STEP]
by (simp add: of_nat_diff C card_Diff_subset_Int algebra_simps power2_eq_square)
[PROOF STATE]
proof (state)
this:
real (card X * card X) + real (2 * (card V - card X) * card X) + (real (card (V - X)))\<^sup>2 \<le> (real (card V))\<^sup>2

goal (2 subgoals):
 1. \<And>V k. \<lbrakk>finite_graph_partition V {} k; finite V\<rbrakk> \<Longrightarrow> (\<Sum>R\<in>{}. \<Sum>S\<in>{}. real (card R * card S)) \<le> (real (card V))\<^sup>2
 2. \<And>x F V k. \<lbrakk>finite F; x \<notin> F; \<And>V k. \<lbrakk>finite_graph_partition V F k; finite V\<rbrakk> \<Longrightarrow> (\<Sum>R\<in>F. \<Sum>S\<in>F. real (card R * card S)) \<le> (real (card V))\<^sup>2; finite_graph_partition V (insert x F) k; finite V\<rbrakk> \<Longrightarrow> (\<Sum>R\<in>insert x F. \<Sum>S\<in>insert x F. real (card R * card S)) \<le> (real (card V))\<^sup>2
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(\<Sum>R\<in>insert X P. \<Sum>S\<in>insert X P. real (card R * card S)) \<le> (real (card V))\<^sup>2
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
(\<Sum>R\<in>insert X P. \<Sum>S\<in>insert X P. real (card R * card S)) \<le> (real (card V))\<^sup>2

goal (1 subgoal):
 1. (\<Sum>R\<in>insert X P. \<Sum>S\<in>insert X P. real (card R * card S)) \<le> (real (card V))\<^sup>2
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
(\<Sum>R\<in>insert X P. \<Sum>S\<in>insert X P. real (card R * card S)) \<le> (real (card V))\<^sup>2

goal (1 subgoal):
 1. \<And>V k. \<lbrakk>finite_graph_partition V {} k; finite V\<rbrakk> \<Longrightarrow> (\<Sum>R\<in>{}. \<Sum>S\<in>{}. real (card R * card S)) \<le> (real (card V))\<^sup>2
[PROOF STEP]
qed auto
[PROOF STATE]
proof (state)
this:
(\<Sum>R\<in>P. \<Sum>S\<in>P. real (card R * card S)) \<le> (real (card V))\<^sup>2

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma sorted_wrt_dist_last_take_mono:
  assumes "sorted_wrt_dist p ps" "n \<le> length ps" "0 < n"
  shows "dist (last (take n ps)) p \<le> dist (last ps) p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dist (last (take n ps)) p \<le> dist (last ps) p
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
sorted_wrt_dist p ps
n \<le> length ps
0 < n

goal (1 subgoal):
 1. dist (last (take n ps)) p \<le> dist (last ps) p
[PROOF STEP]
unfolding sorted_wrt_dist_def
[PROOF STATE]
proof (prove)
using this:
sorted_wrt (\<lambda>p\<^sub>0 p\<^sub>1. dist p\<^sub>0 p \<le> dist p\<^sub>1 p) ps
n \<le> length ps
0 < n

goal (1 subgoal):
 1. dist (last (take n ps)) p \<le> dist (last ps) p
[PROOF STEP]
by (induction ps arbitrary: n) (auto simp add: take_Cons')


[STATEMENT]
lemma fps_lr_inverse_fps_X_plus1:
  "fps_left_inverse (1 + fps_X) (1::'a::ring_1) = Abs_fps (\<lambda>n. (-1)^n)"
  "fps_right_inverse (1 + fps_X) (1::'a) = Abs_fps (\<lambda>n. (-1)^n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fps_left_inverse (1 + fps_X) (1::'a) = Abs_fps ((^) (- (1::'a))) &&& fps_right_inverse (1 + fps_X) (1::'a) = Abs_fps ((^) (- (1::'a)))
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. fps_left_inverse (1 + fps_X) (1::'a) = Abs_fps ((^) (- (1::'a)))
 2. fps_right_inverse (1 + fps_X) (1::'a) = Abs_fps ((^) (- (1::'a)))
[PROOF STEP]
show "fps_left_inverse (1 + fps_X) (1::'a) = Abs_fps (\<lambda>n. (-1)^n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fps_left_inverse (1 + fps_X) (1::'a) = Abs_fps ((^) (- (1::'a)))
[PROOF STEP]
proof (rule fps_ext)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n. fps_left_inverse (1 + fps_X) (1::'a) $ n = Abs_fps ((^) (- (1::'a))) $ n
[PROOF STEP]
fix n
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n. fps_left_inverse (1 + fps_X) (1::'a) $ n = Abs_fps ((^) (- (1::'a))) $ n
[PROOF STEP]
show "fps_left_inverse (1 + fps_X) (1::'a) $ n = Abs_fps (\<lambda>n. (-1)^n) $ n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fps_left_inverse (1 + fps_X) (1::'a) $ n = Abs_fps ((^) (- (1::'a))) $ n
[PROOF STEP]
proof (induct n rule: nat_less_induct)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n. \<forall>m<n. fps_left_inverse (1 + fps_X) (1::'a) $ m = Abs_fps ((^) (- (1::'a))) $ m \<Longrightarrow> fps_left_inverse (1 + fps_X) (1::'a) $ n = Abs_fps ((^) (- (1::'a))) $ n
[PROOF STEP]
case (1 n)
[PROOF STATE]
proof (state)
this:
\<forall>m<n. fps_left_inverse (1 + fps_X) (1::'a) $ m = Abs_fps ((^) (- (1::'a))) $ m

goal (1 subgoal):
 1. \<And>n. \<forall>m<n. fps_left_inverse (1 + fps_X) (1::'a) $ m = Abs_fps ((^) (- (1::'a))) $ m \<Longrightarrow> fps_left_inverse (1 + fps_X) (1::'a) $ n = Abs_fps ((^) (- (1::'a))) $ n
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fps_left_inverse (1 + fps_X) (1::'a) $ n = Abs_fps ((^) (- (1::'a))) $ n
[PROOF STEP]
proof (cases n)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. n = 0 \<Longrightarrow> fps_left_inverse (1 + fps_X) (1::'a) $ n = Abs_fps ((^) (- (1::'a))) $ n
 2. \<And>nat. n = Suc nat \<Longrightarrow> fps_left_inverse (1 + fps_X) (1::'a) $ n = Abs_fps ((^) (- (1::'a))) $ n
[PROOF STEP]
case (Suc m)
[PROOF STATE]
proof (state)
this:
n = Suc m

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> fps_left_inverse (1 + fps_X) (1::'a) $ n = Abs_fps ((^) (- (1::'a))) $ n
 2. \<And>nat. n = Suc nat \<Longrightarrow> fps_left_inverse (1 + fps_X) (1::'a) $ n = Abs_fps ((^) (- (1::'a))) $ n
[PROOF STEP]
have m: "n = Suc m"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n = Suc m
[PROOF STEP]
by fact
[PROOF STATE]
proof (state)
this:
n = Suc m

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> fps_left_inverse (1 + fps_X) (1::'a) $ n = Abs_fps ((^) (- (1::'a))) $ n
 2. \<And>nat. n = Suc nat \<Longrightarrow> fps_left_inverse (1 + fps_X) (1::'a) $ n = Abs_fps ((^) (- (1::'a))) $ n
[PROOF STEP]
from Suc 1
[PROOF STATE]
proof (chain)
picking this:
n = Suc m
\<forall>m<n. fps_left_inverse (1 + fps_X) (1::'a) $ m = Abs_fps ((^) (- (1::'a))) $ m
[PROOF STEP]
have
          A:  "fps_left_inverse (1 + fps_X) (1::'a) $ n =
                - (\<Sum>i=0..m. (- 1)^i * (1 + fps_X) $ (Suc m - i))"
[PROOF STATE]
proof (prove)
using this:
n = Suc m
\<forall>m<n. fps_left_inverse (1 + fps_X) (1::'a) $ m = Abs_fps ((^) (- (1::'a))) $ m

goal (1 subgoal):
 1. fps_left_inverse (1 + fps_X) (1::'a) $ n = - (\<Sum>i = 0..m. (- (1::'a)) ^ i * (1 + fps_X) $ (Suc m - i))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
fps_left_inverse (1 + fps_X) (1::'a) $ n = - (\<Sum>i = 0..m. (- (1::'a)) ^ i * (1 + fps_X) $ (Suc m - i))

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> fps_left_inverse (1 + fps_X) (1::'a) $ n = Abs_fps ((^) (- (1::'a))) $ n
 2. \<And>nat. n = Suc nat \<Longrightarrow> fps_left_inverse (1 + fps_X) (1::'a) $ n = Abs_fps ((^) (- (1::'a))) $ n
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fps_left_inverse (1 + fps_X) (1::'a) $ n = Abs_fps ((^) (- (1::'a))) $ n
[PROOF STEP]
proof (cases m)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. m = 0 \<Longrightarrow> fps_left_inverse (1 + fps_X) (1::'a) $ n = Abs_fps ((^) (- (1::'a))) $ n
 2. \<And>nat. m = Suc nat \<Longrightarrow> fps_left_inverse (1 + fps_X) (1::'a) $ n = Abs_fps ((^) (- (1::'a))) $ n
[PROOF STEP]
case (Suc l)
[PROOF STATE]
proof (state)
this:
m = Suc l

goal (2 subgoals):
 1. m = 0 \<Longrightarrow> fps_left_inverse (1 + fps_X) (1::'a) $ n = Abs_fps ((^) (- (1::'a))) $ n
 2. \<And>nat. m = Suc nat \<Longrightarrow> fps_left_inverse (1 + fps_X) (1::'a) $ n = Abs_fps ((^) (- (1::'a))) $ n
[PROOF STEP]
have "\<forall>i\<in>{0..l}. ((1::'a fps) + fps_X) $ (Suc (Suc l) - i) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>i\<in>{0..l}. (1 + fps_X) $ (Suc (Suc l) - i) = (0::'a)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<forall>i\<in>{0..l}. (1 + fps_X) $ (Suc (Suc l) - i) = (0::'a)

goal (2 subgoals):
 1. m = 0 \<Longrightarrow> fps_left_inverse (1 + fps_X) (1::'a) $ n = Abs_fps ((^) (- (1::'a))) $ n
 2. \<And>nat. m = Suc nat \<Longrightarrow> fps_left_inverse (1 + fps_X) (1::'a) $ n = Abs_fps ((^) (- (1::'a))) $ n
[PROOF STEP]
with Suc A m
[PROOF STATE]
proof (chain)
picking this:
m = Suc l
fps_left_inverse (1 + fps_X) (1::'a) $ n = - (\<Sum>i = 0..m. (- (1::'a)) ^ i * (1 + fps_X) $ (Suc m - i))
n = Suc m
\<forall>i\<in>{0..l}. (1 + fps_X) $ (Suc (Suc l) - i) = (0::'a)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
m = Suc l
fps_left_inverse (1 + fps_X) (1::'a) $ n = - (\<Sum>i = 0..m. (- (1::'a)) ^ i * (1 + fps_X) $ (Suc m - i))
n = Suc m
\<forall>i\<in>{0..l}. (1 + fps_X) $ (Suc (Suc l) - i) = (0::'a)

goal (1 subgoal):
 1. fps_left_inverse (1 + fps_X) (1::'a) $ n = Abs_fps ((^) (- (1::'a))) $ n
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
fps_left_inverse (1 + fps_X) (1::'a) $ n = Abs_fps ((^) (- (1::'a))) $ n

goal (1 subgoal):
 1. m = 0 \<Longrightarrow> fps_left_inverse (1 + fps_X) (1::'a) $ n = Abs_fps ((^) (- (1::'a))) $ n
[PROOF STEP]
qed (simp add: m A)
[PROOF STATE]
proof (state)
this:
fps_left_inverse (1 + fps_X) (1::'a) $ n = Abs_fps ((^) (- (1::'a))) $ n

goal (1 subgoal):
 1. n = 0 \<Longrightarrow> fps_left_inverse (1 + fps_X) (1::'a) $ n = Abs_fps ((^) (- (1::'a))) $ n
[PROOF STEP]
qed simp
[PROOF STATE]
proof (state)
this:
fps_left_inverse (1 + fps_X) (1::'a) $ n = Abs_fps ((^) (- (1::'a))) $ n

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
fps_left_inverse (1 + fps_X) (1::'a) $ n = Abs_fps ((^) (- (1::'a))) $ n

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
fps_left_inverse (1 + fps_X) (1::'a) = Abs_fps ((^) (- (1::'a)))

goal (1 subgoal):
 1. fps_right_inverse (1 + fps_X) (1::'a) = Abs_fps ((^) (- (1::'a)))
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
fps_left_inverse (1 + fps_X) (1::'a) = Abs_fps ((^) (- (1::'a)))

goal (1 subgoal):
 1. fps_right_inverse (1 + fps_X) (1::'a) = Abs_fps ((^) (- (1::'a)))
[PROOF STEP]
have
    "fps_right_inverse (1 + fps_X) (1::'a) = fps_left_inverse (1 + fps_X) 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fps_right_inverse (1 + fps_X) (1::'a) = fps_left_inverse (1 + fps_X) (1::'a)
[PROOF STEP]
by (intro fps_left_inverse_eq_fps_right_inverse[symmetric]) simp_all
[PROOF STATE]
proof (state)
this:
fps_right_inverse (1 + fps_X) (1::'a) = fps_left_inverse (1 + fps_X) (1::'a)

goal (1 subgoal):
 1. fps_right_inverse (1 + fps_X) (1::'a) = Abs_fps ((^) (- (1::'a)))
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
fps_left_inverse (1 + fps_X) (1::'a) = Abs_fps ((^) (- (1::'a)))
fps_right_inverse (1 + fps_X) (1::'a) = fps_left_inverse (1 + fps_X) (1::'a)
[PROOF STEP]
show "fps_right_inverse (1 + fps_X) (1::'a) = Abs_fps (\<lambda>n. (-1)^n)"
[PROOF STATE]
proof (prove)
using this:
fps_left_inverse (1 + fps_X) (1::'a) = Abs_fps ((^) (- (1::'a)))
fps_right_inverse (1 + fps_X) (1::'a) = fps_left_inverse (1 + fps_X) (1::'a)

goal (1 subgoal):
 1. fps_right_inverse (1 + fps_X) (1::'a) = Abs_fps ((^) (- (1::'a)))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
fps_right_inverse (1 + fps_X) (1::'a) = Abs_fps ((^) (- (1::'a)))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma ereal_one_not_less_zero_ereal[simp]: "\<not> 1 < (0::ereal)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<not> 1 < 0
[PROOF STEP]
by (simp add: zero_ereal_def)


[STATEMENT]
lemma ln_shifted_float:
  assumes "0 < m"
  shows "ln (Float m e) = ln 2 * (e + (bitlen m - 1)) + ln (Float m (- (bitlen m - 1)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ln (real_of_float (Float m e)) = ln 2 * real_of_int (e + (bitlen m - 1)) + ln (real_of_float (Float m (- (bitlen m - 1))))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. ln (real_of_float (Float m e)) = ln 2 * real_of_int (e + (bitlen m - 1)) + ln (real_of_float (Float m (- (bitlen m - 1))))
[PROOF STEP]
let ?B = "2^nat (bitlen m - 1)"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. ln (real_of_float (Float m e)) = ln 2 * real_of_int (e + (bitlen m - 1)) + ln (real_of_float (Float m (- (bitlen m - 1))))
[PROOF STEP]
define bl where "bl = bitlen m - 1"
[PROOF STATE]
proof (state)
this:
bl = bitlen m - 1

goal (1 subgoal):
 1. ln (real_of_float (Float m e)) = ln 2 * real_of_int (e + (bitlen m - 1)) + ln (real_of_float (Float m (- (bitlen m - 1))))
[PROOF STEP]
have "0 < real_of_int m" and "\<And>X. (0 :: real) < 2^X" and "0 < (2 :: real)" and "m \<noteq> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (0 < real_of_int m &&& (\<And>X. 0 < 2 ^ X)) &&& 0 < 2 &&& m \<noteq> 0
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
0 < m

goal (1 subgoal):
 1. (0 < real_of_int m &&& (\<And>X. 0 < 2 ^ X)) &&& 0 < 2 &&& m \<noteq> 0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
0 < real_of_int m
0 < 2 ^ ?X1
0 < 2
m \<noteq> 0

goal (1 subgoal):
 1. ln (real_of_float (Float m e)) = ln 2 * real_of_int (e + (bitlen m - 1)) + ln (real_of_float (Float m (- (bitlen m - 1))))
[PROOF STEP]
hence "0 \<le> bl"
[PROOF STATE]
proof (prove)
using this:
0 < real_of_int m
0 < 2 ^ ?X1
0 < 2
m \<noteq> 0

goal (1 subgoal):
 1. 0 \<le> bl
[PROOF STEP]
by (simp add: bitlen_alt_def bl_def)
[PROOF STATE]
proof (state)
this:
0 \<le> bl

goal (1 subgoal):
 1. ln (real_of_float (Float m e)) = ln 2 * real_of_int (e + (bitlen m - 1)) + ln (real_of_float (Float m (- (bitlen m - 1))))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ln (real_of_float (Float m e)) = ln 2 * real_of_int (e + (bitlen m - 1)) + ln (real_of_float (Float m (- (bitlen m - 1))))
[PROOF STEP]
proof (cases "0 \<le> e")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. 0 \<le> e \<Longrightarrow> ln (real_of_float (Float m e)) = ln 2 * real_of_int (e + (bitlen m - 1)) + ln (real_of_float (Float m (- (bitlen m - 1))))
 2. \<not> 0 \<le> e \<Longrightarrow> ln (real_of_float (Float m e)) = ln 2 * real_of_int (e + (bitlen m - 1)) + ln (real_of_float (Float m (- (bitlen m - 1))))
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
0 \<le> e

goal (2 subgoals):
 1. 0 \<le> e \<Longrightarrow> ln (real_of_float (Float m e)) = ln 2 * real_of_int (e + (bitlen m - 1)) + ln (real_of_float (Float m (- (bitlen m - 1))))
 2. \<not> 0 \<le> e \<Longrightarrow> ln (real_of_float (Float m e)) = ln 2 * real_of_int (e + (bitlen m - 1)) + ln (real_of_float (Float m (- (bitlen m - 1))))
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
0 \<le> e

goal (1 subgoal):
 1. ln (real_of_float (Float m e)) = ln 2 * real_of_int (e + (bitlen m - 1)) + ln (real_of_float (Float m (- (bitlen m - 1))))
[PROOF STEP]
unfolding bl_def[symmetric]
[PROOF STATE]
proof (prove)
using this:
0 \<le> e

goal (1 subgoal):
 1. ln (real_of_float (Float m e)) = ln 2 * real_of_int (e + bl) + ln (real_of_float (Float m (- bl)))
[PROOF STEP]
using \<open>0 < real_of_int m\<close> \<open>0 \<le> bl\<close>
[PROOF STATE]
proof (prove)
using this:
0 \<le> e
0 < real_of_int m
0 \<le> bl

goal (1 subgoal):
 1. ln (real_of_float (Float m e)) = ln 2 * real_of_int (e + bl) + ln (real_of_float (Float m (- bl)))
[PROOF STEP]
apply (simp add: ln_mult)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 \<le> e; 0 < m; 0 \<le> bl\<rbrakk> \<Longrightarrow> ln (2 powr real_of_int e) = ln 2 * (real_of_int e + real_of_int bl) + ln (2 powr - real_of_int bl)
[PROOF STEP]
apply (cases "e=0")
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>0 \<le> e; 0 < m; 0 \<le> bl; e = 0\<rbrakk> \<Longrightarrow> ln (2 powr real_of_int e) = ln 2 * (real_of_int e + real_of_int bl) + ln (2 powr - real_of_int bl)
 2. \<lbrakk>0 \<le> e; 0 < m; 0 \<le> bl; e \<noteq> 0\<rbrakk> \<Longrightarrow> ln (2 powr real_of_int e) = ln 2 * (real_of_int e + real_of_int bl) + ln (2 powr - real_of_int bl)
[PROOF STEP]
apply (cases "bl = 0", simp_all add: powr_minus ln_inverse ln_powr)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 \<le> e; 0 < m; 0 \<le> bl; e \<noteq> 0\<rbrakk> \<Longrightarrow> real_of_int e * ln 2 = ln 2 * (real_of_int e + real_of_int bl) - real_of_int bl * ln 2
[PROOF STEP]
apply (cases "bl = 0", simp_all add: powr_minus ln_inverse ln_powr field_simps)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
ln (real_of_float (Float m e)) = ln 2 * real_of_int (e + (bitlen m - 1)) + ln (real_of_float (Float m (- (bitlen m - 1))))

goal (1 subgoal):
 1. \<not> 0 \<le> e \<Longrightarrow> ln (real_of_float (Float m e)) = ln 2 * real_of_int (e + (bitlen m - 1)) + ln (real_of_float (Float m (- (bitlen m - 1))))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> 0 \<le> e \<Longrightarrow> ln (real_of_float (Float m e)) = ln 2 * real_of_int (e + (bitlen m - 1)) + ln (real_of_float (Float m (- (bitlen m - 1))))
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> 0 \<le> e

goal (1 subgoal):
 1. \<not> 0 \<le> e \<Longrightarrow> ln (real_of_float (Float m e)) = ln 2 * real_of_int (e + (bitlen m - 1)) + ln (real_of_float (Float m (- (bitlen m - 1))))
[PROOF STEP]
hence "0 < -e"
[PROOF STATE]
proof (prove)
using this:
\<not> 0 \<le> e

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

goal (1 subgoal):
 1. \<not> 0 \<le> e \<Longrightarrow> ln (real_of_float (Float m e)) = ln 2 * real_of_int (e + (bitlen m - 1)) + ln (real_of_float (Float m (- (bitlen m - 1))))
[PROOF STEP]
have lne: "ln (2 powr real_of_int e) = ln (inverse (2 powr - e))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ln (2 powr real_of_int e) = ln (inverse (2 powr real_of_int (- e)))
[PROOF STEP]
by (simp add: powr_minus)
[PROOF STATE]
proof (state)
this:
ln (2 powr real_of_int e) = ln (inverse (2 powr real_of_int (- e)))

goal (1 subgoal):
 1. \<not> 0 \<le> e \<Longrightarrow> ln (real_of_float (Float m e)) = ln 2 * real_of_int (e + (bitlen m - 1)) + ln (real_of_float (Float m (- (bitlen m - 1))))
[PROOF STEP]
hence pow_gt0: "(0::real) < 2^nat (-e)"
[PROOF STATE]
proof (prove)
using this:
ln (2 powr real_of_int e) = ln (inverse (2 powr real_of_int (- e)))

goal (1 subgoal):
 1. 0 < 2 ^ nat (- e)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
0 < 2 ^ nat (- e)

goal (1 subgoal):
 1. \<not> 0 \<le> e \<Longrightarrow> ln (real_of_float (Float m e)) = ln 2 * real_of_int (e + (bitlen m - 1)) + ln (real_of_float (Float m (- (bitlen m - 1))))
[PROOF STEP]
hence inv_gt0: "(0::real) < inverse (2^nat (-e))"
[PROOF STATE]
proof (prove)
using this:
0 < 2 ^ nat (- e)

goal (1 subgoal):
 1. 0 < inverse (2 ^ nat (- e))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
0 < inverse (2 ^ nat (- e))

goal (1 subgoal):
 1. \<not> 0 \<le> e \<Longrightarrow> ln (real_of_float (Float m e)) = ln 2 * real_of_int (e + (bitlen m - 1)) + ln (real_of_float (Float m (- (bitlen m - 1))))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ln (real_of_float (Float m e)) = ln 2 * real_of_int (e + (bitlen m - 1)) + ln (real_of_float (Float m (- (bitlen m - 1))))
[PROOF STEP]
using False
[PROOF STATE]
proof (prove)
using this:
\<not> 0 \<le> e

goal (1 subgoal):
 1. ln (real_of_float (Float m e)) = ln 2 * real_of_int (e + (bitlen m - 1)) + ln (real_of_float (Float m (- (bitlen m - 1))))
[PROOF STEP]
unfolding bl_def[symmetric]
[PROOF STATE]
proof (prove)
using this:
\<not> 0 \<le> e

goal (1 subgoal):
 1. ln (real_of_float (Float m e)) = ln 2 * real_of_int (e + bl) + ln (real_of_float (Float m (- bl)))
[PROOF STEP]
using \<open>0 < real_of_int m\<close> \<open>0 \<le> bl\<close>
[PROOF STATE]
proof (prove)
using this:
\<not> 0 \<le> e
0 < real_of_int m
0 \<le> bl

goal (1 subgoal):
 1. ln (real_of_float (Float m e)) = ln 2 * real_of_int (e + bl) + ln (real_of_float (Float m (- bl)))
[PROOF STEP]
by (auto simp add: lne ln_mult ln_powr ln_div field_simps)
[PROOF STATE]
proof (state)
this:
ln (real_of_float (Float m e)) = ln 2 * real_of_int (e + (bitlen m - 1)) + ln (real_of_float (Float m (- (bitlen m - 1))))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
ln (real_of_float (Float m e)) = ln 2 * real_of_int (e + (bitlen m - 1)) + ln (real_of_float (Float m (- (bitlen m - 1))))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma Collect_congs_eq_iff[simp]:
  "Collect ((\<cong>) x) = Collect ((\<cong>) y) \<longleftrightarrow> (x \<cong> (y::'a list))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (Collect ((\<cong>) x) = Collect ((\<cong>) y)) = x \<cong> y
[PROOF STEP]
using eq_equiv_class_iff2[OF equiv_EqF]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?x \<in> UNIV; ?y \<in> UNIV\<rbrakk> \<Longrightarrow> ({?x} // {\<cong>} = {?y} // {\<cong>}) = ((?x, ?y) \<in> {\<cong>})

goal (1 subgoal):
 1. (Collect ((\<cong>) x) = Collect ((\<cong>) y)) = x \<cong> y
[PROOF STEP]
apply(simp add: quotient_def Iso_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>x y. ({(x, y). x \<cong> y} `` {x} = {(x, y). x \<cong> y} `` {y}) = x \<cong> y) \<Longrightarrow> (Collect ((\<cong>) x) = Collect ((\<cong>) y)) = x \<cong> y
[PROOF STEP]
apply blast
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma \<P>\<^sub>1_mono[intro]: "a \<le> b \<Longrightarrow> \<P>\<^sub>1 p a \<le> \<P>\<^sub>1 p b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a \<le> b \<Longrightarrow> blinfun_apply (\<P>\<^sub>1 p) a \<le> blinfun_apply (\<P>\<^sub>1 p) b
[PROOF STEP]
using \<P>\<^sub>1_pos[of "b - a"]
[PROOF STATE]
proof (prove)
using this:
0 \<le> b - a \<Longrightarrow> 0 \<le> blinfun_apply (\<P>\<^sub>1 ?d) (b - a)

goal (1 subgoal):
 1. a \<le> b \<Longrightarrow> blinfun_apply (\<P>\<^sub>1 p) a \<le> blinfun_apply (\<P>\<^sub>1 p) b
[PROOF STEP]
by (auto simp: blinfun.diff_right)


[STATEMENT]
lemma older_seniors_card_less:
  "card (older_seniors x n) \<le> card (older_seniors y n) \<longleftrightarrow> older_seniors x n \<subseteq> older_seniors y n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (card (older_seniors x n) \<le> card (older_seniors y n)) = (older_seniors x n \<subseteq> older_seniors y n)
[PROOF STEP]
by (metis not_le older_seniors_card_mono older_seniors_cases_subseteq older_seniors_psubset_card_mono subset_not_subset_eq)


[STATEMENT]
lemma powreal_eq_one_iff [simp]:
  "a pow\<^sub>\<real> x = 1 \<longleftrightarrow> x = 0" if "a > 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (a pow\<^sub>\<real> x = 1) = (x = 0)
[PROOF STEP]
using powreal_inject_exp1 that
[PROOF STATE]
proof (prove)
using this:
1 < ?a \<Longrightarrow> (?a pow\<^sub>\<real> ?r = ?a pow\<^sub>\<real> ?s) = (?s = ?r)
1 < a

goal (1 subgoal):
 1. (a pow\<^sub>\<real> x = 1) = (x = 0)
[PROOF STEP]
by fastforce


[STATEMENT]
lemma suminf_add: "summable f \<Longrightarrow> summable g \<Longrightarrow> suminf f + suminf g = (\<Sum>n. f n + g n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>summable f; summable g\<rbrakk> \<Longrightarrow> suminf f + suminf g = (\<Sum>n. f n + g n)
[PROOF STEP]
by (intro sums_unique sums_add summable_sums)


[STATEMENT]
lemma infsetsum_Un_Int:
  assumes "f abs_summable_on (A \<union> B)"
  shows   "infsetsum f (A \<union> B) = infsetsum f A + infsetsum f B - infsetsum f (A \<inter> B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. infsetsum f (A \<union> B) = infsetsum f A + infsetsum f B - infsetsum f (A \<inter> B)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. infsetsum f (A \<union> B) = infsetsum f A + infsetsum f B - infsetsum f (A \<inter> B)
[PROOF STEP]
have "A \<union> B = A \<union> (B - A \<inter> B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A \<union> B = A \<union> (B - A \<inter> B)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
A \<union> B = A \<union> (B - A \<inter> B)

goal (1 subgoal):
 1. infsetsum f (A \<union> B) = infsetsum f A + infsetsum f B - infsetsum f (A \<inter> B)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
A \<union> B = A \<union> (B - A \<inter> B)

goal (1 subgoal):
 1. infsetsum f (A \<union> B) = infsetsum f A + infsetsum f B - infsetsum f (A \<inter> B)
[PROOF STEP]
have "infsetsum f \<dots> = infsetsum f A + infsetsum f (B - A \<inter> B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. infsetsum f (A \<union> (B - A \<inter> B)) = infsetsum f A + infsetsum f (B - A \<inter> B)
[PROOF STEP]
by (intro infsetsum_Un_disjoint abs_summable_on_subset[OF assms]) auto
[PROOF STATE]
proof (state)
this:
infsetsum f (A \<union> (B - A \<inter> B)) = infsetsum f A + infsetsum f (B - A \<inter> B)

goal (1 subgoal):
 1. infsetsum f (A \<union> B) = infsetsum f A + infsetsum f B - infsetsum f (A \<inter> B)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
infsetsum f (A \<union> (B - A \<inter> B)) = infsetsum f A + infsetsum f (B - A \<inter> B)

goal (1 subgoal):
 1. infsetsum f (A \<union> B) = infsetsum f A + infsetsum f B - infsetsum f (A \<inter> B)
[PROOF STEP]
have "infsetsum f (B - A \<inter> B) = infsetsum f B - infsetsum f (A \<inter> B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. infsetsum f (B - A \<inter> B) = infsetsum f B - infsetsum f (A \<inter> B)
[PROOF STEP]
by (intro infsetsum_Diff abs_summable_on_subset[OF assms]) auto
[PROOF STATE]
proof (state)
this:
infsetsum f (B - A \<inter> B) = infsetsum f B - infsetsum f (A \<inter> B)

goal (1 subgoal):
 1. infsetsum f (A \<union> B) = infsetsum f A + infsetsum f B - infsetsum f (A \<inter> B)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
infsetsum f (A \<union> B) = infsetsum f A + (infsetsum f B - infsetsum f (A \<inter> B))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
infsetsum f (A \<union> B) = infsetsum f A + (infsetsum f B - infsetsum f (A \<inter> B))

goal (1 subgoal):
 1. infsetsum f (A \<union> B) = infsetsum f A + infsetsum f B - infsetsum f (A \<inter> B)
[PROOF STEP]
by (simp add: algebra_simps)
[PROOF STATE]
proof (state)
this:
infsetsum f (A \<union> B) = infsetsum f A + infsetsum f B - infsetsum f (A \<inter> B)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma gauss_lemma:
  fixes p q :: "'a :: ufd fract poly"
  shows "content_ff (p * q) =dff content_ff p * content_ff q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. content_ff (p * q) =dff content_ff p * content_ff q
[PROOF STEP]
proof (cases "p = 0 \<or> q = 0")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. p = 0 \<or> q = 0 \<Longrightarrow> content_ff (p * q) =dff content_ff p * content_ff q
 2. \<not> (p = 0 \<or> q = 0) \<Longrightarrow> content_ff (p * q) =dff content_ff p * content_ff q
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> (p = 0 \<or> q = 0)

goal (2 subgoals):
 1. p = 0 \<or> q = 0 \<Longrightarrow> content_ff (p * q) =dff content_ff p * content_ff q
 2. \<not> (p = 0 \<or> q = 0) \<Longrightarrow> content_ff (p * q) =dff content_ff p * content_ff q
[PROOF STEP]
hence p: "p \<noteq> 0" and q: "q \<noteq> 0"
[PROOF STATE]
proof (prove)
using this:
\<not> (p = 0 \<or> q = 0)

goal (1 subgoal):
 1. p \<noteq> 0 &&& q \<noteq> 0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
p \<noteq> 0
q \<noteq> 0

goal (2 subgoals):
 1. p = 0 \<or> q = 0 \<Longrightarrow> content_ff (p * q) =dff content_ff p * content_ff q
 2. \<not> (p = 0 \<or> q = 0) \<Longrightarrow> content_ff (p * q) =dff content_ff p * content_ff q
[PROOF STEP]
let ?c = "content_ff :: 'a fract poly \<Rightarrow> 'a fract"
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. p = 0 \<or> q = 0 \<Longrightarrow> content_ff (p * q) =dff content_ff p * content_ff q
 2. \<not> (p = 0 \<or> q = 0) \<Longrightarrow> content_ff (p * q) =dff content_ff p * content_ff q
[PROOF STEP]
{
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. p = 0 \<or> q = 0 \<Longrightarrow> content_ff (p * q) =dff content_ff p * content_ff q
 2. \<not> (p = 0 \<or> q = 0) \<Longrightarrow> content_ff (p * q) =dff content_ff p * content_ff q
[PROOF STEP]
fix p q :: "'a fract poly"
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. p = 0 \<or> q = 0 \<Longrightarrow> content_ff (p * q) =dff content_ff p * content_ff q
 2. \<not> (p = 0 \<or> q = 0) \<Longrightarrow> content_ff (p * q) =dff content_ff p * content_ff q
[PROOF STEP]
assume cp1: "?c p =dff 1" and cq1: "?c q =dff 1"
[PROOF STATE]
proof (state)
this:
content_ff p =dff 1
content_ff q =dff 1

goal (2 subgoals):
 1. p = 0 \<or> q = 0 \<Longrightarrow> content_ff (p * q) =dff content_ff p * content_ff q
 2. \<not> (p = 0 \<or> q = 0) \<Longrightarrow> content_ff (p * q) =dff content_ff p * content_ff q
[PROOF STEP]
define ip where "ip \<equiv> map_poly inv_embed p"
[PROOF STATE]
proof (state)
this:
ip \<equiv> map_poly inv_embed p

goal (2 subgoals):
 1. p = 0 \<or> q = 0 \<Longrightarrow> content_ff (p * q) =dff content_ff p * content_ff q
 2. \<not> (p = 0 \<or> q = 0) \<Longrightarrow> content_ff (p * q) =dff content_ff p * content_ff q
[PROOF STEP]
define iq where "iq \<equiv> map_poly inv_embed q"
[PROOF STATE]
proof (state)
this:
iq \<equiv> map_poly inv_embed q

goal (2 subgoals):
 1. p = 0 \<or> q = 0 \<Longrightarrow> content_ff (p * q) =dff content_ff p * content_ff q
 2. \<not> (p = 0 \<or> q = 0) \<Longrightarrow> content_ff (p * q) =dff content_ff p * content_ff q
[PROOF STEP]
interpret map_poly_hom: map_poly_comm_ring_hom to_fract
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map_poly_comm_ring_hom to_fract
[PROOF STEP]
..
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. p = 0 \<or> q = 0 \<Longrightarrow> content_ff (p * q) =dff content_ff p * content_ff q
 2. \<not> (p = 0 \<or> q = 0) \<Longrightarrow> content_ff (p * q) =dff content_ff p * content_ff q
[PROOF STEP]
from content_ff_1_coeffs_to_fract[OF cp1]
[PROOF STATE]
proof (chain)
picking this:
set (coeffs p) \<subseteq> range to_fract
[PROOF STEP]
have cp: "set (coeffs p) \<subseteq> range to_fract"
[PROOF STATE]
proof (prove)
using this:
set (coeffs p) \<subseteq> range to_fract

goal (1 subgoal):
 1. set (coeffs p) \<subseteq> range to_fract
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
set (coeffs p) \<subseteq> range to_fract

goal (2 subgoals):
 1. p = 0 \<or> q = 0 \<Longrightarrow> content_ff (p * q) =dff content_ff p * content_ff q
 2. \<not> (p = 0 \<or> q = 0) \<Longrightarrow> content_ff (p * q) =dff content_ff p * content_ff q
[PROOF STEP]
from content_ff_1_coeffs_to_fract[OF cq1]
[PROOF STATE]
proof (chain)
picking this:
set (coeffs q) \<subseteq> range to_fract
[PROOF STEP]
have cq: "set (coeffs q) \<subseteq> range to_fract"
[PROOF STATE]
proof (prove)
using this:
set (coeffs q) \<subseteq> range to_fract

goal (1 subgoal):
 1. set (coeffs q) \<subseteq> range to_fract
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
set (coeffs q) \<subseteq> range to_fract

goal (2 subgoals):
 1. p = 0 \<or> q = 0 \<Longrightarrow> content_ff (p * q) =dff content_ff p * content_ff q
 2. \<not> (p = 0 \<or> q = 0) \<Longrightarrow> content_ff (p * q) =dff content_ff p * content_ff q
[PROOF STEP]
have ip: "p = map_poly to_fract ip"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. p = map_poly to_fract ip
[PROOF STEP]
unfolding ip_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. p = map_poly to_fract (map_poly inv_embed p)
[PROOF STEP]
by (rule range_to_fract_embed_poly[OF cp])
[PROOF STATE]
proof (state)
this:
p = map_poly to_fract ip

goal (2 subgoals):
 1. p = 0 \<or> q = 0 \<Longrightarrow> content_ff (p * q) =dff content_ff p * content_ff q
 2. \<not> (p = 0 \<or> q = 0) \<Longrightarrow> content_ff (p * q) =dff content_ff p * content_ff q
[PROOF STEP]
have iq: "q = map_poly to_fract iq"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. q = map_poly to_fract iq
[PROOF STEP]
unfolding iq_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. q = map_poly to_fract (map_poly inv_embed q)
[PROOF STEP]
by (rule range_to_fract_embed_poly[OF cq])
[PROOF STATE]
proof (state)
this:
q = map_poly to_fract iq

goal (2 subgoals):
 1. p = 0 \<or> q = 0 \<Longrightarrow> content_ff (p * q) =dff content_ff p * content_ff q
 2. \<not> (p = 0 \<or> q = 0) \<Longrightarrow> content_ff (p * q) =dff content_ff p * content_ff q
[PROOF STEP]
have cpq0: "?c (p * q) \<noteq> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. content_ff (p * q) \<noteq> 0
[PROOF STEP]
unfolding content_ff_0_iff
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. p * q \<noteq> 0
[PROOF STEP]
using cp1 cq1 content_ff_eq_dff_nonzero[of _ 1]
[PROOF STATE]
proof (prove)
using this:
content_ff p =dff 1
content_ff q =dff 1
\<lbrakk>content_ff ?p =dff 1; 1 \<noteq> 0\<rbrakk> \<Longrightarrow> ?p \<noteq> 0

goal (1 subgoal):
 1. p * q \<noteq> 0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
content_ff (p * q) \<noteq> 0

goal (2 subgoals):
 1. p = 0 \<or> q = 0 \<Longrightarrow> content_ff (p * q) =dff content_ff p * content_ff q
 2. \<not> (p = 0 \<or> q = 0) \<Longrightarrow> content_ff (p * q) =dff content_ff p * content_ff q
[PROOF STEP]
have cpq: "set (coeffs (p * q)) \<subseteq> range to_fract"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set (coeffs (p * q)) \<subseteq> range to_fract
[PROOF STEP]
unfolding ip iq
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set (coeffs (map_poly to_fract ip * map_poly to_fract iq)) \<subseteq> range to_fract
[PROOF STEP]
unfolding map_poly_hom.hom_mult[symmetric] to_fract_hom.coeffs_map_poly_hom
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set (map to_fract (coeffs (ip * iq))) \<subseteq> range to_fract
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
set (coeffs (p * q)) \<subseteq> range to_fract

goal (2 subgoals):
 1. p = 0 \<or> q = 0 \<Longrightarrow> content_ff (p * q) =dff content_ff p * content_ff q
 2. \<not> (p = 0 \<or> q = 0) \<Longrightarrow> content_ff (p * q) =dff content_ff p * content_ff q
[PROOF STEP]
have ctnt: "?c (p * q) \<in> range to_fract"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. content_ff (p * q) \<in> range to_fract
[PROOF STEP]
using content_ff_to_fract[OF cpq]
[PROOF STATE]
proof (prove)
using this:
content_ff (p * q) \<in> range to_fract

goal (1 subgoal):
 1. content_ff (p * q) \<in> range to_fract
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
content_ff (p * q) \<in> range to_fract

goal (2 subgoals):
 1. p = 0 \<or> q = 0 \<Longrightarrow> content_ff (p * q) =dff content_ff p * content_ff q
 2. \<not> (p = 0 \<or> q = 0) \<Longrightarrow> content_ff (p * q) =dff content_ff p * content_ff q
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
content_ff (p * q) \<in> range to_fract
[PROOF STEP]
obtain cpq where id: "?c (p * q) = to_fract cpq"
[PROOF STATE]
proof (prove)
using this:
content_ff (p * q) \<in> range to_fract

goal (1 subgoal):
 1. (\<And>cpq. content_ff (p * q) = to_fract cpq \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
content_ff (p * q) = to_fract cpq

goal (2 subgoals):
 1. p = 0 \<or> q = 0 \<Longrightarrow> content_ff (p * q) =dff content_ff p * content_ff q
 2. \<not> (p = 0 \<or> q = 0) \<Longrightarrow> content_ff (p * q) =dff content_ff p * content_ff q
[PROOF STEP]
have dvd: "divides_ff 1 (?c (p * q))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. divides_ff 1 (content_ff (p * q))
[PROOF STEP]
using ctnt
[PROOF STATE]
proof (prove)
using this:
content_ff (p * q) \<in> range to_fract

goal (1 subgoal):
 1. divides_ff 1 (content_ff (p * q))
[PROOF STEP]
unfolding divides_ff_def
[PROOF STATE]
proof (prove)
using this:
content_ff (p * q) \<in> range to_fract

goal (1 subgoal):
 1. \<exists>r. content_ff (p * q) = 1 * to_fract r
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
divides_ff 1 (content_ff (p * q))

goal (2 subgoals):
 1. p = 0 \<or> q = 0 \<Longrightarrow> content_ff (p * q) =dff content_ff p * content_ff q
 2. \<not> (p = 0 \<or> q = 0) \<Longrightarrow> content_ff (p * q) =dff content_ff p * content_ff q
[PROOF STEP]
from cpq0[unfolded id]
[PROOF STATE]
proof (chain)
picking this:
to_fract cpq \<noteq> 0
[PROOF STEP]
have cpq0: "cpq \<noteq> 0"
[PROOF STATE]
proof (prove)
using this:
to_fract cpq \<noteq> 0

goal (1 subgoal):
 1. cpq \<noteq> (0::'a)
[PROOF STEP]
unfolding to_fract_def Zero_fract_def
[PROOF STATE]
proof (prove)
using this:
Fraction_Field.Fract cpq (1::'a) \<noteq> Fraction_Field.Fract (0::'a) (1::'a)

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

goal (2 subgoals):
 1. p = 0 \<or> q = 0 \<Longrightarrow> content_ff (p * q) =dff content_ff p * content_ff q
 2. \<not> (p = 0 \<or> q = 0) \<Longrightarrow> content_ff (p * q) =dff content_ff p * content_ff q
[PROOF STEP]
hence cpqM: "cpq \<in> carrier mk_monoid"
[PROOF STATE]
proof (prove)
using this:
cpq \<noteq> (0::'a)

goal (1 subgoal):
 1. cpq \<in> carrier mk_monoid
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
cpq \<in> carrier mk_monoid

goal (2 subgoals):
 1. p = 0 \<or> q = 0 \<Longrightarrow> content_ff (p * q) =dff content_ff p * content_ff q
 2. \<not> (p = 0 \<or> q = 0) \<Longrightarrow> content_ff (p * q) =dff content_ff p * content_ff q
[PROOF STEP]
have "?c (p * q) =dff 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. content_ff (p * q) =dff 1
[PROOF STEP]
proof (rule ccontr)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> content_ff (p * q) =dff 1 \<Longrightarrow> False
[PROOF STEP]
assume "\<not> ?c (p * q) =dff 1"
[PROOF STATE]
proof (state)
this:
\<not> content_ff (p * q) =dff 1

goal (1 subgoal):
 1. \<not> content_ff (p * q) =dff 1 \<Longrightarrow> False
[PROOF STEP]
with dvd
[PROOF STATE]
proof (chain)
picking this:
divides_ff 1 (content_ff (p * q))
\<not> content_ff (p * q) =dff 1
[PROOF STEP]
have "\<not> divides_ff (?c (p * q)) 1"
[PROOF STATE]
proof (prove)
using this:
divides_ff 1 (content_ff (p * q))
\<not> content_ff (p * q) =dff 1

goal (1 subgoal):
 1. \<not> divides_ff (content_ff (p * q)) 1
[PROOF STEP]
unfolding eq_dff_def
[PROOF STATE]
proof (prove)
using this:
divides_ff 1 (content_ff (p * q))
\<not> (divides_ff (content_ff (p * q)) 1 \<and> divides_ff 1 (content_ff (p * q)))

goal (1 subgoal):
 1. \<not> divides_ff (content_ff (p * q)) 1
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<not> divides_ff (content_ff (p * q)) 1

goal (1 subgoal):
 1. \<not> content_ff (p * q) =dff 1 \<Longrightarrow> False
[PROOF STEP]
from this[unfolded id divides_ff_def]
[PROOF STATE]
proof (chain)
picking this:
\<nexists>r. 1 = to_fract cpq * to_fract r
[PROOF STEP]
have cpq: "\<And> r. cpq * r \<noteq> 1"
[PROOF STATE]
proof (prove)
using this:
\<nexists>r. 1 = to_fract cpq * to_fract r

goal (1 subgoal):
 1. \<And>r. cpq * r \<noteq> (1::'a)
[PROOF STEP]
by (auto simp: to_fract_def One_fract_def eq_fract)
[PROOF STATE]
proof (state)
this:
cpq * ?r1 \<noteq> (1::'a)

goal (1 subgoal):
 1. \<not> content_ff (p * q) =dff 1 \<Longrightarrow> False
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
cpq * ?r1 \<noteq> (1::'a)
[PROOF STEP]
have cpq1: "\<not> cpq dvd 1"
[PROOF STATE]
proof (prove)
using this:
cpq * ?r1 \<noteq> (1::'a)

goal (1 subgoal):
 1. \<not> cpq dvd (1::'a)
[PROOF STEP]
by (auto elim:dvdE simp:ac_simps)
[PROOF STATE]
proof (state)
this:
\<not> cpq dvd (1::'a)

goal (1 subgoal):
 1. \<not> content_ff (p * q) =dff 1 \<Longrightarrow> False
[PROOF STEP]
from mset_factors_exist[OF cpq0 cpq1]
[PROOF STATE]
proof (chain)
picking this:
\<exists>F. mset_factors F cpq
[PROOF STEP]
obtain F where F: "mset_factors F cpq"
[PROOF STATE]
proof (prove)
using this:
\<exists>F. mset_factors F cpq

goal (1 subgoal):
 1. (\<And>F. mset_factors F cpq \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
mset_factors F cpq

goal (1 subgoal):
 1. \<not> content_ff (p * q) =dff 1 \<Longrightarrow> False
[PROOF STEP]
have "F \<noteq> {#}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. F \<noteq> {#}
[PROOF STEP]
using F
[PROOF STATE]
proof (prove)
using this:
mset_factors F cpq

goal (1 subgoal):
 1. F \<noteq> {#}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
F \<noteq> {#}

goal (1 subgoal):
 1. \<not> content_ff (p * q) =dff 1 \<Longrightarrow> False
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
F \<noteq> {#}
[PROOF STEP]
obtain f where f: "f \<in># F"
[PROOF STATE]
proof (prove)
using this:
F \<noteq> {#}

goal (1 subgoal):
 1. (\<And>f. f \<in># F \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
f \<in># F

goal (1 subgoal):
 1. \<not> content_ff (p * q) =dff 1 \<Longrightarrow> False
[PROOF STEP]
with F
[PROOF STATE]
proof (chain)
picking this:
mset_factors F cpq
f \<in># F
[PROOF STEP]
have irrf: "irreducible f" and f0: "f \<noteq> 0"
[PROOF STATE]
proof (prove)
using this:
mset_factors F cpq
f \<in># F

goal (1 subgoal):
 1. irreducible f &&& f \<noteq> (0::'a)
[PROOF STEP]
by (auto dest: mset_factorsD)
[PROOF STATE]
proof (state)
this:
irreducible f
f \<noteq> (0::'a)

goal (1 subgoal):
 1. \<not> content_ff (p * q) =dff 1 \<Longrightarrow> False
[PROOF STEP]
from irrf
[PROOF STATE]
proof (chain)
picking this:
irreducible f
[PROOF STEP]
have pf: "prime_elem f"
[PROOF STATE]
proof (prove)
using this:
irreducible f

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

goal (1 subgoal):
 1. \<not> content_ff (p * q) =dff 1 \<Longrightarrow> False
[PROOF STEP]
note * = this[unfolded prime_elem_def]
[PROOF STATE]
proof (state)
this:
f \<noteq> (0::'a) \<and> \<not> f dvd (1::'a) \<and> (\<forall>a b. f dvd a * b \<longrightarrow> f dvd a \<or> f dvd b)

goal (1 subgoal):
 1. \<not> content_ff (p * q) =dff 1 \<Longrightarrow> False
[PROOF STEP]
from *
[PROOF STATE]
proof (chain)
picking this:
f \<noteq> (0::'a) \<and> \<not> f dvd (1::'a) \<and> (\<forall>a b. f dvd a * b \<longrightarrow> f dvd a \<or> f dvd b)
[PROOF STEP]
have no_unit: "\<not> f dvd 1"
[PROOF STATE]
proof (prove)
using this:
f \<noteq> (0::'a) \<and> \<not> f dvd (1::'a) \<and> (\<forall>a b. f dvd a * b \<longrightarrow> f dvd a \<or> f dvd b)

goal (1 subgoal):
 1. \<not> f dvd (1::'a)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<not> f dvd (1::'a)

goal (1 subgoal):
 1. \<not> content_ff (p * q) =dff 1 \<Longrightarrow> False
[PROOF STEP]
from * f0
[PROOF STATE]
proof (chain)
picking this:
f \<noteq> (0::'a) \<and> \<not> f dvd (1::'a) \<and> (\<forall>a b. f dvd a * b \<longrightarrow> f dvd a \<or> f dvd b)
f \<noteq> (0::'a)
[PROOF STEP]
have prime: "\<And> a b. f dvd a * b \<Longrightarrow> f dvd a \<or> f dvd b"
[PROOF STATE]
proof (prove)
using this:
f \<noteq> (0::'a) \<and> \<not> f dvd (1::'a) \<and> (\<forall>a b. f dvd a * b \<longrightarrow> f dvd a \<or> f dvd b)
f \<noteq> (0::'a)

goal (1 subgoal):
 1. \<And>a b. f dvd a * b \<Longrightarrow> f dvd a \<or> f dvd b
[PROOF STEP]
unfolding dvd_def
[PROOF STATE]
proof (prove)
using this:
f \<noteq> (0::'a) \<and> (\<nexists>k. (1::'a) = f * k) \<and> (\<forall>a b. (\<exists>k. a * b = f * k) \<longrightarrow> (\<exists>k. a = f * k) \<or> (\<exists>k. b = f * k))
f \<noteq> (0::'a)

goal (1 subgoal):
 1. \<And>a b. \<exists>k. a * b = f * k \<Longrightarrow> (\<exists>k. a = f * k) \<or> (\<exists>k. b = f * k)
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
f dvd ?a1 * ?b1 \<Longrightarrow> f dvd ?a1 \<or> f dvd ?b1

goal (1 subgoal):
 1. \<not> content_ff (p * q) =dff 1 \<Longrightarrow> False
[PROOF STEP]
let ?f = "to_fract f"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> content_ff (p * q) =dff 1 \<Longrightarrow> False
[PROOF STEP]
from F f
[PROOF STATE]
proof (chain)
picking this:
mset_factors F cpq
f \<in># F
[PROOF STEP]
have fdvd: "f dvd cpq"
[PROOF STATE]
proof (prove)
using this:
mset_factors F cpq
f \<in># F

goal (1 subgoal):
 1. f dvd cpq
[PROOF STEP]
by (auto intro:mset_factors_imp_dvd)
[PROOF STATE]
proof (state)
this:
f dvd cpq

goal (1 subgoal):
 1. \<not> content_ff (p * q) =dff 1 \<Longrightarrow> False
[PROOF STEP]
hence "divides_ff ?f (to_fract cpq)"
[PROOF STATE]
proof (prove)
using this:
f dvd cpq

goal (1 subgoal):
 1. divides_ff (to_fract f) (to_fract cpq)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
divides_ff (to_fract f) (to_fract cpq)

goal (1 subgoal):
 1. \<not> content_ff (p * q) =dff 1 \<Longrightarrow> False
[PROOF STEP]
from divides_ff_trans[OF this, folded id, OF content_ff_divides_ff]
[PROOF STATE]
proof (chain)
picking this:
?z \<in> set (coeffs (p * q)) \<Longrightarrow> divides_ff (to_fract f) ?z
[PROOF STEP]
have dvd: "\<And> z. z \<in> set (coeffs (p * q)) \<Longrightarrow> divides_ff ?f z"
[PROOF STATE]
proof (prove)
using this:
?z \<in> set (coeffs (p * q)) \<Longrightarrow> divides_ff (to_fract f) ?z

goal (1 subgoal):
 1. \<And>z. z \<in> set (coeffs (p * q)) \<Longrightarrow> divides_ff (to_fract f) z
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
?z1 \<in> set (coeffs (p * q)) \<Longrightarrow> divides_ff (to_fract f) ?z1

goal (1 subgoal):
 1. \<not> content_ff (p * q) =dff 1 \<Longrightarrow> False
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
?z1 \<in> set (coeffs (p * q)) \<Longrightarrow> divides_ff (to_fract f) ?z1

goal (1 subgoal):
 1. \<not> content_ff (p * q) =dff 1 \<Longrightarrow> False
[PROOF STEP]
fix p :: "'a fract poly"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> content_ff (pa__ * q) =dff 1 \<Longrightarrow> False
[PROOF STEP]
assume cp: "?c p =dff 1"
[PROOF STATE]
proof (state)
this:
content_ff p =dff 1

goal (1 subgoal):
 1. \<not> content_ff (pa__ * q) =dff 1 \<Longrightarrow> False
[PROOF STEP]
let ?P = "\<lambda> i. \<not> divides_ff ?f (coeff p i)"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> content_ff (pa__ * q) =dff 1 \<Longrightarrow> False
[PROOF STEP]
{
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> content_ff (pa__ * q) =dff 1 \<Longrightarrow> False
[PROOF STEP]
assume "\<forall> c \<in> set (coeffs p). divides_ff ?f c"
[PROOF STATE]
proof (state)
this:
\<forall>c\<in>set (coeffs p). divides_ff (to_fract f) c

goal (1 subgoal):
 1. \<not> content_ff (pa__ * q) =dff 1 \<Longrightarrow> False
[PROOF STEP]
hence n: "divides_ff ?f (?c p)"
[PROOF STATE]
proof (prove)
using this:
\<forall>c\<in>set (coeffs p). divides_ff (to_fract f) c

goal (1 subgoal):
 1. divides_ff (to_fract f) (content_ff p)
[PROOF STEP]
unfolding content_ff_iff
[PROOF STATE]
proof (prove)
using this:
\<forall>c\<in>set (coeffs p). divides_ff (to_fract f) c

goal (1 subgoal):
 1. Ball (set (coeffs p)) (divides_ff (to_fract f))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
divides_ff (to_fract f) (content_ff p)

goal (1 subgoal):
 1. \<not> content_ff (pa__ * q) =dff 1 \<Longrightarrow> False
[PROOF STEP]
from divides_ff_trans[OF this] cp[unfolded eq_dff_def]
[PROOF STATE]
proof (chain)
picking this:
divides_ff (content_ff p) ?z \<Longrightarrow> divides_ff (to_fract f) ?z
divides_ff (content_ff p) 1 \<and> divides_ff 1 (content_ff p)
[PROOF STEP]
have "divides_ff ?f 1"
[PROOF STATE]
proof (prove)
using this:
divides_ff (content_ff p) ?z \<Longrightarrow> divides_ff (to_fract f) ?z
divides_ff (content_ff p) 1 \<and> divides_ff 1 (content_ff p)

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

goal (1 subgoal):
 1. \<not> content_ff (pa__ * q) =dff 1 \<Longrightarrow> False
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
divides_ff (to_fract f) 1

goal (1 subgoal):
 1. \<not> content_ff (pa__ * q) =dff 1 \<Longrightarrow> False
[PROOF STEP]
have "1 = to_fract 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 = to_fract (1::'c)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
1 = to_fract (1::?'c2)

goal (1 subgoal):
 1. \<not> content_ff (pa__ * q) =dff 1 \<Longrightarrow> False
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
divides_ff (to_fract f) (to_fract (1::'a))
[PROOF STEP]
have "f dvd 1"
[PROOF STATE]
proof (prove)
using this:
divides_ff (to_fract f) (to_fract (1::'a))

goal (1 subgoal):
 1. f dvd (1::'a)
[PROOF STEP]
by (unfold divides_ff_to_fract)
[PROOF STATE]
proof (state)
this:
f dvd (1::'a)

goal (1 subgoal):
 1. \<not> content_ff (pa__ * q) =dff 1 \<Longrightarrow> False
[PROOF STEP]
hence False
[PROOF STATE]
proof (prove)
using this:
f dvd (1::'a)

goal (1 subgoal):
 1. False
[PROOF STEP]
using no_unit
[PROOF STATE]
proof (prove)
using this:
f dvd (1::'a)
\<not> f dvd (1::'a)

goal (1 subgoal):
 1. False
[PROOF STEP]
unfolding dvd_def
[PROOF STATE]
proof (prove)
using this:
\<exists>k. (1::'a) = f * k
\<nexists>k. (1::'a) = f * k

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

goal (1 subgoal):
 1. \<not> content_ff (pa__ * q) =dff 1 \<Longrightarrow> False
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
\<forall>c\<in>set (coeffs p). divides_ff (to_fract f) c \<Longrightarrow> False

goal (1 subgoal):
 1. \<not> content_ff (pa__ * q) =dff 1 \<Longrightarrow> False
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<forall>c\<in>set (coeffs p). divides_ff (to_fract f) c \<Longrightarrow> False
[PROOF STEP]
obtain cp where cp: "cp \<in> set (coeffs p)" and ncp: "\<not> divides_ff ?f cp"
[PROOF STATE]
proof (prove)
using this:
\<forall>c\<in>set (coeffs p). divides_ff (to_fract f) c \<Longrightarrow> False

goal (1 subgoal):
 1. (\<And>cp. \<lbrakk>cp \<in> set (coeffs p); \<not> divides_ff (to_fract f) cp\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
cp \<in> set (coeffs p)
\<not> divides_ff (to_fract f) cp

goal (1 subgoal):
 1. \<not> content_ff (pa__ * q) =dff 1 \<Longrightarrow> False
[PROOF STEP]
hence "cp \<in> range (coeff p)"
[PROOF STATE]
proof (prove)
using this:
cp \<in> set (coeffs p)
\<not> divides_ff (to_fract f) cp

goal (1 subgoal):
 1. cp \<in> range (coeff p)
[PROOF STEP]
unfolding range_coeff
[PROOF STATE]
proof (prove)
using this:
cp \<in> set (coeffs p)
\<not> divides_ff (to_fract f) cp

goal (1 subgoal):
 1. cp \<in> insert 0 (set (coeffs p))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
cp \<in> range (coeff p)

goal (1 subgoal):
 1. \<not> content_ff (pa__ * q) =dff 1 \<Longrightarrow> False
[PROOF STEP]
with ncp
[PROOF STATE]
proof (chain)
picking this:
\<not> divides_ff (to_fract f) cp
cp \<in> range (coeff p)
[PROOF STEP]
have "\<exists> i. ?P i"
[PROOF STATE]
proof (prove)
using this:
\<not> divides_ff (to_fract f) cp
cp \<in> range (coeff p)

goal (1 subgoal):
 1. \<exists>i. \<not> divides_ff (to_fract f) (coeff p i)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<exists>i. \<not> divides_ff (to_fract f) (coeff p i)

goal (1 subgoal):
 1. \<not> content_ff (pa__ * q) =dff 1 \<Longrightarrow> False
[PROOF STEP]
from LeastI_ex[OF this] not_less_Least[of _ ?P]
[PROOF STATE]
proof (chain)
picking this:
\<not> divides_ff (to_fract f) (coeff p (LEAST i. \<not> divides_ff (to_fract f) (coeff p i)))
?k < (LEAST x. \<not> divides_ff (to_fract f) (coeff p x)) \<Longrightarrow> \<not> \<not> divides_ff (to_fract f) (coeff p ?k)
[PROOF STEP]
have "\<exists> i. ?P i \<and> (\<forall> j. j < i \<longrightarrow> divides_ff ?f (coeff p j))"
[PROOF STATE]
proof (prove)
using this:
\<not> divides_ff (to_fract f) (coeff p (LEAST i. \<not> divides_ff (to_fract f) (coeff p i)))
?k < (LEAST x. \<not> divides_ff (to_fract f) (coeff p x)) \<Longrightarrow> \<not> \<not> divides_ff (to_fract f) (coeff p ?k)

goal (1 subgoal):
 1. \<exists>i. \<not> divides_ff (to_fract f) (coeff p i) \<and> (\<forall>j<i. divides_ff (to_fract f) (coeff p j))
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
\<exists>i. \<not> divides_ff (to_fract f) (coeff p i) \<and> (\<forall>j<i. divides_ff (to_fract f) (coeff p j))

goal (1 subgoal):
 1. \<not> content_ff (pa__ * q) =dff 1 \<Longrightarrow> False
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
content_ff ?pb3 =dff 1 \<Longrightarrow> \<exists>i. \<not> divides_ff (to_fract f) (coeff ?pb3 i) \<and> (\<forall>j<i. divides_ff (to_fract f) (coeff ?pb3 j))

goal (1 subgoal):
 1. \<not> content_ff (p * q) =dff 1 \<Longrightarrow> False
[PROOF STEP]
note cont = this
[PROOF STATE]
proof (state)
this:
content_ff ?pb3 =dff 1 \<Longrightarrow> \<exists>i. \<not> divides_ff (to_fract f) (coeff ?pb3 i) \<and> (\<forall>j<i. divides_ff (to_fract f) (coeff ?pb3 j))

goal (1 subgoal):
 1. \<not> content_ff (p * q) =dff 1 \<Longrightarrow> False
[PROOF STEP]
from cont[OF cp1]
[PROOF STATE]
proof (chain)
picking this:
\<exists>i. \<not> divides_ff (to_fract f) (coeff p i) \<and> (\<forall>j<i. divides_ff (to_fract f) (coeff p j))
[PROOF STEP]
obtain r where
        r: "\<not> divides_ff ?f (coeff p r)" and r': "\<And> i. i < r \<Longrightarrow> divides_ff ?f (coeff p i)"
[PROOF STATE]
proof (prove)
using this:
\<exists>i. \<not> divides_ff (to_fract f) (coeff p i) \<and> (\<forall>j<i. divides_ff (to_fract f) (coeff p j))

goal (1 subgoal):
 1. (\<And>r. \<lbrakk>\<not> divides_ff (to_fract f) (coeff p r); \<And>i. i < r \<Longrightarrow> divides_ff (to_fract f) (coeff p i)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<not> divides_ff (to_fract f) (coeff p r)
?i1 < r \<Longrightarrow> divides_ff (to_fract f) (coeff p ?i1)

goal (1 subgoal):
 1. \<not> content_ff (p * q) =dff 1 \<Longrightarrow> False
[PROOF STEP]
have "\<forall> i. \<exists> k. i < r \<longrightarrow> coeff p i = ?f * to_fract k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>i. \<exists>k. i < r \<longrightarrow> coeff p i = to_fract f * to_fract k
[PROOF STEP]
using divides_ff_coeff[OF cp r']
[PROOF STATE]
proof (prove)
using this:
?i < r \<Longrightarrow> \<exists>m. coeff p ?i = to_fract f * to_fract m

goal (1 subgoal):
 1. \<forall>i. \<exists>k. i < r \<longrightarrow> coeff p i = to_fract f * to_fract k
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
\<forall>i. \<exists>k. i < r \<longrightarrow> coeff p i = to_fract f * to_fract k

goal (1 subgoal):
 1. \<not> content_ff (p * q) =dff 1 \<Longrightarrow> False
[PROOF STEP]
from choice[OF this]
[PROOF STATE]
proof (chain)
picking this:
\<exists>fa. \<forall>x<r. coeff p x = to_fract f * to_fract (fa x)
[PROOF STEP]
obtain rr where r': "\<And> i. i < r \<Longrightarrow> coeff p i = ?f * to_fract (rr i)"
[PROOF STATE]
proof (prove)
using this:
\<exists>fa. \<forall>x<r. coeff p x = to_fract f * to_fract (fa x)

goal (1 subgoal):
 1. (\<And>rr. (\<And>i. i < r \<Longrightarrow> coeff p i = to_fract f * to_fract (rr i)) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
?i1 < r \<Longrightarrow> coeff p ?i1 = to_fract f * to_fract (rr ?i1)

goal (1 subgoal):
 1. \<not> content_ff (p * q) =dff 1 \<Longrightarrow> False
[PROOF STEP]
let ?r = "coeff p r"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> content_ff (p * q) =dff 1 \<Longrightarrow> False
[PROOF STEP]
from cont[OF cq1]
[PROOF STATE]
proof (chain)
picking this:
\<exists>i. \<not> divides_ff (to_fract f) (coeff q i) \<and> (\<forall>j<i. divides_ff (to_fract f) (coeff q j))
[PROOF STEP]
obtain s where
        s: "\<not> divides_ff ?f (coeff q s)" and s': "\<And> i. i < s \<Longrightarrow> divides_ff ?f (coeff q i)"
[PROOF STATE]
proof (prove)
using this:
\<exists>i. \<not> divides_ff (to_fract f) (coeff q i) \<and> (\<forall>j<i. divides_ff (to_fract f) (coeff q j))

goal (1 subgoal):
 1. (\<And>s. \<lbrakk>\<not> divides_ff (to_fract f) (coeff q s); \<And>i. i < s \<Longrightarrow> divides_ff (to_fract f) (coeff q i)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<not> divides_ff (to_fract f) (coeff q s)
?i1 < s \<Longrightarrow> divides_ff (to_fract f) (coeff q ?i1)

goal (1 subgoal):
 1. \<not> content_ff (p * q) =dff 1 \<Longrightarrow> False
[PROOF STEP]
have "\<forall> i. \<exists> k. i < s \<longrightarrow> coeff q i = ?f * to_fract k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>i. \<exists>k. i < s \<longrightarrow> coeff q i = to_fract f * to_fract k
[PROOF STEP]
using divides_ff_coeff[OF cq s']
[PROOF STATE]
proof (prove)
using this:
?i < s \<Longrightarrow> \<exists>m. coeff q ?i = to_fract f * to_fract m

goal (1 subgoal):
 1. \<forall>i. \<exists>k. i < s \<longrightarrow> coeff q i = to_fract f * to_fract k
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
\<forall>i. \<exists>k. i < s \<longrightarrow> coeff q i = to_fract f * to_fract k

goal (1 subgoal):
 1. \<not> content_ff (p * q) =dff 1 \<Longrightarrow> False
[PROOF STEP]
from choice[OF this]
[PROOF STATE]
proof (chain)
picking this:
\<exists>fa. \<forall>x<s. coeff q x = to_fract f * to_fract (fa x)
[PROOF STEP]
obtain ss where s': "\<And> i. i < s \<Longrightarrow> coeff q i = ?f * to_fract (ss i)"
[PROOF STATE]
proof (prove)
using this:
\<exists>fa. \<forall>x<s. coeff q x = to_fract f * to_fract (fa x)

goal (1 subgoal):
 1. (\<And>ss. (\<And>i. i < s \<Longrightarrow> coeff q i = to_fract f * to_fract (ss i)) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
?i1 < s \<Longrightarrow> coeff q ?i1 = to_fract f * to_fract (ss ?i1)

goal (1 subgoal):
 1. \<not> content_ff (p * q) =dff 1 \<Longrightarrow> False
[PROOF STEP]
from range_coeffs_to_fract[OF cp]
[PROOF STATE]
proof (chain)
picking this:
\<exists>m. coeff p ?i = to_fract m
[PROOF STEP]
have "\<forall> i. \<exists> m. coeff p i = to_fract m"
[PROOF STATE]
proof (prove)
using this:
\<exists>m. coeff p ?i = to_fract m

goal (1 subgoal):
 1. \<forall>i. \<exists>m. coeff p i = to_fract m
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
\<forall>i. \<exists>m. coeff p i = to_fract m

goal (1 subgoal):
 1. \<not> content_ff (p * q) =dff 1 \<Longrightarrow> False
[PROOF STEP]
from choice[OF this]
[PROOF STATE]
proof (chain)
picking this:
\<exists>f. \<forall>x. coeff p x = to_fract (f x)
[PROOF STEP]
obtain pi where pi: "\<And> i. coeff p i = to_fract (pi i)"
[PROOF STATE]
proof (prove)
using this:
\<exists>f. \<forall>x. coeff p x = to_fract (f x)

goal (1 subgoal):
 1. (\<And>pi. (\<And>i. coeff p i = to_fract (pi i)) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
coeff p ?i1 = to_fract (pi ?i1)

goal (1 subgoal):
 1. \<not> content_ff (p * q) =dff 1 \<Longrightarrow> False
[PROOF STEP]
from range_coeffs_to_fract[OF cq]
[PROOF STATE]
proof (chain)
picking this:
\<exists>m. coeff q ?i = to_fract m
[PROOF STEP]
have "\<forall> i. \<exists> m. coeff q i = to_fract m"
[PROOF STATE]
proof (prove)
using this:
\<exists>m. coeff q ?i = to_fract m

goal (1 subgoal):
 1. \<forall>i. \<exists>m. coeff q i = to_fract m
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
\<forall>i. \<exists>m. coeff q i = to_fract m

goal (1 subgoal):
 1. \<not> content_ff (p * q) =dff 1 \<Longrightarrow> False
[PROOF STEP]
from choice[OF this]
[PROOF STATE]
proof (chain)
picking this:
\<exists>f. \<forall>x. coeff q x = to_fract (f x)
[PROOF STEP]
obtain qi where qi: "\<And> i. coeff q i = to_fract (qi i)"
[PROOF STATE]
proof (prove)
using this:
\<exists>f. \<forall>x. coeff q x = to_fract (f x)

goal (1 subgoal):
 1. (\<And>qi. (\<And>i. coeff q i = to_fract (qi i)) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
coeff q ?i1 = to_fract (qi ?i1)

goal (1 subgoal):
 1. \<not> content_ff (p * q) =dff 1 \<Longrightarrow> False
[PROOF STEP]
let ?s = "coeff q s"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> content_ff (p * q) =dff 1 \<Longrightarrow> False
[PROOF STEP]
let ?g = "\<lambda> i. coeff p i * coeff q (r + s - i)"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> content_ff (p * q) =dff 1 \<Longrightarrow> False
[PROOF STEP]
define a where "a = (\<Sum>i\<in>{..<r}. (rr i * qi (r + s - i)))"
[PROOF STATE]
proof (state)
this:
a = (\<Sum>i<r. rr i * qi (r + s - i))

goal (1 subgoal):
 1. \<not> content_ff (p * q) =dff 1 \<Longrightarrow> False
[PROOF STEP]
define b where "b = (\<Sum> i \<in> {Suc r..r + s}. pi i * (ss (r + s - i)))"
[PROOF STATE]
proof (state)
this:
b = (\<Sum>i = Suc r..r + s. pi i * ss (r + s - i))

goal (1 subgoal):
 1. \<not> content_ff (p * q) =dff 1 \<Longrightarrow> False
[PROOF STEP]
have "coeff (p * q) (r + s) = (\<Sum>i\<le>r + s. ?g i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. coeff (p * q) (r + s) = (\<Sum>i\<le>r + s. coeff p i * coeff q (r + s - i))
[PROOF STEP]
unfolding coeff_mult
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i\<le>r + s. coeff p i * coeff q (r + s - i)) = (\<Sum>i\<le>r + s. coeff p i * coeff q (r + s - i))
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
coeff (p * q) (r + s) = (\<Sum>i\<le>r + s. coeff p i * coeff q (r + s - i))

goal (1 subgoal):
 1. \<not> content_ff (p * q) =dff 1 \<Longrightarrow> False
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
coeff (p * q) (r + s) = (\<Sum>i\<le>r + s. coeff p i * coeff q (r + s - i))

goal (1 subgoal):
 1. \<not> content_ff (p * q) =dff 1 \<Longrightarrow> False
[PROOF STEP]
have "{..r+s} = {..< r} \<union> {r .. r+s}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {..r + s} = {..<r} \<union> {r..r + s}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
{..r + s} = {..<r} \<union> {r..r + s}

goal (1 subgoal):
 1. \<not> content_ff (p * q) =dff 1 \<Longrightarrow> False
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
{..r + s} = {..<r} \<union> {r..r + s}

goal (1 subgoal):
 1. \<not> content_ff (p * q) =dff 1 \<Longrightarrow> False
[PROOF STEP]
have "(\<Sum>i\<in>{..<r} \<union> {r..r + s}. ?g i)
        = (\<Sum>i\<in>{..<r}. ?g i) + (\<Sum> i \<in> {r..r + s}. ?g i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i\<in>{..<r} \<union> {r..r + s}. coeff p i * coeff q (r + s - i)) = (\<Sum>i<r. coeff p i * coeff q (r + s - i)) + (\<Sum>i = r..r + s. coeff p i * coeff q (r + s - i))
[PROOF STEP]
by (rule sum.union_disjoint, auto)
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<in>{..<r} \<union> {r..r + s}. coeff p i * coeff q (r + s - i)) = (\<Sum>i<r. coeff p i * coeff q (r + s - i)) + (\<Sum>i = r..r + s. coeff p i * coeff q (r + s - i))

goal (1 subgoal):
 1. \<not> content_ff (p * q) =dff 1 \<Longrightarrow> False
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<in>{..<r} \<union> {r..r + s}. coeff p i * coeff q (r + s - i)) = (\<Sum>i<r. coeff p i * coeff q (r + s - i)) + (\<Sum>i = r..r + s. coeff p i * coeff q (r + s - i))

goal (1 subgoal):
 1. \<not> content_ff (p * q) =dff 1 \<Longrightarrow> False
[PROOF STEP]
have "(\<Sum>i\<in>{..<r}. ?g i) = (\<Sum>i\<in>{..<r}. ?f * (to_fract (rr i) * to_fract (qi (r + s - i))))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i<r. coeff p i * coeff q (r + s - i)) = (\<Sum>i<r. to_fract f * (to_fract (rr i) * to_fract (qi (r + s - i))))
[PROOF STEP]
by (rule sum.cong[OF refl], insert r' qi, auto)
[PROOF STATE]
proof (state)
this:
(\<Sum>i<r. coeff p i * coeff q (r + s - i)) = (\<Sum>i<r. to_fract f * (to_fract (rr i) * to_fract (qi (r + s - i))))

goal (1 subgoal):
 1. \<not> content_ff (p * q) =dff 1 \<Longrightarrow> False
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>i<r. coeff p i * coeff q (r + s - i)) = (\<Sum>i<r. to_fract f * (to_fract (rr i) * to_fract (qi (r + s - i))))

goal (1 subgoal):
 1. \<not> content_ff (p * q) =dff 1 \<Longrightarrow> False
[PROOF STEP]
have "\<dots> = to_fract (f * a)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i<r. to_fract f * (to_fract (rr i) * to_fract (qi (r + s - i)))) = to_fract (f * a)
[PROOF STEP]
by (simp add: a_def sum_distrib_left)
[PROOF STATE]
proof (state)
this:
(\<Sum>i<r. to_fract f * (to_fract (rr i) * to_fract (qi (r + s - i)))) = to_fract (f * a)

goal (1 subgoal):
 1. \<not> content_ff (p * q) =dff 1 \<Longrightarrow> False
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>i<r. to_fract f * (to_fract (rr i) * to_fract (qi (r + s - i)))) = to_fract (f * a)

goal (1 subgoal):
 1. \<not> content_ff (p * q) =dff 1 \<Longrightarrow> False
[PROOF STEP]
have "(\<Sum> i \<in> {r..r + s}. ?g i) = ?g r + (\<Sum> i \<in> {Suc r..r + s}. ?g i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i = r..r + s. coeff p i * coeff q (r + s - i)) = coeff p r * coeff q (r + s - r) + (\<Sum>i = Suc r..r + s. coeff p i * coeff q (r + s - i))
[PROOF STEP]
by (subst sum.remove[of _ r], auto intro: sum.cong)
[PROOF STATE]
proof (state)
this:
(\<Sum>i = r..r + s. coeff p i * coeff q (r + s - i)) = coeff p r * coeff q (r + s - r) + (\<Sum>i = Suc r..r + s. coeff p i * coeff q (r + s - i))

goal (1 subgoal):
 1. \<not> content_ff (p * q) =dff 1 \<Longrightarrow> False
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>i = r..r + s. coeff p i * coeff q (r + s - i)) = coeff p r * coeff q (r + s - r) + (\<Sum>i = Suc r..r + s. coeff p i * coeff q (r + s - i))

goal (1 subgoal):
 1. \<not> content_ff (p * q) =dff 1 \<Longrightarrow> False
[PROOF STEP]
have "(\<Sum> i \<in> {Suc r..r + s}. ?g i) = (\<Sum> i \<in> {Suc r..r + s}. ?f * (to_fract (pi i) * to_fract (ss (r + s - i))))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i = Suc r..r + s. coeff p i * coeff q (r + s - i)) = (\<Sum>i = Suc r..r + s. to_fract f * (to_fract (pi i) * to_fract (ss (r + s - i))))
[PROOF STEP]
by (rule sum.cong[OF refl], insert s' pi, auto)
[PROOF STATE]
proof (state)
this:
(\<Sum>i = Suc r..r + s. coeff p i * coeff q (r + s - i)) = (\<Sum>i = Suc r..r + s. to_fract f * (to_fract (pi i) * to_fract (ss (r + s - i))))

goal (1 subgoal):
 1. \<not> content_ff (p * q) =dff 1 \<Longrightarrow> False
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>i = Suc r..r + s. coeff p i * coeff q (r + s - i)) = (\<Sum>i = Suc r..r + s. to_fract f * (to_fract (pi i) * to_fract (ss (r + s - i))))

goal (1 subgoal):
 1. \<not> content_ff (p * q) =dff 1 \<Longrightarrow> False
[PROOF STEP]
have "\<dots> = to_fract (f * b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i = Suc r..r + s. to_fract f * (to_fract (pi i) * to_fract (ss (r + s - i)))) = to_fract (f * b)
[PROOF STEP]
by (simp add: sum_distrib_left b_def)
[PROOF STATE]
proof (state)
this:
(\<Sum>i = Suc r..r + s. to_fract f * (to_fract (pi i) * to_fract (ss (r + s - i)))) = to_fract (f * b)

goal (1 subgoal):
 1. \<not> content_ff (p * q) =dff 1 \<Longrightarrow> False
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
coeff (p * q) (r + s) = to_fract (f * a) + (coeff p r * coeff q (r + s - r) + to_fract (f * b))
[PROOF STEP]
have cpq: "coeff (p * q) (r + s) = to_fract (f * (a + b)) + ?r * ?s"
[PROOF STATE]
proof (prove)
using this:
coeff (p * q) (r + s) = to_fract (f * a) + (coeff p r * coeff q (r + s - r) + to_fract (f * b))

goal (1 subgoal):
 1. coeff (p * q) (r + s) = to_fract (f * (a + b)) + coeff p r * coeff q s
[PROOF STEP]
by (simp add: field_simps)
[PROOF STATE]
proof (state)
this:
coeff (p * q) (r + s) = to_fract (f * (a + b)) + coeff p r * coeff q s

goal (1 subgoal):
 1. \<not> content_ff (p * q) =dff 1 \<Longrightarrow> False
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
coeff (p * q) (r + s) = to_fract (f * (a + b)) + coeff p r * coeff q s

goal (1 subgoal):
 1. \<not> content_ff (p * q) =dff 1 \<Longrightarrow> False
[PROOF STEP]
fix i
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> content_ff (p * q) =dff 1 \<Longrightarrow> False
[PROOF STEP]
from dvd[of "coeff (p * q) i"]
[PROOF STATE]
proof (chain)
picking this:
coeff (p * q) i \<in> set (coeffs (p * q)) \<Longrightarrow> divides_ff (to_fract f) (coeff (p * q) i)
[PROOF STEP]
have "divides_ff ?f (coeff (p * q) i)"
[PROOF STATE]
proof (prove)
using this:
coeff (p * q) i \<in> set (coeffs (p * q)) \<Longrightarrow> divides_ff (to_fract f) (coeff (p * q) i)

goal (1 subgoal):
 1. divides_ff (to_fract f) (coeff (p * q) i)
[PROOF STEP]
using range_coeff[of "p * q"]
[PROOF STATE]
proof (prove)
using this:
coeff (p * q) i \<in> set (coeffs (p * q)) \<Longrightarrow> divides_ff (to_fract f) (coeff (p * q) i)
range (coeff (p * q)) = insert 0 (set (coeffs (p * q)))

goal (1 subgoal):
 1. divides_ff (to_fract f) (coeff (p * q) i)
[PROOF STEP]
by (cases "coeff (p * q) i = 0", auto simp: divides_ff_def)
[PROOF STATE]
proof (state)
this:
divides_ff (to_fract f) (coeff (p * q) i)

goal (1 subgoal):
 1. \<not> content_ff (p * q) =dff 1 \<Longrightarrow> False
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
divides_ff (to_fract f) (coeff (p * q) ?i3)

goal (1 subgoal):
 1. \<not> content_ff (p * q) =dff 1 \<Longrightarrow> False
[PROOF STEP]
from this[of "r + s", unfolded cpq]
[PROOF STATE]
proof (chain)
picking this:
divides_ff (to_fract f) (to_fract (f * (a + b)) + coeff p r * coeff q s)
[PROOF STEP]
have "divides_ff ?f (to_fract (f * (a + b) + pi r * qi s))"
[PROOF STATE]
proof (prove)
using this:
divides_ff (to_fract f) (to_fract (f * (a + b)) + coeff p r * coeff q s)

goal (1 subgoal):
 1. divides_ff (to_fract f) (to_fract (f * (a + b) + pi r * qi s))
[PROOF STEP]
unfolding pi qi
[PROOF STATE]
proof (prove)
using this:
divides_ff (to_fract f) (to_fract (f * (a + b)) + to_fract (pi r) * to_fract (qi s))

goal (1 subgoal):
 1. divides_ff (to_fract f) (to_fract (f * (a + b) + pi r * qi s))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
divides_ff (to_fract f) (to_fract (f * (a + b) + pi r * qi s))

goal (1 subgoal):
 1. \<not> content_ff (p * q) =dff 1 \<Longrightarrow> False
[PROOF STEP]
from this[unfolded divides_ff_to_fract]
[PROOF STATE]
proof (chain)
picking this:
f dvd f * (a + b) + pi r * qi s
[PROOF STEP]
have "f dvd pi r * qi s"
[PROOF STATE]
proof (prove)
using this:
f dvd f * (a + b) + pi r * qi s

goal (1 subgoal):
 1. f dvd pi r * qi s
[PROOF STEP]
by (metis dvd_add_times_triv_left_iff mult.commute)
[PROOF STATE]
proof (state)
this:
f dvd pi r * qi s

goal (1 subgoal):
 1. \<not> content_ff (p * q) =dff 1 \<Longrightarrow> False
[PROOF STEP]
from prime[OF this]
[PROOF STATE]
proof (chain)
picking this:
f dvd pi r \<or> f dvd qi s
[PROOF STEP]
have "f dvd pi r \<or> f dvd qi s"
[PROOF STATE]
proof (prove)
using this:
f dvd pi r \<or> f dvd qi s

goal (1 subgoal):
 1. f dvd pi r \<or> f dvd qi s
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
f dvd pi r \<or> f dvd qi s

goal (1 subgoal):
 1. \<not> content_ff (p * q) =dff 1 \<Longrightarrow> False
[PROOF STEP]
with r s
[PROOF STATE]
proof (chain)
picking this:
\<not> divides_ff (to_fract f) (coeff p r)
\<not> divides_ff (to_fract f) (coeff q s)
f dvd pi r \<or> f dvd qi s
[PROOF STEP]
show False
[PROOF STATE]
proof (prove)
using this:
\<not> divides_ff (to_fract f) (coeff p r)
\<not> divides_ff (to_fract f) (coeff q s)
f dvd pi r \<or> f dvd qi s

goal (1 subgoal):
 1. False
[PROOF STEP]
unfolding pi qi
[PROOF STATE]
proof (prove)
using this:
\<not> divides_ff (to_fract f) (to_fract (pi r))
\<not> divides_ff (to_fract f) (to_fract (qi s))
f dvd pi r \<or> f dvd qi s

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

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
content_ff (p * q) =dff 1

goal (2 subgoals):
 1. p = 0 \<or> q = 0 \<Longrightarrow> content_ff (p * q) =dff content_ff p * content_ff q
 2. \<not> (p = 0 \<or> q = 0) \<Longrightarrow> content_ff (p * q) =dff content_ff p * content_ff q
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
\<lbrakk>content_ff ?pa2 =dff 1; content_ff ?qa2 =dff 1\<rbrakk> \<Longrightarrow> content_ff (?pa2 * ?qa2) =dff 1

goal (2 subgoals):
 1. p = 0 \<or> q = 0 \<Longrightarrow> content_ff (p * q) =dff content_ff p * content_ff q
 2. \<not> (p = 0 \<or> q = 0) \<Longrightarrow> content_ff (p * q) =dff content_ff p * content_ff q
[PROOF STEP]
note main = this
[PROOF STATE]
proof (state)
this:
\<lbrakk>content_ff ?pa2 =dff 1; content_ff ?qa2 =dff 1\<rbrakk> \<Longrightarrow> content_ff (?pa2 * ?qa2) =dff 1

goal (2 subgoals):
 1. p = 0 \<or> q = 0 \<Longrightarrow> content_ff (p * q) =dff content_ff p * content_ff q
 2. \<not> (p = 0 \<or> q = 0) \<Longrightarrow> content_ff (p * q) =dff content_ff p * content_ff q
[PROOF STEP]
define n where "n \<equiv> normalize_content_ff :: 'a fract poly \<Rightarrow> 'a fract poly"
[PROOF STATE]
proof (state)
this:
n \<equiv> normalize_content_ff

goal (2 subgoals):
 1. p = 0 \<or> q = 0 \<Longrightarrow> content_ff (p * q) =dff content_ff p * content_ff q
 2. \<not> (p = 0 \<or> q = 0) \<Longrightarrow> content_ff (p * q) =dff content_ff p * content_ff q
[PROOF STEP]
let ?s = "\<lambda> p. smult (content_ff p) (n p)"
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. p = 0 \<or> q = 0 \<Longrightarrow> content_ff (p * q) =dff content_ff p * content_ff q
 2. \<not> (p = 0 \<or> q = 0) \<Longrightarrow> content_ff (p * q) =dff content_ff p * content_ff q
[PROOF STEP]
have "?c (p * q) = ?c (?s p * ?s q)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. content_ff (p * q) = content_ff (smult (content_ff p) (n p) * smult (content_ff q) (n q))
[PROOF STEP]
unfolding smult_normalize_content_ff n_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. content_ff (p * q) = content_ff (p * q)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
content_ff (p * q) = content_ff (smult (content_ff p) (n p) * smult (content_ff q) (n q))

goal (2 subgoals):
 1. p = 0 \<or> q = 0 \<Longrightarrow> content_ff (p * q) =dff content_ff p * content_ff q
 2. \<not> (p = 0 \<or> q = 0) \<Longrightarrow> content_ff (p * q) =dff content_ff p * content_ff q
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
content_ff (p * q) = content_ff (smult (content_ff p) (n p) * smult (content_ff q) (n q))

goal (2 subgoals):
 1. p = 0 \<or> q = 0 \<Longrightarrow> content_ff (p * q) =dff content_ff p * content_ff q
 2. \<not> (p = 0 \<or> q = 0) \<Longrightarrow> content_ff (p * q) =dff content_ff p * content_ff q
[PROOF STEP]
have "?s p * ?s q = smult (?c p * ?c q) (n p * n q)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. smult (content_ff p) (n p) * smult (content_ff q) (n q) = smult (content_ff p * content_ff q) (n p * n q)
[PROOF STEP]
by (simp add: mult.commute)
[PROOF STATE]
proof (state)
this:
smult (content_ff p) (n p) * smult (content_ff q) (n q) = smult (content_ff p * content_ff q) (n p * n q)

goal (2 subgoals):
 1. p = 0 \<or> q = 0 \<Longrightarrow> content_ff (p * q) =dff content_ff p * content_ff q
 2. \<not> (p = 0 \<or> q = 0) \<Longrightarrow> content_ff (p * q) =dff content_ff p * content_ff q
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
smult (content_ff p) (n p) * smult (content_ff q) (n q) = smult (content_ff p * content_ff q) (n p * n q)

goal (2 subgoals):
 1. p = 0 \<or> q = 0 \<Longrightarrow> content_ff (p * q) =dff content_ff p * content_ff q
 2. \<not> (p = 0 \<or> q = 0) \<Longrightarrow> content_ff (p * q) =dff content_ff p * content_ff q
[PROOF STEP]
have "?c (\<dots>) =dff (?c p * ?c q) * ?c (n p * n q)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. content_ff (smult (content_ff p * content_ff q) (n p * n q)) =dff content_ff p * content_ff q * content_ff (n p * n q)
[PROOF STEP]
by (rule content_ff_smult)
[PROOF STATE]
proof (state)
this:
content_ff (smult (content_ff p * content_ff q) (n p * n q)) =dff content_ff p * content_ff q * content_ff (n p * n q)

goal (2 subgoals):
 1. p = 0 \<or> q = 0 \<Longrightarrow> content_ff (p * q) =dff content_ff p * content_ff q
 2. \<not> (p = 0 \<or> q = 0) \<Longrightarrow> content_ff (p * q) =dff content_ff p * content_ff q
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
content_ff (smult (content_ff p * content_ff q) (n p * n q)) =dff content_ff p * content_ff q * content_ff (n p * n q)

goal (2 subgoals):
 1. p = 0 \<or> q = 0 \<Longrightarrow> content_ff (p * q) =dff content_ff p * content_ff q
 2. \<not> (p = 0 \<or> q = 0) \<Longrightarrow> content_ff (p * q) =dff content_ff p * content_ff q
[PROOF STEP]
have "?c (n p * n q) =dff 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. content_ff (n p * n q) =dff 1
[PROOF STEP]
unfolding n_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. content_ff (normalize_content_ff p * normalize_content_ff q) =dff 1
[PROOF STEP]
by (rule main, insert p q, auto simp: content_ff_normalize_content_ff_1)
[PROOF STATE]
proof (state)
this:
content_ff (n p * n q) =dff 1

goal (2 subgoals):
 1. p = 0 \<or> q = 0 \<Longrightarrow> content_ff (p * q) =dff content_ff p * content_ff q
 2. \<not> (p = 0 \<or> q = 0) \<Longrightarrow> content_ff (p * q) =dff content_ff p * content_ff q
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
content_ff (p * q) =dff content_ff p * content_ff q * 1
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
content_ff (p * q) =dff content_ff p * content_ff q * 1

goal (1 subgoal):
 1. content_ff (p * q) =dff content_ff p * content_ff q
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
content_ff (p * q) =dff content_ff p * content_ff q

goal (1 subgoal):
 1. p = 0 \<or> q = 0 \<Longrightarrow> content_ff (p * q) =dff content_ff p * content_ff q
[PROOF STEP]
qed auto


[STATEMENT]
lemma vdisjnt_vunion_left: "vdisjnt (A \<union>\<^sub>\<circ> B) C \<longleftrightarrow> vdisjnt A C \<and> vdisjnt B C"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vdisjnt (A \<union>\<^sub>\<circ> B) C = (vdisjnt A C \<and> vdisjnt B C)
[PROOF STEP]
by auto


[STATEMENT]
lemma tree_map_of_distinct: "distinct (map fst (inorder (tree_map_of' empty pres)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. distinct (map fst (inorder (tree_map_of' empty pres)))
[PROOF STEP]
apply(induction pres)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. distinct (map fst (inorder (tree_map_of' empty [])))
 2. \<And>a pres. distinct (map fst (inorder (tree_map_of' empty pres))) \<Longrightarrow> distinct (map fst (inorder (tree_map_of' empty (a # pres))))
[PROOF STEP]
apply(clarsimp simp: map_empty inorder_empty)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>a pres. distinct (map fst (inorder (tree_map_of' empty pres))) \<Longrightarrow> distinct (map fst (inorder (tree_map_of' empty (a # pres))))
[PROOF STEP]
using distinct_if_sorted invar_def invar_empty invar_update tree_map_of_invar
[PROOF STATE]
proof (prove)
using this:
Sorted_Less.sorted ?xs \<Longrightarrow> distinct ?xs
invar ?t \<equiv> inv ?t \<and> sorted1 (inorder ?t)
invar empty
invar ?m \<Longrightarrow> invar (update ?a ?b ?m)
invar ?T \<Longrightarrow> invar (tree_map_of' ?T ?pres)

goal (1 subgoal):
 1. \<And>a pres. distinct (map fst (inorder (tree_map_of' empty pres))) \<Longrightarrow> distinct (map fst (inorder (tree_map_of' empty (a # pres))))
[PROOF STEP]
by blast


[STATEMENT]
lemma has_contour_integral_midpoint:
  assumes "(f has_contour_integral i) (linepath a (midpoint a b))"
          "(f has_contour_integral j) (linepath (midpoint a b) b)"
    shows "(f has_contour_integral (i + j)) (linepath a b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (f has_contour_integral i + j) (linepath a b)
[PROOF STEP]
proof (rule has_contour_integral_split)
[PROOF STATE]
proof (state)
goal (5 subgoals):
 1. (f has_contour_integral i) (linepath a ?c)
 2. (f has_contour_integral j) (linepath ?c b)
 3. 0 \<le> ?k
 4. ?k \<le> 1
 5. ?c - a = ?k *\<^sub>R (b - a)
[PROOF STEP]
show "midpoint a b - a = (1/2) *\<^sub>R (b - a)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. midpoint a b - a = (1 / 2) *\<^sub>R (b - a)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
(f has_contour_integral i) (linepath a (midpoint a b))
(f has_contour_integral j) (linepath (midpoint a b) b)

goal (1 subgoal):
 1. midpoint a b - a = (1 / 2) *\<^sub>R (b - a)
[PROOF STEP]
by (auto simp: midpoint_def scaleR_conv_of_real)
[PROOF STATE]
proof (state)
this:
midpoint a b - a = (1 / 2) *\<^sub>R (b - a)

goal (4 subgoals):
 1. (f has_contour_integral i) (linepath a (midpoint a b))
 2. (f has_contour_integral j) (linepath (midpoint a b) b)
 3. 0 \<le> 1 / 2
 4. 1 / 2 \<le> 1
[PROOF STEP]
qed (use assms in auto)


[STATEMENT]
lemma n_permutation_enum_correct1: "distinct xs \<Longrightarrow> set (n_permutation_enum xs n) \<subseteq> n_permutations (set xs) n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. distinct xs \<Longrightarrow> set (n_permutation_enum xs n) \<subseteq> n_permutations (set xs) n
[PROOF STEP]
unfolding n_permutations_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. distinct xs \<Longrightarrow> set (n_permutation_enum xs n) \<subseteq> {xsa. set xsa \<subseteq> set xs \<and> distinct xsa \<and> length xsa = n}
[PROOF STEP]
using n_permutation_enum_subset n_permutation_enum_elem_distinct n_permutation_enum_length
[PROOF STATE]
proof (prove)
using this:
?ys \<in> set (n_permutation_enum ?xs ?n) \<Longrightarrow> set ?ys \<subseteq> set ?xs
\<lbrakk>distinct ?xs; ?ys \<in> set (n_permutation_enum ?xs ?n)\<rbrakk> \<Longrightarrow> distinct ?ys
?ys \<in> set (n_permutation_enum ?xs ?n) \<Longrightarrow> length ?ys = ?n

goal (1 subgoal):
 1. distinct xs \<Longrightarrow> set (n_permutation_enum xs n) \<subseteq> {xsa. set xsa \<subseteq> set xs \<and> distinct xsa \<and> length xsa = n}
[PROOF STEP]
by fast


[STATEMENT]
lemma surj_to_test:"\<lbrakk> f \<in> A \<rightarrow> B; \<forall>b\<in>B. \<exists>a\<in>A. f a = b \<rbrakk> \<Longrightarrow>
                                                  surj_to f A B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>f \<in> A \<rightarrow> B; \<forall>b\<in>B. \<exists>a\<in>A. f a = b\<rbrakk> \<Longrightarrow> surj_to f A B
[PROOF STEP]
by (auto simp add:surj_to_def image_def)


[STATEMENT]
lemma permutes_compose: "p permutes S \<Longrightarrow> q permutes S \<Longrightarrow> q \<circ> p permutes S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>p permutes S; q permutes S\<rbrakk> \<Longrightarrow> q \<circ> p permutes S
[PROOF STEP]
unfolding permutes_def o_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>(\<forall>x. x \<notin> S \<longrightarrow> p x = x) \<and> (\<forall>y. \<exists>!x. p x = y); (\<forall>x. x \<notin> S \<longrightarrow> q x = x) \<and> (\<forall>y. \<exists>!x. q x = y)\<rbrakk> \<Longrightarrow> (\<forall>x. x \<notin> S \<longrightarrow> q (p x) = x) \<and> (\<forall>y. \<exists>!x. q (p x) = y)
[PROOF STEP]
by metis


[STATEMENT]
lemma length_l_partition_by_median:
  assumes "0 < length ps" "\<forall>k. distinct (map (\<lambda>p. p$k) ps)" "(l, m, r) = partition_by_median k ps"
  shows "length l = (length ps - 1) div 2 + 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length l = (length ps - 1) div 2 + 1
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
0 < length ps
\<forall>k. distinct (map (\<lambda>p. p $ k) ps)
(l, m, r) = partition_by_median k ps

goal (1 subgoal):
 1. length l = (length ps - 1) div 2 + 1
[PROOF STEP]
unfolding partition_by_median_def
[PROOF STATE]
proof (prove)
using this:
0 < length ps
\<forall>k. distinct (map (\<lambda>p. p $ k) ps)
(l, m, r) = (let m = axis_median k ps; (l, r) = partition (\<lambda>p. p $ k \<le> m) ps in (l, m, r))

goal (1 subgoal):
 1. length l = (length ps - 1) div 2 + 1
[PROOF STEP]
by (auto simp: Let_def length_filter_le_axis_median)


[STATEMENT]
lemma subst_hfml_Conj[simp]:
  "(HConj A B)(i:::=x) = HConj (A(i:::=x)) (B(i:::=x))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (A HAND B)(i:::=x) = A(i:::=x) HAND B(i:::=x)
[PROOF STEP]
unfolding HConj_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (HNeg (A HIMP HNeg B))(i:::=x) = HNeg (A(i:::=x) HIMP HNeg (B(i:::=x)))
[PROOF STEP]
by simp