[STATEMENT]
lemma from_digits_digit':
  "from_digits n (digit x) = x mod (base ^ n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. from_digits n (digit x) = x mod base ^ n
[PROOF STEP]
unfolding from_digits_altdef digit_altdef
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i<n. x div base ^ i mod base * base ^ i) = x mod base ^ n
[PROOF STEP]
proof (induction n arbitrary: x)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>x. (\<Sum>i<0. x div base ^ i mod base * base ^ i) = x mod base ^ 0
 2. \<And>n x. (\<And>x. (\<Sum>i<n. x div base ^ i mod base * base ^ i) = x mod base ^ n) \<Longrightarrow> (\<Sum>i<Suc n. x div base ^ i mod base * base ^ i) = x mod base ^ Suc n
[PROOF STEP]
case 0
[PROOF STATE]
proof (state)
this:

goal (2 subgoals):
 1. \<And>x. (\<Sum>i<0. x div base ^ i mod base * base ^ i) = x mod base ^ 0
 2. \<And>n x. (\<And>x. (\<Sum>i<n. x div base ^ i mod base * base ^ i) = x mod base ^ n) \<Longrightarrow> (\<Sum>i<Suc n. x div base ^ i mod base * base ^ i) = x mod base ^ Suc n
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i<0. x div base ^ i mod base * base ^ i) = x mod base ^ 0
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<Sum>i<0. x div base ^ i mod base * base ^ i) = x mod base ^ 0

goal (1 subgoal):
 1. \<And>n x. (\<And>x. (\<Sum>i<n. x div base ^ i mod base * base ^ i) = x mod base ^ n) \<Longrightarrow> (\<Sum>i<Suc n. x div base ^ i mod base * base ^ i) = x mod base ^ Suc n
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n x. (\<And>x. (\<Sum>i<n. x div base ^ i mod base * base ^ i) = x mod base ^ n) \<Longrightarrow> (\<Sum>i<Suc n. x div base ^ i mod base * base ^ i) = x mod base ^ Suc n
[PROOF STEP]
case (Suc n)
[PROOF STATE]
proof (state)
this:
(\<Sum>i<n. ?x div base ^ i mod base * base ^ i) = ?x mod base ^ n

goal (1 subgoal):
 1. \<And>n x. (\<And>x. (\<Sum>i<n. x div base ^ i mod base * base ^ i) = x mod base ^ n) \<Longrightarrow> (\<Sum>i<Suc n. x div base ^ i mod base * base ^ i) = x mod base ^ Suc n
[PROOF STEP]
define x_less where "x_less = x mod base^n"
[PROOF STATE]
proof (state)
this:
x_less = x mod base ^ n

goal (1 subgoal):
 1. \<And>n x. (\<And>x. (\<Sum>i<n. x div base ^ i mod base * base ^ i) = x mod base ^ n) \<Longrightarrow> (\<Sum>i<Suc n. x div base ^ i mod base * base ^ i) = x mod base ^ Suc n
[PROOF STEP]
define x_n where "x_n = x div base^n mod base"
[PROOF STATE]
proof (state)
this:
x_n = x div base ^ n mod base

goal (1 subgoal):
 1. \<And>n x. (\<And>x. (\<Sum>i<n. x div base ^ i mod base * base ^ i) = x mod base ^ n) \<Longrightarrow> (\<Sum>i<Suc n. x div base ^ i mod base * base ^ i) = x mod base ^ Suc n
[PROOF STEP]
have "x_less < base^n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x_less < base ^ n
[PROOF STEP]
using x_less_def base_pos
      mod_less_divisor
[PROOF STATE]
proof (prove)
using this:
x_less = x mod base ^ n
0 < base
0 < ?n \<Longrightarrow> ?m mod ?n < ?n

goal (1 subgoal):
 1. x_less < base ^ n
[PROOF STEP]
by presburger
[PROOF STATE]
proof (state)
this:
x_less < base ^ n

goal (1 subgoal):
 1. \<And>n x. (\<And>x. (\<Sum>i<n. x div base ^ i mod base * base ^ i) = x mod base ^ n) \<Longrightarrow> (\<Sum>i<Suc n. x div base ^ i mod base * base ^ i) = x mod base ^ Suc n
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
x_less < base ^ n
[PROOF STEP]
have IH_x_less:
    "(\<Sum>i<n. x_less div base ^ i mod base * base ^ i) = x_less"
[PROOF STATE]
proof (prove)
using this:
x_less < base ^ n

goal (1 subgoal):
 1. (\<Sum>i<n. x_less div base ^ i mod base * base ^ i) = x_less
[PROOF STEP]
using Suc.IH
[PROOF STATE]
proof (prove)
using this:
x_less < base ^ n
(\<Sum>i<n. ?x div base ^ i mod base * base ^ i) = ?x mod base ^ n

goal (1 subgoal):
 1. (\<Sum>i<n. x_less div base ^ i mod base * base ^ i) = x_less
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<Sum>i<n. x_less div base ^ i mod base * base ^ i) = x_less

goal (1 subgoal):
 1. \<And>n x. (\<And>x. (\<Sum>i<n. x div base ^ i mod base * base ^ i) = x mod base ^ n) \<Longrightarrow> (\<Sum>i<Suc n. x div base ^ i mod base * base ^ i) = x mod base ^ Suc n
[PROOF STEP]
have "x_n < base"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x_n < base
[PROOF STEP]
using base_pos mod_less_divisor x_n_def
[PROOF STATE]
proof (prove)
using this:
0 < base
0 < ?n \<Longrightarrow> ?m mod ?n < ?n
x_n = x div base ^ n mod base

goal (1 subgoal):
 1. x_n < base
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
x_n < base

goal (1 subgoal):
 1. \<And>n x. (\<And>x. (\<Sum>i<n. x div base ^ i mod base * base ^ i) = x mod base ^ n) \<Longrightarrow> (\<Sum>i<Suc n. x div base ^ i mod base * base ^ i) = x mod base ^ Suc n
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
x_n < base
[PROOF STEP]
have "x_n mod base = x_n"
[PROOF STATE]
proof (prove)
using this:
x_n < base

goal (1 subgoal):
 1. x_n mod base = x_n
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
x_n mod base = x_n

goal (1 subgoal):
 1. \<And>n x. (\<And>x. (\<Sum>i<n. x div base ^ i mod base * base ^ i) = x mod base ^ n) \<Longrightarrow> (\<Sum>i<Suc n. x div base ^ i mod base * base ^ i) = x mod base ^ Suc n
[PROOF STEP]
have x_less_i_eq_x_i:"x mod base^n div base ^i mod base =
    x div base^i mod base" if "i<n" for i
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x mod base ^ n div base ^ i mod base = x div base ^ i mod base
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. x mod base ^ n div base ^ i mod base = x div base ^ i mod base
[PROOF STEP]
have "x div base^i mod base =
      ((x div base^n) * base^n + x mod base^n) div base^i mod base"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x div base ^ i mod base = (x div base ^ n * base ^ n + x mod base ^ n) div base ^ i mod base
[PROOF STEP]
using div_mult_mod_eq[of x "base^n"]
[PROOF STATE]
proof (prove)
using this:
x div base ^ n * base ^ n + x mod base ^ n = x

goal (1 subgoal):
 1. x div base ^ i mod base = (x div base ^ n * base ^ n + x mod base ^ n) div base ^ i mod base
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
x div base ^ i mod base = (x div base ^ n * base ^ n + x mod base ^ n) div base ^ i mod base

goal (1 subgoal):
 1. x mod base ^ n div base ^ i mod base = x div base ^ i mod base
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
x div base ^ i mod base = (x div base ^ n * base ^ n + x mod base ^ n) div base ^ i mod base

goal (1 subgoal):
 1. x mod base ^ n div base ^ i mod base = x div base ^ i mod base
[PROOF STEP]
have "\<dots> = x mod base^n div base^i mod base"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (x div base ^ n * base ^ n + x mod base ^ n) div base ^ i mod base = x mod base ^ n div base ^ i mod base
[PROOF STEP]
using div_distrib[where a="x div base^n" and b = "x mod base^n"]
        that
[PROOF STATE]
proof (prove)
using this:
?i < ?n \<Longrightarrow> (x div base ^ n * base ^ ?n + x mod base ^ n) div base ^ ?i mod base = x mod base ^ n div base ^ ?i mod base
i < n

goal (1 subgoal):
 1. (x div base ^ n * base ^ n + x mod base ^ n) div base ^ i mod base = x mod base ^ n div base ^ i mod base
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(x div base ^ n * base ^ n + x mod base ^ n) div base ^ i mod base = x mod base ^ n div base ^ i mod base

goal (1 subgoal):
 1. x mod base ^ n div base ^ i mod base = x div base ^ i mod base
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
x div base ^ i mod base = x mod base ^ n div base ^ i mod base
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
x div base ^ i mod base = x mod base ^ n div base ^ i mod base

goal (1 subgoal):
 1. x mod base ^ n div base ^ i mod base = x div base ^ i mod base
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
x mod base ^ n div base ^ i mod base = x div base ^ i mod base

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
?i < n \<Longrightarrow> x mod base ^ n div base ^ ?i mod base = x div base ^ ?i mod base

goal (1 subgoal):
 1. \<And>n x. (\<And>x. (\<Sum>i<n. x div base ^ i mod base * base ^ i) = x mod base ^ n) \<Longrightarrow> (\<Sum>i<Suc n. x div base ^ i mod base * base ^ i) = x mod base ^ Suc n
[PROOF STEP]
have "x mod base^Suc n = x_n*base^n + x_less"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x mod base ^ Suc n = x_n * base ^ n + x_less
[PROOF STEP]
by (metis mod_mult2_eq mult.commute power_Suc2 x_less_def x_n_def)
[PROOF STATE]
proof (state)
this:
x mod base ^ Suc n = x_n * base ^ n + x_less

goal (1 subgoal):
 1. \<And>n x. (\<And>x. (\<Sum>i<n. x div base ^ i mod base * base ^ i) = x mod base ^ n) \<Longrightarrow> (\<Sum>i<Suc n. x div base ^ i mod base * base ^ i) = x mod base ^ Suc n
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
x mod base ^ Suc n = x_n * base ^ n + x_less

goal (1 subgoal):
 1. \<And>n x. (\<And>x. (\<Sum>i<n. x div base ^ i mod base * base ^ i) = x mod base ^ n) \<Longrightarrow> (\<Sum>i<Suc n. x div base ^ i mod base * base ^ i) = x mod base ^ Suc n
[PROOF STEP]
have "\<dots> = (x div base^n mod base) * base^n +
                (\<Sum>i<n. x div base ^ i mod base * base ^ i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x_n * base ^ n + x_less = x div base ^ n mod base * base ^ n + (\<Sum>i<n. x div base ^ i mod base * base ^ i)
[PROOF STEP]
using IH_x_less x_less_def x_less_i_eq_x_i x_n_def
[PROOF STATE]
proof (prove)
using this:
(\<Sum>i<n. x_less div base ^ i mod base * base ^ i) = x_less
x_less = x mod base ^ n
?i < n \<Longrightarrow> x mod base ^ n div base ^ ?i mod base = x div base ^ ?i mod base
x_n = x div base ^ n mod base

goal (1 subgoal):
 1. x_n * base ^ n + x_less = x div base ^ n mod base * base ^ n + (\<Sum>i<n. x div base ^ i mod base * base ^ i)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
x_n * base ^ n + x_less = x div base ^ n mod base * base ^ n + (\<Sum>i<n. x div base ^ i mod base * base ^ i)

goal (1 subgoal):
 1. \<And>n x. (\<And>x. (\<Sum>i<n. x div base ^ i mod base * base ^ i) = x mod base ^ n) \<Longrightarrow> (\<Sum>i<Suc n. x div base ^ i mod base * base ^ i) = x mod base ^ Suc n
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
x mod base ^ Suc n = x div base ^ n mod base * base ^ n + (\<Sum>i<n. x div base ^ i mod base * base ^ i)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
x mod base ^ Suc n = x div base ^ n mod base * base ^ n + (\<Sum>i<n. x div base ^ i mod base * base ^ i)

goal (1 subgoal):
 1. (\<Sum>i<Suc n. x div base ^ i mod base * base ^ i) = x mod base ^ Suc n
[PROOF STEP]
using sum.atMost_Suc
[PROOF STATE]
proof (prove)
using this:
x mod base ^ Suc n = x div base ^ n mod base * base ^ n + (\<Sum>i<n. x div base ^ i mod base * base ^ i)
sum ?g {..Suc ?n} = sum ?g {..?n} + ?g (Suc ?n)

goal (1 subgoal):
 1. (\<Sum>i<Suc n. x div base ^ i mod base * base ^ i) = x mod base ^ Suc n
[PROOF STEP]
by (simp add: add.commute)
[PROOF STATE]
proof (state)
this:
(\<Sum>i<Suc n. x div base ^ i mod base * base ^ i) = x mod base ^ Suc n

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma square_free_multD:
  assumes sf: "square_free (f * g)"
  shows "h dvd f \<Longrightarrow> h dvd g \<Longrightarrow> degree h = 0" "square_free f" "square_free g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lbrakk>h dvd f; h dvd g\<rbrakk> \<Longrightarrow> degree h = 0) &&& square_free f &&& square_free g
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. \<lbrakk>h dvd f; h dvd g\<rbrakk> \<Longrightarrow> degree h = 0
 2. square_free f
 3. square_free g
[PROOF STEP]
from sf[unfolded square_free_def]
[PROOF STATE]
proof (chain)
picking this:
f * g \<noteq> 0 \<and> (\<forall>q. 0 < degree q \<longrightarrow> \<not> q * q dvd f * g)
[PROOF STEP]
have 0: "f \<noteq> 0" "g \<noteq> 0"
    and dvd: "\<And> q. q * q dvd f * g \<Longrightarrow> degree q = 0"
[PROOF STATE]
proof (prove)
using this:
f * g \<noteq> 0 \<and> (\<forall>q. 0 < degree q \<longrightarrow> \<not> q * q dvd f * g)

goal (1 subgoal):
 1. (f \<noteq> 0 &&& g \<noteq> 0) &&& (\<And>q. q * q dvd f * g \<Longrightarrow> degree q = 0)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
f \<noteq> 0
g \<noteq> 0
?q * ?q dvd f * g \<Longrightarrow> degree ?q = 0

goal (3 subgoals):
 1. \<lbrakk>h dvd f; h dvd g\<rbrakk> \<Longrightarrow> degree h = 0
 2. square_free f
 3. square_free g
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
f \<noteq> 0
g \<noteq> 0
?q * ?q dvd f * g \<Longrightarrow> degree ?q = 0
[PROOF STEP]
show "square_free f" "square_free g"
[PROOF STATE]
proof (prove)
using this:
f \<noteq> 0
g \<noteq> 0
?q * ?q dvd f * g \<Longrightarrow> degree ?q = 0

goal (1 subgoal):
 1. square_free f &&& square_free g
[PROOF STEP]
by (auto simp: square_free_def)
[PROOF STATE]
proof (state)
this:
square_free f
square_free g

goal (1 subgoal):
 1. \<lbrakk>h dvd f; h dvd g\<rbrakk> \<Longrightarrow> degree h = 0
[PROOF STEP]
assume "h dvd f" "h dvd g"
[PROOF STATE]
proof (state)
this:
h dvd f
h dvd g

goal (1 subgoal):
 1. \<lbrakk>h dvd f; h dvd g\<rbrakk> \<Longrightarrow> degree h = 0
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
h dvd f
h dvd g
[PROOF STEP]
have "h * h dvd f * g"
[PROOF STATE]
proof (prove)
using this:
h dvd f
h dvd g

goal (1 subgoal):
 1. h * h dvd f * g
[PROOF STEP]
by (rule mult_dvd_mono)
[PROOF STATE]
proof (state)
this:
h * h dvd f * g

goal (1 subgoal):
 1. \<lbrakk>h dvd f; h dvd g\<rbrakk> \<Longrightarrow> degree h = 0
[PROOF STEP]
from dvd[OF this]
[PROOF STATE]
proof (chain)
picking this:
degree h = 0
[PROOF STEP]
show "degree h = 0"
[PROOF STATE]
proof (prove)
using this:
degree h = 0

goal (1 subgoal):
 1. degree h = 0
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
degree h = 0

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma integer_partitions_number_partition_eq:
  "integer_partitions n = {N. number_partition n N}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. integer_partitions n = {N. number_partition n N}
[PROOF STEP]
using integer_partitions_def number_partition_def
[PROOF STATE]
proof (prove)
using this:
integer_partitions ?i = {A. \<Sum>\<^sub># A = ?i \<and> 0 \<notin># A}
number_partition ?n ?N = (\<Sum>\<^sub># ?N = ?n \<and> 0 \<notin># ?N)

goal (1 subgoal):
 1. integer_partitions n = {N. number_partition n N}
[PROOF STEP]
by auto


[STATEMENT]
lemma ex_mset_zip_left:
  assumes "length xs = length ys" "mset xs' = mset xs"
  shows "\<exists>ys'. length ys' = length xs' \<and> mset (zip xs' ys') = mset (zip xs ys)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>ys'. length ys' = length xs' \<and> mset (zip xs' ys') = mset (zip xs ys)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
length xs = length ys
mset xs' = mset xs

goal (1 subgoal):
 1. \<exists>ys'. length ys' = length xs' \<and> mset (zip xs' ys') = mset (zip xs ys)
[PROOF STEP]
proof (induct xs ys arbitrary: xs' rule: list_induct2)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>xs'. mset xs' = mset [] \<Longrightarrow> \<exists>ys'. length ys' = length xs' \<and> mset (zip xs' ys') = mset (zip [] [])
 2. \<And>x xs y ys xs'. \<lbrakk>length xs = length ys; \<And>xs'. mset xs' = mset xs \<Longrightarrow> \<exists>ys'. length ys' = length xs' \<and> mset (zip xs' ys') = mset (zip xs ys); mset xs' = mset (x # xs)\<rbrakk> \<Longrightarrow> \<exists>ys'. length ys' = length xs' \<and> mset (zip xs' ys') = mset (zip (x # xs) (y # ys))
[PROOF STEP]
case Nil
[PROOF STATE]
proof (state)
this:
mset xs' = mset []

goal (2 subgoals):
 1. \<And>xs'. mset xs' = mset [] \<Longrightarrow> \<exists>ys'. length ys' = length xs' \<and> mset (zip xs' ys') = mset (zip [] [])
 2. \<And>x xs y ys xs'. \<lbrakk>length xs = length ys; \<And>xs'. mset xs' = mset xs \<Longrightarrow> \<exists>ys'. length ys' = length xs' \<and> mset (zip xs' ys') = mset (zip xs ys); mset xs' = mset (x # xs)\<rbrakk> \<Longrightarrow> \<exists>ys'. length ys' = length xs' \<and> mset (zip xs' ys') = mset (zip (x # xs) (y # ys))
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
using this:
mset xs' = mset []

goal (1 subgoal):
 1. \<exists>ys'. length ys' = length xs' \<and> mset (zip xs' ys') = mset (zip [] [])
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<exists>ys'. length ys' = length xs' \<and> mset (zip xs' ys') = mset (zip [] [])

goal (1 subgoal):
 1. \<And>x xs y ys xs'. \<lbrakk>length xs = length ys; \<And>xs'. mset xs' = mset xs \<Longrightarrow> \<exists>ys'. length ys' = length xs' \<and> mset (zip xs' ys') = mset (zip xs ys); mset xs' = mset (x # xs)\<rbrakk> \<Longrightarrow> \<exists>ys'. length ys' = length xs' \<and> mset (zip xs' ys') = mset (zip (x # xs) (y # ys))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x xs y ys xs'. \<lbrakk>length xs = length ys; \<And>xs'. mset xs' = mset xs \<Longrightarrow> \<exists>ys'. length ys' = length xs' \<and> mset (zip xs' ys') = mset (zip xs ys); mset xs' = mset (x # xs)\<rbrakk> \<Longrightarrow> \<exists>ys'. length ys' = length xs' \<and> mset (zip xs' ys') = mset (zip (x # xs) (y # ys))
[PROOF STEP]
case (Cons x xs y ys xs')
[PROOF STATE]
proof (state)
this:
length xs = length ys
mset ?xs' = mset xs \<Longrightarrow> \<exists>ys'. length ys' = length ?xs' \<and> mset (zip ?xs' ys') = mset (zip xs ys)
mset xs' = mset (x # xs)

goal (1 subgoal):
 1. \<And>x xs y ys xs'. \<lbrakk>length xs = length ys; \<And>xs'. mset xs' = mset xs \<Longrightarrow> \<exists>ys'. length ys' = length xs' \<and> mset (zip xs' ys') = mset (zip xs ys); mset xs' = mset (x # xs)\<rbrakk> \<Longrightarrow> \<exists>ys'. length ys' = length xs' \<and> mset (zip xs' ys') = mset (zip (x # xs) (y # ys))
[PROOF STEP]
obtain j where j_len: "j < length xs'" and nth_j: "xs' ! j = x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>j. \<lbrakk>j < length xs'; xs' ! j = x\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (metis Cons.prems in_set_conv_nth list.set_intros(1) mset_eq_setD)
[PROOF STATE]
proof (state)
this:
j < length xs'
xs' ! j = x

goal (1 subgoal):
 1. \<And>x xs y ys xs'. \<lbrakk>length xs = length ys; \<And>xs'. mset xs' = mset xs \<Longrightarrow> \<exists>ys'. length ys' = length xs' \<and> mset (zip xs' ys') = mset (zip xs ys); mset xs' = mset (x # xs)\<rbrakk> \<Longrightarrow> \<exists>ys'. length ys' = length xs' \<and> mset (zip xs' ys') = mset (zip (x # xs) (y # ys))
[PROOF STEP]
define xsa where "xsa = take j xs' @ drop (Suc j) xs'"
[PROOF STATE]
proof (state)
this:
xsa = take j xs' @ drop (Suc j) xs'

goal (1 subgoal):
 1. \<And>x xs y ys xs'. \<lbrakk>length xs = length ys; \<And>xs'. mset xs' = mset xs \<Longrightarrow> \<exists>ys'. length ys' = length xs' \<and> mset (zip xs' ys') = mset (zip xs ys); mset xs' = mset (x # xs)\<rbrakk> \<Longrightarrow> \<exists>ys'. length ys' = length xs' \<and> mset (zip xs' ys') = mset (zip (x # xs) (y # ys))
[PROOF STEP]
have "mset xs' = {#x#} + mset xsa"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mset xs' = {#x#} + mset xsa
[PROOF STEP]
unfolding xsa_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mset xs' = {#x#} + mset (take j xs' @ drop (Suc j) xs')
[PROOF STEP]
using j_len nth_j
[PROOF STATE]
proof (prove)
using this:
j < length xs'
xs' ! j = x

goal (1 subgoal):
 1. mset xs' = {#x#} + mset (take j xs' @ drop (Suc j) xs')
[PROOF STEP]
by (metis Cons_nth_drop_Suc union_mset_add_mset_right add_mset_remove_trivial add_diff_cancel_left'
        append_take_drop_id mset.simps(2) mset_append)
[PROOF STATE]
proof (state)
this:
mset xs' = {#x#} + mset xsa

goal (1 subgoal):
 1. \<And>x xs y ys xs'. \<lbrakk>length xs = length ys; \<And>xs'. mset xs' = mset xs \<Longrightarrow> \<exists>ys'. length ys' = length xs' \<and> mset (zip xs' ys') = mset (zip xs ys); mset xs' = mset (x # xs)\<rbrakk> \<Longrightarrow> \<exists>ys'. length ys' = length xs' \<and> mset (zip xs' ys') = mset (zip (x # xs) (y # ys))
[PROOF STEP]
hence ms_x: "mset xsa = mset xs"
[PROOF STATE]
proof (prove)
using this:
mset xs' = {#x#} + mset xsa

goal (1 subgoal):
 1. mset xsa = mset xs
[PROOF STEP]
by (simp add: Cons.prems)
[PROOF STATE]
proof (state)
this:
mset xsa = mset xs

goal (1 subgoal):
 1. \<And>x xs y ys xs'. \<lbrakk>length xs = length ys; \<And>xs'. mset xs' = mset xs \<Longrightarrow> \<exists>ys'. length ys' = length xs' \<and> mset (zip xs' ys') = mset (zip xs ys); mset xs' = mset (x # xs)\<rbrakk> \<Longrightarrow> \<exists>ys'. length ys' = length xs' \<and> mset (zip xs' ys') = mset (zip (x # xs) (y # ys))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
mset xsa = mset xs
[PROOF STEP]
obtain ysa where
    len_a: "length ysa = length xsa" and ms_a: "mset (zip xsa ysa) = mset (zip xs ys)"
[PROOF STATE]
proof (prove)
using this:
mset xsa = mset xs

goal (1 subgoal):
 1. (\<And>ysaa. \<lbrakk>length ysaa = length xsa; mset (zip xsa ysaa) = mset (zip xs ys)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using Cons.hyps(2)
[PROOF STATE]
proof (prove)
using this:
mset xsa = mset xs
mset ?xs' = mset xs \<Longrightarrow> \<exists>ys'. length ys' = length ?xs' \<and> mset (zip ?xs' ys') = mset (zip xs ys)

goal (1 subgoal):
 1. (\<And>ysaa. \<lbrakk>length ysaa = length xsa; mset (zip xsa ysaa) = mset (zip xs ys)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
length ysa = length xsa
mset (zip xsa ysa) = mset (zip xs ys)

goal (1 subgoal):
 1. \<And>x xs y ys xs'. \<lbrakk>length xs = length ys; \<And>xs'. mset xs' = mset xs \<Longrightarrow> \<exists>ys'. length ys' = length xs' \<and> mset (zip xs' ys') = mset (zip xs ys); mset xs' = mset (x # xs)\<rbrakk> \<Longrightarrow> \<exists>ys'. length ys' = length xs' \<and> mset (zip xs' ys') = mset (zip (x # xs) (y # ys))
[PROOF STEP]
define ys' where "ys' = take j ysa @ y # drop j ysa"
[PROOF STATE]
proof (state)
this:
ys' = take j ysa @ y # drop j ysa

goal (1 subgoal):
 1. \<And>x xs y ys xs'. \<lbrakk>length xs = length ys; \<And>xs'. mset xs' = mset xs \<Longrightarrow> \<exists>ys'. length ys' = length xs' \<and> mset (zip xs' ys') = mset (zip xs ys); mset xs' = mset (x # xs)\<rbrakk> \<Longrightarrow> \<exists>ys'. length ys' = length xs' \<and> mset (zip xs' ys') = mset (zip (x # xs) (y # ys))
[PROOF STEP]
have xs': "xs' = take j xsa @ x # drop j xsa"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. xs' = take j xsa @ x # drop j xsa
[PROOF STEP]
using ms_x j_len nth_j Cons.prems xsa_def
[PROOF STATE]
proof (prove)
using this:
mset xsa = mset xs
j < length xs'
xs' ! j = x
mset xs' = mset (x # xs)
xsa = take j xs' @ drop (Suc j) xs'

goal (1 subgoal):
 1. xs' = take j xsa @ x # drop j xsa
[PROOF STEP]
by (metis append_eq_append_conv append_take_drop_id diff_Suc_Suc Cons_nth_drop_Suc length_Cons
      length_drop size_mset)
[PROOF STATE]
proof (state)
this:
xs' = take j xsa @ x # drop j xsa

goal (1 subgoal):
 1. \<And>x xs y ys xs'. \<lbrakk>length xs = length ys; \<And>xs'. mset xs' = mset xs \<Longrightarrow> \<exists>ys'. length ys' = length xs' \<and> mset (zip xs' ys') = mset (zip xs ys); mset xs' = mset (x # xs)\<rbrakk> \<Longrightarrow> \<exists>ys'. length ys' = length xs' \<and> mset (zip xs' ys') = mset (zip (x # xs) (y # ys))
[PROOF STEP]
have j_len': "j \<le> length xsa"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. j \<le> length xsa
[PROOF STEP]
using j_len xs' xsa_def
[PROOF STATE]
proof (prove)
using this:
j < length xs'
xs' = take j xsa @ x # drop j xsa
xsa = take j xs' @ drop (Suc j) xs'

goal (1 subgoal):
 1. j \<le> length xsa
[PROOF STEP]
by (metis add_Suc_right append_take_drop_id length_Cons length_append less_eq_Suc_le not_less)
[PROOF STATE]
proof (state)
this:
j \<le> length xsa

goal (1 subgoal):
 1. \<And>x xs y ys xs'. \<lbrakk>length xs = length ys; \<And>xs'. mset xs' = mset xs \<Longrightarrow> \<exists>ys'. length ys' = length xs' \<and> mset (zip xs' ys') = mset (zip xs ys); mset xs' = mset (x # xs)\<rbrakk> \<Longrightarrow> \<exists>ys'. length ys' = length xs' \<and> mset (zip xs' ys') = mset (zip (x # xs) (y # ys))
[PROOF STEP]
have "length ys' = length xs'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length ys' = length xs'
[PROOF STEP]
unfolding ys'_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (take j ysa @ y # drop j ysa) = length xs'
[PROOF STEP]
using Cons.prems len_a ms_x
[PROOF STATE]
proof (prove)
using this:
mset xs' = mset (x # xs)
length ysa = length xsa
mset xsa = mset xs

goal (1 subgoal):
 1. length (take j ysa @ y # drop j ysa) = length xs'
[PROOF STEP]
by (metis add_Suc_right append_take_drop_id length_Cons length_append mset_eq_length)
[PROOF STATE]
proof (state)
this:
length ys' = length xs'

goal (1 subgoal):
 1. \<And>x xs y ys xs'. \<lbrakk>length xs = length ys; \<And>xs'. mset xs' = mset xs \<Longrightarrow> \<exists>ys'. length ys' = length xs' \<and> mset (zip xs' ys') = mset (zip xs ys); mset xs' = mset (x # xs)\<rbrakk> \<Longrightarrow> \<exists>ys'. length ys' = length xs' \<and> mset (zip xs' ys') = mset (zip (x # xs) (y # ys))
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
length ys' = length xs'

goal (1 subgoal):
 1. \<And>x xs y ys xs'. \<lbrakk>length xs = length ys; \<And>xs'. mset xs' = mset xs \<Longrightarrow> \<exists>ys'. length ys' = length xs' \<and> mset (zip xs' ys') = mset (zip xs ys); mset xs' = mset (x # xs)\<rbrakk> \<Longrightarrow> \<exists>ys'. length ys' = length xs' \<and> mset (zip xs' ys') = mset (zip (x # xs) (y # ys))
[PROOF STEP]
have "mset (zip xs' ys') = mset (zip (x # xs) (y # ys))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mset (zip xs' ys') = mset (zip (x # xs) (y # ys))
[PROOF STEP]
unfolding xs' ys'_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mset (zip (take j xsa @ x # drop j xsa) (take j ysa @ y # drop j ysa)) = mset (zip (x # xs) (y # ys))
[PROOF STEP]
by (rule trans[OF mset_zip_take_Cons_drop_twice])
      (auto simp: len_a ms_a j_len')
[PROOF STATE]
proof (state)
this:
mset (zip xs' ys') = mset (zip (x # xs) (y # ys))

goal (1 subgoal):
 1. \<And>x xs y ys xs'. \<lbrakk>length xs = length ys; \<And>xs'. mset xs' = mset xs \<Longrightarrow> \<exists>ys'. length ys' = length xs' \<and> mset (zip xs' ys') = mset (zip xs ys); mset xs' = mset (x # xs)\<rbrakk> \<Longrightarrow> \<exists>ys'. length ys' = length xs' \<and> mset (zip xs' ys') = mset (zip (x # xs) (y # ys))
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
length ys' = length xs'
mset (zip xs' ys') = mset (zip (x # xs) (y # ys))
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
length ys' = length xs'
mset (zip xs' ys') = mset (zip (x # xs) (y # ys))

goal (1 subgoal):
 1. \<exists>ys'. length ys' = length xs' \<and> mset (zip xs' ys') = mset (zip (x # xs) (y # ys))
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
\<exists>ys'. length ys' = length xs' \<and> mset (zip xs' ys') = mset (zip (x # xs) (y # ys))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
theorem reals_Archimedean:
  fixes x :: real
  assumes x_pos: "0 < x"
  shows "\<exists>n. inverse (of_nat (Suc n)) < x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>n. inverse (of_nat (Suc n)) < x
[PROOF STEP]
proof (rule ccontr)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<nexists>n. inverse (of_nat (Suc n)) < x \<Longrightarrow> False
[PROOF STEP]
assume contr: "\<not> ?thesis"
[PROOF STATE]
proof (state)
this:
\<nexists>n. inverse (of_nat (Suc n)) < x

goal (1 subgoal):
 1. \<nexists>n. inverse (of_nat (Suc n)) < x \<Longrightarrow> False
[PROOF STEP]
have "\<forall>n. x * of_nat (Suc n) \<le> 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>n. x * of_nat (Suc n) \<le> 1
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n. x * of_nat (Suc n) \<le> 1
[PROOF STEP]
fix n
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n. x * of_nat (Suc n) \<le> 1
[PROOF STEP]
from contr
[PROOF STATE]
proof (chain)
picking this:
\<nexists>n. inverse (of_nat (Suc n)) < x
[PROOF STEP]
have "x \<le> inverse (of_nat (Suc n))"
[PROOF STATE]
proof (prove)
using this:
\<nexists>n. inverse (of_nat (Suc n)) < x

goal (1 subgoal):
 1. x \<le> inverse (of_nat (Suc n))
[PROOF STEP]
by (simp add: linorder_not_less)
[PROOF STATE]
proof (state)
this:
x \<le> inverse (of_nat (Suc n))

goal (1 subgoal):
 1. \<And>n. x * of_nat (Suc n) \<le> 1
[PROOF STEP]
hence "x \<le> (1 / (of_nat (Suc n)))"
[PROOF STATE]
proof (prove)
using this:
x \<le> inverse (of_nat (Suc n))

goal (1 subgoal):
 1. x \<le> 1 / of_nat (Suc n)
[PROOF STEP]
by (simp add: inverse_eq_divide)
[PROOF STATE]
proof (state)
this:
x \<le> 1 / of_nat (Suc n)

goal (1 subgoal):
 1. \<And>n. x * of_nat (Suc n) \<le> 1
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
x \<le> 1 / of_nat (Suc n)

goal (1 subgoal):
 1. \<And>n. x * of_nat (Suc n) \<le> 1
[PROOF STEP]
have "(0::real) \<le> of_nat (Suc n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 \<le> of_nat (Suc n)
[PROOF STEP]
by (rule of_nat_0_le_iff)
[PROOF STATE]
proof (state)
this:
0 \<le> of_nat (Suc n)

goal (1 subgoal):
 1. \<And>n. x * of_nat (Suc n) \<le> 1
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
x \<le> 1 / of_nat (Suc n)
0 \<le> of_nat (Suc n)
[PROOF STEP]
have "x * of_nat (Suc n) \<le> (1 / of_nat (Suc n)) * of_nat (Suc n)"
[PROOF STATE]
proof (prove)
using this:
x \<le> 1 / of_nat (Suc n)
0 \<le> of_nat (Suc n)

goal (1 subgoal):
 1. x * of_nat (Suc n) \<le> 1 / of_nat (Suc n) * of_nat (Suc n)
[PROOF STEP]
by (rule mult_right_mono)
[PROOF STATE]
proof (state)
this:
x * of_nat (Suc n) \<le> 1 / of_nat (Suc n) * of_nat (Suc n)

goal (1 subgoal):
 1. \<And>n. x * of_nat (Suc n) \<le> 1
[PROOF STEP]
thus "x * of_nat (Suc n) \<le> 1"
[PROOF STATE]
proof (prove)
using this:
x * of_nat (Suc n) \<le> 1 / of_nat (Suc n) * of_nat (Suc n)

goal (1 subgoal):
 1. x * of_nat (Suc n) \<le> 1
[PROOF STEP]
by (simp del: of_nat_Suc)
[PROOF STATE]
proof (state)
this:
x * of_nat (Suc n) \<le> 1

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<forall>n. x * of_nat (Suc n) \<le> 1

goal (1 subgoal):
 1. \<nexists>n. inverse (of_nat (Suc n)) < x \<Longrightarrow> False
[PROOF STEP]
hence 2: "bdd_above {z. \<exists>n. z = x * (of_nat (Suc n))}"
[PROOF STATE]
proof (prove)
using this:
\<forall>n. x * of_nat (Suc n) \<le> 1

goal (1 subgoal):
 1. bdd_above {z. \<exists>n. z = x * of_nat (Suc n)}
[PROOF STEP]
by (auto intro!: bdd_aboveI[of _ 1])
[PROOF STATE]
proof (state)
this:
bdd_above {z. \<exists>n. z = x * of_nat (Suc n)}

goal (1 subgoal):
 1. \<nexists>n. inverse (of_nat (Suc n)) < x \<Longrightarrow> False
[PROOF STEP]
have 1: "\<exists>X. X \<in> {z. \<exists>n. z = x* (of_nat (Suc n))}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>X. X \<in> {z. \<exists>n. z = x * of_nat (Suc n)}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<exists>X. X \<in> {z. \<exists>n. z = x * of_nat (Suc n)}

goal (1 subgoal):
 1. \<nexists>n. inverse (of_nat (Suc n)) < x \<Longrightarrow> False
[PROOF STEP]
obtain t where
    upper: "\<And>z. z \<in> {z. \<exists>n. z = x * of_nat (Suc n)} \<Longrightarrow> z \<le> t" and
    least: "\<And>y. (\<And>a. a \<in> {z. \<exists>n. z = x * of_nat (Suc n)} \<Longrightarrow> a \<le> y) \<Longrightarrow> t \<le> y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>t. \<lbrakk>\<And>z. z \<in> {z. \<exists>n. z = x * of_nat (Suc n)} \<Longrightarrow> z \<le> t; \<And>y. (\<And>a. a \<in> {z. \<exists>n. z = x * of_nat (Suc n)} \<Longrightarrow> a \<le> y) \<Longrightarrow> t \<le> y\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using reals_complete[OF 1 2]
[PROOF STATE]
proof (prove)
using this:
\<exists>xa. (\<forall>s\<in>{z. \<exists>n. z = x * of_nat (Suc n)}. s \<le> xa) \<and> (\<forall>y. (\<forall>s\<in>{z. \<exists>n. z = x * of_nat (Suc n)}. s \<le> y) \<longrightarrow> xa \<le> y)

goal (1 subgoal):
 1. (\<And>t. \<lbrakk>\<And>z. z \<in> {z. \<exists>n. z = x * of_nat (Suc n)} \<Longrightarrow> z \<le> t; \<And>y. (\<And>a. a \<in> {z. \<exists>n. z = x * of_nat (Suc n)} \<Longrightarrow> a \<le> y) \<Longrightarrow> t \<le> y\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
?z \<in> {z. \<exists>n. z = x * of_nat (Suc n)} \<Longrightarrow> ?z \<le> t
(\<And>a. a \<in> {z. \<exists>n. z = x * of_nat (Suc n)} \<Longrightarrow> a \<le> ?y) \<Longrightarrow> t \<le> ?y

goal (1 subgoal):
 1. \<nexists>n. inverse (of_nat (Suc n)) < x \<Longrightarrow> False
[PROOF STEP]
have "t \<le> t + - x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. t \<le> t + - x
[PROOF STEP]
proof (rule least)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a. a \<in> {z. \<exists>n. z = x * of_nat (Suc n)} \<Longrightarrow> a \<le> t + - x
[PROOF STEP]
fix a
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a. a \<in> {z. \<exists>n. z = x * of_nat (Suc n)} \<Longrightarrow> a \<le> t + - x
[PROOF STEP]
assume a: "a \<in> {z. \<exists>n. z = x * (of_nat (Suc n))}"
[PROOF STATE]
proof (state)
this:
a \<in> {z. \<exists>n. z = x * of_nat (Suc n)}

goal (1 subgoal):
 1. \<And>a. a \<in> {z. \<exists>n. z = x * of_nat (Suc n)} \<Longrightarrow> a \<le> t + - x
[PROOF STEP]
have "\<forall>n::nat. x * of_nat n \<le> t + - x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>n. x * of_nat n \<le> t + - x
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n. x * of_nat n \<le> t + - x
[PROOF STEP]
fix n
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n. x * of_nat n \<le> t + - x
[PROOF STEP]
have "x * of_nat (Suc n) \<le> t"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x * of_nat (Suc n) \<le> t
[PROOF STEP]
by (simp add: upper)
[PROOF STATE]
proof (state)
this:
x * of_nat (Suc n) \<le> t

goal (1 subgoal):
 1. \<And>n. x * of_nat n \<le> t + - x
[PROOF STEP]
hence  "x * (of_nat n) + x \<le> t"
[PROOF STATE]
proof (prove)
using this:
x * of_nat (Suc n) \<le> t

goal (1 subgoal):
 1. x * of_nat n + x \<le> t
[PROOF STEP]
by (simp add: distrib_left)
[PROOF STATE]
proof (state)
this:
x * of_nat n + x \<le> t

goal (1 subgoal):
 1. \<And>n. x * of_nat n \<le> t + - x
[PROOF STEP]
thus  "x * (of_nat n) \<le> t + - x"
[PROOF STATE]
proof (prove)
using this:
x * of_nat n + x \<le> t

goal (1 subgoal):
 1. x * of_nat n \<le> t + - x
[PROOF STEP]
by arith
[PROOF STATE]
proof (state)
this:
x * of_nat n \<le> t + - x

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<forall>n. x * of_nat n \<le> t + - x

goal (1 subgoal):
 1. \<And>a. a \<in> {z. \<exists>n. z = x * of_nat (Suc n)} \<Longrightarrow> a \<le> t + - x
[PROOF STEP]
hence "\<forall>m. x * of_nat (Suc m) \<le> t + - x"
[PROOF STATE]
proof (prove)
using this:
\<forall>n. x * of_nat n \<le> t + - x

goal (1 subgoal):
 1. \<forall>m. x * of_nat (Suc m) \<le> t + - x
[PROOF STEP]
by (simp del: of_nat_Suc)
[PROOF STATE]
proof (state)
this:
\<forall>m. x * of_nat (Suc m) \<le> t + - x

goal (1 subgoal):
 1. \<And>a. a \<in> {z. \<exists>n. z = x * of_nat (Suc n)} \<Longrightarrow> a \<le> t + - x
[PROOF STEP]
with a
[PROOF STATE]
proof (chain)
picking this:
a \<in> {z. \<exists>n. z = x * of_nat (Suc n)}
\<forall>m. x * of_nat (Suc m) \<le> t + - x
[PROOF STEP]
show "a \<le> t + - x"
[PROOF STATE]
proof (prove)
using this:
a \<in> {z. \<exists>n. z = x * of_nat (Suc n)}
\<forall>m. x * of_nat (Suc m) \<le> t + - x

goal (1 subgoal):
 1. a \<le> t + - x
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
a \<le> t + - x

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
t \<le> t + - x

goal (1 subgoal):
 1. \<nexists>n. inverse (of_nat (Suc n)) < x \<Longrightarrow> False
[PROOF STEP]
thus False
[PROOF STATE]
proof (prove)
using this:
t \<le> t + - x

goal (1 subgoal):
 1. False
[PROOF STEP]
using x_pos
[PROOF STATE]
proof (prove)
using this:
t \<le> t + - x
0 < x

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

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma poly_induct2 [case_names 0 pCons]:
  assumes "P 0 0" "\<And>a p b q. P p q \<Longrightarrow> P (pCons a p) (pCons b q)"
  shows "P p q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. P p q
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. P p q
[PROOF STEP]
define n where "n = max (length (coeffs p)) (length (coeffs q))"
[PROOF STATE]
proof (state)
this:
n = max (length (coeffs p)) (length (coeffs q))

goal (1 subgoal):
 1. P p q
[PROOF STEP]
define xs where "xs = coeffs p @ (replicate (n - length (coeffs p)) 0)"
[PROOF STATE]
proof (state)
this:
xs = coeffs p @ replicate (n - length (coeffs p)) (0::'a)

goal (1 subgoal):
 1. P p q
[PROOF STEP]
define ys where "ys = coeffs q @ (replicate (n - length (coeffs q)) 0)"
[PROOF STATE]
proof (state)
this:
ys = coeffs q @ replicate (n - length (coeffs q)) (0::'b)

goal (1 subgoal):
 1. P p q
[PROOF STEP]
have "length xs = length ys"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length xs = length ys
[PROOF STEP]
by (simp add: xs_def ys_def n_def)
[PROOF STATE]
proof (state)
this:
length xs = length ys

goal (1 subgoal):
 1. P p q
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
length xs = length ys
[PROOF STEP]
have "P (Poly xs) (Poly ys)"
[PROOF STATE]
proof (prove)
using this:
length xs = length ys

goal (1 subgoal):
 1. P (Poly xs) (Poly ys)
[PROOF STEP]
by (induct rule: list_induct2) (simp_all add: assms)
[PROOF STATE]
proof (state)
this:
P (Poly xs) (Poly ys)

goal (1 subgoal):
 1. P p q
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
P (Poly xs) (Poly ys)

goal (1 subgoal):
 1. P p q
[PROOF STEP]
have "Poly xs = p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Poly xs = p
[PROOF STEP]
by (simp add: xs_def Poly_append_replicate_0)
[PROOF STATE]
proof (state)
this:
Poly xs = p

goal (1 subgoal):
 1. P p q
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
Poly xs = p

goal (1 subgoal):
 1. P p q
[PROOF STEP]
have "Poly ys = q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Poly ys = q
[PROOF STEP]
by (simp add: ys_def Poly_append_replicate_0)
[PROOF STATE]
proof (state)
this:
Poly ys = q

goal (1 subgoal):
 1. P p q
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
P p q
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
P p q

goal (1 subgoal):
 1. P p q
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
P p q

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma RR2_difference:
  assumes "RR2_spec A T" "RR2_spec B U"
  shows "RR2_spec (difference_reg A B) (T - U)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. RR2_spec (difference_reg A B) (T - U)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
RR2_spec A T
RR2_spec B U

goal (1 subgoal):
 1. RR2_spec (difference_reg A B) (T - U)
[PROOF STEP]
by (auto simp: RR2_spec_def \<L>_difference_reg)


[STATEMENT]
lemma periodic_set_subset[elim]:
  assumes "periodic_set S \<delta>" "T \<subseteq> S"
  shows "periodic_set T \<delta>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. periodic_set T \<delta>
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
periodic_set S \<delta>
T \<subseteq> S

goal (1 subgoal):
 1. periodic_set T \<delta>
[PROOF STEP]
unfolding periodic_set_def
[PROOF STATE]
proof (prove)
using this:
\<exists>B. finite B \<and> (\<forall>x\<in>S. \<exists>b\<in>B. \<exists>xa. x = b + real_of_int xa * \<delta>)
T \<subseteq> S

goal (1 subgoal):
 1. \<exists>B. finite B \<and> (\<forall>x\<in>T. \<exists>b\<in>B. \<exists>xa. x = b + real_of_int xa * \<delta>)
[PROOF STEP]
by (meson subsetCE)


[STATEMENT]
lemma pi_approx2':
  fixes n :: nat assumes n: "even n" and "n > 0" and "k \<le> 46*n - 1"
  shows   "\<bar>pi - pi_approx2 n\<bar> \<le> inverse (2^k)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<bar>pi - pi_approx2 n\<bar> \<le> inverse (2 ^ k)
[PROOF STEP]
using assms(3)
[PROOF STATE]
proof (prove)
using this:
k \<le> 46 * n - 1

goal (1 subgoal):
 1. \<bar>pi - pi_approx2 n\<bar> \<le> inverse (2 ^ k)
[PROOF STEP]
by (intro order.trans[OF pi_approx2[OF assms(1,2)]]) (simp_all add: field_simps)


[STATEMENT]
lemma pos_less_minus_divideC_eq [field_simps]:
  "a < - (b /\<^sub>C c) \<longleftrightarrow> c *\<^sub>C a < - b" if "c > 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (a < - (b /\<^sub>C c)) = (c *\<^sub>C a < - b)
[PROOF STEP]
using that
[PROOF STATE]
proof (prove)
using this:
0 < c

goal (1 subgoal):
 1. (a < - (b /\<^sub>C c)) = (c *\<^sub>C a < - b)
[PROOF STEP]
by (metis le_less less_le_not_le pos_divideC_le_eq pos_divideC_less_eq pos_le_minus_divideC_eq)


[STATEMENT]
lemma Pow_lepoll_mono:
  assumes "A \<lesssim> B"
  shows "Pow A \<lesssim> Pow B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Pow A \<lesssim> Pow B
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
A \<lesssim> B

goal (1 subgoal):
 1. Pow A \<lesssim> Pow B
[PROOF STEP]
by (metis Pow_mono image_Pow_surj lepoll_iff)


[STATEMENT]
lemma Idempotent_comp [intro]:
  "\<lbrakk> Idempotent f; Idempotent g; f \<circ> g = g \<circ> f \<rbrakk> \<Longrightarrow> Idempotent (f \<circ> g)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>Idempotent f; Idempotent g; f \<circ> g = g \<circ> f\<rbrakk> \<Longrightarrow> Idempotent (f \<circ> g)
[PROOF STEP]
by (auto simp add: Idempotent_def comp_def, metis)


[STATEMENT]
lemma (in TwoRings) i_contract_mono:"\<lbrakk>f \<in> rHom R R'; ideal R' J1; ideal R' J2;
 J1 \<subseteq> J2 \<rbrakk> \<Longrightarrow> i_contract f R R' J1 \<subseteq> i_contract f R R' J2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>f \<in> rHom R R'; ideal R' J1; ideal R' J2; J1 \<subseteq> J2\<rbrakk> \<Longrightarrow> i_contract f R R' J1 \<subseteq> i_contract f R R' J2
[PROOF STEP]
apply (rule subsetI)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. \<lbrakk>f \<in> rHom R R'; ideal R' J1; ideal R' J2; J1 \<subseteq> J2; x \<in> i_contract f R R' J1\<rbrakk> \<Longrightarrow> x \<in> i_contract f R R' J2
[PROOF STEP]
apply (simp add:i_contract_def invim_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. \<lbrakk>f \<in> rHom R R'; ideal R' J1; ideal R' J2; J1 \<subseteq> J2; x \<in> carrier R \<and> f x \<in> J1\<rbrakk> \<Longrightarrow> f x \<in> J2
[PROOF STEP]
apply (erule conjE)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. \<lbrakk>f \<in> rHom R R'; ideal R' J1; ideal R' J2; J1 \<subseteq> J2; x \<in> carrier R; f x \<in> J1\<rbrakk> \<Longrightarrow> f x \<in> J2
[PROOF STEP]
apply (rule subsetD, assumption+)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma smooth_path_imp_reverse:
  assumes "g C1_differentiable_on {0..1}"
  shows "(reversepath g) C1_differentiable_on {0..1}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. reversepath g C1_differentiable_on {0..1}
[PROOF STEP]
using assms continuous_on_const
[PROOF STATE]
proof (prove)
using this:
g C1_differentiable_on {0..1}
continuous_on ?s (\<lambda>x. ?c)

goal (1 subgoal):
 1. reversepath g C1_differentiable_on {0..1}
[PROOF STEP]
apply (auto simp: reversepath_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. g C1_differentiable_on {0..1} \<Longrightarrow> (\<lambda>x. g (1 - x)) C1_differentiable_on {0..1}
[PROOF STEP]
apply (rule C1_differentiable_compose [of "\<lambda>x::real. 1-x" _ g, unfolded o_def])
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. g C1_differentiable_on {0..1} \<Longrightarrow> (-) 1 C1_differentiable_on {0..1}
 2. g C1_differentiable_on {0..1} \<Longrightarrow> g C1_differentiable_on (-) 1 ` {0..1}
 3. \<And>x. g C1_differentiable_on {0..1} \<Longrightarrow> finite ({0..1} \<inter> (-) 1 -` {x})
[PROOF STEP]
apply (auto simp: C1_differentiable_on_eq)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. \<lbrakk>\<forall>x\<in>{0..1}. g differentiable at x; continuous_on {0..1} (\<lambda>x. vector_derivative g (at x))\<rbrakk> \<Longrightarrow> finite ({0..1} \<inter> (-) 1 -` {x})
[PROOF STEP]
apply (simp add: finite_vimageI inj_on_def)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma adjoint_works:
  fixes f :: "'n::euclidean_space \<Rightarrow> 'm::euclidean_space"
  assumes lf: "linear f"
  shows "x \<bullet> adjoint f y = f x \<bullet> y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<bullet> adjoint f y = f x \<bullet> y
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. x \<bullet> adjoint f y = f x \<bullet> y
[PROOF STEP]
interpret linear f
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. linear f
[PROOF STEP]
by fact
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. x \<bullet> adjoint f y = f x \<bullet> y
[PROOF STEP]
have "\<forall>y. \<exists>w. \<forall>x. f x \<bullet> y = x \<bullet> w"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>y. \<exists>w. \<forall>x. f x \<bullet> y = x \<bullet> w
[PROOF STEP]
proof (intro allI exI)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>y x. f x \<bullet> y = x \<bullet> ?w1 y
[PROOF STEP]
fix y :: "'m" and x
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>y x. f x \<bullet> y = x \<bullet> ?w1 y
[PROOF STEP]
let ?w = "(\<Sum>i\<in>Basis. (f i \<bullet> y) *\<^sub>R i) :: 'n"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>y x. f x \<bullet> y = x \<bullet> ?w1 y
[PROOF STEP]
have "f x \<bullet> y = f (\<Sum>i\<in>Basis. (x \<bullet> i) *\<^sub>R i) \<bullet> y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f x \<bullet> y = f (\<Sum>i\<in>Basis. (x \<bullet> i) *\<^sub>R i) \<bullet> y
[PROOF STEP]
by (simp add: euclidean_representation)
[PROOF STATE]
proof (state)
this:
f x \<bullet> y = f (\<Sum>i\<in>Basis. (x \<bullet> i) *\<^sub>R i) \<bullet> y

goal (1 subgoal):
 1. \<And>y x. f x \<bullet> y = x \<bullet> ?w1 y
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
f x \<bullet> y = f (\<Sum>i\<in>Basis. (x \<bullet> i) *\<^sub>R i) \<bullet> y

goal (1 subgoal):
 1. \<And>y x. f x \<bullet> y = x \<bullet> ?w1 y
[PROOF STEP]
have "\<dots> = (\<Sum>i\<in>Basis. (x \<bullet> i) *\<^sub>R f i) \<bullet> y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f (\<Sum>i\<in>Basis. (x \<bullet> i) *\<^sub>R i) \<bullet> y = (\<Sum>i\<in>Basis. (x \<bullet> i) *\<^sub>R f i) \<bullet> y
[PROOF STEP]
by (simp add: sum scale)
[PROOF STATE]
proof (state)
this:
f (\<Sum>i\<in>Basis. (x \<bullet> i) *\<^sub>R i) \<bullet> y = (\<Sum>i\<in>Basis. (x \<bullet> i) *\<^sub>R f i) \<bullet> y

goal (1 subgoal):
 1. \<And>y x. f x \<bullet> y = x \<bullet> ?w1 y
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
f x \<bullet> y = (\<Sum>i\<in>Basis. (x \<bullet> i) *\<^sub>R f i) \<bullet> y
[PROOF STEP]
show "f x \<bullet> y = x \<bullet> ?w"
[PROOF STATE]
proof (prove)
using this:
f x \<bullet> y = (\<Sum>i\<in>Basis. (x \<bullet> i) *\<^sub>R f i) \<bullet> y

goal (1 subgoal):
 1. f x \<bullet> y = x \<bullet> (\<Sum>i\<in>Basis. (f i \<bullet> y) *\<^sub>R i)
[PROOF STEP]
by (simp add: inner_sum_left inner_sum_right mult.commute)
[PROOF STATE]
proof (state)
this:
f x \<bullet> y = x \<bullet> (\<Sum>i\<in>Basis. (f i \<bullet> y) *\<^sub>R i)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<forall>y. \<exists>w. \<forall>x. f x \<bullet> y = x \<bullet> w

goal (1 subgoal):
 1. x \<bullet> adjoint f y = f x \<bullet> y
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<forall>y. \<exists>w. \<forall>x. f x \<bullet> y = x \<bullet> w
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<forall>y. \<exists>w. \<forall>x. f x \<bullet> y = x \<bullet> w

goal (1 subgoal):
 1. x \<bullet> adjoint f y = f x \<bullet> y
[PROOF STEP]
unfolding adjoint_def choice_iff
[PROOF STATE]
proof (prove)
using this:
\<exists>fa. \<forall>y x. f x \<bullet> y = x \<bullet> fa y

goal (1 subgoal):
 1. x \<bullet> (SOME f'. \<forall>x y. f x \<bullet> y = x \<bullet> f' y) y = f x \<bullet> y
[PROOF STEP]
by (intro someI2_ex[where Q="\<lambda>f'. x \<bullet> f' y = f x \<bullet> y"]) auto
[PROOF STATE]
proof (state)
this:
x \<bullet> adjoint f y = f x \<bullet> y

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma deg_comp_monotone:
  assumes "cmp u v = Lt \<Longrightarrow> cmp (splus t u) (splus t v) = Lt" and "deg_comp cmp u v = Lt"
  shows "deg_comp cmp (splus t u) (splus t v) = Lt"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. deg_comp cmp (splus t u) (splus t v) = Lt
[PROOF STEP]
using assms(2)
[PROOF STATE]
proof (prove)
using this:
deg_comp cmp u v = Lt

goal (1 subgoal):
 1. deg_comp cmp (splus t u) (splus t v) = Lt
[PROOF STEP]
by (auto simp: deg_comp splus_term pprod.splus_def comparator_of_def deg_pp_plus
                          split: order.splits if_splits intro: assms(1))


[STATEMENT]
lemma closure_translation_subtract:
  "closure ((\<lambda>x. x - a) ` s) = (\<lambda>x. x - a) ` closure s" for a :: "'a::real_normed_vector"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. closure ((\<lambda>x. x - a) ` s) = (\<lambda>x. x - a) ` closure s
[PROOF STEP]
using closure_translation [of "- a" s]
[PROOF STATE]
proof (prove)
using this:
closure ((+) (- a) ` s) = (+) (- a) ` closure s

goal (1 subgoal):
 1. closure ((\<lambda>x. x - a) ` s) = (\<lambda>x. x - a) ` closure s
[PROOF STEP]
by (simp cong: image_cong_simp)


[STATEMENT]
lemma cA_index: "cA $ i $ j = c (A $ i $ j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cA $h i $h j = complex_of_real (A $h i $h j)
[PROOF STEP]
unfolding map_matrix_def map_vector_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<chi>i ia. complex_of_real (A $h i $h ia)) $h i $h j = complex_of_real (A $h i $h j)
[PROOF STEP]
by simp


[STATEMENT]
lemma hypnat_diff_mult_distrib2: "\<And>k m n::hypnat. k * (m - n) = (k * m) - (k * n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>k m n. k * (m - n) = k * m - k * n
[PROOF STEP]
by transfer (rule diff_mult_distrib2)


[STATEMENT]
lemma fimage_eq_to_f:
  assumes  "f1 |`| S1 = f2 |`| S2"
  obtains f where "\<And> x. x |\<in>| S2 \<Longrightarrow> f x |\<in>| S1 \<and> f1 (f x) = f2 x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>f. (\<And>x. x |\<in>| S2 \<Longrightarrow> f x |\<in>| S1 \<and> f1 (f x) = f2 x) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
f1 |`| S1 = f2 |`| S2

goal (1 subgoal):
 1. (\<And>f. (\<And>x. x |\<in>| S2 \<Longrightarrow> f x |\<in>| S1 \<and> f1 (f x) = f2 x) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
apply transfer
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>S2 S1 f1 f2 thesis. \<lbrakk>finite S2; finite S1; \<And>f. (\<And>x. x \<in> S2 \<Longrightarrow> f x \<in> S1 \<and> f1 (f x) = f2 x) \<Longrightarrow> thesis; f1 ` S1 = f2 ` S2\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
using image_eq_to_f
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?f1.0 ` ?S1.0 = ?f2.0 ` ?S2.0; \<And>f. (\<And>x. x \<in> ?S2.0 \<Longrightarrow> f x \<in> ?S1.0 \<and> ?f1.0 (f x) = ?f2.0 x) \<Longrightarrow> ?thesis\<rbrakk> \<Longrightarrow> ?thesis

goal (1 subgoal):
 1. \<And>S2 S1 f1 f2 thesis. \<lbrakk>finite S2; finite S1; \<And>f. (\<And>x. x \<in> S2 \<Longrightarrow> f x \<in> S1 \<and> f1 (f x) = f2 x) \<Longrightarrow> thesis; f1 ` S1 = f2 ` S2\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
by metis


[STATEMENT]
lemma vdiff_alt_def:
  assumes "length w = length v"
  shows "w -\<^sub>v v = map (\<lambda>(x, y). x - y) (zip w v)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. w -\<^sub>v v = map2 (-) w v
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
length w = length v

goal (1 subgoal):
 1. w -\<^sub>v v = map2 (-) w v
[PROOF STEP]
by (induct rule: list_induct2) simp_all


[STATEMENT]
lemma E_const[simp]: "E (return_pmf a) = a"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. E (return_pmf a) = a
[PROOF STEP]
unfolding E_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. measure_pmf.expectation (return_pmf a) (\<lambda>x. x) = a
[PROOF STEP]
unfolding return_pmf.rep_eq
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<integral> x. x \<partial>return (count_space UNIV) a = a
[PROOF STEP]
by (simp add: integral_return)


[STATEMENT]
lemma seqstar_inf_parstar: "a\<^sup>; \<le>\<^sub>\<K> a\<^sup>*"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a\<^sup>; \<le> a\<^sup>*
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. a\<^sup>; \<le> a\<^sup>*
[PROOF STEP]
have "a ; a\<^sup>* \<le>\<^sub>\<K> a * a\<^sup>*"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a ; a\<^sup>* \<le> a * a\<^sup>*
[PROOF STEP]
by (rule seq_inf_par)
[PROOF STATE]
proof (state)
this:
a ; a\<^sup>* \<le> a * a\<^sup>*

goal (1 subgoal):
 1. a\<^sup>; \<le> a\<^sup>*
[PROOF STEP]
hence "1 + a ; a\<^sup>* \<le>\<^sub>\<K> 1 + a * a\<^sup>*"
[PROOF STATE]
proof (prove)
using this:
a ; a\<^sup>* \<le> a * a\<^sup>*

goal (1 subgoal):
 1. (1::'a) + a ; a\<^sup>* \<le> (1::'a) + a * a\<^sup>*
[PROOF STEP]
by (simp add: add_left_mono)
[PROOF STATE]
proof (state)
this:
(1::'a) + a ; a\<^sup>* \<le> (1::'a) + a * a\<^sup>*

goal (1 subgoal):
 1. a\<^sup>; \<le> a\<^sup>*
[PROOF STEP]
hence "1 + a ; a\<^sup>* \<le>\<^sub>\<K> a\<^sup>*"
[PROOF STATE]
proof (prove)
using this:
(1::'a) + a ; a\<^sup>* \<le> (1::'a) + a * a\<^sup>*

goal (1 subgoal):
 1. (1::'a) + a ; a\<^sup>* \<le> a\<^sup>*
[PROOF STEP]
by (simp add: star_unfoldl order_trans)
[PROOF STATE]
proof (state)
this:
(1::'a) + a ; a\<^sup>* \<le> a\<^sup>*

goal (1 subgoal):
 1. a\<^sup>; \<le> a\<^sup>*
[PROOF STEP]
hence "a\<^sup>; ; 1 \<le>\<^sub>\<K> a\<^sup>*"
[PROOF STATE]
proof (prove)
using this:
(1::'a) + a ; a\<^sup>* \<le> a\<^sup>*

goal (1 subgoal):
 1. a\<^sup>; ; (1::'a) \<le> a\<^sup>*
[PROOF STEP]
by (rule seqstar_inductl)
[PROOF STATE]
proof (state)
this:
a\<^sup>; ; (1::'a) \<le> a\<^sup>*

goal (1 subgoal):
 1. a\<^sup>; \<le> a\<^sup>*
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
a\<^sup>; ; (1::'a) \<le> a\<^sup>*

goal (1 subgoal):
 1. a\<^sup>; \<le> a\<^sup>*
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
a\<^sup>; \<le> a\<^sup>*

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma det_swapcols:
  assumes *: "k < n" "l < n" "k \<noteq> l" and A: "A \<in> carrier_mat n n"
  shows "det (swapcols k l A) = - det A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. det (swapcols k l A) = - det A
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. det (swapcols k l A) = - det A
[PROOF STEP]
let ?B = "transpose_mat A"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. det (swapcols k l A) = - det A
[PROOF STEP]
let ?C = "swaprows k l ?B"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. det (swapcols k l A) = - det A
[PROOF STEP]
let ?D = "transpose_mat ?C"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. det (swapcols k l A) = - det A
[PROOF STEP]
have C: "?C \<in> carrier_mat n n" and B: "?B \<in> carrier_mat n n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. swaprows k l A\<^sup>T \<in> carrier_mat n n &&& A\<^sup>T \<in> carrier_mat n n
[PROOF STEP]
unfolding transpose_carrier_mat swaprows_carrier
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A \<in> carrier_mat n n &&& A \<in> carrier_mat n n
[PROOF STEP]
using A
[PROOF STATE]
proof (prove)
using this:
A \<in> carrier_mat n n

goal (1 subgoal):
 1. A \<in> carrier_mat n n &&& A \<in> carrier_mat n n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
swaprows k l A\<^sup>T \<in> carrier_mat n n
A\<^sup>T \<in> carrier_mat n n

goal (1 subgoal):
 1. det (swapcols k l A) = - det A
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. det (swapcols k l A) = - det A
[PROOF STEP]
unfolding
      swapcols_is_transp_swap_rows[OF A *(1-2)]
      det_transpose[OF C] det_swaprows[OF * B] det_transpose[OF A]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. - det A = - det A
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
det (swapcols k l A) = - det A

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma cartesian_power_car_memI':
  assumes "length as = n"
  assumes "\<And>i. i < n \<Longrightarrow>  as ! i \<in> carrier R"
  shows "as \<in> carrier (R\<^bsup>n\<^esup>)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. as \<in> carrier (R\<^bsup>n\<^esup>)
[PROOF STEP]
unfolding cartesian_power_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. as \<in> carrier (RDirProd_list (R_list n R))
[PROOF STEP]
apply(rule RDirProd_list_carrier_memI)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. length as = length (R_list n R)
 2. \<And>i. i < length (R_list n R) \<Longrightarrow> as ! i \<in> carrier (R_list n R ! i)
[PROOF STEP]
using R_list_length assms(1)
[PROOF STATE]
proof (prove)
using this:
length (R_list ?n ?R) = ?n
length as = n

goal (2 subgoals):
 1. length as = length (R_list n R)
 2. \<And>i. i < length (R_list n R) \<Longrightarrow> as ! i \<in> carrier (R_list n R ! i)
[PROOF STEP]
apply auto[1]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>i. i < length (R_list n R) \<Longrightarrow> as ! i \<in> carrier (R_list n R ! i)
[PROOF STEP]
by (metis R_list_length R_list_nth assms(2))


[STATEMENT]
lemma div_base_i:
  assumes "\<And>i. i<n \<Longrightarrow> d i < base" "n>0" "i<n"
  shows "from_digits n d div (base ^i) = (\<Sum>j=i..<n. d j * base ^ (j-i))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. from_digits n d div base ^ i = (\<Sum>j = i..<n. d j * base ^ (j - i))
[PROOF STEP]
unfolding from_digits_altdef
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i<n. d i * base ^ i) div base ^ i = (\<Sum>j = i..<n. d j * base ^ (j - i))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<Sum>i<n. d i * base ^ i) div base ^ i = (\<Sum>j = i..<n. d j * base ^ (j - i))
[PROOF STEP]
have base_exp: "base^(j) =  base^(j-i) * base^i"
    if "j\<in>{i..<n}" for j
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. base ^ j = base ^ (j - i) * base ^ i
[PROOF STEP]
by (metis Nat.add_diff_assoc2 add_diff_cancel_right' atLeastLessThan_iff
        power_add that)
[PROOF STATE]
proof (state)
this:
?j \<in> {i..<n} \<Longrightarrow> base ^ ?j = base ^ (?j - i) * base ^ i

goal (1 subgoal):
 1. (\<Sum>i<n. d i * base ^ i) div base ^ i = (\<Sum>j = i..<n. d j * base ^ (j - i))
[PROOF STEP]
have first:"(\<Sum>j<i. d j * base ^ j)< base ^ i"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>j<i. d j * base ^ j) < base ^ i
[PROOF STEP]
using assms from_digits_less[where n="i"]
[PROOF STATE]
proof (prove)
using this:
?i < n \<Longrightarrow> d ?i < base
0 < n
i < n
\<forall>ia<i. ?d ia < base \<Longrightarrow> from_digits i ?d < base ^ i

goal (1 subgoal):
 1. (\<Sum>j<i. d j * base ^ j) < base ^ i
[PROOF STEP]
unfolding from_digits_altdef
[PROOF STATE]
proof (prove)
using this:
?i < n \<Longrightarrow> d ?i < base
0 < n
i < n
\<forall>ia<i. ?d ia < base \<Longrightarrow> (\<Sum>i<i. ?d i * base ^ i) < base ^ i

goal (1 subgoal):
 1. (\<Sum>j<i. d j * base ^ j) < base ^ i
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<Sum>j<i. d j * base ^ j) < base ^ i

goal (1 subgoal):
 1. (\<Sum>i<n. d i * base ^ i) div base ^ i = (\<Sum>j = i..<n. d j * base ^ (j - i))
[PROOF STEP]
have "(\<Sum>j<n. d j * base ^ j) =
          (\<Sum>j<i. d j * base ^ j) + (\<Sum>j=i..<n. d j * base ^ j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>j<n. d j * base ^ j) = (\<Sum>j<i. d j * base ^ j) + (\<Sum>j = i..<n. d j * base ^ j)
[PROOF STEP]
using assms split_sum_mid_less[where f="(\<lambda>j. d j * base^j)"]
[PROOF STATE]
proof (prove)
using this:
?i < n \<Longrightarrow> d ?i < base
0 < n
i < n
?i < ?n \<Longrightarrow> (\<Sum>j<?n. d j * base ^ j) = (\<Sum>j<?i. d j * base ^ j) + (\<Sum>j = ?i..<?n. d j * base ^ j)

goal (1 subgoal):
 1. (\<Sum>j<n. d j * base ^ j) = (\<Sum>j<i. d j * base ^ j) + (\<Sum>j = i..<n. d j * base ^ j)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<Sum>j<n. d j * base ^ j) = (\<Sum>j<i. d j * base ^ j) + (\<Sum>j = i..<n. d j * base ^ j)

goal (1 subgoal):
 1. (\<Sum>i<n. d i * base ^ i) div base ^ i = (\<Sum>j = i..<n. d j * base ^ (j - i))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(\<Sum>j<n. d j * base ^ j) = (\<Sum>j<i. d j * base ^ j) + (\<Sum>j = i..<n. d j * base ^ j)
[PROOF STEP]
have split_sum: "(\<Sum>j<n. d j * base ^ j) =
      (\<Sum>j<i. d j * base ^ j) + base^i * (\<Sum>j=i..<n. d j * base ^ (j-i))"
[PROOF STATE]
proof (prove)
using this:
(\<Sum>j<n. d j * base ^ j) = (\<Sum>j<i. d j * base ^ j) + (\<Sum>j = i..<n. d j * base ^ j)

goal (1 subgoal):
 1. (\<Sum>j<n. d j * base ^ j) = (\<Sum>j<i. d j * base ^ j) + base ^ i * (\<Sum>j = i..<n. d j * base ^ (j - i))
[PROOF STEP]
using base_exp mult.assoc sum_distrib_right
[PROOF STATE]
proof (prove)
using this:
(\<Sum>j<n. d j * base ^ j) = (\<Sum>j<i. d j * base ^ j) + (\<Sum>j = i..<n. d j * base ^ j)
?j \<in> {i..<n} \<Longrightarrow> base ^ ?j = base ^ (?j - i) * base ^ i
?a * ?b * ?c = ?a * (?b * ?c)
sum ?f ?A * ?r = (\<Sum>n\<in>?A. ?f n * ?r)

goal (1 subgoal):
 1. (\<Sum>j<n. d j * base ^ j) = (\<Sum>j<i. d j * base ^ j) + base ^ i * (\<Sum>j = i..<n. d j * base ^ (j - i))
[PROOF STEP]
by (smt (z3) mult.commute sum.cong)
[PROOF STATE]
proof (state)
this:
(\<Sum>j<n. d j * base ^ j) = (\<Sum>j<i. d j * base ^ j) + base ^ i * (\<Sum>j = i..<n. d j * base ^ (j - i))

goal (1 subgoal):
 1. (\<Sum>i<n. d i * base ^ i) div base ^ i = (\<Sum>j = i..<n. d j * base ^ (j - i))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(\<Sum>j<n. d j * base ^ j) = (\<Sum>j<i. d j * base ^ j) + base ^ i * (\<Sum>j = i..<n. d j * base ^ (j - i))
[PROOF STEP]
show "(\<Sum>i<n. d i * base ^ i) div base ^ i =
              (\<Sum>j = i..<n. d j * base ^ (j - i))"
[PROOF STATE]
proof (prove)
using this:
(\<Sum>j<n. d j * base ^ j) = (\<Sum>j<i. d j * base ^ j) + base ^ i * (\<Sum>j = i..<n. d j * base ^ (j - i))

goal (1 subgoal):
 1. (\<Sum>i<n. d i * base ^ i) div base ^ i = (\<Sum>j = i..<n. d j * base ^ (j - i))
[PROOF STEP]
using first
[PROOF STATE]
proof (prove)
using this:
(\<Sum>j<n. d j * base ^ j) = (\<Sum>j<i. d j * base ^ j) + base ^ i * (\<Sum>j = i..<n. d j * base ^ (j - i))
(\<Sum>j<i. d j * base ^ j) < base ^ i

goal (1 subgoal):
 1. (\<Sum>i<n. d i * base ^ i) div base ^ i = (\<Sum>j = i..<n. d j * base ^ (j - i))
[PROOF STEP]
by (simp add:split_sum base_pos)
[PROOF STATE]
proof (state)
this:
(\<Sum>i<n. d i * base ^ i) div base ^ i = (\<Sum>j = i..<n. d j * base ^ (j - i))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma and_mask_eq_iff_le_mask:
  \<open>w AND mask n = w \<longleftrightarrow> w \<le> mask n\<close>
  for w :: \<open>'a::len word\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (w AND mask n = w) = (w \<le> mask n)
[PROOF STEP]
apply (simp flip: take_bit_eq_mask)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (take_bit n w = w) = (w \<le> mask n)
[PROOF STEP]
apply (cases \<open>n \<ge> LENGTH('a)\<close>; transfer)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>n w. LENGTH('a) \<le> n \<Longrightarrow> (take_bit LENGTH('a) (take_bit (min LENGTH('a) n) w) = take_bit LENGTH('a) w) = (take_bit LENGTH('a) w \<le> take_bit LENGTH('a) (mask n))
 2. \<And>n w. \<not> LENGTH('a) \<le> n \<Longrightarrow> (take_bit LENGTH('a) (take_bit (min LENGTH('a) n) w) = take_bit LENGTH('a) w) = (take_bit LENGTH('a) w \<le> take_bit LENGTH('a) (mask n))
[PROOF STEP]
apply (simp_all add: not_le min_def)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>n w. LENGTH('a) \<le> n \<Longrightarrow> take_bit LENGTH('a) w \<le> mask LENGTH('a)
 2. \<And>n w. n < LENGTH('a) \<Longrightarrow> (take_bit n w = take_bit LENGTH('a) w) = (take_bit LENGTH('a) w \<le> mask n)
[PROOF STEP]
apply (simp_all add: mask_eq_exp_minus_1)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>n w. n < LENGTH('a) \<Longrightarrow> (take_bit n w = take_bit LENGTH('a) w) = (take_bit LENGTH('a) w < 2 ^ n)
[PROOF STEP]
apply auto
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>n w. \<lbrakk>n < LENGTH('a); take_bit n w = take_bit LENGTH('a) w\<rbrakk> \<Longrightarrow> take_bit LENGTH('a) w < 2 ^ n
 2. \<And>n w. \<lbrakk>n < LENGTH('a); take_bit LENGTH('a) w < 2 ^ n\<rbrakk> \<Longrightarrow> take_bit n w = take_bit LENGTH('a) w
[PROOF STEP]
apply (metis take_bit_int_less_exp)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>n w. \<lbrakk>n < LENGTH('a); take_bit LENGTH('a) w < 2 ^ n\<rbrakk> \<Longrightarrow> take_bit n w = take_bit LENGTH('a) w
[PROOF STEP]
apply (metis min_def nat_less_le take_bit_int_eq_self_iff take_bit_take_bit)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma critical_set_oLimit:
"critical_set A (oLimit f) = (\<Inter>n. critical_set A (f n))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. critical_set A (oLimit f) = (\<Inter>n. critical_set A (f n))
[PROOF STEP]
apply (unfold critical_set_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ordinal_rec0 A (\<lambda>p x. x \<inter> range (oDeriv (OrdinalVeblen.ordering x))) (\<lambda>f. \<Inter> (range f)) (oLimit f) = (\<Inter>n. ordinal_rec0 A (\<lambda>p x. x \<inter> range (oDeriv (OrdinalVeblen.ordering x))) (\<lambda>f. \<Inter> (range f)) (f n))
[PROOF STEP]
apply (rule omega_complete.ordinal_rec0_oLimit)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. omega_complete ?le (\<lambda>f. \<Inter> (range f))
 2. \<forall>p x. ?le x (x \<inter> range (oDeriv (OrdinalVeblen.ordering x)))
[PROOF STEP]
apply (rule omega_complete_INTER)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>p x. x \<inter> range (oDeriv (OrdinalVeblen.ordering x)) \<subseteq> x
[PROOF STEP]
apply fast
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma QR_decomposition:
  fixes A::"real^'n::{mod_type}^'m::{mod_type}"
  assumes r: "rank A = ncols A"
  shows "A = fst (QR_decomposition A) ** snd (QR_decomposition A) \<and>
  pairwise orthogonal (columns (fst (QR_decomposition A))) \<and>
  (\<forall>i. norm (column i (fst (QR_decomposition A))) = 1) \<and>
  (transpose (fst (QR_decomposition A))) ** (fst (QR_decomposition A)) = mat 1 \<and>
  vec.independent (columns (fst (QR_decomposition A))) \<and>
  col_space A = col_space (fst (QR_decomposition A)) \<and>
  card (columns A) = card (columns (fst (QR_decomposition A))) \<and>
  invertible (snd (QR_decomposition A)) \<and>
  upper_triangular (snd (QR_decomposition A))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A = fst (QR_decomposition A) ** snd (QR_decomposition A) \<and> pairwise orthogonal (columns (fst (QR_decomposition A))) \<and> (\<forall>i. norm (column i (fst (QR_decomposition A))) = 1) \<and> Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) ** fst (QR_decomposition A) = mat 1 \<and> vec.independent (columns (fst (QR_decomposition A))) \<and> col_space A = col_space (fst (QR_decomposition A)) \<and> card (columns A) = card (columns (fst (QR_decomposition A))) \<and> invertible (snd (QR_decomposition A)) \<and> upper_triangular (snd (QR_decomposition A))
[PROOF STEP]
by (metis QR_decomposition_mult col_space_def full_rank_imp_is_basis2
    independent_columns_fst_QR_decomposition invertible_snd_QR_decomposition
    norm_columns_fst_QR_decomposition orthogonal_fst_QR_decomposition
    orthogonal_matrix_fst_QR_decomposition r span_fst_QR_decomposition
    upper_triangular_snd_QR_decomposition)


[STATEMENT]
lemma lookup_default_bind_pmf_aux:
  "Mapping.lookup_default 0 (bind_pmf_aux p f A) x =
     (if x \<in> (\<Union>y\<in>A. set_pmf (f y)) then
        measure_pmf.expectation p (\<lambda>y. indicator A y * pmf (f y) x) else 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Mapping.lookup_default 0 (bind_pmf_aux p f A) x = (if x \<in> (\<Union>y\<in>A. set_pmf (f y)) then measure_pmf.expectation p (\<lambda>y. indicat_real A y * pmf (f y) x) else 0)
[PROOF STEP]
unfolding lookup_default_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (case Mapping.lookup (bind_pmf_aux p f A) x of None \<Rightarrow> 0 | Some v \<Rightarrow> v) = (if x \<in> (\<Union>y\<in>A. set_pmf (f y)) then measure_pmf.expectation p (\<lambda>y. indicat_real A y * pmf (f y) x) else 0)
[PROOF STEP]
by transfer' simp_all


[STATEMENT]
lemma arg_pi2_iff:
  shows "z \<noteq> 0 \<and> Arg z = pi / 2 \<longleftrightarrow> is_imag z \<and> Im z > 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (z \<noteq> 0 \<and> Arg z = pi / 2) = (is_imag z \<and> 0 < Im z)
[PROOF STEP]
by (smt Im_rcis Re_i_times Re_rcis arcsin_minus_1 cos_pi_half divide_minus_left mult.commute mult_cancel_right1 rcis_cmod_Arg is_imag_arg2 sin_arcsin sin_pi_half zero_less_mult_pos zero_less_norm_iff)


[STATEMENT]
lemma "(x - y = z) = (x = z + (y::real))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (x - y = z) = (x = z + y)
[PROOF STEP]
by arith


[STATEMENT]
lemma hypext_cos_Hyperdual:
  "(*h* cos) (Hyperdual a b c d) = cos a *\<^sub>H ba - (b * sin a) *\<^sub>H e1 - (c * sin a) *\<^sub>H e2 - (d * sin a + b * c * cos a) *\<^sub>H e12 "
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (*h* cos) (Hyperdual a b c d) = cos a *\<^sub>H ba - (b * sin a) *\<^sub>H e1 - (c * sin a) *\<^sub>H e2 - (d * sin a + b * c * cos a) *\<^sub>H e12
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (*h* cos) (Hyperdual a b c d) = cos a *\<^sub>H ba - (b * sin a) *\<^sub>H e1 - (c * sin a) *\<^sub>H e2 - (d * sin a + b * c * cos a) *\<^sub>H e12
[PROOF STEP]
have "of_comp (- (d * sin a) - b * c * cos a) * e12 = - (of_comp (d * sin a + b * c * cos a) * e12)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. of_comp (- (d * sin a) - b * c * cos a) * e12 = - (of_comp (d * sin a + b * c * cos a) * e12)
[PROOF STEP]
by (metis add_uminus_conv_diff minus_add_distrib mult_minus_left of_comp_minus)
[PROOF STATE]
proof (state)
this:
of_comp (- (d * sin a) - b * c * cos a) * e12 = - (of_comp (d * sin a + b * c * cos a) * e12)

goal (1 subgoal):
 1. (*h* cos) (Hyperdual a b c d) = cos a *\<^sub>H ba - (b * sin a) *\<^sub>H e1 - (c * sin a) *\<^sub>H e2 - (d * sin a + b * c * cos a) *\<^sub>H e12
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
of_comp (- (d * sin a) - b * c * cos a) * e12 = - (of_comp (d * sin a + b * c * cos a) * e12)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
of_comp (- (d * sin a) - b * c * cos a) * e12 = - (of_comp (d * sin a + b * c * cos a) * e12)

goal (1 subgoal):
 1. (*h* cos) (Hyperdual a b c d) = cos a *\<^sub>H ba - (b * sin a) *\<^sub>H e1 - (c * sin a) *\<^sub>H e2 - (d * sin a + b * c * cos a) *\<^sub>H e12
[PROOF STEP]
by (simp add: hypext_Hyperdual_eq_parts of_comp_minus scaleH_times)
[PROOF STATE]
proof (state)
this:
(*h* cos) (Hyperdual a b c d) = cos a *\<^sub>H ba - (b * sin a) *\<^sub>H e1 - (c * sin a) *\<^sub>H e2 - (d * sin a + b * c * cos a) *\<^sub>H e12

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma self_dvd_gauss_cnj_iff: "z dvd gauss_cnj z \<longleftrightarrow> ReZ z = 0 \<or> ImZ z = 0 \<or> \<bar>ReZ z\<bar> = \<bar>ImZ z\<bar>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (z dvd gauss_cnj z) = (ReZ z = 0 \<or> ImZ z = 0 \<or> \<bar>ReZ z\<bar> = \<bar>ImZ z\<bar>)
[PROOF STEP]
using gauss_cnj_dvd_self_iff[of z]
[PROOF STATE]
proof (prove)
using this:
(gauss_cnj z dvd z) = (ReZ z = 0 \<or> ImZ z = 0 \<or> \<bar>ReZ z\<bar> = \<bar>ImZ z\<bar>)

goal (1 subgoal):
 1. (z dvd gauss_cnj z) = (ReZ z = 0 \<or> ImZ z = 0 \<or> \<bar>ReZ z\<bar> = \<bar>ImZ z\<bar>)
[PROOF STEP]
by (subst (asm) gauss_cnj_dvd_left_iff) auto


[STATEMENT]
lemma gcd_rat_to_gcd_int: "gcd (of_int_poly f :: rat poly) (of_int_poly g) =
  smult (inverse (of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. gcd (of_int_poly f) (of_int_poly g) = smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g))
[PROOF STEP]
proof (cases "f = 0 \<and> g = 0")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. f = 0 \<and> g = 0 \<Longrightarrow> gcd (of_int_poly f) (of_int_poly g) = smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g))
 2. \<not> (f = 0 \<and> g = 0) \<Longrightarrow> gcd (of_int_poly f) (of_int_poly g) = smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g))
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
f = 0 \<and> g = 0

goal (2 subgoals):
 1. f = 0 \<and> g = 0 \<Longrightarrow> gcd (of_int_poly f) (of_int_poly g) = smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g))
 2. \<not> (f = 0 \<and> g = 0) \<Longrightarrow> gcd (of_int_poly f) (of_int_poly g) = smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g))
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
f = 0 \<and> g = 0

goal (1 subgoal):
 1. gcd (of_int_poly f) (of_int_poly g) = smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
gcd (of_int_poly f) (of_int_poly g) = smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g))

goal (1 subgoal):
 1. \<not> (f = 0 \<and> g = 0) \<Longrightarrow> gcd (of_int_poly f) (of_int_poly g) = smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> (f = 0 \<and> g = 0) \<Longrightarrow> gcd (of_int_poly f) (of_int_poly g) = smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g))
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> (f = 0 \<and> g = 0)

goal (1 subgoal):
 1. \<not> (f = 0 \<and> g = 0) \<Longrightarrow> gcd (of_int_poly f) (of_int_poly g) = smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g))
[PROOF STEP]
let ?r = rat_of_int
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> (f = 0 \<and> g = 0) \<Longrightarrow> gcd (of_int_poly f) (of_int_poly g) = smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g))
[PROOF STEP]
let ?rp = "map_poly ?r"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> (f = 0 \<and> g = 0) \<Longrightarrow> gcd (of_int_poly f) (of_int_poly g) = smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g))
[PROOF STEP]
from False
[PROOF STATE]
proof (chain)
picking this:
\<not> (f = 0 \<and> g = 0)
[PROOF STEP]
have gcd0: "gcd f g \<noteq> 0"
[PROOF STATE]
proof (prove)
using this:
\<not> (f = 0 \<and> g = 0)

goal (1 subgoal):
 1. gcd f g \<noteq> 0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
gcd f g \<noteq> 0

goal (1 subgoal):
 1. \<not> (f = 0 \<and> g = 0) \<Longrightarrow> gcd (of_int_poly f) (of_int_poly g) = smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g))
[PROOF STEP]
hence lc0: "lead_coeff (gcd f g) \<noteq> 0"
[PROOF STATE]
proof (prove)
using this:
gcd f g \<noteq> 0

goal (1 subgoal):
 1. lead_coeff (gcd f g) \<noteq> 0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
lead_coeff (gcd f g) \<noteq> 0

goal (1 subgoal):
 1. \<not> (f = 0 \<and> g = 0) \<Longrightarrow> gcd (of_int_poly f) (of_int_poly g) = smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g))
[PROOF STEP]
hence inv: "inverse (?r (lead_coeff (gcd f g))) \<noteq> 0"
[PROOF STATE]
proof (prove)
using this:
lead_coeff (gcd f g) \<noteq> 0

goal (1 subgoal):
 1. inverse (rat_of_int (lead_coeff (gcd f g))) \<noteq> 0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
inverse (rat_of_int (lead_coeff (gcd f g))) \<noteq> 0

goal (1 subgoal):
 1. \<not> (f = 0 \<and> g = 0) \<Longrightarrow> gcd (of_int_poly f) (of_int_poly g) = smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. gcd (of_int_poly f) (of_int_poly g) = smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g))
[PROOF STEP]
proof (rule sym, rule gcdI, goal_cases)
[PROOF STATE]
proof (state)
goal (4 subgoals):
 1. smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g)) dvd of_int_poly f
 2. smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g)) dvd of_int_poly g
 3. \<And>d. \<lbrakk>d dvd of_int_poly f; d dvd of_int_poly g\<rbrakk> \<Longrightarrow> d dvd smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g))
 4. normalize (smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g))) = smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g))
[PROOF STEP]
case 1
[PROOF STATE]
proof (state)
this:

goal (4 subgoals):
 1. smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g)) dvd of_int_poly f
 2. smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g)) dvd of_int_poly g
 3. \<And>d. \<lbrakk>d dvd of_int_poly f; d dvd of_int_poly g\<rbrakk> \<Longrightarrow> d dvd smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g))
 4. normalize (smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g))) = smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g))
[PROOF STEP]
have "gcd f g dvd f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. gcd f g dvd f
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
gcd f g dvd f

goal (4 subgoals):
 1. smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g)) dvd of_int_poly f
 2. smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g)) dvd of_int_poly g
 3. \<And>d. \<lbrakk>d dvd of_int_poly f; d dvd of_int_poly g\<rbrakk> \<Longrightarrow> d dvd smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g))
 4. normalize (smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g))) = smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
gcd f g dvd f
[PROOF STEP]
obtain h where f: "f = gcd f g * h"
[PROOF STATE]
proof (prove)
using this:
gcd f g dvd f

goal (1 subgoal):
 1. (\<And>h. f = gcd f g * h \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
unfolding dvd_def
[PROOF STATE]
proof (prove)
using this:
\<exists>k. f = gcd f g * k

goal (1 subgoal):
 1. (\<And>h. f = gcd f g * h \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
f = gcd f g * h

goal (4 subgoals):
 1. smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g)) dvd of_int_poly f
 2. smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g)) dvd of_int_poly g
 3. \<And>d. \<lbrakk>d dvd of_int_poly f; d dvd of_int_poly g\<rbrakk> \<Longrightarrow> d dvd smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g))
 4. normalize (smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g))) = smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g))
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g)) dvd of_int_poly f
[PROOF STEP]
by (rule smult_dvd[OF _ inv], insert arg_cong[OF f, of ?rp], simp add: hom_distribs)
[PROOF STATE]
proof (state)
this:
smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g)) dvd of_int_poly f

goal (3 subgoals):
 1. smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g)) dvd of_int_poly g
 2. \<And>d. \<lbrakk>d dvd of_int_poly f; d dvd of_int_poly g\<rbrakk> \<Longrightarrow> d dvd smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g))
 3. normalize (smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g))) = smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g)) dvd of_int_poly g
 2. \<And>d. \<lbrakk>d dvd of_int_poly f; d dvd of_int_poly g\<rbrakk> \<Longrightarrow> d dvd smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g))
 3. normalize (smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g))) = smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g))
[PROOF STEP]
case 2
[PROOF STATE]
proof (state)
this:

goal (3 subgoals):
 1. smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g)) dvd of_int_poly g
 2. \<And>d. \<lbrakk>d dvd of_int_poly f; d dvd of_int_poly g\<rbrakk> \<Longrightarrow> d dvd smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g))
 3. normalize (smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g))) = smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g))
[PROOF STEP]
have "gcd f g dvd g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. gcd f g dvd g
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
gcd f g dvd g

goal (3 subgoals):
 1. smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g)) dvd of_int_poly g
 2. \<And>d. \<lbrakk>d dvd of_int_poly f; d dvd of_int_poly g\<rbrakk> \<Longrightarrow> d dvd smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g))
 3. normalize (smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g))) = smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
gcd f g dvd g
[PROOF STEP]
obtain h where g: "g = gcd f g * h"
[PROOF STATE]
proof (prove)
using this:
gcd f g dvd g

goal (1 subgoal):
 1. (\<And>h. g = gcd f g * h \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
unfolding dvd_def
[PROOF STATE]
proof (prove)
using this:
\<exists>k. g = gcd f g * k

goal (1 subgoal):
 1. (\<And>h. g = gcd f g * h \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
g = gcd f g * h

goal (3 subgoals):
 1. smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g)) dvd of_int_poly g
 2. \<And>d. \<lbrakk>d dvd of_int_poly f; d dvd of_int_poly g\<rbrakk> \<Longrightarrow> d dvd smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g))
 3. normalize (smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g))) = smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g))
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g)) dvd of_int_poly g
[PROOF STEP]
by (rule smult_dvd[OF _ inv], insert arg_cong[OF g, of ?rp], simp add: hom_distribs)
[PROOF STATE]
proof (state)
this:
smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g)) dvd of_int_poly g

goal (2 subgoals):
 1. \<And>d. \<lbrakk>d dvd of_int_poly f; d dvd of_int_poly g\<rbrakk> \<Longrightarrow> d dvd smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g))
 2. normalize (smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g))) = smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>d. \<lbrakk>d dvd of_int_poly f; d dvd of_int_poly g\<rbrakk> \<Longrightarrow> d dvd smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g))
 2. normalize (smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g))) = smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g))
[PROOF STEP]
case (3 h)
[PROOF STATE]
proof (state)
this:
h dvd of_int_poly f
h dvd of_int_poly g

goal (2 subgoals):
 1. \<And>d. \<lbrakk>d dvd of_int_poly f; d dvd of_int_poly g\<rbrakk> \<Longrightarrow> d dvd smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g))
 2. normalize (smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g))) = smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g))
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. h dvd smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g))
[PROOF STEP]
proof (rule dvd_smult)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. h dvd of_int_poly (gcd f g)
[PROOF STEP]
obtain ch ph where h: "rat_to_normalized_int_poly h = (ch, ph)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>ch ph. rat_to_normalized_int_poly h = (ch, ph) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
rat_to_normalized_int_poly h = (ch, ph)

goal (1 subgoal):
 1. h dvd of_int_poly (gcd f g)
[PROOF STEP]
from 3
[PROOF STATE]
proof (chain)
picking this:
h dvd of_int_poly f
h dvd of_int_poly g
[PROOF STEP]
obtain ff where f: "?rp f = h * ff"
[PROOF STATE]
proof (prove)
using this:
h dvd of_int_poly f
h dvd of_int_poly g

goal (1 subgoal):
 1. (\<And>ff. of_int_poly f = h * ff \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
unfolding dvd_def
[PROOF STATE]
proof (prove)
using this:
\<exists>k. of_int_poly f = h * k
\<exists>k. of_int_poly g = h * k

goal (1 subgoal):
 1. (\<And>ff. of_int_poly f = h * ff \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
of_int_poly f = h * ff

goal (1 subgoal):
 1. h dvd of_int_poly (gcd f g)
[PROOF STEP]
from 3
[PROOF STATE]
proof (chain)
picking this:
h dvd of_int_poly f
h dvd of_int_poly g
[PROOF STEP]
obtain gg where g: "?rp g = h * gg"
[PROOF STATE]
proof (prove)
using this:
h dvd of_int_poly f
h dvd of_int_poly g

goal (1 subgoal):
 1. (\<And>gg. of_int_poly g = h * gg \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
unfolding dvd_def
[PROOF STATE]
proof (prove)
using this:
\<exists>k. of_int_poly f = h * k
\<exists>k. of_int_poly g = h * k

goal (1 subgoal):
 1. (\<And>gg. of_int_poly g = h * gg \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
of_int_poly g = h * gg

goal (1 subgoal):
 1. h dvd of_int_poly (gcd f g)
[PROOF STEP]
from rat_to_int_factor_explicit[OF f h]
[PROOF STATE]
proof (chain)
picking this:
\<exists>r. f = ph * smult (content f) r
[PROOF STEP]
obtain f' where f: "f = ph * f'"
[PROOF STATE]
proof (prove)
using this:
\<exists>r. f = ph * smult (content f) r

goal (1 subgoal):
 1. (\<And>f'. f = ph * f' \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
f = ph * f'

goal (1 subgoal):
 1. h dvd of_int_poly (gcd f g)
[PROOF STEP]
from rat_to_int_factor_explicit[OF g h]
[PROOF STATE]
proof (chain)
picking this:
\<exists>r. g = ph * smult (content g) r
[PROOF STEP]
obtain g' where g: "g = ph * g'"
[PROOF STATE]
proof (prove)
using this:
\<exists>r. g = ph * smult (content g) r

goal (1 subgoal):
 1. (\<And>g'. g = ph * g' \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
g = ph * g'

goal (1 subgoal):
 1. h dvd of_int_poly (gcd f g)
[PROOF STEP]
from f g
[PROOF STATE]
proof (chain)
picking this:
f = ph * f'
g = ph * g'
[PROOF STEP]
have "ph dvd gcd f g"
[PROOF STATE]
proof (prove)
using this:
f = ph * f'
g = ph * g'

goal (1 subgoal):
 1. ph dvd gcd f g
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
ph dvd gcd f g

goal (1 subgoal):
 1. h dvd of_int_poly (gcd f g)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
ph dvd gcd f g
[PROOF STEP]
obtain gg where gcd: "gcd f g = ph * gg"
[PROOF STATE]
proof (prove)
using this:
ph dvd gcd f g

goal (1 subgoal):
 1. (\<And>gg. gcd f g = ph * gg \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
unfolding dvd_def
[PROOF STATE]
proof (prove)
using this:
\<exists>k. gcd f g = ph * k

goal (1 subgoal):
 1. (\<And>gg. gcd f g = ph * gg \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
gcd f g = ph * gg

goal (1 subgoal):
 1. h dvd of_int_poly (gcd f g)
[PROOF STEP]
note * = rat_to_normalized_int_poly[OF h]
[PROOF STATE]
proof (state)
this:
h = smult ch (of_int_poly ph)
0 < ch
h \<noteq> 0 \<Longrightarrow> content ph = 1
degree ph = degree h

goal (1 subgoal):
 1. h dvd of_int_poly (gcd f g)
[PROOF STEP]
show "h dvd ?rp (gcd f g)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. h dvd of_int_poly (gcd f g)
[PROOF STEP]
unfolding gcd *(1)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. smult ch (of_int_poly ph) dvd of_int_poly (ph * gg)
[PROOF STEP]
by (rule smult_dvd, insert *(2), auto)
[PROOF STATE]
proof (state)
this:
h dvd of_int_poly (gcd f g)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
h dvd smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g))

goal (1 subgoal):
 1. normalize (smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g))) = smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. normalize (smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g))) = smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g))
[PROOF STEP]
case 4
[PROOF STATE]
proof (state)
this:

goal (1 subgoal):
 1. normalize (smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g))) = smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g))
[PROOF STEP]
have [simp]: "[:1:] = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [:1::'a:] = 1
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
[:1::?'a1:] = 1

goal (1 subgoal):
 1. normalize (smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g))) = smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g))
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. normalize (smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g))) = smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g))
[PROOF STEP]
unfolding normalize_poly_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g)) div [:unit_factor (lead_coeff (smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g)))):] = smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g))
[PROOF STEP]
by (rule poly_eqI, simp)
[PROOF STATE]
proof (state)
this:
normalize (smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g))) = smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
gcd (of_int_poly f) (of_int_poly g) = smult (inverse (rat_of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma sublist_app: \<open>\<lbrakk>i1 \<le> i2; i2 \<le> i3\<rbrakk> \<Longrightarrow> sublist xs i1 i2 @ sublist xs (Suc i2) i3 = sublist xs i1 i3\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>i1 \<le> i2; i2 \<le> i3\<rbrakk> \<Longrightarrow> WB_Sort.sublist xs i1 i2 @ WB_Sort.sublist xs (Suc i2) i3 = WB_Sort.sublist xs i1 i3
[PROOF STEP]
unfolding sublist_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>i1 \<le> i2; i2 \<le> i3\<rbrakk> \<Longrightarrow> take (Suc i2 - i1) (drop i1 xs) @ take (Suc i3 - Suc i2) (drop (Suc i2) xs) = take (Suc i3 - i1) (drop i1 xs)
[PROOF STEP]
by (smt (verit) Suc_eq_plus1_left Suc_le_mono append.assoc le_SucI le_add_diff_inverse le_trans same_append_eq take_add)


[STATEMENT]
lemma convex_polychain_map_mirror:
  assumes "convex_polychain hs"
  shows "convex_polychain (map (pairself (mirror_point x)) hs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. convex_polychain (map (pairself (mirror_point x)) hs)
[PROOF STEP]
proof (rule convex_polychainI)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. polychain (map (pairself (mirror_point x)) hs)
 2. \<And>i. Suc i < length (map (pairself (mirror_point x)) hs) \<Longrightarrow> 0 < det3 (fst (map (pairself (mirror_point x)) hs ! i)) (snd (map (pairself (mirror_point x)) hs ! i)) (snd (map (pairself (mirror_point x)) hs ! Suc i))
[PROOF STEP]
qed (insert assms, auto simp: convex_polychain_def polychain_map_pairself pairself_apply
  mirror_point_def det3_def' algebra_simps)


[STATEMENT]
lemma (in R_scalar_mult) trivial_RModule :
  "(\<And>r. r \<in> R \<Longrightarrow> r \<cdot> 0 = 0) \<Longrightarrow> RModule R smult 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>r. r \<in> R \<Longrightarrow> r \<cdot> (0::'m) = (0::'m)) \<Longrightarrow> RModule R (\<cdot>) 0
[PROOF STEP]
using trivial_Group add_closed mult_closed one_closed
[PROOF STATE]
proof (prove)
using this:
Group 0
\<lbrakk>?g \<in> R; ?h \<in> R\<rbrakk> \<Longrightarrow> ?g + ?h \<in> R
\<lbrakk>?r \<in> R; ?s \<in> R\<rbrakk> \<Longrightarrow> ?r * ?s \<in> R
(1::'r) \<in> R

goal (1 subgoal):
 1. (\<And>r. r \<in> R \<Longrightarrow> r \<cdot> (0::'m) = (0::'m)) \<Longrightarrow> RModule R (\<cdot>) 0
[PROOF STEP]
by unfold_locales auto


[STATEMENT]
lemma mignotte_helper_coeff_int': "cmod (coeff_int (\<Prod>a\<leftarrow>lst. [:- a, 1:]) i)
    \<le> ((length lst - 1) choose i) * (\<Prod>a\<leftarrow>lst. (max 1 (cmod a)))
    + min i 1 * ((length lst - 1) choose (nat (i - 1)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cmod (coeff_int (\<Prod>a\<leftarrow>lst. [:- a, 1:]) (int i)) \<le> real (length lst - 1 choose i) * (\<Prod>a\<leftarrow>lst. max 1 (cmod a)) + real (min i 1 * (length lst - 1 choose nat (int i - 1)))
[PROOF STEP]
by (rule order.trans[OF mignotte_helper_coeff_int], auto simp: choose_int_def min_def)


[STATEMENT]
lemma eint_mult_Suc:
   "eint (Suc k) * a = eint k * a + a"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. eint (int (Suc k)) * a = eint (int k) * a + a
[PROOF STEP]
apply(induction a)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>inta. eint (int (Suc k)) * eint inta = eint (int k) * eint inta + eint inta
 2. eint (int (Suc k)) * \<infinity> = eint (int k) * \<infinity> + \<infinity>
[PROOF STEP]
apply (metis add.commute eSuc_eint mult_eSuc' of_nat_Suc)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. eint (int (Suc k)) * \<infinity> = eint (int k) * \<infinity> + \<infinity>
[PROOF STEP]
using plus_eint_simps(3) times_eint_simps(4)
[PROOF STATE]
proof (prove)
using this:
?q + \<infinity> = \<infinity>
eint ?m * \<infinity> = \<infinity>

goal (1 subgoal):
 1. eint (int (Suc k)) * \<infinity> = eint (int k) * \<infinity> + \<infinity>
[PROOF STEP]
by presburger


[STATEMENT]
lemma R_iff: "(\<exists>x\<in>L. (u, x) \<in> R) = (u \<in> L)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<exists>x\<in>L. (u, x) \<in> R) = (u \<in> L)
[PROOF STEP]
using MN_refines MyhillNerode eqR eq_equiv_class_iff
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>MyhillNerode ?L ?R; (?x, ?y) \<in> ?R\<rbrakk> \<Longrightarrow> (?x \<in> ?L) = (?y \<in> ?L)
MyhillNerode L R
equiv UNIV R
\<lbrakk>equiv ?A ?r; ?x \<in> ?A; ?y \<in> ?A\<rbrakk> \<Longrightarrow> (?r `` {?x} = ?r `` {?y}) = ((?x, ?y) \<in> ?r)

goal (1 subgoal):
 1. (\<exists>x\<in>L. (u, x) \<in> R) = (u \<in> L)
[PROOF STEP]
by fastforce