[STATEMENT]
lemma even_card_set:
  assumes "finite A" and "\<forall>x\<in>A. f x\<in>A \<and> f x\<noteq> x \<and> f (f x)=x"
  shows "even(card A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. even (card A)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
finite A
\<forall>x\<in>A. f x \<in> A \<and> f x \<noteq> x \<and> f (f x) = x

goal (1 subgoal):
 1. even (card A)
[PROOF STEP]
proof (induct "card A"  arbitrary:A rule:less_induct)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>A. \<lbrakk>\<And>Aa. \<lbrakk>card Aa < card A; finite Aa; \<forall>x\<in>Aa. f x \<in> Aa \<and> f x \<noteq> x \<and> f (f x) = x\<rbrakk> \<Longrightarrow> even (card Aa); finite A; \<forall>x\<in>A. f x \<in> A \<and> f x \<noteq> x \<and> f (f x) = x\<rbrakk> \<Longrightarrow> even (card A)
[PROOF STEP]
case less
[PROOF STATE]
proof (state)
this:
\<lbrakk>card ?A < card A; finite ?A; \<forall>x\<in>?A. f x \<in> ?A \<and> f x \<noteq> x \<and> f (f x) = x\<rbrakk> \<Longrightarrow> even (card ?A)
finite A
\<forall>x\<in>A. f x \<in> A \<and> f x \<noteq> x \<and> f (f x) = x

goal (1 subgoal):
 1. \<And>A. \<lbrakk>\<And>Aa. \<lbrakk>card Aa < card A; finite Aa; \<forall>x\<in>Aa. f x \<in> Aa \<and> f x \<noteq> x \<and> f (f x) = x\<rbrakk> \<Longrightarrow> even (card Aa); finite A; \<forall>x\<in>A. f x \<in> A \<and> f x \<noteq> x \<and> f (f x) = x\<rbrakk> \<Longrightarrow> even (card A)
[PROOF STEP]
have "A={}\<Longrightarrow>?case"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A = {} \<Longrightarrow> even (card A)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
A = {} \<Longrightarrow> even (card A)

goal (1 subgoal):
 1. \<And>A. \<lbrakk>\<And>Aa. \<lbrakk>card Aa < card A; finite Aa; \<forall>x\<in>Aa. f x \<in> Aa \<and> f x \<noteq> x \<and> f (f x) = x\<rbrakk> \<Longrightarrow> even (card Aa); finite A; \<forall>x\<in>A. f x \<in> A \<and> f x \<noteq> x \<and> f (f x) = x\<rbrakk> \<Longrightarrow> even (card A)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
A = {} \<Longrightarrow> even (card A)

goal (1 subgoal):
 1. \<And>A. \<lbrakk>\<And>Aa. \<lbrakk>card Aa < card A; finite Aa; \<forall>x\<in>Aa. f x \<in> Aa \<and> f x \<noteq> x \<and> f (f x) = x\<rbrakk> \<Longrightarrow> even (card Aa); finite A; \<forall>x\<in>A. f x \<in> A \<and> f x \<noteq> x \<and> f (f x) = x\<rbrakk> \<Longrightarrow> even (card A)
[PROOF STEP]
have "A\<noteq>{}\<Longrightarrow>?case"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A \<noteq> {} \<Longrightarrow> even (card A)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. A \<noteq> {} \<Longrightarrow> even (card A)
[PROOF STEP]
assume "A\<noteq>{}"
[PROOF STATE]
proof (state)
this:
A \<noteq> {}

goal (1 subgoal):
 1. A \<noteq> {} \<Longrightarrow> even (card A)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
A \<noteq> {}
[PROOF STEP]
obtain x where "x\<in>A"
[PROOF STATE]
proof (prove)
using this:
A \<noteq> {}

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

goal (1 subgoal):
 1. A \<noteq> {} \<Longrightarrow> even (card A)
[PROOF STEP]
hence "f x\<in>A" and "f x\<noteq>x"
[PROOF STATE]
proof (prove)
using this:
x \<in> A

goal (1 subgoal):
 1. f x \<in> A &&& f x \<noteq> x
[PROOF STEP]
by (metis less.prems(2))+
[PROOF STATE]
proof (state)
this:
f x \<in> A
f x \<noteq> x

goal (1 subgoal):
 1. A \<noteq> {} \<Longrightarrow> even (card A)
[PROOF STEP]
obtain B where B:"B=A-{x,f x}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>B. B = A - {x, f x} \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
B = A - {x, f x}

goal (1 subgoal):
 1. A \<noteq> {} \<Longrightarrow> even (card A)
[PROOF STEP]
hence "finite B"
[PROOF STATE]
proof (prove)
using this:
B = A - {x, f x}

goal (1 subgoal):
 1. finite B
[PROOF STEP]
using \<open>finite A\<close>
[PROOF STATE]
proof (prove)
using this:
B = A - {x, f x}
finite A

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

goal (1 subgoal):
 1. A \<noteq> {} \<Longrightarrow> even (card A)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
finite B

goal (1 subgoal):
 1. A \<noteq> {} \<Longrightarrow> even (card A)
[PROOF STEP]
have "card B<card A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card B < card A
[PROOF STEP]
using B \<open>finite A\<close>
[PROOF STATE]
proof (prove)
using this:
B = A - {x, f x}
finite A

goal (1 subgoal):
 1. card B < card A
[PROOF STEP]
by (metis Diff_insert \<open>f x \<in> A\<close> \<open>x \<in> A\<close> card_Diff2_less)
[PROOF STATE]
proof (state)
this:
card B < card A

goal (1 subgoal):
 1. A \<noteq> {} \<Longrightarrow> even (card A)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
card B < card A

goal (1 subgoal):
 1. A \<noteq> {} \<Longrightarrow> even (card A)
[PROOF STEP]
have "\<forall>x\<in>B. f x \<in> B \<and> f x \<noteq> x \<and> f (f x) = x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>x\<in>B. f x \<in> B \<and> f x \<noteq> x \<and> f (f x) = x
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> B \<Longrightarrow> f x \<in> B \<and> f x \<noteq> x \<and> f (f x) = x
[PROOF STEP]
fix y
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> B \<Longrightarrow> f x \<in> B \<and> f x \<noteq> x \<and> f (f x) = x
[PROOF STEP]
assume "y\<in>B"
[PROOF STATE]
proof (state)
this:
y \<in> B

goal (1 subgoal):
 1. \<And>x. x \<in> B \<Longrightarrow> f x \<in> B \<and> f x \<noteq> x \<and> f (f x) = x
[PROOF STEP]
hence "y\<in>A"
[PROOF STATE]
proof (prove)
using this:
y \<in> B

goal (1 subgoal):
 1. y \<in> A
[PROOF STEP]
using B
[PROOF STATE]
proof (prove)
using this:
y \<in> B
B = A - {x, f x}

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

goal (1 subgoal):
 1. \<And>x. x \<in> B \<Longrightarrow> f x \<in> B \<and> f x \<noteq> x \<and> f (f x) = x
[PROOF STEP]
hence "f y\<noteq>y" and "f (f y)=y"
[PROOF STATE]
proof (prove)
using this:
y \<in> A

goal (1 subgoal):
 1. f y \<noteq> y &&& f (f y) = y
[PROOF STEP]
by (metis less.prems(2))+
[PROOF STATE]
proof (state)
this:
f y \<noteq> y
f (f y) = y

goal (1 subgoal):
 1. \<And>x. x \<in> B \<Longrightarrow> f x \<in> B \<and> f x \<noteq> x \<and> f (f x) = x
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
f y \<noteq> y
f (f y) = y

goal (1 subgoal):
 1. \<And>x. x \<in> B \<Longrightarrow> f x \<in> B \<and> f x \<noteq> x \<and> f (f x) = x
[PROOF STEP]
have "f y\<in>B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f y \<in> B
[PROOF STEP]
proof (rule ccontr)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. f y \<notin> B \<Longrightarrow> False
[PROOF STEP]
assume "f y\<notin>B"
[PROOF STATE]
proof (state)
this:
f y \<notin> B

goal (1 subgoal):
 1. f y \<notin> B \<Longrightarrow> False
[PROOF STEP]
have "f y\<in>A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f y \<in> A
[PROOF STEP]
by (metis \<open>y \<in> A\<close> less.prems(2))
[PROOF STATE]
proof (state)
this:
f y \<in> A

goal (1 subgoal):
 1. f y \<notin> B \<Longrightarrow> False
[PROOF STEP]
hence "f y\<in>{x, f x}"
[PROOF STATE]
proof (prove)
using this:
f y \<in> A

goal (1 subgoal):
 1. f y \<in> {x, f x}
[PROOF STEP]
by (metis B DiffI \<open>f y \<notin> B\<close>)
[PROOF STATE]
proof (state)
this:
f y \<in> {x, f x}

goal (1 subgoal):
 1. f y \<notin> B \<Longrightarrow> False
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
f y \<in> {x, f x}

goal (1 subgoal):
 1. f y \<notin> B \<Longrightarrow> False
[PROOF STEP]
have "f y=x \<Longrightarrow> False"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f y = x \<Longrightarrow> False
[PROOF STEP]
by (metis B Diff_iff Diff_insert2 \<open>f (f y) = y\<close> \<open>y \<in> B\<close> singleton_iff)
[PROOF STATE]
proof (state)
this:
f y = x \<Longrightarrow> False

goal (1 subgoal):
 1. f y \<notin> B \<Longrightarrow> False
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
f y = x \<Longrightarrow> False

goal (1 subgoal):
 1. f y \<notin> B \<Longrightarrow> False
[PROOF STEP]
have "f y= f x\<Longrightarrow> False"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f y = f x \<Longrightarrow> False
[PROOF STEP]
by (metis B Diff_iff \<open>x \<in> A\<close> \<open>y \<in> B\<close> insertCI less.prems(2))
[PROOF STATE]
proof (state)
this:
f y = f x \<Longrightarrow> False

goal (1 subgoal):
 1. f y \<notin> B \<Longrightarrow> False
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
f y \<in> {x, f x}
f y = x \<Longrightarrow> False
f y = f x \<Longrightarrow> False
[PROOF STEP]
show False
[PROOF STATE]
proof (prove)
using this:
f y \<in> {x, f x}
f y = x \<Longrightarrow> False
f y = f x \<Longrightarrow> False

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

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
f y \<in> B

goal (1 subgoal):
 1. \<And>x. x \<in> B \<Longrightarrow> f x \<in> B \<and> f x \<noteq> x \<and> f (f x) = x
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
f y \<noteq> y
f (f y) = y
f y \<in> B
[PROOF STEP]
show "f y \<in> B \<and> f y \<noteq> y \<and> f (f y) = y"
[PROOF STATE]
proof (prove)
using this:
f y \<noteq> y
f (f y) = y
f y \<in> B

goal (1 subgoal):
 1. f y \<in> B \<and> f y \<noteq> y \<and> f (f y) = y
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
f y \<in> B \<and> f y \<noteq> y \<and> f (f y) = y

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<forall>x\<in>B. f x \<in> B \<and> f x \<noteq> x \<and> f (f x) = x

goal (1 subgoal):
 1. A \<noteq> {} \<Longrightarrow> even (card A)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
finite B
card B < card A
\<forall>x\<in>B. f x \<in> B \<and> f x \<noteq> x \<and> f (f x) = x
[PROOF STEP]
have "even (card B)"
[PROOF STATE]
proof (prove)
using this:
finite B
card B < card A
\<forall>x\<in>B. f x \<in> B \<and> f x \<noteq> x \<and> f (f x) = x

goal (1 subgoal):
 1. even (card B)
[PROOF STEP]
by (metis (full_types) less.hyps)
[PROOF STATE]
proof (state)
this:
even (card B)

goal (1 subgoal):
 1. A \<noteq> {} \<Longrightarrow> even (card A)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
even (card B)

goal (1 subgoal):
 1. A \<noteq> {} \<Longrightarrow> even (card A)
[PROOF STEP]
have "{x,f x}\<subseteq>A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {x, f x} \<subseteq> A
[PROOF STEP]
using \<open>f x\<in>A\<close> \<open>x\<in>A\<close>
[PROOF STATE]
proof (prove)
using this:
f x \<in> A
x \<in> A

goal (1 subgoal):
 1. {x, f x} \<subseteq> A
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
{x, f x} \<subseteq> A

goal (1 subgoal):
 1. A \<noteq> {} \<Longrightarrow> even (card A)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
{x, f x} \<subseteq> A

goal (1 subgoal):
 1. A \<noteq> {} \<Longrightarrow> even (card A)
[PROOF STEP]
have "card {x, f x} = 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card {x, f x} = 2
[PROOF STEP]
using \<open>f x\<noteq>x\<close>
[PROOF STATE]
proof (prove)
using this:
f x \<noteq> x

goal (1 subgoal):
 1. card {x, f x} = 2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
card {x, f x} = 2

goal (1 subgoal):
 1. A \<noteq> {} \<Longrightarrow> even (card A)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
even (card B)
{x, f x} \<subseteq> A
card {x, f x} = 2
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
even (card B)
{x, f x} \<subseteq> A
card {x, f x} = 2

goal (1 subgoal):
 1. even (card A)
[PROOF STEP]
using B \<open>finite A\<close> card_mono [of A "{x, f x}"]
[PROOF STATE]
proof (prove)
using this:
even (card B)
{x, f x} \<subseteq> A
card {x, f x} = 2
B = A - {x, f x}
finite A
\<lbrakk>finite A; {x, f x} \<subseteq> A\<rbrakk> \<Longrightarrow> card {x, f x} \<le> card A

goal (1 subgoal):
 1. even (card A)
[PROOF STEP]
by (simp add: card_Diff_subset)
[PROOF STATE]
proof (state)
this:
even (card A)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
A \<noteq> {} \<Longrightarrow> even (card A)

goal (1 subgoal):
 1. \<And>A. \<lbrakk>\<And>Aa. \<lbrakk>card Aa < card A; finite Aa; \<forall>x\<in>Aa. f x \<in> Aa \<and> f x \<noteq> x \<and> f (f x) = x\<rbrakk> \<Longrightarrow> even (card Aa); finite A; \<forall>x\<in>A. f x \<in> A \<and> f x \<noteq> x \<and> f (f x) = x\<rbrakk> \<Longrightarrow> even (card A)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
A = {} \<Longrightarrow> even (card A)
A \<noteq> {} \<Longrightarrow> even (card A)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
A = {} \<Longrightarrow> even (card A)
A \<noteq> {} \<Longrightarrow> even (card A)

goal (1 subgoal):
 1. even (card A)
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
even (card A)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma addition_over_vec_to_lin_poly:
  fixes x y
  assumes "a < dim_vec x"
  assumes "dim_vec x = dim_vec y"
  shows  "(x + y) $ a = coeff (vec_to_lpoly x + vec_to_lpoly y) a"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (x + y) $ a = Abstract_Linear_Poly.coeff (vec_to_lpoly x + vec_to_lpoly y) a
