[STATEMENT]
lemma minus_flow:
  assumes wf: "wf_residual_network"
  and f: "flow \<Delta> f"
  and g: "flow \<Delta> g"
  and value_le: "value_flow \<Delta> g \<le> value_flow \<Delta> f"
  and f_finite: "f (source \<Delta>, x) \<noteq> \<top>"
  and source_out: "\<And>y. edge \<Delta> (source \<Delta>) y \<longleftrightarrow> y = x"
  shows "flow (residual_network g) (f \<ominus> g)" (is "flow ?\<Delta> ?f")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. flow (residual_network g) (f \<ominus> g)
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>e. (f \<ominus> g) e \<le> capacity (residual_network g) e
 2. \<And>x. \<lbrakk>x \<noteq> source (residual_network g); x \<noteq> sink (residual_network g)\<rbrakk> \<Longrightarrow> KIR (f \<ominus> g) x
[PROOF STEP]
show "?f e \<le> capacity ?\<Delta> e" for e
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (f \<ominus> g) e \<le> capacity (residual_network g) e
[PROOF STEP]
using value_le f_finite flowD_capacity[OF g] flowD_capacity[OF f]
[PROOF STATE]
proof (prove)
using this:
value_flow \<Delta> g \<le> value_flow \<Delta> f
f (source \<Delta>, x) \<noteq> \<top>
g ?e \<le> capacity \<Delta> ?e
f ?e \<le> capacity \<Delta> ?e

goal (1 subgoal):
 1. (f \<ominus> g) e \<le> capacity (residual_network g) e
[PROOF STEP]
by(cases e)(auto simp add: source_in source_out value_flow[OF f source_out] value_flow[OF g source_out] less_top
                     intro!: diff_le_self_ennreal diff_eq_0_ennreal ennreal_minus_mono)
[PROOF STATE]
proof (state)
this:
(f \<ominus> g) ?e \<le> capacity (residual_network g) ?e

goal (1 subgoal):
 1. \<And>x. \<lbrakk>x \<noteq> source (residual_network g); x \<noteq> sink (residual_network g)\<rbrakk> \<Longrightarrow> KIR (f \<ominus> g) x
[PROOF STEP]
fix x
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. \<lbrakk>x \<noteq> source (residual_network g); x \<noteq> sink (residual_network g)\<rbrakk> \<Longrightarrow> KIR (f \<ominus> g) x
[PROOF STEP]
assume "x \<noteq> source ?\<Delta>" "x \<noteq> sink ?\<Delta>"
[PROOF STATE]
proof (state)
this:
x \<noteq> source (residual_network g)
x \<noteq> sink (residual_network g)

goal (1 subgoal):
 1. \<And>x. \<lbrakk>x \<noteq> source (residual_network g); x \<noteq> sink (residual_network g)\<rbrakk> \<Longrightarrow> KIR (f \<ominus> g) x
[PROOF STEP]
hence x: "x \<noteq> source \<Delta>" "x \<noteq> sink \<Delta>"
[PROOF STATE]
proof (prove)
using this:
x \<noteq> source (residual_network g)
x \<noteq> sink (residual_network g)

goal (1 subgoal):
 1. x \<noteq> source \<Delta> &&& x \<noteq> sink \<Delta>
[PROOF STEP]
by simp_all
[PROOF STATE]
proof (state)
this:
x \<noteq> source \<Delta>
x \<noteq> sink \<Delta>

goal (1 subgoal):
 1. \<And>x. \<lbrakk>x \<noteq> source (residual_network g); x \<noteq> sink (residual_network g)\<rbrakk> \<Longrightarrow> KIR (f \<ominus> g) x
[PROOF STEP]
have finite_f_in: "(\<Sum>\<^sup>+ y. f (y, x) * indicator A y) \<noteq> top" for A
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<integral>\<^sup>+y\<in>A. f (y, x)\<partial>count_space UNIV \<noteq> \<top>
[PROOF STEP]
using flowD_finite_IN[OF f, of x]
[PROOF STATE]
proof (prove)
using this:
x \<noteq> sink \<Delta> \<Longrightarrow> d_IN f x \<noteq> \<top>

goal (1 subgoal):
 1. \<integral>\<^sup>+y\<in>A. f (y, x)\<partial>count_space UNIV \<noteq> \<top>
[PROOF STEP]
by(rule neq_top_trans)(auto simp add: x d_IN_def split: split_indicator intro!: nn_integral_mono)
[PROOF STATE]
proof (state)
this:
\<integral>\<^sup>+y\<in>?A. f (y, x)\<partial>count_space UNIV \<noteq> \<top>

goal (1 subgoal):
 1. \<And>x. \<lbrakk>x \<noteq> source (residual_network g); x \<noteq> sink (residual_network g)\<rbrakk> \<Longrightarrow> KIR (f \<ominus> g) x
[PROOF STEP]
have finite_f_out: "(\<Sum>\<^sup>+ y. f (x, y) * indicator A y) \<noteq> top" for A
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<integral>\<^sup>+y\<in>A. f (x, y)\<partial>count_space UNIV \<noteq> \<top>
[PROOF STEP]
using flowD_finite_OUT[OF f, of x]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>x \<noteq> source \<Delta>; x \<noteq> sink \<Delta>\<rbrakk> \<Longrightarrow> d_OUT f x \<noteq> \<top>

goal (1 subgoal):
 1. \<integral>\<^sup>+y\<in>A. f (x, y)\<partial>count_space UNIV \<noteq> \<top>
[PROOF STEP]
by(rule neq_top_trans)(auto simp add: x d_OUT_def split: split_indicator intro!: nn_integral_mono)
[PROOF STATE]
proof (state)
this:
\<integral>\<^sup>+y\<in>?A. f (x, y)\<partial>count_space UNIV \<noteq> \<top>

goal (1 subgoal):
 1. \<And>x. \<lbrakk>x \<noteq> source (residual_network g); x \<noteq> sink (residual_network g)\<rbrakk> \<Longrightarrow> KIR (f \<ominus> g) x
[PROOF STEP]
have finite_f[simp]: "f (x, y) \<noteq> top" "f (y, x) \<noteq> top" for y
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f (x, y) \<noteq> \<top> &&& f (y, x) \<noteq> \<top>
[PROOF STEP]
using finite_f_in[of "{y}"] finite_f_out[of "{y}"]
[PROOF STATE]
proof (prove)
using this:
\<integral>\<^sup>+y\<in>{y}. f (y, x)\<partial>count_space UNIV \<noteq> \<top>
\<integral>\<^sup>+y\<in>{y}. f (x, y)\<partial>count_space UNIV \<noteq> \<top>

goal (1 subgoal):
 1. f (x, y) \<noteq> \<top> &&& f (y, x) \<noteq> \<top>
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
f (x, ?y) \<noteq> \<top>
f (?y, x) \<noteq> \<top>

goal (1 subgoal):
 1. \<And>x. \<lbrakk>x \<noteq> source (residual_network g); x \<noteq> sink (residual_network g)\<rbrakk> \<Longrightarrow> KIR (f \<ominus> g) x
[PROOF STEP]
have finite_g_in: "(\<Sum>\<^sup>+ y. g (y, x) * indicator A y) \<noteq> top" for A
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<integral>\<^sup>+y\<in>A. g (y, x)\<partial>count_space UNIV \<noteq> \<top>
[PROOF STEP]
using flowD_finite_IN[OF g, of x]
[PROOF STATE]
proof (prove)
using this:
x \<noteq> sink \<Delta> \<Longrightarrow> d_IN g x \<noteq> \<top>

goal (1 subgoal):
 1. \<integral>\<^sup>+y\<in>A. g (y, x)\<partial>count_space UNIV \<noteq> \<top>
[PROOF STEP]
by(rule neq_top_trans)(auto simp add: x d_IN_def split: split_indicator intro!: nn_integral_mono)
[PROOF STATE]
proof (state)
this:
\<integral>\<^sup>+y\<in>?A. g (y, x)\<partial>count_space UNIV \<noteq> \<top>

goal (1 subgoal):
 1. \<And>x. \<lbrakk>x \<noteq> source (residual_network g); x \<noteq> sink (residual_network g)\<rbrakk> \<Longrightarrow> KIR (f \<ominus> g) x
[PROOF STEP]
have finite_g_out: "(\<Sum>\<^sup>+ y. g (x, y) * indicator A y) \<noteq> top" for A
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<integral>\<^sup>+y\<in>A. g (x, y)\<partial>count_space UNIV \<noteq> \<top>
[PROOF STEP]
using flowD_finite_OUT[OF g x]
[PROOF STATE]
proof (prove)
using this:
d_OUT g x \<noteq> \<top>

goal (1 subgoal):
 1. \<integral>\<^sup>+y\<in>A. g (x, y)\<partial>count_space UNIV \<noteq> \<top>
[PROOF STEP]
by(rule neq_top_trans)(auto simp add: x d_OUT_def split: split_indicator intro!: nn_integral_mono)
[PROOF STATE]
proof (state)
this:
\<integral>\<^sup>+y\<in>?A. g (x, y)\<partial>count_space UNIV \<noteq> \<top>

goal (1 subgoal):
 1. \<And>x. \<lbrakk>x \<noteq> source (residual_network g); x \<noteq> sink (residual_network g)\<rbrakk> \<Longrightarrow> KIR (f \<ominus> g) x
[PROOF STEP]
have finite_g[simp]: "g (x, y) \<noteq> top" "g (y, x) \<noteq> top" for y
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. g (x, y) \<noteq> \<top> &&& g (y, x) \<noteq> \<top>
[PROOF STEP]
using finite_g_in[of "{y}"] finite_g_out[of "{y}"]
[PROOF STATE]
proof (prove)
using this:
\<integral>\<^sup>+y\<in>{y}. g (y, x)\<partial>count_space UNIV \<noteq> \<top>
\<integral>\<^sup>+y\<in>{y}. g (x, y)\<partial>count_space UNIV \<noteq> \<top>

goal (1 subgoal):
 1. g (x, y) \<noteq> \<top> &&& g (y, x) \<noteq> \<top>
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
g (x, ?y) \<noteq> \<top>
g (?y, x) \<noteq> \<top>

goal (1 subgoal):
 1. \<And>x. \<lbrakk>x \<noteq> source (residual_network g); x \<noteq> sink (residual_network g)\<rbrakk> \<Longrightarrow> KIR (f \<ominus> g) x
[PROOF STEP]
have "d_OUT (f \<ominus> g) x = (\<Sum>\<^sup>+ y. (f (x, y) - g (x, y)) * indicator \<^bold>E (x, y) * indicator {y. g (x, y) \<le> f (x, y)} y) +
    (\<Sum>\<^sup>+ y. (g (y, x) - f (y, x)) * indicator \<^bold>E (y, x) * indicator {y. f (y, x) < g (y, x)} y)"
    (is "_ = ?out + ?in" is "_ = (\<Sum>\<^sup>+ y\<in>_. _ * ?f_ge_g y) + (\<Sum>\<^sup>+ y\<in>_. _ * ?g_gt_f y)")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. d_OUT (f \<ominus> g) x = (\<integral>\<^sup>+y\<in>{y. g (x, y) \<le> f (x, y)}. ((f (x, y) - g (x, y)) * indicator \<^bold>E (x, y))\<partial>count_space UNIV) + (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. ((g (y, x) - f (y, x)) * indicator \<^bold>E (y, x))\<partial>count_space UNIV)
