[STATEMENT]
lemma of_nat_drop_bit:
  \<open>of_nat (drop_bit m n) = drop_bit m (of_nat n)\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. of_nat (drop_bit m n) = drop_bit m (of_nat n)
[PROOF STEP]
by (simp add: drop_bit_eq_div Bit_Operations.drop_bit_eq_div of_nat_div)


[STATEMENT]
lemma cosh_dist_positive:
  assumes "a \<in> hyp2" and "b \<in> hyp2"
  shows "cosh_dist a b > 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < cosh_dist a b
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. 0 < cosh_dist a b
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
a \<in> hyp2
b \<in> hyp2
[PROOF STEP]
have "cosh_dist a b \<ge> 1"
[PROOF STATE]
proof (prove)
using this:
a \<in> hyp2
b \<in> hyp2

goal (1 subgoal):
 1. 1 \<le> cosh_dist a b
[PROOF STEP]
by (rule cosh_dist_at_least_1)
[PROOF STATE]
proof (state)
this:
1 \<le> cosh_dist a b

goal (1 subgoal):
 1. 0 < cosh_dist a b
[PROOF STEP]
thus "cosh_dist a b > 0"
[PROOF STATE]
proof (prove)
using this:
1 \<le> cosh_dist a b

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

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma ivt_increasing_component_1:
  fixes f :: "real \<Rightarrow> 'a::euclidean_space"
  shows "a \<le> b \<Longrightarrow> \<forall>x\<in>{a..b}. continuous (at x) f \<Longrightarrow>
    f a\<bullet>k \<le> y \<Longrightarrow> y \<le> f b\<bullet>k \<Longrightarrow> \<exists>x\<in>{a..b}. (f x)\<bullet>k = y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>a \<le> b; \<forall>x\<in>{a..b}. isCont f x; f a \<bullet> k \<le> y; y \<le> f b \<bullet> k\<rbrakk> \<Longrightarrow> \<exists>x\<in>{a..b}. f x \<bullet> k = y
[PROOF STEP]
by (rule ivt_increasing_component_on_1) (auto simp: continuous_at_imp_continuous_on)


[STATEMENT]
lemma not_collinear_angle: "\<not>collinear {a,b,c} \<Longrightarrow> angle a b c \<in> {0<..<pi}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<not> collinear {a, b, c} \<Longrightarrow> angle a b c \<in> {0<..<pi}
[PROOF STEP]
using angle_bounds[of a b c] angle_collinear[of a b c]
[PROOF STATE]
proof (prove)
using this:
0 \<le> angle a b c
angle a b c \<le> pi
angle a b c \<in> {0, pi} \<Longrightarrow> collinear {a, b, c}

goal (1 subgoal):
 1. \<not> collinear {a, b, c} \<Longrightarrow> angle a b c \<in> {0<..<pi}
[PROOF STEP]
by (cases "angle a b c = 0 \<or> angle a b c = pi") auto


[STATEMENT]
lemma finite_fv_terms_set: "finite (fv_terms_set ts)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite (fv_terms_set ts)
[PROOF STEP]
by (auto simp: fv_terms_set_def finite_fv_term_set)


[STATEMENT]
lemma fcard_finsert: "fcard (finsert x A) = Suc (fcard (A |-| {|x|}))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fcard (finsert x A) = Suc (fcard (A |-| {|x|}))
[PROOF STEP]
by transfer (rule card.insert_remove)


