[STATEMENT]
lemma (in real_distribution) char_approx1:
  assumes integrable_moments: "\<And>k. k \<le> n \<Longrightarrow> integrable M (\<lambda>x. x^k)"
  shows "cmod (char M t - (\<Sum>k \<le> n. ((\<i> * t)^k / fact k) * expectation (\<lambda>x. x^k))) \<le>
    (2*\<bar>t\<bar>^n / fact n) * expectation (\<lambda>x. \<bar>x\<bar>^n)" (is "cmod (char M t - ?t1) \<le> _")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cmod (char M t - (\<Sum>k\<le>n. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (expectation (\<lambda>x. x ^ k)))) \<le> 2 * \<bar>t\<bar> ^ n / fact n * expectation (\<lambda>x. \<bar>x\<bar> ^ n)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. cmod (char M t - (\<Sum>k\<le>n. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (expectation (\<lambda>x. x ^ k)))) \<le> 2 * \<bar>t\<bar> ^ n / fact n * expectation (\<lambda>x. \<bar>x\<bar> ^ n)
[PROOF STEP]
have integ_iexp: "integrable M (\<lambda>x. iexp (t * x))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. complex_integrable M (\<lambda>x. iexp (t * x))
[PROOF STEP]
by (intro integrable_const_bound) auto
[PROOF STATE]
proof (state)
this:
complex_integrable M (\<lambda>x. iexp (t * x))

goal (1 subgoal):
 1. cmod (char M t - (\<Sum>k\<le>n. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (expectation (\<lambda>x. x ^ k)))) \<le> 2 * \<bar>t\<bar> ^ n / fact n * expectation (\<lambda>x. \<bar>x\<bar> ^ n)
[PROOF STEP]
define c where [abs_def]: "c k x = (\<i> * t)^k / fact k * complex_of_real (x^k)" for k x
[PROOF STATE]
proof (state)
this:
c \<equiv> \<lambda>k x. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (x ^ k)

goal (1 subgoal):
 1. cmod (char M t - (\<Sum>k\<le>n. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (expectation (\<lambda>x. x ^ k)))) \<le> 2 * \<bar>t\<bar> ^ n / fact n * expectation (\<lambda>x. \<bar>x\<bar> ^ n)
[PROOF STEP]
have integ_c: "\<And>k. k \<le> n \<Longrightarrow> integrable M (\<lambda>x. c k x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>k. k \<le> n \<Longrightarrow> complex_integrable M (c k)
[PROOF STEP]
unfolding c_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>k. k \<le> n \<Longrightarrow> complex_integrable M (\<lambda>x. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (x ^ k))
[PROOF STEP]
by (intro integrable_mult_right integrable_of_real integrable_moments)
[PROOF STATE]
proof (state)
this:
?k12 \<le> n \<Longrightarrow> complex_integrable M (c ?k12)

goal (1 subgoal):
 1. cmod (char M t - (\<Sum>k\<le>n. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (expectation (\<lambda>x. x ^ k)))) \<le> 2 * \<bar>t\<bar> ^ n / fact n * expectation (\<lambda>x. \<bar>x\<bar> ^ n)