[PROOF STEP]
using flowD_finite[OF g]
[PROOF STATE]
proof (prove)
using this:
g ?e \<noteq> \<top>

goal (1 subgoal):
 1. d_OUT (f \<ominus> g) x = (\<integral>\<^sup>+y\<in>{y. g (x, y) \<le> f (x, y)}. ((f (x, y) - g (x, y)) * indicator \<^bold>E (x, y))\<partial>count_space UNIV) + (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. ((g (y, x) - f (y, x)) * indicator \<^bold>E (y, x))\<partial>count_space UNIV)
[PROOF STEP]
apply(subst nn_integral_add[symmetric])
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. (\<And>e. g e \<noteq> \<top>) \<Longrightarrow> (\<lambda>y. (f (x, y) - g (x, y)) * indicator \<^bold>E (x, y) * indicator {y. g (x, y) \<le> f (x, y)} y) \<in> borel_measurable (count_space UNIV)
 2. (\<And>e. g e \<noteq> \<top>) \<Longrightarrow> (\<lambda>y. (g (y, x) - f (y, x)) * indicator \<^bold>E (y, x) * indicator {y. f (y, x) < g (y, x)} y) \<in> borel_measurable (count_space UNIV)
 3. (\<And>e. g e \<noteq> \<top>) \<Longrightarrow> d_OUT (f \<ominus> g) x = (\<Sum>\<^sup>+ x. (f (x, x) - g (x, x)) * indicator \<^bold>E (x, x) * indicator {y. g (x, y) \<le> f (x, y)} x + (g (x, x) - f (x, x)) * indicator \<^bold>E (x, x) * indicator {y. f (y, x) < g (y, x)} x)
[PROOF STEP]
apply(auto 4 4 simp add: d_OUT_def not_le less_top[symmetric] intro!: nn_integral_cong
           dest!: wf_residual_networkD[OF wf] split: split_indicator intro!: diff_eq_0_ennreal)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
d_OUT (f \<ominus> g) x = (\<integral>\<^sup>+y\<in>{y. g (x, y) \<le> f (x, y)}. ((f (x, y) - g (x, y)) * indicator \<^bold>E (x, y))\<partial>count_space UNIV) + (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. ((g (y, x) - f (y, x)) * indicator \<^bold>E (y, x))\<partial>count_space UNIV)

goal (1 subgoal):
 1. \<And>x. \<lbrakk>x \<noteq> source (residual_network g); x \<noteq> sink (residual_network g)\<rbrakk> \<Longrightarrow> KIR (f \<ominus> g) x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
d_OUT (f \<ominus> g) x = (\<integral>\<^sup>+y\<in>{y. g (x, y) \<le> f (x, y)}. ((f (x, y) - g (x, y)) * indicator \<^bold>E (x, y))\<partial>count_space UNIV) + (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. ((g (y, x) - f (y, x)) * indicator \<^bold>E (y, x))\<partial>count_space UNIV)

goal (1 subgoal):
 1. \<And>x. \<lbrakk>x \<noteq> source (residual_network g); x \<noteq> sink (residual_network g)\<rbrakk> \<Longrightarrow> KIR (f \<ominus> g) x
[PROOF STEP]
have "?in = (\<Sum>\<^sup>+ y. (g (y, x) - f (y, x)) * ?g_gt_f y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. ((g (y, x) - f (y, x)) * indicator \<^bold>E (y, x))\<partial>count_space UNIV = \<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. (g (y, x) - f (y, x))\<partial>count_space UNIV
[PROOF STEP]
using flowD_outside[OF f] flowD_outside[OF g]
[PROOF STATE]
proof (prove)
using this:
?e \<notin> \<^bold>E \<Longrightarrow> f ?e = 0
?e \<notin> \<^bold>E \<Longrightarrow> g ?e = 0

goal (1 subgoal):
 1. \<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. ((g (y, x) - f (y, x)) * indicator \<^bold>E (y, x))\<partial>count_space UNIV = \<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. (g (y, x) - f (y, x))\<partial>count_space UNIV
[PROOF STEP]
by(auto intro!: nn_integral_cong split: split_indicator)
[PROOF STATE]
proof (state)
this:
\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. ((g (y, x) - f (y, x)) * indicator \<^bold>E (y, x))\<partial>count_space UNIV = \<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. (g (y, x) - f (y, x))\<partial>count_space UNIV

goal (1 subgoal):
 1. \<And>x. \<lbrakk>x \<noteq> source (residual_network g); x \<noteq> sink (residual_network g)\<rbrakk> \<Longrightarrow> KIR (f \<ominus> g) x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. ((g (y, x) - f (y, x)) * indicator \<^bold>E (y, x))\<partial>count_space UNIV = \<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. (g (y, x) - f (y, x))\<partial>count_space UNIV

goal (1 subgoal):
 1. \<And>x. \<lbrakk>x \<noteq> source (residual_network g); x \<noteq> sink (residual_network g)\<rbrakk> \<Longrightarrow> KIR (f \<ominus> g) x
[PROOF STEP]
have "\<dots> = (\<Sum>\<^sup>+ y\<in>UNIV. g (y, x) * ?g_gt_f y) - (\<Sum>\<^sup>+ y. f (y, x) * ?g_gt_f y)" (is "_ = ?g_in - ?f_in")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. (g (y, x) - f (y, x))\<partial>count_space UNIV = (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV)
[PROOF STEP]
using finite_f_in
[PROOF STATE]
proof (prove)
using this:
\<integral>\<^sup>+y\<in>?A. f (y, x)\<partial>count_space UNIV \<noteq> \<top>

goal (1 subgoal):
 1. \<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. (g (y, x) - f (y, x))\<partial>count_space UNIV = (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV)
[PROOF STEP]
by(subst nn_integral_diff[symmetric])(auto simp add: AE_count_space split: split_indicator intro!: nn_integral_cong)
[PROOF STATE]
proof (state)
this:
\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. (g (y, x) - f (y, x))\<partial>count_space UNIV = (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV)

goal (1 subgoal):
 1. \<And>x. \<lbrakk>x \<noteq> source (residual_network g); x \<noteq> sink (residual_network g)\<rbrakk> \<Longrightarrow> KIR (f \<ominus> g) x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. (g (y, x) - f (y, x))\<partial>count_space UNIV = (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV)

goal (1 subgoal):
 1. \<And>x. \<lbrakk>x \<noteq> source (residual_network g); x \<noteq> sink (residual_network g)\<rbrakk> \<Longrightarrow> KIR (f \<ominus> g) x
[PROOF STEP]
have "?out = (\<Sum>\<^sup>+ y. (f (x, y) - g (x, y)) * ?f_ge_g y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<integral>\<^sup>+y\<in>{y. g (x, y) \<le> f (x, y)}. ((f (x, y) - g (x, y)) * indicator \<^bold>E (x, y))\<partial>count_space UNIV = \<integral>\<^sup>+y\<in>{y. g (x, y) \<le> f (x, y)}. (f (x, y) - g (x, y))\<partial>count_space UNIV
[PROOF STEP]
using flowD_outside[OF f] flowD_outside[OF g]
[PROOF STATE]
proof (prove)
using this:
?e \<notin> \<^bold>E \<Longrightarrow> f ?e = 0
?e \<notin> \<^bold>E \<Longrightarrow> g ?e = 0

goal (1 subgoal):
 1. \<integral>\<^sup>+y\<in>{y. g (x, y) \<le> f (x, y)}. ((f (x, y) - g (x, y)) * indicator \<^bold>E (x, y))\<partial>count_space UNIV = \<integral>\<^sup>+y\<in>{y. g (x, y) \<le> f (x, y)}. (f (x, y) - g (x, y))\<partial>count_space UNIV
[PROOF STEP]
by(auto intro!: nn_integral_cong split: split_indicator)
[PROOF STATE]
proof (state)
this:
\<integral>\<^sup>+y\<in>{y. g (x, y) \<le> f (x, y)}. ((f (x, y) - g (x, y)) * indicator \<^bold>E (x, y))\<partial>count_space UNIV = \<integral>\<^sup>+y\<in>{y. g (x, y) \<le> f (x, y)}. (f (x, y) - g (x, y))\<partial>count_space UNIV

goal (1 subgoal):
 1. \<And>x. \<lbrakk>x \<noteq> source (residual_network g); x \<noteq> sink (residual_network g)\<rbrakk> \<Longrightarrow> KIR (f \<ominus> g) x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
\<integral>\<^sup>+y\<in>{y. g (x, y) \<le> f (x, y)}. ((f (x, y) - g (x, y)) * indicator \<^bold>E (x, y))\<partial>count_space UNIV = \<integral>\<^sup>+y\<in>{y. g (x, y) \<le> f (x, y)}. (f (x, y) - g (x, y))\<partial>count_space UNIV

goal (1 subgoal):
 1. \<And>x. \<lbrakk>x \<noteq> source (residual_network g); x \<noteq> sink (residual_network g)\<rbrakk> \<Longrightarrow> KIR (f \<ominus> g) x
[PROOF STEP]
have "\<dots> = (\<Sum>\<^sup>+ y. f (x, y) * ?f_ge_g y) - (\<Sum>\<^sup>+ y. g (x, y) * ?f_ge_g y)" (is "_ = ?f_out - ?g_out")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<integral>\<^sup>+y\<in>{y. g (x, y) \<le> f (x, y)}. (f (x, y) - g (x, y))\<partial>count_space UNIV = (\<integral>\<^sup>+y\<in>{y. g (x, y) \<le> f (x, y)}. f (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. g (x, y) \<le> f (x, y)}. g (x, y)\<partial>count_space UNIV)
[PROOF STEP]
using finite_g_out
[PROOF STATE]
proof (prove)
using this:
\<integral>\<^sup>+y\<in>?A. g (x, y)\<partial>count_space UNIV \<noteq> \<top>

goal (1 subgoal):
 1. \<integral>\<^sup>+y\<in>{y. g (x, y) \<le> f (x, y)}. (f (x, y) - g (x, y))\<partial>count_space UNIV = (\<integral>\<^sup>+y\<in>{y. g (x, y) \<le> f (x, y)}. f (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. g (x, y) \<le> f (x, y)}. g (x, y)\<partial>count_space UNIV)
[PROOF STEP]
by(subst nn_integral_diff[symmetric])(auto simp add: AE_count_space split: split_indicator intro!: nn_integral_cong)
[PROOF STATE]
proof (state)
this:
\<integral>\<^sup>+y\<in>{y. g (x, y) \<le> f (x, y)}. (f (x, y) - g (x, y))\<partial>count_space UNIV = (\<integral>\<^sup>+y\<in>{y. g (x, y) \<le> f (x, y)}. f (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. g (x, y) \<le> f (x, y)}. g (x, y)\<partial>count_space UNIV)

