[STATEMENT]
lemma bulk_update_algebraic_closed_form:
  assumes "0 \<le> i"
  and "\<forall> n . \<rho> n < 1"
  and "\<forall> n m . n < m \<longrightarrow> \<rho> n < \<rho> m"
  and "\<rho> 0 = 0"
  shows "bulk_update_account n \<rho> i \<alpha>
           = just_cash (
                (1 + i) ^ n * (cash_reserve \<alpha>)
                + (\<Sum> k = 1..shortest_period \<alpha>.
                      (\<pi> \<alpha> k) * i * ((1 + i) ^ n - (1 - \<rho> k) ^ n)
                         / (i + \<rho> k))
             )
             + (\<Sum>k = 1..shortest_period \<alpha>. \<delta> k ((1 - \<rho> k) ^ n * \<pi> \<alpha> k))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bulk_update_account n \<rho> i \<alpha> = just_cash ((1 + i) ^ n * cash_reserve \<alpha> + (\<Sum>k = 1..shortest_period \<alpha>. \<pi> \<alpha> k * i * ((1 + i) ^ n - (1 - \<rho> k) ^ n) / (i + \<rho> k))) + (\<Sum>k = 1..shortest_period \<alpha>. \<delta> k ((1 - \<rho> k) ^ n * \<pi> \<alpha> k))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. bulk_update_account n \<rho> i \<alpha> = just_cash ((1 + i) ^ n * cash_reserve \<alpha> + (\<Sum>k = 1..shortest_period \<alpha>. \<pi> \<alpha> k * i * ((1 + i) ^ n - (1 - \<rho> k) ^ n) / (i + \<rho> k))) + (\<Sum>k = 1..shortest_period \<alpha>. \<delta> k ((1 - \<rho> k) ^ n * \<pi> \<alpha> k))
