[STATEMENT]
lemma powrfinitesum:
  fixes a::real and s::nat assumes  "s \<le> n"
  shows " (\<Prod>j=s..(n::nat).(a powr (2^j)))  = a powr (\<Sum>j=s..(n::nat).(2^j)) "
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Prod>j = s..n. a powr 2 ^ j) = a powr sum ((^) 2) {s..n}
[PROOF STEP]
using \<open>s \<le> n\<close>
[PROOF STATE]
proof (prove)
using this:
s \<le> n

goal (1 subgoal):
 1. (\<Prod>j = s..n. a powr 2 ^ j) = a powr sum ((^) 2) {s..n}
[PROOF STEP]
proof(induct n)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. s \<le> 0 \<Longrightarrow> (\<Prod>j = s..0. a powr 2 ^ j) = a powr sum ((^) 2) {s..0}
 2. \<And>n. \<lbrakk>s \<le> n \<Longrightarrow> (\<Prod>j = s..n. a powr 2 ^ j) = a powr sum ((^) 2) {s..n}; s \<le> Suc n\<rbrakk> \<Longrightarrow> (\<Prod>j = s..Suc n. a powr 2 ^ j) = a powr sum ((^) 2) {s..Suc n}
[PROOF STEP]
case 0
[PROOF STATE]
proof (state)
this:
s \<le> 0

goal (2 subgoals):
 1. s \<le> 0 \<Longrightarrow> (\<Prod>j = s..0. a powr 2 ^ j) = a powr sum ((^) 2) {s..0}
 2. \<And>n. \<lbrakk>s \<le> n \<Longrightarrow> (\<Prod>j = s..n. a powr 2 ^ j) = a powr sum ((^) 2) {s..n}; s \<le> Suc n\<rbrakk> \<Longrightarrow> (\<Prod>j = s..Suc n. a powr 2 ^ j) = a powr sum ((^) 2) {s..Suc n}
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
s \<le> 0
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
s \<le> 0

goal (1 subgoal):
 1. (\<Prod>j = s..0. a powr 2 ^ j) = a powr sum ((^) 2) {s..0}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<Prod>j = s..0. a powr 2 ^ j) = a powr sum ((^) 2) {s..0}

goal (1 subgoal):
 1. \<And>n. \<lbrakk>s \<le> n \<Longrightarrow> (\<Prod>j = s..n. a powr 2 ^ j) = a powr sum ((^) 2) {s..n}; s \<le> Suc n\<rbrakk> \<Longrightarrow> (\<Prod>j = s..Suc n. a powr 2 ^ j) = a powr sum ((^) 2) {s..Suc n}
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n. \<lbrakk>s \<le> n \<Longrightarrow> (\<Prod>j = s..n. a powr 2 ^ j) = a powr sum ((^) 2) {s..n}; s \<le> Suc n\<rbrakk> \<Longrightarrow> (\<Prod>j = s..Suc n. a powr 2 ^ j) = a powr sum ((^) 2) {s..Suc n}
[PROOF STEP]
case (Suc n)
[PROOF STATE]
proof (state)
this:
s \<le> n \<Longrightarrow> (\<Prod>j = s..n. a powr 2 ^ j) = a powr sum ((^) 2) {s..n}
s \<le> Suc n

goal (1 subgoal):
 1. \<And>n. \<lbrakk>s \<le> n \<Longrightarrow> (\<Prod>j = s..n. a powr 2 ^ j) = a powr sum ((^) 2) {s..n}; s \<le> Suc n\<rbrakk> \<Longrightarrow> (\<Prod>j = s..Suc n. a powr 2 ^ j) = a powr sum ((^) 2) {s..Suc n}
[PROOF STEP]
have ?case when "s\<le>n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Prod>j = s..Suc n. a powr 2 ^ j) = a powr sum ((^) 2) {s..Suc n}
[PROOF STEP]
using Suc.hyps
[PROOF STATE]
proof (prove)
using this:
s \<le> n \<Longrightarrow> (\<Prod>j = s..n. a powr 2 ^ j) = a powr sum ((^) 2) {s..n}

goal (1 subgoal):
 1. (\<Prod>j = s..Suc n. a powr 2 ^ j) = a powr sum ((^) 2) {s..Suc n}
[PROOF STEP]
by (metis Suc.prems add.commute linorder_not_le powr_add prod.nat_ivl_Suc' sum.cl_ivl_Suc that)
[PROOF STATE]
proof (state)
this:
s \<le> n \<Longrightarrow> (\<Prod>j = s..Suc n. a powr 2 ^ j) = a powr sum ((^) 2) {s..Suc n}

goal (1 subgoal):
 1. \<And>n. \<lbrakk>s \<le> n \<Longrightarrow> (\<Prod>j = s..n. a powr 2 ^ j) = a powr sum ((^) 2) {s..n}; s \<le> Suc n\<rbrakk> \<Longrightarrow> (\<Prod>j = s..Suc n. a powr 2 ^ j) = a powr sum ((^) 2) {s..Suc n}
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
s \<le> n \<Longrightarrow> (\<Prod>j = s..Suc n. a powr 2 ^ j) = a powr sum ((^) 2) {s..Suc n}

goal (1 subgoal):
 1. \<And>n. \<lbrakk>s \<le> n \<Longrightarrow> (\<Prod>j = s..n. a powr 2 ^ j) = a powr sum ((^) 2) {s..n}; s \<le> Suc n\<rbrakk> \<Longrightarrow> (\<Prod>j = s..Suc n. a powr 2 ^ j) = a powr sum ((^) 2) {s..Suc n}
[PROOF STEP]
have ?case when "s=Suc n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Prod>j = s..Suc n. a powr 2 ^ j) = a powr sum ((^) 2) {s..Suc n}
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<Prod>j = s..Suc n. a powr 2 ^ j) = a powr sum ((^) 2) {s..Suc n}
[PROOF STEP]
have "(\<Prod>j = s..Suc n. a powr 2 ^ j) =(a powr 2 ^(Suc n))  "
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Prod>j = s..Suc n. a powr 2 ^ j) = a powr 2 ^ Suc n
[PROOF STEP]
using \<open>s=Suc n\<close>
[PROOF STATE]
proof (prove)
using this:
s = Suc n

goal (1 subgoal):
 1. (\<Prod>j = s..Suc n. a powr 2 ^ j) = a powr 2 ^ Suc n
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<Prod>j = s..Suc n. a powr 2 ^ j) = a powr 2 ^ Suc n

goal (1 subgoal):
 1. (\<Prod>j = s..Suc n. a powr 2 ^ j) = a powr sum ((^) 2) {s..Suc n}
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Prod>j = s..Suc n. a powr 2 ^ j) = a powr 2 ^ Suc n

goal (1 subgoal):
 1. (\<Prod>j = s..Suc n. a powr 2 ^ j) = a powr sum ((^) 2) {s..Suc n}
[PROOF STEP]
have "a powr 2 ^ Suc n = a powr sum (power 2) {s..Suc n}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a powr 2 ^ Suc n = a powr sum ((^) 2) {s..Suc n}
[PROOF STEP]
using that
[PROOF STATE]
proof (prove)
using this:
s = Suc n

goal (1 subgoal):
 1. a powr 2 ^ Suc n = a powr sum ((^) 2) {s..Suc n}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
a powr 2 ^ Suc n = a powr sum ((^) 2) {s..Suc n}

goal (1 subgoal):
 1. (\<Prod>j = s..Suc n. a powr 2 ^ j) = a powr sum ((^) 2) {s..Suc n}
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
(\<Prod>j = s..Suc n. a powr 2 ^ j) = a powr 2 ^ Suc n
a powr 2 ^ Suc n = a powr sum ((^) 2) {s..Suc n}
[PROOF STEP]
show "(\<Prod>j = s..Suc n. a powr 2 ^ j) = a powr sum (power 2) {s..Suc n}"
[PROOF STATE]
proof (prove)
using this:
(\<Prod>j = s..Suc n. a powr 2 ^ j) = a powr 2 ^ Suc n
a powr 2 ^ Suc n = a powr sum ((^) 2) {s..Suc n}

goal (1 subgoal):
 1. (\<Prod>j = s..Suc n. a powr 2 ^ j) = a powr sum ((^) 2) {s..Suc n}
[PROOF STEP]
using \<open>s\<le>Suc n\<close>
[PROOF STATE]
proof (prove)
using this:
(\<Prod>j = s..Suc n. a powr 2 ^ j) = a powr 2 ^ Suc n
a powr 2 ^ Suc n = a powr sum ((^) 2) {s..Suc n}
s \<le> Suc n

goal (1 subgoal):
 1. (\<Prod>j = s..Suc n. a powr 2 ^ j) = a powr sum ((^) 2) {s..Suc n}
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
(\<Prod>j = s..Suc n. a powr 2 ^ j) = a powr sum ((^) 2) {s..Suc n}

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
s = Suc n \<Longrightarrow> (\<Prod>j = s..Suc n. a powr 2 ^ j) = a powr sum ((^) 2) {s..Suc n}

goal (1 subgoal):
 1. \<And>n. \<lbrakk>s \<le> n \<Longrightarrow> (\<Prod>j = s..n. a powr 2 ^ j) = a powr sum ((^) 2) {s..n}; s \<le> Suc n\<rbrakk> \<Longrightarrow> (\<Prod>j = s..Suc n. a powr 2 ^ j) = a powr sum ((^) 2) {s..Suc n}
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
s \<le> n \<Longrightarrow> (\<Prod>j = s..Suc n. a powr 2 ^ j) = a powr sum ((^) 2) {s..Suc n}
s = Suc n \<Longrightarrow> (\<Prod>j = s..Suc n. a powr 2 ^ j) = a powr sum ((^) 2) {s..Suc n}
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
s \<le> n \<Longrightarrow> (\<Prod>j = s..Suc n. a powr 2 ^ j) = a powr sum ((^) 2) {s..Suc n}
s = Suc n \<Longrightarrow> (\<Prod>j = s..Suc n. a powr 2 ^ j) = a powr sum ((^) 2) {s..Suc n}

goal (1 subgoal):
 1. (\<Prod>j = s..Suc n. a powr 2 ^ j) = a powr sum ((^) 2) {s..Suc n}
[PROOF STEP]
using \<open>s\<le>Suc n\<close>
[PROOF STATE]
proof (prove)
using this:
s \<le> n \<Longrightarrow> (\<Prod>j = s..Suc n. a powr 2 ^ j) = a powr sum ((^) 2) {s..Suc n}
s = Suc n \<Longrightarrow> (\<Prod>j = s..Suc n. a powr 2 ^ j) = a powr sum ((^) 2) {s..Suc n}
s \<le> Suc n

goal (1 subgoal):
 1. (\<Prod>j = s..Suc n. a powr 2 ^ j) = a powr sum ((^) 2) {s..Suc n}
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
(\<Prod>j = s..Suc n. a powr 2 ^ j) = a powr sum ((^) 2) {s..Suc n}

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma eventually_powr_const_mono_nonneg:
  assumes "p \<ge> (0 :: real)" "eventually (\<lambda>x. l x \<ge> 0) at_top" "eventually (\<lambda>x. l x \<le> f x) at_top"
          "eventually (\<lambda>x. f x \<le> g x) at_top"
  shows   "eventually (\<lambda>x. f x powr p \<le> g x powr p) at_top"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>\<^sub>F x in at_top. f x powr p \<le> g x powr p
[PROOF STEP]
using assms(2-4)
[PROOF STATE]
proof (prove)
using this:
\<forall>\<^sub>F x in at_top. 0 \<le> l x
\<forall>\<^sub>F x in at_top. l x \<le> f x
\<forall>\<^sub>F x in at_top. f x \<le> g x

goal (1 subgoal):
 1. \<forall>\<^sub>F x in at_top. f x powr p \<le> g x powr p
[PROOF STEP]
by eventually_elim (auto simp: assms(1) intro!: powr_mono2)


[STATEMENT]
lemma uint64_UNIV : "(UNIV :: uint64 set) = uint64_of_nat ` {..<2 ^ 64}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. UNIV = uint64_of_nat ` {..<2 ^ 64}
[PROOF STEP]
using nat_of_uint64_bij_betw
[PROOF STATE]
proof (prove)
using this:
bij_betw nat_of_uint64 UNIV {..<2 ^ 64}