goal (1 subgoal):
 1. \<And>x. \<lbrakk>x \<noteq> source (residual_network g); x \<noteq> sink (residual_network g)\<rbrakk> \<Longrightarrow> KIR (f \<ominus> g) x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
\<integral>\<^sup>+y\<in>{y. g (x, y) \<le> f (x, y)}. (f (x, y) - g (x, y))\<partial>count_space UNIV = (\<integral>\<^sup>+y\<in>{y. g (x, y) \<le> f (x, y)}. f (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. g (x, y) \<le> f (x, y)}. g (x, y)\<partial>count_space UNIV)

goal (1 subgoal):
 1. \<And>x. \<lbrakk>x \<noteq> source (residual_network g); x \<noteq> sink (residual_network g)\<rbrakk> \<Longrightarrow> KIR (f \<ominus> g) x
[PROOF STEP]
have "?f_out = d_OUT f x - (\<Sum>\<^sup>+ y. f (x, y) * indicator {y. f (x, y) < g (x, y)} y)" (is "_ = _ - ?f_out_less")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<integral>\<^sup>+y\<in>{y. g (x, y) \<le> f (x, y)}. f (x, y)\<partial>count_space UNIV = d_OUT f x - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV)
[PROOF STEP]
unfolding d_OUT_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<integral>\<^sup>+y\<in>{y. g (x, y) \<le> f (x, y)}. f (x, y)\<partial>count_space UNIV = (\<Sum>\<^sup>+ y. f (x, y)) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV)
[PROOF STEP]
using flowD_finite[OF f]
[PROOF STATE]
proof (prove)
using this:
f ?e \<noteq> \<top>

goal (1 subgoal):
 1. \<integral>\<^sup>+y\<in>{y. g (x, y) \<le> f (x, y)}. f (x, y)\<partial>count_space UNIV = (\<Sum>\<^sup>+ y. f (x, y)) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV)
[PROOF STEP]
using finite_f_out
[PROOF STATE]
proof (prove)
using this:
f ?e \<noteq> \<top>
\<integral>\<^sup>+y\<in>?A. f (x, y)\<partial>count_space UNIV \<noteq> \<top>

goal (1 subgoal):
 1. \<integral>\<^sup>+y\<in>{y. g (x, y) \<le> f (x, y)}. f (x, y)\<partial>count_space UNIV = (\<Sum>\<^sup>+ y. f (x, y)) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV)
[PROOF STEP]
by(subst nn_integral_diff[symmetric])(auto split: split_indicator intro!: nn_integral_cong)
[PROOF STATE]
proof (state)
this:
\<integral>\<^sup>+y\<in>{y. g (x, y) \<le> f (x, y)}. f (x, y)\<partial>count_space UNIV = d_OUT f x - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV)

goal (1 subgoal):
 1. \<And>x. \<lbrakk>x \<noteq> source (residual_network g); x \<noteq> sink (residual_network g)\<rbrakk> \<Longrightarrow> KIR (f \<ominus> g) x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
\<integral>\<^sup>+y\<in>{y. g (x, y) \<le> f (x, y)}. f (x, y)\<partial>count_space UNIV = d_OUT f x - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV)

goal (1 subgoal):
 1. \<And>x. \<lbrakk>x \<noteq> source (residual_network g); x \<noteq> sink (residual_network g)\<rbrakk> \<Longrightarrow> KIR (f \<ominus> g) x
[PROOF STEP]
have "?g_out = d_OUT g x - (\<Sum>\<^sup>+ y. g (x, y) * indicator {y. f (x, y) < g (x, y)} y)" (is "_ = _ - ?g_less_f")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<integral>\<^sup>+y\<in>{y. g (x, y) \<le> f (x, y)}. g (x, y)\<partial>count_space UNIV = d_OUT g x - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV)
[PROOF STEP]
unfolding d_OUT_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<integral>\<^sup>+y\<in>{y. g (x, y) \<le> f (x, y)}. g (x, y)\<partial>count_space UNIV = (\<Sum>\<^sup>+ y. g (x, y)) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV)
[PROOF STEP]
using flowD_finite[OF g] finite_g_out
[PROOF STATE]
proof (prove)
using this:
g ?e \<noteq> \<top>
\<integral>\<^sup>+y\<in>?A. g (x, y)\<partial>count_space UNIV \<noteq> \<top>

goal (1 subgoal):
 1. \<integral>\<^sup>+y\<in>{y. g (x, y) \<le> f (x, y)}. g (x, y)\<partial>count_space UNIV = (\<Sum>\<^sup>+ y. g (x, y)) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV)
[PROOF STEP]
by(subst nn_integral_diff[symmetric])(auto split: split_indicator intro!: nn_integral_cong)
[PROOF STATE]
proof (state)
this:
\<integral>\<^sup>+y\<in>{y. g (x, y) \<le> f (x, y)}. g (x, y)\<partial>count_space UNIV = d_OUT g x - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV)

goal (1 subgoal):
 1. \<And>x. \<lbrakk>x \<noteq> source (residual_network g); x \<noteq> sink (residual_network g)\<rbrakk> \<Longrightarrow> KIR (f \<ominus> g) x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
\<integral>\<^sup>+y\<in>{y. g (x, y) \<le> f (x, y)}. g (x, y)\<partial>count_space UNIV = d_OUT g x - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV)

goal (1 subgoal):
 1. \<And>x. \<lbrakk>x \<noteq> source (residual_network g); x \<noteq> sink (residual_network g)\<rbrakk> \<Longrightarrow> KIR (f \<ominus> g) x
[PROOF STEP]
have "d_OUT f x - ?f_out_less - (d_OUT g x - ?g_less_f) + (?g_in - ?f_in) =
    (?g_less_f + (d_OUT f x - ?f_out_less)) - d_OUT g x + (?g_in - ?f_in)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. d_OUT f x - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV) - (d_OUT g x - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV)) + ((\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV)) = (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) + (d_OUT f x - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV)) - d_OUT g x + ((\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV))
[PROOF STEP]
by (subst diff_diff_ennreal')
       (auto simp: ac_simps d_OUT_def nn_integral_diff[symmetric] finite_g_out finite_f_out intro!: nn_integral_mono split: split_indicator )
[PROOF STATE]
proof (state)
this:
d_OUT f x - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV) - (d_OUT g x - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV)) + ((\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV)) = (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) + (d_OUT f x - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV)) - d_OUT g x + ((\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV))

goal (1 subgoal):
 1. \<And>x. \<lbrakk>x \<noteq> source (residual_network g); x \<noteq> sink (residual_network g)\<rbrakk> \<Longrightarrow> KIR (f \<ominus> g) x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
d_OUT f x - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV) - (d_OUT g x - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV)) + ((\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV)) = (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) + (d_OUT f x - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV)) - d_OUT g x + ((\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV))

goal (1 subgoal):
 1. \<And>x. \<lbrakk>x \<noteq> source (residual_network g); x \<noteq> sink (residual_network g)\<rbrakk> \<Longrightarrow> KIR (f \<ominus> g) x
[PROOF STEP]
have "\<dots> = ?g_less_f + d_OUT f x - ?f_out_less - d_OUT g x + (?g_in - ?f_in)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) + (d_OUT f x - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV)) - d_OUT g x + ((\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV)) = (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) + d_OUT f x - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV) - d_OUT g x + ((\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV))
[PROOF STEP]
by (subst add_diff_eq_ennreal)
       (auto simp: d_OUT_def intro!: nn_integral_mono split: split_indicator)
[PROOF STATE]
proof (state)
this:
(\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) + (d_OUT f x - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV)) - d_OUT g x + ((\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV)) = (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) + d_OUT f x - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV) - d_OUT g x + ((\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV))

goal (1 subgoal):
 1. \<And>x. \<lbrakk>x \<noteq> source (residual_network g); x \<noteq> sink (residual_network g)\<rbrakk> \<Longrightarrow> KIR (f \<ominus> g) x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) + (d_OUT f x - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV)) - d_OUT g x + ((\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV)) = (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) + d_OUT f x - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV) - d_OUT g x + ((\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV))

goal (1 subgoal):
 1. \<And>x. \<lbrakk>x \<noteq> source (residual_network g); x \<noteq> sink (residual_network g)\<rbrakk> \<Longrightarrow> KIR (f \<ominus> g) x
[PROOF STEP]
have "\<dots> = d_OUT f x + ?g_less_f - ?f_out_less - d_OUT g x + (?g_in - ?f_in)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) + d_OUT f x - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV) - d_OUT g x + ((\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV)) = d_OUT f x + (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV) - d_OUT g x + ((\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV))
[PROOF STEP]
by (simp add: ac_simps)
[PROOF STATE]
proof (state)
this:
(\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) + d_OUT f x - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV) - d_OUT g x + ((\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV)) = d_OUT f x + (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV) - d_OUT g x + ((\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV))

goal (1 subgoal):
 1. \<And>x. \<lbrakk>x \<noteq> source (residual_network g); x \<noteq> sink (residual_network g)\<rbrakk> \<Longrightarrow> KIR (f \<ominus> g) x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) + d_OUT f x - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV) - d_OUT g x + ((\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV)) = d_OUT f x + (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV) - d_OUT g x + ((\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV))

goal (1 subgoal):
 1. \<And>x. \<lbrakk>x \<noteq> source (residual_network g); x \<noteq> sink (residual_network g)\<rbrakk> \<Longrightarrow> KIR (f \<ominus> g) x
[PROOF STEP]
have "\<dots> = d_OUT f x + (?g_less_f - ?f_out_less) - d_OUT g x + (?g_in - ?f_in)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. d_OUT f x + (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV) - d_OUT g x + ((\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV)) = d_OUT f x + ((\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV)) - d_OUT g x + ((\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV))
[PROOF STEP]
by (subst add_diff_eq_ennreal[symmetric])
       (auto intro!: nn_integral_mono split: split_indicator)
[PROOF STATE]
proof (state)
this:
d_OUT f x + (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV) - d_OUT g x + ((\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV)) = d_OUT f x + ((\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV)) - d_OUT g x + ((\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV))

goal (1 subgoal):
 1. \<And>x. \<lbrakk>x \<noteq> source (residual_network g); x \<noteq> sink (residual_network g)\<rbrakk> \<Longrightarrow> KIR (f \<ominus> g) x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
d_OUT f x + (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV) - d_OUT g x + ((\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV)) = d_OUT f x + ((\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV)) - d_OUT g x + ((\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV))

goal (1 subgoal):
 1. \<And>x. \<lbrakk>x \<noteq> source (residual_network g); x \<noteq> sink (residual_network g)\<rbrakk> \<Longrightarrow> KIR (f \<ominus> g) x