[PROOF STEP]
{
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. bulk_update_account n \<rho> i \<alpha> = just_cash ((1 + i) ^ n * cash_reserve \<alpha> + (\<Sum>k = 1..shortest_period \<alpha>. \<pi> \<alpha> k * i * ((1 + i) ^ n - (1 - \<rho> k) ^ n) / (i + \<rho> k))) + (\<Sum>k = 1..shortest_period \<alpha>. \<delta> k ((1 - \<rho> k) ^ n * \<pi> \<alpha> k))
[PROOF STEP]
fix m
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. bulk_update_account n \<rho> i \<alpha> = just_cash ((1 + i) ^ n * cash_reserve \<alpha> + (\<Sum>k = 1..shortest_period \<alpha>. \<pi> \<alpha> k * i * ((1 + i) ^ n - (1 - \<rho> k) ^ n) / (i + \<rho> k))) + (\<Sum>k = 1..shortest_period \<alpha>. \<delta> k ((1 - \<rho> k) ^ n * \<pi> \<alpha> k))
[PROOF STEP]
have "\<forall> k \<in> {1..m}. \<rho> k \<noteq> 1 \<and> \<rho> k > 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>k\<in>{1..m}. \<rho> k \<noteq> 1 \<and> 0 < \<rho> k
[PROOF STEP]
by (metis
            assms(2)
            assms(3)
            assms(4)
            atLeastAtMost_iff
            dual_order.refl
            less_numeral_extra(1)
            linorder_not_less
            not_gr_zero)
[PROOF STATE]
proof (state)
this:
\<forall>k\<in>{1..m}. \<rho> k \<noteq> 1 \<and> 0 < \<rho> k

goal (1 subgoal):
 1. bulk_update_account n \<rho> i \<alpha> = just_cash ((1 + i) ^ n * cash_reserve \<alpha> + (\<Sum>k = 1..shortest_period \<alpha>. \<pi> \<alpha> k * i * ((1 + i) ^ n - (1 - \<rho> k) ^ n) / (i + \<rho> k))) + (\<Sum>k = 1..shortest_period \<alpha>. \<delta> k ((1 - \<rho> k) ^ n * \<pi> \<alpha> k))
[PROOF STEP]
hence \<star>: "\<forall> k \<in> {1..m}.
                 bulk_update_account n \<rho> i (\<delta> k (\<pi> \<alpha> k))
               = just_cash ((\<pi> \<alpha> k) * i * ((1 + i) ^ n - (1 - \<rho> k) ^ n)
                               / (i + \<rho> k))
                 + \<delta> k ((1 - \<rho> k) ^ n * (\<pi> \<alpha> k))"
[PROOF STATE]
proof (prove)
using this:
\<forall>k\<in>{1..m}. \<rho> k \<noteq> 1 \<and> 0 < \<rho> k

goal (1 subgoal):
 1. \<forall>k\<in>{1..m}. bulk_update_account n \<rho> i (\<delta> k (\<pi> \<alpha> k)) = just_cash (\<pi> \<alpha> k * i * ((1 + i) ^ n - (1 - \<rho> k) ^ n) / (i + \<rho> k)) + \<delta> k ((1 - \<rho> k) ^ n * \<pi> \<alpha> k)
[PROOF STEP]
using assms(1) assms(4) bulk_update_loan_closed_form
[PROOF STATE]
proof (prove)
using this:
\<forall>k\<in>{1..m}. \<rho> k \<noteq> 1 \<and> 0 < \<rho> k
0 \<le> i
\<rho> 0 = 0
\<lbrakk>?\<rho> ?k \<noteq> 1; 0 < ?\<rho> ?k; ?\<rho> 0 = 0; 0 \<le> ?i\<rbrakk> \<Longrightarrow> bulk_update_account ?n ?\<rho> ?i (\<delta> ?k ?c) = just_cash (?c * ?i * ((1 + ?i) ^ ?n - (1 - ?\<rho> ?k) ^ ?n) / (?i + ?\<rho> ?k)) + \<delta> ?k ((1 - ?\<rho> ?k) ^ ?n * ?c)

goal (1 subgoal):
 1. \<forall>k\<in>{1..m}. bulk_update_account n \<rho> i (\<delta> k (\<pi> \<alpha> k)) = just_cash (\<pi> \<alpha> k * i * ((1 + i) ^ n - (1 - \<rho> k) ^ n) / (i + \<rho> k)) + \<delta> k ((1 - \<rho> k) ^ n * \<pi> \<alpha> k)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
\<forall>k\<in>{1..m}. bulk_update_account n \<rho> i (\<delta> k (\<pi> \<alpha> k)) = just_cash (\<pi> \<alpha> k * i * ((1 + i) ^ n - (1 - \<rho> k) ^ n) / (i + \<rho> k)) + \<delta> k ((1 - \<rho> k) ^ n * \<pi> \<alpha> k)

goal (1 subgoal):
 1. bulk_update_account n \<rho> i \<alpha> = just_cash ((1 + i) ^ n * cash_reserve \<alpha> + (\<Sum>k = 1..shortest_period \<alpha>. \<pi> \<alpha> k * i * ((1 + i) ^ n - (1 - \<rho> k) ^ n) / (i + \<rho> k))) + (\<Sum>k = 1..shortest_period \<alpha>. \<delta> k ((1 - \<rho> k) ^ n * \<pi> \<alpha> k))
[PROOF STEP]
have "bulk_update_account n \<rho> i (\<Sum> k \<le> m. \<delta> k (\<pi> \<alpha> k))
            = (\<Sum> k \<le> m. bulk_update_account n \<rho> i (\<delta> k (\<pi> \<alpha> k)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bulk_update_account n \<rho> i (\<Sum>k\<le>m. \<delta> k (\<pi> \<alpha> k)) = (\<Sum>k\<le>m. bulk_update_account n \<rho> i (\<delta> k (\<pi> \<alpha> k)))
[PROOF STEP]
by (induct m, simp, simp add: bulk_update_account_plus)
[PROOF STATE]
proof (state)
this:
bulk_update_account n \<rho> i (\<Sum>k\<le>m. \<delta> k (\<pi> \<alpha> k)) = (\<Sum>k\<le>m. bulk_update_account n \<rho> i (\<delta> k (\<pi> \<alpha> k)))

goal (1 subgoal):
 1. bulk_update_account n \<rho> i \<alpha> = just_cash ((1 + i) ^ n * cash_reserve \<alpha> + (\<Sum>k = 1..shortest_period \<alpha>. \<pi> \<alpha> k * i * ((1 + i) ^ n - (1 - \<rho> k) ^ n) / (i + \<rho> k))) + (\<Sum>k = 1..shortest_period \<alpha>. \<delta> k ((1 - \<rho> k) ^ n * \<pi> \<alpha> k))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
bulk_update_account n \<rho> i (\<Sum>k\<le>m. \<delta> k (\<pi> \<alpha> k)) = (\<Sum>k\<le>m. bulk_update_account n \<rho> i (\<delta> k (\<pi> \<alpha> k)))

goal (1 subgoal):
 1. bulk_update_account n \<rho> i \<alpha> = just_cash ((1 + i) ^ n * cash_reserve \<alpha> + (\<Sum>k = 1..shortest_period \<alpha>. \<pi> \<alpha> k * i * ((1 + i) ^ n - (1 - \<rho> k) ^ n) / (i + \<rho> k))) + (\<Sum>k = 1..shortest_period \<alpha>. \<delta> k ((1 - \<rho> k) ^ n * \<pi> \<alpha> k))
[PROOF STEP]
have
      "\<dots> =   bulk_update_account n \<rho> i (\<delta> 0 (\<pi> \<alpha> 0))
            + (\<Sum> k = 1..m. bulk_update_account n \<rho> i (\<delta> k (\<pi> \<alpha> k)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>k\<le>m. bulk_update_account n \<rho> i (\<delta> k (\<pi> \<alpha> k))) = bulk_update_account n \<rho> i (\<delta> 0 (\<pi> \<alpha> 0)) + (\<Sum>k = 1..m. bulk_update_account n \<rho> i (\<delta> k (\<pi> \<alpha> k)))
[PROOF STEP]
by (simp add: atMost_atLeast0 sum.atLeast_Suc_atMost)
[PROOF STATE]
proof (state)
this:
(\<Sum>k\<le>m. bulk_update_account n \<rho> i (\<delta> k (\<pi> \<alpha> k))) = bulk_update_account n \<rho> i (\<delta> 0 (\<pi> \<alpha> 0)) + (\<Sum>k = 1..m. bulk_update_account n \<rho> i (\<delta> k (\<pi> \<alpha> k)))

goal (1 subgoal):
 1. bulk_update_account n \<rho> i \<alpha> = just_cash ((1 + i) ^ n * cash_reserve \<alpha> + (\<Sum>k = 1..shortest_period \<alpha>. \<pi> \<alpha> k * i * ((1 + i) ^ n - (1 - \<rho> k) ^ n) / (i + \<rho> k))) + (\<Sum>k = 1..shortest_period \<alpha>. \<delta> k ((1 - \<rho> k) ^ n * \<pi> \<alpha> k))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>k\<le>m. bulk_update_account n \<rho> i (\<delta> k (\<pi> \<alpha> k))) = bulk_update_account n \<rho> i (\<delta> 0 (\<pi> \<alpha> 0)) + (\<Sum>k = 1..m. bulk_update_account n \<rho> i (\<delta> k (\<pi> \<alpha> k)))

goal (1 subgoal):
 1. bulk_update_account n \<rho> i \<alpha> = just_cash ((1 + i) ^ n * cash_reserve \<alpha> + (\<Sum>k = 1..shortest_period \<alpha>. \<pi> \<alpha> k * i * ((1 + i) ^ n - (1 - \<rho> k) ^ n) / (i + \<rho> k))) + (\<Sum>k = 1..shortest_period \<alpha>. \<delta> k ((1 - \<rho> k) ^ n * \<pi> \<alpha> k))
[PROOF STEP]
have
      "\<dots> =   just_cash ((1 + i) ^ n * cash_reserve \<alpha>)
            + (\<Sum> k = 1..m. bulk_update_account n \<rho> i (\<delta> k (\<pi> \<alpha> k)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bulk_update_account n \<rho> i (\<delta> 0 (\<pi> \<alpha> 0)) + (\<Sum>k = 1..m. bulk_update_account n \<rho> i (\<delta> k (\<pi> \<alpha> k))) = just_cash ((1 + i) ^ n * cash_reserve \<alpha>) + (\<Sum>k = 1..m. bulk_update_account n \<rho> i (\<delta> k (\<pi> \<alpha> k)))
[PROOF STEP]
using
        \<open>\<rho> 0 = 0\<close>
        bulk_update_just_cash_closed_form
        loan_just_cash
        cash_reserve_def
[PROOF STATE]
proof (prove)
using this:
\<rho> 0 = 0
?\<rho> 0 = 0 \<Longrightarrow> bulk_update_account ?n ?\<rho> ?i (just_cash ?c) = just_cash ((1 + ?i) ^ ?n * ?c)
\<delta> 0 ?c = just_cash ?c
cash_reserve ?\<alpha> = \<pi> ?\<alpha> 0

goal (1 subgoal):
 1. bulk_update_account n \<rho> i (\<delta> 0 (\<pi> \<alpha> 0)) + (\<Sum>k = 1..m. bulk_update_account n \<rho> i (\<delta> k (\<pi> \<alpha> k))) = just_cash ((1 + i) ^ n * cash_reserve \<alpha>) + (\<Sum>k = 1..m. bulk_update_account n \<rho> i (\<delta> k (\<pi> \<alpha> k)))
[PROOF STEP]
by presburger
[PROOF STATE]
proof (state)
this:
bulk_update_account n \<rho> i (\<delta> 0 (\<pi> \<alpha> 0)) + (\<Sum>k = 1..m. bulk_update_account n \<rho> i (\<delta> k (\<pi> \<alpha> k))) = just_cash ((1 + i) ^ n * cash_reserve \<alpha>) + (\<Sum>k = 1..m. bulk_update_account n \<rho> i (\<delta> k (\<pi> \<alpha> k)))

goal (1 subgoal):
 1. bulk_update_account n \<rho> i \<alpha> = just_cash ((1 + i) ^ n * cash_reserve \<alpha> + (\<Sum>k = 1..shortest_period \<alpha>. \<pi> \<alpha> k * i * ((1 + i) ^ n - (1 - \<rho> k) ^ n) / (i + \<rho> k))) + (\<Sum>k = 1..shortest_period \<alpha>. \<delta> k ((1 - \<rho> k) ^ n * \<pi> \<alpha> k))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
bulk_update_account n \<rho> i (\<delta> 0 (\<pi> \<alpha> 0)) + (\<Sum>k = 1..m. bulk_update_account n \<rho> i (\<delta> k (\<pi> \<alpha> k))) = just_cash ((1 + i) ^ n * cash_reserve \<alpha>) + (\<Sum>k = 1..m. bulk_update_account n \<rho> i (\<delta> k (\<pi> \<alpha> k)))

goal (1 subgoal):
 1. bulk_update_account n \<rho> i \<alpha> = just_cash ((1 + i) ^ n * cash_reserve \<alpha> + (\<Sum>k = 1..shortest_period \<alpha>. \<pi> \<alpha> k * i * ((1 + i) ^ n - (1 - \<rho> k) ^ n) / (i + \<rho> k))) + (\<Sum>k = 1..shortest_period \<alpha>. \<delta> k ((1 - \<rho> k) ^ n * \<pi> \<alpha> k))
[PROOF STEP]
have
      "\<dots> =   just_cash ((1 + i) ^ n * cash_reserve \<alpha>)
            + (\<Sum> k = 1..m.
                  just_cash ((\<pi> \<alpha> k) * i * ((1 + i) ^ n - (1 - \<rho> k) ^ n)
                                 / (i + \<rho> k))
                  + \<delta> k ((1 - \<rho> k) ^ n * (\<pi> \<alpha> k)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. just_cash ((1 + i) ^ n * cash_reserve \<alpha>) + (\<Sum>k = 1..m. bulk_update_account n \<rho> i (\<delta> k (\<pi> \<alpha> k))) = just_cash ((1 + i) ^ n * cash_reserve \<alpha>) + (\<Sum>k = 1..m. just_cash (\<pi> \<alpha> k * i * ((1 + i) ^ n - (1 - \<rho> k) ^ n) / (i + \<rho> k)) + \<delta> k ((1 - \<rho> k) ^ n * \<pi> \<alpha> k))
[PROOF STEP]
using \<star>
[PROOF STATE]
proof (prove)
using this:
\<forall>k\<in>{1..m}. bulk_update_account n \<rho> i (\<delta> k (\<pi> \<alpha> k)) = just_cash (\<pi> \<alpha> k * i * ((1 + i) ^ n - (1 - \<rho> k) ^ n) / (i + \<rho> k)) + \<delta> k ((1 - \<rho> k) ^ n * \<pi> \<alpha> k)

goal (1 subgoal):
 1. just_cash ((1 + i) ^ n * cash_reserve \<alpha>) + (\<Sum>k = 1..m. bulk_update_account n \<rho> i (\<delta> k (\<pi> \<alpha> k))) = just_cash ((1 + i) ^ n * cash_reserve \<alpha>) + (\<Sum>k = 1..m. just_cash (\<pi> \<alpha> k * i * ((1 + i) ^ n - (1 - \<rho> k) ^ n) / (i + \<rho> k)) + \<delta> k ((1 - \<rho> k) ^ n * \<pi> \<alpha> k))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
just_cash ((1 + i) ^ n * cash_reserve \<alpha>) + (\<Sum>k = 1..m. bulk_update_account n \<rho> i (\<delta> k (\<pi> \<alpha> k))) = just_cash ((1 + i) ^ n * cash_reserve \<alpha>) + (\<Sum>k = 1..m. just_cash (\<pi> \<alpha> k * i * ((1 + i) ^ n - (1 - \<rho> k) ^ n) / (i + \<rho> k)) + \<delta> k ((1 - \<rho> k) ^ n * \<pi> \<alpha> k))

goal (1 subgoal):
 1. bulk_update_account n \<rho> i \<alpha> = just_cash ((1 + i) ^ n * cash_reserve \<alpha> + (\<Sum>k = 1..shortest_period \<alpha>. \<pi> \<alpha> k * i * ((1 + i) ^ n - (1 - \<rho> k) ^ n) / (i + \<rho> k))) + (\<Sum>k = 1..shortest_period \<alpha>. \<delta> k ((1 - \<rho> k) ^ n * \<pi> \<alpha> k))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
just_cash ((1 + i) ^ n * cash_reserve \<alpha>) + (\<Sum>k = 1..m. bulk_update_account n \<rho> i (\<delta> k (\<pi> \<alpha> k))) = just_cash ((1 + i) ^ n * cash_reserve \<alpha>) + (\<Sum>k = 1..m. just_cash (\<pi> \<alpha> k * i * ((1 + i) ^ n - (1 - \<rho> k) ^ n) / (i + \<rho> k)) + \<delta> k ((1 - \<rho> k) ^ n * \<pi> \<alpha> k))

goal (1 subgoal):
 1. bulk_update_account n \<rho> i \<alpha> = just_cash ((1 + i) ^ n * cash_reserve \<alpha> + (\<Sum>k = 1..shortest_period \<alpha>. \<pi> \<alpha> k * i * ((1 + i) ^ n - (1 - \<rho> k) ^ n) / (i + \<rho> k))) + (\<Sum>k = 1..shortest_period \<alpha>. \<delta> k ((1 - \<rho> k) ^ n * \<pi> \<alpha> k))
[PROOF STEP]
have
      "\<dots> =   just_cash ((1 + i) ^ n * cash_reserve \<alpha>)
            + (\<Sum> k = 1..m.
                  just_cash ((\<pi> \<alpha> k) * i * ((1 + i) ^ n - (1 - \<rho> k) ^ n)
                                 / (i + \<rho> k)))
            + (\<Sum> k = 1..m. \<delta> k ((1 - \<rho> k) ^ n * (\<pi> \<alpha> k)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. just_cash ((1 + i) ^ n * cash_reserve \<alpha>) + (\<Sum>k = 1..m. just_cash (\<pi> \<alpha> k * i * ((1 + i) ^ n - (1 - \<rho> k) ^ n) / (i + \<rho> k)) + \<delta> k ((1 - \<rho> k) ^ n * \<pi> \<alpha> k)) = just_cash ((1 + i) ^ n * cash_reserve \<alpha>) + (\<Sum>k = 1..m. just_cash (\<pi> \<alpha> k * i * ((1 + i) ^ n - (1 - \<rho> k) ^ n) / (i + \<rho> k))) + (\<Sum>k = 1..m. \<delta> k ((1 - \<rho> k) ^ n * \<pi> \<alpha> k))
[PROOF STEP]
by (induct m, auto)
[PROOF STATE]
proof (state)
this:
just_cash ((1 + i) ^ n * cash_reserve \<alpha>) + (\<Sum>k = 1..m. just_cash (\<pi> \<alpha> k * i * ((1 + i) ^ n - (1 - \<rho> k) ^ n) / (i + \<rho> k)) + \<delta> k ((1 - \<rho> k) ^ n * \<pi> \<alpha> k)) = just_cash ((1 + i) ^ n * cash_reserve \<alpha>) + (\<Sum>k = 1..m. just_cash (\<pi> \<alpha> k * i * ((1 + i) ^ n - (1 - \<rho> k) ^ n) / (i + \<rho> k))) + (\<Sum>k = 1..m. \<delta> k ((1 - \<rho> k) ^ n * \<pi> \<alpha> k))

goal (1 subgoal):
 1. bulk_update_account n \<rho> i \<alpha> = just_cash ((1 + i) ^ n * cash_reserve \<alpha> + (\<Sum>k = 1..shortest_period \<alpha>. \<pi> \<alpha> k * i * ((1 + i) ^ n - (1 - \<rho> k) ^ n) / (i + \<rho> k))) + (\<Sum>k = 1..shortest_period \<alpha>. \<delta> k ((1 - \<rho> k) ^ n * \<pi> \<alpha> k))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
just_cash ((1 + i) ^ n * cash_reserve \<alpha>) + (\<Sum>k = 1..m. just_cash (\<pi> \<alpha> k * i * ((1 + i) ^ n - (1 - \<rho> k) ^ n) / (i + \<rho> k)) + \<delta> k ((1 - \<rho> k) ^ n * \<pi> \<alpha> k)) = just_cash ((1 + i) ^ n * cash_reserve \<alpha>) + (\<Sum>k = 1..m. just_cash (\<pi> \<alpha> k * i * ((1 + i) ^ n - (1 - \<rho> k) ^ n) / (i + \<rho> k))) + (\<Sum>k = 1..m. \<delta> k ((1 - \<rho> k) ^ n * \<pi> \<alpha> k))

goal (1 subgoal):
 1. bulk_update_account n \<rho> i \<alpha> = just_cash ((1 + i) ^ n * cash_reserve \<alpha> + (\<Sum>k = 1..shortest_period \<alpha>. \<pi> \<alpha> k * i * ((1 + i) ^ n - (1 - \<rho> k) ^ n) / (i + \<rho> k))) + (\<Sum>k = 1..shortest_period \<alpha>. \<delta> k ((1 - \<rho> k) ^ n * \<pi> \<alpha> k))
[PROOF STEP]
have
      "\<dots> =   just_cash ((1 + i) ^ n * cash_reserve \<alpha>)
            + just_cash
                (\<Sum> k = 1..m.
                   (\<pi> \<alpha> k) * i * ((1 + i) ^ n - (1 - \<rho> k) ^ n) / (i + \<rho> k))
            + (\<Sum> k = 1..m. \<delta> k ((1 - \<rho> k) ^ n * (\<pi> \<alpha> k)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. just_cash ((1 + i) ^ n * cash_reserve \<alpha>) + (\<Sum>k = 1..m. just_cash (\<pi> \<alpha> k * i * ((1 + i) ^ n - (1 - \<rho> k) ^ n) / (i + \<rho> k))) + (\<Sum>k = 1..m. \<delta> k ((1 - \<rho> k) ^ n * \<pi> \<alpha> k)) = just_cash ((1 + i) ^ n * cash_reserve \<alpha>) + just_cash (\<Sum>k = 1..m. \<pi> \<alpha> k * i * ((1 + i) ^ n - (1 - \<rho> k) ^ n) / (i + \<rho> k)) + (\<Sum>k = 1..m. \<delta> k ((1 - \<rho> k) ^ n * \<pi> \<alpha> k))
[PROOF STEP]
by (induct m, auto, metis (no_types, lifting) add.assoc just_cash_plus)
[PROOF STATE]
proof (state)
this:
just_cash ((1 + i) ^ n * cash_reserve \<alpha>) + (\<Sum>k = 1..m. just_cash (\<pi> \<alpha> k * i * ((1 + i) ^ n - (1 - \<rho> k) ^ n) / (i + \<rho> k))) + (\<Sum>k = 1..m. \<delta> k ((1 - \<rho> k) ^ n * \<pi> \<alpha> k)) = just_cash ((1 + i) ^ n * cash_reserve \<alpha>) + just_cash (\<Sum>k = 1..m. \<pi> \<alpha> k * i * ((1 + i) ^ n - (1 - \<rho> k) ^ n) / (i + \<rho> k)) + (\<Sum>k = 1..m. \<delta> k ((1 - \<rho> k) ^ n * \<pi> \<alpha> k))

goal (1 subgoal):
 1. bulk_update_account n \<rho> i \<alpha> = just_cash ((1 + i) ^ n * cash_reserve \<alpha> + (\<Sum>k = 1..shortest_period \<alpha>. \<pi> \<alpha> k * i * ((1 + i) ^ n - (1 - \<rho> k) ^ n) / (i + \<rho> k))) + (\<Sum>k = 1..shortest_period \<alpha>. \<delta> k ((1 - \<rho> k) ^ n * \<pi> \<alpha> k))
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
bulk_update_account n \<rho> i (\<Sum>k\<le>m. \<delta> k (\<pi> \<alpha> k)) = just_cash ((1 + i) ^ n * cash_reserve \<alpha>) + (\<Sum>k = 1..m. just_cash (\<pi> \<alpha> k * i * ((1 + i) ^ n - (1 - \<rho> k) ^ n) / (i + \<rho> k))) + (\<Sum>k = 1..m. \<delta> k ((1 - \<rho> k) ^ n * \<pi> \<alpha> k))
just_cash ((1 + i) ^ n * cash_reserve \<alpha>) + (\<Sum>k = 1..m. just_cash (\<pi> \<alpha> k * i * ((1 + i) ^ n - (1 - \<rho> k) ^ n) / (i + \<rho> k))) + (\<Sum>k = 1..m. \<delta> k ((1 - \<rho> k) ^ n * \<pi> \<alpha> k)) = just_cash ((1 + i) ^ n * cash_reserve \<alpha>) + just_cash (\<Sum>k = 1..m. \<pi> \<alpha> k * i * ((1 + i) ^ n - (1 - \<rho> k) ^ n) / (i + \<rho> k)) + (\<Sum>k = 1..m. \<delta> k ((1 - \<rho> k) ^ n * \<pi> \<alpha> k))
[PROOF STEP]
have
      "bulk_update_account n \<rho> i (\<Sum> k \<le> m. \<delta> k (\<pi> \<alpha> k)) =
          just_cash (
              (1 + i) ^ n * cash_reserve \<alpha>
            + (\<Sum> k = 1..m.
                  (\<pi> \<alpha> k) * i * ((1 + i) ^ n - (1 - \<rho> k) ^ n) / (i + \<rho> k)))
        + (\<Sum> k = 1..m. \<delta> k ((1 - \<rho> k) ^ n * (\<pi> \<alpha> k)))"
[PROOF STATE]
proof (prove)
using this:
bulk_update_account n \<rho> i (\<Sum>k\<le>m. \<delta> k (\<pi> \<alpha> k)) = just_cash ((1 + i) ^ n * cash_reserve \<alpha>) + (\<Sum>k = 1..m. just_cash (\<pi> \<alpha> k * i * ((1 + i) ^ n - (1 - \<rho> k) ^ n) / (i + \<rho> k))) + (\<Sum>k = 1..m. \<delta> k ((1 - \<rho> k) ^ n * \<pi> \<alpha> k))
just_cash ((1 + i) ^ n * cash_reserve \<alpha>) + (\<Sum>k = 1..m. just_cash (\<pi> \<alpha> k * i * ((1 + i) ^ n - (1 - \<rho> k) ^ n) / (i + \<rho> k))) + (\<Sum>k = 1..m. \<delta> k ((1 - \<rho> k) ^ n * \<pi> \<alpha> k)) = just_cash ((1 + i) ^ n * cash_reserve \<alpha>) + just_cash (\<Sum>k = 1..m. \<pi> \<alpha> k * i * ((1 + i) ^ n - (1 - \<rho> k) ^ n) / (i + \<rho> k)) + (\<Sum>k = 1..m. \<delta> k ((1 - \<rho> k) ^ n * \<pi> \<alpha> k))

goal (1 subgoal):
 1. bulk_update_account n \<rho> i (\<Sum>k\<le>m. \<delta> k (\<pi> \<alpha> k)) = just_cash ((1 + i) ^ n * cash_reserve \<alpha> + (\<Sum>k = 1..m. \<pi> \<alpha> k * i * ((1 + i) ^ n - (1 - \<rho> k) ^ n) / (i + \<rho> k))) + (\<Sum>k = 1..m. \<delta> k ((1 - \<rho> k) ^ n * \<pi> \<alpha> k))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
bulk_update_account n \<rho> i (\<Sum>k\<le>m. \<delta> k (\<pi> \<alpha> k)) = just_cash ((1 + i) ^ n * cash_reserve \<alpha> + (\<Sum>k = 1..m. \<pi> \<alpha> k * i * ((1 + i) ^ n - (1 - \<rho> k) ^ n) / (i + \<rho> k))) + (\<Sum>k = 1..m. \<delta> k ((1 - \<rho> k) ^ n * \<pi> \<alpha> k))

goal (1 subgoal):
 1. bulk_update_account n \<rho> i \<alpha> = just_cash ((1 + i) ^ n * cash_reserve \<alpha> + (\<Sum>k = 1..shortest_period \<alpha>. \<pi> \<alpha> k * i * ((1 + i) ^ n - (1 - \<rho> k) ^ n) / (i + \<rho> k))) + (\<Sum>k = 1..shortest_period \<alpha>. \<delta> k ((1 - \<rho> k) ^ n * \<pi> \<alpha> k))
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
bulk_update_account n \<rho> i (\<Sum>k\<le>?m2. \<delta> k (\<pi> \<alpha> k)) = just_cash ((1 + i) ^ n * cash_reserve \<alpha> + (\<Sum>k = 1..?m2. \<pi> \<alpha> k * i * ((1 + i) ^ n - (1 - \<rho> k) ^ n) / (i + \<rho> k))) + (\<Sum>k = 1..?m2. \<delta> k ((1 - \<rho> k) ^ n * \<pi> \<alpha> k))

goal (1 subgoal):
 1. bulk_update_account n \<rho> i \<alpha> = just_cash ((1 + i) ^ n * cash_reserve \<alpha> + (\<Sum>k = 1..shortest_period \<alpha>. \<pi> \<alpha> k * i * ((1 + i) ^ n - (1 - \<rho> k) ^ n) / (i + \<rho> k))) + (\<Sum>k = 1..shortest_period \<alpha>. \<delta> k ((1 - \<rho> k) ^ n * \<pi> \<alpha> k))
[PROOF STEP]
note \<bullet> = this
[PROOF STATE]
proof (state)
this:
bulk_update_account n \<rho> i (\<Sum>k\<le>?m2. \<delta> k (\<pi> \<alpha> k)) = just_cash ((1 + i) ^ n * cash_reserve \<alpha> + (\<Sum>k = 1..?m2. \<pi> \<alpha> k * i * ((1 + i) ^ n - (1 - \<rho> k) ^ n) / (i + \<rho> k))) + (\<Sum>k = 1..?m2. \<delta> k ((1 - \<rho> k) ^ n * \<pi> \<alpha> k))

goal (1 subgoal):
 1. bulk_update_account n \<rho> i \<alpha> = just_cash ((1 + i) ^ n * cash_reserve \<alpha> + (\<Sum>k = 1..shortest_period \<alpha>. \<pi> \<alpha> k * i * ((1 + i) ^ n - (1 - \<rho> k) ^ n) / (i + \<rho> k))) + (\<Sum>k = 1..shortest_period \<alpha>. \<delta> k ((1 - \<rho> k) ^ n * \<pi> \<alpha> k))
[PROOF STEP]
have
    "bulk_update_account n \<rho> i \<alpha>
       = bulk_update_account n \<rho> i (\<Sum> k \<le> shortest_period \<alpha>. \<delta> k (\<pi> \<alpha> k))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bulk_update_account n \<rho> i \<alpha> = bulk_update_account n \<rho> i (\<Sum>k\<le>shortest_period \<alpha>. \<delta> k (\<pi> \<alpha> k))
[PROOF STEP]
using account_decomposition
[PROOF STATE]
proof (prove)
using this:
?\<alpha> = (\<Sum>i\<le>shortest_period ?\<alpha>. \<delta> i (\<pi> ?\<alpha> i))

goal (1 subgoal):
 1. bulk_update_account n \<rho> i \<alpha> = bulk_update_account n \<rho> i (\<Sum>k\<le>shortest_period \<alpha>. \<delta> k (\<pi> \<alpha> k))
[PROOF STEP]
by presburger
[PROOF STATE]
proof (state)
this:
bulk_update_account n \<rho> i \<alpha> = bulk_update_account n \<rho> i (\<Sum>k\<le>shortest_period \<alpha>. \<delta> k (\<pi> \<alpha> k))

goal (1 subgoal):
 1. bulk_update_account n \<rho> i \<alpha> = just_cash ((1 + i) ^ n * cash_reserve \<alpha> + (\<Sum>k = 1..shortest_period \<alpha>. \<pi> \<alpha> k * i * ((1 + i) ^ n - (1 - \<rho> k) ^ n) / (i + \<rho> k))) + (\<Sum>k = 1..shortest_period \<alpha>. \<delta> k ((1 - \<rho> k) ^ n * \<pi> \<alpha> k))
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
bulk_update_account n \<rho> i \<alpha> = bulk_update_account n \<rho> i (\<Sum>k\<le>shortest_period \<alpha>. \<delta> k (\<pi> \<alpha> k))

goal (1 subgoal):
 1. bulk_update_account n \<rho> i \<alpha> = just_cash ((1 + i) ^ n * cash_reserve \<alpha> + (\<Sum>k = 1..shortest_period \<alpha>. \<pi> \<alpha> k * i * ((1 + i) ^ n - (1 - \<rho> k) ^ n) / (i + \<rho> k))) + (\<Sum>k = 1..shortest_period \<alpha>. \<delta> k ((1 - \<rho> k) ^ n * \<pi> \<alpha> k))
[PROOF STEP]
unfolding \<bullet>
[PROOF STATE]
proof (prove)
using this:
bulk_update_account n \<rho> i \<alpha> = just_cash ((1 + i) ^ n * cash_reserve \<alpha> + (\<Sum>k = 1..shortest_period \<alpha>. \<pi> \<alpha> k * i * ((1 + i) ^ n - (1 - \<rho> k) ^ n) / (i + \<rho> k))) + (\<Sum>k = 1..shortest_period \<alpha>. \<delta> k ((1 - \<rho> k) ^ n * \<pi> \<alpha> k))

goal (1 subgoal):
 1. bulk_update_account n \<rho> i \<alpha> = just_cash ((1 + i) ^ n * cash_reserve \<alpha> + (\<Sum>k = 1..shortest_period \<alpha>. \<pi> \<alpha> k * i * ((1 + i) ^ n - (1 - \<rho> k) ^ n) / (i + \<rho> k))) + (\<Sum>k = 1..shortest_period \<alpha>. \<delta> k ((1 - \<rho> k) ^ n * \<pi> \<alpha> k))
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
bulk_update_account n \<rho> i \<alpha> = just_cash ((1 + i) ^ n * cash_reserve \<alpha> + (\<Sum>k = 1..shortest_period \<alpha>. \<pi> \<alpha> k * i * ((1 + i) ^ n - (1 - \<rho> k) ^ n) / (i + \<rho> k))) + (\<Sum>k = 1..shortest_period \<alpha>. \<delta> k ((1 - \<rho> k) ^ n * \<pi> \<alpha> k))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma matrix_blinfun_of_vmatrix[simp]: "matrix (blinfun_of_vmatrix M) = M"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. matrix (blinfun_apply (blinfun_of_vmatrix M)) = M
[PROOF STEP]
apply vector
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>i ia. matrix (blinfun_apply (blinfun_of_vmatrix M)) $ i $ ia = M $ i $ ia
[PROOF STEP]
apply (auto simp: matrix_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>i ia. blinfun_apply (blinfun_of_vmatrix M) (axis ia 1) $ i = M $ i $ ia
[PROOF STEP]
apply transfer
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>i ia M. (M *v axis ia 1) $ i = M $ i $ ia
[PROOF STEP]
by (metis cart_eq_inner_axis matrix_vector_mul_component)


[STATEMENT]
lemma cbox_Complex_eq: "cbox (Complex a c) (Complex b d) = (\<lambda>(x,y). Complex x y) ` (cbox a b \<times> cbox c d)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cbox (Complex a c) (Complex b d) = (\<lambda>(x, y). Complex x y) ` (cbox a b \<times> cbox c d)
[PROOF STEP]
apply (auto simp: cbox_def Basis_complex_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. \<lbrakk>a \<le> Re x; Re x \<le> b; c \<le> Im x; Im x \<le> d\<rbrakk> \<Longrightarrow> x \<in> (\<lambda>x. case x of (x, y) \<Rightarrow> Complex x y) ` ({x. a \<le> x \<and> x \<le> b} \<times> {x. c \<le> x \<and> x \<le> d})
[PROOF STEP]
apply (rule_tac x = "(Re x, Im x)" in image_eqI)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>x. \<lbrakk>a \<le> Re x; Re x \<le> b; c \<le> Im x; Im x \<le> d\<rbrakk> \<Longrightarrow> x = (case (Re x, Im x) of (x, y) \<Rightarrow> Complex x y)
 2. \<And>x. \<lbrakk>a \<le> Re x; Re x \<le> b; c \<le> Im x; Im x \<le> d\<rbrakk> \<Longrightarrow> (Re x, Im x) \<in> {x. a \<le> x \<and> x \<le> b} \<times> {x. c \<le> x \<and> x \<le> d}
[PROOF STEP]
using complex_eq
[PROOF STATE]
proof (prove)
using this:
?a = complex_of_real (Re ?a) + \<i> * complex_of_real (Im ?a)

goal (2 subgoals):
 1. \<And>x. \<lbrakk>a \<le> Re x; Re x \<le> b; c \<le> Im x; Im x \<le> d\<rbrakk> \<Longrightarrow> x = (case (Re x, Im x) of (x, y) \<Rightarrow> Complex x y)
 2. \<And>x. \<lbrakk>a \<le> Re x; Re x \<le> b; c \<le> Im x; Im x \<le> d\<rbrakk> \<Longrightarrow> (Re x, Im x) \<in> {x. a \<le> x \<and> x \<le> b} \<times> {x. c \<le> x \<and> x \<le> d}
[PROOF STEP]
by auto


[STATEMENT]
lemma vec_set_map[simp]: "set\<^sub>v (map_vec f v) = f ` set\<^sub>v v"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set\<^sub>v (map_vec f v) = f ` set\<^sub>v v
[PROOF STEP]
unfolding vec_set_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ($) (map_vec f v) ` {..<dim_vec (map_vec f v)} = f ` ($) v ` {..<dim_vec v}
[PROOF STEP]
by auto


[STATEMENT]
lemma lucas_lehmer_to_real_power:
  "lucas_lehmer_to_real (x [^]\<^bsub>lucas_lehmer_ring\<^esub> (n :: nat)) = lucas_lehmer_to_real x ^ n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. lucas_lehmer_to_real (x [^]\<^bsub>lucas_lehmer_ring\<^esub> n) = lucas_lehmer_to_real x ^ n
[PROOF STEP]
by (induction n) (auto simp: lucas_lehmer_to_real_simps1)


[STATEMENT]
lemma algebraic_int_of_real_iff [simp]:
  "algebraic_int (of_real x :: 'a :: {field_char_0, real_algebra_1}) \<longleftrightarrow> algebraic_int x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. algebraic_int (of_real x) = algebraic_int x
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. algebraic_int (of_real x) \<Longrightarrow> algebraic_int x
 2. algebraic_int x \<Longrightarrow> algebraic_int (of_real x)
[PROOF STEP]
assume "algebraic_int (of_real x :: 'a)"
[PROOF STATE]
proof (state)
this:
algebraic_int (of_real x)

goal (2 subgoals):
 1. algebraic_int (of_real x) \<Longrightarrow> algebraic_int x
 2. algebraic_int x \<Longrightarrow> algebraic_int (of_real x)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
algebraic_int (of_real x)
[PROOF STEP]
obtain p
    where p: "poly (map_poly of_int p) (of_real x :: 'a) = 0" "lead_coeff p = 1"
[PROOF STATE]
proof (prove)
using this:
algebraic_int (of_real x)

goal (1 subgoal):
 1. (\<And>p. \<lbrakk>poly (map_poly of_int p) (of_real x) = (0::'a); lead_coeff p = 1\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (auto simp: algebraic_int_altdef_ipoly)
[PROOF STATE]
proof (state)
this:
poly (map_poly of_int p) (of_real x) = (0::'a)
lead_coeff p = 1

goal (2 subgoals):
 1. algebraic_int (of_real x) \<Longrightarrow> algebraic_int x
 2. algebraic_int x \<Longrightarrow> algebraic_int (of_real x)
[PROOF STEP]
show "algebraic_int x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. algebraic_int x
[PROOF STEP]
unfolding algebraic_int_altdef_ipoly
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>p. poly (map_poly real_of_int p) x = 0 \<and> lead_coeff p = 1
[PROOF STEP]
proof (intro exI[of _ p] conjI)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. poly (map_poly real_of_int p) x = 0
 2. lead_coeff p = 1
[PROOF STEP]
have "of_real (poly (map_poly real_of_int p) x) = poly (map_poly of_int p) (of_real x :: 'a)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. of_real (poly (map_poly real_of_int p) x) = poly (map_poly of_int p) (of_real x)
[PROOF STEP]
by (induction p) (auto simp: map_poly_pCons)
[PROOF STATE]
proof (state)
this:
of_real (poly (map_poly real_of_int p) x) = poly (map_poly of_int p) (of_real x)

goal (2 subgoals):
 1. poly (map_poly real_of_int p) x = 0
 2. lead_coeff p = 1
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
of_real (poly (map_poly real_of_int p) x) = poly (map_poly of_int p) (of_real x)

goal (2 subgoals):
 1. poly (map_poly real_of_int p) x = 0
 2. lead_coeff p = 1
[PROOF STEP]
note p(1)
[PROOF STATE]
proof (state)
this:
poly (map_poly of_int p) (of_real x) = (0::'a)

goal (2 subgoals):
 1. poly (map_poly real_of_int p) x = 0
 2. lead_coeff p = 1
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
of_real (poly (map_poly real_of_int p) x) = (0::'a)
[PROOF STEP]
show "poly (map_poly real_of_int p) x = 0"
[PROOF STATE]
proof (prove)
using this:
of_real (poly (map_poly real_of_int p) x) = (0::'a)

goal (1 subgoal):
 1. poly (map_poly real_of_int p) x = 0
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
poly (map_poly real_of_int p) x = 0

goal (1 subgoal):
 1. lead_coeff p = 1
[PROOF STEP]
qed (use p in auto)
[PROOF STATE]
proof (state)
this:
algebraic_int x

goal (1 subgoal):
 1. algebraic_int x \<Longrightarrow> algebraic_int (of_real x)
[PROOF STEP]
qed auto


[STATEMENT]
lemma bernoulli_conv_num_denom: "bernoulli n = bernoulli_num n / bernoulli_denom n" (is ?th1)
  and coprime_bernoulli_num_denom: "coprime (bernoulli_num n) (bernoulli_denom n)" (is ?th2)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bernoulli n = real_of_int (bernoulli_num n) / real (bernoulli_denom n) &&& coprime (bernoulli_num n) (int (bernoulli_denom n))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. bernoulli n = real_of_int (bernoulli_num n) / real (bernoulli_denom n)
 2. coprime (bernoulli_num n) (int (bernoulli_denom n))
[PROOF STEP]
obtain a :: int where a: "coprime a (bernoulli_denom n)" "bernoulli n = a / bernoulli_denom n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>a. \<lbrakk>coprime a (int (bernoulli_denom n)); bernoulli n = real_of_int a / real (bernoulli_denom n)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using bernoulli_denom_correct[of n]
[PROOF STATE]
proof (prove)
using this:
(\<And>a. \<lbrakk>coprime a (int (bernoulli_denom n)); bernoulli n = real_of_int a / real (bernoulli_denom n)\<rbrakk> \<Longrightarrow> ?thesis) \<Longrightarrow> ?thesis

goal (1 subgoal):
 1. (\<And>a. \<lbrakk>coprime a (int (bernoulli_denom n)); bernoulli n = real_of_int a / real (bernoulli_denom n)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
coprime a (int (bernoulli_denom n))
bernoulli n = real_of_int a / real (bernoulli_denom n)

goal (2 subgoals):
 1. bernoulli n = real_of_int (bernoulli_num n) / real (bernoulli_denom n)
 2. coprime (bernoulli_num n) (int (bernoulli_denom n))
[PROOF STEP]
thus ?th1
[PROOF STATE]
proof (prove)
using this:
coprime a (int (bernoulli_denom n))
bernoulli n = real_of_int a / real (bernoulli_denom n)

goal (1 subgoal):
 1. bernoulli n = real_of_int (bernoulli_num n) / real (bernoulli_denom n)
[PROOF STEP]
by (simp add: bernoulli_num_def)
[PROOF STATE]
proof (state)
this:
bernoulli n = real_of_int (bernoulli_num n) / real (bernoulli_denom n)

goal (1 subgoal):
 1. coprime (bernoulli_num n) (int (bernoulli_denom n))
[PROOF STEP]
with a
[PROOF STATE]
proof (chain)
picking this:
coprime a (int (bernoulli_denom n))
bernoulli n = real_of_int a / real (bernoulli_denom n)
bernoulli n = real_of_int (bernoulli_num n) / real (bernoulli_denom n)
[PROOF STEP]
show ?th2
[PROOF STATE]
proof (prove)
using this:
coprime a (int (bernoulli_denom n))
bernoulli n = real_of_int a / real (bernoulli_denom n)
bernoulli n = real_of_int (bernoulli_num n) / real (bernoulli_denom n)

goal (1 subgoal):
 1. coprime (bernoulli_num n) (int (bernoulli_denom n))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
coprime (bernoulli_num n) (int (bernoulli_denom n))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma fls_X_intpow_times_conv_shift:
  fixes f :: "'a::semiring_1 fls"
  shows "fls_X_intpow i * f = fls_shift (-i) f" "f * fls_X_intpow i = fls_shift (-i) f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fls_X_intpow i * f = fls_shift (- i) f &&& f * fls_X_intpow i = fls_shift (- i) f
[PROOF STEP]
by    (simp_all add: fls_shifted_times_simps)


[STATEMENT]
lemma \<omega>_sum_replicate [simp]: "\<omega>_sum (replicate m a) = \<omega> \<up> a * ord_of_nat m"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<omega>_sum (replicate m a) = \<omega> \<up> a * ord_of_nat m
[PROOF STEP]
by (induction m) (auto simp: mult_succ simp flip: replicate_append_same)


[STATEMENT]
lemma ceiling_eq: "of_int n < x \<Longrightarrow> x \<le> of_int n + 1 \<Longrightarrow> \<lceil>x\<rceil> = n + 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>of_int n < x; x \<le> of_int n + (1::'a)\<rbrakk> \<Longrightarrow> \<lceil>x\<rceil> = n + 1
[PROOF STEP]
by (simp add: ceiling_unique)


[STATEMENT]
lemma ex_eval_fmla_iff_exists_num:
  "eval_fmla e (exi k A) \<longleftrightarrow> (\<exists>t. eval_fmla e (A(k::=t)) \<and> t \<in> num)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. eval_fmla e (exi k A) = (\<exists>t. eval_fmla e (A(k::=t)) \<and> t \<in> num)
[PROOF STEP]
by (auto simp: eval_subst_fmla) (metis obtain_const_trm)


[STATEMENT]
lemma fmsubset_restrict_set:
  fixes X1 X2 and s :: "'a state"
  assumes "X1 \<subseteq> X2" "s \<in> {s. fmdom' s = X2}"
  shows "fmrestrict_set X1 s \<in> {s. fmdom' s = X1}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fmrestrict_set X1 s \<in> {s. fmdom' s = X1}
[PROOF STEP]
using assms fmdom'_fmsubset_restrict_set
[PROOF STATE]
proof (prove)
using this:
X1 \<subseteq> X2
s \<in> {s. fmdom' s = X2}
\<lbrakk>?X1.0 \<subseteq> ?X2.0; fmdom' ?s = ?X2.0\<rbrakk> \<Longrightarrow> fmdom' (fmrestrict_set ?X1.0 ?s) = ?X1.0

goal (1 subgoal):
 1. fmrestrict_set X1 s \<in> {s. fmdom' s = X1}
[PROOF STEP]
by blast

\<comment> \<open>NOTE added lemma.\<close>


[STATEMENT]
lemma blincomp_scaleR_right: "(a *\<^sub>R (F :: 'a :: real_normed_vector \<Rightarrow>\<^sub>L 'a)) ^^ t = a^t *\<^sub>R F^^t"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (a *\<^sub>R F) ^^ t = a ^ t *\<^sub>R F ^^ t
[PROOF STEP]
by (induction t) (auto intro: blinfun_eqI simp: blinfun.scaleR_left blinfun.scaleR_right)


[STATEMENT]
lemma one_le_Fract_iff: "0 < b \<Longrightarrow> 1 \<le> Fract a b \<longleftrightarrow> b \<le> a"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < b \<Longrightarrow> (1 \<le> Fract a b) = (b \<le> a)
[PROOF STEP]
by (simp add: One_rat_def mult_le_cancel_right)


[STATEMENT]
lemma finite_set_Cons_finite:
  "\<lbrakk>finite xs; finite ys; \<forall>y \<in> ys. finite y\<rbrakk>
    \<Longrightarrow> finite {x # y | x y y'. x \<in> xs \<and> y \<in> y' \<and> y' \<in> ys}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>finite xs; finite ys; \<forall>y\<in>ys. finite y\<rbrakk> \<Longrightarrow> finite {uu_. \<exists>x y y'. uu_ = x # y \<and> x \<in> xs \<and> y \<in> y' \<and> y' \<in> ys}
[PROOF STEP]
using Cons_set_eq_union_set[of xs]
[PROOF STATE]
proof (prove)
using this:
{uu_. \<exists>x y y'. uu_ = x # y \<and> x \<in> xs \<and> y \<in> y' \<and> y' \<in> ?ys} = {x # y |x y. x \<in> xs \<and> y \<in> (\<Union>y\<in>?ys. y)}

goal (1 subgoal):
 1. \<lbrakk>finite xs; finite ys; \<forall>y\<in>ys. finite y\<rbrakk> \<Longrightarrow> finite {uu_. \<exists>x y y'. uu_ = x # y \<and> x \<in> xs \<and> y \<in> y' \<and> y' \<in> ys}
[PROOF STEP]
by (simp add: finite_image_set2)


[STATEMENT]
lemma AXc:
assumes
  "c1 \<noteq> c2" and
  "c1 \<in># X" and
  "c2 \<in># X"
shows "(A1 \<union># ((A2 \<union># (X -# c2)) -# c1))
      = (A2 \<union># ((A1 \<union># (X -# c1)) -# c2))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A1 \<union># A2 \<union># X -# c2 -# c1 = A2 \<union># A1 \<union># X -# c1 -# c2
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. A1 \<union># A2 \<union># X -# c2 -# c1 = A2 \<union># A1 \<union># X -# c1 -# c2
[PROOF STEP]
have
    "(A2 \<union># ((A1 \<union># (X -# c1)) -# c2))
         = (A2 \<union># (A1 \<union># ((X -# c1) -# c2)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A2 \<union># A1 \<union># X -# c1 -# c2 = A2 \<union># A1 \<union># X -# c1 -# c2
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
c1 \<noteq> c2
c1 \<in># X
c2 \<in># X

goal (1 subgoal):
 1. A2 \<union># A1 \<union># X -# c1 -# c2 = A2 \<union># A1 \<union># X -# c1 -# c2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
A2 \<union># A1 \<union># X -# c1 -# c2 = A2 \<union># A1 \<union># X -# c1 -# c2

goal (1 subgoal):
 1. A1 \<union># A2 \<union># X -# c2 -# c1 = A2 \<union># A1 \<union># X -# c1 -# c2
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
A2 \<union># A1 \<union># X -# c1 -# c2 = A2 \<union># A1 \<union># X -# c1 -# c2

goal (1 subgoal):
 1. A1 \<union># A2 \<union># X -# c2 -# c1 = A2 \<union># A1 \<union># X -# c1 -# c2
[PROOF STEP]
have
    "... = (A1 \<union># ((A2 \<union># (X -# c2)) -# c1)) "
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A2 \<union># A1 \<union># X -# c1 -# c2 = A1 \<union># A2 \<union># X -# c2 -# c1
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
c1 \<noteq> c2
c1 \<in># X
c2 \<in># X

goal (1 subgoal):
 1. A2 \<union># A1 \<union># X -# c1 -# c2 = A1 \<union># A2 \<union># X -# c2 -# c1
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
A2 \<union># A1 \<union># X -# c1 -# c2 = A1 \<union># A2 \<union># X -# c2 -# c1

goal (1 subgoal):
 1. A1 \<union># A2 \<union># X -# c2 -# c1 = A2 \<union># A1 \<union># X -# c1 -# c2
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
A2 \<union># A1 \<union># X -# c1 -# c2 = A1 \<union># A2 \<union># X -# c2 -# c1
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
A2 \<union># A1 \<union># X -# c1 -# c2 = A1 \<union># A2 \<union># X -# c2 -# c1

goal (1 subgoal):
 1. A1 \<union># A2 \<union># X -# c2 -# c1 = A2 \<union># A1 \<union># X -# c1 -# c2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
A1 \<union># A2 \<union># X -# c2 -# c1 = A2 \<union># A1 \<union># X -# c1 -# c2

goal:
No subgoals!
[PROOF STEP]
qed


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


[STATEMENT]
lemma AE_E3:
  assumes "AE x in M. P x"
  obtains N where "\<And>x. x \<in> space M - N \<Longrightarrow> P x" "N \<in> null_sets M"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>N. \<lbrakk>\<And>x. x \<in> space M - N \<Longrightarrow> P x; N \<in> null_sets M\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
almost_everywhere M P

goal (1 subgoal):
 1. (\<And>N. \<lbrakk>\<And>x. x \<in> space M - N \<Longrightarrow> P x; N \<in> null_sets M\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
unfolding eventually_ae_filter
[PROOF STATE]
proof (prove)
using this:
Bex (null_sets M) ((\<subseteq>) {x \<in> space M. \<not> P x})

goal (1 subgoal):
 1. (\<And>N. \<lbrakk>\<And>x. x \<in> space M - N \<Longrightarrow> P x; N \<in> null_sets M\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto


[STATEMENT]
lemma unat_less_power:
  fixes k :: "'a::len word"
  assumes szv: "sz < LENGTH('a)"
  and     kv:  "k < 2 ^ sz"
  shows   "unat k < 2 ^ sz"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. unat k < 2 ^ sz
[PROOF STEP]
using szv unat_mono [OF kv]
[PROOF STATE]
proof (prove)
using this:
sz < LENGTH('a)
unat k < unat (2 ^ sz)

goal (1 subgoal):
 1. unat k < 2 ^ sz
[PROOF STEP]
by simp


[STATEMENT]
lemma is_expansion_map_final:
  fixes f :: "'a :: multiseries \<Rightarrow> 'b :: multiseries"
    and F :: "'a ms"
  assumes "is_lifting f basis basis'"
  assumes "is_expansion G (b # basis)"
  assumes "length basis' = expansion_level TYPE('b)"
  shows   "is_expansion (map_ms f G) (b # basis')"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. is_expansion (map_ms f G) (b # basis')
[PROOF STEP]
by (rule is_expansion_map[OF assms(2)]) (insert assms, simp_all add: is_lifting_def)


[STATEMENT]
theorem Myhill_Nerode:
  fixes A::"('a::finite) lang"
  shows "(\<exists>r. A = lang r) \<longleftrightarrow> finite (UNIV // \<approx>A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<exists>r. A = lang r) = finite (UNIV // \<approx>A)
[PROOF STEP]
using Myhill_Nerode1 Myhill_Nerode2
[PROOF STATE]
proof (prove)
using this:
finite (UNIV // \<approx>?A) \<Longrightarrow> \<exists>r. ?A = lang r
finite (UNIV // \<approx>lang ?r)

goal (1 subgoal):
 1. (\<exists>r. A = lang r) = finite (UNIV // \<approx>A)
[PROOF STEP]
by auto


[STATEMENT]
lemma interval_lebesgue_integral_uminus:
  "interval_lebesgue_integral M a b (\<lambda>x. - f x) = - interval_lebesgue_integral M a b f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. LINT x=a..b|M. (- f x) = - interval_lebesgue_integral M a b f
[PROOF STEP]
by (auto simp: interval_lebesgue_integral_def interval_lebesgue_integrable_def set_lebesgue_integral_def)


[STATEMENT]
lemma gauss_cnj_prod [simp]: "gauss_cnj (prod f A) = (\<Prod>x\<in>A. gauss_cnj (f x))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. gauss_cnj (prod f A) = (\<Prod>x\<in>A. gauss_cnj (f x))
[PROOF STEP]
by (induction A rule: infinite_finite_induct) auto


[STATEMENT]
lemma matrix_vector_mult_matrix_matrix_mult_compose:
  "(*v) (A ** B) = (*v) A \<circ> (*v) B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (*v) (A ** B) = (*v) A \<circ> (*v) B
[PROOF STEP]
by (auto simp: matrix_vector_mul_assoc)


[STATEMENT]
lemma mono_ccInf:
  "countable A \<Longrightarrow> f (Inf A) \<le> (INF x\<in>A. f x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. countable A \<Longrightarrow> f (Inf A) \<le> Inf (f ` A)
[PROOF STEP]
using \<open>mono f\<close>
[PROOF STATE]
proof (prove)
using this:
mono f

goal (1 subgoal):
 1. countable A \<Longrightarrow> f (Inf A) \<le> Inf (f ` A)
[PROOF STEP]
by (auto intro!: countable_complete_lattice_class.ccINF_greatest intro: ccInf_lower dest: monoD)


[STATEMENT]
lemma linear_subst_map: "evalUni (map_atomUni (linearSubstitutionUni b c) F) x = evalUni F (-c/b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. evalUni (map_atomUni (linearSubstitutionUni b c) F) x = evalUni F (- c / b)
[PROOF STEP]
apply(induction F)
[PROOF STATE]
proof (prove)
goal (5 subgoals):
 1. evalUni (map_atomUni (linearSubstitutionUni b c) TrueFUni) x = evalUni TrueFUni (- c / b)
 2. evalUni (map_atomUni (linearSubstitutionUni b c) FalseFUni) x = evalUni FalseFUni (- c / b)
 3. \<And>xa. evalUni (map_atomUni (linearSubstitutionUni b c) (AtomUni xa)) x = evalUni (AtomUni xa) (- c / b)
 4. \<And>F1 F2. \<lbrakk>evalUni (map_atomUni (linearSubstitutionUni b c) F1) x = evalUni F1 (- c / b); evalUni (map_atomUni (linearSubstitutionUni b c) F2) x = evalUni F2 (- c / b)\<rbrakk> \<Longrightarrow> evalUni (map_atomUni (linearSubstitutionUni b c) (AndUni F1 F2)) x = evalUni (AndUni F1 F2) (- c / b)
 5. \<And>F1 F2. \<lbrakk>evalUni (map_atomUni (linearSubstitutionUni b c) F1) x = evalUni F1 (- c / b); evalUni (map_atomUni (linearSubstitutionUni b c) F2) x = evalUni F2 (- c / b)\<rbrakk> \<Longrightarrow> evalUni (map_atomUni (linearSubstitutionUni b c) (OrUni F1 F2)) x = evalUni (OrUni F1 F2) (- c / b)
[PROOF STEP]
by auto


[STATEMENT]
lemma nn_integral_FTC_atLeast:
  fixes f :: "real \<Rightarrow> real"
  assumes f_borel: "f \<in> borel_measurable borel"
  assumes f: "\<And>x. a \<le> x \<Longrightarrow> DERIV F x :> f x"
  assumes nonneg: "\<And>x. a \<le> x \<Longrightarrow> 0 \<le> f x"
  assumes lim: "(F \<longlongrightarrow> T) at_top"
  shows "(\<integral>\<^sup>+x. ennreal (f x) * indicator {a ..} x \<partial>lborel) = T - F a"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<integral>\<^sup>+x\<in>{a..}. ennreal (f x)\<partial>lborel = ennreal (T - F a)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<integral>\<^sup>+x\<in>{a..}. ennreal (f x)\<partial>lborel = ennreal (T - F a)
[PROOF STEP]
let ?f = "\<lambda>(i::nat) (x::real). ennreal (f x) * indicator {a..a + real i} x"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<integral>\<^sup>+x\<in>{a..}. ennreal (f x)\<partial>lborel = ennreal (T - F a)
[PROOF STEP]
let ?fR = "\<lambda>x. ennreal (f x) * indicator {a ..} x"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<integral>\<^sup>+x\<in>{a..}. ennreal (f x)\<partial>lborel = ennreal (T - F a)
[PROOF STEP]
have F_mono: "a \<le> x \<Longrightarrow> x \<le> y \<Longrightarrow> F x \<le> F y" for x y
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>a \<le> x; x \<le> y\<rbrakk> \<Longrightarrow> F x \<le> F y
[PROOF STEP]
using f nonneg
[PROOF STATE]
proof (prove)
using this:
a \<le> ?x \<Longrightarrow> (F has_real_derivative f ?x) (at ?x)
a \<le> ?x \<Longrightarrow> 0 \<le> f ?x

goal (1 subgoal):
 1. \<lbrakk>a \<le> x; x \<le> y\<rbrakk> \<Longrightarrow> F x \<le> F y
[PROOF STEP]
by (intro DERIV_nonneg_imp_nondecreasing[of x y F]) (auto intro: order_trans)
[PROOF STATE]
proof (state)
this:
\<lbrakk>a \<le> ?x; ?x \<le> ?y\<rbrakk> \<Longrightarrow> F ?x \<le> F ?y

goal (1 subgoal):
 1. \<integral>\<^sup>+x\<in>{a..}. ennreal (f x)\<partial>lborel = ennreal (T - F a)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>a \<le> ?x; ?x \<le> ?y\<rbrakk> \<Longrightarrow> F ?x \<le> F ?y
[PROOF STEP]
have F_le_T: "a \<le> x \<Longrightarrow> F x \<le> T" for x
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>a \<le> ?x; ?x \<le> ?y\<rbrakk> \<Longrightarrow> F ?x \<le> F ?y

goal (1 subgoal):
 1. a \<le> x \<Longrightarrow> F x \<le> T
[PROOF STEP]
by (intro tendsto_lowerbound[OF lim])
       (auto simp: eventually_at_top_linorder)
[PROOF STATE]
proof (state)
this:
a \<le> ?x \<Longrightarrow> F ?x \<le> T

goal (1 subgoal):
 1. \<integral>\<^sup>+x\<in>{a..}. ennreal (f x)\<partial>lborel = ennreal (T - F a)
[PROOF STEP]
have "(SUP i. ?f i x) = ?fR x" for x
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (SUP i. ennreal (f x) * indicator {a..a + real i} x) = ennreal (f x) * indicator {a..} x
[PROOF STEP]
proof (rule LIMSEQ_unique[OF LIMSEQ_SUP])
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. incseq (\<lambda>i. ennreal (f x) * indicator {a..a + real i} x)
 2. (\<lambda>i. ennreal (f x) * indicator {a..a + real i} x) \<longlonglongrightarrow> ennreal (f x) * indicator {a..} x
[PROOF STEP]
obtain n where "x - a < real n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>n. x - a < real n \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using reals_Archimedean2[of "x - a"]
[PROOF STATE]
proof (prove)
using this:
\<exists>n. x - a < real n

goal (1 subgoal):
 1. (\<And>n. x - a < real n \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
x - a < real n

goal (2 subgoals):
 1. incseq (\<lambda>i. ennreal (f x) * indicator {a..a + real i} x)
 2. (\<lambda>i. ennreal (f x) * indicator {a..a + real i} x) \<longlonglongrightarrow> ennreal (f x) * indicator {a..} x
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
x - a < real n
[PROOF STEP]
have "eventually (\<lambda>n. ?f n x = ?fR x) sequentially"
[PROOF STATE]
proof (prove)
using this:
x - a < real n

goal (1 subgoal):
 1. \<forall>\<^sub>F n in sequentially. ennreal (f x) * indicator {a..a + real n} x = ennreal (f x) * indicator {a..} x
[PROOF STEP]
by (auto intro!: eventually_sequentiallyI[where c=n] split: split_indicator)
[PROOF STATE]
proof (state)
this:
\<forall>\<^sub>F n in sequentially. ennreal (f x) * indicator {a..a + real n} x = ennreal (f x) * indicator {a..} x

goal (2 subgoals):
 1. incseq (\<lambda>i. ennreal (f x) * indicator {a..a + real i} x)
 2. (\<lambda>i. ennreal (f x) * indicator {a..a + real i} x) \<longlonglongrightarrow> ennreal (f x) * indicator {a..} x
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<forall>\<^sub>F n in sequentially. ennreal (f x) * indicator {a..a + real n} x = ennreal (f x) * indicator {a..} x
[PROOF STEP]
show "(\<lambda>n. ?f n x) \<longlonglongrightarrow> ?fR x"
[PROOF STATE]
proof (prove)
using this:
\<forall>\<^sub>F n in sequentially. ennreal (f x) * indicator {a..a + real n} x = ennreal (f x) * indicator {a..} x

goal (1 subgoal):
 1. (\<lambda>n. ennreal (f x) * indicator {a..a + real n} x) \<longlonglongrightarrow> ennreal (f x) * indicator {a..} x
[PROOF STEP]
by (rule tendsto_eventually)
[PROOF STATE]
proof (state)
this:
(\<lambda>n. ennreal (f x) * indicator {a..a + real n} x) \<longlonglongrightarrow> ennreal (f x) * indicator {a..} x

goal (1 subgoal):
 1. incseq (\<lambda>i. ennreal (f x) * indicator {a..a + real i} x)
[PROOF STEP]
qed (auto simp: nonneg incseq_def le_fun_def split: split_indicator)
[PROOF STATE]
proof (state)
this:
(SUP i. ennreal (f ?x) * indicator {a..a + real i} ?x) = ennreal (f ?x) * indicator {a..} ?x

goal (1 subgoal):
 1. \<integral>\<^sup>+x\<in>{a..}. ennreal (f x)\<partial>lborel = ennreal (T - F a)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(SUP i. ennreal (f ?x) * indicator {a..a + real i} ?x) = ennreal (f ?x) * indicator {a..} ?x
[PROOF STEP]
have "integral\<^sup>N lborel ?fR = (\<integral>\<^sup>+ x. (SUP i. ?f i x) \<partial>lborel)"
[PROOF STATE]
proof (prove)
using this:
(SUP i. ennreal (f ?x) * indicator {a..a + real i} ?x) = ennreal (f ?x) * indicator {a..} ?x

goal (1 subgoal):
 1. \<integral>\<^sup>+x\<in>{a..}. ennreal (f x)\<partial>lborel = \<integral>\<^sup>+ x. (SUP i. ennreal (f x) * indicator {a..a + real i} x) \<partial>lborel
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<integral>\<^sup>+x\<in>{a..}. ennreal (f x)\<partial>lborel = \<integral>\<^sup>+ x. (SUP i. ennreal (f x) * indicator {a..a + real i} x) \<partial>lborel

goal (1 subgoal):
 1. \<integral>\<^sup>+x\<in>{a..}. ennreal (f x)\<partial>lborel = ennreal (T - F a)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
\<integral>\<^sup>+x\<in>{a..}. ennreal (f x)\<partial>lborel = \<integral>\<^sup>+ x. (SUP i. ennreal (f x) * indicator {a..a + real i} x) \<partial>lborel

goal (1 subgoal):
 1. \<integral>\<^sup>+x\<in>{a..}. ennreal (f x)\<partial>lborel = ennreal (T - F a)
[PROOF STEP]
have "\<dots> = (SUP i. (\<integral>\<^sup>+ x. ?f i x \<partial>lborel))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<integral>\<^sup>+ x. (SUP i. ennreal (f x) * indicator {a..a + real i} x) \<partial>lborel = (SUP i. \<integral>\<^sup>+x\<in>{a..a + real i}. ennreal (f x)\<partial>lborel)
[PROOF STEP]
proof (rule nn_integral_monotone_convergence_SUP)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. incseq (\<lambda>i x. ennreal (f x) * indicator {a..a + real i} x)
 2. \<And>i. (\<lambda>x. ennreal (f x) * indicator {a..a + real i} x) \<in> borel_measurable lborel
[PROOF STEP]
show "incseq ?f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. incseq (\<lambda>i x. ennreal (f x) * indicator {a..a + real i} x)
[PROOF STEP]
using nonneg
[PROOF STATE]
proof (prove)
using this:
a \<le> ?x \<Longrightarrow> 0 \<le> f ?x

goal (1 subgoal):
 1. incseq (\<lambda>i x. ennreal (f x) * indicator {a..a + real i} x)
[PROOF STEP]
by (auto simp: incseq_def le_fun_def split: split_indicator)
[PROOF STATE]
proof (state)
this:
incseq (\<lambda>i x. ennreal (f x) * indicator {a..a + real i} x)

goal (1 subgoal):
 1. \<And>i. (\<lambda>x. ennreal (f x) * indicator {a..a + real i} x) \<in> borel_measurable lborel
[PROOF STEP]
show "\<And>i. (?f i) \<in> borel_measurable lborel"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>i. (\<lambda>x. ennreal (f x) * indicator {a..a + real i} x) \<in> borel_measurable lborel
[PROOF STEP]
using f_borel
[PROOF STATE]
proof (prove)
using this:
f \<in> borel_measurable borel

goal (1 subgoal):
 1. \<And>i. (\<lambda>x. ennreal (f x) * indicator {a..a + real i} x) \<in> borel_measurable lborel
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<lambda>x. ennreal (f x) * indicator {a..a + real ?i} x) \<in> borel_measurable lborel

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<integral>\<^sup>+ x. (SUP i. ennreal (f x) * indicator {a..a + real i} x) \<partial>lborel = (SUP i. \<integral>\<^sup>+x\<in>{a..a + real i}. ennreal (f x)\<partial>lborel)

goal (1 subgoal):
 1. \<integral>\<^sup>+x\<in>{a..}. ennreal (f x)\<partial>lborel = ennreal (T - F a)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
\<integral>\<^sup>+ x. (SUP i. ennreal (f x) * indicator {a..a + real i} x) \<partial>lborel = (SUP i. \<integral>\<^sup>+x\<in>{a..a + real i}. ennreal (f x)\<partial>lborel)

goal (1 subgoal):
 1. \<integral>\<^sup>+x\<in>{a..}. ennreal (f x)\<partial>lborel = ennreal (T - F a)
[PROOF STEP]
have "\<dots> = (SUP i. ennreal (F (a + real i) - F a))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (SUP i. \<integral>\<^sup>+x\<in>{a..a + real i}. ennreal (f x)\<partial>lborel) = (SUP i. ennreal (F (a + real i) - F a))
[PROOF STEP]
by (subst nn_integral_FTC_Icc[OF f_borel f nonneg]) auto
[PROOF STATE]
proof (state)
this:
(SUP i. \<integral>\<^sup>+x\<in>{a..a + real i}. ennreal (f x)\<partial>lborel) = (SUP i. ennreal (F (a + real i) - F a))

goal (1 subgoal):
 1. \<integral>\<^sup>+x\<in>{a..}. ennreal (f x)\<partial>lborel = ennreal (T - F a)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(SUP i. \<integral>\<^sup>+x\<in>{a..a + real i}. ennreal (f x)\<partial>lborel) = (SUP i. ennreal (F (a + real i) - F a))

goal (1 subgoal):
 1. \<integral>\<^sup>+x\<in>{a..}. ennreal (f x)\<partial>lborel = ennreal (T - F a)
[PROOF STEP]
have "\<dots> = T - F a"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (SUP i. ennreal (F (a + real i) - F a)) = ennreal (T - F a)
[PROOF STEP]
proof (rule LIMSEQ_unique[OF LIMSEQ_SUP])
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. incseq (\<lambda>i. ennreal (F (a + real i) - F a))
 2. (\<lambda>i. ennreal (F (a + real i) - F a)) \<longlonglongrightarrow> ennreal (T - F a)
[PROOF STEP]
have "(\<lambda>x. F (a + real x)) \<longlonglongrightarrow> T"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. F (a + real x)) \<longlonglongrightarrow> T
[PROOF STEP]
by (auto intro: filterlim_compose[OF lim filterlim_tendsto_add_at_top] filterlim_real_sequentially)
[PROOF STATE]
proof (state)
this:
(\<lambda>x. F (a + real x)) \<longlonglongrightarrow> T

goal (2 subgoals):
 1. incseq (\<lambda>i. ennreal (F (a + real i) - F a))
 2. (\<lambda>i. ennreal (F (a + real i) - F a)) \<longlonglongrightarrow> ennreal (T - F a)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(\<lambda>x. F (a + real x)) \<longlonglongrightarrow> T
[PROOF STEP]
show "(\<lambda>n. ennreal (F (a + real n) - F a)) \<longlonglongrightarrow> ennreal (T - F a)"
[PROOF STATE]
proof (prove)
using this:
(\<lambda>x. F (a + real x)) \<longlonglongrightarrow> T

goal (1 subgoal):
 1. (\<lambda>n. ennreal (F (a + real n) - F a)) \<longlonglongrightarrow> ennreal (T - F a)
[PROOF STEP]
by (simp add: F_mono F_le_T tendsto_diff)
[PROOF STATE]
proof (state)
this:
(\<lambda>n. ennreal (F (a + real n) - F a)) \<longlonglongrightarrow> ennreal (T - F a)

goal (1 subgoal):
 1. incseq (\<lambda>i. ennreal (F (a + real i) - F a))
[PROOF STEP]
qed (auto simp: incseq_def intro!: ennreal_le_iff[THEN iffD2] F_mono)
[PROOF STATE]
proof (state)
this:
(SUP i. ennreal (F (a + real i) - F a)) = ennreal (T - F a)

goal (1 subgoal):
 1. \<integral>\<^sup>+x\<in>{a..}. ennreal (f x)\<partial>lborel = ennreal (T - F a)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
\<integral>\<^sup>+x\<in>{a..}. ennreal (f x)\<partial>lborel = ennreal (T - F a)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<integral>\<^sup>+x\<in>{a..}. ennreal (f x)\<partial>lborel = ennreal (T - F a)

goal (1 subgoal):
 1. \<integral>\<^sup>+x\<in>{a..}. ennreal (f x)\<partial>lborel = ennreal (T - F a)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
\<integral>\<^sup>+x\<in>{a..}. ennreal (f x)\<partial>lborel = ennreal (T - F a)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma finite_convergent_set:
  assumes "finite A" and "finite B"
  shows "finite (convergent_set A B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite (convergent_set A B)
[PROOF STEP]
using convergent_set_sub_powerset finite_Pow_iff finite_sumset assms finite_subset
[PROOF STATE]
proof (prove)
using this:
convergent_set ?A ?B \<subseteq> Pow (sumset ?A ?B)
finite (Pow ?A) = finite ?A
\<lbrakk>finite ?A; finite ?B\<rbrakk> \<Longrightarrow> finite (sumset ?A ?B)
finite A
finite B
\<lbrakk>?A \<subseteq> ?B; finite ?B\<rbrakk> \<Longrightarrow> finite ?A

goal (1 subgoal):
 1. finite (convergent_set A B)
[PROOF STEP]
by metis


[STATEMENT]
lemma ewp_alt1: "(\<forall>z. x\<^sup>\<omega> \<le> x\<^sup>\<star> \<cdot> z) \<longleftrightarrow> (\<forall>y z. y \<le> x \<cdot> y + z \<longrightarrow> y \<le> x\<^sup>\<star> \<cdot> z)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<forall>z. x\<^sup>\<omega> \<le> x\<^sup>\<star> \<cdot> z) = (\<forall>y z. y \<le> x \<cdot> y + z \<longrightarrow> y \<le> x\<^sup>\<star> \<cdot> z)
[PROOF STEP]
by (metis add_comm less_eq_def omega_coinduct omega_unfold_eq order_prop)


[STATEMENT]
lemma next_primes: assumes res: "next_primes n = (m,ps)"
  and n: "candidate_invariant n"
  shows "candidate_invariant m" "sorted ps" "distinct ps" "n < m"
  "set ps = {i. prime i \<and> n \<le> i \<and> i < m}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (candidate_invariant m &&& sorted ps) &&& distinct ps &&& n < m &&& set ps = {i. prime i \<and> n \<le> i \<and> i < m}
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (5 subgoals):
 1. candidate_invariant m
 2. sorted ps
 3. distinct ps
 4. n < m
 5. set ps = {i. prime i \<and> n \<le> i \<and> i < m}
[PROOF STEP]
have "candidate_invariant m \<and> sorted ps \<and> distinct ps \<and> n < m \<and>
    set ps = {i. prime i \<and> n \<le> i \<and> i < m}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. candidate_invariant m \<and> sorted ps \<and> distinct ps \<and> n < m \<and> set ps = {i. prime i \<and> n \<le> i \<and> i < m}
[PROOF STEP]
proof (cases "n = 0")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. n = 0 \<Longrightarrow> candidate_invariant m \<and> sorted ps \<and> distinct ps \<and> n < m \<and> set ps = {i. prime i \<and> n \<le> i \<and> i < m}
 2. n \<noteq> 0 \<Longrightarrow> candidate_invariant m \<and> sorted ps \<and> distinct ps \<and> n < m \<and> set ps = {i. prime i \<and> n \<le> i \<and> i < m}
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
n = 0

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> candidate_invariant m \<and> sorted ps \<and> distinct ps \<and> n < m \<and> set ps = {i. prime i \<and> n \<le> i \<and> i < m}
 2. n \<noteq> 0 \<Longrightarrow> candidate_invariant m \<and> sorted ps \<and> distinct ps \<and> n < m \<and> set ps = {i. prime i \<and> n \<le> i \<and> i < m}
[PROOF STEP]
with res[unfolded next_primes_def]
[PROOF STATE]
proof (chain)
picking this:
(if n = 0 then next_candidates 0 else let (m, ps) = next_candidates n in (m, filter prime ps)) = (m, ps)
n = 0
[PROOF STEP]
have nc: "next_candidates 0 = (m,ps)"
[PROOF STATE]
proof (prove)
using this:
(if n = 0 then next_candidates 0 else let (m, ps) = next_candidates n in (m, filter prime ps)) = (m, ps)
n = 0

goal (1 subgoal):
 1. next_candidates 0 = (m, ps)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
next_candidates 0 = (m, ps)

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> candidate_invariant m \<and> sorted ps \<and> distinct ps \<and> n < m \<and> set ps = {i. prime i \<and> n \<le> i \<and> i < m}
 2. n \<noteq> 0 \<Longrightarrow> candidate_invariant m \<and> sorted ps \<and> distinct ps \<and> n < m \<and> set ps = {i. prime i \<and> n \<le> i \<and> i < m}
[PROOF STEP]
from this[unfolded next_candidates_def]
[PROOF STATE]
proof (chain)
picking this:
(if 0 = 0 then (1001, primes_1000) else (0 + 30, [0, 0 + 2, 0 + 6, 0 + 8, 0 + 12, 0 + 18, 0 + 20, 0 + 26])) = (m, ps)
[PROOF STEP]
have ps: "ps = primes_1000" and m: "m = 1001"
[PROOF STATE]
proof (prove)
using this:
(if 0 = 0 then (1001, primes_1000) else (0 + 30, [0, 0 + 2, 0 + 6, 0 + 8, 0 + 12, 0 + 18, 0 + 20, 0 + 26])) = (m, ps)

goal (1 subgoal):
 1. ps = primes_1000 &&& m = 1001
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
ps = primes_1000
m = 1001

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> candidate_invariant m \<and> sorted ps \<and> distinct ps \<and> n < m \<and> set ps = {i. prime i \<and> n \<le> i \<and> i < m}
 2. n \<noteq> 0 \<Longrightarrow> candidate_invariant m \<and> sorted ps \<and> distinct ps \<and> n < m \<and> set ps = {i. prime i \<and> n \<le> i \<and> i < m}
[PROOF STEP]
have ps: "set ps = {i. prime i \<and> n \<le> i \<and> i < m}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set ps = {i. prime i \<and> n \<le> i \<and> i < m}
[PROOF STEP]
unfolding m True ps
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set primes_1000 = {i. prime i \<and> 0 \<le> i \<and> i < 1001}
[PROOF STEP]
by (auto simp: primes_1000)
[PROOF STATE]
proof (state)
this:
set ps = {i. prime i \<and> n \<le> i \<and> i < m}

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> candidate_invariant m \<and> sorted ps \<and> distinct ps \<and> n < m \<and> set ps = {i. prime i \<and> n \<le> i \<and> i < m}
 2. n \<noteq> 0 \<Longrightarrow> candidate_invariant m \<and> sorted ps \<and> distinct ps \<and> n < m \<and> set ps = {i. prime i \<and> n \<le> i \<and> i < m}
[PROOF STEP]
with next_candidates[OF nc n[unfolded True]] True
[PROOF STATE]
proof (chain)
picking this:
candidate_invariant m
sorted ps
{i. prime i \<and> 0 \<le> i \<and> i < m} \<subseteq> set ps
set ps \<subseteq> {2..} \<inter> {0..<m}
distinct ps
ps \<noteq> []
0 < m
n = 0
set ps = {i. prime i \<and> n \<le> i \<and> i < m}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
candidate_invariant m
sorted ps
{i. prime i \<and> 0 \<le> i \<and> i < m} \<subseteq> set ps
set ps \<subseteq> {2..} \<inter> {0..<m}
distinct ps
ps \<noteq> []
0 < m
n = 0
set ps = {i. prime i \<and> n \<le> i \<and> i < m}

goal (1 subgoal):
 1. candidate_invariant m \<and> sorted ps \<and> distinct ps \<and> n < m \<and> set ps = {i. prime i \<and> n \<le> i \<and> i < m}
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
candidate_invariant m \<and> sorted ps \<and> distinct ps \<and> n < m \<and> set ps = {i. prime i \<and> n \<le> i \<and> i < m}

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> candidate_invariant m \<and> sorted ps \<and> distinct ps \<and> n < m \<and> set ps = {i. prime i \<and> n \<le> i \<and> i < m}
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> candidate_invariant m \<and> sorted ps \<and> distinct ps \<and> n < m \<and> set ps = {i. prime i \<and> n \<le> i \<and> i < m}
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
n \<noteq> 0

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> candidate_invariant m \<and> sorted ps \<and> distinct ps \<and> n < m \<and> set ps = {i. prime i \<and> n \<le> i \<and> i < m}
[PROOF STEP]
with res[unfolded next_primes_def Let_def]
[PROOF STATE]
proof (chain)
picking this:
(if n = 0 then next_candidates 0 else case next_candidates n of (m, ps) \<Rightarrow> (m, filter prime ps)) = (m, ps)
n \<noteq> 0
[PROOF STEP]
obtain qs where nc: "next_candidates n = (m, qs)"
      and ps: "ps = filter prime qs"
[PROOF STATE]
proof (prove)
using this:
(if n = 0 then next_candidates 0 else case next_candidates n of (m, ps) \<Rightarrow> (m, filter prime ps)) = (m, ps)
n \<noteq> 0

goal (1 subgoal):
 1. (\<And>qs. \<lbrakk>next_candidates n = (m, qs); ps = filter prime qs\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (cases "next_candidates n", auto)
[PROOF STATE]
proof (state)
this:
next_candidates n = (m, qs)
ps = filter prime qs

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> candidate_invariant m \<and> sorted ps \<and> distinct ps \<and> n < m \<and> set ps = {i. prime i \<and> n \<le> i \<and> i < m}
[PROOF STEP]
have "sorted qs \<Longrightarrow> sorted ps"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sorted qs \<Longrightarrow> sorted ps
[PROOF STEP]
unfolding ps
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sorted qs \<Longrightarrow> sorted (filter prime qs)
[PROOF STEP]
using sorted_filter[of id qs prime]
[PROOF STATE]
proof (prove)
using this:
sorted (map id qs) \<Longrightarrow> sorted (map id (filter prime qs))

goal (1 subgoal):
 1. sorted qs \<Longrightarrow> sorted (filter prime qs)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
sorted qs \<Longrightarrow> sorted ps

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> candidate_invariant m \<and> sorted ps \<and> distinct ps \<and> n < m \<and> set ps = {i. prime i \<and> n \<le> i \<and> i < m}
[PROOF STEP]
with next_candidates[OF nc n]
[PROOF STATE]
proof (chain)
picking this:
candidate_invariant m
sorted qs
{i. prime i \<and> n \<le> i \<and> i < m} \<subseteq> set qs
set qs \<subseteq> {2..} \<inter> {n..<m}
distinct qs
qs \<noteq> []
n < m
sorted qs \<Longrightarrow> sorted ps
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
candidate_invariant m
sorted qs
{i. prime i \<and> n \<le> i \<and> i < m} \<subseteq> set qs
set qs \<subseteq> {2..} \<inter> {n..<m}
distinct qs
qs \<noteq> []
n < m
sorted qs \<Longrightarrow> sorted ps

goal (1 subgoal):
 1. candidate_invariant m \<and> sorted ps \<and> distinct ps \<and> n < m \<and> set ps = {i. prime i \<and> n \<le> i \<and> i < m}
[PROOF STEP]
unfolding ps
[PROOF STATE]
proof (prove)
using this:
candidate_invariant m
sorted qs
{i. prime i \<and> n \<le> i \<and> i < m} \<subseteq> set qs
set qs \<subseteq> {2..} \<inter> {n..<m}
distinct qs
qs \<noteq> []
n < m
sorted qs \<Longrightarrow> sorted (filter prime qs)

goal (1 subgoal):
 1. candidate_invariant m \<and> sorted (filter prime qs) \<and> distinct (filter prime qs) \<and> n < m \<and> set (filter prime qs) = {i. prime i \<and> n \<le> i \<and> i < m}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
candidate_invariant m \<and> sorted ps \<and> distinct ps \<and> n < m \<and> set ps = {i. prime i \<and> n \<le> i \<and> i < m}

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
candidate_invariant m \<and> sorted ps \<and> distinct ps \<and> n < m \<and> set ps = {i. prime i \<and> n \<le> i \<and> i < m}

goal (5 subgoals):
 1. candidate_invariant m
 2. sorted ps
 3. distinct ps
 4. n < m
 5. set ps = {i. prime i \<and> n \<le> i \<and> i < m}
[PROOF STEP]
thus "candidate_invariant m" "sorted ps" "distinct ps" "n < m"
    "set ps = {i. prime i \<and> n \<le> i \<and> i < m}"
[PROOF STATE]
proof (prove)
using this:
candidate_invariant m \<and> sorted ps \<and> distinct ps \<and> n < m \<and> set ps = {i. prime i \<and> n \<le> i \<and> i < m}

goal (1 subgoal):
 1. (candidate_invariant m &&& sorted ps) &&& distinct ps &&& n < m &&& set ps = {i. prime i \<and> n \<le> i \<and> i < m}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
candidate_invariant m
sorted ps
distinct ps
n < m
set ps = {i. prime i \<and> n \<le> i \<and> i < m}

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma cnj_of_nat [simp]: "cnj (octo_of_nat x) = octo_of_nat( x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Octonions.cnj (octo_of_nat x) = octo_of_nat x
[PROOF STEP]
using cnj_of_real octo_of_real_of_nat_eq
[PROOF STATE]
proof (prove)
using this:
Octonions.cnj (octo_of_real ?x) = octo_of_real ?x
octo_of_real (real ?x) = octo_of_nat ?x

goal (1 subgoal):
 1. Octonions.cnj (octo_of_nat x) = octo_of_nat x
[PROOF STEP]
by metis


[STATEMENT]
lemma of_rat_floor [simp]:
  "\<lfloor>of_rat r\<rfloor> = \<lfloor>r\<rfloor>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lfloor>of_rat r\<rfloor> = \<lfloor>r\<rfloor>
[PROOF STEP]
by (cases r) (simp add: Fract_of_int_quotient of_rat_divide floor_divide_of_int_eq)


[STATEMENT]
lemma impl_disjI: "\<lbrakk> `P \<Rightarrow> R`; `Q \<Rightarrow> R` \<rbrakk> \<Longrightarrow> `(P \<or> Q) \<Rightarrow> R`"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>`P \<Rightarrow> R`; `Q \<Rightarrow> R`\<rbrakk> \<Longrightarrow> `P \<or> Q \<Rightarrow> R`
[PROOF STEP]
by (rel_auto)


[STATEMENT]
lemma valid_in_equiv: "valid_in I (\<phi> \<leftrightarrow> \<psi>) = ((fml_sem I \<phi>) = (fml_sem I \<psi>))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. valid_in I (\<phi> \<leftrightarrow> \<psi>) = (fml_sem I \<phi> = fml_sem I \<psi>)
[PROOF STEP]
using valid_in_def Equiv_def Or_def
[PROOF STATE]
proof (prove)
using this:
valid_in ?I ?\<phi> \<equiv> \<forall>\<omega>. \<omega> \<in> fml_sem ?I ?\<phi>
(?P \<leftrightarrow> ?Q) = (?P && ?Q || ! ?P && ! ?Q)
(?P || ?Q) = ! (! ?P && ! ?Q)

goal (1 subgoal):
 1. valid_in I (\<phi> \<leftrightarrow> \<psi>) = (fml_sem I \<phi> = fml_sem I \<psi>)
[PROOF STEP]
by auto


[STATEMENT]
lemma order_full_node: "order k (full_node k a h)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. order k (full_node k a h)
[PROOF STEP]
apply(induction k a h rule: full_node.induct)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>k c. order k (full_node k c 0)
 2. \<And>k c n. \<lbrakk>order k (full_node k c n); order k (full_node k c n)\<rbrakk> \<Longrightarrow> order k (full_node k c (Suc n))
[PROOF STEP]
apply auto
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma num_reachable_norefl_correct:
    "wf_list_graph G \<Longrightarrow>
     FiniteGraph.num_reachable_norefl (list_graph_to_graph G) v = num_reachable_norefl G v"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. wf_list_graph G \<Longrightarrow> FiniteGraph.num_reachable_norefl (list_graph_to_graph G) v = FiniteListGraph.num_reachable_norefl G v
[PROOF STEP]
unfolding num_reachable_norefl_def FiniteGraph.num_reachable_norefl_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. wf_list_graph G \<Longrightarrow> card (FiniteGraph.succ_tran (list_graph_to_graph G) v - {v}) = length (filter (\<lambda>x. x \<noteq> v) (FiniteListGraph.succ_tran G v))
[PROOF STEP]
by (metis (full_types) List.distinct_card distinct_filter distinct_succ_tran set_minus_filter_out succ_tran_correct)

  \<comment> \<open>backlinks, i.e. backflows in formal def\<close>


[STATEMENT]
lemma map2_rev: "\<And>ys.
  length xs = length ys \<Longrightarrow>
  rev (map2 f xs ys) = map2 f (rev xs) (rev ys)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>ys. length xs = length ys \<Longrightarrow> rev (List2.map2 f xs ys) = List2.map2 f (rev xs) (rev ys)
[PROOF STEP]
apply (induct xs, simp)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>a xs ys. \<lbrakk>\<And>ys. length xs = length ys \<Longrightarrow> rev (List2.map2 f xs ys) = List2.map2 f (rev xs) (rev ys); length (a # xs) = length ys\<rbrakk> \<Longrightarrow> rev (List2.map2 f (a # xs) ys) = List2.map2 f (rev (a # xs)) (rev ys)
[PROOF STEP]
apply (case_tac ys, simp)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>a xs ys aa list. \<lbrakk>\<And>ys. length xs = length ys \<Longrightarrow> rev (List2.map2 f xs ys) = List2.map2 f (rev xs) (rev ys); length (a # xs) = length ys; ys = aa # list\<rbrakk> \<Longrightarrow> rev (List2.map2 f (a # xs) ys) = List2.map2 f (rev (a # xs)) (rev ys)
[PROOF STEP]
apply (simp add: map2_Cons_Cons map2_snoc_snoc)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma of_real_inverse [simp]:
  "of_real (inverse x) = inverse (of_real x :: 'a::{real_div_algebra,division_ring})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. of_real (inverse x) = inverse (of_real x)
[PROOF STEP]
by (simp add: of_real_def inverse_scaleR_distrib)


[STATEMENT]
lemma homeomorphic_maps_iff_homeomorphism [simp]:
   "homeomorphic_maps (top_of_set S) (top_of_set T) f g \<longleftrightarrow> homeomorphism S T f g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. homeomorphic_maps (top_of_set S) (top_of_set T) f g = homeomorphism S T f g
[PROOF STEP]
unfolding homeomorphic_maps_def homeomorphism_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (continuous_map (top_of_set S) (top_of_set T) f \<and> continuous_map (top_of_set T) (top_of_set S) g \<and> (\<forall>x\<in>topspace (top_of_set S). g (f x) = x) \<and> (\<forall>y\<in>topspace (top_of_set T). f (g y) = y)) = ((\<forall>x\<in>S. g (f x) = x) \<and> f ` S = T \<and> continuous_on S f \<and> (\<forall>y\<in>T. f (g y) = y) \<and> g ` T = S \<and> continuous_on T g)
[PROOF STEP]
by force


[STATEMENT]
lemma The_opt_eq_none [simp] :
"((The_opt p) = None) \<longleftrightarrow> \<not>(\<exists>!x. p x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (The_opt p = None) = (\<nexists>!x. p x)
[PROOF STEP]
unfolding The_opt_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((if Ex1 p then Some (The p) else None) = None) = (\<nexists>!x. p x)
[PROOF STEP]
by auto


[STATEMENT]
lemma measurable_poisson_density'[measurable]:
    "case_prod poisson_density' \<in> borel_measurable (borel \<Otimes>\<^sub>M count_space UNIV)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>(x, y). poisson_density' x y) \<in> borel_measurable (borel \<Otimes>\<^sub>M count_space UNIV)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<lambda>(x, y). poisson_density' x y) \<in> borel_measurable (borel \<Otimes>\<^sub>M count_space UNIV)
[PROOF STEP]
have "case_prod poisson_density' =
    (\<lambda>(rate, k). rate ^ nat k / real_of_nat (fact (nat k)) * exp (-rate) * indicator ({0 <..} \<times> {0..}) (rate, k))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>(x, y). poisson_density' x y) = (\<lambda>x. ennreal (case x of (rate, k) \<Rightarrow> rate ^ nat k / real (fact (nat k)) * exp (- rate) * indicat_real ({0<..} \<times> {0..}) (rate, k)))
[PROOF STEP]
by (auto split: split_indicator simp: fun_eq_iff poisson_density'_def)
[PROOF STATE]
proof (state)
this:
(\<lambda>(x, y). poisson_density' x y) = (\<lambda>x. ennreal (case x of (rate, k) \<Rightarrow> rate ^ nat k / real (fact (nat k)) * exp (- rate) * indicat_real ({0<..} \<times> {0..}) (rate, k)))

goal (1 subgoal):
 1. (\<lambda>(x, y). poisson_density' x y) \<in> borel_measurable (borel \<Otimes>\<^sub>M count_space UNIV)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(\<lambda>(x, y). poisson_density' x y) = (\<lambda>x. ennreal (case x of (rate, k) \<Rightarrow> rate ^ nat k / real (fact (nat k)) * exp (- rate) * indicat_real ({0<..} \<times> {0..}) (rate, k)))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(\<lambda>(x, y). poisson_density' x y) = (\<lambda>x. ennreal (case x of (rate, k) \<Rightarrow> rate ^ nat k / real (fact (nat k)) * exp (- rate) * indicat_real ({0<..} \<times> {0..}) (rate, k)))

goal (1 subgoal):
 1. (\<lambda>(x, y). poisson_density' x y) \<in> borel_measurable (borel \<Otimes>\<^sub>M count_space UNIV)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<lambda>(x, y). poisson_density' x y) \<in> borel_measurable (borel \<Otimes>\<^sub>M count_space UNIV)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma mult_min_right: "a \<ge> 0 \<Longrightarrow> (a :: real) * min b c = min (a * b) (a * c)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 \<le> a \<Longrightarrow> a * min b c = min (a * b) (a * c)
[PROOF STEP]
by (metis min.absorb_iff2 min_def mult_left_mono)


[STATEMENT]
lemma is_list_UNIV_iff: "is_list_UNIV xs \<longleftrightarrow> set xs = UNIV"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. is_list_UNIV xs = (set xs = UNIV)
[PROOF STEP]
by(auto simp add: is_list_UNIV_def Let_def card_eq_0_iff List.card_set[symmetric]
   dest: subst[where P="finite", OF _ finite_set] card_eq_UNIV_imp_eq_UNIV)


[STATEMENT]
lemma prob_space_exponential: "0 < l \<Longrightarrow> prob_space (exponential l)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < l \<Longrightarrow> prob_space (exponential l)
[PROOF STEP]
unfolding exponential_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < l \<Longrightarrow> prob_space (density lborel (\<lambda>x. ennreal (exponential_density l x)))
[PROOF STEP]
by (intro prob_space_exponential_density)


[STATEMENT]
lemma chebyshev_inequality:
  fixes Y :: "'a \<Rightarrow> real"
  assumes Y_int: "integrable M (\<lambda>y. (Y y)^2)"
  assumes Y_borel: "Y \<in> borel_measurable M"
  fixes s :: "real"
  assumes s_pos: "0 < s"
  shows "prob {a \<in> space M. s \<le> \<bar>Y a - expectation Y\<bar>} \<le> variance Y / s^2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. prob {a \<in> space M. s \<le> \<bar>Y a - expectation Y\<bar>} \<le> expectation (\<lambda>x. (Y x - expectation Y)\<^sup>2) / s\<^sup>2
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. prob {a \<in> space M. s \<le> \<bar>Y a - expectation Y\<bar>} \<le> expectation (\<lambda>x. (Y x - expectation Y)\<^sup>2) / s\<^sup>2
[PROOF STEP]
let ?X = "\<lambda>a. (Y a - expectation Y)^2"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. prob {a \<in> space M. s \<le> \<bar>Y a - expectation Y\<bar>} \<le> expectation (\<lambda>x. (Y x - expectation Y)\<^sup>2) / s\<^sup>2
[PROOF STEP]
let ?t = "s^2"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. prob {a \<in> space M. s \<le> \<bar>Y a - expectation Y\<bar>} \<le> expectation (\<lambda>x. (Y x - expectation Y)\<^sup>2) / s\<^sup>2
[PROOF STEP]
have "0 < ?t"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < s\<^sup>2
[PROOF STEP]
using s_pos
[PROOF STATE]
proof (prove)
using this:
0 < s

goal (1 subgoal):
 1. 0 < s\<^sup>2
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
0 < s\<^sup>2

goal (1 subgoal):
 1. prob {a \<in> space M. s \<le> \<bar>Y a - expectation Y\<bar>} \<le> expectation (\<lambda>x. (Y x - expectation Y)\<^sup>2) / s\<^sup>2
[PROOF STEP]
hence "prob {a \<in> space M. ?t \<le> ?X a} \<le> variance Y / s^2"
[PROOF STATE]
proof (prove)
using this:
0 < s\<^sup>2

goal (1 subgoal):
 1. prob {a \<in> space M. s\<^sup>2 \<le> (Y a - expectation Y)\<^sup>2} \<le> expectation (\<lambda>x. (Y x - expectation Y)\<^sup>2) / s\<^sup>2
[PROOF STEP]
using markov_inequality variance_expectation[OF Y_int Y_borel]
[PROOF STATE]
proof (prove)
using this:
0 < s\<^sup>2
\<lbrakk>\<And>a. 0 \<le> ?X a; integrable M ?X; 0 < ?t\<rbrakk> \<Longrightarrow> prob {a \<in> space M. ?t \<le> ?X a} \<le> expectation ?X / ?t
integrable M (\<lambda>x. (Y x - expectation Y)\<^sup>2)
expectation (\<lambda>x. (Y x - expectation Y)\<^sup>2) = expectation (\<lambda>x. (Y x)\<^sup>2) - (expectation Y)\<^sup>2

goal (1 subgoal):
 1. prob {a \<in> space M. s\<^sup>2 \<le> (Y a - expectation Y)\<^sup>2} \<le> expectation (\<lambda>x. (Y x - expectation Y)\<^sup>2) / s\<^sup>2
[PROOF STEP]
by (simp add: field_simps)
[PROOF STATE]
proof (state)
this:
prob {a \<in> space M. s\<^sup>2 \<le> (Y a - expectation Y)\<^sup>2} \<le> expectation (\<lambda>x. (Y x - expectation Y)\<^sup>2) / s\<^sup>2

goal (1 subgoal):
 1. prob {a \<in> space M. s \<le> \<bar>Y a - expectation Y\<bar>} \<le> expectation (\<lambda>x. (Y x - expectation Y)\<^sup>2) / s\<^sup>2
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
prob {a \<in> space M. s\<^sup>2 \<le> (Y a - expectation Y)\<^sup>2} \<le> expectation (\<lambda>x. (Y x - expectation Y)\<^sup>2) / s\<^sup>2

goal (1 subgoal):
 1. prob {a \<in> space M. s \<le> \<bar>Y a - expectation Y\<bar>} \<le> expectation (\<lambda>x. (Y x - expectation Y)\<^sup>2) / s\<^sup>2
[PROOF STEP]
have "{a \<in> space M. ?t \<le> ?X a} = {a \<in> space M. s \<le> \<bar>Y a - expectation Y\<bar>}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {a \<in> space M. s\<^sup>2 \<le> (Y a - expectation Y)\<^sup>2} = {a \<in> space M. s \<le> \<bar>Y a - expectation Y\<bar>}
[PROOF STEP]
using abs_le_square_iff s_pos
[PROOF STATE]
proof (prove)
using this:
(\<bar>?x\<bar> \<le> \<bar>?y\<bar>) = (?x\<^sup>2 \<le> ?y\<^sup>2)
0 < s

goal (1 subgoal):
 1. {a \<in> space M. s\<^sup>2 \<le> (Y a - expectation Y)\<^sup>2} = {a \<in> space M. s \<le> \<bar>Y a - expectation Y\<bar>}
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
{a \<in> space M. s\<^sup>2 \<le> (Y a - expectation Y)\<^sup>2} = {a \<in> space M. s \<le> \<bar>Y a - expectation Y\<bar>}

goal (1 subgoal):
 1. prob {a \<in> space M. s \<le> \<bar>Y a - expectation Y\<bar>} \<le> expectation (\<lambda>x. (Y x - expectation Y)\<^sup>2) / s\<^sup>2
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
prob {a \<in> space M. s\<^sup>2 \<le> (Y a - expectation Y)\<^sup>2} \<le> expectation (\<lambda>x. (Y x - expectation Y)\<^sup>2) / s\<^sup>2
{a \<in> space M. s\<^sup>2 \<le> (Y a - expectation Y)\<^sup>2} = {a \<in> space M. s \<le> \<bar>Y a - expectation Y\<bar>}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
prob {a \<in> space M. s\<^sup>2 \<le> (Y a - expectation Y)\<^sup>2} \<le> expectation (\<lambda>x. (Y x - expectation Y)\<^sup>2) / s\<^sup>2
{a \<in> space M. s\<^sup>2 \<le> (Y a - expectation Y)\<^sup>2} = {a \<in> space M. s \<le> \<bar>Y a - expectation Y\<bar>}

goal (1 subgoal):
 1. prob {a \<in> space M. s \<le> \<bar>Y a - expectation Y\<bar>} \<le> expectation (\<lambda>x. (Y x - expectation Y)\<^sup>2) / s\<^sup>2
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
prob {a \<in> space M. s \<le> \<bar>Y a - expectation Y\<bar>} \<le> expectation (\<lambda>x. (Y x - expectation Y)\<^sup>2) / s\<^sup>2

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma bnds_power:
  "\<forall>(x::real) l u. (l1, u1) = float_power_bnds prec n l u \<and> x \<in> {l .. u} \<longrightarrow>
    l1 \<le> x ^ n \<and> x ^ n \<le> u1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>x l u. (l1, u1) = float_power_bnds prec n l u \<and> x \<in> {real_of_float l..real_of_float u} \<longrightarrow> real_of_float l1 \<le> x ^ n \<and> x ^ n \<le> real_of_float u1
[PROOF STEP]
using float_power_bnds
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>(?l1.0, ?u1.0) = float_power_bnds ?prec ?n ?l ?u; ?x \<in> {real_of_float ?l..real_of_float ?u}\<rbrakk> \<Longrightarrow> ?x ^ ?n \<in> {real_of_float ?l1.0..real_of_float ?u1.0}

goal (1 subgoal):
 1. \<forall>x l u. (l1, u1) = float_power_bnds prec n l u \<and> x \<in> {real_of_float l..real_of_float u} \<longrightarrow> real_of_float l1 \<le> x ^ n \<and> x ^ n \<le> real_of_float u1
[PROOF STEP]
by auto


[STATEMENT]
lemma AE_uniform_measureI:
  "A \<in> sets M \<Longrightarrow> (AE x in M. x \<in> A \<longrightarrow> P x) \<Longrightarrow> (AE x in uniform_measure M A. P x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>A \<in> sets M; set_almost_everywhere A M P\<rbrakk> \<Longrightarrow> almost_everywhere (uniform_measure M A) P
[PROOF STEP]
unfolding uniform_measure_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>A \<in> sets M; set_almost_everywhere A M P\<rbrakk> \<Longrightarrow> almost_everywhere (density M (\<lambda>x. indicator A x / emeasure M A)) P
[PROOF STEP]
by (auto simp: AE_density divide_ennreal_def)


[STATEMENT]
lemma pdevs_val_filter_pdevs:
  "pdevs_val e (filter_pdevs I x) =
    (\<Sum>i \<in> {..<degree x} \<inter> {i. I i (pdevs_apply x i)}. e i *\<^sub>R pdevs_apply x i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. pdevs_val e (filter_pdevs I x) = (\<Sum>i\<in>{..<degree x} \<inter> {i. I i (pdevs_apply x i)}. e i *\<^sub>R pdevs_apply x i)
[PROOF STEP]
by (auto simp: pdevs_val_sum if_distrib sum.inter_restrict degree_filter_pdevs_le degree_gt
    intro!: sum.mono_neutral_cong_left split: if_split_asm)


[STATEMENT]
lemma create_unconnected_fsm_with_precomputations_code [code] : "FSM_Impl.create_unconnected_fsm_from_fsets q ns ins outs = FSMWP (create_unconnected_fsm_from_fsets q ns ins outs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. FSM_Impl.create_unconnected_fsm_from_fsets q ns ins outs = FSMWP (FSM_Code_Datatype.create_unconnected_fsm_from_fsets q ns ins outs)
[PROOF STEP]
unfolding FSM_Impl.create_unconnected_fsm_from_fsets.simps
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. FSMI q (insert q (fset ns)) (fset ins) (fset outs) {} = FSMWP (FSM_Code_Datatype.create_unconnected_fsm_from_fsets q ns ins outs)
[PROOF STEP]
unfolding FSMWP_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. FSMI q (insert q (fset ns)) (fset ins) (fset outs) {} = FSMI (initial_wp (FSM_Code_Datatype.create_unconnected_fsm_from_fsets q ns ins outs)) (states_wp (FSM_Code_Datatype.create_unconnected_fsm_from_fsets q ns ins outs)) (inputs_wp (FSM_Code_Datatype.create_unconnected_fsm_from_fsets q ns ins outs)) (outputs_wp (FSM_Code_Datatype.create_unconnected_fsm_from_fsets q ns ins outs)) (transitions_wp (FSM_Code_Datatype.create_unconnected_fsm_from_fsets q ns ins outs))
[PROOF STEP]
unfolding create_unconnected_fsm_from_fsets_simps
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. FSMI q (insert q (fset ns)) (fset ins) (fset outs) {} = FSMI q (insert q (fset ns)) (fset ins) (fset outs) {}
[PROOF STEP]
by presburger


[STATEMENT]
lemma fps_lr_inverse_gp_ring1':
  fixes   ones :: "'a :: ring_1 fps"
  defines "ones \<equiv> Abs_fps (\<lambda>n. 1)"
  shows   "fps_left_inverse ones 1 = 1 - fps_X"
  and     "fps_right_inverse ones 1 = 1 - fps_X"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fps_left_inverse ones (1::'a) = 1 - fps_X &&& fps_right_inverse ones (1::'a) = 1 - fps_X
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. fps_left_inverse ones (1::'a) = 1 - fps_X
 2. fps_right_inverse ones (1::'a) = 1 - fps_X
[PROOF STEP]
define ones_inv :: "'a :: ring_1 fps"
    where "ones_inv \<equiv> Abs_fps (\<lambda>n. if n=0 then 1 else if n=1 then - 1 else 0)"
[PROOF STATE]
proof (state)
this:
ones_inv \<equiv> Abs_fps (\<lambda>n. if n = 0 then 1::'a else if n = 1 then - (1::'a) else (0::'a))

goal (2 subgoals):
 1. fps_left_inverse ones (1::'a) = 1 - fps_X
 2. fps_right_inverse ones (1::'a) = 1 - fps_X
[PROOF STEP]
hence "fps_left_inverse ones 1 = ones_inv"
  and   "fps_right_inverse ones 1 = ones_inv"
[PROOF STATE]
proof (prove)
using this:
ones_inv \<equiv> Abs_fps (\<lambda>n. if n = 0 then 1::'a else if n = 1 then - (1::'a) else (0::'a))

goal (1 subgoal):
 1. fps_left_inverse ones (1::'a) = ones_inv &&& fps_right_inverse ones (1::'a) = ones_inv
[PROOF STEP]
using ones_def fps_lr_inverse_gp_ring1
[PROOF STATE]
proof (prove)
using this:
ones_inv \<equiv> Abs_fps (\<lambda>n. if n = 0 then 1::'a else if n = 1 then - (1::'a) else (0::'a))
ones \<equiv> Abs_fps (\<lambda>n. 1::'a)
fps_left_inverse (Abs_fps (\<lambda>n. 1::?'a)) (1::?'a) = Abs_fps (\<lambda>n. if n = 0 then 1::?'a else if n = 1 then - (1::?'a) else (0::?'a))
fps_right_inverse (Abs_fps (\<lambda>n. 1::?'a)) (1::?'a) = Abs_fps (\<lambda>n. if n = 0 then 1::?'a else if n = 1 then - (1::?'a) else (0::?'a))

goal (1 subgoal):
 1. fps_left_inverse ones (1::'a) = ones_inv &&& fps_right_inverse ones (1::'a) = ones_inv
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
fps_left_inverse ones (1::'a) = ones_inv
fps_right_inverse ones (1::'a) = ones_inv

goal (2 subgoals):
 1. fps_left_inverse ones (1::'a) = 1 - fps_X
 2. fps_right_inverse ones (1::'a) = 1 - fps_X
[PROOF STEP]
thus "fps_left_inverse ones 1 = 1 - fps_X"
  and   "fps_right_inverse ones 1 = 1 - fps_X"
[PROOF STATE]
proof (prove)
using this:
fps_left_inverse ones (1::'a) = ones_inv
fps_right_inverse ones (1::'a) = ones_inv

goal (1 subgoal):
 1. fps_left_inverse ones (1::'a) = 1 - fps_X &&& fps_right_inverse ones (1::'a) = 1 - fps_X
[PROOF STEP]
by (auto intro: fps_ext simp: ones_inv_def)
[PROOF STATE]
proof (state)
this:
fps_left_inverse ones (1::'a) = 1 - fps_X
fps_right_inverse ones (1::'a) = 1 - fps_X

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma calc_ideal_point_2_unit:
  assumes "is_real A" "(cmod B)\<^sup>2 > (cmod A)\<^sup>2"
  assumes "(z1, z2) = calc_ideal_point2_cvec A B"
  shows "z1 * cnj z1 = z2 * cnj z2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. z1 * cnj z1 = z2 * cnj z2
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. z1 * cnj z1 = z2 * cnj z2
[PROOF STEP]
let ?discr = "Re ((cmod B)\<^sup>2 - (Re A)\<^sup>2)"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. z1 * cnj z1 = z2 * cnj z2
[PROOF STEP]
have "?discr > 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < Re (cor ((cmod B)\<^sup>2 - (Re A)\<^sup>2))
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
is_real A
(cmod A)\<^sup>2 < (cmod B)\<^sup>2
(z1, z2) = calc_ideal_point2_cvec A B

goal (1 subgoal):
 1. 0 < Re (cor ((cmod B)\<^sup>2 - (Re A)\<^sup>2))
[PROOF STEP]
by (simp add: cmod_power2)
[PROOF STATE]
proof (state)
this:
0 < Re (cor ((cmod B)\<^sup>2 - (Re A)\<^sup>2))

goal (1 subgoal):
 1. z1 * cnj z1 = z2 * cnj z2
[PROOF STEP]
have "(B*(-A + \<i>*sqrt(?discr))) * cnj (B*(-A + \<i>*sqrt(?discr))) = (B * cnj B) * (A\<^sup>2 + cor (abs ?discr))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. B * (- A + \<i> * cor (sqrt (Re (cor ((cmod B)\<^sup>2 - (Re A)\<^sup>2))))) * cnj (B * (- A + \<i> * cor (sqrt (Re (cor ((cmod B)\<^sup>2 - (Re A)\<^sup>2)))))) = B * cnj B * (A\<^sup>2 + cor \<bar>Re (cor ((cmod B)\<^sup>2 - (Re A)\<^sup>2))\<bar>)
[PROOF STEP]
using \<open>is_real A\<close> eq_cnj_iff_real[of A]
[PROOF STATE]
proof (prove)
using this:
is_real A
(cnj A = A) = is_real A

goal (1 subgoal):
 1. B * (- A + \<i> * cor (sqrt (Re (cor ((cmod B)\<^sup>2 - (Re A)\<^sup>2))))) * cnj (B * (- A + \<i> * cor (sqrt (Re (cor ((cmod B)\<^sup>2 - (Re A)\<^sup>2)))))) = B * cnj B * (A\<^sup>2 + cor \<bar>Re (cor ((cmod B)\<^sup>2 - (Re A)\<^sup>2))\<bar>)
[PROOF STEP]
by (simp add: field_simps power2_eq_square)
[PROOF STATE]
proof (state)
this:
B * (- A + \<i> * cor (sqrt (Re (cor ((cmod B)\<^sup>2 - (Re A)\<^sup>2))))) * cnj (B * (- A + \<i> * cor (sqrt (Re (cor ((cmod B)\<^sup>2 - (Re A)\<^sup>2)))))) = B * cnj B * (A\<^sup>2 + cor \<bar>Re (cor ((cmod B)\<^sup>2 - (Re A)\<^sup>2))\<bar>)

goal (1 subgoal):
 1. z1 * cnj z1 = z2 * cnj z2
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
B * (- A + \<i> * cor (sqrt (Re (cor ((cmod B)\<^sup>2 - (Re A)\<^sup>2))))) * cnj (B * (- A + \<i> * cor (sqrt (Re (cor ((cmod B)\<^sup>2 - (Re A)\<^sup>2)))))) = B * cnj B * (A\<^sup>2 + cor \<bar>Re (cor ((cmod B)\<^sup>2 - (Re A)\<^sup>2))\<bar>)

goal (1 subgoal):
 1. z1 * cnj z1 = z2 * cnj z2
[PROOF STEP]
have "... = (B * cnj B) * (cmod B)\<^sup>2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. B * cnj B * (A\<^sup>2 + cor \<bar>Re (cor ((cmod B)\<^sup>2 - (Re A)\<^sup>2))\<bar>) = B * cnj B * cor ((cmod B)\<^sup>2)
[PROOF STEP]
using \<open>?discr > 0\<close>
[PROOF STATE]
proof (prove)
using this:
0 < Re (cor ((cmod B)\<^sup>2 - (Re A)\<^sup>2))

goal (1 subgoal):
 1. B * cnj B * (A\<^sup>2 + cor \<bar>Re (cor ((cmod B)\<^sup>2 - (Re A)\<^sup>2))\<bar>) = B * cnj B * cor ((cmod B)\<^sup>2)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
0 < Re (cor ((cmod B)\<^sup>2 - (Re A)\<^sup>2))
is_real A
(cmod A)\<^sup>2 < (cmod B)\<^sup>2
(z1, z2) = calc_ideal_point2_cvec A B

goal (1 subgoal):
 1. B * cnj B * (A\<^sup>2 + cor \<bar>Re (cor ((cmod B)\<^sup>2 - (Re A)\<^sup>2))\<bar>) = B * cnj B * cor ((cmod B)\<^sup>2)
[PROOF STEP]
using complex_of_real_Re[of "(cmod B)\<^sup>2 - (Re A)\<^sup>2"] complex_of_real_Re[of A] \<open>is_real A\<close>
[PROOF STATE]
proof (prove)
using this:
0 < Re (cor ((cmod B)\<^sup>2 - (Re A)\<^sup>2))
is_real A
(cmod A)\<^sup>2 < (cmod B)\<^sup>2
(z1, z2) = calc_ideal_point2_cvec A B
is_real (cor ((cmod B)\<^sup>2 - (Re A)\<^sup>2)) \<Longrightarrow> cor (Re (cor ((cmod B)\<^sup>2 - (Re A)\<^sup>2))) = cor ((cmod B)\<^sup>2 - (Re A)\<^sup>2)
is_real A \<Longrightarrow> cor (Re A) = A
is_real A

goal (1 subgoal):
 1. B * cnj B * (A\<^sup>2 + cor \<bar>Re (cor ((cmod B)\<^sup>2 - (Re A)\<^sup>2))\<bar>) = B * cnj B * cor ((cmod B)\<^sup>2)
[PROOF STEP]
by (simp add: power2_eq_square)
[PROOF STATE]
proof (state)
this:
B * cnj B * (A\<^sup>2 + cor \<bar>Re (cor ((cmod B)\<^sup>2 - (Re A)\<^sup>2))\<bar>) = B * cnj B * cor ((cmod B)\<^sup>2)

goal (1 subgoal):
 1. z1 * cnj z1 = z2 * cnj z2
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
B * cnj B * (A\<^sup>2 + cor \<bar>Re (cor ((cmod B)\<^sup>2 - (Re A)\<^sup>2))\<bar>) = B * cnj B * cor ((cmod B)\<^sup>2)

goal (1 subgoal):
 1. z1 * cnj z1 = z2 * cnj z2
[PROOF STEP]
have "... = (cmod B)\<^sup>2 * cnj ((cmod B)\<^sup>2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. B * cnj B * cor ((cmod B)\<^sup>2) = cor ((cmod B)\<^sup>2) * cnj (cor ((cmod B)\<^sup>2))
[PROOF STEP]
using complex_cnj_complex_of_real complex_mult_cnj_cmod
[PROOF STATE]
proof (prove)
using this:
cnj (cor ?x) = cor ?x
?z * cnj ?z = cor ((cmod ?z)\<^sup>2)

goal (1 subgoal):
 1. B * cnj B * cor ((cmod B)\<^sup>2) = cor ((cmod B)\<^sup>2) * cnj (cor ((cmod B)\<^sup>2))
[PROOF STEP]
by presburger
[PROOF STATE]
proof (state)
this:
B * cnj B * cor ((cmod B)\<^sup>2) = cor ((cmod B)\<^sup>2) * cnj (cor ((cmod B)\<^sup>2))

goal (1 subgoal):
 1. z1 * cnj z1 = z2 * cnj z2
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
B * (- A + \<i> * cor (sqrt (Re (cor ((cmod B)\<^sup>2 - (Re A)\<^sup>2))))) * cnj (B * (- A + \<i> * cor (sqrt (Re (cor ((cmod B)\<^sup>2 - (Re A)\<^sup>2)))))) = cor ((cmod B)\<^sup>2) * cnj (cor ((cmod B)\<^sup>2))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
B * (- A + \<i> * cor (sqrt (Re (cor ((cmod B)\<^sup>2 - (Re A)\<^sup>2))))) * cnj (B * (- A + \<i> * cor (sqrt (Re (cor ((cmod B)\<^sup>2 - (Re A)\<^sup>2)))))) = cor ((cmod B)\<^sup>2) * cnj (cor ((cmod B)\<^sup>2))

goal (1 subgoal):
 1. z1 * cnj z1 = z2 * cnj z2
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
B * (- A + \<i> * cor (sqrt (Re (cor ((cmod B)\<^sup>2 - (Re A)\<^sup>2))))) * cnj (B * (- A + \<i> * cor (sqrt (Re (cor ((cmod B)\<^sup>2 - (Re A)\<^sup>2)))))) = cor ((cmod B)\<^sup>2) * cnj (cor ((cmod B)\<^sup>2))
is_real A
(cmod A)\<^sup>2 < (cmod B)\<^sup>2
(z1, z2) = calc_ideal_point2_cvec A B

goal (1 subgoal):
 1. z1 * cnj z1 = z2 * cnj z2
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
z1 * cnj z1 = z2 * cnj z2

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma real_of_int_div4: "real_of_int (n div x) \<le> real_of_int n / real_of_int x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real_of_int (n div x) \<le> real_of_int n / real_of_int x
[PROOF STEP]
using real_of_int_div2 [of n x]
[PROOF STATE]
proof (prove)
using this:
0 \<le> real_of_int n / real_of_int x - real_of_int (n div x)

goal (1 subgoal):
 1. real_of_int (n div x) \<le> real_of_int n / real_of_int x
[PROOF STEP]
by simp


[STATEMENT]
lemma closed_real_abs_le: "closed {w \<in> \<real>. \<bar>Re w\<bar> \<le> r}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. closed {w \<in> \<real>. \<bar>Re w\<bar> \<le> r}
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. closed {w \<in> \<real>. \<bar>Re w\<bar> \<le> r}
[PROOF STEP]
have "{w \<in> \<real>. \<bar>Re w\<bar> \<le> r} = (\<real> \<inter> {w. Re w \<le> r}) \<inter> (\<real> \<inter> {w. Re w \<ge> -r})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {w \<in> \<real>. \<bar>Re w\<bar> \<le> r} = \<real> \<inter> {w. Re w \<le> r} \<inter> (\<real> \<inter> {w. - r \<le> Re w})
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
{w \<in> \<real>. \<bar>Re w\<bar> \<le> r} = \<real> \<inter> {w. Re w \<le> r} \<inter> (\<real> \<inter> {w. - r \<le> Re w})

goal (1 subgoal):
 1. closed {w \<in> \<real>. \<bar>Re w\<bar> \<le> r}
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
{w \<in> \<real>. \<bar>Re w\<bar> \<le> r} = \<real> \<inter> {w. Re w \<le> r} \<inter> (\<real> \<inter> {w. - r \<le> Re w})
[PROOF STEP]
show "closed {w \<in> \<real>. \<bar>Re w\<bar> \<le> r}"
[PROOF STATE]
proof (prove)
using this:
{w \<in> \<real>. \<bar>Re w\<bar> \<le> r} = \<real> \<inter> {w. Re w \<le> r} \<inter> (\<real> \<inter> {w. - r \<le> Re w})

goal (1 subgoal):
 1. closed {w \<in> \<real>. \<bar>Re w\<bar> \<le> r}
[PROOF STEP]
by (simp add: closed_Int closed_Real_halfspace_Re_ge closed_Real_halfspace_Re_le)
[PROOF STATE]
proof (state)
this:
closed {w \<in> \<real>. \<bar>Re w\<bar> \<le> r}

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma linear_inj_bounded_below_pos:
  fixes f :: "'a::real_normed_vector \<Rightarrow> 'b::euclidean_space"
  assumes "linear f" "inj f"
  obtains B where "B > 0" "\<And>x. B * norm x \<le> norm(f x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>B. \<lbrakk>0 < B; \<And>x. B * norm x \<le> norm (f x)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using linear_injective_left_inverse [OF assms]
    linear_invertible_bounded_below_pos assms
[PROOF STATE]
proof (prove)
using this:
\<exists>g. linear g \<and> g \<circ> f = id
\<lbrakk>linear ?f; linear ?g; ?g \<circ> ?f = id; \<And>B. \<lbrakk>0 < B; \<And>x. B * norm x \<le> norm (?f x)\<rbrakk> \<Longrightarrow> ?thesis\<rbrakk> \<Longrightarrow> ?thesis
linear f
inj f

goal (1 subgoal):
 1. (\<And>B. \<lbrakk>0 < B; \<And>x. B * norm x \<le> norm (f x)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast