[STATEMENT]
lemma SMVT_lemma4:
  fixes f :: "real \<Rightarrow> real"
  assumes f: "f integrable_on {a..b}"
    and "a \<le> b"
    and g: "\<And>x y. x \<le> y \<Longrightarrow> g x \<le> g y"
    and 01: "\<And>x. \<lbrakk>a \<le> x; x \<le> b\<rbrakk> \<Longrightarrow> 0 \<le> g x \<and> g x \<le> 1"
  obtains c where "a \<le> c" "c \<le> b" "((\<lambda>x. g x *\<^sub>R f x) has_integral integral {c..b} f) {a..b}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>c. \<lbrakk>a \<le> c; c \<le> b; ((\<lambda>x. g x *\<^sub>R f x) has_integral integral {c..b} f) {a..b}\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<And>c. \<lbrakk>a \<le> c; c \<le> b; ((\<lambda>x. g x *\<^sub>R f x) has_integral integral {c..b} f) {a..b}\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
have "connected ((\<lambda>x. integral {x..b} f) ` {a..b})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. connected ((\<lambda>x. integral {x..b} f) ` {a..b})
[PROOF STEP]
by (simp add: f indefinite_integral_continuous_1' connected_continuous_image)
[PROOF STATE]
proof (state)
this:
connected ((\<lambda>x. integral {x..b} f) ` {a..b})

goal (1 subgoal):
 1. (\<And>c. \<lbrakk>a \<le> c; c \<le> b; ((\<lambda>x. g x *\<^sub>R f x) has_integral integral {c..b} f) {a..b}\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
connected ((\<lambda>x. integral {x..b} f) ` {a..b})

goal (1 subgoal):
 1. (\<And>c. \<lbrakk>a \<le> c; c \<le> b; ((\<lambda>x. g x *\<^sub>R f x) has_integral integral {c..b} f) {a..b}\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
have "compact ((\<lambda>x. integral {x..b} f) ` {a..b})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. compact ((\<lambda>x. integral {x..b} f) ` {a..b})
[PROOF STEP]
by (simp add: compact_continuous_image f indefinite_integral_continuous_1')
[PROOF STATE]
proof (state)
this:
compact ((\<lambda>x. integral {x..b} f) ` {a..b})

goal (1 subgoal):
 1. (\<And>c. \<lbrakk>a \<le> c; c \<le> b; ((\<lambda>x. g x *\<^sub>R f x) has_integral integral {c..b} f) {a..b}\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
connected ((\<lambda>x. integral {x..b} f) ` {a..b})
compact ((\<lambda>x. integral {x..b} f) ` {a..b})
[PROOF STEP]
obtain m M where int_fab: "(\<lambda>x. integral {x..b} f) ` {a..b} = {m..M}"
[PROOF STATE]
proof (prove)
using this:
connected ((\<lambda>x. integral {x..b} f) ` {a..b})
compact ((\<lambda>x. integral {x..b} f) ` {a..b})

goal (1 subgoal):
 1. (\<And>m M. (\<lambda>x. integral {x..b} f) ` {a..b} = {m..M} \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using connected_compact_interval_1
[PROOF STATE]
proof (prove)
using this:
connected ((\<lambda>x. integral {x..b} f) ` {a..b})
compact ((\<lambda>x. integral {x..b} f) ` {a..b})
(connected ?S \<and> compact ?S) = (\<exists>a b. ?S = {a..b})

goal (1 subgoal):
 1. (\<And>m M. (\<lambda>x. integral {x..b} f) ` {a..b} = {m..M} \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by meson
[PROOF STATE]
proof (state)
this:
(\<lambda>x. integral {x..b} f) ` {a..b} = {m..M}

goal (1 subgoal):
 1. (\<And>c. \<lbrakk>a \<le> c; c \<le> b; ((\<lambda>x. g x *\<^sub>R f x) has_integral integral {c..b} f) {a..b}\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
have "\<exists>c. c \<in> {a..b} \<and>
              integral {c..b} f =
              integral {a..b} (\<lambda>x. (\<Sum>k = 1..n. if g x \<ge> real k / real n then inverse n *\<^sub>R f x else 0))" for n
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>c. c \<in> {a..b} \<and> integral {c..b} f = integral {a..b} (\<lambda>x. \<Sum>k = 1..n. if real k / real n \<le> g x then f x /\<^sub>R real n else 0)
[PROOF STEP]
proof (cases "n=0")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. n = 0 \<Longrightarrow> \<exists>c. c \<in> {a..b} \<and> integral {c..b} f = integral {a..b} (\<lambda>x. \<Sum>k = 1..n. if real k / real n \<le> g x then f x /\<^sub>R real n else 0)
 2. n \<noteq> 0 \<Longrightarrow> \<exists>c. c \<in> {a..b} \<and> integral {c..b} f = integral {a..b} (\<lambda>x. \<Sum>k = 1..n. if real k / real n \<le> g x then f x /\<^sub>R real n else 0)
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
n = 0

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> \<exists>c. c \<in> {a..b} \<and> integral {c..b} f = integral {a..b} (\<lambda>x. \<Sum>k = 1..n. if real k / real n \<le> g x then f x /\<^sub>R real n else 0)
 2. n \<noteq> 0 \<Longrightarrow> \<exists>c. c \<in> {a..b} \<and> integral {c..b} f = integral {a..b} (\<lambda>x. \<Sum>k = 1..n. if real k / real n \<le> g x then f x /\<^sub>R real n else 0)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
n = 0
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
n = 0

goal (1 subgoal):
 1. \<exists>c. c \<in> {a..b} \<and> integral {c..b} f = integral {a..b} (\<lambda>x. \<Sum>k = 1..n. if real k / real n \<le> g x then f x /\<^sub>R real n else 0)
[PROOF STEP]
using \<open>a \<le> b\<close>
[PROOF STATE]
proof (prove)
using this:
n = 0
a \<le> b

goal (1 subgoal):
 1. \<exists>c. c \<in> {a..b} \<and> integral {c..b} f = integral {a..b} (\<lambda>x. \<Sum>k = 1..n. if real k / real n \<le> g x then f x /\<^sub>R real n else 0)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<exists>c. c \<in> {a..b} \<and> integral {c..b} f = integral {a..b} (\<lambda>x. \<Sum>k = 1..n. if real k / real n \<le> g x then f x /\<^sub>R real n else 0)

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> \<exists>c. c \<in> {a..b} \<and> integral {c..b} f = integral {a..b} (\<lambda>x. \<Sum>k = 1..n. if real k / real n \<le> g x then f x /\<^sub>R real n else 0)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> \<exists>c. c \<in> {a..b} \<and> integral {c..b} f = integral {a..b} (\<lambda>x. \<Sum>k = 1..n. if real k / real n \<le> g x then f x /\<^sub>R real n else 0)
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
n \<noteq> 0

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> \<exists>c. c \<in> {a..b} \<and> integral {c..b} f = integral {a..b} (\<lambda>x. \<Sum>k = 1..n. if real k / real n \<le> g x then f x /\<^sub>R real n else 0)
[PROOF STEP]
have "(\<Union>c::real. {\<lambda>x. if g x \<ge> c then f x else 0}) equiintegrable_on {a..b}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Union>c. {\<lambda>x. if c \<le> g x then f x else 0}) equiintegrable_on {a..b}
[PROOF STEP]
using SMVT_lemma2 [OF f g]
[PROOF STATE]
proof (prove)
using this:
(\<And>x y. x \<le> y \<Longrightarrow> ?y3 x \<le> ?y3 y) \<Longrightarrow> (\<Union>y. {\<lambda>x. if y \<le> g (?y3 x) then f x else 0}) equiintegrable_on {a..b}

goal (1 subgoal):
 1. (\<Union>c. {\<lambda>x. if c \<le> g x then f x else 0}) equiintegrable_on {a..b}
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
(\<Union>c. {\<lambda>x. if c \<le> g x then f x else 0}) equiintegrable_on {a..b}

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> \<exists>c. c \<in> {a..b} \<and> integral {c..b} f = integral {a..b} (\<lambda>x. \<Sum>k = 1..n. if real k / real n \<le> g x then f x /\<^sub>R real n else 0)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(\<Union>c. {\<lambda>x. if c \<le> g x then f x else 0}) equiintegrable_on {a..b}
[PROOF STEP]
have int: "(\<lambda>x. if g x \<ge> c then f x else 0) integrable_on {a..b}" for c
[PROOF STATE]
proof (prove)
using this:
(\<Union>c. {\<lambda>x. if c \<le> g x then f x else 0}) equiintegrable_on {a..b}

goal (1 subgoal):
 1. (\<lambda>x. if c \<le> g x then f x else 0) integrable_on {a..b}
[PROOF STEP]
by (simp add: equiintegrable_on_def)
[PROOF STATE]
proof (state)
this:
(\<lambda>x. if ?c \<le> g x then f x else 0) integrable_on {a..b}

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> \<exists>c. c \<in> {a..b} \<and> integral {c..b} f = integral {a..b} (\<lambda>x. \<Sum>k = 1..n. if real k / real n \<le> g x then f x /\<^sub>R real n else 0)
[PROOF STEP]
have int': "(\<lambda>x. if g x \<ge> c then u * f x else 0) integrable_on {a..b}" for c u
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. if c \<le> g x then u * f x else 0) integrable_on {a..b}
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<lambda>x. if c \<le> g x then u * f x else 0) integrable_on {a..b}
[PROOF STEP]
have "(\<lambda>x. if g x \<ge> c then u * f x else 0) = (\<lambda>x. u * (if g x \<ge> c then f x else 0))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. if c \<le> g x then u * f x else 0) = (\<lambda>x. u * (if c \<le> g x then f x else 0))
[PROOF STEP]
by (force simp: if_distrib)
[PROOF STATE]
proof (state)
this:
(\<lambda>x. if c \<le> g x then u * f x else 0) = (\<lambda>x. u * (if c \<le> g x then f x else 0))

goal (1 subgoal):
 1. (\<lambda>x. if c \<le> g x then u * f x else 0) integrable_on {a..b}
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(\<lambda>x. if c \<le> g x then u * f x else 0) = (\<lambda>x. u * (if c \<le> g x then f x else 0))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(\<lambda>x. if c \<le> g x then u * f x else 0) = (\<lambda>x. u * (if c \<le> g x then f x else 0))

goal (1 subgoal):
 1. (\<lambda>x. if c \<le> g x then u * f x else 0) integrable_on {a..b}
[PROOF STEP]
using integrable_on_cmult_left [OF int]
[PROOF STATE]
proof (prove)
using this:
(\<lambda>x. if c \<le> g x then u * f x else 0) = (\<lambda>x. u * (if c \<le> g x then f x else 0))
(\<lambda>x. of_real ?c * (if ?c1 \<le> g x then f x else 0)) integrable_on {a..b}

goal (1 subgoal):
 1. (\<lambda>x. if c \<le> g x then u * f x else 0) integrable_on {a..b}
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<lambda>x. if c \<le> g x then u * f x else 0) integrable_on {a..b}

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<lambda>x. if ?c \<le> g x then ?u * f x else 0) integrable_on {a..b}

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> \<exists>c. c \<in> {a..b} \<and> integral {c..b} f = integral {a..b} (\<lambda>x. \<Sum>k = 1..n. if real k / real n \<le> g x then f x /\<^sub>R real n else 0)
[PROOF STEP]
have "\<exists>d. d \<in> {a..b} \<and> integral {a..b} (\<lambda>x. if g x \<ge> y then f x else 0) = integral {d..b} f" for y
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>d. d \<in> {a..b} \<and> integral {a..b} (\<lambda>x. if y \<le> g x then f x else 0) = integral {d..b} f
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>d. d \<in> {a..b} \<and> integral {a..b} (\<lambda>x. if y \<le> g x then f x else 0) = integral {d..b} f
[PROOF STEP]
let ?X = "{x. g x \<ge> y}"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>d. d \<in> {a..b} \<and> integral {a..b} (\<lambda>x. if y \<le> g x then f x else 0) = integral {d..b} f
[PROOF STEP]
have *: "\<exists>a. ?X = {a..} \<or> ?X = {a<..}"
        if 1: "?X \<noteq> {}" and 2: "?X \<noteq> UNIV"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>a. {x. y \<le> g x} = {a..} \<or> {x. y \<le> g x} = {a<..}
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>a. {x. y \<le> g x} = {a..} \<or> {x. y \<le> g x} = {a<..}
[PROOF STEP]
let ?\<mu> = "Inf{x. g x \<ge> y}"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>a. {x. y \<le> g x} = {a..} \<or> {x. y \<le> g x} = {a<..}
[PROOF STEP]
have lower: "?\<mu> \<le> x" if "g x \<ge> y" for x
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Inf {x. y \<le> g x} \<le> x
[PROOF STEP]
proof (rule cInf_lower)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. x \<in> {x. y \<le> g x}
 2. bdd_below {x. y \<le> g x}
[PROOF STEP]
show "x \<in> {x. y \<le> g x}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<in> {x. y \<le> g x}
[PROOF STEP]
using 1 2
[PROOF STATE]
proof (prove)
using this:
{x. y \<le> g x} \<noteq> {}
{x. y \<le> g x} \<noteq> UNIV

goal (1 subgoal):
 1. x \<in> {x. y \<le> g x}
[PROOF STEP]
by (auto simp: that)
[PROOF STATE]
proof (state)
this:
x \<in> {x. y \<le> g x}

goal (1 subgoal):
 1. bdd_below {x. y \<le> g x}
[PROOF STEP]
show "bdd_below {x. y \<le> g x}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bdd_below {x. y \<le> g x}
[PROOF STEP]
unfolding bdd_below_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>M. Ball {x. y \<le> g x} ((\<le>) M)
[PROOF STEP]
by (metis "2" UNIV_eq_I dual_order.trans g less_eq_real_def mem_Collect_eq not_le)
[PROOF STATE]
proof (state)
this:
bdd_below {x. y \<le> g x}

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
y \<le> g ?x \<Longrightarrow> Inf {x. y \<le> g x} \<le> ?x

goal (1 subgoal):
 1. \<exists>a. {x. y \<le> g x} = {a..} \<or> {x. y \<le> g x} = {a<..}
[PROOF STEP]
have greatest: "?\<mu> \<ge> z" if "\<And>x. g x \<ge> y \<Longrightarrow> z \<le> x" for z
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. z \<le> Inf {x. y \<le> g x}
[PROOF STEP]
by (metis cInf_greatest mem_Collect_eq that 1)
[PROOF STATE]
proof (state)
this:
(\<And>x. y \<le> g x \<Longrightarrow> ?z \<le> x) \<Longrightarrow> ?z \<le> Inf {x. y \<le> g x}

goal (1 subgoal):
 1. \<exists>a. {x. y \<le> g x} = {a..} \<or> {x. y \<le> g x} = {a<..}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>a. {x. y \<le> g x} = {a..} \<or> {x. y \<le> g x} = {a<..}
[PROOF STEP]
proof (cases "g ?\<mu> \<ge> y")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. y \<le> g (Inf {x. y \<le> g x}) \<Longrightarrow> \<exists>a. {x. y \<le> g x} = {a..} \<or> {x. y \<le> g x} = {a<..}
 2. \<not> y \<le> g (Inf {x. y \<le> g x}) \<Longrightarrow> \<exists>a. {x. y \<le> g x} = {a..} \<or> {x. y \<le> g x} = {a<..}
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
y \<le> g (Inf {x. y \<le> g x})

goal (2 subgoals):
 1. y \<le> g (Inf {x. y \<le> g x}) \<Longrightarrow> \<exists>a. {x. y \<le> g x} = {a..} \<or> {x. y \<le> g x} = {a<..}
 2. \<not> y \<le> g (Inf {x. y \<le> g x}) \<Longrightarrow> \<exists>a. {x. y \<le> g x} = {a..} \<or> {x. y \<le> g x} = {a<..}
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
y \<le> g (Inf {x. y \<le> g x})
[PROOF STEP]
obtain \<zeta> where \<zeta>: "\<And>x. g x \<ge> y \<longleftrightarrow> x \<ge> \<zeta>"
[PROOF STATE]
proof (prove)
using this:
y \<le> g (Inf {x. y \<le> g x})

goal (1 subgoal):
 1. (\<And>\<zeta>. (\<And>x. (y \<le> g x) = (\<zeta> \<le> x)) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (metis g lower order.trans)  \<comment> \<open>in fact y is @{term ?\<mu>}\<close>
[PROOF STATE]
proof (state)
this:
(y \<le> g ?x) = (\<zeta> \<le> ?x)

goal (2 subgoals):
 1. y \<le> g (Inf {x. y \<le> g x}) \<Longrightarrow> \<exists>a. {x. y \<le> g x} = {a..} \<or> {x. y \<le> g x} = {a<..}
 2. \<not> y \<le> g (Inf {x. y \<le> g x}) \<Longrightarrow> \<exists>a. {x. y \<le> g x} = {a..} \<or> {x. y \<le> g x} = {a<..}
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(y \<le> g ?x) = (\<zeta> \<le> ?x)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(y \<le> g ?x) = (\<zeta> \<le> ?x)

goal (1 subgoal):
 1. \<exists>a. {x. y \<le> g x} = {a..} \<or> {x. y \<le> g x} = {a<..}
[PROOF STEP]
by (force simp: \<zeta>)
[PROOF STATE]
proof (state)
this:
\<exists>a. {x. y \<le> g x} = {a..} \<or> {x. y \<le> g x} = {a<..}

goal (1 subgoal):
 1. \<not> y \<le> g (Inf {x. y \<le> g x}) \<Longrightarrow> \<exists>a. {x. y \<le> g x} = {a..} \<or> {x. y \<le> g x} = {a<..}
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> y \<le> g (Inf {x. y \<le> g x}) \<Longrightarrow> \<exists>a. {x. y \<le> g x} = {a..} \<or> {x. y \<le> g x} = {a<..}
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> y \<le> g (Inf {x. y \<le> g x})

goal (1 subgoal):
 1. \<not> y \<le> g (Inf {x. y \<le> g x}) \<Longrightarrow> \<exists>a. {x. y \<le> g x} = {a..} \<or> {x. y \<le> g x} = {a<..}
[PROOF STEP]
have "(y \<le> g x) = (?\<mu> < x)" for x
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (y \<le> g x) = (Inf {x. y \<le> g x} < x)
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. y \<le> g x \<Longrightarrow> Inf {x. y \<le> g x} < x
 2. Inf {x. y \<le> g x} < x \<Longrightarrow> y \<le> g x
[PROOF STEP]
show "?\<mu> < x" if "y \<le> g x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Inf {x. y \<le> g x} < x
[PROOF STEP]
using that False less_eq_real_def lower
[PROOF STATE]
proof (prove)
using this:
y \<le> g x
\<not> y \<le> g (Inf {x. y \<le> g x})
(?x \<le> ?y) = (?x < ?y \<or> ?x = ?y)
y \<le> g ?x \<Longrightarrow> Inf {x. y \<le> g x} \<le> ?x

goal (1 subgoal):
 1. Inf {x. y \<le> g x} < x
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
y \<le> g x \<Longrightarrow> Inf {x. y \<le> g x} < x

goal (1 subgoal):
 1. Inf {x. y \<le> g x} < x \<Longrightarrow> y \<le> g x
[PROOF STEP]
show "y \<le> g x" if "?\<mu> < x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. y \<le> g x
[PROOF STEP]
by (metis g greatest le_less_trans that less_le_trans linear not_less)
[PROOF STATE]
proof (state)
this:
Inf {x. y \<le> g x} < x \<Longrightarrow> y \<le> g x

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(y \<le> g ?x) = (Inf {x. y \<le> g x} < ?x)

goal (1 subgoal):
 1. \<not> y \<le> g (Inf {x. y \<le> g x}) \<Longrightarrow> \<exists>a. {x. y \<le> g x} = {a..} \<or> {x. y \<le> g x} = {a<..}
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(y \<le> g ?x) = (Inf {x. y \<le> g x} < ?x)
[PROOF STEP]
obtain \<zeta> where \<zeta>: "\<And>x. g x \<ge> y \<longleftrightarrow> x > \<zeta>"
[PROOF STATE]
proof (prove)
using this:
(y \<le> g ?x) = (Inf {x. y \<le> g x} < ?x)

goal (1 subgoal):
 1. (\<And>\<zeta>. (\<And>x. (y \<le> g x) = (\<zeta> < x)) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
(y \<le> g ?x) = (\<zeta> < ?x)

goal (1 subgoal):
 1. \<not> y \<le> g (Inf {x. y \<le> g x}) \<Longrightarrow> \<exists>a. {x. y \<le> g x} = {a..} \<or> {x. y \<le> g x} = {a<..}
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(y \<le> g ?x) = (\<zeta> < ?x)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(y \<le> g ?x) = (\<zeta> < ?x)

goal (1 subgoal):
 1. \<exists>a. {x. y \<le> g x} = {a..} \<or> {x. y \<le> g x} = {a<..}
[PROOF STEP]
by (force simp: \<zeta>)
[PROOF STATE]
proof (state)
this:
\<exists>a. {x. y \<le> g x} = {a..} \<or> {x. y \<le> g x} = {a<..}

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<exists>a. {x. y \<le> g x} = {a..} \<or> {x. y \<le> g x} = {a<..}

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<lbrakk>{x. y \<le> g x} \<noteq> {}; {x. y \<le> g x} \<noteq> UNIV\<rbrakk> \<Longrightarrow> \<exists>a. {x. y \<le> g x} = {a..} \<or> {x. y \<le> g x} = {a<..}

goal (1 subgoal):
 1. \<exists>d. d \<in> {a..b} \<and> integral {a..b} (\<lambda>x. if y \<le> g x then f x else 0) = integral {d..b} f
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>{x. y \<le> g x} \<noteq> {}; {x. y \<le> g x} \<noteq> UNIV\<rbrakk> \<Longrightarrow> \<exists>a. {x. y \<le> g x} = {a..} \<or> {x. y \<le> g x} = {a<..}
[PROOF STEP]
consider "?X = {}" | "?X = UNIV" | (intv) d where "?X = {d..} \<or> ?X = {d<..}"
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>{x. y \<le> g x} \<noteq> {}; {x. y \<le> g x} \<noteq> UNIV\<rbrakk> \<Longrightarrow> \<exists>a. {x. y \<le> g x} = {a..} \<or> {x. y \<le> g x} = {a<..}

goal (1 subgoal):
 1. \<lbrakk>{x. y \<le> g x} = {} \<Longrightarrow> thesis; {x. y \<le> g x} = UNIV \<Longrightarrow> thesis; \<And>d. {x. y \<le> g x} = {d..} \<or> {x. y \<le> g x} = {d<..} \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
\<lbrakk>{x. y \<le> g x} = {} \<Longrightarrow> ?thesis; {x. y \<le> g x} = UNIV \<Longrightarrow> ?thesis; \<And>d. {x. y \<le> g x} = {d..} \<or> {x. y \<le> g x} = {d<..} \<Longrightarrow> ?thesis\<rbrakk> \<Longrightarrow> ?thesis

goal (1 subgoal):
 1. \<exists>d. d \<in> {a..b} \<and> integral {a..b} (\<lambda>x. if y \<le> g x then f x else 0) = integral {d..b} f
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>{x. y \<le> g x} = {} \<Longrightarrow> ?thesis; {x. y \<le> g x} = UNIV \<Longrightarrow> ?thesis; \<And>d. {x. y \<le> g x} = {d..} \<or> {x. y \<le> g x} = {d<..} \<Longrightarrow> ?thesis\<rbrakk> \<Longrightarrow> ?thesis
[PROOF STEP]
have "\<exists>d. d \<in> {a..b} \<and> integral {a..b} (\<lambda>x. if x \<in> ?X then f x else 0) = integral {d..b} f"
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>{x. y \<le> g x} = {} \<Longrightarrow> ?thesis; {x. y \<le> g x} = UNIV \<Longrightarrow> ?thesis; \<And>d. {x. y \<le> g x} = {d..} \<or> {x. y \<le> g x} = {d<..} \<Longrightarrow> ?thesis\<rbrakk> \<Longrightarrow> ?thesis

goal (1 subgoal):
 1. \<exists>d. d \<in> {a..b} \<and> integral {a..b} (\<lambda>x. if x \<in> {x. y \<le> g x} then f x else 0) = integral {d..b} f
[PROOF STEP]
proof cases
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. {x. y \<le> g x} = {} \<Longrightarrow> \<exists>d. d \<in> {a..b} \<and> integral {a..b} (\<lambda>x. if x \<in> {x. y \<le> g x} then f x else 0) = integral {d..b} f
 2. {x. y \<le> g x} = UNIV \<Longrightarrow> \<exists>d. d \<in> {a..b} \<and> integral {a..b} (\<lambda>x. if x \<in> {x. y \<le> g x} then f x else 0) = integral {d..b} f
 3. \<And>d. {x. y \<le> g x} = {d..} \<or> {x. y \<le> g x} = {d<..} \<Longrightarrow> \<exists>d. d \<in> {a..b} \<and> integral {a..b} (\<lambda>x. if x \<in> {x. y \<le> g x} then f x else 0) = integral {d..b} f
[PROOF STEP]
case (intv d)
[PROOF STATE]
proof (state)
this:
{x. y \<le> g x} = {d..} \<or> {x. y \<le> g x} = {d<..}

goal (3 subgoals):
 1. {x. y \<le> g x} = {} \<Longrightarrow> \<exists>d. d \<in> {a..b} \<and> integral {a..b} (\<lambda>x. if x \<in> {x. y \<le> g x} then f x else 0) = integral {d..b} f
 2. {x. y \<le> g x} = UNIV \<Longrightarrow> \<exists>d. d \<in> {a..b} \<and> integral {a..b} (\<lambda>x. if x \<in> {x. y \<le> g x} then f x else 0) = integral {d..b} f
 3. \<And>d. {x. y \<le> g x} = {d..} \<or> {x. y \<le> g x} = {d<..} \<Longrightarrow> \<exists>d. d \<in> {a..b} \<and> integral {a..b} (\<lambda>x. if x \<in> {x. y \<le> g x} then f x else 0) = integral {d..b} f
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>d. d \<in> {a..b} \<and> integral {a..b} (\<lambda>x. if x \<in> {x. y \<le> g x} then f x else 0) = integral {d..b} f
[PROOF STEP]
proof (cases "d < a")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. d < a \<Longrightarrow> \<exists>d. d \<in> {a..b} \<and> integral {a..b} (\<lambda>x. if x \<in> {x. y \<le> g x} then f x else 0) = integral {d..b} f
 2. \<not> d < a \<Longrightarrow> \<exists>d. d \<in> {a..b} \<and> integral {a..b} (\<lambda>x. if x \<in> {x. y \<le> g x} then f x else 0) = integral {d..b} f
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
d < a

goal (2 subgoals):
 1. d < a \<Longrightarrow> \<exists>d. d \<in> {a..b} \<and> integral {a..b} (\<lambda>x. if x \<in> {x. y \<le> g x} then f x else 0) = integral {d..b} f
 2. \<not> d < a \<Longrightarrow> \<exists>d. d \<in> {a..b} \<and> integral {a..b} (\<lambda>x. if x \<in> {x. y \<le> g x} then f x else 0) = integral {d..b} f
[PROOF STEP]
with intv
[PROOF STATE]
proof (chain)
picking this:
{x. y \<le> g x} = {d..} \<or> {x. y \<le> g x} = {d<..}
d < a
[PROOF STEP]
have "integral {a..b} (\<lambda>x. if y \<le> g x then f x else 0) = integral {a..b} f"
[PROOF STATE]
proof (prove)
using this:
{x. y \<le> g x} = {d..} \<or> {x. y \<le> g x} = {d<..}
d < a

goal (1 subgoal):
 1. integral {a..b} (\<lambda>x. if y \<le> g x then f x else 0) = integral {a..b} f
[PROOF STEP]
by (intro Henstock_Kurzweil_Integration.integral_cong) force
[PROOF STATE]
proof (state)
this:
integral {a..b} (\<lambda>x. if y \<le> g x then f x else 0) = integral {a..b} f

goal (2 subgoals):
 1. d < a \<Longrightarrow> \<exists>d. d \<in> {a..b} \<and> integral {a..b} (\<lambda>x. if x \<in> {x. y \<le> g x} then f x else 0) = integral {d..b} f
 2. \<not> d < a \<Longrightarrow> \<exists>d. d \<in> {a..b} \<and> integral {a..b} (\<lambda>x. if x \<in> {x. y \<le> g x} then f x else 0) = integral {d..b} f
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
integral {a..b} (\<lambda>x. if y \<le> g x then f x else 0) = integral {a..b} f
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
integral {a..b} (\<lambda>x. if y \<le> g x then f x else 0) = integral {a..b} f

goal (1 subgoal):
 1. \<exists>d. d \<in> {a..b} \<and> integral {a..b} (\<lambda>x. if x \<in> {x. y \<le> g x} then f x else 0) = integral {d..b} f
[PROOF STEP]
by (rule_tac x=a in exI) (simp add: \<open>a \<le> b\<close>)
[PROOF STATE]
proof (state)
this:
\<exists>d. d \<in> {a..b} \<and> integral {a..b} (\<lambda>x. if x \<in> {x. y \<le> g x} then f x else 0) = integral {d..b} f

goal (1 subgoal):
 1. \<not> d < a \<Longrightarrow> \<exists>d. d \<in> {a..b} \<and> integral {a..b} (\<lambda>x. if x \<in> {x. y \<le> g x} then f x else 0) = integral {d..b} f
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> d < a \<Longrightarrow> \<exists>d. d \<in> {a..b} \<and> integral {a..b} (\<lambda>x. if x \<in> {x. y \<le> g x} then f x else 0) = integral {d..b} f
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> d < a

goal (1 subgoal):
 1. \<not> d < a \<Longrightarrow> \<exists>d. d \<in> {a..b} \<and> integral {a..b} (\<lambda>x. if x \<in> {x. y \<le> g x} then f x else 0) = integral {d..b} f
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>d. d \<in> {a..b} \<and> integral {a..b} (\<lambda>x. if x \<in> {x. y \<le> g x} then f x else 0) = integral {d..b} f
[PROOF STEP]
proof (cases "b < d")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. b < d \<Longrightarrow> \<exists>d. d \<in> {a..b} \<and> integral {a..b} (\<lambda>x. if x \<in> {x. y \<le> g x} then f x else 0) = integral {d..b} f
 2. \<not> b < d \<Longrightarrow> \<exists>d. d \<in> {a..b} \<and> integral {a..b} (\<lambda>x. if x \<in> {x. y \<le> g x} then f x else 0) = integral {d..b} f
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
b < d

goal (2 subgoals):
 1. b < d \<Longrightarrow> \<exists>d. d \<in> {a..b} \<and> integral {a..b} (\<lambda>x. if x \<in> {x. y \<le> g x} then f x else 0) = integral {d..b} f
 2. \<not> b < d \<Longrightarrow> \<exists>d. d \<in> {a..b} \<and> integral {a..b} (\<lambda>x. if x \<in> {x. y \<le> g x} then f x else 0) = integral {d..b} f
[PROOF STEP]
have "integral {a..b} (\<lambda>x. if x \<in> {x. y \<le> g x} then f x else 0) = integral {a..b} (\<lambda>x. 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. integral {a..b} (\<lambda>x. if x \<in> {x. y \<le> g x} then f x else 0) = integral {a..b} (\<lambda>x. 0)
[PROOF STEP]
by (rule Henstock_Kurzweil_Integration.integral_cong) (use intv True in fastforce)
[PROOF STATE]
proof (state)
this:
integral {a..b} (\<lambda>x. if x \<in> {x. y \<le> g x} then f x else 0) = integral {a..b} (\<lambda>x. 0)

goal (2 subgoals):
 1. b < d \<Longrightarrow> \<exists>d. d \<in> {a..b} \<and> integral {a..b} (\<lambda>x. if x \<in> {x. y \<le> g x} then f x else 0) = integral {d..b} f
 2. \<not> b < d \<Longrightarrow> \<exists>d. d \<in> {a..b} \<and> integral {a..b} (\<lambda>x. if x \<in> {x. y \<le> g x} then f x else 0) = integral {d..b} f
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
integral {a..b} (\<lambda>x. if x \<in> {x. y \<le> g x} then f x else 0) = integral {a..b} (\<lambda>x. 0)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
integral {a..b} (\<lambda>x. if x \<in> {x. y \<le> g x} then f x else 0) = integral {a..b} (\<lambda>x. 0)

goal (1 subgoal):
 1. \<exists>d. d \<in> {a..b} \<and> integral {a..b} (\<lambda>x. if x \<in> {x. y \<le> g x} then f x else 0) = integral {d..b} f
[PROOF STEP]
using \<open>a \<le> b\<close>
[PROOF STATE]
proof (prove)
using this:
integral {a..b} (\<lambda>x. if x \<in> {x. y \<le> g x} then f x else 0) = integral {a..b} (\<lambda>x. 0)
a \<le> b

goal (1 subgoal):
 1. \<exists>d. d \<in> {a..b} \<and> integral {a..b} (\<lambda>x. if x \<in> {x. y \<le> g x} then f x else 0) = integral {d..b} f
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<exists>d. d \<in> {a..b} \<and> integral {a..b} (\<lambda>x. if x \<in> {x. y \<le> g x} then f x else 0) = integral {d..b} f

goal (1 subgoal):
 1. \<not> b < d \<Longrightarrow> \<exists>d. d \<in> {a..b} \<and> integral {a..b} (\<lambda>x. if x \<in> {x. y \<le> g x} then f x else 0) = integral {d..b} f
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> b < d \<Longrightarrow> \<exists>d. d \<in> {a..b} \<and> integral {a..b} (\<lambda>x. if x \<in> {x. y \<le> g x} then f x else 0) = integral {d..b} f
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> b < d

goal (1 subgoal):
 1. \<not> b < d \<Longrightarrow> \<exists>d. d \<in> {a..b} \<and> integral {a..b} (\<lambda>x. if x \<in> {x. y \<le> g x} then f x else 0) = integral {d..b} f
[PROOF STEP]
with \<open>\<not> d < a\<close>
[PROOF STATE]
proof (chain)
picking this:
\<not> d < a
\<not> b < d
[PROOF STEP]
have eq: "{d..} \<inter> {a..b} = {d..b}" "{d<..} \<inter> {a..b} = {d<..b}"
[PROOF STATE]
proof (prove)
using this:
\<not> d < a
\<not> b < d

goal (1 subgoal):
 1. {d..} \<inter> {a..b} = {d..b} &&& {d<..} \<inter> {a..b} = {d<..b}
[PROOF STEP]
by force+
[PROOF STATE]
proof (state)
this:
{d..} \<inter> {a..b} = {d..b}
{d<..} \<inter> {a..b} = {d<..b}

goal (1 subgoal):
 1. \<not> b < d \<Longrightarrow> \<exists>d. d \<in> {a..b} \<and> integral {a..b} (\<lambda>x. if x \<in> {x. y \<le> g x} then f x else 0) = integral {d..b} f
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
{d..} \<inter> {a..b} = {d..b}
{d<..} \<inter> {a..b} = {d<..b}

goal (1 subgoal):
 1. \<not> b < d \<Longrightarrow> \<exists>d. d \<in> {a..b} \<and> integral {a..b} (\<lambda>x. if x \<in> {x. y \<le> g x} then f x else 0) = integral {d..b} f
[PROOF STEP]
have "integral {d<..b} f = integral {d..b} f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. integral {d<..b} f = integral {d..b} f
[PROOF STEP]
by (rule integral_spike_set [OF empty_imp_negligible negligible_subset [OF negligible_sing [of d]]]) auto
[PROOF STATE]
proof (state)
this:
integral {d<..b} f = integral {d..b} f

goal (1 subgoal):
 1. \<not> b < d \<Longrightarrow> \<exists>d. d \<in> {a..b} \<and> integral {a..b} (\<lambda>x. if x \<in> {x. y \<le> g x} then f x else 0) = integral {d..b} f
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
{d..} \<inter> {a..b} = {d..b}
{d<..} \<inter> {a..b} = {d<..b}
integral {d<..b} f = integral {d..b} f
[PROOF STEP]
have "integral {a..b} (\<lambda>x. if x \<in> {x. y \<le> g x} then f x else 0) =  integral {d..b} f"
[PROOF STATE]
proof (prove)
using this:
{d..} \<inter> {a..b} = {d..b}
{d<..} \<inter> {a..b} = {d<..b}
integral {d<..b} f = integral {d..b} f

goal (1 subgoal):
 1. integral {a..b} (\<lambda>x. if x \<in> {x. y \<le> g x} then f x else 0) = integral {d..b} f
[PROOF STEP]
unfolding integral_restrict_Int
[PROOF STATE]
proof (prove)
using this:
{d..} \<inter> {a..b} = {d..b}
{d<..} \<inter> {a..b} = {d<..b}
integral {d<..b} f = integral {d..b} f

goal (1 subgoal):
 1. integral ({x. y \<le> g x} \<inter> {a..b}) f = integral {d..b} f
[PROOF STEP]
using intv
[PROOF STATE]
proof (prove)
using this:
{d..} \<inter> {a..b} = {d..b}
{d<..} \<inter> {a..b} = {d<..b}
integral {d<..b} f = integral {d..b} f
{x. y \<le> g x} = {d..} \<or> {x. y \<le> g x} = {d<..}

goal (1 subgoal):
 1. integral ({x. y \<le> g x} \<inter> {a..b}) f = integral {d..b} f
[PROOF STEP]
by presburger
[PROOF STATE]
proof (state)
this:
integral {a..b} (\<lambda>x. if x \<in> {x. y \<le> g x} then f x else 0) = integral {d..b} f

goal (1 subgoal):
 1. \<not> b < d \<Longrightarrow> \<exists>d. d \<in> {a..b} \<and> integral {a..b} (\<lambda>x. if x \<in> {x. y \<le> g x} then f x else 0) = integral {d..b} f
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
integral {a..b} (\<lambda>x. if x \<in> {x. y \<le> g x} then f x else 0) = integral {d..b} f

goal (1 subgoal):
 1. \<not> b < d \<Longrightarrow> \<exists>d. d \<in> {a..b} \<and> integral {a..b} (\<lambda>x. if x \<in> {x. y \<le> g x} then f x else 0) = integral {d..b} f
[PROOF STEP]
have "d \<in> {a..b}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. d \<in> {a..b}
[PROOF STEP]
using \<open>\<not> d < a\<close> \<open>a \<le> b\<close> False
[PROOF STATE]
proof (prove)
using this:
\<not> d < a
a \<le> b
\<not> b < d

goal (1 subgoal):
 1. d \<in> {a..b}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
d \<in> {a..b}

goal (1 subgoal):
 1. \<not> b < d \<Longrightarrow> \<exists>d. d \<in> {a..b} \<and> integral {a..b} (\<lambda>x. if x \<in> {x. y \<le> g x} then f x else 0) = integral {d..b} f
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
integral {a..b} (\<lambda>x. if x \<in> {x. y \<le> g x} then f x else 0) = integral {d..b} f
d \<in> {a..b}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
integral {a..b} (\<lambda>x. if x \<in> {x. y \<le> g x} then f x else 0) = integral {d..b} f
d \<in> {a..b}

goal (1 subgoal):
 1. \<exists>d. d \<in> {a..b} \<and> integral {a..b} (\<lambda>x. if x \<in> {x. y \<le> g x} then f x else 0) = integral {d..b} f
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<exists>d. d \<in> {a..b} \<and> integral {a..b} (\<lambda>x. if x \<in> {x. y \<le> g x} then f x else 0) = integral {d..b} f

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<exists>d. d \<in> {a..b} \<and> integral {a..b} (\<lambda>x. if x \<in> {x. y \<le> g x} then f x else 0) = integral {d..b} f

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<exists>d. d \<in> {a..b} \<and> integral {a..b} (\<lambda>x. if x \<in> {x. y \<le> g x} then f x else 0) = integral {d..b} f

goal (2 subgoals):
 1. {x. y \<le> g x} = {} \<Longrightarrow> \<exists>d. d \<in> {a..b} \<and> integral {a..b} (\<lambda>x. if x \<in> {x. y \<le> g x} then f x else 0) = integral {d..b} f
 2. {x. y \<le> g x} = UNIV \<Longrightarrow> \<exists>d. d \<in> {a..b} \<and> integral {a..b} (\<lambda>x. if x \<in> {x. y \<le> g x} then f x else 0) = integral {d..b} f
[PROOF STEP]
qed (use \<open>a \<le> b\<close> in auto)
[PROOF STATE]
proof (state)
this:
\<exists>d. d \<in> {a..b} \<and> integral {a..b} (\<lambda>x. if x \<in> {x. y \<le> g x} then f x else 0) = integral {d..b} f

goal (1 subgoal):
 1. \<exists>d. d \<in> {a..b} \<and> integral {a..b} (\<lambda>x. if y \<le> g x then f x else 0) = integral {d..b} f
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<exists>d. d \<in> {a..b} \<and> integral {a..b} (\<lambda>x. if x \<in> {x. y \<le> g x} then f x else 0) = integral {d..b} f
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<exists>d. d \<in> {a..b} \<and> integral {a..b} (\<lambda>x. if x \<in> {x. y \<le> g x} then f x else 0) = integral {d..b} f

goal (1 subgoal):
 1. \<exists>d. d \<in> {a..b} \<and> integral {a..b} (\<lambda>x. if y \<le> g x then f x else 0) = integral {d..b} f
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<exists>d. d \<in> {a..b} \<and> integral {a..b} (\<lambda>x. if y \<le> g x then f x else 0) = integral {d..b} f

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<exists>d. d \<in> {a..b} \<and> integral {a..b} (\<lambda>x. if ?y \<le> g x then f x else 0) = integral {d..b} f

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> \<exists>c. c \<in> {a..b} \<and> integral {c..b} f = integral {a..b} (\<lambda>x. \<Sum>k = 1..n. if real k / real n \<le> g x then f x /\<^sub>R real n else 0)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<exists>d. d \<in> {a..b} \<and> integral {a..b} (\<lambda>x. if ?y \<le> g x then f x else 0) = integral {d..b} f
[PROOF STEP]
have "\<forall>k. \<exists>d. d \<in> {a..b} \<and> integral {a..b} (\<lambda>x. if real k / real n \<le> g x then f x else 0) = integral {d..b} f"
[PROOF STATE]
proof (prove)
using this:
\<exists>d. d \<in> {a..b} \<and> integral {a..b} (\<lambda>x. if ?y \<le> g x then f x else 0) = integral {d..b} f

goal (1 subgoal):
 1. \<forall>k. \<exists>d. d \<in> {a..b} \<and> integral {a..b} (\<lambda>x. if real k / real n \<le> g x then f x else 0) = integral {d..b} f
[PROOF STEP]
by meson
[PROOF STATE]
proof (state)
this:
\<forall>k. \<exists>d. d \<in> {a..b} \<and> integral {a..b} (\<lambda>x. if real k / real n \<le> g x then f x else 0) = integral {d..b} f

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> \<exists>c. c \<in> {a..b} \<and> integral {c..b} f = integral {a..b} (\<lambda>x. \<Sum>k = 1..n. if real k / real n \<le> g x then f x /\<^sub>R real n else 0)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<forall>k. \<exists>d. d \<in> {a..b} \<and> integral {a..b} (\<lambda>x. if real k / real n \<le> g x then f x else 0) = integral {d..b} f
[PROOF STEP]
obtain d where dab: "\<And>k. d k \<in> {a..b}"
      and deq: "\<And>k::nat. integral {a..b} (\<lambda>x. if k/n \<le> g x then f x else 0) = integral {d k..b} f"
[PROOF STATE]
proof (prove)
using this:
\<forall>k. \<exists>d. d \<in> {a..b} \<and> integral {a..b} (\<lambda>x. if real k / real n \<le> g x then f x else 0) = integral {d..b} f

goal (1 subgoal):
 1. (\<And>d. \<lbrakk>\<And>k. d k \<in> {a..b}; \<And>k. integral {a..b} (\<lambda>x. if real k / real n \<le> g x then f x else 0) = integral {d k..b} f\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
d ?k \<in> {a..b}
integral {a..b} (\<lambda>x. if real ?k / real n \<le> g x then f x else 0) = integral {d ?k..b} f

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> \<exists>c. c \<in> {a..b} \<and> integral {c..b} f = integral {a..b} (\<lambda>x. \<Sum>k = 1..n. if real k / real n \<le> g x then f x /\<^sub>R real n else 0)
[PROOF STEP]
have "(\<Sum>k = 1..n. integral {a..b} (\<lambda>x. if real k / real n \<le> g x then f x else 0)) /\<^sub>R n \<in> {m..M}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>k = 1..n. integral {a..b} (\<lambda>x. if real k / real n \<le> g x then f x else 0)) /\<^sub>R real n \<in> {m..M}
[PROOF STEP]
unfolding scaleR_right.sum
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>x = 1..n. integral {a..b} (\<lambda>xa. if real x / real n \<le> g xa then f xa else 0) /\<^sub>R real n) \<in> {m..M}
[PROOF STEP]
proof (intro conjI allI impI convex [THEN iffD1, rule_format])
[PROOF STATE]
proof (state)
goal (4 subgoals):
 1. convex {m..M}
 2. \<And>x. 1 \<le> x \<and> x \<le> n \<Longrightarrow> 0 \<le> inverse (real n)
 3. \<And>x. 1 \<le> x \<and> x \<le> n \<Longrightarrow> integral {a..b} (\<lambda>xa. if real x / real n \<le> g xa then f xa else 0) \<in> {m..M}
 4. (\<Sum>i = 1..n. inverse (real n)) = 1
[PROOF STEP]
show "integral {a..b} (\<lambda>xa. if real k / real n \<le> g xa then f xa else 0) \<in> {m..M}" for k
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. integral {a..b} (\<lambda>xa. if real k / real n \<le> g xa then f xa else 0) \<in> {m..M}
[PROOF STEP]
by (metis (no_types, lifting) deq image_eqI int_fab dab)
[PROOF STATE]
proof (state)
this:
integral {a..b} (\<lambda>xa. if real ?k / real n \<le> g xa then f xa else 0) \<in> {m..M}

goal (3 subgoals):
 1. convex {m..M}
 2. \<And>x. 1 \<le> x \<and> x \<le> n \<Longrightarrow> 0 \<le> inverse (real n)
 3. (\<Sum>i = 1..n. inverse (real n)) = 1
[PROOF STEP]
qed (use \<open>n \<noteq> 0\<close> in auto)
[PROOF STATE]
proof (state)
this:
(\<Sum>k = 1..n. integral {a..b} (\<lambda>x. if real k / real n \<le> g x then f x else 0)) /\<^sub>R real n \<in> {m..M}

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> \<exists>c. c \<in> {a..b} \<and> integral {c..b} f = integral {a..b} (\<lambda>x. \<Sum>k = 1..n. if real k / real n \<le> g x then f x /\<^sub>R real n else 0)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(\<Sum>k = 1..n. integral {a..b} (\<lambda>x. if real k / real n \<le> g x then f x else 0)) /\<^sub>R real n \<in> {m..M}
[PROOF STEP]
have "\<exists>c. c \<in> {a..b} \<and>
              integral {c..b} f = inverse n *\<^sub>R (\<Sum>k = 1..n. integral {a..b} (\<lambda>x. if g x \<ge> real k / real n then f x else 0))"
[PROOF STATE]
proof (prove)
using this:
(\<Sum>k = 1..n. integral {a..b} (\<lambda>x. if real k / real n \<le> g x then f x else 0)) /\<^sub>R real n \<in> {m..M}

goal (1 subgoal):
 1. \<exists>c. c \<in> {a..b} \<and> integral {c..b} f = (\<Sum>k = 1..n. integral {a..b} (\<lambda>x. if real k / real n \<le> g x then f x else 0)) /\<^sub>R real n
[PROOF STEP]
by (metis (no_types, lifting) int_fab imageE)
[PROOF STATE]
proof (state)
this:
\<exists>c. c \<in> {a..b} \<and> integral {c..b} f = (\<Sum>k = 1..n. integral {a..b} (\<lambda>x. if real k / real n \<le> g x then f x else 0)) /\<^sub>R real n

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> \<exists>c. c \<in> {a..b} \<and> integral {c..b} f = integral {a..b} (\<lambda>x. \<Sum>k = 1..n. if real k / real n \<le> g x then f x /\<^sub>R real n else 0)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<exists>c. c \<in> {a..b} \<and> integral {c..b} f = (\<Sum>k = 1..n. integral {a..b} (\<lambda>x. if real k / real n \<le> g x then f x else 0)) /\<^sub>R real n
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<exists>c. c \<in> {a..b} \<and> integral {c..b} f = (\<Sum>k = 1..n. integral {a..b} (\<lambda>x. if real k / real n \<le> g x then f x else 0)) /\<^sub>R real n

goal (1 subgoal):
 1. \<exists>c. c \<in> {a..b} \<and> integral {c..b} f = integral {a..b} (\<lambda>x. \<Sum>k = 1..n. if real k / real n \<le> g x then f x /\<^sub>R real n else 0)
[PROOF STEP]
by (simp add: sum_distrib_left if_distrib integral_sum int' flip: integral_mult_right cong: if_cong)
[PROOF STATE]
proof (state)
this:
\<exists>c. c \<in> {a..b} \<and> integral {c..b} f = integral {a..b} (\<lambda>x. \<Sum>k = 1..n. if real k / real n \<le> g x then f x /\<^sub>R real n else 0)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<exists>c. c \<in> {a..b} \<and> integral {c..b} f = integral {a..b} (\<lambda>x. \<Sum>k = 1..?n. if real k / real ?n \<le> g x then f x /\<^sub>R real ?n else 0)

goal (1 subgoal):
 1. (\<And>c. \<lbrakk>a \<le> c; c \<le> b; ((\<lambda>x. g x *\<^sub>R f x) has_integral integral {c..b} f) {a..b}\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<exists>c. c \<in> {a..b} \<and> integral {c..b} f = integral {a..b} (\<lambda>x. \<Sum>k = 1..?n. if real k / real ?n \<le> g x then f x /\<^sub>R real ?n else 0)
[PROOF STEP]
obtain c where cab: "\<And>n. c n \<in> {a..b}"
    and c: "\<And>n. integral {c n..b} f = integral {a..b} (\<lambda>x. (\<Sum>k = 1..n. if g x \<ge> real k / real n then f x /\<^sub>R n else 0))"
[PROOF STATE]
proof (prove)
using this:
\<exists>c. c \<in> {a..b} \<and> integral {c..b} f = integral {a..b} (\<lambda>x. \<Sum>k = 1..?n. if real k / real ?n \<le> g x then f x /\<^sub>R real ?n else 0)

goal (1 subgoal):
 1. (\<And>c. \<lbrakk>\<And>n. c n \<in> {a..b}; \<And>n. integral {c n..b} f = integral {a..b} (\<lambda>x. \<Sum>k = 1..n. if real k / real n \<le> g x then f x /\<^sub>R real n else 0)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
c ?n \<in> {a..b}
integral {c ?n..b} f = integral {a..b} (\<lambda>x. \<Sum>k = 1..?n. if real k / real ?n \<le> g x then f x /\<^sub>R real ?n else 0)

goal (1 subgoal):
 1. (\<And>c. \<lbrakk>a \<le> c; c \<le> b; ((\<lambda>x. g x *\<^sub>R f x) has_integral integral {c..b} f) {a..b}\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
obtain d and \<sigma> :: "nat\<Rightarrow>nat"
    where "d \<in> {a..b}" and \<sigma>: "strict_mono \<sigma>" and d: "(c \<circ> \<sigma>) \<longlonglongrightarrow> d" and non0: "\<And>n. \<sigma> n \<ge> Suc 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>d \<sigma>. \<lbrakk>d \<in> {a..b}; strict_mono \<sigma>; (c \<circ> \<sigma>) \<longlonglongrightarrow> d; \<And>n. Suc 0 \<le> \<sigma> n\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<And>d \<sigma>. \<lbrakk>d \<in> {a..b}; strict_mono \<sigma>; (c \<circ> \<sigma>) \<longlonglongrightarrow> d; \<And>n. Suc 0 \<le> \<sigma> n\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
have "compact{a..b}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. compact {a..b}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
compact {a..b}

goal (1 subgoal):
 1. (\<And>d \<sigma>. \<lbrakk>d \<in> {a..b}; strict_mono \<sigma>; (c \<circ> \<sigma>) \<longlonglongrightarrow> d; \<And>n. Suc 0 \<le> \<sigma> n\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
with cab
[PROOF STATE]
proof (chain)
picking this:
c ?n \<in> {a..b}
compact {a..b}
[PROOF STEP]
obtain d and s0
      where "d \<in> {a..b}" and s0: "strict_mono s0" and tends: "(c \<circ> s0) \<longlonglongrightarrow> d"
[PROOF STATE]
proof (prove)
using this:
c ?n \<in> {a..b}
compact {a..b}

goal (1 subgoal):
 1. (\<And>d s0. \<lbrakk>d \<in> {a..b}; strict_mono s0; (c \<circ> s0) \<longlonglongrightarrow> d\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
unfolding compact_def
[PROOF STATE]
proof (prove)
using this:
c ?n \<in> {a..b}
\<forall>f. (\<forall>n. f n \<in> {a..b}) \<longrightarrow> (\<exists>l\<in>{a..b}. \<exists>r. strict_mono r \<and> (f \<circ> r) \<longlonglongrightarrow> l)

goal (1 subgoal):
 1. (\<And>d s0. \<lbrakk>d \<in> {a..b}; strict_mono s0; (c \<circ> s0) \<longlonglongrightarrow> d\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using that
[PROOF STATE]
proof (prove)
using this:
c ?n \<in> {a..b}
\<forall>f. (\<forall>n. f n \<in> {a..b}) \<longrightarrow> (\<exists>l\<in>{a..b}. \<exists>r. strict_mono r \<and> (f \<circ> r) \<longlonglongrightarrow> l)
\<lbrakk>?d \<in> {a..b}; strict_mono ?s0.0; (c \<circ> ?s0.0) \<longlonglongrightarrow> ?d\<rbrakk> \<Longrightarrow> thesis

goal (1 subgoal):
 1. (\<And>d s0. \<lbrakk>d \<in> {a..b}; strict_mono s0; (c \<circ> s0) \<longlonglongrightarrow> d\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
d \<in> {a..b}
strict_mono s0
(c \<circ> s0) \<longlonglongrightarrow> d

goal (1 subgoal):
 1. (\<And>d \<sigma>. \<lbrakk>d \<in> {a..b}; strict_mono \<sigma>; (c \<circ> \<sigma>) \<longlonglongrightarrow> d; \<And>n. Suc 0 \<le> \<sigma> n\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
show thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. thesis
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (4 subgoals):
 1. ?d \<in> {a..b}
 2. strict_mono ?\<sigma>
 3. (c \<circ> ?\<sigma>) \<longlonglongrightarrow> ?d
 4. \<And>n. Suc 0 \<le> ?\<sigma> n
[PROOF STEP]
show "d \<in> {a..b}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. d \<in> {a..b}
[PROOF STEP]
by fact
[PROOF STATE]
proof (state)
this:
d \<in> {a..b}

goal (3 subgoals):
 1. strict_mono ?\<sigma>
 2. (c \<circ> ?\<sigma>) \<longlonglongrightarrow> d
 3. \<And>n. Suc 0 \<le> ?\<sigma> n
[PROOF STEP]
show "strict_mono (s0 \<circ> Suc)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. strict_mono (s0 \<circ> Suc)
[PROOF STEP]
using s0
[PROOF STATE]
proof (prove)
using this:
strict_mono s0

goal (1 subgoal):
 1. strict_mono (s0 \<circ> Suc)
[PROOF STEP]
by (auto simp: strict_mono_def)
[PROOF STATE]
proof (state)
this:
strict_mono (s0 \<circ> Suc)

goal (2 subgoals):
 1. (c \<circ> (s0 \<circ> Suc)) \<longlonglongrightarrow> d
 2. \<And>n. Suc 0 \<le> (s0 \<circ> Suc) n
[PROOF STEP]
show "(c \<circ> (s0 \<circ> Suc)) \<longlonglongrightarrow> d"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (c \<circ> (s0 \<circ> Suc)) \<longlonglongrightarrow> d
[PROOF STEP]
by (metis tends LIMSEQ_subseq_LIMSEQ Suc_less_eq comp_assoc strict_mono_def)
[PROOF STATE]
proof (state)
this:
(c \<circ> (s0 \<circ> Suc)) \<longlonglongrightarrow> d

goal (1 subgoal):
 1. \<And>n. Suc 0 \<le> (s0 \<circ> Suc) n
[PROOF STEP]
show "\<And>n. (s0 \<circ> Suc) n \<ge> Suc 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>n. Suc 0 \<le> (s0 \<circ> Suc) n
[PROOF STEP]
by (metis comp_apply le0 not_less_eq_eq old.nat.exhaust s0 seq_suble)
[PROOF STATE]
proof (state)
this:
Suc 0 \<le> (s0 \<circ> Suc) ?n

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

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
d \<in> {a..b}
strict_mono \<sigma>
(c \<circ> \<sigma>) \<longlonglongrightarrow> d
Suc 0 \<le> \<sigma> ?n

goal (1 subgoal):
 1. (\<And>c. \<lbrakk>a \<le> c; c \<le> b; ((\<lambda>x. g x *\<^sub>R f x) has_integral integral {c..b} f) {a..b}\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
define \<phi> where "\<phi> \<equiv> \<lambda>n x. \<Sum>k = Suc 0..\<sigma> n. if k/(\<sigma> n) \<le> g x then f x /\<^sub>R (\<sigma> n) else 0"
[PROOF STATE]
proof (state)
this:
\<phi> \<equiv> \<lambda>n x. \<Sum>k = Suc 0..\<sigma> n. if real k / real (\<sigma> n) \<le> g x then f x /\<^sub>R real (\<sigma> n) else 0

goal (1 subgoal):
 1. (\<And>c. \<lbrakk>a \<le> c; c \<le> b; ((\<lambda>x. g x *\<^sub>R f x) has_integral integral {c..b} f) {a..b}\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
define \<psi> where "\<psi> \<equiv> \<lambda>n x. \<Sum>k = Suc 0..\<sigma> n. if k/(\<sigma> n) \<le> g x then inverse (\<sigma> n) else 0"
[PROOF STATE]
proof (state)
this:
\<psi> \<equiv> \<lambda>n x. \<Sum>k = Suc 0..\<sigma> n. if real k / real (\<sigma> n) \<le> g x then inverse (real (\<sigma> n)) else 0

goal (1 subgoal):
 1. (\<And>c. \<lbrakk>a \<le> c; c \<le> b; ((\<lambda>x. g x *\<^sub>R f x) has_integral integral {c..b} f) {a..b}\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
have **: "(\<lambda>x. g x *\<^sub>R f x) integrable_on cbox a b \<and>
            (\<lambda>n. integral (cbox a b) (\<phi> n)) \<longlonglongrightarrow> integral (cbox a b) (\<lambda>x. g x *\<^sub>R f x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. g x *\<^sub>R f x) integrable_on cbox a b \<and> (\<lambda>n. integral (cbox a b) (\<phi> n)) \<longlonglongrightarrow> integral (cbox a b) (\<lambda>x. g x *\<^sub>R f x)
[PROOF STEP]
proof (rule equiintegrable_limit)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. range \<phi> equiintegrable_on cbox a b
 2. \<And>x. x \<in> cbox a b \<Longrightarrow> (\<lambda>n. \<phi> n x) \<longlonglongrightarrow> g x *\<^sub>R f x
[PROOF STEP]
have \<dagger>: "((\<lambda>n. \<lambda>x. (\<Sum>k = Suc 0..n. if k / n \<le> g x then inverse n *\<^sub>R f x else 0)) ` {Suc 0..}) equiintegrable_on {a..b}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>n x. \<Sum>k = Suc 0..n. if real k / real n \<le> g x then f x /\<^sub>R real n else 0) ` {Suc 0..} equiintegrable_on {a..b}
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<lambda>n x. \<Sum>k = Suc 0..n. if real k / real n \<le> g x then f x /\<^sub>R real n else 0) ` {Suc 0..} equiintegrable_on {a..b}
[PROOF STEP]
have *: "(\<Union>c::real. {\<lambda>x. if g x \<ge> c then f x else 0}) equiintegrable_on {a..b}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Union>c. {\<lambda>x. if c \<le> g x then f x else 0}) equiintegrable_on {a..b}
[PROOF STEP]
using SMVT_lemma2 [OF f g]
[PROOF STATE]
proof (prove)
using this:
(\<And>x y. x \<le> y \<Longrightarrow> ?y3 x \<le> ?y3 y) \<Longrightarrow> (\<Union>y. {\<lambda>x. if y \<le> g (?y3 x) then f x else 0}) equiintegrable_on {a..b}

goal (1 subgoal):
 1. (\<Union>c. {\<lambda>x. if c \<le> g x then f x else 0}) equiintegrable_on {a..b}
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
(\<Union>c. {\<lambda>x. if c \<le> g x then f x else 0}) equiintegrable_on {a..b}

goal (1 subgoal):
 1. (\<lambda>n x. \<Sum>k = Suc 0..n. if real k / real n \<le> g x then f x /\<^sub>R real n else 0) ` {Suc 0..} equiintegrable_on {a..b}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>n x. \<Sum>k = Suc 0..n. if real k / real n \<le> g x then f x /\<^sub>R real n else 0) ` {Suc 0..} equiintegrable_on {a..b}
[PROOF STEP]
apply (rule equiintegrable_on_subset [OF equiintegrable_sum_real [OF *]], clarify)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x n. Suc 0 \<le> n \<Longrightarrow> (\<lambda>x. \<Sum>k = Suc 0..n. if real k / real n \<le> g x then f x /\<^sub>R real n else 0) \<in> (\<Union>I\<in>Collect finite. \<Union>c\<in>{c. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1}. \<Union>f\<in>I \<rightarrow> (\<Union>c. {\<lambda>x. if c \<le> g x then f x else 0}). {\<lambda>x. \<Sum>i\<in>I. c i *\<^sub>R f i x})
[PROOF STEP]
apply (rule_tac a="{Suc 0..n}" in UN_I, force)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x n. Suc 0 \<le> n \<Longrightarrow> (\<lambda>x. \<Sum>k = Suc 0..n. if real k / real n \<le> g x then f x /\<^sub>R real n else 0) \<in> (\<Union>c\<in>{c. (\<forall>i\<in>{Suc 0..n}. 0 \<le> c i) \<and> sum c {Suc 0..n} = 1}. \<Union>f\<in>{Suc 0..n} \<rightarrow> (\<Union>c. {\<lambda>x. if c \<le> g x then f x else 0}). {\<lambda>x. \<Sum>i = Suc 0..n. c i *\<^sub>R f i x})
[PROOF STEP]
apply (rule_tac a="\<lambda>k. inverse n" in UN_I, auto)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>n. Suc 0 \<le> n \<Longrightarrow> \<exists>x\<in>{Suc 0..n} \<rightarrow> (\<Union>c. {\<lambda>x. if c \<le> g x then f x else 0}). (\<lambda>x. \<Sum>k = Suc 0..n. if real k / real n \<le> g x then f x /\<^sub>R real n else 0) = (\<lambda>xa. \<Sum>i = Suc 0..n. inverse (real n) * x i xa)
[PROOF STEP]
apply (rule_tac x="\<lambda>k x. if real k / real n \<le> g x then f x else 0" in bexI)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>n. Suc 0 \<le> n \<Longrightarrow> (\<lambda>x. \<Sum>k = Suc 0..n. if real k / real n \<le> g x then f x /\<^sub>R real n else 0) = (\<lambda>x. \<Sum>i = Suc 0..n. inverse (real n) * (if real i / real n \<le> g x then f x else 0))
 2. \<And>n. Suc 0 \<le> n \<Longrightarrow> (\<lambda>k x. if real k / real n \<le> g x then f x else 0) \<in> {Suc 0..n} \<rightarrow> (\<Union>c. {\<lambda>x. if c \<le> g x then f x else 0})
[PROOF STEP]
apply (force intro: sum.cong)+
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
(\<lambda>n x. \<Sum>k = Suc 0..n. if real k / real n \<le> g x then f x /\<^sub>R real n else 0) ` {Suc 0..} equiintegrable_on {a..b}

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<lambda>n x. \<Sum>k = Suc 0..n. if real k / real n \<le> g x then f x /\<^sub>R real n else 0) ` {Suc 0..} equiintegrable_on {a..b}

goal (2 subgoals):
 1. range \<phi> equiintegrable_on cbox a b
 2. \<And>x. x \<in> cbox a b \<Longrightarrow> (\<lambda>n. \<phi> n x) \<longlonglongrightarrow> g x *\<^sub>R f x
[PROOF STEP]
show "range \<phi> equiintegrable_on cbox a b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. range \<phi> equiintegrable_on cbox a b
[PROOF STEP]
unfolding \<phi>_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. range (\<lambda>n x. \<Sum>k = Suc 0..\<sigma> n. if real k / real (\<sigma> n) \<le> g x then f x /\<^sub>R real (\<sigma> n) else 0) equiintegrable_on cbox a b
[PROOF STEP]
by (auto simp: non0 intro: equiintegrable_on_subset [OF \<dagger>])
[PROOF STATE]
proof (state)
this:
range \<phi> equiintegrable_on cbox a b

goal (1 subgoal):
 1. \<And>x. x \<in> cbox a b \<Longrightarrow> (\<lambda>n. \<phi> n x) \<longlonglongrightarrow> g x *\<^sub>R f x
[PROOF STEP]
show "(\<lambda>n. \<phi> n x) \<longlonglongrightarrow> g x *\<^sub>R f x"
      if x: "x \<in> cbox a b" for x
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>n. \<phi> n x) \<longlonglongrightarrow> g x *\<^sub>R f x
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<lambda>n. \<phi> n x) \<longlonglongrightarrow> g x *\<^sub>R f x
[PROOF STEP]
have eq: "\<phi> n x = \<psi> n x *\<^sub>R f x"  for n
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<phi> n x = \<psi> n x *\<^sub>R f x
[PROOF STEP]
by (auto simp: \<phi>_def \<psi>_def sum_distrib_right if_distrib intro: sum.cong)
[PROOF STATE]
proof (state)
this:
\<phi> ?n x = \<psi> ?n x *\<^sub>R f x

goal (1 subgoal):
 1. (\<lambda>n. \<phi> n x) \<longlonglongrightarrow> g x *\<^sub>R f x
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>n. \<phi> n x) \<longlonglongrightarrow> g x *\<^sub>R f x
[PROOF STEP]
unfolding eq
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>n. \<psi> n x *\<^sub>R f x) \<longlonglongrightarrow> g x *\<^sub>R f x
[PROOF STEP]
proof (rule tendsto_scaleR [OF _ tendsto_const])
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<lambda>xa. \<psi> xa x) \<longlonglongrightarrow> g x
[PROOF STEP]
show "(\<lambda>n. \<psi> n x) \<longlonglongrightarrow> g x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>n. \<psi> n x) \<longlonglongrightarrow> g x
[PROOF STEP]
unfolding lim_sequentially dist_real_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>r>0. \<exists>no. \<forall>n\<ge>no. \<bar>\<psi> n x - g x\<bar> < r
[PROOF STEP]
proof (intro allI impI)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>r. 0 < r \<Longrightarrow> \<exists>no. \<forall>n\<ge>no. \<bar>\<psi> n x - g x\<bar> < r
[PROOF STEP]
fix e :: real
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>r. 0 < r \<Longrightarrow> \<exists>no. \<forall>n\<ge>no. \<bar>\<psi> n x - g x\<bar> < r
[PROOF STEP]
assume "e > 0"
[PROOF STATE]
proof (state)
this:
0 < e

