[STATEMENT]
lemma Abs_freeletter_in_FreeGroup_iff: "(Abs_freeletter s \<in> FreeGroup S) = (s\<in>S)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (Abs_freeletter s \<in> FreeGroup S) = (s \<in> S)
[PROOF STEP]
using Abs_freeword_inverse[of "[pairtrue s]"]
[PROOF STATE]
proof (prove)
using this:
[pairtrue s] \<in> {as. proper_signed_list as} \<Longrightarrow> freeword (Abs_freeletter s) = [pairtrue s]

goal (1 subgoal):
 1. (Abs_freeletter s \<in> FreeGroup S) = (s \<in> S)
[PROOF STEP]
unfolding FreeGroup_def
[PROOF STATE]
proof (prove)
using this:
[pairtrue s] \<in> {as. proper_signed_list as} \<Longrightarrow> freeword (Abs_freeletter s) = [pairtrue s]

goal (1 subgoal):
 1. (Abs_freeletter s \<in> {x. fst ` set (freeword x) \<subseteq> S}) = (s \<in> S)
[PROOF STEP]
by simp


[STATEMENT]
lemma diff_mod_0_imp_mod_eq:"
  \<lbrakk> (b - a) mod m = 0; a \<le> b \<rbrakk> \<Longrightarrow> (a::nat) mod m = b mod m"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>(b - a) mod m = 0; a \<le> b\<rbrakk> \<Longrightarrow> a mod m = b mod m
[PROOF STEP]
apply (rule ccontr)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>(b - a) mod m = 0; a \<le> b; a mod m \<noteq> b mod m\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
apply (drule mod_neq_imp_diff_mod_neq0)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>(b - a) mod m = 0; a \<le> b\<rbrakk> \<Longrightarrow> a \<le> b
 2. \<lbrakk>(b - a) mod m = 0; a \<le> b; 0 < (b - a) mod m\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
apply simp_all
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma implements_trans:
  "\<lbrakk> implements pi1 S1 S2; implements pi2 S2 S3 \<rbrakk>
  \<Longrightarrow> implements (pi1 o pi2) S1 S3"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>implements pi1 S1 S2; implements pi2 S2 S3\<rbrakk> \<Longrightarrow> implements (pi1 \<circ> pi2) S1 S3
[PROOF STEP]
by (auto simp add: implements_def image_comp del: subsetI
         dest: image_mono [where f="map pi1"])


[STATEMENT]
lemma not_mem_eq_mem_not: "a \<notin> A \<longleftrightarrow> a \<in> - A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (a \<notin> A) = (a \<in> - A)
[PROOF STEP]
by auto


[STATEMENT]
lemma mon_pl_set: "mon_pl w = \<Union>{ fst e \<union> snd e | e. e\<in>set w }"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mon_pl w = \<Union> {fst e \<union> snd e |e. e \<in> set w}
[PROOF STEP]
by (auto simp add: mon_pl_def foldl_set) blast+


[STATEMENT]
lemma length_Cons: "length (x # xs) = Suc (length xs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (x # xs) = Suc (length xs)
[PROOF STEP]
by simp


[STATEMENT]
lemma divides_primepow:
  assumes "prime p" and "a dvd p ^ n"
  obtains m where "m \<le> n" and "normalize a = p ^ m"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>m. \<lbrakk>m \<le> n; normalize a = p ^ m\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using divides_primepow_weak[OF assms] that assms
[PROOF STATE]
proof (prove)
using this:
(\<And>m. \<lbrakk>m \<le> n; normalize a = normalize (p ^ m)\<rbrakk> \<Longrightarrow> ?thesis) \<Longrightarrow> ?thesis
\<lbrakk>?m1 \<le> n; normalize a = p ^ ?m1\<rbrakk> \<Longrightarrow> thesis
prime p
a dvd p ^ n

goal (1 subgoal):
 1. (\<And>m. \<lbrakk>m \<le> n; normalize a = p ^ m\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (auto simp add: normalize_power)


[STATEMENT]
lemma card_literal: "CARD(String.literal) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. CARD(String.literal) = 0
[PROOF STEP]
by(simp add: card_eq_0_iff infinite_literal)


[STATEMENT]
theorem I_pres_qe: "Z.normal \<phi> \<Longrightarrow>  Z.I (qe_pres \<phi>) xs = Z.I \<phi> xs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Z.normal \<phi> \<Longrightarrow> Z.I (qe_pres \<phi>) xs = Z.I \<phi> xs
[PROOF STEP]
by(simp add:qe_pres_def Z.I_lift_dnf_qe_anormal I_qe_pres\<^sub>1_o qfree_qe_pres_o normal_qe_pres\<^sub>1_o del:o_apply)


[STATEMENT]
lemma modI_numeral_numeral [simp]:
  "mod\<cdot>(numeral i)\<cdot>(numeral j) = MkI' (Rings.modulo (numeral i) (numeral j))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mod\<cdot>(numeral i)\<cdot>(numeral j) = MkI' (modulo (numeral i) (numeral j))
[PROOF STEP]
unfolding numeral_Integer_eq mod_Integer_def MkI'_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (case MkI\<cdot>(numeral i) of MkI\<cdot>x \<Rightarrow> \<Lambda> (MkI\<cdot>y). MkI\<cdot>(modulo x y))\<cdot>(MkI\<cdot>(numeral j)) = MkI\<cdot>(modulo (numeral i) (numeral j))
[PROOF STEP]
by simp


[STATEMENT]
lemma Sigma_mset_mono:
  assumes "A \<subseteq># C" and "\<And>x. x \<in># A \<Longrightarrow> B x \<subseteq># D x"
  shows "Sigma_mset A B \<subseteq># Sigma_mset C D"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Sigma_mset A B \<subseteq># Sigma_mset C D
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. Sigma_mset A B \<subseteq># Sigma_mset C D
[PROOF STEP]
have "count A a * count (B a) b \<le> count C a * count (D a) b" for a b
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. count A a * count (B a) b \<le> count C a * count (D a) b
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
A \<subseteq># C
?x \<in># A \<Longrightarrow> B ?x \<subseteq># D ?x

goal (1 subgoal):
 1. count A a * count (B a) b \<le> count C a * count (D a) b
[PROOF STEP]
unfolding subseteq_mset_def
[PROOF STATE]
proof (prove)
using this:
\<forall>a. count A a \<le> count C a
?x \<in># A \<Longrightarrow> \<forall>a. count (B ?x) a \<le> count (D ?x) a

goal (1 subgoal):
 1. count A a * count (B a) b \<le> count C a * count (D a) b
[PROOF STEP]
by (metis count_inI eq_iff mult_eq_0_iff mult_le_mono)
[PROOF STATE]
proof (state)
this:
count A ?a * count (B ?a) ?b \<le> count C ?a * count (D ?a) ?b

goal (1 subgoal):
 1. Sigma_mset A B \<subseteq># Sigma_mset C D
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
count A ?a * count (B ?a) ?b \<le> count C ?a * count (D ?a) ?b
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
count A ?a * count (B ?a) ?b \<le> count C ?a * count (D ?a) ?b

goal (1 subgoal):
 1. Sigma_mset A B \<subseteq># Sigma_mset C D
[PROOF STEP]
by (auto simp: subseteq_mset_def count_Sigma_mset)
[PROOF STATE]
proof (state)
this:
Sigma_mset A B \<subseteq># Sigma_mset C D

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma le_1_WtFT[simp]: "0 \<le> 1 - WtFT cl" (is "0 \<le> ?R")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 \<le> 1 - WtFT cl
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. 0 \<le> 1 - WtFT cl
[PROOF STEP]
have a: "-1 \<le> - WtFT cl"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. - 1 \<le> - WtFT cl
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
- 1 \<le> - WtFT cl

goal (1 subgoal):
 1. 0 \<le> 1 - WtFT cl
[PROOF STEP]
have "(0 :: real) = 1 + (-1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 = 1 + - 1
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
0 = 1 + - 1

goal (1 subgoal):
 1. 0 \<le> 1 - WtFT cl
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
0 = 1 + - 1

goal (1 subgoal):
 1. 0 \<le> 1 - WtFT cl
[PROOF STEP]
have "1 + (-1) \<le> 1 + (- WtFT cl)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 + - 1 \<le> 1 + - WtFT cl
[PROOF STEP]
using a
[PROOF STATE]
proof (prove)
using this:
- 1 \<le> - WtFT cl

goal (1 subgoal):
 1. 1 + - 1 \<le> 1 + - WtFT cl
[PROOF STEP]
by arith
[PROOF STATE]
proof (state)
this:
1 + - 1 \<le> 1 + - WtFT cl

goal (1 subgoal):
 1. 0 \<le> 1 - WtFT cl
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
1 + - 1 \<le> 1 + - WtFT cl

goal (1 subgoal):
 1. 0 \<le> 1 - WtFT cl
[PROOF STEP]
have "... = ?R"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 + - WtFT cl = 1 - WtFT cl
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
1 + - WtFT cl = 1 - WtFT cl

goal (1 subgoal):
 1. 0 \<le> 1 - WtFT cl
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
0 \<le> 1 - WtFT cl
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
0 \<le> 1 - WtFT cl

goal (1 subgoal):
 1. 0 \<le> 1 - WtFT cl
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
0 \<le> 1 - WtFT cl

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma zero_in_lattice:
  assumes fs_carrier: "set fs \<subseteq> carrier_vec n"
  shows "0\<^sub>v n \<in> lattice_of fs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0\<^sub>v n \<in> lattice_of fs
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. 0\<^sub>v n \<in> lattice_of fs
[PROOF STEP]
have "\<forall>f. lincomb (\<lambda>v. 0 * f v) (set fs) = 0\<^sub>v n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>f. lincomb (\<lambda>v. 0 * f v) (set fs) = 0\<^sub>v n
[PROOF STEP]
using fs_carrier lincomb_closed lincomb_smult lmult_0
[PROOF STATE]
proof (prove)
using this:
set fs \<subseteq> carrier_vec n
?S \<subseteq> carrier_vec n \<Longrightarrow> lincomb ?a ?S \<in> carrier_vec n
?A \<subseteq> carrier_vec n \<Longrightarrow> lincomb (\<lambda>w. ?c * ?a w) ?A = ?c \<cdot>\<^sub>v lincomb ?a ?A
?m \<in> carrier_vec n \<Longrightarrow> 0 \<cdot>\<^sub>v ?m = 0\<^sub>v n

goal (1 subgoal):
 1. \<forall>f. lincomb (\<lambda>v. 0 * f v) (set fs) = 0\<^sub>v n
[PROOF STEP]
by presburger
[PROOF STATE]
proof (state)
this:
\<forall>f. lincomb (\<lambda>v. 0 * f v) (set fs) = 0\<^sub>v n

goal (1 subgoal):
 1. 0\<^sub>v n \<in> lattice_of fs
[PROOF STEP]
hence "lincomb (\<lambda>i. 0) (set fs) = 0\<^sub>v n"
[PROOF STATE]
proof (prove)
using this:
\<forall>f. lincomb (\<lambda>v. 0 * f v) (set fs) = 0\<^sub>v n

goal (1 subgoal):
 1. lincomb (\<lambda>i. 0) (set fs) = 0\<^sub>v n
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
lincomb (\<lambda>i. 0) (set fs) = 0\<^sub>v n

goal (1 subgoal):
 1. 0\<^sub>v n \<in> lattice_of fs
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
lincomb (\<lambda>i. 0) (set fs) = 0\<^sub>v n

goal (1 subgoal):
 1. 0\<^sub>v n \<in> lattice_of fs
[PROOF STEP]
unfolding lattice_of_altdef_lincomb[OF fs_carrier]
[PROOF STATE]
proof (prove)
using this:
lincomb (\<lambda>i. 0) (set fs) = 0\<^sub>v n

goal (1 subgoal):
 1. 0\<^sub>v n \<in> {y. \<exists>f. lincomb (of_int \<circ> f) (set fs) = y}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
0\<^sub>v n \<in> lattice_of fs

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma acyclic_3c_3d:
  shows "acyclic_3c x \<longleftrightarrow> acyclic_3d x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. acyclic_3c x = acyclic_3d x
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. acyclic_3c x = acyclic_3d x
[PROOF STEP]
have "\<And>y z . y \<le> z \<and> z \<le> y\<^sup>+ \<longleftrightarrow> y \<le> z \<and> y\<^sup>+ = z\<^sup>+"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>y z. (y \<le> z \<and> z \<le> y\<^sup>+) = (y \<le> z \<and> y\<^sup>+ = z\<^sup>+)
[PROOF STEP]
apply (rule iffI)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>y z. y \<le> z \<and> z \<le> y\<^sup>+ \<Longrightarrow> y \<le> z \<and> y\<^sup>+ = z\<^sup>+
 2. \<And>y z. y \<le> z \<and> y\<^sup>+ = z\<^sup>+ \<Longrightarrow> y \<le> z \<and> z \<le> y\<^sup>+
[PROOF STEP]
apply (smt comp_associative plus_sup star.circ_transitive_equal star.left_plus_circ sup_absorb1 sup_absorb2)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>y z. y \<le> z \<and> y\<^sup>+ = z\<^sup>+ \<Longrightarrow> y \<le> z \<and> z \<le> y\<^sup>+
[PROOF STEP]
by (simp add: star.circ_mult_increasing)
[PROOF STATE]
proof (state)
this:
(?y1 \<le> ?z1 \<and> ?z1 \<le> ?y1\<^sup>+) = (?y1 \<le> ?z1 \<and> ?y1\<^sup>+ = ?z1\<^sup>+)

goal (1 subgoal):
 1. acyclic_3c x = acyclic_3d x
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
(?y1 \<le> ?z1 \<and> ?z1 \<le> ?y1\<^sup>+) = (?y1 \<le> ?z1 \<and> ?y1\<^sup>+ = ?z1\<^sup>+)

goal (1 subgoal):
 1. acyclic_3c x = acyclic_3d x
[PROOF STEP]
by (simp add: acyclic_3c_def acyclic_3d_def)
[PROOF STATE]
proof (state)
this:
acyclic_3c x = acyclic_3d x

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma aff_dim_linear_image_le:
  assumes "linear f"
    shows "aff_dim(f ` S) \<le> aff_dim S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. aff_dim (f ` S) \<le> aff_dim S
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. aff_dim (f ` S) \<le> aff_dim S
[PROOF STEP]
have "aff_dim (f ` T) \<le> aff_dim T" if "affine T" for T
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. aff_dim (f ` T) \<le> aff_dim T
[PROOF STEP]
proof (cases "T = {}")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. T = {} \<Longrightarrow> aff_dim (f ` T) \<le> aff_dim T
 2. T \<noteq> {} \<Longrightarrow> aff_dim (f ` T) \<le> aff_dim T
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
T = {}

goal (2 subgoals):
 1. T = {} \<Longrightarrow> aff_dim (f ` T) \<le> aff_dim T
 2. T \<noteq> {} \<Longrightarrow> aff_dim (f ` T) \<le> aff_dim T
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
T = {}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
T = {}

goal (1 subgoal):
 1. aff_dim (f ` T) \<le> aff_dim T
[PROOF STEP]
by (simp add: aff_dim_geq)
[PROOF STATE]
proof (state)
this:
aff_dim (f ` T) \<le> aff_dim T

goal (1 subgoal):
 1. T \<noteq> {} \<Longrightarrow> aff_dim (f ` T) \<le> aff_dim T
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. T \<noteq> {} \<Longrightarrow> aff_dim (f ` T) \<le> aff_dim T
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
T \<noteq> {}

goal (1 subgoal):
 1. T \<noteq> {} \<Longrightarrow> aff_dim (f ` T) \<le> aff_dim T
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
T \<noteq> {}
[PROOF STEP]
obtain a where "a \<in> T"
[PROOF STATE]
proof (prove)
using this:
T \<noteq> {}

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

goal (1 subgoal):
 1. T \<noteq> {} \<Longrightarrow> aff_dim (f ` T) \<le> aff_dim T
[PROOF STEP]
have 1: "((\<lambda>x. x - f a) ` f ` T) = {x - f a |x. x \<in> f ` T}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. x - f a) ` f ` T = {x - f a |x. x \<in> f ` T}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<lambda>x. x - f a) ` f ` T = {x - f a |x. x \<in> f ` T}

