[STATEMENT]
lemma bij_betw_number_partition_of:
  assumes "finite A" "finite B"
  shows "bij_betw (number_partition_of A B) ({f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} // domain_and_range_permutation A B) {N. (\<forall>n. n\<in># N \<longrightarrow> n = 1) \<and> number_partition (card A) N \<and> size N \<le> card B}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bij_betw (number_partition_of A B) ({f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} // domain_and_range_permutation A B) {N. (\<forall>n. n \<in># N \<longrightarrow> n = 1) \<and> number_partition (card A) N \<and> size N \<le> card B}
[PROOF STEP]
proof (rule bij_betw_byWitness[where f'="functions_of A B"])
[PROOF STATE]
proof (state)
goal (4 subgoals):
 1. \<forall>a\<in>{f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} // domain_and_range_permutation A B. functions_of A B (number_partition_of A B a) = a
 2. \<forall>a'\<in>{N. (\<forall>n. n \<in># N \<longrightarrow> n = 1) \<and> number_partition (card A) N \<and> size N \<le> card B}. number_partition_of A B (functions_of A B a') = a'
 3. number_partition_of A B ` {f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} // domain_and_range_permutation A B \<subseteq> {N. (\<forall>n. n \<in># N \<longrightarrow> n = 1) \<and> number_partition (card A) N \<and> size N \<le> card B}
 4. functions_of A B ` {N. (\<forall>n. n \<in># N \<longrightarrow> n = 1) \<and> number_partition (card A) N \<and> size N \<le> card B} \<subseteq> {f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} // domain_and_range_permutation A B
[PROOF STEP]
have quotient_eq: "{f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} // domain_and_range_permutation A B = {F \<in> ((A \<rightarrow>\<^sub>E B) // domain_and_range_permutation A B). univ (\<lambda>f. inj_on f A) F}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} // domain_and_range_permutation A B = {F \<in> (A \<rightarrow>\<^sub>E B) // domain_and_range_permutation A B. univ (\<lambda>f. inj_on f A) F}
[PROOF STEP]
using equiv_domain_and_range_permutation[of A B] inj_on_respects_domain_and_range_permutation[of A B]
[PROOF STATE]
proof (prove)
using this:
equiv (A \<rightarrow>\<^sub>E B) (domain_and_range_permutation A B)
(\<lambda>f. inj_on f A) respects domain_and_range_permutation A B

goal (1 subgoal):
 1. {f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} // domain_and_range_permutation A B = {F \<in> (A \<rightarrow>\<^sub>E B) // domain_and_range_permutation A B. univ (\<lambda>f. inj_on f A) F}
[PROOF STEP]
by (simp only: univ_preserves_predicate)
[PROOF STATE]
proof (state)
this:
{f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} // domain_and_range_permutation A B = {F \<in> (A \<rightarrow>\<^sub>E B) // domain_and_range_permutation A B. univ (\<lambda>f. inj_on f A) F}

goal (4 subgoals):
 1. \<forall>a\<in>{f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} // domain_and_range_permutation A B. functions_of A B (number_partition_of A B a) = a
 2. \<forall>a'\<in>{N. (\<forall>n. n \<in># N \<longrightarrow> n = 1) \<and> number_partition (card A) N \<and> size N \<le> card B}. number_partition_of A B (functions_of A B a') = a'
 3. number_partition_of A B ` {f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} // domain_and_range_permutation A B \<subseteq> {N. (\<forall>n. n \<in># N \<longrightarrow> n = 1) \<and> number_partition (card A) N \<and> size N \<le> card B}
 4. functions_of A B ` {N. (\<forall>n. n \<in># N \<longrightarrow> n = 1) \<and> number_partition (card A) N \<and> size N \<le> card B} \<subseteq> {f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} // domain_and_range_permutation A B
[PROOF STEP]
show "\<forall>F\<in>{f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} // domain_and_range_permutation A B.
       functions_of A B (number_partition_of A B F) = F"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>F\<in>{f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} // domain_and_range_permutation A B. functions_of A B (number_partition_of A B F) = F
[PROOF STEP]
using \<open>finite A\<close> \<open>finite B\<close>
[PROOF STATE]
proof (prove)
using this:
finite A
finite B

goal (1 subgoal):
 1. \<forall>F\<in>{f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} // domain_and_range_permutation A B. functions_of A B (number_partition_of A B F) = F
[PROOF STEP]
by (auto simp only: quotient_eq functions_of_number_partition_of)
[PROOF STATE]
proof (state)
this:
\<forall>F\<in>{f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} // domain_and_range_permutation A B. functions_of A B (number_partition_of A B F) = F

goal (3 subgoals):
 1. \<forall>a'\<in>{N. (\<forall>n. n \<in># N \<longrightarrow> n = 1) \<and> number_partition (card A) N \<and> size N \<le> card B}. number_partition_of A B (functions_of A B a') = a'
 2. number_partition_of A B ` {f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} // domain_and_range_permutation A B \<subseteq> {N. (\<forall>n. n \<in># N \<longrightarrow> n = 1) \<and> number_partition (card A) N \<and> size N \<le> card B}
 3. functions_of A B ` {N. (\<forall>n. n \<in># N \<longrightarrow> n = 1) \<and> number_partition (card A) N \<and> size N \<le> card B} \<subseteq> {f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} // domain_and_range_permutation A B
[PROOF STEP]
show "\<forall>N\<in> {N. (\<forall>n. n\<in># N \<longrightarrow> n = 1) \<and> number_partition (card A) N \<and> size N \<le> card B}. number_partition_of A B (functions_of A B N) = N"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>N\<in>{N. (\<forall>n. n \<in># N \<longrightarrow> n = 1) \<and> number_partition (card A) N \<and> size N \<le> card B}. number_partition_of A B (functions_of A B N) = N
[PROOF STEP]
using \<open>finite A\<close> \<open>finite B\<close> number_partition_of_functions_of
[PROOF STATE]
proof (prove)
using this:
finite A
finite B
\<lbrakk>finite ?A; finite ?B; number_partition (card ?A) ?N; size ?N \<le> card ?B\<rbrakk> \<Longrightarrow> number_partition_of ?A ?B (functions_of ?A ?B ?N) = ?N

goal (1 subgoal):
 1. \<forall>N\<in>{N. (\<forall>n. n \<in># N \<longrightarrow> n = 1) \<and> number_partition (card A) N \<and> size N \<le> card B}. number_partition_of A B (functions_of A B N) = N
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<forall>N\<in>{N. (\<forall>n. n \<in># N \<longrightarrow> n = 1) \<and> number_partition (card A) N \<and> size N \<le> card B}. number_partition_of A B (functions_of A B N) = N

goal (2 subgoals):
 1. number_partition_of A B ` {f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} // domain_and_range_permutation A B \<subseteq> {N. (\<forall>n. n \<in># N \<longrightarrow> n = 1) \<and> number_partition (card A) N \<and> size N \<le> card B}
 2. functions_of A B ` {N. (\<forall>n. n \<in># N \<longrightarrow> n = 1) \<and> number_partition (card A) N \<and> size N \<le> card B} \<subseteq> {f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} // domain_and_range_permutation A B
[PROOF STEP]
show "number_partition_of A B ` ({f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} // domain_and_range_permutation A B)
    \<subseteq> {N. (\<forall>n. n\<in># N \<longrightarrow> n = 1) \<and> number_partition (card A) N \<and> size N \<le> card B}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. number_partition_of A B ` {f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} // domain_and_range_permutation A B \<subseteq> {N. (\<forall>n. n \<in># N \<longrightarrow> n = 1) \<and> number_partition (card A) N \<and> size N \<le> card B}
[PROOF STEP]
using \<open>finite A\<close> \<open>finite B\<close>
[PROOF STATE]
proof (prove)
using this:
finite A
finite B

goal (1 subgoal):
 1. number_partition_of A B ` {f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} // domain_and_range_permutation A B \<subseteq> {N. (\<forall>n. n \<in># N \<longrightarrow> n = 1) \<and> number_partition (card A) N \<and> size N \<le> card B}
[PROOF STEP]
by (auto simp add: quotient_eq number_partition_of inj_on_implies_all_one simp del: One_nat_def)
[PROOF STATE]
proof (state)
this:
number_partition_of A B ` {f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} // domain_and_range_permutation A B \<subseteq> {N. (\<forall>n. n \<in># N \<longrightarrow> n = 1) \<and> number_partition (card A) N \<and> size N \<le> card B}

goal (1 subgoal):
 1. functions_of A B ` {N. (\<forall>n. n \<in># N \<longrightarrow> n = 1) \<and> number_partition (card A) N \<and> size N \<le> card B} \<subseteq> {f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} // domain_and_range_permutation A B
[PROOF STEP]
show "functions_of A B ` {N. (\<forall>n. n\<in># N \<longrightarrow> n = 1) \<and> number_partition (card A) N \<and> size N \<le> card B}
    \<subseteq> {f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} // domain_and_range_permutation A B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. functions_of A B ` {N. (\<forall>n. n \<in># N \<longrightarrow> n = 1) \<and> number_partition (card A) N \<and> size N \<le> card B} \<subseteq> {f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} // domain_and_range_permutation A B
[PROOF STEP]
using \<open>finite A\<close> \<open>finite B\<close>
[PROOF STATE]
proof (prove)
using this:
finite A
finite B

goal (1 subgoal):
 1. functions_of A B ` {N. (\<forall>n. n \<in># N \<longrightarrow> n = 1) \<and> number_partition (card A) N \<and> size N \<le> card B} \<subseteq> {f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} // domain_and_range_permutation A B
[PROOF STEP]
by (auto simp add: quotient_eq intro: functions_of functions_of_is_inj_on)
[PROOF STATE]
proof (state)
this:
functions_of A B ` {N. (\<forall>n. n \<in># N \<longrightarrow> n = 1) \<and> number_partition (card A) N \<and> size N \<le> card B} \<subseteq> {f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} // domain_and_range_permutation A B

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
theorem matrix_equation_R:
  fixes p:: "real poly"
  fixes qs:: "real poly list"
  fixes subsets:: "(nat list*nat list) list"
  fixes signs:: "rat list list"
  assumes nonzero: "p\<noteq>0"
  assumes distinct_signs: "distinct signs"
  assumes all_info: "set (characterize_consistent_signs_at_roots p qs) \<subseteq> set(signs)"
  assumes welldefined: "all_list_constr_R (subsets) (length qs)"
  shows "satisfy_equation_R p qs subsets signs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. satisfy_equation_R p qs subsets signs
[PROOF STEP]
unfolding satisfy_equation_R_def matrix_A_R_def
    construct_lhs_vector_R_def construct_rhs_vector_R_def all_list_constr_R_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mat_of_rows_list (length signs) (map (mtx_row_R signs) subsets) *\<^sub>v vec_of_list (map (\<lambda>w. rat_of_int (int (length (filter (\<lambda>v. v = w) (map (consistent_sign_vec qs) (characterize_root_list_p p)))))) signs) = vec_of_list (map (\<lambda>(I1, I2). construct_NofI_R p (retrieve_polys qs I1) (retrieve_polys qs I2)) subsets)
[PROOF STEP]
apply (subst mult_mat_vec_of_list)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. length (map (\<lambda>w. rat_of_int (int (length (filter (\<lambda>v. v = w) (map (consistent_sign_vec qs) (characterize_root_list_p p)))))) signs) = length signs
 2. list_all (\<lambda>r. length r = length signs) (map (mtx_row_R signs) subsets)
 3. vec_of_list (map (\<lambda>r. vec_of_list r \<bullet> vec_of_list (map (\<lambda>w. rat_of_int (int (length (filter (\<lambda>v. v = w) (map (consistent_sign_vec qs) (characterize_root_list_p p)))))) signs)) (map (mtx_row_R signs) subsets)) = vec_of_list (map (\<lambda>(I1, I2). construct_NofI_R p (retrieve_polys qs I1) (retrieve_polys qs I2)) subsets)
[PROOF STEP]
apply (auto simp add: mtx_row_length_R intro!: map_vec_vec_of_list_eq_intro)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>a b. (a, b) \<in> set subsets \<Longrightarrow> vec_of_list (mtx_row_R signs (a, b)) \<bullet> map_vec (\<lambda>w. rat_of_nat (length (filter ((\<lambda>v. v = w) \<circ> consistent_sign_vec qs) (characterize_root_list_p p)))) (vec_of_list signs) = construct_NofI_R p (retrieve_polys qs a) (retrieve_polys qs b)
[PROOF STEP]
using matrix_equation_main_step_R[OF assms(1-3), unfolded construct_lhs_vector_R_def]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>list_constr (fst ?I) (length qs); list_constr (snd ?I) (length qs)\<rbrakk> \<Longrightarrow> vec_of_list (mtx_row_R signs ?I) \<bullet> vec_of_list (map (\<lambda>w. rat_of_int (int (length (filter (\<lambda>v. v = w) (map (consistent_sign_vec qs) (characterize_root_list_p p)))))) signs) = construct_NofI_R p (retrieve_polys qs (fst ?I)) (retrieve_polys qs (snd ?I))

goal (1 subgoal):
 1. \<And>a b. (a, b) \<in> set subsets \<Longrightarrow> vec_of_list (mtx_row_R signs (a, b)) \<bullet> map_vec (\<lambda>w. rat_of_nat (length (filter ((\<lambda>v. v = w) \<circ> consistent_sign_vec qs) (characterize_root_list_p p)))) (vec_of_list signs) = construct_NofI_R p (retrieve_polys qs a) (retrieve_polys qs b)
[PROOF STEP]
using all_list_constr_R_def in_set_member welldefined
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>list_constr (fst ?I) (length qs); list_constr (snd ?I) (length qs)\<rbrakk> \<Longrightarrow> vec_of_list (mtx_row_R signs ?I) \<bullet> vec_of_list (map (\<lambda>w. rat_of_int (int (length (filter (\<lambda>v. v = w) (map (consistent_sign_vec qs) (characterize_root_list_p p)))))) signs) = construct_NofI_R p (retrieve_polys qs (fst ?I)) (retrieve_polys qs (snd ?I))
all_list_constr_R ?L ?n \<equiv> \<forall>x. List.member ?L x \<longrightarrow> list_constr (fst x) ?n \<and> list_constr (snd x) ?n
(?x \<in> set ?xs) = List.member ?xs ?x
all_list_constr_R subsets (length qs)

goal (1 subgoal):
 1. \<And>a b. (a, b) \<in> set subsets \<Longrightarrow> vec_of_list (mtx_row_R signs (a, b)) \<bullet> map_vec (\<lambda>w. rat_of_nat (length (filter ((\<lambda>v. v = w) \<circ> consistent_sign_vec qs) (characterize_root_list_p p)))) (vec_of_list signs) = construct_NofI_R p (retrieve_polys qs a) (retrieve_polys qs b)
[PROOF STEP]
by fastforce


[STATEMENT]
lemma (in comm_ring_hom) char_poly_matrix_hom: assumes A: "A \<in> carrier_mat n n"
  shows "char_poly_matrix (mat\<^sub>h A) = map_mat (map_poly hom) (char_poly_matrix A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. char_poly_matrix (mat\<^sub>h A) = map_mat (map_poly hom) (char_poly_matrix A)
[PROOF STEP]
unfolding char_poly_defs
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [:0::'b, 1::'b:] \<cdot>\<^sub>m 1\<^sub>m (dim_row (mat\<^sub>h A)) + map_mat (\<lambda>a. [:- a:]) (mat\<^sub>h A) = map_mat (map_poly hom) ([:0::'a, 1::'a:] \<cdot>\<^sub>m 1\<^sub>m (dim_row A) + map_mat (\<lambda>a. [:- a:]) A)
[PROOF STEP]
by (rule eq_matI, insert A, auto simp: smult_mat_def hom_distribs)


[STATEMENT]
lemma "filterlim (\<lambda>x::real. exp (exp (x - exp (-x)) / (1 - 1/x)) - exp (exp x)) at_top at_top"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. LIM x at_top. exp (exp (x - exp (- x)) / (1 - 1 / x)) - exp (exp x) :> at_top
[PROOF STEP]
by real_asymp


[STATEMENT]
theorem T1a: "\<lfloor>\<^bold>\<forall>X::\<langle>\<zero>\<rangle>. \<P> X \<^bold>\<rightarrow> \<^bold>\<diamond>(\<^bold>\<exists>\<^sup>Ez. \<lparr>X z\<rparr>)\<rfloor>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lfloor>(\<lambda>w. \<forall>x. (\<P> x \<^bold>\<rightarrow> \<^bold>\<diamond>(\<lambda>v. \<exists>xa. existsAt xa v \<and> x xa)) w)\<rfloor>
[PROOF STEP]
using A1a A2
[PROOF STATE]
proof (prove)
using this:
\<lfloor>(\<lambda>w. \<forall>x. (\<P> (\<rightharpoondown>x) \<^bold>\<rightarrow> \<^bold>\<not>\<P> x) w)\<rfloor>
\<lfloor>(\<lambda>w. universal (\<lambda>x xa. (\<P> x \<^bold>\<and> \<^bold>\<box>(\<lambda>v. \<forall>xb. existsAt xb v \<longrightarrow> x xb \<longrightarrow> xa xb) \<^bold>\<rightarrow> \<P> xa) w))\<rfloor>

goal (1 subgoal):
 1. \<lfloor>(\<lambda>w. \<forall>x. (\<P> x \<^bold>\<rightarrow> \<^bold>\<diamond>(\<lambda>v. \<exists>xa. existsAt xa v \<and> x xa)) w)\<rfloor>
[PROOF STEP]
by blast \<comment> \<open>this is the one used in the book\<close>


[STATEMENT]
lemma  state_in_successor_proj_in_state_in_successor: "
  (s' \<in> state_successors (prob_proj PROB vs) s)
  \<Longrightarrow> (fmrestrict_set vs s'  \<in> state_successors (prob_proj PROB vs) (fmrestrict_set vs s))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. s' \<in> state_successors (prob_proj PROB vs) s \<Longrightarrow> fmrestrict_set vs s' \<in> state_successors (prob_proj PROB vs) (fmrestrict_set vs s)
[PROOF STEP]
using proj_successors
[PROOF STATE]
proof (prove)
using this:
fmrestrict_set ?vs ` state_successors (prob_proj ?PROB ?vs) ?s \<subseteq> state_successors (prob_proj ?PROB ?vs) (fmrestrict_set ?vs ?s)

goal (1 subgoal):
 1. s' \<in> state_successors (prob_proj PROB vs) s \<Longrightarrow> fmrestrict_set vs s' \<in> state_successors (prob_proj PROB vs) (fmrestrict_set vs s)
[PROOF STEP]
by force


[STATEMENT]
lemma bezout_ring_imp_diagonal_admits_SNF_mod_ring:
  assumes of: "OFCLASS('a::comm_ring_1, bezout_ring_class)"
  shows "\<forall>A::'a^'n::nontriv mod_ring^'n::nontriv mod_ring. isDiagonal A
    \<longrightarrow> (\<exists>P Q.
        invertible (P::'a^'n::nontriv mod_ring^'n::nontriv mod_ring) \<and>
        invertible (Q::'a^'n::nontriv mod_ring^'n::nontriv mod_ring) \<and>
        Smith_normal_form (P**A**Q))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>A. isDiagonal A \<longrightarrow> (\<exists>P Q. invertible P \<and> invertible Q \<and> Smith_normal_form (P ** A ** Q))
[PROOF STEP]
using bezout_ring_imp_diagonal_admits_SNF[OF assms]
[PROOF STATE]
proof (prove)
using this:
\<forall>A. isDiagonal A \<longrightarrow> (\<exists>P Q. invertible P \<and> invertible Q \<and> Smith_normal_form (P ** A ** Q))

goal (1 subgoal):
 1. \<forall>A. isDiagonal A \<longrightarrow> (\<exists>P Q. invertible P \<and> invertible Q \<and> Smith_normal_form (P ** A ** Q))
[PROOF STEP]
by auto


[STATEMENT]
lemma backlinks_in_nodes_G: "\<lbrakk> fst ` set (edgesL G) \<subseteq> set (nodesL G); snd ` set (edgesL G) \<subseteq> set (nodesL G) \<rbrakk> \<Longrightarrow>
    fst` set (edgesL (undirected G)) \<subseteq> set (nodesL (undirected G)) \<and> snd` set (edgesL (undirected G)) \<subseteq> set (nodesL (undirected G))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>fst ` set (edgesL G) \<subseteq> set (nodesL G); snd ` set (edgesL G) \<subseteq> set (nodesL G)\<rbrakk> \<Longrightarrow> fst ` set (edgesL (FiniteListGraph.undirected G)) \<subseteq> set (nodesL (FiniteListGraph.undirected G)) \<and> snd ` set (edgesL (FiniteListGraph.undirected G)) \<subseteq> set (nodesL (FiniteListGraph.undirected G))
[PROOF STEP]
unfolding undirected_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>fst ` set (edgesL G) \<subseteq> set (nodesL G); snd ` set (edgesL G) \<subseteq> set (nodesL G)\<rbrakk> \<Longrightarrow> fst ` set (edgesL \<lparr>nodesL = nodesL G, edgesL = remdups (edgesL G @ backlinks (edgesL G))\<rparr>) \<subseteq> set (nodesL \<lparr>nodesL = nodesL G, edgesL = remdups (edgesL G @ backlinks (edgesL G))\<rparr>) \<and> snd ` set (edgesL \<lparr>nodesL = nodesL G, edgesL = remdups (edgesL G @ backlinks (edgesL G))\<rparr>) \<subseteq> set (nodesL \<lparr>nodesL = nodesL G, edgesL = remdups (edgesL G @ backlinks (edgesL G))\<rparr>)
[PROOF STEP]
by(auto simp: backlinks_set)


[STATEMENT]
lemma Borsukian_circle:
  fixes S :: "'a::real_normed_vector set"
  shows "Borsukian S \<longleftrightarrow>
         (\<forall>f. continuous_on S f \<and> f ` S \<subseteq> sphere (0::complex) 1
              \<longrightarrow> (\<exists>a. homotopic_with_canon (\<lambda>h. True) S (sphere (0::complex) 1) f (\<lambda>x. a)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Borsukian S = (\<forall>f. continuous_on S f \<and> f ` S \<subseteq> sphere 0 1 \<longrightarrow> (\<exists>a. homotopic_with_canon (\<lambda>h. True) S (sphere 0 1) f (\<lambda>x. a)))
[PROOF STEP]
by (simp add: inessential_eq_continuous_logarithm_circle Borsukian_continuous_logarithm_circle_real)


[STATEMENT]
lemma Span_hom:
  assumes "K \<subseteq> carrier R" "set Us \<subseteq> carrier R"
  shows "Span (h ` K) (map h Us) = h ` R.Span K Us"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. S.Span (h ` K) (map h Us) = h ` R.Span K Us
[PROOF STEP]
using assms line_extension_hom R.Span_in_carrier
[PROOF STATE]
proof (prove)
using this:
K \<subseteq> carrier R
set Us \<subseteq> carrier R
\<lbrakk>?K \<subseteq> carrier R; ?a \<in> carrier R; ?E \<subseteq> carrier R\<rbrakk> \<Longrightarrow> S.line_extension (h ` ?K) (h ?a) (h ` ?E) = h ` R.line_extension ?K ?a ?E
\<lbrakk>?K \<subseteq> carrier R; set ?Us \<subseteq> carrier R\<rbrakk> \<Longrightarrow> R.Span ?K ?Us \<subseteq> carrier R

goal (1 subgoal):
 1. S.Span (h ` K) (map h Us) = h ` R.Span K Us
[PROOF STEP]
by (induct Us) (auto)


[STATEMENT]
lemma surj_quantale_hom_bij_on:
  fixes f :: "'a::quantale_with_dual \<Rightarrow> 'b::quantale_with_dual"
  assumes "surj f"
  and "f \<in> quantale_homset"
  shows "bij_betw f (range (radj f \<circ> f)) UNIV"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bij_betw f (range (radj f \<circ> f)) UNIV
[PROOF STEP]
using assms quantale_homset_iff surj_Sup_pres_bij_on
[PROOF STATE]
proof (prove)
using this:
top_pres ((`) f)
f \<in> quantale_homset
(?f \<in> quantale_homset) = (comp_pres ?f \<and> Sup_pres ?f)
\<lbrakk>top_pres ((`) ?f); Sup_pres ?f\<rbrakk> \<Longrightarrow> bij_betw ?f (range (radj ?f \<circ> ?f)) UNIV

goal (1 subgoal):
 1. bij_betw f (range (radj f \<circ> f)) UNIV
[PROOF STEP]
by blast


[STATEMENT]
lemma nat_test_pre_post:
  "nat_test t s \<Longrightarrow> -q \<le> s \<Longrightarrow> (\<forall>n . x \<le> t n*-p*-q\<stileturn>(pSum t n*-q)) \<Longrightarrow> -p\<star>x \<le> -q\<stileturn>--p*-q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>nat_test t s; - q \<le> s; \<forall>n. x \<le> t n * - p * - q \<stileturn> pSum t n * - q\<rbrakk> \<Longrightarrow> - p \<star> x \<le> - q \<stileturn> - - p * - q
[PROOF STEP]
by (smt (verit, ccfv_threshold) nat_test_def nat_test_pre pSum_test_nat pre_post_galois tests_dual.sub_sup_closed)


[STATEMENT]
lemma expectation_shift: "expectation (\<lambda>x. f x - expectation f) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. expectation (\<lambda>x. f x - expectation f) = 0
[PROOF STEP]
by (subst Bochner_Integration.integral_diff) (auto simp: integrable prob_space)


[STATEMENT]
lemma numer_cf2_pos: fixes x::real shows "x\<^sup>2 + 6 * x + 12 > 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < x\<^sup>2 + 6 * x + 12
[PROOF STEP]
by (sos "((R<1 + ((R<1 * ((R<5 * [3/10*x + 1]^2) + (R<1/20 * [x]^2))) + ((A<=0 * R<1) * (R<1/2 * [1]^2)))))")


[STATEMENT]
lemma nformsStops: "!!f.
  [| branch subs gamma f; !n . ~proofTree (tree subs (f n));
     nforms (f n) = [] |]
  ==> nforms (f (Suc n)) = [] & atoms (f (Suc n)) = atoms (f n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>f. \<lbrakk>branch subs gamma f; \<forall>n. \<not> proofTree (tree subs (f n)); nforms (f n) = []\<rbrakk> \<Longrightarrow> nforms (f (Suc n)) = [] \<and> atoms (f (Suc n)) = atoms (f n)
[PROOF STEP]
apply(subgoal_tac "f (Suc n) = f n")
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>f. \<lbrakk>branch subs gamma f; \<forall>n. \<not> proofTree (tree subs (f n)); nforms (f n) = []; f (Suc n) = f n\<rbrakk> \<Longrightarrow> nforms (f (Suc n)) = [] \<and> atoms (f (Suc n)) = atoms (f n)
 2. \<And>f. \<lbrakk>branch subs gamma f; \<forall>n. \<not> proofTree (tree subs (f n)); nforms (f n) = []\<rbrakk> \<Longrightarrow> f (Suc n) = f n
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>f. \<lbrakk>branch subs gamma f; \<forall>n. \<not> proofTree (tree subs (f n)); nforms (f n) = []\<rbrakk> \<Longrightarrow> f (Suc n) = f n
[PROOF STEP]
apply(blast intro: branchStops nformsTerminal)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma maximum:
  "FPRE (\<lambda>s:: nat store. True)
   (IF (\<lambda>s. s ''x'' \<ge> s ''y'')
    THEN (''z'' ::= (\<lambda>s. s ''x''))
    ELSE (''z'' ::= (\<lambda>s. s ''y''))
    FI)
   POST (\<lambda>s. s ''z'' = max (s ''x'') (s ''y''))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rel_antirange_kleene_algebra.bdia (IF (\<lambda>s. s ''y'' \<le> s ''x'') THEN (''z'' ::= (\<lambda>s. s ''x'')) ELSE (''z'' ::= (\<lambda>s. s ''y'')) FI) \<lceil>\<lambda>s. True\<rceil> \<subseteq> rel_antirange_kleene_algebra.ars_r \<lceil>\<lambda>s. s ''z'' = max (s ''x'') (s ''y'')\<rceil>
[PROOF STEP]
by auto


[STATEMENT]
lemma cblinfun_image_INF_eq[simp]:
  fixes V :: "'a \<Rightarrow> 'b::chilbert_space ccsubspace"
    and U :: "'b \<Rightarrow>\<^sub>C\<^sub>L 'c::chilbert_space"
  assumes \<open>isometry U\<close>
  shows "U *\<^sub>S (INF i. V i) = (INF i. U *\<^sub>S V i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. U *\<^sub>S \<Sqinter> range V = (\<Sqinter>i. U *\<^sub>S V i)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. U *\<^sub>S \<Sqinter> range V = (\<Sqinter>i. U *\<^sub>S V i)
[PROOF STEP]
from \<open>isometry U\<close>
[PROOF STATE]
proof (chain)
picking this:
isometry U
[PROOF STEP]
have "U* o\<^sub>C\<^sub>L U o\<^sub>C\<^sub>L U* = U*"
[PROOF STATE]
proof (prove)
using this:
isometry U

goal (1 subgoal):
 1. U* o\<^sub>C\<^sub>L U o\<^sub>C\<^sub>L U* = U*
[PROOF STEP]
unfolding isometry_def
[PROOF STATE]
proof (prove)
using this:
U* o\<^sub>C\<^sub>L U = id_cblinfun

goal (1 subgoal):
 1. U* o\<^sub>C\<^sub>L U o\<^sub>C\<^sub>L U* = U*
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
U* o\<^sub>C\<^sub>L U o\<^sub>C\<^sub>L U* = U*

goal (1 subgoal):
 1. U *\<^sub>S \<Sqinter> range V = (\<Sqinter>i. U *\<^sub>S V i)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
U* o\<^sub>C\<^sub>L U o\<^sub>C\<^sub>L U* = U*

goal (1 subgoal):
 1. U *\<^sub>S \<Sqinter> range V = (\<Sqinter>i. U *\<^sub>S V i)
[PROOF STEP]
from \<open>isometry U\<close>
[PROOF STATE]
proof (chain)
picking this:
isometry U
[PROOF STEP]
have "U o\<^sub>C\<^sub>L U* o\<^sub>C\<^sub>L U = U"
[PROOF STATE]
proof (prove)
using this:
isometry U

goal (1 subgoal):
 1. U o\<^sub>C\<^sub>L U* o\<^sub>C\<^sub>L U = U
[PROOF STEP]
unfolding isometry_def
[PROOF STATE]
proof (prove)
using this:
U* o\<^sub>C\<^sub>L U = id_cblinfun

goal (1 subgoal):
 1. U o\<^sub>C\<^sub>L U* o\<^sub>C\<^sub>L U = U
[PROOF STEP]
by (simp add: cblinfun_compose_assoc)
[PROOF STATE]
proof (state)
this:
U o\<^sub>C\<^sub>L U* o\<^sub>C\<^sub>L U = U

goal (1 subgoal):
 1. U *\<^sub>S \<Sqinter> range V = (\<Sqinter>i. U *\<^sub>S V i)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
U o\<^sub>C\<^sub>L U* o\<^sub>C\<^sub>L U = U

goal (1 subgoal):
 1. U *\<^sub>S \<Sqinter> range V = (\<Sqinter>i. U *\<^sub>S V i)
[PROOF STEP]
have "V i \<le> U* *\<^sub>S top" for i
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. V i \<le> U* *\<^sub>S \<top>
[PROOF STEP]
by (simp add: range_adjoint_isometry assms)
[PROOF STATE]
proof (state)
this:
V ?i \<le> U* *\<^sub>S \<top>

goal (1 subgoal):
 1. U *\<^sub>S \<Sqinter> range V = (\<Sqinter>i. U *\<^sub>S V i)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
U* o\<^sub>C\<^sub>L U o\<^sub>C\<^sub>L U* = U*
U o\<^sub>C\<^sub>L U* o\<^sub>C\<^sub>L U = U
V ?i \<le> U* *\<^sub>S \<top>
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
U* o\<^sub>C\<^sub>L U o\<^sub>C\<^sub>L U* = U*
U o\<^sub>C\<^sub>L U* o\<^sub>C\<^sub>L U = U
V ?i \<le> U* *\<^sub>S \<top>

goal (1 subgoal):
 1. U *\<^sub>S \<Sqinter> range V = (\<Sqinter>i. U *\<^sub>S V i)
[PROOF STEP]
by (rule cblinfun_image_INF_eq_general)
[PROOF STATE]
proof (state)
this:
U *\<^sub>S \<Sqinter> range V = (\<Sqinter>i. U *\<^sub>S V i)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma mem_Collect_eq_not: "(a \<notin> {x. P x}) = (\<not> P a)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (a \<notin> {x. P x}) = (\<not> P a)
[PROOF STEP]
by blast


[STATEMENT]
lemma "\<psi>\<^sub>1\<^sub>0_tensor_\<psi>\<^sub>1\<^sub>1_is_\<psi>\<^sub>1":
  assumes "n \<ge> 1"
  shows "(\<psi>\<^sub>1\<^sub>0 n) \<Otimes> \<psi>\<^sub>1\<^sub>1 = \<psi>\<^sub>1 n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Matrix.mat (2 ^ n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ n)) \<Otimes> Matrix.mat 2 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if i = 0 then 1 / sqrt 2 else - 1 / sqrt 2)) = Matrix.mat (2 ^ (n + 1)) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if even i then 1 / sqrt 2 ^ (n + 1) else - 1 / sqrt 2 ^ (n + 1)))
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < dim_row (Matrix.mat (2 ^ (n + 1)) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if even i then 1 / sqrt 2 ^ (n + 1) else - 1 / sqrt 2 ^ (n + 1)))); j < dim_col (Matrix.mat (2 ^ (n + 1)) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if even i then 1 / sqrt 2 ^ (n + 1) else - 1 / sqrt 2 ^ (n + 1))))\<rbrakk> \<Longrightarrow> (Matrix.mat (2 ^ n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ n)) \<Otimes> Matrix.mat 2 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if i = 0 then 1 / sqrt 2 else - 1 / sqrt 2))) $$ (i, j) = Matrix.mat (2 ^ (n + 1)) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if even i then 1 / sqrt 2 ^ (n + 1) else - 1 / sqrt 2 ^ (n + 1))) $$ (i, j)
 2. dim_row (Matrix.mat (2 ^ n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ n)) \<Otimes> Matrix.mat 2 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if i = 0 then 1 / sqrt 2 else - 1 / sqrt 2))) = dim_row (Matrix.mat (2 ^ (n + 1)) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if even i then 1 / sqrt 2 ^ (n + 1) else - 1 / sqrt 2 ^ (n + 1))))
 3. dim_col (Matrix.mat (2 ^ n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ n)) \<Otimes> Matrix.mat 2 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if i = 0 then 1 / sqrt 2 else - 1 / sqrt 2))) = dim_col (Matrix.mat (2 ^ (n + 1)) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if even i then 1 / sqrt 2 ^ (n + 1) else - 1 / sqrt 2 ^ (n + 1))))
[PROOF STEP]
show "dim_col ((\<psi>\<^sub>1\<^sub>0 n) \<Otimes> \<psi>\<^sub>1\<^sub>1) = dim_col (\<psi>\<^sub>1 n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_col (Matrix.mat (2 ^ n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ n)) \<Otimes> Matrix.mat 2 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if i = 0 then 1 / sqrt 2 else - 1 / sqrt 2))) = dim_col (Matrix.mat (2 ^ (n + 1)) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if even i then 1 / sqrt 2 ^ (n + 1) else - 1 / sqrt 2 ^ (n + 1))))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
dim_col (Matrix.mat (2 ^ n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ n)) \<Otimes> Matrix.mat 2 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if i = 0 then 1 / sqrt 2 else - 1 / sqrt 2))) = dim_col (Matrix.mat (2 ^ (n + 1)) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if even i then 1 / sqrt 2 ^ (n + 1) else - 1 / sqrt 2 ^ (n + 1))))