goal (1 subgoal):
 1. \<And>r. 0 < r \<Longrightarrow> \<exists>no. \<forall>n\<ge>no. \<bar>\<psi> n x - g x\<bar> < r
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
0 < e
[PROOF STEP]
obtain N where "N \<noteq> 0" "0 < inverse (real N)" and N: "inverse (real N) < e"
[PROOF STATE]
proof (prove)
using this:
0 < e

goal (1 subgoal):
 1. (\<And>N. \<lbrakk>N \<noteq> 0; 0 < inverse (real N); inverse (real N) < e\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using real_arch_inverse
[PROOF STATE]
proof (prove)
using this:
0 < e
(0 < ?e) = (\<exists>n. n \<noteq> 0 \<and> 0 < inverse (real n) \<and> inverse (real n) < ?e)

goal (1 subgoal):
 1. (\<And>N. \<lbrakk>N \<noteq> 0; 0 < inverse (real N); inverse (real N) < e\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
N \<noteq> 0
0 < inverse (real N)
inverse (real N) < e

goal (1 subgoal):
 1. \<And>r. 0 < r \<Longrightarrow> \<exists>no. \<forall>n\<ge>no. \<bar>\<psi> n x - g x\<bar> < r
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
N \<noteq> 0
0 < inverse (real N)
inverse (real N) < e

goal (1 subgoal):
 1. \<And>r. 0 < r \<Longrightarrow> \<exists>no. \<forall>n\<ge>no. \<bar>\<psi> n x - g x\<bar> < r
[PROOF STEP]
have "\<bar>\<psi> n x - g x\<bar> < inverse (real N)" if "n\<ge>N" for n
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<bar>\<psi> n x - g x\<bar> < inverse (real N)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<bar>\<psi> n x - g x\<bar> < inverse (real N)
[PROOF STEP]
have "\<bar>g x - \<psi> n x\<bar> < inverse (real (\<sigma> n))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<bar>g x - \<psi> n x\<bar> < inverse (real (\<sigma> n))
[PROOF STEP]
unfolding \<psi>_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<bar>g x - (\<Sum>k = Suc 0..\<sigma> n. if real k / real (\<sigma> n) \<le> g x then inverse (real (\<sigma> n)) else 0)\<bar> < inverse (real (\<sigma> n))
[PROOF STEP]
proof (rule level_approx [of "{a..b}" g])
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. \<And>x. x \<in> {a..b} \<Longrightarrow> 0 \<le> g x \<and> g x \<le> 1
 2. x \<in> {a..b}
 3. \<sigma> n \<noteq> 0
[PROOF STEP]
show "\<sigma> n \<noteq> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<sigma> n \<noteq> 0
[PROOF STEP]
by (metis Suc_n_not_le_n non0)
[PROOF STATE]
proof (state)
this:
\<sigma> n \<noteq> 0

goal (2 subgoals):
 1. \<And>x. x \<in> {a..b} \<Longrightarrow> 0 \<le> g x \<and> g x \<le> 1
 2. x \<in> {a..b}
[PROOF STEP]
qed (use x 01 non0 in auto)
[PROOF STATE]
proof (state)
this:
\<bar>g x - \<psi> n x\<bar> < inverse (real (\<sigma> n))

goal (1 subgoal):
 1. \<bar>\<psi> n x - g x\<bar> < inverse (real N)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
\<bar>g x - \<psi> n x\<bar> < inverse (real (\<sigma> n))

goal (1 subgoal):
 1. \<bar>\<psi> n x - g x\<bar> < inverse (real N)
[PROOF STEP]
have "\<dots> \<le> inverse N"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inverse (real (\<sigma> n)) \<le> inverse (real N)
[PROOF STEP]
using seq_suble [OF \<sigma>] \<open>N \<noteq> 0\<close> non0 that
[PROOF STATE]
proof (prove)
using this:
?n \<le> \<sigma> ?n
N \<noteq> 0
Suc 0 \<le> \<sigma> ?n
N \<le> n

goal (1 subgoal):
 1. inverse (real (\<sigma> n)) \<le> inverse (real N)
[PROOF STEP]
by (auto intro: order_trans simp: field_split_simps)
[PROOF STATE]
proof (state)
this:
inverse (real (\<sigma> n)) \<le> inverse (real N)

goal (1 subgoal):
 1. \<bar>\<psi> n x - g x\<bar> < inverse (real N)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
\<bar>g x - \<psi> n x\<bar> < inverse (real N)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<bar>g x - \<psi> n x\<bar> < inverse (real N)

goal (1 subgoal):
 1. \<bar>\<psi> n x - g x\<bar> < inverse (real N)
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
\<bar>\<psi> n x - g x\<bar> < inverse (real N)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
N \<le> ?n \<Longrightarrow> \<bar>\<psi> ?n x - g x\<bar> < inverse (real N)

goal (1 subgoal):
 1. \<And>r. 0 < r \<Longrightarrow> \<exists>no. \<forall>n\<ge>no. \<bar>\<psi> n x - g x\<bar> < r
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
N \<noteq> 0
0 < inverse (real N)
inverse (real N) < e
N \<le> ?n \<Longrightarrow> \<bar>\<psi> ?n x - g x\<bar> < inverse (real N)
[PROOF STEP]
show "\<exists>N. \<forall>n\<ge>N. \<bar>\<psi> n x - g x\<bar> < e"
[PROOF STATE]
proof (prove)
using this:
N \<noteq> 0
0 < inverse (real N)
inverse (real N) < e
N \<le> ?n \<Longrightarrow> \<bar>\<psi> ?n x - g x\<bar> < inverse (real N)

goal (1 subgoal):
 1. \<exists>N. \<forall>n\<ge>N. \<bar>\<psi> n x - g x\<bar> < e
[PROOF STEP]
using less_trans
[PROOF STATE]
proof (prove)
using this:
N \<noteq> 0
0 < inverse (real N)
inverse (real N) < e
N \<le> ?n \<Longrightarrow> \<bar>\<psi> ?n x - g x\<bar> < inverse (real N)
\<lbrakk>?x < ?y; ?y < ?z\<rbrakk> \<Longrightarrow> ?x < ?z

goal (1 subgoal):
 1. \<exists>N. \<forall>n\<ge>N. \<bar>\<psi> n x - g x\<bar> < e
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
\<exists>N. \<forall>n\<ge>N. \<bar>\<psi> n x - g x\<bar> < e

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<lambda>n. \<psi> n x) \<longlonglongrightarrow> g x

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<lambda>n. \<phi> n x) \<longlonglongrightarrow> g x *\<^sub>R f x

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
?x \<in> cbox a b \<Longrightarrow> (\<lambda>n. \<phi> n ?x) \<longlonglongrightarrow> g ?x *\<^sub>R f ?x

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<lambda>x. g x *\<^sub>R f x) integrable_on cbox a b \<and> (\<lambda>n. integral (cbox a b) (\<phi> n)) \<longlonglongrightarrow> integral (cbox a b) (\<lambda>x. g x *\<^sub>R f x)