goal (1 subgoal):
 1. T \<noteq> {} \<Longrightarrow> aff_dim (f ` T) \<le> aff_dim T
[PROOF STEP]
have 2: "{x - f a| x. x \<in> f ` T} = f ` ((\<lambda>x. x - a) ` T)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {x - f a |x. x \<in> f ` T} = f ` (\<lambda>x. x - a) ` T
[PROOF STEP]
by (force simp: linear_diff [OF assms])
[PROOF STATE]
proof (state)
this:
{x - f a |x. x \<in> f ` T} = f ` (\<lambda>x. x - a) ` T

goal (1 subgoal):
 1. T \<noteq> {} \<Longrightarrow> aff_dim (f ` T) \<le> aff_dim T
[PROOF STEP]
have "aff_dim (f ` T) = int (dim {x - f a |x. x \<in> f ` T})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. aff_dim (f ` T) = int (dim {x - f a |x. x \<in> f ` T})
[PROOF STEP]
by (simp add: \<open>a \<in> T\<close> hull_inc aff_dim_eq_dim [of "f a"] 1 cong: image_cong_simp)
[PROOF STATE]
proof (state)
this:
aff_dim (f ` T) = int (dim {x - f a |x. x \<in> f ` T})

goal (1 subgoal):
 1. T \<noteq> {} \<Longrightarrow> aff_dim (f ` T) \<le> aff_dim T
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
aff_dim (f ` T) = int (dim {x - f a |x. x \<in> f ` T})

goal (1 subgoal):
 1. T \<noteq> {} \<Longrightarrow> aff_dim (f ` T) \<le> aff_dim T
[PROOF STEP]
have "... = int (dim (f ` ((\<lambda>x. x - a) ` T)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. int (dim {x - f a |x. x \<in> f ` T}) = int (dim (f ` (\<lambda>x. x - a) ` T))
[PROOF STEP]
by (force simp: linear_diff [OF assms] 2)
[PROOF STATE]
proof (state)
this:
int (dim {x - f a |x. x \<in> f ` T}) = int (dim (f ` (\<lambda>x. x - a) ` T))

goal (1 subgoal):
 1. T \<noteq> {} \<Longrightarrow> aff_dim (f ` T) \<le> aff_dim T
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
int (dim {x - f a |x. x \<in> f ` T}) = int (dim (f ` (\<lambda>x. x - a) ` T))

goal (1 subgoal):
 1. T \<noteq> {} \<Longrightarrow> aff_dim (f ` T) \<le> aff_dim T
[PROOF STEP]
have "... \<le> int (dim ((\<lambda>x. x - a) ` T))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. int (dim (f ` (\<lambda>x. x - a) ` T)) \<le> int (dim ((\<lambda>x. x - a) ` T))
[PROOF STEP]
by (simp add: dim_image_le [OF assms])
[PROOF STATE]
proof (state)
this:
int (dim (f ` (\<lambda>x. x - a) ` T)) \<le> int (dim ((\<lambda>x. x - a) ` T))

goal (1 subgoal):
 1. T \<noteq> {} \<Longrightarrow> aff_dim (f ` T) \<le> aff_dim T
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
int (dim (f ` (\<lambda>x. x - a) ` T)) \<le> int (dim ((\<lambda>x. x - a) ` T))

goal (1 subgoal):
 1. T \<noteq> {} \<Longrightarrow> aff_dim (f ` T) \<le> aff_dim T
[PROOF STEP]
have "... \<le> aff_dim T"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. int (dim ((\<lambda>x. x - a) ` T)) \<le> aff_dim T
[PROOF STEP]
by (simp add: aff_dim_dim_affine_diffs [symmetric] \<open>a \<in> T\<close> \<open>affine T\<close>)
[PROOF STATE]
proof (state)
this:
int (dim ((\<lambda>x. x - a) ` T)) \<le> aff_dim T

goal (1 subgoal):
 1. T \<noteq> {} \<Longrightarrow> aff_dim (f ` T) \<le> aff_dim T
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
aff_dim (f ` T) \<le> aff_dim T
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
aff_dim (f ` T) \<le> aff_dim T

goal (1 subgoal):
 1. aff_dim (f ` T) \<le> aff_dim T
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
aff_dim (f ` T) \<le> aff_dim T

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
affine ?T \<Longrightarrow> aff_dim (f ` ?T) \<le> aff_dim ?T

goal (1 subgoal):
 1. aff_dim (f ` S) \<le> aff_dim S
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
affine ?T \<Longrightarrow> aff_dim (f ` ?T) \<le> aff_dim ?T
[PROOF STEP]
have "aff_dim (f ` (affine hull S)) \<le> aff_dim (affine hull S)"
[PROOF STATE]
proof (prove)
using this:
affine ?T \<Longrightarrow> aff_dim (f ` ?T) \<le> aff_dim ?T

goal (1 subgoal):
 1. aff_dim (f ` (affine hull S)) \<le> aff_dim (affine hull S)
[PROOF STEP]
using affine_affine_hull [of S]
[PROOF STATE]
proof (prove)
using this:
affine ?T \<Longrightarrow> aff_dim (f ` ?T) \<le> aff_dim ?T
affine (affine hull S)

goal (1 subgoal):
 1. aff_dim (f ` (affine hull S)) \<le> aff_dim (affine hull S)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
aff_dim (f ` (affine hull S)) \<le> aff_dim (affine hull S)

goal (1 subgoal):
 1. aff_dim (f ` S) \<le> aff_dim S
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
aff_dim (f ` (affine hull S)) \<le> aff_dim (affine hull S)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
aff_dim (f ` (affine hull S)) \<le> aff_dim (affine hull S)

goal (1 subgoal):
 1. aff_dim (f ` S) \<le> aff_dim S
[PROOF STEP]
using affine_hull_linear_image assms linear_conv_bounded_linear
[PROOF STATE]
proof (prove)
using this:
aff_dim (f ` (affine hull S)) \<le> aff_dim (affine hull S)
bounded_linear ?f \<Longrightarrow> ?f ` (affine hull ?s) = affine hull ?f ` ?s
linear f
linear ?f = bounded_linear ?f

goal (1 subgoal):
 1. aff_dim (f ` S) \<le> aff_dim S
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
aff_dim (f ` S) \<le> aff_dim S

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma Ex_surj_conv' [reversal_rule]: assumes "surj f" shows "Ex (P o f) \<longleftrightarrow> Ex P"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Ex (P \<circ> f) = Ex P
[PROOF STEP]
unfolding comp_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<exists>x. P (f x)) = Ex P
[PROOF STEP]
using Ex_surj_conv[OF assms]
[PROOF STATE]
proof (prove)
using this:
(\<exists>x. ?P (f x)) = (\<exists>y. ?P y)

goal (1 subgoal):
 1. (\<exists>x. P (f x)) = Ex P
[PROOF STEP]
.

  \<comment> \<open>\<^const>\<open>Ex1\<close>\<close>


[STATEMENT]
lemma has_contour_integral_shiftpath:
  assumes f: "(f has_contour_integral i) g" "valid_path g"
      and a: "a \<in> {0..1}"
    shows "(f has_contour_integral i) (shiftpath a g)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (f has_contour_integral i) (shiftpath a g)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (f has_contour_integral i) (shiftpath a g)
[PROOF STEP]
obtain S
    where S: "finite S" and g: "\<forall>x\<in>{0..1} - S. g differentiable at x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>S. \<lbrakk>finite S; \<forall>x\<in>{0..1} - S. g differentiable at x\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
(f has_contour_integral i) g
valid_path g
a \<in> {0..1}

goal (1 subgoal):
 1. (\<And>S. \<lbrakk>finite S; \<forall>x\<in>{0..1} - S. g differentiable at x\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (auto simp: valid_path_def piecewise_C1_differentiable_on_def C1_differentiable_on_eq)
[PROOF STATE]
proof (state)
this:
finite S
\<forall>x\<in>{0..1} - S. g differentiable at x

goal (1 subgoal):
 1. (f has_contour_integral i) (shiftpath a g)
[PROOF STEP]
have *: "((\<lambda>x. f (g x) * vector_derivative g (at x)) has_integral i) {0..1}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>x. f (g x) * vector_derivative g (at x)) has_integral i) {0..1}
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
(f has_contour_integral i) g
valid_path g
a \<in> {0..1}

goal (1 subgoal):
 1. ((\<lambda>x. f (g x) * vector_derivative g (at x)) has_integral i) {0..1}
[PROOF STEP]
by (auto simp: has_contour_integral)
[PROOF STATE]
proof (state)
this:
((\<lambda>x. f (g x) * vector_derivative g (at x)) has_integral i) {0..1}

goal (1 subgoal):
 1. (f has_contour_integral i) (shiftpath a g)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
((\<lambda>x. f (g x) * vector_derivative g (at x)) has_integral i) {0..1}
[PROOF STEP]
have i: "i = integral {a..1} (\<lambda>x. f (g x) * vector_derivative g (at x)) +
                    integral {0..a} (\<lambda>x. f (g x) * vector_derivative g (at x))"
[PROOF STATE]
proof (prove)
using this:
((\<lambda>x. f (g x) * vector_derivative g (at x)) has_integral i) {0..1}

goal (1 subgoal):
 1. i = integral {a..1} (\<lambda>x. f (g x) * vector_derivative g (at x)) + integral {0..a} (\<lambda>x. f (g x) * vector_derivative g (at x))
[PROOF STEP]
apply (rule has_integral_unique)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>x. f (g x) * vector_derivative g (at x)) has_integral integral {a..1} (\<lambda>x. f (g x) * vector_derivative g (at x)) + integral {0..a} (\<lambda>x. f (g x) * vector_derivative g (at x))) {0..1}
[PROOF STEP]
apply (subst add.commute)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>x. f (g x) * vector_derivative g (at x)) has_integral integral {0..a} (\<lambda>x. f (g x) * vector_derivative g (at x)) + integral {a..1} (\<lambda>x. f (g x) * vector_derivative g (at x))) {0..1}
[PROOF STEP]
apply (subst Henstock_Kurzweil_Integration.integral_combine)
[PROOF STATE]
proof (prove)
goal (4 subgoals):
 1. 0 \<le> a
 2. a \<le> 1
 3. (\<lambda>x. f (g x) * vector_derivative g (at x)) integrable_on {0..1}
 4. ((\<lambda>x. f (g x) * vector_derivative g (at x)) has_integral integral {0..1} (\<lambda>x. f (g x) * vector_derivative g (at x))) {0..1}
[PROOF STEP]
using assms * integral_unique
[PROOF STATE]
proof (prove)
using this:
(f has_contour_integral i) g
valid_path g
a \<in> {0..1}
((\<lambda>x. f (g x) * vector_derivative g (at x)) has_integral i) {0..1}
(?f has_integral ?y) ?k \<Longrightarrow> integral ?k ?f = ?y

goal (4 subgoals):
 1. 0 \<le> a
 2. a \<le> 1
 3. (\<lambda>x. f (g x) * vector_derivative g (at x)) integrable_on {0..1}
 4. ((\<lambda>x. f (g x) * vector_derivative g (at x)) has_integral integral {0..1} (\<lambda>x. f (g x) * vector_derivative g (at x))) {0..1}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
i = integral {a..1} (\<lambda>x. f (g x) * vector_derivative g (at x)) + integral {0..a} (\<lambda>x. f (g x) * vector_derivative g (at x))

goal (1 subgoal):
 1. (f has_contour_integral i) (shiftpath a g)
[PROOF STEP]
have vd1: "vector_derivative (shiftpath a g) (at x) = vector_derivative g (at (x + a))"
    if "0 \<le> x" "x + a < 1" "x \<notin> (\<lambda>x. x - a) ` S" for x
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vector_derivative (shiftpath a g) (at x) = vector_derivative g (at (x + a))
[PROOF STEP]
unfolding shiftpath_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vector_derivative (\<lambda>x. if a + x \<le> 1 then g (a + x) else g (a + x - 1)) (at x) = vector_derivative g (at (x + a))
[PROOF STEP]
proof (rule vector_derivative_at [OF has_vector_derivative_transform_within])
[PROOF STATE]
proof (state)
goal (4 subgoals):
 1. (?f1 has_vector_derivative vector_derivative g (at (x + a))) (at x)
 2. 0 < ?d1
 3. x \<in> UNIV
 4. \<And>x'. \<lbrakk>x' \<in> UNIV; dist x' x < ?d1\<rbrakk> \<Longrightarrow> ?f1 x' = (if a + x' \<le> 1 then g (a + x') else g (a + x' - 1))
[PROOF STEP]
have "((\<lambda>x. g (x + a)) has_vector_derivative vector_derivative g (at (a + x))) (at x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>x. g (x + a)) has_vector_derivative vector_derivative g (at (a + x))) (at x)
[PROOF STEP]
proof (rule vector_diff_chain_at [of _ 1, simplified o_def scaleR_one])
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. ((\<lambda>x. x + a) has_vector_derivative 1) (at x)
 2. (g has_vector_derivative vector_derivative g (at (a + x))) (at (x + a))
[PROOF STEP]
show "((\<lambda>x. x + a) has_vector_derivative 1) (at x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>x. x + a) has_vector_derivative 1) (at x)
[PROOF STEP]
by (rule derivative_eq_intros | simp)+
[PROOF STATE]
proof (state)
this:
((\<lambda>x. x + a) has_vector_derivative 1) (at x)

goal (1 subgoal):
 1. (g has_vector_derivative vector_derivative g (at (a + x))) (at (x + a))
[PROOF STEP]
have "g differentiable at (x + a)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. g differentiable at (x + a)
[PROOF STEP]
using g a that
[PROOF STATE]
proof (prove)
using this:
\<forall>x\<in>{0..1} - S. g differentiable at x
a \<in> {0..1}
0 \<le> x
x + a < 1
x \<notin> (\<lambda>x. x - a) ` S

goal (1 subgoal):
 1. g differentiable at (x + a)
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
g differentiable at (x + a)

goal (1 subgoal):
 1. (g has_vector_derivative vector_derivative g (at (a + x))) (at (x + a))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
g differentiable at (x + a)
[PROOF STEP]
show "(g has_vector_derivative vector_derivative g (at (a + x))) (at (x + a))"
[PROOF STATE]
proof (prove)
using this:
g differentiable at (x + a)

goal (1 subgoal):
 1. (g has_vector_derivative vector_derivative g (at (a + x))) (at (x + a))
[PROOF STEP]
by (metis add.commute vector_derivative_works)
[PROOF STATE]
proof (state)
this:
(g has_vector_derivative vector_derivative g (at (a + x))) (at (x + a))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
((\<lambda>x. g (x + a)) has_vector_derivative vector_derivative g (at (a + x))) (at x)

goal (4 subgoals):
 1. (?f1 has_vector_derivative vector_derivative g (at (x + a))) (at x)
 2. 0 < ?d1
 3. x \<in> UNIV
 4. \<And>x'. \<lbrakk>x' \<in> UNIV; dist x' x < ?d1\<rbrakk> \<Longrightarrow> ?f1 x' = (if a + x' \<le> 1 then g (a + x') else g (a + x' - 1))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
((\<lambda>x. g (x + a)) has_vector_derivative vector_derivative g (at (a + x))) (at x)
[PROOF STEP]
show "((\<lambda>x. g (a + x)) has_vector_derivative vector_derivative g (at (x + a))) (at x)"
[PROOF STATE]
proof (prove)
using this:
((\<lambda>x. g (x + a)) has_vector_derivative vector_derivative g (at (a + x))) (at x)

goal (1 subgoal):
 1. ((\<lambda>x. g (a + x)) has_vector_derivative vector_derivative g (at (x + a))) (at x)
[PROOF STEP]
by (auto simp: field_simps)
[PROOF STATE]
proof (state)
this:
((\<lambda>x. g (a + x)) has_vector_derivative vector_derivative g (at (x + a))) (at x)

goal (3 subgoals):
 1. 0 < ?d1
 2. x \<in> UNIV
 3. \<And>x'. \<lbrakk>x' \<in> UNIV; dist x' x < ?d1\<rbrakk> \<Longrightarrow> g (a + x') = (if a + x' \<le> 1 then g (a + x') else g (a + x' - 1))
[PROOF STEP]
show "0 < dist (1 - a) x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < dist (1 - a) x
[PROOF STEP]
using that
[PROOF STATE]
proof (prove)
using this:
0 \<le> x
x + a < 1
x \<notin> (\<lambda>x. x - a) ` S

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

goal (2 subgoals):
 1. x \<in> UNIV
 2. \<And>x'. \<lbrakk>x' \<in> UNIV; dist x' x < dist (1 - a) x\<rbrakk> \<Longrightarrow> g (a + x') = (if a + x' \<le> 1 then g (a + x') else g (a + x' - 1))
[PROOF STEP]
qed (use that in \<open>auto simp: dist_real_def\<close>)
[PROOF STATE]
proof (state)
this:
\<lbrakk>0 \<le> ?x; ?x + a < 1; ?x \<notin> (\<lambda>x. x - a) ` S\<rbrakk> \<Longrightarrow> vector_derivative (shiftpath a g) (at ?x) = vector_derivative g (at (?x + a))

goal (1 subgoal):
 1. (f has_contour_integral i) (shiftpath a g)
[PROOF STEP]
have vd2: "vector_derivative (shiftpath a g) (at x) = vector_derivative g (at (x + a - 1))"
    if "x \<le> 1" "1 < x + a" "x \<notin> (\<lambda>x. x - a + 1) ` S" for x
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vector_derivative (shiftpath a g) (at x) = vector_derivative g (at (x + a - 1))
[PROOF STEP]
unfolding shiftpath_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vector_derivative (\<lambda>x. if a + x \<le> 1 then g (a + x) else g (a + x - 1)) (at x) = vector_derivative g (at (x + a - 1))
[PROOF STEP]
proof (rule vector_derivative_at [OF has_vector_derivative_transform_within])
[PROOF STATE]
proof (state)
goal (4 subgoals):
 1. (?f1 has_vector_derivative vector_derivative g (at (x + a - 1))) (at x)
 2. 0 < ?d1
 3. x \<in> UNIV
 4. \<And>x'. \<lbrakk>x' \<in> UNIV; dist x' x < ?d1\<rbrakk> \<Longrightarrow> ?f1 x' = (if a + x' \<le> 1 then g (a + x') else g (a + x' - 1))
[PROOF STEP]
have "((\<lambda>x. g (x + a - 1)) has_vector_derivative vector_derivative g (at (a+x-1))) (at x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>x. g (x + a - 1)) has_vector_derivative vector_derivative g (at (a + x - 1))) (at x)
[PROOF STEP]
proof (rule vector_diff_chain_at [of _ 1, simplified o_def scaleR_one])
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. ((\<lambda>x. x + a - 1) has_vector_derivative 1) (at x)
 2. (g has_vector_derivative vector_derivative g (at (a + x - 1))) (at (x + a - 1))
[PROOF STEP]
show "((\<lambda>x. x + a - 1) has_vector_derivative 1) (at x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>x. x + a - 1) has_vector_derivative 1) (at x)
[PROOF STEP]
by (rule derivative_eq_intros | simp)+
[PROOF STATE]
proof (state)
this:
((\<lambda>x. x + a - 1) has_vector_derivative 1) (at x)

goal (1 subgoal):
 1. (g has_vector_derivative vector_derivative g (at (a + x - 1))) (at (x + a - 1))
[PROOF STEP]
have "g differentiable at (x+a-1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. g differentiable at (x + a - 1)
[PROOF STEP]
using g a that
[PROOF STATE]
proof (prove)
using this:
\<forall>x\<in>{0..1} - S. g differentiable at x
a \<in> {0..1}
x \<le> 1
1 < x + a
x \<notin> (\<lambda>x. x - a + 1) ` S

goal (1 subgoal):
 1. g differentiable at (x + a - 1)
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
g differentiable at (x + a - 1)

goal (1 subgoal):
 1. (g has_vector_derivative vector_derivative g (at (a + x - 1))) (at (x + a - 1))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
g differentiable at (x + a - 1)
[PROOF STEP]
show "(g has_vector_derivative vector_derivative g (at (a+x-1))) (at (x + a - 1))"
[PROOF STATE]
proof (prove)
using this:
g differentiable at (x + a - 1)

goal (1 subgoal):
 1. (g has_vector_derivative vector_derivative g (at (a + x - 1))) (at (x + a - 1))
[PROOF STEP]
by (metis add.commute vector_derivative_works)
[PROOF STATE]
proof (state)
this:
(g has_vector_derivative vector_derivative g (at (a + x - 1))) (at (x + a - 1))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
((\<lambda>x. g (x + a - 1)) has_vector_derivative vector_derivative g (at (a + x - 1))) (at x)

goal (4 subgoals):
 1. (?f1 has_vector_derivative vector_derivative g (at (x + a - 1))) (at x)
 2. 0 < ?d1
 3. x \<in> UNIV
 4. \<And>x'. \<lbrakk>x' \<in> UNIV; dist x' x < ?d1\<rbrakk> \<Longrightarrow> ?f1 x' = (if a + x' \<le> 1 then g (a + x') else g (a + x' - 1))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
((\<lambda>x. g (x + a - 1)) has_vector_derivative vector_derivative g (at (a + x - 1))) (at x)
[PROOF STEP]
show "((\<lambda>x. g (a + x - 1)) has_vector_derivative vector_derivative g (at (x + a - 1))) (at x)"
[PROOF STATE]
proof (prove)
using this:
((\<lambda>x. g (x + a - 1)) has_vector_derivative vector_derivative g (at (a + x - 1))) (at x)

goal (1 subgoal):
 1. ((\<lambda>x. g (a + x - 1)) has_vector_derivative vector_derivative g (at (x + a - 1))) (at x)
[PROOF STEP]
by (auto simp: field_simps)
[PROOF STATE]
proof (state)
this:
((\<lambda>x. g (a + x - 1)) has_vector_derivative vector_derivative g (at (x + a - 1))) (at x)

goal (3 subgoals):
 1. 0 < ?d1
 2. x \<in> UNIV
 3. \<And>x'. \<lbrakk>x' \<in> UNIV; dist x' x < ?d1\<rbrakk> \<Longrightarrow> g (a + x' - 1) = (if a + x' \<le> 1 then g (a + x') else g (a + x' - 1))
[PROOF STEP]
show "0 < dist (1 - a) x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < dist (1 - a) x
[PROOF STEP]
using that
[PROOF STATE]
proof (prove)
using this:
x \<le> 1
1 < x + a
x \<notin> (\<lambda>x. x - a + 1) ` S

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

goal (2 subgoals):
 1. x \<in> UNIV
 2. \<And>x'. \<lbrakk>x' \<in> UNIV; dist x' x < dist (1 - a) x\<rbrakk> \<Longrightarrow> g (a + x' - 1) = (if a + x' \<le> 1 then g (a + x') else g (a + x' - 1))
[PROOF STEP]
qed (use that in \<open>auto simp: dist_real_def\<close>)
[PROOF STATE]
proof (state)
this:
\<lbrakk>?x \<le> 1; 1 < ?x + a; ?x \<notin> (\<lambda>x. x - a + 1) ` S\<rbrakk> \<Longrightarrow> vector_derivative (shiftpath a g) (at ?x) = vector_derivative g (at (?x + a - 1))

goal (1 subgoal):
 1. (f has_contour_integral i) (shiftpath a g)
[PROOF STEP]
have va1: "(\<lambda>x. f (g x) * vector_derivative g (at x)) integrable_on ({a..1})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. f (g x) * vector_derivative g (at x)) integrable_on {a..1}
[PROOF STEP]
using * a
[PROOF STATE]
proof (prove)
using this:
((\<lambda>x. f (g x) * vector_derivative g (at x)) has_integral i) {0..1}
a \<in> {0..1}

goal (1 subgoal):
 1. (\<lambda>x. f (g x) * vector_derivative g (at x)) integrable_on {a..1}
[PROOF STEP]
by (fastforce intro: integrable_subinterval_real)
[PROOF STATE]
proof (state)
this:
(\<lambda>x. f (g x) * vector_derivative g (at x)) integrable_on {a..1}

goal (1 subgoal):
 1. (f has_contour_integral i) (shiftpath a g)
[PROOF STEP]
have v0a: "(\<lambda>x. f (g x) * vector_derivative g (at x)) integrable_on ({0..a})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. f (g x) * vector_derivative g (at x)) integrable_on {0..a}
[PROOF STEP]
using * a
[PROOF STATE]
proof (prove)
using this:
((\<lambda>x. f (g x) * vector_derivative g (at x)) has_integral i) {0..1}
a \<in> {0..1}

goal (1 subgoal):
 1. (\<lambda>x. f (g x) * vector_derivative g (at x)) integrable_on {0..a}
[PROOF STEP]
by (force intro: integrable_subinterval_real)
[PROOF STATE]
proof (state)
this:
(\<lambda>x. f (g x) * vector_derivative g (at x)) integrable_on {0..a}

goal (1 subgoal):
 1. (f has_contour_integral i) (shiftpath a g)
[PROOF STEP]
have "finite ({1 - a} \<union> (\<lambda>x. x - a) ` S)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite ({1 - a} \<union> (\<lambda>x. x - a) ` S)
[PROOF STEP]
using S
[PROOF STATE]
proof (prove)
using this:
finite S

goal (1 subgoal):
 1. finite ({1 - a} \<union> (\<lambda>x. x - a) ` S)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
finite ({1 - a} \<union> (\<lambda>x. x - a) ` S)

goal (1 subgoal):
 1. (f has_contour_integral i) (shiftpath a g)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
finite ({1 - a} \<union> (\<lambda>x. x - a) ` S)
[PROOF STEP]
have "((\<lambda>x. f (shiftpath a g x) * vector_derivative (shiftpath a g) (at x))
        has_integral integral {a..1} (\<lambda>x. f (g x) * vector_derivative g (at x)))  {0..1 - a}"
[PROOF STATE]
proof (prove)
using this:
finite ({1 - a} \<union> (\<lambda>x. x - a) ` S)

goal (1 subgoal):
 1. ((\<lambda>x. f (shiftpath a g x) * vector_derivative (shiftpath a g) (at x)) has_integral integral {a..1} (\<lambda>x. f (g x) * vector_derivative g (at x))) {0..1 - a}
[PROOF STEP]
apply (rule has_integral_spike_finite
        [where f = "\<lambda>x. f(g(a+x)) * vector_derivative g (at(a+x))"])
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>x. x \<in> {0..1 - a} - ({1 - a} \<union> (\<lambda>x. x - a) ` S) \<Longrightarrow> f (shiftpath a g x) * vector_derivative (shiftpath a g) (at x) = f (g (a + x)) * vector_derivative g (at (a + x))
 2. ((\<lambda>x. f (g (a + x)) * vector_derivative g (at (a + x))) has_integral integral {a..1} (\<lambda>x. f (g x) * vector_derivative g (at x))) {0..1 - a}
[PROOF STEP]
subgoal
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x_ \<in> {0..1 - a} - ({1 - a} \<union> (\<lambda>x. x - a) ` S) \<Longrightarrow> f (shiftpath a g x_) * vector_derivative (shiftpath a g) (at x_) = f (g (a + x_)) * vector_derivative g (at (a + x_))
[PROOF STEP]
using a
[PROOF STATE]
proof (prove)
using this:
a \<in> {0..1}

goal (1 subgoal):
 1. x_ \<in> {0..1 - a} - ({1 - a} \<union> (\<lambda>x. x - a) ` S) \<Longrightarrow> f (shiftpath a g x_) * vector_derivative (shiftpath a g) (at x_) = f (g (a + x_)) * vector_derivative g (at (a + x_))
[PROOF STEP]
by (simp add: vd1) (force simp: shiftpath_def add.commute)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>x. f (g (a + x)) * vector_derivative g (at (a + x))) has_integral integral {a..1} (\<lambda>x. f (g x) * vector_derivative g (at x))) {0..1 - a}
[PROOF STEP]
subgoal
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>x. f (g (a + x)) * vector_derivative g (at (a + x))) has_integral integral {a..1} (\<lambda>x. f (g x) * vector_derivative g (at x))) {0..1 - a}
[PROOF STEP]
using has_integral_affinity [where m=1 and c=a] integrable_integral [OF va1]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>(?f has_integral ?i) (cbox ?a ?b); 1 \<noteq> 0\<rbrakk> \<Longrightarrow> ((\<lambda>x. ?f (1 *\<^sub>R x + a)) has_integral (1 / \<bar>1\<bar> ^ DIM(real)) *\<^sub>R ?i) ((\<lambda>x. (1 / 1) *\<^sub>R x + - ((1 / 1) *\<^sub>R a)) ` cbox ?a ?b)
((\<lambda>x. f (g x) * vector_derivative g (at x)) has_integral integral {a..1} (\<lambda>x. f (g x) * vector_derivative g (at x))) {a..1}

goal (1 subgoal):
 1. ((\<lambda>x. f (g (a + x)) * vector_derivative g (at (a + x))) has_integral integral {a..1} (\<lambda>x. f (g x) * vector_derivative g (at x))) {0..1 - a}
[PROOF STEP]
by (force simp add: add.commute)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
((\<lambda>x. f (shiftpath a g x) * vector_derivative (shiftpath a g) (at x)) has_integral integral {a..1} (\<lambda>x. f (g x) * vector_derivative g (at x))) {0..1 - a}

goal (1 subgoal):
 1. (f has_contour_integral i) (shiftpath a g)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
((\<lambda>x. f (shiftpath a g x) * vector_derivative (shiftpath a g) (at x)) has_integral integral {a..1} (\<lambda>x. f (g x) * vector_derivative g (at x))) {0..1 - a}

goal (1 subgoal):
 1. (f has_contour_integral i) (shiftpath a g)
[PROOF STEP]
have "finite ({1 - a} \<union> (\<lambda>x. x - a + 1) ` S)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite ({1 - a} \<union> (\<lambda>x. x - a + 1) ` S)
[PROOF STEP]
using S
[PROOF STATE]
proof (prove)
using this:
finite S

goal (1 subgoal):
 1. finite ({1 - a} \<union> (\<lambda>x. x - a + 1) ` S)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