[PROOF STEP]
have "\<dots> = (?g_in - ?f_in) + ((?g_less_f - ?f_out_less) + d_OUT f x - d_OUT g x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. d_OUT f x + ((\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV)) - d_OUT g x + ((\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV)) = (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV) + ((\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV) + d_OUT f x - d_OUT g x)
[PROOF STEP]
by (simp add: ac_simps)
[PROOF STATE]
proof (state)
this:
d_OUT f x + ((\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV)) - d_OUT g x + ((\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV)) = (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV) + ((\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV) + d_OUT f x - d_OUT g x)

goal (1 subgoal):
 1. \<And>x. \<lbrakk>x \<noteq> source (residual_network g); x \<noteq> sink (residual_network g)\<rbrakk> \<Longrightarrow> KIR (f \<ominus> g) x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
d_OUT f x + ((\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV)) - d_OUT g x + ((\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV)) = (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV) + ((\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV) + d_OUT f x - d_OUT g x)

goal (1 subgoal):
 1. \<And>x. \<lbrakk>x \<noteq> source (residual_network g); x \<noteq> sink (residual_network g)\<rbrakk> \<Longrightarrow> KIR (f \<ominus> g) x
[PROOF STEP]
have "\<dots> = ((?g_in - ?f_in) + ((?g_less_f - ?f_out_less) + d_OUT f x)) - d_OUT g x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV) + ((\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV) + d_OUT f x - d_OUT g x) = (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV) + ((\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV) + d_OUT f x) - d_OUT g x
[PROOF STEP]
apply (subst add_diff_eq_ennreal)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. d_OUT g x \<le> (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV) + d_OUT f x
 2. (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV) + ((\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV) + d_OUT f x) - d_OUT g x = (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV) + ((\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV) + d_OUT f x) - d_OUT g x
[PROOF STEP]
apply (simp_all add: d_OUT_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>\<^sup>+ y. g (x, y)) \<le> (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV) + (\<Sum>\<^sup>+ y. f (x, y))
[PROOF STEP]
apply (subst nn_integral_diff[symmetric])
[PROOF STATE]
proof (prove)
goal (5 subgoals):
 1. (\<lambda>y. g (x, y) * indicator {y. f (x, y) < g (x, y)} y) \<in> borel_measurable (count_space UNIV)
 2. (\<lambda>y. f (x, y) * indicator {y. f (x, y) < g (x, y)} y) \<in> borel_measurable (count_space UNIV)
 3. \<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV \<noteq> \<infinity>
 4. AE x in count_space UNIV. f (x, x) * indicator {y. f (x, y) < g (x, y)} x \<le> g (x, x) * indicator {y. f (x, y) < g (x, y)} x
 5. (\<Sum>\<^sup>+ y. g (x, y)) \<le> (\<Sum>\<^sup>+ x. g (x, x) * indicator {y. f (x, y) < g (x, y)} x - f (x, x) * indicator {y. f (x, y) < g (x, y)} x) + (\<Sum>\<^sup>+ y. f (x, y))
[PROOF STEP]
apply (auto simp: AE_count_space finite_f_out nn_integral_add[symmetric] not_less diff_add_cancel_ennreal intro!: nn_integral_mono split: split_indicator)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
(\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV) + ((\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV) + d_OUT f x - d_OUT g x) = (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV) + ((\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV) + d_OUT f x) - d_OUT g x

goal (1 subgoal):
 1. \<And>x. \<lbrakk>x \<noteq> source (residual_network g); x \<noteq> sink (residual_network g)\<rbrakk> \<Longrightarrow> KIR (f \<ominus> g) x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV) + ((\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV) + d_OUT f x - d_OUT g x) = (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV) + ((\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV) + d_OUT f x) - d_OUT g x

goal (1 subgoal):
 1. \<And>x. \<lbrakk>x \<noteq> source (residual_network g); x \<noteq> sink (residual_network g)\<rbrakk> \<Longrightarrow> KIR (f \<ominus> g) x
[PROOF STEP]
have "\<dots> = ((?g_less_f - ?f_out_less) + (d_OUT f x + (?g_in - ?f_in))) - d_OUT g x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV) + ((\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV) + d_OUT f x) - d_OUT g x = (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV) + (d_OUT f x + ((\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV))) - d_OUT g x
[PROOF STEP]
by (simp add: ac_simps)
[PROOF STATE]
proof (state)
this:
(\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV) + ((\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV) + d_OUT f x) - d_OUT g x = (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV) + (d_OUT f x + ((\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV))) - d_OUT g x

goal (1 subgoal):
 1. \<And>x. \<lbrakk>x \<noteq> source (residual_network g); x \<noteq> sink (residual_network g)\<rbrakk> \<Longrightarrow> KIR (f \<ominus> g) x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV) + ((\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV) + d_OUT f x) - d_OUT g x = (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV) + (d_OUT f x + ((\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV))) - d_OUT g x

goal (1 subgoal):
 1. \<And>x. \<lbrakk>x \<noteq> source (residual_network g); x \<noteq> sink (residual_network g)\<rbrakk> \<Longrightarrow> KIR (f \<ominus> g) x
[PROOF STEP]
have "\<dots> = ((?g_less_f - ?f_out_less) + (d_IN f x + (?g_in - ?f_in))) - d_IN g x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV) + (d_OUT f x + ((\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV))) - d_OUT g x = (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV) + (d_IN f x + ((\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV))) - d_IN g x
[PROOF STEP]
unfolding flowD_KIR[OF f x] flowD_KIR[OF g x]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV) + (d_IN f x + ((\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV))) - d_IN g x = (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV) + (d_IN f x + ((\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV))) - d_IN g x
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
(\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV) + (d_OUT f x + ((\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV))) - d_OUT g x = (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV) + (d_IN f x + ((\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV))) - d_IN g x

goal (1 subgoal):
 1. \<And>x. \<lbrakk>x \<noteq> source (residual_network g); x \<noteq> sink (residual_network g)\<rbrakk> \<Longrightarrow> KIR (f \<ominus> g) x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV) + (d_OUT f x + ((\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV))) - d_OUT g x = (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV) + (d_IN f x + ((\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV))) - d_IN g x

goal (1 subgoal):
 1. \<And>x. \<lbrakk>x \<noteq> source (residual_network g); x \<noteq> sink (residual_network g)\<rbrakk> \<Longrightarrow> KIR (f \<ominus> g) x
[PROOF STEP]
have "\<dots> = (?g_less_f - ?f_out_less) + ((d_IN f x + (?g_in - ?f_in)) - d_IN g x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV) + (d_IN f x + ((\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV))) - d_IN g x = (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV) + (d_IN f x + ((\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV)) - d_IN g x)
[PROOF STEP]
apply (subst (2) add_diff_eq_ennreal)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. d_IN g x \<le> d_IN f x + ((\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV))
 2. (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV) + (d_IN f x + ((\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV))) - d_IN g x = (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV) + (d_IN f x + ((\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV))) - d_IN g x
[PROOF STEP]
apply (simp_all add: d_IN_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>\<^sup>+ x. g (x, x)) \<le> (\<Sum>\<^sup>+ x. f (x, x)) + ((\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV))
[PROOF STEP]
apply (subst nn_integral_diff[symmetric])
[PROOF STATE]
proof (prove)
goal (5 subgoals):
 1. (\<lambda>y. g (y, x) * indicator {y. f (y, x) < g (y, x)} y) \<in> borel_measurable (count_space UNIV)
 2. (\<lambda>y. f (y, x) * indicator {y. f (y, x) < g (y, x)} y) \<in> borel_measurable (count_space UNIV)
 3. \<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV \<noteq> \<infinity>
 4. AE x in count_space UNIV. f (x, x) * indicator {y. f (y, x) < g (y, x)} x \<le> g (x, x) * indicator {y. f (y, x) < g (y, x)} x
 5. (\<Sum>\<^sup>+ x. g (x, x)) \<le> (\<Sum>\<^sup>+ x. f (x, x)) + (\<Sum>\<^sup>+ x. g (x, x) * indicator {y. f (y, x) < g (y, x)} x - f (x, x) * indicator {y. f (y, x) < g (y, x)} x)
[PROOF STEP]
apply (auto simp: AE_count_space finite_f_in finite_f_out nn_integral_add[symmetric] not_less  ennreal_ineq_diff_add[symmetric]
                intro!: nn_integral_mono split: split_indicator)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
(\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV) + (d_IN f x + ((\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV))) - d_IN g x = (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV) + (d_IN f x + ((\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV)) - d_IN g x)

goal (1 subgoal):
 1. \<And>x. \<lbrakk>x \<noteq> source (residual_network g); x \<noteq> sink (residual_network g)\<rbrakk> \<Longrightarrow> KIR (f \<ominus> g) x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV) + (d_IN f x + ((\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV))) - d_IN g x = (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV) + (d_IN f x + ((\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV)) - d_IN g x)

goal (1 subgoal):
 1. \<And>x. \<lbrakk>x \<noteq> source (residual_network g); x \<noteq> sink (residual_network g)\<rbrakk> \<Longrightarrow> KIR (f \<ominus> g) x
[PROOF STEP]
have "\<dots> = (?g_less_f - ?f_out_less) + (d_IN f x + ?g_in - d_IN g x - ?f_in)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV) + (d_IN f x + ((\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV)) - d_IN g x) = (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV) + (d_IN f x + (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - d_IN g x - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV))
[PROOF STEP]
by (subst (2) add_diff_eq_ennreal) (auto intro!: nn_integral_mono split: split_indicator simp: diff_diff_commute_ennreal)
[PROOF STATE]
proof (state)
this:
(\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV) + (d_IN f x + ((\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV)) - d_IN g x) = (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV) + (d_IN f x + (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - d_IN g x - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV))

goal (1 subgoal):
 1. \<And>x. \<lbrakk>x \<noteq> source (residual_network g); x \<noteq> sink (residual_network g)\<rbrakk> \<Longrightarrow> KIR (f \<ominus> g) x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV) + (d_IN f x + ((\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV)) - d_IN g x) = (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV) + (d_IN f x + (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - d_IN g x - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV))

goal (1 subgoal):
 1. \<And>x. \<lbrakk>x \<noteq> source (residual_network g); x \<noteq> sink (residual_network g)\<rbrakk> \<Longrightarrow> KIR (f \<ominus> g) x
[PROOF STEP]
have "\<dots> = (?g_less_f - ?f_out_less) + (d_IN f x - (d_IN g x - ?g_in) - ?f_in)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV) + (d_IN f x + (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - d_IN g x - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV)) = (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV) + (d_IN f x - (d_IN g x - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV)) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV))
[PROOF STEP]
apply (subst diff_diff_ennreal')
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. \<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV \<le> d_IN g x
 2. d_IN g x - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) \<le> d_IN f x
 3. (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV) + (d_IN f x + (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - d_IN g x - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV)) = (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV) + (d_IN f x + (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - d_IN g x - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV))