goal (1 subgoal):
 1. (\<And>c. \<lbrakk>a \<le> c; c \<le> b; ((\<lambda>x. g x *\<^sub>R f x) has_integral integral {c..b} f) {a..b}\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
show thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. thesis
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. a \<le> ?c
 2. ?c \<le> b
 3. ((\<lambda>x. g x *\<^sub>R f x) has_integral integral {?c..b} f) {a..b}
[PROOF STEP]
show "a \<le> d" "d \<le> b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a \<le> d &&& d \<le> b
[PROOF STEP]
using \<open>d \<in> {a..b}\<close> atLeastAtMost_iff
[PROOF STATE]
proof (prove)
using this:
d \<in> {a..b}
(?i \<in> {?l..?u}) = (?l \<le> ?i \<and> ?i \<le> ?u)

goal (1 subgoal):
 1. a \<le> d &&& d \<le> b
[PROOF STEP]
by blast+
[PROOF STATE]
proof (state)
this:
a \<le> d
d \<le> b

goal (1 subgoal):
 1. ((\<lambda>x. g x *\<^sub>R f x) has_integral integral {d..b} f) {a..b}
[PROOF STEP]
show "((\<lambda>x. g x *\<^sub>R f x) has_integral integral {d..b} f) {a..b}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>x. g x *\<^sub>R f x) has_integral integral {d..b} f) {a..b}
[PROOF STEP]
unfolding has_integral_iff
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. g x *\<^sub>R f x) integrable_on {a..b} \<and> integral {a..b} (\<lambda>x. g x *\<^sub>R f x) = integral {d..b} f
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. (\<lambda>x. g x *\<^sub>R f x) integrable_on {a..b}
 2. integral {a..b} (\<lambda>x. g x *\<^sub>R f x) = integral {d..b} f