goal (1 subgoal):
 1. UNIV = uint64_of_nat ` {..<2 ^ 64}
[PROOF STEP]
by (metis UNIV_I UNIV_eq_I bij_betw_def card_UNIV_uint64 imageI image_eqI inj_on_contraD lessThan_iff rangeI uint64_nat_bij uint64_range)


[STATEMENT]
lemma sin_two_pi [simp]: "sin (2 * pi) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sin (2 * pi) = 0
[PROOF STEP]
by (simp add: sin_double)


[STATEMENT]
lemma cardOneImageCardOne:
  assumes "card A = 1"
  shows "card (f`A) = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card (f ` A) = 1
[PROOF STEP]
using assms card_image card_image_le
[PROOF STATE]
proof (prove)
using this:
card A = 1
inj_on ?f ?A \<Longrightarrow> card (?f ` ?A) = card ?A
finite ?A \<Longrightarrow> card (?f ` ?A) \<le> card ?A

goal (1 subgoal):
 1. card (f ` A) = 1
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<lbrakk>card A = 1; \<And>f A. inj_on f A \<Longrightarrow> card (f ` A) = card A; \<And>A f. finite A \<Longrightarrow> card (f ` A) \<le> card A\<rbrakk> \<Longrightarrow> card (f ` A) = 1
[PROOF STEP]
have "finite (f`A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite (f ` A)
[PROOF STEP]
using assms One_nat_def Suc_not_Zero card.infinite finite_imageI
[PROOF STATE]
proof (prove)
using this:
card A = 1
1 = Suc 0
Suc ?m \<noteq> 0
infinite ?A \<Longrightarrow> card ?A = 0
finite ?F \<Longrightarrow> finite (?h ` ?F)

goal (1 subgoal):
 1. finite (f ` A)
[PROOF STEP]
by (metis(no_types))
[PROOF STATE]
proof (state)
this:
finite (f ` A)

goal (1 subgoal):
 1. \<lbrakk>card A = 1; \<And>f A. inj_on f A \<Longrightarrow> card (f ` A) = card A; \<And>A f. finite A \<Longrightarrow> card (f ` A) \<le> card A\<rbrakk> \<Longrightarrow> card (f ` A) = 1
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
finite (f ` A)

goal (1 subgoal):
 1. \<lbrakk>card A = 1; \<And>f A. inj_on f A \<Longrightarrow> card (f ` A) = card A; \<And>A f. finite A \<Longrightarrow> card (f ` A) \<le> card A\<rbrakk> \<Longrightarrow> card (f ` A) = 1
[PROOF STEP]
have "f`A \<noteq> {}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f ` A \<noteq> {}
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
card A = 1

goal (1 subgoal):
 1. f ` A \<noteq> {}
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
f ` A \<noteq> {}

goal (1 subgoal):
 1. \<lbrakk>card A = 1; \<And>f A. inj_on f A \<Longrightarrow> card (f ` A) = card A; \<And>A f. finite A \<Longrightarrow> card (f ` A) \<le> card A\<rbrakk> \<Longrightarrow> card (f ` A) = 1
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
f ` A \<noteq> {}

goal (1 subgoal):
 1. \<lbrakk>card A = 1; \<And>f A. inj_on f A \<Longrightarrow> card (f ` A) = card A; \<And>A f. finite A \<Longrightarrow> card (f ` A) \<le> card A\<rbrakk> \<Longrightarrow> card (f ` A) = 1
[PROOF STEP]
have "card (f`A) \<le> 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card (f ` A) \<le> 1
[PROOF STEP]
using assms card_image_le One_nat_def Suc_not_Zero card.infinite
[PROOF STATE]
proof (prove)
using this:
card A = 1
finite ?A \<Longrightarrow> card (?f ` ?A) \<le> card ?A
1 = Suc 0
Suc ?m \<noteq> 0
infinite ?A \<Longrightarrow> card ?A = 0

goal (1 subgoal):
 1. card (f ` A) \<le> 1
[PROOF STEP]
by (metis)
[PROOF STATE]
proof (state)
this:
card (f ` A) \<le> 1

goal (1 subgoal):
 1. \<lbrakk>card A = 1; \<And>f A. inj_on f A \<Longrightarrow> card (f ` A) = card A; \<And>A f. finite A \<Longrightarrow> card (f ` A) \<le> card A\<rbrakk> \<Longrightarrow> card (f ` A) = 1
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
finite (f ` A)
f ` A \<noteq> {}
card (f ` A) \<le> 1
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
finite (f ` A)
f ` A \<noteq> {}
card (f ` A) \<le> 1

goal (1 subgoal):
 1. card (f ` A) = 1
[PROOF STEP]
by (metis assms image_empty image_insert
                                    cardinalityOneTheElemIdentity the_elem_eq)
[PROOF STATE]
proof (state)
this:
card (f ` A) = 1

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma lin_bound_arg_general_set:
  fixes A ::"('a :: {field})vec set"
  assumes "A \<subseteq> carrier_vec nr"
  assumes "vec_space.lin_indpt_vs nr A"
  shows "card A \<le> nr"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card A \<le> nr