[STATEMENT]
lemma uminus_mtx2: "-mtx
  ([a, b] #
   [c, d] # []) = (mtx
  ([-a, -b] #
   [-c, -d] # [])::2 sq_mtx)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. - mtx [[a, b], [c, d]] = mtx [[- a, - b], [- c, - d]]
[PROOF STEP]
by (simp add: sq_mtx_uminus_eq sq_mtx_eq_iff)


[STATEMENT]
lemma disjoint_partition_Int: "
  \<forall>c1\<in>C. \<forall>c2\<in>C. c1 \<noteq> c2 \<longrightarrow> c1 \<inter> c2 = {} \<Longrightarrow>
  \<forall>a1\<in>{A \<inter> c| c. c \<in> C}. \<forall>a2\<in>{A \<inter> c| c. c \<in> C}.
    a1 \<noteq> a2 \<longrightarrow> a1 \<inter> a2 = {}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>c1\<in>C. \<forall>c2\<in>C. c1 \<noteq> c2 \<longrightarrow> c1 \<inter> c2 = {} \<Longrightarrow> \<forall>a1\<in>{A \<inter> c |c. c \<in> C}. \<forall>a2\<in>{A \<inter> c |c. c \<in> C}. a1 \<noteq> a2 \<longrightarrow> a1 \<inter> a2 = {}
[PROOF STEP]
by blast


[STATEMENT]
lemma is_norm_le_1[simp]: "is_norm_le_1 x = (norm x \<le> 1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. is_norm_le_1 x = (cmod x \<le> 1)
[PROOF STEP]
unfolding is_norm_le_1_def norm_complex_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((Re x)\<^sup>2 + (Im x)\<^sup>2 \<le> 1) = (sqrt ((Re x)\<^sup>2 + (Im x)\<^sup>2) \<le> 1)
[PROOF STEP]
by simp


[STATEMENT]
lemma measure_spmf_return_spmf: "measure_spmf (return_spmf x) = Giry_Monad.return (count_space UNIV) x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. measure_spmf (return_spmf x) = return (count_space UNIV) x
[PROOF STEP]
by(rule measure_eqI)(simp_all add: measure_spmf_def emeasure_distr space_restrict_space emeasure_restrict_space indicator_def)


[STATEMENT]
lemma shuffle_fisher_yates_step:
  assumes xs_nonempty [simp]: "xs \<noteq> []"
  shows "shuffle xs =
           do {i \<leftarrow> pmf_of_set {..<length xs};
               let ys = swap xs 0 i;
               zs \<leftarrow> shuffle (tl ys);
               return_pmf (hd ys # zs)
              }"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. shuffle xs = pmf_of_set {..<length xs} \<bind> (\<lambda>i. let ys = swap xs 0 i in shuffle (tl ys) \<bind> (\<lambda>zs. return_pmf (hd ys # zs)))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. shuffle xs = pmf_of_set {..<length xs} \<bind> (\<lambda>i. let ys = swap xs 0 i in shuffle (tl ys) \<bind> (\<lambda>zs. return_pmf (hd ys # zs)))
[PROOF STEP]
have "shuffle xs = do {x \<leftarrow> pmf_of_multiset (mset xs);
             xs \<leftarrow> pmf_of_set (permutations_of_multiset (mset xs - {#x#}));
             return_pmf (x#xs)
            }"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. shuffle xs = pmf_of_multiset (mset xs) \<bind> (\<lambda>x. pmf_of_set (permutations_of_multiset (mset xs - {#x#})) \<bind> (\<lambda>xs. return_pmf (x # xs)))
[PROOF STEP]
unfolding shuffle_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. pmf_of_set (permutations_of_multiset (mset xs)) = pmf_of_multiset (mset xs) \<bind> (\<lambda>x. pmf_of_set (permutations_of_multiset (mset xs - {#x#})) \<bind> (\<lambda>xs. return_pmf (x # xs)))
[PROOF STEP]
by (simp add: pmf_of_set_permutations_of_multiset_nonempty)
[PROOF STATE]
proof (state)
this:
shuffle xs = pmf_of_multiset (mset xs) \<bind> (\<lambda>x. pmf_of_set (permutations_of_multiset (mset xs - {#x#})) \<bind> (\<lambda>xs. return_pmf (x # xs)))

goal (1 subgoal):
 1. shuffle xs = pmf_of_set {..<length xs} \<bind> (\<lambda>i. let ys = swap xs 0 i in shuffle (tl ys) \<bind> (\<lambda>zs. return_pmf (hd ys # zs)))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
shuffle xs = pmf_of_multiset (mset xs) \<bind> (\<lambda>x. pmf_of_set (permutations_of_multiset (mset xs - {#x#})) \<bind> (\<lambda>xs. return_pmf (x # xs)))

goal (1 subgoal):
 1. shuffle xs = pmf_of_set {..<length xs} \<bind> (\<lambda>i. let ys = swap xs 0 i in shuffle (tl ys) \<bind> (\<lambda>zs. return_pmf (hd ys # zs)))
[PROOF STEP]
have "pmf_of_multiset (mset xs) =
               pmf_of_multiset (image_mset ((!) xs) (mset (upt 0 (length xs))))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. pmf_of_multiset (mset xs) = pmf_of_multiset (image_mset ((!) xs) (mset [0..<length xs]))
[PROOF STEP]
by (subst mset_map [symmetric]) (simp add: map_nth)
[PROOF STATE]
proof (state)
this:
pmf_of_multiset (mset xs) = pmf_of_multiset (image_mset ((!) xs) (mset [0..<length xs]))

goal (1 subgoal):
 1. shuffle xs = pmf_of_set {..<length xs} \<bind> (\<lambda>i. let ys = swap xs 0 i in shuffle (tl ys) \<bind> (\<lambda>zs. return_pmf (hd ys # zs)))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
pmf_of_multiset (mset xs) = pmf_of_multiset (image_mset ((!) xs) (mset [0..<length xs]))

goal (1 subgoal):
 1. shuffle xs = pmf_of_set {..<length xs} \<bind> (\<lambda>i. let ys = swap xs 0 i in shuffle (tl ys) \<bind> (\<lambda>zs. return_pmf (hd ys # zs)))
[PROOF STEP]
have "\<dots> = map_pmf ((!) xs) (pmf_of_set {..<length xs})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. pmf_of_multiset (image_mset ((!) xs) (mset [0..<length xs])) = map_pmf ((!) xs) (pmf_of_set {..<length xs})
[PROOF STEP]
by (subst map_pmf_of_set) (auto simp add: map_pmf_of_set atLeast0LessThan lessThan_empty_iff)
[PROOF STATE]
proof (state)
this:
pmf_of_multiset (image_mset ((!) xs) (mset [0..<length xs])) = map_pmf ((!) xs) (pmf_of_set {..<length xs})

goal (1 subgoal):
 1. shuffle xs = pmf_of_set {..<length xs} \<bind> (\<lambda>i. let ys = swap xs 0 i in shuffle (tl ys) \<bind> (\<lambda>zs. return_pmf (hd ys # zs)))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
pmf_of_multiset (image_mset ((!) xs) (mset [0..<length xs])) = map_pmf ((!) xs) (pmf_of_set {..<length xs})

goal (1 subgoal):
 1. shuffle xs = pmf_of_set {..<length xs} \<bind> (\<lambda>i. let ys = swap xs 0 i in shuffle (tl ys) \<bind> (\<lambda>zs. return_pmf (hd ys # zs)))
[PROOF STEP]
have "do {x \<leftarrow> map_pmf ((!) xs) (pmf_of_set {..<length xs});
                 ys \<leftarrow> pmf_of_set (permutations_of_multiset (mset xs - {#x#}));
                 return_pmf (x # ys)
                } =
             do {i \<leftarrow> pmf_of_set {..<length xs};
                 ys \<leftarrow> pmf_of_set (permutations_of_multiset (mset xs - {#xs ! i#}));
                 return_pmf (xs ! i # ys)
                }"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map_pmf ((!) xs) (pmf_of_set {..<length xs}) \<bind> (\<lambda>x. pmf_of_set (permutations_of_multiset (mset xs - {#x#})) \<bind> (\<lambda>ys. return_pmf (x # ys))) = pmf_of_set {..<length xs} \<bind> (\<lambda>i. pmf_of_set (permutations_of_multiset (mset xs - {#xs ! i#})) \<bind> (\<lambda>ys. return_pmf (xs ! i # ys)))
[PROOF STEP]
by (simp add: map_pmf_def bind_assoc_pmf bind_return_pmf)
[PROOF STATE]
proof (state)
this:
map_pmf ((!) xs) (pmf_of_set {..<length xs}) \<bind> (\<lambda>x. pmf_of_set (permutations_of_multiset (mset xs - {#x#})) \<bind> (\<lambda>ys. return_pmf (x # ys))) = pmf_of_set {..<length xs} \<bind> (\<lambda>i. pmf_of_set (permutations_of_multiset (mset xs - {#xs ! i#})) \<bind> (\<lambda>ys. return_pmf (xs ! i # ys)))

goal (1 subgoal):
 1. shuffle xs = pmf_of_set {..<length xs} \<bind> (\<lambda>i. let ys = swap xs 0 i in shuffle (tl ys) \<bind> (\<lambda>zs. return_pmf (hd ys # zs)))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
map_pmf ((!) xs) (pmf_of_set {..<length xs}) \<bind> (\<lambda>x. pmf_of_set (permutations_of_multiset (mset xs - {#x#})) \<bind> (\<lambda>ys. return_pmf (x # ys))) = pmf_of_set {..<length xs} \<bind> (\<lambda>i. pmf_of_set (permutations_of_multiset (mset xs - {#xs ! i#})) \<bind> (\<lambda>ys. return_pmf (xs ! i # ys)))

goal (1 subgoal):
 1. shuffle xs = pmf_of_set {..<length xs} \<bind> (\<lambda>i. let ys = swap xs 0 i in shuffle (tl ys) \<bind> (\<lambda>zs. return_pmf (hd ys # zs)))
[PROOF STEP]
have "\<dots> = do {i \<leftarrow> pmf_of_set {..<length xs};
                      let ys = swap xs 0 i;
                      zs \<leftarrow> shuffle (tl (swap xs 0 i));
                      return_pmf (hd ys # zs)
                     }"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. pmf_of_set {..<length xs} \<bind> (\<lambda>i. pmf_of_set (permutations_of_multiset (mset xs - {#xs ! i#})) \<bind> (\<lambda>ys. return_pmf (xs ! i # ys))) = pmf_of_set {..<length xs} \<bind> (\<lambda>i. let ys = swap xs 0 i in shuffle (tl (swap xs 0 i)) \<bind> (\<lambda>zs. return_pmf (hd ys # zs)))
[PROOF STEP]
unfolding Let_def shuffle_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. pmf_of_set {..<length xs} \<bind> (\<lambda>i. pmf_of_set (permutations_of_multiset (mset xs - {#xs ! i#})) \<bind> (\<lambda>ys. return_pmf (xs ! i # ys))) = pmf_of_set {..<length xs} \<bind> (\<lambda>i. pmf_of_set (permutations_of_multiset (mset (tl (swap xs 0 i)))) \<bind> (\<lambda>zs. return_pmf (hd (swap xs 0 i) # zs)))
[PROOF STEP]
by (intro bind_pmf_cong refl, subst (asm) set_pmf_of_set)
       (auto simp: lessThan_empty_iff mset_tl mset_swap hd_swap_0)
[PROOF STATE]
proof (state)
this:
pmf_of_set {..<length xs} \<bind> (\<lambda>i. pmf_of_set (permutations_of_multiset (mset xs - {#xs ! i#})) \<bind> (\<lambda>ys. return_pmf (xs ! i # ys))) = pmf_of_set {..<length xs} \<bind> (\<lambda>i. let ys = swap xs 0 i in shuffle (tl (swap xs 0 i)) \<bind> (\<lambda>zs. return_pmf (hd ys # zs)))

goal (1 subgoal):
 1. shuffle xs = pmf_of_set {..<length xs} \<bind> (\<lambda>i. let ys = swap xs 0 i in shuffle (tl ys) \<bind> (\<lambda>zs. return_pmf (hd ys # zs)))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
shuffle xs = pmf_of_set {..<length xs} \<bind> (\<lambda>i. let ys = swap xs 0 i in shuffle (tl (swap xs 0 i)) \<bind> (\<lambda>zs. return_pmf (hd ys # zs)))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
shuffle xs = pmf_of_set {..<length xs} \<bind> (\<lambda>i. let ys = swap xs 0 i in shuffle (tl (swap xs 0 i)) \<bind> (\<lambda>zs. return_pmf (hd ys # zs)))

goal (1 subgoal):
 1. shuffle xs = pmf_of_set {..<length xs} \<bind> (\<lambda>i. let ys = swap xs 0 i in shuffle (tl ys) \<bind> (\<lambda>zs. return_pmf (hd ys # zs)))
[PROOF STEP]
by (simp add: Let_def)
[PROOF STATE]
proof (state)
this:
shuffle xs = pmf_of_set {..<length xs} \<bind> (\<lambda>i. let ys = swap xs 0 i in shuffle (tl ys) \<bind> (\<lambda>zs. return_pmf (hd ys # zs)))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma emeasure_lborel_cbox_eq:
  "emeasure lborel (cbox l u) = (if \<forall>b\<in>Basis. l \<bullet> b \<le> u \<bullet> b then \<Prod>b\<in>Basis. (u - l) \<bullet> b else 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. emeasure lborel (cbox l u) = ennreal (if \<forall>b\<in>Basis. l \<bullet> b \<le> u \<bullet> b then prod ((\<bullet>) (u - l)) Basis else 0)
[PROOF STEP]
using box_eq_empty(2)[THEN iffD2, of u l]
[PROOF STATE]
proof (prove)
using this:
\<exists>i\<in>Basis. u \<bullet> i < l \<bullet> i \<Longrightarrow> cbox l u = {}

goal (1 subgoal):
 1. emeasure lborel (cbox l u) = ennreal (if \<forall>b\<in>Basis. l \<bullet> b \<le> u \<bullet> b then prod ((\<bullet>) (u - l)) Basis else 0)
[PROOF STEP]
by (auto simp: not_le)


[STATEMENT]
lemma solve_rat_fps_aux:
  fixes p :: "'a :: {field_char_0,field_gcd} poly" and cs :: "('a \<times> nat) list"
  assumes distinct: "distinct (map fst cs)"
  assumes azs: "(a, zs) = poly_pfd_simple p cs"
  assumes nz: "0 \<notin> fst ` set cs"
  shows "fps_of_poly p / fps_of_poly (\<Prod>(c,n)\<leftarrow>cs. [:1,-c:]^Suc n) =
           Abs_fps (\<lambda>k. coeff a k + (\<Sum>i<length cs. poly (\<Sum>j\<le>snd (cs ! i).
                   (inverse_irred_power_poly (zs ! i ! j) (snd (cs ! i)+1 - j)))
               (of_nat k) * (fst (cs ! i)) ^ k))" (is "_ = ?rhs")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fps_of_poly p / fps_of_poly (\<Prod>(c, n)\<leftarrow>cs. [:1::'a, - c:] ^ Suc n) = Abs_fps (\<lambda>k. coeff a k + (\<Sum>i<length cs. poly (\<Sum>j\<le>snd (cs ! i). inverse_irred_power_poly (zs ! i ! j) (snd (cs ! i) + 1 - j)) (of_nat k) * fst (cs ! i) ^ k))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. fps_of_poly p / fps_of_poly (\<Prod>(c, n)\<leftarrow>cs. [:1::'a, - c:] ^ Suc n) = Abs_fps (\<lambda>k. coeff a k + (\<Sum>i<length cs. poly (\<Sum>j\<le>snd (cs ! i). inverse_irred_power_poly (zs ! i ! j) (snd (cs ! i) + 1 - j)) (of_nat k) * fst (cs ! i) ^ k))
[PROOF STEP]
interpret pfd_homomorphism "fps_of_poly :: 'a poly \<Rightarrow> 'a fps"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. pfd_homomorphism fps_of_poly
[PROOF STEP]
by standard (auto simp: fps_of_poly_add fps_of_poly_mult)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. fps_of_poly p / fps_of_poly (\<Prod>(c, n)\<leftarrow>cs. [:1::'a, - c:] ^ Suc n) = Abs_fps (\<lambda>k. coeff a k + (\<Sum>i<length cs. poly (\<Sum>j\<le>snd (cs ! i). inverse_irred_power_poly (zs ! i ! j) (snd (cs ! i) + 1 - j)) (of_nat k) * fst (cs ! i) ^ k))
[PROOF STEP]
from distinct
[PROOF STATE]
proof (chain)
picking this:
distinct (map fst cs)
[PROOF STEP]
have distinct': "(a, b1) \<in> set cs \<Longrightarrow>
    (a, b2) \<in> set cs \<Longrightarrow> b1 = b2" for a b1 b2
[PROOF STATE]
proof (prove)
using this:
distinct (map fst cs)

goal (1 subgoal):
 1. \<lbrakk>(a, b1) \<in> set cs; (a, b2) \<in> set cs\<rbrakk> \<Longrightarrow> b1 = b2
[PROOF STEP]
by (metis (no_types, opaque_lifting) Some_eq_map_of_iff image_set in_set_zipE insert_iff list.simps(15) map_of_Cons_code(2) map_of_SomeD nz snd_conv)
[PROOF STATE]
proof (state)
this:
\<lbrakk>(?a, ?b1.0) \<in> set cs; (?a, ?b2.0) \<in> set cs\<rbrakk> \<Longrightarrow> ?b1.0 = ?b2.0

goal (1 subgoal):
 1. fps_of_poly p / fps_of_poly (\<Prod>(c, n)\<leftarrow>cs. [:1::'a, - c:] ^ Suc n) = Abs_fps (\<lambda>k. coeff a k + (\<Sum>i<length cs. poly (\<Sum>j\<le>snd (cs ! i). inverse_irred_power_poly (zs ! i ! j) (snd (cs ! i) + 1 - j)) (of_nat k) * fst (cs ! i) ^ k))
[PROOF STEP]
from nz
[PROOF STATE]
proof (chain)
picking this:
(0::'a) \<notin> fst ` set cs
[PROOF STEP]
have nz': "(0, b) \<notin> set cs" for b
[PROOF STATE]
proof (prove)
using this:
(0::'a) \<notin> fst ` set cs

goal (1 subgoal):
 1. (0::'a, b) \<notin> set cs
[PROOF STEP]
by (auto simp add: image_iff)
[PROOF STATE]
proof (state)
this:
(0::'a, ?b) \<notin> set cs

goal (1 subgoal):
 1. fps_of_poly p / fps_of_poly (\<Prod>(c, n)\<leftarrow>cs. [:1::'a, - c:] ^ Suc n) = Abs_fps (\<lambda>k. coeff a k + (\<Sum>i<length cs. poly (\<Sum>j\<le>snd (cs ! i). inverse_irred_power_poly (zs ! i ! j) (snd (cs ! i) + 1 - j)) (of_nat k) * fst (cs ! i) ^ k))
[PROOF STEP]
define n where "n = length cs"
[PROOF STATE]
proof (state)
this:
n = length cs

goal (1 subgoal):
 1. fps_of_poly p / fps_of_poly (\<Prod>(c, n)\<leftarrow>cs. [:1::'a, - c:] ^ Suc n) = Abs_fps (\<lambda>k. coeff a k + (\<Sum>i<length cs. poly (\<Sum>j\<le>snd (cs ! i). inverse_irred_power_poly (zs ! i ! j) (snd (cs ! i) + 1 - j)) (of_nat k) * fst (cs ! i) ^ k))
[PROOF STEP]
let ?g = "\<lambda>(c, n). [:1, - c:] ^ Suc n"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. fps_of_poly p / fps_of_poly (\<Prod>(c, n)\<leftarrow>cs. [:1::'a, - c:] ^ Suc n) = Abs_fps (\<lambda>k. coeff a k + (\<Sum>i<length cs. poly (\<Sum>j\<le>snd (cs ! i). inverse_irred_power_poly (zs ! i ! j) (snd (cs ! i) + 1 - j)) (of_nat k) * fst (cs ! i) ^ k))
[PROOF STEP]
have "inj_on ?g (set cs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inj_on (\<lambda>(c, n). [:1::'a, - c:] ^ Suc n) (set cs)
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x \<in> set cs; y \<in> set cs; (case x of (c, n) \<Rightarrow> [:1::'a, - c:] ^ Suc n) = (case y of (c, n) \<Rightarrow> [:1::'a, - c:] ^ Suc n)\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
fix x y
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x \<in> set cs; y \<in> set cs; (case x of (c, n) \<Rightarrow> [:1::'a, - c:] ^ Suc n) = (case y of (c, n) \<Rightarrow> [:1::'a, - c:] ^ Suc n)\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
assume "x \<in> set cs" "y \<in> set cs" "?g x = ?g y"
[PROOF STATE]
proof (state)
this:
x \<in> set cs
y \<in> set cs
(case x of (c, n) \<Rightarrow> [:1::'a, - c:] ^ Suc n) = (case y of (c, n) \<Rightarrow> [:1::'a, - c:] ^ Suc n)

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x \<in> set cs; y \<in> set cs; (case x of (c, n) \<Rightarrow> [:1::'a, - c:] ^ Suc n) = (case y of (c, n) \<Rightarrow> [:1::'a, - c:] ^ Suc n)\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
x \<in> set cs
y \<in> set cs
(case x of (c, n) \<Rightarrow> [:1::'a, - c:] ^ Suc n) = (case y of (c, n) \<Rightarrow> [:1::'a, - c:] ^ Suc n)

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x \<in> set cs; y \<in> set cs; (case x of (c, n) \<Rightarrow> [:1::'a, - c:] ^ Suc n) = (case y of (c, n) \<Rightarrow> [:1::'a, - c:] ^ Suc n)\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
obtain c1 n1 c2 n2 where [simp]: "x = (c1, n1)" "y = (c2, n2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>c1 n1 c2 n2. \<lbrakk>x = (c1, n1); y = (c2, n2)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (cases x, cases y)
[PROOF STATE]
proof (state)
this:
x = (c1, n1)
y = (c2, n2)

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x \<in> set cs; y \<in> set cs; (case x of (c, n) \<Rightarrow> [:1::'a, - c:] ^ Suc n) = (case y of (c, n) \<Rightarrow> [:1::'a, - c:] ^ Suc n)\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
x \<in> set cs
y \<in> set cs
(case x of (c, n) \<Rightarrow> [:1::'a, - c:] ^ Suc n) = (case y of (c, n) \<Rightarrow> [:1::'a, - c:] ^ Suc n)
x = (c1, n1)
y = (c2, n2)
[PROOF STEP]
have in_cs: "(c1, n1) \<in> set cs"
      "(c2, n2) \<in> set cs"
      and eq: "[:1, - c1:] ^ Suc n1 = [:1, - c2:] ^ Suc n2"
[PROOF STATE]
proof (prove)
using this:
x \<in> set cs
y \<in> set cs
(case x of (c, n) \<Rightarrow> [:1::'a, - c:] ^ Suc n) = (case y of (c, n) \<Rightarrow> [:1::'a, - c:] ^ Suc n)
x = (c1, n1)
y = (c2, n2)

goal (1 subgoal):
 1. ((c1, n1) \<in> set cs &&& (c2, n2) \<in> set cs) &&& [:1::'a, - c1:] ^ Suc n1 = [:1::'a, - c2:] ^ Suc n2
[PROOF STEP]
by simp_all
[PROOF STATE]
proof (state)
this:
(c1, n1) \<in> set cs
(c2, n2) \<in> set cs
[:1::'a, - c1:] ^ Suc n1 = [:1::'a, - c2:] ^ Suc n2

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x \<in> set cs; y \<in> set cs; (case x of (c, n) \<Rightarrow> [:1::'a, - c:] ^ Suc n) = (case y of (c, n) \<Rightarrow> [:1::'a, - c:] ^ Suc n)\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
with nz
[PROOF STATE]
proof (chain)
picking this:
(0::'a) \<notin> fst ` set cs
(c1, n1) \<in> set cs
(c2, n2) \<in> set cs
[:1::'a, - c1:] ^ Suc n1 = [:1::'a, - c2:] ^ Suc n2
[PROOF STEP]
have [simp]: "c1 \<noteq> 0" "c2 \<noteq> 0"
[PROOF STATE]
proof (prove)
using this:
(0::'a) \<notin> fst ` set cs
(c1, n1) \<in> set cs
(c2, n2) \<in> set cs
[:1::'a, - c1:] ^ Suc n1 = [:1::'a, - c2:] ^ Suc n2

goal (1 subgoal):
 1. c1 \<noteq> (0::'a) &&& c2 \<noteq> (0::'a)
[PROOF STEP]
by (auto simp add: image_iff)
[PROOF STATE]
proof (state)
this:
c1 \<noteq> (0::'a)
c2 \<noteq> (0::'a)

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x \<in> set cs; y \<in> set cs; (case x of (c, n) \<Rightarrow> [:1::'a, - c:] ^ Suc n) = (case y of (c, n) \<Rightarrow> [:1::'a, - c:] ^ Suc n)\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
have "Suc n1 = degree ([:1, - c1:] ^ Suc n1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Suc n1 = degree ([:1::'a, - c1:] ^ Suc n1)
[PROOF STEP]
by (simp add: degree_power_eq del: power_Suc)
[PROOF STATE]
proof (state)
this:
Suc n1 = degree ([:1::'a, - c1:] ^ Suc n1)

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x \<in> set cs; y \<in> set cs; (case x of (c, n) \<Rightarrow> [:1::'a, - c:] ^ Suc n) = (case y of (c, n) \<Rightarrow> [:1::'a, - c:] ^ Suc n)\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
Suc n1 = degree ([:1::'a, - c1:] ^ Suc n1)

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x \<in> set cs; y \<in> set cs; (case x of (c, n) \<Rightarrow> [:1::'a, - c:] ^ Suc n) = (case y of (c, n) \<Rightarrow> [:1::'a, - c:] ^ Suc n)\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
have "\<dots> = degree ([:1, - c2:] ^ Suc n2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. degree ([:1::'a, - c1:] ^ Suc n1) = degree ([:1::'a, - c2:] ^ Suc n2)
[PROOF STEP]
using eq
[PROOF STATE]
proof (prove)
using this:
[:1::'a, - c1:] ^ Suc n1 = [:1::'a, - c2:] ^ Suc n2

goal (1 subgoal):
 1. degree ([:1::'a, - c1:] ^ Suc n1) = degree ([:1::'a, - c2:] ^ Suc n2)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
degree ([:1::'a, - c1:] ^ Suc n1) = degree ([:1::'a, - c2:] ^ Suc n2)

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x \<in> set cs; y \<in> set cs; (case x of (c, n) \<Rightarrow> [:1::'a, - c:] ^ Suc n) = (case y of (c, n) \<Rightarrow> [:1::'a, - c:] ^ Suc n)\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
degree ([:1::'a, - c1:] ^ Suc n1) = degree ([:1::'a, - c2:] ^ Suc n2)

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x \<in> set cs; y \<in> set cs; (case x of (c, n) \<Rightarrow> [:1::'a, - c:] ^ Suc n) = (case y of (c, n) \<Rightarrow> [:1::'a, - c:] ^ Suc n)\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
have "\<dots> = Suc n2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. degree ([:1::'a, - c2:] ^ Suc n2) = Suc n2
[PROOF STEP]
by (simp add: degree_power_eq del: power_Suc)
[PROOF STATE]
proof (state)
this:
degree ([:1::'a, - c2:] ^ Suc n2) = Suc n2

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x \<in> set cs; y \<in> set cs; (case x of (c, n) \<Rightarrow> [:1::'a, - c:] ^ Suc n) = (case y of (c, n) \<Rightarrow> [:1::'a, - c:] ^ Suc n)\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
Suc n1 = Suc n2
[PROOF STEP]
have "n1 = n2"
[PROOF STATE]
proof (prove)
using this:
Suc n1 = Suc n2

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

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x \<in> set cs; y \<in> set cs; (case x of (c, n) \<Rightarrow> [:1::'a, - c:] ^ Suc n) = (case y of (c, n) \<Rightarrow> [:1::'a, - c:] ^ Suc n)\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
n1 = n2
[PROOF STEP]
have "0 = poly ([:1, - c1:] ^ Suc n1) (1 / c1)"
[PROOF STATE]
proof (prove)
using this:
n1 = n2

goal (1 subgoal):
 1. (0::'a) = poly ([:1::'a, - c1:] ^ Suc n1) ((1::'a) / c1)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(0::'a) = poly ([:1::'a, - c1:] ^ Suc n1) ((1::'a) / c1)

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x \<in> set cs; y \<in> set cs; (case x of (c, n) \<Rightarrow> [:1::'a, - c:] ^ Suc n) = (case y of (c, n) \<Rightarrow> [:1::'a, - c:] ^ Suc n)\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(0::'a) = poly ([:1::'a, - c1:] ^ Suc n1) ((1::'a) / c1)

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x \<in> set cs; y \<in> set cs; (case x of (c, n) \<Rightarrow> [:1::'a, - c:] ^ Suc n) = (case y of (c, n) \<Rightarrow> [:1::'a, - c:] ^ Suc n)\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
have "\<dots> = poly ([:1, - c2:] ^ Suc n2) (1 / c1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly ([:1::'a, - c1:] ^ Suc n1) ((1::'a) / c1) = poly ([:1::'a, - c2:] ^ Suc n2) ((1::'a) / c1)
[PROOF STEP]
using eq
[PROOF STATE]
proof (prove)
using this:
[:1::'a, - c1:] ^ Suc n1 = [:1::'a, - c2:] ^ Suc n2

goal (1 subgoal):
 1. poly ([:1::'a, - c1:] ^ Suc n1) ((1::'a) / c1) = poly ([:1::'a, - c2:] ^ Suc n2) ((1::'a) / c1)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
poly ([:1::'a, - c1:] ^ Suc n1) ((1::'a) / c1) = poly ([:1::'a, - c2:] ^ Suc n2) ((1::'a) / c1)

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x \<in> set cs; y \<in> set cs; (case x of (c, n) \<Rightarrow> [:1::'a, - c:] ^ Suc n) = (case y of (c, n) \<Rightarrow> [:1::'a, - c:] ^ Suc n)\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(0::'a) = poly ([:1::'a, - c2:] ^ Suc n2) ((1::'a) / c1)
[PROOF STEP]
show "x = y"
[PROOF STATE]
proof (prove)
using this:
(0::'a) = poly ([:1::'a, - c2:] ^ Suc n2) ((1::'a) / c1)

goal (1 subgoal):
 1. x = y
[PROOF STEP]
using \<open>n1 = n2\<close>
[PROOF STATE]
proof (prove)
using this:
(0::'a) = poly ([:1::'a, - c2:] ^ Suc n2) ((1::'a) / c1)
n1 = n2

goal (1 subgoal):
 1. x = y
[PROOF STEP]
by (auto simp: field_simps)
[PROOF STATE]
proof (state)
this:
x = y

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
inj_on (\<lambda>(c, n). [:1::'a, - c:] ^ Suc n) (set cs)

goal (1 subgoal):
 1. fps_of_poly p / fps_of_poly (\<Prod>(c, n)\<leftarrow>cs. [:1::'a, - c:] ^ Suc n) = Abs_fps (\<lambda>k. coeff a k + (\<Sum>i<length cs. poly (\<Sum>j\<le>snd (cs ! i). inverse_irred_power_poly (zs ! i ! j) (snd (cs ! i) + 1 - j)) (of_nat k) * fst (cs ! i) ^ k))
[PROOF STEP]
with distinct
[PROOF STATE]
proof (chain)
picking this:
distinct (map fst cs)
inj_on (\<lambda>(c, n). [:1::'a, - c:] ^ Suc n) (set cs)
[PROOF STEP]
have distinct': "distinct (map ?g cs)"
[PROOF STATE]
proof (prove)
using this:
distinct (map fst cs)
inj_on (\<lambda>(c, n). [:1::'a, - c:] ^ Suc n) (set cs)

goal (1 subgoal):
 1. distinct (map (\<lambda>(c, n). [:1::'a, - c:] ^ Suc n) cs)
[PROOF STEP]
by (simp add: distinct_map del: power_Suc)
[PROOF STATE]
proof (state)
this:
distinct (map (\<lambda>(c, n). [:1::'a, - c:] ^ Suc n) cs)

goal (1 subgoal):
 1. fps_of_poly p / fps_of_poly (\<Prod>(c, n)\<leftarrow>cs. [:1::'a, - c:] ^ Suc n) = Abs_fps (\<lambda>k. coeff a k + (\<Sum>i<length cs. poly (\<Sum>j\<le>snd (cs ! i). inverse_irred_power_poly (zs ! i ! j) (snd (cs ! i) + 1 - j)) (of_nat k) * fst (cs ! i) ^ k))
[PROOF STEP]
from nz' distinct
[PROOF STATE]
proof (chain)
picking this:
(0::'a, ?b) \<notin> set cs
distinct (map fst cs)
[PROOF STEP]
have coprime: "pairwise coprime (?g ` set cs)"
[PROOF STATE]
proof (prove)
using this:
(0::'a, ?b) \<notin> set cs
distinct (map fst cs)

goal (1 subgoal):
 1. pairwise coprime ((\<lambda>(c, n). [:1::'a, - c:] ^ Suc n) ` set cs)
[PROOF STEP]
by (auto intro!: pairwise_imageI coprime_linear_poly' simp add: eq_key_imp_eq_value
      simp del: power_Suc)
[PROOF STATE]
proof (state)
this:
pairwise coprime ((\<lambda>(c, n). [:1::'a, - c:] ^ Suc n) ` set cs)

goal (1 subgoal):
 1. fps_of_poly p / fps_of_poly (\<Prod>(c, n)\<leftarrow>cs. [:1::'a, - c:] ^ Suc n) = Abs_fps (\<lambda>k. coeff a k + (\<Sum>i<length cs. poly (\<Sum>j\<le>snd (cs ! i). inverse_irred_power_poly (zs ! i ! j) (snd (cs ! i) + 1 - j)) (of_nat k) * fst (cs ! i) ^ k))
[PROOF STEP]
have [simp]: "length zs = n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length zs = n
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
distinct (map fst cs)
(a, zs) = poly_pfd_simple p cs
(0::'a) \<notin> fst ` set cs

goal (1 subgoal):
 1. length zs = n
[PROOF STEP]
by (simp add: poly_pfd_simple_def n_def split: if_split_asm)
[PROOF STATE]
proof (state)
this:
length zs = n

goal (1 subgoal):
 1. fps_of_poly p / fps_of_poly (\<Prod>(c, n)\<leftarrow>cs. [:1::'a, - c:] ^ Suc n) = Abs_fps (\<lambda>k. coeff a k + (\<Sum>i<length cs. poly (\<Sum>j\<le>snd (cs ! i). inverse_irred_power_poly (zs ! i ! j) (snd (cs ! i) + 1 - j)) (of_nat k) * fst (cs ! i) ^ k))
[PROOF STEP]
have [simp]: "i < length cs \<Longrightarrow> length (zs!i) = snd (cs!i)+1" for i
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. i < length cs \<Longrightarrow> length (zs ! i) = snd (cs ! i) + 1
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
distinct (map fst cs)
(a, zs) = poly_pfd_simple p cs
(0::'a) \<notin> fst ` set cs

goal (1 subgoal):
 1. i < length cs \<Longrightarrow> length (zs ! i) = snd (cs ! i) + 1
[PROOF STEP]
by (simp add: poly_pfd_simple_def Let_def case_prod_unfold split: if_split_asm)
[PROOF STATE]
proof (state)
this:
?i1 < length cs \<Longrightarrow> length (zs ! ?i1) = snd (cs ! ?i1) + 1

goal (1 subgoal):
 1. fps_of_poly p / fps_of_poly (\<Prod>(c, n)\<leftarrow>cs. [:1::'a, - c:] ^ Suc n) = Abs_fps (\<lambda>k. coeff a k + (\<Sum>i<length cs. poly (\<Sum>j\<le>snd (cs ! i). inverse_irred_power_poly (zs ! i ! j) (snd (cs ! i) + 1 - j)) (of_nat k) * fst (cs ! i) ^ k))
[PROOF STEP]
let ?f = "\<lambda>(c, n). ([:1,-c:], n)"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. fps_of_poly p / fps_of_poly (\<Prod>(c, n)\<leftarrow>cs. [:1::'a, - c:] ^ Suc n) = Abs_fps (\<lambda>k. coeff a k + (\<Sum>i<length cs. poly (\<Sum>j\<le>snd (cs ! i). inverse_irred_power_poly (zs ! i ! j) (snd (cs ! i) + 1 - j)) (of_nat k) * fst (cs ! i) ^ k))
[PROOF STEP]
let ?cs' = "map ?f cs"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. fps_of_poly p / fps_of_poly (\<Prod>(c, n)\<leftarrow>cs. [:1::'a, - c:] ^ Suc n) = Abs_fps (\<lambda>k. coeff a k + (\<Sum>i<length cs. poly (\<Sum>j\<le>snd (cs ! i). inverse_irred_power_poly (zs ! i ! j) (snd (cs ! i) + 1 - j)) (of_nat k) * fst (cs ! i) ^ k))
[PROOF STEP]
have "fps_of_poly (fst (poly_pfd_simple p cs)) +
          (\<Sum>i<length ?cs'. \<Sum>j\<le>snd (?cs' ! i).
               from_decomp (map (map (\<lambda>c. [:c:])) (snd (poly_pfd_simple p cs)) ! i ! j)
                           (fst (?cs' ! i)) (snd (?cs' ! i)+1 - j)) =
          fps_of_poly p / fps_of_poly (\<Prod>(x, n)\<leftarrow>?cs'. x ^ Suc n)"
          (is "?A = ?B")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fps_of_poly (fst (poly_pfd_simple p cs)) + (\<Sum>i<length (map (\<lambda>(c, n). ([:1::'a, - c:], n)) cs). \<Sum>j\<le>snd (map (\<lambda>(c, n). ([:1::'a, - c:], n)) cs ! i). from_decomp (map (map (\<lambda>c. [:c:])) (snd (poly_pfd_simple p cs)) ! i ! j) (fst (map (\<lambda>(c, n). ([:1::'a, - c:], n)) cs ! i)) (snd (map (\<lambda>(c, n). ([:1::'a, - c:], n)) cs ! i) + 1 - j)) = fps_of_poly p / fps_of_poly (\<Prod>(x, n)\<leftarrow>map (\<lambda>(c, n). ([:1::'a, - c:], n)) cs. x ^ Suc n)
[PROOF STEP]
using nz distinct' coprime
[PROOF STATE]
proof (prove)
using this:
(0::'a) \<notin> fst ` set cs
distinct (map (\<lambda>(c, n). [:1::'a, - c:] ^ Suc n) cs)
pairwise coprime ((\<lambda>(c, n). [:1::'a, - c:] ^ Suc n) ` set cs)

goal (1 subgoal):
 1. fps_of_poly (fst (poly_pfd_simple p cs)) + (\<Sum>i<length (map (\<lambda>(c, n). ([:1::'a, - c:], n)) cs). \<Sum>j\<le>snd (map (\<lambda>(c, n). ([:1::'a, - c:], n)) cs ! i). from_decomp (map (map (\<lambda>c. [:c:])) (snd (poly_pfd_simple p cs)) ! i ! j) (fst (map (\<lambda>(c, n). ([:1::'a, - c:], n)) cs ! i)) (snd (map (\<lambda>(c, n). ([:1::'a, - c:], n)) cs ! i) + 1 - j)) = fps_of_poly p / fps_of_poly (\<Prod>(x, n)\<leftarrow>map (\<lambda>(c, n). ([:1::'a, - c:], n)) cs. x ^ Suc n)
[PROOF STEP]
by (intro partial_fraction_decomposition poly_pfd_simple)
       (force simp: o_def case_prod_unfold simp del: power_Suc)+
[PROOF STATE]
proof (state)
this:
fps_of_poly (fst (poly_pfd_simple p cs)) + (\<Sum>i<length (map (\<lambda>(c, n). ([:1::'a, - c:], n)) cs). \<Sum>j\<le>snd (map (\<lambda>(c, n). ([:1::'a, - c:], n)) cs ! i). from_decomp (map (map (\<lambda>c. [:c:])) (snd (poly_pfd_simple p cs)) ! i ! j) (fst (map (\<lambda>(c, n). ([:1::'a, - c:], n)) cs ! i)) (snd (map (\<lambda>(c, n). ([:1::'a, - c:], n)) cs ! i) + 1 - j)) = fps_of_poly p / fps_of_poly (\<Prod>(x, n)\<leftarrow>map (\<lambda>(c, n). ([:1::'a, - c:], n)) cs. x ^ Suc n)

goal (1 subgoal):
 1. fps_of_poly p / fps_of_poly (\<Prod>(c, n)\<leftarrow>cs. [:1::'a, - c:] ^ Suc n) = Abs_fps (\<lambda>k. coeff a k + (\<Sum>i<length cs. poly (\<Sum>j\<le>snd (cs ! i). inverse_irred_power_poly (zs ! i ! j) (snd (cs ! i) + 1 - j)) (of_nat k) * fst (cs ! i) ^ k))
[PROOF STEP]
note this [symmetric]
[PROOF STATE]
proof (state)
this:
fps_of_poly p / fps_of_poly (\<Prod>(x, n)\<leftarrow>map (\<lambda>(c, n). ([:1::'a, - c:], n)) cs. x ^ Suc n) = fps_of_poly (fst (poly_pfd_simple p cs)) + (\<Sum>i<length (map (\<lambda>(c, n). ([:1::'a, - c:], n)) cs). \<Sum>j\<le>snd (map (\<lambda>(c, n). ([:1::'a, - c:], n)) cs ! i). from_decomp (map (map (\<lambda>c. [:c:])) (snd (poly_pfd_simple p cs)) ! i ! j) (fst (map (\<lambda>(c, n). ([:1::'a, - c:], n)) cs ! i)) (snd (map (\<lambda>(c, n). ([:1::'a, - c:], n)) cs ! i) + 1 - j))

goal (1 subgoal):
 1. fps_of_poly p / fps_of_poly (\<Prod>(c, n)\<leftarrow>cs. [:1::'a, - c:] ^ Suc n) = Abs_fps (\<lambda>k. coeff a k + (\<Sum>i<length cs. poly (\<Sum>j\<le>snd (cs ! i). inverse_irred_power_poly (zs ! i ! j) (snd (cs ! i) + 1 - j)) (of_nat k) * fst (cs ! i) ^ k))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
fps_of_poly p / fps_of_poly (\<Prod>(x, n)\<leftarrow>map (\<lambda>(c, n). ([:1::'a, - c:], n)) cs. x ^ Suc n) = fps_of_poly (fst (poly_pfd_simple p cs)) + (\<Sum>i<length (map (\<lambda>(c, n). ([:1::'a, - c:], n)) cs). \<Sum>j\<le>snd (map (\<lambda>(c, n). ([:1::'a, - c:], n)) cs ! i). from_decomp (map (map (\<lambda>c. [:c:])) (snd (poly_pfd_simple p cs)) ! i ! j) (fst (map (\<lambda>(c, n). ([:1::'a, - c:], n)) cs ! i)) (snd (map (\<lambda>(c, n). ([:1::'a, - c:], n)) cs ! i) + 1 - j))

goal (1 subgoal):
 1. fps_of_poly p / fps_of_poly (\<Prod>(c, n)\<leftarrow>cs. [:1::'a, - c:] ^ Suc n) = Abs_fps (\<lambda>k. coeff a k + (\<Sum>i<length cs. poly (\<Sum>j\<le>snd (cs ! i). inverse_irred_power_poly (zs ! i ! j) (snd (cs ! i) + 1 - j)) (of_nat k) * fst (cs ! i) ^ k))
[PROOF STEP]
from azs [symmetric]
[PROOF STATE]
proof (chain)
picking this:
poly_pfd_simple p cs = (a, zs)
[PROOF STEP]
have "?A = fps_of_poly a + (\<Sum>i<n. \<Sum>j\<le>snd (cs ! i). from_decomp
                  (map (map (\<lambda>c. [:c:])) zs ! i ! j) [:1,-fst (cs ! i):] (snd (cs ! i)+1 - j))"
      (is "_ = _ + ?S")
[PROOF STATE]
proof (prove)
using this:
poly_pfd_simple p cs = (a, zs)

goal (1 subgoal):
 1. fps_of_poly (fst (poly_pfd_simple p cs)) + (\<Sum>i<length (map (\<lambda>(c, n). ([:1::'a, - c:], n)) cs). \<Sum>j\<le>snd (map (\<lambda>(c, n). ([:1::'a, - c:], n)) cs ! i). from_decomp (map (map (\<lambda>c. [:c:])) (snd (poly_pfd_simple p cs)) ! i ! j) (fst (map (\<lambda>(c, n). ([:1::'a, - c:], n)) cs ! i)) (snd (map (\<lambda>(c, n). ([:1::'a, - c:], n)) cs ! i) + 1 - j)) = fps_of_poly a + (\<Sum>i<n. \<Sum>j\<le>snd (cs ! i). from_decomp (map (map (\<lambda>c. [:c:])) zs ! i ! j) [:1::'a, - fst (cs ! i):] (snd (cs ! i) + 1 - j))
[PROOF STEP]
by (simp add: case_prod_unfold Let_def n_def)
[PROOF STATE]
proof (state)
this:
fps_of_poly (fst (poly_pfd_simple p cs)) + (\<Sum>i<length (map (\<lambda>(c, n). ([:1::'a, - c:], n)) cs). \<Sum>j\<le>snd (map (\<lambda>(c, n). ([:1::'a, - c:], n)) cs ! i). from_decomp (map (map (\<lambda>c. [:c:])) (snd (poly_pfd_simple p cs)) ! i ! j) (fst (map (\<lambda>(c, n). ([:1::'a, - c:], n)) cs ! i)) (snd (map (\<lambda>(c, n). ([:1::'a, - c:], n)) cs ! i) + 1 - j)) = fps_of_poly a + (\<Sum>i<n. \<Sum>j\<le>snd (cs ! i). from_decomp (map (map (\<lambda>c. [:c:])) zs ! i ! j) [:1::'a, - fst (cs ! i):] (snd (cs ! i) + 1 - j))

goal (1 subgoal):
 1. fps_of_poly p / fps_of_poly (\<Prod>(c, n)\<leftarrow>cs. [:1::'a, - c:] ^ Suc n) = Abs_fps (\<lambda>k. coeff a k + (\<Sum>i<length cs. poly (\<Sum>j\<le>snd (cs ! i). inverse_irred_power_poly (zs ! i ! j) (snd (cs ! i) + 1 - j)) (of_nat k) * fst (cs ! i) ^ k))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
fps_of_poly (fst (poly_pfd_simple p cs)) + (\<Sum>i<length (map (\<lambda>(c, n). ([:1::'a, - c:], n)) cs). \<Sum>j\<le>snd (map (\<lambda>(c, n). ([:1::'a, - c:], n)) cs ! i). from_decomp (map (map (\<lambda>c. [:c:])) (snd (poly_pfd_simple p cs)) ! i ! j) (fst (map (\<lambda>(c, n). ([:1::'a, - c:], n)) cs ! i)) (snd (map (\<lambda>(c, n). ([:1::'a, - c:], n)) cs ! i) + 1 - j)) = fps_of_poly a + (\<Sum>i<n. \<Sum>j\<le>snd (cs ! i). from_decomp (map (map (\<lambda>c. [:c:])) zs ! i ! j) [:1::'a, - fst (cs ! i):] (snd (cs ! i) + 1 - j))

goal (1 subgoal):
 1. fps_of_poly p / fps_of_poly (\<Prod>(c, n)\<leftarrow>cs. [:1::'a, - c:] ^ Suc n) = Abs_fps (\<lambda>k. coeff a k + (\<Sum>i<length cs. poly (\<Sum>j\<le>snd (cs ! i). inverse_irred_power_poly (zs ! i ! j) (snd (cs ! i) + 1 - j)) (of_nat k) * fst (cs ! i) ^ k))
[PROOF STEP]
have "?S = (\<Sum>i<length cs. \<Sum>j\<le>snd (cs ! i). fps_const (zs ! i ! j) /
                      ((1 - fps_const (fst (cs!i))*fps_X) ^ (snd (cs!i)+1 - j)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i<n. \<Sum>j\<le>snd (cs ! i). from_decomp (map (map (\<lambda>c. [:c:])) zs ! i ! j) [:1::'a, - fst (cs ! i):] (snd (cs ! i) + 1 - j)) = (\<Sum>i<length cs. \<Sum>j\<le>snd (cs ! i). fps_const (zs ! i ! j) / (1 - fps_const (fst (cs ! i)) * fps_X) ^ (snd (cs ! i) + 1 - j))
[PROOF STEP]
by (intro sum.cong refl)
       (auto simp: from_decomp_def map_nth n_def fps_of_poly_linear' fps_of_poly_simps
                    fps_const_neg [symmetric] mult_ac simp del: fps_const_neg)
[PROOF STATE]
proof (state)
this:
(\<Sum>i<n. \<Sum>j\<le>snd (cs ! i). from_decomp (map (map (\<lambda>c. [:c:])) zs ! i ! j) [:1::'a, - fst (cs ! i):] (snd (cs ! i) + 1 - j)) = (\<Sum>i<length cs. \<Sum>j\<le>snd (cs ! i). fps_const (zs ! i ! j) / (1 - fps_const (fst (cs ! i)) * fps_X) ^ (snd (cs ! i) + 1 - j))

goal (1 subgoal):
 1. fps_of_poly p / fps_of_poly (\<Prod>(c, n)\<leftarrow>cs. [:1::'a, - c:] ^ Suc n) = Abs_fps (\<lambda>k. coeff a k + (\<Sum>i<length cs. poly (\<Sum>j\<le>snd (cs ! i). inverse_irred_power_poly (zs ! i ! j) (snd (cs ! i) + 1 - j)) (of_nat k) * fst (cs ! i) ^ k))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>i<n. \<Sum>j\<le>snd (cs ! i). from_decomp (map (map (\<lambda>c. [:c:])) zs ! i ! j) [:1::'a, - fst (cs ! i):] (snd (cs ! i) + 1 - j)) = (\<Sum>i<length cs. \<Sum>j\<le>snd (cs ! i). fps_const (zs ! i ! j) / (1 - fps_const (fst (cs ! i)) * fps_X) ^ (snd (cs ! i) + 1 - j))

goal (1 subgoal):
 1. fps_of_poly p / fps_of_poly (\<Prod>(c, n)\<leftarrow>cs. [:1::'a, - c:] ^ Suc n) = Abs_fps (\<lambda>k. coeff a k + (\<Sum>i<length cs. poly (\<Sum>j\<le>snd (cs ! i). inverse_irred_power_poly (zs ! i ! j) (snd (cs ! i) + 1 - j)) (of_nat k) * fst (cs ! i) ^ k))
[PROOF STEP]
have "\<dots> = (\<Sum>i<length cs. \<Sum>j\<le>snd (cs ! i) .
                      Abs_fps (\<lambda>k. poly (inverse_irred_power_poly (zs ! i ! j)
                          (snd (cs ! i)+1 - j)) (of_nat k) * (fst (cs ! i)) ^ k))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i<length cs. \<Sum>j\<le>snd (cs ! i). fps_const (zs ! i ! j) / (1 - fps_const (fst (cs ! i)) * fps_X) ^ (snd (cs ! i) + 1 - j)) = (\<Sum>i<length cs. \<Sum>j\<le>snd (cs ! i). Abs_fps (\<lambda>k. poly (inverse_irred_power_poly (zs ! i ! j) (snd (cs ! i) + 1 - j)) (of_nat k) * fst (cs ! i) ^ k))
[PROOF STEP]
using nz
[PROOF STATE]
proof (prove)
using this:
(0::'a) \<notin> fst ` set cs

goal (1 subgoal):
 1. (\<Sum>i<length cs. \<Sum>j\<le>snd (cs ! i). fps_const (zs ! i ! j) / (1 - fps_const (fst (cs ! i)) * fps_X) ^ (snd (cs ! i) + 1 - j)) = (\<Sum>i<length cs. \<Sum>j\<le>snd (cs ! i). Abs_fps (\<lambda>k. poly (inverse_irred_power_poly (zs ! i ! j) (snd (cs ! i) + 1 - j)) (of_nat k) * fst (cs ! i) ^ k))
[PROOF STEP]
by (intro sum.cong refl one_minus_const_fps_X_neg_power'') auto
[PROOF STATE]
proof (state)
this:
(\<Sum>i<length cs. \<Sum>j\<le>snd (cs ! i). fps_const (zs ! i ! j) / (1 - fps_const (fst (cs ! i)) * fps_X) ^ (snd (cs ! i) + 1 - j)) = (\<Sum>i<length cs. \<Sum>j\<le>snd (cs ! i). Abs_fps (\<lambda>k. poly (inverse_irred_power_poly (zs ! i ! j) (snd (cs ! i) + 1 - j)) (of_nat k) * fst (cs ! i) ^ k))

goal (1 subgoal):
 1. fps_of_poly p / fps_of_poly (\<Prod>(c, n)\<leftarrow>cs. [:1::'a, - c:] ^ Suc n) = Abs_fps (\<lambda>k. coeff a k + (\<Sum>i<length cs. poly (\<Sum>j\<le>snd (cs ! i). inverse_irred_power_poly (zs ! i ! j) (snd (cs ! i) + 1 - j)) (of_nat k) * fst (cs ! i) ^ k))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>i<length cs. \<Sum>j\<le>snd (cs ! i). fps_const (zs ! i ! j) / (1 - fps_const (fst (cs ! i)) * fps_X) ^ (snd (cs ! i) + 1 - j)) = (\<Sum>i<length cs. \<Sum>j\<le>snd (cs ! i). Abs_fps (\<lambda>k. poly (inverse_irred_power_poly (zs ! i ! j) (snd (cs ! i) + 1 - j)) (of_nat k) * fst (cs ! i) ^ k))

goal (1 subgoal):
 1. fps_of_poly p / fps_of_poly (\<Prod>(c, n)\<leftarrow>cs. [:1::'a, - c:] ^ Suc n) = Abs_fps (\<lambda>k. coeff a k + (\<Sum>i<length cs. poly (\<Sum>j\<le>snd (cs ! i). inverse_irred_power_poly (zs ! i ! j) (snd (cs ! i) + 1 - j)) (of_nat k) * fst (cs ! i) ^ k))
[PROOF STEP]
have "fps_of_poly a + \<dots> = ?rhs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fps_of_poly a + (\<Sum>i<length cs. \<Sum>j\<le>snd (cs ! i). Abs_fps (\<lambda>k. poly (inverse_irred_power_poly (zs ! i ! j) (snd (cs ! i) + 1 - j)) (of_nat k) * fst (cs ! i) ^ k)) = Abs_fps (\<lambda>k. coeff a k + (\<Sum>i<length cs. poly (\<Sum>j\<le>snd (cs ! i). inverse_irred_power_poly (zs ! i ! j) (snd (cs ! i) + 1 - j)) (of_nat k) * fst (cs ! i) ^ k))
[PROOF STEP]
by (intro fps_ext) (simp_all add: sum_distrib_right fps_sum_nth poly_sum)
[PROOF STATE]
proof (state)
this:
fps_of_poly a + (\<Sum>i<length cs. \<Sum>j\<le>snd (cs ! i). Abs_fps (\<lambda>k. poly (inverse_irred_power_poly (zs ! i ! j) (snd (cs ! i) + 1 - j)) (of_nat k) * fst (cs ! i) ^ k)) = Abs_fps (\<lambda>k. coeff a k + (\<Sum>i<length cs. poly (\<Sum>j\<le>snd (cs ! i). inverse_irred_power_poly (zs ! i ! j) (snd (cs ! i) + 1 - j)) (of_nat k) * fst (cs ! i) ^ k))

goal (1 subgoal):
 1. fps_of_poly p / fps_of_poly (\<Prod>(c, n)\<leftarrow>cs. [:1::'a, - c:] ^ Suc n) = Abs_fps (\<lambda>k. coeff a k + (\<Sum>i<length cs. poly (\<Sum>j\<le>snd (cs ! i). inverse_irred_power_poly (zs ! i ! j) (snd (cs ! i) + 1 - j)) (of_nat k) * fst (cs ! i) ^ k))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
fps_of_poly p / fps_of_poly (\<Prod>a\<leftarrow>map (\<lambda>a. case a of (c, n) \<Rightarrow> ([:1::'a, - c:], n)) cs. case a of (x, n) \<Rightarrow> x ^ Suc n) = Abs_fps (\<lambda>k. coeff a k + (\<Sum>i<length cs. poly (\<Sum>j\<le>snd (cs ! i). inverse_irred_power_poly (zs ! i ! j) (snd (cs ! i) + 1 - j)) (of_nat k) * fst (cs ! i) ^ k))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
fps_of_poly p / fps_of_poly (\<Prod>a\<leftarrow>map (\<lambda>a. case a of (c, n) \<Rightarrow> ([:1::'a, - c:], n)) cs. case a of (x, n) \<Rightarrow> x ^ Suc n) = Abs_fps (\<lambda>k. coeff a k + (\<Sum>i<length cs. poly (\<Sum>j\<le>snd (cs ! i). inverse_irred_power_poly (zs ! i ! j) (snd (cs ! i) + 1 - j)) (of_nat k) * fst (cs ! i) ^ k))

goal (1 subgoal):
 1. fps_of_poly p / fps_of_poly (\<Prod>(c, n)\<leftarrow>cs. [:1::'a, - c:] ^ Suc n) = Abs_fps (\<lambda>k. coeff a k + (\<Sum>i<length cs. poly (\<Sum>j\<le>snd (cs ! i). inverse_irred_power_poly (zs ! i ! j) (snd (cs ! i) + 1 - j)) (of_nat k) * fst (cs ! i) ^ k))
[PROOF STEP]
by (simp add: o_def case_prod_unfold)
[PROOF STATE]
proof (state)
this:
fps_of_poly p / fps_of_poly (\<Prod>(c, n)\<leftarrow>cs. [:1::'a, - c:] ^ Suc n) = Abs_fps (\<lambda>k. coeff a k + (\<Sum>i<length cs. poly (\<Sum>j\<le>snd (cs ! i). inverse_irred_power_poly (zs ! i ! j) (snd (cs ! i) + 1 - j)) (of_nat k) * fst (cs ! i) ^ k))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma mult_eSuc: "eSuc m * n = n + m * n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. eSuc m * n = n + m * n
[PROOF STEP]
unfolding eSuc_plus_1
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (m + 1) * n = n + m * n
[PROOF STEP]
by (simp add: algebra_simps)


[STATEMENT]
lemma CARD_sum [card_simps]:
  "CARD('a + 'b) = card_sum CARD('a) CARD('b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. CARD('a + 'b) = card_sum CARD('a) CARD('b)
[PROOF STEP]
by(simp add: card_UNIV_sum card_sum_def)


[STATEMENT]
lemma to_int_mod_ring_numeral [simp]:
  "to_int_mod_ring (numeral n :: 'a :: nontriv mod_ring) = numeral n mod CARD('a)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. to_int_mod_ring (numeral n) = int (numeral n mod CARD('a))
[PROOF STEP]
by (metis of_nat_numeral to_int_mod_ring_of_nat)


[STATEMENT]
lemma timpl_closure_set_finite:
  fixes TI::"('sets set \<times> 'sets set) list"
  assumes M_finite: "finite M"
    and M_wf: "wf\<^sub>t\<^sub>r\<^sub>m\<^sub>s M"
  shows "finite (timpl_closure_set M (set TI))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite (timpl_closure_set M (set TI))
[PROOF STEP]
using timpl_closure_set_is_timpl_closure_union[of M "set TI"]
      timpl_closure_finite[of _ TI] M_finite M_wf finite
[PROOF STATE]
proof (prove)
using this:
timpl_closure_set M (set TI) = (\<Union>t\<in>M. timpl_closure t (set TI))
wf\<^sub>t\<^sub>r\<^sub>m ?t \<Longrightarrow> finite (timpl_closure ?t (set TI))
finite M
wf\<^sub>t\<^sub>r\<^sub>m\<^sub>s M
finite ?A

goal (1 subgoal):
 1. finite (timpl_closure_set M (set TI))
[PROOF STEP]
by auto


[STATEMENT]
lemma in_open_segment_iff_rot:
  "x \<in> {a<--<b} \<longleftrightarrow> (x - a) \<bullet> rot (b - a) = 0 \<and> x \<bullet> (b - a) \<in> {a\<bullet>(b - a) <..< b \<bullet> (b - a)}"
  if "a \<noteq> b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (x \<in> {a<--<b}) = ((x - a) \<bullet> rot (b - a) = 0 \<and> x \<bullet> (b - a) \<in> {a \<bullet> (b - a)<..<b \<bullet> (b - a)})
[PROOF STEP]
unfolding open_segment_line_hyperplanes[OF that]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (x \<in> range (\<lambda>u. a + u *\<^sub>R (b - a)) \<inter> {x. a \<bullet> (b - a) < x \<bullet> (b - a) \<and> x \<bullet> (b - a) < b \<bullet> (b - a)}) = ((x - a) \<bullet> rot (b - a) = 0 \<and> x \<bullet> (b - a) \<in> {a \<bullet> (b - a)<..<b \<bullet> (b - a)})
[PROOF STEP]
by (auto simp: nrm_dot intro!: inner_rot_in_segment)


[STATEMENT]
lemma "finite (prime_factors x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite (prime_factors x)
[PROOF STEP]
using finite_set_mset
[PROOF STATE]
proof (prove)
using this:
finite (set_mset ?M)

goal (1 subgoal):
 1. finite (prime_factors x)
[PROOF STEP]
by blast


[STATEMENT]
lemma real_root_commute: "root m (root n x) = root n (root m x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. root m (root n x) = root n (root m x)
[PROOF STEP]
by (simp add: real_root_mult_exp [symmetric] mult.commute)


[STATEMENT]
lemma constraints_of_mat_vec_solution_main: assumes A: "A \<in> carrier_mat nr nc"
  and x: "x \<in> carrier_vec nc"
  and b: "b \<in> carrier_vec nr"
  and sol: "A *\<^sub>v x \<le> b"
  and c: "c \<in> constraints_of_mat_vec A b"
shows "val_of_vec x \<Turnstile>\<^sub>l\<^sub>e c"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. val_of_vec x \<Turnstile>\<^sub>l\<^sub>e c
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. val_of_vec x \<Turnstile>\<^sub>l\<^sub>e c
[PROOF STEP]
from c[unfolded constraints_of_mat_vec_def] A
[PROOF STATE]
proof (chain)
picking this:
c \<in> (\<lambda>i. Le_Constraint Leq_Rel (poly_of_vec (row A i)) (b $ i)) ` {0..<dim_row A}
A \<in> carrier_mat nr nc
[PROOF STEP]
obtain i where
    i: "i < nr" and c: "c = Leqc (poly_of_vec (row A i)) (b $ i)"
[PROOF STATE]
proof (prove)
using this:
c \<in> (\<lambda>i. Le_Constraint Leq_Rel (poly_of_vec (row A i)) (b $ i)) ` {0..<dim_row A}
A \<in> carrier_mat nr nc

goal (1 subgoal):
 1. (\<And>i. \<lbrakk>i < nr; c = Le_Constraint Leq_Rel (poly_of_vec (row A i)) (b $ i)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
i < nr
c = Le_Constraint Leq_Rel (poly_of_vec (row A i)) (b $ i)

goal (1 subgoal):
 1. val_of_vec x \<Turnstile>\<^sub>l\<^sub>e c
[PROOF STEP]
from i A
[PROOF STATE]
proof (chain)
picking this:
i < nr
A \<in> carrier_mat nr nc
[PROOF STEP]
have ri: "row A i \<in> carrier_vec nc"
[PROOF STATE]
proof (prove)
using this:
i < nr
A \<in> carrier_mat nr nc

goal (1 subgoal):
 1. row A i \<in> carrier_vec nc
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
row A i \<in> carrier_vec nc

goal (1 subgoal):
 1. val_of_vec x \<Turnstile>\<^sub>l\<^sub>e c
[PROOF STEP]
from sol i A x b
[PROOF STATE]
proof (chain)
picking this:
A *\<^sub>v x \<le> b
i < nr
A \<in> carrier_mat nr nc
x \<in> carrier_vec nc
b \<in> carrier_vec nr
[PROOF STEP]
have sol: "(A *\<^sub>v x) $ i \<le> b $ i"
[PROOF STATE]
proof (prove)
using this:
A *\<^sub>v x \<le> b
i < nr
A \<in> carrier_mat nr nc
x \<in> carrier_vec nc
b \<in> carrier_vec nr

goal (1 subgoal):
 1. (A *\<^sub>v x) $ i \<le> b $ i
[PROOF STEP]
unfolding less_eq_vec_def
[PROOF STATE]
proof (prove)
using this:
dim_vec (A *\<^sub>v x) = dim_vec b \<and> (\<forall>i<dim_vec b. (A *\<^sub>v x) $ i \<le> b $ i)
i < nr
A \<in> carrier_mat nr nc
x \<in> carrier_vec nc
b \<in> carrier_vec nr

goal (1 subgoal):
 1. (A *\<^sub>v x) $ i \<le> b $ i
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(A *\<^sub>v x) $ i \<le> b $ i

goal (1 subgoal):
 1. val_of_vec x \<Turnstile>\<^sub>l\<^sub>e c
[PROOF STEP]
thus "val_of_vec x \<Turnstile>\<^sub>l\<^sub>e c"
[PROOF STATE]
proof (prove)
using this:
(A *\<^sub>v x) $ i \<le> b $ i

goal (1 subgoal):
 1. val_of_vec x \<Turnstile>\<^sub>l\<^sub>e c
[PROOF STEP]
unfolding c satisfiable_le_constraint.simps rel_of.simps
      valuate_poly_of_vec[OF x ri]
[PROOF STATE]
proof (prove)
using this:
(A *\<^sub>v x) $ i \<le> b $ i

goal (1 subgoal):
 1. row A i \<bullet> x \<le> b $ i
[PROOF STEP]
using A x i
[PROOF STATE]
proof (prove)
using this:
(A *\<^sub>v x) $ i \<le> b $ i
A \<in> carrier_mat nr nc
x \<in> carrier_vec nc
i < nr

goal (1 subgoal):
 1. row A i \<bullet> x \<le> b $ i
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
val_of_vec x \<Turnstile>\<^sub>l\<^sub>e c

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma T_on'_append: "T_on' A s (xs@ys) = T_on' A s xs + T_on' A (config' A s xs) ys"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. T_on' A s (xs @ ys) = T_on' A s xs + T_on' A (config' A s xs) ys
[PROOF STEP]
apply(induct xs arbitrary: s)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>s. T_on' A s ([] @ ys) = T_on' A s [] + T_on' A (config' A s []) ys
 2. \<And>a xs s. (\<And>s. T_on' A s (xs @ ys) = T_on' A s xs + T_on' A (config' A s xs) ys) \<Longrightarrow> T_on' A s ((a # xs) @ ys) = T_on' A s (a # xs) + T_on' A (config' A s (a # xs)) ys
[PROOF STEP]
by simp_all


[STATEMENT]
lemma atMost_eq_UNIV_iff: "{..\<le>\<^sub>ax} = UNIV \<longleftrightarrow> x = extremum"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ({..\<le>\<^sub>ax} = UNIV) = (x = extremum)
[PROOF STEP]
by (metis ord.lessThan_iff eq_iff UNIV_I UNIV_eq_I extremum)


[STATEMENT]
lemma algebraic_int_csqrt [intro]: "algebraic_int x \<Longrightarrow> algebraic_int (csqrt x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. algebraic_int x \<Longrightarrow> algebraic_int (csqrt x)
[PROOF STEP]
by (rule algebraic_int_root[where p = "monom 1 2"])
     (auto simp: poly_monom degree_monom_eq)


[STATEMENT]
theorem free_hull_inter: "\<langle>G\<rangle>\<^sub>F = \<Inter> {M. G \<subseteq> M \<and> M = \<langle>M\<rangle>\<^sub>F}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<langle>G\<rangle>\<^sub>F = \<Inter> {M. G \<subseteq> M \<and> M = \<langle>M\<rangle>\<^sub>F}
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<langle>G\<rangle>\<^sub>F \<subseteq> \<Inter> {M. G \<subseteq> M \<and> M = \<langle>M\<rangle>\<^sub>F}
 2. \<Inter> {M. G \<subseteq> M \<and> M = \<langle>M\<rangle>\<^sub>F} \<subseteq> \<langle>G\<rangle>\<^sub>F
[PROOF STEP]
have "X \<in> {M. G \<subseteq> M \<and> M = \<langle>M\<rangle>\<^sub>F} \<Longrightarrow> \<langle>G\<rangle>\<^sub>F \<subseteq> X" for X
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. X \<in> {M. G \<subseteq> M \<and> M = \<langle>M\<rangle>\<^sub>F} \<Longrightarrow> \<langle>G\<rangle>\<^sub>F \<subseteq> X
[PROOF STEP]
unfolding mem_Collect_eq[of _ "\<lambda> M. G \<subseteq> M \<and> M = \<langle>M\<rangle>\<^sub>F"]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. G \<subseteq> X \<and> X = \<langle>X\<rangle>\<^sub>F \<Longrightarrow> \<langle>G\<rangle>\<^sub>F \<subseteq> X
[PROOF STEP]
using free_hull_mono[of G X]
[PROOF STATE]
proof (prove)
using this:
G \<subseteq> X \<Longrightarrow> \<langle>G\<rangle>\<^sub>F \<subseteq> \<langle>X\<rangle>\<^sub>F

goal (1 subgoal):
 1. G \<subseteq> X \<and> X = \<langle>X\<rangle>\<^sub>F \<Longrightarrow> \<langle>G\<rangle>\<^sub>F \<subseteq> X
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
?X \<in> {M. G \<subseteq> M \<and> M = \<langle>M\<rangle>\<^sub>F} \<Longrightarrow> \<langle>G\<rangle>\<^sub>F \<subseteq> ?X

goal (2 subgoals):
 1. \<langle>G\<rangle>\<^sub>F \<subseteq> \<Inter> {M. G \<subseteq> M \<and> M = \<langle>M\<rangle>\<^sub>F}
 2. \<Inter> {M. G \<subseteq> M \<and> M = \<langle>M\<rangle>\<^sub>F} \<subseteq> \<langle>G\<rangle>\<^sub>F
[PROOF STEP]
from Inter_greatest[of "{M. G \<subseteq> M \<and> M = \<langle>M\<rangle>\<^sub>F}", OF this]
[PROOF STATE]
proof (chain)
picking this:
(\<And>X. X \<in> {M. G \<subseteq> M \<and> M = \<langle>M\<rangle>\<^sub>F} \<Longrightarrow> X \<in> {M. G \<subseteq> M \<and> M = \<langle>M\<rangle>\<^sub>F}) \<Longrightarrow> \<langle>G\<rangle>\<^sub>F \<subseteq> \<Inter> {M. G \<subseteq> M \<and> M = \<langle>M\<rangle>\<^sub>F}
[PROOF STEP]
show "\<langle>G\<rangle>\<^sub>F \<subseteq> \<Inter> {M. G \<subseteq> M \<and> M = \<langle>M\<rangle>\<^sub>F}"
[PROOF STATE]
proof (prove)
using this:
(\<And>X. X \<in> {M. G \<subseteq> M \<and> M = \<langle>M\<rangle>\<^sub>F} \<Longrightarrow> X \<in> {M. G \<subseteq> M \<and> M = \<langle>M\<rangle>\<^sub>F}) \<Longrightarrow> \<langle>G\<rangle>\<^sub>F \<subseteq> \<Inter> {M. G \<subseteq> M \<and> M = \<langle>M\<rangle>\<^sub>F}

goal (1 subgoal):
 1. \<langle>G\<rangle>\<^sub>F \<subseteq> \<Inter> {M. G \<subseteq> M \<and> M = \<langle>M\<rangle>\<^sub>F}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
\<langle>G\<rangle>\<^sub>F \<subseteq> \<Inter> {M. G \<subseteq> M \<and> M = \<langle>M\<rangle>\<^sub>F}

goal (1 subgoal):
 1. \<Inter> {M. G \<subseteq> M \<and> M = \<langle>M\<rangle>\<^sub>F} \<subseteq> \<langle>G\<rangle>\<^sub>F
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<Inter> {M. G \<subseteq> M \<and> M = \<langle>M\<rangle>\<^sub>F} \<subseteq> \<langle>G\<rangle>\<^sub>F
[PROOF STEP]
show " \<Inter> {M. G \<subseteq> M \<and> M = \<langle>M\<rangle>\<^sub>F} \<subseteq> \<langle>G\<rangle>\<^sub>F"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<Inter> {M. G \<subseteq> M \<and> M = \<langle>M\<rangle>\<^sub>F} \<subseteq> \<langle>G\<rangle>\<^sub>F
[PROOF STEP]
by (simp add: Inter_lower free_hull_idem genset_sub_free)
[PROOF STATE]
proof (state)
this:
\<Inter> {M. G \<subseteq> M \<and> M = \<langle>M\<rangle>\<^sub>F} \<subseteq> \<langle>G\<rangle>\<^sub>F

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma fps_const_divide: "fps_const (x :: _ :: division_ring) / fps_const y = fps_const (x / y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fps_const x / fps_const y = fps_const (x / y)
[PROOF STEP]
by (simp add: fps_divide_def fps_const_inverse divide_inverse)


[STATEMENT]
lemma convex_hull_insert_segments:
   "convex hull (insert a S) =
    (if S = {} then {a} else  \<Union>x \<in> convex hull S. closed_segment a x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. convex hull insert a S = (if S = {} then {a} else \<Union> (closed_segment a ` (convex hull S)))
[PROOF STEP]
by (force simp add: convex_hull_insert_alt in_segment)


[STATEMENT]
lemma (in prob_space) integral_le_const:
  fixes c :: real
  shows "integrable M f \<Longrightarrow> (AE x in M. f x \<le> c) \<Longrightarrow> (\<integral>x. f x \<partial>M) \<le> c"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>integrable M f; AE x in M. f x \<le> c\<rbrakk> \<Longrightarrow> expectation f \<le> c
[PROOF STEP]
using integral_mono_AE[of M f "\<lambda>x. c"] prob_space
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>integrable M f; integrable M (\<lambda>x. c); AE x in M. f x \<le> c\<rbrakk> \<Longrightarrow> expectation f \<le> expectation (\<lambda>x. c)
prob (space M) = 1

goal (1 subgoal):
 1. \<lbrakk>integrable M f; AE x in M. f x \<le> c\<rbrakk> \<Longrightarrow> expectation f \<le> c
[PROOF STEP]
by simp