[PROOF STEP]
show "(\<lambda>x. g x *\<^sub>R f x) integrable_on {a..b}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. g x *\<^sub>R f x) integrable_on {a..b}
[PROOF STEP]
using **
[PROOF STATE]
proof (prove)
using this:
(\<lambda>x. g x *\<^sub>R f x) integrable_on cbox a b \<and> (\<lambda>n. integral (cbox a b) (\<phi> n)) \<longlonglongrightarrow> integral (cbox a b) (\<lambda>x. g x *\<^sub>R f x)

goal (1 subgoal):
 1. (\<lambda>x. g x *\<^sub>R f x) integrable_on {a..b}
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<lambda>x. g x *\<^sub>R f x) integrable_on {a..b}

goal (1 subgoal):
 1. integral {a..b} (\<lambda>x. g x *\<^sub>R f x) = integral {d..b} f
[PROOF STEP]
show "integral {a..b} (\<lambda>x. g x *\<^sub>R f x) = integral {d..b} f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. integral {a..b} (\<lambda>x. g x *\<^sub>R f x) = integral {d..b} f
[PROOF STEP]
proof (rule tendsto_unique)
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. ?F \<noteq> bot
 2. (?f \<longlongrightarrow> integral {a..b} (\<lambda>x. g x *\<^sub>R f x)) ?F
 3. (?f \<longlongrightarrow> integral {d..b} f) ?F