[PROOF STEP]
apply (auto simp: d_IN_def intro!: nn_integral_mono split: split_indicator)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>\<^sup>+ x. g (x, x)) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) \<le> (\<Sum>\<^sup>+ x. f (x, x))
[PROOF STEP]
apply (subst nn_integral_diff[symmetric])
[PROOF STATE]
proof (prove)
goal (5 subgoals):
 1. (\<lambda>x. g (x, x)) \<in> borel_measurable (count_space UNIV)
 2. (\<lambda>y. g (y, x) * indicator {y. f (y, x) < g (y, x)} y) \<in> borel_measurable (count_space UNIV)
 3. \<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV \<noteq> \<infinity>
 4. AE x in count_space UNIV. g (x, x) * indicator {y. f (y, x) < g (y, x)} x \<le> g (x, x)
 5. (\<Sum>\<^sup>+ x. g (x, x) - g (x, x) * indicator {y. f (y, x) < g (y, x)} x) \<le> (\<Sum>\<^sup>+ x. f (x, x))
[PROOF STEP]
apply (auto simp: AE_count_space finite_g_in intro!: nn_integral_mono split: split_indicator)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
(\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV) + (d_IN f x + (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - d_IN g x - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV)) = (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV) + (d_IN f x - (d_IN g x - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV)) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV))

goal (1 subgoal):
 1. \<And>x. \<lbrakk>x \<noteq> source (residual_network g); x \<noteq> sink (residual_network g)\<rbrakk> \<Longrightarrow> KIR (f \<ominus> g) x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV) + (d_IN f x + (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) - d_IN g x - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV)) = (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV) + (d_IN f x - (d_IN g x - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV)) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV))

goal (1 subgoal):
 1. \<And>x. \<lbrakk>x \<noteq> source (residual_network g); x \<noteq> sink (residual_network g)\<rbrakk> \<Longrightarrow> KIR (f \<ominus> g) x
[PROOF STEP]
have "\<dots> =(d_IN f x - ?f_in) - (d_IN g x - ?g_in) + (?g_less_f - ?f_out_less)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV) + (d_IN f x - (d_IN g x - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV)) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV)) = d_IN f x - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV) - (d_IN g x - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV)) + ((\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV))
[PROOF STEP]
by (simp add: ac_simps diff_diff_commute_ennreal)
[PROOF STATE]
proof (state)
this:
(\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV) + (d_IN f x - (d_IN g x - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV)) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV)) = d_IN f x - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV) - (d_IN g x - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV)) + ((\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV))

goal (1 subgoal):
 1. \<And>x. \<lbrakk>x \<noteq> source (residual_network g); x \<noteq> sink (residual_network g)\<rbrakk> \<Longrightarrow> KIR (f \<ominus> g) x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV) + (d_IN f x - (d_IN g x - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV)) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV)) = d_IN f x - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV) - (d_IN g x - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV)) + ((\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV))

goal (1 subgoal):
 1. \<And>x. \<lbrakk>x \<noteq> source (residual_network g); x \<noteq> sink (residual_network g)\<rbrakk> \<Longrightarrow> KIR (f \<ominus> g) x
[PROOF STEP]
have "?g_less_f - ?f_out_less = (\<Sum>\<^sup>+ y. (g (x, y) - f (x, y)) * indicator {y. f (x, y) < g (x, y)} y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV) = \<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. (g (x, y) - f (x, y))\<partial>count_space UNIV
[PROOF STEP]
using finite_f_out
[PROOF STATE]
proof (prove)
using this:
\<integral>\<^sup>+y\<in>?A. f (x, y)\<partial>count_space UNIV \<noteq> \<top>

goal (1 subgoal):
 1. (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV) = \<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. (g (x, y) - f (x, y))\<partial>count_space UNIV
[PROOF STEP]
by(subst nn_integral_diff[symmetric])(auto simp add: AE_count_space split: split_indicator intro!: nn_integral_cong)
[PROOF STATE]
proof (state)
this:
(\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV) = \<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. (g (x, y) - f (x, y))\<partial>count_space UNIV

goal (1 subgoal):
 1. \<And>x. \<lbrakk>x \<noteq> source (residual_network g); x \<noteq> sink (residual_network g)\<rbrakk> \<Longrightarrow> KIR (f \<ominus> g) x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. g (x, y)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. f (x, y)\<partial>count_space UNIV) = \<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. (g (x, y) - f (x, y))\<partial>count_space UNIV

goal (1 subgoal):
 1. \<And>x. \<lbrakk>x \<noteq> source (residual_network g); x \<noteq> sink (residual_network g)\<rbrakk> \<Longrightarrow> KIR (f \<ominus> g) x
[PROOF STEP]
have "\<dots> = (\<Sum>\<^sup>+ y. (g (x, y) - f (x, y)) * indicator \<^bold>E (x, y) * indicator {y. f (x, y) < g (x, y)} y)" (is "_ = ?diff_out")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. (g (x, y) - f (x, y))\<partial>count_space UNIV = \<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. ((g (x, y) - f (x, y)) * indicator \<^bold>E (x, y))\<partial>count_space UNIV
[PROOF STEP]
using flowD_outside[OF f] flowD_outside[OF g]
[PROOF STATE]
proof (prove)
using this:
?e \<notin> \<^bold>E \<Longrightarrow> f ?e = 0
?e \<notin> \<^bold>E \<Longrightarrow> g ?e = 0

goal (1 subgoal):
 1. \<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. (g (x, y) - f (x, y))\<partial>count_space UNIV = \<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. ((g (x, y) - f (x, y)) * indicator \<^bold>E (x, y))\<partial>count_space UNIV
[PROOF STEP]
by(auto intro!: nn_integral_cong split: split_indicator)
[PROOF STATE]
proof (state)
this:
\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. (g (x, y) - f (x, y))\<partial>count_space UNIV = \<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. ((g (x, y) - f (x, y)) * indicator \<^bold>E (x, y))\<partial>count_space UNIV

goal (1 subgoal):
 1. \<And>x. \<lbrakk>x \<noteq> source (residual_network g); x \<noteq> sink (residual_network g)\<rbrakk> \<Longrightarrow> KIR (f \<ominus> g) x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. (g (x, y) - f (x, y))\<partial>count_space UNIV = \<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. ((g (x, y) - f (x, y)) * indicator \<^bold>E (x, y))\<partial>count_space UNIV

goal (1 subgoal):
 1. \<And>x. \<lbrakk>x \<noteq> source (residual_network g); x \<noteq> sink (residual_network g)\<rbrakk> \<Longrightarrow> KIR (f \<ominus> g) x
[PROOF STEP]
have "d_IN f x - ?f_in = (\<Sum>\<^sup>+ y. f (y, x) * indicator {y. g (y, x) \<le> f (y, x)} y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. d_IN f x - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV) = \<integral>\<^sup>+y\<in>{y. g (y, x) \<le> f (y, x)}. f (y, x)\<partial>count_space UNIV
[PROOF STEP]
unfolding d_IN_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>\<^sup>+ x. f (x, x)) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV) = \<integral>\<^sup>+y\<in>{y. g (y, x) \<le> f (y, x)}. f (y, x)\<partial>count_space UNIV
[PROOF STEP]
using finite_f_in
[PROOF STATE]
proof (prove)
using this:
\<integral>\<^sup>+y\<in>?A. f (y, x)\<partial>count_space UNIV \<noteq> \<top>

goal (1 subgoal):
 1. (\<Sum>\<^sup>+ x. f (x, x)) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV) = \<integral>\<^sup>+y\<in>{y. g (y, x) \<le> f (y, x)}. f (y, x)\<partial>count_space UNIV
[PROOF STEP]
apply(subst nn_integral_diff[symmetric])
[PROOF STATE]
proof (prove)
goal (5 subgoals):
 1. (\<And>A. \<integral>\<^sup>+y\<in>A. f (y, x)\<partial>count_space UNIV \<noteq> \<top>) \<Longrightarrow> (\<lambda>x. f (x, x)) \<in> borel_measurable (count_space UNIV)
 2. (\<And>A. \<integral>\<^sup>+y\<in>A. f (y, x)\<partial>count_space UNIV \<noteq> \<top>) \<Longrightarrow> (\<lambda>y. f (y, x) * indicator {y. f (y, x) < g (y, x)} y) \<in> borel_measurable (count_space UNIV)
 3. (\<And>A. \<integral>\<^sup>+y\<in>A. f (y, x)\<partial>count_space UNIV \<noteq> \<top>) \<Longrightarrow> \<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV \<noteq> \<infinity>
 4. (\<And>A. \<integral>\<^sup>+y\<in>A. f (y, x)\<partial>count_space UNIV \<noteq> \<top>) \<Longrightarrow> AE x in count_space UNIV. f (x, x) * indicator {y. f (y, x) < g (y, x)} x \<le> f (x, x)
 5. (\<And>A. \<integral>\<^sup>+y\<in>A. f (y, x)\<partial>count_space UNIV \<noteq> \<top>) \<Longrightarrow> (\<Sum>\<^sup>+ x. f (x, x) - f (x, x) * indicator {y. f (y, x) < g (y, x)} x) = \<integral>\<^sup>+y\<in>{y. g (y, x) \<le> f (y, x)}. f (y, x)\<partial>count_space UNIV
[PROOF STEP]
apply(auto simp add: AE_count_space split: split_indicator intro!: nn_integral_cong)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
d_IN f x - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV) = \<integral>\<^sup>+y\<in>{y. g (y, x) \<le> f (y, x)}. f (y, x)\<partial>count_space UNIV

goal (1 subgoal):
 1. \<And>x. \<lbrakk>x \<noteq> source (residual_network g); x \<noteq> sink (residual_network g)\<rbrakk> \<Longrightarrow> KIR (f \<ominus> g) x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
d_IN f x - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. f (y, x)\<partial>count_space UNIV) = \<integral>\<^sup>+y\<in>{y. g (y, x) \<le> f (y, x)}. f (y, x)\<partial>count_space UNIV

goal (1 subgoal):
 1. \<And>x. \<lbrakk>x \<noteq> source (residual_network g); x \<noteq> sink (residual_network g)\<rbrakk> \<Longrightarrow> KIR (f \<ominus> g) x
[PROOF STEP]
have "d_IN g x - ?g_in = (\<Sum>\<^sup>+ y. g (y, x) * indicator {y. g (y, x) \<le> f (y, x)} y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. d_IN g x - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) = \<integral>\<^sup>+y\<in>{y. g (y, x) \<le> f (y, x)}. g (y, x)\<partial>count_space UNIV
[PROOF STEP]
unfolding d_IN_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>\<^sup>+ x. g (x, x)) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) = \<integral>\<^sup>+y\<in>{y. g (y, x) \<le> f (y, x)}. g (y, x)\<partial>count_space UNIV
[PROOF STEP]
using finite_g_in
[PROOF STATE]
proof (prove)
using this:
\<integral>\<^sup>+y\<in>?A. g (y, x)\<partial>count_space UNIV \<noteq> \<top>