finite ({1 - a} \<union> (\<lambda>x. x - a + 1) ` S)

goal (1 subgoal):
 1. (f has_contour_integral i) (shiftpath a g)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
finite ({1 - a} \<union> (\<lambda>x. x - a + 1) ` S)
[PROOF STEP]
have "((\<lambda>x. f (shiftpath a g x) * vector_derivative (shiftpath a g) (at x))
             has_integral  integral {0..a} (\<lambda>x. f (g x) * vector_derivative g (at x)))  {1 - a..1}"
[PROOF STATE]
proof (prove)
using this:
finite ({1 - a} \<union> (\<lambda>x. x - a + 1) ` S)

goal (1 subgoal):
 1. ((\<lambda>x. f (shiftpath a g x) * vector_derivative (shiftpath a g) (at x)) has_integral integral {0..a} (\<lambda>x. f (g x) * vector_derivative g (at x))) {1 - a..1}
[PROOF STEP]
apply (rule has_integral_spike_finite
        [where f = "\<lambda>x. f(g(a+x-1)) * vector_derivative g (at(a+x-1))"])
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>x. x \<in> {1 - a..1} - ({1 - a} \<union> (\<lambda>x. x - a + 1) ` S) \<Longrightarrow> f (shiftpath a g x) * vector_derivative (shiftpath a g) (at x) = f (g (a + x - 1)) * vector_derivative g (at (a + x - 1))
 2. ((\<lambda>x. f (g (a + x - 1)) * vector_derivative g (at (a + x - 1))) has_integral integral {0..a} (\<lambda>x. f (g x) * vector_derivative g (at x))) {1 - a..1}