[PROOF STEP]
show "(\<lambda>n. integral {c(\<sigma> n)..b} f) \<longlonglongrightarrow> integral {a..b} (\<lambda>x. g x *\<^sub>R f x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>n. integral {c (\<sigma> n)..b} f) \<longlonglongrightarrow> integral {a..b} (\<lambda>x. g x *\<^sub>R f x)
[PROOF STEP]
using **
[PROOF STATE]
proof (prove)
using this:
(\<lambda>x. g x *\<^sub>R f x) integrable_on cbox a b \<and> (\<lambda>n. integral (cbox a b) (\<phi> n)) \<longlonglongrightarrow> integral (cbox a b) (\<lambda>x. g x *\<^sub>R f x)

goal (1 subgoal):
 1. (\<lambda>n. integral {c (\<sigma> n)..b} f) \<longlonglongrightarrow> integral {a..b} (\<lambda>x. g x *\<^sub>R f x)
[PROOF STEP]
by (simp add: c \<phi>_def)
[PROOF STATE]
proof (state)
this:
(\<lambda>n. integral {c (\<sigma> n)..b} f) \<longlonglongrightarrow> integral {a..b} (\<lambda>x. g x *\<^sub>R f x)

goal (2 subgoals):
 1. sequentially \<noteq> bot
 2. (\<lambda>n. integral {c (\<sigma> n)..b} f) \<longlonglongrightarrow> integral {d..b} f