goal (2 subgoals):
 1. \<And>i j. \<lbrakk>i < dim_row (Matrix.mat (2 ^ (n + 1)) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if even i then 1 / sqrt 2 ^ (n + 1) else - 1 / sqrt 2 ^ (n + 1)))); j < dim_col (Matrix.mat (2 ^ (n + 1)) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if even i then 1 / sqrt 2 ^ (n + 1) else - 1 / sqrt 2 ^ (n + 1))))\<rbrakk> \<Longrightarrow> (Matrix.mat (2 ^ n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ n)) \<Otimes> Matrix.mat 2 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if i = 0 then 1 / sqrt 2 else - 1 / sqrt 2))) $$ (i, j) = Matrix.mat (2 ^ (n + 1)) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if even i then 1 / sqrt 2 ^ (n + 1) else - 1 / sqrt 2 ^ (n + 1))) $$ (i, j)
 2. dim_row (Matrix.mat (2 ^ n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ n)) \<Otimes> Matrix.mat 2 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if i = 0 then 1 / sqrt 2 else - 1 / sqrt 2))) = dim_row (Matrix.mat (2 ^ (n + 1)) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if even i then 1 / sqrt 2 ^ (n + 1) else - 1 / sqrt 2 ^ (n + 1))))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>i j. \<lbrakk>i < dim_row (Matrix.mat (2 ^ (n + 1)) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if even i then 1 / sqrt 2 ^ (n + 1) else - 1 / sqrt 2 ^ (n + 1)))); j < dim_col (Matrix.mat (2 ^ (n + 1)) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if even i then 1 / sqrt 2 ^ (n + 1) else - 1 / sqrt 2 ^ (n + 1))))\<rbrakk> \<Longrightarrow> (Matrix.mat (2 ^ n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ n)) \<Otimes> Matrix.mat 2 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if i = 0 then 1 / sqrt 2 else - 1 / sqrt 2))) $$ (i, j) = Matrix.mat (2 ^ (n + 1)) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if even i then 1 / sqrt 2 ^ (n + 1) else - 1 / sqrt 2 ^ (n + 1))) $$ (i, j)
 2. dim_row (Matrix.mat (2 ^ n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ n)) \<Otimes> Matrix.mat 2 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if i = 0 then 1 / sqrt 2 else - 1 / sqrt 2))) = dim_row (Matrix.mat (2 ^ (n + 1)) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if even i then 1 / sqrt 2 ^ (n + 1) else - 1 / sqrt 2 ^ (n + 1))))