[PROOF STEP]
using  assms(1) assms(2) coeff_plus index_add_vec(1)
[PROOF STATE]
proof (prove)
using this:
a < dim_vec x
dim_vec x = dim_vec y
Abstract_Linear_Poly.coeff (?lp1.0 + ?lp2.0) ?var = Abstract_Linear_Poly.coeff ?lp1.0 ?var + Abstract_Linear_Poly.coeff ?lp2.0 ?var
?i < dim_vec ?v\<^sub>2 \<Longrightarrow> (?v\<^sub>1 + ?v\<^sub>2) $ ?i = ?v\<^sub>1 $ ?i + ?v\<^sub>2 $ ?i

goal (1 subgoal):
 1. (x + y) $ a = Abstract_Linear_Poly.coeff (vec_to_lpoly x + vec_to_lpoly y) a
[PROOF STEP]
by (metis vec_to_lin_poly_coeff_access)


[STATEMENT]
lemma arctan_less_pi4_pos: "x < 1 \<Longrightarrow> arctan x < pi/4"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x < 1 \<Longrightarrow> arctan x < pi / 4
[PROOF STEP]
by (metis arctan_less_iff arctan_one)


[STATEMENT]
lemma repeat_mset_distrib_add_mset[simp]:
  "repeat_mset n (add_mset a A) = replicate_mset n a + repeat_mset n A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. repeat_mset n (add_mset a A) = replicate_mset n a + repeat_mset n A
[PROOF STEP]
by (auto simp: multiset_eq_iff)


[STATEMENT]
lemma not_limit_ordinal_nat: "\<not> limit_ordinal (ordinal_of_nat n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<not> limit_ordinal (ordinal_of_nat n)
[PROOF STEP]
by (induct n) simp_all


[STATEMENT]
lemma step_4_pop_big_size_ok_4_aux: "\<lbrakk>
  0 < size big;
  4 \<le> remaining_steps (States dir big small);
  size_new big + remaining_steps (States dir big small) + 2 \<le> 3 * size_new small
\<rbrakk> \<Longrightarrow> size_new big - 1 + (remaining_steps (States dir big small) - 4) + 2 \<le> 3 * size_new small"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < size big; 4 \<le> remaining_steps (States dir big small); size_new big + remaining_steps (States dir big small) + 2 \<le> 3 * size_new small\<rbrakk> \<Longrightarrow> size_new big - 1 + (remaining_steps (States dir big small) - 4) + 2 \<le> 3 * size_new small
[PROOF STEP]
by linarith


[STATEMENT]
lemma rank_eq_card_iarrays:
  fixes A::"'a::{field}^'columns::{mod_type}^'rows::{mod_type}"
  shows "rank A = card {vec_to_iarray (row i (Gauss_Jordan A)) |i. \<not> is_zero_iarray (vec_to_iarray (row i (Gauss_Jordan A)))}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rank A = card {vec_to_iarray (row i (Gauss_Jordan A)) |i. \<not> is_zero_iarray (vec_to_iarray (row i (Gauss_Jordan A)))}
[PROOF STEP]
proof (unfold rank_Gauss_Jordan_eq Let_def, rule bij_betw_same_card[of "vec_to_iarray"], auto simp add: bij_betw_def)
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. inj_on vec_to_iarray {row i (Gauss_Jordan A) |i. row i (Gauss_Jordan A) \<noteq> 0}
 2. \<And>i. row i (Gauss_Jordan A) \<noteq> 0 \<Longrightarrow> \<exists>ia. vec_to_iarray (row i (Gauss_Jordan A)) = vec_to_iarray (row ia (Gauss_Jordan A)) \<and> \<not> is_zero_iarray (vec_to_iarray (row ia (Gauss_Jordan A)))
 3. \<And>i. \<not> is_zero_iarray (vec_to_iarray (row i (Gauss_Jordan A))) \<Longrightarrow> vec_to_iarray (row i (Gauss_Jordan A)) \<in> vec_to_iarray ` {row i (Gauss_Jordan A) |i. row i (Gauss_Jordan A) \<noteq> 0}
[PROOF STEP]
show "inj_on vec_to_iarray {row i (Gauss_Jordan A) |i. row i (Gauss_Jordan A) \<noteq> 0}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inj_on vec_to_iarray {row i (Gauss_Jordan A) |i. row i (Gauss_Jordan A) \<noteq> 0}
[PROOF STEP]
using inj_vec_to_iarray
[PROOF STATE]
proof (prove)
using this:
inj vec_to_iarray

goal (1 subgoal):
 1. inj_on vec_to_iarray {row i (Gauss_Jordan A) |i. row i (Gauss_Jordan A) \<noteq> 0}
[PROOF STEP]
unfolding inj_on_def
[PROOF STATE]
proof (prove)
using this:
\<forall>x\<in>UNIV. \<forall>y\<in>UNIV. vec_to_iarray x = vec_to_iarray y \<longrightarrow> x = y

goal (1 subgoal):
 1. \<forall>x\<in>{row i (Gauss_Jordan A) |i. row i (Gauss_Jordan A) \<noteq> 0}. \<forall>y\<in>{row i (Gauss_Jordan A) |i. row i (Gauss_Jordan A) \<noteq> 0}. vec_to_iarray x = vec_to_iarray y \<longrightarrow> x = y
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
inj_on vec_to_iarray {row i (Gauss_Jordan A) |i. row i (Gauss_Jordan A) \<noteq> 0}

goal (2 subgoals):
 1. \<And>i. row i (Gauss_Jordan A) \<noteq> 0 \<Longrightarrow> \<exists>ia. vec_to_iarray (row i (Gauss_Jordan A)) = vec_to_iarray (row ia (Gauss_Jordan A)) \<and> \<not> is_zero_iarray (vec_to_iarray (row ia (Gauss_Jordan A)))
 2. \<And>i. \<not> is_zero_iarray (vec_to_iarray (row i (Gauss_Jordan A))) \<Longrightarrow> vec_to_iarray (row i (Gauss_Jordan A)) \<in> vec_to_iarray ` {row i (Gauss_Jordan A) |i. row i (Gauss_Jordan A) \<noteq> 0}
[PROOF STEP]
fix i
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>i. row i (Gauss_Jordan A) \<noteq> 0 \<Longrightarrow> \<exists>ia. vec_to_iarray (row i (Gauss_Jordan A)) = vec_to_iarray (row ia (Gauss_Jordan A)) \<and> \<not> is_zero_iarray (vec_to_iarray (row ia (Gauss_Jordan A)))
 2. \<And>i. \<not> is_zero_iarray (vec_to_iarray (row i (Gauss_Jordan A))) \<Longrightarrow> vec_to_iarray (row i (Gauss_Jordan A)) \<in> vec_to_iarray ` {row i (Gauss_Jordan A) |i. row i (Gauss_Jordan A) \<noteq> 0}
[PROOF STEP]
assume r: "row i (Gauss_Jordan A) \<noteq> 0"
[PROOF STATE]
proof (state)
this:
row i (Gauss_Jordan A) \<noteq> 0

goal (2 subgoals):
 1. \<And>i. row i (Gauss_Jordan A) \<noteq> 0 \<Longrightarrow> \<exists>ia. vec_to_iarray (row i (Gauss_Jordan A)) = vec_to_iarray (row ia (Gauss_Jordan A)) \<and> \<not> is_zero_iarray (vec_to_iarray (row ia (Gauss_Jordan A)))
 2. \<And>i. \<not> is_zero_iarray (vec_to_iarray (row i (Gauss_Jordan A))) \<Longrightarrow> vec_to_iarray (row i (Gauss_Jordan A)) \<in> vec_to_iarray ` {row i (Gauss_Jordan A) |i. row i (Gauss_Jordan A) \<noteq> 0}
[PROOF STEP]
show "\<exists>ia. vec_to_iarray (row i (Gauss_Jordan A)) = vec_to_iarray (row ia (Gauss_Jordan A)) \<and> \<not> is_zero_iarray (vec_to_iarray (row ia (Gauss_Jordan A)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>ia. vec_to_iarray (row i (Gauss_Jordan A)) = vec_to_iarray (row ia (Gauss_Jordan A)) \<and> \<not> is_zero_iarray (vec_to_iarray (row ia (Gauss_Jordan A)))
[PROOF STEP]
proof (rule exI[of _ i], simp)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> is_zero_iarray (vec_to_iarray (row i (Gauss_Jordan A)))
[PROOF STEP]
show "\<not> is_zero_iarray (vec_to_iarray (row i (Gauss_Jordan A)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<not> is_zero_iarray (vec_to_iarray (row i (Gauss_Jordan A)))
[PROOF STEP]
using r
[PROOF STATE]
proof (prove)
using this:
row i (Gauss_Jordan A) \<noteq> 0

goal (1 subgoal):
 1. \<not> is_zero_iarray (vec_to_iarray (row i (Gauss_Jordan A)))
[PROOF STEP]
unfolding is_zero_iarray_eq_iff
[PROOF STATE]
proof (prove)
using this:
\<not> is_zero_iarray (vec_to_iarray (row i (Gauss_Jordan A)))

goal (1 subgoal):
 1. \<not> is_zero_iarray (vec_to_iarray (row i (Gauss_Jordan A)))
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
\<not> is_zero_iarray (vec_to_iarray (row i (Gauss_Jordan A)))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<exists>ia. vec_to_iarray (row i (Gauss_Jordan A)) = vec_to_iarray (row ia (Gauss_Jordan A)) \<and> \<not> is_zero_iarray (vec_to_iarray (row ia (Gauss_Jordan A)))

goal (1 subgoal):
 1. \<And>i. \<not> is_zero_iarray (vec_to_iarray (row i (Gauss_Jordan A))) \<Longrightarrow> vec_to_iarray (row i (Gauss_Jordan A)) \<in> vec_to_iarray ` {row i (Gauss_Jordan A) |i. row i (Gauss_Jordan A) \<noteq> 0}
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i. \<not> is_zero_iarray (vec_to_iarray (row i (Gauss_Jordan A))) \<Longrightarrow> vec_to_iarray (row i (Gauss_Jordan A)) \<in> vec_to_iarray ` {row i (Gauss_Jordan A) |i. row i (Gauss_Jordan A) \<noteq> 0}
[PROOF STEP]
fix i
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i. \<not> is_zero_iarray (vec_to_iarray (row i (Gauss_Jordan A))) \<Longrightarrow> vec_to_iarray (row i (Gauss_Jordan A)) \<in> vec_to_iarray ` {row i (Gauss_Jordan A) |i. row i (Gauss_Jordan A) \<noteq> 0}
[PROOF STEP]
assume not_zero_iarray: "\<not> is_zero_iarray (vec_to_iarray (row i (Gauss_Jordan A)))"
[PROOF STATE]
proof (state)
this:
\<not> is_zero_iarray (vec_to_iarray (row i (Gauss_Jordan A)))

goal (1 subgoal):
 1. \<And>i. \<not> is_zero_iarray (vec_to_iarray (row i (Gauss_Jordan A))) \<Longrightarrow> vec_to_iarray (row i (Gauss_Jordan A)) \<in> vec_to_iarray ` {row i (Gauss_Jordan A) |i. row i (Gauss_Jordan A) \<noteq> 0}