[PROOF STEP]
subgoal
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x_ \<in> {1 - a..1} - ({1 - a} \<union> (\<lambda>x. x - a + 1) ` S) \<Longrightarrow> f (shiftpath a g x_) * vector_derivative (shiftpath a g) (at x_) = f (g (a + x_ - 1)) * vector_derivative g (at (a + x_ - 1))
[PROOF STEP]
using a
[PROOF STATE]
proof (prove)
using this:
a \<in> {0..1}

goal (1 subgoal):
 1. x_ \<in> {1 - a..1} - ({1 - a} \<union> (\<lambda>x. x - a + 1) ` S) \<Longrightarrow> f (shiftpath a g x_) * vector_derivative (shiftpath a g) (at x_) = f (g (a + x_ - 1)) * vector_derivative g (at (a + x_ - 1))
[PROOF STEP]
by (simp add: vd2) (force simp: shiftpath_def add.commute)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>x. f (g (a + x - 1)) * vector_derivative g (at (a + x - 1))) has_integral integral {0..a} (\<lambda>x. f (g x) * vector_derivative g (at x))) {1 - a..1}
[PROOF STEP]
subgoal
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>x. f (g (a + x - 1)) * vector_derivative g (at (a + x - 1))) has_integral integral {0..a} (\<lambda>x. f (g x) * vector_derivative g (at x))) {1 - a..1}
[PROOF STEP]
using has_integral_affinity [where m=1 and c="a-1", simplified, OF integrable_integral [OF v0a]]
[PROOF STATE]
proof (prove)
using this:
((\<lambda>x. f (g (x + (a - 1))) * vector_derivative g (at (x + (a - 1)))) has_integral integral {0..a} (\<lambda>x. f (g x) * vector_derivative g (at x))) {0 + (1 - a)..a + (1 - a)}

goal (1 subgoal):
 1. ((\<lambda>x. f (g (a + x - 1)) * vector_derivative g (at (a + x - 1))) has_integral integral {0..a} (\<lambda>x. f (g x) * vector_derivative g (at x))) {1 - a..1}
[PROOF STEP]
by (force simp add: algebra_simps)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
((\<lambda>x. f (shiftpath a g x) * vector_derivative (shiftpath a g) (at x)) has_integral integral {0..a} (\<lambda>x. f (g x) * vector_derivative g (at x))) {1 - a..1}

goal (1 subgoal):
 1. (f has_contour_integral i) (shiftpath a g)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
((\<lambda>x. f (shiftpath a g x) * vector_derivative (shiftpath a g) (at x)) has_integral integral {a..1} (\<lambda>x. f (g x) * vector_derivative g (at x))) {0..1 - a}
((\<lambda>x. f (shiftpath a g x) * vector_derivative (shiftpath a g) (at x)) has_integral integral {0..a} (\<lambda>x. f (g x) * vector_derivative g (at x))) {1 - a..1}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
((\<lambda>x. f (shiftpath a g x) * vector_derivative (shiftpath a g) (at x)) has_integral integral {a..1} (\<lambda>x. f (g x) * vector_derivative g (at x))) {0..1 - a}
((\<lambda>x. f (shiftpath a g x) * vector_derivative (shiftpath a g) (at x)) has_integral integral {0..a} (\<lambda>x. f (g x) * vector_derivative g (at x))) {1 - a..1}

goal (1 subgoal):
 1. (f has_contour_integral i) (shiftpath a g)
[PROOF STEP]
using a
[PROOF STATE]
proof (prove)
using this:
((\<lambda>x. f (shiftpath a g x) * vector_derivative (shiftpath a g) (at x)) has_integral integral {a..1} (\<lambda>x. f (g x) * vector_derivative g (at x))) {0..1 - a}
((\<lambda>x. f (shiftpath a g x) * vector_derivative (shiftpath a g) (at x)) has_integral integral {0..a} (\<lambda>x. f (g x) * vector_derivative g (at x))) {1 - a..1}
a \<in> {0..1}

goal (1 subgoal):
 1. (f has_contour_integral i) (shiftpath a g)
[PROOF STEP]
by (auto simp: i has_contour_integral intro: has_integral_combine [where c = "1-a"])
[PROOF STATE]
proof (state)
this:
(f has_contour_integral i) (shiftpath a g)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma cos_eq_neg_periodic_intro:
  assumes "x - y=2*(of_int k)*pi + pi \<or> x + y = 2*(of_int k)*pi + pi"
  shows "cos x = - cos y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cos x = - cos y
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
x - y = 2 * real_of_int k * pi + pi \<or> x + y = 2 * real_of_int k * pi + pi

goal (1 subgoal):
 1. cos x = - cos y
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. x - y = 2 * real_of_int k * pi + pi \<Longrightarrow> cos x = - cos y
 2. x + y = 2 * real_of_int k * pi + pi \<Longrightarrow> cos x = - cos y
[PROOF STEP]
assume "x - y = 2 * (of_int k) * pi + pi"
[PROOF STATE]
proof (state)
this:
x - y = 2 * real_of_int k * pi + pi

goal (2 subgoals):
 1. x - y = 2 * real_of_int k * pi + pi \<Longrightarrow> cos x = - cos y
 2. x + y = 2 * real_of_int k * pi + pi \<Longrightarrow> cos x = - cos y
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
x - y = 2 * real_of_int k * pi + pi
[PROOF STEP]
have "cos x = cos ((y+ pi) + (of_int k)*(2*pi))"
[PROOF STATE]
proof (prove)
using this:
x - y = 2 * real_of_int k * pi + pi

goal (1 subgoal):
 1. cos x = cos (y + pi + real_of_int k * (2 * pi))
[PROOF STEP]
by (auto simp add:algebra_simps)
[PROOF STATE]
proof (state)
this:
cos x = cos (y + pi + real_of_int k * (2 * pi))

goal (2 subgoals):
 1. x - y = 2 * real_of_int k * pi + pi \<Longrightarrow> cos x = - cos y
 2. x + y = 2 * real_of_int k * pi + pi \<Longrightarrow> cos x = - cos y
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
cos x = cos (y + pi + real_of_int k * (2 * pi))

goal (2 subgoals):
 1. x - y = 2 * real_of_int k * pi + pi \<Longrightarrow> cos x = - cos y
 2. x + y = 2 * real_of_int k * pi + pi \<Longrightarrow> cos x = - cos y
[PROOF STEP]
have "... = cos (y+pi)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cos (y + pi + real_of_int k * (2 * pi)) = cos (y + pi)
[PROOF STEP]
using cos.periodic_simps[of "y+pi"]
[PROOF STATE]
proof (prove)
using this:
cos (y + pi + real ?na * (2 * of_real pi)) = cos (y + pi)
cos (y + pi - real ?na * (2 * of_real pi)) = cos (y + pi)
cos (y + pi + real_of_int ?n * (2 * of_real pi)) = cos (y + pi)
cos (y + pi - real_of_int ?n * (2 * of_real pi)) = cos (y + pi)
cos (y + pi + numeral ?nb * (2 * of_real pi)) = cos (y + pi)
cos (y + pi - numeral ?nb * (2 * of_real pi)) = cos (y + pi)
cos (y + pi + 2 * of_real pi) = cos (y + pi)
cos (y + pi - 2 * of_real pi) = cos (y + pi)

goal (1 subgoal):
 1. cos (y + pi + real_of_int k * (2 * pi)) = cos (y + pi)
[PROOF STEP]
by (auto simp add:algebra_simps)
[PROOF STATE]
proof (state)
this:
cos (y + pi + real_of_int k * (2 * pi)) = cos (y + pi)

goal (2 subgoals):
 1. x - y = 2 * real_of_int k * pi + pi \<Longrightarrow> cos x = - cos y
 2. x + y = 2 * real_of_int k * pi + pi \<Longrightarrow> cos x = - cos y
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
cos (y + pi + real_of_int k * (2 * pi)) = cos (y + pi)

goal (2 subgoals):
 1. x - y = 2 * real_of_int k * pi + pi \<Longrightarrow> cos x = - cos y
 2. x + y = 2 * real_of_int k * pi + pi \<Longrightarrow> cos x = - cos y
[PROOF STEP]
have "... = - cos y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cos (y + pi) = - cos y
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
cos (y + pi) = - cos y

goal (2 subgoals):
 1. x - y = 2 * real_of_int k * pi + pi \<Longrightarrow> cos x = - cos y
 2. x + y = 2 * real_of_int k * pi + pi \<Longrightarrow> cos x = - cos y
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
cos x = - cos y
[PROOF STEP]
show "cos x = - cos y"
[PROOF STATE]
proof (prove)
using this:
cos x = - cos y

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

goal (1 subgoal):
 1. x + y = 2 * real_of_int k * pi + pi \<Longrightarrow> cos x = - cos y
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. x + y = 2 * real_of_int k * pi + pi \<Longrightarrow> cos x = - cos y
[PROOF STEP]
assume "x + y = 2 * real_of_int k * pi + pi "
[PROOF STATE]
proof (state)
this:
x + y = 2 * real_of_int k * pi + pi

goal (1 subgoal):
 1. x + y = 2 * real_of_int k * pi + pi \<Longrightarrow> cos x = - cos y
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
x + y = 2 * real_of_int k * pi + pi
[PROOF STEP]
have "cos x = cos ((- y+ pi) + (of_int k)*(2*pi))"
[PROOF STATE]
proof (prove)
using this:
x + y = 2 * real_of_int k * pi + pi

goal (1 subgoal):
 1. cos x = cos (- y + pi + real_of_int k * (2 * pi))
[PROOF STEP]
apply (intro arg_cong[where f=cos])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x + y = 2 * real_of_int k * pi + pi \<Longrightarrow> x = - y + pi + real_of_int k * (2 * pi)
[PROOF STEP]
by (auto simp add:algebra_simps)
[PROOF STATE]
proof (state)
this:
cos x = cos (- y + pi + real_of_int k * (2 * pi))

goal (1 subgoal):
 1. x + y = 2 * real_of_int k * pi + pi \<Longrightarrow> cos x = - cos y
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
cos x = cos (- y + pi + real_of_int k * (2 * pi))

goal (1 subgoal):
 1. x + y = 2 * real_of_int k * pi + pi \<Longrightarrow> cos x = - cos y
[PROOF STEP]
have "... = cos (- y +pi)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cos (- y + pi + real_of_int k * (2 * pi)) = cos (- y + pi)
[PROOF STEP]
using cos.periodic_simps[of "-y+pi"]
[PROOF STATE]
proof (prove)
using this:
cos (- y + pi + real ?na * (2 * of_real pi)) = cos (- y + pi)
cos (- y + pi - real ?na * (2 * of_real pi)) = cos (- y + pi)
cos (- y + pi + real_of_int ?n * (2 * of_real pi)) = cos (- y + pi)
cos (- y + pi - real_of_int ?n * (2 * of_real pi)) = cos (- y + pi)
cos (- y + pi + numeral ?nb * (2 * of_real pi)) = cos (- y + pi)
cos (- y + pi - numeral ?nb * (2 * of_real pi)) = cos (- y + pi)
cos (- y + pi + 2 * of_real pi) = cos (- y + pi)
cos (- y + pi - 2 * of_real pi) = cos (- y + pi)

goal (1 subgoal):
 1. cos (- y + pi + real_of_int k * (2 * pi)) = cos (- y + pi)
[PROOF STEP]
by (auto simp add:algebra_simps)
[PROOF STATE]
proof (state)
this:
cos (- y + pi + real_of_int k * (2 * pi)) = cos (- y + pi)