[PROOF STEP]
show "dim_row ((\<psi>\<^sub>1\<^sub>0 n) \<Otimes> \<psi>\<^sub>1\<^sub>1) = dim_row (\<psi>\<^sub>1 n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_row (Matrix.mat (2 ^ n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ n)) \<Otimes> Matrix.mat 2 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if i = 0 then 1 / sqrt 2 else - 1 / sqrt 2))) = dim_row (Matrix.mat (2 ^ (n + 1)) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if even i then 1 / sqrt 2 ^ (n + 1) else - 1 / sqrt 2 ^ (n + 1))))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
dim_row (Matrix.mat (2 ^ n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ n)) \<Otimes> Matrix.mat 2 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if i = 0 then 1 / sqrt 2 else - 1 / sqrt 2))) = dim_row (Matrix.mat (2 ^ (n + 1)) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if even i then 1 / sqrt 2 ^ (n + 1) else - 1 / sqrt 2 ^ (n + 1))))

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row (Matrix.mat (2 ^ (n + 1)) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if even i then 1 / sqrt 2 ^ (n + 1) else - 1 / sqrt 2 ^ (n + 1)))); j < dim_col (Matrix.mat (2 ^ (n + 1)) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if even i then 1 / sqrt 2 ^ (n + 1) else - 1 / sqrt 2 ^ (n + 1))))\<rbrakk> \<Longrightarrow> (Matrix.mat (2 ^ n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ n)) \<Otimes> Matrix.mat 2 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if i = 0 then 1 / sqrt 2 else - 1 / sqrt 2))) $$ (i, j) = Matrix.mat (2 ^ (n + 1)) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if even i then 1 / sqrt 2 ^ (n + 1) else - 1 / sqrt 2 ^ (n + 1))) $$ (i, j)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row (Matrix.mat (2 ^ (n + 1)) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if even i then 1 / sqrt 2 ^ (n + 1) else - 1 / sqrt 2 ^ (n + 1)))); j < dim_col (Matrix.mat (2 ^ (n + 1)) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if even i then 1 / sqrt 2 ^ (n + 1) else - 1 / sqrt 2 ^ (n + 1))))\<rbrakk> \<Longrightarrow> (Matrix.mat (2 ^ n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ n)) \<Otimes> Matrix.mat 2 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if i = 0 then 1 / sqrt 2 else - 1 / sqrt 2))) $$ (i, j) = Matrix.mat (2 ^ (n + 1)) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if even i then 1 / sqrt 2 ^ (n + 1) else - 1 / sqrt 2 ^ (n + 1))) $$ (i, j)
[PROOF STEP]
fix i j:: nat
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row (Matrix.mat (2 ^ (n + 1)) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if even i then 1 / sqrt 2 ^ (n + 1) else - 1 / sqrt 2 ^ (n + 1)))); j < dim_col (Matrix.mat (2 ^ (n + 1)) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if even i then 1 / sqrt 2 ^ (n + 1) else - 1 / sqrt 2 ^ (n + 1))))\<rbrakk> \<Longrightarrow> (Matrix.mat (2 ^ n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ n)) \<Otimes> Matrix.mat 2 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if i = 0 then 1 / sqrt 2 else - 1 / sqrt 2))) $$ (i, j) = Matrix.mat (2 ^ (n + 1)) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if even i then 1 / sqrt 2 ^ (n + 1) else - 1 / sqrt 2 ^ (n + 1))) $$ (i, j)
[PROOF STEP]
assume a0: "i < dim_row (\<psi>\<^sub>1 n)" and a1: "j < dim_col (\<psi>\<^sub>1 n)"
[PROOF STATE]
proof (state)
this:
i < dim_row (Matrix.mat (2 ^ (n + 1)) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if even i then 1 / sqrt 2 ^ (n + 1) else - 1 / sqrt 2 ^ (n + 1))))
j < dim_col (Matrix.mat (2 ^ (n + 1)) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if even i then 1 / sqrt 2 ^ (n + 1) else - 1 / sqrt 2 ^ (n + 1))))

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row (Matrix.mat (2 ^ (n + 1)) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if even i then 1 / sqrt 2 ^ (n + 1) else - 1 / sqrt 2 ^ (n + 1)))); j < dim_col (Matrix.mat (2 ^ (n + 1)) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if even i then 1 / sqrt 2 ^ (n + 1) else - 1 / sqrt 2 ^ (n + 1))))\<rbrakk> \<Longrightarrow> (Matrix.mat (2 ^ n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ n)) \<Otimes> Matrix.mat 2 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if i = 0 then 1 / sqrt 2 else - 1 / sqrt 2))) $$ (i, j) = Matrix.mat (2 ^ (n + 1)) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if even i then 1 / sqrt 2 ^ (n + 1) else - 1 / sqrt 2 ^ (n + 1))) $$ (i, j)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
i < dim_row (Matrix.mat (2 ^ (n + 1)) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if even i then 1 / sqrt 2 ^ (n + 1) else - 1 / sqrt 2 ^ (n + 1))))
j < dim_col (Matrix.mat (2 ^ (n + 1)) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if even i then 1 / sqrt 2 ^ (n + 1) else - 1 / sqrt 2 ^ (n + 1))))
[PROOF STEP]
have "i < 2^(n+1)" and "j = 0"
[PROOF STATE]
proof (prove)
using this:
i < dim_row (Matrix.mat (2 ^ (n + 1)) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if even i then 1 / sqrt 2 ^ (n + 1) else - 1 / sqrt 2 ^ (n + 1))))
j < dim_col (Matrix.mat (2 ^ (n + 1)) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if even i then 1 / sqrt 2 ^ (n + 1) else - 1 / sqrt 2 ^ (n + 1))))

goal (1 subgoal):
 1. i < 2 ^ (n + 1) &&& j = 0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