[PROOF STEP]
using vec_space.lin_indpt_set_card_lt_dim[of "A" "nr"] vec_space.lin_indpt_vs_def[of nr A]
    vec_space.dim_is_n assms
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>A \<subseteq> carrier_vec nr; \<not> module.lin_dep class_ring (module_vec TYPE('a) nr) A\<rbrakk> \<Longrightarrow> card A \<le> vectorspace.dim class_ring (module_vec TYPE('a) nr)
vec_space.lin_indpt_vs nr A = (\<not> module.lin_dep class_ring (module_vec TYPE('a) nr) A)
vectorspace.dim class_ring (module_vec TYPE(?'a) ?n) = ?n
A \<subseteq> carrier_vec nr
vec_space.lin_indpt_vs nr A

goal (1 subgoal):
 1. card A \<le> nr
[PROOF STEP]
by metis


[STATEMENT]
lemma gcd_scm: "VARS a b x y
 {0<A & 0<B & a=A & b=B & x=B & y=A}
 WHILE  a ~= b
 INV {0<a & 0<b & gcd A B = gcd a b & 2*A*B = a*x + b*y}
 DO IF a<b THEN (b := b-a; x := x+y) ELSE (a := a-b; y := y+x) FI OD
 {a = gcd A B & 2*A*B = a*(x+y)}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {0 < A \<and> 0 < B \<and> a = A \<and> b = B \<and> x = B \<and> y = A}
WHILE a \<noteq> b INV {0 < a \<and> 0 < b \<and> Arith2.gcd A B = Arith2.gcd a b \<and> 2 * A * B = a * x + b * y}  VAR {0}
DO IF a < b THEN b := b - a; x := x + y  ELSE a := a - b; y := y + x FI OD
{a = Arith2.gcd A B \<and> 2 * A * B = a * (x + y)}
[PROOF STEP]
apply vcg
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. \<And>a b x y. 0 < A \<and> 0 < B \<and> a = A \<and> b = B \<and> x = B \<and> y = A \<Longrightarrow> 0 < a \<and> 0 < b \<and> Arith2.gcd A B = Arith2.gcd a b \<and> 2 * A * B = a * x + b * y
 2. \<And>a b x y. (0 < a \<and> 0 < b \<and> Arith2.gcd A B = Arith2.gcd a b \<and> 2 * A * B = a * x + b * y) \<and> a \<noteq> b \<Longrightarrow> (a < b \<longrightarrow> 0 < a \<and> 0 < b - a \<and> Arith2.gcd A B = Arith2.gcd a (b - a) \<and> 2 * A * B = a * (x + y) + (b - a) * y) \<and> (\<not> a < b \<longrightarrow> 0 < a - b \<and> 0 < b \<and> Arith2.gcd A B = Arith2.gcd (a - b) b \<and> 2 * A * B = (a - b) * x + b * (y + x))
 3. \<And>a b x y. (0 < a \<and> 0 < b \<and> Arith2.gcd A B = Arith2.gcd a b \<and> 2 * A * B = a * x + b * y) \<and> \<not> a \<noteq> b \<Longrightarrow> a = Arith2.gcd A B \<and> 2 * A * B = a * (x + y)
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>a b x y. (0 < a \<and> 0 < b \<and> Arith2.gcd A B = Arith2.gcd a b \<and> 2 * A * B = a * x + b * y) \<and> a \<noteq> b \<Longrightarrow> (a < b \<longrightarrow> 0 < a \<and> 0 < b - a \<and> Arith2.gcd A B = Arith2.gcd a (b - a) \<and> 2 * A * B = a * (x + y) + (b - a) * y) \<and> (\<not> a < b \<longrightarrow> 0 < a - b \<and> 0 < b \<and> Arith2.gcd A B = Arith2.gcd (a - b) b \<and> 2 * A * B = (a - b) * x + b * (y + x))
 2. \<And>a b x y. (0 < a \<and> 0 < b \<and> Arith2.gcd A B = Arith2.gcd a b \<and> 2 * A * B = a * x + b * y) \<and> \<not> a \<noteq> b \<Longrightarrow> a = Arith2.gcd A B \<and> 2 * A * B = a * (x + y)
[PROOF STEP]
apply(simp add: distribs gcd_diff_r linorder_not_less gcd_diff_l)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>a b x y. (0 < a \<and> 0 < b \<and> Arith2.gcd A B = Arith2.gcd a b \<and> 2 * A * B = a * x + b * y) \<and> \<not> a \<noteq> b \<Longrightarrow> a = Arith2.gcd A B \<and> 2 * A * B = a * (x + y)
[PROOF STEP]
apply(simp add: distribs gcd_nnn)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma onorm_triangle:
  assumes f: "bounded_linear f"
  assumes g: "bounded_linear g"
  shows "onorm (\<lambda>x. f x + g x) \<le> onorm f + onorm g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. onorm (\<lambda>x. f x + g x) \<le> onorm f + onorm g
[PROOF STEP]
proof (rule onorm_bound)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. 0 \<le> onorm f + onorm g
 2. \<And>x. norm (f x + g x) \<le> (onorm f + onorm g) * norm x
[PROOF STEP]
show "0 \<le> onorm f + onorm g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 \<le> onorm f + onorm g
[PROOF STEP]
by (intro add_nonneg_nonneg onorm_pos_le f g)
[PROOF STATE]
proof (state)
this:
0 \<le> onorm f + onorm g

goal (1 subgoal):
 1. \<And>x. norm (f x + g x) \<le> (onorm f + onorm g) * norm x
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. norm (f x + g x) \<le> (onorm f + onorm g) * norm x
[PROOF STEP]
fix x
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. norm (f x + g x) \<le> (onorm f + onorm g) * norm x
[PROOF STEP]
have "norm (f x + g x) \<le> norm (f x) + norm (g x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. norm (f x + g x) \<le> norm (f x) + norm (g x)
[PROOF STEP]
by (rule norm_triangle_ineq)
[PROOF STATE]
proof (state)
this:
norm (f x + g x) \<le> norm (f x) + norm (g x)

goal (1 subgoal):
 1. \<And>x. norm (f x + g x) \<le> (onorm f + onorm g) * norm x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
norm (f x + g x) \<le> norm (f x) + norm (g x)

goal (1 subgoal):
 1. \<And>x. norm (f x + g x) \<le> (onorm f + onorm g) * norm x
[PROOF STEP]
have "norm (f x) + norm (g x) \<le> onorm f * norm x + onorm g * norm x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. norm (f x) + norm (g x) \<le> onorm f * norm x + onorm g * norm x
[PROOF STEP]
by (intro add_mono onorm f g)
[PROOF STATE]
proof (state)
this:
norm (f x) + norm (g x) \<le> onorm f * norm x + onorm g * norm x

goal (1 subgoal):
 1. \<And>x. norm (f x + g x) \<le> (onorm f + onorm g) * norm x
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
norm (f x + g x) \<le> onorm f * norm x + onorm g * norm x
[PROOF STEP]
show "norm (f x + g x) \<le> (onorm f + onorm g) * norm x"
[PROOF STATE]
proof (prove)
using this:
norm (f x + g x) \<le> onorm f * norm x + onorm g * norm x

goal (1 subgoal):
 1. norm (f x + g x) \<le> (onorm f + onorm g) * norm x
[PROOF STEP]
by (simp only: distrib_right)
[PROOF STATE]
proof (state)
this:
norm (f x + g x) \<le> (onorm f + onorm g) * norm x

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma Log_less_cancel_iff [simp]:
  assumes "1 < a"
  and "0 < x"
  and "0 < y"
shows "(Log a x < Log a y) = (x < y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (Log a x < Log a y) = (x < y)
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. Log a x < Log a y \<Longrightarrow> x < y
 2. x < y \<Longrightarrow> Log a x < Log a y
[PROOF STEP]
assume "Log a x < Log a y"
[PROOF STATE]
proof (state)
this:
Log a x < Log a y

goal (2 subgoals):
 1. Log a x < Log a y \<Longrightarrow> x < y
 2. x < y \<Longrightarrow> Log a x < Log a y
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
Log a x < Log a y
[PROOF STEP]
show "x < y"
[PROOF STATE]
proof (prove)
using this:
Log a x < Log a y

goal (1 subgoal):
 1. x < y
[PROOF STEP]
using powreal_Log_cancel assms powreal_less_cancel_iff
[PROOF STATE]
proof (prove)
using this:
Log a x < Log a y
\<lbrakk>0 < ?a; ?a \<noteq> 1; 0 < ?x\<rbrakk> \<Longrightarrow> ?a pow\<^sub>\<real> Log ?a ?x = ?x
1 < a
0 < x
0 < y
1 < ?a \<Longrightarrow> (?a pow\<^sub>\<real> ?r < ?a pow\<^sub>\<real> ?s) = (?r < ?s)

goal (1 subgoal):
 1. x < y
[PROOF STEP]
by (metis less_irrefl real_inverse_bet_one_one_lemma
          inverse_positive_iff_positive)
[PROOF STATE]
proof (state)
this:
x < y

goal (1 subgoal):
 1. x < y \<Longrightarrow> Log a x < Log a y
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. x < y \<Longrightarrow> Log a x < Log a y
[PROOF STEP]
assume "x < y"
[PROOF STATE]
proof (state)
this:
x < y

goal (1 subgoal):
 1. x < y \<Longrightarrow> Log a x < Log a y
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
x < y
[PROOF STEP]
show "Log a x < Log a y"
[PROOF STATE]
proof (prove)
using this:
x < y

goal (1 subgoal):
 1. Log a x < Log a y
[PROOF STEP]
using assms(1) assms(2) powreal_less_cancel_iff
[PROOF STATE]
proof (prove)
using this:
x < y
1 < a
0 < x
1 < ?a \<Longrightarrow> (?a pow\<^sub>\<real> ?r < ?a pow\<^sub>\<real> ?s) = (?r < ?s)

goal (1 subgoal):
 1. Log a x < Log a y
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
Log a x < Log a y

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma linorder_rank_singleton:
  "linorder_rank R {y} x = (if x \<noteq> y \<and> (y,x) \<in> R then 1 else 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. linorder_rank R {y} x = (if x \<noteq> y \<and> (y, x) \<in> R then 1 else 0)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. linorder_rank R {y} x = (if x \<noteq> y \<and> (y, x) \<in> R then 1 else 0)
[PROOF STEP]
have "linorder_rank R {y} x = card {z\<in>{y}-{x}. (z,x) \<in> R}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. linorder_rank R {y} x = card {z \<in> {y} - {x}. (z, x) \<in> R}
[PROOF STEP]
by (simp add: linorder_rank_def)
[PROOF STATE]
proof (state)
this:
linorder_rank R {y} x = card {z \<in> {y} - {x}. (z, x) \<in> R}

goal (1 subgoal):
 1. linorder_rank R {y} x = (if x \<noteq> y \<and> (y, x) \<in> R then 1 else 0)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
linorder_rank R {y} x = card {z \<in> {y} - {x}. (z, x) \<in> R}

goal (1 subgoal):
 1. linorder_rank R {y} x = (if x \<noteq> y \<and> (y, x) \<in> R then 1 else 0)
[PROOF STEP]
have "{z\<in>{y}-{x}. (z,x) \<in> R} = (if x \<noteq> y \<and> (y,x) \<in> R then {y} else {})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {z \<in> {y} - {x}. (z, x) \<in> R} = (if x \<noteq> y \<and> (y, x) \<in> R then {y} else {})
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
{z \<in> {y} - {x}. (z, x) \<in> R} = (if x \<noteq> y \<and> (y, x) \<in> R then {y} else {})

goal (1 subgoal):
 1. linorder_rank R {y} x = (if x \<noteq> y \<and> (y, x) \<in> R then 1 else 0)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
{z \<in> {y} - {x}. (z, x) \<in> R} = (if x \<noteq> y \<and> (y, x) \<in> R then {y} else {})

goal (1 subgoal):
 1. linorder_rank R {y} x = (if x \<noteq> y \<and> (y, x) \<in> R then 1 else 0)
[PROOF STEP]
have "card \<dots> = (if x \<noteq> y \<and> (y,x) \<in> R then 1 else 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card (if x \<noteq> y \<and> (y, x) \<in> R then {y} else {}) = (if x \<noteq> y \<and> (y, x) \<in> R then 1 else 0)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
card (if x \<noteq> y \<and> (y, x) \<in> R then {y} else {}) = (if x \<noteq> y \<and> (y, x) \<in> R then 1 else 0)

goal (1 subgoal):
 1. linorder_rank R {y} x = (if x \<noteq> y \<and> (y, x) \<in> R then 1 else 0)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
linorder_rank R {y} x = (if x \<noteq> y \<and> (y, x) \<in> R then 1 else 0)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
linorder_rank R {y} x = (if x \<noteq> y \<and> (y, x) \<in> R then 1 else 0)

goal (1 subgoal):
 1. linorder_rank R {y} x = (if x \<noteq> y \<and> (y, x) \<in> R then 1 else 0)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
linorder_rank R {y} x = (if x \<noteq> y \<and> (y, x) \<in> R then 1 else 0)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma card_face_cycle_sets_conv:
  shows "card (pre_digraph_map.face_cycle_sets G M) = length (lists_fcs (remdups (snd G_list)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card face_cycle_sets = length (lists_fcs (remdups (snd G_list)))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. card face_cycle_sets = length (lists_fcs (remdups (snd G_list)))
[PROOF STEP]
interpret digraph_map G M
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. digraph_map (with_proj (list_digraph G_list)) (to_map' (snd G_list) xss)
[PROOF STEP]
by (rule digraph_map)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. card face_cycle_sets = length (lists_fcs (remdups (snd G_list)))
[PROOF STEP]
have "face_cycle_sets = {face_cycle_set a | a. a \<in> parcs G}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. face_cycle_sets = {face_cycle_set a |a. a \<in> parcs (list_digraph G_list)}
[PROOF STEP]
by (auto simp: face_cycle_sets_def)
[PROOF STATE]
proof (state)
this:
face_cycle_sets = {face_cycle_set a |a. a \<in> parcs (list_digraph G_list)}

goal (1 subgoal):
 1. card face_cycle_sets = length (lists_fcs (remdups (snd G_list)))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
face_cycle_sets = {face_cycle_set a |a. a \<in> parcs (list_digraph G_list)}

goal (1 subgoal):
 1. card face_cycle_sets = length (lists_fcs (remdups (snd G_list)))
[PROOF STEP]
have "\<dots> = sset (lists_fcs (remdups (snd G_list)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {face_cycle_set a |a. a \<in> parcs (list_digraph G_list)} = sset (lists_fcs (remdups (snd G_list)))
[PROOF STEP]
unfolding sset_lists_fcs
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {face_cycle_set a |a. a \<in> parcs (list_digraph G_list)} = {face_cycle_set a |a. a \<in> set (remdups (snd G_list))}
[PROOF STEP]
by (simp add: list_digraph_simps)
[PROOF STATE]
proof (state)
this:
{face_cycle_set a |a. a \<in> parcs (list_digraph G_list)} = sset (lists_fcs (remdups (snd G_list)))

goal (1 subgoal):
 1. card face_cycle_sets = length (lists_fcs (remdups (snd G_list)))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
{face_cycle_set a |a. a \<in> parcs (list_digraph G_list)} = sset (lists_fcs (remdups (snd G_list)))

goal (1 subgoal):
 1. card face_cycle_sets = length (lists_fcs (remdups (snd G_list)))
[PROOF STEP]
have "card \<dots> = length (lists_fcs (remdups (snd G_list)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card (sset (lists_fcs (remdups (snd G_list)))) = length (lists_fcs (remdups (snd G_list)))
[PROOF STEP]
by (simp add: card_image distincts_inj_on_set distinct_card distincts_distinct distincts_lists_fcs)
[PROOF STATE]
proof (state)
this:
card (sset (lists_fcs (remdups (snd G_list)))) = length (lists_fcs (remdups (snd G_list)))

goal (1 subgoal):
 1. card face_cycle_sets = length (lists_fcs (remdups (snd G_list)))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
card face_cycle_sets = length (lists_fcs (remdups (snd G_list)))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
card face_cycle_sets = length (lists_fcs (remdups (snd G_list)))

goal (1 subgoal):
 1. card face_cycle_sets = length (lists_fcs (remdups (snd G_list)))
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
card face_cycle_sets = length (lists_fcs (remdups (snd G_list)))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma scalar_prod_ge_0: "(x :: 'a :: linordered_idom vec) \<bullet> x \<ge> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (0::'a) \<le> x \<bullet> x
[PROOF STEP]
unfolding scalar_prod_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (0::'a) \<le> (\<Sum>i = 0..<dim_vec x. x $ i * x $ i)
[PROOF STEP]
by (rule sum_nonneg, auto)


[STATEMENT]
lemma mono_bij_cInf:
  fixes f :: "'a::conditionally_complete_linorder \<Rightarrow> 'b::conditionally_complete_linorder"
  assumes "mono f" "bij f" "A \<noteq> {}" "bdd_below A"
  shows "f (Inf A) = Inf (f`A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f (\<Sqinter> A) = \<Sqinter> (f ` A)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. f (\<Sqinter> A) = \<Sqinter> (f ` A)
[PROOF STEP]
have "(inv f) (Inf (f`A)) \<le> Inf ((inv f)`(f`A))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inv f (\<Sqinter> (f ` A)) \<le> \<Sqinter> (inv f ` f ` A)
[PROOF STEP]
apply (rule cInf_greatest, auto simp add: assms(3))
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>xb. xb \<in> A \<Longrightarrow> inv f (\<Sqinter> (f ` A)) \<le> inv f (f xb)
[PROOF STEP]
using mono_inv[OF assms(1) assms(2)] assms
[PROOF STATE]
proof (prove)
using this:
mono (inv f)
mono f
bij f
A \<noteq> {}
bdd_below A

goal (1 subgoal):
 1. \<And>xb. xb \<in> A \<Longrightarrow> inv f (\<Sqinter> (f ` A)) \<le> inv f (f xb)
[PROOF STEP]
by (simp add: mono_def bdd_below_image_mono cInf_lower)
[PROOF STATE]
proof (state)
this:
inv f (\<Sqinter> (f ` A)) \<le> \<Sqinter> (inv f ` f ` A)

goal (1 subgoal):
 1. f (\<Sqinter> A) = \<Sqinter> (f ` A)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
inv f (\<Sqinter> (f ` A)) \<le> \<Sqinter> (inv f ` f ` A)
[PROOF STEP]
have "Inf (f`A) \<le> f (Inf ((inv f)`(f`A)))"
[PROOF STATE]
proof (prove)
using this:
inv f (\<Sqinter> (f ` A)) \<le> \<Sqinter> (inv f ` f ` A)

goal (1 subgoal):
 1. \<Sqinter> (f ` A) \<le> f (\<Sqinter> (inv f ` f ` A))
[PROOF STEP]
by (metis (no_types, lifting) assms(1) assms(2) mono_def bij_inv_eq_iff)
[PROOF STATE]
proof (state)
this:
\<Sqinter> (f ` A) \<le> f (\<Sqinter> (inv f ` f ` A))

goal (1 subgoal):
 1. f (\<Sqinter> A) = \<Sqinter> (f ` A)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
\<Sqinter> (f ` A) \<le> f (\<Sqinter> (inv f ` f ` A))

goal (1 subgoal):
 1. f (\<Sqinter> A) = \<Sqinter> (f ` A)
[PROOF STEP]
have "... = f(Inf A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f (\<Sqinter> (inv f ` f ` A)) = f (\<Sqinter> A)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
mono f
bij f
A \<noteq> {}
bdd_below A

goal (1 subgoal):
 1. f (\<Sqinter> (inv f ` f ` A)) = f (\<Sqinter> A)
[PROOF STEP]
by (simp add: bij_is_inj)
[PROOF STATE]
proof (state)
this:
f (\<Sqinter> (inv f ` f ` A)) = f (\<Sqinter> A)

goal (1 subgoal):
 1. f (\<Sqinter> A) = \<Sqinter> (f ` A)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
\<Sqinter> (f ` A) \<le> f (\<Sqinter> A)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<Sqinter> (f ` A) \<le> f (\<Sqinter> A)

goal (1 subgoal):
 1. f (\<Sqinter> A) = \<Sqinter> (f ` A)
[PROOF STEP]
using mono_cInf[OF assms(1) assms(3) assms(4)]
[PROOF STATE]
proof (prove)
using this:
\<Sqinter> (f ` A) \<le> f (\<Sqinter> A)
f (\<Sqinter> A) \<le> \<Sqinter> (f ` A)

goal (1 subgoal):
 1. f (\<Sqinter> A) = \<Sqinter> (f ` A)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
f (\<Sqinter> A) = \<Sqinter> (f ` A)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma gbinomial_factors: "((a + 1) gchoose (Suc k)) = (a + 1) / of_nat (Suc k) * (a gchoose k)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a + (1::'a) gchoose Suc k = (a + (1::'a)) / of_nat (Suc k) * (a gchoose k)
[PROOF STEP]
proof (cases k)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. k = 0 \<Longrightarrow> a + (1::'a) gchoose Suc k = (a + (1::'a)) / of_nat (Suc k) * (a gchoose k)
 2. \<And>nat. k = Suc nat \<Longrightarrow> a + (1::'a) gchoose Suc k = (a + (1::'a)) / of_nat (Suc k) * (a gchoose k)
[PROOF STEP]
case 0
[PROOF STATE]
proof (state)
this:
k = 0

goal (2 subgoals):
 1. k = 0 \<Longrightarrow> a + (1::'a) gchoose Suc k = (a + (1::'a)) / of_nat (Suc k) * (a gchoose k)
 2. \<And>nat. k = Suc nat \<Longrightarrow> a + (1::'a) gchoose Suc k = (a + (1::'a)) / of_nat (Suc k) * (a gchoose k)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
k = 0
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
k = 0

goal (1 subgoal):
 1. a + (1::'a) gchoose Suc k = (a + (1::'a)) / of_nat (Suc k) * (a gchoose k)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
a + (1::'a) gchoose Suc k = (a + (1::'a)) / of_nat (Suc k) * (a gchoose k)

goal (1 subgoal):
 1. \<And>nat. k = Suc nat \<Longrightarrow> a + (1::'a) gchoose Suc k = (a + (1::'a)) / of_nat (Suc k) * (a gchoose k)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>nat. k = Suc nat \<Longrightarrow> a + (1::'a) gchoose Suc k = (a + (1::'a)) / of_nat (Suc k) * (a gchoose k)
[PROOF STEP]
case (Suc b)
[PROOF STATE]
proof (state)
this:
k = Suc b

goal (1 subgoal):
 1. \<And>nat. k = Suc nat \<Longrightarrow> a + (1::'a) gchoose Suc k = (a + (1::'a)) / of_nat (Suc k) * (a gchoose k)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
k = Suc b
[PROOF STEP]
have "((a + 1) gchoose (Suc (Suc b))) = (\<Prod>i = 0 .. Suc b. a + (1 - of_nat i)) / fact (b + 2)"
[PROOF STATE]
proof (prove)
using this:
k = Suc b

goal (1 subgoal):
 1. a + (1::'a) gchoose Suc (Suc b) = (\<Prod>i = 0..Suc b. a + ((1::'a) - of_nat i)) / fact (b + 2)
[PROOF STEP]
by (simp add: field_simps gbinomial_prod_rev atLeastLessThanSuc_atLeastAtMost)
[PROOF STATE]
proof (state)
this:
a + (1::'a) gchoose Suc (Suc b) = (\<Prod>i = 0..Suc b. a + ((1::'a) - of_nat i)) / fact (b + 2)

