[STATEMENT]
lemma invertible_fst_row_add_iterate_PA:
  fixes A::"'a::{ring_1}^'n^'m::{mod_type}"
  assumes n: "n<nrows A"
  and inv_P: "invertible P"
  shows "invertible (fst (row_add_iterate_PA (P,A) n i j))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. invertible (fst (row_add_iterate_PA (P, A) n i j))
[PROOF STEP]
using n inv_P
[PROOF STATE]
proof (prove)
using this:
n < nrows A
invertible P

goal (1 subgoal):
 1. invertible (fst (row_add_iterate_PA (P, A) n i j))
[PROOF STEP]
proof (induct n arbitrary: A P)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>A P. \<lbrakk>0 < nrows A; invertible P\<rbrakk> \<Longrightarrow> invertible (fst (row_add_iterate_PA (P, A) 0 i j))
 2. \<And>n A P. \<lbrakk>\<And>A P. \<lbrakk>n < nrows A; invertible P\<rbrakk> \<Longrightarrow> invertible (fst (row_add_iterate_PA (P, A) n i j)); Suc n < nrows A; invertible P\<rbrakk> \<Longrightarrow> invertible (fst (row_add_iterate_PA (P, A) (Suc n) i j))
[PROOF STEP]
case 0
[PROOF STATE]
proof (state)
this:
0 < nrows A
invertible P