i < 2 ^ (n + 1)
j = 0

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row (Matrix.mat (2 ^ (n + 1)) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if even i then 1 / sqrt 2 ^ (n + 1) else - 1 / sqrt 2 ^ (n + 1)))); j < dim_col (Matrix.mat (2 ^ (n + 1)) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if even i then 1 / sqrt 2 ^ (n + 1) else - 1 / sqrt 2 ^ (n + 1))))\<rbrakk> \<Longrightarrow> (Matrix.mat (2 ^ n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ n)) \<Otimes> Matrix.mat 2 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if i = 0 then 1 / sqrt 2 else - 1 / sqrt 2))) $$ (i, j) = Matrix.mat (2 ^ (n + 1)) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if even i then 1 / sqrt 2 ^ (n + 1) else - 1 / sqrt 2 ^ (n + 1))) $$ (i, j)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
i < 2 ^ (n + 1)
j = 0
[PROOF STEP]
have f0: "((\<psi>\<^sub>1\<^sub>0 n) \<Otimes> \<psi>\<^sub>1\<^sub>1) $$ (i,j) = 1/(sqrt 2)^n * \<psi>\<^sub>1\<^sub>1 $$ (i mod 2, j)"
[PROOF STATE]
proof (prove)
using this:
i < 2 ^ (n + 1)
j = 0

goal (1 subgoal):
 1. (Matrix.mat (2 ^ n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ n)) \<Otimes> Matrix.mat 2 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if i = 0 then 1 / sqrt 2 else - 1 / sqrt 2))) $$ (i, j) = complex_of_real (1 / sqrt 2 ^ n) * Matrix.mat 2 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if i = 0 then 1 / sqrt 2 else - 1 / sqrt 2)) $$ (i mod 2, j)
[PROOF STEP]
using \<psi>\<^sub>1\<^sub>0_values[of "i div 2" n "j div 1"] a0 a1
[PROOF STATE]
proof (prove)
using this:
i < 2 ^ (n + 1)
j = 0
\<lbrakk>i div 2 < dim_row (Matrix.mat (2 ^ n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ n))); j div 1 < dim_col (Matrix.mat (2 ^ n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ n)))\<rbrakk> \<Longrightarrow> Matrix.mat (2 ^ n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ n)) $$ (i div 2, j div 1) = complex_of_real (1 / sqrt 2 ^ n)
i < dim_row (Matrix.mat (2 ^ (n + 1)) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if even i then 1 / sqrt 2 ^ (n + 1) else - 1 / sqrt 2 ^ (n + 1))))
j < dim_col (Matrix.mat (2 ^ (n + 1)) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if even i then 1 / sqrt 2 ^ (n + 1) else - 1 / sqrt 2 ^ (n + 1))))

goal (1 subgoal):
 1. (Matrix.mat (2 ^ n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ n)) \<Otimes> Matrix.mat 2 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if i = 0 then 1 / sqrt 2 else - 1 / sqrt 2))) $$ (i, j) = complex_of_real (1 / sqrt 2 ^ n) * Matrix.mat 2 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if i = 0 then 1 / sqrt 2 else - 1 / sqrt 2)) $$ (i mod 2, j)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(Matrix.mat (2 ^ n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ n)) \<Otimes> Matrix.mat 2 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if i = 0 then 1 / sqrt 2 else - 1 / sqrt 2))) $$ (i, j) = complex_of_real (1 / sqrt 2 ^ n) * Matrix.mat 2 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if i = 0 then 1 / sqrt 2 else - 1 / sqrt 2)) $$ (i mod 2, j)

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row (Matrix.mat (2 ^ (n + 1)) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if even i then 1 / sqrt 2 ^ (n + 1) else - 1 / sqrt 2 ^ (n + 1)))); j < dim_col (Matrix.mat (2 ^ (n + 1)) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if even i then 1 / sqrt 2 ^ (n + 1) else - 1 / sqrt 2 ^ (n + 1))))\<rbrakk> \<Longrightarrow> (Matrix.mat (2 ^ n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ n)) \<Otimes> Matrix.mat 2 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if i = 0 then 1 / sqrt 2 else - 1 / sqrt 2))) $$ (i, j) = Matrix.mat (2 ^ (n + 1)) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if even i then 1 / sqrt 2 ^ (n + 1) else - 1 / sqrt 2 ^ (n + 1))) $$ (i, j)
[PROOF STEP]
show "((\<psi>\<^sub>1\<^sub>0 n) \<Otimes> \<psi>\<^sub>1\<^sub>1) $$ (i,j) = (\<psi>\<^sub>1 n) $$ (i,j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (Matrix.mat (2 ^ n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ n)) \<Otimes> Matrix.mat 2 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if i = 0 then 1 / sqrt 2 else - 1 / sqrt 2))) $$ (i, j) = Matrix.mat (2 ^ (n + 1)) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if even i then 1 / sqrt 2 ^ (n + 1) else - 1 / sqrt 2 ^ (n + 1))) $$ (i, j)
[PROOF STEP]
using f0 \<psi>\<^sub>1_values_even \<psi>\<^sub>1_values_odd a0 a1
[PROOF STATE]
proof (prove)
using this:
(Matrix.mat (2 ^ n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ n)) \<Otimes> Matrix.mat 2 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if i = 0 then 1 / sqrt 2 else - 1 / sqrt 2))) $$ (i, j) = complex_of_real (1 / sqrt 2 ^ n) * Matrix.mat 2 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if i = 0 then 1 / sqrt 2 else - 1 / sqrt 2)) $$ (i mod 2, j)
\<lbrakk>?i < dim_row (Matrix.mat (2 ^ (?n + 1)) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if even i then 1 / sqrt 2 ^ (?n + 1) else - 1 / sqrt 2 ^ (?n + 1)))); ?j < dim_col (Matrix.mat (2 ^ (?n + 1)) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if even i then 1 / sqrt 2 ^ (?n + 1) else - 1 / sqrt 2 ^ (?n + 1)))); even ?i\<rbrakk> \<Longrightarrow> Matrix.mat (2 ^ (?n + 1)) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if even i then 1 / sqrt 2 ^ (?n + 1) else - 1 / sqrt 2 ^ (?n + 1))) $$ (?i, ?j) = complex_of_real (1 / sqrt 2 ^ (?n + 1))
\<lbrakk>?i < dim_row (Matrix.mat (2 ^ (?n + 1)) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if even i then 1 / sqrt 2 ^ (?n + 1) else - 1 / sqrt 2 ^ (?n + 1)))); ?j < dim_col (Matrix.mat (2 ^ (?n + 1)) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if even i then 1 / sqrt 2 ^ (?n + 1) else - 1 / sqrt 2 ^ (?n + 1)))); odd ?i\<rbrakk> \<Longrightarrow> Matrix.mat (2 ^ (?n + 1)) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if even i then 1 / sqrt 2 ^ (?n + 1) else - 1 / sqrt 2 ^ (?n + 1))) $$ (?i, ?j) = complex_of_real (- 1 / sqrt 2 ^ (?n + 1))
i < dim_row (Matrix.mat (2 ^ (n + 1)) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if even i then 1 / sqrt 2 ^ (n + 1) else - 1 / sqrt 2 ^ (n + 1))))
j < dim_col (Matrix.mat (2 ^ (n + 1)) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if even i then 1 / sqrt 2 ^ (n + 1) else - 1 / sqrt 2 ^ (n + 1))))

goal (1 subgoal):
 1. (Matrix.mat (2 ^ n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ n)) \<Otimes> Matrix.mat 2 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if i = 0 then 1 / sqrt 2 else - 1 / sqrt 2))) $$ (i, j) = Matrix.mat (2 ^ (n + 1)) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if even i then 1 / sqrt 2 ^ (n + 1) else - 1 / sqrt 2 ^ (n + 1))) $$ (i, j)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(Matrix.mat (2 ^ n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ n)) \<Otimes> Matrix.mat 2 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if i = 0 then 1 / sqrt 2 else - 1 / sqrt 2))) $$ (i, j) = Matrix.mat (2 ^ (n + 1)) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> if even i then 1 / sqrt 2 ^ (n + 1) else - 1 / sqrt 2 ^ (n + 1))) $$ (i, j)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma LeastI_ex: "(\<exists> x. P (x::'a::wellorder)) \<Longrightarrow> P (LEAST x. P x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>x. P x \<Longrightarrow> P (LEAST x. P x)
[PROOF STEP]
by(blast intro: LeastI)


[STATEMENT]
lemma (in design) n_inter_num_choose_design_inter: "b1 \<in># \<B> \<Longrightarrow> b2 \<in># \<B>
    \<Longrightarrow> b1 |\<inter>|\<^sub>n b2 = (nat (b1 |\<inter>| b2) choose n) "
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>b1 \<in># \<B>; b2 \<in># \<B>\<rbrakk> \<Longrightarrow> (b1 |\<inter>|\<^sub>n b2) = nat (int (b1 |\<inter>| b2)) choose n
[PROOF STEP]
using finite_blocks
[PROOF STATE]
proof (prove)
using this:
?b \<in># \<B> \<Longrightarrow> finite ?b

goal (1 subgoal):
 1. \<lbrakk>b1 \<in># \<B>; b2 \<in># \<B>\<rbrakk> \<Longrightarrow> (b1 |\<inter>|\<^sub>n b2) = nat (int (b1 |\<inter>| b2)) choose n
[PROOF STEP]
by (simp add: n_inter_num_choose intersection_number_def)


[STATEMENT]
lemma length_filter:"length (filter p xs) = sum_list (map (\<lambda>x. of_bool ( p x)) xs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (filter p xs) = (\<Sum>x\<leftarrow>xs. of_bool (p x))
[PROOF STEP]
by (induct xs, simp_all)


[STATEMENT]
theorem sw_compose:
"((z @zs[x \<and> y]_xs) @zs[x' \<and> y']_xs') =
 ((z @zs[x' \<and> y']_xs') @zs[(x @xs[x' \<and> y']_xs') \<and> (y @xs[x' \<and> y']_xs')]_xs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. z @zs[x \<and> y]_xs @zs[x' \<and> y']_xs' = z @zs[x' \<and> y']_xs' @zs[x @xs[x' \<and> y']_xs' \<and> y @xs[x' \<and> y']_xs']_xs
[PROOF STEP]
by(unfold sw_def, auto)


[STATEMENT]
lemma smult_div_poly: assumes "\<And> c. c \<in> set (coeffs p) \<Longrightarrow> a dvd c"
  shows "smult a (div_poly a p) = p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. smult a (div_poly a p) = p
[PROOF STEP]
unfolding smult_as_map_poly div_poly_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map_poly ((*) a) (map_poly (\<lambda>c. c div a) p) = p
[PROOF STEP]
by (subst map_poly_map_poly, force, subst map_poly_idI, insert assms, auto)


[STATEMENT]
lemma stern_brocot_fractions_not_repeated_strict_prefix:
  assumes "root (traverse_tree path stern_brocot_iterate) = root (traverse_tree path' stern_brocot_iterate)"
  assumes pp': "strict_prefix path path'"
  shows False
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. False
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. False
[PROOF STEP]
from pp'
[PROOF STATE]
proof (chain)
picking this:
strict_prefix path path'
[PROOF STEP]
obtain d ds where pp': "path' = path @ [d] @ ds"
[PROOF STATE]
proof (prove)
using this:
strict_prefix path path'

goal (1 subgoal):
 1. (\<And>d ds. path' = path @ [d] @ ds \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (auto elim!: strict_prefixE')
[PROOF STATE]
proof (state)
this:
path' = path @ [d] @ ds

goal (1 subgoal):
 1. False
[PROOF STEP]
define m where "m = root (traverse_tree path (stern_brocot_iterate_aux I))"
[PROOF STATE]
proof (state)
this:
m = root (traverse_tree path (stern_brocot_iterate_aux I))

goal (1 subgoal):
 1. False
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
m = root (traverse_tree path (stern_brocot_iterate_aux I))
[PROOF STEP]
have Dm: "Det m = 1" and Pm: "0 < snd (mediant m)"
[PROOF STATE]
proof (prove)
using this:
m = root (traverse_tree path (stern_brocot_iterate_aux I))

goal (1 subgoal):
 1. Det m = 1 &&& 0 < snd (mediant m)
[PROOF STEP]
using stern_brocot_iterate_aux_Det[where path="path" and m="I"]
[PROOF STATE]
proof (prove)
using this:
m = root (traverse_tree path (stern_brocot_iterate_aux I))
\<lbrakk>Det I = 1; 0 < snd (mediant I)\<rbrakk> \<Longrightarrow> Det (root (traverse_tree path (stern_brocot_iterate_aux I))) = 1
\<lbrakk>Det I = 1; 0 < snd (mediant I)\<rbrakk> \<Longrightarrow> 0 < snd (mediant (root (traverse_tree path (stern_brocot_iterate_aux I))))

goal (1 subgoal):
 1. Det m = 1 &&& 0 < snd (mediant m)
[PROOF STEP]
by simp_all
[PROOF STATE]
proof (state)
this:
Det m = 1
0 < snd (mediant m)

goal (1 subgoal):
 1. False
[PROOF STEP]
define m' where "m' = root (traverse_tree path' (stern_brocot_iterate_aux I))"
[PROOF STATE]
proof (state)
this:
m' = root (traverse_tree path' (stern_brocot_iterate_aux I))

goal (1 subgoal):
 1. False
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
m' = root (traverse_tree path' (stern_brocot_iterate_aux I))
[PROOF STEP]
have Dm': "Det m' = 1"
[PROOF STATE]
proof (prove)
using this:
m' = root (traverse_tree path' (stern_brocot_iterate_aux I))

goal (1 subgoal):
 1. Det m' = 1