[PROOF STEP]
show "vec_to_iarray (row i (Gauss_Jordan A)) \<in> vec_to_iarray ` {row i (Gauss_Jordan A) |i. row i (Gauss_Jordan A) \<noteq> 0}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vec_to_iarray (row i (Gauss_Jordan A)) \<in> vec_to_iarray ` {row i (Gauss_Jordan A) |i. row i (Gauss_Jordan A) \<noteq> 0}
[PROOF STEP]
by (rule imageI, auto simp add: not_zero_iarray  is_zero_iarray_eq_iff)
[PROOF STATE]
proof (state)
this:
vec_to_iarray (row i (Gauss_Jordan A)) \<in> vec_to_iarray ` {row i (Gauss_Jordan A) |i. row i (Gauss_Jordan A) \<noteq> 0}

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma "sum (IArray [1,2,3,4,5,6,7,8,9::int]) = 45"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. IArray_Examples.sum (IArray [1, 2, 3, 4, 5, 6, 7, 8, 9]) = 45
[PROOF STEP]
by eval


[STATEMENT]
lemma (in abelian_group) a_solve_equation:
    "\<lbrakk>subgroup H (add_monoid G); x \<in> H; y \<in> H\<rbrakk> \<Longrightarrow> \<exists>h\<in>H. y = h \<oplus> x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>subgroup H (add_monoid G); x \<in> H; y \<in> H\<rbrakk> \<Longrightarrow> \<exists>h\<in>H. y = h \<oplus> x
[PROOF STEP]
by (rule group.solve_equation [OF a_group,
    folded a_r_coset_def, simplified monoid_record_simps])


[STATEMENT]
theorem language_Brzozowski: "dfa.language Brzozowski = language"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dfa.language Brzozowski = language
[PROOF STEP]
by (simp add: Brzozowski_def dfa.Accessible_language nfa.Power_language
          dfa.dfa_Accessible dfa.nfa_Reverse_nfa nfa.dfa_Power nfa_Reverse_nfa
          dfa.language_Reverse_nfa image_image)


[STATEMENT]
lemma Frct_diff: "Frct (a, numeral b) - Frct (c, numeral d) =
                    Frct (Rat.normalize (a * numeral d - c * numeral b, numeral (b*d)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Frct (a, numeral b) - Frct (c, numeral d) = Frct (Rat.normalize (a * numeral d - c * numeral b, numeral (b * d)))
[PROOF STEP]
by (auto simp: rat_number_collapse Fract_normalize)


[STATEMENT]
lemma pderiv_smult:
  assumes "a \<in> carrier R"
  assumes "f \<in> carrier P"
  shows "pderiv (a \<odot>\<^bsub>P\<^esub> f) = a \<odot>\<^bsub>P\<^esub> (pderiv f)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. pderiv (a \<odot>\<^bsub>P\<^esub> f) = a \<odot>\<^bsub>P\<^esub> pderiv f
[PROOF STEP]
unfolding pderiv_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly_shift (n_mult (a \<odot>\<^bsub>P\<^esub> f)) = a \<odot>\<^bsub>P\<^esub> poly_shift (n_mult f)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
a \<in> carrier R
f \<in> carrier P

goal (1 subgoal):
 1. poly_shift (n_mult (a \<odot>\<^bsub>P\<^esub> f)) = a \<odot>\<^bsub>P\<^esub> poly_shift (n_mult f)
[PROOF STEP]
by (simp add: n_mult_closed nmult_smult poly_shift_s_mult)


[STATEMENT]
lemma retract_of_compact:
     "\<lbrakk>compact T; S retract_of T\<rbrakk> \<Longrightarrow> compact S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>compact T; S retract_of T\<rbrakk> \<Longrightarrow> compact S
[PROOF STEP]
by (metis compact_continuous_image retract_of_def retraction)


[STATEMENT]
lemma real_interval_times: "real_interval (A * B) = real_interval A * real_interval B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real_interval (A * B) = real_interval A * real_interval B
[PROOF STEP]
by (auto simp: interval_eq_iff lower_times upper_times min_def max_def)


[STATEMENT]
lemma closure_affine_hull:
  fixes S :: "'n::euclidean_space set"
  shows "closure S \<subseteq> affine hull S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. closure S \<subseteq> affine hull S
[PROOF STEP]
by (intro closure_minimal hull_subset affine_closed affine_affine_hull)


[STATEMENT]
lemma poly_tuple_pullback_eq_poly_map_vimage:
  assumes "is_poly_tuple n fs"
  assumes "length fs = m"
  assumes "S \<subseteq> carrir (Q\<^sub>p\<^bsup>m\<^esup>)"
  shows "poly_map n fs  \<inverse>\<^bsub>n\<^esub> S = poly_tuple_pullback n S fs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly_map n fs \<inverse>\<^bsub>n\<^esub> S = poly_tuple_pullback n S fs
[PROOF STEP]
unfolding poly_map_def poly_tuple_pullback_def evimage_def restrict_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. if x \<in> carrier (Q\<^sub>p\<^bsup>n\<^esup>) then poly_tuple_eval fs x else undefined) -` S \<inter> carrier (Q\<^sub>p\<^bsup>n\<^esup>) = poly_tuple_eval fs -` S \<inter> carrier (Q\<^sub>p\<^bsup>n\<^esup>)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
is_poly_tuple n fs
length fs = m
S \<subseteq> carrir (Q\<^sub>p\<^bsup>m\<^esup>)

goal (1 subgoal):
 1. (\<lambda>x. if x \<in> carrier (Q\<^sub>p\<^bsup>n\<^esup>) then poly_tuple_eval fs x else undefined) -` S \<inter> carrier (Q\<^sub>p\<^bsup>n\<^esup>) = poly_tuple_eval fs -` S \<inter> carrier (Q\<^sub>p\<^bsup>n\<^esup>)
[PROOF STEP]
by (smt vimage_inter_cong)


[STATEMENT]
lemma float_abs:
  "\<bar>float (a,b)\<bar> = (if 0 <= a then (float (a,b)) else (float (-a,b)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<bar>float (a, b)\<bar> = (if 0 \<le> a then float (a, b) else float (- a, b))
[PROOF STEP]
by (simp add: float_def abs_if mult_less_0_iff not_less)


[STATEMENT]
lemma (in Corps) eSum_minus_x:"\<lbrakk>\<forall>j \<le> n. (x j) \<in> carrier K;
       \<forall>j \<le> n. (b j) \<in> carrier K; l \<le> n;
       \<forall>j\<in>({h. h \<le> n} -{l}). (g j = (x j) \<cdot>\<^sub>r (1\<^sub>r \<plusminus> -\<^sub>a (b j)));
       g l = (x l) \<cdot>\<^sub>r (-\<^sub>a (b l)) \<rbrakk> \<Longrightarrow>
       (nsum K (\<lambda>j\<in>{h. h \<le> n}. (x j) \<cdot>\<^sub>r (1\<^sub>r \<plusminus> -\<^sub>a (b j))) n) \<plusminus> (-\<^sub>a (x l)) =
                        nsum K g n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<forall>j\<le>n. x j \<in> carrier K; \<forall>j\<le>n. b j \<in> carrier K; l \<le> n; \<forall>j\<in>{h. h \<le> n} - {l}. g j = x j \<cdot>\<^sub>r (1\<^sub>r \<plusminus> -\<^sub>a b j); g l = x l \<cdot>\<^sub>r (-\<^sub>a b l)\<rbrakk> \<Longrightarrow> \<Sigma>\<^sub>e K (\<lambda>j\<in>{h. h \<le> n}. x j \<cdot>\<^sub>r (1\<^sub>r \<plusminus> -\<^sub>a b j)) n \<plusminus> -\<^sub>a x l = \<Sigma>\<^sub>e K g n
[PROOF STEP]
by (cut_tac eSum_tr[of "n" "x" "b" "l" "g"], simp)


[STATEMENT]
lemma emeasure_bind:
    "\<lbrakk>space M \<noteq> {}; f \<in> measurable M (subprob_algebra N);X \<in> sets N\<rbrakk>
      \<Longrightarrow> emeasure (M \<bind> f) X = \<integral>\<^sup>+x. emeasure (f x) X \<partial>M"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>space M \<noteq> {}; f \<in> M \<rightarrow>\<^sub>M subprob_algebra N; X \<in> sets N\<rbrakk> \<Longrightarrow> emeasure (M \<bind> f) X = \<integral>\<^sup>+ x. emeasure (f x) X \<partial>M
[PROOF STEP]
by (simp add: bind_nonempty'' emeasure_join nn_integral_distr measurable_emeasure_subprob_algebra)


[STATEMENT]
lemma mult_eSuc_right: "(m::eint) * (n + 1) =  m * n +  m "
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. m * (n + 1) = m * n + m
[PROOF STEP]
by(simp add: distrib_left)


[STATEMENT]
lemma mult_mv_cancel_l:
  assumes "mat_det A \<noteq> 0" and "A *\<^sub>m\<^sub>v v = A *\<^sub>m\<^sub>v v'"
  shows "v = v'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. v = v'
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
mat_det A \<noteq> 0
A *\<^sub>m\<^sub>v v = A *\<^sub>m\<^sub>v v'

goal (1 subgoal):
 1. v = v'
[PROOF STEP]
using mult_mv_inv
[PROOF STATE]
proof (prove)
using this:
mat_det A \<noteq> 0
A *\<^sub>m\<^sub>v v = A *\<^sub>m\<^sub>v v'
\<lbrakk>?x = ?A *\<^sub>m\<^sub>v ?y; mat_det ?A \<noteq> 0\<rbrakk> \<Longrightarrow> ?y = mat_inv ?A *\<^sub>m\<^sub>v ?x

goal (1 subgoal):
 1. v = v'
[PROOF STEP]
by blast


[STATEMENT]
lemma basic_cong[simp]:
  fixes p :: int
  assumes "2 < p"
  shows   "[-1 \<noteq>  1] (mod p)"
          "[ 1 \<noteq> -1] (mod p)"
          "[ 0 \<noteq>  1] (mod p)"
          "[ 1 \<noteq>  0] (mod p)"
          "[ 0 \<noteq> -1] (mod p)"
          "[-1 \<noteq>  0] (mod p)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ([- 1 \<noteq> 1] (mod p) &&& [1 \<noteq> - 1] (mod p) &&& [0 \<noteq> 1] (mod p)) &&& [1 \<noteq> 0] (mod p) &&& [0 \<noteq> - 1] (mod p) &&& [- 1 \<noteq> 0] (mod p)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
2 < p

goal (1 subgoal):
 1. ([- 1 \<noteq> 1] (mod p) &&& [1 \<noteq> - 1] (mod p) &&& [0 \<noteq> 1] (mod p)) &&& [1 \<noteq> 0] (mod p) &&& [0 \<noteq> - 1] (mod p) &&& [- 1 \<noteq> 0] (mod p)
[PROOF STEP]
by (simp_all add: cong_iff_dvd_diff zdvd_not_zless)


[STATEMENT]
lemma to_hnr_prod_fst_snd:
    "fst (A *\<^sub>a B) = to_hnr_prod (fst A) (fst B)"
    "snd (A *\<^sub>a B) = to_hnr_prod (snd A) (snd B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fst (A *\<^sub>a B) = to_hnr_prod (fst A) (fst B) &&& snd (A *\<^sub>a B) = to_hnr_prod (snd A) (snd B)
[PROOF STEP]
unfolding hfprod_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fst (fst A \<times>\<^sub>a fst B, snd A \<times>\<^sub>a snd B) = to_hnr_prod (fst A) (fst B) &&& snd (fst A \<times>\<^sub>a fst B, snd A \<times>\<^sub>a snd B) = to_hnr_prod (snd A) (snd B)
[PROOF STEP]
by auto


[STATEMENT]
lemma ennreal_pmf_join: "ennreal (pmf (join_pmf N) i) = (\<integral>\<^sup>+M. pmf M i \<partial>measure_pmf N)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ennreal (pmf (join_pmf N) i) = \<integral>\<^sup>+ x. ennreal (pmf x i) \<partial>measure_pmf N
[PROOF STEP]
unfolding join_pmf_def ennreal_pmf_bind
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<integral>\<^sup>+ x. ennreal (pmf x i) \<partial>measure_pmf N = \<integral>\<^sup>+ x. ennreal (pmf x i) \<partial>measure_pmf N
[PROOF STEP]
..


[STATEMENT]
lemma (in cpx_sq_mat) mult_add_distrib_right:
  assumes "A\<in> fc_mats" "B\<in> fc_mats" "C\<in> fc_mats"
  shows "A * (B + C) = A * B + A * C"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A * (B + C) = A * B + A * C
[PROOF STEP]
using assms fc_mats_carrier mult_add_distrib_mat dim_eq
[PROOF STATE]
proof (prove)
using this:
A \<in> fc_mats
B \<in> fc_mats
C \<in> fc_mats
fc_mats = carrier_mat dimR dimC
\<lbrakk>?A \<in> carrier_mat ?nr ?n; ?B \<in> carrier_mat ?n ?nc; ?C \<in> carrier_mat ?n ?nc\<rbrakk> \<Longrightarrow> ?A * (?B + ?C) = ?A * ?B + ?A * ?C
dimR = dimC

goal (1 subgoal):
 1. A * (B + C) = A * B + A * C
[PROOF STEP]
by simp


[STATEMENT]
lemma continuous_within_topological:
  "continuous (at x within s) f \<longleftrightarrow>
    (\<forall>B. open B \<longrightarrow> f x \<in> B \<longrightarrow> (\<exists>A. open A \<and> x \<in> A \<and> (\<forall>y\<in>s. y \<in> A \<longrightarrow> f y \<in> B)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. continuous (at x within s) f = (\<forall>B. open B \<longrightarrow> f x \<in> B \<longrightarrow> (\<exists>A. open A \<and> x \<in> A \<and> (\<forall>y\<in>s. y \<in> A \<longrightarrow> f y \<in> B)))
[PROOF STEP]
unfolding continuous_within tendsto_def eventually_at_topological
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<forall>S. open S \<longrightarrow> f x \<in> S \<longrightarrow> (\<exists>Sa. open Sa \<and> x \<in> Sa \<and> (\<forall>xa\<in>Sa. xa \<noteq> x \<longrightarrow> xa \<in> s \<longrightarrow> f xa \<in> S))) = (\<forall>B. open B \<longrightarrow> f x \<in> B \<longrightarrow> (\<exists>A. open A \<and> x \<in> A \<and> (\<forall>y\<in>s. y \<in> A \<longrightarrow> f y \<in> B)))
[PROOF STEP]
by metis


[STATEMENT]
lemma SA_a_inv_eval:
  assumes "f \<in> carrier (SA n)"
  assumes "x \<in> carrier (Q\<^sub>p\<^bsup>n\<^esup>)"
  shows "(\<ominus>\<^bsub>SA n\<^esub> f) x = \<ominus> (f x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<ominus>\<^bsub>SA n\<^esub> f) x = \<ominus> f x
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<ominus>\<^bsub>SA n\<^esub> f) x = \<ominus> f x
[PROOF STEP]
have  "f \<oplus>\<^bsub>SA n\<^esub> (\<ominus>\<^bsub>SA n\<^esub> f) = \<zero> \<^bsub>SA n\<^esub>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f \<oplus>\<^bsub>SA n\<^esub> \<ominus>\<^bsub>SA n\<^esub> f = \<zero>\<^bsub>SA n\<^esub>
[PROOF STEP]
using assms SA_is_cring cring.cring_simprules(17)
[PROOF STATE]
proof (prove)
using this:
f \<in> carrier (SA n)
x \<in> carrier (Q\<^sub>p\<^bsup>n\<^esup>)
cring (SA ?n)
\<lbrakk>cring ?R; ?x \<in> carrier ?R\<rbrakk> \<Longrightarrow> ?x \<oplus>\<^bsub>?R\<^esub> \<ominus>\<^bsub>?R\<^esub> ?x = \<zero>\<^bsub>?R\<^esub>

goal (1 subgoal):
 1. f \<oplus>\<^bsub>SA n\<^esub> \<ominus>\<^bsub>SA n\<^esub> f = \<zero>\<^bsub>SA n\<^esub>
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
f \<oplus>\<^bsub>SA n\<^esub> \<ominus>\<^bsub>SA n\<^esub> f = \<zero>\<^bsub>SA n\<^esub>

goal (1 subgoal):
 1. (\<ominus>\<^bsub>SA n\<^esub> f) x = \<ominus> f x
[PROOF STEP]
have  "(f \<oplus>\<^bsub>SA n\<^esub> (\<ominus>\<^bsub>SA n\<^esub> f)) x = \<zero> \<^bsub>SA n\<^esub> x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (f \<oplus>\<^bsub>SA n\<^esub> \<ominus>\<^bsub>SA n\<^esub> f) x = \<zero>\<^bsub>SA n\<^esub> x
[PROOF STEP]
using assms \<open>f \<oplus>\<^bsub>SA n\<^esub> \<ominus>\<^bsub>SA n\<^esub> f = \<zero>\<^bsub>SA n\<^esub>\<close>
[PROOF STATE]
proof (prove)
using this:
f \<in> carrier (SA n)
x \<in> carrier (Q\<^sub>p\<^bsup>n\<^esup>)
f \<oplus>\<^bsub>SA n\<^esub> \<ominus>\<^bsub>SA n\<^esub> f = \<zero>\<^bsub>SA n\<^esub>

goal (1 subgoal):
 1. (f \<oplus>\<^bsub>SA n\<^esub> \<ominus>\<^bsub>SA n\<^esub> f) x = \<zero>\<^bsub>SA n\<^esub> x
[PROOF STEP]
by presburger
[PROOF STATE]
proof (state)
this:
(f \<oplus>\<^bsub>SA n\<^esub> \<ominus>\<^bsub>SA n\<^esub> f) x = \<zero>\<^bsub>SA n\<^esub> x

goal (1 subgoal):
 1. (\<ominus>\<^bsub>SA n\<^esub> f) x = \<ominus> f x
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(f \<oplus>\<^bsub>SA n\<^esub> \<ominus>\<^bsub>SA n\<^esub> f) x = \<zero>\<^bsub>SA n\<^esub> x
[PROOF STEP]
have "(f x) \<oplus> (\<ominus>\<^bsub>SA n\<^esub> f) x = \<zero>"
[PROOF STATE]
proof (prove)
using this:
(f \<oplus>\<^bsub>SA n\<^esub> \<ominus>\<^bsub>SA n\<^esub> f) x = \<zero>\<^bsub>SA n\<^esub> x

goal (1 subgoal):
 1. f x \<oplus> (\<ominus>\<^bsub>SA n\<^esub> f) x = \<zero>
[PROOF STEP]
by (metis function_zero_eval SA_add SA_zero assms)
[PROOF STATE]
proof (state)
this:
f x \<oplus> (\<ominus>\<^bsub>SA n\<^esub> f) x = \<zero>

goal (1 subgoal):
 1. (\<ominus>\<^bsub>SA n\<^esub> f) x = \<ominus> f x
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
f x \<oplus> (\<ominus>\<^bsub>SA n\<^esub> f) x = \<zero>
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
f x \<oplus> (\<ominus>\<^bsub>SA n\<^esub> f) x = \<zero>

goal (1 subgoal):
 1. (\<ominus>\<^bsub>SA n\<^esub> f) x = \<ominus> f x
[PROOF STEP]
by (metis (no_types, lifting) PiE Q\<^sub>p_def Qp.add.m_comm Qp.minus_equality SA_is_cring Zp_def assms(1) assms(2) cring.cring_simprules(3) padic_fields.SA_car_memE(3) padic_fields_axioms)
[PROOF STATE]
proof (state)
this:
(\<ominus>\<^bsub>SA n\<^esub> f) x = \<ominus> f x

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma collinear_trans1:
  assumes "collinear z0 z2 z1" and "collinear z0 z3 z1" and "z0 \<noteq> z1"
  shows "collinear z0 z2 z3"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. collinear z0 z2 z3
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
collinear z0 z2 z1
collinear z0 z3 z1
z0 \<noteq> z1

goal (1 subgoal):
 1. collinear z0 z2 z3
[PROOF STEP]
unfolding collinear_ex_real
[PROOF STATE]
proof (prove)
using this:
\<exists>k. z0 = z2 \<or> z1 - z0 = cor k * (z2 - z0)
\<exists>k. z0 = z3 \<or> z1 - z0 = cor k * (z3 - z0)
z0 \<noteq> z1

goal (1 subgoal):
 1. \<exists>k. z0 = z2 \<or> z3 - z0 = cor k * (z2 - z0)
[PROOF STEP]
by (cases "z0 = z2", auto) (rule_tac x="k/ka" in exI, case_tac "ka = 0", auto simp add: field_simps)


[STATEMENT]
lemma lnth_llist_of [simp]: "lnth (llist_of xs) = nth xs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. lnth (llist_of xs) = (!) xs
[PROOF STEP]
proof(rule ext)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. lnth (llist_of xs) x = xs ! x
[PROOF STEP]
fix n
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. lnth (llist_of xs) x = xs ! x
[PROOF STEP]
show "lnth (llist_of xs) n = xs ! n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. lnth (llist_of xs) n = xs ! n
[PROOF STEP]
proof(induct xs arbitrary: n)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>n. lnth (llist_of []) n = [] ! n
 2. \<And>a xs n. (\<And>n. lnth (llist_of xs) n = xs ! n) \<Longrightarrow> lnth (llist_of (a # xs)) n = (a # xs) ! n
[PROOF STEP]
case Nil
[PROOF STATE]
proof (state)
this:

goal (2 subgoals):
 1. \<And>n. lnth (llist_of []) n = [] ! n
 2. \<And>a xs n. (\<And>n. lnth (llist_of xs) n = xs ! n) \<Longrightarrow> lnth (llist_of (a # xs)) n = (a # xs) ! n
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. lnth (llist_of []) n = [] ! n
[PROOF STEP]
by(cases n)(simp_all add: nth_def lnth_def)
[PROOF STATE]
proof (state)
this:
lnth (llist_of []) n = [] ! n

goal (1 subgoal):
 1. \<And>a xs n. (\<And>n. lnth (llist_of xs) n = xs ! n) \<Longrightarrow> lnth (llist_of (a # xs)) n = (a # xs) ! n
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a xs n. (\<And>n. lnth (llist_of xs) n = xs ! n) \<Longrightarrow> lnth (llist_of (a # xs)) n = (a # xs) ! n
[PROOF STEP]
case Cons
[PROOF STATE]
proof (state)
this:
lnth (llist_of xs_) ?n = xs_ ! ?n

goal (1 subgoal):
 1. \<And>a xs n. (\<And>n. lnth (llist_of xs) n = xs ! n) \<Longrightarrow> lnth (llist_of (a # xs)) n = (a # xs) ! n
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
using this:
lnth (llist_of xs_) ?n = xs_ ! ?n

goal (1 subgoal):
 1. lnth (llist_of (a_ # xs_)) n = (a_ # xs_) ! n
[PROOF STEP]
by(simp add: lnth_LCons split: nat.split)
[PROOF STATE]
proof (state)
this:
lnth (llist_of (a_ # xs_)) n = (a_ # xs_) ! n

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
lnth (llist_of xs) n = xs ! n

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma (in abelian_group) inv_add:
  assumes "a \<in> carrier G" and "b \<in> carrier G"
  shows "\<ominus> (a \<oplus> b) = \<ominus> a \<ominus> b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<ominus> (a \<oplus> b) = \<ominus> a \<ominus> b
[PROOF STEP]
using assms minus_add
[PROOF STATE]
proof (prove)
using this:
a \<in> carrier G
b \<in> carrier G
\<lbrakk>?x \<in> carrier G; ?y \<in> carrier G\<rbrakk> \<Longrightarrow> \<ominus> (?x \<oplus> ?y) = \<ominus> ?x \<oplus> \<ominus> ?y

goal (1 subgoal):
 1. \<ominus> (a \<oplus> b) = \<ominus> a \<ominus> b
[PROOF STEP]
by (simp add: a_minus_def)


[STATEMENT]
lemma idty_index:
  assumes "bij_betw f {..< n} {..< n}"
  and "i < n"
  and "j < n"
shows "(1\<^sub>m n)$$(i,j) = (1\<^sub>m n)$$(f i, f j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1\<^sub>m n $$ (i, j) = 1\<^sub>m n $$ (f i, f j)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. 1\<^sub>m n $$ (i, j) = 1\<^sub>m n $$ (f i, f j)
[PROOF STEP]
have "f i < n" "f j < n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f i < n &&& f j < n
[PROOF STEP]
using assms bij_betwE
[PROOF STATE]
proof (prove)
using this:
bij_betw f {..<n} {..<n}
i < n
j < n
bij_betw ?f ?A ?B \<Longrightarrow> \<forall>a\<in>?A. ?f a \<in> ?B

goal (1 subgoal):
 1. f i < n &&& f j < n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
f i < n
f j < n

goal (1 subgoal):
 1. 1\<^sub>m n $$ (i, j) = 1\<^sub>m n $$ (f i, f j)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1\<^sub>m n $$ (i, j) = 1\<^sub>m n $$ (f i, f j)
[PROOF STEP]
proof (cases "i = j")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. i = j \<Longrightarrow> 1\<^sub>m n $$ (i, j) = 1\<^sub>m n $$ (f i, f j)
 2. i \<noteq> j \<Longrightarrow> 1\<^sub>m n $$ (i, j) = 1\<^sub>m n $$ (f i, f j)
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
i = j

goal (2 subgoals):
 1. i = j \<Longrightarrow> 1\<^sub>m n $$ (i, j) = 1\<^sub>m n $$ (f i, f j)
 2. i \<noteq> j \<Longrightarrow> 1\<^sub>m n $$ (i, j) = 1\<^sub>m n $$ (f i, f j)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
i = j
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
i = j

goal (1 subgoal):
 1. 1\<^sub>m n $$ (i, j) = 1\<^sub>m n $$ (f i, f j)
[PROOF STEP]
using \<open>f i < n\<close> assms
[PROOF STATE]
proof (prove)
using this:
i = j
f i < n
bij_betw f {..<n} {..<n}
i < n
j < n

goal (1 subgoal):
 1. 1\<^sub>m n $$ (i, j) = 1\<^sub>m n $$ (f i, f j)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
1\<^sub>m n $$ (i, j) = 1\<^sub>m n $$ (f i, f j)

goal (1 subgoal):
 1. i \<noteq> j \<Longrightarrow> 1\<^sub>m n $$ (i, j) = 1\<^sub>m n $$ (f i, f j)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. i \<noteq> j \<Longrightarrow> 1\<^sub>m n $$ (i, j) = 1\<^sub>m n $$ (f i, f j)
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
i \<noteq> j

goal (1 subgoal):
 1. i \<noteq> j \<Longrightarrow> 1\<^sub>m n $$ (i, j) = 1\<^sub>m n $$ (f i, f j)
[PROOF STEP]
hence "f i \<noteq> f j"
[PROOF STATE]
proof (prove)
using this:
i \<noteq> j

goal (1 subgoal):
 1. f i \<noteq> f j
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
i \<noteq> j
bij_betw f {..<n} {..<n}
i < n
j < n

goal (1 subgoal):
 1. f i \<noteq> f j
[PROOF STEP]
by (metis bij_betw_iff_bijections lessThan_iff)
[PROOF STATE]
proof (state)
this:
f i \<noteq> f j

goal (1 subgoal):
 1. i \<noteq> j \<Longrightarrow> 1\<^sub>m n $$ (i, j) = 1\<^sub>m n $$ (f i, f j)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
f i \<noteq> f j
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
f i \<noteq> f j

goal (1 subgoal):
 1. 1\<^sub>m n $$ (i, j) = 1\<^sub>m n $$ (f i, f j)
[PROOF STEP]
by (metis \<open>f i < n\<close> \<open>f j < n\<close> assms(2) assms(3) index_one_mat(1))
[PROOF STATE]
proof (state)
this:
1\<^sub>m n $$ (i, j) = 1\<^sub>m n $$ (f i, f j)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
1\<^sub>m n $$ (i, j) = 1\<^sub>m n $$ (f i, f j)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma rotate_pow_comm: "rotate n (u\<^sup>@k) = (rotate n u)\<^sup>@k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rotate n (u \<^sup>@ k) = rotate n u \<^sup>@ k
[PROOF STEP]
proof (cases "u = \<epsilon>", simp)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. u \<noteq> \<epsilon> \<Longrightarrow> rotate n (u \<^sup>@ k) = rotate n u \<^sup>@ k
[PROOF STEP]
assume "u \<noteq> \<epsilon>"
[PROOF STATE]
proof (state)
this:
u \<noteq> \<epsilon>

goal (1 subgoal):
 1. u \<noteq> \<epsilon> \<Longrightarrow> rotate n (u \<^sup>@ k) = rotate n u \<^sup>@ k
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rotate n (u \<^sup>@ k) = rotate n u \<^sup>@ k
[PROOF STEP]
unfolding rotate_drop_take[of n u] rotate_pow_mod[of n u k]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rotate (n mod \<^bold>|u\<^bold>|) (u \<^sup>@ k) = (drop (n mod \<^bold>|u\<^bold>|) u \<cdot> take (n mod \<^bold>|u\<^bold>|) u) \<^sup>@ k
[PROOF STEP]
using rotate_conj_pow[of "take (n mod \<^bold>|u\<^bold>|) u" "drop (n mod \<^bold>|u\<^bold>|) u" k, unfolded append_take_drop_id[of "n mod \<^bold>|u\<^bold>|" u]]
[PROOF STATE]
proof (prove)
using this:
rotate \<^bold>|take (n mod \<^bold>|u\<^bold>|) u\<^bold>| (u \<^sup>@ k) = (drop (n mod \<^bold>|u\<^bold>|) u \<cdot> take (n mod \<^bold>|u\<^bold>|) u) \<^sup>@ k

goal (1 subgoal):
 1. rotate (n mod \<^bold>|u\<^bold>|) (u \<^sup>@ k) = (drop (n mod \<^bold>|u\<^bold>|) u \<cdot> take (n mod \<^bold>|u\<^bold>|) u) \<^sup>@ k
[PROOF STEP]
unfolding  mod_le_divisor[of "\<^bold>|u\<^bold>|" n, THEN take_len, OF \<open>u\<noteq>\<epsilon>\<close>[unfolded length_greater_0_conv[symmetric]]]
[PROOF STATE]
proof (prove)
using this:
rotate (n mod \<^bold>|u\<^bold>|) (u \<^sup>@ k) = (drop (n mod \<^bold>|u\<^bold>|) u \<cdot> take (n mod \<^bold>|u\<^bold>|) u) \<^sup>@ k

goal (1 subgoal):
 1. rotate (n mod \<^bold>|u\<^bold>|) (u \<^sup>@ k) = (drop (n mod \<^bold>|u\<^bold>|) u \<cdot> take (n mod \<^bold>|u\<^bold>|) u) \<^sup>@ k
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
rotate n (u \<^sup>@ k) = rotate n u \<^sup>@ k

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma cos_mono_le: assumes "abs x \<le> pi"
  and "abs y \<le> pi"
shows "cos x \<le> cos y \<longleftrightarrow> abs y \<le> abs x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (cos x \<le> cos y) = (\<bar>y\<bar> \<le> \<bar>x\<bar>)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (cos x \<le> cos y) = (\<bar>y\<bar> \<le> \<bar>x\<bar>)
[PROOF STEP]
have "cos x \<le> cos y \<longleftrightarrow> cos (abs x) \<le> cos (abs y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (cos x \<le> cos y) = (cos \<bar>x\<bar> \<le> cos \<bar>y\<bar>)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(cos x \<le> cos y) = (cos \<bar>x\<bar> \<le> cos \<bar>y\<bar>)

goal (1 subgoal):
 1. (cos x \<le> cos y) = (\<bar>y\<bar> \<le> \<bar>x\<bar>)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(cos x \<le> cos y) = (cos \<bar>x\<bar> \<le> cos \<bar>y\<bar>)

goal (1 subgoal):
 1. (cos x \<le> cos y) = (\<bar>y\<bar> \<le> \<bar>x\<bar>)
[PROOF STEP]
have "\<dots> \<longleftrightarrow> abs y \<le> abs x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (cos \<bar>x\<bar> \<le> cos \<bar>y\<bar>) = (\<bar>y\<bar> \<le> \<bar>x\<bar>)
[PROOF STEP]
by (subst cos_mono_le_eq, insert assms, auto)
[PROOF STATE]
proof (state)
this:
(cos \<bar>x\<bar> \<le> cos \<bar>y\<bar>) = (\<bar>y\<bar> \<le> \<bar>x\<bar>)

goal (1 subgoal):
 1. (cos x \<le> cos y) = (\<bar>y\<bar> \<le> \<bar>x\<bar>)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(cos x \<le> cos y) = (\<bar>y\<bar> \<le> \<bar>x\<bar>)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(cos x \<le> cos y) = (\<bar>y\<bar> \<le> \<bar>x\<bar>)

goal (1 subgoal):
 1. (cos x \<le> cos y) = (\<bar>y\<bar> \<le> \<bar>x\<bar>)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
(cos x \<le> cos y) = (\<bar>y\<bar> \<le> \<bar>x\<bar>)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma set_permutation_the_inv_restrict1:
  assumes "bij_betw f A A"
  shows   "the_inv (restrict1 f A) = restrict1 (the_inv_into A f) A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. the_inv (restrict1 f A) = restrict1 (the_inv_into A f) A
[PROOF STEP]
proof (rule ext, rule the_inv_into_f_eq)
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. \<And>a. inj (restrict1 f A)
 2. \<And>a. restrict1 f A (restrict1 (the_inv_into A f) A a) = a
 3. \<And>a. restrict1 (the_inv_into A f) A a \<in> UNIV
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
bij_betw f A A
[PROOF STEP]
show "inj (restrict1 f A)"
[PROOF STATE]
proof (prove)
using this:
bij_betw f A A

goal (1 subgoal):
 1. inj (restrict1 f A)
[PROOF STEP]
using bij_is_inj set_permutation_bij_restrict1
[PROOF STATE]
proof (prove)
using this:
bij_betw f A A
bij ?f \<Longrightarrow> inj ?f
bij_betw ?f ?A ?A \<Longrightarrow> bij (restrict1 ?f ?A)

goal (1 subgoal):
 1. inj (restrict1 f A)
[PROOF STEP]
by fast
[PROOF STATE]
proof (state)
this:
inj (restrict1 f A)

goal (2 subgoals):
 1. \<And>a. restrict1 f A (restrict1 (the_inv_into A f) A a) = a
 2. \<And>a. restrict1 (the_inv_into A f) A a \<in> UNIV
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>a. restrict1 f A (restrict1 (the_inv_into A f) A a) = a
 2. \<And>a. restrict1 (the_inv_into A f) A a \<in> UNIV
[PROOF STEP]
fix a
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>a. restrict1 f A (restrict1 (the_inv_into A f) A a) = a
 2. \<And>a. restrict1 (the_inv_into A f) A a \<in> UNIV
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
bij_betw f A A
[PROOF STEP]
show  "restrict1 f A (restrict1 (the_inv_into A f) A a) = a"
[PROOF STATE]
proof (prove)
using this:
bij_betw f A A

goal (1 subgoal):
 1. restrict1 f A (restrict1 (the_inv_into A f) A a) = a
[PROOF STEP]
using bij_betw_def[of f]
[PROOF STATE]
proof (prove)
using this:
bij_betw f A A
bij_betw f ?A ?B = (inj_on f ?A \<and> f ` ?A = ?B)