[PROOF STEP]
have "continuous (at d within {a..b}) (\<lambda>x. integral {x..b} f)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. continuous (at d within {a..b}) (\<lambda>x. integral {x..b} f)
[PROOF STEP]
using indefinite_integral_continuous_1' [OF f] \<open>d \<in> {a..b}\<close>
[PROOF STATE]
proof (prove)
using this:
continuous_on {a..b} (\<lambda>x. integral {x..b} f)
d \<in> {a..b}

goal (1 subgoal):
 1. continuous (at d within {a..b}) (\<lambda>x. integral {x..b} f)
[PROOF STEP]
by (simp add: continuous_on_eq_continuous_within)
[PROOF STATE]
proof (state)
this:
continuous (at d within {a..b}) (\<lambda>x. integral {x..b} f)

goal (2 subgoals):
 1. sequentially \<noteq> bot
 2. (\<lambda>n. integral {c (\<sigma> n)..b} f) \<longlonglongrightarrow> integral {d..b} f
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
continuous (at d within {a..b}) (\<lambda>x. integral {x..b} f)
[PROOF STEP]
show "(\<lambda>n. integral {c(\<sigma> n)..b} f) \<longlonglongrightarrow> integral {d..b} f"
[PROOF STATE]
proof (prove)
using this:
continuous (at d within {a..b}) (\<lambda>x. integral {x..b} f)

goal (1 subgoal):
 1. (\<lambda>n. integral {c (\<sigma> n)..b} f) \<longlonglongrightarrow> integral {d..b} f
[PROOF STEP]
using d cab
[PROOF STATE]
proof (prove)
using this:
continuous (at d within {a..b}) (\<lambda>x. integral {x..b} f)
(c \<circ> \<sigma>) \<longlonglongrightarrow> d
c ?n \<in> {a..b}

goal (1 subgoal):
 1. (\<lambda>n. integral {c (\<sigma> n)..b} f) \<longlonglongrightarrow> integral {d..b} f
[PROOF STEP]
unfolding o_def
[PROOF STATE]
proof (prove)
using this:
continuous (at d within {a..b}) (\<lambda>x. integral {x..b} f)
(\<lambda>x. c (\<sigma> x)) \<longlonglongrightarrow> d
c ?n \<in> {a..b}

goal (1 subgoal):
 1. (\<lambda>n. integral {c (\<sigma> n)..b} f) \<longlonglongrightarrow> integral {d..b} f
[PROOF STEP]
by (simp add: continuous_within_sequentially o_def)
[PROOF STATE]
proof (state)
this:
(\<lambda>n. integral {c (\<sigma> n)..b} f) \<longlonglongrightarrow> integral {d..b} f

goal (1 subgoal):
 1. sequentially \<noteq> bot
[PROOF STEP]
qed auto
[PROOF STATE]
proof (state)
this:
integral {a..b} (\<lambda>x. g x *\<^sub>R f x) = integral {d..b} f

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
((\<lambda>x. g x *\<^sub>R f x) has_integral integral {d..b} f) {a..b}

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

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma common_range_limit:
  assumes "finite (range x)"
    and "finite (range y)"
  obtains i where "limit x = range (suffix i x)"
    and "limit y = range (suffix i y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>i. \<lbrakk>limit x = range (suffix i x); limit y = range (suffix i y)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<And>i. \<lbrakk>limit x = range (suffix i x); limit y = range (suffix i y)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
obtain i j where 1: "limit x = range (suffix i x)"
    and 2: "limit y = range (suffix j y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>i j. \<lbrakk>limit x = range (suffix i x); limit y = range (suffix j y)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using assms limit_is_suffix
[PROOF STATE]
proof (prove)
using this:
finite (range x)
finite (range y)
finite (range ?x) \<Longrightarrow> \<exists>k. limit ?x = range (suffix k ?x)