goal (1 subgoal):
 1. \<And>nat. k = Suc nat \<Longrightarrow> a + (1::'a) gchoose Suc k = (a + (1::'a)) / of_nat (Suc k) * (a gchoose k)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
a + (1::'a) gchoose Suc (Suc b) = (\<Prod>i = 0..Suc b. a + ((1::'a) - of_nat i)) / fact (b + 2)

goal (1 subgoal):
 1. \<And>nat. k = Suc nat \<Longrightarrow> a + (1::'a) gchoose Suc k = (a + (1::'a)) / of_nat (Suc k) * (a gchoose k)
[PROOF STEP]
have "(\<Prod>i = 0 .. Suc b. a + (1 - of_nat i)) = (a + 1) * (\<Prod>i = 0..b. a - of_nat i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Prod>i = 0..Suc b. a + ((1::'a) - of_nat i)) = (a + (1::'a)) * (\<Prod>i = 0..b. a - of_nat i)
[PROOF STEP]
by (simp add: prod.atLeast0_atMost_Suc_shift del: prod.cl_ivl_Suc)
[PROOF STATE]
proof (state)
this:
(\<Prod>i = 0..Suc b. a + ((1::'a) - of_nat i)) = (a + (1::'a)) * (\<Prod>i = 0..b. a - of_nat i)

goal (1 subgoal):
 1. \<And>nat. k = Suc nat \<Longrightarrow> a + (1::'a) gchoose Suc k = (a + (1::'a)) / of_nat (Suc k) * (a gchoose k)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Prod>i = 0..Suc b. a + ((1::'a) - of_nat i)) = (a + (1::'a)) * (\<Prod>i = 0..b. a - of_nat i)

goal (1 subgoal):
 1. \<And>nat. k = Suc nat \<Longrightarrow> a + (1::'a) gchoose Suc k = (a + (1::'a)) / of_nat (Suc k) * (a gchoose k)
[PROOF STEP]
have "\<dots> / fact (b + 2) = (a + 1) / of_nat (Suc (Suc b)) * (a gchoose Suc b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (a + (1::'a)) * (\<Prod>i = 0..b. a - of_nat i) / fact (b + 2) = (a + (1::'a)) / of_nat (Suc (Suc b)) * (a gchoose Suc b)
[PROOF STEP]
by (simp_all add: gbinomial_prod_rev atLeastLessThanSuc_atLeastAtMost atLeast0AtMost)
[PROOF STATE]
proof (state)
this:
(a + (1::'a)) * (\<Prod>i = 0..b. a - of_nat i) / fact (b + 2) = (a + (1::'a)) / of_nat (Suc (Suc b)) * (a gchoose Suc b)

goal (1 subgoal):
 1. \<And>nat. k = Suc nat \<Longrightarrow> a + (1::'a) gchoose Suc k = (a + (1::'a)) / of_nat (Suc k) * (a gchoose k)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
a + (1::'a) gchoose Suc (Suc b) = (a + (1::'a)) / of_nat (Suc (Suc b)) * (a gchoose Suc b)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
a + (1::'a) gchoose Suc (Suc b) = (a + (1::'a)) / of_nat (Suc (Suc b)) * (a gchoose Suc b)

goal (1 subgoal):
 1. a + (1::'a) gchoose Suc k = (a + (1::'a)) / of_nat (Suc k) * (a gchoose k)
[PROOF STEP]
by (simp add: Suc)
[PROOF STATE]
proof (state)
this:
a + (1::'a) gchoose Suc k = (a + (1::'a)) / of_nat (Suc k) * (a gchoose k)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma arctan_add_raw:
  assumes "\<bar>arctan x + arctan y\<bar> < pi/2"
    shows "arctan x + arctan y = arctan((x + y) / (1 - x * y))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. arctan x + arctan y = arctan ((x + y) / (1 - x * y))
[PROOF STEP]
proof (rule arctan_unique [symmetric])
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. - (pi / 2) < arctan x + arctan y
 2. arctan x + arctan y < pi / 2
 3. tan (arctan x + arctan y) = (x + y) / (1 - x * y)
[PROOF STEP]
show 12: "- (pi / 2) < arctan x + arctan y" "arctan x + arctan y < pi / 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. - (pi / 2) < arctan x + arctan y &&& arctan x + arctan y < pi / 2
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
\<bar>arctan x + arctan y\<bar> < pi / 2

goal (1 subgoal):
 1. - (pi / 2) < arctan x + arctan y &&& arctan x + arctan y < pi / 2
[PROOF STEP]
by linarith+
[PROOF STATE]
proof (state)
this:
- (pi / 2) < arctan x + arctan y
arctan x + arctan y < pi / 2

goal (1 subgoal):
 1. tan (arctan x + arctan y) = (x + y) / (1 - x * y)
[PROOF STEP]
show "tan (arctan x + arctan y) = (x + y) / (1 - x * y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. tan (arctan x + arctan y) = (x + y) / (1 - x * y)
[PROOF STEP]
using cos_gt_zero_pi [OF 12]
[PROOF STATE]
proof (prove)
using this:
0 < cos (arctan x + arctan y)

goal (1 subgoal):
 1. tan (arctan x + arctan y) = (x + y) / (1 - x * y)
[PROOF STEP]
by (simp add: arctan tan_add)
[PROOF STATE]
proof (state)
this:
tan (arctan x + arctan y) = (x + y) / (1 - x * y)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma sum_splice:
  "(\<Sum>i::nat = 0..<2*nn. f i) = (\<Sum>i = 0..<nn. f (2*i)) + (\<Sum>i = 0..<nn. f (2*i+1))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum f {0..<2 * nn} = (\<Sum>i = 0..<nn. f (2 * i)) + (\<Sum>i = 0..<nn. f (2 * i + 1))
[PROOF STEP]
proof(induction nn)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. sum f {0..<2 * 0} = (\<Sum>i = 0..<0. f (2 * i)) + (\<Sum>i = 0..<0. f (2 * i + 1))
 2. \<And>nn. sum f {0..<2 * nn} = (\<Sum>i = 0..<nn. f (2 * i)) + (\<Sum>i = 0..<nn. f (2 * i + 1)) \<Longrightarrow> sum f {0..<2 * Suc nn} = (\<Sum>i = 0..<Suc nn. f (2 * i)) + (\<Sum>i = 0..<Suc nn. f (2 * i + 1))
[PROOF STEP]
case (Suc n)
[PROOF STATE]
proof (state)
this:
sum f {0..<2 * n} = (\<Sum>i = 0..<n. f (2 * i)) + (\<Sum>i = 0..<n. f (2 * i + 1))

goal (2 subgoals):
 1. sum f {0..<2 * 0} = (\<Sum>i = 0..<0. f (2 * i)) + (\<Sum>i = 0..<0. f (2 * i + 1))
 2. \<And>nn. sum f {0..<2 * nn} = (\<Sum>i = 0..<nn. f (2 * i)) + (\<Sum>i = 0..<nn. f (2 * i + 1)) \<Longrightarrow> sum f {0..<2 * Suc nn} = (\<Sum>i = 0..<Suc nn. f (2 * i)) + (\<Sum>i = 0..<Suc nn. f (2 * i + 1))
[PROOF STEP]
have "(\<Sum>i::nat = 0..<2*(n+1). f i)  = (\<Sum>i::nat = 0..<(2*n). f i) + f(2*n+1) + f (2*n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum f {0..<2 * (n + 1)} = sum f {0..<2 * n} + f (2 * n + 1) + f (2 * n)
[PROOF STEP]
by( simp add: algebra_simps)
[PROOF STATE]
proof (state)
this:
sum f {0..<2 * (n + 1)} = sum f {0..<2 * n} + f (2 * n + 1) + f (2 * n)

goal (2 subgoals):
 1. sum f {0..<2 * 0} = (\<Sum>i = 0..<0. f (2 * i)) + (\<Sum>i = 0..<0. f (2 * i + 1))
 2. \<And>nn. sum f {0..<2 * nn} = (\<Sum>i = 0..<nn. f (2 * i)) + (\<Sum>i = 0..<nn. f (2 * i + 1)) \<Longrightarrow> sum f {0..<2 * Suc nn} = (\<Sum>i = 0..<Suc nn. f (2 * i)) + (\<Sum>i = 0..<Suc nn. f (2 * i + 1))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
sum f {0..<2 * (n + 1)} = sum f {0..<2 * n} + f (2 * n + 1) + f (2 * n)

goal (2 subgoals):
 1. sum f {0..<2 * 0} = (\<Sum>i = 0..<0. f (2 * i)) + (\<Sum>i = 0..<0. f (2 * i + 1))
 2. \<And>nn. sum f {0..<2 * nn} = (\<Sum>i = 0..<nn. f (2 * i)) + (\<Sum>i = 0..<nn. f (2 * i + 1)) \<Longrightarrow> sum f {0..<2 * Suc nn} = (\<Sum>i = 0..<Suc nn. f (2 * i)) + (\<Sum>i = 0..<Suc nn. f (2 * i + 1))
[PROOF STEP]
have "\<dots> = (\<Sum>i::nat = 0..<n. f (2*i)) + (\<Sum>i::nat = 0..<n. f (2*i+1)) + f(2*n+1) + f (2*n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum f {0..<2 * n} + f (2 * n + 1) + f (2 * n) = (\<Sum>i = 0..<n. f (2 * i)) + (\<Sum>i = 0..<n. f (2 * i + 1)) + f (2 * n + 1) + f (2 * n)
[PROOF STEP]
using Suc
[PROOF STATE]
proof (prove)
using this:
sum f {0..<2 * n} = (\<Sum>i = 0..<n. f (2 * i)) + (\<Sum>i = 0..<n. f (2 * i + 1))

goal (1 subgoal):
 1. sum f {0..<2 * n} + f (2 * n + 1) + f (2 * n) = (\<Sum>i = 0..<n. f (2 * i)) + (\<Sum>i = 0..<n. f (2 * i + 1)) + f (2 * n + 1) + f (2 * n)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
sum f {0..<2 * n} + f (2 * n + 1) + f (2 * n) = (\<Sum>i = 0..<n. f (2 * i)) + (\<Sum>i = 0..<n. f (2 * i + 1)) + f (2 * n + 1) + f (2 * n)

goal (2 subgoals):
 1. sum f {0..<2 * 0} = (\<Sum>i = 0..<0. f (2 * i)) + (\<Sum>i = 0..<0. f (2 * i + 1))
 2. \<And>nn. sum f {0..<2 * nn} = (\<Sum>i = 0..<nn. f (2 * i)) + (\<Sum>i = 0..<nn. f (2 * i + 1)) \<Longrightarrow> sum f {0..<2 * Suc nn} = (\<Sum>i = 0..<Suc nn. f (2 * i)) + (\<Sum>i = 0..<Suc nn. f (2 * i + 1))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
sum f {0..<2 * n} + f (2 * n + 1) + f (2 * n) = (\<Sum>i = 0..<n. f (2 * i)) + (\<Sum>i = 0..<n. f (2 * i + 1)) + f (2 * n + 1) + f (2 * n)

goal (2 subgoals):
 1. sum f {0..<2 * 0} = (\<Sum>i = 0..<0. f (2 * i)) + (\<Sum>i = 0..<0. f (2 * i + 1))
 2. \<And>nn. sum f {0..<2 * nn} = (\<Sum>i = 0..<nn. f (2 * i)) + (\<Sum>i = 0..<nn. f (2 * i + 1)) \<Longrightarrow> sum f {0..<2 * Suc nn} = (\<Sum>i = 0..<Suc nn. f (2 * i)) + (\<Sum>i = 0..<Suc nn. f (2 * i + 1))
[PROOF STEP]
have "\<dots> = (\<Sum>i::nat = 0..<(Suc n). f (2*i)) + (\<Sum>i::nat = 0..<(Suc n). f (2*i+1))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i = 0..<n. f (2 * i)) + (\<Sum>i = 0..<n. f (2 * i + 1)) + f (2 * n + 1) + f (2 * n) = (\<Sum>i = 0..<Suc n. f (2 * i)) + (\<Sum>i = 0..<Suc n. f (2 * i + 1))
[PROOF STEP]
by( simp add: algebra_simps)
[PROOF STATE]
proof (state)
this:
(\<Sum>i = 0..<n. f (2 * i)) + (\<Sum>i = 0..<n. f (2 * i + 1)) + f (2 * n + 1) + f (2 * n) = (\<Sum>i = 0..<Suc n. f (2 * i)) + (\<Sum>i = 0..<Suc n. f (2 * i + 1))

goal (2 subgoals):
 1. sum f {0..<2 * 0} = (\<Sum>i = 0..<0. f (2 * i)) + (\<Sum>i = 0..<0. f (2 * i + 1))
 2. \<And>nn. sum f {0..<2 * nn} = (\<Sum>i = 0..<nn. f (2 * i)) + (\<Sum>i = 0..<nn. f (2 * i + 1)) \<Longrightarrow> sum f {0..<2 * Suc nn} = (\<Sum>i = 0..<Suc nn. f (2 * i)) + (\<Sum>i = 0..<Suc nn. f (2 * i + 1))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
sum f {0..<2 * (n + 1)} = (\<Sum>i = 0..<Suc n. f (2 * i)) + (\<Sum>i = 0..<Suc n. f (2 * i + 1))
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
sum f {0..<2 * (n + 1)} = (\<Sum>i = 0..<Suc n. f (2 * i)) + (\<Sum>i = 0..<Suc n. f (2 * i + 1))