[PROOF STEP]
using stern_brocot_iterate_aux_Det[where path=path' and m="I"]
[PROOF STATE]
proof (prove)
using this:
m' = root (traverse_tree path' (stern_brocot_iterate_aux I))
\<lbrakk>Det I = 1; 0 < snd (mediant I)\<rbrakk> \<Longrightarrow> Det (root (traverse_tree path' (stern_brocot_iterate_aux I))) = 1
\<lbrakk>Det I = 1; 0 < snd (mediant I)\<rbrakk> \<Longrightarrow> 0 < snd (mediant (root (traverse_tree path' (stern_brocot_iterate_aux I))))

goal (1 subgoal):
 1. Det m' = 1
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
Det m' = 1

goal (1 subgoal):
 1. False
[PROOF STEP]
let ?M = "case d of L \<Rightarrow> m \<otimes> LL | R \<Rightarrow> m \<otimes> UR"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. False
[PROOF STEP]
from pp'
[PROOF STATE]
proof (chain)
picking this:
path' = path @ [d] @ ds
[PROOF STEP]
have "root (traverse_tree ds (stern_brocot_iterate_aux ?M)) = m'"
[PROOF STATE]
proof (prove)
using this:
path' = path @ [d] @ ds

goal (1 subgoal):
 1. root (traverse_tree ds (stern_brocot_iterate_aux (case d of L \<Rightarrow> m \<otimes> LL | R \<Rightarrow> m \<otimes> UR))) = m'
[PROOF STEP]
by(simp add: m_def m'_def stern_brocot_iterate_aux_def traverse_tree_tree_iterate split: dir.splits)
[PROOF STATE]
proof (state)
this:
root (traverse_tree ds (stern_brocot_iterate_aux (case d of L \<Rightarrow> m \<otimes> LL | R \<Rightarrow> m \<otimes> UR))) = m'

goal (1 subgoal):
 1. False
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
root (traverse_tree ds (stern_brocot_iterate_aux (case d of L \<Rightarrow> m \<otimes> LL | R \<Rightarrow> m \<otimes> UR))) = m'
[PROOF STEP]
obtain m'' where mm'm'': "?M \<otimes> m''= m'" and Dm'': "Det m'' = 1"
[PROOF STATE]
proof (prove)
using this:
root (traverse_tree ds (stern_brocot_iterate_aux (case d of L \<Rightarrow> m \<otimes> LL | R \<Rightarrow> m \<otimes> UR))) = m'

goal (1 subgoal):
 1. (\<And>m''. \<lbrakk>(case d of L \<Rightarrow> m \<otimes> LL | R \<Rightarrow> m \<otimes> UR) \<otimes> m'' = m'; Det m'' = 1\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using stern_brocot_iterate_aux_decompose[where path="ds" and m="?M"]
[PROOF STATE]
proof (prove)
using this:
root (traverse_tree ds (stern_brocot_iterate_aux (case d of L \<Rightarrow> m \<otimes> LL | R \<Rightarrow> m \<otimes> UR))) = m'
\<exists>m''. (case d of L \<Rightarrow> m \<otimes> LL | R \<Rightarrow> m \<otimes> UR) \<otimes> m'' = root (traverse_tree ds (stern_brocot_iterate_aux (case d of L \<Rightarrow> m \<otimes> LL | R \<Rightarrow> m \<otimes> UR))) \<and> Det m'' = 1

goal (1 subgoal):
 1. (\<And>m''. \<lbrakk>(case d of L \<Rightarrow> m \<otimes> LL | R \<Rightarrow> m \<otimes> UR) \<otimes> m'' = m'; Det m'' = 1\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by clarsimp
[PROOF STATE]
proof (state)
this:
(case d of L \<Rightarrow> m \<otimes> LL | R \<Rightarrow> m \<otimes> UR) \<otimes> m'' = m'
Det m'' = 1

goal (1 subgoal):
 1. False
[PROOF STEP]
hence "case d of L \<Rightarrow> rat_of (mediant m') < rat_of (mediant m) | R \<Rightarrow> rat_of (mediant m) < rat_of (mediant m')"
[PROOF STATE]
proof (prove)
using this:
(case d of L \<Rightarrow> m \<otimes> LL | R \<Rightarrow> m \<otimes> UR) \<otimes> m'' = m'
Det m'' = 1

goal (1 subgoal):
 1. case d of L \<Rightarrow> rat_of (mediant m') < rat_of (mediant m) | R \<Rightarrow> rat_of (mediant m) < rat_of (mediant m')
[PROOF STEP]
using tree_ordering_left[OF Dm Dm'' Pm] tree_ordering_right[OF Dm Dm'' Pm]
[PROOF STATE]
proof (prove)
using this:
(case d of L \<Rightarrow> m \<otimes> LL | R \<Rightarrow> m \<otimes> UR) \<otimes> m'' = m'
Det m'' = 1
rat_of (mediant (m \<otimes> LL \<otimes> m'')) < rat_of (mediant m)
rat_of (mediant m) < rat_of (mediant (m \<otimes> UR \<otimes> m''))

goal (1 subgoal):
 1. case d of L \<Rightarrow> rat_of (mediant m') < rat_of (mediant m) | R \<Rightarrow> rat_of (mediant m) < rat_of (mediant m')
[PROOF STEP]
by (simp split: dir.splits)
[PROOF STATE]
proof (state)
this:
case d of L \<Rightarrow> rat_of (mediant m') < rat_of (mediant m) | R \<Rightarrow> rat_of (mediant m) < rat_of (mediant m')

goal (1 subgoal):
 1. False
[PROOF STEP]
with assms
[PROOF STATE]
proof (chain)
picking this:
root (traverse_tree path stern_brocot_iterate) = root (traverse_tree path' stern_brocot_iterate)
strict_prefix path path'
case d of L \<Rightarrow> rat_of (mediant m') < rat_of (mediant m) | R \<Rightarrow> rat_of (mediant m) < rat_of (mediant m')
[PROOF STEP]
show False
[PROOF STATE]
proof (prove)
using this:
root (traverse_tree path stern_brocot_iterate) = root (traverse_tree path' stern_brocot_iterate)
strict_prefix path path'
case d of L \<Rightarrow> rat_of (mediant m') < rat_of (mediant m) | R \<Rightarrow> rat_of (mediant m) < rat_of (mediant m')

goal (1 subgoal):
 1. False
[PROOF STEP]
by (simp add: stern_brocot_iterate_def m_def m'_def split: dir.splits)
[PROOF STATE]
proof (state)
this:
False

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma phiDefNodes_aux_finite: "finite (phiDefNodes_aux g v un m)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite (phiDefNodes_aux g v un m)
[PROOF STEP]
proof (induction un arbitrary:m rule:removeAll_induct)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>xs m. (\<And>x m. x \<in> set xs \<Longrightarrow> finite (phiDefNodes_aux g v (removeAll x xs) m)) \<Longrightarrow> finite (phiDefNodes_aux g v xs m)
[PROOF STEP]
case (1 un)
[PROOF STATE]
proof (state)
this:
?x1 \<in> set un \<Longrightarrow> finite (phiDefNodes_aux g v (removeAll ?x1 un) ?m1)

goal (1 subgoal):
 1. \<And>xs m. (\<And>x m. x \<in> set xs \<Longrightarrow> finite (phiDefNodes_aux g v (removeAll x xs) m)) \<Longrightarrow> finite (phiDefNodes_aux g v xs m)
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
using this:
?x1 \<in> set un \<Longrightarrow> finite (phiDefNodes_aux g v (removeAll ?x1 un) ?m1)

goal (1 subgoal):
 1. finite (phiDefNodes_aux g v un m)
[PROOF STEP]
by (cases un v g m rule:phiDefNodes_aux_cases) auto
[PROOF STATE]
proof (state)
this:
finite (phiDefNodes_aux g v un m)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma nat_mult_power_less_eq:
  "b > 0 \<Longrightarrow> (a * b ^ n < (b :: nat) ^ m) = (a < b ^ (m - n))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < b \<Longrightarrow> (a * b ^ n < b ^ m) = (a < b ^ (m - n))
[PROOF STEP]
using mult_less_cancel2[where m = a and k = "b ^ n" and n="b ^ (m - n)"]
        mult_less_cancel2[where m="a * b ^ (n - m)" and k="b ^ m" and n=1]
[PROOF STATE]
proof (prove)
using this:
(a * b ^ n < b ^ (m - n) * b ^ n) = (0 < b ^ n \<and> a < b ^ (m - n))
(a * b ^ (n - m) * b ^ m < 1 * b ^ m) = (0 < b ^ m \<and> a * b ^ (n - m) < 1)

goal (1 subgoal):
 1. 0 < b \<Longrightarrow> (a * b ^ n < b ^ m) = (a < b ^ (m - n))
[PROOF STEP]
apply (simp only: power_add[symmetric] nat_minus_add_max)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < b; (a * b ^ n < b ^ max m n) = (0 < b ^ n \<and> a < b ^ (m - n)); (a * b ^ (n - m) * b ^ m < 1 * b ^ m) = (0 < b ^ m \<and> a * b ^ (n - m) < 1)\<rbrakk> \<Longrightarrow> (a * b ^ n < b ^ m) = (a < b ^ (m - n))
[PROOF STEP]
apply (simp only: power_add[symmetric] nat_minus_add_max ac_simps)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < b; (a * b ^ n < b ^ max m n) = (0 < b ^ n \<and> a < b ^ (m - n)); (a * b ^ (m + (n - m)) < 1 * b ^ m) = (0 < b ^ m \<and> a * b ^ (n - m) < 1)\<rbrakk> \<Longrightarrow> (a * b ^ n < b ^ m) = (a < b ^ (m - n))
[PROOF STEP]
apply (simp add: max_def split: if_split_asm)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma fixp_lfp_parametric_eq:
  includes lifting_syntax
  assumes f: "\<And>x. lfp.mono_body (\<lambda>f. F f x)"
  and g: "\<And>x. lfp.mono_body (\<lambda>f. G f x)"
  and param: "((A ===> (=)) ===> A ===> (=)) F G"
  shows "(A ===> (=)) (lfp.fixp_fun F) (lfp.fixp_fun G)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (A ===> (=)) (lfp.fixp_fun F) (lfp.fixp_fun G)
[PROOF STEP]
using f g
[PROOF STATE]
proof (prove)
using this:
monotone lfp.le_fun (\<le>) (\<lambda>f. F f ?x)
monotone lfp.le_fun (\<le>) (\<lambda>f. G f ?x)

goal (1 subgoal):
 1. (A ===> (=)) (lfp.fixp_fun F) (lfp.fixp_fun G)
[PROOF STEP]
proof(rule parallel_fixp_induct_1_1[OF complete_lattice_partial_function_definitions complete_lattice_partial_function_definitions _ _ reflexive reflexive, where P="(A ===> (=))"])
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. ccpo.admissible (prod_lub lfp.lub_fun lfp.lub_fun) (rel_prod lfp.le_fun lfp.le_fun) (\<lambda>x. (A ===> (=)) (fst x) (snd x))
 2. (A ===> (=)) (\<lambda>_. \<Squnion> {}) (\<lambda>_. \<Squnion> {})
 3. \<And>f g. (A ===> (=)) f g \<Longrightarrow> (A ===> (=)) (F f) (G g)
[PROOF STEP]
show "ccpo.admissible (prod_lub lfp.lub_fun lfp.lub_fun) (rel_prod lfp.le_fun lfp.le_fun) (\<lambda>x. (A ===> (=)) (fst x) (snd x))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ccpo.admissible (prod_lub lfp.lub_fun lfp.lub_fun) (rel_prod lfp.le_fun lfp.le_fun) (\<lambda>x. (A ===> (=)) (fst x) (snd x))
[PROOF STEP]
unfolding rel_fun_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ccpo.admissible (prod_lub lfp.lub_fun lfp.lub_fun) (rel_prod lfp.le_fun lfp.le_fun) (\<lambda>x. \<forall>xa y. A xa y \<longrightarrow> fst x xa = snd x y)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
ccpo.admissible (prod_lub lfp.lub_fun lfp.lub_fun) (rel_prod lfp.le_fun lfp.le_fun) (\<lambda>x. (A ===> (=)) (fst x) (snd x))

goal (2 subgoals):
 1. (A ===> (=)) (\<lambda>_. \<Squnion> {}) (\<lambda>_. \<Squnion> {})
 2. \<And>f g. (A ===> (=)) f g \<Longrightarrow> (A ===> (=)) (F f) (G g)
[PROOF STEP]
show "(A ===> (=)) (\<lambda>_. \<Squnion>{}) (\<lambda>_. \<Squnion>{})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (A ===> (=)) (\<lambda>_. \<Squnion> {}) (\<lambda>_. \<Squnion> {})
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(A ===> (=)) (\<lambda>_. \<Squnion> {}) (\<lambda>_. \<Squnion> {})

goal (1 subgoal):
 1. \<And>f g. (A ===> (=)) f g \<Longrightarrow> (A ===> (=)) (F f) (G g)
[PROOF STEP]
show "(A ===> (=)) (F f) (G g)" if "(A ===> (=)) f g" for f g
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (A ===> (=)) (F f) (G g)
[PROOF STEP]
using that
[PROOF STATE]
proof (prove)
using this:
(A ===> (=)) f g

goal (1 subgoal):
 1. (A ===> (=)) (F f) (G g)
[PROOF STEP]
by(rule rel_funD[OF param])
[PROOF STATE]
proof (state)
this:
(A ===> (=)) ?f2 ?g2 \<Longrightarrow> (A ===> (=)) (F ?f2) (G ?g2)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma gcd_greatest_iff [simp]: "a dvd gcd b c \<longleftrightarrow> a dvd b \<and> a dvd c"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (a dvd gcd b c) = (a dvd b \<and> a dvd c)
[PROOF STEP]
by (blast intro!: gcd_greatest intro: dvd_trans)


[STATEMENT]
lemma summable_sum: "(\<And>i. i \<in> I \<Longrightarrow> summable (f i)) \<Longrightarrow> summable (\<lambda>n. \<Sum>i\<in>I. f i n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>i. i \<in> I \<Longrightarrow> summable (f i)) \<Longrightarrow> summable (\<lambda>n. \<Sum>i\<in>I. f i n)
[PROOF STEP]
using sums_summable[OF sums_sum[OF summable_sums]]
[PROOF STATE]
proof (prove)
using this:
(\<And>i. i \<in> I \<Longrightarrow> summable (f i)) \<Longrightarrow> summable (\<lambda>n. \<Sum>i\<in>I. f i n)

goal (1 subgoal):
 1. (\<And>i. i \<in> I \<Longrightarrow> summable (f i)) \<Longrightarrow> summable (\<lambda>n. \<Sum>i\<in>I. f i n)
[PROOF STEP]
.


[STATEMENT]
lemma word_overflow_unat:"unat ((x::('a::len) word) + 1) = unat x + 1 \<or> x + 1 = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. unat (x + 1) = unat x + 1 \<or> x + 1 = 0
[PROOF STEP]
by (metis Suc_eq_plus1 add.commute unatSuc)


[STATEMENT]
lemma rat_sgn_code [code abstract]: "quotient_of (sgn p) = (sgn (fst (quotient_of p)), 1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. quotient_of (sgn p) = (sgn (fst (quotient_of p)), 1)
[PROOF STEP]
proof (cases p)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a b. \<lbrakk>p = Fract a b; 0 < b; coprime a b\<rbrakk> \<Longrightarrow> quotient_of (sgn p) = (sgn (fst (quotient_of p)), 1)
[PROOF STEP]
case (Fract a b)
[PROOF STATE]
proof (state)
this:
p = Fract a b
0 < b
coprime a b

goal (1 subgoal):
 1. \<And>a b. \<lbrakk>p = Fract a b; 0 < b; coprime a b\<rbrakk> \<Longrightarrow> quotient_of (sgn p) = (sgn (fst (quotient_of p)), 1)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
p = Fract a b
0 < b
coprime a b
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
p = Fract a b
0 < b
coprime a b

goal (1 subgoal):
 1. quotient_of (sgn p) = (sgn (fst (quotient_of p)), 1)
[PROOF STEP]
by (cases "0::int" a rule: linorder_cases) (simp_all add: quotient_of_Fract)
[PROOF STATE]
proof (state)
this:
quotient_of (sgn p) = (sgn (fst (quotient_of p)), 1)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma hom_relboundary_empty: "hom_relboundary p X S {} = hom_boundary p X S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. hom_relboundary p X S {} = hom_boundary p X S
[PROOF STEP]
apply (simp add: hom_relboundary_def o_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. hom_induced (p - 1) (subtopology X S) {} (subtopology X S) {} id (hom_boundary p X S x)) = hom_boundary p X S
[PROOF STEP]
apply (subst hom_induced_id)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>x. hom_boundary p X S x \<in> carrier (homology_group (p - 1) (subtopology X S))
 2. hom_boundary p X S = hom_boundary p X S
[PROOF STEP]
apply (metis hom_boundary_carrier, auto)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma mono_prop_set_equiv:
  assumes "mono_prop P"
      and "equiv A B"
    shows "setify P A \<longleftrightarrow> setify P B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. setify P A = setify P B
[PROOF STEP]
by (meson assms(1) assms(2) local.equiv_def sep_algebra.mono_prop_set sep_algebra_axioms)


[STATEMENT]
lemma matrix_to_iarray_Gauss_Jordan_column_k_2:
  fixes A::"'a::{field}^'columns::{mod_type}^'rows::{mod_type}"
  assumes k: "k<ncols A"
  and i: "i\<le>nrows A"
  shows "matrix_to_iarray (snd (Gauss_Jordan_column_k (i, A) k)) = snd (Gauss_Jordan_column_k_iarrays (i, matrix_to_iarray A) k)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. matrix_to_iarray (snd (Gauss_Jordan_column_k (i, A) k)) = snd (Gauss_Jordan_column_k_iarrays (i, matrix_to_iarray A) k)
[PROOF STEP]
proof (cases "i<nrows A")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. i < nrows A \<Longrightarrow> matrix_to_iarray (snd (Gauss_Jordan_column_k (i, A) k)) = snd (Gauss_Jordan_column_k_iarrays (i, matrix_to_iarray A) k)
 2. \<not> i < nrows A \<Longrightarrow> matrix_to_iarray (snd (Gauss_Jordan_column_k (i, A) k)) = snd (Gauss_Jordan_column_k_iarrays (i, matrix_to_iarray A) k)
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
i < nrows A

goal (2 subgoals):
 1. i < nrows A \<Longrightarrow> matrix_to_iarray (snd (Gauss_Jordan_column_k (i, A) k)) = snd (Gauss_Jordan_column_k_iarrays (i, matrix_to_iarray A) k)
 2. \<not> i < nrows A \<Longrightarrow> matrix_to_iarray (snd (Gauss_Jordan_column_k (i, A) k)) = snd (Gauss_Jordan_column_k_iarrays (i, matrix_to_iarray A) k)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. matrix_to_iarray (snd (Gauss_Jordan_column_k (i, A) k)) = snd (Gauss_Jordan_column_k_iarrays (i, matrix_to_iarray A) k)
[PROOF STEP]
unfolding Gauss_Jordan_column_k_def Let_def Gauss_Jordan_column_k_iarrays_def fst_conv snd_conv
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. matrix_to_iarray (snd (if (\<forall>m\<ge>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a)) \<or> i = nrows A then (i, A) else (i + 1, Gauss_Jordan_in_ij A (mod_type_class.from_nat i) (mod_type_class.from_nat k)))) = snd (if vector_all_zero_from_index (i, column_iarray k (matrix_to_iarray A)) \<or> i = nrows_iarray (matrix_to_iarray A) then (i, matrix_to_iarray A) else (Suc i, Gauss_Jordan_in_ij_iarrays (matrix_to_iarray A) i k))
[PROOF STEP]
unfolding vec_to_iarray_column[of "from_nat k" A, unfolded to_nat_from_nat_id[OF k[unfolded ncols_def]], symmetric]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. matrix_to_iarray (snd (if (\<forall>m\<ge>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a)) \<or> i = nrows A then (i, A) else (i + 1, Gauss_Jordan_in_ij A (mod_type_class.from_nat i) (mod_type_class.from_nat k)))) = snd (if vector_all_zero_from_index (i, vec_to_iarray (column (mod_type_class.from_nat k) A)) \<or> i = nrows_iarray (matrix_to_iarray A) then (i, matrix_to_iarray A) else (Suc i, Gauss_Jordan_in_ij_iarrays (matrix_to_iarray A) i k))
[PROOF STEP]
unfolding matrix_vector_all_zero_from_index[symmetric, of "from_nat i::'rows" "from_nat k::'columns", symmetric]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. matrix_to_iarray (snd (if vector_all_zero_from_index (mod_type_class.to_nat (mod_type_class.from_nat i), vec_to_iarray (column (mod_type_class.from_nat k) A)) \<or> i = nrows A then (i, A) else (i + 1, Gauss_Jordan_in_ij A (mod_type_class.from_nat i) (mod_type_class.from_nat k)))) = snd (if vector_all_zero_from_index (i, vec_to_iarray (column (mod_type_class.from_nat k) A)) \<or> i = nrows_iarray (matrix_to_iarray A) then (i, matrix_to_iarray A) else (Suc i, Gauss_Jordan_in_ij_iarrays (matrix_to_iarray A) i k))
[PROOF STEP]
using matrix_to_iarray_Gauss_Jordan_in_ij[of "from_nat i::'rows" "from_nat k::'columns"]
[PROOF STATE]
proof (prove)
using this:
\<not> vector_all_zero_from_index (mod_type_class.to_nat (mod_type_class.from_nat i), vec_to_iarray (column (mod_type_class.from_nat k) ?A)) \<Longrightarrow> matrix_to_iarray (Gauss_Jordan_in_ij ?A (mod_type_class.from_nat i) (mod_type_class.from_nat k)) = Gauss_Jordan_in_ij_iarrays (matrix_to_iarray ?A) (mod_type_class.to_nat (mod_type_class.from_nat i)) (mod_type_class.to_nat (mod_type_class.from_nat k))

goal (1 subgoal):
 1. matrix_to_iarray (snd (if vector_all_zero_from_index (mod_type_class.to_nat (mod_type_class.from_nat i), vec_to_iarray (column (mod_type_class.from_nat k) A)) \<or> i = nrows A then (i, A) else (i + 1, Gauss_Jordan_in_ij A (mod_type_class.from_nat i) (mod_type_class.from_nat k)))) = snd (if vector_all_zero_from_index (i, vec_to_iarray (column (mod_type_class.from_nat k) A)) \<or> i = nrows_iarray (matrix_to_iarray A) then (i, matrix_to_iarray A) else (Suc i, Gauss_Jordan_in_ij_iarrays (matrix_to_iarray A) i k))
[PROOF STEP]
unfolding to_nat_from_nat_id[OF True[unfolded nrows_def]] to_nat_from_nat_id[OF k[unfolded ncols_def]]
[PROOF STATE]
proof (prove)
using this:
\<not> vector_all_zero_from_index (i, vec_to_iarray (column (mod_type_class.from_nat k) ?A)) \<Longrightarrow> matrix_to_iarray (Gauss_Jordan_in_ij ?A (mod_type_class.from_nat i) (mod_type_class.from_nat k)) = Gauss_Jordan_in_ij_iarrays (matrix_to_iarray ?A) i k

goal (1 subgoal):
 1. matrix_to_iarray (snd (if vector_all_zero_from_index (i, vec_to_iarray (column (mod_type_class.from_nat k) A)) \<or> i = nrows A then (i, A) else (i + 1, Gauss_Jordan_in_ij A (mod_type_class.from_nat i) (mod_type_class.from_nat k)))) = snd (if vector_all_zero_from_index (i, vec_to_iarray (column (mod_type_class.from_nat k) A)) \<or> i = nrows_iarray (matrix_to_iarray A) then (i, matrix_to_iarray A) else (Suc i, Gauss_Jordan_in_ij_iarrays (matrix_to_iarray A) i k))
[PROOF STEP]
unfolding matrix_to_iarray_nrows
[PROOF STATE]
proof (prove)
using this:
\<not> vector_all_zero_from_index (i, vec_to_iarray (column (mod_type_class.from_nat k) ?A)) \<Longrightarrow> matrix_to_iarray (Gauss_Jordan_in_ij ?A (mod_type_class.from_nat i) (mod_type_class.from_nat k)) = Gauss_Jordan_in_ij_iarrays (matrix_to_iarray ?A) i k

goal (1 subgoal):
 1. matrix_to_iarray (snd (if vector_all_zero_from_index (i, vec_to_iarray (column (mod_type_class.from_nat k) A)) \<or> i = nrows_iarray (matrix_to_iarray A) then (i, A) else (i + 1, Gauss_Jordan_in_ij A (mod_type_class.from_nat i) (mod_type_class.from_nat k)))) = snd (if vector_all_zero_from_index (i, vec_to_iarray (column (mod_type_class.from_nat k) A)) \<or> i = nrows_iarray (matrix_to_iarray A) then (i, matrix_to_iarray A) else (Suc i, Gauss_Jordan_in_ij_iarrays (matrix_to_iarray A) i k))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
matrix_to_iarray (snd (Gauss_Jordan_column_k (i, A) k)) = snd (Gauss_Jordan_column_k_iarrays (i, matrix_to_iarray A) k)

goal (1 subgoal):
 1. \<not> i < nrows A \<Longrightarrow> matrix_to_iarray (snd (Gauss_Jordan_column_k (i, A) k)) = snd (Gauss_Jordan_column_k_iarrays (i, matrix_to_iarray A) k)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> i < nrows A \<Longrightarrow> matrix_to_iarray (snd (Gauss_Jordan_column_k (i, A) k)) = snd (Gauss_Jordan_column_k_iarrays (i, matrix_to_iarray A) k)
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> i < nrows A

goal (1 subgoal):
 1. \<not> i < nrows A \<Longrightarrow> matrix_to_iarray (snd (Gauss_Jordan_column_k (i, A) k)) = snd (Gauss_Jordan_column_k_iarrays (i, matrix_to_iarray A) k)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. matrix_to_iarray (snd (Gauss_Jordan_column_k (i, A) k)) = snd (Gauss_Jordan_column_k_iarrays (i, matrix_to_iarray A) k)
[PROOF STEP]
using assms False
[PROOF STATE]
proof (prove)
using this:
k < ncols A
i \<le> nrows A
\<not> i < nrows A

goal (1 subgoal):
 1. matrix_to_iarray (snd (Gauss_Jordan_column_k (i, A) k)) = snd (Gauss_Jordan_column_k_iarrays (i, matrix_to_iarray A) k)
[PROOF STEP]
unfolding Gauss_Jordan_column_k_def Let_def Gauss_Jordan_column_k_iarrays_def
[PROOF STATE]
proof (prove)
using this:
k < ncols A
i \<le> nrows A
\<not> i < nrows A

goal (1 subgoal):
 1. matrix_to_iarray (snd (if (\<forall>m\<ge>mod_type_class.from_nat (fst (i, A)). snd (i, A) $ m $ mod_type_class.from_nat k = (0::'a)) \<or> fst (i, A) = nrows (snd (i, A)) then (fst (i, A), snd (i, A)) else (fst (i, A) + 1, Gauss_Jordan_in_ij (snd (i, A)) (mod_type_class.from_nat (fst (i, A))) (mod_type_class.from_nat k)))) = snd (if vector_all_zero_from_index (fst (i, matrix_to_iarray A), column_iarray k (snd (i, matrix_to_iarray A))) \<or> fst (i, matrix_to_iarray A) = nrows_iarray (snd (i, matrix_to_iarray A)) then (fst (i, matrix_to_iarray A), snd (i, matrix_to_iarray A)) else (Suc (fst (i, matrix_to_iarray A)), Gauss_Jordan_in_ij_iarrays (snd (i, matrix_to_iarray A)) (fst (i, matrix_to_iarray A)) k))
[PROOF STEP]
by (auto simp add: matrix_to_iarray_nrows)
[PROOF STATE]
proof (state)
this:
matrix_to_iarray (snd (Gauss_Jordan_column_k (i, A) k)) = snd (Gauss_Jordan_column_k_iarrays (i, matrix_to_iarray A) k)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma count_derangements:
  "real (count_derangements n) = fact n * (\<Sum>k \<in> {0..n}. (-1) ^ k / fact k)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real (count_derangements n) = fact n * (\<Sum>k = 0..n. (- 1) ^ k / fact k)
[PROOF STEP]
proof (induct n rule: count_derangements.induct)
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. real (count_derangements 0) = fact 0 * (\<Sum>k = 0..0. (- 1) ^ k / fact k)
 2. real (count_derangements (Suc 0)) = fact (Suc 0) * (\<Sum>k = 0..Suc 0. (- 1) ^ k / fact k)
 3. \<And>n. \<lbrakk>real (count_derangements (Suc n)) = fact (Suc n) * (\<Sum>k = 0..Suc n. (- 1) ^ k / fact k); real (count_derangements n) = fact n * (\<Sum>k = 0..n. (- 1) ^ k / fact k)\<rbrakk> \<Longrightarrow> real (count_derangements (Suc (Suc n))) = fact (Suc (Suc n)) * (\<Sum>k = 0..Suc (Suc n). (- 1) ^ k / fact k)
[PROOF STEP]
case (3 n)
[PROOF STATE]
proof (state)
this:
real (count_derangements (Suc n)) = fact (Suc n) * (\<Sum>k = 0..Suc n. (- 1) ^ k / fact k)
real (count_derangements n) = fact n * (\<Sum>k = 0..n. (- 1) ^ k / fact k)

goal (3 subgoals):
 1. real (count_derangements 0) = fact 0 * (\<Sum>k = 0..0. (- 1) ^ k / fact k)
 2. real (count_derangements (Suc 0)) = fact (Suc 0) * (\<Sum>k = 0..Suc 0. (- 1) ^ k / fact k)
 3. \<And>n. \<lbrakk>real (count_derangements (Suc n)) = fact (Suc n) * (\<Sum>k = 0..Suc n. (- 1) ^ k / fact k); real (count_derangements n) = fact n * (\<Sum>k = 0..n. (- 1) ^ k / fact k)\<rbrakk> \<Longrightarrow> real (count_derangements (Suc (Suc n))) = fact (Suc (Suc n)) * (\<Sum>k = 0..Suc (Suc n). (- 1) ^ k / fact k)
[PROOF STEP]
let ?f = "\<lambda>n. fact n * (\<Sum>k = 0..n. (- 1) ^ k / fact k)"
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. real (count_derangements 0) = fact 0 * (\<Sum>k = 0..0. (- 1) ^ k / fact k)
 2. real (count_derangements (Suc 0)) = fact (Suc 0) * (\<Sum>k = 0..Suc 0. (- 1) ^ k / fact k)
 3. \<And>n. \<lbrakk>real (count_derangements (Suc n)) = fact (Suc n) * (\<Sum>k = 0..Suc n. (- 1) ^ k / fact k); real (count_derangements n) = fact n * (\<Sum>k = 0..n. (- 1) ^ k / fact k)\<rbrakk> \<Longrightarrow> real (count_derangements (Suc (Suc n))) = fact (Suc (Suc n)) * (\<Sum>k = 0..Suc (Suc n). (- 1) ^ k / fact k)
[PROOF STEP]
have "real (count_derangements (Suc (Suc n))) = (n + 1) * (count_derangements (n + 1) + count_derangements n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real (count_derangements (Suc (Suc n))) = real ((n + 1) * (count_derangements (n + 1) + count_derangements n))
[PROOF STEP]
unfolding count_derangements.simps
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real ((n + 1) * (count_derangements (Suc n) + count_derangements n)) = real ((n + 1) * (count_derangements (n + 1) + count_derangements n))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
real (count_derangements (Suc (Suc n))) = real ((n + 1) * (count_derangements (n + 1) + count_derangements n))

goal (3 subgoals):
 1. real (count_derangements 0) = fact 0 * (\<Sum>k = 0..0. (- 1) ^ k / fact k)
 2. real (count_derangements (Suc 0)) = fact (Suc 0) * (\<Sum>k = 0..Suc 0. (- 1) ^ k / fact k)
 3. \<And>n. \<lbrakk>real (count_derangements (Suc n)) = fact (Suc n) * (\<Sum>k = 0..Suc n. (- 1) ^ k / fact k); real (count_derangements n) = fact n * (\<Sum>k = 0..n. (- 1) ^ k / fact k)\<rbrakk> \<Longrightarrow> real (count_derangements (Suc (Suc n))) = fact (Suc (Suc n)) * (\<Sum>k = 0..Suc (Suc n). (- 1) ^ k / fact k)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
real (count_derangements (Suc (Suc n))) = real ((n + 1) * (count_derangements (n + 1) + count_derangements n))

goal (3 subgoals):
 1. real (count_derangements 0) = fact 0 * (\<Sum>k = 0..0. (- 1) ^ k / fact k)
 2. real (count_derangements (Suc 0)) = fact (Suc 0) * (\<Sum>k = 0..Suc 0. (- 1) ^ k / fact k)
 3. \<And>n. \<lbrakk>real (count_derangements (Suc n)) = fact (Suc n) * (\<Sum>k = 0..Suc n. (- 1) ^ k / fact k); real (count_derangements n) = fact n * (\<Sum>k = 0..n. (- 1) ^ k / fact k)\<rbrakk> \<Longrightarrow> real (count_derangements (Suc (Suc n))) = fact (Suc (Suc n)) * (\<Sum>k = 0..Suc (Suc n). (- 1) ^ k / fact k)
[PROOF STEP]
have "... = real (n + 1) * (real (count_derangements (n + 1)) + real (count_derangements n))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real ((n + 1) * (count_derangements (n + 1) + count_derangements n)) = real (n + 1) * (real (count_derangements (n + 1)) + real (count_derangements n))
[PROOF STEP]
by (simp only: of_nat_mult of_nat_add)
[PROOF STATE]
proof (state)
this:
real ((n + 1) * (count_derangements (n + 1) + count_derangements n)) = real (n + 1) * (real (count_derangements (n + 1)) + real (count_derangements n))

goal (3 subgoals):
 1. real (count_derangements 0) = fact 0 * (\<Sum>k = 0..0. (- 1) ^ k / fact k)
 2. real (count_derangements (Suc 0)) = fact (Suc 0) * (\<Sum>k = 0..Suc 0. (- 1) ^ k / fact k)
 3. \<And>n. \<lbrakk>real (count_derangements (Suc n)) = fact (Suc n) * (\<Sum>k = 0..Suc n. (- 1) ^ k / fact k); real (count_derangements n) = fact n * (\<Sum>k = 0..n. (- 1) ^ k / fact k)\<rbrakk> \<Longrightarrow> real (count_derangements (Suc (Suc n))) = fact (Suc (Suc n)) * (\<Sum>k = 0..Suc (Suc n). (- 1) ^ k / fact k)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
real ((n + 1) * (count_derangements (n + 1) + count_derangements n)) = real (n + 1) * (real (count_derangements (n + 1)) + real (count_derangements n))

goal (3 subgoals):
 1. real (count_derangements 0) = fact 0 * (\<Sum>k = 0..0. (- 1) ^ k / fact k)
 2. real (count_derangements (Suc 0)) = fact (Suc 0) * (\<Sum>k = 0..Suc 0. (- 1) ^ k / fact k)
 3. \<And>n. \<lbrakk>real (count_derangements (Suc n)) = fact (Suc n) * (\<Sum>k = 0..Suc n. (- 1) ^ k / fact k); real (count_derangements n) = fact n * (\<Sum>k = 0..n. (- 1) ^ k / fact k)\<rbrakk> \<Longrightarrow> real (count_derangements (Suc (Suc n))) = fact (Suc (Suc n)) * (\<Sum>k = 0..Suc (Suc n). (- 1) ^ k / fact k)
[PROOF STEP]
have "... = (n + 1) * (?f (n + 1) + ?f n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real (n + 1) * (real (count_derangements (n + 1)) + real (count_derangements n)) = real (n + 1) * (fact (n + 1) * (\<Sum>k = 0..n + 1. (- 1) ^ k / fact k) + fact n * (\<Sum>k = 0..n. (- 1) ^ k / fact k))
[PROOF STEP]
unfolding 3(2) 3(1)[unfolded Suc_eq_plus1]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real (n + 1) * (fact (n + 1) * (\<Sum>k = 0..n + 1. (- 1) ^ k / fact k) + fact n * (\<Sum>k = 0..n. (- 1) ^ k / fact k)) = real (n + 1) * (fact (n + 1) * (\<Sum>k = 0..n + 1. (- 1) ^ k / fact k) + fact n * (\<Sum>k = 0..n. (- 1) ^ k / fact k))
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
real (n + 1) * (real (count_derangements (n + 1)) + real (count_derangements n)) = real (n + 1) * (fact (n + 1) * (\<Sum>k = 0..n + 1. (- 1) ^ k / fact k) + fact n * (\<Sum>k = 0..n. (- 1) ^ k / fact k))

goal (3 subgoals):
 1. real (count_derangements 0) = fact 0 * (\<Sum>k = 0..0. (- 1) ^ k / fact k)
 2. real (count_derangements (Suc 0)) = fact (Suc 0) * (\<Sum>k = 0..Suc 0. (- 1) ^ k / fact k)
 3. \<And>n. \<lbrakk>real (count_derangements (Suc n)) = fact (Suc n) * (\<Sum>k = 0..Suc n. (- 1) ^ k / fact k); real (count_derangements n) = fact n * (\<Sum>k = 0..n. (- 1) ^ k / fact k)\<rbrakk> \<Longrightarrow> real (count_derangements (Suc (Suc n))) = fact (Suc (Suc n)) * (\<Sum>k = 0..Suc (Suc n). (- 1) ^ k / fact k)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
real (n + 1) * (real (count_derangements (n + 1)) + real (count_derangements n)) = real (n + 1) * (fact (n + 1) * (\<Sum>k = 0..n + 1. (- 1) ^ k / fact k) + fact n * (\<Sum>k = 0..n. (- 1) ^ k / fact k))

goal (3 subgoals):
 1. real (count_derangements 0) = fact 0 * (\<Sum>k = 0..0. (- 1) ^ k / fact k)
 2. real (count_derangements (Suc 0)) = fact (Suc 0) * (\<Sum>k = 0..Suc 0. (- 1) ^ k / fact k)
 3. \<And>n. \<lbrakk>real (count_derangements (Suc n)) = fact (Suc n) * (\<Sum>k = 0..Suc n. (- 1) ^ k / fact k); real (count_derangements n) = fact n * (\<Sum>k = 0..n. (- 1) ^ k / fact k)\<rbrakk> \<Longrightarrow> real (count_derangements (Suc (Suc n))) = fact (Suc (Suc n)) * (\<Sum>k = 0..Suc (Suc n). (- 1) ^ k / fact k)
[PROOF STEP]
have "(n + 1) * (?f (n + 1) + ?f n) = ?f (n + 2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real (n + 1) * (fact (n + 1) * (\<Sum>k = 0..n + 1. (- 1) ^ k / fact k) + fact n * (\<Sum>k = 0..n. (- 1) ^ k / fact k)) = fact (n + 2) * (\<Sum>k = 0..n + 2. (- 1) ^ k / fact k)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. real (n + 1) * (fact (n + 1) * (\<Sum>k = 0..n + 1. (- 1) ^ k / fact k) + fact n * (\<Sum>k = 0..n. (- 1) ^ k / fact k)) = fact (n + 2) * (\<Sum>k = 0..n + 2. (- 1) ^ k / fact k)
[PROOF STEP]
define f where "f n = ((fact n) :: real) * (\<Sum>k = 0..n. (- 1) ^ k / fact k)" for n
[PROOF STATE]
proof (state)
this:
f ?n = fact ?n * (\<Sum>k = 0..?n. (- 1) ^ k / fact k)

goal (1 subgoal):
 1. real (n + 1) * (fact (n + 1) * (\<Sum>k = 0..n + 1. (- 1) ^ k / fact k) + fact n * (\<Sum>k = 0..n. (- 1) ^ k / fact k)) = fact (n + 2) * (\<Sum>k = 0..n + 2. (- 1) ^ k / fact k)
[PROOF STEP]
have f_eq: "\<And>n. f (n + 1) = (n + 1) * f n + (- 1) ^ (n + 1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>n. f (n + 1) = (real n + 1) * f n + (- 1) ^ (n + 1)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n. f (n + 1) = (real n + 1) * f n + (- 1) ^ (n + 1)
[PROOF STEP]
fix n
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n. f (n + 1) = (real n + 1) * f n + (- 1) ^ (n + 1)
[PROOF STEP]
have "?f (n + 1) = (n + 1) * fact n * (\<Sum>k = 0..n. (- 1) ^ k / fact k) + fact (n + 1) * ((- 1) ^ (n + 1) / fact (n + 1))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fact (n + 1) * (\<Sum>k = 0..n + 1. (- 1) ^ k / fact k) = real ((n + 1) * fact n) * (\<Sum>k = 0..n. (- 1) ^ k / fact k) + fact (n + 1) * ((- 1) ^ (n + 1) / fact (n + 1))
[PROOF STEP]
by (simp add: field_simps)
[PROOF STATE]
proof (state)
this:
fact (n + 1) * (\<Sum>k = 0..n + 1. (- 1) ^ k / fact k) = real ((n + 1) * fact n) * (\<Sum>k = 0..n. (- 1) ^ k / fact k) + fact (n + 1) * ((- 1) ^ (n + 1) / fact (n + 1))

goal (1 subgoal):
 1. \<And>n. f (n + 1) = (real n + 1) * f n + (- 1) ^ (n + 1)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
fact (n + 1) * (\<Sum>k = 0..n + 1. (- 1) ^ k / fact k) = real ((n + 1) * fact n) * (\<Sum>k = 0..n. (- 1) ^ k / fact k) + fact (n + 1) * ((- 1) ^ (n + 1) / fact (n + 1))

goal (1 subgoal):
 1. \<And>n. f (n + 1) = (real n + 1) * f n + (- 1) ^ (n + 1)
[PROOF STEP]
have "... = (n + 1) * ?f n + (- 1) ^ (n + 1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real ((n + 1) * fact n) * (\<Sum>k = 0..n. (- 1) ^ k / fact k) + fact (n + 1) * ((- 1) ^ (n + 1) / fact (n + 1)) = real (n + 1) * (fact n * (\<Sum>k = 0..n. (- 1) ^ k / fact k)) + (- 1) ^ (n + 1)
[PROOF STEP]
by (simp del: One_nat_def)
[PROOF STATE]
proof (state)
this:
real ((n + 1) * fact n) * (\<Sum>k = 0..n. (- 1) ^ k / fact k) + fact (n + 1) * ((- 1) ^ (n + 1) / fact (n + 1)) = real (n + 1) * (fact n * (\<Sum>k = 0..n. (- 1) ^ k / fact k)) + (- 1) ^ (n + 1)

goal (1 subgoal):
 1. \<And>n. f (n + 1) = (real n + 1) * f n + (- 1) ^ (n + 1)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
fact (n + 1) * (\<Sum>k = 0..n + 1. (- 1) ^ k / fact k) = real (n + 1) * (fact n * (\<Sum>k = 0..n. (- 1) ^ k / fact k)) + (- 1) ^ (n + 1)
[PROOF STEP]
show "?thesis n"
[PROOF STATE]
proof (prove)
using this:
fact (n + 1) * (\<Sum>k = 0..n + 1. (- 1) ^ k / fact k) = real (n + 1) * (fact n * (\<Sum>k = 0..n. (- 1) ^ k / fact k)) + (- 1) ^ (n + 1)

goal (1 subgoal):
 1. f (n + 1) = (real n + 1) * f n + (- 1) ^ (n + 1)
[PROOF STEP]
unfolding f_def
[PROOF STATE]
proof (prove)
using this:
fact (n + 1) * (\<Sum>k = 0..n + 1. (- 1) ^ k / fact k) = real (n + 1) * (fact n * (\<Sum>k = 0..n. (- 1) ^ k / fact k)) + (- 1) ^ (n + 1)

goal (1 subgoal):
 1. fact (n + 1) * (\<Sum>k = 0..n + 1. (- 1) ^ k / fact k) = (real n + 1) * (fact n * (\<Sum>k = 0..n. (- 1) ^ k / fact k)) + (- 1) ^ (n + 1)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
f (n + 1) = (real n + 1) * f n + (- 1) ^ (n + 1)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
f (?n1 + 1) = (real ?n1 + 1) * f ?n1 + (- 1) ^ (?n1 + 1)

goal (1 subgoal):
 1. real (n + 1) * (fact (n + 1) * (\<Sum>k = 0..n + 1. (- 1) ^ k / fact k) + fact n * (\<Sum>k = 0..n. (- 1) ^ k / fact k)) = fact (n + 2) * (\<Sum>k = 0..n + 2. (- 1) ^ k / fact k)
[PROOF STEP]
from this
[PROOF STATE]
proof (chain)
picking this:
f (?n1 + 1) = (real ?n1 + 1) * f ?n1 + (- 1) ^ (?n1 + 1)
[PROOF STEP]
have f_eq': "\<And> n. (n + 1) * f n = f (n + 1) + (- 1) ^ n"
[PROOF STATE]
proof (prove)
using this:
f (?n1 + 1) = (real ?n1 + 1) * f ?n1 + (- 1) ^ (?n1 + 1)

goal (1 subgoal):
 1. \<And>n. (real n + 1) * f n = f (n + 1) + (- 1) ^ n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(real ?n1 + 1) * f ?n1 = f (?n1 + 1) + (- 1) ^ ?n1

goal (1 subgoal):
 1. real (n + 1) * (fact (n + 1) * (\<Sum>k = 0..n + 1. (- 1) ^ k / fact k) + fact n * (\<Sum>k = 0..n. (- 1) ^ k / fact k)) = fact (n + 2) * (\<Sum>k = 0..n + 2. (- 1) ^ k / fact k)
[PROOF STEP]
from f_eq'[of n]
[PROOF STATE]
proof (chain)
picking this:
(real n + 1) * f n = f (n + 1) + (- 1) ^ n
[PROOF STEP]
have "(n + 1) * (f (n + 1) + f n) = ((n + 1) * f (n + 1)) + f (n + 1) + (- 1) ^ n"
[PROOF STATE]
proof (prove)
using this:
(real n + 1) * f n = f (n + 1) + (- 1) ^ n

goal (1 subgoal):
 1. real (n + 1) * (f (n + 1) + f n) = real (n + 1) * f (n + 1) + f (n + 1) + (- 1) ^ n
[PROOF STEP]
by (simp only: distrib_left of_nat_add of_nat_1)
[PROOF STATE]
proof (state)
this:
real (n + 1) * (f (n + 1) + f n) = real (n + 1) * f (n + 1) + f (n + 1) + (- 1) ^ n

goal (1 subgoal):
 1. real (n + 1) * (fact (n + 1) * (\<Sum>k = 0..n + 1. (- 1) ^ k / fact k) + fact n * (\<Sum>k = 0..n. (- 1) ^ k / fact k)) = fact (n + 2) * (\<Sum>k = 0..n + 2. (- 1) ^ k / fact k)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
real (n + 1) * (f (n + 1) + f n) = real (n + 1) * f (n + 1) + f (n + 1) + (- 1) ^ n

goal (1 subgoal):
 1. real (n + 1) * (fact (n + 1) * (\<Sum>k = 0..n + 1. (- 1) ^ k / fact k) + fact n * (\<Sum>k = 0..n. (- 1) ^ k / fact k)) = fact (n + 2) * (\<Sum>k = 0..n + 2. (- 1) ^ k / fact k)
[PROOF STEP]
have "... = (n + 2) * f (n + 1) + (- 1) ^ (n + 2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real (n + 1) * f (n + 1) + f (n + 1) + (- 1) ^ n = real (n + 2) * f (n + 1) + (- 1) ^ (n + 2)
[PROOF STEP]
by (simp del: One_nat_def add_2_eq_Suc' add: algebra_simps) simp
[PROOF STATE]
proof (state)
this:
real (n + 1) * f (n + 1) + f (n + 1) + (- 1) ^ n = real (n + 2) * f (n + 1) + (- 1) ^ (n + 2)

goal (1 subgoal):
 1. real (n + 1) * (fact (n + 1) * (\<Sum>k = 0..n + 1. (- 1) ^ k / fact k) + fact n * (\<Sum>k = 0..n. (- 1) ^ k / fact k)) = fact (n + 2) * (\<Sum>k = 0..n + 2. (- 1) ^ k / fact k)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
real (n + 1) * f (n + 1) + f (n + 1) + (- 1) ^ n = real (n + 2) * f (n + 1) + (- 1) ^ (n + 2)

goal (1 subgoal):
 1. real (n + 1) * (fact (n + 1) * (\<Sum>k = 0..n + 1. (- 1) ^ k / fact k) + fact n * (\<Sum>k = 0..n. (- 1) ^ k / fact k)) = fact (n + 2) * (\<Sum>k = 0..n + 2. (- 1) ^ k / fact k)
[PROOF STEP]
from f_eq[of "n + 1"]
[PROOF STATE]
proof (chain)
picking this:
f (n + 1 + 1) = (real (n + 1) + 1) * f (n + 1) + (- 1) ^ (n + 1 + 1)
[PROOF STEP]
have "... = f (n + 2)"
[PROOF STATE]
proof (prove)
using this:
f (n + 1 + 1) = (real (n + 1) + 1) * f (n + 1) + (- 1) ^ (n + 1 + 1)

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

goal (1 subgoal):
 1. real (n + 1) * (fact (n + 1) * (\<Sum>k = 0..n + 1. (- 1) ^ k / fact k) + fact n * (\<Sum>k = 0..n. (- 1) ^ k / fact k)) = fact (n + 2) * (\<Sum>k = 0..n + 2. (- 1) ^ k / fact k)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
real (n + 1) * (f (n + 1) + f n) = f (n + 2)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
real (n + 1) * (f (n + 1) + f n) = f (n + 2)

goal (1 subgoal):
 1. real (n + 1) * (fact (n + 1) * (\<Sum>k = 0..n + 1. (- 1) ^ k / fact k) + fact n * (\<Sum>k = 0..n. (- 1) ^ k / fact k)) = fact (n + 2) * (\<Sum>k = 0..n + 2. (- 1) ^ k / fact k)
[PROOF STEP]
unfolding f_def
[PROOF STATE]
proof (prove)
using this:
real (n + 1) * (fact (n + 1) * (\<Sum>k = 0..n + 1. (- 1) ^ k / fact k) + fact n * (\<Sum>k = 0..n. (- 1) ^ k / fact k)) = fact (n + 2) * (\<Sum>k = 0..n + 2. (- 1) ^ k / fact k)

goal (1 subgoal):
 1. real (n + 1) * (fact (n + 1) * (\<Sum>k = 0..n + 1. (- 1) ^ k / fact k) + fact n * (\<Sum>k = 0..n. (- 1) ^ k / fact k)) = fact (n + 2) * (\<Sum>k = 0..n + 2. (- 1) ^ k / fact k)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
real (n + 1) * (fact (n + 1) * (\<Sum>k = 0..n + 1. (- 1) ^ k / fact k) + fact n * (\<Sum>k = 0..n. (- 1) ^ k / fact k)) = fact (n + 2) * (\<Sum>k = 0..n + 2. (- 1) ^ k / fact k)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
real (n + 1) * (fact (n + 1) * (\<Sum>k = 0..n + 1. (- 1) ^ k / fact k) + fact n * (\<Sum>k = 0..n. (- 1) ^ k / fact k)) = fact (n + 2) * (\<Sum>k = 0..n + 2. (- 1) ^ k / fact k)

goal (3 subgoals):
 1. real (count_derangements 0) = fact 0 * (\<Sum>k = 0..0. (- 1) ^ k / fact k)
 2. real (count_derangements (Suc 0)) = fact (Suc 0) * (\<Sum>k = 0..Suc 0. (- 1) ^ k / fact k)
 3. \<And>n. \<lbrakk>real (count_derangements (Suc n)) = fact (Suc n) * (\<Sum>k = 0..Suc n. (- 1) ^ k / fact k); real (count_derangements n) = fact n * (\<Sum>k = 0..n. (- 1) ^ k / fact k)\<rbrakk> \<Longrightarrow> real (count_derangements (Suc (Suc n))) = fact (Suc (Suc n)) * (\<Sum>k = 0..Suc (Suc n). (- 1) ^ k / fact k)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
real (count_derangements (Suc (Suc n))) = fact (n + 2) * (\<Sum>k = 0..n + 2. (- 1) ^ k / fact k)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
real (count_derangements (Suc (Suc n))) = fact (n + 2) * (\<Sum>k = 0..n + 2. (- 1) ^ k / fact k)

goal (1 subgoal):
 1. real (count_derangements (Suc (Suc n))) = fact (Suc (Suc n)) * (\<Sum>k = 0..Suc (Suc n). (- 1) ^ k / fact k)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
real (count_derangements (Suc (Suc n))) = fact (Suc (Suc n)) * (\<Sum>k = 0..Suc (Suc n). (- 1) ^ k / fact k)

goal (2 subgoals):
 1. real (count_derangements 0) = fact 0 * (\<Sum>k = 0..0. (- 1) ^ k / fact k)
 2. real (count_derangements (Suc 0)) = fact (Suc 0) * (\<Sum>k = 0..Suc 0. (- 1) ^ k / fact k)
[PROOF STEP]
qed (auto)


[STATEMENT]
lemma epath_effect:
  assumes \<open>epath steps\<close> \<open>shd steps = ((A, z), r)\<close>
  shows \<open>\<exists>B z' r'. (B, z') |\<in>| effect r (A, z) \<and> shd (stl steps) = ((B, z'), r') \<and>
          (B = remdups (A @ subterms z @ subterms z'))\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>B z' r'. (B, z') |\<in>| effect r (A, z) \<and> shd (stl steps) = ((B, z'), r') \<and> B = remdups (A @ subterms z @ subterms z')
[PROOF STEP]
using assms epath_eff effect_tms
[PROOF STATE]
proof (prove)
using this:
epath steps
shd steps = ((A, z), r)
\<lbrakk>epath ?steps; effStep (shd ?steps) ?ss\<rbrakk> \<Longrightarrow> fst (shd (stl ?steps)) |\<in>| ?ss
(?B, ?z') |\<in>| effect ?r (?A, ?z) \<Longrightarrow> ?B = remdups (?A @ subterms ?z @ subterms ?z')

goal (1 subgoal):
 1. \<exists>B z' r'. (B, z') |\<in>| effect r (A, z) \<and> shd (stl steps) = ((B, z'), r') \<and> B = remdups (A @ subterms z @ subterms z')
[PROOF STEP]
by (metis (mono_tags, lifting) eff_def fst_conv prod.collapse snd_conv)


[STATEMENT]
lemma top_injective_inf_complement_2:
  assumes "injective x"
  shows "(x\<^sup>T \<sqinter> y) * top \<sqinter> (x\<^sup>T \<sqinter> -y) * top = bot"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (x\<^sup>T \<sqinter> y) * top \<sqinter> (x\<^sup>T \<sqinter> - y) * top = bot
[PROOF STEP]
by (smt assms top_injective_inf_complement conv_dist_comp conv_dist_inf conv_involutive conv_complement conv_top conv_bot)


[STATEMENT]
lemma Max_atLeastLessThan: "m < n \<Longrightarrow> Max {m..<n} = n - Suc 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. m < n \<Longrightarrow> Max {m..<n} = n - Suc 0
[PROOF STEP]
by (rule Max_equality[OF _ finite_atLeastLessThan], simp_all add: less_imp_le_pred)


[STATEMENT]
lemma zet_ext_eq: "(A = B) = (\<forall>x. zin x A = zin x B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (A = B) = (\<forall>x. zin x A = zin x B)
[PROOF STEP]
by (auto simp add: Rep_zet_inject[symmetric] zin_def)


[STATEMENT]
lemma fls_times_both_shifted_simp:
  fixes f g :: "'a::{comm_monoid_add, mult_zero} fls"
  shows "(fls_shift m f) * (fls_shift n g) = fls_shift (m+n) (f*g)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fls_shift m f * fls_shift n g = fls_shift (m + n) (f * g)
[PROOF STEP]
by    (simp add: fls_shifted_times_simps)


[STATEMENT]
lemma list_Reverse2 [simp]: "\<lbrakk>
  0 < size (Reverse2 current auxS big newS count);
  invar (Reverse2 current auxS big newS count)
\<rbrakk> \<Longrightarrow>
   fst (Current.pop current) # Small.list (Reverse2 (drop_first current) auxS big newS count) =
   Small.list (Reverse2 current auxS big newS count)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < size (Reverse2 current auxS big newS count); invar (Reverse2 current auxS big newS count)\<rbrakk> \<Longrightarrow> fst (Current.pop current) # Small.list (Reverse2 (drop_first current) auxS big newS count) = Small.list (Reverse2 current auxS big newS count)
[PROOF STEP]
by(induction current rule: Current.pop.induct)
    (auto simp: first_hd rev_take Suc_diff_le)


[STATEMENT]
lemma has_vector_derivative_transform_at:
  assumes "0 < d"
    and "\<forall>x'. dist x' x < d \<longrightarrow> f x' = g x'"
    and "(f has_vector_derivative f') (at x)"
  shows "(g has_vector_derivative f') (at x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (g has_vector_derivative f') (at x)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
0 < d
\<forall>x'. dist x' x < d \<longrightarrow> f x' = g x'
(f has_vector_derivative f') (at x)

goal (1 subgoal):
 1. (g has_vector_derivative f') (at x)
[PROOF STEP]
unfolding has_vector_derivative_def
[PROOF STATE]
proof (prove)
using this:
0 < d
\<forall>x'. dist x' x < d \<longrightarrow> f x' = g x'
(f has_derivative (\<lambda>x. x *\<^sub>R f')) (at x)

goal (1 subgoal):
 1. (g has_derivative (\<lambda>x. x *\<^sub>R f')) (at x)
[PROOF STEP]
by (rule has_derivative_transform_at)


[STATEMENT]
lemma depth_bt_map [simp]: "depth (bt_map f t) = depth t"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. depth (bt_map f t) = depth t
[PROOF STEP]
apply (induct t)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. depth (bt_map f Lf) = depth Lf
 2. \<And>x1 t1 t2. \<lbrakk>depth (bt_map f t1) = depth t1; depth (bt_map f t2) = depth t2\<rbrakk> \<Longrightarrow> depth (bt_map f (Br x1 t1 t2)) = depth (Br x1 t1 t2)
[PROOF STEP]
apply (metis bt_map.simps(1) depth.simps(1))
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x1 t1 t2. \<lbrakk>depth (bt_map f t1) = depth t1; depth (bt_map f t2) = depth t2\<rbrakk> \<Longrightarrow> depth (bt_map f (Br x1 t1 t2)) = depth (Br x1 t1 t2)
[PROOF STEP]
by simp


[STATEMENT]
lemma rule_sub_remark_7:
    assumes "\<And>v.[\<phi> \<^bold>\<equiv> (\<^bold>\<not>(\<^bold>\<not>\<phi>)) in v]"
        and "[\<^bold>\<box>(\<phi> \<^bold>\<rightarrow> \<phi>) in v]"
    shows "[\<^bold>\<box>((\<^bold>\<not>(\<^bold>\<not>\<phi>)) \<^bold>\<rightarrow> \<phi>) in v]"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [\<^bold>\<box>(\<^bold>\<not>\<^bold>\<not>\<phi> \<^bold>\<rightarrow> \<phi>) in v]
[PROOF STEP]
apply (insert assms)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<And>v. [\<phi> \<^bold>\<equiv> \<^bold>\<not>\<^bold>\<not>\<phi> in v]; [\<^bold>\<box>(\<phi> \<^bold>\<rightarrow> \<phi>) in v]\<rbrakk> \<Longrightarrow> [\<^bold>\<box>(\<^bold>\<not>\<^bold>\<not>\<phi> \<^bold>\<rightarrow> \<phi>) in v]
[PROOF STEP]
apply PLM_autosubst
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>\<And>v. [\<phi> \<^bold>\<equiv> \<^bold>\<not>\<^bold>\<not>\<phi> in v]; [\<^bold>\<box>(\<phi> \<^bold>\<rightarrow> \<phi>) in v]\<rbrakk> \<Longrightarrow> \<forall>v. [\<phi> \<^bold>\<equiv> \<^bold>\<not>\<^bold>\<not>\<phi> in v]
 2. \<lbrakk>\<And>v. [\<phi> \<^bold>\<equiv> \<^bold>\<not>\<^bold>\<not>\<phi> in v]; [\<^bold>\<box>(\<phi> \<^bold>\<rightarrow> \<phi>) in v]\<rbrakk> \<Longrightarrow> [\<^bold>\<box>(\<phi> \<^bold>\<rightarrow> \<phi>) in v]
[PROOF STEP]
by auto