goal (1 subgoal):
 1. (\<Sum>\<^sup>+ x. g (x, x)) - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) = \<integral>\<^sup>+y\<in>{y. g (y, x) \<le> f (y, x)}. g (y, x)\<partial>count_space UNIV
[PROOF STEP]
by(subst nn_integral_diff[symmetric])(auto simp add: flowD_finite[OF g] AE_count_space split: split_indicator intro!: nn_integral_cong)
[PROOF STATE]
proof (state)
this:
d_IN g x - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) = \<integral>\<^sup>+y\<in>{y. g (y, x) \<le> f (y, x)}. g (y, x)\<partial>count_space UNIV

goal (1 subgoal):
 1. \<And>x. \<lbrakk>x \<noteq> source (residual_network g); x \<noteq> sink (residual_network g)\<rbrakk> \<Longrightarrow> KIR (f \<ominus> g) x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
d_IN g x - (\<integral>\<^sup>+y\<in>{y. f (y, x) < g (y, x)}. g (y, x)\<partial>count_space UNIV) = \<integral>\<^sup>+y\<in>{y. g (y, x) \<le> f (y, x)}. g (y, x)\<partial>count_space UNIV

goal (1 subgoal):
 1. \<And>x. \<lbrakk>x \<noteq> source (residual_network g); x \<noteq> sink (residual_network g)\<rbrakk> \<Longrightarrow> KIR (f \<ominus> g) x
[PROOF STEP]
have "(\<Sum>\<^sup>+ y\<in>UNIV. f (y, x) * indicator {y. g (y, x) \<le> f (y, x)} y) - \<dots> = (\<Sum>\<^sup>+ y. (f (y, x) - g (y, x)) * indicator {y. g (y, x) \<le> f (y, x)} y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<integral>\<^sup>+y\<in>{y. g (y, x) \<le> f (y, x)}. f (y, x)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. g (y, x) \<le> f (y, x)}. g (y, x)\<partial>count_space UNIV) = \<integral>\<^sup>+y\<in>{y. g (y, x) \<le> f (y, x)}. (f (y, x) - g (y, x))\<partial>count_space UNIV
[PROOF STEP]
using finite_g_in
[PROOF STATE]
proof (prove)
using this:
\<integral>\<^sup>+y\<in>?A. g (y, x)\<partial>count_space UNIV \<noteq> \<top>

goal (1 subgoal):
 1. (\<integral>\<^sup>+y\<in>{y. g (y, x) \<le> f (y, x)}. f (y, x)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. g (y, x) \<le> f (y, x)}. g (y, x)\<partial>count_space UNIV) = \<integral>\<^sup>+y\<in>{y. g (y, x) \<le> f (y, x)}. (f (y, x) - g (y, x))\<partial>count_space UNIV
[PROOF STEP]
by(subst nn_integral_diff[symmetric])(auto simp add: flowD_finite[OF g] AE_count_space split: split_indicator intro!: nn_integral_cong)
[PROOF STATE]
proof (state)
this:
(\<integral>\<^sup>+y\<in>{y. g (y, x) \<le> f (y, x)}. f (y, x)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. g (y, x) \<le> f (y, x)}. g (y, x)\<partial>count_space UNIV) = \<integral>\<^sup>+y\<in>{y. g (y, x) \<le> f (y, x)}. (f (y, x) - g (y, x))\<partial>count_space UNIV

goal (1 subgoal):
 1. \<And>x. \<lbrakk>x \<noteq> source (residual_network g); x \<noteq> sink (residual_network g)\<rbrakk> \<Longrightarrow> KIR (f \<ominus> g) x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<integral>\<^sup>+y\<in>{y. g (y, x) \<le> f (y, x)}. f (y, x)\<partial>count_space UNIV) - (\<integral>\<^sup>+y\<in>{y. g (y, x) \<le> f (y, x)}. g (y, x)\<partial>count_space UNIV) = \<integral>\<^sup>+y\<in>{y. g (y, x) \<le> f (y, x)}. (f (y, x) - g (y, x))\<partial>count_space UNIV

goal (1 subgoal):
 1. \<And>x. \<lbrakk>x \<noteq> source (residual_network g); x \<noteq> sink (residual_network g)\<rbrakk> \<Longrightarrow> KIR (f \<ominus> g) x
[PROOF STEP]
have "\<dots> = (\<Sum>\<^sup>+ y. (f (y, x) - g (y, x)) * indicator \<^bold>E (y, x) * indicator {y. g (y, x) \<le> f (y, x)} y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<integral>\<^sup>+y\<in>{y. g (y, x) \<le> f (y, x)}. (f (y, x) - g (y, x))\<partial>count_space UNIV = \<integral>\<^sup>+y\<in>{y. g (y, x) \<le> f (y, x)}. ((f (y, x) - g (y, x)) * indicator \<^bold>E (y, x))\<partial>count_space UNIV
[PROOF STEP]
using flowD_outside[OF f] flowD_outside[OF g]
[PROOF STATE]
proof (prove)
using this:
?e \<notin> \<^bold>E \<Longrightarrow> f ?e = 0
?e \<notin> \<^bold>E \<Longrightarrow> g ?e = 0

goal (1 subgoal):
 1. \<integral>\<^sup>+y\<in>{y. g (y, x) \<le> f (y, x)}. (f (y, x) - g (y, x))\<partial>count_space UNIV = \<integral>\<^sup>+y\<in>{y. g (y, x) \<le> f (y, x)}. ((f (y, x) - g (y, x)) * indicator \<^bold>E (y, x))\<partial>count_space UNIV
[PROOF STEP]
by(auto intro!: nn_integral_cong split: split_indicator)
[PROOF STATE]
proof (state)
this:
\<integral>\<^sup>+y\<in>{y. g (y, x) \<le> f (y, x)}. (f (y, x) - g (y, x))\<partial>count_space UNIV = \<integral>\<^sup>+y\<in>{y. g (y, x) \<le> f (y, x)}. ((f (y, x) - g (y, x)) * indicator \<^bold>E (y, x))\<partial>count_space UNIV

goal (1 subgoal):
 1. \<And>x. \<lbrakk>x \<noteq> source (residual_network g); x \<noteq> sink (residual_network g)\<rbrakk> \<Longrightarrow> KIR (f \<ominus> g) x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
\<integral>\<^sup>+y\<in>{y. g (y, x) \<le> f (y, x)}. (f (y, x) - g (y, x))\<partial>count_space UNIV = \<integral>\<^sup>+y\<in>{y. g (y, x) \<le> f (y, x)}. ((f (y, x) - g (y, x)) * indicator \<^bold>E (y, x))\<partial>count_space UNIV

goal (1 subgoal):
 1. \<And>x. \<lbrakk>x \<noteq> source (residual_network g); x \<noteq> sink (residual_network g)\<rbrakk> \<Longrightarrow> KIR (f \<ominus> g) x
[PROOF STEP]
have "\<dots> + ?diff_out = d_IN ?f x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<integral>\<^sup>+y\<in>{y. g (y, x) \<le> f (y, x)}. ((f (y, x) - g (y, x)) * indicator \<^bold>E (y, x))\<partial>count_space UNIV) + (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. ((g (x, y) - f (x, y)) * indicator \<^bold>E (x, y))\<partial>count_space UNIV) = d_IN (f \<ominus> g) x
[PROOF STEP]
using flowD_finite[OF g]
[PROOF STATE]
proof (prove)
using this:
g ?e \<noteq> \<top>

goal (1 subgoal):
 1. (\<integral>\<^sup>+y\<in>{y. g (y, x) \<le> f (y, x)}. ((f (y, x) - g (y, x)) * indicator \<^bold>E (y, x))\<partial>count_space UNIV) + (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. ((g (x, y) - f (x, y)) * indicator \<^bold>E (x, y))\<partial>count_space UNIV) = d_IN (f \<ominus> g) x
[PROOF STEP]
apply(subst nn_integral_add[symmetric])
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. (\<And>e. g e \<noteq> \<top>) \<Longrightarrow> (\<lambda>y. (f (y, x) - g (y, x)) * indicator \<^bold>E (y, x) * indicator {y. g (y, x) \<le> f (y, x)} y) \<in> borel_measurable (count_space UNIV)
 2. (\<And>e. g e \<noteq> \<top>) \<Longrightarrow> (\<lambda>y. (g (x, y) - f (x, y)) * indicator \<^bold>E (x, y) * indicator {y. f (x, y) < g (x, y)} y) \<in> borel_measurable (count_space UNIV)
 3. (\<And>e. g e \<noteq> \<top>) \<Longrightarrow> (\<Sum>\<^sup>+ x. (f (x, x) - g (x, x)) * indicator \<^bold>E (x, x) * indicator {y. g (y, x) \<le> f (y, x)} x + (g (x, x) - f (x, x)) * indicator \<^bold>E (x, x) * indicator {y. f (x, y) < g (x, y)} x) = d_IN (f \<ominus> g) x
[PROOF STEP]
apply(auto 4 4 simp add: d_IN_def not_le less_top[symmetric] intro!: nn_integral_cong
               dest!: wf_residual_networkD[OF wf] split: split_indicator intro: diff_eq_0_ennreal)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
(\<integral>\<^sup>+y\<in>{y. g (y, x) \<le> f (y, x)}. ((f (y, x) - g (y, x)) * indicator \<^bold>E (y, x))\<partial>count_space UNIV) + (\<integral>\<^sup>+y\<in>{y. f (x, y) < g (x, y)}. ((g (x, y) - f (x, y)) * indicator \<^bold>E (x, y))\<partial>count_space UNIV) = d_IN (f \<ominus> g) x

goal (1 subgoal):
 1. \<And>x. \<lbrakk>x \<noteq> source (residual_network g); x \<noteq> sink (residual_network g)\<rbrakk> \<Longrightarrow> KIR (f \<ominus> g) x
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
KIR (f \<ominus> g) x
[PROOF STEP]
show "KIR ?f x"
[PROOF STATE]
proof (prove)
using this:
KIR (f \<ominus> g) x

goal (1 subgoal):
 1. KIR (f \<ominus> g) x
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
KIR (f \<ominus> g) x

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma Sup_iter_unfold_var: "1 \<squnion> (\<Squnion>n. x \<cdot> x ^ n) = (\<Squnion>n. x ^ n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (1::'a) \<squnion> (\<Squnion>n. x \<cdot> x ^ n) = \<Squnion> range ((^) x)
[PROOF STEP]
by (simp only: Sup_iter_unfold[symmetric]) auto


[STATEMENT]
lemma set_comp_pair: "{f t r |t r. P t r} = {x. \<exists>t r. P t r \<and> x = (f t r)}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {f t r |t r. P t r} = {x. \<exists>t r. P t r \<and> x = f t r}
[PROOF STEP]
by auto


[STATEMENT]
lemma explode_Empty: "(explode x = {}) = (x = Empty)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (explode x = {}) = (x = Empty)
[PROOF STEP]
by (auto simp add: explode_def Ext Empty)


