[STATEMENT]
lemma vec_to_iarray_least_non_zero_position_of_vector_from_index:
fixes A::"'a::{zero}^'n::{mod_type}"
assumes not_all_zero: "\<not> (vector_all_zero_from_index (to_nat i,  vec_to_iarray A))"
shows "least_non_zero_position_of_vector_from_index (vec_to_iarray A) (to_nat i) = to_nat (LEAST n. A $ n \<noteq> 0 \<and> i \<le> n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. least_non_zero_position_of_vector_from_index (vec_to_iarray A) (mod_type_class.to_nat i) = mod_type_class.to_nat (LEAST n. A $ n \<noteq> (0::'a) \<and> i \<le> n)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. least_non_zero_position_of_vector_from_index (vec_to_iarray A) (mod_type_class.to_nat i) = mod_type_class.to_nat (LEAST n. A $ n \<noteq> (0::'a) \<and> i \<le> n)
[PROOF STEP]
have "\<exists>a. List.find (\<lambda>x. vec_to_iarray A !! x \<noteq> 0) [to_nat i..<IArray.length (vec_to_iarray A)] = Some a"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>a. find (\<lambda>x. vec_to_iarray A !! x \<noteq> (0::'a)) [mod_type_class.to_nat i..<IArray.length (vec_to_iarray A)] = Some a
[PROOF STEP]
proof (rule ccontr, simp, unfold IArray.sub_def[symmetric] IArray.length_def[symmetric])
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. find (\<lambda>x. vec_to_iarray A !! x \<noteq> (0::'a)) [mod_type_class.to_nat i..<IArray.length (vec_to_iarray A)] = None \<Longrightarrow> False
[PROOF STEP]
assume "List.find (\<lambda>x. (vec_to_iarray A) !! x \<noteq> 0) [to_nat i..<IArray.length (vec_to_iarray A)] = None"
[PROOF STATE]
proof (state)
this:
find (\<lambda>x. vec_to_iarray A !! x \<noteq> (0::'a)) [mod_type_class.to_nat i..<IArray.length (vec_to_iarray A)] = None

goal (1 subgoal):
 1. find (\<lambda>x. vec_to_iarray A !! x \<noteq> (0::'a)) [mod_type_class.to_nat i..<IArray.length (vec_to_iarray A)] = None \<Longrightarrow> False
[PROOF STEP]
hence "\<not> (\<exists>x. x \<in> set [mod_type_class.to_nat i..<IArray.length (vec_to_iarray A)] \<and> vec_to_iarray A !! x \<noteq> 0)"
[PROOF STATE]
proof (prove)
using this:
find (\<lambda>x. vec_to_iarray A !! x \<noteq> (0::'a)) [mod_type_class.to_nat i..<IArray.length (vec_to_iarray A)] = None

goal (1 subgoal):
 1. \<nexists>x. x \<in> set [mod_type_class.to_nat i..<IArray.length (vec_to_iarray A)] \<and> vec_to_iarray A !! x \<noteq> (0::'a)
[PROOF STEP]
unfolding find_None_iff
[PROOF STATE]
proof (prove)
using this:
\<nexists>x. x \<in> set [mod_type_class.to_nat i..<IArray.length (vec_to_iarray A)] \<and> vec_to_iarray A !! x \<noteq> (0::'a)

goal (1 subgoal):
 1. \<nexists>x. x \<in> set [mod_type_class.to_nat i..<IArray.length (vec_to_iarray A)] \<and> vec_to_iarray A !! x \<noteq> (0::'a)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
\<nexists>x. x \<in> set [mod_type_class.to_nat i..<IArray.length (vec_to_iarray A)] \<and> vec_to_iarray A !! x \<noteq> (0::'a)

goal (1 subgoal):
 1. find (\<lambda>x. vec_to_iarray A !! x \<noteq> (0::'a)) [mod_type_class.to_nat i..<IArray.length (vec_to_iarray A)] = None \<Longrightarrow> False
[PROOF STEP]
thus False
[PROOF STATE]
proof (prove)
using this:
\<nexists>x. x \<in> set [mod_type_class.to_nat i..<IArray.length (vec_to_iarray A)] \<and> vec_to_iarray A !! x \<noteq> (0::'a)

goal (1 subgoal):
 1. False
[PROOF STEP]
using not_all_zero
[PROOF STATE]
proof (prove)
using this:
\<nexists>x. x \<in> set [mod_type_class.to_nat i..<IArray.length (vec_to_iarray A)] \<and> vec_to_iarray A !! x \<noteq> (0::'a)
\<not> vector_all_zero_from_index (mod_type_class.to_nat i, vec_to_iarray A)

goal (1 subgoal):
 1. False
[PROOF STEP]
unfolding vector_all_zero_from_index_eq[symmetric]
[PROOF STATE]
proof (prove)
using this:
\<nexists>x. x \<in> set [mod_type_class.to_nat i..<IArray.length (vec_to_iarray A)] \<and> vec_to_iarray A !! x \<noteq> (0::'a)
\<not> (\<forall>m\<ge>i. A $ m = (0::'a))

goal (1 subgoal):
 1. False
[PROOF STEP]
by (simp del: IArray.length_def IArray.sub_def, unfold length_vec_to_iarray, metis to_nat_less_card to_nat_mono' vec_to_iarray_nth')
[PROOF STATE]
proof (state)
this:
False

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<exists>a. find (\<lambda>x. vec_to_iarray A !! x \<noteq> (0::'a)) [mod_type_class.to_nat i..<IArray.length (vec_to_iarray A)] = Some a

goal (1 subgoal):
 1. least_non_zero_position_of_vector_from_index (vec_to_iarray A) (mod_type_class.to_nat i) = mod_type_class.to_nat (LEAST n. A $ n \<noteq> (0::'a) \<and> i \<le> n)
[PROOF STEP]
from this
[PROOF STATE]
proof (chain)
picking this:
\<exists>a. find (\<lambda>x. vec_to_iarray A !! x \<noteq> (0::'a)) [mod_type_class.to_nat i..<IArray.length (vec_to_iarray A)] = Some a
[PROOF STEP]
obtain a where a: "List.find (\<lambda>x. vec_to_iarray A !! x \<noteq> 0) [to_nat i..<IArray.length (vec_to_iarray A)] = Some a"
[PROOF STATE]
proof (prove)
using this:
\<exists>a. find (\<lambda>x. vec_to_iarray A !! x \<noteq> (0::'a)) [mod_type_class.to_nat i..<IArray.length (vec_to_iarray A)] = Some a

goal (1 subgoal):
 1. (\<And>a. find (\<lambda>x. vec_to_iarray A !! x \<noteq> (0::'a)) [mod_type_class.to_nat i..<IArray.length (vec_to_iarray A)] = Some a \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
find (\<lambda>x. vec_to_iarray A !! x \<noteq> (0::'a)) [mod_type_class.to_nat i..<IArray.length (vec_to_iarray A)] = Some a

goal (1 subgoal):
 1. least_non_zero_position_of_vector_from_index (vec_to_iarray A) (mod_type_class.to_nat i) = mod_type_class.to_nat (LEAST n. A $ n \<noteq> (0::'a) \<and> i \<le> n)
[PROOF STEP]
from this
[PROOF STATE]
proof (chain)
picking this:
find (\<lambda>x. vec_to_iarray A !! x \<noteq> (0::'a)) [mod_type_class.to_nat i..<IArray.length (vec_to_iarray A)] = Some a
[PROOF STEP]
obtain ia where
    ia_less_length: "ia<length [to_nat i..<IArray.length (vec_to_iarray A)]" and
    not_eq_zero: "vec_to_iarray A !! ([to_nat i..<IArray.length (vec_to_iarray A)] ! ia) \<noteq> 0" and
    a_eq: "a = [to_nat i..<IArray.length (vec_to_iarray A)] ! ia"
    and least: "(\<forall>ja<ia. \<not> vec_to_iarray A !! ([to_nat i..<IArray.length (vec_to_iarray A)] ! ja) \<noteq> 0)"
[PROOF STATE]
proof (prove)
using this:
find (\<lambda>x. vec_to_iarray A !! x \<noteq> (0::'a)) [mod_type_class.to_nat i..<IArray.length (vec_to_iarray A)] = Some a

goal (1 subgoal):
 1. (\<And>ia. \<lbrakk>ia < length [mod_type_class.to_nat i..<IArray.length (vec_to_iarray A)]; vec_to_iarray A !! ([mod_type_class.to_nat i..<IArray.length (vec_to_iarray A)] ! ia) \<noteq> (0::'a); a = [mod_type_class.to_nat i..<IArray.length (vec_to_iarray A)] ! ia; \<forall>ja<ia. \<not> vec_to_iarray A !! ([mod_type_class.to_nat i..<IArray.length (vec_to_iarray A)] ! ja) \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
unfolding find_Some_iff
[PROOF STATE]
proof (prove)
using this:
\<exists>ia<length [mod_type_class.to_nat i..<IArray.length (vec_to_iarray A)]. vec_to_iarray A !! ([mod_type_class.to_nat i..<IArray.length (vec_to_iarray A)] ! ia) \<noteq> (0::'a) \<and> a = [mod_type_class.to_nat i..<IArray.length (vec_to_iarray A)] ! ia \<and> (\<forall>j<ia. \<not> vec_to_iarray A !! ([mod_type_class.to_nat i..<IArray.length (vec_to_iarray A)] ! j) \<noteq> (0::'a))

goal (1 subgoal):
 1. (\<And>ia. \<lbrakk>ia < length [mod_type_class.to_nat i..<IArray.length (vec_to_iarray A)]; vec_to_iarray A !! ([mod_type_class.to_nat i..<IArray.length (vec_to_iarray A)] ! ia) \<noteq> (0::'a); a = [mod_type_class.to_nat i..<IArray.length (vec_to_iarray A)] ! ia; \<forall>ja<ia. \<not> vec_to_iarray A !! ([mod_type_class.to_nat i..<IArray.length (vec_to_iarray A)] ! ja) \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
ia < length [mod_type_class.to_nat i..<IArray.length (vec_to_iarray A)]
vec_to_iarray A !! ([mod_type_class.to_nat i..<IArray.length (vec_to_iarray A)] ! ia) \<noteq> (0::'a)
a = [mod_type_class.to_nat i..<IArray.length (vec_to_iarray A)] ! ia
\<forall>ja<ia. \<not> vec_to_iarray A !! ([mod_type_class.to_nat i..<IArray.length (vec_to_iarray A)] ! ja) \<noteq> (0::'a)

goal (1 subgoal):
 1. least_non_zero_position_of_vector_from_index (vec_to_iarray A) (mod_type_class.to_nat i) = mod_type_class.to_nat (LEAST n. A $ n \<noteq> (0::'a) \<and> i \<le> n)
[PROOF STEP]
have not_eq_zero': "vec_to_iarray A !! a \<noteq> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vec_to_iarray A !! a \<noteq> (0::'a)
[PROOF STEP]
using not_eq_zero
[PROOF STATE]
proof (prove)
using this:
vec_to_iarray A !! ([mod_type_class.to_nat i..<IArray.length (vec_to_iarray A)] ! ia) \<noteq> (0::'a)

goal (1 subgoal):
 1. vec_to_iarray A !! a \<noteq> (0::'a)
[PROOF STEP]
unfolding a_eq
[PROOF STATE]
proof (prove)
using this:
vec_to_iarray A !! ([mod_type_class.to_nat i..<IArray.length (vec_to_iarray A)] ! ia) \<noteq> (0::'a)

goal (1 subgoal):
 1. vec_to_iarray A !! ([mod_type_class.to_nat i..<IArray.length (vec_to_iarray A)] ! ia) \<noteq> (0::'a)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
vec_to_iarray A !! a \<noteq> (0::'a)

goal (1 subgoal):
 1. least_non_zero_position_of_vector_from_index (vec_to_iarray A) (mod_type_class.to_nat i) = mod_type_class.to_nat (LEAST n. A $ n \<noteq> (0::'a) \<and> i \<le> n)
[PROOF STEP]
have i_less_a: "to_nat i \<le> a"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mod_type_class.to_nat i \<le> a
[PROOF STEP]
using  ia_less_length length_upt nth_upt a_eq
[PROOF STATE]
proof (prove)
using this:
ia < length [mod_type_class.to_nat i..<IArray.length (vec_to_iarray A)]
length [?i..<?j] = ?j - ?i
?i + ?k < ?j \<Longrightarrow> [?i..<?j] ! ?k = ?i + ?k
a = [mod_type_class.to_nat i..<IArray.length (vec_to_iarray A)] ! ia

goal (1 subgoal):
 1. mod_type_class.to_nat i \<le> a
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
mod_type_class.to_nat i \<le> a

goal (1 subgoal):
 1. least_non_zero_position_of_vector_from_index (vec_to_iarray A) (mod_type_class.to_nat i) = mod_type_class.to_nat (LEAST n. A $ n \<noteq> (0::'a) \<and> i \<le> n)
[PROOF STEP]
have a_less_card: "a<CARD('n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a < CARD('n)
[PROOF STEP]
using a_eq ia_less_length
[PROOF STATE]
proof (prove)
using this:
a = [mod_type_class.to_nat i..<IArray.length (vec_to_iarray A)] ! ia
ia < length [mod_type_class.to_nat i..<IArray.length (vec_to_iarray A)]

goal (1 subgoal):
 1. a < CARD('n)
[PROOF STEP]
unfolding vec_to_iarray_def
[PROOF STATE]
proof (prove)
using this:
a = [mod_type_class.to_nat i..<IArray.length (IArray.of_fun (\<lambda>i. A $ mod_type_class.from_nat i) CARD('n))] ! ia
ia < length [mod_type_class.to_nat i..<IArray.length (IArray.of_fun (\<lambda>i. A $ mod_type_class.from_nat i) CARD('n))]

goal (1 subgoal):
 1. a < CARD('n)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
a < CARD('n)

goal (1 subgoal):
 1. least_non_zero_position_of_vector_from_index (vec_to_iarray A) (mod_type_class.to_nat i) = mod_type_class.to_nat (LEAST n. A $ n \<noteq> (0::'a) \<and> i \<le> n)
[PROOF STEP]
have "(LEAST n. A $ n \<noteq> 0 \<and> i \<le> n) = from_nat a"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (LEAST n. A $ n \<noteq> (0::'a) \<and> i \<le> n) = mod_type_class.from_nat a
[PROOF STEP]
proof (rule Least_equality, rule conjI)
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. A $ mod_type_class.from_nat a \<noteq> (0::'a)
 2. i \<le> mod_type_class.from_nat a
 3. \<And>y. A $ y \<noteq> (0::'a) \<and> i \<le> y \<Longrightarrow> mod_type_class.from_nat a \<le> y
[PROOF STEP]
show "A $ from_nat a \<noteq> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A $ mod_type_class.from_nat a \<noteq> (0::'a)
[PROOF STEP]
unfolding vec_to_iarray_nth'[symmetric]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vec_to_iarray A !! mod_type_class.to_nat (mod_type_class.from_nat a) \<noteq> (0::'a)
[PROOF STEP]
using not_eq_zero'
[PROOF STATE]
proof (prove)
using this:
vec_to_iarray A !! a \<noteq> (0::'a)

goal (1 subgoal):
 1. vec_to_iarray A !! mod_type_class.to_nat (mod_type_class.from_nat a) \<noteq> (0::'a)
[PROOF STEP]
unfolding to_nat_from_nat_id[OF a_less_card]
[PROOF STATE]
proof (prove)
using this:
vec_to_iarray A !! a \<noteq> (0::'a)

goal (1 subgoal):
 1. vec_to_iarray A !! a \<noteq> (0::'a)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
A $ mod_type_class.from_nat a \<noteq> (0::'a)

goal (2 subgoals):
 1. i \<le> mod_type_class.from_nat a
 2. \<And>y. A $ y \<noteq> (0::'a) \<and> i \<le> y \<Longrightarrow> mod_type_class.from_nat a \<le> y
[PROOF STEP]
show "i \<le> from_nat a"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. i \<le> mod_type_class.from_nat a
[PROOF STEP]
using a_less_card from_nat_mono' from_nat_to_nat_id i_less_a
[PROOF STATE]
proof (prove)
using this:
a < CARD('n)
\<lbrakk>?i \<le> ?j; ?j < CARD(?'a)\<rbrakk> \<Longrightarrow> mod_type_class.from_nat ?i \<le> mod_type_class.from_nat ?j
mod_type_class.from_nat (mod_type_class.to_nat ?x) = ?x
mod_type_class.to_nat i \<le> a

goal (1 subgoal):
 1. i \<le> mod_type_class.from_nat a
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
i \<le> mod_type_class.from_nat a

goal (1 subgoal):
 1. \<And>y. A $ y \<noteq> (0::'a) \<and> i \<le> y \<Longrightarrow> mod_type_class.from_nat a \<le> y
[PROOF STEP]
fix x
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>y. A $ y \<noteq> (0::'a) \<and> i \<le> y \<Longrightarrow> mod_type_class.from_nat a \<le> y
[PROOF STEP]
assume "A $ x  \<noteq> 0 \<and> i \<le> x"
[PROOF STATE]
proof (state)
this:
A $ x \<noteq> (0::'a) \<and> i \<le> x

goal (1 subgoal):
 1. \<And>y. A $ y \<noteq> (0::'a) \<and> i \<le> y \<Longrightarrow> mod_type_class.from_nat a \<le> y
[PROOF STEP]
hence Axj: "A $ x \<noteq> 0" and i_le_x: "i \<le> x"
[PROOF STATE]
proof (prove)
using this:
A $ x \<noteq> (0::'a) \<and> i \<le> x

goal (1 subgoal):
 1. A $ x \<noteq> (0::'a) &&& i \<le> x
[PROOF STEP]
by fast+
[PROOF STATE]
proof (state)
this:
A $ x \<noteq> (0::'a)
i \<le> x

goal (1 subgoal):
 1. \<And>y. A $ y \<noteq> (0::'a) \<and> i \<le> y \<Longrightarrow> mod_type_class.from_nat a \<le> y
[PROOF STEP]
show "from_nat a \<le> x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mod_type_class.from_nat a \<le> x
[PROOF STEP]
proof (rule ccontr)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> mod_type_class.from_nat a \<le> x \<Longrightarrow> False
[PROOF STEP]
assume "\<not> from_nat a \<le> x"
[PROOF STATE]
proof (state)
this:
\<not> mod_type_class.from_nat a \<le> x

goal (1 subgoal):
 1. \<not> mod_type_class.from_nat a \<le> x \<Longrightarrow> False
[PROOF STEP]
hence x_less_from_nat_a: "x < from_nat a"
[PROOF STATE]
proof (prove)
using this:
\<not> mod_type_class.from_nat a \<le> x

goal (1 subgoal):
 1. x < mod_type_class.from_nat a
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
x < mod_type_class.from_nat a

goal (1 subgoal):
 1. \<not> mod_type_class.from_nat a \<le> x \<Longrightarrow> False
[PROOF STEP]
define ja where "ja = (to_nat x) - (to_nat i)"
[PROOF STATE]
proof (state)
this:
ja = mod_type_class.to_nat x - mod_type_class.to_nat i

goal (1 subgoal):
 1. \<not> mod_type_class.from_nat a \<le> x \<Longrightarrow> False
[PROOF STEP]
have to_nat_x_less_card: "to_nat x < CARD ('n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mod_type_class.to_nat x < CARD('n)
[PROOF STEP]
using bij_to_nat[where ?'a='n]
[PROOF STATE]
proof (prove)
using this:
bij_betw mod_type_class.to_nat UNIV {0..<CARD('n)}

goal (1 subgoal):
 1. mod_type_class.to_nat x < CARD('n)
[PROOF STEP]
unfolding bij_betw_def
[PROOF STATE]
proof (prove)
using this:
inj mod_type_class.to_nat \<and> range mod_type_class.to_nat = {0..<CARD('n)}

goal (1 subgoal):
 1. mod_type_class.to_nat x < CARD('n)
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
mod_type_class.to_nat x < CARD('n)

goal (1 subgoal):
 1. \<not> mod_type_class.from_nat a \<le> x \<Longrightarrow> False
[PROOF STEP]
hence ja_less_length: "ja < IArray.length (vec_to_iarray A)"
[PROOF STATE]
proof (prove)
using this:
mod_type_class.to_nat x < CARD('n)

goal (1 subgoal):
 1. ja < IArray.length (vec_to_iarray A)
[PROOF STEP]
unfolding ja_def vec_to_iarray_def
[PROOF STATE]
proof (prove)
using this:
mod_type_class.to_nat x < CARD('n)

goal (1 subgoal):
 1. mod_type_class.to_nat x - mod_type_class.to_nat i < IArray.length (IArray.of_fun (\<lambda>i. A $ mod_type_class.from_nat i) CARD('n))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
ja < IArray.length (vec_to_iarray A)

goal (1 subgoal):
 1. \<not> mod_type_class.from_nat a \<le> x \<Longrightarrow> False
[PROOF STEP]
have "[to_nat i..<IArray.length (vec_to_iarray A)] ! ja = to_nat i + ja"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [mod_type_class.to_nat i..<IArray.length (vec_to_iarray A)] ! ja = mod_type_class.to_nat i + ja
[PROOF STEP]
by (rule nth_upt, unfold vec_to_iarray_def,auto, metis add_diff_inverse diff_add_zero ja_def not_less_iff_gr_or_eq to_nat_less_card)
[PROOF STATE]
proof (state)
this:
[mod_type_class.to_nat i..<IArray.length (vec_to_iarray A)] ! ja = mod_type_class.to_nat i + ja

goal (1 subgoal):
 1. \<not> mod_type_class.from_nat a \<le> x \<Longrightarrow> False
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
[mod_type_class.to_nat i..<IArray.length (vec_to_iarray A)] ! ja = mod_type_class.to_nat i + ja

goal (1 subgoal):
 1. \<not> mod_type_class.from_nat a \<le> x \<Longrightarrow> False
[PROOF STEP]
have i_plus_ja: "... = to_nat x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mod_type_class.to_nat i + ja = mod_type_class.to_nat x
[PROOF STEP]
unfolding ja_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mod_type_class.to_nat i + (mod_type_class.to_nat x - mod_type_class.to_nat i) = mod_type_class.to_nat x
[PROOF STEP]
by (simp add: i_le_x to_nat_mono')
[PROOF STATE]
proof (state)
this:
mod_type_class.to_nat i + ja = mod_type_class.to_nat x

goal (1 subgoal):
 1. \<not> mod_type_class.from_nat a \<le> x \<Longrightarrow> False
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
[mod_type_class.to_nat i..<IArray.length (vec_to_iarray A)] ! ja = mod_type_class.to_nat x
[PROOF STEP]
have list_rw: "[to_nat i..<IArray.length (vec_to_iarray A)] ! ja = to_nat x"
[PROOF STATE]
proof (prove)
using this:
[mod_type_class.to_nat i..<IArray.length (vec_to_iarray A)] ! ja = mod_type_class.to_nat x

goal (1 subgoal):
 1. [mod_type_class.to_nat i..<IArray.length (vec_to_iarray A)] ! ja = mod_type_class.to_nat x
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
[mod_type_class.to_nat i..<IArray.length (vec_to_iarray A)] ! ja = mod_type_class.to_nat x

goal (1 subgoal):
 1. \<not> mod_type_class.from_nat a \<le> x \<Longrightarrow> False
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
[mod_type_class.to_nat i..<IArray.length (vec_to_iarray A)] ! ja = mod_type_class.to_nat x

goal (1 subgoal):
 1. \<not> mod_type_class.from_nat a \<le> x \<Longrightarrow> False
[PROOF STEP]
have "ja<ia"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ja < ia
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. ja < ia
[PROOF STEP]
have "a = to_nat i + ia"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a = mod_type_class.to_nat i + ia
[PROOF STEP]
unfolding a_eq
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [mod_type_class.to_nat i..<IArray.length (vec_to_iarray A)] ! ia = mod_type_class.to_nat i + ia
[PROOF STEP]
by (rule nth_upt, metis ia_less_length length_upt less_diff_conv add.commute)
[PROOF STATE]
proof (state)
this:
a = mod_type_class.to_nat i + ia

goal (1 subgoal):
 1. ja < ia
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
a = mod_type_class.to_nat i + ia

goal (1 subgoal):
 1. ja < ia
[PROOF STEP]
by (metis i_plus_ja add_less_cancel_right add.commute to_nat_le x_less_from_nat_a)
[PROOF STATE]
proof (state)
this:
ja < ia

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
ja < ia

goal (1 subgoal):
 1. \<not> mod_type_class.from_nat a \<le> x \<Longrightarrow> False
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
[mod_type_class.to_nat i..<IArray.length (vec_to_iarray A)] ! ja = mod_type_class.to_nat x
ja < ia
[PROOF STEP]
have "vec_to_iarray A !! (to_nat x) = 0"
[PROOF STATE]
proof (prove)
using this:
[mod_type_class.to_nat i..<IArray.length (vec_to_iarray A)] ! ja = mod_type_class.to_nat x
ja < ia

goal (1 subgoal):
 1. vec_to_iarray A !! mod_type_class.to_nat x = (0::'a)
[PROOF STEP]
using least
[PROOF STATE]
proof (prove)
using this:
[mod_type_class.to_nat i..<IArray.length (vec_to_iarray A)] ! ja = mod_type_class.to_nat x
ja < ia
\<forall>ja<ia. \<not> vec_to_iarray A !! ([mod_type_class.to_nat i..<IArray.length (vec_to_iarray A)] ! ja) \<noteq> (0::'a)

goal (1 subgoal):
 1. vec_to_iarray A !! mod_type_class.to_nat x = (0::'a)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
vec_to_iarray A !! mod_type_class.to_nat x = (0::'a)

goal (1 subgoal):
 1. \<not> mod_type_class.from_nat a \<le> x \<Longrightarrow> False
[PROOF STEP]
hence "A $ x = 0"
[PROOF STATE]
proof (prove)
using this:
vec_to_iarray A !! mod_type_class.to_nat x = (0::'a)

goal (1 subgoal):
 1. A $ x = (0::'a)
[PROOF STEP]
unfolding vec_to_iarray_nth'
[PROOF STATE]
proof (prove)
using this:
A $ x = (0::'a)

goal (1 subgoal):
 1. A $ x = (0::'a)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
A $ x = (0::'a)

goal (1 subgoal):
 1. \<not> mod_type_class.from_nat a \<le> x \<Longrightarrow> False
[PROOF STEP]
thus False
[PROOF STATE]
proof (prove)
using this:
A $ x = (0::'a)

goal (1 subgoal):
 1. False
[PROOF STEP]
using Axj
[PROOF STATE]
proof (prove)
using this:
A $ x = (0::'a)
A $ x \<noteq> (0::'a)

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

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
mod_type_class.from_nat a \<le> x

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(LEAST n. A $ n \<noteq> (0::'a) \<and> i \<le> n) = mod_type_class.from_nat a

goal (1 subgoal):
 1. least_non_zero_position_of_vector_from_index (vec_to_iarray A) (mod_type_class.to_nat i) = mod_type_class.to_nat (LEAST n. A $ n \<noteq> (0::'a) \<and> i \<le> n)
[PROOF STEP]
hence "a = to_nat (LEAST n. A $ n \<noteq> 0 \<and> i \<le> n)"
[PROOF STATE]
proof (prove)
using this:
(LEAST n. A $ n \<noteq> (0::'a) \<and> i \<le> n) = mod_type_class.from_nat a

goal (1 subgoal):
 1. a = mod_type_class.to_nat (LEAST n. A $ n \<noteq> (0::'a) \<and> i \<le> n)
[PROOF STEP]
using to_nat_from_nat_id[OF a_less_card]
[PROOF STATE]
proof (prove)
using this:
(LEAST n. A $ n \<noteq> (0::'a) \<and> i \<le> n) = mod_type_class.from_nat a
mod_type_class.to_nat (mod_type_class.from_nat a) = a

goal (1 subgoal):
 1. a = mod_type_class.to_nat (LEAST n. A $ n \<noteq> (0::'a) \<and> i \<le> n)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
a = mod_type_class.to_nat (LEAST n. A $ n \<noteq> (0::'a) \<and> i \<le> n)

goal (1 subgoal):
 1. least_non_zero_position_of_vector_from_index (vec_to_iarray A) (mod_type_class.to_nat i) = mod_type_class.to_nat (LEAST n. A $ n \<noteq> (0::'a) \<and> i \<le> n)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
a = mod_type_class.to_nat (LEAST n. A $ n \<noteq> (0::'a) \<and> i \<le> n)

goal (1 subgoal):
 1. least_non_zero_position_of_vector_from_index (vec_to_iarray A) (mod_type_class.to_nat i) = mod_type_class.to_nat (LEAST n. A $ n \<noteq> (0::'a) \<and> i \<le> n)
[PROOF STEP]
unfolding least_non_zero_position_of_vector_from_index_def
[PROOF STATE]
proof (prove)
using this:
a = mod_type_class.to_nat (LEAST n. A $ n \<noteq> (0::'a) \<and> i \<le> n)

goal (1 subgoal):
 1. the (find (\<lambda>x. vec_to_iarray A !! x \<noteq> (0::'a)) [mod_type_class.to_nat i..<IArray.length (vec_to_iarray A)]) = mod_type_class.to_nat (LEAST n. A $ n \<noteq> (0::'a) \<and> i \<le> n)
[PROOF STEP]
unfolding a
[PROOF STATE]
proof (prove)
using this:
a = mod_type_class.to_nat (LEAST n. A $ n \<noteq> (0::'a) \<and> i \<le> n)

goal (1 subgoal):
 1. the (Some a) = mod_type_class.to_nat (LEAST n. A $ n \<noteq> (0::'a) \<and> i \<le> n)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
least_non_zero_position_of_vector_from_index (vec_to_iarray A) (mod_type_class.to_nat i) = mod_type_class.to_nat (LEAST n. A $ n \<noteq> (0::'a) \<and> i \<le> n)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma floor_divide_upper:
  fixes q :: "'a::floor_ceiling"
  shows "q > 0 \<Longrightarrow> p < (of_int \<lfloor>p / q\<rfloor> + 1) * q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (0::'a) < q \<Longrightarrow> p < (of_int \<lfloor>p / q\<rfloor> + (1::'a)) * q
[PROOF STEP]
by (meson floor_eq_iff pos_divide_less_eq)


[STATEMENT]
lemma p_leI: "1 \<ge> (\<Sum>i<k. as!i * bs!i powr p') \<Longrightarrow> p' \<ge> p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i<k. as ! i * bs ! i powr p') \<le> 1 \<Longrightarrow> p \<le> p'
[PROOF STEP]
by (rule disjE[OF le_less_linear, of p p'], simp, drule akra_bazzi_p_strict_mono,
      subst (asm) p_props, simp_all)


[STATEMENT]
lemma sd_chain_strictly_preferred:
  assumes "m < n"
  assumes "sd_chain m = Some q"
  assumes "sd_chain n = Some s"
  shows   "q \<prec>[Pareto(SD\<circ>R)] s"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. q \<prec>[Pareto (SD \<circ> R)] s
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
m < n
sd_chain m = Some q
sd_chain n = Some s

goal (1 subgoal):
 1. q \<prec>[Pareto (SD \<circ> R)] s
[PROOF STEP]
proof (induction arbitrary: q rule: strict_inc_induct)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>i q. \<lbrakk>n = Suc i; sd_chain i = Some q; sd_chain n = Some s\<rbrakk> \<Longrightarrow> q \<prec>[Pareto (SD \<circ> R)] s
 2. \<And>i q. \<lbrakk>i < n; \<And>q. \<lbrakk>sd_chain (Suc i) = Some q; sd_chain n = Some s\<rbrakk> \<Longrightarrow> q \<prec>[Pareto (SD \<circ> R)] s; sd_chain i = Some q; sd_chain n = Some s\<rbrakk> \<Longrightarrow> q \<prec>[Pareto (SD \<circ> R)] s
[PROOF STEP]
case (base k q)
[PROOF STATE]
proof (state)
this:
n = Suc k
sd_chain k = Some q
sd_chain n = Some s

goal (2 subgoals):
 1. \<And>i q. \<lbrakk>n = Suc i; sd_chain i = Some q; sd_chain n = Some s\<rbrakk> \<Longrightarrow> q \<prec>[Pareto (SD \<circ> R)] s
 2. \<And>i q. \<lbrakk>i < n; \<And>q. \<lbrakk>sd_chain (Suc i) = Some q; sd_chain n = Some s\<rbrakk> \<Longrightarrow> q \<prec>[Pareto (SD \<circ> R)] s; sd_chain i = Some q; sd_chain n = Some s\<rbrakk> \<Longrightarrow> q \<prec>[Pareto (SD \<circ> R)] s
[PROOF STEP]
with sd_chain_Suc[of k q s]
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>sd_chain k = Some q; sd_chain (Suc k) = Some s\<rbrakk> \<Longrightarrow> q \<prec>[Pareto (SD \<circ> R)] s
n = Suc k
sd_chain k = Some q
sd_chain n = Some s
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>sd_chain k = Some q; sd_chain (Suc k) = Some s\<rbrakk> \<Longrightarrow> q \<prec>[Pareto (SD \<circ> R)] s
n = Suc k
sd_chain k = Some q
sd_chain n = Some s

goal (1 subgoal):
 1. q \<prec>[Pareto (SD \<circ> R)] s
[PROOF STEP]
by (simp del: sd_chain.simps add: o_def)
[PROOF STATE]
proof (state)
this:
q \<prec>[Pareto (SD \<circ> R)] s

goal (1 subgoal):
 1. \<And>i q. \<lbrakk>i < n; \<And>q. \<lbrakk>sd_chain (Suc i) = Some q; sd_chain n = Some s\<rbrakk> \<Longrightarrow> q \<prec>[Pareto (SD \<circ> R)] s; sd_chain i = Some q; sd_chain n = Some s\<rbrakk> \<Longrightarrow> q \<prec>[Pareto (SD \<circ> R)] s
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i q. \<lbrakk>i < n; \<And>q. \<lbrakk>sd_chain (Suc i) = Some q; sd_chain n = Some s\<rbrakk> \<Longrightarrow> q \<prec>[Pareto (SD \<circ> R)] s; sd_chain i = Some q; sd_chain n = Some s\<rbrakk> \<Longrightarrow> q \<prec>[Pareto (SD \<circ> R)] s
[PROOF STEP]
case (step k q)
[PROOF STATE]
proof (state)
this:
k < n
\<lbrakk>sd_chain (Suc k) = Some ?q; sd_chain n = Some s\<rbrakk> \<Longrightarrow> ?q \<prec>[Pareto (SD \<circ> R)] s
sd_chain k = Some q
sd_chain n = Some s

goal (1 subgoal):
 1. \<And>i q. \<lbrakk>i < n; \<And>q. \<lbrakk>sd_chain (Suc i) = Some q; sd_chain n = Some s\<rbrakk> \<Longrightarrow> q \<prec>[Pareto (SD \<circ> R)] s; sd_chain i = Some q; sd_chain n = Some s\<rbrakk> \<Longrightarrow> q \<prec>[Pareto (SD \<circ> R)] s
[PROOF STEP]
from step.hyps
[PROOF STATE]
proof (chain)
picking this:
k < n
[PROOF STEP]
have "Suc k \<le> n"
[PROOF STATE]
proof (prove)
using this:
k < n

goal (1 subgoal):
 1. Suc k \<le> n
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
Suc k \<le> n

goal (1 subgoal):
 1. \<And>i q. \<lbrakk>i < n; \<And>q. \<lbrakk>sd_chain (Suc i) = Some q; sd_chain n = Some s\<rbrakk> \<Longrightarrow> q \<prec>[Pareto (SD \<circ> R)] s; sd_chain i = Some q; sd_chain n = Some s\<rbrakk> \<Longrightarrow> q \<prec>[Pareto (SD \<circ> R)] s
[PROOF STEP]
from sd_chain_Some_propagate[OF this, of s] step.prems
[PROOF STATE]
proof (chain)
picking this:
sd_chain n = Some s \<Longrightarrow> \<exists>q'. sd_chain (Suc k) = Some q'
sd_chain k = Some q
sd_chain n = Some s
[PROOF STEP]
obtain r
    where r: "sd_chain (Suc k) = Some r"
[PROOF STATE]
proof (prove)
using this:
sd_chain n = Some s \<Longrightarrow> \<exists>q'. sd_chain (Suc k) = Some q'
sd_chain k = Some q
sd_chain n = Some s

goal (1 subgoal):
 1. (\<And>r. sd_chain (Suc k) = Some r \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (auto simp del: sd_chain.simps)
[PROOF STATE]
proof (state)
this:
sd_chain (Suc k) = Some r

goal (1 subgoal):
 1. \<And>i q. \<lbrakk>i < n; \<And>q. \<lbrakk>sd_chain (Suc i) = Some q; sd_chain n = Some s\<rbrakk> \<Longrightarrow> q \<prec>[Pareto (SD \<circ> R)] s; sd_chain i = Some q; sd_chain n = Some s\<rbrakk> \<Longrightarrow> q \<prec>[Pareto (SD \<circ> R)] s
[PROOF STEP]
with step.prems
[PROOF STATE]
proof (chain)
picking this:
sd_chain k = Some q
sd_chain n = Some s
sd_chain (Suc k) = Some r
[PROOF STEP]
have "q \<prec>[Pareto (SD \<circ> R)] r"
[PROOF STATE]
proof (prove)
using this:
sd_chain k = Some q
sd_chain n = Some s
sd_chain (Suc k) = Some r

goal (1 subgoal):
 1. q \<prec>[Pareto (SD \<circ> R)] r
[PROOF STEP]
by (intro sd_chain_Suc)
[PROOF STATE]
proof (state)
this:
q \<prec>[Pareto (SD \<circ> R)] r

goal (1 subgoal):
 1. \<And>i q. \<lbrakk>i < n; \<And>q. \<lbrakk>sd_chain (Suc i) = Some q; sd_chain n = Some s\<rbrakk> \<Longrightarrow> q \<prec>[Pareto (SD \<circ> R)] s; sd_chain i = Some q; sd_chain n = Some s\<rbrakk> \<Longrightarrow> q \<prec>[Pareto (SD \<circ> R)] s
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
q \<prec>[Pareto (SD \<circ> R)] r

goal (1 subgoal):
 1. \<And>i q. \<lbrakk>i < n; \<And>q. \<lbrakk>sd_chain (Suc i) = Some q; sd_chain n = Some s\<rbrakk> \<Longrightarrow> q \<prec>[Pareto (SD \<circ> R)] s; sd_chain i = Some q; sd_chain n = Some s\<rbrakk> \<Longrightarrow> q \<prec>[Pareto (SD \<circ> R)] s
[PROOF STEP]
from r step.prems
[PROOF STATE]
proof (chain)
picking this:
sd_chain (Suc k) = Some r
sd_chain k = Some q
sd_chain n = Some s
[PROOF STEP]
have "r \<prec>[Pareto (SD \<circ> R)] s"
[PROOF STATE]
proof (prove)
using this:
sd_chain (Suc k) = Some r
sd_chain k = Some q
sd_chain n = Some s

goal (1 subgoal):
 1. r \<prec>[Pareto (SD \<circ> R)] s
[PROOF STEP]
by (intro step.IH) simp_all
[PROOF STATE]
proof (state)
this:
r \<prec>[Pareto (SD \<circ> R)] s

goal (1 subgoal):
 1. \<And>i q. \<lbrakk>i < n; \<And>q. \<lbrakk>sd_chain (Suc i) = Some q; sd_chain n = Some s\<rbrakk> \<Longrightarrow> q \<prec>[Pareto (SD \<circ> R)] s; sd_chain i = Some q; sd_chain n = Some s\<rbrakk> \<Longrightarrow> q \<prec>[Pareto (SD \<circ> R)] s
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
q \<prec>[Pareto (SD \<circ> R)] r
r \<prec>[Pareto (SD \<circ> R)] s
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
q \<prec>[Pareto (SD \<circ> R)] r
r \<prec>[Pareto (SD \<circ> R)] s

goal (1 subgoal):
 1. q \<prec>[Pareto (SD \<circ> R)] s
[PROOF STEP]
by (rule SD.Pareto.strict_trans)
[PROOF STATE]
proof (state)
this:
q \<prec>[Pareto (SD \<circ> R)] s

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma affine_independent_span_gt:
  fixes S :: "'a::euclidean_space set"
  assumes ind: "\<not> affine_dependent S" and dim: "DIM ('a) < card S"
    shows "affine hull S = UNIV"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. affine hull S = UNIV
[PROOF STEP]
proof (intro affine_independent_span_eq [OF ind] antisym)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. card S \<le> Suc DIM('a)
 2. Suc DIM('a) \<le> card S
[PROOF STEP]
show "card S \<le> Suc DIM('a)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card S \<le> Suc DIM('a)
[PROOF STEP]
using aff_independent_finite affine_dependent_biggerset ind
[PROOF STATE]
proof (prove)
using this:
\<not> affine_dependent ?B \<Longrightarrow> finite ?B
\<lbrakk>finite ?s; DIM(?'a) + 2 \<le> card ?s\<rbrakk> \<Longrightarrow> affine_dependent ?s
\<not> affine_dependent S

goal (1 subgoal):
 1. card S \<le> Suc DIM('a)
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
card S \<le> Suc DIM('a)

goal (1 subgoal):
 1. Suc DIM('a) \<le> card S
[PROOF STEP]
show "Suc DIM('a) \<le> card S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Suc DIM('a) \<le> card S
[PROOF STEP]
using Suc_leI dim
[PROOF STATE]
proof (prove)
using this:
?m < ?n \<Longrightarrow> Suc ?m \<le> ?n
DIM('a) < card S

goal (1 subgoal):
 1. Suc DIM('a) \<le> card S
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
Suc DIM('a) \<le> card S

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma fun_upd_in_PiE: "x \<notin> S \<Longrightarrow> f \<in> Pi\<^sub>E (insert x S) T \<Longrightarrow> f(x := undefined) \<in> Pi\<^sub>E S T"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>x \<notin> S; f \<in> Pi\<^sub>E (insert x S) T\<rbrakk> \<Longrightarrow> f(x := undefined) \<in> Pi\<^sub>E S T
[PROOF STEP]
unfolding PiE_def extensional_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>x \<notin> S; f \<in> Pi (insert x S) T \<inter> {f. \<forall>xa. xa \<notin> insert x S \<longrightarrow> f xa = undefined}\<rbrakk> \<Longrightarrow> f(x := undefined) \<in> Pi S T \<inter> {f. \<forall>x. x \<notin> S \<longrightarrow> f x = undefined}
[PROOF STEP]
by auto


[STATEMENT]
lemma extend_map_to_freeword_hom1:
  fixes   f :: "'a \<Rightarrow> 'b::group_add"
  defines "h::'a signed \<Rightarrow> 'b \<equiv> \<lambda>(s,b). if b then f s else - (f s)"
  defines "g::'a freeword \<Rightarrow> 'b \<equiv> \<lambda>x. sum_list (map h (freeword x))"
  shows   "g (Abs_freeletter s) = f s"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. g (Abs_freeletter s) = f s
[PROOF STEP]
using   assms
[PROOF STATE]
proof (prove)
using this:
h \<equiv> \<lambda>(s, b). if b then f s else - f s
g \<equiv> \<lambda>x. sum_list (map h (freeword x))

goal (1 subgoal):
 1. g (Abs_freeletter s) = f s
[PROOF STEP]
by      (simp add: Abs_freeword_inverse)


[STATEMENT]
lemma lm094:
  assumes "finite Y"
  shows   "set [ f +* {(x,y)} . y \<leftarrow> sorted_list_of_set (Y - (Range f)) ] =
           {      f +* {(x,y)} | y . y \<in>                 Y - (Range f)}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set (map (\<lambda>y. f +< {(x, y)}) (sorted_list_of_set (Y - Range f))) = {f +< {(x, y)} |y. y \<in> Y - Range f}
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
finite Y

goal (1 subgoal):
 1. set (map (\<lambda>y. f +< {(x, y)}) (sorted_list_of_set (Y - Range f))) = {f +< {(x, y)} |y. y \<in> Y - Range f}
[PROOF STEP]
by auto


[STATEMENT]
lemma chain_homotopic_singular_subdivision:
  obtains h where
        "\<And>p. h p 0 = 0"
        "\<And>p c1 c2. h p (c1-c2) = h p c1 - h p c2"
        "\<And>p X c. singular_chain p X c \<Longrightarrow> singular_chain (Suc p) X (h p c)"
        "\<And>p X c. singular_chain p X c
                 \<Longrightarrow> chain_boundary (Suc p) (h p c) + h (p - Suc 0) (chain_boundary p c) = singular_subdivision p c - c"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>h. \<lbrakk>\<And>p. h p 0 = 0; \<And>p c1 c2. h p (c1 - c2) = h p c1 - h p c2; \<And>p X c. singular_chain p X c \<Longrightarrow> singular_chain (Suc p) X (h p c); \<And>p X c. singular_chain p X c \<Longrightarrow> chain_boundary (Suc p) (h p c) + h (p - Suc 0) (chain_boundary p c) = singular_subdivision p c - c\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<And>h. \<lbrakk>\<And>p. h p 0 = 0; \<And>p c1 c2. h p (c1 - c2) = h p c1 - h p c2; \<And>p X c. singular_chain p X c \<Longrightarrow> singular_chain (Suc p) X (h p c); \<And>p X c. singular_chain p X c \<Longrightarrow> chain_boundary (Suc p) (h p c) + h (p - Suc 0) (chain_boundary p c) = singular_subdivision p c - c\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
define k where "k \<equiv> \<lambda>p. frag_extend (\<lambda>f:: (nat \<Rightarrow> real) \<Rightarrow> 'a. chain_map (Suc p) f (subd p (frag_of(restrict id (standard_simplex p)))))"
[PROOF STATE]
proof (state)
this:
k \<equiv> \<lambda>p. frag_extend (\<lambda>f. chain_map (Suc p) f (subd p (frag_of (restrict id (standard_simplex p)))))

goal (1 subgoal):
 1. (\<And>h. \<lbrakk>\<And>p. h p 0 = 0; \<And>p c1 c2. h p (c1 - c2) = h p c1 - h p c2; \<And>p X c. singular_chain p X c \<Longrightarrow> singular_chain (Suc p) X (h p c); \<And>p X c. singular_chain p X c \<Longrightarrow> chain_boundary (Suc p) (h p c) + h (p - Suc 0) (chain_boundary p c) = singular_subdivision p c - c\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. thesis
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (4 subgoals):
 1. \<And>p. ?h p 0 = 0
 2. \<And>p c1 c2. ?h p (c1 - c2) = ?h p c1 - ?h p c2
 3. \<And>p X c. singular_chain p X c \<Longrightarrow> singular_chain (Suc p) X (?h p c)
 4. \<And>p X c. singular_chain p X c \<Longrightarrow> chain_boundary (Suc p) (?h p c) + ?h (p - Suc 0) (chain_boundary p c) = singular_subdivision p c - c
[PROOF STEP]
fix p X and c :: "'a chain"
[PROOF STATE]
proof (state)
goal (4 subgoals):
 1. \<And>p. ?h p 0 = 0
 2. \<And>p c1 c2. ?h p (c1 - c2) = ?h p c1 - ?h p c2
 3. \<And>p X c. singular_chain p X c \<Longrightarrow> singular_chain (Suc p) X (?h p c)
 4. \<And>p X c. singular_chain p X c \<Longrightarrow> chain_boundary (Suc p) (?h p c) + ?h (p - Suc 0) (chain_boundary p c) = singular_subdivision p c - c
[PROOF STEP]
assume c: "singular_chain p X c"
[PROOF STATE]
proof (state)
this:
singular_chain p X c

goal (4 subgoals):
 1. \<And>p. ?h p 0 = 0
 2. \<And>p c1 c2. ?h p (c1 - c2) = ?h p c1 - ?h p c2
 3. \<And>p X c. singular_chain p X c \<Longrightarrow> singular_chain (Suc p) X (?h p c)
 4. \<And>p X c. singular_chain p X c \<Longrightarrow> chain_boundary (Suc p) (?h p c) + ?h (p - Suc 0) (chain_boundary p c) = singular_subdivision p c - c
[PROOF STEP]
have "singular_chain (Suc p) X (k p c) \<and>
               chain_boundary (Suc p) (k p c) + k (p - Suc 0) (chain_boundary p c) = singular_subdivision p c - c"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. singular_chain (Suc p) X (k p c) \<and> chain_boundary (Suc p) (k p c) + k (p - Suc 0) (chain_boundary p c) = singular_subdivision p c - c
[PROOF STEP]
using c [unfolded singular_chain_def]
[PROOF STATE]
proof (prove)
using this:
Poly_Mapping.keys c \<subseteq> singular_simplex_set p X

goal (1 subgoal):
 1. singular_chain (Suc p) X (k p c) \<and> chain_boundary (Suc p) (k p c) + k (p - Suc 0) (chain_boundary p c) = singular_subdivision p c - c
[PROOF STEP]
proof (induction rule: frag_induction)
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. singular_chain (Suc p) X (k p 0) \<and> chain_boundary (Suc p) (k p 0) + k (p - Suc 0) (chain_boundary p 0) = singular_subdivision p 0 - 0
 2. \<And>x. x \<in> singular_simplex_set p X \<Longrightarrow> singular_chain (Suc p) X (k p (frag_of x)) \<and> chain_boundary (Suc p) (k p (frag_of x)) + k (p - Suc 0) (chain_boundary p (frag_of x)) = singular_subdivision p (frag_of x) - frag_of x
 3. \<And>a b. \<lbrakk>singular_chain (Suc p) X (k p a) \<and> chain_boundary (Suc p) (k p a) + k (p - Suc 0) (chain_boundary p a) = singular_subdivision p a - a; singular_chain (Suc p) X (k p b) \<and> chain_boundary (Suc p) (k p b) + k (p - Suc 0) (chain_boundary p b) = singular_subdivision p b - b\<rbrakk> \<Longrightarrow> singular_chain (Suc p) X (k p (a - b)) \<and> chain_boundary (Suc p) (k p (a - b)) + k (p - Suc 0) (chain_boundary p (a - b)) = singular_subdivision p (a - b) - (a - b)
[PROOF STEP]
case (one f)
[PROOF STATE]
proof (state)
this:
f \<in> singular_simplex_set p X

goal (3 subgoals):
 1. singular_chain (Suc p) X (k p 0) \<and> chain_boundary (Suc p) (k p 0) + k (p - Suc 0) (chain_boundary p 0) = singular_subdivision p 0 - 0
 2. \<And>x. x \<in> singular_simplex_set p X \<Longrightarrow> singular_chain (Suc p) X (k p (frag_of x)) \<and> chain_boundary (Suc p) (k p (frag_of x)) + k (p - Suc 0) (chain_boundary p (frag_of x)) = singular_subdivision p (frag_of x) - frag_of x
 3. \<And>a b. \<lbrakk>singular_chain (Suc p) X (k p a) \<and> chain_boundary (Suc p) (k p a) + k (p - Suc 0) (chain_boundary p a) = singular_subdivision p a - a; singular_chain (Suc p) X (k p b) \<and> chain_boundary (Suc p) (k p b) + k (p - Suc 0) (chain_boundary p b) = singular_subdivision p b - b\<rbrakk> \<Longrightarrow> singular_chain (Suc p) X (k p (a - b)) \<and> chain_boundary (Suc p) (k p (a - b)) + k (p - Suc 0) (chain_boundary p (a - b)) = singular_subdivision p (a - b) - (a - b)
[PROOF STEP]
let ?X = "subtopology (powertop_real UNIV) (standard_simplex p)"
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. singular_chain (Suc p) X (k p 0) \<and> chain_boundary (Suc p) (k p 0) + k (p - Suc 0) (chain_boundary p 0) = singular_subdivision p 0 - 0
 2. \<And>x. x \<in> singular_simplex_set p X \<Longrightarrow> singular_chain (Suc p) X (k p (frag_of x)) \<and> chain_boundary (Suc p) (k p (frag_of x)) + k (p - Suc 0) (chain_boundary p (frag_of x)) = singular_subdivision p (frag_of x) - frag_of x
 3. \<And>a b. \<lbrakk>singular_chain (Suc p) X (k p a) \<and> chain_boundary (Suc p) (k p a) + k (p - Suc 0) (chain_boundary p a) = singular_subdivision p a - a; singular_chain (Suc p) X (k p b) \<and> chain_boundary (Suc p) (k p b) + k (p - Suc 0) (chain_boundary p b) = singular_subdivision p b - b\<rbrakk> \<Longrightarrow> singular_chain (Suc p) X (k p (a - b)) \<and> chain_boundary (Suc p) (k p (a - b)) + k (p - Suc 0) (chain_boundary p (a - b)) = singular_subdivision p (a - b) - (a - b)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. singular_chain (Suc p) X (k p (frag_of f)) \<and> chain_boundary (Suc p) (k p (frag_of f)) + k (p - Suc 0) (chain_boundary p (frag_of f)) = singular_subdivision p (frag_of f) - frag_of f
[PROOF STEP]
proof (simp add: k_def, intro conjI)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. singular_chain (Suc p) X (chain_map (Suc p) f (subd p (frag_of (restrict id (standard_simplex p)))))
 2. chain_boundary (Suc p) (chain_map (Suc p) f (subd p (frag_of (restrict id (standard_simplex p))))) + frag_extend (\<lambda>f. chain_map (Suc (p - Suc 0)) f (subd (p - Suc 0) (frag_of (restrict id (standard_simplex (p - Suc 0)))))) (chain_boundary p (frag_of f)) = singular_subdivision p (frag_of f) - frag_of f
[PROOF STEP]
show "singular_chain (Suc p) X (chain_map (Suc p) f (subd p (frag_of (restrict id (standard_simplex p)))))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. singular_chain (Suc p) X (chain_map (Suc p) f (subd p (frag_of (restrict id (standard_simplex p)))))
[PROOF STEP]
proof (rule singular_chain_chain_map)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. singular_chain (Suc p) ?X (subd p (frag_of (restrict id (standard_simplex p))))
 2. continuous_map ?X X f
[PROOF STEP]
show "singular_chain (Suc p) ?X  (subd p (frag_of (restrict id (standard_simplex p))))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. singular_chain (Suc p) (subtopology (powertop_real UNIV) (standard_simplex p)) (subd p (frag_of (restrict id (standard_simplex p))))
[PROOF STEP]
by (simp add: chain_homotopic_simplicial_subdivision2 simplicial_imp_singular_chain)
[PROOF STATE]
proof (state)
this:
singular_chain (Suc p) (subtopology (powertop_real UNIV) (standard_simplex p)) (subd p (frag_of (restrict id (standard_simplex p))))

goal (1 subgoal):
 1. continuous_map (subtopology (powertop_real UNIV) (standard_simplex p)) X f
[PROOF STEP]
show "continuous_map ?X X f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. continuous_map (subtopology (powertop_real UNIV) (standard_simplex p)) X f
[PROOF STEP]
using one.hyps singular_simplex_def
[PROOF STATE]
proof (prove)
using this:
f \<in> singular_simplex_set p X
singular_simplex ?p ?X ?f \<equiv> continuous_map (subtopology (powertop_real UNIV) (standard_simplex ?p)) ?X ?f \<and> ?f \<in> extensional (standard_simplex ?p)

goal (1 subgoal):
 1. continuous_map (subtopology (powertop_real UNIV) (standard_simplex p)) X f
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
continuous_map (subtopology (powertop_real UNIV) (standard_simplex p)) X f

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
singular_chain (Suc p) X (chain_map (Suc p) f (subd p (frag_of (restrict id (standard_simplex p)))))

goal (1 subgoal):
 1. chain_boundary (Suc p) (chain_map (Suc p) f (subd p (frag_of (restrict id (standard_simplex p))))) + frag_extend (\<lambda>f. chain_map (Suc (p - Suc 0)) f (subd (p - Suc 0) (frag_of (restrict id (standard_simplex (p - Suc 0)))))) (chain_boundary p (frag_of f)) = singular_subdivision p (frag_of f) - frag_of f
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. chain_boundary (Suc p) (chain_map (Suc p) f (subd p (frag_of (restrict id (standard_simplex p))))) + frag_extend (\<lambda>f. chain_map (Suc (p - Suc 0)) f (subd (p - Suc 0) (frag_of (restrict id (standard_simplex (p - Suc 0)))))) (chain_boundary p (frag_of f)) = singular_subdivision p (frag_of f) - frag_of f
[PROOF STEP]
have scp: "singular_chain (Suc p) ?X (subd p (frag_of (restrict id (standard_simplex p))))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. singular_chain (Suc p) (subtopology (powertop_real UNIV) (standard_simplex p)) (subd p (frag_of (restrict id (standard_simplex p))))
[PROOF STEP]
by (simp add: chain_homotopic_simplicial_subdivision2 simplicial_imp_singular_chain)
[PROOF STATE]
proof (state)
this:
singular_chain (Suc p) (subtopology (powertop_real UNIV) (standard_simplex p)) (subd p (frag_of (restrict id (standard_simplex p))))

goal (1 subgoal):
 1. chain_boundary (Suc p) (chain_map (Suc p) f (subd p (frag_of (restrict id (standard_simplex p))))) + frag_extend (\<lambda>f. chain_map (Suc (p - Suc 0)) f (subd (p - Suc 0) (frag_of (restrict id (standard_simplex (p - Suc 0)))))) (chain_boundary p (frag_of f)) = singular_subdivision p (frag_of f) - frag_of f
[PROOF STEP]
have feqf: "frag_of (simplex_map p f (restrict id (standard_simplex p))) = frag_of f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. frag_of (simplex_map p f (restrict id (standard_simplex p))) = frag_of f
[PROOF STEP]
using one.hyps singular_simplex_chain_map_id
[PROOF STATE]
proof (prove)
using this:
f \<in> singular_simplex_set p X
singular_simplex ?p ?X ?f \<Longrightarrow> chain_map ?p ?f (frag_of (restrict id (standard_simplex ?p))) = frag_of ?f

goal (1 subgoal):
 1. frag_of (simplex_map p f (restrict id (standard_simplex p))) = frag_of f
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
frag_of (simplex_map p f (restrict id (standard_simplex p))) = frag_of f

goal (1 subgoal):
 1. chain_boundary (Suc p) (chain_map (Suc p) f (subd p (frag_of (restrict id (standard_simplex p))))) + frag_extend (\<lambda>f. chain_map (Suc (p - Suc 0)) f (subd (p - Suc 0) (frag_of (restrict id (standard_simplex (p - Suc 0)))))) (chain_boundary p (frag_of f)) = singular_subdivision p (frag_of f) - frag_of f
[PROOF STEP]
have *: "chain_map p f
                   (subd (p - Suc 0)
                     (\<Sum>k\<le>p. frag_cmul ((-1) ^ k) (frag_of (singular_face p k id))))
              = (\<Sum>x\<le>p. frag_cmul ((-1) ^ x)
                         (chain_map p (singular_face p x f)
                           (subd (p - Suc 0) (frag_of (restrict id (standard_simplex (p - Suc 0)))))))"
                  (is "?lhs = ?rhs")
                  if "p > 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. chain_map p f (subd (p - Suc 0) (\<Sum>k\<le>p. frag_cmul ((- 1) ^ k) (frag_of (singular_face p k id)))) = (\<Sum>x\<le>p. frag_cmul ((- 1) ^ x) (chain_map p (singular_face p x f) (subd (p - Suc 0) (frag_of (restrict id (standard_simplex (p - Suc 0)))))))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. chain_map p f (subd (p - Suc 0) (\<Sum>k\<le>p. frag_cmul ((- 1) ^ k) (frag_of (singular_face p k id)))) = (\<Sum>x\<le>p. frag_cmul ((- 1) ^ x) (chain_map p (singular_face p x f) (subd (p - Suc 0) (frag_of (restrict id (standard_simplex (p - Suc 0)))))))
[PROOF STEP]
have eqc: "subd (p - Suc 0) (frag_of (singular_face p i id))
                   = chain_map p (singular_face p i id)
                                 (subd (p - Suc 0) (frag_of (restrict id (standard_simplex (p - Suc 0)))))"
            if "i \<le> p" for i
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. subd (p - Suc 0) (frag_of (singular_face p i id)) = chain_map p (singular_face p i id) (subd (p - Suc 0) (frag_of (restrict id (standard_simplex (p - Suc 0)))))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. subd (p - Suc 0) (frag_of (singular_face p i id)) = chain_map p (singular_face p i id) (subd (p - Suc 0) (frag_of (restrict id (standard_simplex (p - Suc 0)))))
[PROOF STEP]
have 1: "simplicial_chain (p - Suc 0) (standard_simplex (p - Suc 0))
                       (frag_of (restrict id (standard_simplex (p - Suc 0))))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. simplicial_chain (p - Suc 0) (standard_simplex (p - Suc 0)) (frag_of (restrict id (standard_simplex (p - Suc 0))))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
simplicial_chain (p - Suc 0) (standard_simplex (p - Suc 0)) (frag_of (restrict id (standard_simplex (p - Suc 0))))

goal (1 subgoal):
 1. subd (p - Suc 0) (frag_of (singular_face p i id)) = chain_map p (singular_face p i id) (subd (p - Suc 0) (frag_of (restrict id (standard_simplex (p - Suc 0)))))
[PROOF STEP]
have 2: "simplicial_simplex (p - Suc 0) (standard_simplex p) (singular_face p i id)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. simplicial_simplex (p - Suc 0) (standard_simplex p) (singular_face p i id)
[PROOF STEP]
by (metis One_nat_def Suc_leI \<open>0 < p\<close> simplicial_simplex_id simplicial_simplex_singular_face singular_face_restrict subsetI that)
[PROOF STATE]
proof (state)
this:
simplicial_simplex (p - Suc 0) (standard_simplex p) (singular_face p i id)

goal (1 subgoal):
 1. subd (p - Suc 0) (frag_of (singular_face p i id)) = chain_map p (singular_face p i id) (subd (p - Suc 0) (frag_of (restrict id (standard_simplex (p - Suc 0)))))
[PROOF STEP]
have 3: "simplex_map (p - Suc 0) (singular_face p i id) (restrict id (standard_simplex (p - Suc 0)))
                   = singular_face p i id"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. simplex_map (p - Suc 0) (singular_face p i id) (restrict id (standard_simplex (p - Suc 0))) = singular_face p i id
[PROOF STEP]
by (force simp: simplex_map_def singular_face_def)
[PROOF STATE]
proof (state)
this:
simplex_map (p - Suc 0) (singular_face p i id) (restrict id (standard_simplex (p - Suc 0))) = singular_face p i id

goal (1 subgoal):
 1. subd (p - Suc 0) (frag_of (singular_face p i id)) = chain_map p (singular_face p i id) (subd (p - Suc 0) (frag_of (restrict id (standard_simplex (p - Suc 0)))))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. subd (p - Suc 0) (frag_of (singular_face p i id)) = chain_map p (singular_face p i id) (subd (p - Suc 0) (frag_of (restrict id (standard_simplex (p - Suc 0)))))
[PROOF STEP]
using chain_homotopic_simplicial_subdivision1 [OF 1 2]
                that \<open>p > 0\<close>
[PROOF STATE]
proof (prove)
using this:
chain_map (Suc (p - Suc 0)) (singular_face p i id) (subd (p - Suc 0) (frag_of (restrict id (standard_simplex (p - Suc 0))))) = subd (p - Suc 0) (chain_map (p - Suc 0) (singular_face p i id) (frag_of (restrict id (standard_simplex (p - Suc 0)))))
i \<le> p
0 < p

goal (1 subgoal):
 1. subd (p - Suc 0) (frag_of (singular_face p i id)) = chain_map p (singular_face p i id) (subd (p - Suc 0) (frag_of (restrict id (standard_simplex (p - Suc 0)))))
[PROOF STEP]
by (simp add: 3)
[PROOF STATE]
proof (state)
this:
subd (p - Suc 0) (frag_of (singular_face p i id)) = chain_map p (singular_face p i id) (subd (p - Suc 0) (frag_of (restrict id (standard_simplex (p - Suc 0)))))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
?i \<le> p \<Longrightarrow> subd (p - Suc 0) (frag_of (singular_face p ?i id)) = chain_map p (singular_face p ?i id) (subd (p - Suc 0) (frag_of (restrict id (standard_simplex (p - Suc 0)))))

goal (1 subgoal):
 1. chain_map p f (subd (p - Suc 0) (\<Sum>k\<le>p. frag_cmul ((- 1) ^ k) (frag_of (singular_face p k id)))) = (\<Sum>x\<le>p. frag_cmul ((- 1) ^ x) (chain_map p (singular_face p x f) (subd (p - Suc 0) (frag_of (restrict id (standard_simplex (p - Suc 0)))))))
[PROOF STEP]
have xx: "simplicial_chain p (standard_simplex(p - Suc 0))
                    (subd (p - Suc 0) (frag_of (restrict id (standard_simplex (p - Suc 0)))))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. simplicial_chain p (standard_simplex (p - Suc 0)) (subd (p - Suc 0) (frag_of (restrict id (standard_simplex (p - Suc 0)))))
[PROOF STEP]
by (metis Suc_pred chain_homotopic_simplicial_subdivision2 order_refl simplicial_chain_of simplicial_simplex_id that)
[PROOF STATE]
proof (state)
this:
simplicial_chain p (standard_simplex (p - Suc 0)) (subd (p - Suc 0) (frag_of (restrict id (standard_simplex (p - Suc 0)))))

goal (1 subgoal):
 1. chain_map p f (subd (p - Suc 0) (\<Sum>k\<le>p. frag_cmul ((- 1) ^ k) (frag_of (singular_face p k id)))) = (\<Sum>x\<le>p. frag_cmul ((- 1) ^ x) (chain_map p (singular_face p x f) (subd (p - Suc 0) (frag_of (restrict id (standard_simplex (p - Suc 0)))))))
[PROOF STEP]
have yy: "\<And>k. k \<le> p \<Longrightarrow>
                 chain_map p f
                  (chain_map p (singular_face p k id) h) = chain_map p (singular_face p k f) h"
            if "simplicial_chain p (standard_simplex(p - Suc 0)) h" for h
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>k. k \<le> p \<Longrightarrow> chain_map p f (chain_map p (singular_face p k id) h) = chain_map p (singular_face p k f) h
[PROOF STEP]
using that
[PROOF STATE]
proof (prove)
using this:
simplicial_chain p (standard_simplex (p - Suc 0)) h

goal (1 subgoal):
 1. \<And>k. k \<le> p \<Longrightarrow> chain_map p f (chain_map p (singular_face p k id) h) = chain_map p (singular_face p k f) h
[PROOF STEP]
unfolding simplicial_chain_def
[PROOF STATE]
proof (prove)
using this:
Poly_Mapping.keys h \<subseteq> Collect (simplicial_simplex p (standard_simplex (p - Suc 0)))

goal (1 subgoal):
 1. \<And>k. k \<le> p \<Longrightarrow> chain_map p f (chain_map p (singular_face p k id) h) = chain_map p (singular_face p k f) h
[PROOF STEP]
proof (induction h rule: frag_induction)
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. \<And>k. k \<le> p \<Longrightarrow> chain_map p f (chain_map p (singular_face p k id) 0) = chain_map p (singular_face p k f) 0
 2. \<And>x k. \<lbrakk>x \<in> Collect (simplicial_simplex p (standard_simplex (p - Suc 0))); k \<le> p\<rbrakk> \<Longrightarrow> chain_map p f (chain_map p (singular_face p k id) (frag_of x)) = chain_map p (singular_face p k f) (frag_of x)
 3. \<And>a b k. \<lbrakk>\<And>k. k \<le> p \<Longrightarrow> chain_map p f (chain_map p (singular_face p k id) a) = chain_map p (singular_face p k f) a; \<And>k. k \<le> p \<Longrightarrow> chain_map p f (chain_map p (singular_face p k id) b) = chain_map p (singular_face p k f) b; k \<le> p\<rbrakk> \<Longrightarrow> chain_map p f (chain_map p (singular_face p k id) (a - b)) = chain_map p (singular_face p k f) (a - b)
[PROOF STEP]
case (one x)
[PROOF STATE]
proof (state)
this:
x \<in> Collect (simplicial_simplex p (standard_simplex (p - Suc 0)))
k \<le> p

goal (3 subgoals):
 1. \<And>k. k \<le> p \<Longrightarrow> chain_map p f (chain_map p (singular_face p k id) 0) = chain_map p (singular_face p k f) 0
 2. \<And>x k. \<lbrakk>x \<in> Collect (simplicial_simplex p (standard_simplex (p - Suc 0))); k \<le> p\<rbrakk> \<Longrightarrow> chain_map p f (chain_map p (singular_face p k id) (frag_of x)) = chain_map p (singular_face p k f) (frag_of x)
 3. \<And>a b k. \<lbrakk>\<And>k. k \<le> p \<Longrightarrow> chain_map p f (chain_map p (singular_face p k id) a) = chain_map p (singular_face p k f) a; \<And>k. k \<le> p \<Longrightarrow> chain_map p f (chain_map p (singular_face p k id) b) = chain_map p (singular_face p k f) b; k \<le> p\<rbrakk> \<Longrightarrow> chain_map p f (chain_map p (singular_face p k id) (a - b)) = chain_map p (singular_face p k f) (a - b)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
x \<in> Collect (simplicial_simplex p (standard_simplex (p - Suc 0)))
k \<le> p
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
x \<in> Collect (simplicial_simplex p (standard_simplex (p - Suc 0)))
k \<le> p

goal (1 subgoal):
 1. chain_map p f (chain_map p (singular_face p k id) (frag_of x)) = chain_map p (singular_face p k f) (frag_of x)
[PROOF STEP]
using one
[PROOF STATE]
proof (prove)
using this:
x \<in> Collect (simplicial_simplex p (standard_simplex (p - Suc 0)))
k \<le> p
x \<in> Collect (simplicial_simplex p (standard_simplex (p - Suc 0)))
k \<le> p

goal (1 subgoal):
 1. chain_map p f (chain_map p (singular_face p k id) (frag_of x)) = chain_map p (singular_face p k f) (frag_of x)
[PROOF STEP]
apply (simp add: chain_map_of singular_simplex_def simplicial_simplex_def, auto)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>l. \<lbrakk>simplicial_simplex p (standard_simplex (p - Suc 0)) (oriented_simplex p l); k \<le> p; continuous_map (subtopology (powertop_real UNIV) (standard_simplex p)) (subtopology (powertop_real UNIV) (standard_simplex (p - Suc 0))) (oriented_simplex p l); oriented_simplex p l \<in> extensional (standard_simplex p); x = oriented_simplex p l\<rbrakk> \<Longrightarrow> frag_of (simplex_map p f (simplex_map p (singular_face p k (\<lambda>a. a)) (oriented_simplex p l))) = frag_of (simplex_map p (singular_face p k f) (oriented_simplex p l))
[PROOF STEP]
apply (rule_tac f=frag_of in arg_cong, rule)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>l xa. \<lbrakk>simplicial_simplex p (standard_simplex (p - Suc 0)) (oriented_simplex p l); k \<le> p; continuous_map (subtopology (powertop_real UNIV) (standard_simplex p)) (subtopology (powertop_real UNIV) (standard_simplex (p - Suc 0))) (oriented_simplex p l); oriented_simplex p l \<in> extensional (standard_simplex p); x = oriented_simplex p l\<rbrakk> \<Longrightarrow> simplex_map p f (simplex_map p (singular_face p k (\<lambda>a. a)) (oriented_simplex p l)) xa = simplex_map p (singular_face p k f) (oriented_simplex p l) xa
[PROOF STEP]
apply (simp add: simplex_map_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>l xa. \<lbrakk>simplicial_simplex p (standard_simplex (p - Suc 0)) (oriented_simplex p l); k \<le> p; continuous_map (subtopology (powertop_real UNIV) (standard_simplex p)) (subtopology (powertop_real UNIV) (standard_simplex (p - Suc 0))) (oriented_simplex p l); oriented_simplex p l \<in> extensional (standard_simplex p); x = oriented_simplex p l\<rbrakk> \<Longrightarrow> xa \<in> standard_simplex p \<longrightarrow> f (singular_face p k (\<lambda>a. a) (oriented_simplex p l xa)) = singular_face p k f (oriented_simplex p l xa)
[PROOF STEP]
by (simp add: continuous_map_in_subtopology image_subset_iff singular_face_def)
[PROOF STATE]
proof (state)
this:
chain_map p f (chain_map p (singular_face p k id) (frag_of x)) = chain_map p (singular_face p k f) (frag_of x)

goal (2 subgoals):
 1. \<And>k. k \<le> p \<Longrightarrow> chain_map p f (chain_map p (singular_face p k id) 0) = chain_map p (singular_face p k f) 0
 2. \<And>a b k. \<lbrakk>\<And>k. k \<le> p \<Longrightarrow> chain_map p f (chain_map p (singular_face p k id) a) = chain_map p (singular_face p k f) a; \<And>k. k \<le> p \<Longrightarrow> chain_map p f (chain_map p (singular_face p k id) b) = chain_map p (singular_face p k f) b; k \<le> p\<rbrakk> \<Longrightarrow> chain_map p f (chain_map p (singular_face p k id) (a - b)) = chain_map p (singular_face p k f) (a - b)
[PROOF STEP]
qed (auto simp: chain_map_diff)
[PROOF STATE]
proof (state)
this:
\<lbrakk>simplicial_chain p (standard_simplex (p - Suc 0)) ?h1; ?k \<le> p\<rbrakk> \<Longrightarrow> chain_map p f (chain_map p (singular_face p ?k id) ?h1) = chain_map p (singular_face p ?k f) ?h1

goal (1 subgoal):
 1. chain_map p f (subd (p - Suc 0) (\<Sum>k\<le>p. frag_cmul ((- 1) ^ k) (frag_of (singular_face p k id)))) = (\<Sum>x\<le>p. frag_cmul ((- 1) ^ x) (chain_map p (singular_face p x f) (subd (p - Suc 0) (frag_of (restrict id (standard_simplex (p - Suc 0)))))))
[PROOF STEP]
have "?lhs
                = chain_map p f
                      (\<Sum>k\<le>p. frag_cmul ((-1) ^ k)
                          (chain_map p (singular_face p k id)
                           (subd (p - Suc 0) (frag_of (restrict id (standard_simplex (p - Suc 0)))))))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. chain_map p f (subd (p - Suc 0) (\<Sum>k\<le>p. frag_cmul ((- 1) ^ k) (frag_of (singular_face p k id)))) = chain_map p f (\<Sum>k\<le>p. frag_cmul ((- 1) ^ k) (chain_map p (singular_face p k id) (subd (p - Suc 0) (frag_of (restrict id (standard_simplex (p - Suc 0)))))))
[PROOF STEP]
by (simp add: subd_power_sum subd_power_uminus eqc)
[PROOF STATE]
proof (state)
this:
chain_map p f (subd (p - Suc 0) (\<Sum>k\<le>p. frag_cmul ((- 1) ^ k) (frag_of (singular_face p k id)))) = chain_map p f (\<Sum>k\<le>p. frag_cmul ((- 1) ^ k) (chain_map p (singular_face p k id) (subd (p - Suc 0) (frag_of (restrict id (standard_simplex (p - Suc 0)))))))

goal (1 subgoal):
 1. chain_map p f (subd (p - Suc 0) (\<Sum>k\<le>p. frag_cmul ((- 1) ^ k) (frag_of (singular_face p k id)))) = (\<Sum>x\<le>p. frag_cmul ((- 1) ^ x) (chain_map p (singular_face p x f) (subd (p - Suc 0) (frag_of (restrict id (standard_simplex (p - Suc 0)))))))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
chain_map p f (subd (p - Suc 0) (\<Sum>k\<le>p. frag_cmul ((- 1) ^ k) (frag_of (singular_face p k id)))) = chain_map p f (\<Sum>k\<le>p. frag_cmul ((- 1) ^ k) (chain_map p (singular_face p k id) (subd (p - Suc 0) (frag_of (restrict id (standard_simplex (p - Suc 0)))))))

goal (1 subgoal):
 1. chain_map p f (subd (p - Suc 0) (\<Sum>k\<le>p. frag_cmul ((- 1) ^ k) (frag_of (singular_face p k id)))) = (\<Sum>x\<le>p. frag_cmul ((- 1) ^ x) (chain_map p (singular_face p x f) (subd (p - Suc 0) (frag_of (restrict id (standard_simplex (p - Suc 0)))))))
[PROOF STEP]
have "\<dots> = ?rhs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. chain_map p f (\<Sum>k\<le>p. frag_cmul ((- 1) ^ k) (chain_map p (singular_face p k id) (subd (p - Suc 0) (frag_of (restrict id (standard_simplex (p - Suc 0))))))) = (\<Sum>x\<le>p. frag_cmul ((- 1) ^ x) (chain_map p (singular_face p x f) (subd (p - Suc 0) (frag_of (restrict id (standard_simplex (p - Suc 0)))))))
[PROOF STEP]
by (simp add: chain_map_sum xx yy)
[PROOF STATE]
proof (state)
this:
chain_map p f (\<Sum>k\<le>p. frag_cmul ((- 1) ^ k) (chain_map p (singular_face p k id) (subd (p - Suc 0) (frag_of (restrict id (standard_simplex (p - Suc 0))))))) = (\<Sum>x\<le>p. frag_cmul ((- 1) ^ x) (chain_map p (singular_face p x f) (subd (p - Suc 0) (frag_of (restrict id (standard_simplex (p - Suc 0)))))))

goal (1 subgoal):
 1. chain_map p f (subd (p - Suc 0) (\<Sum>k\<le>p. frag_cmul ((- 1) ^ k) (frag_of (singular_face p k id)))) = (\<Sum>x\<le>p. frag_cmul ((- 1) ^ x) (chain_map p (singular_face p x f) (subd (p - Suc 0) (frag_of (restrict id (standard_simplex (p - Suc 0)))))))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
chain_map p f (subd (p - Suc 0) (\<Sum>k\<le>p. frag_cmul ((- 1) ^ k) (frag_of (singular_face p k id)))) = (\<Sum>x\<le>p. frag_cmul ((- 1) ^ x) (chain_map p (singular_face p x f) (subd (p - Suc 0) (frag_of (restrict id (standard_simplex (p - Suc 0)))))))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
chain_map p f (subd (p - Suc 0) (\<Sum>k\<le>p. frag_cmul ((- 1) ^ k) (frag_of (singular_face p k id)))) = (\<Sum>x\<le>p. frag_cmul ((- 1) ^ x) (chain_map p (singular_face p x f) (subd (p - Suc 0) (frag_of (restrict id (standard_simplex (p - Suc 0)))))))

goal (1 subgoal):
 1. chain_map p f (subd (p - Suc 0) (\<Sum>k\<le>p. frag_cmul ((- 1) ^ k) (frag_of (singular_face p k id)))) = (\<Sum>x\<le>p. frag_cmul ((- 1) ^ x) (chain_map p (singular_face p x f) (subd (p - Suc 0) (frag_of (restrict id (standard_simplex (p - Suc 0)))))))
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
chain_map p f (subd (p - Suc 0) (\<Sum>k\<le>p. frag_cmul ((- 1) ^ k) (frag_of (singular_face p k id)))) = (\<Sum>x\<le>p. frag_cmul ((- 1) ^ x) (chain_map p (singular_face p x f) (subd (p - Suc 0) (frag_of (restrict id (standard_simplex (p - Suc 0)))))))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
0 < p \<Longrightarrow> chain_map p f (subd (p - Suc 0) (\<Sum>k\<le>p. frag_cmul ((- 1) ^ k) (frag_of (singular_face p k id)))) = (\<Sum>x\<le>p. frag_cmul ((- 1) ^ x) (chain_map p (singular_face p x f) (subd (p - Suc 0) (frag_of (restrict id (standard_simplex (p - Suc 0)))))))

goal (1 subgoal):
 1. chain_boundary (Suc p) (chain_map (Suc p) f (subd p (frag_of (restrict id (standard_simplex p))))) + frag_extend (\<lambda>f. chain_map (Suc (p - Suc 0)) f (subd (p - Suc 0) (frag_of (restrict id (standard_simplex (p - Suc 0)))))) (chain_boundary p (frag_of f)) = singular_subdivision p (frag_of f) - frag_of f
[PROOF STEP]
have "chain_map p f
                   (simplicial_subdivision p (frag_of (restrict id (standard_simplex p)))
                   - subd (p - Suc 0) (chain_boundary p (frag_of (restrict id (standard_simplex p)))))
              = singular_subdivision p (frag_of f)
              - frag_extend
                   (\<lambda>f. chain_map (Suc (p - Suc 0)) f
                         (subd (p - Suc 0) (frag_of (restrict id (standard_simplex (p - Suc 0))))))
                   (chain_boundary p (frag_of f))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. chain_map p f (simplicial_subdivision p (frag_of (restrict id (standard_simplex p))) - subd (p - Suc 0) (chain_boundary p (frag_of (restrict id (standard_simplex p))))) = singular_subdivision p (frag_of f) - frag_extend (\<lambda>f. chain_map (Suc (p - Suc 0)) f (subd (p - Suc 0) (frag_of (restrict id (standard_simplex (p - Suc 0)))))) (chain_boundary p (frag_of f))
[PROOF STEP]
apply (simp add: singular_subdivision_def chain_map_diff)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. chain_map p f (subd (p - Suc 0) (chain_boundary p (frag_of (restrict id (standard_simplex p))))) = frag_extend (\<lambda>f. chain_map (Suc (p - Suc 0)) f (subd (p - Suc 0) (frag_of (restrict id (standard_simplex (p - Suc 0)))))) (chain_boundary p (frag_of f))
[PROOF STEP]
apply (clarsimp simp add: chain_boundary_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < p \<Longrightarrow> chain_map p f (subd (p - Suc 0) (\<Sum>k\<le>p. frag_cmul ((- 1) ^ k) (frag_of (singular_face p k id)))) = frag_extend (\<lambda>f. chain_map p f (subd (p - Suc 0) (frag_of (restrict id (standard_simplex (p - Suc 0)))))) (\<Sum>k\<le>p. frag_cmul ((- 1) ^ k) (frag_of (singular_face p k f)))
[PROOF STEP]
apply (simp add: frag_extend_sum frag_extend_cmul *)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
chain_map p f (simplicial_subdivision p (frag_of (restrict id (standard_simplex p))) - subd (p - Suc 0) (chain_boundary p (frag_of (restrict id (standard_simplex p))))) = singular_subdivision p (frag_of f) - frag_extend (\<lambda>f. chain_map (Suc (p - Suc 0)) f (subd (p - Suc 0) (frag_of (restrict id (standard_simplex (p - Suc 0)))))) (chain_boundary p (frag_of f))

goal (1 subgoal):
 1. chain_boundary (Suc p) (chain_map (Suc p) f (subd p (frag_of (restrict id (standard_simplex p))))) + frag_extend (\<lambda>f. chain_map (Suc (p - Suc 0)) f (subd (p - Suc 0) (frag_of (restrict id (standard_simplex (p - Suc 0)))))) (chain_boundary p (frag_of f)) = singular_subdivision p (frag_of f) - frag_of f
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
chain_map p f (simplicial_subdivision p (frag_of (restrict id (standard_simplex p))) - subd (p - Suc 0) (chain_boundary p (frag_of (restrict id (standard_simplex p))))) = singular_subdivision p (frag_of f) - frag_extend (\<lambda>f. chain_map (Suc (p - Suc 0)) f (subd (p - Suc 0) (frag_of (restrict id (standard_simplex (p - Suc 0)))))) (chain_boundary p (frag_of f))
[PROOF STEP]
show "chain_boundary (Suc p) (chain_map (Suc p) f (subd p (frag_of (restrict id (standard_simplex p)))))
                 + frag_extend
                   (\<lambda>f. chain_map (Suc (p - Suc 0)) f
                         (subd (p - Suc 0) (frag_of (restrict id (standard_simplex (p - Suc 0))))))
                   (chain_boundary p (frag_of f))
                 = singular_subdivision p (frag_of f) - frag_of f"
[PROOF STATE]
proof (prove)
using this:
chain_map p f (simplicial_subdivision p (frag_of (restrict id (standard_simplex p))) - subd (p - Suc 0) (chain_boundary p (frag_of (restrict id (standard_simplex p))))) = singular_subdivision p (frag_of f) - frag_extend (\<lambda>f. chain_map (Suc (p - Suc 0)) f (subd (p - Suc 0) (frag_of (restrict id (standard_simplex (p - Suc 0)))))) (chain_boundary p (frag_of f))

goal (1 subgoal):
 1. chain_boundary (Suc p) (chain_map (Suc p) f (subd p (frag_of (restrict id (standard_simplex p))))) + frag_extend (\<lambda>f. chain_map (Suc (p - Suc 0)) f (subd (p - Suc 0) (frag_of (restrict id (standard_simplex (p - Suc 0)))))) (chain_boundary p (frag_of f)) = singular_subdivision p (frag_of f) - frag_of f
[PROOF STEP]
by (simp add: chain_boundary_chain_map [OF scp] chain_homotopic_simplicial_subdivision3 [where q=p] chain_map_diff feqf)
[PROOF STATE]
proof (state)
this:
chain_boundary (Suc p) (chain_map (Suc p) f (subd p (frag_of (restrict id (standard_simplex p))))) + frag_extend (\<lambda>f. chain_map (Suc (p - Suc 0)) f (subd (p - Suc 0) (frag_of (restrict id (standard_simplex (p - Suc 0)))))) (chain_boundary p (frag_of f)) = singular_subdivision p (frag_of f) - frag_of f

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
singular_chain (Suc p) X (k p (frag_of f)) \<and> chain_boundary (Suc p) (k p (frag_of f)) + k (p - Suc 0) (chain_boundary p (frag_of f)) = singular_subdivision p (frag_of f) - frag_of f

goal (2 subgoals):
 1. singular_chain (Suc p) X (k p 0) \<and> chain_boundary (Suc p) (k p 0) + k (p - Suc 0) (chain_boundary p 0) = singular_subdivision p 0 - 0
 2. \<And>a b. \<lbrakk>singular_chain (Suc p) X (k p a) \<and> chain_boundary (Suc p) (k p a) + k (p - Suc 0) (chain_boundary p a) = singular_subdivision p a - a; singular_chain (Suc p) X (k p b) \<and> chain_boundary (Suc p) (k p b) + k (p - Suc 0) (chain_boundary p b) = singular_subdivision p b - b\<rbrakk> \<Longrightarrow> singular_chain (Suc p) X (k p (a - b)) \<and> chain_boundary (Suc p) (k p (a - b)) + k (p - Suc 0) (chain_boundary p (a - b)) = singular_subdivision p (a - b) - (a - b)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. singular_chain (Suc p) X (k p 0) \<and> chain_boundary (Suc p) (k p 0) + k (p - Suc 0) (chain_boundary p 0) = singular_subdivision p 0 - 0
 2. \<And>a b. \<lbrakk>singular_chain (Suc p) X (k p a) \<and> chain_boundary (Suc p) (k p a) + k (p - Suc 0) (chain_boundary p a) = singular_subdivision p a - a; singular_chain (Suc p) X (k p b) \<and> chain_boundary (Suc p) (k p b) + k (p - Suc 0) (chain_boundary p b) = singular_subdivision p b - b\<rbrakk> \<Longrightarrow> singular_chain (Suc p) X (k p (a - b)) \<and> chain_boundary (Suc p) (k p (a - b)) + k (p - Suc 0) (chain_boundary p (a - b)) = singular_subdivision p (a - b) - (a - b)
[PROOF STEP]
case (diff a b)
[PROOF STATE]
proof (state)
this:
singular_chain (Suc p) X (k p a) \<and> chain_boundary (Suc p) (k p a) + k (p - Suc 0) (chain_boundary p a) = singular_subdivision p a - a
singular_chain (Suc p) X (k p b) \<and> chain_boundary (Suc p) (k p b) + k (p - Suc 0) (chain_boundary p b) = singular_subdivision p b - b

goal (2 subgoals):
 1. singular_chain (Suc p) X (k p 0) \<and> chain_boundary (Suc p) (k p 0) + k (p - Suc 0) (chain_boundary p 0) = singular_subdivision p 0 - 0
 2. \<And>a b. \<lbrakk>singular_chain (Suc p) X (k p a) \<and> chain_boundary (Suc p) (k p a) + k (p - Suc 0) (chain_boundary p a) = singular_subdivision p a - a; singular_chain (Suc p) X (k p b) \<and> chain_boundary (Suc p) (k p b) + k (p - Suc 0) (chain_boundary p b) = singular_subdivision p b - b\<rbrakk> \<Longrightarrow> singular_chain (Suc p) X (k p (a - b)) \<and> chain_boundary (Suc p) (k p (a - b)) + k (p - Suc 0) (chain_boundary p (a - b)) = singular_subdivision p (a - b) - (a - b)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
singular_chain (Suc p) X (k p a) \<and> chain_boundary (Suc p) (k p a) + k (p - Suc 0) (chain_boundary p a) = singular_subdivision p a - a
singular_chain (Suc p) X (k p b) \<and> chain_boundary (Suc p) (k p b) + k (p - Suc 0) (chain_boundary p b) = singular_subdivision p b - b
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
singular_chain (Suc p) X (k p a) \<and> chain_boundary (Suc p) (k p a) + k (p - Suc 0) (chain_boundary p a) = singular_subdivision p a - a
singular_chain (Suc p) X (k p b) \<and> chain_boundary (Suc p) (k p b) + k (p - Suc 0) (chain_boundary p b) = singular_subdivision p b - b

goal (1 subgoal):
 1. singular_chain (Suc p) X (k p (a - b)) \<and> chain_boundary (Suc p) (k p (a - b)) + k (p - Suc 0) (chain_boundary p (a - b)) = singular_subdivision p (a - b) - (a - b)
[PROOF STEP]
apply (simp only: k_def singular_chain_diff chain_boundary_diff frag_extend_diff singular_subdivision_diff)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>singular_chain (Suc p) X (frag_extend (\<lambda>f. chain_map (Suc p) f (subd p (frag_of (restrict id (standard_simplex p))))) a) \<and> chain_boundary (Suc p) (frag_extend (\<lambda>f. chain_map (Suc p) f (subd p (frag_of (restrict id (standard_simplex p))))) a) + frag_extend (\<lambda>f. chain_map (Suc (p - Suc 0)) f (subd (p - Suc 0) (frag_of (restrict id (standard_simplex (p - Suc 0)))))) (chain_boundary p a) = singular_subdivision p a - a; singular_chain (Suc p) X (frag_extend (\<lambda>f. chain_map (Suc p) f (subd p (frag_of (restrict id (standard_simplex p))))) b) \<and> chain_boundary (Suc p) (frag_extend (\<lambda>f. chain_map (Suc p) f (subd p (frag_of (restrict id (standard_simplex p))))) b) + frag_extend (\<lambda>f. chain_map (Suc (p - Suc 0)) f (subd (p - Suc 0) (frag_of (restrict id (standard_simplex (p - Suc 0)))))) (chain_boundary p b) = singular_subdivision p b - b\<rbrakk> \<Longrightarrow> True \<and> chain_boundary (Suc p) (frag_extend (\<lambda>f. chain_map (Suc p) f (subd p (frag_of (restrict id (standard_simplex p))))) a) - chain_boundary (Suc p) (frag_extend (\<lambda>f. chain_map (Suc p) f (subd p (frag_of (restrict id (standard_simplex p))))) b) + (frag_extend (\<lambda>f. chain_map (Suc (p - Suc 0)) f (subd (p - Suc 0) (frag_of (restrict id (standard_simplex (p - Suc 0)))))) (chain_boundary p a) - frag_extend (\<lambda>f. chain_map (Suc (p - Suc 0)) f (subd (p - Suc 0) (frag_of (restrict id (standard_simplex (p - Suc 0)))))) (chain_boundary p b)) = singular_subdivision p a - singular_subdivision p b - (a - b)
[PROOF STEP]
by (metis (no_types, lifting) add_diff_add diff_add_cancel)
[PROOF STATE]
proof (state)
this:
singular_chain (Suc p) X (k p (a - b)) \<and> chain_boundary (Suc p) (k p (a - b)) + k (p - Suc 0) (chain_boundary p (a - b)) = singular_subdivision p (a - b) - (a - b)

goal (1 subgoal):
 1. singular_chain (Suc p) X (k p 0) \<and> chain_boundary (Suc p) (k p 0) + k (p - Suc 0) (chain_boundary p 0) = singular_subdivision p 0 - 0
[PROOF STEP]
qed (auto simp: k_def)
[PROOF STATE]
proof (state)
this:
singular_chain (Suc p) X (k p c) \<and> chain_boundary (Suc p) (k p c) + k (p - Suc 0) (chain_boundary p c) = singular_subdivision p c - c

goal (4 subgoals):
 1. \<And>p. ?h p 0 = 0
 2. \<And>p c1 c2. ?h p (c1 - c2) = ?h p c1 - ?h p c2
 3. \<And>p X c. singular_chain p X c \<Longrightarrow> singular_chain (Suc p) X (?h p c)
 4. \<And>p X c. singular_chain p X c \<Longrightarrow> chain_boundary (Suc p) (?h p c) + ?h (p - Suc 0) (chain_boundary p c) = singular_subdivision p c - c
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
singular_chain (Suc p) X (k p c) \<and> chain_boundary (Suc p) (k p c) + k (p - Suc 0) (chain_boundary p c) = singular_subdivision p c - c
[PROOF STEP]
show "singular_chain (Suc p) X (k p c)" "chain_boundary (Suc p) (k p c) + k (p - Suc 0) (chain_boundary p c) = singular_subdivision p c - c"
[PROOF STATE]
proof (prove)
using this:
singular_chain (Suc p) X (k p c) \<and> chain_boundary (Suc p) (k p c) + k (p - Suc 0) (chain_boundary p c) = singular_subdivision p c - c

goal (1 subgoal):
 1. singular_chain (Suc p) X (k p c) &&& chain_boundary (Suc p) (k p c) + k (p - Suc 0) (chain_boundary p c) = singular_subdivision p c - c
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
singular_chain (Suc p) X (k p c)
chain_boundary (Suc p) (k p c) + k (p - Suc 0) (chain_boundary p c) = singular_subdivision p c - c

goal (2 subgoals):
 1. \<And>p. k p 0 = 0
 2. \<And>p c1 c2. k p (c1 - c2) = k p c1 - k p c2
[PROOF STEP]
qed (auto simp: k_def frag_extend_diff)
[PROOF STATE]
proof (state)
this:
thesis

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma insert_finite_tree :
  assumes "finite_tree t"
  shows "finite_tree (insert t xs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite_tree (Prefix_Tree.insert t xs)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. finite_tree (Prefix_Tree.insert t xs)
[PROOF STEP]
have "{xs'. \<exists>xs''. xs = xs' @ xs''} = list.set (prefixes xs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {xs'. \<exists>xs''. xs = xs' @ xs''} = list.set (prefixes xs)
[PROOF STEP]
unfolding prefixes_set
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {xs'. \<exists>xs''. xs = xs' @ xs''} = {xs'. \<exists>xs''. xs' @ xs'' = xs}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
{xs'. \<exists>xs''. xs = xs' @ xs''} = list.set (prefixes xs)

goal (1 subgoal):
 1. finite_tree (Prefix_Tree.insert t xs)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
{xs'. \<exists>xs''. xs = xs' @ xs''} = list.set (prefixes xs)
[PROOF STEP]
have "finite {xs'. \<exists>xs''. xs = xs' @ xs''}"
[PROOF STATE]
proof (prove)
using this:
{xs'. \<exists>xs''. xs = xs' @ xs''} = list.set (prefixes xs)

goal (1 subgoal):
 1. finite {xs'. \<exists>xs''. xs = xs' @ xs''}
[PROOF STEP]
using List.finite_set
[PROOF STATE]
proof (prove)
using this:
{xs'. \<exists>xs''. xs = xs' @ xs''} = list.set (prefixes xs)
finite (list.set ?xs)

goal (1 subgoal):
 1. finite {xs'. \<exists>xs''. xs = xs' @ xs''}
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
finite {xs'. \<exists>xs''. xs = xs' @ xs''}

goal (1 subgoal):
 1. finite_tree (Prefix_Tree.insert t xs)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
finite {xs'. \<exists>xs''. xs = xs' @ xs''}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
finite {xs'. \<exists>xs''. xs = xs' @ xs''}

goal (1 subgoal):
 1. finite_tree (Prefix_Tree.insert t xs)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
finite {xs'. \<exists>xs''. xs = xs' @ xs''}
finite_tree t

goal (1 subgoal):
 1. finite_tree (Prefix_Tree.insert t xs)
[PROOF STEP]
unfolding finite_tree_iff insert_set
[PROOF STATE]
proof (prove)
using this:
finite {xs'. \<exists>xs''. xs = xs' @ xs''}
finite (Prefix_Tree.set t)

goal (1 subgoal):
 1. finite (Prefix_Tree.set t \<union> {xs'. \<exists>xs''. xs = xs' @ xs''})
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
finite_tree (Prefix_Tree.insert t xs)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma homeomorphic_interiors_same_dimension:
  fixes S :: "'a::euclidean_space set" and T :: "'b::euclidean_space set"
  assumes "S homeomorphic T" and dimeq: "DIM('a) = DIM('b)"
  shows "(interior S) homeomorphic (interior T)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. interior S homeomorphic interior T
[PROOF STEP]
using assms [unfolded homeomorphic_minimal]
[PROOF STATE]
proof (prove)
using this:
\<exists>f g. (\<forall>x\<in>S. f x \<in> T \<and> g (f x) = x) \<and> (\<forall>y\<in>T. g y \<in> S \<and> f (g y) = y) \<and> continuous_on S f \<and> continuous_on T g
DIM('a) = DIM('b)

goal (1 subgoal):
 1. interior S homeomorphic interior T
[PROOF STEP]
unfolding homeomorphic_def
[PROOF STATE]
proof (prove)
using this:
\<exists>f g. (\<forall>x\<in>S. f x \<in> T \<and> g (f x) = x) \<and> (\<forall>y\<in>T. g y \<in> S \<and> f (g y) = y) \<and> continuous_on S f \<and> continuous_on T g
DIM('a) = DIM('b)

goal (1 subgoal):
 1. \<exists>f g. homeomorphism (interior S) (interior T) f g
[PROOF STEP]
proof (clarify elim!: ex_forward)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>f g. \<lbrakk>DIM('a) = DIM('b); \<forall>x\<in>S. f x \<in> T \<and> g (f x) = x; \<forall>y\<in>T. g y \<in> S \<and> f (g y) = y; continuous_on S f; continuous_on T g\<rbrakk> \<Longrightarrow> homeomorphism (interior S) (interior T) f g
[PROOF STEP]
fix f g
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>f g. \<lbrakk>DIM('a) = DIM('b); \<forall>x\<in>S. f x \<in> T \<and> g (f x) = x; \<forall>y\<in>T. g y \<in> S \<and> f (g y) = y; continuous_on S f; continuous_on T g\<rbrakk> \<Longrightarrow> homeomorphism (interior S) (interior T) f g
[PROOF STEP]
assume S: "\<forall>x\<in>S. f x \<in> T \<and> g (f x) = x" and T: "\<forall>y\<in>T. g y \<in> S \<and> f (g y) = y"
     and contf: "continuous_on S f" and contg: "continuous_on T g"
[PROOF STATE]
proof (state)
this:
\<forall>x\<in>S. f x \<in> T \<and> g (f x) = x
\<forall>y\<in>T. g y \<in> S \<and> f (g y) = y
continuous_on S f
continuous_on T g

goal (1 subgoal):
 1. \<And>f g. \<lbrakk>DIM('a) = DIM('b); \<forall>x\<in>S. f x \<in> T \<and> g (f x) = x; \<forall>y\<in>T. g y \<in> S \<and> f (g y) = y; continuous_on S f; continuous_on T g\<rbrakk> \<Longrightarrow> homeomorphism (interior S) (interior T) f g
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<forall>x\<in>S. f x \<in> T \<and> g (f x) = x
\<forall>y\<in>T. g y \<in> S \<and> f (g y) = y
continuous_on S f
continuous_on T g
[PROOF STEP]
have fST: "f ` S = T" and gTS: "g ` T = S" and "inj_on f S" "inj_on g T"
[PROOF STATE]
proof (prove)
using this:
\<forall>x\<in>S. f x \<in> T \<and> g (f x) = x
\<forall>y\<in>T. g y \<in> S \<and> f (g y) = y
continuous_on S f
continuous_on T g

goal (1 subgoal):
 1. f ` S = T &&& g ` T = S &&& inj_on f S &&& inj_on g T
[PROOF STEP]
by (auto simp: inj_on_def intro: rev_image_eqI) metis+
[PROOF STATE]
proof (state)
this:
f ` S = T
g ` T = S
inj_on f S
inj_on g T

goal (1 subgoal):
 1. \<And>f g. \<lbrakk>DIM('a) = DIM('b); \<forall>x\<in>S. f x \<in> T \<and> g (f x) = x; \<forall>y\<in>T. g y \<in> S \<and> f (g y) = y; continuous_on S f; continuous_on T g\<rbrakk> \<Longrightarrow> homeomorphism (interior S) (interior T) f g
[PROOF STEP]
have fim: "f ` interior S \<subseteq> interior T"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f ` interior S \<subseteq> interior T
[PROOF STEP]
using continuous_image_subset_interior [OF contf \<open>inj_on f S\<close>] dimeq fST
[PROOF STATE]
proof (prove)
using this:
DIM('b) \<le> DIM('a) \<Longrightarrow> f ` interior S \<subseteq> interior (f ` S)
DIM('a) = DIM('b)
f ` S = T

goal (1 subgoal):
 1. f ` interior S \<subseteq> interior T
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
f ` interior S \<subseteq> interior T

goal (1 subgoal):
 1. \<And>f g. \<lbrakk>DIM('a) = DIM('b); \<forall>x\<in>S. f x \<in> T \<and> g (f x) = x; \<forall>y\<in>T. g y \<in> S \<and> f (g y) = y; continuous_on S f; continuous_on T g\<rbrakk> \<Longrightarrow> homeomorphism (interior S) (interior T) f g
[PROOF STEP]
have gim: "g ` interior T \<subseteq> interior S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. g ` interior T \<subseteq> interior S
[PROOF STEP]
using continuous_image_subset_interior [OF contg \<open>inj_on g T\<close>] dimeq gTS
[PROOF STATE]
proof (prove)
using this:
DIM('a) \<le> DIM('b) \<Longrightarrow> g ` interior T \<subseteq> interior (g ` T)
DIM('a) = DIM('b)
g ` T = S

goal (1 subgoal):
 1. g ` interior T \<subseteq> interior S
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
g ` interior T \<subseteq> interior S

goal (1 subgoal):
 1. \<And>f g. \<lbrakk>DIM('a) = DIM('b); \<forall>x\<in>S. f x \<in> T \<and> g (f x) = x; \<forall>y\<in>T. g y \<in> S \<and> f (g y) = y; continuous_on S f; continuous_on T g\<rbrakk> \<Longrightarrow> homeomorphism (interior S) (interior T) f g
[PROOF STEP]
show "homeomorphism (interior S) (interior T) f g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. homeomorphism (interior S) (interior T) f g
[PROOF STEP]
unfolding homeomorphism_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<forall>x\<in>interior S. g (f x) = x) \<and> f ` interior S = interior T \<and> continuous_on (interior S) f \<and> (\<forall>y\<in>interior T. f (g y) = y) \<and> g ` interior T = interior S \<and> continuous_on (interior T) g
[PROOF STEP]
proof (intro conjI ballI)
[PROOF STATE]
proof (state)
goal (6 subgoals):
 1. \<And>x. x \<in> interior S \<Longrightarrow> g (f x) = x
 2. f ` interior S = interior T
 3. continuous_on (interior S) f
 4. \<And>y. y \<in> interior T \<Longrightarrow> f (g y) = y
 5. g ` interior T = interior S
 6. continuous_on (interior T) g
[PROOF STEP]
show "\<And>x. x \<in> interior S \<Longrightarrow> g (f x) = x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. x \<in> interior S \<Longrightarrow> g (f x) = x
[PROOF STEP]
by (meson \<open>\<forall>x\<in>S. f x \<in> T \<and> g (f x) = x\<close> subsetD interior_subset)
[PROOF STATE]
proof (state)
this:
?x \<in> interior S \<Longrightarrow> g (f ?x) = ?x

goal (5 subgoals):
 1. f ` interior S = interior T
 2. continuous_on (interior S) f
 3. \<And>y. y \<in> interior T \<Longrightarrow> f (g y) = y
 4. g ` interior T = interior S
 5. continuous_on (interior T) g
[PROOF STEP]
have "interior T \<subseteq> f ` interior S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. interior T \<subseteq> f ` interior S
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> interior T \<Longrightarrow> x \<in> f ` interior S
[PROOF STEP]
fix x
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> interior T \<Longrightarrow> x \<in> f ` interior S
[PROOF STEP]
assume "x \<in> interior T"
[PROOF STATE]
proof (state)
this:
x \<in> interior T

goal (1 subgoal):
 1. \<And>x. x \<in> interior T \<Longrightarrow> x \<in> f ` interior S
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
x \<in> interior T
[PROOF STEP]
have "g x \<in> interior S"
[PROOF STATE]
proof (prove)
using this:
x \<in> interior T

goal (1 subgoal):
 1. g x \<in> interior S
[PROOF STEP]
using gim
[PROOF STATE]
proof (prove)
using this:
x \<in> interior T
g ` interior T \<subseteq> interior S

goal (1 subgoal):
 1. g x \<in> interior S
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
g x \<in> interior S

goal (1 subgoal):
 1. \<And>x. x \<in> interior T \<Longrightarrow> x \<in> f ` interior S
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
g x \<in> interior S
[PROOF STEP]
show "x \<in> f ` interior S"
[PROOF STATE]
proof (prove)
using this:
g x \<in> interior S

goal (1 subgoal):
 1. x \<in> f ` interior S
[PROOF STEP]
by (metis T \<open>x \<in> interior T\<close> image_iff interior_subset subsetCE)
[PROOF STATE]
proof (state)
this:
x \<in> f ` interior S

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
interior T \<subseteq> f ` interior S

goal (5 subgoals):
 1. f ` interior S = interior T
 2. continuous_on (interior S) f
 3. \<And>y. y \<in> interior T \<Longrightarrow> f (g y) = y
 4. g ` interior T = interior S
 5. continuous_on (interior T) g
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
interior T \<subseteq> f ` interior S
[PROOF STEP]
show "f ` interior S = interior T"
[PROOF STATE]
proof (prove)
using this:
interior T \<subseteq> f ` interior S

goal (1 subgoal):
 1. f ` interior S = interior T
[PROOF STEP]
using fim
[PROOF STATE]
proof (prove)
using this:
interior T \<subseteq> f ` interior S
f ` interior S \<subseteq> interior T

goal (1 subgoal):
 1. f ` interior S = interior T
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
f ` interior S = interior T

goal (4 subgoals):
 1. continuous_on (interior S) f
 2. \<And>y. y \<in> interior T \<Longrightarrow> f (g y) = y
 3. g ` interior T = interior S
 4. continuous_on (interior T) g
[PROOF STEP]
show "continuous_on (interior S) f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. continuous_on (interior S) f
[PROOF STEP]
by (metis interior_subset continuous_on_subset contf)
[PROOF STATE]
proof (state)
this:
continuous_on (interior S) f

goal (3 subgoals):
 1. \<And>y. y \<in> interior T \<Longrightarrow> f (g y) = y
 2. g ` interior T = interior S
 3. continuous_on (interior T) g
[PROOF STEP]
show "\<And>y. y \<in> interior T \<Longrightarrow> f (g y) = y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>y. y \<in> interior T \<Longrightarrow> f (g y) = y
[PROOF STEP]
by (meson T subsetD interior_subset)
[PROOF STATE]
proof (state)
this:
?y \<in> interior T \<Longrightarrow> f (g ?y) = ?y

goal (2 subgoals):
 1. g ` interior T = interior S
 2. continuous_on (interior T) g
[PROOF STEP]
have "interior S \<subseteq> g ` interior T"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. interior S \<subseteq> g ` interior T
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> interior S \<Longrightarrow> x \<in> g ` interior T
[PROOF STEP]
fix x
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> interior S \<Longrightarrow> x \<in> g ` interior T
[PROOF STEP]
assume "x \<in> interior S"
[PROOF STATE]
proof (state)
this:
x \<in> interior S

goal (1 subgoal):
 1. \<And>x. x \<in> interior S \<Longrightarrow> x \<in> g ` interior T
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
x \<in> interior S
[PROOF STEP]
have "f x \<in> interior T"
[PROOF STATE]
proof (prove)
using this:
x \<in> interior S

goal (1 subgoal):
 1. f x \<in> interior T
[PROOF STEP]
using fim
[PROOF STATE]
proof (prove)
using this:
x \<in> interior S
f ` interior S \<subseteq> interior T

goal (1 subgoal):
 1. f x \<in> interior T
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
f x \<in> interior T

goal (1 subgoal):
 1. \<And>x. x \<in> interior S \<Longrightarrow> x \<in> g ` interior T
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
f x \<in> interior T
[PROOF STEP]
show "x \<in> g ` interior T"
[PROOF STATE]
proof (prove)
using this:
f x \<in> interior T

goal (1 subgoal):
 1. x \<in> g ` interior T
[PROOF STEP]
by (metis S \<open>x \<in> interior S\<close> image_iff interior_subset subsetCE)
[PROOF STATE]
proof (state)
this:
x \<in> g ` interior T

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
interior S \<subseteq> g ` interior T

goal (2 subgoals):
 1. g ` interior T = interior S
 2. continuous_on (interior T) g
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
interior S \<subseteq> g ` interior T
[PROOF STEP]
show "g ` interior T = interior S"
[PROOF STATE]
proof (prove)
using this:
interior S \<subseteq> g ` interior T

goal (1 subgoal):
 1. g ` interior T = interior S
[PROOF STEP]
using gim
[PROOF STATE]
proof (prove)
using this:
interior S \<subseteq> g ` interior T
g ` interior T \<subseteq> interior S

goal (1 subgoal):
 1. g ` interior T = interior S
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
g ` interior T = interior S

goal (1 subgoal):
 1. continuous_on (interior T) g
[PROOF STEP]
show "continuous_on (interior T) g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. continuous_on (interior T) g
[PROOF STEP]
by (metis interior_subset continuous_on_subset contg)
[PROOF STATE]
proof (state)
this:
continuous_on (interior T) g

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
homeomorphism (interior S) (interior T) f g

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma imult_is_infinity: "((a::enat) * b = \<infinity>) = (a = \<infinity> \<and> b \<noteq> 0 \<or> b = \<infinity> \<and> a \<noteq> 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (a * b = \<infinity>) = (a = \<infinity> \<and> b \<noteq> 0 \<or> b = \<infinity> \<and> a \<noteq> 0)
[PROOF STEP]
by (auto simp add: times_enat_def zero_enat_def split: enat.split)


[STATEMENT]
lemma lm030:
  "card (omega pair)= card (snd pair)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card (omega pair) = card (snd pair)
[PROOF STEP]
using cardFinestpart card_cartesian_product_singleton
[PROOF STATE]
proof (prove)
using this:
card (finestpart ?X) = card ?X
card ({?x} \<times> ?A) = card ?A

goal (1 subgoal):
 1. card (omega pair) = card (snd pair)
[PROOF STEP]
by metis


[STATEMENT]
lemma vector_matrix_mul_assoc:
  fixes v :: "('a::comm_semiring_1)^'n"
  shows "(v v* M) v* N = v v* (M ** N)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. v v* M v* N = v v* (M ** N)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. v v* M v* N = v v* (M ** N)
[PROOF STEP]
from matrix_vector_mul_assoc
[PROOF STATE]
proof (chain)
picking this:
?A *v (?B *v ?x) = ?A ** ?B *v ?x
[PROOF STEP]
have "transpose N *v (transpose M *v v) = (transpose N ** transpose M) *v v"
[PROOF STATE]
proof (prove)
using this:
?A *v (?B *v ?x) = ?A ** ?B *v ?x

goal (1 subgoal):
 1. Finite_Cartesian_Product.transpose N *v (Finite_Cartesian_Product.transpose M *v v) = Finite_Cartesian_Product.transpose N ** Finite_Cartesian_Product.transpose M *v v
[PROOF STEP]
by fast
[PROOF STATE]
proof (state)
this:
Finite_Cartesian_Product.transpose N *v (Finite_Cartesian_Product.transpose M *v v) = Finite_Cartesian_Product.transpose N ** Finite_Cartesian_Product.transpose M *v v

goal (1 subgoal):
 1. v v* M v* N = v v* (M ** N)
[PROOF STEP]
thus "(v v* M) v* N = v v* (M ** N)"
[PROOF STATE]
proof (prove)
using this:
Finite_Cartesian_Product.transpose N *v (Finite_Cartesian_Product.transpose M *v v) = Finite_Cartesian_Product.transpose N ** Finite_Cartesian_Product.transpose M *v v

goal (1 subgoal):
 1. v v* M v* N = v v* (M ** N)
[PROOF STEP]
by (simp add: matrix_transpose_mul [symmetric])
[PROOF STATE]
proof (state)
this:
v v* M v* N = v v* (M ** N)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma sinpoly_lb_imp_cospoly_ub:
  assumes x0: "0 \<le> x" and k0: "k>0" and "\<And>x. 0 \<le> x \<Longrightarrow> sinpoly (k - 1) x \<le> sin x"
    shows "cos x \<le> cospoly k x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cos x \<le> cospoly k x
[PROOF STEP]
apply (rule gen_lower_bound_increasing [OF x0])
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. \<And>y. \<lbrakk>0 \<le> y; y \<le> x\<rbrakk> \<Longrightarrow> ((\<lambda>x. cos x - cospoly k x) has_real_derivative ?g y) (at y)
 2. \<And>y. \<lbrakk>0 \<le> y; y \<le> x\<rbrakk> \<Longrightarrow> ?g y \<le> 0
 3. cos 0 = cospoly k 0
[PROOF STEP]
apply (intro derivative_eq_intros | simp)+
[PROOF STATE]
proof (prove)
goal (4 subgoals):
 1. \<And>y. \<lbrakk>0 \<le> y; y \<le> x\<rbrakk> \<Longrightarrow> (cospoly k has_real_derivative ?g'5 y) (at y)
 2. \<And>y. \<lbrakk>0 \<le> y; y \<le> x\<rbrakk> \<Longrightarrow> - sin y - ?g'5 y = ?g y
 3. \<And>y. \<lbrakk>0 \<le> y; y \<le> x\<rbrakk> \<Longrightarrow> ?g y \<le> 0
 4. cos 0 = cospoly k 0
[PROOF STEP]
using d_cospoly_sinpoly [of "k - 1"] assms
[PROOF STATE]
proof (prove)
using this:
(cospoly (Suc (k - 1)) has_real_derivative - sinpoly (k - 1) ?x) (at ?x)
0 \<le> x
0 < k
0 \<le> ?x \<Longrightarrow> sinpoly (k - 1) ?x \<le> sin ?x

goal (4 subgoals):
 1. \<And>y. \<lbrakk>0 \<le> y; y \<le> x\<rbrakk> \<Longrightarrow> (cospoly k has_real_derivative ?g'5 y) (at y)
 2. \<And>y. \<lbrakk>0 \<le> y; y \<le> x\<rbrakk> \<Longrightarrow> - sin y - ?g'5 y = ?g y
 3. \<And>y. \<lbrakk>0 \<le> y; y \<le> x\<rbrakk> \<Longrightarrow> ?g y \<le> 0
 4. cos 0 = cospoly k 0
[PROOF STEP]
apply auto
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<And>x. (cospoly k has_real_derivative - sinpoly (k - Suc 0) x) (at x); 0 \<le> x; 0 < k; \<And>x. 0 \<le> x \<Longrightarrow> sinpoly (k - Suc 0) x \<le> sin x\<rbrakk> \<Longrightarrow> cospoly k 0 = 1
[PROOF STEP]
apply (simp add: cospoly_def)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma Joints_swap_Cons_append:
  "length xs = length XS \<Longrightarrow> x#ys@xs\<in>Joints (X#YS@XS) \<longleftrightarrow> ys@x#xs \<in> Joints (YS@X#XS)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length xs = length XS \<Longrightarrow> (x # ys @ xs \<in> Joints (X # YS @ XS)) = (ys @ x # xs \<in> Joints (YS @ X # XS))
[PROOF STEP]
by (auto simp: Joints_def valuate_def)