[PROOF STEP]
have "k \<le> n \<Longrightarrow> expectation (c k) = (\<i>*t) ^ k * (expectation (\<lambda>x. x ^ k)) / fact k" for k
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. k \<le> n \<Longrightarrow> expectation (c k) = (\<i> * complex_of_real t) ^ k * complex_of_real (expectation (\<lambda>x. x ^ k)) / fact k
[PROOF STEP]
unfolding c_def integral_mult_right_zero integral_complex_of_real
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. k \<le> n \<Longrightarrow> (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (expectation (\<lambda>x. x ^ k)) = (\<i> * complex_of_real t) ^ k * complex_of_real (expectation (\<lambda>x. x ^ k)) / fact k
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
?k12 \<le> n \<Longrightarrow> expectation (c ?k12) = (\<i> * complex_of_real t) ^ ?k12 * complex_of_real (expectation (\<lambda>x. x ^ ?k12)) / fact ?k12

goal (1 subgoal):
 1. cmod (char M t - (\<Sum>k\<le>n. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (expectation (\<lambda>x. x ^ k)))) \<le> 2 * \<bar>t\<bar> ^ n / fact n * expectation (\<lambda>x. \<bar>x\<bar> ^ n)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
?k12 \<le> n \<Longrightarrow> expectation (c ?k12) = (\<i> * complex_of_real t) ^ ?k12 * complex_of_real (expectation (\<lambda>x. x ^ ?k12)) / fact ?k12
[PROOF STEP]
have "norm (char M t - ?t1) = norm (char M t - (CLINT x | M. (\<Sum>k \<le> n. c k x)))"
[PROOF STATE]
proof (prove)
using this:
?k12 \<le> n \<Longrightarrow> expectation (c ?k12) = (\<i> * complex_of_real t) ^ ?k12 * complex_of_real (expectation (\<lambda>x. x ^ ?k12)) / fact ?k12

goal (1 subgoal):
 1. cmod (char M t - (\<Sum>k\<le>n. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (expectation (\<lambda>x. x ^ k)))) = cmod (char M t - expectation (\<lambda>x. \<Sum>k\<le>n. c k x))
[PROOF STEP]
by (simp add: integ_c)
[PROOF STATE]
proof (state)
this:
cmod (char M t - (\<Sum>k\<le>n. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (expectation (\<lambda>x. x ^ k)))) = cmod (char M t - expectation (\<lambda>x. \<Sum>k\<le>n. c k x))

goal (1 subgoal):
 1. cmod (char M t - (\<Sum>k\<le>n. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (expectation (\<lambda>x. x ^ k)))) \<le> 2 * \<bar>t\<bar> ^ n / fact n * expectation (\<lambda>x. \<bar>x\<bar> ^ n)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
cmod (char M t - (\<Sum>k\<le>n. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (expectation (\<lambda>x. x ^ k)))) = cmod (char M t - expectation (\<lambda>x. \<Sum>k\<le>n. c k x))

goal (1 subgoal):
 1. cmod (char M t - (\<Sum>k\<le>n. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (expectation (\<lambda>x. x ^ k)))) \<le> 2 * \<bar>t\<bar> ^ n / fact n * expectation (\<lambda>x. \<bar>x\<bar> ^ n)
[PROOF STEP]
have "\<dots> = norm ((CLINT x | M. iexp (t * x) - (\<Sum>k \<le> n. c k x)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cmod (char M t - expectation (\<lambda>x. \<Sum>k\<le>n. c k x)) = cmod (expectation (\<lambda>x. iexp (t * x) - (\<Sum>k\<le>n. c k x)))
[PROOF STEP]
unfolding char_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cmod (expectation (\<lambda>x. iexp (t * x)) - expectation (\<lambda>x. \<Sum>k\<le>n. c k x)) = cmod (expectation (\<lambda>x. iexp (t * x) - (\<Sum>k\<le>n. c k x)))
[PROOF STEP]
by (subst Bochner_Integration.integral_diff[OF integ_iexp]) (auto intro!: integ_c)
[PROOF STATE]
proof (state)
this:
cmod (char M t - expectation (\<lambda>x. \<Sum>k\<le>n. c k x)) = cmod (expectation (\<lambda>x. iexp (t * x) - (\<Sum>k\<le>n. c k x)))

goal (1 subgoal):
 1. cmod (char M t - (\<Sum>k\<le>n. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (expectation (\<lambda>x. x ^ k)))) \<le> 2 * \<bar>t\<bar> ^ n / fact n * expectation (\<lambda>x. \<bar>x\<bar> ^ n)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
cmod (char M t - expectation (\<lambda>x. \<Sum>k\<le>n. c k x)) = cmod (expectation (\<lambda>x. iexp (t * x) - (\<Sum>k\<le>n. c k x)))

goal (1 subgoal):
 1. cmod (char M t - (\<Sum>k\<le>n. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (expectation (\<lambda>x. x ^ k)))) \<le> 2 * \<bar>t\<bar> ^ n / fact n * expectation (\<lambda>x. \<bar>x\<bar> ^ n)
[PROOF STEP]
have "\<dots> \<le> expectation (\<lambda>x. cmod (iexp (t * x) - (\<Sum>k \<le> n. c k x)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cmod (expectation (\<lambda>x. iexp (t * x) - (\<Sum>k\<le>n. c k x))) \<le> expectation (\<lambda>x. cmod (iexp (t * x) - (\<Sum>k\<le>n. c k x)))
[PROOF STEP]
by (intro integral_norm_bound)
[PROOF STATE]
proof (state)
this:
cmod (expectation (\<lambda>x. iexp (t * x) - (\<Sum>k\<le>n. c k x))) \<le> expectation (\<lambda>x. cmod (iexp (t * x) - (\<Sum>k\<le>n. c k x)))

goal (1 subgoal):
 1. cmod (char M t - (\<Sum>k\<le>n. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (expectation (\<lambda>x. x ^ k)))) \<le> 2 * \<bar>t\<bar> ^ n / fact n * expectation (\<lambda>x. \<bar>x\<bar> ^ n)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
cmod (expectation (\<lambda>x. iexp (t * x) - (\<Sum>k\<le>n. c k x))) \<le> expectation (\<lambda>x. cmod (iexp (t * x) - (\<Sum>k\<le>n. c k x)))

goal (1 subgoal):
 1. cmod (char M t - (\<Sum>k\<le>n. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (expectation (\<lambda>x. x ^ k)))) \<le> 2 * \<bar>t\<bar> ^ n / fact n * expectation (\<lambda>x. \<bar>x\<bar> ^ n)
[PROOF STEP]
have "\<dots> \<le> expectation (\<lambda>x. 2 * \<bar>t\<bar> ^ n / fact n * \<bar>x\<bar> ^ n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. expectation (\<lambda>x. cmod (iexp (t * x) - (\<Sum>k\<le>n. c k x))) \<le> expectation (\<lambda>x. 2 * \<bar>t\<bar> ^ n / fact n * \<bar>x\<bar> ^ n)
[PROOF STEP]
proof (rule integral_mono)
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. integrable M (\<lambda>x. cmod (iexp (t * x) - (\<Sum>k\<le>n. c k x)))
 2. integrable M (\<lambda>x. 2 * \<bar>t\<bar> ^ n / fact n * \<bar>x\<bar> ^ n)
 3. \<And>x. x \<in> space M \<Longrightarrow> cmod (iexp (t * x) - (\<Sum>k\<le>n. c k x)) \<le> 2 * \<bar>t\<bar> ^ n / fact n * \<bar>x\<bar> ^ n
[PROOF STEP]
show "integrable M (\<lambda>x. cmod (iexp (t * x) - (\<Sum>k\<le>n. c k x)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. integrable M (\<lambda>x. cmod (iexp (t * x) - (\<Sum>k\<le>n. c k x)))
[PROOF STEP]
by (intro integrable_norm Bochner_Integration.integrable_diff integ_iexp Bochner_Integration.integrable_sum integ_c) simp
[PROOF STATE]
proof (state)
this:
integrable M (\<lambda>x. cmod (iexp (t * x) - (\<Sum>k\<le>n. c k x)))

goal (2 subgoals):
 1. integrable M (\<lambda>x. 2 * \<bar>t\<bar> ^ n / fact n * \<bar>x\<bar> ^ n)
 2. \<And>x. x \<in> space M \<Longrightarrow> cmod (iexp (t * x) - (\<Sum>k\<le>n. c k x)) \<le> 2 * \<bar>t\<bar> ^ n / fact n * \<bar>x\<bar> ^ n
[PROOF STEP]
show "integrable M (\<lambda>x. 2 * \<bar>t\<bar> ^ n / fact n * \<bar>x\<bar> ^ n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. integrable M (\<lambda>x. 2 * \<bar>t\<bar> ^ n / fact n * \<bar>x\<bar> ^ n)
[PROOF STEP]
unfolding power_abs[symmetric]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. integrable M (\<lambda>x. 2 * \<bar>t ^ n\<bar> / fact n * \<bar>x ^ n\<bar>)
[PROOF STEP]
by (intro integrable_mult_right integrable_abs integrable_moments) simp
[PROOF STATE]
proof (state)
this:
integrable M (\<lambda>x. 2 * \<bar>t\<bar> ^ n / fact n * \<bar>x\<bar> ^ n)

goal (1 subgoal):
 1. \<And>x. x \<in> space M \<Longrightarrow> cmod (iexp (t * x) - (\<Sum>k\<le>n. c k x)) \<le> 2 * \<bar>t\<bar> ^ n / fact n * \<bar>x\<bar> ^ n
[PROOF STEP]
show "cmod (iexp (t * x) - (\<Sum>k\<le>n. c k x)) \<le> 2 * \<bar>t\<bar> ^ n / fact n * \<bar>x\<bar> ^ n" for x
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cmod (iexp (t * x) - (\<Sum>k\<le>n. c k x)) \<le> 2 * \<bar>t\<bar> ^ n / fact n * \<bar>x\<bar> ^ n
[PROOF STEP]
using iexp_approx2[of "t * x" n]
[PROOF STATE]
proof (prove)
using this:
cmod (iexp (t * x) - (\<Sum>k\<le>n. (\<i> * complex_of_real (t * x)) ^ k / fact k)) \<le> 2 * \<bar>t * x\<bar> ^ n / fact n

goal (1 subgoal):
 1. cmod (iexp (t * x) - (\<Sum>k\<le>n. c k x)) \<le> 2 * \<bar>t\<bar> ^ n / fact n * \<bar>x\<bar> ^ n
[PROOF STEP]
by (auto simp add: abs_mult field_simps c_def)
[PROOF STATE]
proof (state)
this:
cmod (iexp (t * ?x12) - (\<Sum>k\<le>n. c k ?x12)) \<le> 2 * \<bar>t\<bar> ^ n / fact n * \<bar>?x12\<bar> ^ n

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
expectation (\<lambda>x. cmod (iexp (t * x) - (\<Sum>k\<le>n. c k x))) \<le> expectation (\<lambda>x. 2 * \<bar>t\<bar> ^ n / fact n * \<bar>x\<bar> ^ n)

goal (1 subgoal):
 1. cmod (char M t - (\<Sum>k\<le>n. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (expectation (\<lambda>x. x ^ k)))) \<le> 2 * \<bar>t\<bar> ^ n / fact n * expectation (\<lambda>x. \<bar>x\<bar> ^ n)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
cmod (char M t - (\<Sum>k\<le>n. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (expectation (\<lambda>x. x ^ k)))) \<le> expectation (\<lambda>x. 2 * \<bar>t\<bar> ^ n / fact n * \<bar>x\<bar> ^ n)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
cmod (char M t - (\<Sum>k\<le>n. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (expectation (\<lambda>x. x ^ k)))) \<le> expectation (\<lambda>x. 2 * \<bar>t\<bar> ^ n / fact n * \<bar>x\<bar> ^ n)

goal (1 subgoal):
 1. cmod (char M t - (\<Sum>k\<le>n. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (expectation (\<lambda>x. x ^ k)))) \<le> 2 * \<bar>t\<bar> ^ n / fact n * expectation (\<lambda>x. \<bar>x\<bar> ^ n)
[PROOF STEP]
unfolding integral_mult_right_zero
[PROOF STATE]
proof (prove)
using this:
cmod (char M t - (\<Sum>k\<le>n. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (expectation (\<lambda>x. x ^ k)))) \<le> 2 * \<bar>t\<bar> ^ n / fact n * expectation (\<lambda>x. \<bar>x\<bar> ^ n)

goal (1 subgoal):
 1. cmod (char M t - (\<Sum>k\<le>n. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (expectation (\<lambda>x. x ^ k)))) \<le> 2 * \<bar>t\<bar> ^ n / fact n * expectation (\<lambda>x. \<bar>x\<bar> ^ n)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
cmod (char M t - (\<Sum>k\<le>n. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (expectation (\<lambda>x. x ^ k)))) \<le> 2 * \<bar>t\<bar> ^ n / fact n * expectation (\<lambda>x. \<bar>x\<bar> ^ n)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma parent_l_child[simp]: "parent l (l_child l n) = n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. parent l (l_child l n) = n
[PROOF STEP]
unfolding parent_def l_child_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. l + (2 * n - l + 1 - l - 1) div 2 = n
[PROOF STEP]
by simp


[STATEMENT]
lemma check_prime_factors_subset_correct:
  assumes "check_prime_factors_subset n ps" "list_all prime ps"
  shows   "prime_factors n \<subseteq> set ps"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. prime_factors n \<subseteq> set ps
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
check_prime_factors_subset n ps
list_all prime ps

goal (1 subgoal):
 1. prime_factors n \<subseteq> set ps
[PROOF STEP]
proof (induction n ps rule: check_prime_factors_subset.induct)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>n. \<lbrakk>check_prime_factors_subset n []; list_all prime []\<rbrakk> \<Longrightarrow> prime_factors n \<subseteq> set []
 2. \<And>n p ps. \<lbrakk>\<lbrakk>n \<noteq> 0; 1 < p \<and> p dvd n; check_prime_factors_subset (n div p) (p # ps); list_all prime (p # ps)\<rbrakk> \<Longrightarrow> prime_factors (n div p) \<subseteq> set (p # ps); \<lbrakk>n \<noteq> 0; \<not> (1 < p \<and> p dvd n); check_prime_factors_subset n ps; list_all prime ps\<rbrakk> \<Longrightarrow> prime_factors n \<subseteq> set ps; check_prime_factors_subset n (p # ps); list_all prime (p # ps)\<rbrakk> \<Longrightarrow> prime_factors n \<subseteq> set (p # ps)
[PROOF STEP]
case (2 n p ps)
[PROOF STATE]
proof (state)
this:
\<lbrakk>n \<noteq> 0; 1 < p \<and> p dvd n; check_prime_factors_subset (n div p) (p # ps); list_all prime (p # ps)\<rbrakk> \<Longrightarrow> prime_factors (n div p) \<subseteq> set (p # ps)
\<lbrakk>n \<noteq> 0; \<not> (1 < p \<and> p dvd n); check_prime_factors_subset n ps; list_all prime ps\<rbrakk> \<Longrightarrow> prime_factors n \<subseteq> set ps
check_prime_factors_subset n (p # ps)
list_all prime (p # ps)

goal (2 subgoals):
 1. \<And>n. \<lbrakk>check_prime_factors_subset n []; list_all prime []\<rbrakk> \<Longrightarrow> prime_factors n \<subseteq> set []
 2. \<And>n p ps. \<lbrakk>\<lbrakk>n \<noteq> 0; 1 < p \<and> p dvd n; check_prime_factors_subset (n div p) (p # ps); list_all prime (p # ps)\<rbrakk> \<Longrightarrow> prime_factors (n div p) \<subseteq> set (p # ps); \<lbrakk>n \<noteq> 0; \<not> (1 < p \<and> p dvd n); check_prime_factors_subset n ps; list_all prime ps\<rbrakk> \<Longrightarrow> prime_factors n \<subseteq> set ps; check_prime_factors_subset n (p # ps); list_all prime (p # ps)\<rbrakk> \<Longrightarrow> prime_factors n \<subseteq> set (p # ps)
[PROOF STEP]
note * = this
[PROOF STATE]
proof (state)
this:
\<lbrakk>n \<noteq> 0; 1 < p \<and> p dvd n; check_prime_factors_subset (n div p) (p # ps); list_all prime (p # ps)\<rbrakk> \<Longrightarrow> prime_factors (n div p) \<subseteq> set (p # ps)
\<lbrakk>n \<noteq> 0; \<not> (1 < p \<and> p dvd n); check_prime_factors_subset n ps; list_all prime ps\<rbrakk> \<Longrightarrow> prime_factors n \<subseteq> set ps
check_prime_factors_subset n (p # ps)
list_all prime (p # ps)

goal (2 subgoals):
 1. \<And>n. \<lbrakk>check_prime_factors_subset n []; list_all prime []\<rbrakk> \<Longrightarrow> prime_factors n \<subseteq> set []
 2. \<And>n p ps. \<lbrakk>\<lbrakk>n \<noteq> 0; 1 < p \<and> p dvd n; check_prime_factors_subset (n div p) (p # ps); list_all prime (p # ps)\<rbrakk> \<Longrightarrow> prime_factors (n div p) \<subseteq> set (p # ps); \<lbrakk>n \<noteq> 0; \<not> (1 < p \<and> p dvd n); check_prime_factors_subset n ps; list_all prime ps\<rbrakk> \<Longrightarrow> prime_factors n \<subseteq> set ps; check_prime_factors_subset n (p # ps); list_all prime (p # ps)\<rbrakk> \<Longrightarrow> prime_factors n \<subseteq> set (p # ps)
[PROOF STEP]
from "2.prems"
[PROOF STATE]
proof (chain)
picking this:
check_prime_factors_subset n (p # ps)
list_all prime (p # ps)
[PROOF STEP]
have "prime p" and "p > 1"
[PROOF STATE]
proof (prove)
using this:
check_prime_factors_subset n (p # ps)
list_all prime (p # ps)

goal (1 subgoal):
 1. prime p &&& 1 < p
[PROOF STEP]
by (auto simp: prime_gt_Suc_0_nat)
[PROOF STATE]
proof (state)
this:
prime p
1 < p

goal (2 subgoals):
 1. \<And>n. \<lbrakk>check_prime_factors_subset n []; list_all prime []\<rbrakk> \<Longrightarrow> prime_factors n \<subseteq> set []
 2. \<And>n p ps. \<lbrakk>\<lbrakk>n \<noteq> 0; 1 < p \<and> p dvd n; check_prime_factors_subset (n div p) (p # ps); list_all prime (p # ps)\<rbrakk> \<Longrightarrow> prime_factors (n div p) \<subseteq> set (p # ps); \<lbrakk>n \<noteq> 0; \<not> (1 < p \<and> p dvd n); check_prime_factors_subset n ps; list_all prime ps\<rbrakk> \<Longrightarrow> prime_factors n \<subseteq> set ps; check_prime_factors_subset n (p # ps); list_all prime (p # ps)\<rbrakk> \<Longrightarrow> prime_factors n \<subseteq> set (p # ps)
[PROOF STEP]
consider "n = 0" | "n > 0" "p dvd n" | "n > 0" "\<not>(p dvd n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>n = 0 \<Longrightarrow> thesis; \<lbrakk>0 < n; p dvd n\<rbrakk> \<Longrightarrow> thesis; \<lbrakk>0 < n; \<not> p dvd n\<rbrakk> \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
\<lbrakk>n = 0 \<Longrightarrow> ?thesis; \<lbrakk>0 < n; p dvd n\<rbrakk> \<Longrightarrow> ?thesis; \<lbrakk>0 < n; \<not> p dvd n\<rbrakk> \<Longrightarrow> ?thesis\<rbrakk> \<Longrightarrow> ?thesis

goal (2 subgoals):
 1. \<And>n. \<lbrakk>check_prime_factors_subset n []; list_all prime []\<rbrakk> \<Longrightarrow> prime_factors n \<subseteq> set []
 2. \<And>n p ps. \<lbrakk>\<lbrakk>n \<noteq> 0; 1 < p \<and> p dvd n; check_prime_factors_subset (n div p) (p # ps); list_all prime (p # ps)\<rbrakk> \<Longrightarrow> prime_factors (n div p) \<subseteq> set (p # ps); \<lbrakk>n \<noteq> 0; \<not> (1 < p \<and> p dvd n); check_prime_factors_subset n ps; list_all prime ps\<rbrakk> \<Longrightarrow> prime_factors n \<subseteq> set ps; check_prime_factors_subset n (p # ps); list_all prime (p # ps)\<rbrakk> \<Longrightarrow> prime_factors n \<subseteq> set (p # ps)
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>n = 0 \<Longrightarrow> ?thesis; \<lbrakk>0 < n; p dvd n\<rbrakk> \<Longrightarrow> ?thesis; \<lbrakk>0 < n; \<not> p dvd n\<rbrakk> \<Longrightarrow> ?thesis\<rbrakk> \<Longrightarrow> ?thesis

goal (1 subgoal):
 1. prime_factors n \<subseteq> set (p # ps)
[PROOF STEP]
proof cases
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. n = 0 \<Longrightarrow> prime_factors n \<subseteq> set (p # ps)
 2. \<lbrakk>0 < n; p dvd n\<rbrakk> \<Longrightarrow> prime_factors n \<subseteq> set (p # ps)
 3. \<lbrakk>0 < n; \<not> p dvd n\<rbrakk> \<Longrightarrow> prime_factors n \<subseteq> set (p # ps)
[PROOF STEP]
case 2
[PROOF STATE]
proof (state)
this:
0 < n
p dvd n

goal (3 subgoals):
 1. n = 0 \<Longrightarrow> prime_factors n \<subseteq> set (p # ps)
 2. \<lbrakk>0 < n; p dvd n\<rbrakk> \<Longrightarrow> prime_factors n \<subseteq> set (p # ps)
 3. \<lbrakk>0 < n; \<not> p dvd n\<rbrakk> \<Longrightarrow> prime_factors n \<subseteq> set (p # ps)
[PROOF STEP]
hence "n div p > 0"
[PROOF STATE]
proof (prove)
using this:
0 < n
p dvd n

goal (1 subgoal):
 1. 0 < n div p
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
0 < n div p

goal (3 subgoals):
 1. n = 0 \<Longrightarrow> prime_factors n \<subseteq> set (p # ps)
 2. \<lbrakk>0 < n; p dvd n\<rbrakk> \<Longrightarrow> prime_factors n \<subseteq> set (p # ps)
 3. \<lbrakk>0 < n; \<not> p dvd n\<rbrakk> \<Longrightarrow> prime_factors n \<subseteq> set (p # ps)
[PROOF STEP]
hence "prime_factors ((n div p) * p) = insert p (prime_factors (n div p))"
[PROOF STATE]
proof (prove)
using this:
0 < n div p

goal (1 subgoal):
 1. prime_factors (n div p * p) = insert p (prime_factors (n div p))
[PROOF STEP]
using \<open>p > 1\<close> \<open>prime p\<close>
[PROOF STATE]
proof (prove)
using this:
0 < n div p
1 < p
prime p

goal (1 subgoal):
 1. prime_factors (n div p * p) = insert p (prime_factors (n div p))
[PROOF STEP]
by (auto simp: prime_factors_product prime_prime_factors)
[PROOF STATE]
proof (state)
this:
prime_factors (n div p * p) = insert p (prime_factors (n div p))

goal (3 subgoals):
 1. n = 0 \<Longrightarrow> prime_factors n \<subseteq> set (p # ps)
 2. \<lbrakk>0 < n; p dvd n\<rbrakk> \<Longrightarrow> prime_factors n \<subseteq> set (p # ps)
 3. \<lbrakk>0 < n; \<not> p dvd n\<rbrakk> \<Longrightarrow> prime_factors n \<subseteq> set (p # ps)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
prime_factors (n div p * p) = insert p (prime_factors (n div p))

goal (3 subgoals):
 1. n = 0 \<Longrightarrow> prime_factors n \<subseteq> set (p # ps)
 2. \<lbrakk>0 < n; p dvd n\<rbrakk> \<Longrightarrow> prime_factors n \<subseteq> set (p # ps)
 3. \<lbrakk>0 < n; \<not> p dvd n\<rbrakk> \<Longrightarrow> prime_factors n \<subseteq> set (p # ps)
[PROOF STEP]
have "(n div p) * p = n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n div p * p = n
[PROOF STEP]
using 2
[PROOF STATE]
proof (prove)
using this:
0 < n
p dvd n

goal (1 subgoal):
 1. n div p * p = n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
n div p * p = n

goal (3 subgoals):
 1. n = 0 \<Longrightarrow> prime_factors n \<subseteq> set (p # ps)
 2. \<lbrakk>0 < n; p dvd n\<rbrakk> \<Longrightarrow> prime_factors n \<subseteq> set (p # ps)
 3. \<lbrakk>0 < n; \<not> p dvd n\<rbrakk> \<Longrightarrow> prime_factors n \<subseteq> set (p # ps)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
prime_factors n = insert p (prime_factors (n div p))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
prime_factors n = insert p (prime_factors (n div p))

goal (1 subgoal):
 1. prime_factors n \<subseteq> set (p # ps)
[PROOF STEP]
using 2 \<open>p > 1\<close> *
[PROOF STATE]
proof (prove)
using this:
prime_factors n = insert p (prime_factors (n div p))
0 < n
p dvd n
1 < p
\<lbrakk>n \<noteq> 0; 1 < p \<and> p dvd n; check_prime_factors_subset (n div p) (p # ps); list_all prime (p # ps)\<rbrakk> \<Longrightarrow> prime_factors (n div p) \<subseteq> set (p # ps)
\<lbrakk>n \<noteq> 0; \<not> (1 < p \<and> p dvd n); check_prime_factors_subset n ps; list_all prime ps\<rbrakk> \<Longrightarrow> prime_factors n \<subseteq> set ps
check_prime_factors_subset n (p # ps)
list_all prime (p # ps)

goal (1 subgoal):
 1. prime_factors n \<subseteq> set (p # ps)
[PROOF STEP]
by (auto simp: check_prime_factors_subset.simps(2)[of n])
[PROOF STATE]
proof (state)
this:
prime_factors n \<subseteq> set (p # ps)

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> prime_factors n \<subseteq> set (p # ps)
 2. \<lbrakk>0 < n; \<not> p dvd n\<rbrakk> \<Longrightarrow> prime_factors n \<subseteq> set (p # ps)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. n = 0 \<Longrightarrow> prime_factors n \<subseteq> set (p # ps)
 2. \<lbrakk>0 < n; \<not> p dvd n\<rbrakk> \<Longrightarrow> prime_factors n \<subseteq> set (p # ps)
[PROOF STEP]
case 3
[PROOF STATE]
proof (state)
this:
0 < n
\<not> p dvd n

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> prime_factors n \<subseteq> set (p # ps)
 2. \<lbrakk>0 < n; \<not> p dvd n\<rbrakk> \<Longrightarrow> prime_factors n \<subseteq> set (p # ps)
[PROOF STEP]
with * and \<open>p > 1\<close>
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>n \<noteq> 0; 1 < p \<and> p dvd n; check_prime_factors_subset (n div p) (p # ps); list_all prime (p # ps)\<rbrakk> \<Longrightarrow> prime_factors (n div p) \<subseteq> set (p # ps)
\<lbrakk>n \<noteq> 0; \<not> (1 < p \<and> p dvd n); check_prime_factors_subset n ps; list_all prime ps\<rbrakk> \<Longrightarrow> prime_factors n \<subseteq> set ps
check_prime_factors_subset n (p # ps)
list_all prime (p # ps)
1 < p
0 < n
\<not> p dvd n
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>n \<noteq> 0; 1 < p \<and> p dvd n; check_prime_factors_subset (n div p) (p # ps); list_all prime (p # ps)\<rbrakk> \<Longrightarrow> prime_factors (n div p) \<subseteq> set (p # ps)
\<lbrakk>n \<noteq> 0; \<not> (1 < p \<and> p dvd n); check_prime_factors_subset n ps; list_all prime ps\<rbrakk> \<Longrightarrow> prime_factors n \<subseteq> set ps
check_prime_factors_subset n (p # ps)
list_all prime (p # ps)
1 < p
0 < n
\<not> p dvd n

goal (1 subgoal):
 1. prime_factors n \<subseteq> set (p # ps)
[PROOF STEP]
by (auto simp: check_prime_factors_subset.simps(2)[of n])
[PROOF STATE]
proof (state)
this:
prime_factors n \<subseteq> set (p # ps)

goal (1 subgoal):
 1. n = 0 \<Longrightarrow> prime_factors n \<subseteq> set (p # ps)
[PROOF STEP]
qed auto
[PROOF STATE]
proof (state)
this:
prime_factors n \<subseteq> set (p # ps)

goal (1 subgoal):
 1. \<And>n. \<lbrakk>check_prime_factors_subset n []; list_all prime []\<rbrakk> \<Longrightarrow> prime_factors n \<subseteq> set []
[PROOF STEP]
qed auto


[STATEMENT]
lemma integrable_on_Icc_iff_Ioo:
  fixes f :: "real \<Rightarrow> 'a :: banach"
  shows "f integrable_on {a..b} \<longleftrightarrow> f integrable_on {a<..<b}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (f integrable_on {a..b}) = (f integrable_on {a<..<b})
[PROOF STEP]
using has_integral_Icc_iff_Ioo
[PROOF STATE]
proof (prove)
using this:
(?f has_integral ?I) {?a..?b} = (?f has_integral ?I) {?a<..<?b}

goal (1 subgoal):
 1. (f integrable_on {a..b}) = (f integrable_on {a<..<b})
[PROOF STEP]
by blast


[STATEMENT]
lemma pos_divideC_less_eq [field_simps]:
  "b /\<^sub>C c < a \<longleftrightarrow> b < c *\<^sub>C a" if "c > 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (b /\<^sub>C c < a) = (b < c *\<^sub>C a)
[PROOF STEP]
using that pos_less_divideC_eq [of "inverse c" b a]
[PROOF STATE]
proof (prove)
using this:
0 < c
0 < inverse c \<Longrightarrow> (b < a /\<^sub>C inverse c) = (b /\<^sub>C c < a)

goal (1 subgoal):
 1. (b /\<^sub>C c < a) = (b < c *\<^sub>C a)
[PROOF STEP]
by (simp add: local.less_le_not_le local.pos_divideC_le_eq local.pos_le_divideC_eq)


[STATEMENT]
lemma mono_omega_fun [simp]:
  fixes f :: "'a::complete_lattice \<Rightarrow> 'a"
  assumes "mono f"
  shows "mono (omega_fun f)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mono (omega_fun f)
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x y. x \<le> y \<Longrightarrow> omega_fun f x \<le> omega_fun f y
[PROOF STEP]
fix a b :: 'a
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x y. x \<le> y \<Longrightarrow> omega_fun f x \<le> omega_fun f y
[PROOF STEP]
assume "a \<le> b"
[PROOF STATE]
proof (state)
this:
a \<le> b

goal (1 subgoal):
 1. \<And>x y. x \<le> y \<Longrightarrow> omega_fun f x \<le> omega_fun f y
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
mono f
[PROOF STEP]
have "mono (lfp (Omega_fun f id))"
[PROOF STATE]
proof (prove)
using this:
mono f

goal (1 subgoal):
 1. mono (lfp (Omega_fun f id))
[PROOF STEP]
by (auto intro: mono_mono_Omega_fun)
[PROOF STATE]
proof (state)
this:
mono (lfp (Omega_fun f id))

goal (1 subgoal):
 1. \<And>x y. x \<le> y \<Longrightarrow> omega_fun f x \<le> omega_fun f y
[PROOF STEP]
with \<open>a \<le> b\<close>
[PROOF STATE]
proof (chain)
picking this:
a \<le> b
mono (lfp (Omega_fun f id))
[PROOF STEP]
show "omega_fun f a \<le> omega_fun f b"
[PROOF STATE]
proof (prove)
using this:
a \<le> b
mono (lfp (Omega_fun f id))

goal (1 subgoal):
 1. omega_fun f a \<le> omega_fun f b
[PROOF STEP]
by (auto simp add: omega_fun_def elim: monoE)
[PROOF STATE]
proof (state)
this:
omega_fun f a \<le> omega_fun f b

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma Polygamma_real_mono:
  assumes "x > 0" "x \<le> (y::real)" "even n"
  shows   "Polygamma n x \<le> Polygamma n y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Polygamma n x \<le> Polygamma n y
[PROOF STEP]
using Polygamma_real_strict_mono[OF assms(1) _ assms(3), of y] assms(2)
[PROOF STATE]
proof (prove)
using this:
x < y \<Longrightarrow> Polygamma n x < Polygamma n y
x \<le> y

goal (1 subgoal):
 1. Polygamma n x \<le> Polygamma n y
[PROOF STEP]
by (cases "x = y") simp_all


[STATEMENT]
lemma del_order:
  assumes "k > 0"
    and "root_order k t"
    and "bal t"
    and "sorted (leaves t)"
  shows "almost_order k (del k x t)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. almost_order k (del k x t)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
0 < k
root_order k t
bal t
sorted_less (leaves t)

goal (1 subgoal):
 1. almost_order k (del k x t)
[PROOF STEP]
proof (induction k x t rule: del.induct)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>k x xs. \<lbrakk>0 < k; root_order k (Leaf xs); bal (Leaf xs); sorted_less (leaves (Leaf xs))\<rbrakk> \<Longrightarrow> almost_order k (del k x (Leaf xs))
 2. \<And>k x ts t. \<lbrakk>\<And>xa y. \<lbrakk>(xa, y) = split ts x; y = []; 0 < k; root_order k t; bal t; sorted_less (leaves t)\<rbrakk> \<Longrightarrow> almost_order k (del k x t); \<And>xa y x21 x22 xb ya. \<lbrakk>(xa, y) = split ts x; y = x21 # x22; (xb, ya) = x21; 0 < k; root_order k xb; bal xb; sorted_less (leaves xb)\<rbrakk> \<Longrightarrow> almost_order k (del k x xb); 0 < k; root_order k (Node ts t); bal (Node ts t); sorted_less (leaves (Node ts t))\<rbrakk> \<Longrightarrow> almost_order k (del k x (Node ts t))
[PROOF STEP]
case (1 k x xs)
[PROOF STATE]
proof (state)
this:
0 < k
root_order k (Leaf xs)
bal (Leaf xs)
sorted_less (leaves (Leaf xs))

goal (2 subgoals):
 1. \<And>k x xs. \<lbrakk>0 < k; root_order k (Leaf xs); bal (Leaf xs); sorted_less (leaves (Leaf xs))\<rbrakk> \<Longrightarrow> almost_order k (del k x (Leaf xs))
 2. \<And>k x ts t. \<lbrakk>\<And>xa y. \<lbrakk>(xa, y) = split ts x; y = []; 0 < k; root_order k t; bal t; sorted_less (leaves t)\<rbrakk> \<Longrightarrow> almost_order k (del k x t); \<And>xa y x21 x22 xb ya. \<lbrakk>(xa, y) = split ts x; y = x21 # x22; (xb, ya) = x21; 0 < k; root_order k xb; bal xb; sorted_less (leaves xb)\<rbrakk> \<Longrightarrow> almost_order k (del k x xb); 0 < k; root_order k (Node ts t); bal (Node ts t); sorted_less (leaves (Node ts t))\<rbrakk> \<Longrightarrow> almost_order k (del k x (Node ts t))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
0 < k
root_order k (Leaf xs)
bal (Leaf xs)
sorted_less (leaves (Leaf xs))
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
0 < k
root_order k (Leaf xs)
bal (Leaf xs)
sorted_less (leaves (Leaf xs))

goal (1 subgoal):
 1. almost_order k (del k x (Leaf xs))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
almost_order k (del k x (Leaf xs))

goal (1 subgoal):
 1. \<And>k x ts t. \<lbrakk>\<And>xa y. \<lbrakk>(xa, y) = split ts x; y = []; 0 < k; root_order k t; bal t; sorted_less (leaves t)\<rbrakk> \<Longrightarrow> almost_order k (del k x t); \<And>xa y x21 x22 xb ya. \<lbrakk>(xa, y) = split ts x; y = x21 # x22; (xb, ya) = x21; 0 < k; root_order k xb; bal xb; sorted_less (leaves xb)\<rbrakk> \<Longrightarrow> almost_order k (del k x xb); 0 < k; root_order k (Node ts t); bal (Node ts t); sorted_less (leaves (Node ts t))\<rbrakk> \<Longrightarrow> almost_order k (del k x (Node ts t))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>k x ts t. \<lbrakk>\<And>xa y. \<lbrakk>(xa, y) = split ts x; y = []; 0 < k; root_order k t; bal t; sorted_less (leaves t)\<rbrakk> \<Longrightarrow> almost_order k (del k x t); \<And>xa y x21 x22 xb ya. \<lbrakk>(xa, y) = split ts x; y = x21 # x22; (xb, ya) = x21; 0 < k; root_order k xb; bal xb; sorted_less (leaves xb)\<rbrakk> \<Longrightarrow> almost_order k (del k x xb); 0 < k; root_order k (Node ts t); bal (Node ts t); sorted_less (leaves (Node ts t))\<rbrakk> \<Longrightarrow> almost_order k (del k x (Node ts t))
[PROOF STEP]
case (2 k x ts t)
[PROOF STATE]
proof (state)
this:
\<lbrakk>(?xa, ?y) = split ts x; ?y = []; 0 < k; root_order k t; bal t; sorted_less (leaves t)\<rbrakk> \<Longrightarrow> almost_order k (del k x t)
\<lbrakk>(?xa, ?y) = split ts x; ?y = ?x21.0 # ?x22.0; (?xb, ?ya) = ?x21.0; 0 < k; root_order k ?xb; bal ?xb; sorted_less (leaves ?xb)\<rbrakk> \<Longrightarrow> almost_order k (del k x ?xb)
0 < k
root_order k (Node ts t)
bal (Node ts t)
sorted_less (leaves (Node ts t))

goal (1 subgoal):
 1. \<And>k x ts t. \<lbrakk>\<And>xa y. \<lbrakk>(xa, y) = split ts x; y = []; 0 < k; root_order k t; bal t; sorted_less (leaves t)\<rbrakk> \<Longrightarrow> almost_order k (del k x t); \<And>xa y x21 x22 xb ya. \<lbrakk>(xa, y) = split ts x; y = x21 # x22; (xb, ya) = x21; 0 < k; root_order k xb; bal xb; sorted_less (leaves xb)\<rbrakk> \<Longrightarrow> almost_order k (del k x xb); 0 < k; root_order k (Node ts t); bal (Node ts t); sorted_less (leaves (Node ts t))\<rbrakk> \<Longrightarrow> almost_order k (del k x (Node ts t))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>(?xa, ?y) = split ts x; ?y = []; 0 < k; root_order k t; bal t; sorted_less (leaves t)\<rbrakk> \<Longrightarrow> almost_order k (del k x t)
\<lbrakk>(?xa, ?y) = split ts x; ?y = ?x21.0 # ?x22.0; (?xb, ?ya) = ?x21.0; 0 < k; root_order k ?xb; bal ?xb; sorted_less (leaves ?xb)\<rbrakk> \<Longrightarrow> almost_order k (del k x ?xb)
0 < k
root_order k (Node ts t)
bal (Node ts t)
sorted_less (leaves (Node ts t))
[PROOF STEP]
obtain ls list where list_split: "split ts x = (ls, list)"
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>(?xa, ?y) = split ts x; ?y = []; 0 < k; root_order k t; bal t; sorted_less (leaves t)\<rbrakk> \<Longrightarrow> almost_order k (del k x t)
\<lbrakk>(?xa, ?y) = split ts x; ?y = ?x21.0 # ?x22.0; (?xb, ?ya) = ?x21.0; 0 < k; root_order k ?xb; bal ?xb; sorted_less (leaves ?xb)\<rbrakk> \<Longrightarrow> almost_order k (del k x ?xb)
0 < k
root_order k (Node ts t)
bal (Node ts t)
sorted_less (leaves (Node ts t))

goal (1 subgoal):
 1. (\<And>ls list. split ts x = (ls, list) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (cases "split ts x")
[PROOF STATE]
proof (state)
this:
split ts x = (ls, list)

goal (1 subgoal):
 1. \<And>k x ts t. \<lbrakk>\<And>xa y. \<lbrakk>(xa, y) = split ts x; y = []; 0 < k; root_order k t; bal t; sorted_less (leaves t)\<rbrakk> \<Longrightarrow> almost_order k (del k x t); \<And>xa y x21 x22 xb ya. \<lbrakk>(xa, y) = split ts x; y = x21 # x22; (xb, ya) = x21; 0 < k; root_order k xb; bal xb; sorted_less (leaves xb)\<rbrakk> \<Longrightarrow> almost_order k (del k x xb); 0 < k; root_order k (Node ts t); bal (Node ts t); sorted_less (leaves (Node ts t))\<rbrakk> \<Longrightarrow> almost_order k (del k x (Node ts t))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
split ts x = (ls, list)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
split ts x = (ls, list)

goal (1 subgoal):
 1. almost_order k (del k x (Node ts t))
[PROOF STEP]
proof (cases list)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<lbrakk>split ts x = (ls, list); list = []\<rbrakk> \<Longrightarrow> almost_order k (del k x (Node ts t))
 2. \<And>a lista. \<lbrakk>split ts x = (ls, list); list = a # lista\<rbrakk> \<Longrightarrow> almost_order k (del k x (Node ts t))
[PROOF STEP]
case Nil
[PROOF STATE]
proof (state)
this:
list = []

goal (2 subgoals):
 1. \<lbrakk>split ts x = (ls, list); list = []\<rbrakk> \<Longrightarrow> almost_order k (del k x (Node ts t))
 2. \<And>a lista. \<lbrakk>split ts x = (ls, list); list = a # lista\<rbrakk> \<Longrightarrow> almost_order k (del k x (Node ts t))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
list = []
[PROOF STEP]
have "almost_order k (del k x t)"
[PROOF STATE]
proof (prove)
using this:
list = []

goal (1 subgoal):
 1. almost_order k (del k x t)
[PROOF STEP]
using 2 list_split
[PROOF STATE]
proof (prove)
using this:
list = []
\<lbrakk>(?xa, ?y) = split ts x; ?y = []; 0 < k; root_order k t; bal t; sorted_less (leaves t)\<rbrakk> \<Longrightarrow> almost_order k (del k x t)
\<lbrakk>(?xa, ?y) = split ts x; ?y = ?x21.0 # ?x22.0; (?xb, ?ya) = ?x21.0; 0 < k; root_order k ?xb; bal ?xb; sorted_less (leaves ?xb)\<rbrakk> \<Longrightarrow> almost_order k (del k x ?xb)
0 < k
root_order k (Node ts t)
bal (Node ts t)
sorted_less (leaves (Node ts t))
split ts x = (ls, list)

goal (1 subgoal):
 1. almost_order k (del k x t)
[PROOF STEP]
by (simp add: order_impl_root_order sorted_wrt_append)
[PROOF STATE]
proof (state)
this:
almost_order k (del k x t)

goal (2 subgoals):
 1. \<lbrakk>split ts x = (ls, list); list = []\<rbrakk> \<Longrightarrow> almost_order k (del k x (Node ts t))
 2. \<And>a lista. \<lbrakk>split ts x = (ls, list); list = a # lista\<rbrakk> \<Longrightarrow> almost_order k (del k x (Node ts t))
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
almost_order k (del k x t)

goal (2 subgoals):
 1. \<lbrakk>split ts x = (ls, list); list = []\<rbrakk> \<Longrightarrow> almost_order k (del k x (Node ts t))
 2. \<And>a lista. \<lbrakk>split ts x = (ls, list); list = a # lista\<rbrakk> \<Longrightarrow> almost_order k (del k x (Node ts t))
[PROOF STEP]
obtain lls lsub lsep where ls_split: "ls = lls@[(lsub,lsep)]"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>lls lsub lsep. ls = lls @ [(lsub, lsep)] \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using 2 Nil list_split
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>(?xa, ?y) = split ts x; ?y = []; 0 < k; root_order k t; bal t; sorted_less (leaves t)\<rbrakk> \<Longrightarrow> almost_order k (del k x t)
\<lbrakk>(?xa, ?y) = split ts x; ?y = ?x21.0 # ?x22.0; (?xb, ?ya) = ?x21.0; 0 < k; root_order k ?xb; bal ?xb; sorted_less (leaves ?xb)\<rbrakk> \<Longrightarrow> almost_order k (del k x ?xb)
0 < k
root_order k (Node ts t)
bal (Node ts t)
sorted_less (leaves (Node ts t))
list = []
split ts x = (ls, list)

goal (1 subgoal):
 1. (\<And>lls lsub lsep. ls = lls @ [(lsub, lsep)] \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (metis append_Nil length_0_conv less_nat_zero_code old.prod.exhaust rev_exhaust root_order.simps(2) split_conc)
[PROOF STATE]
proof (state)
this:
ls = lls @ [(lsub, lsep)]

goal (2 subgoals):
 1. \<lbrakk>split ts x = (ls, list); list = []\<rbrakk> \<Longrightarrow> almost_order k (del k x (Node ts t))
 2. \<And>a lista. \<lbrakk>split ts x = (ls, list); list = a # lista\<rbrakk> \<Longrightarrow> almost_order k (del k x (Node ts t))
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
ls = lls @ [(lsub, lsep)]

goal (2 subgoals):
 1. \<lbrakk>split ts x = (ls, list); list = []\<rbrakk> \<Longrightarrow> almost_order k (del k x (Node ts t))
 2. \<And>a lista. \<lbrakk>split ts x = (ls, list); list = a # lista\<rbrakk> \<Longrightarrow> almost_order k (del k x (Node ts t))
[PROOF STEP]
have "height t = height (del k x t)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. height t = height (del k x t)
[PROOF STEP]
using del_height 2
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>0 < ?k; root_order ?k ?t; bal ?t\<rbrakk> \<Longrightarrow> height (del ?k ?x ?t) = height ?t
\<lbrakk>(?xa, ?y) = split ts x; ?y = []; 0 < k; root_order k t; bal t; sorted_less (leaves t)\<rbrakk> \<Longrightarrow> almost_order k (del k x t)
\<lbrakk>(?xa, ?y) = split ts x; ?y = ?x21.0 # ?x22.0; (?xb, ?ya) = ?x21.0; 0 < k; root_order k ?xb; bal ?xb; sorted_less (leaves ?xb)\<rbrakk> \<Longrightarrow> almost_order k (del k x ?xb)
0 < k
root_order k (Node ts t)
bal (Node ts t)
sorted_less (leaves (Node ts t))

goal (1 subgoal):
 1. height t = height (del k x t)
[PROOF STEP]
by (simp add: order_impl_root_order)
[PROOF STATE]
proof (state)
this:
height t = height (del k x t)

goal (2 subgoals):
 1. \<lbrakk>split ts x = (ls, list); list = []\<rbrakk> \<Longrightarrow> almost_order k (del k x (Node ts t))
 2. \<And>a lista. \<lbrakk>split ts x = (ls, list); list = a # lista\<rbrakk> \<Longrightarrow> almost_order k (del k x (Node ts t))
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
height t = height (del k x t)

goal (2 subgoals):
 1. \<lbrakk>split ts x = (ls, list); list = []\<rbrakk> \<Longrightarrow> almost_order k (del k x (Node ts t))
 2. \<And>a lista. \<lbrakk>split ts x = (ls, list); list = a # lista\<rbrakk> \<Longrightarrow> almost_order k (del k x (Node ts t))
[PROOF STEP]
have "length ls = length ts"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length ls = length ts
[PROOF STEP]
using Nil list_split
[PROOF STATE]
proof (prove)
using this:
list = []
split ts x = (ls, list)

goal (1 subgoal):
 1. length ls = length ts
[PROOF STEP]
by (auto dest: split_length)
[PROOF STATE]
proof (state)
this:
length ls = length ts

goal (2 subgoals):
 1. \<lbrakk>split ts x = (ls, list); list = []\<rbrakk> \<Longrightarrow> almost_order k (del k x (Node ts t))
 2. \<And>a lista. \<lbrakk>split ts x = (ls, list); list = a # lista\<rbrakk> \<Longrightarrow> almost_order k (del k x (Node ts t))
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
almost_order k (del k x t)
ls = lls @ [(lsub, lsep)]
height t = height (del k x t)
length ls = length ts
[PROOF STEP]
have "almost_order k (rebalance_last_tree k ls (del k x t))"
[PROOF STATE]
proof (prove)
using this:
almost_order k (del k x t)
ls = lls @ [(lsub, lsep)]
height t = height (del k x t)
length ls = length ts

goal (1 subgoal):
 1. almost_order k (rebalance_last_tree k ls (del k x t))
[PROOF STEP]
using rebalance_last_tree_order[of ls lls lsub lsep k "del k x t"]
[PROOF STATE]
proof (prove)
using this:
almost_order k (del k x t)
ls = lls @ [(lsub, lsep)]
height t = height (del k x t)
length ls = length ts
\<lbrakk>ls = lls @ [(lsub, lsep)]; \<forall>s\<in>set (subtrees ls). order k s; almost_order k (del k x t); length ls \<le> 2 * k; height lsub = height (del k x t)\<rbrakk> \<Longrightarrow> almost_order k (rebalance_last_tree k ls (del k x t))

goal (1 subgoal):
 1. almost_order k (rebalance_last_tree k ls (del k x t))
[PROOF STEP]
by (metis "2.prems"(2) "2.prems"(3) Un_iff append_Nil2 bal.simps(2) list_split Nil root_order.simps(2) singletonI split_conc subtrees_split)
[PROOF STATE]
proof (state)
this:
almost_order k (rebalance_last_tree k ls (del k x t))

goal (2 subgoals):
 1. \<lbrakk>split ts x = (ls, list); list = []\<rbrakk> \<Longrightarrow> almost_order k (del k x (Node ts t))
 2. \<And>a lista. \<lbrakk>split ts x = (ls, list); list = a # lista\<rbrakk> \<Longrightarrow> almost_order k (del k x (Node ts t))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
almost_order k (rebalance_last_tree k ls (del k x t))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
almost_order k (rebalance_last_tree k ls (del k x t))

goal (1 subgoal):
 1. almost_order k (del k x (Node ts t))
[PROOF STEP]
using 2 list_split Nil
[PROOF STATE]
proof (prove)
using this:
almost_order k (rebalance_last_tree k ls (del k x t))
\<lbrakk>(?xa, ?y) = split ts x; ?y = []; 0 < k; root_order k t; bal t; sorted_less (leaves t)\<rbrakk> \<Longrightarrow> almost_order k (del k x t)
\<lbrakk>(?xa, ?y) = split ts x; ?y = ?x21.0 # ?x22.0; (?xb, ?ya) = ?x21.0; 0 < k; root_order k ?xb; bal ?xb; sorted_less (leaves ?xb)\<rbrakk> \<Longrightarrow> almost_order k (del k x ?xb)
0 < k
root_order k (Node ts t)
bal (Node ts t)
sorted_less (leaves (Node ts t))
split ts x = (ls, list)
list = []

goal (1 subgoal):
 1. almost_order k (del k x (Node ts t))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
almost_order k (del k x (Node ts t))

goal (1 subgoal):
 1. \<And>a lista. \<lbrakk>split ts x = (ls, list); list = a # lista\<rbrakk> \<Longrightarrow> almost_order k (del k x (Node ts t))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a lista. \<lbrakk>split ts x = (ls, list); list = a # lista\<rbrakk> \<Longrightarrow> almost_order k (del k x (Node ts t))
[PROOF STEP]
case (Cons r rs)
[PROOF STATE]
proof (state)
this:
list = r # rs

goal (1 subgoal):
 1. \<And>a lista. \<lbrakk>split ts x = (ls, list); list = a # lista\<rbrakk> \<Longrightarrow> almost_order k (del k x (Node ts t))
[PROOF STEP]
from Cons
[PROOF STATE]
proof (chain)
picking this:
list = r # rs
[PROOF STEP]
obtain sub sep where r_split: "r = (sub,sep)"
[PROOF STATE]
proof (prove)
using this:
list = r # rs

goal (1 subgoal):
 1. (\<And>sub sep. r = (sub, sep) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (cases r)
[PROOF STATE]
proof (state)
this:
r = (sub, sep)

goal (1 subgoal):
 1. \<And>a lista. \<lbrakk>split ts x = (ls, list); list = a # lista\<rbrakk> \<Longrightarrow> almost_order k (del k x (Node ts t))
[PROOF STEP]
have inductive_help:
      "case rs of [] \<Rightarrow> True | (rsub,rsep)#_ \<Rightarrow> height rsub = height t"
      "\<forall>s\<in>set (subtrees (ls @ rs)). order k s"
      "Suc (length (ls @ rs)) \<le> 2 * k"
      "order k t"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (case rs of [] \<Rightarrow> True | (rsub, rsep) # x \<Rightarrow> height rsub = height t &&& \<forall>s\<in>set (subtrees (ls @ rs)). order k s) &&& Suc (length (ls @ rs)) \<le> 2 * k &&& order k t
[PROOF STEP]
using Cons r_split "2.prems" list_split split_set
[PROOF STATE]
proof (prove)
using this:
list = r # rs
r = (sub, sep)
0 < k
root_order k (Node ts t)
bal (Node ts t)
sorted_less (leaves (Node ts t))
split ts x = (ls, list)
split ?ts ?z = (?ls, (?a, ?b) # ?rs) \<Longrightarrow> (?a, ?b) \<in> set ?ts
\<lbrakk>split ?ts ?z = (?ls, (?a, ?b) # ?rs); (?x, ?y) \<in> set ?ls\<rbrakk> \<Longrightarrow> (?x, ?y) \<in> set ?ts
\<lbrakk>split ?ts ?z = (?ls, (?a, ?b) # ?rs); (?x, ?y) \<in> set ?rs\<rbrakk> \<Longrightarrow> (?x, ?y) \<in> set ?ts
split ?ts ?z = (?ls, (?a, ?b) # ?rs) \<Longrightarrow> set ?ls \<union> set ?rs \<union> {(?a, ?b)} = set ?ts
split ?ts ?z = (?ls, (?a, ?b) # ?rs) \<Longrightarrow> \<exists>x\<in>set ?ts. ?b \<in> Basic_BNFs.snds x

goal (1 subgoal):
 1. (case rs of [] \<Rightarrow> True | (rsub, rsep) # x \<Rightarrow> height rsub = height t &&& \<forall>s\<in>set (subtrees (ls @ rs)). order k s) &&& Suc (length (ls @ rs)) \<le> 2 * k &&& order k t
[PROOF STEP]
by (auto dest: split_conc split!: list.splits)
[PROOF STATE]
proof (state)
this:
case rs of [] \<Rightarrow> True | (rsub, rsep) # x \<Rightarrow> height rsub = height t
\<forall>s\<in>set (subtrees (ls @ rs)). order k s
Suc (length (ls @ rs)) \<le> 2 * k
order k t

goal (1 subgoal):
 1. \<And>a lista. \<lbrakk>split ts x = (ls, list); list = a # lista\<rbrakk> \<Longrightarrow> almost_order k (del k x (Node ts t))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
case rs of [] \<Rightarrow> True | (rsub, rsep) # x \<Rightarrow> height rsub = height t
\<forall>s\<in>set (subtrees (ls @ rs)). order k s
Suc (length (ls @ rs)) \<le> 2 * k
order k t
[PROOF STEP]
have "almost_order k (del k x sub)"
[PROOF STATE]
proof (prove)
using this:
case rs of [] \<Rightarrow> True | (rsub, rsep) # x \<Rightarrow> height rsub = height t
\<forall>s\<in>set (subtrees (ls @ rs)). order k s
Suc (length (ls @ rs)) \<le> 2 * k
order k t

goal (1 subgoal):
 1. almost_order k (del k x sub)
[PROOF STEP]
using 2 list_split Cons r_split order_impl_root_order
[PROOF STATE]
proof (prove)
using this:
case rs of [] \<Rightarrow> True | (rsub, rsep) # x \<Rightarrow> height rsub = height t
\<forall>s\<in>set (subtrees (ls @ rs)). order k s
Suc (length (ls @ rs)) \<le> 2 * k
order k t
\<lbrakk>(?xa, ?y) = split ts x; ?y = []; 0 < k; root_order k t; bal t; sorted_less (leaves t)\<rbrakk> \<Longrightarrow> almost_order k (del k x t)
\<lbrakk>(?xa, ?y) = split ts x; ?y = ?x21.0 # ?x22.0; (?xb, ?ya) = ?x21.0; 0 < k; root_order k ?xb; bal ?xb; sorted_less (leaves ?xb)\<rbrakk> \<Longrightarrow> almost_order k (del k x ?xb)
0 < k
root_order k (Node ts t)
bal (Node ts t)
sorted_less (leaves (Node ts t))
split ts x = (ls, list)
list = r # rs
r = (sub, sep)
\<lbrakk>0 < ?k; order ?k ?t\<rbrakk> \<Longrightarrow> root_order ?k ?t

goal (1 subgoal):
 1. almost_order k (del k x sub)
[PROOF STEP]
by (metis bal.simps(2) root_order.simps(2) some_child_sub(1) sorted_leaves_induct_subtree split_conc split_set(1))
[PROOF STATE]
proof (state)
this:
almost_order k (del k x sub)

goal (1 subgoal):
 1. \<And>a lista. \<lbrakk>split ts x = (ls, list); list = a # lista\<rbrakk> \<Longrightarrow> almost_order k (del k x (Node ts t))
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
almost_order k (del k x sub)

goal (1 subgoal):
 1. \<And>a lista. \<lbrakk>split ts x = (ls, list); list = a # lista\<rbrakk> \<Longrightarrow> almost_order k (del k x (Node ts t))
[PROOF STEP]
have "height (del k x sub) = height t"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. height (del k x sub) = height t
[PROOF STEP]
by (metis "2.prems"(1) "2.prems"(2) "2.prems"(3) bal.simps(2) list_split Cons order_impl_root_order r_split root_order.simps(2) some_child_sub(1) del_height split_set(1))
[PROOF STATE]
proof (state)
this:
height (del k x sub) = height t

goal (1 subgoal):
 1. \<And>a lista. \<lbrakk>split ts x = (ls, list); list = a # lista\<rbrakk> \<Longrightarrow> almost_order k (del k x (Node ts t))
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
almost_order k (del k x sub)
height (del k x sub) = height t
[PROOF STEP]
have "almost_order k (rebalance_middle_tree k ls (del k x sub) sep rs t)"
[PROOF STATE]
proof (prove)
using this:
almost_order k (del k x sub)
height (del k x sub) = height t

goal (1 subgoal):
 1. almost_order k (rebalance_middle_tree k ls (del k x sub) sep rs t)
[PROOF STEP]
using rebalance_middle_tree_order[of k "del k x sub" ls rs t sep]
[PROOF STATE]
proof (prove)
using this:
almost_order k (del k x sub)
height (del k x sub) = height t
\<lbrakk>almost_order k (del k x sub); \<forall>s\<in>set (subtrees (ls @ rs)). order k s; order k t; case rs of [] \<Rightarrow> True | (rsub, rsep) # list \<Rightarrow> height rsub = height t; length (ls @ (del k x sub, sep) # rs) \<le> 2 * k; height (del k x sub) = height t\<rbrakk> \<Longrightarrow> almost_order k (rebalance_middle_tree k ls (del k x sub) sep rs t)

goal (1 subgoal):
 1. almost_order k (rebalance_middle_tree k ls (del k x sub) sep rs t)
[PROOF STEP]
using inductive_help
[PROOF STATE]
proof (prove)
using this:
almost_order k (del k x sub)
height (del k x sub) = height t
\<lbrakk>almost_order k (del k x sub); \<forall>s\<in>set (subtrees (ls @ rs)). order k s; order k t; case rs of [] \<Rightarrow> True | (rsub, rsep) # list \<Rightarrow> height rsub = height t; length (ls @ (del k x sub, sep) # rs) \<le> 2 * k; height (del k x sub) = height t\<rbrakk> \<Longrightarrow> almost_order k (rebalance_middle_tree k ls (del k x sub) sep rs t)
case rs of [] \<Rightarrow> True | (rsub, rsep) # x \<Rightarrow> height rsub = height t
\<forall>s\<in>set (subtrees (ls @ rs)). order k s
Suc (length (ls @ rs)) \<le> 2 * k
order k t

goal (1 subgoal):
 1. almost_order k (rebalance_middle_tree k ls (del k x sub) sep rs t)
[PROOF STEP]
using Cons r_split list_split
[PROOF STATE]
proof (prove)
using this:
almost_order k (del k x sub)
height (del k x sub) = height t
\<lbrakk>almost_order k (del k x sub); \<forall>s\<in>set (subtrees (ls @ rs)). order k s; order k t; case rs of [] \<Rightarrow> True | (rsub, rsep) # list \<Rightarrow> height rsub = height t; length (ls @ (del k x sub, sep) # rs) \<le> 2 * k; height (del k x sub) = height t\<rbrakk> \<Longrightarrow> almost_order k (rebalance_middle_tree k ls (del k x sub) sep rs t)
case rs of [] \<Rightarrow> True | (rsub, rsep) # x \<Rightarrow> height rsub = height t
\<forall>s\<in>set (subtrees (ls @ rs)). order k s
Suc (length (ls @ rs)) \<le> 2 * k
order k t
list = r # rs
r = (sub, sep)
split ts x = (ls, list)

goal (1 subgoal):
 1. almost_order k (rebalance_middle_tree k ls (del k x sub) sep rs t)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
almost_order k (rebalance_middle_tree k ls (del k x sub) sep rs t)

goal (1 subgoal):
 1. \<And>a lista. \<lbrakk>split ts x = (ls, list); list = a # lista\<rbrakk> \<Longrightarrow> almost_order k (del k x (Node ts t))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
almost_order k (rebalance_middle_tree k ls (del k x sub) sep rs t)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
almost_order k (rebalance_middle_tree k ls (del k x sub) sep rs t)

goal (1 subgoal):
 1. almost_order k (del k x (Node ts t))
[PROOF STEP]
using 2 Cons r_split list_split
[PROOF STATE]
proof (prove)
using this:
almost_order k (rebalance_middle_tree k ls (del k x sub) sep rs t)
\<lbrakk>(?xa, ?y) = split ts x; ?y = []; 0 < k; root_order k t; bal t; sorted_less (leaves t)\<rbrakk> \<Longrightarrow> almost_order k (del k x t)
\<lbrakk>(?xa, ?y) = split ts x; ?y = ?x21.0 # ?x22.0; (?xb, ?ya) = ?x21.0; 0 < k; root_order k ?xb; bal ?xb; sorted_less (leaves ?xb)\<rbrakk> \<Longrightarrow> almost_order k (del k x ?xb)
0 < k
root_order k (Node ts t)
bal (Node ts t)
sorted_less (leaves (Node ts t))
list = r # rs
r = (sub, sep)
split ts x = (ls, list)

goal (1 subgoal):
 1. almost_order k (del k x (Node ts t))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
almost_order k (del k x (Node ts t))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
almost_order k (del k x (Node ts t))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma sum_list_nonneg: "\<forall>x\<in>set xs. x \<ge> 0 \<Longrightarrow> sum_list xs \<ge> (0 :: 'a :: ordered_ab_group_add)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>x\<in>set xs. (0::'a) \<le> x \<Longrightarrow> (0::'a) \<le> sum_list xs
[PROOF STEP]
by (induction xs) auto


[STATEMENT]
lemma ccSUP_le_iff: "countable A \<Longrightarrow> (SUP i \<in> A. f i) \<le> u \<longleftrightarrow> (\<forall>i\<in>A. f i \<le> u)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. countable A \<Longrightarrow> (Sup (f ` A) \<le> u) = (\<forall>i\<in>A. f i \<le> u)
[PROOF STEP]
using ccSup_le_iff [of "f ` A"]
[PROOF STATE]
proof (prove)
using this:
countable (f ` A) \<Longrightarrow> (Sup (f ` A) \<le> ?b) = (\<forall>a\<in>f ` A. a \<le> ?b)

goal (1 subgoal):
 1. countable A \<Longrightarrow> (Sup (f ` A) \<le> u) = (\<forall>i\<in>A. f i \<le> u)
[PROOF STEP]
by simp


[STATEMENT]
lemma linear_homeomorphic_image:
  fixes f :: "'a::euclidean_space \<Rightarrow> 'b::euclidean_space"
  assumes "linear f" "inj f"
    shows "S homeomorphic f ` S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. S homeomorphic f ` S
[PROOF STEP]
by (meson homeomorphic_def homeomorphic_sym linear_homeomorphism_image [OF assms])


[STATEMENT]
lemma subcocycle_integrable:
  assumes "subcocycle u"
  shows "integrable M (u n)"
        "u n \<in> borel_measurable M"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. integrable M (u n) &&& u n \<in> borel_measurable M
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
subcocycle u

goal (1 subgoal):
 1. integrable M (u n) &&& u n \<in> borel_measurable M
[PROOF STEP]
unfolding subcocycle_def
[PROOF STATE]
proof (prove)
using this:
(\<forall>n. integrable M (u n)) \<and> (\<forall>n m x. u (n + m) x \<le> u n x + u m ((T ^^ n) x))

goal (1 subgoal):
 1. integrable M (u n) &&& u n \<in> borel_measurable M
[PROOF STEP]
by auto


[STATEMENT]
lemma islimpt_Un_finite:
  fixes x :: "'a::t1_space"
  shows "finite s \<Longrightarrow> x islimpt (s \<union> t) \<longleftrightarrow> x islimpt t"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite s \<Longrightarrow> x islimpt s \<union> t = x islimpt t
[PROOF STEP]
by (simp add: islimpt_Un islimpt_finite)


[STATEMENT]
lemma exponent_Float:
  shows "Float.exponent (Float m e) = (if m = 0 then 0 else bitlen \<bar>m\<bar> + e) - bitlen \<bar>mantissa (Float m e)\<bar> "
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Float.exponent (Float m e) = (if m = 0 then 0 else bitlen \<bar>m\<bar> + e) - bitlen \<bar>mantissa (Float m e)\<bar>
[PROOF STEP]
using bitlen_Float[of m e]
[PROOF STATE]
proof (prove)
using this:
bitlen \<bar>mantissa (Float m e)\<bar> + Float.exponent (Float m e) = (if m = 0 then 0 else bitlen \<bar>m\<bar> + e)

goal (1 subgoal):
 1. Float.exponent (Float m e) = (if m = 0 then 0 else bitlen \<bar>m\<bar> + e) - bitlen \<bar>mantissa (Float m e)\<bar>
[PROOF STEP]
by auto


[STATEMENT]
lemma Stream_snth: "(x ## s) !! n = (case n of 0 \<Rightarrow> x | Suc n \<Rightarrow> s !! n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (x ## s) !! n = (case n of 0 \<Rightarrow> x | Suc n \<Rightarrow> s !! n)
[PROOF STEP]
by (cases n) simp_all


[STATEMENT]
lemma necessity_D':
  assumes edr: "(\<forall>(A::'a mat). admits_diagonal_reduction A)"
  shows "\<forall>a b c::'a. ideal_generated {a,b,c} = ideal_generated{1}
  \<longrightarrow> (\<exists>p q. ideal_generated {p*a,p*b+q*c} = ideal_generated {1})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>a b c. ideal_generated {a, b, c} = ideal_generated {1::'a} \<longrightarrow> (\<exists>p q. ideal_generated {p * a, p * b + q * c} = ideal_generated {1::'a})
[PROOF STEP]
proof ((rule allI)+, rule impI)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a b c. ideal_generated {a, b, c} = ideal_generated {1::'a} \<Longrightarrow> \<exists>p q. ideal_generated {p * a, p * b + q * c} = ideal_generated {1::'a}
[PROOF STEP]
fix a b c::'a
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a b c. ideal_generated {a, b, c} = ideal_generated {1::'a} \<Longrightarrow> \<exists>p q. ideal_generated {p * a, p * b + q * c} = ideal_generated {1::'a}
[PROOF STEP]
assume i: "ideal_generated {a,b,c} = ideal_generated{1}"
[PROOF STATE]
proof (state)
this:
ideal_generated {a, b, c} = ideal_generated {1::'a}

goal (1 subgoal):
 1. \<And>a b c. ideal_generated {a, b, c} = ideal_generated {1::'a} \<Longrightarrow> \<exists>p q. ideal_generated {p * a, p * b + q * c} = ideal_generated {1::'a}
[PROOF STEP]
define A where "A = Matrix.mat 2 2 (\<lambda>(i,j). if i = 0 \<and> j = 0 then a else
                                    if  i = 0 \<and> j = 1 then b else
                                    if  i = 1 \<and> j = 0 then 0 else c)"
[PROOF STATE]
proof (state)
this:
A = Matrix.mat 2 2 (\<lambda>(i, j). if i = 0 \<and> j = 0 then a else if i = 0 \<and> j = 1 then b else if i = 1 \<and> j = 0 then 0::'a else c)

goal (1 subgoal):
 1. \<And>a b c. ideal_generated {a, b, c} = ideal_generated {1::'a} \<Longrightarrow> \<exists>p q. ideal_generated {p * a, p * b + q * c} = ideal_generated {1::'a}
[PROOF STEP]
have A: "A \<in> carrier_mat 2 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A \<in> carrier_mat 2 2
[PROOF STEP]
unfolding A_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Matrix.mat 2 2 (\<lambda>(i, j). if i = 0 \<and> j = 0 then a else if i = 0 \<and> j = 1 then b else if i = 1 \<and> j = 0 then 0::'a else c) \<in> carrier_mat 2 2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
A \<in> carrier_mat 2 2

goal (1 subgoal):
 1. \<And>a b c. ideal_generated {a, b, c} = ideal_generated {1::'a} \<Longrightarrow> \<exists>p q. ideal_generated {p * a, p * b + q * c} = ideal_generated {1::'a}
[PROOF STEP]
obtain P Q where P: "P \<in> carrier_mat (dim_row A) (dim_row A)"
        and Q: "Q \<in> carrier_mat (dim_col A) (dim_col A)"
        and inv_P: "invertible_mat P" and inv_Q: "invertible_mat Q"
        and SNF_PAQ: "Smith_normal_form_mat (P * A * Q)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>P Q. \<lbrakk>P \<in> carrier_mat (dim_row A) (dim_row A); Q \<in> carrier_mat (dim_col A) (dim_col A); invertible_mat P; invertible_mat Q; Smith_normal_form_mat (P * A * Q)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using edr
[PROOF STATE]
proof (prove)
using this:
\<forall>A. admits_diagonal_reduction A

goal (1 subgoal):
 1. (\<And>P Q. \<lbrakk>P \<in> carrier_mat (dim_row A) (dim_row A); Q \<in> carrier_mat (dim_col A) (dim_col A); invertible_mat P; invertible_mat Q; Smith_normal_form_mat (P * A * Q)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
unfolding admits_diagonal_reduction_def
[PROOF STATE]
proof (prove)
using this:
\<forall>A. \<exists>P Q. P \<in> carrier_mat (dim_row A) (dim_row A) \<and> Q \<in> carrier_mat (dim_col A) (dim_col A) \<and> invertible_mat P \<and> invertible_mat Q \<and> Smith_normal_form_mat (P * A * Q)

goal (1 subgoal):
 1. (\<And>P Q. \<lbrakk>P \<in> carrier_mat (dim_row A) (dim_row A); Q \<in> carrier_mat (dim_col A) (dim_col A); invertible_mat P; invertible_mat Q; Smith_normal_form_mat (P * A * Q)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
P \<in> carrier_mat (dim_row A) (dim_row A)
Q \<in> carrier_mat (dim_col A) (dim_col A)
invertible_mat P
invertible_mat Q
Smith_normal_form_mat (P * A * Q)

goal (1 subgoal):
 1. \<And>a b c. ideal_generated {a, b, c} = ideal_generated {1::'a} \<Longrightarrow> \<exists>p q. ideal_generated {p * a, p * b + q * c} = ideal_generated {1::'a}
[PROOF STEP]
have [simp]: "dim_row P = 2" and [simp]: "dim_col P = 2 " and [simp]: "dim_row Q = 2"
    and [simp]: "dim_col Q = 2" and [simp]: "dim_col A = 2" and [simp]: "dim_row A = 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (dim_row P = 2 &&& dim_col P = 2 &&& dim_row Q = 2) &&& dim_col Q = 2 &&& dim_col A = 2 &&& dim_row A = 2
[PROOF STEP]
using A P Q
[PROOF STATE]
proof (prove)
using this:
A \<in> carrier_mat 2 2
P \<in> carrier_mat (dim_row A) (dim_row A)
Q \<in> carrier_mat (dim_col A) (dim_col A)

goal (1 subgoal):
 1. (dim_row P = 2 &&& dim_col P = 2 &&& dim_row Q = 2) &&& dim_col Q = 2 &&& dim_col A = 2 &&& dim_row A = 2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
dim_row P = 2
dim_col P = 2
dim_row Q = 2
dim_col Q = 2
dim_col A = 2
dim_row A = 2

goal (1 subgoal):
 1. \<And>a b c. ideal_generated {a, b, c} = ideal_generated {1::'a} \<Longrightarrow> \<exists>p q. ideal_generated {p * a, p * b + q * c} = ideal_generated {1::'a}
[PROOF STEP]
define u where "u = (P*A*Q) $$ (0,0)"
[PROOF STATE]
proof (state)
this:
u = (P * A * Q) $$ (0, 0)

goal (1 subgoal):
 1. \<And>a b c. ideal_generated {a, b, c} = ideal_generated {1::'a} \<Longrightarrow> \<exists>p q. ideal_generated {p * a, p * b + q * c} = ideal_generated {1::'a}
[PROOF STEP]
define p where "p = P $$ (0,0)"
[PROOF STATE]
proof (state)
this:
p = P $$ (0, 0)

goal (1 subgoal):
 1. \<And>a b c. ideal_generated {a, b, c} = ideal_generated {1::'a} \<Longrightarrow> \<exists>p q. ideal_generated {p * a, p * b + q * c} = ideal_generated {1::'a}
[PROOF STEP]
define q where "q = P $$ (0,1)"
[PROOF STATE]
proof (state)
this:
q = P $$ (0, 1)

goal (1 subgoal):
 1. \<And>a b c. ideal_generated {a, b, c} = ideal_generated {1::'a} \<Longrightarrow> \<exists>p q. ideal_generated {p * a, p * b + q * c} = ideal_generated {1::'a}
[PROOF STEP]
define x where "x = Q $$ (0,0)"
[PROOF STATE]
proof (state)
this:
x = Q $$ (0, 0)

goal (1 subgoal):
 1. \<And>a b c. ideal_generated {a, b, c} = ideal_generated {1::'a} \<Longrightarrow> \<exists>p q. ideal_generated {p * a, p * b + q * c} = ideal_generated {1::'a}
[PROOF STEP]
define y where "y = Q $$ (1,0)"
[PROOF STATE]
proof (state)
this:
y = Q $$ (1, 0)

goal (1 subgoal):
 1. \<And>a b c. ideal_generated {a, b, c} = ideal_generated {1::'a} \<Longrightarrow> \<exists>p q. ideal_generated {p * a, p * b + q * c} = ideal_generated {1::'a}
[PROOF STEP]
have eq: "p*a*x + p*b*y + q*c*y = u"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. p * a * x + p * b * y + q * c * y = u
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. p * a * x + p * b * y + q * c * y = u
[PROOF STEP]
have rw1: "(\<Sum>ia = 0..<2. P $$ (0, ia) * A $$ (ia, x)) * Q $$ (x, 0)
    = (\<Sum>ia\<in>{0, 1}. P $$ (0, ia) * A $$ (ia, x)) * Q $$ (x, 0)"
      for x
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>ia = 0..<2. P $$ (0, ia) * A $$ (ia, x)) * Q $$ (x, 0) = (\<Sum>ia\<in>{0, 1}. P $$ (0, ia) * A $$ (ia, x)) * Q $$ (x, 0)
[PROOF STEP]
by (unfold sum_distrib_right, rule sum.cong, auto)
[PROOF STATE]
proof (state)
this:
(\<Sum>ia = 0..<2. P $$ (0, ia) * A $$ (ia, ?x)) * Q $$ (?x, 0) = (\<Sum>ia\<in>{0, 1}. P $$ (0, ia) * A $$ (ia, ?x)) * Q $$ (?x, 0)

goal (1 subgoal):
 1. p * a * x + p * b * y + q * c * y = u
[PROOF STEP]
have "u = (\<Sum>i = 0..<2. (\<Sum>ia = 0..<2. P $$ (0, ia) * A $$ (ia, i)) * Q $$ (i, 0))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. u = (\<Sum>i = 0..<2. (\<Sum>ia = 0..<2. P $$ (0, ia) * A $$ (ia, i)) * Q $$ (i, 0))
[PROOF STEP]
unfolding u_def p_def q_def x_def y_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (P * A * Q) $$ (0, 0) = (\<Sum>i = 0..<2. (\<Sum>ia = 0..<2. P $$ (0, ia) * A $$ (ia, i)) * Q $$ (i, 0))
[PROOF STEP]
unfolding times_mat_def scalar_prod_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Matrix.mat (dim_row (Matrix.mat (dim_row P) (dim_col A) (\<lambda>(i, j). \<Sum>ia = 0..<dim_vec (col A j). Matrix.row P i $v ia * col A j $v ia))) (dim_col Q) (\<lambda>(i, j). \<Sum>ia = 0..<dim_vec (col Q j). Matrix.row (Matrix.mat (dim_row P) (dim_col A) (\<lambda>(i, j). \<Sum>ia = 0..<dim_vec (col A j). Matrix.row P i $v ia * col A j $v ia)) i $v ia * col Q j $v ia) $$ (0, 0) = (\<Sum>i = 0..<2. (\<Sum>ia = 0..<2. P $$ (0, ia) * A $$ (ia, i)) * Q $$ (i, 0))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
u = (\<Sum>i = 0..<2. (\<Sum>ia = 0..<2. P $$ (0, ia) * A $$ (ia, i)) * Q $$ (i, 0))

goal (1 subgoal):
 1. p * a * x + p * b * y + q * c * y = u
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
u = (\<Sum>i = 0..<2. (\<Sum>ia = 0..<2. P $$ (0, ia) * A $$ (ia, i)) * Q $$ (i, 0))

goal (1 subgoal):
 1. p * a * x + p * b * y + q * c * y = u
[PROOF STEP]
have "... = (\<Sum>i \<in>{0,1}. (\<Sum>ia \<in> {0,1}. P $$ (0, ia) * A $$ (ia, i)) * Q $$ (i, 0))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i = 0..<2. (\<Sum>ia = 0..<2. P $$ (0, ia) * A $$ (ia, i)) * Q $$ (i, 0)) = (\<Sum>i\<in>{0, 1}. (\<Sum>ia\<in>{0, 1}. P $$ (0, ia) * A $$ (ia, i)) * Q $$ (i, 0))
[PROOF STEP]
by (rule sum.cong[OF _ rw1], auto)
[PROOF STATE]
proof (state)
this:
(\<Sum>i = 0..<2. (\<Sum>ia = 0..<2. P $$ (0, ia) * A $$ (ia, i)) * Q $$ (i, 0)) = (\<Sum>i\<in>{0, 1}. (\<Sum>ia\<in>{0, 1}. P $$ (0, ia) * A $$ (ia, i)) * Q $$ (i, 0))

goal (1 subgoal):
 1. p * a * x + p * b * y + q * c * y = u
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>i = 0..<2. (\<Sum>ia = 0..<2. P $$ (0, ia) * A $$ (ia, i)) * Q $$ (i, 0)) = (\<Sum>i\<in>{0, 1}. (\<Sum>ia\<in>{0, 1}. P $$ (0, ia) * A $$ (ia, i)) * Q $$ (i, 0))

goal (1 subgoal):
 1. p * a * x + p * b * y + q * c * y = u
[PROOF STEP]
have "... = p*a*x + p*b*y+q*c*y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i\<in>{0, 1}. (\<Sum>ia\<in>{0, 1}. P $$ (0, ia) * A $$ (ia, i)) * Q $$ (i, 0)) = p * a * x + p * b * y + q * c * y
[PROOF STEP]
unfolding u_def p_def q_def x_def y_def A_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i\<in>{0, 1}. (\<Sum>ia\<in>{0, 1}. P $$ (0, ia) * Matrix.mat 2 2 (\<lambda>(i, j). if i = 0 \<and> j = 0 then a else if i = 0 \<and> j = 1 then b else if i = 1 \<and> j = 0 then 0::'a else c) $$ (ia, i)) * Q $$ (i, 0)) = P $$ (0, 0) * a * Q $$ (0, 0) + P $$ (0, 0) * b * Q $$ (1, 0) + P $$ (0, 1) * c * Q $$ (1, 0)
[PROOF STEP]
using ring_class.ring_distribs(2)
[PROOF STATE]
proof (prove)
using this:
(?a + ?b) * ?c = ?a * ?c + ?b * ?c

goal (1 subgoal):
 1. (\<Sum>i\<in>{0, 1}. (\<Sum>ia\<in>{0, 1}. P $$ (0, ia) * Matrix.mat 2 2 (\<lambda>(i, j). if i = 0 \<and> j = 0 then a else if i = 0 \<and> j = 1 then b else if i = 1 \<and> j = 0 then 0::'a else c) $$ (ia, i)) * Q $$ (i, 0)) = P $$ (0, 0) * a * Q $$ (0, 0) + P $$ (0, 0) * b * Q $$ (1, 0) + P $$ (0, 1) * c * Q $$ (1, 0)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<in>{0, 1}. (\<Sum>ia\<in>{0, 1}. P $$ (0, ia) * A $$ (ia, i)) * Q $$ (i, 0)) = p * a * x + p * b * y + q * c * y

goal (1 subgoal):
 1. p * a * x + p * b * y + q * c * y = u
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
u = p * a * x + p * b * y + q * c * y
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
u = p * a * x + p * b * y + q * c * y

goal (1 subgoal):
 1. p * a * x + p * b * y + q * c * y = u
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
p * a * x + p * b * y + q * c * y = u

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
p * a * x + p * b * y + q * c * y = u

goal (1 subgoal):
 1. \<And>a b c. ideal_generated {a, b, c} = ideal_generated {1::'a} \<Longrightarrow> \<exists>p q. ideal_generated {p * a, p * b + q * c} = ideal_generated {1::'a}
[PROOF STEP]
have u_dvd_1: "u dvd 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. u dvd (1::'a)
[PROOF STEP]
(*
  The article deduces this fact since u divides all the elements of the matrix A. Here, this is
  already proved using GCD and minors, but it requires the semiring_GCD class.
  At the end, I proved this fact by means of matrix multiplications once the inverse matrices of P
  and Q are obtained.
  *)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. u dvd (1::'a)
[PROOF STEP]
proof (rule ideal_generated_dvd2[OF i])
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. finite {a, b, c}
 2. \<forall>x\<in>{a, b, c}. u dvd x
[PROOF STEP]
define D where "D = (P*A*Q)"
[PROOF STATE]
proof (state)
this:
D = P * A * Q

goal (2 subgoals):
 1. finite {a, b, c}
 2. \<forall>x\<in>{a, b, c}. u dvd x
[PROOF STEP]
obtain P' where  P'[simp]: "P' \<in> carrier_mat 2 2" and inv_P: "inverts_mat P' P"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>P'. \<lbrakk>P' \<in> carrier_mat 2 2; inverts_mat P' P\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using inv_P obtain_inverse_matrix[OF P inv_P]
[PROOF STATE]
proof (prove)
using this:
invertible_mat P
(\<And>B. \<lbrakk>inverts_mat P B; inverts_mat B P; B \<in> carrier_mat (dim_row A) (dim_row A)\<rbrakk> \<Longrightarrow> ?thesis) \<Longrightarrow> ?thesis

goal (1 subgoal):
 1. (\<And>P'. \<lbrakk>P' \<in> carrier_mat 2 2; inverts_mat P' P\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (metis \<open>dim_row A = 2\<close>)
[PROOF STATE]
proof (state)
this:
P' \<in> carrier_mat 2 2
inverts_mat P' P

goal (2 subgoals):
 1. finite {a, b, c}
 2. \<forall>x\<in>{a, b, c}. u dvd x
[PROOF STEP]
obtain Q' where [simp]: "Q' \<in> carrier_mat 2 2" and inv_Q: "inverts_mat Q Q'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>Q'. \<lbrakk>Q' \<in> carrier_mat 2 2; inverts_mat Q Q'\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using inv_Q obtain_inverse_matrix[OF Q inv_Q]
[PROOF STATE]
proof (prove)
using this:
invertible_mat Q
(\<And>B. \<lbrakk>inverts_mat Q B; inverts_mat B Q; B \<in> carrier_mat (dim_col A) (dim_col A)\<rbrakk> \<Longrightarrow> ?thesis) \<Longrightarrow> ?thesis

goal (1 subgoal):
 1. (\<And>Q'. \<lbrakk>Q' \<in> carrier_mat 2 2; inverts_mat Q Q'\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (metis \<open>dim_col A = 2\<close>)
[PROOF STATE]
proof (state)
this:
Q' \<in> carrier_mat 2 2
inverts_mat Q Q'

goal (2 subgoals):
 1. finite {a, b, c}
 2. \<forall>x\<in>{a, b, c}. u dvd x
[PROOF STEP]
have D[simp]: "D \<in> carrier_mat 2 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. D \<in> carrier_mat 2 2
[PROOF STEP]
unfolding D_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. P * A * Q \<in> carrier_mat 2 2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
D \<in> carrier_mat 2 2

goal (2 subgoals):
 1. finite {a, b, c}
 2. \<forall>x\<in>{a, b, c}. u dvd x
[PROOF STEP]
have e: "P' * D * Q' = A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. P' * D * Q' = A
[PROOF STEP]
unfolding D_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. P' * (P * A * Q) * Q' = A
[PROOF STEP]
by (rule inv_P'PAQQ'[OF _ _ inv_P inv_Q], auto)
[PROOF STATE]
proof (state)
this:
P' * D * Q' = A

goal (2 subgoals):
 1. finite {a, b, c}
 2. \<forall>x\<in>{a, b, c}. u dvd x
[PROOF STEP]
have [simp]: "(P' * D) \<in> carrier_mat 2 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. P' * D \<in> carrier_mat 2 2
[PROOF STEP]
using D P' mult_carrier_mat
[PROOF STATE]
proof (prove)
using this:
D \<in> carrier_mat 2 2
P' \<in> carrier_mat 2 2
\<lbrakk>?A \<in> carrier_mat ?nr ?n; ?B \<in> carrier_mat ?n ?nc\<rbrakk> \<Longrightarrow> ?A * ?B \<in> carrier_mat ?nr ?nc

goal (1 subgoal):
 1. P' * D \<in> carrier_mat 2 2
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
P' * D \<in> carrier_mat 2 2

goal (2 subgoals):
 1. finite {a, b, c}
 2. \<forall>x\<in>{a, b, c}. u dvd x
[PROOF STEP]
have D_01: "D $$ (0, 1) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. D $$ (0, 1) = (0::'a)
[PROOF STEP]
using D_def SNF_PAQ
[PROOF STATE]
proof (prove)
using this:
D = P * A * Q
Smith_normal_form_mat (P * A * Q)

goal (1 subgoal):
 1. D $$ (0, 1) = (0::'a)
[PROOF STEP]
unfolding Smith_normal_form_mat_def isDiagonal_mat_def
[PROOF STATE]
proof (prove)
using this:
D = P * A * Q
(\<forall>a. a + 1 < min (dim_row (P * A * Q)) (dim_col (P * A * Q)) \<longrightarrow> (P * A * Q) $$ (a, a) dvd (P * A * Q) $$ (a + 1, a + 1)) \<and> (\<forall>i j. i \<noteq> j \<and> i < dim_row (P * A * Q) \<and> j < dim_col (P * A * Q) \<longrightarrow> (P * A * Q) $$ (i, j) = (0::'a))

goal (1 subgoal):
 1. D $$ (0, 1) = (0::'a)
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
D $$ (0, 1) = (0::'a)

goal (2 subgoals):
 1. finite {a, b, c}
 2. \<forall>x\<in>{a, b, c}. u dvd x
[PROOF STEP]
have D_10: "D $$ (1, 0) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. D $$ (1, 0) = (0::'a)
[PROOF STEP]
using D_def SNF_PAQ
[PROOF STATE]
proof (prove)
using this:
D = P * A * Q
Smith_normal_form_mat (P * A * Q)

goal (1 subgoal):
 1. D $$ (1, 0) = (0::'a)
[PROOF STEP]
unfolding Smith_normal_form_mat_def isDiagonal_mat_def
[PROOF STATE]
proof (prove)
using this:
D = P * A * Q
(\<forall>a. a + 1 < min (dim_row (P * A * Q)) (dim_col (P * A * Q)) \<longrightarrow> (P * A * Q) $$ (a, a) dvd (P * A * Q) $$ (a + 1, a + 1)) \<and> (\<forall>i j. i \<noteq> j \<and> i < dim_row (P * A * Q) \<and> j < dim_col (P * A * Q) \<longrightarrow> (P * A * Q) $$ (i, j) = (0::'a))

goal (1 subgoal):
 1. D $$ (1, 0) = (0::'a)
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
D $$ (1, 0) = (0::'a)

goal (2 subgoals):
 1. finite {a, b, c}
 2. \<forall>x\<in>{a, b, c}. u dvd x
[PROOF STEP]
have "D $$ (0,0) dvd D $$ (1, 1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. D $$ (0, 0) dvd D $$ (1, 1)
[PROOF STEP]
using D_def SNF_PAQ
[PROOF STATE]
proof (prove)
using this:
D = P * A * Q
Smith_normal_form_mat (P * A * Q)

goal (1 subgoal):
 1. D $$ (0, 0) dvd D $$ (1, 1)
[PROOF STEP]
unfolding Smith_normal_form_mat_def
[PROOF STATE]
proof (prove)
using this:
D = P * A * Q
(\<forall>a. a + 1 < min (dim_row (P * A * Q)) (dim_col (P * A * Q)) \<longrightarrow> (P * A * Q) $$ (a, a) dvd (P * A * Q) $$ (a + 1, a + 1)) \<and> isDiagonal_mat (P * A * Q)

goal (1 subgoal):
 1. D $$ (0, 0) dvd D $$ (1, 1)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
D $$ (0, 0) dvd D $$ (1, 1)

goal (2 subgoals):
 1. finite {a, b, c}
 2. \<forall>x\<in>{a, b, c}. u dvd x
[PROOF STEP]
from this
[PROOF STATE]
proof (chain)
picking this:
D $$ (0, 0) dvd D $$ (1, 1)
[PROOF STEP]
obtain k where D11: "D $$ (1, 1) = D $$ (0,0) * k"
[PROOF STATE]
proof (prove)
using this:
D $$ (0, 0) dvd D $$ (1, 1)

goal (1 subgoal):
 1. (\<And>k. D $$ (1, 1) = D $$ (0, 0) * k \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
unfolding dvd_def
[PROOF STATE]
proof (prove)
using this:
\<exists>k. D $$ (1, 1) = D $$ (0, 0) * k

goal (1 subgoal):
 1. (\<And>k. D $$ (1, 1) = D $$ (0, 0) * k \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
D $$ (1, 1) = D $$ (0, 0) * k

goal (2 subgoals):
 1. finite {a, b, c}
 2. \<forall>x\<in>{a, b, c}. u dvd x
[PROOF STEP]
have P'D_00: "(P' * D) $$ (0, 0) = P' $$ (0, 0) * D $$ (0, 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (P' * D) $$ (0, 0) = P' $$ (0, 0) * D $$ (0, 0)
[PROOF STEP]
using mat_mult2_00[of P' D] D_10
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>P' \<in> carrier_mat 2 2; D \<in> carrier_mat 2 2; ?A = P' * D\<rbrakk> \<Longrightarrow> ?A $$ (0, 0) = P' $$ (0, 0) * D $$ (0, 0) + P' $$ (0, 1) * D $$ (1, 0)
D $$ (1, 0) = (0::'a)

goal (1 subgoal):
 1. (P' * D) $$ (0, 0) = P' $$ (0, 0) * D $$ (0, 0)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(P' * D) $$ (0, 0) = P' $$ (0, 0) * D $$ (0, 0)

goal (2 subgoals):
 1. finite {a, b, c}
 2. \<forall>x\<in>{a, b, c}. u dvd x
[PROOF STEP]
have P'D_01: "(P' * D) $$ (0, 1) =  P' $$ (0, 1) * D $$ (1, 1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (P' * D) $$ (0, 1) = P' $$ (0, 1) * D $$ (1, 1)
[PROOF STEP]
using mat_mult2_01[of P' D] D_01
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>P' \<in> carrier_mat 2 2; D \<in> carrier_mat 2 2; ?A = P' * D\<rbrakk> \<Longrightarrow> ?A $$ (0, 1) = P' $$ (0, 0) * D $$ (0, 1) + P' $$ (0, 1) * D $$ (1, 1)
D $$ (0, 1) = (0::'a)

goal (1 subgoal):
 1. (P' * D) $$ (0, 1) = P' $$ (0, 1) * D $$ (1, 1)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(P' * D) $$ (0, 1) = P' $$ (0, 1) * D $$ (1, 1)

goal (2 subgoals):
 1. finite {a, b, c}
 2. \<forall>x\<in>{a, b, c}. u dvd x
[PROOF STEP]
have P'D_10: "(P' * D) $$ (1, 0) = P' $$ (1, 0) * D $$ (0, 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (P' * D) $$ (1, 0) = P' $$ (1, 0) * D $$ (0, 0)
[PROOF STEP]
using mat_mult2_10[of P' D] D_10
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>P' \<in> carrier_mat 2 2; D \<in> carrier_mat 2 2; ?A = P' * D\<rbrakk> \<Longrightarrow> ?A $$ (1, 0) = P' $$ (1, 0) * D $$ (0, 0) + P' $$ (1, 1) * D $$ (1, 0)
D $$ (1, 0) = (0::'a)

goal (1 subgoal):
 1. (P' * D) $$ (1, 0) = P' $$ (1, 0) * D $$ (0, 0)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(P' * D) $$ (1, 0) = P' $$ (1, 0) * D $$ (0, 0)

goal (2 subgoals):
 1. finite {a, b, c}
 2. \<forall>x\<in>{a, b, c}. u dvd x
[PROOF STEP]
have P'D_11: "(P' * D) $$ (1, 1) = P' $$ (1, 1) * D $$ (1, 1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (P' * D) $$ (1, 1) = P' $$ (1, 1) * D $$ (1, 1)
[PROOF STEP]
using mat_mult2_11[of P' D] D_01
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>P' \<in> carrier_mat 2 2; D \<in> carrier_mat 2 2; ?A = P' * D\<rbrakk> \<Longrightarrow> ?A $$ (1, 1) = P' $$ (1, 0) * D $$ (0, 1) + P' $$ (1, 1) * D $$ (1, 1)
D $$ (0, 1) = (0::'a)

goal (1 subgoal):
 1. (P' * D) $$ (1, 1) = P' $$ (1, 1) * D $$ (1, 1)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(P' * D) $$ (1, 1) = P' $$ (1, 1) * D $$ (1, 1)

goal (2 subgoals):
 1. finite {a, b, c}
 2. \<forall>x\<in>{a, b, c}. u dvd x
[PROOF STEP]
have "a = (P' * D * Q') $$ (0,0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a = (P' * D * Q') $$ (0, 0)
[PROOF STEP]
using e A_def
[PROOF STATE]
proof (prove)
using this:
P' * D * Q' = A
A = Matrix.mat 2 2 (\<lambda>(i, j). if i = 0 \<and> j = 0 then a else if i = 0 \<and> j = 1 then b else if i = 1 \<and> j = 0 then 0::'a else c)

goal (1 subgoal):
 1. a = (P' * D * Q') $$ (0, 0)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
a = (P' * D * Q') $$ (0, 0)

goal (2 subgoals):
 1. finite {a, b, c}
 2. \<forall>x\<in>{a, b, c}. u dvd x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
a = (P' * D * Q') $$ (0, 0)

goal (2 subgoals):
 1. finite {a, b, c}
 2. \<forall>x\<in>{a, b, c}. u dvd x
[PROOF STEP]
have "... = (P' * D) $$ (0, 0) * Q' $$ (0, 0) + (P' * D) $$ (0, 1) * Q' $$ (1, 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (P' * D * Q') $$ (0, 0) = (P' * D) $$ (0, 0) * Q' $$ (0, 0) + (P' * D) $$ (0, 1) * Q' $$ (1, 0)
[PROOF STEP]
by (rule mat_mult2_00, auto)
[PROOF STATE]
proof (state)
this:
(P' * D * Q') $$ (0, 0) = (P' * D) $$ (0, 0) * Q' $$ (0, 0) + (P' * D) $$ (0, 1) * Q' $$ (1, 0)

goal (2 subgoals):
 1. finite {a, b, c}
 2. \<forall>x\<in>{a, b, c}. u dvd x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(P' * D * Q') $$ (0, 0) = (P' * D) $$ (0, 0) * Q' $$ (0, 0) + (P' * D) $$ (0, 1) * Q' $$ (1, 0)

goal (2 subgoals):
 1. finite {a, b, c}
 2. \<forall>x\<in>{a, b, c}. u dvd x
[PROOF STEP]
have "... = P' $$ (0, 0) * D $$ (0, 0) * Q' $$ (0, 0)
      + P' $$ (0, 1) * (D $$ (0, 0) * k) * Q' $$ (1, 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (P' * D) $$ (0, 0) * Q' $$ (0, 0) + (P' * D) $$ (0, 1) * Q' $$ (1, 0) = P' $$ (0, 0) * D $$ (0, 0) * Q' $$ (0, 0) + P' $$ (0, 1) * (D $$ (0, 0) * k) * Q' $$ (1, 0)
[PROOF STEP]
unfolding P'D_00 P'D_01 D11
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. P' $$ (0, 0) * D $$ (0, 0) * Q' $$ (0, 0) + P' $$ (0, 1) * (D $$ (0, 0) * k) * Q' $$ (1, 0) = P' $$ (0, 0) * D $$ (0, 0) * Q' $$ (0, 0) + P' $$ (0, 1) * (D $$ (0, 0) * k) * Q' $$ (1, 0)
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
(P' * D) $$ (0, 0) * Q' $$ (0, 0) + (P' * D) $$ (0, 1) * Q' $$ (1, 0) = P' $$ (0, 0) * D $$ (0, 0) * Q' $$ (0, 0) + P' $$ (0, 1) * (D $$ (0, 0) * k) * Q' $$ (1, 0)

goal (2 subgoals):
 1. finite {a, b, c}
 2. \<forall>x\<in>{a, b, c}. u dvd x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(P' * D) $$ (0, 0) * Q' $$ (0, 0) + (P' * D) $$ (0, 1) * Q' $$ (1, 0) = P' $$ (0, 0) * D $$ (0, 0) * Q' $$ (0, 0) + P' $$ (0, 1) * (D $$ (0, 0) * k) * Q' $$ (1, 0)

goal (2 subgoals):
 1. finite {a, b, c}
 2. \<forall>x\<in>{a, b, c}. u dvd x
[PROOF STEP]
have "... = D $$ (0, 0) * (P' $$ (0, 0) * Q' $$ (0, 0)
      + P' $$ (0, 1) * k * Q' $$ (1, 0))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. P' $$ (0, 0) * D $$ (0, 0) * Q' $$ (0, 0) + P' $$ (0, 1) * (D $$ (0, 0) * k) * Q' $$ (1, 0) = D $$ (0, 0) * (P' $$ (0, 0) * Q' $$ (0, 0) + P' $$ (0, 1) * k * Q' $$ (1, 0))
[PROOF STEP]
by (simp add: distrib_left)
[PROOF STATE]
proof (state)
this:
P' $$ (0, 0) * D $$ (0, 0) * Q' $$ (0, 0) + P' $$ (0, 1) * (D $$ (0, 0) * k) * Q' $$ (1, 0) = D $$ (0, 0) * (P' $$ (0, 0) * Q' $$ (0, 0) + P' $$ (0, 1) * k * Q' $$ (1, 0))

goal (2 subgoals):
 1. finite {a, b, c}
 2. \<forall>x\<in>{a, b, c}. u dvd x
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
a = D $$ (0, 0) * (P' $$ (0, 0) * Q' $$ (0, 0) + P' $$ (0, 1) * k * Q' $$ (1, 0))
[PROOF STEP]
have u_dvd_a: "u dvd a"
[PROOF STATE]
proof (prove)
using this:
a = D $$ (0, 0) * (P' $$ (0, 0) * Q' $$ (0, 0) + P' $$ (0, 1) * k * Q' $$ (1, 0))

goal (1 subgoal):
 1. u dvd a
[PROOF STEP]
unfolding u_def D_def dvd_def
[PROOF STATE]
proof (prove)
using this:
a = (P * A * Q) $$ (0, 0) * (P' $$ (0, 0) * Q' $$ (0, 0) + P' $$ (0, 1) * k * Q' $$ (1, 0))

goal (1 subgoal):
 1. \<exists>k. a = (P * A * Q) $$ (0, 0) * k
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
u dvd a

goal (2 subgoals):
 1. finite {a, b, c}
 2. \<forall>x\<in>{a, b, c}. u dvd x
[PROOF STEP]
have "b = (P' * D * Q') $$ (0,1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. b = (P' * D * Q') $$ (0, 1)
[PROOF STEP]
using e A_def
[PROOF STATE]
proof (prove)
using this:
P' * D * Q' = A
A = Matrix.mat 2 2 (\<lambda>(i, j). if i = 0 \<and> j = 0 then a else if i = 0 \<and> j = 1 then b else if i = 1 \<and> j = 0 then 0::'a else c)

goal (1 subgoal):
 1. b = (P' * D * Q') $$ (0, 1)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
b = (P' * D * Q') $$ (0, 1)

goal (2 subgoals):
 1. finite {a, b, c}
 2. \<forall>x\<in>{a, b, c}. u dvd x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
b = (P' * D * Q') $$ (0, 1)

goal (2 subgoals):
 1. finite {a, b, c}
 2. \<forall>x\<in>{a, b, c}. u dvd x
[PROOF STEP]
have "... = (P' * D) $$ (0, 0) * Q' $$ (0, 1) + (P' * D) $$ (0, 1) * Q' $$ (1, 1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (P' * D * Q') $$ (0, 1) = (P' * D) $$ (0, 0) * Q' $$ (0, 1) + (P' * D) $$ (0, 1) * Q' $$ (1, 1)
[PROOF STEP]
by (rule mat_mult2_01, auto)
[PROOF STATE]
proof (state)
this:
(P' * D * Q') $$ (0, 1) = (P' * D) $$ (0, 0) * Q' $$ (0, 1) + (P' * D) $$ (0, 1) * Q' $$ (1, 1)

goal (2 subgoals):
 1. finite {a, b, c}
 2. \<forall>x\<in>{a, b, c}. u dvd x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(P' * D * Q') $$ (0, 1) = (P' * D) $$ (0, 0) * Q' $$ (0, 1) + (P' * D) $$ (0, 1) * Q' $$ (1, 1)

goal (2 subgoals):
 1. finite {a, b, c}
 2. \<forall>x\<in>{a, b, c}. u dvd x
[PROOF STEP]
have "... =  P' $$ (0, 0) * D $$ (0, 0) * Q' $$ (0, 1) +
       P' $$ (0, 1) * (D $$ (0, 0) * k) * Q' $$ (1, 1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (P' * D) $$ (0, 0) * Q' $$ (0, 1) + (P' * D) $$ (0, 1) * Q' $$ (1, 1) = P' $$ (0, 0) * D $$ (0, 0) * Q' $$ (0, 1) + P' $$ (0, 1) * (D $$ (0, 0) * k) * Q' $$ (1, 1)
[PROOF STEP]
unfolding P'D_00 P'D_01 D11
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. P' $$ (0, 0) * D $$ (0, 0) * Q' $$ (0, 1) + P' $$ (0, 1) * (D $$ (0, 0) * k) * Q' $$ (1, 1) = P' $$ (0, 0) * D $$ (0, 0) * Q' $$ (0, 1) + P' $$ (0, 1) * (D $$ (0, 0) * k) * Q' $$ (1, 1)
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
(P' * D) $$ (0, 0) * Q' $$ (0, 1) + (P' * D) $$ (0, 1) * Q' $$ (1, 1) = P' $$ (0, 0) * D $$ (0, 0) * Q' $$ (0, 1) + P' $$ (0, 1) * (D $$ (0, 0) * k) * Q' $$ (1, 1)

goal (2 subgoals):
 1. finite {a, b, c}
 2. \<forall>x\<in>{a, b, c}. u dvd x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(P' * D) $$ (0, 0) * Q' $$ (0, 1) + (P' * D) $$ (0, 1) * Q' $$ (1, 1) = P' $$ (0, 0) * D $$ (0, 0) * Q' $$ (0, 1) + P' $$ (0, 1) * (D $$ (0, 0) * k) * Q' $$ (1, 1)

goal (2 subgoals):
 1. finite {a, b, c}
 2. \<forall>x\<in>{a, b, c}. u dvd x
[PROOF STEP]
have "... = D $$ (0, 0) * (P' $$ (0, 0) * Q' $$ (0, 1) +
       P' $$ (0, 1) * k * Q' $$ (1, 1))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. P' $$ (0, 0) * D $$ (0, 0) * Q' $$ (0, 1) + P' $$ (0, 1) * (D $$ (0, 0) * k) * Q' $$ (1, 1) = D $$ (0, 0) * (P' $$ (0, 0) * Q' $$ (0, 1) + P' $$ (0, 1) * k * Q' $$ (1, 1))
[PROOF STEP]
by (simp add: distrib_left)
[PROOF STATE]
proof (state)
this:
P' $$ (0, 0) * D $$ (0, 0) * Q' $$ (0, 1) + P' $$ (0, 1) * (D $$ (0, 0) * k) * Q' $$ (1, 1) = D $$ (0, 0) * (P' $$ (0, 0) * Q' $$ (0, 1) + P' $$ (0, 1) * k * Q' $$ (1, 1))

goal (2 subgoals):
 1. finite {a, b, c}
 2. \<forall>x\<in>{a, b, c}. u dvd x
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
b = D $$ (0, 0) * (P' $$ (0, 0) * Q' $$ (0, 1) + P' $$ (0, 1) * k * Q' $$ (1, 1))
[PROOF STEP]
have u_dvd_b: "u dvd b"
[PROOF STATE]
proof (prove)
using this:
b = D $$ (0, 0) * (P' $$ (0, 0) * Q' $$ (0, 1) + P' $$ (0, 1) * k * Q' $$ (1, 1))

goal (1 subgoal):
 1. u dvd b
[PROOF STEP]
unfolding u_def D_def dvd_def
[PROOF STATE]
proof (prove)
using this:
b = (P * A * Q) $$ (0, 0) * (P' $$ (0, 0) * Q' $$ (0, 1) + P' $$ (0, 1) * k * Q' $$ (1, 1))

goal (1 subgoal):
 1. \<exists>k. b = (P * A * Q) $$ (0, 0) * k
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
u dvd b

goal (2 subgoals):
 1. finite {a, b, c}
 2. \<forall>x\<in>{a, b, c}. u dvd x
[PROOF STEP]
have "c = (P' * D * Q') $$ (1,1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. c = (P' * D * Q') $$ (1, 1)
[PROOF STEP]
using e A_def
[PROOF STATE]
proof (prove)
using this:
P' * D * Q' = A
A = Matrix.mat 2 2 (\<lambda>(i, j). if i = 0 \<and> j = 0 then a else if i = 0 \<and> j = 1 then b else if i = 1 \<and> j = 0 then 0::'a else c)

goal (1 subgoal):
 1. c = (P' * D * Q') $$ (1, 1)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
c = (P' * D * Q') $$ (1, 1)

goal (2 subgoals):
 1. finite {a, b, c}
 2. \<forall>x\<in>{a, b, c}. u dvd x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
c = (P' * D * Q') $$ (1, 1)

goal (2 subgoals):
 1. finite {a, b, c}
 2. \<forall>x\<in>{a, b, c}. u dvd x
[PROOF STEP]
have "... = (P' * D) $$ (1, 0) * Q' $$ (0, 1) + (P' * D) $$ (1, 1) * Q' $$ (1, 1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (P' * D * Q') $$ (1, 1) = (P' * D) $$ (1, 0) * Q' $$ (0, 1) + (P' * D) $$ (1, 1) * Q' $$ (1, 1)
[PROOF STEP]
by (rule mat_mult2_11, auto)
[PROOF STATE]
proof (state)
this:
(P' * D * Q') $$ (1, 1) = (P' * D) $$ (1, 0) * Q' $$ (0, 1) + (P' * D) $$ (1, 1) * Q' $$ (1, 1)

goal (2 subgoals):
 1. finite {a, b, c}
 2. \<forall>x\<in>{a, b, c}. u dvd x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(P' * D * Q') $$ (1, 1) = (P' * D) $$ (1, 0) * Q' $$ (0, 1) + (P' * D) $$ (1, 1) * Q' $$ (1, 1)

goal (2 subgoals):
 1. finite {a, b, c}
 2. \<forall>x\<in>{a, b, c}. u dvd x
[PROOF STEP]
have "... = P' $$ (1, 0) * D $$ (0, 0) * Q' $$ (0, 1)
        + P' $$ (1, 1) * (D $$ (0, 0) * k) * Q' $$ (1, 1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (P' * D) $$ (1, 0) * Q' $$ (0, 1) + (P' * D) $$ (1, 1) * Q' $$ (1, 1) = P' $$ (1, 0) * D $$ (0, 0) * Q' $$ (0, 1) + P' $$ (1, 1) * (D $$ (0, 0) * k) * Q' $$ (1, 1)
[PROOF STEP]
unfolding P'D_11 P'D_10 D11
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. P' $$ (1, 0) * D $$ (0, 0) * Q' $$ (0, 1) + P' $$ (1, 1) * (D $$ (0, 0) * k) * Q' $$ (1, 1) = P' $$ (1, 0) * D $$ (0, 0) * Q' $$ (0, 1) + P' $$ (1, 1) * (D $$ (0, 0) * k) * Q' $$ (1, 1)
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
(P' * D) $$ (1, 0) * Q' $$ (0, 1) + (P' * D) $$ (1, 1) * Q' $$ (1, 1) = P' $$ (1, 0) * D $$ (0, 0) * Q' $$ (0, 1) + P' $$ (1, 1) * (D $$ (0, 0) * k) * Q' $$ (1, 1)

goal (2 subgoals):
 1. finite {a, b, c}
 2. \<forall>x\<in>{a, b, c}. u dvd x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(P' * D) $$ (1, 0) * Q' $$ (0, 1) + (P' * D) $$ (1, 1) * Q' $$ (1, 1) = P' $$ (1, 0) * D $$ (0, 0) * Q' $$ (0, 1) + P' $$ (1, 1) * (D $$ (0, 0) * k) * Q' $$ (1, 1)

goal (2 subgoals):
 1. finite {a, b, c}
 2. \<forall>x\<in>{a, b, c}. u dvd x
[PROOF STEP]
have "... = D $$ (0, 0) * (P' $$ (1, 0) * Q' $$ (0, 1)
        + P' $$ (1, 1) * k * Q' $$ (1, 1))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. P' $$ (1, 0) * D $$ (0, 0) * Q' $$ (0, 1) + P' $$ (1, 1) * (D $$ (0, 0) * k) * Q' $$ (1, 1) = D $$ (0, 0) * (P' $$ (1, 0) * Q' $$ (0, 1) + P' $$ (1, 1) * k * Q' $$ (1, 1))
[PROOF STEP]
by (simp add: distrib_left)
[PROOF STATE]
proof (state)
this:
P' $$ (1, 0) * D $$ (0, 0) * Q' $$ (0, 1) + P' $$ (1, 1) * (D $$ (0, 0) * k) * Q' $$ (1, 1) = D $$ (0, 0) * (P' $$ (1, 0) * Q' $$ (0, 1) + P' $$ (1, 1) * k * Q' $$ (1, 1))

goal (2 subgoals):
 1. finite {a, b, c}
 2. \<forall>x\<in>{a, b, c}. u dvd x
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
c = D $$ (0, 0) * (P' $$ (1, 0) * Q' $$ (0, 1) + P' $$ (1, 1) * k * Q' $$ (1, 1))
[PROOF STEP]
have u_dvd_c: "u dvd c"
[PROOF STATE]
proof (prove)
using this:
c = D $$ (0, 0) * (P' $$ (1, 0) * Q' $$ (0, 1) + P' $$ (1, 1) * k * Q' $$ (1, 1))

goal (1 subgoal):
 1. u dvd c
[PROOF STEP]
unfolding u_def D_def dvd_def
[PROOF STATE]
proof (prove)
using this:
c = (P * A * Q) $$ (0, 0) * (P' $$ (1, 0) * Q' $$ (0, 1) + P' $$ (1, 1) * k * Q' $$ (1, 1))

goal (1 subgoal):
 1. \<exists>k. c = (P * A * Q) $$ (0, 0) * k
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
u dvd c

goal (2 subgoals):
 1. finite {a, b, c}
 2. \<forall>x\<in>{a, b, c}. u dvd x
[PROOF STEP]
show "\<forall>x\<in>{a,b,c}. u dvd x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>x\<in>{a, b, c}. u dvd x
[PROOF STEP]
using u_dvd_a u_dvd_b u_dvd_c
[PROOF STATE]
proof (prove)
using this:
u dvd a
u dvd b
u dvd c

goal (1 subgoal):
 1. \<forall>x\<in>{a, b, c}. u dvd x
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<forall>x\<in>{a, b, c}. u dvd x

goal (1 subgoal):
 1. finite {a, b, c}
[PROOF STEP]
qed (simp)
[PROOF STATE]
proof (state)
this:
u dvd (1::'a)

goal (1 subgoal):
 1. \<And>a b c. ideal_generated {a, b, c} = ideal_generated {1::'a} \<Longrightarrow> \<exists>p q. ideal_generated {p * a, p * b + q * c} = ideal_generated {1::'a}
[PROOF STEP]
have "ideal_generated {p*a,p*b+q*c} = ideal_generated {1}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ideal_generated {p * a, p * b + q * c} = ideal_generated {1::'a}
[PROOF STEP]
by (metis (no_types, lifting) eq add.assoc ideal_generated_1 ideal_generated_pair_UNIV
        mult.commute semiring_normalization_rules(34) u_dvd_1)
[PROOF STATE]
proof (state)
this:
ideal_generated {p * a, p * b + q * c} = ideal_generated {1::'a}

goal (1 subgoal):
 1. \<And>a b c. ideal_generated {a, b, c} = ideal_generated {1::'a} \<Longrightarrow> \<exists>p q. ideal_generated {p * a, p * b + q * c} = ideal_generated {1::'a}
[PROOF STEP]
from this
[PROOF STATE]
proof (chain)
picking this:
ideal_generated {p * a, p * b + q * c} = ideal_generated {1::'a}
[PROOF STEP]
show "\<exists>p q. ideal_generated {p * a, p * b + q * c} = ideal_generated {1}"
[PROOF STATE]
proof (prove)
using this:
ideal_generated {p * a, p * b + q * c} = ideal_generated {1::'a}

goal (1 subgoal):
 1. \<exists>p q. ideal_generated {p * a, p * b + q * c} = ideal_generated {1::'a}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<exists>p q. ideal_generated {p * a, p * b + q * c} = ideal_generated {1::'a}

goal:
No subgoals!
[PROOF STEP]
qed