[STATEMENT]
lemma unit_factor_primepow:
  fixes p :: "'a :: factorial_semiring_multiplicative"
  shows "primepow p \<Longrightarrow> unit_factor p = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. primepow p \<Longrightarrow> unit_factor p = (1::'a)
[PROOF STEP]
by (auto simp: primepow_def unit_factor_power)


[STATEMENT]
lemma winning_position_will_remain_winning_Even:
  assumes "odd (length p)" "position (p @ [m])" "winning_position_Even p"
  shows "winning_position_Even (p @ [m])"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. winning_position_Even (p @ [m])
[PROOF STEP]
using assms any_moves_remain_winning_Even[OF assms(1)]
[PROOF STATE]
proof (prove)
using this:
odd (length p)
position (p @ [m])
winning_position_Even p
strategy_winning_by_Even ?\<sigma> p \<Longrightarrow> strategy_winning_by_Even ?\<sigma> (p @ [?m])

goal (1 subgoal):
 1. winning_position_Even (p @ [m])
[PROOF STEP]
by auto


[STATEMENT]
lemma sum_le_suminf:
  shows "summable f \<Longrightarrow> finite I \<Longrightarrow> (\<And>n. n \<in>- I \<Longrightarrow> 0 \<le> f n) \<Longrightarrow> sum f I \<le> suminf f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>summable f; finite I; \<And>n. n \<in> - I \<Longrightarrow> (0::'a) \<le> f n\<rbrakk> \<Longrightarrow> sum f I \<le> suminf f
[PROOF STEP]
by (rule sums_le[OF _ sums_If_finite_set summable_sums]) auto


[STATEMENT]
lemma poly_subst_sum: "poly_subst f (sum p A) = (\<Sum>a\<in>A. poly_subst f (p a))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly_subst f (sum p A) = (\<Sum>a\<in>A. poly_subst f (p a))
[PROOF STEP]
by (rule fun_sum_commute, simp_all add: poly_subst_plus)


[STATEMENT]
lemma fps_of_poly_power: "fps_of_poly (p ^ n) = fps_of_poly p ^ n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fps_of_poly (p ^ n) = fps_of_poly p ^ n
[PROOF STEP]
by (induction n) (simp_all add: fps_of_poly_mult)


[STATEMENT]
lemma map_of_sinter_with:
  "\<lbrakk> sorted (map fst xs); sorted (map fst ys) \<rbrakk>
  \<Longrightarrow> map_of (sinter_with f xs ys) k =
  (case map_of xs k of None \<Rightarrow> None | Some v \<Rightarrow> map_option (f k v) (map_of ys k))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>sorted (map fst xs); sorted (map fst ys)\<rbrakk> \<Longrightarrow> map_of (sinter_with f xs ys) k = (case map_of xs k of None \<Rightarrow> None | Some v \<Rightarrow> map_option (f k v) (map_of ys k))
[PROOF STEP]
apply(induct f xs ys rule: sinter_with.induct)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. \<And>f ka v as k' v' bs. \<lbrakk>\<lbrakk>k' < ka; sorted (map fst ((ka, v) # as)); sorted (map fst bs)\<rbrakk> \<Longrightarrow> map_of (sinter_with f ((ka, v) # as) bs) k = (case map_of ((ka, v) # as) k of None \<Rightarrow> None | Some v \<Rightarrow> map_option (f k v) (map_of bs k)); \<lbrakk>\<not> k' < ka; ka < k'; sorted (map fst as); sorted (map fst ((k', v') # bs))\<rbrakk> \<Longrightarrow> map_of (sinter_with f as ((k', v') # bs)) k = (case map_of as k of None \<Rightarrow> None | Some v \<Rightarrow> map_option (f k v) (map_of ((k', v') # bs) k)); \<lbrakk>\<not> k' < ka; \<not> ka < k'; sorted (map fst as); sorted (map fst bs)\<rbrakk> \<Longrightarrow> map_of (sinter_with f as bs) k = (case map_of as k of None \<Rightarrow> None | Some v \<Rightarrow> map_option (f k v) (map_of bs k)); sorted (map fst ((ka, v) # as)); sorted (map fst ((k', v') # bs))\<rbrakk> \<Longrightarrow> map_of (sinter_with f ((ka, v) # as) ((k', v') # bs)) k = (case map_of ((ka, v) # as) k of None \<Rightarrow> None | Some v \<Rightarrow> map_option (f k v) (map_of ((k', v') # bs) k))
 2. \<And>f uu_. \<lbrakk>sorted (map fst []); sorted (map fst uu_)\<rbrakk> \<Longrightarrow> map_of (sinter_with f [] uu_) k = (case map_of [] k of None \<Rightarrow> None | Some v \<Rightarrow> map_option (f k v) (map_of uu_ k))
 3. \<And>f uv_. \<lbrakk>sorted (map fst uv_); sorted (map fst [])\<rbrakk> \<Longrightarrow> map_of (sinter_with f uv_ []) k = (case map_of uv_ k of None \<Rightarrow> None | Some v \<Rightarrow> map_option (f k v) (map_of [] k))
[PROOF STEP]
apply(auto simp add: map_option_case split: option.splits dest: map_of_SomeD bspec)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
theorem is_chainD: \<open>is_chain f \<Longrightarrow> x \<in> f m \<Longrightarrow> x \<in> f (m + n)\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>is_chain f; x \<in> f m\<rbrakk> \<Longrightarrow> x \<in> f (m + n)
[PROOF STEP]
by (induct n) (auto simp: is_chain_def)


[STATEMENT]
lemma Sup_upto_llist_0[simp]: "Sup_upto_llist Xs 0 = (if lnull Xs then {} else lhd Xs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Sup_upto_llist Xs 0 = (if lnull Xs then {} else lhd Xs)
[PROOF STEP]
unfolding zero_enat_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Sup_upto_llist Xs (enat 0) = (if lnull Xs then {} else lhd Xs)
[PROOF STEP]
by (rule Sup_upto_llist_enat_0)


[STATEMENT]
lemma strong_fermat_liar_code [code]:
  "strong_fermat_liar \<longleftrightarrow>
     (let (m, k) = divide_out 2 (n - 1)
      in [a^m = 1](mod n) \<or> (\<exists>i \<in> {0..< k}. [a^(2 ^ i * m) = n-1] (mod n)))"
  (is "?lhs = ?rhs")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. local.strong_fermat_liar = (let (m, k) = divide_out 2 (n - 1) in [a ^ m = 1] (mod n) \<or> (\<exists>i\<in>{0..<k}. [a ^ (2 ^ i * m) = n - 1] (mod n)))
[PROOF STEP]
proof (cases "n > 1")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. 1 < n \<Longrightarrow> local.strong_fermat_liar = (let (m, k) = divide_out 2 (n - 1) in [a ^ m = 1] (mod n) \<or> (\<exists>i\<in>{0..<k}. [a ^ (2 ^ i * m) = n - 1] (mod n)))
 2. \<not> 1 < n \<Longrightarrow> local.strong_fermat_liar = (let (m, k) = divide_out 2 (n - 1) in [a ^ m = 1] (mod n) \<or> (\<exists>i\<in>{0..<k}. [a ^ (2 ^ i * m) = n - 1] (mod n)))
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
1 < n

goal (2 subgoals):
 1. 1 < n \<Longrightarrow> local.strong_fermat_liar = (let (m, k) = divide_out 2 (n - 1) in [a ^ m = 1] (mod n) \<or> (\<exists>i\<in>{0..<k}. [a ^ (2 ^ i * m) = n - 1] (mod n)))
 2. \<not> 1 < n \<Longrightarrow> local.strong_fermat_liar = (let (m, k) = divide_out 2 (n - 1) in [a ^ m = 1] (mod n) \<or> (\<exists>i\<in>{0..<k}. [a ^ (2 ^ i * m) = n - 1] (mod n)))
[PROOF STEP]
define m where "m = (n - 1) div 2 ^ multiplicity 2 (n - 1)"
[PROOF STATE]
proof (state)
this:
m = (n - 1) div 2 ^ multiplicity 2 (n - 1)

goal (2 subgoals):
 1. 1 < n \<Longrightarrow> local.strong_fermat_liar = (let (m, k) = divide_out 2 (n - 1) in [a ^ m = 1] (mod n) \<or> (\<exists>i\<in>{0..<k}. [a ^ (2 ^ i * m) = n - 1] (mod n)))
 2. \<not> 1 < n \<Longrightarrow> local.strong_fermat_liar = (let (m, k) = divide_out 2 (n - 1) in [a ^ m = 1] (mod n) \<or> (\<exists>i\<in>{0..<k}. [a ^ (2 ^ i * m) = n - 1] (mod n)))
[PROOF STEP]
define k where "k = multiplicity 2 (n - 1)"
[PROOF STATE]
proof (state)
this:
k = multiplicity 2 (n - 1)

goal (2 subgoals):
 1. 1 < n \<Longrightarrow> local.strong_fermat_liar = (let (m, k) = divide_out 2 (n - 1) in [a ^ m = 1] (mod n) \<or> (\<exists>i\<in>{0..<k}. [a ^ (2 ^ i * m) = n - 1] (mod n)))
 2. \<not> 1 < n \<Longrightarrow> local.strong_fermat_liar = (let (m, k) = divide_out 2 (n - 1) in [a ^ m = 1] (mod n) \<or> (\<exists>i\<in>{0..<k}. [a ^ (2 ^ i * m) = n - 1] (mod n)))
[PROOF STEP]
have mk: "odd m \<and> n - 1 = 2 ^ k * m"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. odd m \<and> n - 1 = 2 ^ k * m
[PROOF STEP]
using True multiplicity_decompose[of "n - 1" 2] multiplicity_dvd[of 2 "n - 1"]
[PROOF STATE]
proof (prove)
using this:
1 < n
\<lbrakk>n - 1 \<noteq> 0; \<not> is_unit 2\<rbrakk> \<Longrightarrow> odd ((n - 1) div 2 ^ multiplicity 2 (n - 1))
2 ^ multiplicity 2 (n - 1) dvd n - 1

goal (1 subgoal):
 1. odd m \<and> n - 1 = 2 ^ k * m
[PROOF STEP]
by (auto simp: m_def k_def)
[PROOF STATE]
proof (state)
this:
odd m \<and> n - 1 = 2 ^ k * m

goal (2 subgoals):
 1. 1 < n \<Longrightarrow> local.strong_fermat_liar = (let (m, k) = divide_out 2 (n - 1) in [a ^ m = 1] (mod n) \<or> (\<exists>i\<in>{0..<k}. [a ^ (2 ^ i * m) = n - 1] (mod n)))
 2. \<not> 1 < n \<Longrightarrow> local.strong_fermat_liar = (let (m, k) = divide_out 2 (n - 1) in [a ^ m = 1] (mod n) \<or> (\<exists>i\<in>{0..<k}. [a ^ (2 ^ i * m) = n - 1] (mod n)))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. local.strong_fermat_liar = (let (m, k) = divide_out 2 (n - 1) in [a ^ m = 1] (mod n) \<or> (\<exists>i\<in>{0..<k}. [a ^ (2 ^ i * m) = n - 1] (mod n)))
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. local.strong_fermat_liar \<Longrightarrow> let (m, k) = divide_out 2 (n - 1) in [a ^ m = 1] (mod n) \<or> (\<exists>i\<in>{0..<k}. [a ^ (2 ^ i * m) = n - 1] (mod n))
 2. let (m, k) = divide_out 2 (n - 1) in [a ^ m = 1] (mod n) \<or> (\<exists>i\<in>{0..<k}. [a ^ (2 ^ i * m) = n - 1] (mod n)) \<Longrightarrow> local.strong_fermat_liar