goal (1 subgoal):
 1. x + y = 2 * real_of_int k * pi + pi \<Longrightarrow> cos x = - cos y
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
cos (- y + pi + real_of_int k * (2 * pi)) = cos (- y + pi)

goal (1 subgoal):
 1. x + y = 2 * real_of_int k * pi + pi \<Longrightarrow> cos x = - cos y
[PROOF STEP]
have "... = - cos y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cos (- y + pi) = - cos y
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
cos (- y + pi) = - cos y

goal (1 subgoal):
 1. x + y = 2 * real_of_int k * pi + pi \<Longrightarrow> cos x = - cos y
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
cos x = - cos y
[PROOF STEP]
show "cos x = - cos y"
[PROOF STATE]
proof (prove)
using this:
cos x = - cos y

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

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma closure_eq_lfinite:
  assumes closed_Q: "closed {xs. Q xs}"
  assumes downwards_Q: "\<And>xs ys. Q xs \<Longrightarrow> lprefix ys xs \<Longrightarrow> Q ys"
  shows "{xs. Q xs} = closure {xs. lfinite xs \<and> Q xs}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {xs. Q xs} = closure {xs. lfinite xs \<and> Q xs}
[PROOF STEP]
proof (rule closure_unique[symmetric])
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. {xs. lfinite xs \<and> Q xs} \<subseteq> {xs. Q xs}
 2. closed {xs. Q xs}
 3. \<And>T'. \<lbrakk>{xs. lfinite xs \<and> Q xs} \<subseteq> T'; closed T'\<rbrakk> \<Longrightarrow> {xs. Q xs} \<subseteq> T'
[PROOF STEP]
fix T
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. {xs. lfinite xs \<and> Q xs} \<subseteq> {xs. Q xs}
 2. closed {xs. Q xs}
 3. \<And>T'. \<lbrakk>{xs. lfinite xs \<and> Q xs} \<subseteq> T'; closed T'\<rbrakk> \<Longrightarrow> {xs. Q xs} \<subseteq> T'
[PROOF STEP]
assume T: "{xs. lfinite xs \<and> Q xs} \<subseteq> T" and "closed T"
[PROOF STATE]
proof (state)
this:
{xs. lfinite xs \<and> Q xs} \<subseteq> T
closed T

goal (3 subgoals):
 1. {xs. lfinite xs \<and> Q xs} \<subseteq> {xs. Q xs}
 2. closed {xs. Q xs}
 3. \<And>T'. \<lbrakk>{xs. lfinite xs \<and> Q xs} \<subseteq> T'; closed T'\<rbrakk> \<Longrightarrow> {xs. Q xs} \<subseteq> T'
[PROOF STEP]
show "{xs. Q xs} \<subseteq> T"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {xs. Q xs} \<subseteq> T
[PROOF STEP]
proof clarify
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. Q x \<Longrightarrow> x \<in> T
[PROOF STEP]
fix xs :: "'a llist"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. Q x \<Longrightarrow> x \<in> T
[PROOF STEP]
let ?F = "{ys. lprefix ys xs \<and> lfinite ys}"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. Q x \<Longrightarrow> x \<in> T
[PROOF STEP]
assume "Q xs"
[PROOF STATE]
proof (state)
this:
Q xs

goal (1 subgoal):
 1. \<And>x. Q x \<Longrightarrow> x \<in> T
[PROOF STEP]
with T downwards_Q
[PROOF STATE]
proof (chain)
picking this:
{xs. lfinite xs \<and> Q xs} \<subseteq> T
\<lbrakk>Q ?xs; lprefix ?ys ?xs\<rbrakk> \<Longrightarrow> Q ?ys
Q xs
[PROOF STEP]
have "?F \<subseteq> T"
[PROOF STATE]
proof (prove)
using this:
{xs. lfinite xs \<and> Q xs} \<subseteq> T
\<lbrakk>Q ?xs; lprefix ?ys ?xs\<rbrakk> \<Longrightarrow> Q ?ys
Q xs

goal (1 subgoal):
 1. {ys. lprefix ys xs \<and> lfinite ys} \<subseteq> T
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
{ys. lprefix ys xs \<and> lfinite ys} \<subseteq> T

goal (1 subgoal):
 1. \<And>x. Q x \<Longrightarrow> x \<in> T
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
{ys. lprefix ys xs \<and> lfinite ys} \<subseteq> T

goal (1 subgoal):
 1. \<And>x. Q x \<Longrightarrow> x \<in> T
[PROOF STEP]
have "chain ?F" "?F \<noteq> {}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. chain {ys. lprefix ys xs \<and> lfinite ys} &&& {ys. lprefix ys xs \<and> lfinite ys} \<noteq> {}
[PROOF STEP]
by (auto intro: lprefixes_chain chain_subset)
[PROOF STATE]
proof (state)
this:
chain {ys. lprefix ys xs \<and> lfinite ys}
{ys. lprefix ys xs \<and> lfinite ys} \<noteq> {}

goal (1 subgoal):
 1. \<And>x. Q x \<Longrightarrow> x \<in> T
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
chain {ys. lprefix ys xs \<and> lfinite ys}
{ys. lprefix ys xs \<and> lfinite ys} \<noteq> {}

goal (1 subgoal):
 1. \<And>x. Q x \<Longrightarrow> x \<in> T
[PROOF STEP]
have "lSup ?F = xs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. lSup {ys. lprefix ys xs \<and> lfinite ys} = xs
[PROOF STEP]
by (rule lSup_finite_prefixes)
[PROOF STATE]
proof (state)
this:
lSup {ys. lprefix ys xs \<and> lfinite ys} = xs

goal (1 subgoal):
 1. \<And>x. Q x \<Longrightarrow> x \<in> T
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
{ys. lprefix ys xs \<and> lfinite ys} \<subseteq> T
chain {ys. lprefix ys xs \<and> lfinite ys}
{ys. lprefix ys xs \<and> lfinite ys} \<noteq> {}
lSup {ys. lprefix ys xs \<and> lfinite ys} = xs
[PROOF STEP]
show "xs \<in> T"
[PROOF STATE]
proof (prove)
using this:
{ys. lprefix ys xs \<and> lfinite ys} \<subseteq> T
chain {ys. lprefix ys xs \<and> lfinite ys}
{ys. lprefix ys xs \<and> lfinite ys} \<noteq> {}
lSup {ys. lprefix ys xs \<and> lfinite ys} = xs

goal (1 subgoal):
 1. xs \<in> T
[PROOF STEP]
using \<open>closed T\<close>
[PROOF STATE]
proof (prove)
using this:
{ys. lprefix ys xs \<and> lfinite ys} \<subseteq> T
chain {ys. lprefix ys xs \<and> lfinite ys}
{ys. lprefix ys xs \<and> lfinite ys} \<noteq> {}
lSup {ys. lprefix ys xs \<and> lfinite ys} = xs
closed T

goal (1 subgoal):
 1. xs \<in> T
[PROOF STEP]
by (auto simp: closed_ccpo Sup_llist_def)
[PROOF STATE]
proof (state)
this:
xs \<in> T

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
{xs. Q xs} \<subseteq> T

goal (2 subgoals):
 1. {xs. lfinite xs \<and> Q xs} \<subseteq> {xs. Q xs}
 2. closed {xs. Q xs}
[PROOF STEP]
qed (auto simp: closed_Q)


[STATEMENT]
lemma col_index: assumes m: "mat nr nc m"
  and i: "i < nc"
  shows "col m i = map (\<lambda> j. m ! i ! j) [0 ..< nr]"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. col m i = map ((!) (m ! i)) [0..<nr]
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. col m i = map ((!) (m ! i)) [0..<nr]
[PROOF STEP]
from m[unfolded mat_def] i
[PROOF STATE]
proof (chain)
picking this:
length m = nc \<and> Ball (set m) (vec nr)
i < nc
[PROOF STEP]
have nr: "nr = length (m ! i)"
[PROOF STATE]
proof (prove)
using this:
length m = nc \<and> Ball (set m) (vec nr)
i < nc

goal (1 subgoal):
 1. nr = length (m ! i)
[PROOF STEP]
by (auto simp: vec_def)
[PROOF STATE]
proof (state)
this:
nr = length (m ! i)

goal (1 subgoal):
 1. col m i = map ((!) (m ! i)) [0..<nr]
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. col m i = map ((!) (m ! i)) [0..<nr]
[PROOF STEP]
unfolding nr col_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. m ! i = map ((!) (m ! i)) [0..<length (m ! i)]
[PROOF STEP]
by (rule map_nth[symmetric])
[PROOF STATE]
proof (state)
this:
col m i = map ((!) (m ! i)) [0..<nr]

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma insertion_polypow[simp]: "insertion e (a ^\<^sub>p b) = insertion e a ^ b"
  for a::"'a::comm_ring_1 poly"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. insertion e (a ^\<^sub>p b) = insertion e a ^ b
[PROOF STEP]
proof (induction b rule: nat_less_induct)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n. \<forall>m<n. insertion e (a ^\<^sub>p m) = insertion e a ^ m \<Longrightarrow> insertion e (a ^\<^sub>p n) = insertion e a ^ n
[PROOF STEP]
case (1 n)
[PROOF STATE]
proof (state)
this:
\<forall>m<n. insertion e (a ^\<^sub>p m) = insertion e a ^ m

goal (1 subgoal):
 1. \<And>n. \<forall>m<n. insertion e (a ^\<^sub>p m) = insertion e a ^ m \<Longrightarrow> insertion e (a ^\<^sub>p n) = insertion e a ^ n
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<forall>m<n. insertion e (a ^\<^sub>p m) = insertion e a ^ m
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
\<forall>m<n. insertion e (a ^\<^sub>p m) = insertion e a ^ m

goal (1 subgoal):
 1. insertion e (a ^\<^sub>p n) = insertion e a ^ n
[PROOF STEP]
proof (cases n)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<lbrakk>\<forall>m<n. insertion e (a ^\<^sub>p m) = insertion e a ^ m; n = 0\<rbrakk> \<Longrightarrow> insertion e (a ^\<^sub>p n) = insertion e a ^ n
 2. \<And>nat. \<lbrakk>\<forall>m<n. insertion e (a ^\<^sub>p m) = insertion e a ^ m; n = Suc nat\<rbrakk> \<Longrightarrow> insertion e (a ^\<^sub>p n) = insertion e a ^ n
[PROOF STEP]
case (Suc nat)
[PROOF STATE]
proof (state)
this:
n = Suc nat

goal (2 subgoals):
 1. \<lbrakk>\<forall>m<n. insertion e (a ^\<^sub>p m) = insertion e a ^ m; n = 0\<rbrakk> \<Longrightarrow> insertion e (a ^\<^sub>p n) = insertion e a ^ n
 2. \<And>nat. \<lbrakk>\<forall>m<n. insertion e (a ^\<^sub>p m) = insertion e a ^ m; n = Suc nat\<rbrakk> \<Longrightarrow> insertion e (a ^\<^sub>p n) = insertion e a ^ n
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
n = Suc nat
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
n = Suc nat

goal (1 subgoal):
 1. insertion e (a ^\<^sub>p n) = insertion e a ^ n
[PROOF STEP]
apply auto
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n = Suc nat \<Longrightarrow> insertion e (let q = a ^\<^sub>p Suc nat div 2; d = q *\<^sub>p q in if odd nat then d else a *\<^sub>p d) = insertion e a * insertion e a ^ nat
[PROOF STEP]
apply (auto simp: Let_def div2_less_self 1 simp del: polypow.simps)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>n = Suc nat; odd nat\<rbrakk> \<Longrightarrow> insertion e a * insertion e a ^ (nat div 2) * (insertion e a * insertion e a ^ (nat div 2)) = insertion e a * insertion e a ^ nat
 2. \<lbrakk>n = Suc nat; even nat\<rbrakk> \<Longrightarrow> insertion e a * (insertion e a ^ (nat div 2) * insertion e a ^ (nat div 2)) = insertion e a * insertion e a ^ nat
[PROOF STEP]
apply (metis even_Suc even_two_times_div_two odd_Suc_div_two semiring_normalization_rules(27) semiring_normalization_rules(36))
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>n = Suc nat; even nat\<rbrakk> \<Longrightarrow> insertion e a * (insertion e a ^ (nat div 2) * insertion e a ^ (nat div 2)) = insertion e a * insertion e a ^ nat
[PROOF STEP]
apply (metis even_two_times_div_two semiring_normalization_rules(36))
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
insertion e (a ^\<^sub>p n) = insertion e a ^ n

goal (1 subgoal):
 1. \<lbrakk>\<forall>m<n. insertion e (a ^\<^sub>p m) = insertion e a ^ m; n = 0\<rbrakk> \<Longrightarrow> insertion e (a ^\<^sub>p n) = insertion e a ^ n