goal (1 subgoal):
 1. restrict1 f A (restrict1 (the_inv_into A f) A a) = a
[PROOF STEP]
by (simp add: the_inv_into_into f_the_inv_into_f)
[PROOF STATE]
proof (state)
this:
restrict1 f A (restrict1 (the_inv_into A f) A a) = a

goal (1 subgoal):
 1. \<And>a. restrict1 (the_inv_into A f) A a \<in> UNIV
[PROOF STEP]
qed simp


[STATEMENT]
lemma dist_in_open_segment:
  fixes a :: "'a :: euclidean_space"
  assumes "x \<in> open_segment a b"
    shows "dist x a < dist a b \<and> dist x b < dist a b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dist x a < dist a b \<and> dist x b < dist a b
[PROOF STEP]
proof (intro conjI)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. dist x a < dist a b
 2. dist x b < dist a b
[PROOF STEP]
obtain u where u: "0 < u" "u < 1" and x: "x = (1 - u) *\<^sub>R a + u *\<^sub>R b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>u. \<lbrakk>0 < u; u < 1; x = (1 - u) *\<^sub>R a + u *\<^sub>R b\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
x \<in> open_segment a b

goal (1 subgoal):
 1. (\<And>u. \<lbrakk>0 < u; u < 1; x = (1 - u) *\<^sub>R a + u *\<^sub>R b\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (force simp: in_segment algebra_simps)
[PROOF STATE]
proof (state)
this:
0 < u
u < 1
x = (1 - u) *\<^sub>R a + u *\<^sub>R b

goal (2 subgoals):
 1. dist x a < dist a b
 2. dist x b < dist a b
[PROOF STEP]
have "dist x a = u * dist a b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dist x a = u * dist a b
[PROOF STEP]
apply (simp add: dist_norm algebra_simps x)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. norm (u *\<^sub>R b - u *\<^sub>R a) = u * norm (a - b)
[PROOF STEP]
by (metis abs_of_nonneg less_eq_real_def norm_minus_commute norm_scaleR real_vector.scale_right_diff_distrib \<open>0 < u\<close>)
[PROOF STATE]
proof (state)
this:
dist x a = u * dist a b

goal (2 subgoals):
 1. dist x a < dist a b
 2. dist x b < dist a b
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
dist x a = u * dist a b

goal (2 subgoals):
 1. dist x a < dist a b
 2. dist x b < dist a b
[PROOF STEP]
have *: "...  < dist a b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. u * dist a b < dist a b
[PROOF STEP]
using assms mult_less_cancel_right2 u(2)
[PROOF STATE]
proof (prove)
using this:
x \<in> open_segment a b
(?a * ?c < ?c) = (((0::?'a) \<le> ?c \<longrightarrow> ?a < (1::?'a)) \<and> (?c \<le> (0::?'a) \<longrightarrow> (1::?'a) < ?a))
u < 1

goal (1 subgoal):
 1. u * dist a b < dist a b
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
u * dist a b < dist a b

goal (2 subgoals):
 1. dist x a < dist a b
 2. dist x b < dist a b
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
dist x a < dist a b
[PROOF STEP]
show "dist x a < dist a b"
[PROOF STATE]
proof (prove)
using this:
dist x a < dist a b

goal (1 subgoal):
 1. dist x a < dist a b
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
dist x a < dist a b

goal (1 subgoal):
 1. dist x b < dist a b
[PROOF STEP]
have ab_ne0: "dist a b \<noteq> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dist a b \<noteq> 0
[PROOF STEP]
using *
[PROOF STATE]
proof (prove)
using this:
u * dist a b < dist a b

goal (1 subgoal):
 1. dist a b \<noteq> 0
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
dist a b \<noteq> 0

goal (1 subgoal):
 1. dist x b < dist a b
[PROOF STEP]
have "dist x b = norm ((1-u) *\<^sub>R a - (1-u) *\<^sub>R b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dist x b = norm ((1 - u) *\<^sub>R a - (1 - u) *\<^sub>R b)
[PROOF STEP]
by (simp add: dist_norm algebra_simps x)
[PROOF STATE]
proof (state)
this:
dist x b = norm ((1 - u) *\<^sub>R a - (1 - u) *\<^sub>R b)

goal (1 subgoal):
 1. dist x b < dist a b
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
dist x b = norm ((1 - u) *\<^sub>R a - (1 - u) *\<^sub>R b)

goal (1 subgoal):
 1. dist x b < dist a b
[PROOF STEP]
have "... = (1-u) * dist a b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. norm ((1 - u) *\<^sub>R a - (1 - u) *\<^sub>R b) = (1 - u) * dist a b
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. norm ((1 - u) *\<^sub>R a - (1 - u) *\<^sub>R b) = (1 - u) * dist a b
[PROOF STEP]
have "norm ((1 - 1 * u) *\<^sub>R (a - b)) = (1 - 1 * u) * norm (a - b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. norm ((1 - 1 * u) *\<^sub>R (a - b)) = (1 - 1 * u) * norm (a - b)
[PROOF STEP]
using \<open>u < 1\<close>
[PROOF STATE]
proof (prove)
using this:
u < 1

goal (1 subgoal):
 1. norm ((1 - 1 * u) *\<^sub>R (a - b)) = (1 - 1 * u) * norm (a - b)
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
norm ((1 - 1 * u) *\<^sub>R (a - b)) = (1 - 1 * u) * norm (a - b)

goal (1 subgoal):
 1. norm ((1 - u) *\<^sub>R a - (1 - u) *\<^sub>R b) = (1 - u) * dist a b
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
norm ((1 - 1 * u) *\<^sub>R (a - b)) = (1 - 1 * u) * norm (a - b)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
norm ((1 - 1 * u) *\<^sub>R (a - b)) = (1 - 1 * u) * norm (a - b)

goal (1 subgoal):
 1. norm ((1 - u) *\<^sub>R a - (1 - u) *\<^sub>R b) = (1 - u) * dist a b
[PROOF STEP]
by (simp add: dist_norm real_vector.scale_right_diff_distrib)
[PROOF STATE]
proof (state)
this:
norm ((1 - u) *\<^sub>R a - (1 - u) *\<^sub>R b) = (1 - u) * dist a b

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
norm ((1 - u) *\<^sub>R a - (1 - u) *\<^sub>R b) = (1 - u) * dist a b

goal (1 subgoal):
 1. dist x b < dist a b
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
norm ((1 - u) *\<^sub>R a - (1 - u) *\<^sub>R b) = (1 - u) * dist a b

goal (1 subgoal):
 1. dist x b < dist a b
[PROOF STEP]
have "... < dist a b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (1 - u) * dist a b < dist a b
[PROOF STEP]
using ab_ne0 \<open>0 < u\<close>
[PROOF STATE]
proof (prove)
using this:
dist a b \<noteq> 0
0 < u

goal (1 subgoal):
 1. (1 - u) * dist a b < dist a b
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(1 - u) * dist a b < dist a b

goal (1 subgoal):
 1. dist x b < dist a b
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
dist x b < dist a b
[PROOF STEP]
show "dist x b < dist a b"
[PROOF STATE]
proof (prove)
using this:
dist x b < dist a b

goal (1 subgoal):
 1. dist x b < dist a b
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
dist x b < dist a b

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma X_minus_plus:
  assumes "a \<in> carrier R"
  shows "(X_minus a) = X_plus (\<ominus>a)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. X_poly_minus R a = X_poly_plus R (\<ominus> a)
[PROOF STEP]
using P_def UP_ring.UP_ring  UP_ring_axioms
[PROOF STATE]
proof (prove)
using this:
P \<equiv> UP R
UP_ring ?R \<Longrightarrow> ring (UP ?R)
UP_ring R

goal (1 subgoal):
 1. X_poly_minus R a = X_poly_plus R (\<ominus> a)
[PROOF STEP]
by (simp add: X_poly_minus_def X_poly_plus_def a_minus_def assms to_poly_a_inv)


[STATEMENT]
lemma lhopital_at_top_at_top:
  fixes f g :: "real \<Rightarrow> real"
  assumes f_0: "LIM x at a. f x :> at_top"
  assumes g_0: "LIM x at a. g x :> at_top"
    and ev:
      "eventually (\<lambda>x. DERIV f x :> f' x) (at a)"
      "eventually (\<lambda>x. DERIV g x :> g' x) (at a)"
    and lim: "filterlim (\<lambda> x. (f' x / g' x)) at_top (at a)"
  shows "filterlim (\<lambda> x. f x / g x) at_top (at a)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. LIM x at a. f x / g x :> at_top
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
filterlim f at_top (at a)
filterlim g at_top (at a)
\<forall>\<^sub>F x in at a. (f has_real_derivative f' x) (at x)
\<forall>\<^sub>F x in at a. (g has_real_derivative g' x) (at x)
LIM x at a. f' x / g' x :> at_top

goal (1 subgoal):
 1. LIM x at a. f x / g x :> at_top
[PROOF STEP]
unfolding eventually_at_split filterlim_at_split
[PROOF STATE]
proof (prove)
using this:
filterlim f at_top (at_left a) \<and> filterlim f at_top (at_right a)
filterlim g at_top (at_left a) \<and> filterlim g at_top (at_right a)
(\<forall>\<^sub>F x in at_left a. (f has_real_derivative f' x) (at x)) \<and> (\<forall>\<^sub>F x in at_right a. (f has_real_derivative f' x) (at x))
(\<forall>\<^sub>F x in at_left a. (g has_real_derivative g' x) (at x)) \<and> (\<forall>\<^sub>F x in at_right a. (g has_real_derivative g' x) (at x))
(LIM x at_left a. f' x / g' x :> at_top) \<and> (LIM x at_right a. f' x / g' x :> at_top)

goal (1 subgoal):
 1. (LIM x at_left a. f x / g x :> at_top) \<and> (LIM x at_right a. f x / g x :> at_top)
[PROOF STEP]
by (auto intro!: lhopital_right_at_top_at_top[of f a g f' g']
                   lhopital_left_at_top_at_top[of f a g f' g'])


[STATEMENT]
lemma summable_on_cong:
  assumes "\<And>x. x\<in>A \<Longrightarrow> f x = g x"
  shows "f summable_on A \<longleftrightarrow> g summable_on A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (f summable_on A) = (g summable_on A)
[PROOF STEP]
by (metis assms summable_on_def has_sum_cong)


[STATEMENT]
lemma Node_right_inj2: "inj2 (\<lambda>l r. Node l e r)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inj2 (\<lambda>l. Node l e)
[PROOF STEP]
unfolding inj2_on_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>x1\<in>UNIV. \<forall>x2\<in>UNIV. \<forall>y1\<in>UNIV. \<forall>y2\<in>UNIV. \<langle>x1, e, y1\<rangle> = \<langle>x2, e, y2\<rangle> \<longrightarrow> x1 = x2 \<and> y1 = y2
[PROOF STEP]
by simp


[STATEMENT]
lemma le_vec_mono_left: assumes B: "\<And> i j. B $ i $ j \<ge> 0"
  and "le_vec x y"
shows "le_vec (B *v x) (B *v y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. le_vec (B *v x) (B *v y)
[PROOF STEP]
proof (intro allI)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i. (B *v x) $h i \<le> (B *v y) $h i
[PROOF STEP]
fix i
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i. (B *v x) $h i \<le> (B *v y) $h i
[PROOF STEP]
show "(B *v x) $ i \<le> (B *v y) $ i"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (B *v x) $h i \<le> (B *v y) $h i
[PROOF STEP]
unfolding matrix_vector_mult_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<chi>i. \<Sum>j\<in>UNIV. B $h i $h j * x $h j) $h i \<le> (\<chi>i. \<Sum>j\<in>UNIV. B $h i $h j * y $h j) $h i
[PROOF STEP]
using B[of i] assms(2)
[PROOF STATE]
proof (prove)
using this:
0 \<le> B $h i $h ?j
le_vec x y

goal (1 subgoal):
 1. (\<chi>i. \<Sum>j\<in>UNIV. B $h i $h j * x $h j) $h i \<le> (\<chi>i. \<Sum>j\<in>UNIV. B $h i $h j * y $h j) $h i
[PROOF STEP]
by (auto intro!: sum_mono mult_left_mono)
[PROOF STATE]
proof (state)
this:
(B *v x) $h i \<le> (B *v y) $h i

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma nat_to_sch_6: "c_fst n mod 7 = 6 \<Longrightarrow> nat_to_sch n = Rec_op (nat_to_sch (c_fst (c_snd n))) (nat_to_sch (c_snd (c_snd n)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. c_fst n mod 7 = 6 \<Longrightarrow> nat_to_sch n = Rec_op (nat_to_sch (c_fst (c_snd n))) (nat_to_sch (c_snd (c_snd n)))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. c_fst n mod 7 = 6 \<Longrightarrow> nat_to_sch n = Rec_op (nat_to_sch (c_fst (c_snd n))) (nat_to_sch (c_snd (c_snd n)))
[PROOF STEP]
assume A1: "c_fst n mod 7 = 6"
[PROOF STATE]
proof (state)
this:
c_fst n mod 7 = 6

goal (1 subgoal):
 1. c_fst n mod 7 = 6 \<Longrightarrow> nat_to_sch n = Rec_op (nat_to_sch (c_fst (c_snd n))) (nat_to_sch (c_snd (c_snd n)))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
c_fst n mod 7 = 6
[PROOF STEP]
have "nat_to_sch n = (let u=(c_fst n) mod 7; v=c_snd n; v1=c_fst v; v2 = c_snd v; sch1=nat_to_sch v1; sch2=nat_to_sch v2 in loc_f u sch1 sch2)"
[PROOF STATE]
proof (prove)
using this:
c_fst n mod 7 = 6

goal (1 subgoal):
 1. nat_to_sch n = (let u = c_fst n mod 7; v = c_snd n; v1 = c_fst v; v2 = c_snd v; sch1 = nat_to_sch v1 in Let (nat_to_sch v2) (loc_f u sch1))
[PROOF STEP]
by (simp add: loc_lm_2)
[PROOF STATE]
proof (state)
this:
nat_to_sch n = (let u = c_fst n mod 7; v = c_snd n; v1 = c_fst v; v2 = c_snd v; sch1 = nat_to_sch v1 in Let (nat_to_sch v2) (loc_f u sch1))

goal (1 subgoal):
 1. c_fst n mod 7 = 6 \<Longrightarrow> nat_to_sch n = Rec_op (nat_to_sch (c_fst (c_snd n))) (nat_to_sch (c_snd (c_snd n)))
[PROOF STEP]
with A1
[PROOF STATE]
proof (chain)
picking this:
c_fst n mod 7 = 6
nat_to_sch n = (let u = c_fst n mod 7; v = c_snd n; v1 = c_fst v; v2 = c_snd v; sch1 = nat_to_sch v1 in Let (nat_to_sch v2) (loc_f u sch1))
[PROOF STEP]
show "nat_to_sch n = Rec_op (nat_to_sch (c_fst (c_snd n))) (nat_to_sch (c_snd (c_snd n)))"
[PROOF STATE]
proof (prove)
using this:
c_fst n mod 7 = 6
nat_to_sch n = (let u = c_fst n mod 7; v = c_snd n; v1 = c_fst v; v2 = c_snd v; sch1 = nat_to_sch v1 in Let (nat_to_sch v2) (loc_f u sch1))

goal (1 subgoal):
 1. nat_to_sch n = Rec_op (nat_to_sch (c_fst (c_snd n))) (nat_to_sch (c_snd (c_snd n)))
[PROOF STEP]
by (simp add: Let_def loc_f_def)
[PROOF STATE]
proof (state)
this:
nat_to_sch n = Rec_op (nat_to_sch (c_fst (c_snd n))) (nat_to_sch (c_snd (c_snd n)))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma image_involution: assumes "f \<circ> f \<equiv> id" shows "(image f) \<circ> (image f) \<equiv> id"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (`) f \<circ> (`) f \<equiv> id
[PROOF STEP]
unfolding image_comp_image \<open>f \<circ> f \<equiv> id\<close> image_id
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. id \<equiv> id
[PROOF STEP]
.


[STATEMENT]
lemma infsum_mono_complex:
  \<comment> \<open>For \<^typ>\<open>real\<close>, @{thm [source] infsum_mono} can be used.
      But \<^typ>\<open>complex\<close> does not have the right typeclass.\<close>
  fixes f g :: "'a \<Rightarrow> complex"
  assumes f_sum: "f summable_on A" and g_sum: "g summable_on A"
  assumes leq: "\<And>x. x \<in> A \<Longrightarrow> f x \<le> g x"
  shows   "infsum f A \<le> infsum g A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. infsum f A \<le> infsum g A
[PROOF STEP]
by (metis DiffE IntD1 f_sum g_sum infsum_mono_neutral_complex leq)


[STATEMENT]
lemma gauss_poly_factor:
  assumes "n > 0"
  shows "gauss_poly R n = (X [^]\<^bsub>P\<^esub> (n-1) \<ominus>\<^bsub>P\<^esub> \<one>\<^bsub>P\<^esub>) \<otimes>\<^bsub>P\<^esub> X" (is "_ = ?rhs")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. gauss_poly R n = (X [^]\<^bsub>P\<^esub> (n - 1) \<ominus>\<^bsub>P\<^esub> \<one>\<^bsub>P\<^esub>) \<otimes>\<^bsub>P\<^esub> X
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. gauss_poly R n = (X [^]\<^bsub>P\<^esub> (n - 1) \<ominus>\<^bsub>P\<^esub> \<one>\<^bsub>P\<^esub>) \<otimes>\<^bsub>P\<^esub> X
[PROOF STEP]
have a:"1 + (n - 1) = n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 + (n - 1) = n
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
0 < n

goal (1 subgoal):
 1. 1 + (n - 1) = n
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
1 + (n - 1) = n

goal (1 subgoal):
 1. gauss_poly R n = (X [^]\<^bsub>P\<^esub> (n - 1) \<ominus>\<^bsub>P\<^esub> \<one>\<^bsub>P\<^esub>) \<otimes>\<^bsub>P\<^esub> X
[PROOF STEP]
have "gauss_poly R n = X [^]\<^bsub>P\<^esub> (1+(n-1)) \<ominus>\<^bsub>P\<^esub> X"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. gauss_poly R n = X [^]\<^bsub>P\<^esub> (1 + (n - 1)) \<ominus>\<^bsub>P\<^esub> X
[PROOF STEP]
unfolding gauss_poly_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. X [^]\<^bsub>P\<^esub> n \<ominus>\<^bsub>P\<^esub> X = X [^]\<^bsub>P\<^esub> (1 + (n - 1)) \<ominus>\<^bsub>P\<^esub> X
[PROOF STEP]
by (subst a, simp)
[PROOF STATE]
proof (state)
this:
gauss_poly R n = X [^]\<^bsub>P\<^esub> (1 + (n - 1)) \<ominus>\<^bsub>P\<^esub> X

goal (1 subgoal):
 1. gauss_poly R n = (X [^]\<^bsub>P\<^esub> (n - 1) \<ominus>\<^bsub>P\<^esub> \<one>\<^bsub>P\<^esub>) \<otimes>\<^bsub>P\<^esub> X
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
gauss_poly R n = X [^]\<^bsub>P\<^esub> (1 + (n - 1)) \<ominus>\<^bsub>P\<^esub> X

goal (1 subgoal):
 1. gauss_poly R n = (X [^]\<^bsub>P\<^esub> (n - 1) \<ominus>\<^bsub>P\<^esub> \<one>\<^bsub>P\<^esub>) \<otimes>\<^bsub>P\<^esub> X
[PROOF STEP]
have "... = (X [^]\<^bsub>P\<^esub> (n-1)) \<otimes>\<^bsub>P\<^esub> X \<ominus>\<^bsub>P\<^esub> \<one>\<^bsub>P\<^esub> \<otimes>\<^bsub>P\<^esub> X"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. X [^]\<^bsub>P\<^esub> (1 + (n - 1)) \<ominus>\<^bsub>P\<^esub> X = X [^]\<^bsub>P\<^esub> (n - 1) \<otimes>\<^bsub>P\<^esub> X \<ominus>\<^bsub>P\<^esub> \<one>\<^bsub>P\<^esub> \<otimes>\<^bsub>P\<^esub> X
[PROOF STEP]
using var_closed
[PROOF STATE]
proof (prove)
using this:
X \<in> carrier P
polynomial (carrier R) X

goal (1 subgoal):
 1. X [^]\<^bsub>P\<^esub> (1 + (n - 1)) \<ominus>\<^bsub>P\<^esub> X = X [^]\<^bsub>P\<^esub> (n - 1) \<otimes>\<^bsub>P\<^esub> X \<ominus>\<^bsub>P\<^esub> \<one>\<^bsub>P\<^esub> \<otimes>\<^bsub>P\<^esub> X
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
X [^]\<^bsub>P\<^esub> (1 + (n - 1)) \<ominus>\<^bsub>P\<^esub> X = X [^]\<^bsub>P\<^esub> (n - 1) \<otimes>\<^bsub>P\<^esub> X \<ominus>\<^bsub>P\<^esub> \<one>\<^bsub>P\<^esub> \<otimes>\<^bsub>P\<^esub> X

goal (1 subgoal):
 1. gauss_poly R n = (X [^]\<^bsub>P\<^esub> (n - 1) \<ominus>\<^bsub>P\<^esub> \<one>\<^bsub>P\<^esub>) \<otimes>\<^bsub>P\<^esub> X
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
X [^]\<^bsub>P\<^esub> (1 + (n - 1)) \<ominus>\<^bsub>P\<^esub> X = X [^]\<^bsub>P\<^esub> (n - 1) \<otimes>\<^bsub>P\<^esub> X \<ominus>\<^bsub>P\<^esub> \<one>\<^bsub>P\<^esub> \<otimes>\<^bsub>P\<^esub> X

goal (1 subgoal):
 1. gauss_poly R n = (X [^]\<^bsub>P\<^esub> (n - 1) \<ominus>\<^bsub>P\<^esub> \<one>\<^bsub>P\<^esub>) \<otimes>\<^bsub>P\<^esub> X
[PROOF STEP]
have "... = ?rhs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. X [^]\<^bsub>P\<^esub> (n - 1) \<otimes>\<^bsub>P\<^esub> X \<ominus>\<^bsub>P\<^esub> \<one>\<^bsub>P\<^esub> \<otimes>\<^bsub>P\<^esub> X = (X [^]\<^bsub>P\<^esub> (n - 1) \<ominus>\<^bsub>P\<^esub> \<one>\<^bsub>P\<^esub>) \<otimes>\<^bsub>P\<^esub> X
[PROOF STEP]
unfolding a_minus_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. X [^]\<^bsub>P\<^esub> (n - 1) \<otimes>\<^bsub>P\<^esub> X \<oplus>\<^bsub>P\<^esub> \<ominus>\<^bsub>P\<^esub> (\<one>\<^bsub>P\<^esub> \<otimes>\<^bsub>P\<^esub> X) = (X [^]\<^bsub>P\<^esub> (n - 1) \<oplus>\<^bsub>P\<^esub> \<ominus>\<^bsub>P\<^esub> \<one>\<^bsub>P\<^esub>) \<otimes>\<^bsub>P\<^esub> X
[PROOF STEP]
using var_closed l_one
[PROOF STATE]
proof (prove)
using this:
X \<in> carrier P
polynomial (carrier R) X
?x \<in> carrier R \<Longrightarrow> \<one> \<otimes> ?x = ?x

goal (1 subgoal):
 1. X [^]\<^bsub>P\<^esub> (n - 1) \<otimes>\<^bsub>P\<^esub> X \<oplus>\<^bsub>P\<^esub> \<ominus>\<^bsub>P\<^esub> (\<one>\<^bsub>P\<^esub> \<otimes>\<^bsub>P\<^esub> X) = (X [^]\<^bsub>P\<^esub> (n - 1) \<oplus>\<^bsub>P\<^esub> \<ominus>\<^bsub>P\<^esub> \<one>\<^bsub>P\<^esub>) \<otimes>\<^bsub>P\<^esub> X
[PROOF STEP]
by (subst p.l_distr, auto, algebra)
[PROOF STATE]
proof (state)
this:
X [^]\<^bsub>P\<^esub> (n - 1) \<otimes>\<^bsub>P\<^esub> X \<ominus>\<^bsub>P\<^esub> \<one>\<^bsub>P\<^esub> \<otimes>\<^bsub>P\<^esub> X = (X [^]\<^bsub>P\<^esub> (n - 1) \<ominus>\<^bsub>P\<^esub> \<one>\<^bsub>P\<^esub>) \<otimes>\<^bsub>P\<^esub> X

goal (1 subgoal):
 1. gauss_poly R n = (X [^]\<^bsub>P\<^esub> (n - 1) \<ominus>\<^bsub>P\<^esub> \<one>\<^bsub>P\<^esub>) \<otimes>\<^bsub>P\<^esub> X
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
gauss_poly R n = (X [^]\<^bsub>P\<^esub> (n - 1) \<ominus>\<^bsub>P\<^esub> \<one>\<^bsub>P\<^esub>) \<otimes>\<^bsub>P\<^esub> X
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
gauss_poly R n = (X [^]\<^bsub>P\<^esub> (n - 1) \<ominus>\<^bsub>P\<^esub> \<one>\<^bsub>P\<^esub>) \<otimes>\<^bsub>P\<^esub> X

goal (1 subgoal):
 1. gauss_poly R n = (X [^]\<^bsub>P\<^esub> (n - 1) \<ominus>\<^bsub>P\<^esub> \<one>\<^bsub>P\<^esub>) \<otimes>\<^bsub>P\<^esub> X
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
gauss_poly R n = (X [^]\<^bsub>P\<^esub> (n - 1) \<ominus>\<^bsub>P\<^esub> \<one>\<^bsub>P\<^esub>) \<otimes>\<^bsub>P\<^esub> X

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma VInter_vdoubleton: "\<Inter>\<^sub>\<circ> (set {a, b}) = a \<inter>\<^sub>\<circ> b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<Inter>\<^sub>\<circ> (set {a, b}) = a \<inter>\<^sub>\<circ> b
[PROOF STEP]
proof(intro vsubset_antisym vsubsetI)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>x. x \<in>\<^sub>\<circ> \<Inter>\<^sub>\<circ> (set {a, b}) \<Longrightarrow> x \<in>\<^sub>\<circ> a \<inter>\<^sub>\<circ> b
 2. \<And>x. x \<in>\<^sub>\<circ> a \<inter>\<^sub>\<circ> b \<Longrightarrow> x \<in>\<^sub>\<circ> \<Inter>\<^sub>\<circ> (set {a, b})
[PROOF STEP]
show "x \<in>\<^sub>\<circ> \<Inter>\<^sub>\<circ> (set {a, b}) \<Longrightarrow> x \<in>\<^sub>\<circ> a \<inter>\<^sub>\<circ> b" for x
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<in>\<^sub>\<circ> \<Inter>\<^sub>\<circ> (set {a, b}) \<Longrightarrow> x \<in>\<^sub>\<circ> a \<inter>\<^sub>\<circ> b
[PROOF STEP]
by (elim VInterE3) auto
[PROOF STATE]
proof (state)
this:
?x \<in>\<^sub>\<circ> \<Inter>\<^sub>\<circ> (set {a, b}) \<Longrightarrow> ?x \<in>\<^sub>\<circ> a \<inter>\<^sub>\<circ> b

goal (1 subgoal):
 1. \<And>x. x \<in>\<^sub>\<circ> a \<inter>\<^sub>\<circ> b \<Longrightarrow> x \<in>\<^sub>\<circ> \<Inter>\<^sub>\<circ> (set {a, b})
[PROOF STEP]
show "x \<in>\<^sub>\<circ> a \<inter>\<^sub>\<circ> b \<Longrightarrow> x \<in>\<^sub>\<circ> \<Inter>\<^sub>\<circ> (set {a, b})" for x
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<in>\<^sub>\<circ> a \<inter>\<^sub>\<circ> b \<Longrightarrow> x \<in>\<^sub>\<circ> \<Inter>\<^sub>\<circ> (set {a, b})
[PROOF STEP]
by (intro VInterI) force+
[PROOF STATE]
proof (state)
this:
?x \<in>\<^sub>\<circ> a \<inter>\<^sub>\<circ> b \<Longrightarrow> ?x \<in>\<^sub>\<circ> \<Inter>\<^sub>\<circ> (set {a, b})

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma continuous_on_product_then_coordinatewise_UNIV:
  assumes "continuous_on UNIV f"
  shows "continuous_on UNIV (\<lambda>x. f x i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. continuous_on UNIV (\<lambda>x. f x i)
[PROOF STEP]
unfolding continuous_map_iff_continuous2 [symmetric]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. continuous_map euclidean euclidean (\<lambda>x. f x i)
[PROOF STEP]
by (rule continuous_map_product_then_coordinatewise [where I=UNIV]) (use assms in \<open>auto simp: euclidean_product_topology\<close>)


[STATEMENT]
lemma equivalentFormulaeIffEntailEachOther:
  fixes formula1 :: Formula and formula2 :: Formula
  shows "equivalentFormulae formula1 formula2 = (formulaEntailsFormula formula1 formula2 \<and> formulaEntailsFormula formula2 formula1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. equivalentFormulae formula1 formula2 = (formulaEntailsFormula formula1 formula2 \<and> formulaEntailsFormula formula2 formula1)
[PROOF STEP]
by (auto simp add:formulaEntailsFormula_def equivalentFormulae_def)


[STATEMENT]
lemma mssnth_exp_series_stream_aux:
  "mssnth (exp_series_stream_aux (1 / fact n) (n + 1)) m = 1 / fact (n + m)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mssnth (exp_series_stream_aux (1 / fact n) (real (n + 1))) m = 1 / fact (n + m)
[PROOF STEP]
proof (induction m arbitrary: n)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>n. mssnth (exp_series_stream_aux (1 / fact n) (real (n + 1))) 0 = 1 / fact (n + 0)
 2. \<And>m n. (\<And>n. mssnth (exp_series_stream_aux (1 / fact n) (real (n + 1))) m = 1 / fact (n + m)) \<Longrightarrow> mssnth (exp_series_stream_aux (1 / fact n) (real (n + 1))) (Suc m) = 1 / fact (n + Suc m)
[PROOF STEP]
case (0 n)
[PROOF STATE]
proof (state)
this:

goal (2 subgoals):
 1. \<And>n. mssnth (exp_series_stream_aux (1 / fact n) (real (n + 1))) 0 = 1 / fact (n + 0)
 2. \<And>m n. (\<And>n. mssnth (exp_series_stream_aux (1 / fact n) (real (n + 1))) m = 1 / fact (n + m)) \<Longrightarrow> mssnth (exp_series_stream_aux (1 / fact n) (real (n + 1))) (Suc m) = 1 / fact (n + Suc m)
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mssnth (exp_series_stream_aux (1 / fact n) (real (n + 1))) 0 = 1 / fact (n + 0)
[PROOF STEP]
by (subst exp_series_stream_aux.code) simp
[PROOF STATE]
proof (state)
this:
mssnth (exp_series_stream_aux (1 / fact n) (real (n + 1))) 0 = 1 / fact (n + 0)

goal (1 subgoal):
 1. \<And>m n. (\<And>n. mssnth (exp_series_stream_aux (1 / fact n) (real (n + 1))) m = 1 / fact (n + m)) \<Longrightarrow> mssnth (exp_series_stream_aux (1 / fact n) (real (n + 1))) (Suc m) = 1 / fact (n + Suc m)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>m n. (\<And>n. mssnth (exp_series_stream_aux (1 / fact n) (real (n + 1))) m = 1 / fact (n + m)) \<Longrightarrow> mssnth (exp_series_stream_aux (1 / fact n) (real (n + 1))) (Suc m) = 1 / fact (n + Suc m)
[PROOF STEP]
case (Suc m n)
[PROOF STATE]
proof (state)
this:
mssnth (exp_series_stream_aux (1 / fact ?n) (real (?n + 1))) m = 1 / fact (?n + m)

goal (1 subgoal):
 1. \<And>m n. (\<And>n. mssnth (exp_series_stream_aux (1 / fact n) (real (n + 1))) m = 1 / fact (n + m)) \<Longrightarrow> mssnth (exp_series_stream_aux (1 / fact n) (real (n + 1))) (Suc m) = 1 / fact (n + Suc m)
[PROOF STEP]
from Suc.IH[of "n + 1"]
[PROOF STATE]
proof (chain)
picking this:
mssnth (exp_series_stream_aux (1 / fact (n + 1)) (real (n + 1 + 1))) m = 1 / fact (n + 1 + m)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
mssnth (exp_series_stream_aux (1 / fact (n + 1)) (real (n + 1 + 1))) m = 1 / fact (n + 1 + m)

goal (1 subgoal):
 1. mssnth (exp_series_stream_aux (1 / fact n) (real (n + 1))) (Suc m) = 1 / fact (n + Suc m)
[PROOF STEP]
by (subst exp_series_stream_aux.code) (simp add: algebra_simps)
[PROOF STATE]
proof (state)
this:
mssnth (exp_series_stream_aux (1 / fact n) (real (n + 1))) (Suc m) = 1 / fact (n + Suc m)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma root_set_finite:
  assumes fin: "finite les"
  assumes nex: "\<not>(\<exists> (a, b, c) \<in> les. a = 0 \<and> b = 0 \<and> c = 0 )"
  shows "finite (root_set les)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite (root_set les)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. finite (root_set les)
[PROOF STEP]
have "\<forall>(a, b, c) \<in> les. finite {(x::real). a*x^2 + b*x + c = 0}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>(a, b, c)\<in>les. finite {x. a * x\<^sup>2 + b * x + c = 0}
[PROOF STEP]
proof clarsimp
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a aa b. (a, aa, b) \<in> les \<Longrightarrow> finite {x. a * x\<^sup>2 + aa * x + b = 0}
[PROOF STEP]
fix a b c
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a aa b. (a, aa, b) \<in> les \<Longrightarrow> finite {x. a * x\<^sup>2 + aa * x + b = 0}
[PROOF STEP]
assume "(a, b, c) \<in> les"
[PROOF STATE]
proof (state)
this:
(a, b, c) \<in> les

goal (1 subgoal):
 1. \<And>a aa b. (a, aa, b) \<in> les \<Longrightarrow> finite {x. a * x\<^sup>2 + aa * x + b = 0}
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(a, b, c) \<in> les
[PROOF STEP]
have "[:c, b, a:] \<noteq> 0"
[PROOF STATE]
proof (prove)
using this:
(a, b, c) \<in> les

goal (1 subgoal):
 1. [:c, b, a:] \<noteq> 0
[PROOF STEP]
using nex
[PROOF STATE]
proof (prove)
using this:
(a, b, c) \<in> les
\<not> (\<exists>(a, b, c)\<in>les. a = 0 \<and> b = 0 \<and> c = 0)

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

goal (1 subgoal):
 1. \<And>a aa b. (a, aa, b) \<in> les \<Longrightarrow> finite {x. a * x\<^sup>2 + aa * x + b = 0}
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
[:c, b, a:] \<noteq> 0
[PROOF STEP]
have "finite {x. poly [:c, b, a:] x = 0}"
[PROOF STATE]
proof (prove)
using this:
[:c, b, a:] \<noteq> 0

goal (1 subgoal):
 1. finite {x. poly [:c, b, a:] x = 0}
[PROOF STEP]
using poly_roots_finite[where p = "[:c, b, a:]"]
[PROOF STATE]
proof (prove)
using this:
[:c, b, a:] \<noteq> 0
[:c, b, a:] \<noteq> 0 \<Longrightarrow> finite {x. poly [:c, b, a:] x = 0}

goal (1 subgoal):
 1. finite {x. poly [:c, b, a:] x = 0}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
finite {x. poly [:c, b, a:] x = 0}

goal (1 subgoal):
 1. \<And>a aa b. (a, aa, b) \<in> les \<Longrightarrow> finite {x. a * x\<^sup>2 + aa * x + b = 0}
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
finite {x. poly [:c, b, a:] x = 0}
[PROOF STEP]
show "finite {x. a * x\<^sup>2 + b * x + c = 0}"
[PROOF STATE]
proof (prove)
using this:
finite {x. poly [:c, b, a:] x = 0}

goal (1 subgoal):
 1. finite {x. a * x\<^sup>2 + b * x + c = 0}
[PROOF STEP]
using  poly_roots_set_same
[PROOF STATE]
proof (prove)
using this:
finite {x. poly [:c, b, a:] x = 0}
{x. ?a * x\<^sup>2 + ?b * x + ?c = 0} = {x. poly [:?c, ?b, ?a:] x = 0}

goal (1 subgoal):
 1. finite {x. a * x\<^sup>2 + b * x + c = 0}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
finite {x. a * x\<^sup>2 + b * x + c = 0}

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<forall>(a, b, c)\<in>les. finite {x. a * x\<^sup>2 + b * x + c = 0}

goal (1 subgoal):
 1. finite (root_set les)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<forall>(a, b, c)\<in>les. finite {x. a * x\<^sup>2 + b * x + c = 0}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<forall>(a, b, c)\<in>les. finite {x. a * x\<^sup>2 + b * x + c = 0}

goal (1 subgoal):
 1. finite (root_set les)
[PROOF STEP]
using fin
[PROOF STATE]
proof (prove)
using this:
\<forall>(a, b, c)\<in>les. finite {x. a * x\<^sup>2 + b * x + c = 0}
finite les

goal (1 subgoal):
 1. finite (root_set les)
[PROOF STEP]
unfolding root_set_def
[PROOF STATE]
proof (prove)
using this:
\<forall>(a, b, c)\<in>les. finite {x. a * x\<^sup>2 + b * x + c = 0}
finite les

goal (1 subgoal):
 1. finite {x. \<exists>(a, b, c)\<in>les. a * x\<^sup>2 + b * x + c = 0}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
finite (root_set les)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma primroot_ex:
  obtains primroot::"('a::prime_card) mod_ring" where
    "primroot^(p-1) = 1"
    "primroot \<noteq> 1"
    "residue_primroot p (nat (to_int_mod_ring primroot))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>primroot. \<lbrakk>primroot ^ (p - 1) = 1; primroot \<noteq> 1; residue_primroot p (nat (to_int_mod_ring primroot))\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<And>primroot. \<lbrakk>primroot ^ (p - 1) = 1; primroot \<noteq> 1; residue_primroot p (nat (to_int_mod_ring primroot))\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
obtain g where g_Def: "residue_primroot p g \<and> g \<noteq> 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>g. residue_primroot p g \<and> g \<noteq> 1 \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using prime_nat_iff' prime_primitive_root_exists test
[PROOF STATE]
proof (prove)
using this:
prime ?p = (1 < ?p \<and> (\<forall>n\<in>{2..<?p}. \<not> n dvd ?p))
\<lbrakk>1 < ?n; prime ?n\<rbrakk> \<Longrightarrow> \<exists>x. residue_primroot ?n x
prime p

goal (1 subgoal):
 1. (\<And>g. residue_primroot p g \<and> g \<noteq> 1 \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (metis bigger_prime euler_theorem ord_1_right power_one_right prime_nat_iff'' residue_primroot.cases residue_primroot_cong)
[PROOF STATE]
proof (state)
this:
residue_primroot p g \<and> g \<noteq> 1

goal (1 subgoal):
 1. (\<And>primroot. \<lbrakk>primroot ^ (p - 1) = 1; primroot \<noteq> 1; residue_primroot p (nat (to_int_mod_ring primroot))\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
hence "[g \<noteq> 1] (mod p)"
[PROOF STATE]
proof (prove)
using this:
residue_primroot p g \<and> g \<noteq> 1

goal (1 subgoal):
 1. [g \<noteq> 1] (mod p)
[PROOF STEP]
using prime_not_2_order_not_1_mod[of p g]
[PROOF STATE]
proof (prove)
using this:
residue_primroot p g \<and> g \<noteq> 1
\<lbrakk>prime p; 2 < p; 2 < ord p g\<rbrakk> \<Longrightarrow> [g \<noteq> 1] (mod p)

goal (1 subgoal):
 1. [g \<noteq> 1] (mod p)
[PROOF STEP]
by (metis One_nat_def p_lst3 less_numeral_extra(4) ord_eq_Suc_0_iff residue_primroot.cases totient_gt_1)
[PROOF STATE]
proof (state)
this:
[g \<noteq> 1] (mod p)

goal (1 subgoal):
 1. (\<And>primroot. \<lbrakk>primroot ^ (p - 1) = 1; primroot \<noteq> 1; residue_primroot p (nat (to_int_mod_ring primroot))\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
hence "[g^(p-1) = 1] (mod p)"
[PROOF STATE]
proof (prove)
using this:
[g \<noteq> 1] (mod p)

goal (1 subgoal):
 1. [g ^ (p - 1) = 1] (mod p)
[PROOF STEP]
using g_Def
[PROOF STATE]
proof (prove)
using this:
[g \<noteq> 1] (mod p)
residue_primroot p g \<and> g \<noteq> 1

goal (1 subgoal):
 1. [g ^ (p - 1) = 1] (mod p)
[PROOF STEP]
by (metis coprime_commute euler_theorem residue_primroot_def test totient_prime)
[PROOF STATE]
proof (state)
this:
[g ^ (p - 1) = 1] (mod p)

goal (1 subgoal):
 1. (\<And>primroot. \<lbrakk>primroot ^ (p - 1) = 1; primroot \<noteq> 1; residue_primroot p (nat (to_int_mod_ring primroot))\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
[g ^ (p - 1) = 1] (mod p)

goal (1 subgoal):
 1. (\<And>primroot. \<lbrakk>primroot ^ (p - 1) = 1; primroot \<noteq> 1; residue_primroot p (nat (to_int_mod_ring primroot))\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
hence "int (g ^ (p - 1)) mod int p = (1::int)"
[PROOF STATE]
proof (prove)
using this:
[g ^ (p - 1) = 1] (mod p)

goal (1 subgoal):
 1. int (g ^ (p - 1)) mod int p = 1
[PROOF STEP]
by (metis cong_def int_ops(2) mod_less of_nat_mod prime_gt_1_nat test)
[PROOF STATE]
proof (state)
this:
int (g ^ (p - 1)) mod int p = 1

goal (1 subgoal):
 1. (\<And>primroot. \<lbrakk>primroot ^ (p - 1) = 1; primroot \<noteq> 1; residue_primroot p (nat (to_int_mod_ring primroot))\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
int (g ^ (p - 1)) mod int p = 1

goal (1 subgoal):
 1. (\<And>primroot. \<lbrakk>primroot ^ (p - 1) = 1; primroot \<noteq> 1; residue_primroot p (nat (to_int_mod_ring primroot))\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
hence "of_int_mod_ring (int (g ^ (p - 1)) mod int p) =
                      ((of_int_mod_ring 1) ::(('a::prime_card) mod_ring))"
[PROOF STATE]
proof (prove)
using this:
int (g ^ (p - 1)) mod int p = 1

goal (1 subgoal):
 1. of_int_mod_ring (int (g ^ (p - 1)) mod int p) = of_int_mod_ring 1
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
of_int_mod_ring (int (g ^ (p - 1)) mod int p) = of_int_mod_ring 1

goal (1 subgoal):
 1. (\<And>primroot. \<lbrakk>primroot ^ (p - 1) = 1; primroot \<noteq> 1; residue_primroot p (nat (to_int_mod_ring primroot))\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
[g ^ (p - 1) = 1] (mod p)
int (g ^ (p - 1)) mod int p = 1
of_int_mod_ring (int (g ^ (p - 1)) mod int p) = of_int_mod_ring 1
[PROOF STEP]
have "(of_int_mod_ring (g^(p-1))) = (1 ::(('a::prime_card) mod_ring))"
[PROOF STATE]
proof (prove)
using this:
[g ^ (p - 1) = 1] (mod p)
int (g ^ (p - 1)) mod int p = 1
of_int_mod_ring (int (g ^ (p - 1)) mod int p) = of_int_mod_ring 1

goal (1 subgoal):
 1. of_int_mod_ring (int (g ^ (p - 1))) = 1
[PROOF STEP]
using mod_homo[of "g^(p-1)"]
[PROOF STATE]
proof (prove)
using this:
[g ^ (p - 1) = 1] (mod p)
int (g ^ (p - 1)) mod int p = 1
of_int_mod_ring (int (g ^ (p - 1)) mod int p) = of_int_mod_ring 1
of_int_mod_ring (int (g ^ (p - 1))) = of_int_mod_ring (int (g ^ (p - 1)) mod int p)

goal (1 subgoal):
 1. of_int_mod_ring (int (g ^ (p - 1))) = 1
[PROOF STEP]
by (metis exp_homo power_0)
[PROOF STATE]
proof (state)
this:
of_int_mod_ring (int (g ^ (p - 1))) = 1

goal (1 subgoal):
 1. (\<And>primroot. \<lbrakk>primroot ^ (p - 1) = 1; primroot \<noteq> 1; residue_primroot p (nat (to_int_mod_ring primroot))\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
hence "((of_int_mod_ring g)^(p-1) ::(('a::prime_card) mod_ring)) = 1"
[PROOF STATE]
proof (prove)
using this:
of_int_mod_ring (int (g ^ (p - 1))) = 1

goal (1 subgoal):
 1. of_int_mod_ring (int g) ^ (p - 1) = 1
[PROOF STEP]
using exp_homo[of "int g" "p-1"]
[PROOF STATE]
proof (prove)
using this:
of_int_mod_ring (int (g ^ (p - 1))) = 1
of_int_mod_ring (int g ^ (p - 1)) = of_int_mod_ring (int g) ^ (p - 1)

goal (1 subgoal):
 1. of_int_mod_ring (int g) ^ (p - 1) = 1
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
of_int_mod_ring (int g) ^ (p - 1) = 1

goal (1 subgoal):
 1. (\<And>primroot. \<lbrakk>primroot ^ (p - 1) = 1; primroot \<noteq> 1; residue_primroot p (nat (to_int_mod_ring primroot))\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
of_int_mod_ring (int g) ^ (p - 1) = 1

goal (1 subgoal):
 1. (\<And>primroot. \<lbrakk>primroot ^ (p - 1) = 1; primroot \<noteq> 1; residue_primroot p (nat (to_int_mod_ring primroot))\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
have "((of_int_mod_ring g) ::(('a::prime_card) mod_ring)) \<noteq> 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. of_int_mod_ring (int g) \<noteq> 1
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. of_int_mod_ring (int g) = 1 \<Longrightarrow> False
[PROOF STEP]
assume "((of_int_mod_ring g) ::(('a::prime_card) mod_ring)) = 1"
[PROOF STATE]
proof (state)
this:
of_int_mod_ring (int g) = 1

goal (1 subgoal):
 1. of_int_mod_ring (int g) = 1 \<Longrightarrow> False
[PROOF STEP]
hence "[int g = 1] (mod p)"
[PROOF STATE]
proof (prove)
using this:
of_int_mod_ring (int g) = 1

goal (1 subgoal):
 1. [int g = 1] (mod int p)
[PROOF STEP]
using p_def
[PROOF STATE]
proof (prove)
using this:
of_int_mod_ring (int g) = 1
p = CARD('a)

goal (1 subgoal):
 1. [int g = 1] (mod int p)
[PROOF STEP]
unfolding of_int_mod_ring_def
[PROOF STATE]
proof (prove)
using this:
(id ---> Abs_mod_ring) (\<lambda>x. x mod int CARD('a)) (int g) = 1
p = CARD('a)

goal (1 subgoal):
 1. [int g = 1] (mod int p)
[PROOF STEP]
by (metis \<open>of_int_mod_ring (int g) = 1\<close> cong_def of_int_mod_ring.rep_eq one_mod_card_int one_mod_ring.rep_eq)
[PROOF STATE]
proof (state)
this:
[int g = 1] (mod int p)

goal (1 subgoal):
 1. of_int_mod_ring (int g) = 1 \<Longrightarrow> False
[PROOF STEP]
hence "[g=1] (mod p)"
[PROOF STATE]
proof (prove)
using this:
[int g = 1] (mod int p)

goal (1 subgoal):
 1. [g = 1] (mod p)
[PROOF STEP]
by (metis cong_int_iff int_ops(2))
[PROOF STATE]
proof (state)
this:
[g = 1] (mod p)

goal (1 subgoal):
 1. of_int_mod_ring (int g) = 1 \<Longrightarrow> False
[PROOF STEP]
thus False
[PROOF STATE]
proof (prove)
using this:
[g = 1] (mod p)

goal (1 subgoal):
 1. False
[PROOF STEP]
using \<open>[g \<noteq> 1] (mod p)\<close>
[PROOF STATE]
proof (prove)
using this:
[g = 1] (mod p)
[g \<noteq> 1] (mod p)

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

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
of_int_mod_ring (int g) \<noteq> 1

goal (1 subgoal):
 1. (\<And>primroot. \<lbrakk>primroot ^ (p - 1) = 1; primroot \<noteq> 1; residue_primroot p (nat (to_int_mod_ring primroot))\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
of_int_mod_ring (int g) \<noteq> 1

goal (1 subgoal):
 1. thesis
[PROOF STEP]
using that g_Def calculation
[PROOF STATE]
proof (prove)
using this:
of_int_mod_ring (int g) \<noteq> 1
\<lbrakk>?primroot ^ (p - 1) = 1; ?primroot \<noteq> 1; residue_primroot p (nat (to_int_mod_ring ?primroot))\<rbrakk> \<Longrightarrow> thesis
residue_primroot p g \<and> g \<noteq> 1
of_int_mod_ring (int g) ^ (p - 1) = 1

goal (1 subgoal):
 1. thesis
[PROOF STEP]
by (metis Euclidean_Division.pos_mod_bound Euclidean_Division.pos_mod_sign mod_homo nat_int of_nat_0_less_iff of_nat_mod p_def residue_primroot_mod to_int_mod_ring_of_int_mod_ring zero_less_card_finite)
[PROOF STATE]
proof (state)
this:
thesis

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma even_odd_interpolate_compose:
  "even_odd_interpolate (f o u) (f o v) = f o (even_odd_interpolate u v)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. even_odd_interpolate (f \<circ> u) (f \<circ> v) = f \<circ> even_odd_interpolate u v
[PROOF STEP]
unfolding even_odd_interpolate_def comp_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>n. if even n then f (u (n div 2)) else f (v (n div 2))) = (\<lambda>x. f (if even x then u (x div 2) else v (x div 2)))
[PROOF STEP]
by auto


[STATEMENT]
lemma has_vector_derivative_weaken:
  fixes x D and f g S T
  assumes f: "(f has_vector_derivative D) (at x within T)"
    and "x \<in> S" "S \<subseteq> T"
    and "\<And>x. x \<in> S \<Longrightarrow> f x = g x"
  shows "(g has_vector_derivative D) (at x within S)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (g has_vector_derivative D) (at x within S)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (g has_vector_derivative D) (at x within S)
[PROOF STEP]
have "(f has_vector_derivative D) (at x within S) \<longleftrightarrow> (g has_vector_derivative D) (at x within S)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (f has_vector_derivative D) (at x within S) = (g has_vector_derivative D) (at x within S)
[PROOF STEP]
unfolding has_vector_derivative_def has_derivative_iff_norm
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (bounded_linear (\<lambda>x. x *\<^sub>R D) \<and> ((\<lambda>y. norm (f y - f x - (y - x) *\<^sub>R D) / norm (y - x)) \<longlongrightarrow> 0) (at x within S)) = (bounded_linear (\<lambda>x. x *\<^sub>R D) \<and> ((\<lambda>y. norm (g y - g x - (y - x) *\<^sub>R D) / norm (y - x)) \<longlongrightarrow> 0) (at x within S))
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
(f has_vector_derivative D) (at x within T)
x \<in> S
S \<subseteq> T
?x \<in> S \<Longrightarrow> f ?x = g ?x

goal (1 subgoal):
 1. (bounded_linear (\<lambda>x. x *\<^sub>R D) \<and> ((\<lambda>y. norm (f y - f x - (y - x) *\<^sub>R D) / norm (y - x)) \<longlongrightarrow> 0) (at x within S)) = (bounded_linear (\<lambda>x. x *\<^sub>R D) \<and> ((\<lambda>y. norm (g y - g x - (y - x) *\<^sub>R D) / norm (y - x)) \<longlongrightarrow> 0) (at x within S))
[PROOF STEP]
by (intro conj_cong Lim_cong_within refl) auto
[PROOF STATE]
proof (state)
this:
(f has_vector_derivative D) (at x within S) = (g has_vector_derivative D) (at x within S)

goal (1 subgoal):
 1. (g has_vector_derivative D) (at x within S)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(f has_vector_derivative D) (at x within S) = (g has_vector_derivative D) (at x within S)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(f has_vector_derivative D) (at x within S) = (g has_vector_derivative D) (at x within S)

goal (1 subgoal):
 1. (g has_vector_derivative D) (at x within S)
[PROOF STEP]
using has_vector_derivative_within_subset[OF f \<open>S \<subseteq> T\<close>]
[PROOF STATE]
proof (prove)
using this:
(f has_vector_derivative D) (at x within S) = (g has_vector_derivative D) (at x within S)
(f has_vector_derivative D) (at x within S)

goal (1 subgoal):
 1. (g has_vector_derivative D) (at x within S)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(g has_vector_derivative D) (at x within S)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma confluentpI[intro]:
    assumes "\<And> x y1 y2. r\<^sup>*\<^sup>* x y1 \<Longrightarrow> r\<^sup>*\<^sup>* x y2 \<Longrightarrow> \<exists> z. r\<^sup>*\<^sup>* y1 z \<and> r\<^sup>*\<^sup>* y2 z"
    shows "confluentp r"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. confluentp r
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>r\<^sup>*\<^sup>* ?x ?y1.0; r\<^sup>*\<^sup>* ?x ?y2.0\<rbrakk> \<Longrightarrow> \<exists>z. r\<^sup>*\<^sup>* ?y1.0 z \<and> r\<^sup>*\<^sup>* ?y2.0 z

goal (1 subgoal):
 1. confluentp r
[PROOF STEP]
unfolding confluentp_def
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>r\<^sup>*\<^sup>* ?x ?y1.0; r\<^sup>*\<^sup>* ?x ?y2.0\<rbrakk> \<Longrightarrow> \<exists>z. r\<^sup>*\<^sup>* ?y1.0 z \<and> r\<^sup>*\<^sup>* ?y2.0 z

goal (1 subgoal):
 1. \<forall>x y1 y2. r\<^sup>*\<^sup>* x y1 \<longrightarrow> r\<^sup>*\<^sup>* x y2 \<longrightarrow> (\<exists>z. r\<^sup>*\<^sup>* y1 z \<and> r\<^sup>*\<^sup>* y2 z)
[PROOF STEP]
by simp


[STATEMENT]
lemma gcd_red_int: "gcd x y = gcd y (x mod y)"
  for x y :: int
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. gcd x y = gcd y (x mod y)
[PROOF STEP]
proof (cases y "0::int" rule: linorder_cases)
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. y < 0 \<Longrightarrow> gcd x y = gcd y (x mod y)
 2. y = 0 \<Longrightarrow> gcd x y = gcd y (x mod y)
 3. 0 < y \<Longrightarrow> gcd x y = gcd y (x mod y)
[PROOF STEP]
case less
[PROOF STATE]
proof (state)
this:
y < 0

goal (3 subgoals):
 1. y < 0 \<Longrightarrow> gcd x y = gcd y (x mod y)
 2. y = 0 \<Longrightarrow> gcd x y = gcd y (x mod y)
 3. 0 < y \<Longrightarrow> gcd x y = gcd y (x mod y)
[PROOF STEP]
with gcd_non_0_int [of "- y" "- x"]
[PROOF STATE]
proof (chain)
picking this:
0 < - y \<Longrightarrow> gcd (- x) (- y) = gcd (- y) (- x mod - y)
y < 0
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
0 < - y \<Longrightarrow> gcd (- x) (- y) = gcd (- y) (- x mod - y)
y < 0

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

goal (2 subgoals):
 1. y = 0 \<Longrightarrow> gcd x y = gcd y (x mod y)
 2. 0 < y \<Longrightarrow> gcd x y = gcd y (x mod y)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. y = 0 \<Longrightarrow> gcd x y = gcd y (x mod y)
 2. 0 < y \<Longrightarrow> gcd x y = gcd y (x mod y)
[PROOF STEP]
case greater
[PROOF STATE]
proof (state)
this:
0 < y

goal (2 subgoals):
 1. y = 0 \<Longrightarrow> gcd x y = gcd y (x mod y)
 2. 0 < y \<Longrightarrow> gcd x y = gcd y (x mod y)
[PROOF STEP]
with gcd_non_0_int [of y x]
[PROOF STATE]
proof (chain)
picking this:
0 < y \<Longrightarrow> gcd x y = gcd y (x mod y)
0 < y
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
0 < y \<Longrightarrow> gcd x y = gcd y (x mod y)
0 < y

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

goal (1 subgoal):
 1. y = 0 \<Longrightarrow> gcd x y = gcd y (x mod y)
[PROOF STEP]
qed auto