goal (2 subgoals):
 1. \<And>A P. \<lbrakk>0 < nrows A; invertible P\<rbrakk> \<Longrightarrow> invertible (fst (row_add_iterate_PA (P, A) 0 i j))
 2. \<And>n A P. \<lbrakk>\<And>A P. \<lbrakk>n < nrows A; invertible P\<rbrakk> \<Longrightarrow> invertible (fst (row_add_iterate_PA (P, A) n i j)); Suc n < nrows A; invertible P\<rbrakk> \<Longrightarrow> invertible (fst (row_add_iterate_PA (P, A) (Suc n) i j))
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. invertible (fst (row_add_iterate_PA (P, A) 0 i j))
[PROOF STEP]
proof (unfold row_add_iterate_PA.simps, auto simp add: "0.prems")
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. i \<noteq> (0::'m) \<Longrightarrow> invertible (row_add P (0::'m) i (- A $ (0::'m) $ j))
[PROOF STEP]
assume i_not_0: "i \<noteq> 0"
[PROOF STATE]
proof (state)
this:
i \<noteq> (0::'m)

goal (1 subgoal):
 1. i \<noteq> (0::'m) \<Longrightarrow> invertible (row_add P (0::'m) i (- A $ (0::'m) $ j))
[PROOF STEP]
have "row_add P 0 i (- A $ 0 $ j) = row_add (mat 1) 0 i (- A $ 0 $ j) ** P"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. row_add P (0::'m) i (- A $ (0::'m) $ j) = row_add (mat (1::'a)) (0::'m) i (- A $ (0::'m) $ j) ** P
[PROOF STEP]
unfolding row_add_mat_1
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. row_add P (0::'m) i (- A $ (0::'m) $ j) = row_add P (0::'m) i (- A $ (0::'m) $ j)
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
row_add P (0::'m) i (- A $ (0::'m) $ j) = row_add (mat (1::'a)) (0::'m) i (- A $ (0::'m) $ j) ** P

goal (1 subgoal):
 1. i \<noteq> (0::'m) \<Longrightarrow> invertible (row_add P (0::'m) i (- A $ (0::'m) $ j))
[PROOF STEP]
show "invertible (row_add P 0 i (- A $ 0 $ j))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. invertible (row_add P (0::'m) i (- A $ (0::'m) $ j))
[PROOF STEP]
by (subst row_add_mat_1[symmetric], rule invertible_mult, auto simp add: invertible_row_add[of 0 i "(- A $ 0 $ j)"] i_not_0 "0.prems")
[PROOF STATE]
proof (state)
this:
invertible (row_add P (0::'m) i (- A $ (0::'m) $ j))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
invertible (fst (row_add_iterate_PA (P, A) 0 i j))

goal (1 subgoal):
 1. \<And>n A P. \<lbrakk>\<And>A P. \<lbrakk>n < nrows A; invertible P\<rbrakk> \<Longrightarrow> invertible (fst (row_add_iterate_PA (P, A) n i j)); Suc n < nrows A; invertible P\<rbrakk> \<Longrightarrow> invertible (fst (row_add_iterate_PA (P, A) (Suc n) i j))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n A P. \<lbrakk>\<And>A P. \<lbrakk>n < nrows A; invertible P\<rbrakk> \<Longrightarrow> invertible (fst (row_add_iterate_PA (P, A) n i j)); Suc n < nrows A; invertible P\<rbrakk> \<Longrightarrow> invertible (fst (row_add_iterate_PA (P, A) (Suc n) i j))
[PROOF STEP]
case (Suc n)
[PROOF STATE]
proof (state)
this:
\<lbrakk>n < nrows ?A; invertible ?P\<rbrakk> \<Longrightarrow> invertible (fst (row_add_iterate_PA (?P, ?A) n i j))
Suc n < nrows A
invertible P

goal (1 subgoal):
 1. \<And>n A P. \<lbrakk>\<And>A P. \<lbrakk>n < nrows A; invertible P\<rbrakk> \<Longrightarrow> invertible (fst (row_add_iterate_PA (P, A) n i j)); Suc n < nrows A; invertible P\<rbrakk> \<Longrightarrow> invertible (fst (row_add_iterate_PA (P, A) (Suc n) i j))
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. invertible (fst (row_add_iterate_PA (P, A) (Suc n) i j))
[PROOF STEP]
proof (cases "Suc n = to_nat i")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. Suc n = mod_type_class.to_nat i \<Longrightarrow> invertible (fst (row_add_iterate_PA (P, A) (Suc n) i j))
 2. Suc n \<noteq> mod_type_class.to_nat i \<Longrightarrow> invertible (fst (row_add_iterate_PA (P, A) (Suc n) i j))
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
Suc n = mod_type_class.to_nat i

goal (2 subgoals):
 1. Suc n = mod_type_class.to_nat i \<Longrightarrow> invertible (fst (row_add_iterate_PA (P, A) (Suc n) i j))
 2. Suc n \<noteq> mod_type_class.to_nat i \<Longrightarrow> invertible (fst (row_add_iterate_PA (P, A) (Suc n) i j))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. invertible (fst (row_add_iterate_PA (P, A) (Suc n) i j))
[PROOF STEP]
unfolding row_add_iterate_PA.simps if_P[OF True]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. invertible (fst (row_add_iterate_PA (P, A) n i j))
[PROOF STEP]
using Suc.hyps Suc.prems
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>n < nrows ?A; invertible ?P\<rbrakk> \<Longrightarrow> invertible (fst (row_add_iterate_PA (?P, ?A) n i j))
Suc n < nrows A
invertible P

goal (1 subgoal):
 1. invertible (fst (row_add_iterate_PA (P, A) n i j))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
invertible (fst (row_add_iterate_PA (P, A) (Suc n) i j))

goal (1 subgoal):
 1. Suc n \<noteq> mod_type_class.to_nat i \<Longrightarrow> invertible (fst (row_add_iterate_PA (P, A) (Suc n) i j))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. Suc n \<noteq> mod_type_class.to_nat i \<Longrightarrow> invertible (fst (row_add_iterate_PA (P, A) (Suc n) i j))
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
Suc n \<noteq> mod_type_class.to_nat i

goal (1 subgoal):
 1. Suc n \<noteq> mod_type_class.to_nat i \<Longrightarrow> invertible (fst (row_add_iterate_PA (P, A) (Suc n) i j))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. invertible (fst (row_add_iterate_PA (P, A) (Suc n) i j))
[PROOF STEP]
proof (unfold row_add_iterate_PA.simps if_not_P[OF False], rule Suc.hyps, unfold nrows_def)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. n < CARD('m)
 2. invertible (row_add P (mod_type_class.from_nat (Suc n)) i (- A $ mod_type_class.from_nat (Suc n) $ j))
[PROOF STEP]
show "n < CARD('m)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n < CARD('m)
[PROOF STEP]
using Suc.prems(1)
[PROOF STATE]
proof (prove)
using this:
Suc n < nrows A

goal (1 subgoal):
 1. n < CARD('m)
[PROOF STEP]
unfolding nrows_def
[PROOF STATE]
proof (prove)
using this:
Suc n < CARD('m)

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

goal (1 subgoal):
 1. invertible (row_add P (mod_type_class.from_nat (Suc n)) i (- A $ mod_type_class.from_nat (Suc n) $ j))
[PROOF STEP]
show "invertible (row_add P (from_nat (Suc n)) i (- A $ from_nat (Suc n) $ j))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. invertible (row_add P (mod_type_class.from_nat (Suc n)) i (- A $ mod_type_class.from_nat (Suc n) $ j))
[PROOF STEP]
proof (subst row_add_mat_1[symmetric], rule invertible_mult, rule invertible_row_add)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. mod_type_class.from_nat (Suc n) \<noteq> i
 2. invertible P
[PROOF STEP]
show "from_nat (Suc n) \<noteq> i"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mod_type_class.from_nat (Suc n) \<noteq> i
[PROOF STEP]
using False Suc.prems(1) from_nat_not_eq
[PROOF STATE]
proof (prove)
using this:
Suc n \<noteq> mod_type_class.to_nat i
Suc n < nrows A
\<lbrakk>?a \<noteq> mod_type_class.to_nat ?b; ?a < CARD(?'a)\<rbrakk> \<Longrightarrow> mod_type_class.from_nat ?a \<noteq> ?b

goal (1 subgoal):
 1. mod_type_class.from_nat (Suc n) \<noteq> i
[PROOF STEP]
unfolding nrows_def
[PROOF STATE]
proof (prove)
using this:
Suc n \<noteq> mod_type_class.to_nat i
Suc n < CARD('m)
\<lbrakk>?a \<noteq> mod_type_class.to_nat ?b; ?a < CARD(?'a)\<rbrakk> \<Longrightarrow> mod_type_class.from_nat ?a \<noteq> ?b

goal (1 subgoal):
 1. mod_type_class.from_nat (Suc n) \<noteq> i
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
mod_type_class.from_nat (Suc n) \<noteq> i

goal (1 subgoal):
 1. invertible P
[PROOF STEP]
show "invertible P"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. invertible P
[PROOF STEP]
using Suc.prems(2)
[PROOF STATE]
proof (prove)
using this:
invertible P

goal (1 subgoal):
 1. invertible P
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
invertible P

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
invertible (row_add P (mod_type_class.from_nat (Suc n)) i (- A $ mod_type_class.from_nat (Suc n) $ j))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
invertible (fst (row_add_iterate_PA (P, A) (Suc n) i j))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
invertible (fst (row_add_iterate_PA (P, A) (Suc n) i j))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma i_aggregate_assoc: "
  \<lbrakk> 0 < a; 0 < b;
    \<And>xs. length xs mod a = 0 \<Longrightarrow> ag (f_aggregate xs a ag) = ag xs \<rbrakk> \<Longrightarrow>
  i_aggregate (i_aggregate f a ag) b ag = i_aggregate f (a * b) ag"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < a; 0 < b; \<And>xs. length xs mod a = 0 \<Longrightarrow> ag (f_aggregate xs a ag) = ag xs\<rbrakk> \<Longrightarrow> i_aggregate (i_aggregate f a ag) b ag = i_aggregate f (a * b) ag
[PROOF STEP]
apply (simp add: ilist_eq_iff i_aggregate_nth)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < a; 0 < b; \<And>xs. length xs mod a = 0 \<Longrightarrow> ag (f_aggregate xs a ag) = ag xs\<rbrakk> \<Longrightarrow> \<forall>x. ag (i_aggregate f a ag \<Up> (x * b) \<Down> b) = ag (f \<Up> (x * (a * b)) \<Down> (a * b))
[PROOF STEP]
apply (simp add: i_aggregate_i_drop_mult[symmetric] i_aggregate_i_take_mult[symmetric] mult.commute[of a] mult.assoc)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma totient_code1: "totient n = totient_aux1 n (prime_factors_nat n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. totient n = totient_aux1 n (prime_factors_nat n)
[PROOF STEP]
by (intro totient_conv_totient_aux1) simp_all


[STATEMENT]
lemma fInf_subdistl:
  fixes f :: "'a::complete_lattice \<Rightarrow> 'b::complete_lattice"
  shows  "mono f \<Longrightarrow> (\<circ>) f \<circ> Inf \<le> Inf \<circ> (`) ((\<circ>) f)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mono f \<Longrightarrow> (\<circ>) f \<circ> Inf \<le> Inf \<circ> (`) ((\<circ>) f)
[PROOF STEP]
by (simp add: fun_isol subdistl_iso)


[STATEMENT]
lemma sin_exp_eq': "sin z = \<i> * (exp(-(\<i> * z)) - exp(\<i> * z)) / 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sin z = \<i> * (exp (- (\<i> * z)) - exp (\<i> * z)) / 2
[PROOF STEP]
by (simp add: exp_Euler exp_minus_Euler)


[STATEMENT]
lemma shiftl1_is_mult: "(x << 1) = (x :: 'a::len word) * 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x << 1 = x * 2
[PROOF STEP]
by (metis One_nat_def mult_2 mult_2_right one_add_one
        power_0 power_Suc shiftl_t2n)


[STATEMENT]
lemma tensor_unpack_inj:
  assumes "i < A * B" and "j < A * B"
  shows "tensor_unpack A B i = tensor_unpack A B j \<longleftrightarrow> i = j"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (tensor_unpack A B i = tensor_unpack A B j) = (i = j)
[PROOF STEP]
by (metis div_mult_mod_eq prod.sel(1) prod.sel(2) tensor_unpack_def)


[STATEMENT]
theorem wf_dbtm_iff_is_tm: "wf_dbtm x \<longleftrightarrow> (\<exists>t::tm. x = trans_tm [] t)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. wf_dbtm x = (\<exists>t. x = trans_tm [] t)
[PROOF STEP]
by (metis wf_dbtm_imp_is_tm wf_dbtm_trans_tm)


[STATEMENT]
lemma coeffs_pCons_eq_cCons [simp]: "coeffs (pCons a p) = a ## coeffs p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. coeffs (pCons a p) = a ## coeffs p
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. coeffs (pCons a p) = a ## coeffs p
[PROOF STEP]
have *: "\<forall>m\<in>set ms. m > 0 \<Longrightarrow> map (case_nat x f) ms = map f (map (\<lambda>n. n - 1) ms)"
    for ms :: "nat list" and f :: "nat \<Rightarrow> 'a" and x :: "'a"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>m\<in>set ms. 0 < m \<Longrightarrow> map (case_nat x f) ms = map f (map (\<lambda>n. n - 1) ms)
[PROOF STEP]
by (induct ms) (auto split: nat.split)
[PROOF STATE]
proof (state)
this:
\<forall>m\<in>set ?ms. 0 < m \<Longrightarrow> map (case_nat ?x ?f) ?ms = map ?f (map (\<lambda>n. n - 1) ?ms)

goal (1 subgoal):
 1. coeffs (pCons a p) = a ## coeffs p
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. coeffs (pCons a p) = a ## coeffs p
[PROOF STEP]
by (simp add: * coeffs_def upt_conv_Cons coeff_pCons map_decr_upt del: upt_Suc)
[PROOF STATE]
proof (state)
this:
coeffs (pCons a p) = a ## coeffs p

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma vi_gs_policy_opt:
  assumes "0 < eps"
  shows "dist (\<nu>\<^sub>b (mk_stationary_det (vi_gs_policy eps v))) \<nu>\<^sub>b_opt < eps"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dist (\<nu>\<^sub>b (mk_stationary_det (vi_gs_policy eps v))) \<nu>\<^sub>b_opt < eps
[PROOF STEP]
unfolding vi_gs_policy_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dist (\<nu>\<^sub>b (mk_stationary_det (opt_policy_gs (gs_iteration eps v)))) \<nu>\<^sub>b_opt < eps
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
0 < eps

goal (1 subgoal):
 1. dist (\<nu>\<^sub>b (mk_stationary_det (opt_policy_gs (gs_iteration eps v)))) \<nu>\<^sub>b_opt < eps
[PROOF STEP]
proof (induction eps v rule: gs_iteration.induct)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>eps v. \<lbrakk>\<lbrakk>\<not> (2 * l * dist v (GS_rec_fun\<^sub>b v) < eps * (1 - l) \<or> eps \<le> 0); 0 < eps\<rbrakk> \<Longrightarrow> dist (\<nu>\<^sub>b (mk_stationary_det (opt_policy_gs (gs_iteration eps (GS_rec_fun\<^sub>b v))))) \<nu>\<^sub>b_opt < eps; 0 < eps\<rbrakk> \<Longrightarrow> dist (\<nu>\<^sub>b (mk_stationary_det (opt_policy_gs (gs_iteration eps v)))) \<nu>\<^sub>b_opt < eps
[PROOF STEP]
case (1 v)
[PROOF STATE]
proof (state)
this:
\<lbrakk>\<not> (2 * l * dist v_ (GS_rec_fun\<^sub>b v_) < v * (1 - l) \<or> v \<le> 0); 0 < v\<rbrakk> \<Longrightarrow> dist (\<nu>\<^sub>b (mk_stationary_det (opt_policy_gs (gs_iteration v (GS_rec_fun\<^sub>b v_))))) \<nu>\<^sub>b_opt < v
0 < v

goal (1 subgoal):
 1. \<And>eps v. \<lbrakk>\<lbrakk>\<not> (2 * l * dist v (GS_rec_fun\<^sub>b v) < eps * (1 - l) \<or> eps \<le> 0); 0 < eps\<rbrakk> \<Longrightarrow> dist (\<nu>\<^sub>b (mk_stationary_det (opt_policy_gs (gs_iteration eps (GS_rec_fun\<^sub>b v))))) \<nu>\<^sub>b_opt < eps; 0 < eps\<rbrakk> \<Longrightarrow> dist (\<nu>\<^sub>b (mk_stationary_det (opt_policy_gs (gs_iteration eps v)))) \<nu>\<^sub>b_opt < eps
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>\<not> (2 * l * dist v_ (GS_rec_fun\<^sub>b v_) < v * (1 - l) \<or> v \<le> 0); 0 < v\<rbrakk> \<Longrightarrow> dist (\<nu>\<^sub>b (mk_stationary_det (opt_policy_gs (gs_iteration v (GS_rec_fun\<^sub>b v_))))) \<nu>\<^sub>b_opt < v
0 < v
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>\<not> (2 * l * dist v_ (GS_rec_fun\<^sub>b v_) < v * (1 - l) \<or> v \<le> 0); 0 < v\<rbrakk> \<Longrightarrow> dist (\<nu>\<^sub>b (mk_stationary_det (opt_policy_gs (gs_iteration v (GS_rec_fun\<^sub>b v_))))) \<nu>\<^sub>b_opt < v
0 < v

goal (1 subgoal):
 1. dist (\<nu>\<^sub>b (mk_stationary_det (opt_policy_gs (gs_iteration v v_)))) \<nu>\<^sub>b_opt < v
[PROOF STEP]
using find_policy_error_bound_gs
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>\<not> (2 * l * dist v_ (GS_rec_fun\<^sub>b v_) < v * (1 - l) \<or> v \<le> 0); 0 < v\<rbrakk> \<Longrightarrow> dist (\<nu>\<^sub>b (mk_stationary_det (opt_policy_gs (gs_iteration v (GS_rec_fun\<^sub>b v_))))) \<nu>\<^sub>b_opt < v
0 < v
\<lbrakk>0 < ?eps; 2 * l * dist ?v (GS_rec_fun\<^sub>b ?v) < ?eps * (1 - l)\<rbrakk> \<Longrightarrow> dist (\<nu>\<^sub>b (mk_stationary_det (opt_policy_gs (GS_rec_fun\<^sub>b ?v)))) \<nu>\<^sub>b_opt < ?eps

goal (1 subgoal):
 1. dist (\<nu>\<^sub>b (mk_stationary_det (opt_policy_gs (gs_iteration v v_)))) \<nu>\<^sub>b_opt < v
[PROOF STEP]
by (subst gs_iteration.simps) auto
[PROOF STATE]
proof (state)
this:
dist (\<nu>\<^sub>b (mk_stationary_det (opt_policy_gs (gs_iteration v v_)))) \<nu>\<^sub>b_opt < v

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma prod_mset_delta: "prod_mset (image_mset (\<lambda>x. if x = y then c else 1) A) = c ^ count A y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. prod_mset {#if x = y then c else (1::'a). x \<in># A#} = c ^ count A y
[PROOF STEP]
by (induction A) simp_all


[STATEMENT]
lemma intersection_num_non_neg: "b1 |\<inter>| b2 \<ge> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 \<le> b1 |\<inter>| b2
[PROOF STEP]
by (simp add: intersection_number_def)


[STATEMENT]
lemma bij_inv_project_act_eq: "bij h ==> inv (project_act (%(x,u::'c). inv h x)) =
                project_act (%(x,u::'c). h x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bij h \<Longrightarrow> inv (project_act (\<lambda>(x, u). inv h x)) = project_act (\<lambda>(x, u). h x)
[PROOF STEP]
apply (simp (no_asm_simp) add: bij_extend_act_eq_project_act [symmetric])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bij h \<Longrightarrow> inv (extend_act (\<lambda>(x, u). h x)) = project_act (\<lambda>(x, u). h x)
[PROOF STEP]
apply (rule surj_imp_inv_eq)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. bij h \<Longrightarrow> surj (extend_act (\<lambda>(x, u). h x))
 2. \<And>x. bij h \<Longrightarrow> project_act (\<lambda>(x, u). h x) (extend_act (\<lambda>(x, u). h x) x) = x
[PROOF STEP]
apply (blast intro!: bij_extend_act bij_is_surj)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. bij h \<Longrightarrow> project_act (\<lambda>(x, u). h x) (extend_act (\<lambda>(x, u). h x) x) = x
[PROOF STEP]
apply (simp (no_asm_simp) add: Extend.extend_act_inverse)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma cos_odd_kpi [simp]:
  fixes k::int
  assumes "odd k"
  shows "cos (k * pi) = -1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cos (real_of_int k * pi) = - 1
[PROOF STEP]
by (simp add: assms mult.commute)


[STATEMENT]
lemma det_four_block_mat_lower_left_zero: fixes A1 :: "'a :: idom mat"
  assumes A1: "A1 \<in> carrier_mat n n"
  and A2: "A2 \<in> carrier_mat n m" and A30: "A3 = 0\<^sub>m m n"
  and A4: "A4 \<in> carrier_mat m m"
shows "Determinant.det (four_block_mat A1 A2 A3 A4) = Determinant.det A1 * Determinant.det A4"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Determinant.det (four_block_mat A1 A2 A3 A4) = Determinant.det A1 * Determinant.det A4
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. Determinant.det (four_block_mat A1 A2 A3 A4) = Determinant.det A1 * Determinant.det A4
[PROOF STEP]
let ?det = Determinant.det
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. Determinant.det (four_block_mat A1 A2 A3 A4) = Determinant.det A1 * Determinant.det A4
[PROOF STEP]
let ?t = "transpose_mat"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. Determinant.det (four_block_mat A1 A2 A3 A4) = Determinant.det A1 * Determinant.det A4
[PROOF STEP]
let ?A = "four_block_mat A1 A2 A3 A4"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. Determinant.det (four_block_mat A1 A2 A3 A4) = Determinant.det A1 * Determinant.det A4
[PROOF STEP]
let ?k = "n + m"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. Determinant.det (four_block_mat A1 A2 A3 A4) = Determinant.det A1 * Determinant.det A4
[PROOF STEP]
have A3: "A3 \<in> carrier_mat m n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A3 \<in> carrier_mat m n
[PROOF STEP]
unfolding A30
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0\<^sub>m m n \<in> carrier_mat m n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
A3 \<in> carrier_mat m n

goal (1 subgoal):
 1. Determinant.det (four_block_mat A1 A2 A3 A4) = Determinant.det A1 * Determinant.det A4
[PROOF STEP]
have A: "?A \<in> carrier_mat ?k ?k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. four_block_mat A1 A2 A3 A4 \<in> carrier_mat (n + m) (n + m)
[PROOF STEP]
by (rule four_block_carrier_mat[OF A1 A4])
[PROOF STATE]
proof (state)
this:
four_block_mat A1 A2 A3 A4 \<in> carrier_mat (n + m) (n + m)

goal (1 subgoal):
 1. Determinant.det (four_block_mat A1 A2 A3 A4) = Determinant.det A1 * Determinant.det A4
[PROOF STEP]
have "?det ?A = ?det (?t ?A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Determinant.det (four_block_mat A1 A2 A3 A4) = Determinant.det (four_block_mat A1 A2 A3 A4)\<^sup>T
[PROOF STEP]
by (rule sym, rule Determinant.det_transpose[OF A])
[PROOF STATE]
proof (state)
this:
Determinant.det (four_block_mat A1 A2 A3 A4) = Determinant.det (four_block_mat A1 A2 A3 A4)\<^sup>T

goal (1 subgoal):
 1. Determinant.det (four_block_mat A1 A2 A3 A4) = Determinant.det A1 * Determinant.det A4
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
Determinant.det (four_block_mat A1 A2 A3 A4) = Determinant.det (four_block_mat A1 A2 A3 A4)\<^sup>T

goal (1 subgoal):
 1. Determinant.det (four_block_mat A1 A2 A3 A4) = Determinant.det A1 * Determinant.det A4
[PROOF STEP]
have "?t ?A = four_block_mat (?t A1) (?t A3) (?t A2) (?t A4)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (four_block_mat A1 A2 A3 A4)\<^sup>T = four_block_mat A1\<^sup>T A3\<^sup>T A2\<^sup>T A4\<^sup>T
[PROOF STEP]
by (rule transpose_four_block_mat[OF A1 A2 A3 A4])
[PROOF STATE]
proof (state)
this:
(four_block_mat A1 A2 A3 A4)\<^sup>T = four_block_mat A1\<^sup>T A3\<^sup>T A2\<^sup>T A4\<^sup>T

goal (1 subgoal):
 1. Determinant.det (four_block_mat A1 A2 A3 A4) = Determinant.det A1 * Determinant.det A4
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(four_block_mat A1 A2 A3 A4)\<^sup>T = four_block_mat A1\<^sup>T A3\<^sup>T A2\<^sup>T A4\<^sup>T

goal (1 subgoal):
 1. Determinant.det (four_block_mat A1 A2 A3 A4) = Determinant.det A1 * Determinant.det A4
[PROOF STEP]
have "?det \<dots> = ?det (?t A1) * ?det (?t A4)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Determinant.det (four_block_mat A1\<^sup>T A3\<^sup>T A2\<^sup>T A4\<^sup>T) = Determinant.det A1\<^sup>T * Determinant.det A4\<^sup>T
[PROOF STEP]
by (rule det_four_block_mat_upper_right_zero[of _ n _ m], insert A1 A2 A30 A4, auto)
[PROOF STATE]
proof (state)
this:
Determinant.det (four_block_mat A1\<^sup>T A3\<^sup>T A2\<^sup>T A4\<^sup>T) = Determinant.det A1\<^sup>T * Determinant.det A4\<^sup>T

goal (1 subgoal):
 1. Determinant.det (four_block_mat A1 A2 A3 A4) = Determinant.det A1 * Determinant.det A4
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
Determinant.det (four_block_mat A1\<^sup>T A3\<^sup>T A2\<^sup>T A4\<^sup>T) = Determinant.det A1\<^sup>T * Determinant.det A4\<^sup>T

goal (1 subgoal):
 1. Determinant.det (four_block_mat A1 A2 A3 A4) = Determinant.det A1 * Determinant.det A4
[PROOF STEP]
have "?det (?t A1) = ?det A1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Determinant.det A1\<^sup>T = Determinant.det A1
[PROOF STEP]
by (rule Determinant.det_transpose[OF A1])
[PROOF STATE]
proof (state)
this:
Determinant.det A1\<^sup>T = Determinant.det A1

goal (1 subgoal):
 1. Determinant.det (four_block_mat A1 A2 A3 A4) = Determinant.det A1 * Determinant.det A4
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
Determinant.det A1\<^sup>T = Determinant.det A1

goal (1 subgoal):
 1. Determinant.det (four_block_mat A1 A2 A3 A4) = Determinant.det A1 * Determinant.det A4
[PROOF STEP]
have "?det (?t A4) = ?det A4"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Determinant.det A4\<^sup>T = Determinant.det A4
[PROOF STEP]
by (rule Determinant.det_transpose[OF A4])
[PROOF STATE]
proof (state)
this:
Determinant.det A4\<^sup>T = Determinant.det A4

goal (1 subgoal):
 1. Determinant.det (four_block_mat A1 A2 A3 A4) = Determinant.det A1 * Determinant.det A4
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
Determinant.det (four_block_mat A1 A2 A3 A4) = Determinant.det A1 * Determinant.det A4
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
Determinant.det (four_block_mat A1 A2 A3 A4) = Determinant.det A1 * Determinant.det A4

goal (1 subgoal):
 1. Determinant.det (four_block_mat A1 A2 A3 A4) = Determinant.det A1 * Determinant.det A4
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
Determinant.det (four_block_mat A1 A2 A3 A4) = Determinant.det A1 * Determinant.det A4

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma condition_2_part_3:
  fixes A::"'a::{field}^'columns::{mod_type}^'rows::{mod_type}" and k::nat
  defines ia:"ia\<equiv>(if \<forall>m. is_zero_row_upt_k m k A then 0 else to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1)"
  defines B:"B\<equiv>(snd (Gauss_Jordan_column_k (ia,A) k))"
  assumes rref: "reduced_row_echelon_form_upt_k A k"
  and not_zero_i_suc_k: "\<not> is_zero_row_upt_k i (Suc k) B"
  and not_zero_m: "\<not> is_zero_row_upt_k m k A"
  and zero_below_greatest: "\<forall>m\<ge>(GREATEST n. \<not> is_zero_row_upt_k n k A) + 1. A $ m $ from_nat k = 0"
  shows "A $ i $ (LEAST k. A $ i $ k \<noteq> 0) = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A $ i $ (LEAST k. A $ i $ k \<noteq> (0::'a)) = (1::'a)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. A $ i $ (LEAST k. A $ i $ k \<noteq> (0::'a)) = (1::'a)
[PROOF STEP]
have ia2: "ia=to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ia = mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1
[PROOF STEP]
unfolding ia
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1) = mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1
[PROOF STEP]
using not_zero_m
[PROOF STATE]
proof (prove)
using this:
\<not> is_zero_row_upt_k m k A

goal (1 subgoal):
 1. (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1) = mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1
[PROOF STEP]
by presburger
[PROOF STATE]
proof (state)
this:
ia = mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1

goal (1 subgoal):
 1. A $ i $ (LEAST k. A $ i $ k \<noteq> (0::'a)) = (1::'a)
[PROOF STEP]
have B_eq_A: "B=A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. B = A
[PROOF STEP]
unfolding B Gauss_Jordan_column_k_def Let_def fst_conv snd_conv ia2
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. snd (if (\<forall>m\<ge>mod_type_class.from_nat (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1). A $ m $ mod_type_class.from_nat k = (0::'a)) \<or> mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1 = nrows A then (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1, A) else (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1 + 1, Gauss_Jordan_in_ij A (mod_type_class.from_nat (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1)) (mod_type_class.from_nat k))) = A
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<exists>m\<ge>mod_type_class.from_nat (Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A))). A $ m $ mod_type_class.from_nat k \<noteq> (0::'a)) \<and> Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) \<noteq> nrows A \<longrightarrow> Gauss_Jordan_in_ij A (mod_type_class.from_nat (Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)))) (mod_type_class.from_nat k) = A
[PROOF STEP]
unfolding from_nat_to_nat_greatest
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<exists>m\<ge>(GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows). A $ m $ mod_type_class.from_nat k \<noteq> (0::'a)) \<and> Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) \<noteq> nrows A \<longrightarrow> Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k) = A
[PROOF STEP]
using zero_below_greatest
[PROOF STATE]
proof (prove)
using this:
\<forall>m\<ge>(GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows). A $ m $ mod_type_class.from_nat k = (0::'a)

goal (1 subgoal):
 1. (\<exists>m\<ge>(GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows). A $ m $ mod_type_class.from_nat k \<noteq> (0::'a)) \<and> Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) \<noteq> nrows A \<longrightarrow> Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k) = A
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
B = A

goal (1 subgoal):
 1. A $ i $ (LEAST k. A $ i $ k \<noteq> (0::'a)) = (1::'a)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A $ i $ (LEAST k. A $ i $ k \<noteq> (0::'a)) = (1::'a)
[PROOF STEP]
proof (cases "to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1 < CARD('rows)")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1 < CARD('rows) \<Longrightarrow> A $ i $ (LEAST k. A $ i $ k \<noteq> (0::'a)) = (1::'a)
 2. \<not> mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1 < CARD('rows) \<Longrightarrow> A $ i $ (LEAST k. A $ i $ k \<noteq> (0::'a)) = (1::'a)
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1 < CARD('rows)

goal (2 subgoals):
 1. mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1 < CARD('rows) \<Longrightarrow> A $ i $ (LEAST k. A $ i $ k \<noteq> (0::'a)) = (1::'a)
 2. \<not> mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1 < CARD('rows) \<Longrightarrow> A $ i $ (LEAST k. A $ i $ k \<noteq> (0::'a)) = (1::'a)
[PROOF STEP]
have "\<not> is_zero_row_upt_k i k A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<not> is_zero_row_upt_k i k A
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> is_zero_row_upt_k i k A
[PROOF STEP]
have "i<(GREATEST n. \<not> is_zero_row_upt_k n k A) + 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. i < (GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)
[PROOF STEP]
proof (rule ccontr)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> i < (GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows) \<Longrightarrow> False
[PROOF STEP]
assume "\<not> i < (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1"
[PROOF STATE]
proof (state)
this:
\<not> i < (GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)

goal (1 subgoal):
 1. \<not> i < (GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows) \<Longrightarrow> False
[PROOF STEP]
hence i: "(GREATEST n. \<not> is_zero_row_upt_k n k A) + 1 \<le> i"
[PROOF STATE]
proof (prove)
using this:
\<not> i < (GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)

goal (1 subgoal):
 1. (GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows) \<le> i
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows) \<le> i

goal (1 subgoal):
 1. \<not> i < (GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows) \<Longrightarrow> False
[PROOF STEP]
hence "(GREATEST n. \<not> is_zero_row_upt_k n k A) < i"
[PROOF STATE]
proof (prove)
using this:
(GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows) \<le> i

goal (1 subgoal):
 1. (GREATEST n. \<not> is_zero_row_upt_k n k A) < i
[PROOF STEP]
using le_Suc' True
[PROOF STATE]
proof (prove)
using this:
(GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows) \<le> i
\<lbrakk>?a + (1::?'a) \<le> ?b; mod_type_class.to_nat ?a + 1 < CARD(?'a)\<rbrakk> \<Longrightarrow> ?a < ?b
mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1 < CARD('rows)

goal (1 subgoal):
 1. (GREATEST n. \<not> is_zero_row_upt_k n k A) < i
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(GREATEST n. \<not> is_zero_row_upt_k n k A) < i

goal (1 subgoal):
 1. \<not> i < (GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows) \<Longrightarrow> False
[PROOF STEP]
hence zero_i: "is_zero_row_upt_k i k A"
[PROOF STATE]
proof (prove)
using this:
(GREATEST n. \<not> is_zero_row_upt_k n k A) < i

goal (1 subgoal):
 1. is_zero_row_upt_k i k A
[PROOF STEP]
using not_greater_Greatest
[PROOF STATE]
proof (prove)
using this:
(GREATEST n. \<not> is_zero_row_upt_k n k A) < i
(GREATEST x. ?P x) < ?k \<Longrightarrow> \<not> ?P ?k

goal (1 subgoal):
 1. is_zero_row_upt_k i k A
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
is_zero_row_upt_k i k A

goal (1 subgoal):
 1. \<not> i < (GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows) \<Longrightarrow> False
[PROOF STEP]
hence "is_zero_row_upt_k i (Suc k) A"
[PROOF STATE]
proof (prove)
using this:
is_zero_row_upt_k i k A

goal (1 subgoal):
 1. is_zero_row_upt_k i (Suc k) A
[PROOF STEP]
proof (unfold is_zero_row_upt_k_def, clarify)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>j. \<lbrakk>\<forall>j. mod_type_class.to_nat j < k \<longrightarrow> A $ i $ j = (0::'a); is_zero_row_upt_k i k A; mod_type_class.to_nat j < Suc k\<rbrakk> \<Longrightarrow> A $ i $ j = (0::'a)
[PROOF STEP]
fix j::'columns
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>j. \<lbrakk>\<forall>j. mod_type_class.to_nat j < k \<longrightarrow> A $ i $ j = (0::'a); is_zero_row_upt_k i k A; mod_type_class.to_nat j < Suc k\<rbrakk> \<Longrightarrow> A $ i $ j = (0::'a)
[PROOF STEP]
assume "to_nat j < Suc k"
[PROOF STATE]
proof (state)
this:
mod_type_class.to_nat j < Suc k

goal (1 subgoal):
 1. \<And>j. \<lbrakk>\<forall>j. mod_type_class.to_nat j < k \<longrightarrow> A $ i $ j = (0::'a); is_zero_row_upt_k i k A; mod_type_class.to_nat j < Suc k\<rbrakk> \<Longrightarrow> A $ i $ j = (0::'a)
[PROOF STEP]
thus "A $ i $ j = 0"
[PROOF STATE]
proof (prove)
using this:
mod_type_class.to_nat j < Suc k

goal (1 subgoal):
 1. A $ i $ j = (0::'a)
[PROOF STEP]
using zero_i
[PROOF STATE]
proof (prove)
using this:
mod_type_class.to_nat j < Suc k
is_zero_row_upt_k i k A

goal (1 subgoal):
 1. A $ i $ j = (0::'a)
[PROOF STEP]
unfolding is_zero_row_upt_k_def
[PROOF STATE]
proof (prove)
using this:
mod_type_class.to_nat j < Suc k
\<forall>j. mod_type_class.to_nat j < k \<longrightarrow> A $ i $ j = (0::'a)

goal (1 subgoal):
 1. A $ i $ j = (0::'a)
[PROOF STEP]
using zero_below_greatest i
[PROOF STATE]
proof (prove)
using this:
mod_type_class.to_nat j < Suc k
\<forall>j. mod_type_class.to_nat j < k \<longrightarrow> A $ i $ j = (0::'a)
\<forall>m\<ge>(GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows). A $ m $ mod_type_class.from_nat k = (0::'a)
(GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows) \<le> i

goal (1 subgoal):
 1. A $ i $ j = (0::'a)
[PROOF STEP]
by (metis from_nat_to_nat_id le_neq_implies_less not_le not_less_eq_eq)
[PROOF STATE]
proof (state)
this:
A $ i $ j = (0::'a)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
is_zero_row_upt_k i (Suc k) A

goal (1 subgoal):
 1. \<not> i < (GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows) \<Longrightarrow> False
[PROOF STEP]
thus False
[PROOF STATE]
proof (prove)
using this:
is_zero_row_upt_k i (Suc k) A

goal (1 subgoal):
 1. False
[PROOF STEP]
using not_zero_i_suc_k
[PROOF STATE]
proof (prove)
using this:
is_zero_row_upt_k i (Suc k) A
\<not> is_zero_row_upt_k i (Suc k) B

goal (1 subgoal):
 1. False
[PROOF STEP]
unfolding B_eq_A
[PROOF STATE]
proof (prove)
using this:
is_zero_row_upt_k i (Suc k) A
\<not> is_zero_row_upt_k i (Suc k) A

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

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
i < (GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)

goal (1 subgoal):
 1. \<not> is_zero_row_upt_k i k A
[PROOF STEP]
hence "i\<le>(GREATEST n. \<not> is_zero_row_upt_k n k A)"
[PROOF STATE]
proof (prove)
using this:
i < (GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)

goal (1 subgoal):
 1. i \<le> (GREATEST n. \<not> is_zero_row_upt_k n k A)
[PROOF STEP]
using not_le le_Suc
[PROOF STATE]
proof (prove)
using this:
i < (GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)
(\<not> ?x \<le> ?y) = (?y < ?x)
?a < ?b \<Longrightarrow> ?a + (1::?'a) \<le> ?b

goal (1 subgoal):
 1. i \<le> (GREATEST n. \<not> is_zero_row_upt_k n k A)
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
i \<le> (GREATEST n. \<not> is_zero_row_upt_k n k A)

goal (1 subgoal):
 1. \<not> is_zero_row_upt_k i k A
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
i \<le> (GREATEST n. \<not> is_zero_row_upt_k n k A)

goal (1 subgoal):
 1. \<not> is_zero_row_upt_k i k A
[PROOF STEP]
using greatest_ge_nonzero_row'[OF rref] not_zero_m
[PROOF STATE]
proof (prove)
using this:
i \<le> (GREATEST n. \<not> is_zero_row_upt_k n k A)
\<lbrakk>?i \<le> (GREATEST m. \<not> is_zero_row_upt_k m k A); \<not> (\<forall>a. is_zero_row_upt_k a k A)\<rbrakk> \<Longrightarrow> \<not> is_zero_row_upt_k ?i k A
\<not> is_zero_row_upt_k m k A

goal (1 subgoal):
 1. \<not> is_zero_row_upt_k i k A
[PROOF STEP]
by fast
[PROOF STATE]
proof (state)
this:
\<not> is_zero_row_upt_k i k A

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<not> is_zero_row_upt_k i k A

goal (2 subgoals):
 1. mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1 < CARD('rows) \<Longrightarrow> A $ i $ (LEAST k. A $ i $ k \<noteq> (0::'a)) = (1::'a)
 2. \<not> mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1 < CARD('rows) \<Longrightarrow> A $ i $ (LEAST k. A $ i $ k \<noteq> (0::'a)) = (1::'a)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
\<not> is_zero_row_upt_k i k A

goal (1 subgoal):
 1. A $ i $ (LEAST k. A $ i $ k \<noteq> (0::'a)) = (1::'a)
[PROOF STEP]
using rref_upt_condition2[OF rref]
[PROOF STATE]
proof (prove)
using this:
\<not> is_zero_row_upt_k i k A
\<forall>i. \<not> is_zero_row_upt_k i k A \<longrightarrow> A $ i $ (LEAST k. A $ i $ k \<noteq> (0::'a)) = (1::'a)

goal (1 subgoal):
 1. A $ i $ (LEAST k. A $ i $ k \<noteq> (0::'a)) = (1::'a)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
A $ i $ (LEAST k. A $ i $ k \<noteq> (0::'a)) = (1::'a)

goal (1 subgoal):
 1. \<not> mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1 < CARD('rows) \<Longrightarrow> A $ i $ (LEAST k. A $ i $ k \<noteq> (0::'a)) = (1::'a)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1 < CARD('rows) \<Longrightarrow> A $ i $ (LEAST k. A $ i $ k \<noteq> (0::'a)) = (1::'a)
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1 < CARD('rows)

goal (1 subgoal):
 1. \<not> mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1 < CARD('rows) \<Longrightarrow> A $ i $ (LEAST k. A $ i $ k \<noteq> (0::'a)) = (1::'a)
[PROOF STEP]
have greatest_plus_one_eq_0: "(GREATEST n. \<not> is_zero_row_upt_k n k A) + 1 = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows) = (0::'rows)
[PROOF STEP]
using to_nat_plus_one_less_card False
[PROOF STATE]
proof (prove)
using this:
\<forall>a. a + (1::?'a) \<noteq> (0::?'a) \<longrightarrow> mod_type_class.to_nat a + 1 < CARD(?'a)
\<not> mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1 < CARD('rows)

goal (1 subgoal):
 1. (GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows) = (0::'rows)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
(GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows) = (0::'rows)

goal (1 subgoal):
 1. \<not> mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1 < CARD('rows) \<Longrightarrow> A $ i $ (LEAST k. A $ i $ k \<noteq> (0::'a)) = (1::'a)
[PROOF STEP]
have "\<not> is_zero_row_upt_k i k A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<not> is_zero_row_upt_k i k A
[PROOF STEP]
proof (rule not_is_zero_row_upt_suc)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<not> is_zero_row_upt_k i (Suc k) A
 2. \<forall>i. A $ i $ mod_type_class.from_nat k = (0::'a)
[PROOF STEP]
show "\<not> is_zero_row_upt_k i (Suc k) A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<not> is_zero_row_upt_k i (Suc k) A
[PROOF STEP]
using not_zero_i_suc_k
[PROOF STATE]
proof (prove)
using this:
\<not> is_zero_row_upt_k i (Suc k) B

goal (1 subgoal):
 1. \<not> is_zero_row_upt_k i (Suc k) A
[PROOF STEP]
unfolding B_eq_A
[PROOF STATE]
proof (prove)
using this:
\<not> is_zero_row_upt_k i (Suc k) A

goal (1 subgoal):
 1. \<not> is_zero_row_upt_k i (Suc k) A
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
\<not> is_zero_row_upt_k i (Suc k) A

goal (1 subgoal):
 1. \<forall>i. A $ i $ mod_type_class.from_nat k = (0::'a)
[PROOF STEP]
show "\<forall>i. A $ i $ from_nat k = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>i. A $ i $ mod_type_class.from_nat k = (0::'a)
[PROOF STEP]
using zero_below_greatest
[PROOF STATE]
proof (prove)
using this:
\<forall>m\<ge>(GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows). A $ m $ mod_type_class.from_nat k = (0::'a)

goal (1 subgoal):
 1. \<forall>i. A $ i $ mod_type_class.from_nat k = (0::'a)
[PROOF STEP]
unfolding greatest_plus_one_eq_0
[PROOF STATE]
proof (prove)
using this:
\<forall>m\<ge>0::'rows. A $ m $ mod_type_class.from_nat k = (0::'a)

goal (1 subgoal):
 1. \<forall>i. A $ i $ mod_type_class.from_nat k = (0::'a)
[PROOF STEP]
using least_mod_type
[PROOF STATE]
proof (prove)
using this:
\<forall>m\<ge>0::'rows. A $ m $ mod_type_class.from_nat k = (0::'a)
(0::?'a) \<le> ?n

goal (1 subgoal):
 1. \<forall>i. A $ i $ mod_type_class.from_nat k = (0::'a)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
\<forall>i. A $ i $ mod_type_class.from_nat k = (0::'a)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<not> is_zero_row_upt_k i k A

goal (1 subgoal):
 1. \<not> mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1 < CARD('rows) \<Longrightarrow> A $ i $ (LEAST k. A $ i $ k \<noteq> (0::'a)) = (1::'a)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
\<not> is_zero_row_upt_k i k A

goal (1 subgoal):
 1. A $ i $ (LEAST k. A $ i $ k \<noteq> (0::'a)) = (1::'a)
[PROOF STEP]
using rref_upt_condition2[OF rref]
[PROOF STATE]
proof (prove)
using this:
\<not> is_zero_row_upt_k i k A
\<forall>i. \<not> is_zero_row_upt_k i k A \<longrightarrow> A $ i $ (LEAST k. A $ i $ k \<noteq> (0::'a)) = (1::'a)

goal (1 subgoal):
 1. A $ i $ (LEAST k. A $ i $ k \<noteq> (0::'a)) = (1::'a)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
A $ i $ (LEAST k. A $ i $ k \<noteq> (0::'a)) = (1::'a)

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

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma strongly_fair_def3:
  "strongly_fair enabled taken = (\<box>\<diamond>enabled \<^bold>\<longrightarrow> \<box>\<diamond>taken)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. strongly_fair enabled taken = (\<lambda>s. (\<box>\<diamond>enabled) s \<longrightarrow> (\<box>\<diamond>taken) s)
[PROOF STEP]
unfolding strongly_fair_def2
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<box>(\<lambda>s. \<not> (\<box>(\<lambda>s. (\<diamond>enabled) s \<and> \<not> taken s)) s) = (\<lambda>s. (\<box>\<diamond>enabled) s \<longrightarrow> (\<box>\<diamond>taken) s)
[PROOF STEP]
by (metis (full_types) always_eventually_always weakly_fair_def2 weakly_fair_def3)


[STATEMENT]
lemma disj_matrices_add_x: "disj_matrices A B \<Longrightarrow> disj_matrices A C \<Longrightarrow> disj_matrices (B+C) (A::('a::lattice_ab_group_add) matrix)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>disj_matrices A B; disj_matrices A C\<rbrakk> \<Longrightarrow> disj_matrices (B + C) A
[PROOF STEP]
by (simp add: disj_matrices_x_add disj_matrices_commute)


[STATEMENT]
lemma least_max_arg_max_enum_correct1:
  assumes "X \<noteq> {}"
  shows "fst (least_max_arg_max_enum (f :: _ \<Rightarrow> (_ :: linorder)) X) = (LEAST x. is_arg_max f (\<lambda>x. x \<in> X) x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fst (least_max_arg_max_enum f X) = (LEAST x. is_arg_max f (\<lambda>x. x \<in> X) x)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. fst (least_max_arg_max_enum f X) = (LEAST x. is_arg_max f (\<lambda>x. x \<in> X) x)
[PROOF STEP]
have *: "xs \<noteq> [] \<Longrightarrow> (x = hd xs \<or> x \<in> set (tl xs)) \<longleftrightarrow> x \<in> set xs" for x xs
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. xs \<noteq> [] \<Longrightarrow> (x = hd xs \<or> x \<in> set (tl xs)) = (x \<in> set xs)
[PROOF STEP]
using list.set_sel list.exhaust_sel set_ConsD
[PROOF STATE]
proof (prove)
using this:
?a \<noteq> [] \<Longrightarrow> hd ?a \<in> set ?a
\<lbrakk>?a \<noteq> []; ?x \<in> set (tl ?a)\<rbrakk> \<Longrightarrow> ?x \<in> set ?a
\<lbrakk>?list = [] \<Longrightarrow> ?P; ?list = hd ?list # tl ?list \<Longrightarrow> ?P\<rbrakk> \<Longrightarrow> ?P
?y \<in> set (?x # ?xs) \<Longrightarrow> ?y = ?x \<or> ?y \<in> set ?xs

goal (1 subgoal):
 1. xs \<noteq> [] \<Longrightarrow> (x = hd xs \<or> x \<in> set (tl xs)) = (x \<in> set xs)
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
?xs1 \<noteq> [] \<Longrightarrow> (?x1 = hd ?xs1 \<or> ?x1 \<in> set (tl ?xs1)) = (?x1 \<in> set ?xs1)

goal (1 subgoal):
 1. fst (least_max_arg_max_enum f X) = (LEAST x. is_arg_max f (\<lambda>x. x \<in> X) x)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
?xs1 \<noteq> [] \<Longrightarrow> (?x1 = hd ?xs1 \<or> ?x1 \<in> set (tl ?xs1)) = (?x1 \<in> set ?xs1)

goal (1 subgoal):
 1. fst (least_max_arg_max_enum f X) = (LEAST x. is_arg_max f (\<lambda>x. x \<in> X) x)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
?xs1 \<noteq> [] \<Longrightarrow> (?x1 = hd ?xs1 \<or> ?x1 \<in> set (tl ?xs1)) = (?x1 \<in> set ?xs1)
X \<noteq> {}

goal (1 subgoal):
 1. fst (least_max_arg_max_enum f X) = (LEAST x. is_arg_max f (\<lambda>x. x \<in> X) x)
[PROOF STEP]
by (auto simp: least_max_arg_max_enum_def Let_def fst_least_max_arg_max_list *)
[PROOF STATE]
proof (state)
this:
fst (least_max_arg_max_enum f X) = (LEAST x. is_arg_max f (\<lambda>x. x \<in> X) x)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma is_bezout_ext_euclid_ext2: "is_bezout_ext (euclid_ext2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. is_bezout_ext euclid_ext2
[PROOF STEP]
proof (unfold is_bezout_ext_def Let_def, clarify, intro conjI)
[PROOF STATE]
proof (state)
goal (6 subgoals):
 1. \<And>a b p aa ab ac ba. euclid_ext2 a b = (p, aa, ab, ac, ba) \<Longrightarrow> p * a + aa * b = ba
 2. \<And>a b p aa ab ac ba. euclid_ext2 a b = (p, aa, ab, ac, ba) \<Longrightarrow> ba dvd a
 3. \<And>a b p aa ab ac ba. euclid_ext2 a b = (p, aa, ab, ac, ba) \<Longrightarrow> ba dvd b
 4. \<And>a b p aa ab ac ba. euclid_ext2 a b = (p, aa, ab, ac, ba) \<Longrightarrow> \<forall>d'. d' dvd a \<and> d' dvd b \<longrightarrow> d' dvd ba
 5. \<And>a b p aa ab ac ba. euclid_ext2 a b = (p, aa, ab, ac, ba) \<Longrightarrow> ba * ab = - b
 6. \<And>a b p aa ab ac ba. euclid_ext2 a b = (p, aa, ab, ac, ba) \<Longrightarrow> ba * ac = a
[PROOF STEP]
fix a b p q u v d
[PROOF STATE]
proof (state)
goal (6 subgoals):
 1. \<And>a b p aa ab ac ba. euclid_ext2 a b = (p, aa, ab, ac, ba) \<Longrightarrow> p * a + aa * b = ba
 2. \<And>a b p aa ab ac ba. euclid_ext2 a b = (p, aa, ab, ac, ba) \<Longrightarrow> ba dvd a
 3. \<And>a b p aa ab ac ba. euclid_ext2 a b = (p, aa, ab, ac, ba) \<Longrightarrow> ba dvd b
 4. \<And>a b p aa ab ac ba. euclid_ext2 a b = (p, aa, ab, ac, ba) \<Longrightarrow> \<forall>d'. d' dvd a \<and> d' dvd b \<longrightarrow> d' dvd ba
 5. \<And>a b p aa ab ac ba. euclid_ext2 a b = (p, aa, ab, ac, ba) \<Longrightarrow> ba * ab = - b
 6. \<And>a b p aa ab ac ba. euclid_ext2 a b = (p, aa, ab, ac, ba) \<Longrightarrow> ba * ac = a
[PROOF STEP]
assume e: "euclid_ext2 a b = (p, q, u, v, d)"
[PROOF STATE]
proof (state)
this:
euclid_ext2 a b = (p, q, u, v, d)

goal (6 subgoals):
 1. \<And>a b p aa ab ac ba. euclid_ext2 a b = (p, aa, ab, ac, ba) \<Longrightarrow> p * a + aa * b = ba
 2. \<And>a b p aa ab ac ba. euclid_ext2 a b = (p, aa, ab, ac, ba) \<Longrightarrow> ba dvd a
 3. \<And>a b p aa ab ac ba. euclid_ext2 a b = (p, aa, ab, ac, ba) \<Longrightarrow> ba dvd b
 4. \<And>a b p aa ab ac ba. euclid_ext2 a b = (p, aa, ab, ac, ba) \<Longrightarrow> \<forall>d'. d' dvd a \<and> d' dvd b \<longrightarrow> d' dvd ba
 5. \<And>a b p aa ab ac ba. euclid_ext2 a b = (p, aa, ab, ac, ba) \<Longrightarrow> ba * ab = - b
 6. \<And>a b p aa ab ac ba. euclid_ext2 a b = (p, aa, ab, ac, ba) \<Longrightarrow> ba * ac = a
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
euclid_ext2 a b = (p, q, u, v, d)
[PROOF STEP]
have "bezout_coefficients a b = (p, q)" and "gcd a b = d"
[PROOF STATE]
proof (prove)
using this:
euclid_ext2 a b = (p, q, u, v, d)

goal (1 subgoal):
 1. bezout_coefficients a b = (p, q) &&& gcd a b = d
[PROOF STEP]
by (auto simp add: euclid_ext2_def)
[PROOF STATE]
proof (state)
this:
bezout_coefficients a b = (p, q)
gcd a b = d

goal (6 subgoals):
 1. \<And>a b p aa ab ac ba. euclid_ext2 a b = (p, aa, ab, ac, ba) \<Longrightarrow> p * a + aa * b = ba
 2. \<And>a b p aa ab ac ba. euclid_ext2 a b = (p, aa, ab, ac, ba) \<Longrightarrow> ba dvd a
 3. \<And>a b p aa ab ac ba. euclid_ext2 a b = (p, aa, ab, ac, ba) \<Longrightarrow> ba dvd b
 4. \<And>a b p aa ab ac ba. euclid_ext2 a b = (p, aa, ab, ac, ba) \<Longrightarrow> \<forall>d'. d' dvd a \<and> d' dvd b \<longrightarrow> d' dvd ba
 5. \<And>a b p aa ab ac ba. euclid_ext2 a b = (p, aa, ab, ac, ba) \<Longrightarrow> ba * ab = - b
 6. \<And>a b p aa ab ac ba. euclid_ext2 a b = (p, aa, ab, ac, ba) \<Longrightarrow> ba * ac = a
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
bezout_coefficients a b = (p, q)
gcd a b = d
[PROOF STEP]
show "p * a + q * b = d"
[PROOF STATE]
proof (prove)
using this:
bezout_coefficients a b = (p, q)
gcd a b = d

goal (1 subgoal):
 1. p * a + q * b = d
[PROOF STEP]
by (simp add: bezout_coefficients)
[PROOF STATE]
proof (state)
this:
p * a + q * b = d

goal (5 subgoals):
 1. \<And>a b p aa ab ac ba. euclid_ext2 a b = (p, aa, ab, ac, ba) \<Longrightarrow> ba dvd a
 2. \<And>a b p aa ab ac ba. euclid_ext2 a b = (p, aa, ab, ac, ba) \<Longrightarrow> ba dvd b
 3. \<And>a b p aa ab ac ba. euclid_ext2 a b = (p, aa, ab, ac, ba) \<Longrightarrow> \<forall>d'. d' dvd a \<and> d' dvd b \<longrightarrow> d' dvd ba
 4. \<And>a b p aa ab ac ba. euclid_ext2 a b = (p, aa, ab, ac, ba) \<Longrightarrow> ba * ab = - b
 5. \<And>a b p aa ab ac ba. euclid_ext2 a b = (p, aa, ab, ac, ba) \<Longrightarrow> ba * ac = a
[PROOF STEP]
from \<open>gcd a b = d\<close>
[PROOF STATE]
proof (chain)
picking this:
gcd a b = d
[PROOF STEP]
show "d dvd a" and "d dvd b"
[PROOF STATE]
proof (prove)
using this:
gcd a b = d

goal (1 subgoal):
 1. d dvd a &&& d dvd b
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
d dvd a
d dvd b

goal (3 subgoals):
 1. \<And>a b p aa ab ac ba. euclid_ext2 a b = (p, aa, ab, ac, ba) \<Longrightarrow> \<forall>d'. d' dvd a \<and> d' dvd b \<longrightarrow> d' dvd ba
 2. \<And>a b p aa ab ac ba. euclid_ext2 a b = (p, aa, ab, ac, ba) \<Longrightarrow> ba * ab = - b
 3. \<And>a b p aa ab ac ba. euclid_ext2 a b = (p, aa, ab, ac, ba) \<Longrightarrow> ba * ac = a
[PROOF STEP]
from \<open>gcd a b = d\<close>
[PROOF STATE]
proof (chain)
picking this:
gcd a b = d
[PROOF STEP]
show "\<forall>d'. d' dvd a \<and> d' dvd b \<longrightarrow> d' dvd d"
[PROOF STATE]
proof (prove)
using this:
gcd a b = d

goal (1 subgoal):
 1. \<forall>d'. d' dvd a \<and> d' dvd b \<longrightarrow> d' dvd d
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<forall>d'. d' dvd a \<and> d' dvd b \<longrightarrow> d' dvd d

goal (2 subgoals):
 1. \<And>a b p aa ab ac ba. euclid_ext2 a b = (p, aa, ab, ac, ba) \<Longrightarrow> ba * ab = - b
 2. \<And>a b p aa ab ac ba. euclid_ext2 a b = (p, aa, ab, ac, ba) \<Longrightarrow> ba * ac = a
[PROOF STEP]
have "a div d = v" and "-b div d = u"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a div d = v &&& - b div d = u
[PROOF STEP]
using e
[PROOF STATE]
proof (prove)
using this:
euclid_ext2 a b = (p, q, u, v, d)

goal (1 subgoal):
 1. a div d = v &&& - b div d = u
[PROOF STEP]
by (auto simp add: euclid_ext2_def)
[PROOF STATE]
proof (state)
this:
a div d = v
- b div d = u

goal (2 subgoals):
 1. \<And>a b p aa ab ac ba. euclid_ext2 a b = (p, aa, ab, ac, ba) \<Longrightarrow> ba * ab = - b
 2. \<And>a b p aa ab ac ba. euclid_ext2 a b = (p, aa, ab, ac, ba) \<Longrightarrow> ba * ac = a
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
a div d = v
- b div d = u
[PROOF STEP]
show "d * v = a" and "d * u = - b"
[PROOF STATE]
proof (prove)
using this:
a div d = v
- b div d = u

goal (1 subgoal):
 1. d * v = a &&& d * u = - b
[PROOF STEP]
using \<open>d dvd a\<close> and \<open>d dvd b\<close>
[PROOF STATE]
proof (prove)
using this:
a div d = v
- b div d = u
d dvd a
d dvd b

goal (1 subgoal):
 1. d * v = a &&& d * u = - b
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
d * v = a
d * u = - b

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma conjugate_id_iff:
  shows "conjugate a = a \<longleftrightarrow> is_real (to_complex a) \<or> a = \<infinity>\<^sub>h"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (conjugate a = a) = (is_real (to_complex a) \<or> a = \<infinity>\<^sub>h)
[PROOF STEP]
using inf_or_of_complex[of a]
[PROOF STATE]
proof (prove)
using this:
a = \<infinity>\<^sub>h \<or> (\<exists>x. a = of_complex x)

goal (1 subgoal):
 1. (conjugate a = a) = (is_real (to_complex a) \<or> a = \<infinity>\<^sub>h)
[PROOF STEP]
by (metis conjugate_inf conjugate_of_complex eq_cnj_iff_real to_complex_of_complex)


[STATEMENT]
lemma sorted_descending_append: "sorted_descending (xs @ ys) =
    (sorted_descending xs \<and> sorted_descending ys \<and> (\<forall>x\<in>set xs. \<forall>y\<in>set ys. x \<ge> y))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sorted_descending (xs @ ys) = (sorted_descending xs \<and> sorted_descending ys \<and> (\<forall>x\<in>set xs. \<forall>y\<in>set ys. y \<le> x))
[PROOF STEP]
by(induction xs) auto


[STATEMENT]
lemma card_isolated_verts_da: "card H.isolated_verts = Suc (Suc (card G.isolated_verts))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card H.isolated_verts = Suc (Suc (card G.isolated_verts))
[PROOF STEP]
using no_loop_a isolated_tail isolated_head
[PROOF STATE]
proof (prove)
using this:
head G a \<noteq> tail G a
tail G a \<in> H.isolated_verts
head G a \<in> H.isolated_verts

goal (1 subgoal):
 1. card H.isolated_verts = Suc (Suc (card G.isolated_verts))
[PROOF STEP]
by (simp add: card_isolated_verts_da0 card_insert_if)


[STATEMENT]
lemma (in linorder_topology) at_eq_sup_left_right: "at x = sup (at_left x) (at_right x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. at x = sup (at_left x) (at_right x)
[PROOF STEP]
by (auto simp: eventually_at_filter filter_eq_iff eventually_sup
      elim: eventually_elim2 eventually_mono)


[STATEMENT]
lemma finite_Image:
  "finite A \<Longrightarrow> finite (R `` A) \<longleftrightarrow> (\<forall>x\<in>A. finite {y. (x, y) \<in> R})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite A \<Longrightarrow> finite (R `` A) = (\<forall>x\<in>A. finite {y. (x, y) \<in> R})
[PROOF STEP]
by(simp add: Image_def)


[STATEMENT]
lemma tensor_lookup:
assumes "\<And>is. is \<lhd> dims A \<Longrightarrow> lookup A is = e is"
shows "tensor_from_lookup (dims A) e = A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. tensor_from_lookup (dims A) e = A
[PROOF STEP]
using tensor_lookup_base lookup_def length_vec tensor_from_lookup_def
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>length ?v = prod_list ?ds; \<And>is. is \<lhd> ?ds \<Longrightarrow> lookup_base ?ds ?v is = ?e is\<rbrakk> \<Longrightarrow> tensor_vec_from_lookup ?ds ?e = ?v
lookup ?A = lookup_base (dims ?A) (vec ?A)
length (vec ?A) = prod_list (dims ?A)
tensor_from_lookup ?ds ?e = tensor_from_vec ?ds (tensor_vec_from_lookup ?ds ?e)

goal (1 subgoal):
 1. tensor_from_lookup (dims A) e = A
[PROOF STEP]
by (metis assms tensor_from_vec_simp)


[STATEMENT]
lemma inverse_pow_pow:
  assumes "a \<in> carrier G"
  shows "inv (a [^] (r::nat)) = (inv a) [^] r"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inv (a [^] r) = inv a [^] r
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. inv (a [^] r) = inv a [^] r
[PROOF STEP]
have "a [^] r \<in> carrier G"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a [^] r \<in> carrier G
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
a \<in> carrier G

goal (1 subgoal):
 1. a [^] r \<in> carrier G
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
a [^] r \<in> carrier G

goal (1 subgoal):
 1. inv (a [^] r) = inv a [^] r
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
a [^] r \<in> carrier G
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
a [^] r \<in> carrier G

goal (1 subgoal):
 1. inv (a [^] r) = inv a [^] r
[PROOF STEP]
by (simp add: assms nat_pow_inv)
[PROOF STATE]
proof (state)
this:
inv (a [^] r) = inv a [^] r

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma (in field) nonzero_insert:
  "nonzero xs (List.insert p ps) = (peval xs p \<noteq> \<zero> \<and> nonzero xs ps)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. nonzero xs (List.insert p ps) = (peval xs p \<noteq> \<zero> \<and> nonzero xs ps)
[PROOF STEP]
by (simp add: List.insert_def nonzero_idempotent)


[STATEMENT]
lemma in_inv_image_iff: "(x,y) \<in> inv_image r f = ((f x, f y) \<in> r)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((x, y) \<in> inv_image r f) = ((f x, f y) \<in> r)
[PROOF STEP]
by (simp add: inv_image_def)


[STATEMENT]
theorem exp_irrational:
  fixes q::real assumes "q \<in> \<rat>" "q \<noteq> 0" shows "exp q \<notin> \<rat>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. exp q \<notin> \<rat>
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. exp q \<in> \<rat> \<Longrightarrow> False
[PROOF STEP]
assume q: "exp q \<in> \<rat>"
[PROOF STATE]
proof (state)
this:
exp q \<in> \<rat>

goal (1 subgoal):
 1. exp q \<in> \<rat> \<Longrightarrow> False
[PROOF STEP]
obtain s t where "s \<noteq> 0" "t > 0" "q = of_int s / of_int t"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>s t. \<lbrakk>s \<noteq> 0; 0 < t; q = real_of_int s / real_of_int t\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (metis Rats_cases' assms div_0 of_int_0)
[PROOF STATE]
proof (state)
this:
s \<noteq> 0
0 < t
q = real_of_int s / real_of_int t

goal (1 subgoal):
 1. exp q \<in> \<rat> \<Longrightarrow> False
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
s \<noteq> 0
0 < t
q = real_of_int s / real_of_int t
[PROOF STEP]
have "(exp q) ^ (nat t) = exp s"
[PROOF STATE]
proof (prove)
using this:
s \<noteq> 0
0 < t
q = real_of_int s / real_of_int t

goal (1 subgoal):
 1. exp q ^ nat t = exp (real_of_int s)
[PROOF STEP]
by (smt (verit, best) exp_divide_power_eq of_nat_nat zero_less_nat_eq)
[PROOF STATE]
proof (state)
this:
exp q ^ nat t = exp (real_of_int s)

goal (1 subgoal):
 1. exp q \<in> \<rat> \<Longrightarrow> False
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
exp q ^ nat t = exp (real_of_int s)

goal (1 subgoal):
 1. exp q \<in> \<rat> \<Longrightarrow> False
[PROOF STEP]
have "exp q ^ (nat t) \<in> \<rat>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. exp q ^ nat t \<in> \<rat>
[PROOF STEP]
by (simp add: q)
[PROOF STATE]
proof (state)
this:
exp q ^ nat t \<in> \<rat>

goal (1 subgoal):
 1. exp q \<in> \<rat> \<Longrightarrow> False
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
exp q ^ nat t = exp (real_of_int s)
exp q ^ nat t \<in> \<rat>
[PROOF STEP]
show False
[PROOF STATE]
proof (prove)
using this:
exp q ^ nat t = exp (real_of_int s)
exp q ^ nat t \<in> \<rat>

goal (1 subgoal):
 1. False
[PROOF STEP]
by (smt (verit, del_insts) Rats_inverse \<open>s \<noteq> 0\<close> exp_minus exp_nat_irrational of_int_of_nat)
[PROOF STATE]
proof (state)
this:
False

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma measure_count_space[simp]:
  "B \<subseteq> A \<Longrightarrow> finite B \<Longrightarrow> measure (count_space A) B = card B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>B \<subseteq> A; finite B\<rbrakk> \<Longrightarrow> Sigma_Algebra.measure (count_space A) B = real (card B)
[PROOF STEP]
unfolding measure_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>B \<subseteq> A; finite B\<rbrakk> \<Longrightarrow> enn2real (emeasure (count_space A) B) = real (card B)
[PROOF STEP]
by (subst emeasure_count_space ) auto


[STATEMENT]
lemma simple_path_linear_image_eq:
  fixes f :: "'a::euclidean_space \<Rightarrow> 'b::euclidean_space"
  assumes "linear f" "inj f"
    shows "simple_path(f \<circ> g) = simple_path g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. simple_path (f \<circ> g) = simple_path g
[PROOF STEP]
using assms inj_on_eq_iff [of f]
[PROOF STATE]
proof (prove)
using this:
linear f
inj f
\<lbrakk>inj_on f ?A; ?x \<in> ?A; ?y \<in> ?A\<rbrakk> \<Longrightarrow> (f ?x = f ?y) = (?x = ?y)

goal (1 subgoal):
 1. simple_path (f \<circ> g) = simple_path g
[PROOF STEP]
by (auto simp: path_linear_image_eq simple_path_def path_translation_eq)


[STATEMENT]
lemma (in vec_space) full_rank_lin_indpt:
assumes "A \<in> carrier_mat n nc"
assumes "rank A = nc"
assumes "distinct (cols A)"
shows "lin_indpt (set (cols A))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. lin_indpt (set (cols A))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. lin_indpt (set (cols A))
[PROOF STEP]
have 1:"set (cols A) \<subseteq> carrier_vec n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set (cols A) \<subseteq> carrier_vec n
[PROOF STEP]
using assms(1) cols_dim
[PROOF STATE]
proof (prove)
using this:
A \<in> carrier_mat n nc
set (cols ?A) \<subseteq> carrier_vec (dim_row ?A)

goal (1 subgoal):
 1. set (cols A) \<subseteq> carrier_vec n
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
set (cols A) \<subseteq> carrier_vec n

goal (1 subgoal):
 1. lin_indpt (set (cols A))
[PROOF STEP]
have 2:"finite (set (cols A))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite (set (cols A))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
finite (set (cols A))

goal (1 subgoal):
 1. lin_indpt (set (cols A))
[PROOF STEP]
have "card (set (cols A)) = nc"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card (set (cols A)) = nc
[PROOF STEP]
using assms(1) assms(3) distinct_card
[PROOF STATE]
proof (prove)
using this:
A \<in> carrier_mat n nc
distinct (cols A)
distinct ?xs \<Longrightarrow> card (set ?xs) = length ?xs

goal (1 subgoal):
 1. card (set (cols A)) = nc
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
card (set (cols A)) = nc

goal (1 subgoal):
 1. lin_indpt (set (cols A))
[PROOF STEP]
have 3:"vectorspace.dim class_ring (span_vs (set (cols A))) = card (set (cols A))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vectorspace.dim class_ring (vs (local.span (set (cols A)))) = card (set (cols A))
[PROOF STEP]
using \<open>rank A = nc\<close>[unfolded rank_def]
[PROOF STATE]
proof (prove)
using this:
vectorspace.dim class_ring (vs (local.span (set (cols A)))) = nc

goal (1 subgoal):
 1. vectorspace.dim class_ring (vs (local.span (set (cols A)))) = card (set (cols A))
[PROOF STEP]
using assms(1) assms(3) distinct_card
[PROOF STATE]
proof (prove)
using this:
vectorspace.dim class_ring (vs (local.span (set (cols A)))) = nc
A \<in> carrier_mat n nc
distinct (cols A)
distinct ?xs \<Longrightarrow> card (set ?xs) = length ?xs

goal (1 subgoal):
 1. vectorspace.dim class_ring (vs (local.span (set (cols A)))) = card (set (cols A))
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
vectorspace.dim class_ring (vs (local.span (set (cols A)))) = card (set (cols A))

goal (1 subgoal):
 1. lin_indpt (set (cols A))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. lin_indpt (set (cols A))
[PROOF STEP]
using full_dim_span[OF 1 2 3]
[PROOF STATE]
proof (prove)
using this:
lin_indpt (set (cols A))

goal (1 subgoal):
 1. lin_indpt (set (cols A))
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
lin_indpt (set (cols A))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma Max_enat_minus1:
  assumes "finite A" "A \<noteq> {}"
  shows "Max A - m = Max ((\<lambda>n :: enat. n - m) ` A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Max A - m = (MAX n\<in>A. n - m)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
finite A
A \<noteq> {}

goal (1 subgoal):
 1. Max A - m = (MAX n\<in>A. n - m)
[PROOF STEP]
proof induct
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. {} \<noteq> {} \<Longrightarrow> Max {} - m = (MAX n\<in>{}. n - m)
 2. \<And>x F. \<lbrakk>finite F; x \<notin> F; F \<noteq> {} \<Longrightarrow> Max F - m = (MAX n\<in>F. n - m); insert x F \<noteq> {}\<rbrakk> \<Longrightarrow> Max (insert x F) - m = (MAX n\<in>insert x F. n - m)
[PROOF STEP]
case (insert x A)
[PROOF STATE]
proof (state)
this:
finite A
x \<notin> A
A \<noteq> {} \<Longrightarrow> Max A - m = (MAX n\<in>A. n - m)
insert x A \<noteq> {}

goal (2 subgoals):
 1. {} \<noteq> {} \<Longrightarrow> Max {} - m = (MAX n\<in>{}. n - m)
 2. \<And>x F. \<lbrakk>finite F; x \<notin> F; F \<noteq> {} \<Longrightarrow> Max F - m = (MAX n\<in>F. n - m); insert x F \<noteq> {}\<rbrakk> \<Longrightarrow> Max (insert x F) - m = (MAX n\<in>insert x F. n - m)
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
using this:
finite A
x \<notin> A
A \<noteq> {} \<Longrightarrow> Max A - m = (MAX n\<in>A. n - m)
insert x A \<noteq> {}

goal (1 subgoal):
 1. Max (insert x A) - m = (MAX n\<in>insert x A. n - m)
[PROOF STEP]
by(cases "A = {}")(simp_all add: max_enat_minus1)
[PROOF STATE]
proof (state)
this:
Max (insert x A) - m = (MAX n\<in>insert x A. n - m)

goal (1 subgoal):
 1. {} \<noteq> {} \<Longrightarrow> Max {} - m = (MAX n\<in>{}. n - m)
[PROOF STEP]
qed simp


[STATEMENT]
lemma closed_Collect_le_within:
  fixes f g :: "'a :: topological_space \<Rightarrow> 'b::linorder_topology"
  assumes f: "continuous_on UNIV f"
    and g: "continuous_on UNIV g"
    and "closed R"
  shows "closed {x \<in> R. f x \<le> g x}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. closed {x \<in> R. f x \<le> g x}
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. closed {x \<in> R. f x \<le> g x}
[PROOF STEP]
have *: "- R \<union> {x. g x < f x} = - {x \<in> R. f x \<le> g x}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. - R \<union> {x. g x < f x} = - {x \<in> R. f x \<le> g x}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
- R \<union> {x. g x < f x} = - {x \<in> R. f x \<le> g x}

goal (1 subgoal):
 1. closed {x \<in> R. f x \<le> g x}
[PROOF STEP]
have "open (-R)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. open (- R)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
continuous_on UNIV f
continuous_on UNIV g
closed R

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

goal (1 subgoal):
 1. closed {x \<in> R. f x \<le> g x}
[PROOF STEP]
from open_Un[OF this open_Collect_less [OF g f], unfolded *]
[PROOF STATE]
proof (chain)
picking this:
open (- {x \<in> R. f x \<le> g x})
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
open (- {x \<in> R. f x \<le> g x})

goal (1 subgoal):
 1. closed {x \<in> R. f x \<le> g x}
[PROOF STEP]
by (simp add: closed_open)
[PROOF STATE]
proof (state)
this:
closed {x \<in> R. f x \<le> g x}

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma card_PiE_dflt:
  assumes "finite A" "\<And>x. x \<in> A \<Longrightarrow> finite (B x)"
  shows   "card (PiE_dflt A d B) = (\<Prod>x\<in>A. card (B x))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card (Pi_pmf.PiE_dflt A d B) = (\<Prod>x\<in>A. card (B x))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. card (Pi_pmf.PiE_dflt A d B) = (\<Prod>x\<in>A. card (B x))
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
finite A
?x \<in> A \<Longrightarrow> finite (B ?x)
[PROOF STEP]
have "(\<Prod>x\<in>A. card (B x)) = card (PiE A B)"
[PROOF STATE]
proof (prove)
using this:
finite A
?x \<in> A \<Longrightarrow> finite (B ?x)

goal (1 subgoal):
 1. (\<Prod>x\<in>A. card (B x)) = card (Pi\<^sub>E A B)
[PROOF STEP]
by (intro card_PiE [symmetric]) auto
[PROOF STATE]
proof (state)
this:
(\<Prod>x\<in>A. card (B x)) = card (Pi\<^sub>E A B)

goal (1 subgoal):
 1. card (Pi_pmf.PiE_dflt A d B) = (\<Prod>x\<in>A. card (B x))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Prod>x\<in>A. card (B x)) = card (Pi\<^sub>E A B)

goal (1 subgoal):
 1. card (Pi_pmf.PiE_dflt A d B) = (\<Prod>x\<in>A. card (B x))
[PROOF STEP]
have "PiE A B = (\<lambda>f. restrict f A) ` PiE_dflt A d B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Pi\<^sub>E A B = (\<lambda>f. restrict f A) ` Pi_pmf.PiE_dflt A d B
[PROOF STEP]
by (rule restrict_PiE_dflt [symmetric])
[PROOF STATE]
proof (state)
this:
Pi\<^sub>E A B = (\<lambda>f. restrict f A) ` Pi_pmf.PiE_dflt A d B

goal (1 subgoal):
 1. card (Pi_pmf.PiE_dflt A d B) = (\<Prod>x\<in>A. card (B x))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
Pi\<^sub>E A B = (\<lambda>f. restrict f A) ` Pi_pmf.PiE_dflt A d B

goal (1 subgoal):
 1. card (Pi_pmf.PiE_dflt A d B) = (\<Prod>x\<in>A. card (B x))
[PROOF STEP]
have "card \<dots> = card (PiE_dflt A d B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card ((\<lambda>f. restrict f A) ` Pi_pmf.PiE_dflt A d B) = card (Pi_pmf.PiE_dflt A d B)
[PROOF STEP]
by (intro card_image) (force simp: inj_on_def restrict_def fun_eq_iff PiE_dflt_def)
[PROOF STATE]
proof (state)
this:
card ((\<lambda>f. restrict f A) ` Pi_pmf.PiE_dflt A d B) = card (Pi_pmf.PiE_dflt A d B)

goal (1 subgoal):
 1. card (Pi_pmf.PiE_dflt A d B) = (\<Prod>x\<in>A. card (B x))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(\<Prod>x\<in>A. card (B x)) = card (Pi_pmf.PiE_dflt A d B)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(\<Prod>x\<in>A. card (B x)) = card (Pi_pmf.PiE_dflt A d B)

goal (1 subgoal):
 1. card (Pi_pmf.PiE_dflt A d B) = (\<Prod>x\<in>A. card (B x))
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
card (Pi_pmf.PiE_dflt A d B) = (\<Prod>x\<in>A. card (B x))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma spmf_False_conv_True: "lossless_spmf p \<Longrightarrow> spmf p False = 1 - spmf p True"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. lossless_spmf p \<Longrightarrow> spmf p False = 1 - spmf p True
[PROOF STEP]
by(clarsimp simp add: lossless_spmf_conv_spmf_of_pmf pmf_False_conv_True)


[STATEMENT]
lemma Re_powr_le: "r \<in> \<real>\<^sub>\<ge>\<^sub>0 \<Longrightarrow> Re (r powr z) \<le> Re r powr Re z"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. r \<in> \<real>\<^sub>\<ge>\<^sub>0 \<Longrightarrow> Re (r powr z) \<le> Re r powr Re z
[PROOF STEP]
by (auto simp: powr_def nonneg_Reals_def order_trans [OF complex_Re_le_cmod])


[STATEMENT]
lemma dotprod_le_take:
  assumes "length a = length b"
    and "k \<le> length a"
  shows"take k a \<bullet> take k b \<le> a \<bullet> b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. take k a \<bullet> take k b \<le> a \<bullet> b
[PROOF STEP]
using assms and append_take_drop_id [of k a] and append_take_drop_id [of k b]
[PROOF STATE]
proof (prove)
using this:
length a = length b
k \<le> length a
take k a @ drop k a = a
take k b @ drop k b = b

goal (1 subgoal):
 1. take k a \<bullet> take k b \<le> a \<bullet> b
[PROOF STEP]
by (metis add_right_cancel leI length_append length_drop not_add_less1 dotprod_append)


[STATEMENT]
lemma lookup_None_iff: "lookup P xs = None \<longleftrightarrow> \<not> (\<exists>x. x \<in> set (map fst xs) \<and> P x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (lookup P xs = None) = (\<nexists>x. x \<in> set (map fst xs) \<and> P x)
[PROOF STEP]
by (induction xs) (auto split: if_splits)


[STATEMENT]
lemma "Second (autodiff logistic x) = ((exp (- x) - 1) * exp (- x)) / ((1 + exp (- x)) ^ 3)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Second (autodiff logistic x) = (exp (- x) - 1) * exp (- x) / (1 + exp (- x)) ^ 3
[PROOF STEP]
(* Move to hyperdual variant: *)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Second (autodiff logistic x) = (exp (- x) - 1) * exp (- x) / (1 + exp (- x)) ^ 3
[PROOF STEP]
apply (simp only: autodiff.simps hyperdual_to_derivs.simps derivs.sel hypext_logistic)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Eps12 (hyp_logistic (\<beta> x)) = (exp (- x) - 1) * exp (- x) / (1 + exp (- x)) ^ 3
[PROOF STEP]
(* Unfold extensions of functions that have a hyperdual variant (all except exp): *)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Eps12 (hyp_logistic (\<beta> x)) = (exp (- x) - 1) * exp (- x) / (1 + exp (- x)) ^ 3
[PROOF STEP]
apply (simp only: hyp_logistic_def inverse_hyperdual.code hyperdual.sel)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 * (Eps1 (1 + (*h* exp) (- \<beta> x)) * Eps2 (1 + (*h* exp) (- \<beta> x)) / Base (1 + (*h* exp) (- \<beta> x)) ^ 3) - Eps12 (1 + (*h* exp) (- \<beta> x)) / (Base (1 + (*h* exp) (- \<beta> x)))\<^sup>2 = (exp (- x) - 1) * exp (- x) / (1 + exp (- x)) ^ 3
[PROOF STEP]
(* Finish by expanding the extension of exp and hyperdual computations: *)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 * (Eps1 (1 + (*h* exp) (- \<beta> x)) * Eps2 (1 + (*h* exp) (- \<beta> x)) / Base (1 + (*h* exp) (- \<beta> x)) ^ 3) - Eps12 (1 + (*h* exp) (- \<beta> x)) / (Base (1 + (*h* exp) (- \<beta> x)))\<^sup>2 = (exp (- x) - 1) * exp (- x) / (1 + exp (- x)) ^ 3
[PROOF STEP]
apply (simp add: hyperdualx_def hypext_exp_Hyperdual hyperdual_bases)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 * (exp (- x) * exp (- x)) / (1 + exp (- x)) ^ 3 - exp (- x) / (1 + exp (- x))\<^sup>2 = (exp (- x) - 1) * exp (- x) / (1 + exp (- x)) ^ 3
[PROOF STEP]
(* Simplify the resulting expression: *)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 * (exp (- x) * exp (- x)) / (1 + exp (- x)) ^ 3 - exp (- x) / (1 + exp (- x))\<^sup>2 = (exp (- x) - 1) * exp (- x) / (1 + exp (- x)) ^ 3
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. 2 * (exp (- x) * exp (- x)) / (1 + exp (- x)) ^ 3 - exp (- x) / (1 + exp (- x))\<^sup>2 = (exp (- x) - 1) * exp (- x) / (1 + exp (- x)) ^ 3
[PROOF STEP]
have
    "2 * (exp (- x) * exp (- x)) / (1 + exp (- x)) ^ 3 - exp (- x) / (1 + exp (- x)) ^ 2 =
     (2 * exp (- x) / (1 + exp (- x)) ^ 3 - 1 / (1 + exp (- x)) ^ 2) * exp (- x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 * (exp (- x) * exp (- x)) / (1 + exp (- x)) ^ 3 - exp (- x) / (1 + exp (- x))\<^sup>2 = (2 * exp (- x) / (1 + exp (- x)) ^ 3 - 1 / (1 + exp (- x))\<^sup>2) * exp (- x)
[PROOF STEP]
by (simp add: field_simps)
[PROOF STATE]
proof (state)
this:
2 * (exp (- x) * exp (- x)) / (1 + exp (- x)) ^ 3 - exp (- x) / (1 + exp (- x))\<^sup>2 = (2 * exp (- x) / (1 + exp (- x)) ^ 3 - 1 / (1 + exp (- x))\<^sup>2) * exp (- x)

goal (1 subgoal):
 1. 2 * (exp (- x) * exp (- x)) / (1 + exp (- x)) ^ 3 - exp (- x) / (1 + exp (- x))\<^sup>2 = (exp (- x) - 1) * exp (- x) / (1 + exp (- x)) ^ 3
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
2 * (exp (- x) * exp (- x)) / (1 + exp (- x)) ^ 3 - exp (- x) / (1 + exp (- x))\<^sup>2 = (2 * exp (- x) / (1 + exp (- x)) ^ 3 - 1 / (1 + exp (- x))\<^sup>2) * exp (- x)

goal (1 subgoal):
 1. 2 * (exp (- x) * exp (- x)) / (1 + exp (- x)) ^ 3 - exp (- x) / (1 + exp (- x))\<^sup>2 = (exp (- x) - 1) * exp (- x) / (1 + exp (- x)) ^ 3
[PROOF STEP]
have "... = (2 * exp (- x) / (1 + exp (- x)) ^ 3 - (1 + exp (- x)) / (1 + exp (- x)) ^ 3) * exp (- x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (2 * exp (- x) / (1 + exp (- x)) ^ 3 - 1 / (1 + exp (- x))\<^sup>2) * exp (- x) = (2 * exp (- x) / (1 + exp (- x)) ^ 3 - (1 + exp (- x)) / (1 + exp (- x)) ^ 3) * exp (- x)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (2 * exp (- x) / (1 + exp (- x)) ^ 3 - 1 / (1 + exp (- x))\<^sup>2) * exp (- x) = (2 * exp (- x) / (1 + exp (- x)) ^ 3 - (1 + exp (- x)) / (1 + exp (- x)) ^ 3) * exp (- x)
[PROOF STEP]
have "inverse ((1 + exp (- x)) ^ 2) = inverse (1 + exp (- x)) ^ 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inverse ((1 + exp (- x))\<^sup>2) = (inverse (1 + exp (- x)))\<^sup>2
[PROOF STEP]
by (simp add: power_inverse)
[PROOF STATE]
proof (state)
this:
inverse ((1 + exp (- x))\<^sup>2) = (inverse (1 + exp (- x)))\<^sup>2

goal (1 subgoal):
 1. (2 * exp (- x) / (1 + exp (- x)) ^ 3 - 1 / (1 + exp (- x))\<^sup>2) * exp (- x) = (2 * exp (- x) / (1 + exp (- x)) ^ 3 - (1 + exp (- x)) / (1 + exp (- x)) ^ 3) * exp (- x)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
inverse ((1 + exp (- x))\<^sup>2) = (inverse (1 + exp (- x)))\<^sup>2

goal (1 subgoal):
 1. (2 * exp (- x) / (1 + exp (- x)) ^ 3 - 1 / (1 + exp (- x))\<^sup>2) * exp (- x) = (2 * exp (- x) / (1 + exp (- x)) ^ 3 - (1 + exp (- x)) / (1 + exp (- x)) ^ 3) * exp (- x)
[PROOF STEP]
have "... = (1 + exp (- x)) * inverse (1 + exp (- x)) * inverse (1 + exp (- x)) ^ 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (inverse (1 + exp (- x)))\<^sup>2 = (1 + exp (- x)) * inverse (1 + exp (- x)) * (inverse (1 + exp (- x)))\<^sup>2
[PROOF STEP]
by (simp add: inverse_eq_divide)
[PROOF STATE]
proof (state)
this:
(inverse (1 + exp (- x)))\<^sup>2 = (1 + exp (- x)) * inverse (1 + exp (- x)) * (inverse (1 + exp (- x)))\<^sup>2

goal (1 subgoal):
 1. (2 * exp (- x) / (1 + exp (- x)) ^ 3 - 1 / (1 + exp (- x))\<^sup>2) * exp (- x) = (2 * exp (- x) / (1 + exp (- x)) ^ 3 - (1 + exp (- x)) / (1 + exp (- x)) ^ 3) * exp (- x)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(inverse (1 + exp (- x)))\<^sup>2 = (1 + exp (- x)) * inverse (1 + exp (- x)) * (inverse (1 + exp (- x)))\<^sup>2

goal (1 subgoal):
 1. (2 * exp (- x) / (1 + exp (- x)) ^ 3 - 1 / (1 + exp (- x))\<^sup>2) * exp (- x) = (2 * exp (- x) / (1 + exp (- x)) ^ 3 - (1 + exp (- x)) / (1 + exp (- x)) ^ 3) * exp (- x)
[PROOF STEP]
have "... = (1 + exp (- x)) * inverse (1 + exp (- x)) ^ 3"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (1 + exp (- x)) * inverse (1 + exp (- x)) * (inverse (1 + exp (- x)))\<^sup>2 = (1 + exp (- x)) * inverse (1 + exp (- x)) ^ 3
[PROOF STEP]
by (simp add: power2_eq_square power3_eq_cube)
[PROOF STATE]
proof (state)
this:
(1 + exp (- x)) * inverse (1 + exp (- x)) * (inverse (1 + exp (- x)))\<^sup>2 = (1 + exp (- x)) * inverse (1 + exp (- x)) ^ 3

goal (1 subgoal):
 1. (2 * exp (- x) / (1 + exp (- x)) ^ 3 - 1 / (1 + exp (- x))\<^sup>2) * exp (- x) = (2 * exp (- x) / (1 + exp (- x)) ^ 3 - (1 + exp (- x)) / (1 + exp (- x)) ^ 3) * exp (- x)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
inverse ((1 + exp (- x))\<^sup>2) = (1 + exp (- x)) * inverse (1 + exp (- x)) ^ 3
[PROOF STEP]
have "inverse ((1 + exp (- x)) ^ 2) = (1 + exp (- x)) * inverse ((1 + exp (- x)) ^ 3)"
[PROOF STATE]
proof (prove)
using this:
inverse ((1 + exp (- x))\<^sup>2) = (1 + exp (- x)) * inverse (1 + exp (- x)) ^ 3

goal (1 subgoal):
 1. inverse ((1 + exp (- x))\<^sup>2) = (1 + exp (- x)) * inverse ((1 + exp (- x)) ^ 3)
[PROOF STEP]
by (simp add: power_inverse)
[PROOF STATE]
proof (state)
this:
inverse ((1 + exp (- x))\<^sup>2) = (1 + exp (- x)) * inverse ((1 + exp (- x)) ^ 3)

goal (1 subgoal):
 1. (2 * exp (- x) / (1 + exp (- x)) ^ 3 - 1 / (1 + exp (- x))\<^sup>2) * exp (- x) = (2 * exp (- x) / (1 + exp (- x)) ^ 3 - (1 + exp (- x)) / (1 + exp (- x)) ^ 3) * exp (- x)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
inverse ((1 + exp (- x))\<^sup>2) = (1 + exp (- x)) * inverse ((1 + exp (- x)) ^ 3)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
inverse ((1 + exp (- x))\<^sup>2) = (1 + exp (- x)) * inverse ((1 + exp (- x)) ^ 3)

goal (1 subgoal):
 1. (2 * exp (- x) / (1 + exp (- x)) ^ 3 - 1 / (1 + exp (- x))\<^sup>2) * exp (- x) = (2 * exp (- x) / (1 + exp (- x)) ^ 3 - (1 + exp (- x)) / (1 + exp (- x)) ^ 3) * exp (- x)
[PROOF STEP]
by (simp add: inverse_eq_divide)
[PROOF STATE]
proof (state)
this:
(2 * exp (- x) / (1 + exp (- x)) ^ 3 - 1 / (1 + exp (- x))\<^sup>2) * exp (- x) = (2 * exp (- x) / (1 + exp (- x)) ^ 3 - (1 + exp (- x)) / (1 + exp (- x)) ^ 3) * exp (- x)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(2 * exp (- x) / (1 + exp (- x)) ^ 3 - 1 / (1 + exp (- x))\<^sup>2) * exp (- x) = (2 * exp (- x) / (1 + exp (- x)) ^ 3 - (1 + exp (- x)) / (1 + exp (- x)) ^ 3) * exp (- x)

goal (1 subgoal):
 1. 2 * (exp (- x) * exp (- x)) / (1 + exp (- x)) ^ 3 - exp (- x) / (1 + exp (- x))\<^sup>2 = (exp (- x) - 1) * exp (- x) / (1 + exp (- x)) ^ 3
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(2 * exp (- x) / (1 + exp (- x)) ^ 3 - 1 / (1 + exp (- x))\<^sup>2) * exp (- x) = (2 * exp (- x) / (1 + exp (- x)) ^ 3 - (1 + exp (- x)) / (1 + exp (- x)) ^ 3) * exp (- x)

goal (1 subgoal):
 1. 2 * (exp (- x) * exp (- x)) / (1 + exp (- x)) ^ 3 - exp (- x) / (1 + exp (- x))\<^sup>2 = (exp (- x) - 1) * exp (- x) / (1 + exp (- x)) ^ 3
[PROOF STEP]
have "... = (2 * exp (- x) - (1 + exp (- x))) / (1 + exp (- x)) ^ 3 * exp (- x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (2 * exp (- x) / (1 + exp (- x)) ^ 3 - (1 + exp (- x)) / (1 + exp (- x)) ^ 3) * exp (- x) = (2 * exp (- x) - (1 + exp (- x))) / (1 + exp (- x)) ^ 3 * exp (- x)
[PROOF STEP]
by (metis diff_divide_distrib)
[PROOF STATE]
proof (state)
this:
(2 * exp (- x) / (1 + exp (- x)) ^ 3 - (1 + exp (- x)) / (1 + exp (- x)) ^ 3) * exp (- x) = (2 * exp (- x) - (1 + exp (- x))) / (1 + exp (- x)) ^ 3 * exp (- x)

goal (1 subgoal):
 1. 2 * (exp (- x) * exp (- x)) / (1 + exp (- x)) ^ 3 - exp (- x) / (1 + exp (- x))\<^sup>2 = (exp (- x) - 1) * exp (- x) / (1 + exp (- x)) ^ 3
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
2 * (exp (- x) * exp (- x)) / (1 + exp (- x)) ^ 3 - exp (- x) / (1 + exp (- x))\<^sup>2 = (2 * exp (- x) - (1 + exp (- x))) / (1 + exp (- x)) ^ 3 * exp (- x)
[PROOF STEP]
show
    "2 * (exp (- x) * exp (- x)) / (1 + exp (- x)) ^ 3 - exp (- x) / (1 + exp (- x))\<^sup>2 =
     (exp (- x) - 1) * exp (- x) / (1 + exp (- x)) ^ 3"
[PROOF STATE]
proof (prove)
using this:
2 * (exp (- x) * exp (- x)) / (1 + exp (- x)) ^ 3 - exp (- x) / (1 + exp (- x))\<^sup>2 = (2 * exp (- x) - (1 + exp (- x))) / (1 + exp (- x)) ^ 3 * exp (- x)

goal (1 subgoal):
 1. 2 * (exp (- x) * exp (- x)) / (1 + exp (- x)) ^ 3 - exp (- x) / (1 + exp (- x))\<^sup>2 = (exp (- x) - 1) * exp (- x) / (1 + exp (- x)) ^ 3
[PROOF STEP]
by (simp add: field_simps)
[PROOF STATE]
proof (state)
this:
2 * (exp (- x) * exp (- x)) / (1 + exp (- x)) ^ 3 - exp (- x) / (1 + exp (- x))\<^sup>2 = (exp (- x) - 1) * exp (- x) / (1 + exp (- x)) ^ 3

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma lnths_upt_eq_ltake [simp]:
  "lnths xs {..<n} = ltake (enat n) xs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. lnths xs {..<n} = ltake (enat n) xs
[PROOF STEP]
apply(rule sym)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ltake (enat n) xs = lnths xs {..<n}
[PROOF STEP]
proof(induct n arbitrary: xs)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>xs. ltake (enat 0) xs = lnths xs {..<0}
 2. \<And>n xs. (\<And>xs. ltake (enat n) xs = lnths xs {..<n}) \<Longrightarrow> ltake (enat (Suc n)) xs = lnths xs {..<Suc n}
[PROOF STEP]
case 0
[PROOF STATE]
proof (state)
this:

goal (2 subgoals):
 1. \<And>xs. ltake (enat 0) xs = lnths xs {..<0}
 2. \<And>n xs. (\<And>xs. ltake (enat n) xs = lnths xs {..<n}) \<Longrightarrow> ltake (enat (Suc n)) xs = lnths xs {..<Suc n}
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ltake (enat 0) xs = lnths xs {..<0}
[PROOF STEP]
by(simp add: zero_enat_def[symmetric])
[PROOF STATE]
proof (state)
this:
ltake (enat 0) xs = lnths xs {..<0}

goal (1 subgoal):
 1. \<And>n xs. (\<And>xs. ltake (enat n) xs = lnths xs {..<n}) \<Longrightarrow> ltake (enat (Suc n)) xs = lnths xs {..<Suc n}
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n xs. (\<And>xs. ltake (enat n) xs = lnths xs {..<n}) \<Longrightarrow> ltake (enat (Suc n)) xs = lnths xs {..<Suc n}
[PROOF STEP]
case (Suc n)
[PROOF STATE]
proof (state)
this:
ltake (enat n) ?xs = lnths ?xs {..<n}

goal (1 subgoal):
 1. \<And>n xs. (\<And>xs. ltake (enat n) xs = lnths xs {..<n}) \<Longrightarrow> ltake (enat (Suc n)) xs = lnths xs {..<Suc n}
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
using this:
ltake (enat n) ?xs = lnths ?xs {..<n}

goal (1 subgoal):
 1. ltake (enat (Suc n)) xs = lnths xs {..<Suc n}
[PROOF STEP]
by(cases xs)(simp_all add: eSuc_enat[symmetric] lnths_LCons lessThan_def)
[PROOF STATE]
proof (state)
this:
ltake (enat (Suc n)) xs = lnths xs {..<Suc n}

goal:
No subgoals!
[PROOF STEP]
qed