goal (1 subgoal):
 1. sum f {0..<2 * Suc n} = (\<Sum>i = 0..<Suc n. f (2 * i)) + (\<Sum>i = 0..<Suc n. f (2 * i + 1))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
sum f {0..<2 * Suc n} = (\<Sum>i = 0..<Suc n. f (2 * i)) + (\<Sum>i = 0..<Suc n. f (2 * i + 1))

goal (1 subgoal):
 1. sum f {0..<2 * 0} = (\<Sum>i = 0..<0. f (2 * i)) + (\<Sum>i = 0..<0. f (2 * i + 1))
[PROOF STEP]
qed simp


[STATEMENT]
theorem omega_lfp:
  "x ^ \<omega> * y = lfp (\<lambda> z . (x * z) \<sqinter> y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x ^ \<omega> * y = lfp (\<lambda>z. x * z \<sqinter> y)
[PROOF STEP]
apply (rule order.antisym)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. x ^ \<omega> * y \<le> lfp (\<lambda>z. x * z \<sqinter> y)
 2. lfp (\<lambda>z. x * z \<sqinter> y) \<le> x ^ \<omega> * y
[PROOF STEP]
apply (rule lfp_greatest)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>u. x * u \<sqinter> y \<le> u \<Longrightarrow> x ^ \<omega> * y \<le> u
 2. lfp (\<lambda>z. x * z \<sqinter> y) \<le> x ^ \<omega> * y