[PROOF STEP]
qed simp
[PROOF STATE]
proof (state)
this:
insertion e (a ^\<^sub>p n) = insertion e a ^ n

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma fls_is_left_unit_iff_base_is_left_unit:
  fixes f :: "'a :: ring_1_no_zero_divisors fls"
  shows "(\<exists>g. 1 = f * g) \<longleftrightarrow> (\<exists>k. 1 = f $$ fls_subdegree f * k)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<exists>g. 1 = f * g) = (\<exists>k. (1::'a) = f $$ fls_subdegree f * k)
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<exists>g. 1 = f * g \<Longrightarrow> \<exists>k. (1::'a) = f $$ fls_subdegree f * k
 2. \<exists>k. (1::'a) = f $$ fls_subdegree f * k \<Longrightarrow> \<exists>g. 1 = f * g
[PROOF STEP]
assume "\<exists>g. 1 = f * g"
[PROOF STATE]
proof (state)
this:
\<exists>g. 1 = f * g

goal (2 subgoals):
 1. \<exists>g. 1 = f * g \<Longrightarrow> \<exists>k. (1::'a) = f $$ fls_subdegree f * k
 2. \<exists>k. (1::'a) = f $$ fls_subdegree f * k \<Longrightarrow> \<exists>g. 1 = f * g
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<exists>g. 1 = f * g
[PROOF STEP]
obtain g where "1 = f * g"
[PROOF STATE]
proof (prove)
using this:
\<exists>g. 1 = f * g

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

goal (2 subgoals):
 1. \<exists>g. 1 = f * g \<Longrightarrow> \<exists>k. (1::'a) = f $$ fls_subdegree f * k
 2. \<exists>k. (1::'a) = f $$ fls_subdegree f * k \<Longrightarrow> \<exists>g. 1 = f * g
[PROOF STEP]
hence "1 = (f $$ fls_subdegree f) * (g $$ fls_subdegree g)"
[PROOF STATE]
proof (prove)
using this:
1 = f * g

goal (1 subgoal):
 1. (1::'a) = f $$ fls_subdegree f * g $$ fls_subdegree g
[PROOF STEP]
using fls_subdegree_mult[of f g] fls_times_base[of f g]
[PROOF STATE]
proof (prove)
using this:
1 = f * g
\<lbrakk>f \<noteq> 0; g \<noteq> 0\<rbrakk> \<Longrightarrow> fls_subdegree (f * g) = fls_subdegree f + fls_subdegree g
(f * g) $$ (fls_subdegree f + fls_subdegree g) = f $$ fls_subdegree f * g $$ fls_subdegree g

goal (1 subgoal):
 1. (1::'a) = f $$ fls_subdegree f * g $$ fls_subdegree g
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
(1::'a) = f $$ fls_subdegree f * g $$ fls_subdegree g

goal (2 subgoals):
 1. \<exists>g. 1 = f * g \<Longrightarrow> \<exists>k. (1::'a) = f $$ fls_subdegree f * k
 2. \<exists>k. (1::'a) = f $$ fls_subdegree f * k \<Longrightarrow> \<exists>g. 1 = f * g
[PROOF STEP]
thus "\<exists>k. 1 = f $$ fls_subdegree f * k"
[PROOF STATE]
proof (prove)
using this:
(1::'a) = f $$ fls_subdegree f * g $$ fls_subdegree g

goal (1 subgoal):
 1. \<exists>k. (1::'a) = f $$ fls_subdegree f * k
[PROOF STEP]
by fast
[PROOF STATE]
proof (state)
this:
\<exists>k. (1::'a) = f $$ fls_subdegree f * k

goal (1 subgoal):
 1. \<exists>k. (1::'a) = f $$ fls_subdegree f * k \<Longrightarrow> \<exists>g. 1 = f * g
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>k. (1::'a) = f $$ fls_subdegree f * k \<Longrightarrow> \<exists>g. 1 = f * g
[PROOF STEP]
assume "\<exists>k. 1 = f $$ fls_subdegree f * k"
[PROOF STATE]
proof (state)
this:
\<exists>k. (1::'a) = f $$ fls_subdegree f * k

goal (1 subgoal):
 1. \<exists>k. (1::'a) = f $$ fls_subdegree f * k \<Longrightarrow> \<exists>g. 1 = f * g
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<exists>k. (1::'a) = f $$ fls_subdegree f * k
[PROOF STEP]
obtain k where "1 = f $$ fls_subdegree f * k"
[PROOF STATE]
proof (prove)
using this:
\<exists>k. (1::'a) = f $$ fls_subdegree f * k

goal (1 subgoal):
 1. (\<And>k. (1::'a) = f $$ fls_subdegree f * k \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by fast
[PROOF STATE]
proof (state)
this:
(1::'a) = f $$ fls_subdegree f * k

goal (1 subgoal):
 1. \<exists>k. (1::'a) = f $$ fls_subdegree f * k \<Longrightarrow> \<exists>g. 1 = f * g
[PROOF STEP]
hence "1 = f * fls_right_inverse f k"
[PROOF STATE]
proof (prove)
using this:
(1::'a) = f $$ fls_subdegree f * k

goal (1 subgoal):
 1. 1 = f * fls_right_inverse f k
[PROOF STEP]
using fls_right_inverse
[PROOF STATE]
proof (prove)
using this:
(1::'a) = f $$ fls_subdegree f * k
?f $$ fls_subdegree ?f * ?y = (1::?'a) \<Longrightarrow> ?f * fls_right_inverse ?f ?y = 1

goal (1 subgoal):
 1. 1 = f * fls_right_inverse f k
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
1 = f * fls_right_inverse f k

goal (1 subgoal):
 1. \<exists>k. (1::'a) = f $$ fls_subdegree f * k \<Longrightarrow> \<exists>g. 1 = f * g
[PROOF STEP]
thus "\<exists>g. 1 = f * g"
[PROOF STATE]
proof (prove)
using this:
1 = f * fls_right_inverse f k

goal (1 subgoal):
 1. \<exists>g. 1 = f * g
[PROOF STEP]
by fast
[PROOF STATE]
proof (state)
this:
\<exists>g. 1 = f * g

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma Qp_res_eq_zeroI:
  assumes "a \<in> \<O>\<^sub>p"
  assumes "val a \<ge> n"
  shows "Qp_res a n = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Qp_res a n = 0
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. Qp_res a n = 0
[PROOF STEP]
have 0: "val_Zp (to_Zp a) \<ge> n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. eint (int n) \<le> val_Zp (to_Zp a)
[PROOF STEP]
using assms to_Zp_val
[PROOF STATE]
proof (prove)
using this:
a \<in> \<O>\<^sub>p
eint (int n) \<le> val a
?a \<in> \<O>\<^sub>p \<Longrightarrow> val_Zp (to_Zp ?a) = val ?a

goal (1 subgoal):
 1. eint (int n) \<le> val_Zp (to_Zp a)
[PROOF STEP]
by presburger
[PROOF STATE]
proof (state)
this:
eint (int n) \<le> val_Zp (to_Zp a)

goal (1 subgoal):
 1. Qp_res a n = 0
[PROOF STEP]
have 1: "to_Zp a n = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. to_Zp a n = 0
[PROOF STEP]
apply(rule zero_below_val_Zp, rule to_Zp_closed)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. a \<in> carrier Q\<^sub>p
 2. eint (int n) \<le> val_Zp (to_Zp a)
[PROOF STEP]
using val_ring_closed assms
[PROOF STATE]
proof (prove)
using this:
\<O>\<^sub>p \<subseteq> carrier Q\<^sub>p
a \<in> \<O>\<^sub>p
eint (int n) \<le> val a

goal (2 subgoals):
 1. a \<in> carrier Q\<^sub>p
 2. eint (int n) \<le> val_Zp (to_Zp a)
[PROOF STEP]
apply blast
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. eint (int n) \<le> val_Zp (to_Zp a)
[PROOF STEP]
by(rule 0)
[PROOF STATE]
proof (state)
this:
to_Zp a n = 0

goal (1 subgoal):
 1. Qp_res a n = 0
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
to_Zp a n = 0

goal (1 subgoal):
 1. Qp_res a n = 0
[PROOF STEP]
unfolding Qp_res_def
[PROOF STATE]
proof (prove)
using this:
to_Zp a n = 0

goal (1 subgoal):
 1. to_Zp a n = 0
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
Qp_res a n = 0

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma bs_inter_correct: "bs_\<alpha> (bs_inter s1 s2) = bs_\<alpha> s1 \<inter> bs_\<alpha> s2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bs_\<alpha> (bs_inter s1 s2) = bs_\<alpha> s1 \<inter> bs_\<alpha> s2
[PROOF STEP]
unfolding bs_\<alpha>_def bs_inter_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {n. bit (s1 AND s2) n} = {n. bit s1 n} \<inter> {n. bit s2 n}
[PROOF STEP]
by transfer (simp add: bit_eq_iff, auto simp add: bit_simps)


[STATEMENT]
lemma exponential_orderD:
  assumes "exponential_order M c f"
  shows "0 < M" "\<forall>\<^sub>F t in at_top. norm (f t) \<le> M * exp (c * t)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < M &&& \<forall>\<^sub>F t in at_top. norm (f t) \<le> M * exp (c * t)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
exponential_order M c f

goal (1 subgoal):
 1. 0 < M &&& \<forall>\<^sub>F t in at_top. norm (f t) \<le> M * exp (c * t)
[PROOF STEP]
by (auto simp: exponential_order_def)


[STATEMENT]
lemma nths_only_one:
assumes "{i. i < length xs \<and> i\<in>I} = {j}"
shows "nths xs I = [xs!j]"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. nths xs I = [xs ! j]
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. nths xs I = [xs ! j]
[PROOF STEP]
have "set (nths xs I) = {xs!j}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set (nths xs I) = {xs ! j}
[PROOF STEP]
unfolding set_nths
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {xs ! i |i. i < length xs \<and> i \<in> I} = {xs ! j}
[PROOF STEP]
using subset_antisym assms
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?A \<subseteq> ?B; ?B \<subseteq> ?A\<rbrakk> \<Longrightarrow> ?A = ?B
{i. i < length xs \<and> i \<in> I} = {j}

goal (1 subgoal):
 1. {xs ! i |i. i < length xs \<and> i \<in> I} = {xs ! j}
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
set (nths xs I) = {xs ! j}

goal (1 subgoal):
 1. nths xs I = [xs ! j]
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
set (nths xs I) = {xs ! j}

goal (1 subgoal):
 1. nths xs I = [xs ! j]
[PROOF STEP]
have "length (nths xs I) = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (nths xs I) = 1
[PROOF STEP]
unfolding length_nths assms
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card {j} = 1
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
length (nths xs I) = 1

goal (1 subgoal):
 1. nths xs I = [xs ! j]
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
set (nths xs I) = {xs ! j}
length (nths xs I) = 1
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
set (nths xs I) = {xs ! j}
length (nths xs I) = 1

goal (1 subgoal):
 1. nths xs I = [xs ! j]
[PROOF STEP]
by (metis One_nat_def length_0_conv length_Suc_conv the_elem_eq the_elem_set)
[PROOF STATE]
proof (state)
this:
nths xs I = [xs ! j]

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma strong_rev_children:
  assumes "tree_invar t"
  shows "invar (rev [t \<leftarrow> children t. 0 < rank t])"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. invar (rev (filter (\<lambda>t. 0 < rank t) (children t)))
[PROOF STEP]
proof (cases t)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x1 x2 x3 x4. t = Node x1 x2 x3 x4 \<Longrightarrow> invar (rev (filter (\<lambda>t. 0 < rank t) (children t)))
[PROOF STEP]
case (Node e a nat list)
[PROOF STATE]
proof (state)
this:
t = Node e a nat list

goal (1 subgoal):
 1. \<And>x1 x2 x3 x4. t = Node x1 x2 x3 x4 \<Longrightarrow> invar (rev (filter (\<lambda>t. 0 < rank t) (children t)))
[PROOF STEP]
with assms
[PROOF STATE]
proof (chain)
picking this:
tree_invar t
t = Node e a nat list
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
tree_invar t
t = Node e a nat list

goal (1 subgoal):
 1. invar (rev (filter (\<lambda>t. 0 < rank t) (children t)))
[PROOF STEP]
proof (induct "nat" arbitrary: t e a list)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>t e a list. \<lbrakk>tree_invar t; t = Node e a 0 list\<rbrakk> \<Longrightarrow> invar (rev (filter (\<lambda>t. 0 < rank t) (children t)))
 2. \<And>nat t e a list. \<lbrakk>\<And>t e a list. \<lbrakk>tree_invar t; t = Node e a nat list\<rbrakk> \<Longrightarrow> invar (rev (filter (\<lambda>t. 0 < rank t) (children t))); tree_invar t; t = Node e a (Suc nat) list\<rbrakk> \<Longrightarrow> invar (rev (filter (\<lambda>t. 0 < rank t) (children t)))
[PROOF STEP]
case 0
[PROOF STATE]
proof (state)
this:
tree_invar t
t = Node e a 0 list

goal (2 subgoals):
 1. \<And>t e a list. \<lbrakk>tree_invar t; t = Node e a 0 list\<rbrakk> \<Longrightarrow> invar (rev (filter (\<lambda>t. 0 < rank t) (children t)))
 2. \<And>nat t e a list. \<lbrakk>\<And>t e a list. \<lbrakk>tree_invar t; t = Node e a nat list\<rbrakk> \<Longrightarrow> invar (rev (filter (\<lambda>t. 0 < rank t) (children t))); tree_invar t; t = Node e a (Suc nat) list\<rbrakk> \<Longrightarrow> invar (rev (filter (\<lambda>t. 0 < rank t) (children t)))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
tree_invar t
t = Node e a 0 list
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
tree_invar t
t = Node e a 0 list

goal (1 subgoal):
 1. invar (rev (filter (\<lambda>t. 0 < rank t) (children t)))
[PROOF STEP]
by (simp add: invar_def)
[PROOF STATE]
proof (state)
this:
invar (rev (filter (\<lambda>t. 0 < rank t) (children t)))

goal (1 subgoal):
 1. \<And>nat t e a list. \<lbrakk>\<And>t e a list. \<lbrakk>tree_invar t; t = Node e a nat list\<rbrakk> \<Longrightarrow> invar (rev (filter (\<lambda>t. 0 < rank t) (children t))); tree_invar t; t = Node e a (Suc nat) list\<rbrakk> \<Longrightarrow> invar (rev (filter (\<lambda>t. 0 < rank t) (children t)))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>nat t e a list. \<lbrakk>\<And>t e a list. \<lbrakk>tree_invar t; t = Node e a nat list\<rbrakk> \<Longrightarrow> invar (rev (filter (\<lambda>t. 0 < rank t) (children t))); tree_invar t; t = Node e a (Suc nat) list\<rbrakk> \<Longrightarrow> invar (rev (filter (\<lambda>t. 0 < rank t) (children t)))
[PROOF STEP]
case (Suc nat)
[PROOF STATE]
proof (state)
this:
\<lbrakk>tree_invar ?t; ?t = Node ?e ?a nat ?list\<rbrakk> \<Longrightarrow> invar (rev (filter (\<lambda>t. 0 < rank t) (children ?t)))
tree_invar t
t = Node e a (Suc nat) list

goal (1 subgoal):
 1. \<And>nat t e a list. \<lbrakk>\<And>t e a list. \<lbrakk>tree_invar t; t = Node e a nat list\<rbrakk> \<Longrightarrow> invar (rev (filter (\<lambda>t. 0 < rank t) (children t))); tree_invar t; t = Node e a (Suc nat) list\<rbrakk> \<Longrightarrow> invar (rev (filter (\<lambda>t. 0 < rank t) (children t)))
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. invar (rev (filter (\<lambda>t. 0 < rank t) (children t)))
[PROOF STEP]
proof (cases "nat")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. nat = 0 \<Longrightarrow> invar (rev (filter (\<lambda>t. 0 < rank t) (children t)))
 2. \<And>nat. nat = Suc nat \<Longrightarrow> invar (rev (filter (\<lambda>t. 0 < rank t) (children t)))
[PROOF STEP]
case 0
[PROOF STATE]
proof (state)
this:
nat = 0

goal (2 subgoals):
 1. nat = 0 \<Longrightarrow> invar (rev (filter (\<lambda>t. 0 < rank t) (children t)))
 2. \<And>nat. nat = Suc nat \<Longrightarrow> invar (rev (filter (\<lambda>t. 0 < rank t) (children t)))
[PROOF STEP]
with Suc
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>tree_invar ?t; ?t = Node ?e ?a nat ?list\<rbrakk> \<Longrightarrow> invar (rev (filter (\<lambda>t. 0 < rank t) (children ?t)))
tree_invar t
t = Node e a (Suc nat) list
nat = 0
[PROOF STEP]
obtain e1 a1 e2 a2 e' a' where
        O: "tree_invar (Node e1 a1 0 [])" "tree_invar (Node e2 a2 0 [])"
        "t = link (Node e1 a1 0 []) (Node e2 a2 0 [])
        \<or> t = skewlink e' a' (Node e1 a1 0 []) (Node e2 a2 0 [])"
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>tree_invar ?t; ?t = Node ?e ?a nat ?list\<rbrakk> \<Longrightarrow> invar (rev (filter (\<lambda>t. 0 < rank t) (children ?t)))
tree_invar t
t = Node e a (Suc nat) list
nat = 0

goal (1 subgoal):
 1. (\<And>e1 a1 e2 a2 e' a'. \<lbrakk>tree_invar (Node e1 a1 0 []); tree_invar (Node e2 a2 0 []); t = link (Node e1 a1 0 []) (Node e2 a2 0 []) \<or> t = skewlink e' a' (Node e1 a1 0 []) (Node e2 a2 0 [])\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (simp only: tree_invar.simps) blast
[PROOF STATE]
proof (state)
this:
tree_invar (Node e1 a1 0 [])
tree_invar (Node e2 a2 0 [])
t = link (Node e1 a1 0 []) (Node e2 a2 0 []) \<or> t = skewlink e' a' (Node e1 a1 0 []) (Node e2 a2 0 [])

goal (2 subgoals):
 1. nat = 0 \<Longrightarrow> invar (rev (filter (\<lambda>t. 0 < rank t) (children t)))
 2. \<And>nat. nat = Suc nat \<Longrightarrow> invar (rev (filter (\<lambda>t. 0 < rank t) (children t)))
[PROOF STEP]
hence "[t \<leftarrow> children t. 0 < rank t] = []"
[PROOF STATE]
proof (prove)
using this:
tree_invar (Node e1 a1 0 [])
tree_invar (Node e2 a2 0 [])
t = link (Node e1 a1 0 []) (Node e2 a2 0 []) \<or> t = skewlink e' a' (Node e1 a1 0 []) (Node e2 a2 0 [])

goal (1 subgoal):
 1. filter (\<lambda>t. 0 < rank t) (children t) = []
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
filter (\<lambda>t. 0 < rank t) (children t) = []

goal (2 subgoals):
 1. nat = 0 \<Longrightarrow> invar (rev (filter (\<lambda>t. 0 < rank t) (children t)))
 2. \<And>nat. nat = Suc nat \<Longrightarrow> invar (rev (filter (\<lambda>t. 0 < rank t) (children t)))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
filter (\<lambda>t. 0 < rank t) (children t) = []
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
filter (\<lambda>t. 0 < rank t) (children t) = []

goal (1 subgoal):
 1. invar (rev (filter (\<lambda>t. 0 < rank t) (children t)))
[PROOF STEP]
by (simp add: invar_def)
[PROOF STATE]
proof (state)
this:
invar (rev (filter (\<lambda>t. 0 < rank t) (children t)))

goal (1 subgoal):
 1. \<And>nat. nat = Suc nat \<Longrightarrow> invar (rev (filter (\<lambda>t. 0 < rank t) (children t)))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>nat. nat = Suc nat \<Longrightarrow> invar (rev (filter (\<lambda>t. 0 < rank t) (children t)))
[PROOF STEP]
case Suc': (Suc n)
[PROOF STATE]
proof (state)
this:
nat = Suc n

goal (1 subgoal):
 1. \<And>nat. nat = Suc nat \<Longrightarrow> invar (rev (filter (\<lambda>t. 0 < rank t) (children t)))
[PROOF STEP]
from Suc
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>tree_invar ?t; ?t = Node ?e ?a nat ?list\<rbrakk> \<Longrightarrow> invar (rev (filter (\<lambda>t. 0 < rank t) (children ?t)))
tree_invar t
t = Node e a (Suc nat) list
[PROOF STEP]
obtain e1 a1 ts1 e2 a2 ts2 e' a' where
        O: "tree_invar (Node e1 a1 nat ts1)" "tree_invar (Node e2 a2 nat ts2)"
        "t = link (Node e1 a1 nat ts1) (Node e2 a2 nat ts2)
        \<or> t = skewlink e' a' (Node e1 a1 nat ts1) (Node e2 a2 nat ts2)"
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>tree_invar ?t; ?t = Node ?e ?a nat ?list\<rbrakk> \<Longrightarrow> invar (rev (filter (\<lambda>t. 0 < rank t) (children ?t)))
tree_invar t
t = Node e a (Suc nat) list

goal (1 subgoal):
 1. (\<And>e1 a1 ts1 e2 a2 ts2 e' a'. \<lbrakk>tree_invar (Node e1 a1 nat ts1); tree_invar (Node e2 a2 nat ts2); t = link (Node e1 a1 nat ts1) (Node e2 a2 nat ts2) \<or> t = skewlink e' a' (Node e1 a1 nat ts1) (Node e2 a2 nat ts2)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (simp only: tree_invar.simps) blast
[PROOF STATE]
proof (state)
this:
tree_invar (Node e1 a1 nat ts1)
tree_invar (Node e2 a2 nat ts2)
t = link (Node e1 a1 nat ts1) (Node e2 a2 nat ts2) \<or> t = skewlink e' a' (Node e1 a1 nat ts1) (Node e2 a2 nat ts2)

goal (1 subgoal):
 1. \<And>nat. nat = Suc nat \<Longrightarrow> invar (rev (filter (\<lambda>t. 0 < rank t) (children t)))
[PROOF STEP]
hence ch_id:
        "children t = (if a1 \<le> a2 then
          (Node e2 a2 nat ts2)#ts1
        else (Node e1 a1 nat ts1)#ts2)
        \<or>
        children t = (if a' \<le> a1 \<and> a' \<le> a2 then
          [(Node e1 a1 nat ts1), (Node e2 a2 nat ts2)]
        else (if a1 \<le> a2 then
          (Node e' a' 0 []) # (Node e2 a2 nat ts2) # ts1
        else (Node e' a' 0 []) # (Node e1 a1 nat ts1) # ts2))"
[PROOF STATE]
proof (prove)
using this:
tree_invar (Node e1 a1 nat ts1)
tree_invar (Node e2 a2 nat ts2)
t = link (Node e1 a1 nat ts1) (Node e2 a2 nat ts2) \<or> t = skewlink e' a' (Node e1 a1 nat ts1) (Node e2 a2 nat ts2)

goal (1 subgoal):
 1. children t = (if a1 \<le> a2 then Node e2 a2 nat ts2 # ts1 else Node e1 a1 nat ts1 # ts2) \<or> children t = (if a' \<le> a1 \<and> a' \<le> a2 then [Node e1 a1 nat ts1, Node e2 a2 nat ts2] else if a1 \<le> a2 then Node e' a' 0 [] # Node e2 a2 nat ts2 # ts1 else Node e' a' 0 [] # Node e1 a1 nat ts1 # ts2)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
children t = (if a1 \<le> a2 then Node e2 a2 nat ts2 # ts1 else Node e1 a1 nat ts1 # ts2) \<or> children t = (if a' \<le> a1 \<and> a' \<le> a2 then [Node e1 a1 nat ts1, Node e2 a2 nat ts2] else if a1 \<le> a2 then Node e' a' 0 [] # Node e2 a2 nat ts2 # ts1 else Node e' a' 0 [] # Node e1 a1 nat ts1 # ts2)

goal (1 subgoal):
 1. \<And>nat. nat = Suc nat \<Longrightarrow> invar (rev (filter (\<lambda>t. 0 < rank t) (children t)))
[PROOF STEP]
from O Suc(1)[of "Node e1 a1 nat ts1" "e1" "a1" "ts1"]
[PROOF STATE]
proof (chain)
picking this:
tree_invar (Node e1 a1 nat ts1)
tree_invar (Node e2 a2 nat ts2)
t = link (Node e1 a1 nat ts1) (Node e2 a2 nat ts2) \<or> t = skewlink e' a' (Node e1 a1 nat ts1) (Node e2 a2 nat ts2)
\<lbrakk>tree_invar (Node e1 a1 nat ts1); Node e1 a1 nat ts1 = Node e1 a1 nat ts1\<rbrakk> \<Longrightarrow> invar (rev (filter (\<lambda>t. 0 < rank t) (children (Node e1 a1 nat ts1))))
[PROOF STEP]
have
        rev_ts1: "invar (rev [t \<leftarrow> ts1. 0 < rank t])"
[PROOF STATE]
proof (prove)
using this:
tree_invar (Node e1 a1 nat ts1)
tree_invar (Node e2 a2 nat ts2)
t = link (Node e1 a1 nat ts1) (Node e2 a2 nat ts2) \<or> t = skewlink e' a' (Node e1 a1 nat ts1) (Node e2 a2 nat ts2)
\<lbrakk>tree_invar (Node e1 a1 nat ts1); Node e1 a1 nat ts1 = Node e1 a1 nat ts1\<rbrakk> \<Longrightarrow> invar (rev (filter (\<lambda>t. 0 < rank t) (children (Node e1 a1 nat ts1))))

goal (1 subgoal):
 1. invar (rev (filter (\<lambda>t. 0 < rank t) ts1))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
invar (rev (filter (\<lambda>t. 0 < rank t) ts1))

goal (1 subgoal):
 1. \<And>nat. nat = Suc nat \<Longrightarrow> invar (rev (filter (\<lambda>t. 0 < rank t) (children t)))
[PROOF STEP]
from O children_rank_less[of "Node e1 a1 nat ts1"]
[PROOF STATE]
proof (chain)
picking this:
tree_invar (Node e1 a1 nat ts1)
tree_invar (Node e2 a2 nat ts2)
t = link (Node e1 a1 nat ts1) (Node e2 a2 nat ts2) \<or> t = skewlink e' a' (Node e1 a1 nat ts1) (Node e2 a2 nat ts2)
tree_invar (Node e1 a1 nat ts1) \<Longrightarrow> \<forall>t'\<in>set (children (Node e1 a1 nat ts1)). rank t' < rank (Node e1 a1 nat ts1)
[PROOF STEP]
have
        "\<forall>t\<in>set (rev [t \<leftarrow> ts1. 0 < rank t]). rank t < rank (Node e2 a2 nat ts2)"
[PROOF STATE]
proof (prove)
using this:
tree_invar (Node e1 a1 nat ts1)
tree_invar (Node e2 a2 nat ts2)
t = link (Node e1 a1 nat ts1) (Node e2 a2 nat ts2) \<or> t = skewlink e' a' (Node e1 a1 nat ts1) (Node e2 a2 nat ts2)
tree_invar (Node e1 a1 nat ts1) \<Longrightarrow> \<forall>t'\<in>set (children (Node e1 a1 nat ts1)). rank t' < rank (Node e1 a1 nat ts1)

goal (1 subgoal):
 1. \<forall>t\<in>set (rev (filter (\<lambda>t. 0 < rank t) ts1)). rank t < rank (Node e2 a2 nat ts2)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<forall>t\<in>set (rev (filter (\<lambda>t. 0 < rank t) ts1)). rank t < rank (Node e2 a2 nat ts2)

goal (1 subgoal):
 1. \<And>nat. nat = Suc nat \<Longrightarrow> invar (rev (filter (\<lambda>t. 0 < rank t) (children t)))
[PROOF STEP]
with O rev_ts1
        invar_app_single[of "rev [t \<leftarrow> ts1. 0 < rank t]"
                                  "Node e2 a2 nat ts2"]
[PROOF STATE]
proof (chain)
picking this:
tree_invar (Node e1 a1 nat ts1)
tree_invar (Node e2 a2 nat ts2)
t = link (Node e1 a1 nat ts1) (Node e2 a2 nat ts2) \<or> t = skewlink e' a' (Node e1 a1 nat ts1) (Node e2 a2 nat ts2)
invar (rev (filter (\<lambda>t. 0 < rank t) ts1))
\<lbrakk>invar (rev (filter (\<lambda>t. 0 < rank t) ts1)); \<forall>t\<in>set (rev (filter (\<lambda>t. 0 < rank t) ts1)). rank t < rank (Node e2 a2 nat ts2); tree_invar (Node e2 a2 nat ts2)\<rbrakk> \<Longrightarrow> invar (rev (filter (\<lambda>t. 0 < rank t) ts1) @ [Node e2 a2 nat ts2])
\<forall>t\<in>set (rev (filter (\<lambda>t. 0 < rank t) ts1)). rank t < rank (Node e2 a2 nat ts2)
[PROOF STEP]
have
        "invar (rev ((Node e2 a2 nat ts2) # [t \<leftarrow> ts1. 0 < rank t]))"
[PROOF STATE]
proof (prove)
using this:
tree_invar (Node e1 a1 nat ts1)
tree_invar (Node e2 a2 nat ts2)
t = link (Node e1 a1 nat ts1) (Node e2 a2 nat ts2) \<or> t = skewlink e' a' (Node e1 a1 nat ts1) (Node e2 a2 nat ts2)
invar (rev (filter (\<lambda>t. 0 < rank t) ts1))
\<lbrakk>invar (rev (filter (\<lambda>t. 0 < rank t) ts1)); \<forall>t\<in>set (rev (filter (\<lambda>t. 0 < rank t) ts1)). rank t < rank (Node e2 a2 nat ts2); tree_invar (Node e2 a2 nat ts2)\<rbrakk> \<Longrightarrow> invar (rev (filter (\<lambda>t. 0 < rank t) ts1) @ [Node e2 a2 nat ts2])
\<forall>t\<in>set (rev (filter (\<lambda>t. 0 < rank t) ts1)). rank t < rank (Node e2 a2 nat ts2)

goal (1 subgoal):
 1. invar (rev (Node e2 a2 nat ts2 # filter (\<lambda>t. 0 < rank t) ts1))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
invar (rev (Node e2 a2 nat ts2 # filter (\<lambda>t. 0 < rank t) ts1))

goal (1 subgoal):
 1. \<And>nat. nat = Suc nat \<Longrightarrow> invar (rev (filter (\<lambda>t. 0 < rank t) (children t)))
[PROOF STEP]
with Suc'
[PROOF STATE]
proof (chain)
picking this:
nat = Suc n
invar (rev (Node e2 a2 nat ts2 # filter (\<lambda>t. 0 < rank t) ts1))
[PROOF STEP]
have p1: "invar (rev [t \<leftarrow> ((Node e2 a2 nat ts2) # ts1). 0 < rank t])"
[PROOF STATE]
proof (prove)
using this:
nat = Suc n
invar (rev (Node e2 a2 nat ts2 # filter (\<lambda>t. 0 < rank t) ts1))

goal (1 subgoal):
 1. invar (rev (filter (\<lambda>t. 0 < rank t) (Node e2 a2 nat ts2 # ts1)))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
invar (rev (filter (\<lambda>t. 0 < rank t) (Node e2 a2 nat ts2 # ts1)))

goal (1 subgoal):
 1. \<And>nat. nat = Suc nat \<Longrightarrow> invar (rev (filter (\<lambda>t. 0 < rank t) (children t)))
[PROOF STEP]
from O Suc(1)[of "Node e2 a2 nat ts2" "e2" "a2" "ts2"]
[PROOF STATE]
proof (chain)
picking this:
tree_invar (Node e1 a1 nat ts1)
tree_invar (Node e2 a2 nat ts2)
t = link (Node e1 a1 nat ts1) (Node e2 a2 nat ts2) \<or> t = skewlink e' a' (Node e1 a1 nat ts1) (Node e2 a2 nat ts2)
\<lbrakk>tree_invar (Node e2 a2 nat ts2); Node e2 a2 nat ts2 = Node e2 a2 nat ts2\<rbrakk> \<Longrightarrow> invar (rev (filter (\<lambda>t. 0 < rank t) (children (Node e2 a2 nat ts2))))
[PROOF STEP]
have rev_ts2: "invar (rev [t \<leftarrow> ts2. 0 < rank t])"
[PROOF STATE]
proof (prove)
using this:
tree_invar (Node e1 a1 nat ts1)
tree_invar (Node e2 a2 nat ts2)
t = link (Node e1 a1 nat ts1) (Node e2 a2 nat ts2) \<or> t = skewlink e' a' (Node e1 a1 nat ts1) (Node e2 a2 nat ts2)
\<lbrakk>tree_invar (Node e2 a2 nat ts2); Node e2 a2 nat ts2 = Node e2 a2 nat ts2\<rbrakk> \<Longrightarrow> invar (rev (filter (\<lambda>t. 0 < rank t) (children (Node e2 a2 nat ts2))))

goal (1 subgoal):
 1. invar (rev (filter (\<lambda>t. 0 < rank t) ts2))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
invar (rev (filter (\<lambda>t. 0 < rank t) ts2))

goal (1 subgoal):
 1. \<And>nat. nat = Suc nat \<Longrightarrow> invar (rev (filter (\<lambda>t. 0 < rank t) (children t)))
[PROOF STEP]
from O children_rank_less[of "Node e2 a2 nat ts2"]
[PROOF STATE]
proof (chain)
picking this:
tree_invar (Node e1 a1 nat ts1)
tree_invar (Node e2 a2 nat ts2)
t = link (Node e1 a1 nat ts1) (Node e2 a2 nat ts2) \<or> t = skewlink e' a' (Node e1 a1 nat ts1) (Node e2 a2 nat ts2)
tree_invar (Node e2 a2 nat ts2) \<Longrightarrow> \<forall>t'\<in>set (children (Node e2 a2 nat ts2)). rank t' < rank (Node e2 a2 nat ts2)
[PROOF STEP]
have "\<forall>t\<in>set (rev [t \<leftarrow> ts2. 0 < rank t]).
        rank t < rank (Node e1 a1 nat ts1)"
[PROOF STATE]
proof (prove)
using this:
tree_invar (Node e1 a1 nat ts1)
tree_invar (Node e2 a2 nat ts2)
t = link (Node e1 a1 nat ts1) (Node e2 a2 nat ts2) \<or> t = skewlink e' a' (Node e1 a1 nat ts1) (Node e2 a2 nat ts2)
tree_invar (Node e2 a2 nat ts2) \<Longrightarrow> \<forall>t'\<in>set (children (Node e2 a2 nat ts2)). rank t' < rank (Node e2 a2 nat ts2)

goal (1 subgoal):
 1. \<forall>t\<in>set (rev (filter (\<lambda>t. 0 < rank t) ts2)). rank t < rank (Node e1 a1 nat ts1)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<forall>t\<in>set (rev (filter (\<lambda>t. 0 < rank t) ts2)). rank t < rank (Node e1 a1 nat ts1)

goal (1 subgoal):
 1. \<And>nat. nat = Suc nat \<Longrightarrow> invar (rev (filter (\<lambda>t. 0 < rank t) (children t)))
[PROOF STEP]
with O rev_ts2 invar_app_single[of "rev [t \<leftarrow> ts2. 0 < rank t]"
                                         "Node e1 a1 nat ts1"]
[PROOF STATE]
proof (chain)
picking this:
tree_invar (Node e1 a1 nat ts1)
tree_invar (Node e2 a2 nat ts2)
t = link (Node e1 a1 nat ts1) (Node e2 a2 nat ts2) \<or> t = skewlink e' a' (Node e1 a1 nat ts1) (Node e2 a2 nat ts2)
invar (rev (filter (\<lambda>t. 0 < rank t) ts2))
\<lbrakk>invar (rev (filter (\<lambda>t. 0 < rank t) ts2)); \<forall>t\<in>set (rev (filter (\<lambda>t. 0 < rank t) ts2)). rank t < rank (Node e1 a1 nat ts1); tree_invar (Node e1 a1 nat ts1)\<rbrakk> \<Longrightarrow> invar (rev (filter (\<lambda>t. 0 < rank t) ts2) @ [Node e1 a1 nat ts1])
\<forall>t\<in>set (rev (filter (\<lambda>t. 0 < rank t) ts2)). rank t < rank (Node e1 a1 nat ts1)
[PROOF STEP]
have "invar (rev [t \<leftarrow> ts2. 0 < rank t] @ [Node e1 a1 nat ts1])"
[PROOF STATE]
proof (prove)
using this:
tree_invar (Node e1 a1 nat ts1)
tree_invar (Node e2 a2 nat ts2)
t = link (Node e1 a1 nat ts1) (Node e2 a2 nat ts2) \<or> t = skewlink e' a' (Node e1 a1 nat ts1) (Node e2 a2 nat ts2)
invar (rev (filter (\<lambda>t. 0 < rank t) ts2))
\<lbrakk>invar (rev (filter (\<lambda>t. 0 < rank t) ts2)); \<forall>t\<in>set (rev (filter (\<lambda>t. 0 < rank t) ts2)). rank t < rank (Node e1 a1 nat ts1); tree_invar (Node e1 a1 nat ts1)\<rbrakk> \<Longrightarrow> invar (rev (filter (\<lambda>t. 0 < rank t) ts2) @ [Node e1 a1 nat ts1])
\<forall>t\<in>set (rev (filter (\<lambda>t. 0 < rank t) ts2)). rank t < rank (Node e1 a1 nat ts1)

goal (1 subgoal):
 1. invar (rev (filter (\<lambda>t. 0 < rank t) ts2) @ [Node e1 a1 nat ts1])
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
invar (rev (filter (\<lambda>t. 0 < rank t) ts2) @ [Node e1 a1 nat ts1])

goal (1 subgoal):
 1. \<And>nat. nat = Suc nat \<Longrightarrow> invar (rev (filter (\<lambda>t. 0 < rank t) (children t)))
[PROOF STEP]
with Suc'
[PROOF STATE]
proof (chain)
picking this:
nat = Suc n
invar (rev (filter (\<lambda>t. 0 < rank t) ts2) @ [Node e1 a1 nat ts1])
[PROOF STEP]
have p2: "invar (rev [t \<leftarrow> ((Node e1 a1 nat ts1) # ts2). 0 < rank t])"
[PROOF STATE]
proof (prove)
using this:
nat = Suc n
invar (rev (filter (\<lambda>t. 0 < rank t) ts2) @ [Node e1 a1 nat ts1])

goal (1 subgoal):
 1. invar (rev (filter (\<lambda>t. 0 < rank t) (Node e1 a1 nat ts1 # ts2)))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
invar (rev (filter (\<lambda>t. 0 < rank t) (Node e1 a1 nat ts1 # ts2)))

goal (1 subgoal):
 1. \<And>nat. nat = Suc nat \<Longrightarrow> invar (rev (filter (\<lambda>t. 0 < rank t) (children t)))
[PROOF STEP]
from O(1-2)
[PROOF STATE]
proof (chain)
picking this:
tree_invar (Node e1 a1 nat ts1)
tree_invar (Node e2 a2 nat ts2)
[PROOF STEP]
have p3: "invar (rev (filter (\<lambda> t. 0 < rank t)
                                 [(Node e1 a1 nat ts1), (Node e2 a2 nat ts2)]))"
[PROOF STATE]
proof (prove)
using this:
tree_invar (Node e1 a1 nat ts1)
tree_invar (Node e2 a2 nat ts2)

goal (1 subgoal):
 1. invar (rev (filter (\<lambda>t. 0 < rank t) [Node e1 a1 nat ts1, Node e2 a2 nat ts2]))
[PROOF STEP]
by (simp add: invar_def)
[PROOF STATE]
proof (state)
this:
invar (rev (filter (\<lambda>t. 0 < rank t) [Node e1 a1 nat ts1, Node e2 a2 nat ts2]))

goal (1 subgoal):
 1. \<And>nat. nat = Suc nat \<Longrightarrow> invar (rev (filter (\<lambda>t. 0 < rank t) (children t)))
[PROOF STEP]
from p1
[PROOF STATE]
proof (chain)
picking this:
invar (rev (filter (\<lambda>t. 0 < rank t) (Node e2 a2 nat ts2 # ts1)))
[PROOF STEP]
have p4: "invar (rev
           [t \<leftarrow> ((Node e' a' 0 []) # (Node e2 a2 nat ts2) # ts1). 0 < rank t])"
[PROOF STATE]
proof (prove)
using this:
invar (rev (filter (\<lambda>t. 0 < rank t) (Node e2 a2 nat ts2 # ts1)))

goal (1 subgoal):
 1. invar (rev (filter (\<lambda>t. 0 < rank t) (Node e' a' 0 [] # Node e2 a2 nat ts2 # ts1)))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
invar (rev (filter (\<lambda>t. 0 < rank t) (Node e' a' 0 [] # Node e2 a2 nat ts2 # ts1)))

goal (1 subgoal):
 1. \<And>nat. nat = Suc nat \<Longrightarrow> invar (rev (filter (\<lambda>t. 0 < rank t) (children t)))
[PROOF STEP]
from p2
[PROOF STATE]
proof (chain)
picking this:
invar (rev (filter (\<lambda>t. 0 < rank t) (Node e1 a1 nat ts1 # ts2)))
[PROOF STEP]
have p5: "invar (rev
           [t \<leftarrow> ((Node e' a' 0 []) # (Node e1 a1 nat ts1) # ts2). 0 < rank t])"
[PROOF STATE]
proof (prove)
using this:
invar (rev (filter (\<lambda>t. 0 < rank t) (Node e1 a1 nat ts1 # ts2)))

goal (1 subgoal):
 1. invar (rev (filter (\<lambda>t. 0 < rank t) (Node e' a' 0 [] # Node e1 a1 nat ts1 # ts2)))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
invar (rev (filter (\<lambda>t. 0 < rank t) (Node e' a' 0 [] # Node e1 a1 nat ts1 # ts2)))

goal (1 subgoal):
 1. \<And>nat. nat = Suc nat \<Longrightarrow> invar (rev (filter (\<lambda>t. 0 < rank t) (children t)))
[PROOF STEP]
from p1 p2 p3 p4 p5 ch_id
[PROOF STATE]
proof (chain)
picking this:
invar (rev (filter (\<lambda>t. 0 < rank t) (Node e2 a2 nat ts2 # ts1)))
invar (rev (filter (\<lambda>t. 0 < rank t) (Node e1 a1 nat ts1 # ts2)))
invar (rev (filter (\<lambda>t. 0 < rank t) [Node e1 a1 nat ts1, Node e2 a2 nat ts2]))
invar (rev (filter (\<lambda>t. 0 < rank t) (Node e' a' 0 [] # Node e2 a2 nat ts2 # ts1)))
invar (rev (filter (\<lambda>t. 0 < rank t) (Node e' a' 0 [] # Node e1 a1 nat ts1 # ts2)))
children t = (if a1 \<le> a2 then Node e2 a2 nat ts2 # ts1 else Node e1 a1 nat ts1 # ts2) \<or> children t = (if a' \<le> a1 \<and> a' \<le> a2 then [Node e1 a1 nat ts1, Node e2 a2 nat ts2] else if a1 \<le> a2 then Node e' a' 0 [] # Node e2 a2 nat ts2 # ts1 else Node e' a' 0 [] # Node e1 a1 nat ts1 # ts2)
[PROOF STEP]
show
        "invar (rev [t\<leftarrow>children t . 0 < rank t])"
[PROOF STATE]
proof (prove)
using this:
invar (rev (filter (\<lambda>t. 0 < rank t) (Node e2 a2 nat ts2 # ts1)))
invar (rev (filter (\<lambda>t. 0 < rank t) (Node e1 a1 nat ts1 # ts2)))
invar (rev (filter (\<lambda>t. 0 < rank t) [Node e1 a1 nat ts1, Node e2 a2 nat ts2]))
invar (rev (filter (\<lambda>t. 0 < rank t) (Node e' a' 0 [] # Node e2 a2 nat ts2 # ts1)))
invar (rev (filter (\<lambda>t. 0 < rank t) (Node e' a' 0 [] # Node e1 a1 nat ts1 # ts2)))
children t = (if a1 \<le> a2 then Node e2 a2 nat ts2 # ts1 else Node e1 a1 nat ts1 # ts2) \<or> children t = (if a' \<le> a1 \<and> a' \<le> a2 then [Node e1 a1 nat ts1, Node e2 a2 nat ts2] else if a1 \<le> a2 then Node e' a' 0 [] # Node e2 a2 nat ts2 # ts1 else Node e' a' 0 [] # Node e1 a1 nat ts1 # ts2)

goal (1 subgoal):
 1. invar (rev (filter (\<lambda>t. 0 < rank t) (children t)))
[PROOF STEP]
by (cases "children t = (if a1 \<le> a2 then (Node e2 a2 nat ts2)#ts1
                                else (Node e1 a1 nat ts1)#ts2)") metis+
[PROOF STATE]
proof (state)
this:
invar (rev (filter (\<lambda>t. 0 < rank t) (children t)))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
invar (rev (filter (\<lambda>t. 0 < rank t) (children t)))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
invar (rev (filter (\<lambda>t. 0 < rank t) (children t)))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma Bounded_vec_mono: "b \<le> B \<Longrightarrow> Bounded_vec b \<subseteq> Bounded_vec B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. b \<le> B \<Longrightarrow> Bounded_vec b \<subseteq> Bounded_vec B
[PROOF STEP]
unfolding Bounded_vec_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. b \<le> B \<Longrightarrow> {x. \<forall>i<dim_vec x. \<bar>x $ i\<bar> \<le> b} \<subseteq> {x. \<forall>i<dim_vec x. \<bar>x $ i\<bar> \<le> B}
[PROOF STEP]
by auto


[STATEMENT]
lemma tensor_ell2_extensionality:
  assumes "(\<And>s t. a *\<^sub>V (s \<otimes>\<^sub>s t) = b *\<^sub>V (s \<otimes>\<^sub>s t))"
  shows "a = b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a = b
[PROOF STEP]
apply (rule equal_ket, case_tac x, hypsubst_thin)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x aa ba. a *\<^sub>V ket (aa, ba) = b *\<^sub>V ket (aa, ba)
[PROOF STEP]
by (simp add: assms flip: tensor_ell2_ket)