[PROOF STEP]
assume ?lhs
[PROOF STATE]
proof (state)
this:
local.strong_fermat_liar

goal (2 subgoals):
 1. local.strong_fermat_liar \<Longrightarrow> let (m, k) = divide_out 2 (n - 1) in [a ^ m = 1] (mod n) \<or> (\<exists>i\<in>{0..<k}. [a ^ (2 ^ i * m) = n - 1] (mod n))
 2. let (m, k) = divide_out 2 (n - 1) in [a ^ m = 1] (mod n) \<or> (\<exists>i\<in>{0..<k}. [a ^ (2 ^ i * m) = n - 1] (mod n)) \<Longrightarrow> local.strong_fermat_liar
[PROOF STEP]
hence "[a^m = 1] (mod n) \<or> (\<exists>i \<in> {0..< k}. [a^(2 ^ i * m) = n-1] (mod n))"
[PROOF STATE]
proof (prove)
using this:
local.strong_fermat_liar

goal (1 subgoal):
 1. [a ^ m = 1] (mod n) \<or> (\<exists>i\<in>{0..<k}. [a ^ (2 ^ i * m) = n - 1] (mod n))
[PROOF STEP]
using True mk
[PROOF STATE]
proof (prove)
using this:
local.strong_fermat_liar
1 < n
odd m \<and> n - 1 = 2 ^ k * m

goal (1 subgoal):
 1. [a ^ m = 1] (mod n) \<or> (\<exists>i\<in>{0..<k}. [a ^ (2 ^ i * m) = n - 1] (mod n))
[PROOF STEP]
by (auto simp: divide_out_def strong_fermat_liar_def)
[PROOF STATE]
proof (state)
this:
[a ^ m = 1] (mod n) \<or> (\<exists>i\<in>{0..<k}. [a ^ (2 ^ i * m) = n - 1] (mod n))

goal (2 subgoals):
 1. local.strong_fermat_liar \<Longrightarrow> let (m, k) = divide_out 2 (n - 1) in [a ^ m = 1] (mod n) \<or> (\<exists>i\<in>{0..<k}. [a ^ (2 ^ i * m) = n - 1] (mod n))
 2. let (m, k) = divide_out 2 (n - 1) in [a ^ m = 1] (mod n) \<or> (\<exists>i\<in>{0..<k}. [a ^ (2 ^ i * m) = n - 1] (mod n)) \<Longrightarrow> local.strong_fermat_liar
[PROOF STEP]
thus ?rhs
[PROOF STATE]
proof (prove)
using this:
[a ^ m = 1] (mod n) \<or> (\<exists>i\<in>{0..<k}. [a ^ (2 ^ i * m) = n - 1] (mod n))

goal (1 subgoal):
 1. let (m, k) = divide_out 2 (n - 1) in [a ^ m = 1] (mod n) \<or> (\<exists>i\<in>{0..<k}. [a ^ (2 ^ i * m) = n - 1] (mod n))
[PROOF STEP]
by (auto simp: Let_def divide_out_def m_def k_def)
[PROOF STATE]
proof (state)
this:
let (m, k) = divide_out 2 (n - 1) in [a ^ m = 1] (mod n) \<or> (\<exists>i\<in>{0..<k}. [a ^ (2 ^ i * m) = n - 1] (mod n))

goal (1 subgoal):
 1. let (m, k) = divide_out 2 (n - 1) in [a ^ m = 1] (mod n) \<or> (\<exists>i\<in>{0..<k}. [a ^ (2 ^ i * m) = n - 1] (mod n)) \<Longrightarrow> local.strong_fermat_liar
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. let (m, k) = divide_out 2 (n - 1) in [a ^ m = 1] (mod n) \<or> (\<exists>i\<in>{0..<k}. [a ^ (2 ^ i * m) = n - 1] (mod n)) \<Longrightarrow> local.strong_fermat_liar
[PROOF STEP]
assume ?rhs
[PROOF STATE]
proof (state)
this:
let (m, k) = divide_out 2 (n - 1) in [a ^ m = 1] (mod n) \<or> (\<exists>i\<in>{0..<k}. [a ^ (2 ^ i * m) = n - 1] (mod n))

goal (1 subgoal):
 1. let (m, k) = divide_out 2 (n - 1) in [a ^ m = 1] (mod n) \<or> (\<exists>i\<in>{0..<k}. [a ^ (2 ^ i * m) = n - 1] (mod n)) \<Longrightarrow> local.strong_fermat_liar
[PROOF STEP]
thus ?lhs
[PROOF STATE]
proof (prove)
using this:
let (m, k) = divide_out 2 (n - 1) in [a ^ m = 1] (mod n) \<or> (\<exists>i\<in>{0..<k}. [a ^ (2 ^ i * m) = n - 1] (mod n))

goal (1 subgoal):
 1. local.strong_fermat_liar
[PROOF STEP]
using divide_out_unique_nat[of 2]
[PROOF STATE]
proof (prove)
using this:
let (m, k) = divide_out 2 (n - 1) in [a ^ m = 1] (mod n) \<or> (\<exists>i\<in>{0..<k}. [a ^ (2 ^ i * m) = n - 1] (mod n))
\<lbrakk>\<not> is_unit 2; 2 \<noteq> 0; odd ?m; ?n = 2 ^ ?k * ?m\<rbrakk> \<Longrightarrow> ?m = ?n div 2 ^ multiplicity 2 ?n
\<lbrakk>\<not> is_unit 2; 2 \<noteq> 0; odd ?m; ?n = 2 ^ ?k * ?m\<rbrakk> \<Longrightarrow> ?k = multiplicity 2 ?n

goal (1 subgoal):
 1. local.strong_fermat_liar
[PROOF STEP]
by (auto simp: strong_fermat_liar_def divide_out_def)
[PROOF STATE]
proof (state)
this:
local.strong_fermat_liar

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
local.strong_fermat_liar = (let (m, k) = divide_out 2 (n - 1) in [a ^ m = 1] (mod n) \<or> (\<exists>i\<in>{0..<k}. [a ^ (2 ^ i * m) = n - 1] (mod n)))

goal (1 subgoal):
 1. \<not> 1 < n \<Longrightarrow> local.strong_fermat_liar = (let (m, k) = divide_out 2 (n - 1) in [a ^ m = 1] (mod n) \<or> (\<exists>i\<in>{0..<k}. [a ^ (2 ^ i * m) = n - 1] (mod n)))
[PROOF STEP]
qed (auto simp: strong_fermat_liar_def divide_out_def)


[STATEMENT]
lemma set_vebt_mint''[vebt_simps]:
  "invar_vebt t n \<Longrightarrow> vebt_mint t = (if set_vebt t = {} then None else Some (Min (set_vebt t)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. invar_vebt t n \<Longrightarrow> vebt_mint t = (if set_vebt t = {} then None else Some (Min (set_vebt t)))
[PROOF STEP]
by (metis Min_in Min_le VEBT_internal.set_vebt_finite VEBT_internal.set_vebt_set_vebt'_valid empty_iff option.exhaust set_vebt_mint')


[STATEMENT]
lemma (in Module) generator_generator_elim:
 "\<lbrakk>f \<in> {j. j \<le> (n::nat)} \<rightarrow> carrier M; generator R M (f ` {j. j \<le> n});
  (\<forall>i\<in>nset (Suc 0) n. f i \<in> linear_span R M (carrier R)
     (f ` {j. j \<le> (i - Suc 0)}))\<rbrakk> \<Longrightarrow>
   linear_span R M (carrier R) {f 0} = carrier M"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>f \<in> {j. j \<le> n} \<rightarrow> carrier M; generator R M (f ` {j. j \<le> n}); \<forall>i\<in>nset (Suc 0) n. f i \<in> linear_span R M (carrier R) (f ` {j. j \<le> i - Suc 0})\<rbrakk> \<Longrightarrow> linear_span R M (carrier R) {f 0} = carrier M
[PROOF STEP]
apply (simp add:generator_elimTr [of f n])
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma (in infinite_cts_filtration) expect_prob_comp:
fixes f::"bool stream\<Rightarrow>real"
  assumes "f\<in> borel_measurable (F n)"
  shows "expectation f =
    (\<Sum> w\<in> range (pseudo_proj_True n). (prod (prob_component p w) {0..<n}) * (f w))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. expectation f = (\<Sum>w\<in>range (pseudo_proj_True n). prod (prob_component p w) {0..<n} * f w)
[PROOF STEP]
using assms F_n_integral_prob_comp has_bochner_integral_iff
[PROOF STATE]
proof (prove)
using this:
f \<in> borel_measurable (F n)
?f \<in> borel_measurable (F ?n) \<Longrightarrow> has_bochner_integral M ?f (\<Sum>w\<in>range (pseudo_proj_True ?n). prod (prob_component p w) {0..<?n} * ?f w)
has_bochner_integral ?M ?f ?x = (integrable ?M ?f \<and> integral\<^sup>L ?M ?f = ?x)

goal (1 subgoal):
 1. expectation f = (\<Sum>w\<in>range (pseudo_proj_True n). prod (prob_component p w) {0..<n} * f w)
[PROOF STEP]
by blast


[STATEMENT]
lemma find_index_less_size_conv:
  "(find_index P xs < size xs) = (\<exists>x \<in> set xs. P x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (find_index P xs < length xs) = (\<exists>x\<in>set xs. P x)
[PROOF STEP]
by (induct xs) auto


[STATEMENT]
lemma mset_subset_add_iff1:
  "j \<le> (i::nat) \<Longrightarrow> (repeat_mset i u + m \<subset># repeat_mset j u + n) = (repeat_mset (i-j) u + m \<subset># n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. j \<le> i \<Longrightarrow> (repeat_mset i u + m \<subset># repeat_mset j u + n) = (repeat_mset (i - j) u + m \<subset># n)
[PROOF STEP]
unfolding subset_mset_def repeat_mset_iterate_add
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. j \<le> i \<Longrightarrow> (iterate_add i u + m \<subseteq># iterate_add j u + n \<and> iterate_add i u + m \<noteq> iterate_add j u + n) = (iterate_add (i - j) u + m \<subseteq># n \<and> iterate_add (i - j) u + m \<noteq> n)
[PROOF STEP]
by (simp add: iterate_add_eq_add_iff1 mset_subseteq_add_iff1[unfolded repeat_mset_iterate_add])