goal (1 subgoal):
 1. (\<And>i j. \<lbrakk>limit x = range (suffix i x); limit y = range (suffix j y)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
limit x = range (suffix i x)
limit y = range (suffix j y)

goal (1 subgoal):
 1. (\<And>i. \<lbrakk>limit x = range (suffix i x); limit y = range (suffix i y)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
have "limit x = range (suffix (max i j) x)"
    and "limit y = range (suffix (max i j) y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. limit x = range (suffix (max i j) x) &&& limit y = range (suffix (max i j) y)
[PROOF STEP]
using limit_range_suffix_incr[OF 1] limit_range_suffix_incr[OF 2]
[PROOF STATE]
proof (prove)
using this:
i \<le> ?j \<Longrightarrow> limit x = range (suffix ?j x)
j \<le> ?j \<Longrightarrow> limit y = range (suffix ?j y)

goal (1 subgoal):
 1. limit x = range (suffix (max i j) x) &&& limit y = range (suffix (max i j) y)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
limit x = range (suffix (max i j) x)
limit y = range (suffix (max i j) y)

goal (1 subgoal):
 1. (\<And>i. \<lbrakk>limit x = range (suffix i x); limit y = range (suffix i y)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
limit x = range (suffix (max i j) x)
limit y = range (suffix (max i j) y)

goal (1 subgoal):
 1. thesis
[PROOF STEP]
using that
[PROOF STATE]
proof (prove)
using this:
limit x = range (suffix (max i j) x)
limit y = range (suffix (max i j) y)
\<lbrakk>limit x = range (suffix ?i x); limit y = range (suffix ?i y)\<rbrakk> \<Longrightarrow> thesis

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

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma continuous_on_sequentiallyI:
  fixes f :: "'a::{first_countable_topology, t2_space} \<Rightarrow> 'b::topological_space"
  assumes "\<And>u a. (\<forall>n. u n \<in> s) \<Longrightarrow> a \<in> s \<Longrightarrow> u \<longlonglongrightarrow> a \<Longrightarrow> (\<lambda>n. f (u n)) \<longlonglongrightarrow> f a"
  shows "continuous_on s f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. continuous_on s f
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>\<forall>n. ?u n \<in> s; ?a \<in> s; ?u \<longlonglongrightarrow> ?a\<rbrakk> \<Longrightarrow> (\<lambda>n. f (?u n)) \<longlonglongrightarrow> f ?a

goal (1 subgoal):
 1. continuous_on s f
[PROOF STEP]
unfolding continuous_on_eq_continuous_within
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>\<forall>n. ?u n \<in> s; ?a \<in> s; ?u \<longlonglongrightarrow> ?a\<rbrakk> \<Longrightarrow> (\<lambda>n. f (?u n)) \<longlonglongrightarrow> f ?a

goal (1 subgoal):
 1. \<forall>x\<in>s. continuous (at x within s) f
[PROOF STEP]
using continuous_within_sequentiallyI[of _ s f]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>\<forall>n. ?u n \<in> s; ?a \<in> s; ?u \<longlonglongrightarrow> ?a\<rbrakk> \<Longrightarrow> (\<lambda>n. f (?u n)) \<longlonglongrightarrow> f ?a
(\<And>u. \<lbrakk>u \<longlonglongrightarrow> ?a; \<forall>n. u n \<in> s\<rbrakk> \<Longrightarrow> (\<lambda>n. f (u n)) \<longlonglongrightarrow> f ?a) \<Longrightarrow> continuous (at ?a within s) f

goal (1 subgoal):
 1. \<forall>x\<in>s. continuous (at x within s) f
[PROOF STEP]
by auto


[STATEMENT]
lemma lcoset_eq_reps_subset:
  "(a::'a::group_add) +o A \<subseteq> a +o B \<Longrightarrow> A \<subseteq> B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a +o A \<subseteq> a +o B \<Longrightarrow> A \<subseteq> B
[PROOF STEP]
using elt_set_plus_def[of a]
[PROOF STATE]
proof (prove)
using this:
a +o ?B = {c. \<exists>b\<in>?B. c = a + b}

goal (1 subgoal):
 1. a +o A \<subseteq> a +o B \<Longrightarrow> A \<subseteq> B
[PROOF STEP]
by auto


[STATEMENT]
lemma rsum_zero [simp]: "rsum D (\<lambda>x. 0) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rsum D (\<lambda>x. 0) = 0
[PROOF STEP]
by (induct D, auto)


[STATEMENT]
lemma abs_summable_equivalent: \<open>Infinite_Sum.abs_summable_on f A \<longleftrightarrow> f abs_summable_on A\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Infinite_Sum.abs_summable_on f A = (f abs_summable_on A)
[PROOF STEP]
proof (rule iffI)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. Infinite_Sum.abs_summable_on f A \<Longrightarrow> f abs_summable_on A
 2. f abs_summable_on A \<Longrightarrow> Infinite_Sum.abs_summable_on f A
[PROOF STEP]
define n where \<open>n x = norm (f x)\<close> for x
[PROOF STATE]
proof (state)
this:
n ?x = norm (f ?x)

goal (2 subgoals):
 1. Infinite_Sum.abs_summable_on f A \<Longrightarrow> f abs_summable_on A
 2. f abs_summable_on A \<Longrightarrow> Infinite_Sum.abs_summable_on f A
[PROOF STEP]
assume \<open>n summable_on A\<close>
[PROOF STATE]
proof (state)
this:
n summable_on A

goal (2 subgoals):
 1. Infinite_Sum.abs_summable_on f A \<Longrightarrow> f abs_summable_on A
 2. f abs_summable_on A \<Longrightarrow> Infinite_Sum.abs_summable_on f A
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
n summable_on A
[PROOF STEP]
have \<open>sum n F \<le> infsum n A\<close> if \<open>finite F\<close> and \<open>F\<subseteq>A\<close> for F
[PROOF STATE]
proof (prove)
using this:
n summable_on A

goal (1 subgoal):
 1. sum n F \<le> infsum n A
[PROOF STEP]
using that
[PROOF STATE]
proof (prove)
using this:
n summable_on A
finite F
F \<subseteq> A

goal (1 subgoal):
 1. sum n F \<le> infsum n A
[PROOF STEP]
by (auto simp flip: infsum_finite simp: n_def[abs_def] intro!: infsum_mono_neutral)
[PROOF STATE]
proof (state)
this:
\<lbrakk>finite ?F; ?F \<subseteq> A\<rbrakk> \<Longrightarrow> sum n ?F \<le> infsum n A

goal (2 subgoals):
 1. Infinite_Sum.abs_summable_on f A \<Longrightarrow> f abs_summable_on A
 2. f abs_summable_on A \<Longrightarrow> Infinite_Sum.abs_summable_on f A
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>finite ?F; ?F \<subseteq> A\<rbrakk> \<Longrightarrow> sum n ?F \<le> infsum n A
[PROOF STEP]
show \<open>f abs_summable_on A\<close>
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>finite ?F; ?F \<subseteq> A\<rbrakk> \<Longrightarrow> sum n ?F \<le> infsum n A

goal (1 subgoal):
 1. f abs_summable_on A
[PROOF STEP]
by (auto intro!: abs_summable_finite_sumsI simp: n_def)
[PROOF STATE]
proof (state)
this:
f abs_summable_on A

goal (1 subgoal):
 1. f abs_summable_on A \<Longrightarrow> Infinite_Sum.abs_summable_on f A
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. f abs_summable_on A \<Longrightarrow> Infinite_Sum.abs_summable_on f A
[PROOF STEP]
define n where \<open>n x = norm (f x)\<close> for x
[PROOF STATE]
proof (state)
this:
n ?x = norm (f ?x)

goal (1 subgoal):
 1. f abs_summable_on A \<Longrightarrow> Infinite_Sum.abs_summable_on f A
[PROOF STEP]
assume \<open>f abs_summable_on A\<close>
[PROOF STATE]
proof (state)
this:
f abs_summable_on A

goal (1 subgoal):
 1. f abs_summable_on A \<Longrightarrow> Infinite_Sum.abs_summable_on f A
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
f abs_summable_on A
[PROOF STEP]
have \<open>n abs_summable_on A\<close>
[PROOF STATE]
proof (prove)
using this:
f abs_summable_on A

goal (1 subgoal):
 1. n abs_summable_on A
[PROOF STEP]
by (simp add: \<open>f abs_summable_on A\<close> n_def)
[PROOF STATE]
proof (state)
this:
n abs_summable_on A

goal (1 subgoal):
 1. f abs_summable_on A \<Longrightarrow> Infinite_Sum.abs_summable_on f A
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
n abs_summable_on A
[PROOF STEP]
have \<open>sum n F \<le> infsetsum n A\<close> if \<open>finite F\<close> and \<open>F\<subseteq>A\<close> for F
[PROOF STATE]
proof (prove)
using this:
n abs_summable_on A

goal (1 subgoal):
 1. sum n F \<le> infsetsum n A
[PROOF STEP]
using that
[PROOF STATE]
proof (prove)
using this:
n abs_summable_on A
finite F
F \<subseteq> A

goal (1 subgoal):
 1. sum n F \<le> infsetsum n A
[PROOF STEP]
by (auto simp flip: infsetsum_finite simp: n_def[abs_def] intro!: infsetsum_mono_neutral)
[PROOF STATE]
proof (state)
this:
\<lbrakk>finite ?F; ?F \<subseteq> A\<rbrakk> \<Longrightarrow> sum n ?F \<le> infsetsum n A

goal (1 subgoal):
 1. f abs_summable_on A \<Longrightarrow> Infinite_Sum.abs_summable_on f A
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>finite ?F; ?F \<subseteq> A\<rbrakk> \<Longrightarrow> sum n ?F \<le> infsetsum n A
[PROOF STEP]
show \<open>n summable_on A\<close>
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>finite ?F; ?F \<subseteq> A\<rbrakk> \<Longrightarrow> sum n ?F \<le> infsetsum n A

goal (1 subgoal):
 1. n summable_on A
[PROOF STEP]
apply (rule_tac nonneg_bdd_above_summable_on)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>x. \<lbrakk>\<And>F. \<lbrakk>finite F; F \<subseteq> A\<rbrakk> \<Longrightarrow> sum n F \<le> infsetsum n A; x \<in> A\<rbrakk> \<Longrightarrow> 0 \<le> n x
 2. (\<And>F. \<lbrakk>finite F; F \<subseteq> A\<rbrakk> \<Longrightarrow> sum n F \<le> infsetsum n A) \<Longrightarrow> bdd_above (sum n ` {F. F \<subseteq> A \<and> finite F})
[PROOF STEP]
by (auto simp add: n_def bdd_above_def)
[PROOF STATE]
proof (state)
this:
n summable_on A

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma tendsto_shift_1_over_n [tendsto_intros]:
  fixes f::"nat \<Rightarrow> real"
  assumes "(\<lambda>n. f n / n) \<longlonglongrightarrow> l"
  shows "(\<lambda>n. f (n+k) / n) \<longlonglongrightarrow> l"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>n. f (n + k) / real n) \<longlonglongrightarrow> l
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<lambda>n. f (n + k) / real n) \<longlonglongrightarrow> l
[PROOF STEP]
have "(1+k*(1/n))* (f(n+k)/(n+k)) = f(n+k)/n" if "n>0" for n
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (1 + real k * (1 / real n)) * (f (n + k) / real (n + k)) = f (n + k) / real n
[PROOF STEP]
using that
[PROOF STATE]
proof (prove)
using this:
0 < n

goal (1 subgoal):
 1. (1 + real k * (1 / real n)) * (f (n + k) / real (n + k)) = f (n + k) / real n
[PROOF STEP]
by (auto simp add: divide_simps)
[PROOF STATE]
proof (state)
this:
0 < ?n \<Longrightarrow> (1 + real k * (1 / real ?n)) * (f (?n + k) / real (?n + k)) = f (?n + k) / real ?n

goal (1 subgoal):
 1. (\<lambda>n. f (n + k) / real n) \<longlonglongrightarrow> l
[PROOF STEP]
with eventually_mono[OF eventually_gt_at_top[of "0::nat"] this]
[PROOF STATE]
proof (chain)
picking this:
(\<And>x. 0 < x \<Longrightarrow> 0 < ?n1 x) \<Longrightarrow> \<forall>\<^sub>F x in sequentially. (1 + real k * (1 / real (?n1 x))) * (f (?n1 x + k) / real (?n1 x + k)) = f (?n1 x + k) / real (?n1 x)
0 < ?n \<Longrightarrow> (1 + real k * (1 / real ?n)) * (f (?n + k) / real (?n + k)) = f (?n + k) / real ?n
[PROOF STEP]
have "eventually (\<lambda>n.(1+k*(1/n))* (f(n+k)/(n+k)) = f(n+k)/n) sequentially"
[PROOF STATE]
proof (prove)
using this:
(\<And>x. 0 < x \<Longrightarrow> 0 < ?n1 x) \<Longrightarrow> \<forall>\<^sub>F x in sequentially. (1 + real k * (1 / real (?n1 x))) * (f (?n1 x + k) / real (?n1 x + k)) = f (?n1 x + k) / real (?n1 x)
0 < ?n \<Longrightarrow> (1 + real k * (1 / real ?n)) * (f (?n + k) / real (?n + k)) = f (?n + k) / real ?n

goal (1 subgoal):
 1. \<forall>\<^sub>F n in sequentially. (1 + real k * (1 / real n)) * (f (n + k) / real (n + k)) = f (n + k) / real n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<forall>\<^sub>F n in sequentially. (1 + real k * (1 / real n)) * (f (n + k) / real (n + k)) = f (n + k) / real n

goal (1 subgoal):
 1. (\<lambda>n. f (n + k) / real n) \<longlonglongrightarrow> l
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
\<forall>\<^sub>F n in sequentially. (1 + real k * (1 / real n)) * (f (n + k) / real (n + k)) = f (n + k) / real n

goal (1 subgoal):
 1. (\<lambda>n. f (n + k) / real n) \<longlonglongrightarrow> l
[PROOF STEP]
have "(\<lambda>n. (1+k*(1/n))* (f(n+k)/(n+k))) \<longlonglongrightarrow> (1+real k*0) * l"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>n. (1 + real k * (1 / real n)) * (f (n + k) / real (n + k))) \<longlonglongrightarrow> (1 + real k * 0) * l
[PROOF STEP]
by (intro tendsto_intros LIMSEQ_ignore_initial_segment assms)
[PROOF STATE]
proof (state)
this:
(\<lambda>n. (1 + real k * (1 / real n)) * (f (n + k) / real (n + k))) \<longlonglongrightarrow> (1 + real k * 0) * l

goal (1 subgoal):
 1. (\<lambda>n. f (n + k) / real n) \<longlonglongrightarrow> l
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
\<forall>\<^sub>F n in sequentially. (1 + real k * (1 / real n)) * (f (n + k) / real (n + k)) = f (n + k) / real n
(\<lambda>n. (1 + real k * (1 / real n)) * (f (n + k) / real (n + k))) \<longlonglongrightarrow> (1 + real k * 0) * l
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<forall>\<^sub>F n in sequentially. (1 + real k * (1 / real n)) * (f (n + k) / real (n + k)) = f (n + k) / real n
(\<lambda>n. (1 + real k * (1 / real n)) * (f (n + k) / real (n + k))) \<longlonglongrightarrow> (1 + real k * 0) * l

goal (1 subgoal):
 1. (\<lambda>n. f (n + k) / real n) \<longlonglongrightarrow> l
[PROOF STEP]
using Lim_transform_eventually
[PROOF STATE]
proof (prove)
using this:
\<forall>\<^sub>F n in sequentially. (1 + real k * (1 / real n)) * (f (n + k) / real (n + k)) = f (n + k) / real n
(\<lambda>n. (1 + real k * (1 / real n)) * (f (n + k) / real (n + k))) \<longlonglongrightarrow> (1 + real k * 0) * l
\<lbrakk>(?f \<longlongrightarrow> ?l) ?F; \<forall>\<^sub>F x in ?F. ?f x = ?g x\<rbrakk> \<Longrightarrow> (?g \<longlongrightarrow> ?l) ?F

goal (1 subgoal):
 1. (\<lambda>n. f (n + k) / real n) \<longlonglongrightarrow> l
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<lambda>n. f (n + k) / real n) \<longlonglongrightarrow> l

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma lookup_row_to_poly:
  assumes "distinct ts" and "dim_vec r = length ts" and "i < length ts"
  shows "lookup (row_to_poly ts r) (ts ! i) = r $ i"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. lookup (row_to_poly ts r) (ts ! i) = r $ i
[PROOF STEP]
proof (simp only: row_to_poly_def lookup_list_to_poly)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. list_to_fun ts (list_of_vec r) (ts ! i) = r $ i
[PROOF STEP]
from assms(2) assms(3)
[PROOF STATE]
proof (chain)
picking this:
dim_vec r = length ts
i < length ts
[PROOF STEP]
have "i < dim_vec r"
[PROOF STATE]
proof (prove)
using this:
dim_vec r = length ts
i < length ts

goal (1 subgoal):
 1. i < dim_vec r
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
i < dim_vec r

goal (1 subgoal):
 1. list_to_fun ts (list_of_vec r) (ts ! i) = r $ i
[PROOF STEP]
have "map_of (zip ts (list_of_vec r)) (ts ! i) = Some ((list_of_vec r) ! i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map_of (zip ts (list_of_vec r)) (ts ! i) = Some (list_of_vec r ! i)
[PROOF STEP]
by (rule map_of_zip_nth, simp_all only: length_list_of_vec assms(2), fact, fact)
[PROOF STATE]
proof (state)
this:
map_of (zip ts (list_of_vec r)) (ts ! i) = Some (list_of_vec r ! i)

goal (1 subgoal):
 1. list_to_fun ts (list_of_vec r) (ts ! i) = r $ i
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
map_of (zip ts (list_of_vec r)) (ts ! i) = Some (list_of_vec r ! i)

goal (1 subgoal):
 1. list_to_fun ts (list_of_vec r) (ts ! i) = r $ i
[PROOF STEP]
have "... = Some (r $ i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Some (list_of_vec r ! i) = Some (r $ i)
[PROOF STEP]
by (simp only: list_of_vec_index)
[PROOF STATE]
proof (state)
this:
Some (list_of_vec r ! i) = Some (r $ i)

goal (1 subgoal):
 1. list_to_fun ts (list_of_vec r) (ts ! i) = r $ i
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
map_of (zip ts (list_of_vec r)) (ts ! i) = Some (r $ i)
[PROOF STEP]
show "list_to_fun ts (list_of_vec r) (ts ! i) = r $ i"
[PROOF STATE]
proof (prove)
using this:
map_of (zip ts (list_of_vec r)) (ts ! i) = Some (r $ i)

goal (1 subgoal):
 1. list_to_fun ts (list_of_vec r) (ts ! i) = r $ i
[PROOF STEP]
by (simp add: list_to_fun_def)
[PROOF STATE]
proof (state)
this:
list_to_fun ts (list_of_vec r) (ts ! i) = r $ i

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma FvarsT_substT:
assumes "s \<in> atrm" "t \<in> trm" "x \<in> var"
shows "FvarsT (substT s t x) = (FvarsT s - {x}) \<union> (if x \<in> FvarsT s then FvarsT t else {})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. FvarsT (substT s t x) = FvarsT s - {x} \<union> (if x \<in> FvarsT s then FvarsT t else {})
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
s \<in> atrm
t \<in> trm
x \<in> var

goal (1 subgoal):
 1. FvarsT (substT s t x) = FvarsT s - {x} \<union> (if x \<in> FvarsT s then FvarsT t else {})
[PROOF STEP]
by induct auto


[STATEMENT]
lemma root_nat_floor [simp]: "root_nat_floor p x = floor (root p (real x))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. root_nat_floor p x = \<lfloor>root p (real x)\<rfloor>
[PROOF STEP]
unfolding root_nat_floor_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. root_int_floor_pos p (int x) = \<lfloor>root p (real x)\<rfloor>
[PROOF STEP]
using root_int_floor_pos[of "int x" p]
[PROOF STATE]
proof (prove)
using this:
0 \<le> int x \<Longrightarrow> root_int_floor_pos p (int x) = \<lfloor>root p (real_of_int (int x))\<rfloor>

goal (1 subgoal):
 1. root_int_floor_pos p (int x) = \<lfloor>root p (real x)\<rfloor>
[PROOF STEP]
by auto


[STATEMENT]
lemma Ball_at_Least0LessThan_conv [simp]:
  "length xs = n \<Longrightarrow>
    (\<forall>i \<in> {0 ..< n}. P (xs ! i)) \<longleftrightarrow> (\<forall>x \<in> set xs. P x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length xs = n \<Longrightarrow> (\<forall>i\<in>{0..<n}. P (xs ! i)) = (\<forall>x\<in>set xs. P x)
[PROOF STEP]
by (metis atLeast0LessThan in_set_conv_nth lessThan_iff)


[STATEMENT]
lemma list_decomp[rule_format]: "v \<in> set p --> (\<exists> xs ys. p = xs@(v#ys) \<and> v \<notin> set xs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. v \<in> set p \<longrightarrow> (\<exists>xs ys. p = xs @ v # ys \<and> v \<notin> set xs)
[PROOF STEP]
apply(induct p)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. v \<in> set [] \<longrightarrow> (\<exists>xs ys. [] = xs @ v # ys \<and> v \<notin> set xs)
 2. \<And>a p. v \<in> set p \<longrightarrow> (\<exists>xs ys. p = xs @ v # ys \<and> v \<notin> set xs) \<Longrightarrow> v \<in> set (a # p) \<longrightarrow> (\<exists>xs ys. a # p = xs @ v # ys \<and> v \<notin> set xs)
[PROOF STEP]
apply(force)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>a p. v \<in> set p \<longrightarrow> (\<exists>xs ys. p = xs @ v # ys \<and> v \<notin> set xs) \<Longrightarrow> v \<in> set (a # p) \<longrightarrow> (\<exists>xs ys. a # p = xs @ v # ys \<and> v \<notin> set xs)
[PROOF STEP]
apply(case_tac "v=a")
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>a p. \<lbrakk>v \<in> set p \<longrightarrow> (\<exists>xs ys. p = xs @ v # ys \<and> v \<notin> set xs); v = a\<rbrakk> \<Longrightarrow> v \<in> set (a # p) \<longrightarrow> (\<exists>xs ys. a # p = xs @ v # ys \<and> v \<notin> set xs)
 2. \<And>a p. \<lbrakk>v \<in> set p \<longrightarrow> (\<exists>xs ys. p = xs @ v # ys \<and> v \<notin> set xs); v \<noteq> a\<rbrakk> \<Longrightarrow> v \<in> set (a # p) \<longrightarrow> (\<exists>xs ys. a # p = xs @ v # ys \<and> v \<notin> set xs)
[PROOF STEP]
apply(force)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>a p. \<lbrakk>v \<in> set p \<longrightarrow> (\<exists>xs ys. p = xs @ v # ys \<and> v \<notin> set xs); v \<noteq> a\<rbrakk> \<Longrightarrow> v \<in> set (a # p) \<longrightarrow> (\<exists>xs ys. a # p = xs @ v # ys \<and> v \<notin> set xs)
[PROOF STEP]
apply(auto)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>a xs ys. \<lbrakk>v \<noteq> a; v \<notin> set xs\<rbrakk> \<Longrightarrow> \<exists>xsa. (\<exists>ysa. a # xs @ v # ys = xsa @ v # ysa) \<and> v \<notin> set xsa
[PROOF STEP]
apply(rule_tac x="a#xs" in exI)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>a xs ys. \<lbrakk>v \<noteq> a; v \<notin> set xs\<rbrakk> \<Longrightarrow> (\<exists>ysa. a # xs @ v # ys = (a # xs) @ v # ysa) \<and> v \<notin> set (a # xs)
[PROOF STEP]
apply(auto)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma le_apply_matrix:
  assumes
  "f 0 = 0"
  "\<forall>x y. x <= y \<longrightarrow> f x <= f y"
  "(a::('a::{ord, zero}) matrix) <= b"
  shows
  "apply_matrix f a <= apply_matrix f b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. apply_matrix f a \<le> apply_matrix f b
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
f (0::'a) = (0::'b)
\<forall>x y. x \<le> y \<longrightarrow> f x \<le> f y
a \<le> b

goal (1 subgoal):
 1. apply_matrix f a \<le> apply_matrix f b
[PROOF STEP]
by (simp add: le_matrix_def)


[STATEMENT]
lemma Nodes_subset: "Nodes i levellista \<subseteq> Nodes (Suc i) levellista"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Nodes i levellista \<subseteq> Nodes (Suc i) levellista
[PROOF STEP]
apply (simp add: Nodes_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Union>k\<in>{k. k < i}. set (levellista ! k)) \<subseteq> (\<Union>k\<in>{k. k < Suc i}. set (levellista ! k))
[PROOF STEP]
apply (simp add: set_split)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma fds_abs_converges_comparison_test:
  fixes s :: "'a :: dirichlet_series"
  assumes "eventually (\<lambda>n. norm (fds_nth f n) \<le> fds_nth g n) at_top" and "fds_converges g (s \<bullet> 1)"
  shows   "fds_abs_converges f s"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fds_abs_converges f s
[PROOF STEP]
unfolding fds_abs_converges_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. summable (\<lambda>n. norm (fds_nth f n / nat_power n s))
[PROOF STEP]
proof (rule summable_comparison_test_ev)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<forall>\<^sub>F n in sequentially. norm (norm (fds_nth f n / nat_power n s)) \<le> ?g n
 2. summable ?g
[PROOF STEP]
from assms(2)
[PROOF STATE]
proof (chain)
picking this:
fds_converges g (s \<bullet> (1::'a))
[PROOF STEP]
show "summable (\<lambda>n. fds_nth g n / n powr (s \<bullet> 1))"
[PROOF STATE]
proof (prove)
using this:
fds_converges g (s \<bullet> (1::'a))

goal (1 subgoal):
 1. summable (\<lambda>n. fds_nth g n / real n powr (s \<bullet> (1::'a)))
[PROOF STEP]
by (auto simp: fds_converges_def)
[PROOF STATE]
proof (state)
this:
summable (\<lambda>n. fds_nth g n / real n powr (s \<bullet> (1::'a)))

goal (1 subgoal):
 1. \<forall>\<^sub>F n in sequentially. norm (norm (fds_nth f n / nat_power n s)) \<le> fds_nth g n / real n powr (s \<bullet> (1::'a))
[PROOF STEP]
from assms(1) eventually_gt_at_top[of 0]
[PROOF STATE]
proof (chain)
picking this:
\<forall>\<^sub>F n in sequentially. norm (fds_nth f n) \<le> fds_nth g n
eventually ((<) (0::?'b1)) at_top
[PROOF STEP]
show "eventually (\<lambda>n. norm (norm (fds_nth f n / nat_power n s)) \<le>
                            fds_nth g n / real n powr (s \<bullet> 1)) at_top"
[PROOF STATE]
proof (prove)
using this:
\<forall>\<^sub>F n in sequentially. norm (fds_nth f n) \<le> fds_nth g n
eventually ((<) (0::?'b1)) at_top

goal (1 subgoal):
 1. \<forall>\<^sub>F n in sequentially. norm (norm (fds_nth f n / nat_power n s)) \<le> fds_nth g n / real n powr (s \<bullet> (1::'a))
[PROOF STEP]
by eventually_elim (auto simp: norm_divide norm_nat_power intro!: divide_right_mono)
[PROOF STATE]
proof (state)
this:
\<forall>\<^sub>F n in sequentially. norm (norm (fds_nth f n / nat_power n s)) \<le> fds_nth g n / real n powr (s \<bullet> (1::'a))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma card_Inr_vimage_le_length: "card (Inr -` set xs) \<le> length xs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card (Inr -` set xs) \<le> length xs
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. card (Inr -` set xs) \<le> length xs
[PROOF STEP]
have "card (Inr -` set xs) \<le> card (set xs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card (Inr -` set xs) \<le> card (set xs)
[PROOF STEP]
by (meson List.finite_set card_inj_on_le image_vimage_subset inj_Inr)
[PROOF STATE]
proof (state)
this:
card (Inr -` set xs) \<le> card (set xs)

goal (1 subgoal):
 1. card (Inr -` set xs) \<le> length xs
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
card (Inr -` set xs) \<le> card (set xs)

goal (1 subgoal):
 1. card (Inr -` set xs) \<le> length xs
[PROOF STEP]
have "\<dots> \<le> length xs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card (set xs) \<le> length xs
[PROOF STEP]
by (rule card_length)
[PROOF STATE]
proof (state)
this:
card (set xs) \<le> length xs

goal (1 subgoal):
 1. card (Inr -` set xs) \<le> length xs
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
card (Inr -` set xs) \<le> length xs
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
card (Inr -` set xs) \<le> length xs

goal (1 subgoal):
 1. card (Inr -` set xs) \<le> length xs
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
card (Inr -` set xs) \<le> length xs

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma mrbst_insert_altdef: "mrbst_insert x t = mrbst_union \<langle>\<langle>\<rangle>, x, \<langle>\<rangle>\<rangle> t"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mrbst_insert x t = mrbst_union \<langle>\<langle>\<rangle>, x, \<langle>\<rangle>\<rangle> t
[PROOF STEP]
by (induction x t rule: mrbst_insert.induct)
     (simp_all add: Let_def map_pmf_def bind_return_pmf case_prod_unfold cong: if_cong)


[STATEMENT]
lemma refine_trans_using_invariants:
  "\<lbrakk> {R \<inter> I \<times> J} (trans Ta), (trans Tc) {> R};
     {I \<inter> Domain (R \<inter> UNIV \<times> J)} (trans Ta) {> I};
     {J \<inter> Range (R \<inter> I \<times> UNIV)} (trans Tc) {> J} \<rbrakk>
  \<Longrightarrow> {R \<inter> I \<times> J} (trans Ta), (trans Tc) {> R  \<inter> I \<times> J}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>{R \<inter> I \<times> J} TS.trans Ta, TS.trans Tc {> R}; {I \<inter> Domain (R \<inter> UNIV \<times> J)} TS.trans Ta {> I}; {J \<inter> Range (R \<inter> I \<times> UNIV)} TS.trans Tc {> J}\<rbrakk> \<Longrightarrow> {R \<inter> I \<times> J} TS.trans Ta, TS.trans Tc {> R \<inter> I \<times> J}
[PROOF STEP]
by (rule relhoare_conj_right_cartesian) (auto)


[STATEMENT]
theorem "\<forall>(x::nat). \<exists>(y::nat). (0::nat) \<le> 5 \<longrightarrow> y = 5 + x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>x. \<exists>y. 0 \<le> 5 \<longrightarrow> y = 5 + x
[PROOF STEP]
by cooper


[STATEMENT]
lemma oSuc_plus_ordinal_of_nat:
"oSuc x + ordinal_of_nat n = oSuc (x + ordinal_of_nat n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. oSuc x + ordinal_of_nat n = oSuc (x + ordinal_of_nat n)
[PROOF STEP]
by (induct n) simp_all


[STATEMENT]
lemma primeD2: "prime p \<Longrightarrow> m dvd p \<Longrightarrow> m = 1 \<or> m = p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>prime p; m dvd p\<rbrakk> \<Longrightarrow> m = 1 \<or> m = p
[PROOF STEP]
by auto2