[PROOF STEP]
apply (drule omega_least, simp)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. lfp (\<lambda>z. x * z \<sqinter> y) \<le> x ^ \<omega> * y
[PROOF STEP]
apply (rule lfp_lowerbound)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x * (x ^ \<omega> * y) \<sqinter> y \<le> x ^ \<omega> * y
[PROOF STEP]
apply (subst (2) omega_fix)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x * (x ^ \<omega> * y) \<sqinter> y \<le> x * x ^ \<omega> \<sqinter> (1::'a) * y
[PROOF STEP]
by (simp add: inf_comp mult.assoc)


[STATEMENT]
lemma coeff_sum: "MPoly_Type.coeff (sum f S) x = sum (\<lambda>i. MPoly_Type.coeff (f i) x) S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. MPoly_Type.coeff (sum f S) x = (\<Sum>i\<in>S. MPoly_Type.coeff (f i) x)
[PROOF STEP]
apply (induction S rule: infinite_finite_induct)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. \<And>A. infinite A \<Longrightarrow> MPoly_Type.coeff (sum f A) x = (\<Sum>i\<in>A. MPoly_Type.coeff (f i) x)
 2. MPoly_Type.coeff (sum f {}) x = (\<Sum>i\<in>{}. MPoly_Type.coeff (f i) x)
 3. \<And>xa F. \<lbrakk>finite F; xa \<notin> F; MPoly_Type.coeff (sum f F) x = (\<Sum>i\<in>F. MPoly_Type.coeff (f i) x)\<rbrakk> \<Longrightarrow> MPoly_Type.coeff (sum f (insert xa F)) x = (\<Sum>i\<in>insert xa F. MPoly_Type.coeff (f i) x)
[PROOF STEP]
apply (auto)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>xa F. \<lbrakk>finite F; xa \<notin> F; MPoly_Type.coeff (sum f F) x = (\<Sum>i\<in>F. MPoly_Type.coeff (f i) x)\<rbrakk> \<Longrightarrow> MPoly_Type.coeff (f xa + sum f F) x = MPoly_Type.coeff (f xa) x + (\<Sum>i\<in>F. MPoly_Type.coeff (f i) x)
[PROOF STEP]
by (metis More_MPoly_Type.coeff_add)


[STATEMENT]
lemma int_group_gen_by_one: "\<langle>{1}\<rangle>\<^bsub>int_group\<^esub> = carrier int_group"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<langle>{1}\<rangle>\<^bsub>int_group\<^esub> = carrier int_group
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<langle>{1}\<rangle>\<^bsub>int_group\<^esub> \<subseteq> carrier int_group
 2. carrier int_group \<subseteq> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>
[PROOF STEP]
show "\<langle>{1}\<rangle>\<^bsub>int_group\<^esub> \<subseteq> carrier int_group"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<langle>{1}\<rangle>\<^bsub>int_group\<^esub> \<subseteq> carrier int_group
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<langle>{1}\<rangle>\<^bsub>int_group\<^esub> \<subseteq> carrier int_group

goal (1 subgoal):
 1. carrier int_group \<subseteq> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>
[PROOF STEP]
show "carrier int_group \<subseteq> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. carrier int_group \<subseteq> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> carrier int_group \<Longrightarrow> x \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>
[PROOF STEP]
interpret int: group int_group
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Group.group int_group
[PROOF STEP]
using int.a_group
[PROOF STATE]
proof (prove)
using this:
Group.group \<lparr>carrier = UNIV, monoid.mult = (+), one = 0, \<dots> = undefined\<rparr>

goal (1 subgoal):
 1. Group.group int_group
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> carrier int_group \<Longrightarrow> x \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>
[PROOF STEP]
fix x
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> carrier int_group \<Longrightarrow> x \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>
[PROOF STEP]
have plus1: "1 \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>
[PROOF STEP]
by (auto intro:gen_span.gen_gens)
[PROOF STATE]
proof (state)
this:
1 \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>

goal (1 subgoal):
 1. \<And>x. x \<in> carrier int_group \<Longrightarrow> x \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>
[PROOF STEP]
hence "inv\<^bsub>int_group\<^esub> 1 \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>"
[PROOF STATE]
proof (prove)
using this:
1 \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>

goal (1 subgoal):
 1. inv\<^bsub>int_group\<^esub> 1 \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>
[PROOF STEP]
by (auto intro:gen_span.gen_inv)
[PROOF STATE]
proof (state)
this:
inv\<^bsub>int_group\<^esub> 1 \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>

goal (1 subgoal):
 1. \<And>x. x \<in> carrier int_group \<Longrightarrow> x \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
inv\<^bsub>int_group\<^esub> 1 \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>

goal (1 subgoal):
 1. \<And>x. x \<in> carrier int_group \<Longrightarrow> x \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>
[PROOF STEP]
have "-1 = inv\<^bsub>int_group\<^esub> 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. - 1 = inv\<^bsub>int_group\<^esub> 1
[PROOF STEP]
by (rule sym, rule int.inv_equality) simp_all
[PROOF STATE]
proof (state)
this:
- 1 = inv\<^bsub>int_group\<^esub> 1

goal (1 subgoal):
 1. \<And>x. x \<in> carrier int_group \<Longrightarrow> x \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
inv\<^bsub>int_group\<^esub> 1 \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>
- 1 = inv\<^bsub>int_group\<^esub> 1
[PROOF STEP]
have minus1: "-1 \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>"
[PROOF STATE]
proof (prove)
using this:
inv\<^bsub>int_group\<^esub> 1 \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>
- 1 = inv\<^bsub>int_group\<^esub> 1

goal (1 subgoal):
 1. - 1 \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>
[PROOF STEP]
by (simp)
[PROOF STATE]
proof (state)
this:
- 1 \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>

goal (1 subgoal):
 1. \<And>x. x \<in> carrier int_group \<Longrightarrow> x \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>
[PROOF STEP]
show "x \<in> \<langle>{1::int}\<rangle>\<^bsub>int_group\<^esub>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>
[PROOF STEP]
(*
    It does not work directly, unfortunately:
    apply(induct x rule:int_induct[of _ "0::int"])
    apply (auto simp add: int_arith_rules intro:gen_span.intros[of int_group])
    *)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>
[PROOF STEP]
proof(induct x rule:int_induct[of _ "0::int"])
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. 0 \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>
 2. \<And>i. \<lbrakk>0 \<le> i; i \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>\<rbrakk> \<Longrightarrow> i + 1 \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>
 3. \<And>i. \<lbrakk>i \<le> 0; i \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>\<rbrakk> \<Longrightarrow> i - 1 \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>
[PROOF STEP]
case base
[PROOF STATE]
proof (state)
this:

goal (3 subgoals):
 1. 0 \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>
 2. \<And>i. \<lbrakk>0 \<le> i; i \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>\<rbrakk> \<Longrightarrow> i + 1 \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>
 3. \<And>i. \<lbrakk>i \<le> 0; i \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>\<rbrakk> \<Longrightarrow> i - 1 \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>
[PROOF STEP]
have "\<one>\<^bsub>int_group\<^esub> \<in> \<langle>{1::int}\<rangle>\<^bsub>int_group\<^esub>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<one>\<^bsub>int_group\<^esub> \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>
[PROOF STEP]
by (rule gen_span.gen_one)
[PROOF STATE]
proof (state)
this:
\<one>\<^bsub>int_group\<^esub> \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>

goal (3 subgoals):
 1. 0 \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>
 2. \<And>i. \<lbrakk>0 \<le> i; i \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>\<rbrakk> \<Longrightarrow> i + 1 \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>
 3. \<And>i. \<lbrakk>i \<le> 0; i \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>\<rbrakk> \<Longrightarrow> i - 1 \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>
[PROOF STEP]
thus"0 \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>"
[PROOF STATE]
proof (prove)
using this:
\<one>\<^bsub>int_group\<^esub> \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>

goal (1 subgoal):
 1. 0 \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
0 \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>

goal (2 subgoals):
 1. \<And>i. \<lbrakk>0 \<le> i; i \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>\<rbrakk> \<Longrightarrow> i + 1 \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>
 2. \<And>i. \<lbrakk>i \<le> 0; i \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>\<rbrakk> \<Longrightarrow> i - 1 \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>i. \<lbrakk>0 \<le> i; i \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>\<rbrakk> \<Longrightarrow> i + 1 \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>
 2. \<And>i. \<lbrakk>i \<le> 0; i \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>\<rbrakk> \<Longrightarrow> i - 1 \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>
[PROOF STEP]
case (step1 i)
[PROOF STATE]
proof (state)
this:
0 \<le> i
i \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>

goal (2 subgoals):
 1. \<And>i. \<lbrakk>0 \<le> i; i \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>\<rbrakk> \<Longrightarrow> i + 1 \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>
 2. \<And>i. \<lbrakk>i \<le> 0; i \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>\<rbrakk> \<Longrightarrow> i - 1 \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>
[PROOF STEP]
from \<open>i \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>\<close> and plus1
[PROOF STATE]
proof (chain)
picking this:
i \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>
1 \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>
[PROOF STEP]
have "i \<otimes>\<^bsub>int_group\<^esub> 1 \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>"
[PROOF STATE]
proof (prove)
using this:
i \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>
1 \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>

goal (1 subgoal):
 1. i \<otimes>\<^bsub>int_group\<^esub> 1 \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>
[PROOF STEP]
by (rule gen_span.gen_mult)
[PROOF STATE]
proof (state)
this:
i \<otimes>\<^bsub>int_group\<^esub> 1 \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>

goal (2 subgoals):
 1. \<And>i. \<lbrakk>0 \<le> i; i \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>\<rbrakk> \<Longrightarrow> i + 1 \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>
 2. \<And>i. \<lbrakk>i \<le> 0; i \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>\<rbrakk> \<Longrightarrow> i - 1 \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>
[PROOF STEP]
thus "i + 1 \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>"
[PROOF STATE]
proof (prove)
using this:
i \<otimes>\<^bsub>int_group\<^esub> 1 \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>

goal (1 subgoal):
 1. i + 1 \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
i + 1 \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>

goal (1 subgoal):
 1. \<And>i. \<lbrakk>i \<le> 0; i \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>\<rbrakk> \<Longrightarrow> i - 1 \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i. \<lbrakk>i \<le> 0; i \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>\<rbrakk> \<Longrightarrow> i - 1 \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>
[PROOF STEP]
case (step2 i)
[PROOF STATE]
proof (state)
this:
i \<le> 0
i \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>

goal (1 subgoal):
 1. \<And>i. \<lbrakk>i \<le> 0; i \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>\<rbrakk> \<Longrightarrow> i - 1 \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>
[PROOF STEP]
from \<open>i \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>\<close> and minus1
[PROOF STATE]
proof (chain)
picking this:
i \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>
- 1 \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>
[PROOF STEP]
have "i \<otimes>\<^bsub>int_group\<^esub> -1 \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>"
[PROOF STATE]
proof (prove)
using this:
i \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>
- 1 \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>

goal (1 subgoal):
 1. i \<otimes>\<^bsub>int_group\<^esub> - 1 \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>
[PROOF STEP]
by (rule gen_span.gen_mult)
[PROOF STATE]
proof (state)
this:
i \<otimes>\<^bsub>int_group\<^esub> - 1 \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>

goal (1 subgoal):
 1. \<And>i. \<lbrakk>i \<le> 0; i \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>\<rbrakk> \<Longrightarrow> i - 1 \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>
[PROOF STEP]
thus "i - 1 \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>"
[PROOF STATE]
proof (prove)
using this:
i \<otimes>\<^bsub>int_group\<^esub> - 1 \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>

goal (1 subgoal):
 1. i - 1 \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
i - 1 \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
x \<in> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
carrier int_group \<subseteq> \<langle>{1}\<rangle>\<^bsub>int_group\<^esub>

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma matrix_construction_is_kronecker_product:
  fixes qs1 :: "real poly list"
  fixes subs1 subs2 :: "nat list list"
  fixes signs1 signs2 :: "rat list list"
    (* n1 is the number of polynomials in the "1" sets *)
  assumes "\<And>l i. l \<in> set subs1 \<Longrightarrow> i \<in> set l \<Longrightarrow> i < n1"
  assumes "\<And>j. j \<in> set signs1 \<Longrightarrow> length j = n1"
  shows "
    (matrix_A (signs_smash signs1 signs2) (subsets_smash n1 subs1 subs2)) =
    kronecker_product (matrix_A signs1 subs1) (matrix_A signs2 subs2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. M_mat (signs_smash signs1 signs2) (subsets_smash n1 subs1 subs2) = kronecker_product (M_mat signs1 subs1) (M_mat signs2 subs2)
[PROOF STEP]
unfolding mat_eq_iff dim_row_matrix_A dim_col_matrix_A
    length_subsets_smash length_signs_smash dim_kronecker
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length subs1 * length subs2 = length subs1 * length subs2 \<and> length signs1 * length signs2 = length signs1 * length signs2 \<and> (\<forall>i j. i < length subs1 * length subs2 \<longrightarrow> j < length signs1 * length signs2 \<longrightarrow> M_mat (signs_smash signs1 signs2) (subsets_smash n1 subs1 subs2) $$ (i, j) = kronecker_product (M_mat signs1 subs1) (M_mat signs2 subs2) $$ (i, j))
[PROOF STEP]
proof safe
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < length subs1 * length subs2; j < length signs1 * length signs2\<rbrakk> \<Longrightarrow> M_mat (signs_smash signs1 signs2) (subsets_smash n1 subs1 subs2) $$ (i, j) = kronecker_product (M_mat signs1 subs1) (M_mat signs2 subs2) $$ (i, j)
[PROOF STEP]
fix i j
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < length subs1 * length subs2; j < length signs1 * length signs2\<rbrakk> \<Longrightarrow> M_mat (signs_smash signs1 signs2) (subsets_smash n1 subs1 subs2) $$ (i, j) = kronecker_product (M_mat signs1 subs1) (M_mat signs2 subs2) $$ (i, j)
[PROOF STEP]
assume i: "i < length subs1 * length subs2"
     and j: "j < length signs1 * length signs2"
[PROOF STATE]
proof (state)
this:
i < length subs1 * length subs2
j < length signs1 * length signs2

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < length subs1 * length subs2; j < length signs1 * length signs2\<rbrakk> \<Longrightarrow> M_mat (signs_smash signs1 signs2) (subsets_smash n1 subs1 subs2) $$ (i, j) = kronecker_product (M_mat signs1 subs1) (M_mat signs2 subs2) $$ (i, j)
[PROOF STEP]
have ld: "i div length subs2 < length subs1"
    "j div length signs2 < length signs1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. i div length subs2 < length subs1 &&& j div length signs2 < length signs1
[PROOF STEP]
using i j less_mult_imp_div_less
[PROOF STATE]
proof (prove)
using this:
i < length subs1 * length subs2
j < length signs1 * length signs2
?m < ?i * ?n \<Longrightarrow> ?m div ?n < ?i

goal (1 subgoal):
 1. i div length subs2 < length subs1 &&& j div length signs2 < length signs1
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
i div length subs2 < length subs1
j div length signs2 < length signs1

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < length subs1 * length subs2; j < length signs1 * length signs2\<rbrakk> \<Longrightarrow> M_mat (signs_smash signs1 signs2) (subsets_smash n1 subs1 subs2) $$ (i, j) = kronecker_product (M_mat signs1 subs1) (M_mat signs2 subs2) $$ (i, j)
[PROOF STEP]
have lm: "i mod length subs2 < length subs2"
    "j mod length signs2 < length signs2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. i mod length subs2 < length subs2 &&& j mod length signs2 < length signs2
[PROOF STEP]
using i j less_mult_imp_mod_less
[PROOF STATE]
proof (prove)
using this:
i < length subs1 * length subs2
j < length signs1 * length signs2
?m < ?n * ?i \<Longrightarrow> ?m mod ?i < ?i

goal (1 subgoal):
 1. i mod length subs2 < length subs2 &&& j mod length signs2 < length signs2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
i mod length subs2 < length subs2
j mod length signs2 < length signs2

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < length subs1 * length subs2; j < length signs1 * length signs2\<rbrakk> \<Longrightarrow> M_mat (signs_smash signs1 signs2) (subsets_smash n1 subs1 subs2) $$ (i, j) = kronecker_product (M_mat signs1 subs1) (M_mat signs2 subs2) $$ (i, j)
[PROOF STEP]
have n1: "n1 = length (signs1 ! (j div length signs2))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n1 = length (signs1 ! (j div length signs2))
[PROOF STEP]
using assms(2) ld(2) nth_mem
[PROOF STATE]
proof (prove)
using this:
?j \<in> set signs1 \<Longrightarrow> length ?j = n1
j div length signs2 < length signs1
?n < length ?xs \<Longrightarrow> ?xs ! ?n \<in> set ?xs

goal (1 subgoal):
 1. n1 = length (signs1 ! (j div length signs2))
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
n1 = length (signs1 ! (j div length signs2))

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < length subs1 * length subs2; j < length signs1 * length signs2\<rbrakk> \<Longrightarrow> M_mat (signs_smash signs1 signs2) (subsets_smash n1 subs1 subs2) $$ (i, j) = kronecker_product (M_mat signs1 subs1) (M_mat signs2 subs2) $$ (i, j)
[PROOF STEP]
have 1: "matrix_A (signs_smash signs1 signs2) (subsets_smash n1 subs1 subs2) $$ (i, j) =
    z (subsets_smash n1 subs1 subs2 ! i) (signs_smash signs1 signs2 ! j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. M_mat (signs_smash signs1 signs2) (subsets_smash n1 subs1 subs2) $$ (i, j) = z (subsets_smash n1 subs1 subs2 ! i) (signs_smash signs1 signs2 ! j)
[PROOF STEP]
unfolding mat_of_rows_list_def matrix_A_def mtx_row_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mat (length (map (\<lambda>index_list. map (z index_list) (signs_smash signs1 signs2)) (subsets_smash n1 subs1 subs2))) (length (signs_smash signs1 signs2)) (\<lambda>(i, y). map (\<lambda>index_list. map (z index_list) (signs_smash signs1 signs2)) (subsets_smash n1 subs1 subs2) ! i ! y) $$ (i, j) = z (subsets_smash n1 subs1 subs2 ! i) (signs_smash signs1 signs2 ! j)
[PROOF STEP]
using i j
[PROOF STATE]
proof (prove)
using this:
i < length subs1 * length subs2
j < length signs1 * length signs2

goal (1 subgoal):
 1. mat (length (map (\<lambda>index_list. map (z index_list) (signs_smash signs1 signs2)) (subsets_smash n1 subs1 subs2))) (length (signs_smash signs1 signs2)) (\<lambda>(i, y). map (\<lambda>index_list. map (z index_list) (signs_smash signs1 signs2)) (subsets_smash n1 subs1 subs2) ! i ! y) $$ (i, j) = z (subsets_smash n1 subs1 subs2 ! i) (signs_smash signs1 signs2 ! j)
[PROOF STEP]
by (simp add: length_signs_smash length_subsets_smash)
[PROOF STATE]
proof (state)
this:
M_mat (signs_smash signs1 signs2) (subsets_smash n1 subs1 subs2) $$ (i, j) = z (subsets_smash n1 subs1 subs2 ! i) (signs_smash signs1 signs2 ! j)

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < length subs1 * length subs2; j < length signs1 * length signs2\<rbrakk> \<Longrightarrow> M_mat (signs_smash signs1 signs2) (subsets_smash n1 subs1 subs2) $$ (i, j) = kronecker_product (M_mat signs1 subs1) (M_mat signs2 subs2) $$ (i, j)
[PROOF STEP]
have 2: " ... = z (subs1 ! (i div length subs2) @ map ((+) n1) (subs2 ! (i mod length subs2)))
     (signs1 ! (j div length signs2) @ signs2 ! (j mod length signs2))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. z (subsets_smash n1 subs1 subs2 ! i) (signs_smash signs1 signs2 ! j) = z (subs1 ! (i div length subs2) @ map ((+) n1) (subs2 ! (i mod length subs2))) (signs1 ! (j div length signs2) @ signs2 ! (j mod length signs2))
[PROOF STEP]
unfolding signs_smash_def subsets_smash_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. z (concat (map (\<lambda>l1. map (\<lambda>l2. l1 @ map ((+) n1) l2) subs2) subs1) ! i) (concat (map (\<lambda>l1. map ((@) l1) signs2) signs1) ! j) = z (subs1 ! (i div length subs2) @ map ((+) n1) (subs2 ! (i mod length subs2))) (signs1 ! (j div length signs2) @ signs2 ! (j mod length signs2))
[PROOF STEP]
apply (subst length_eq_concat)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. \<And>x. x \<in> set (map (\<lambda>l1. map (\<lambda>l2. l1 @ map ((+) n1) l2) subs2) subs1) \<Longrightarrow> length x = ?n
 2. i < ?n * length (map (\<lambda>l1. map (\<lambda>l2. l1 @ map ((+) n1) l2) subs2) subs1)
 3. z (map (\<lambda>l1. map (\<lambda>l2. l1 @ map ((+) n1) l2) subs2) subs1 ! (i div ?n) ! (i mod ?n)) (concat (map (\<lambda>l1. map ((@) l1) signs2) signs1) ! j) = z (subs1 ! (i div length subs2) @ map ((+) n1) (subs2 ! (i mod length subs2))) (signs1 ! (j div length signs2) @ signs2 ! (j mod length signs2))
[PROOF STEP]
using i
[PROOF STATE]
proof (prove)
using this:
i < length subs1 * length subs2

goal (3 subgoals):
 1. \<And>x. x \<in> set (map (\<lambda>l1. map (\<lambda>l2. l1 @ map ((+) n1) l2) subs2) subs1) \<Longrightarrow> length x = ?n
 2. i < ?n * length (map (\<lambda>l1. map (\<lambda>l2. l1 @ map ((+) n1) l2) subs2) subs1)
 3. z (map (\<lambda>l1. map (\<lambda>l2. l1 @ map ((+) n1) l2) subs2) subs1 ! (i div ?n) ! (i mod ?n)) (concat (map (\<lambda>l1. map ((@) l1) signs2) signs1) ! j) = z (subs1 ! (i div length subs2) @ map ((+) n1) (subs2 ! (i mod length subs2))) (signs1 ! (j div length signs2) @ signs2 ! (j mod length signs2))
[PROOF STEP]
apply (auto simp add: mult.commute)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. i < length subs1 * length subs2 \<Longrightarrow> z (map (\<lambda>l1. map (\<lambda>l2. l1 @ map ((+) n1) l2) subs2) subs1 ! (i div length subs2) ! (i mod length subs2)) (concat (map (\<lambda>l1. map ((@) l1) signs2) signs1) ! j) = z (subs1 ! (i div length subs2) @ map ((+) n1) (subs2 ! (i mod length subs2))) (signs1 ! (j div length signs2) @ signs2 ! (j mod length signs2))
[PROOF STEP]
apply (subst length_eq_concat)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. \<And>x. \<lbrakk>i < length subs1 * length subs2; x \<in> set (map (\<lambda>l1. map ((@) l1) signs2) signs1)\<rbrakk> \<Longrightarrow> length x = ?n11
 2. i < length subs1 * length subs2 \<Longrightarrow> j < ?n11 * length (map (\<lambda>l1. map ((@) l1) signs2) signs1)
 3. i < length subs1 * length subs2 \<Longrightarrow> z (map (\<lambda>l1. map (\<lambda>l2. l1 @ map ((+) n1) l2) subs2) subs1 ! (i div length subs2) ! (i mod length subs2)) (map (\<lambda>l1. map ((@) l1) signs2) signs1 ! (j div ?n11) ! (j mod ?n11)) = z (subs1 ! (i div length subs2) @ map ((+) n1) (subs2 ! (i mod length subs2))) (signs1 ! (j div length signs2) @ signs2 ! (j mod length signs2))
[PROOF STEP]
using j
[PROOF STATE]
proof (prove)
using this:
j < length signs1 * length signs2

goal (3 subgoals):
 1. \<And>x. \<lbrakk>i < length subs1 * length subs2; x \<in> set (map (\<lambda>l1. map ((@) l1) signs2) signs1)\<rbrakk> \<Longrightarrow> length x = ?n11
 2. i < length subs1 * length subs2 \<Longrightarrow> j < ?n11 * length (map (\<lambda>l1. map ((@) l1) signs2) signs1)
 3. i < length subs1 * length subs2 \<Longrightarrow> z (map (\<lambda>l1. map (\<lambda>l2. l1 @ map ((+) n1) l2) subs2) subs1 ! (i div length subs2) ! (i mod length subs2)) (map (\<lambda>l1. map ((@) l1) signs2) signs1 ! (j div ?n11) ! (j mod ?n11)) = z (subs1 ! (i div length subs2) @ map ((+) n1) (subs2 ! (i mod length subs2))) (signs1 ! (j div length signs2) @ signs2 ! (j mod length signs2))
[PROOF STEP]
apply (auto simp add: mult.commute)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>i < length subs1 * length subs2; j < length signs1 * length signs2\<rbrakk> \<Longrightarrow> z (map (\<lambda>l1. map (\<lambda>l2. l1 @ map ((+) n1) l2) subs2) subs1 ! (i div length subs2) ! (i mod length subs2)) (map (\<lambda>l1. map ((@) l1) signs2) signs1 ! (j div length signs2) ! (j mod length signs2)) = z (subs1 ! (i div length subs2) @ map ((+) n1) (subs2 ! (i mod length subs2))) (signs1 ! (j div length signs2) @ signs2 ! (j mod length signs2))
[PROOF STEP]
using ld lm
[PROOF STATE]
proof (prove)
using this:
i div length subs2 < length subs1
j div length signs2 < length signs1
i mod length subs2 < length subs2
j mod length signs2 < length signs2

goal (1 subgoal):
 1. \<lbrakk>i < length subs1 * length subs2; j < length signs1 * length signs2\<rbrakk> \<Longrightarrow> z (map (\<lambda>l1. map (\<lambda>l2. l1 @ map ((+) n1) l2) subs2) subs1 ! (i div length subs2) ! (i mod length subs2)) (map (\<lambda>l1. map ((@) l1) signs2) signs1 ! (j div length signs2) ! (j mod length signs2)) = z (subs1 ! (i div length subs2) @ map ((+) n1) (subs2 ! (i mod length subs2))) (signs1 ! (j div length signs2) @ signs2 ! (j mod length signs2))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
z (subsets_smash n1 subs1 subs2 ! i) (signs_smash signs1 signs2 ! j) = z (subs1 ! (i div length subs2) @ map ((+) n1) (subs2 ! (i mod length subs2))) (signs1 ! (j div length signs2) @ signs2 ! (j mod length signs2))

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < length subs1 * length subs2; j < length signs1 * length signs2\<rbrakk> \<Longrightarrow> M_mat (signs_smash signs1 signs2) (subsets_smash n1 subs1 subs2) $$ (i, j) = kronecker_product (M_mat signs1 subs1) (M_mat signs2 subs2) $$ (i, j)
[PROOF STEP]
have 3: "... =
  z (subs1 ! (i div length subs2)) (signs1 ! (j div length signs2)) *
  z (subs2 ! (i mod length subs2)) (signs2 ! (j mod length signs2))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. z (subs1 ! (i div length subs2) @ map ((+) n1) (subs2 ! (i mod length subs2))) (signs1 ! (j div length signs2) @ signs2 ! (j mod length signs2)) = z (subs1 ! (i div length subs2)) (signs1 ! (j div length signs2)) * z (subs2 ! (i mod length subs2)) (signs2 ! (j mod length signs2))
[PROOF STEP]
unfolding n1
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. z (subs1 ! (i div length subs2) @ map ((+) (length (signs1 ! (j div length signs2)))) (subs2 ! (i mod length subs2))) (signs1 ! (j div length signs2) @ signs2 ! (j mod length signs2)) = z (subs1 ! (i div length subs2)) (signs1 ! (j div length signs2)) * z (subs2 ! (i mod length subs2)) (signs2 ! (j mod length signs2))
[PROOF STEP]
apply (subst z_append)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>ia. ia \<in> set (subs1 ! (i div length subs2)) \<Longrightarrow> ia < length (signs1 ! (j div length signs2))
 2. z (subs1 ! (i div length subs2)) (signs1 ! (j div length signs2)) * z (subs2 ! (i mod length subs2)) (signs2 ! (j mod length signs2)) = z (subs1 ! (i div length subs2)) (signs1 ! (j div length signs2)) * z (subs2 ! (i mod length subs2)) (signs2 ! (j mod length signs2))
[PROOF STEP]
apply (auto simp add: n1[symmetric])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>ia. ia \<in> set (subs1 ! (i div length subs2)) \<Longrightarrow> ia < n1
[PROOF STEP]
using assms(1) ld(1) nth_mem
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?l \<in> set subs1; ?i \<in> set ?l\<rbrakk> \<Longrightarrow> ?i < n1
i div length subs2 < length subs1
?n < length ?xs \<Longrightarrow> ?xs ! ?n \<in> set ?xs

goal (1 subgoal):
 1. \<And>ia. ia \<in> set (subs1 ! (i div length subs2)) \<Longrightarrow> ia < n1
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
z (subs1 ! (i div length subs2) @ map ((+) n1) (subs2 ! (i mod length subs2))) (signs1 ! (j div length signs2) @ signs2 ! (j mod length signs2)) = z (subs1 ! (i div length subs2)) (signs1 ! (j div length signs2)) * z (subs2 ! (i mod length subs2)) (signs2 ! (j mod length signs2))

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < length subs1 * length subs2; j < length signs1 * length signs2\<rbrakk> \<Longrightarrow> M_mat (signs_smash signs1 signs2) (subsets_smash n1 subs1 subs2) $$ (i, j) = kronecker_product (M_mat signs1 subs1) (M_mat signs2 subs2) $$ (i, j)
[PROOF STEP]
have 4: "kronecker_product (matrix_A signs1 subs1) (matrix_A signs2 subs2) $$ (i,j) =
    z (subs1 ! (i div length subs2))
     (signs1 ! (j div length signs2)) *
    z (subs2 ! (i mod length subs2))
     (signs2 ! (j mod length signs2))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. kronecker_product (M_mat signs1 subs1) (M_mat signs2 subs2) $$ (i, j) = z (subs1 ! (i div length subs2)) (signs1 ! (j div length signs2)) * z (subs2 ! (i mod length subs2)) (signs2 ! (j mod length signs2))
[PROOF STEP]
unfolding kronecker_product_def matrix_A_def mat_of_rows_list_def mtx_row_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (let ra = dim_row (mat (length (map (\<lambda>index_list. map (z index_list) signs1) subs1)) (length signs1) (\<lambda>(i, y). map (\<lambda>index_list. map (z index_list) signs1) subs1 ! i ! y)); ca = dim_col (mat (length (map (\<lambda>index_list. map (z index_list) signs1) subs1)) (length signs1) (\<lambda>(i, y). map (\<lambda>index_list. map (z index_list) signs1) subs1 ! i ! y)); rb = dim_row (mat (length (map (\<lambda>index_list. map (z index_list) signs2) subs2)) (length signs2) (\<lambda>(i, y). map (\<lambda>index_list. map (z index_list) signs2) subs2 ! i ! y)); cb = dim_col (mat (length (map (\<lambda>index_list. map (z index_list) signs2) subs2)) (length signs2) (\<lambda>(i, y). map (\<lambda>index_list. map (z index_list) signs2) subs2 ! i ! y)) in mat (ra * rb) (ca * cb) (\<lambda>(i, j). mat (length (map (\<lambda>index_list. map (z index_list) signs1) subs1)) (length signs1) (\<lambda>(i, y). map (\<lambda>index_list. map (z index_list) signs1) subs1 ! i ! y) $$ (i div rb, j div cb) * mat (length (map (\<lambda>index_list. map (z index_list) signs2) subs2)) (length signs2) (\<lambda>(i, y). map (\<lambda>index_list. map (z index_list) signs2) subs2 ! i ! y) $$ (i mod rb, j mod cb))) $$ (i, j) = z (subs1 ! (i div length subs2)) (signs1 ! (j div length signs2)) * z (subs2 ! (i mod length subs2)) (signs2 ! (j mod length signs2))
[PROOF STEP]
using i j
[PROOF STATE]
proof (prove)
using this:
i < length subs1 * length subs2
j < length signs1 * length signs2

goal (1 subgoal):
 1. (let ra = dim_row (mat (length (map (\<lambda>index_list. map (z index_list) signs1) subs1)) (length signs1) (\<lambda>(i, y). map (\<lambda>index_list. map (z index_list) signs1) subs1 ! i ! y)); ca = dim_col (mat (length (map (\<lambda>index_list. map (z index_list) signs1) subs1)) (length signs1) (\<lambda>(i, y). map (\<lambda>index_list. map (z index_list) signs1) subs1 ! i ! y)); rb = dim_row (mat (length (map (\<lambda>index_list. map (z index_list) signs2) subs2)) (length signs2) (\<lambda>(i, y). map (\<lambda>index_list. map (z index_list) signs2) subs2 ! i ! y)); cb = dim_col (mat (length (map (\<lambda>index_list. map (z index_list) signs2) subs2)) (length signs2) (\<lambda>(i, y). map (\<lambda>index_list. map (z index_list) signs2) subs2 ! i ! y)) in mat (ra * rb) (ca * cb) (\<lambda>(i, j). mat (length (map (\<lambda>index_list. map (z index_list) signs1) subs1)) (length signs1) (\<lambda>(i, y). map (\<lambda>index_list. map (z index_list) signs1) subs1 ! i ! y) $$ (i div rb, j div cb) * mat (length (map (\<lambda>index_list. map (z index_list) signs2) subs2)) (length signs2) (\<lambda>(i, y). map (\<lambda>index_list. map (z index_list) signs2) subs2 ! i ! y) $$ (i mod rb, j mod cb))) $$ (i, j) = z (subs1 ! (i div length subs2)) (signs1 ! (j div length signs2)) * z (subs2 ! (i mod length subs2)) (signs2 ! (j mod length signs2))
[PROOF STEP]
apply (auto simp add: Let_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>i < length subs1 * length subs2; j < length signs1 * length signs2\<rbrakk> \<Longrightarrow> mat (length subs1) (length signs1) (\<lambda>(i, y). map (\<lambda>index_list. map (z index_list) signs1) subs1 ! i ! y) $$ (i div length subs2, j div length signs2) * mat (length subs2) (length signs2) (\<lambda>(i, y). map (\<lambda>index_list. map (z index_list) signs2) subs2 ! i ! y) $$ (i mod length subs2, j mod length signs2) = z (subs1 ! (i div length subs2)) (signs1 ! (j div length signs2)) * z (subs2 ! (i mod length subs2)) (signs2 ! (j mod length signs2))
[PROOF STEP]
apply (subst index_mat(1)[OF ld])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>i < length subs1 * length subs2; j < length signs1 * length signs2\<rbrakk> \<Longrightarrow> (case (i div length subs2, j div length signs2) of (i, x) \<Rightarrow> map (\<lambda>index_list. map (z index_list) signs1) subs1 ! i ! x) * mat (length subs2) (length signs2) (\<lambda>(i, y). map (\<lambda>index_list. map (z index_list) signs2) subs2 ! i ! y) $$ (i mod length subs2, j mod length signs2) = z (subs1 ! (i div length subs2)) (signs1 ! (j div length signs2)) * z (subs2 ! (i mod length subs2)) (signs2 ! (j mod length signs2))
[PROOF STEP]
apply (subst index_mat(1)[OF lm])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>i < length subs1 * length subs2; j < length signs1 * length signs2\<rbrakk> \<Longrightarrow> (case (i div length subs2, j div length signs2) of (i, x) \<Rightarrow> map (\<lambda>index_list. map (z index_list) signs1) subs1 ! i ! x) * (case (i mod length subs2, j mod length signs2) of (i, x) \<Rightarrow> map (\<lambda>index_list. map (z index_list) signs2) subs2 ! i ! x) = z (subs1 ! (i div length subs2)) (signs1 ! (j div length signs2)) * z (subs2 ! (i mod length subs2)) (signs2 ! (j mod length signs2))
[PROOF STEP]
using ld lm
[PROOF STATE]
proof (prove)
using this:
i div length subs2 < length subs1
j div length signs2 < length signs1
i mod length subs2 < length subs2
j mod length signs2 < length signs2

goal (1 subgoal):
 1. \<lbrakk>i < length subs1 * length subs2; j < length signs1 * length signs2\<rbrakk> \<Longrightarrow> (case (i div length subs2, j div length signs2) of (i, x) \<Rightarrow> map (\<lambda>index_list. map (z index_list) signs1) subs1 ! i ! x) * (case (i mod length subs2, j mod length signs2) of (i, x) \<Rightarrow> map (\<lambda>index_list. map (z index_list) signs2) subs2 ! i ! x) = z (subs1 ! (i div length subs2)) (signs1 ! (j div length signs2)) * z (subs2 ! (i mod length subs2)) (signs2 ! (j mod length signs2))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
kronecker_product (M_mat signs1 subs1) (M_mat signs2 subs2) $$ (i, j) = z (subs1 ! (i div length subs2)) (signs1 ! (j div length signs2)) * z (subs2 ! (i mod length subs2)) (signs2 ! (j mod length signs2))

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < length subs1 * length subs2; j < length signs1 * length signs2\<rbrakk> \<Longrightarrow> M_mat (signs_smash signs1 signs2) (subsets_smash n1 subs1 subs2) $$ (i, j) = kronecker_product (M_mat signs1 subs1) (M_mat signs2 subs2) $$ (i, j)
[PROOF STEP]
show "matrix_A (signs_smash signs1 signs2) (subsets_smash n1 subs1 subs2) $$ (i, j) =
        kronecker_product (matrix_A signs1 subs1) (matrix_A signs2 subs2) $$ (i, j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. M_mat (signs_smash signs1 signs2) (subsets_smash n1 subs1 subs2) $$ (i, j) = kronecker_product (M_mat signs1 subs1) (M_mat signs2 subs2) $$ (i, j)
[PROOF STEP]
using 1 2 3 4
[PROOF STATE]
proof (prove)
using this:
M_mat (signs_smash signs1 signs2) (subsets_smash n1 subs1 subs2) $$ (i, j) = z (subsets_smash n1 subs1 subs2 ! i) (signs_smash signs1 signs2 ! j)
z (subsets_smash n1 subs1 subs2 ! i) (signs_smash signs1 signs2 ! j) = z (subs1 ! (i div length subs2) @ map ((+) n1) (subs2 ! (i mod length subs2))) (signs1 ! (j div length signs2) @ signs2 ! (j mod length signs2))
z (subs1 ! (i div length subs2) @ map ((+) n1) (subs2 ! (i mod length subs2))) (signs1 ! (j div length signs2) @ signs2 ! (j mod length signs2)) = z (subs1 ! (i div length subs2)) (signs1 ! (j div length signs2)) * z (subs2 ! (i mod length subs2)) (signs2 ! (j mod length signs2))
kronecker_product (M_mat signs1 subs1) (M_mat signs2 subs2) $$ (i, j) = z (subs1 ! (i div length subs2)) (signs1 ! (j div length signs2)) * z (subs2 ! (i mod length subs2)) (signs2 ! (j mod length signs2))

goal (1 subgoal):
 1. M_mat (signs_smash signs1 signs2) (subsets_smash n1 subs1 subs2) $$ (i, j) = kronecker_product (M_mat signs1 subs1) (M_mat signs2 subs2) $$ (i, j)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
M_mat (signs_smash signs1 signs2) (subsets_smash n1 subs1 subs2) $$ (i, j) = kronecker_product (M_mat signs1 subs1) (M_mat signs2 subs2) $$ (i, j)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma split_sum_mid_less: assumes "i<(n::nat)"
  shows "(\<Sum>j<n. f j) = (\<Sum>j<i. f j) + (\<Sum>j=i..<n. f j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum f {..<n} = sum f {..<i} + sum f {i..<n}
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. sum f {..<n} = sum f {..<i} + sum f {i..<n}
[PROOF STEP]
have "(\<Sum>j<n. f j) = (\<Sum>j\<in>{..<i} \<union> {i..<n}. f j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum f {..<n} = sum f ({..<i} \<union> {i..<n})
[PROOF STEP]
using \<open>i < n\<close>
[PROOF STATE]
proof (prove)
using this:
i < n

goal (1 subgoal):
 1. sum f {..<n} = sum f ({..<i} \<union> {i..<n})
[PROOF STEP]
by (intro sum.cong) auto
[PROOF STATE]
proof (state)
this:
sum f {..<n} = sum f ({..<i} \<union> {i..<n})

goal (1 subgoal):
 1. sum f {..<n} = sum f {..<i} + sum f {i..<n}
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
sum f {..<n} = sum f ({..<i} \<union> {i..<n})

goal (1 subgoal):
 1. sum f {..<n} = sum f {..<i} + sum f {i..<n}
[PROOF STEP]
have "\<dots> = (\<Sum>j<i. f j) + (\<Sum>j=i..<n. f j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum f ({..<i} \<union> {i..<n}) = sum f {..<i} + sum f {i..<n}
[PROOF STEP]
by (subst sum.union_disjoint) auto
[PROOF STATE]
proof (state)
this:
sum f ({..<i} \<union> {i..<n}) = sum f {..<i} + sum f {i..<n}

goal (1 subgoal):
 1. sum f {..<n} = sum f {..<i} + sum f {i..<n}
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
sum f {..<n} = sum f {..<i} + sum f {i..<n}
[PROOF STEP]
show "(\<Sum>j<n. f j) = (\<Sum>j<i. f j) + (\<Sum>j=i..<n. f j)"
[PROOF STATE]
proof (prove)
using this:
sum f {..<n} = sum f {..<i} + sum f {i..<n}

goal (1 subgoal):
 1. sum f {..<n} = sum f {..<i} + sum f {i..<n}
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
sum f {..<n} = sum f {..<i} + sum f {i..<n}

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma bw_diff_gbinomial:
  assumes "0 < k"
  shows "bw_diff (\<lambda>x::int. (x + n) gchoose k) = (\<lambda>x. (x + n - 1) gchoose (k - 1))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bw_diff (\<lambda>x. x + n gchoose k) = (\<lambda>x. x + n - 1 gchoose (k - 1))
[PROOF STEP]
proof (rule ext)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. bw_diff (\<lambda>x. x + n gchoose k) x = x + n - 1 gchoose (k - 1)
[PROOF STEP]
fix x::int
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. bw_diff (\<lambda>x. x + n gchoose k) x = x + n - 1 gchoose (k - 1)
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
0 < k
[PROOF STEP]
have eq: "Suc (k - Suc 0) = k"
[PROOF STATE]
proof (prove)
using this:
0 < k

goal (1 subgoal):
 1. Suc (k - Suc 0) = k
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
Suc (k - Suc 0) = k

goal (1 subgoal):
 1. \<And>x. bw_diff (\<lambda>x. x + n gchoose k) x = x + n - 1 gchoose (k - 1)
[PROOF STEP]
have "x + n gchoose k = (x + n - 1) + 1 gchoose (Suc (k - 1))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x + n gchoose k = x + n - 1 + 1 gchoose Suc (k - 1)
[PROOF STEP]
by (simp add: eq)
[PROOF STATE]
proof (state)
this:
x + n gchoose k = x + n - 1 + 1 gchoose Suc (k - 1)

goal (1 subgoal):
 1. \<And>x. bw_diff (\<lambda>x. x + n gchoose k) x = x + n - 1 gchoose (k - 1)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
x + n gchoose k = x + n - 1 + 1 gchoose Suc (k - 1)

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

goal (1 subgoal):
 1. \<And>x. bw_diff (\<lambda>x. x + n gchoose k) x = x + n - 1 gchoose (k - 1)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
x + n gchoose k = x + n - 1 gchoose (k - 1) + (x + n - 1 gchoose Suc (k - 1))
[PROOF STEP]
show "bw_diff (\<lambda>x. x + n gchoose k) x = x + n - 1 gchoose (k - 1)"
[PROOF STATE]
proof (prove)
using this:
x + n gchoose k = x + n - 1 gchoose (k - 1) + (x + n - 1 gchoose Suc (k - 1))

goal (1 subgoal):
 1. bw_diff (\<lambda>x. x + n gchoose k) x = x + n - 1 gchoose (k - 1)
[PROOF STEP]
by (simp add: eq bw_diff_def algebra_simps)
[PROOF STATE]
proof (state)
this:
bw_diff (\<lambda>x. x + n gchoose k) x = x + n - 1 gchoose (k - 1)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma " ((a::int) + b + c) ^ 2 = a ^ 2 + b ^ 2 + c ^ 2 + 2 * a * b + 2 * b * c + 2 * a * c"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (a + b + c)\<^sup>2 = a\<^sup>2 + b\<^sup>2 + c\<^sup>2 + 2 * a * b + 2 * b * c + 2 * a * c
[PROOF STEP]
by ring


[STATEMENT]
lemma fix_ind_k:
  fixes k::nat
  assumes adm: "adm P"
  assumes base_k_steps: "\<forall>i<k. P (iterate i\<cdot>f\<cdot>\<bottom>)"
  assumes step: "\<And>x. (\<forall>i<k.  P (iterate i\<cdot>f\<cdot>x)) \<Longrightarrow> P (iterate k\<cdot>f\<cdot>x)"
  shows "P (fix\<cdot>f)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. P (fix\<cdot>f)
[PROOF STEP]
unfolding fix_def2
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. P (\<Squnion>i. iterate i\<cdot>f\<cdot>\<bottom>)
[PROOF STEP]
apply (rule admD [OF adm chain_iterate])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>i. P (iterate i\<cdot>f\<cdot>\<bottom>)
[PROOF STEP]
apply(rule nat_k_induct[of k], simp add: base_k_steps)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>i. \<forall>n\<^sub>0. (\<forall>i<k. P (iterate (n\<^sub>0 + i)\<cdot>f\<cdot>\<bottom>)) \<longrightarrow> P (iterate (n\<^sub>0 + k)\<cdot>f\<cdot>\<bottom>)
[PROOF STEP]
using step
[PROOF STATE]
proof (prove)
using this:
\<forall>i<k. P (iterate i\<cdot>f\<cdot>?x) \<Longrightarrow> P (iterate k\<cdot>f\<cdot>?x)

goal (1 subgoal):
 1. \<And>i. \<forall>n\<^sub>0. (\<forall>i<k. P (iterate (n\<^sub>0 + i)\<cdot>f\<cdot>\<bottom>)) \<longrightarrow> P (iterate (n\<^sub>0 + k)\<cdot>f\<cdot>\<bottom>)
[PROOF STEP]
by (subst (1 2) add.commute, unfold iterate_iterate[symmetric]) blast


[STATEMENT]
theorem borel_measurable_det_Jacobian:
 fixes f :: "real^'n::{finite,wellorder} \<Rightarrow> real^'n::_"
  assumes S: "S \<in> sets lebesgue" and f: "\<And>x. x \<in> S \<Longrightarrow> (f has_derivative f' x) (at x within S)"
  shows "(\<lambda>x. det(matrix(f' x))) \<in> borel_measurable (lebesgue_on S)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. det (matrix (f' x))) \<in> borel_measurable (lebesgue_on S)
[PROOF STEP]
unfolding det_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. \<Sum>p | p permutes UNIV. real_of_int (sign p) * (\<Prod>i\<in>UNIV. matrix (f' x) $ i $ p i)) \<in> borel_measurable (lebesgue_on S)
[PROOF STEP]
by (intro measurable) (auto intro: f borel_measurable_partial_derivatives [OF S])


[STATEMENT]
lemma cos_double_cos: "cos (2 * w) = 2 * cos w ^ 2 - 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cos ((2::'a) * w) = (2::'a) * (cos w)\<^sup>2 - (1::'a)
[PROOF STEP]
by (simp add: cos_double sin_squared_eq)


[STATEMENT]
theorem content_std_simplex:
  "measure lborel (convex hull (insert 0 Basis :: 'a :: euclidean_space set)) =
     1 / fact DIM('a)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. content (convex hull insert (0::'a) Basis) = 1 / fact DIM('a)
[PROOF STEP]
by (simp add: measure_def emeasure_std_simplex)


[STATEMENT]
lemma set_integral_add [simp, intro]:
  fixes f g :: "_ \<Rightarrow> _ :: {banach, second_countable_topology}"
  assumes "set_integrable M A f" "set_integrable M A g"
  shows "set_integrable M A (\<lambda>x. f x + g x)"
    and "LINT x:A|M. f x + g x = (LINT x:A|M. f x) + (LINT x:A|M. g x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set_integrable M A (\<lambda>x. f x + g x) &&& LINT x:A|M. f x + g x = set_lebesgue_integral M A f + set_lebesgue_integral M A g
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
set_integrable M A f
set_integrable M A g

goal (1 subgoal):
 1. set_integrable M A (\<lambda>x. f x + g x) &&& LINT x:A|M. f x + g x = set_lebesgue_integral M A f + set_lebesgue_integral M A g
[PROOF STEP]
unfolding set_integrable_def set_lebesgue_integral_def
[PROOF STATE]
proof (prove)
using this:
integrable M (\<lambda>x. indicat_real A x *\<^sub>R f x)
integrable M (\<lambda>x. indicat_real A x *\<^sub>R g x)

goal (1 subgoal):
 1. integrable M (\<lambda>x. indicat_real A x *\<^sub>R (f x + g x)) &&& LINT x|M. indicat_real A x *\<^sub>R (f x + g x) = (LINT x|M. indicat_real A x *\<^sub>R f x) + (LINT x|M. indicat_real A x *\<^sub>R g x)
[PROOF STEP]
by (simp_all add: scaleR_add_right)


[STATEMENT]
lemma sum_setv_subset_eq:
  assumes "finite A"
  assumes "set\<^sub>v v \<subseteq> A"
  shows "(\<Sum> i \<in> set\<^sub>v v. count_vec v i) = (\<Sum> i \<in> A. count_vec v i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum (count_vec v) (set\<^sub>v v) = sum (count_vec v) A
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. sum (count_vec v) (set\<^sub>v v) = sum (count_vec v) A
[PROOF STEP]
have ni: "\<And> x. x \<notin> set\<^sub>v v \<Longrightarrow> count_vec v x = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. x \<notin> set\<^sub>v v \<Longrightarrow> count_vec v x = 0
[PROOF STEP]
by (simp add: setv_not_in_count0_iff)
[PROOF STATE]
proof (state)
this:
?x \<notin> set\<^sub>v v \<Longrightarrow> count_vec v ?x = 0

goal (1 subgoal):
 1. sum (count_vec v) (set\<^sub>v v) = sum (count_vec v) A
[PROOF STEP]
have "(\<Sum> i \<in> A. count_vec v i) = (\<Sum> i \<in> A - (set\<^sub>v v). count_vec v i) + (\<Sum> i \<in> (set\<^sub>v v). count_vec v i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum (count_vec v) A = sum (count_vec v) (A - set\<^sub>v v) + sum (count_vec v) (set\<^sub>v v)
[PROOF STEP]
using sum.subset_diff assms
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?B \<subseteq> ?A; finite ?A\<rbrakk> \<Longrightarrow> sum ?g ?A = sum ?g (?A - ?B) + sum ?g ?B
finite A
set\<^sub>v v \<subseteq> A

goal (1 subgoal):
 1. sum (count_vec v) A = sum (count_vec v) (A - set\<^sub>v v) + sum (count_vec v) (set\<^sub>v v)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
sum (count_vec v) A = sum (count_vec v) (A - set\<^sub>v v) + sum (count_vec v) (set\<^sub>v v)

goal (1 subgoal):
 1. sum (count_vec v) (set\<^sub>v v) = sum (count_vec v) A
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
sum (count_vec v) A = sum (count_vec v) (A - set\<^sub>v v) + sum (count_vec v) (set\<^sub>v v)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
sum (count_vec v) A = sum (count_vec v) (A - set\<^sub>v v) + sum (count_vec v) (set\<^sub>v v)

goal (1 subgoal):
 1. sum (count_vec v) (set\<^sub>v v) = sum (count_vec v) A
[PROOF STEP]
using ni
[PROOF STATE]
proof (prove)
using this:
sum (count_vec v) A = sum (count_vec v) (A - set\<^sub>v v) + sum (count_vec v) (set\<^sub>v v)
?x \<notin> set\<^sub>v v \<Longrightarrow> count_vec v ?x = 0

goal (1 subgoal):
 1. sum (count_vec v) (set\<^sub>v v) = sum (count_vec v) A
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
sum (count_vec v) (set\<^sub>v v) = sum (count_vec v) A

goal:
No subgoals!
[PROOF STEP]
qed