[STATEMENT]
lemma f0_exact_space_usage':
  defines "\<Omega> \<equiv> fold (\<lambda>a state. state \<bind> f0_update a) as (f0_init \<delta> \<epsilon> n)"
  shows "AE \<omega> in \<Omega>. bit_count (encode_f0_state \<omega>) \<le> f0_space_usage (n, \<epsilon>, \<delta>)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. AE \<omega> in measure_pmf \<Omega>. bit_count (encode_f0_state \<omega>) \<le> ereal (f0_space_usage (n, \<epsilon>, \<delta>))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. AE \<omega> in measure_pmf \<Omega>. bit_count (encode_f0_state \<omega>) \<le> ereal (f0_space_usage (n, \<epsilon>, \<delta>))
[PROOF STEP]
have log_2_4: "log 2 4 = 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. log 2 4 = 2
[PROOF STEP]
by (metis log2_of_power_eq mult_2 numeral_Bit0 of_nat_numeral power2_eq_square)
[PROOF STATE]
proof (state)
this:
log 2 4 = 2

goal (1 subgoal):
 1. AE \<omega> in measure_pmf \<Omega>. bit_count (encode_f0_state \<omega>) \<le> ereal (f0_space_usage (n, \<epsilon>, \<delta>))
[PROOF STEP]
have a: "bit_count (F\<^sub>e (float_of (truncate_down r y))) \<le>
    ereal (12 + 4 * real r + 2 * log 2 (log 2 (n+13)))" if a_1:"y \<in> {..<p}" for y
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bit_count (F\<^sub>e (float_of (truncate_down r (real y)))) \<le> ereal (12 + 4 * real r + 2 * log 2 (log 2 (real (n + 13))))
[PROOF STEP]
proof (cases "y \<ge> 1")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. 1 \<le> y \<Longrightarrow> bit_count (F\<^sub>e (float_of (truncate_down r (real y)))) \<le> ereal (12 + 4 * real r + 2 * log 2 (log 2 (real (n + 13))))
 2. \<not> 1 \<le> y \<Longrightarrow> bit_count (F\<^sub>e (float_of (truncate_down r (real y)))) \<le> ereal (12 + 4 * real r + 2 * log 2 (log 2 (real (n + 13))))
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
1 \<le> y

goal (2 subgoals):
 1. 1 \<le> y \<Longrightarrow> bit_count (F\<^sub>e (float_of (truncate_down r (real y)))) \<le> ereal (12 + 4 * real r + 2 * log 2 (log 2 (real (n + 13))))
 2. \<not> 1 \<le> y \<Longrightarrow> bit_count (F\<^sub>e (float_of (truncate_down r (real y)))) \<le> ereal (12 + 4 * real r + 2 * log 2 (log 2 (real (n + 13))))
[PROOF STEP]
have aux_1: " 0 < 2 + log 2 (real y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < 2 + log 2 (real y)
[PROOF STEP]
using True
[PROOF STATE]
proof (prove)
using this:
1 \<le> y

goal (1 subgoal):
 1. 0 < 2 + log 2 (real y)
[PROOF STEP]
by (intro add_pos_nonneg, auto)
[PROOF STATE]
proof (state)
this:
0 < 2 + log 2 (real y)

goal (2 subgoals):
 1. 1 \<le> y \<Longrightarrow> bit_count (F\<^sub>e (float_of (truncate_down r (real y)))) \<le> ereal (12 + 4 * real r + 2 * log 2 (log 2 (real (n + 13))))
 2. \<not> 1 \<le> y \<Longrightarrow> bit_count (F\<^sub>e (float_of (truncate_down r (real y)))) \<le> ereal (12 + 4 * real r + 2 * log 2 (log 2 (real (n + 13))))
[PROOF STEP]
have aux_2: "0 < 2 + log 2 (real p)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < 2 + log 2 (real p)
[PROOF STEP]
using p_gt_1
[PROOF STATE]
proof (prove)
using this:
1 < p

goal (1 subgoal):
 1. 0 < 2 + log 2 (real p)
[PROOF STEP]
by (intro add_pos_nonneg, auto)
[PROOF STATE]
proof (state)
this:
0 < 2 + log 2 (real p)

goal (2 subgoals):
 1. 1 \<le> y \<Longrightarrow> bit_count (F\<^sub>e (float_of (truncate_down r (real y)))) \<le> ereal (12 + 4 * real r + 2 * log 2 (log 2 (real (n + 13))))
 2. \<not> 1 \<le> y \<Longrightarrow> bit_count (F\<^sub>e (float_of (truncate_down r (real y)))) \<le> ereal (12 + 4 * real r + 2 * log 2 (log 2 (real (n + 13))))
[PROOF STEP]
have "bit_count (F\<^sub>e (float_of (truncate_down r y))) \<le>
      ereal (10 + 4 * real r + 2 * log 2 (2 + \<bar>log 2 \<bar>real y\<bar>\<bar>))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bit_count (F\<^sub>e (float_of (truncate_down r (real y)))) \<le> ereal (10 + 4 * real r + 2 * log 2 (2 + \<bar>log 2 \<bar>real y\<bar>\<bar>))
[PROOF STEP]
by (rule truncate_float_bit_count)
[PROOF STATE]
proof (state)
this:
bit_count (F\<^sub>e (float_of (truncate_down r (real y)))) \<le> ereal (10 + 4 * real r + 2 * log 2 (2 + \<bar>log 2 \<bar>real y\<bar>\<bar>))

goal (2 subgoals):
 1. 1 \<le> y \<Longrightarrow> bit_count (F\<^sub>e (float_of (truncate_down r (real y)))) \<le> ereal (12 + 4 * real r + 2 * log 2 (log 2 (real (n + 13))))
 2. \<not> 1 \<le> y \<Longrightarrow> bit_count (F\<^sub>e (float_of (truncate_down r (real y)))) \<le> ereal (12 + 4 * real r + 2 * log 2 (log 2 (real (n + 13))))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
bit_count (F\<^sub>e (float_of (truncate_down r (real y)))) \<le> ereal (10 + 4 * real r + 2 * log 2 (2 + \<bar>log 2 \<bar>real y\<bar>\<bar>))

goal (2 subgoals):
 1. 1 \<le> y \<Longrightarrow> bit_count (F\<^sub>e (float_of (truncate_down r (real y)))) \<le> ereal (12 + 4 * real r + 2 * log 2 (log 2 (real (n + 13))))
 2. \<not> 1 \<le> y \<Longrightarrow> bit_count (F\<^sub>e (float_of (truncate_down r (real y)))) \<le> ereal (12 + 4 * real r + 2 * log 2 (log 2 (real (n + 13))))
[PROOF STEP]
have "... = ereal (10 + 4 * real r + 2 * log 2 (2 + (log 2 (real y))))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ereal (10 + 4 * real r + 2 * log 2 (2 + \<bar>log 2 \<bar>real y\<bar>\<bar>)) = ereal (10 + 4 * real r + 2 * log 2 (2 + log 2 (real y)))
[PROOF STEP]
using True
[PROOF STATE]
proof (prove)
using this:
1 \<le> y

goal (1 subgoal):
 1. ereal (10 + 4 * real r + 2 * log 2 (2 + \<bar>log 2 \<bar>real y\<bar>\<bar>)) = ereal (10 + 4 * real r + 2 * log 2 (2 + log 2 (real y)))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
ereal (10 + 4 * real r + 2 * log 2 (2 + \<bar>log 2 \<bar>real y\<bar>\<bar>)) = ereal (10 + 4 * real r + 2 * log 2 (2 + log 2 (real y)))

goal (2 subgoals):
 1. 1 \<le> y \<Longrightarrow> bit_count (F\<^sub>e (float_of (truncate_down r (real y)))) \<le> ereal (12 + 4 * real r + 2 * log 2 (log 2 (real (n + 13))))
 2. \<not> 1 \<le> y \<Longrightarrow> bit_count (F\<^sub>e (float_of (truncate_down r (real y)))) \<le> ereal (12 + 4 * real r + 2 * log 2 (log 2 (real (n + 13))))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
ereal (10 + 4 * real r + 2 * log 2 (2 + \<bar>log 2 \<bar>real y\<bar>\<bar>)) = ereal (10 + 4 * real r + 2 * log 2 (2 + log 2 (real y)))

goal (2 subgoals):
 1. 1 \<le> y \<Longrightarrow> bit_count (F\<^sub>e (float_of (truncate_down r (real y)))) \<le> ereal (12 + 4 * real r + 2 * log 2 (log 2 (real (n + 13))))
 2. \<not> 1 \<le> y \<Longrightarrow> bit_count (F\<^sub>e (float_of (truncate_down r (real y)))) \<le> ereal (12 + 4 * real r + 2 * log 2 (log 2 (real (n + 13))))
[PROOF STEP]
have "... \<le> ereal (10 + 4 * real r + 2 * log 2 (2 + log 2 p))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ereal (10 + 4 * real r + 2 * log 2 (2 + log 2 (real y))) \<le> ereal (10 + 4 * real r + 2 * log 2 (2 + log 2 (real p)))
[PROOF STEP]
using aux_1 aux_2 True p_gt_0 a_1
[PROOF STATE]
proof (prove)
using this:
0 < 2 + log 2 (real y)
0 < 2 + log 2 (real p)
1 \<le> y
0 < p
y \<in> {..<p}

goal (1 subgoal):
 1. ereal (10 + 4 * real r + 2 * log 2 (2 + log 2 (real y))) \<le> ereal (10 + 4 * real r + 2 * log 2 (2 + log 2 (real p)))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
ereal (10 + 4 * real r + 2 * log 2 (2 + log 2 (real y))) \<le> ereal (10 + 4 * real r + 2 * log 2 (2 + log 2 (real p)))

goal (2 subgoals):
 1. 1 \<le> y \<Longrightarrow> bit_count (F\<^sub>e (float_of (truncate_down r (real y)))) \<le> ereal (12 + 4 * real r + 2 * log 2 (log 2 (real (n + 13))))
 2. \<not> 1 \<le> y \<Longrightarrow> bit_count (F\<^sub>e (float_of (truncate_down r (real y)))) \<le> ereal (12 + 4 * real r + 2 * log 2 (log 2 (real (n + 13))))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
ereal (10 + 4 * real r + 2 * log 2 (2 + log 2 (real y))) \<le> ereal (10 + 4 * real r + 2 * log 2 (2 + log 2 (real p)))

goal (2 subgoals):
 1. 1 \<le> y \<Longrightarrow> bit_count (F\<^sub>e (float_of (truncate_down r (real y)))) \<le> ereal (12 + 4 * real r + 2 * log 2 (log 2 (real (n + 13))))
 2. \<not> 1 \<le> y \<Longrightarrow> bit_count (F\<^sub>e (float_of (truncate_down r (real y)))) \<le> ereal (12 + 4 * real r + 2 * log 2 (log 2 (real (n + 13))))
[PROOF STEP]
have "... \<le> ereal (10 + 4 * real r + 2 * log 2 (log 2 4 + log 2 (2 * n + 40)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ereal (10 + 4 * real r + 2 * log 2 (2 + log 2 (real p))) \<le> ereal (10 + 4 * real r + 2 * log 2 (log 2 4 + log 2 (real (2 * n + 40))))
[PROOF STEP]
using log_2_4 p_le_n p_gt_0
[PROOF STATE]
proof (prove)
using this:
log 2 4 = 2
p \<le> 2 * n + 40
0 < p

goal (1 subgoal):
 1. ereal (10 + 4 * real r + 2 * log 2 (2 + log 2 (real p))) \<le> ereal (10 + 4 * real r + 2 * log 2 (log 2 4 + log 2 (real (2 * n + 40))))
[PROOF STEP]
by (intro ereal_mono add_mono mult_left_mono log_mono of_nat_mono add_pos_nonneg, auto)
[PROOF STATE]
proof (state)
this:
ereal (10 + 4 * real r + 2 * log 2 (2 + log 2 (real p))) \<le> ereal (10 + 4 * real r + 2 * log 2 (log 2 4 + log 2 (real (2 * n + 40))))

goal (2 subgoals):
 1. 1 \<le> y \<Longrightarrow> bit_count (F\<^sub>e (float_of (truncate_down r (real y)))) \<le> ereal (12 + 4 * real r + 2 * log 2 (log 2 (real (n + 13))))
 2. \<not> 1 \<le> y \<Longrightarrow> bit_count (F\<^sub>e (float_of (truncate_down r (real y)))) \<le> ereal (12 + 4 * real r + 2 * log 2 (log 2 (real (n + 13))))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
ereal (10 + 4 * real r + 2 * log 2 (2 + log 2 (real p))) \<le> ereal (10 + 4 * real r + 2 * log 2 (log 2 4 + log 2 (real (2 * n + 40))))

goal (2 subgoals):
 1. 1 \<le> y \<Longrightarrow> bit_count (F\<^sub>e (float_of (truncate_down r (real y)))) \<le> ereal (12 + 4 * real r + 2 * log 2 (log 2 (real (n + 13))))
 2. \<not> 1 \<le> y \<Longrightarrow> bit_count (F\<^sub>e (float_of (truncate_down r (real y)))) \<le> ereal (12 + 4 * real r + 2 * log 2 (log 2 (real (n + 13))))
[PROOF STEP]
have "... = ereal (10 + 4 * real r + 2 * log 2 (log 2 (8 * n + 160)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ereal (10 + 4 * real r + 2 * log 2 (log 2 4 + log 2 (real (2 * n + 40)))) = ereal (10 + 4 * real r + 2 * log 2 (log 2 (real (8 * n + 160))))
[PROOF STEP]
by (simp add:log_mult[symmetric])
[PROOF STATE]
proof (state)
this:
ereal (10 + 4 * real r + 2 * log 2 (log 2 4 + log 2 (real (2 * n + 40)))) = ereal (10 + 4 * real r + 2 * log 2 (log 2 (real (8 * n + 160))))

goal (2 subgoals):
 1. 1 \<le> y \<Longrightarrow> bit_count (F\<^sub>e (float_of (truncate_down r (real y)))) \<le> ereal (12 + 4 * real r + 2 * log 2 (log 2 (real (n + 13))))
 2. \<not> 1 \<le> y \<Longrightarrow> bit_count (F\<^sub>e (float_of (truncate_down r (real y)))) \<le> ereal (12 + 4 * real r + 2 * log 2 (log 2 (real (n + 13))))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
ereal (10 + 4 * real r + 2 * log 2 (log 2 4 + log 2 (real (2 * n + 40)))) = ereal (10 + 4 * real r + 2 * log 2 (log 2 (real (8 * n + 160))))

goal (2 subgoals):
 1. 1 \<le> y \<Longrightarrow> bit_count (F\<^sub>e (float_of (truncate_down r (real y)))) \<le> ereal (12 + 4 * real r + 2 * log 2 (log 2 (real (n + 13))))
 2. \<not> 1 \<le> y \<Longrightarrow> bit_count (F\<^sub>e (float_of (truncate_down r (real y)))) \<le> ereal (12 + 4 * real r + 2 * log 2 (log 2 (real (n + 13))))
[PROOF STEP]
have "... \<le> ereal (10 + 4 * real r + 2 * log 2 (log 2 ((n+13) powr 2)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ereal (10 + 4 * real r + 2 * log 2 (log 2 (real (8 * n + 160)))) \<le> ereal (10 + 4 * real r + 2 * log 2 (log 2 (real (n + 13) powr 2)))
[PROOF STEP]
by (intro ereal_mono add_mono mult_left_mono log_mono of_nat_mono add_pos_nonneg)
       (auto simp add:power2_eq_square algebra_simps)
[PROOF STATE]
proof (state)
this:
ereal (10 + 4 * real r + 2 * log 2 (log 2 (real (8 * n + 160)))) \<le> ereal (10 + 4 * real r + 2 * log 2 (log 2 (real (n + 13) powr 2)))

goal (2 subgoals):
 1. 1 \<le> y \<Longrightarrow> bit_count (F\<^sub>e (float_of (truncate_down r (real y)))) \<le> ereal (12 + 4 * real r + 2 * log 2 (log 2 (real (n + 13))))
 2. \<not> 1 \<le> y \<Longrightarrow> bit_count (F\<^sub>e (float_of (truncate_down r (real y)))) \<le> ereal (12 + 4 * real r + 2 * log 2 (log 2 (real (n + 13))))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
ereal (10 + 4 * real r + 2 * log 2 (log 2 (real (8 * n + 160)))) \<le> ereal (10 + 4 * real r + 2 * log 2 (log 2 (real (n + 13) powr 2)))

goal (2 subgoals):
 1. 1 \<le> y \<Longrightarrow> bit_count (F\<^sub>e (float_of (truncate_down r (real y)))) \<le> ereal (12 + 4 * real r + 2 * log 2 (log 2 (real (n + 13))))
 2. \<not> 1 \<le> y \<Longrightarrow> bit_count (F\<^sub>e (float_of (truncate_down r (real y)))) \<le> ereal (12 + 4 * real r + 2 * log 2 (log 2 (real (n + 13))))
[PROOF STEP]
have "... = ereal (10 +  4 * real r + 2 * log 2 (log 2 4 * log 2 (n + 13)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ereal (10 + 4 * real r + 2 * log 2 (log 2 (real (n + 13) powr 2))) = ereal (10 + 4 * real r + 2 * log 2 (log 2 4 * log 2 (real (n + 13))))
[PROOF STEP]
by (subst log_powr, simp_all add:log_2_4)
[PROOF STATE]
proof (state)
this:
ereal (10 + 4 * real r + 2 * log 2 (log 2 (real (n + 13) powr 2))) = ereal (10 + 4 * real r + 2 * log 2 (log 2 4 * log 2 (real (n + 13))))

goal (2 subgoals):
 1. 1 \<le> y \<Longrightarrow> bit_count (F\<^sub>e (float_of (truncate_down r (real y)))) \<le> ereal (12 + 4 * real r + 2 * log 2 (log 2 (real (n + 13))))
 2. \<not> 1 \<le> y \<Longrightarrow> bit_count (F\<^sub>e (float_of (truncate_down r (real y)))) \<le> ereal (12 + 4 * real r + 2 * log 2 (log 2 (real (n + 13))))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
ereal (10 + 4 * real r + 2 * log 2 (log 2 (real (n + 13) powr 2))) = ereal (10 + 4 * real r + 2 * log 2 (log 2 4 * log 2 (real (n + 13))))

goal (2 subgoals):
 1. 1 \<le> y \<Longrightarrow> bit_count (F\<^sub>e (float_of (truncate_down r (real y)))) \<le> ereal (12 + 4 * real r + 2 * log 2 (log 2 (real (n + 13))))
 2. \<not> 1 \<le> y \<Longrightarrow> bit_count (F\<^sub>e (float_of (truncate_down r (real y)))) \<le> ereal (12 + 4 * real r + 2 * log 2 (log 2 (real (n + 13))))
[PROOF STEP]
have "... = ereal (12 +  4 * real r + 2 * log 2 (log 2 (n + 13)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ereal (10 + 4 * real r + 2 * log 2 (log 2 4 * log 2 (real (n + 13)))) = ereal (12 + 4 * real r + 2 * log 2 (log 2 (real (n + 13))))
[PROOF STEP]
by (subst log_mult, simp_all add:log_2_4)
[PROOF STATE]
proof (state)
this:
ereal (10 + 4 * real r + 2 * log 2 (log 2 4 * log 2 (real (n + 13)))) = ereal (12 + 4 * real r + 2 * log 2 (log 2 (real (n + 13))))

goal (2 subgoals):
 1. 1 \<le> y \<Longrightarrow> bit_count (F\<^sub>e (float_of (truncate_down r (real y)))) \<le> ereal (12 + 4 * real r + 2 * log 2 (log 2 (real (n + 13))))
 2. \<not> 1 \<le> y \<Longrightarrow> bit_count (F\<^sub>e (float_of (truncate_down r (real y)))) \<le> ereal (12 + 4 * real r + 2 * log 2 (log 2 (real (n + 13))))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
bit_count (F\<^sub>e (float_of (truncate_down r (real y)))) \<le> ereal (12 + 4 * real r + 2 * log 2 (log 2 (real (n + 13))))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
bit_count (F\<^sub>e (float_of (truncate_down r (real y)))) \<le> ereal (12 + 4 * real r + 2 * log 2 (log 2 (real (n + 13))))

goal (1 subgoal):
 1. bit_count (F\<^sub>e (float_of (truncate_down r (real y)))) \<le> ereal (12 + 4 * real r + 2 * log 2 (log 2 (real (n + 13))))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
bit_count (F\<^sub>e (float_of (truncate_down r (real y)))) \<le> ereal (12 + 4 * real r + 2 * log 2 (log 2 (real (n + 13))))

goal (1 subgoal):
 1. \<not> 1 \<le> y \<Longrightarrow> bit_count (F\<^sub>e (float_of (truncate_down r (real y)))) \<le> ereal (12 + 4 * real r + 2 * log 2 (log 2 (real (n + 13))))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> 1 \<le> y \<Longrightarrow> bit_count (F\<^sub>e (float_of (truncate_down r (real y)))) \<le> ereal (12 + 4 * real r + 2 * log 2 (log 2 (real (n + 13))))
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> 1 \<le> y

goal (1 subgoal):
 1. \<not> 1 \<le> y \<Longrightarrow> bit_count (F\<^sub>e (float_of (truncate_down r (real y)))) \<le> ereal (12 + 4 * real r + 2 * log 2 (log 2 (real (n + 13))))
[PROOF STEP]
hence "y = 0"
[PROOF STATE]
proof (prove)
using this:
\<not> 1 \<le> y

goal (1 subgoal):
 1. y = 0
[PROOF STEP]
using a_1
[PROOF STATE]
proof (prove)
using this:
\<not> 1 \<le> y
y \<in> {..<p}

goal (1 subgoal):
 1. y = 0
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
y = 0

goal (1 subgoal):
 1. \<not> 1 \<le> y \<Longrightarrow> bit_count (F\<^sub>e (float_of (truncate_down r (real y)))) \<le> ereal (12 + 4 * real r + 2 * log 2 (log 2 (real (n + 13))))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
y = 0
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
y = 0

goal (1 subgoal):
 1. bit_count (F\<^sub>e (float_of (truncate_down r (real y)))) \<le> ereal (12 + 4 * real r + 2 * log 2 (log 2 (real (n + 13))))
[PROOF STEP]
by (simp add:float_bit_count_zero)
[PROOF STATE]
proof (state)
this:
bit_count (F\<^sub>e (float_of (truncate_down r (real y)))) \<le> ereal (12 + 4 * real r + 2 * log 2 (log 2 (real (n + 13))))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
?y1 \<in> {..<p} \<Longrightarrow> bit_count (F\<^sub>e (float_of (truncate_down r (real ?y1)))) \<le> ereal (12 + 4 * real r + 2 * log 2 (log 2 (real (n + 13))))

goal (1 subgoal):
 1. AE \<omega> in measure_pmf \<Omega>. bit_count (encode_f0_state \<omega>) \<le> ereal (f0_space_usage (n, \<epsilon>, \<delta>))
[PROOF STEP]
have "bit_count (encode_f0_state (s, t, p, r, x, \<lambda>i\<in>{..<s}. sketch_rv (x i))) \<le>
        f0_space_usage (n, \<epsilon>, \<delta>)" if b: "x \<in> {..<s} \<rightarrow>\<^sub>E space" for x
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bit_count (encode_f0_state (s, t, p, r, x, \<lambda>i\<in>{..<s}. sketch_rv (x i))) \<le> ereal (f0_space_usage (n, \<epsilon>, \<delta>))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. bit_count (encode_f0_state (s, t, p, r, x, \<lambda>i\<in>{..<s}. sketch_rv (x i))) \<le> ereal (f0_space_usage (n, \<epsilon>, \<delta>))
[PROOF STEP]
have c: "x \<in> extensional {..<s}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<in> extensional {..<s}
[PROOF STEP]
using b
[PROOF STATE]
proof (prove)
using this:
x \<in> {..<s} \<rightarrow>\<^sub>E local.space

goal (1 subgoal):
 1. x \<in> extensional {..<s}
[PROOF STEP]
by (simp add:PiE_def)
[PROOF STATE]
proof (state)
this:
x \<in> extensional {..<s}

goal (1 subgoal):
 1. bit_count (encode_f0_state (s, t, p, r, x, \<lambda>i\<in>{..<s}. sketch_rv (x i))) \<le> ereal (f0_space_usage (n, \<epsilon>, \<delta>))
[PROOF STEP]
have d: "sketch_rv (x y) \<subseteq> (\<lambda>k. float_of (truncate_down r k)) ` {..<p} "
      if d_1: "y < s" for y
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sketch_rv (x y) \<subseteq> (\<lambda>k. float_of (truncate_down r (real k))) ` {..<p}
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. sketch_rv (x y) \<subseteq> (\<lambda>k. float_of (truncate_down r (real k))) ` {..<p}
[PROOF STEP]
have "sketch_rv (x y) \<subseteq> (\<lambda>xa. float_of (truncate_down r (hash xa (x y)))) ` set as"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sketch_rv (x y) \<subseteq> (\<lambda>xa. float_of (truncate_down r (real (Frequency_Moment_0.hash p xa (x y))))) ` set as
[PROOF STEP]
using least_subset
[PROOF STATE]
proof (prove)
using this:
K_Smallest.least ?k ?S \<subseteq> ?S

goal (1 subgoal):
 1. sketch_rv (x y) \<subseteq> (\<lambda>xa. float_of (truncate_down r (real (Frequency_Moment_0.hash p xa (x y))))) ` set as
[PROOF STEP]
by (auto simp add:sketch_rv_def tr_hash_def)
[PROOF STATE]
proof (state)
this:
sketch_rv (x y) \<subseteq> (\<lambda>xa. float_of (truncate_down r (real (Frequency_Moment_0.hash p xa (x y))))) ` set as

goal (1 subgoal):
 1. sketch_rv (x y) \<subseteq> (\<lambda>k. float_of (truncate_down r (real k))) ` {..<p}
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
sketch_rv (x y) \<subseteq> (\<lambda>xa. float_of (truncate_down r (real (Frequency_Moment_0.hash p xa (x y))))) ` set as

goal (1 subgoal):
 1. sketch_rv (x y) \<subseteq> (\<lambda>k. float_of (truncate_down r (real k))) ` {..<p}
[PROOF STEP]
have "... \<subseteq> (\<lambda>k. float_of (truncate_down r (real k))) ` {..<p}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>xa. float_of (truncate_down r (real (Frequency_Moment_0.hash p xa (x y))))) ` set as \<subseteq> (\<lambda>k. float_of (truncate_down r (real k))) ` {..<p}
[PROOF STEP]
using b hash_range as_lt_p d_1
[PROOF STATE]
proof (prove)
using this:
x \<in> {..<s} \<rightarrow>\<^sub>E local.space
\<lbrakk>?\<omega> \<in> local.space; ?x \<in> carrier (Field.mod_ring p)\<rbrakk> \<Longrightarrow> Frequency_Moment_0.hash p ?x ?\<omega> \<in> carrier (Field.mod_ring p)
?x \<in> set as \<Longrightarrow> ?x < p
y < s

goal (1 subgoal):
 1. (\<lambda>xa. float_of (truncate_down r (real (Frequency_Moment_0.hash p xa (x y))))) ` set as \<subseteq> (\<lambda>k. float_of (truncate_down r (real k))) ` {..<p}
[PROOF STEP]
by (intro f_subset[where f="\<lambda>x. float_of (truncate_down r (real x))"] image_subsetI)
         (simp add: PiE_iff mod_ring_carr)
[PROOF STATE]
proof (state)
this:
(\<lambda>xa. float_of (truncate_down r (real (Frequency_Moment_0.hash p xa (x y))))) ` set as \<subseteq> (\<lambda>k. float_of (truncate_down r (real k))) ` {..<p}

goal (1 subgoal):
 1. sketch_rv (x y) \<subseteq> (\<lambda>k. float_of (truncate_down r (real k))) ` {..<p}
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
sketch_rv (x y) \<subseteq> (\<lambda>k. float_of (truncate_down r (real k))) ` {..<p}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
sketch_rv (x y) \<subseteq> (\<lambda>k. float_of (truncate_down r (real k))) ` {..<p}

goal (1 subgoal):
 1. sketch_rv (x y) \<subseteq> (\<lambda>k. float_of (truncate_down r (real k))) ` {..<p}
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
sketch_rv (x y) \<subseteq> (\<lambda>k. float_of (truncate_down r (real k))) ` {..<p}

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
?y1 < s \<Longrightarrow> sketch_rv (x ?y1) \<subseteq> (\<lambda>k. float_of (truncate_down r (real k))) ` {..<p}

goal (1 subgoal):
 1. bit_count (encode_f0_state (s, t, p, r, x, \<lambda>i\<in>{..<s}. sketch_rv (x i))) \<le> ereal (f0_space_usage (n, \<epsilon>, \<delta>))
[PROOF STEP]
have "\<And>y. y < s \<Longrightarrow> finite (sketch_rv (x y))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>y. y < s \<Longrightarrow> finite (sketch_rv (x y))
[PROOF STEP]
unfolding sketch_rv_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>y. y < s \<Longrightarrow> finite (K_Smallest.least t ((\<lambda>xa. float_of (tr_hash xa (x y))) ` set as))
[PROOF STEP]
by (rule finite_subset[OF least_subset], simp)
[PROOF STATE]
proof (state)
this:
?y1 < s \<Longrightarrow> finite (sketch_rv (x ?y1))

goal (1 subgoal):
 1. bit_count (encode_f0_state (s, t, p, r, x, \<lambda>i\<in>{..<s}. sketch_rv (x i))) \<le> ereal (f0_space_usage (n, \<epsilon>, \<delta>))
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
?y1 < s \<Longrightarrow> finite (sketch_rv (x ?y1))

goal (1 subgoal):
 1. bit_count (encode_f0_state (s, t, p, r, x, \<lambda>i\<in>{..<s}. sketch_rv (x i))) \<le> ereal (f0_space_usage (n, \<epsilon>, \<delta>))
[PROOF STEP]
have card_sketch: "\<And>y. y < s \<Longrightarrow> card (sketch_rv (x y)) \<le> t "
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>y. y < s \<Longrightarrow> card (sketch_rv (x y)) \<le> t
[PROOF STEP]
by (simp add:sketch_rv_def card_least)
[PROOF STATE]
proof (state)
this:
?y1 < s \<Longrightarrow> card (sketch_rv (x ?y1)) \<le> t

goal (1 subgoal):
 1. bit_count (encode_f0_state (s, t, p, r, x, \<lambda>i\<in>{..<s}. sketch_rv (x i))) \<le> ereal (f0_space_usage (n, \<epsilon>, \<delta>))
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
?y1 < s \<Longrightarrow> card (sketch_rv (x ?y1)) \<le> t

goal (1 subgoal):
 1. bit_count (encode_f0_state (s, t, p, r, x, \<lambda>i\<in>{..<s}. sketch_rv (x i))) \<le> ereal (f0_space_usage (n, \<epsilon>, \<delta>))
[PROOF STEP]
have "\<And>y z. y < s \<Longrightarrow> z \<in> sketch_rv (x y) \<Longrightarrow>
      bit_count (F\<^sub>e z) \<le> ereal (12 + 4 * real r + 2 * log 2 (log 2 (real n + 13)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>y z. \<lbrakk>y < s; z \<in> sketch_rv (x y)\<rbrakk> \<Longrightarrow> bit_count (F\<^sub>e z) \<le> ereal (12 + 4 * real r + 2 * log 2 (log 2 (real n + 13)))
[PROOF STEP]
using a d
[PROOF STATE]
proof (prove)
using this:
?y1 \<in> {..<p} \<Longrightarrow> bit_count (F\<^sub>e (float_of (truncate_down r (real ?y1)))) \<le> ereal (12 + 4 * real r + 2 * log 2 (log 2 (real (n + 13))))
?y1 < s \<Longrightarrow> sketch_rv (x ?y1) \<subseteq> (\<lambda>k. float_of (truncate_down r (real k))) ` {..<p}

goal (1 subgoal):
 1. \<And>y z. \<lbrakk>y < s; z \<in> sketch_rv (x y)\<rbrakk> \<Longrightarrow> bit_count (F\<^sub>e z) \<le> ereal (12 + 4 * real r + 2 * log 2 (log 2 (real n + 13)))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<lbrakk>?y1 < s; ?z1 \<in> sketch_rv (x ?y1)\<rbrakk> \<Longrightarrow> bit_count (F\<^sub>e ?z1) \<le> ereal (12 + 4 * real r + 2 * log 2 (log 2 (real n + 13)))

goal (1 subgoal):
 1. bit_count (encode_f0_state (s, t, p, r, x, \<lambda>i\<in>{..<s}. sketch_rv (x i))) \<le> ereal (f0_space_usage (n, \<epsilon>, \<delta>))
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
?y1 < s \<Longrightarrow> finite (sketch_rv (x ?y1))
?y1 < s \<Longrightarrow> card (sketch_rv (x ?y1)) \<le> t
\<lbrakk>?y1 < s; ?z1 \<in> sketch_rv (x ?y1)\<rbrakk> \<Longrightarrow> bit_count (F\<^sub>e ?z1) \<le> ereal (12 + 4 * real r + 2 * log 2 (log 2 (real n + 13)))
[PROOF STEP]
have e: "\<And>y. y < s \<Longrightarrow> bit_count (S\<^sub>e F\<^sub>e (sketch_rv (x y)))
      \<le> ereal (real t) * (ereal (12 + 4 * real r + 2 * log 2 (log 2 (real (n + 13)))) + 1) + 1"
[PROOF STATE]
proof (prove)
using this:
?y1 < s \<Longrightarrow> finite (sketch_rv (x ?y1))
?y1 < s \<Longrightarrow> card (sketch_rv (x ?y1)) \<le> t
\<lbrakk>?y1 < s; ?z1 \<in> sketch_rv (x ?y1)\<rbrakk> \<Longrightarrow> bit_count (F\<^sub>e ?z1) \<le> ereal (12 + 4 * real r + 2 * log 2 (log 2 (real n + 13)))

goal (1 subgoal):
 1. \<And>y. y < s \<Longrightarrow> bit_count (S\<^sub>e F\<^sub>e (sketch_rv (x y))) \<le> ereal (real t) * (ereal (12 + 4 * real r + 2 * log 2 (log 2 (real (n + 13)))) + 1) + 1
[PROOF STEP]
using float_encoding
[PROOF STATE]
proof (prove)
using this:
?y1 < s \<Longrightarrow> finite (sketch_rv (x ?y1))
?y1 < s \<Longrightarrow> card (sketch_rv (x ?y1)) \<le> t
\<lbrakk>?y1 < s; ?z1 \<in> sketch_rv (x ?y1)\<rbrakk> \<Longrightarrow> bit_count (F\<^sub>e ?z1) \<le> ereal (12 + 4 * real r + 2 * log 2 (log 2 (real n + 13)))
is_encoding F\<^sub>e

goal (1 subgoal):
 1. \<And>y. y < s \<Longrightarrow> bit_count (S\<^sub>e F\<^sub>e (sketch_rv (x y))) \<le> ereal (real t) * (ereal (12 + 4 * real r + 2 * log 2 (log 2 (real (n + 13)))) + 1) + 1
[PROOF STEP]
by (intro set_bit_count_est, auto)
[PROOF STATE]
proof (state)
this:
?y1 < s \<Longrightarrow> bit_count (S\<^sub>e F\<^sub>e (sketch_rv (x ?y1))) \<le> ereal (real t) * (ereal (12 + 4 * real r + 2 * log 2 (log 2 (real (n + 13)))) + 1) + 1

goal (1 subgoal):
 1. bit_count (encode_f0_state (s, t, p, r, x, \<lambda>i\<in>{..<s}. sketch_rv (x i))) \<le> ereal (f0_space_usage (n, \<epsilon>, \<delta>))
[PROOF STEP]
have f: "\<And>y. y < s \<Longrightarrow> bit_count (P\<^sub>e p 2 (x y)) \<le> ereal (real 2 * (log 2 (real p) + 1))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>y. y < s \<Longrightarrow> bit_count (P\<^sub>e p 2 (x y)) \<le> ereal (real 2 * (log 2 (real p) + 1))
[PROOF STEP]
using p_gt_1 b
[PROOF STATE]
proof (prove)
using this:
1 < p
x \<in> {..<s} \<rightarrow>\<^sub>E local.space

goal (1 subgoal):
 1. \<And>y. y < s \<Longrightarrow> bit_count (P\<^sub>e p 2 (x y)) \<le> ereal (real 2 * (log 2 (real p) + 1))
[PROOF STEP]
by (intro bounded_degree_polynomial_bit_count) (simp_all add:space_def PiE_def Pi_def)
[PROOF STATE]
proof (state)
this:
?y1 < s \<Longrightarrow> bit_count (P\<^sub>e p 2 (x ?y1)) \<le> ereal (real 2 * (log 2 (real p) + 1))

goal (1 subgoal):
 1. bit_count (encode_f0_state (s, t, p, r, x, \<lambda>i\<in>{..<s}. sketch_rv (x i))) \<le> ereal (f0_space_usage (n, \<epsilon>, \<delta>))
[PROOF STEP]
have "bit_count (encode_f0_state (s, t, p, r, x, \<lambda>i\<in>{..<s}. sketch_rv (x i))) =
      bit_count (N\<^sub>e s) + bit_count (N\<^sub>e t) +  bit_count (N\<^sub>e p) + bit_count (N\<^sub>e r) +
      bit_count (([0..<s] \<rightarrow>\<^sub>e P\<^sub>e p 2) x) +
      bit_count (([0..<s] \<rightarrow>\<^sub>e S\<^sub>e F\<^sub>e) (\<lambda>i\<in>{..<s}. sketch_rv (x i)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bit_count (encode_f0_state (s, t, p, r, x, \<lambda>i\<in>{..<s}. sketch_rv (x i))) = bit_count (N\<^sub>e s) + bit_count (N\<^sub>e t) + bit_count (N\<^sub>e p) + bit_count (N\<^sub>e r) + bit_count (([0..<s] \<rightarrow>\<^sub>e P\<^sub>e p 2) x) + bit_count (([0..<s] \<rightarrow>\<^sub>e S\<^sub>e F\<^sub>e) (\<lambda>i\<in>{..<s}. sketch_rv (x i)))
[PROOF STEP]
by (simp add:encode_f0_state_def dependent_bit_count lessThan_atLeast0
        s_def[symmetric] t_def[symmetric] p_def[symmetric] r_def[symmetric] ac_simps)
[PROOF STATE]
proof (state)
this:
bit_count (encode_f0_state (s, t, p, r, x, \<lambda>i\<in>{..<s}. sketch_rv (x i))) = bit_count (N\<^sub>e s) + bit_count (N\<^sub>e t) + bit_count (N\<^sub>e p) + bit_count (N\<^sub>e r) + bit_count (([0..<s] \<rightarrow>\<^sub>e P\<^sub>e p 2) x) + bit_count (([0..<s] \<rightarrow>\<^sub>e S\<^sub>e F\<^sub>e) (\<lambda>i\<in>{..<s}. sketch_rv (x i)))

goal (1 subgoal):
 1. bit_count (encode_f0_state (s, t, p, r, x, \<lambda>i\<in>{..<s}. sketch_rv (x i))) \<le> ereal (f0_space_usage (n, \<epsilon>, \<delta>))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
bit_count (encode_f0_state (s, t, p, r, x, \<lambda>i\<in>{..<s}. sketch_rv (x i))) = bit_count (N\<^sub>e s) + bit_count (N\<^sub>e t) + bit_count (N\<^sub>e p) + bit_count (N\<^sub>e r) + bit_count (([0..<s] \<rightarrow>\<^sub>e P\<^sub>e p 2) x) + bit_count (([0..<s] \<rightarrow>\<^sub>e S\<^sub>e F\<^sub>e) (\<lambda>i\<in>{..<s}. sketch_rv (x i)))

goal (1 subgoal):
 1. bit_count (encode_f0_state (s, t, p, r, x, \<lambda>i\<in>{..<s}. sketch_rv (x i))) \<le> ereal (f0_space_usage (n, \<epsilon>, \<delta>))
[PROOF STEP]
have "... \<le> ereal (2* log 2 (real s + 1) + 1) + ereal  (2* log 2 (real t + 1) + 1)
      + ereal (2* log 2 (real p + 1) + 1) + ereal (2 * log 2 (real r + 1) + 1)
      + (ereal (real s) * (ereal (real 2 * (log 2 (real p) + 1))))
      + (ereal (real s) * ((ereal (real t) *
            (ereal (12 + 4 * real r + 2 * log 2 (log 2 (real (n + 13)))) + 1) + 1)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bit_count (N\<^sub>e s) + bit_count (N\<^sub>e t) + bit_count (N\<^sub>e p) + bit_count (N\<^sub>e r) + bit_count (([0..<s] \<rightarrow>\<^sub>e P\<^sub>e p 2) x) + bit_count (([0..<s] \<rightarrow>\<^sub>e S\<^sub>e F\<^sub>e) (\<lambda>i\<in>{..<s}. sketch_rv (x i))) \<le> ereal (2 * log 2 (real s + 1) + 1) + ereal (2 * log 2 (real t + 1) + 1) + ereal (2 * log 2 (real p + 1) + 1) + ereal (2 * log 2 (real r + 1) + 1) + ereal (real s) * ereal (real 2 * (log 2 (real p) + 1)) + ereal (real s) * (ereal (real t) * (ereal (12 + 4 * real r + 2 * log 2 (log 2 (real (n + 13)))) + 1) + 1)
[PROOF STEP]
using c e f
[PROOF STATE]
proof (prove)
using this:
x \<in> extensional {..<s}
?y1 < s \<Longrightarrow> bit_count (S\<^sub>e F\<^sub>e (sketch_rv (x ?y1))) \<le> ereal (real t) * (ereal (12 + 4 * real r + 2 * log 2 (log 2 (real (n + 13)))) + 1) + 1
?y1 < s \<Longrightarrow> bit_count (P\<^sub>e p 2 (x ?y1)) \<le> ereal (real 2 * (log 2 (real p) + 1))

goal (1 subgoal):
 1. bit_count (N\<^sub>e s) + bit_count (N\<^sub>e t) + bit_count (N\<^sub>e p) + bit_count (N\<^sub>e r) + bit_count (([0..<s] \<rightarrow>\<^sub>e P\<^sub>e p 2) x) + bit_count (([0..<s] \<rightarrow>\<^sub>e S\<^sub>e F\<^sub>e) (\<lambda>i\<in>{..<s}. sketch_rv (x i))) \<le> ereal (2 * log 2 (real s + 1) + 1) + ereal (2 * log 2 (real t + 1) + 1) + ereal (2 * log 2 (real p + 1) + 1) + ereal (2 * log 2 (real r + 1) + 1) + ereal (real s) * ereal (real 2 * (log 2 (real p) + 1)) + ereal (real s) * (ereal (real t) * (ereal (12 + 4 * real r + 2 * log 2 (log 2 (real (n + 13)))) + 1) + 1)
[PROOF STEP]
by (intro add_mono exp_golomb_bit_count fun_bit_count_est[where xs="[0..<s]", simplified])
       (simp_all add:lessThan_atLeast0)
[PROOF STATE]
proof (state)
this:
bit_count (N\<^sub>e s) + bit_count (N\<^sub>e t) + bit_count (N\<^sub>e p) + bit_count (N\<^sub>e r) + bit_count (([0..<s] \<rightarrow>\<^sub>e P\<^sub>e p 2) x) + bit_count (([0..<s] \<rightarrow>\<^sub>e S\<^sub>e F\<^sub>e) (\<lambda>i\<in>{..<s}. sketch_rv (x i))) \<le> ereal (2 * log 2 (real s + 1) + 1) + ereal (2 * log 2 (real t + 1) + 1) + ereal (2 * log 2 (real p + 1) + 1) + ereal (2 * log 2 (real r + 1) + 1) + ereal (real s) * ereal (real 2 * (log 2 (real p) + 1)) + ereal (real s) * (ereal (real t) * (ereal (12 + 4 * real r + 2 * log 2 (log 2 (real (n + 13)))) + 1) + 1)

goal (1 subgoal):
 1. bit_count (encode_f0_state (s, t, p, r, x, \<lambda>i\<in>{..<s}. sketch_rv (x i))) \<le> ereal (f0_space_usage (n, \<epsilon>, \<delta>))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
bit_count (N\<^sub>e s) + bit_count (N\<^sub>e t) + bit_count (N\<^sub>e p) + bit_count (N\<^sub>e r) + bit_count (([0..<s] \<rightarrow>\<^sub>e P\<^sub>e p 2) x) + bit_count (([0..<s] \<rightarrow>\<^sub>e S\<^sub>e F\<^sub>e) (\<lambda>i\<in>{..<s}. sketch_rv (x i))) \<le> ereal (2 * log 2 (real s + 1) + 1) + ereal (2 * log 2 (real t + 1) + 1) + ereal (2 * log 2 (real p + 1) + 1) + ereal (2 * log 2 (real r + 1) + 1) + ereal (real s) * ereal (real 2 * (log 2 (real p) + 1)) + ereal (real s) * (ereal (real t) * (ereal (12 + 4 * real r + 2 * log 2 (log 2 (real (n + 13)))) + 1) + 1)

goal (1 subgoal):
 1. bit_count (encode_f0_state (s, t, p, r, x, \<lambda>i\<in>{..<s}. sketch_rv (x i))) \<le> ereal (f0_space_usage (n, \<epsilon>, \<delta>))
[PROOF STEP]
have "... = ereal ( 4 + 2 * log 2 (real s + 1) + 2 * log 2 (real t + 1) +
      2 * log 2 (real p + 1) + 2 * log 2 (real r + 1) + real s * (3 + 2 * log 2 (real p) +
      real t * (13 + (4 * real r + 2 * log 2 (log 2 (real n + 13))))))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ereal (2 * log 2 (real s + 1) + 1) + ereal (2 * log 2 (real t + 1) + 1) + ereal (2 * log 2 (real p + 1) + 1) + ereal (2 * log 2 (real r + 1) + 1) + ereal (real s) * ereal (real 2 * (log 2 (real p) + 1)) + ereal (real s) * (ereal (real t) * (ereal (12 + 4 * real r + 2 * log 2 (log 2 (real (n + 13)))) + 1) + 1) = ereal (4 + 2 * log 2 (real s + 1) + 2 * log 2 (real t + 1) + 2 * log 2 (real p + 1) + 2 * log 2 (real r + 1) + real s * (3 + 2 * log 2 (real p) + real t * (13 + (4 * real r + 2 * log 2 (log 2 (real n + 13))))))
[PROOF STEP]
by (simp add:algebra_simps)
[PROOF STATE]
proof (state)
this:
ereal (2 * log 2 (real s + 1) + 1) + ereal (2 * log 2 (real t + 1) + 1) + ereal (2 * log 2 (real p + 1) + 1) + ereal (2 * log 2 (real r + 1) + 1) + ereal (real s) * ereal (real 2 * (log 2 (real p) + 1)) + ereal (real s) * (ereal (real t) * (ereal (12 + 4 * real r + 2 * log 2 (log 2 (real (n + 13)))) + 1) + 1) = ereal (4 + 2 * log 2 (real s + 1) + 2 * log 2 (real t + 1) + 2 * log 2 (real p + 1) + 2 * log 2 (real r + 1) + real s * (3 + 2 * log 2 (real p) + real t * (13 + (4 * real r + 2 * log 2 (log 2 (real n + 13))))))

goal (1 subgoal):
 1. bit_count (encode_f0_state (s, t, p, r, x, \<lambda>i\<in>{..<s}. sketch_rv (x i))) \<le> ereal (f0_space_usage (n, \<epsilon>, \<delta>))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
ereal (2 * log 2 (real s + 1) + 1) + ereal (2 * log 2 (real t + 1) + 1) + ereal (2 * log 2 (real p + 1) + 1) + ereal (2 * log 2 (real r + 1) + 1) + ereal (real s) * ereal (real 2 * (log 2 (real p) + 1)) + ereal (real s) * (ereal (real t) * (ereal (12 + 4 * real r + 2 * log 2 (log 2 (real (n + 13)))) + 1) + 1) = ereal (4 + 2 * log 2 (real s + 1) + 2 * log 2 (real t + 1) + 2 * log 2 (real p + 1) + 2 * log 2 (real r + 1) + real s * (3 + 2 * log 2 (real p) + real t * (13 + (4 * real r + 2 * log 2 (log 2 (real n + 13))))))

goal (1 subgoal):
 1. bit_count (encode_f0_state (s, t, p, r, x, \<lambda>i\<in>{..<s}. sketch_rv (x i))) \<le> ereal (f0_space_usage (n, \<epsilon>, \<delta>))
[PROOF STEP]
have "... \<le> ereal ( 4 + 2 * log 2 (real s + 1)  + 2 * log 2 (real t + 1) +
      2 * log 2 (2 * (21 + real n)) + 2 * log 2 (real r + 1) + real s * (3 + 2 * log 2 (2 * (21 + real n)) +
      real t * (13 + (4 * real r + 2 * log 2 (log 2 (real n + 13))))))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ereal (4 + 2 * log 2 (real s + 1) + 2 * log 2 (real t + 1) + 2 * log 2 (real p + 1) + 2 * log 2 (real r + 1) + real s * (3 + 2 * log 2 (real p) + real t * (13 + (4 * real r + 2 * log 2 (log 2 (real n + 13)))))) \<le> ereal (4 + 2 * log 2 (real s + 1) + 2 * log 2 (real t + 1) + 2 * log 2 (2 * (21 + real n)) + 2 * log 2 (real r + 1) + real s * (3 + 2 * log 2 (2 * (21 + real n)) + real t * (13 + (4 * real r + 2 * log 2 (log 2 (real n + 13))))))
[PROOF STEP]
using p_le_n p_gt_0
[PROOF STATE]
proof (prove)
using this:
p \<le> 2 * n + 40
0 < p

goal (1 subgoal):
 1. ereal (4 + 2 * log 2 (real s + 1) + 2 * log 2 (real t + 1) + 2 * log 2 (real p + 1) + 2 * log 2 (real r + 1) + real s * (3 + 2 * log 2 (real p) + real t * (13 + (4 * real r + 2 * log 2 (log 2 (real n + 13)))))) \<le> ereal (4 + 2 * log 2 (real s + 1) + 2 * log 2 (real t + 1) + 2 * log 2 (2 * (21 + real n)) + 2 * log 2 (real r + 1) + real s * (3 + 2 * log 2 (2 * (21 + real n)) + real t * (13 + (4 * real r + 2 * log 2 (log 2 (real n + 13))))))
[PROOF STEP]
by (intro ereal_mono add_mono mult_left_mono, auto)
[PROOF STATE]
proof (state)
this:
ereal (4 + 2 * log 2 (real s + 1) + 2 * log 2 (real t + 1) + 2 * log 2 (real p + 1) + 2 * log 2 (real r + 1) + real s * (3 + 2 * log 2 (real p) + real t * (13 + (4 * real r + 2 * log 2 (log 2 (real n + 13)))))) \<le> ereal (4 + 2 * log 2 (real s + 1) + 2 * log 2 (real t + 1) + 2 * log 2 (2 * (21 + real n)) + 2 * log 2 (real r + 1) + real s * (3 + 2 * log 2 (2 * (21 + real n)) + real t * (13 + (4 * real r + 2 * log 2 (log 2 (real n + 13))))))

goal (1 subgoal):
 1. bit_count (encode_f0_state (s, t, p, r, x, \<lambda>i\<in>{..<s}. sketch_rv (x i))) \<le> ereal (f0_space_usage (n, \<epsilon>, \<delta>))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
ereal (4 + 2 * log 2 (real s + 1) + 2 * log 2 (real t + 1) + 2 * log 2 (real p + 1) + 2 * log 2 (real r + 1) + real s * (3 + 2 * log 2 (real p) + real t * (13 + (4 * real r + 2 * log 2 (log 2 (real n + 13)))))) \<le> ereal (4 + 2 * log 2 (real s + 1) + 2 * log 2 (real t + 1) + 2 * log 2 (2 * (21 + real n)) + 2 * log 2 (real r + 1) + real s * (3 + 2 * log 2 (2 * (21 + real n)) + real t * (13 + (4 * real r + 2 * log 2 (log 2 (real n + 13))))))

goal (1 subgoal):
 1. bit_count (encode_f0_state (s, t, p, r, x, \<lambda>i\<in>{..<s}. sketch_rv (x i))) \<le> ereal (f0_space_usage (n, \<epsilon>, \<delta>))
[PROOF STEP]
have "... =  ereal (6 + 2 * log 2 (real s + 1) + 2 * log 2 (real t + 1) +
      2 * log 2 (21 + real n) + 2 * log 2 (real r + 1) + real s * (5 + 2 * log 2 (21 + real n) +
      real t * (13 + (4 * real r + 2 * log 2 (log 2 (real n + 13))))))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ereal (4 + 2 * log 2 (real s + 1) + 2 * log 2 (real t + 1) + 2 * log 2 (2 * (21 + real n)) + 2 * log 2 (real r + 1) + real s * (3 + 2 * log 2 (2 * (21 + real n)) + real t * (13 + (4 * real r + 2 * log 2 (log 2 (real n + 13)))))) = ereal (6 + 2 * log 2 (real s + 1) + 2 * log 2 (real t + 1) + 2 * log 2 (21 + real n) + 2 * log 2 (real r + 1) + real s * (5 + 2 * log 2 (21 + real n) + real t * (13 + (4 * real r + 2 * log 2 (log 2 (real n + 13))))))
[PROOF STEP]
by (subst (1 2) log_mult, auto)
[PROOF STATE]
proof (state)
this:
ereal (4 + 2 * log 2 (real s + 1) + 2 * log 2 (real t + 1) + 2 * log 2 (2 * (21 + real n)) + 2 * log 2 (real r + 1) + real s * (3 + 2 * log 2 (2 * (21 + real n)) + real t * (13 + (4 * real r + 2 * log 2 (log 2 (real n + 13)))))) = ereal (6 + 2 * log 2 (real s + 1) + 2 * log 2 (real t + 1) + 2 * log 2 (21 + real n) + 2 * log 2 (real r + 1) + real s * (5 + 2 * log 2 (21 + real n) + real t * (13 + (4 * real r + 2 * log 2 (log 2 (real n + 13))))))

goal (1 subgoal):
 1. bit_count (encode_f0_state (s, t, p, r, x, \<lambda>i\<in>{..<s}. sketch_rv (x i))) \<le> ereal (f0_space_usage (n, \<epsilon>, \<delta>))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
ereal (4 + 2 * log 2 (real s + 1) + 2 * log 2 (real t + 1) + 2 * log 2 (2 * (21 + real n)) + 2 * log 2 (real r + 1) + real s * (3 + 2 * log 2 (2 * (21 + real n)) + real t * (13 + (4 * real r + 2 * log 2 (log 2 (real n + 13)))))) = ereal (6 + 2 * log 2 (real s + 1) + 2 * log 2 (real t + 1) + 2 * log 2 (21 + real n) + 2 * log 2 (real r + 1) + real s * (5 + 2 * log 2 (21 + real n) + real t * (13 + (4 * real r + 2 * log 2 (log 2 (real n + 13))))))

goal (1 subgoal):
 1. bit_count (encode_f0_state (s, t, p, r, x, \<lambda>i\<in>{..<s}. sketch_rv (x i))) \<le> ereal (f0_space_usage (n, \<epsilon>, \<delta>))
[PROOF STEP]
have "... \<le> f0_space_usage (n, \<epsilon>, \<delta>)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ereal (6 + 2 * log 2 (real s + 1) + 2 * log 2 (real t + 1) + 2 * log 2 (21 + real n) + 2 * log 2 (real r + 1) + real s * (5 + 2 * log 2 (21 + real n) + real t * (13 + (4 * real r + 2 * log 2 (log 2 (real n + 13)))))) \<le> ereal (f0_space_usage (n, \<epsilon>, \<delta>))
[PROOF STEP]
by (simp add:s_def[symmetric] r_def[symmetric] t_def[symmetric] Let_def)
       (simp add:algebra_simps)
[PROOF STATE]
proof (state)
this:
ereal (6 + 2 * log 2 (real s + 1) + 2 * log 2 (real t + 1) + 2 * log 2 (21 + real n) + 2 * log 2 (real r + 1) + real s * (5 + 2 * log 2 (21 + real n) + real t * (13 + (4 * real r + 2 * log 2 (log 2 (real n + 13)))))) \<le> ereal (f0_space_usage (n, \<epsilon>, \<delta>))

goal (1 subgoal):
 1. bit_count (encode_f0_state (s, t, p, r, x, \<lambda>i\<in>{..<s}. sketch_rv (x i))) \<le> ereal (f0_space_usage (n, \<epsilon>, \<delta>))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
bit_count (encode_f0_state (s, t, p, r, x, \<lambda>i\<in>{..<s}. sketch_rv (x i))) \<le> ereal (f0_space_usage (n, \<epsilon>, \<delta>))
[PROOF STEP]
show "bit_count (encode_f0_state (s, t, p, r, x, \<lambda>i\<in>{..<s}. sketch_rv (x i))) \<le>
        f0_space_usage (n, \<epsilon>, \<delta>)"
[PROOF STATE]
proof (prove)
using this:
bit_count (encode_f0_state (s, t, p, r, x, \<lambda>i\<in>{..<s}. sketch_rv (x i))) \<le> ereal (f0_space_usage (n, \<epsilon>, \<delta>))

goal (1 subgoal):
 1. bit_count (encode_f0_state (s, t, p, r, x, \<lambda>i\<in>{..<s}. sketch_rv (x i))) \<le> ereal (f0_space_usage (n, \<epsilon>, \<delta>))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
bit_count (encode_f0_state (s, t, p, r, x, \<lambda>i\<in>{..<s}. sketch_rv (x i))) \<le> ereal (f0_space_usage (n, \<epsilon>, \<delta>))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
?x1 \<in> {..<s} \<rightarrow>\<^sub>E local.space \<Longrightarrow> bit_count (encode_f0_state (s, t, p, r, ?x1, \<lambda>i\<in>{..<s}. sketch_rv (?x1 i))) \<le> ereal (f0_space_usage (n, \<epsilon>, \<delta>))

goal (1 subgoal):
 1. AE \<omega> in measure_pmf \<Omega>. bit_count (encode_f0_state \<omega>) \<le> ereal (f0_space_usage (n, \<epsilon>, \<delta>))
[PROOF STEP]
hence "\<And>x. x \<in> set_pmf \<Omega>\<^sub>0 \<Longrightarrow>
         bit_count (encode_f0_state (s, t, p, r, x, \<lambda>i\<in>{..<s}. sketch_rv (x i)))  \<le> ereal (f0_space_usage (n, \<epsilon>, \<delta>))"
[PROOF STATE]
proof (prove)
using this:
?x1 \<in> {..<s} \<rightarrow>\<^sub>E local.space \<Longrightarrow> bit_count (encode_f0_state (s, t, p, r, ?x1, \<lambda>i\<in>{..<s}. sketch_rv (?x1 i))) \<le> ereal (f0_space_usage (n, \<epsilon>, \<delta>))

goal (1 subgoal):
 1. \<And>x. x \<in> set_pmf \<Omega>\<^sub>0 \<Longrightarrow> bit_count (encode_f0_state (s, t, p, r, x, \<lambda>i\<in>{..<s}. sketch_rv (x i))) \<le> ereal (f0_space_usage (n, \<epsilon>, \<delta>))
[PROOF STEP]
by (simp add:\<Omega>\<^sub>0_def set_prod_pmf del:f0_space_usage.simps)
[PROOF STATE]
proof (state)
this:
?x1 \<in> set_pmf \<Omega>\<^sub>0 \<Longrightarrow> bit_count (encode_f0_state (s, t, p, r, ?x1, \<lambda>i\<in>{..<s}. sketch_rv (?x1 i))) \<le> ereal (f0_space_usage (n, \<epsilon>, \<delta>))

goal (1 subgoal):
 1. AE \<omega> in measure_pmf \<Omega>. bit_count (encode_f0_state \<omega>) \<le> ereal (f0_space_usage (n, \<epsilon>, \<delta>))
[PROOF STEP]
hence "\<And>y. y \<in> set_pmf \<Omega> \<Longrightarrow> bit_count (encode_f0_state y) \<le> ereal (f0_space_usage (n, \<epsilon>, \<delta>))"
[PROOF STATE]
proof (prove)
using this:
?x1 \<in> set_pmf \<Omega>\<^sub>0 \<Longrightarrow> bit_count (encode_f0_state (s, t, p, r, ?x1, \<lambda>i\<in>{..<s}. sketch_rv (?x1 i))) \<le> ereal (f0_space_usage (n, \<epsilon>, \<delta>))

goal (1 subgoal):
 1. \<And>y. y \<in> set_pmf \<Omega> \<Longrightarrow> bit_count (encode_f0_state y) \<le> ereal (f0_space_usage (n, \<epsilon>, \<delta>))
[PROOF STEP]
by (simp add: \<Omega>_def f0_alg_sketch del:f0_space_usage.simps f0_init.simps)
     (metis (no_types, lifting) image_iff pmf.set_map)
[PROOF STATE]
proof (state)
this:
?y1 \<in> set_pmf \<Omega> \<Longrightarrow> bit_count (encode_f0_state ?y1) \<le> ereal (f0_space_usage (n, \<epsilon>, \<delta>))

goal (1 subgoal):
 1. AE \<omega> in measure_pmf \<Omega>. bit_count (encode_f0_state \<omega>) \<le> ereal (f0_space_usage (n, \<epsilon>, \<delta>))
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
?y1 \<in> set_pmf \<Omega> \<Longrightarrow> bit_count (encode_f0_state ?y1) \<le> ereal (f0_space_usage (n, \<epsilon>, \<delta>))

goal (1 subgoal):
 1. AE \<omega> in measure_pmf \<Omega>. bit_count (encode_f0_state \<omega>) \<le> ereal (f0_space_usage (n, \<epsilon>, \<delta>))
[PROOF STEP]
by (simp add: AE_measure_pmf_iff del:f0_space_usage.simps)
[PROOF STATE]
proof (state)
this:
AE \<omega> in measure_pmf \<Omega>. bit_count (encode_f0_state \<omega>) \<le> ereal (f0_space_usage (n, \<epsilon>, \<delta>))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma nodes_semi_auxi:
  "let A = (rev \<circ> sorted_list_of_set) ` (Pow (set (nodes)));
       r = nodes_le;
       f = (\<lambda>x y.  (inter_sorted_rev x y))
    in semilat(A, r, f)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. let A = (rev \<circ> sorted_list_of_set) ` Pow (set nodes); r = nodes_le; f = inter_sorted_rev in semilat (A, r, f)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. let A = (rev \<circ> sorted_list_of_set) ` Pow (set nodes); r = nodes_le; f = inter_sorted_rev in semilat (A, r, f)
[PROOF STEP]
let ?A = "(rev \<circ> sorted_list_of_set) ` (Pow (set (nodes)))"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. let A = (rev \<circ> sorted_list_of_set) ` Pow (set nodes); r = nodes_le; f = inter_sorted_rev in semilat (A, r, f)
[PROOF STEP]
let ?r = "nodes_le"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. let A = (rev \<circ> sorted_list_of_set) ` Pow (set nodes); r = nodes_le; f = inter_sorted_rev in semilat (A, r, f)
[PROOF STEP]
let ?f = "(\<lambda>x y. (inter_sorted_rev x y))"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. let A = (rev \<circ> sorted_list_of_set) ` Pow (set nodes); r = nodes_le; f = inter_sorted_rev in semilat (A, r, f)
[PROOF STEP]
have "order ?r ?A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. order nodes_le ((rev \<circ> sorted_list_of_set) ` Pow (set nodes))
[PROOF STEP]
by (rule nodes_le_order)
[PROOF STATE]
proof (state)
this:
order nodes_le ((rev \<circ> sorted_list_of_set) ` Pow (set nodes))

goal (1 subgoal):
 1. let A = (rev \<circ> sorted_list_of_set) ` Pow (set nodes); r = nodes_le; f = inter_sorted_rev in semilat (A, r, f)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
order nodes_le ((rev \<circ> sorted_list_of_set) ` Pow (set nodes))

goal (1 subgoal):
 1. let A = (rev \<circ> sorted_list_of_set) ` Pow (set nodes); r = nodes_le; f = inter_sorted_rev in semilat (A, r, f)
[PROOF STEP]
have "closed ?A ?f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. closed ((rev \<circ> sorted_list_of_set) ` Pow (set nodes)) inter_sorted_rev
[PROOF STEP]
proof (unfold closed_def, intro strip)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes); y \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes)\<rbrakk> \<Longrightarrow> x \<squnion>\<^bsub>inter_sorted_rev\<^esub> y \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes)
[PROOF STEP]
fix xs ys
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes); y \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes)\<rbrakk> \<Longrightarrow> x \<squnion>\<^bsub>inter_sorted_rev\<^esub> y \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes)
[PROOF STEP]
assume xs_in: "xs \<in> ?A" and ys_in: "ys \<in> ?A"
[PROOF STATE]
proof (state)
this:
xs \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes)
ys \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes)

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes); y \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes)\<rbrakk> \<Longrightarrow> x \<squnion>\<^bsub>inter_sorted_rev\<^esub> y \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
xs \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes)
ys \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes)
[PROOF STEP]
have sorted_xs: "sorted (rev xs)"
          and sorted_ys: "sorted (rev ys)"
[PROOF STATE]
proof (prove)
using this:
xs \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes)
ys \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes)

goal (1 subgoal):
 1. Sorted_Less.sorted (rev xs) &&& Sorted_Less.sorted (rev ys)
[PROOF STEP]
by (auto intro: sorted_less_sorted_list_of_set)
[PROOF STATE]
proof (state)
this:
Sorted_Less.sorted (rev xs)
Sorted_Less.sorted (rev ys)

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes); y \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes)\<rbrakk> \<Longrightarrow> x \<squnion>\<^bsub>inter_sorted_rev\<^esub> y \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
Sorted_Less.sorted (rev xs)
Sorted_Less.sorted (rev ys)
[PROOF STEP]
have inter_xs_ys: "set (?f xs ys) = set xs \<inter> set ys" and
              sorted_res: "sorted (rev (?f xs ys))"
[PROOF STATE]
proof (prove)
using this:
Sorted_Less.sorted (rev xs)
Sorted_Less.sorted (rev ys)

goal (1 subgoal):
 1. set (inter_sorted_rev xs ys) = set xs \<inter> set ys &&& Sorted_Less.sorted (rev (inter_sorted_rev xs ys))
[PROOF STEP]
using inter_sorted_correct
[PROOF STATE]
proof (prove)
using this:
Sorted_Less.sorted (rev xs)
Sorted_Less.sorted (rev ys)
\<lbrakk>Sorted_Less.sorted (rev ?l1.0); Sorted_Less.sorted (rev ?l2.0)\<rbrakk> \<Longrightarrow> Sorted_Less.sorted (rev (inter_sorted_rev ?l1.0 ?l2.0)) \<and> set (inter_sorted_rev ?l1.0 ?l2.0) = set ?l1.0 \<inter> set ?l2.0

goal (1 subgoal):
 1. set (inter_sorted_rev xs ys) = set xs \<inter> set ys &&& Sorted_Less.sorted (rev (inter_sorted_rev xs ys))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
set (inter_sorted_rev xs ys) = set xs \<inter> set ys
Sorted_Less.sorted (rev (inter_sorted_rev xs ys))

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes); y \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes)\<rbrakk> \<Longrightarrow> x \<squnion>\<^bsub>inter_sorted_rev\<^esub> y \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes)
[PROOF STEP]
from xs_in
[PROOF STATE]
proof (chain)
picking this:
xs \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes)
[PROOF STEP]
have "set xs \<subseteq> set nodes"
[PROOF STATE]
proof (prove)
using this:
xs \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes)

goal (1 subgoal):
 1. set xs \<subseteq> set nodes
[PROOF STEP]
using inpow_subset_nodes
[PROOF STATE]
proof (prove)
using this:
xs \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes)
?xs \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes) \<Longrightarrow> set ?xs \<subseteq> set nodes

goal (1 subgoal):
 1. set xs \<subseteq> set nodes
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
set xs \<subseteq> set nodes

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes); y \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes)\<rbrakk> \<Longrightarrow> x \<squnion>\<^bsub>inter_sorted_rev\<^esub> y \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes)
[PROOF STEP]
with inter_xs_ys
[PROOF STATE]
proof (chain)
picking this:
set (inter_sorted_rev xs ys) = set xs \<inter> set ys
set xs \<subseteq> set nodes
[PROOF STEP]
have "set (?f xs ys) \<subseteq> set nodes"
[PROOF STATE]
proof (prove)
using this:
set (inter_sorted_rev xs ys) = set xs \<inter> set ys
set xs \<subseteq> set nodes

goal (1 subgoal):
 1. set (inter_sorted_rev xs ys) \<subseteq> set nodes
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
set (inter_sorted_rev xs ys) \<subseteq> set nodes

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes); y \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes)\<rbrakk> \<Longrightarrow> x \<squnion>\<^bsub>inter_sorted_rev\<^esub> y \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes)
[PROOF STEP]
with sorted_res
[PROOF STATE]
proof (chain)
picking this:
Sorted_Less.sorted (rev (inter_sorted_rev xs ys))
set (inter_sorted_rev xs ys) \<subseteq> set nodes
[PROOF STEP]
show "xs \<squnion>\<^bsub>?f\<^esub> ys\<in> ?A"
[PROOF STATE]
proof (prove)
using this:
Sorted_Less.sorted (rev (inter_sorted_rev xs ys))
set (inter_sorted_rev xs ys) \<subseteq> set nodes

goal (1 subgoal):
 1. xs \<squnion>\<^bsub>inter_sorted_rev\<^esub> ys \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes)
[PROOF STEP]
using subset_nodes_inpow
[PROOF STATE]
proof (prove)
using this:
Sorted_Less.sorted (rev (inter_sorted_rev xs ys))
set (inter_sorted_rev xs ys) \<subseteq> set nodes
\<lbrakk>Sorted_Less.sorted (rev ?xs); set ?xs \<subseteq> set nodes\<rbrakk> \<Longrightarrow> ?xs \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes)

goal (1 subgoal):
 1. xs \<squnion>\<^bsub>inter_sorted_rev\<^esub> ys \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes)
[PROOF STEP]
by (auto simp add:plussub_def)
[PROOF STATE]
proof (state)
this:
xs \<squnion>\<^bsub>inter_sorted_rev\<^esub> ys \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
closed ((rev \<circ> sorted_list_of_set) ` Pow (set nodes)) inter_sorted_rev

goal (1 subgoal):
 1. let A = (rev \<circ> sorted_list_of_set) ` Pow (set nodes); r = nodes_le; f = inter_sorted_rev in semilat (A, r, f)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
closed ((rev \<circ> sorted_list_of_set) ` Pow (set nodes)) inter_sorted_rev

goal (1 subgoal):
 1. let A = (rev \<circ> sorted_list_of_set) ` Pow (set nodes); r = nodes_le; f = inter_sorted_rev in semilat (A, r, f)
[PROOF STEP]
have "(\<forall>x\<in>?A. \<forall>y\<in>?A. x \<sqsubseteq>\<^bsub>?r\<^esub> x \<squnion>\<^bsub>?f\<^esub> y) \<and> (\<forall>x\<in>?A. \<forall>y\<in>?A. y \<sqsubseteq>\<^bsub>?r\<^esub> x \<squnion>\<^bsub>?f\<^esub> y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<forall>x\<in>(rev \<circ> sorted_list_of_set) ` Pow (set nodes). \<forall>y\<in>(rev \<circ> sorted_list_of_set) ` Pow (set nodes). x \<sqsubseteq>\<^bsub>nodes_le\<^esub> x \<squnion>\<^bsub>inter_sorted_rev\<^esub> y) \<and> (\<forall>x\<in>(rev \<circ> sorted_list_of_set) ` Pow (set nodes). \<forall>y\<in>(rev \<circ> sorted_list_of_set) ` Pow (set nodes). y \<sqsubseteq>\<^bsub>nodes_le\<^esub> x \<squnion>\<^bsub>inter_sorted_rev\<^esub> y)
[PROOF STEP]
proof(rule conjI, intro strip)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>x y. \<lbrakk>x \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes); y \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes)\<rbrakk> \<Longrightarrow> x \<sqsubseteq>\<^bsub>nodes_le\<^esub> x \<squnion>\<^bsub>inter_sorted_rev\<^esub> y
 2. \<forall>x\<in>(rev \<circ> sorted_list_of_set) ` Pow (set nodes). \<forall>y\<in>(rev \<circ> sorted_list_of_set) ` Pow (set nodes). y \<sqsubseteq>\<^bsub>nodes_le\<^esub> x \<squnion>\<^bsub>inter_sorted_rev\<^esub> y
[PROOF STEP]
fix xs ys
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>x y. \<lbrakk>x \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes); y \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes)\<rbrakk> \<Longrightarrow> x \<sqsubseteq>\<^bsub>nodes_le\<^esub> x \<squnion>\<^bsub>inter_sorted_rev\<^esub> y
 2. \<forall>x\<in>(rev \<circ> sorted_list_of_set) ` Pow (set nodes). \<forall>y\<in>(rev \<circ> sorted_list_of_set) ` Pow (set nodes). y \<sqsubseteq>\<^bsub>nodes_le\<^esub> x \<squnion>\<^bsub>inter_sorted_rev\<^esub> y
[PROOF STEP]
assume xs_in: "xs \<in> ?A" and ys_in: "ys \<in> ?A"
[PROOF STATE]
proof (state)
this:
xs \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes)
ys \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes)

goal (2 subgoals):
 1. \<And>x y. \<lbrakk>x \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes); y \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes)\<rbrakk> \<Longrightarrow> x \<sqsubseteq>\<^bsub>nodes_le\<^esub> x \<squnion>\<^bsub>inter_sorted_rev\<^esub> y
 2. \<forall>x\<in>(rev \<circ> sorted_list_of_set) ` Pow (set nodes). \<forall>y\<in>(rev \<circ> sorted_list_of_set) ` Pow (set nodes). y \<sqsubseteq>\<^bsub>nodes_le\<^esub> x \<squnion>\<^bsub>inter_sorted_rev\<^esub> y
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
xs \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes)
ys \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes)
[PROOF STEP]
have sorted_xs: "sorted (rev xs)" and sorted_ys: "sorted (rev ys)"
[PROOF STATE]
proof (prove)
using this:
xs \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes)
ys \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes)

goal (1 subgoal):
 1. Sorted_Less.sorted (rev xs) &&& Sorted_Less.sorted (rev ys)
[PROOF STEP]
by (auto intro: sorted_less_sorted_list_of_set)
[PROOF STATE]
proof (state)
this:
Sorted_Less.sorted (rev xs)
Sorted_Less.sorted (rev ys)

goal (2 subgoals):
 1. \<And>x y. \<lbrakk>x \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes); y \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes)\<rbrakk> \<Longrightarrow> x \<sqsubseteq>\<^bsub>nodes_le\<^esub> x \<squnion>\<^bsub>inter_sorted_rev\<^esub> y
 2. \<forall>x\<in>(rev \<circ> sorted_list_of_set) ` Pow (set nodes). \<forall>y\<in>(rev \<circ> sorted_list_of_set) ` Pow (set nodes). y \<sqsubseteq>\<^bsub>nodes_le\<^esub> x \<squnion>\<^bsub>inter_sorted_rev\<^esub> y
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
Sorted_Less.sorted (rev xs)
Sorted_Less.sorted (rev ys)
[PROOF STEP]
have "set (?f xs ys) \<subseteq> set xs" and sorted_f_xs_ys: "sorted (rev (?f xs ys))"
[PROOF STATE]
proof (prove)
using this:
Sorted_Less.sorted (rev xs)
Sorted_Less.sorted (rev ys)

goal (1 subgoal):
 1. set (inter_sorted_rev xs ys) \<subseteq> set xs &&& Sorted_Less.sorted (rev (inter_sorted_rev xs ys))
[PROOF STEP]
by (auto simp add: inter_sorted_correct)
[PROOF STATE]
proof (state)
this:
set (inter_sorted_rev xs ys) \<subseteq> set xs
Sorted_Less.sorted (rev (inter_sorted_rev xs ys))

goal (2 subgoals):
 1. \<And>x y. \<lbrakk>x \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes); y \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes)\<rbrakk> \<Longrightarrow> x \<sqsubseteq>\<^bsub>nodes_le\<^esub> x \<squnion>\<^bsub>inter_sorted_rev\<^esub> y
 2. \<forall>x\<in>(rev \<circ> sorted_list_of_set) ` Pow (set nodes). \<forall>y\<in>(rev \<circ> sorted_list_of_set) ` Pow (set nodes). y \<sqsubseteq>\<^bsub>nodes_le\<^esub> x \<squnion>\<^bsub>inter_sorted_rev\<^esub> y
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
set (inter_sorted_rev xs ys) \<subseteq> set xs
Sorted_Less.sorted (rev (inter_sorted_rev xs ys))
[PROOF STEP]
show "xs \<sqsubseteq>\<^bsub>?r\<^esub> xs \<squnion>\<^bsub>?f\<^esub> ys"
[PROOF STATE]
proof (prove)
using this:
set (inter_sorted_rev xs ys) \<subseteq> set xs
Sorted_Less.sorted (rev (inter_sorted_rev xs ys))

goal (1 subgoal):
 1. xs \<sqsubseteq>\<^bsub>nodes_le\<^esub> xs \<squnion>\<^bsub>inter_sorted_rev\<^esub> ys
[PROOF STEP]
by (simp add: lesub_def sorted_xs sorted_ys sorted_f_xs_ys nodes_le_def plussub_def)
[PROOF STATE]
proof (state)
this:
xs \<sqsubseteq>\<^bsub>nodes_le\<^esub> xs \<squnion>\<^bsub>inter_sorted_rev\<^esub> ys

goal (1 subgoal):
 1. \<forall>x\<in>(rev \<circ> sorted_list_of_set) ` Pow (set nodes). \<forall>y\<in>(rev \<circ> sorted_list_of_set) ` Pow (set nodes). y \<sqsubseteq>\<^bsub>nodes_le\<^esub> x \<squnion>\<^bsub>inter_sorted_rev\<^esub> y
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<forall>x\<in>(rev \<circ> sorted_list_of_set) ` Pow (set nodes). \<forall>y\<in>(rev \<circ> sorted_list_of_set) ` Pow (set nodes). y \<sqsubseteq>\<^bsub>nodes_le\<^esub> x \<squnion>\<^bsub>inter_sorted_rev\<^esub> y
[PROOF STEP]
show "\<forall>x\<in>?A. \<forall>y\<in>?A. y \<sqsubseteq>\<^bsub>?r\<^esub> x \<squnion>\<^bsub>?f\<^esub> y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>x\<in>(rev \<circ> sorted_list_of_set) ` Pow (set nodes). \<forall>y\<in>(rev \<circ> sorted_list_of_set) ` Pow (set nodes). y \<sqsubseteq>\<^bsub>nodes_le\<^esub> x \<squnion>\<^bsub>inter_sorted_rev\<^esub> y
[PROOF STEP]
proof (intro strip)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes); y \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes)\<rbrakk> \<Longrightarrow> y \<sqsubseteq>\<^bsub>nodes_le\<^esub> x \<squnion>\<^bsub>inter_sorted_rev\<^esub> y
[PROOF STEP]
fix xs ys
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes); y \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes)\<rbrakk> \<Longrightarrow> y \<sqsubseteq>\<^bsub>nodes_le\<^esub> x \<squnion>\<^bsub>inter_sorted_rev\<^esub> y
[PROOF STEP]
assume xs_in: "xs \<in> ?A" and ys_in: "ys \<in> ?A"
[PROOF STATE]
proof (state)
this:
xs \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes)
ys \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes)

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes); y \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes)\<rbrakk> \<Longrightarrow> y \<sqsubseteq>\<^bsub>nodes_le\<^esub> x \<squnion>\<^bsub>inter_sorted_rev\<^esub> y
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
xs \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes)
ys \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes)
[PROOF STEP]
have sorted_xs: "sorted (rev xs)" and sorted_ys: "sorted (rev ys)"
[PROOF STATE]
proof (prove)
using this:
xs \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes)
ys \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes)

goal (1 subgoal):
 1. Sorted_Less.sorted (rev xs) &&& Sorted_Less.sorted (rev ys)
[PROOF STEP]
by (auto intro: sorted_less_sorted_list_of_set)
[PROOF STATE]
proof (state)
this:
Sorted_Less.sorted (rev xs)
Sorted_Less.sorted (rev ys)

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes); y \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes)\<rbrakk> \<Longrightarrow> y \<sqsubseteq>\<^bsub>nodes_le\<^esub> x \<squnion>\<^bsub>inter_sorted_rev\<^esub> y
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
Sorted_Less.sorted (rev xs)
Sorted_Less.sorted (rev ys)
[PROOF STEP]
have "set (?f xs ys) \<subseteq> set ys" and sorted_f_xs_ys: "sorted (rev (?f xs ys))"
[PROOF STATE]
proof (prove)
using this:
Sorted_Less.sorted (rev xs)
Sorted_Less.sorted (rev ys)

goal (1 subgoal):
 1. set (inter_sorted_rev xs ys) \<subseteq> set ys &&& Sorted_Less.sorted (rev (inter_sorted_rev xs ys))
[PROOF STEP]
by (auto simp add: inter_sorted_correct)
[PROOF STATE]
proof (state)
this:
set (inter_sorted_rev xs ys) \<subseteq> set ys
Sorted_Less.sorted (rev (inter_sorted_rev xs ys))

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes); y \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes)\<rbrakk> \<Longrightarrow> y \<sqsubseteq>\<^bsub>nodes_le\<^esub> x \<squnion>\<^bsub>inter_sorted_rev\<^esub> y
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
set (inter_sorted_rev xs ys) \<subseteq> set ys
Sorted_Less.sorted (rev (inter_sorted_rev xs ys))
[PROOF STEP]
show "ys \<sqsubseteq>\<^bsub>?r\<^esub> xs \<squnion>\<^bsub>?f\<^esub> ys"
[PROOF STATE]
proof (prove)
using this:
set (inter_sorted_rev xs ys) \<subseteq> set ys
Sorted_Less.sorted (rev (inter_sorted_rev xs ys))

goal (1 subgoal):
 1. ys \<sqsubseteq>\<^bsub>nodes_le\<^esub> xs \<squnion>\<^bsub>inter_sorted_rev\<^esub> ys
[PROOF STEP]
by (simp add: lesub_def sorted_ys sorted_xs sorted_f_xs_ys nodes_le_def plussub_def)
[PROOF STATE]
proof (state)
this:
ys \<sqsubseteq>\<^bsub>nodes_le\<^esub> xs \<squnion>\<^bsub>inter_sorted_rev\<^esub> ys

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<forall>x\<in>(rev \<circ> sorted_list_of_set) ` Pow (set nodes). \<forall>y\<in>(rev \<circ> sorted_list_of_set) ` Pow (set nodes). y \<sqsubseteq>\<^bsub>nodes_le\<^esub> x \<squnion>\<^bsub>inter_sorted_rev\<^esub> y

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<forall>x\<in>(rev \<circ> sorted_list_of_set) ` Pow (set nodes). \<forall>y\<in>(rev \<circ> sorted_list_of_set) ` Pow (set nodes). x \<sqsubseteq>\<^bsub>nodes_le\<^esub> x \<squnion>\<^bsub>inter_sorted_rev\<^esub> y) \<and> (\<forall>x\<in>(rev \<circ> sorted_list_of_set) ` Pow (set nodes). \<forall>y\<in>(rev \<circ> sorted_list_of_set) ` Pow (set nodes). y \<sqsubseteq>\<^bsub>nodes_le\<^esub> x \<squnion>\<^bsub>inter_sorted_rev\<^esub> y)

goal (1 subgoal):
 1. let A = (rev \<circ> sorted_list_of_set) ` Pow (set nodes); r = nodes_le; f = inter_sorted_rev in semilat (A, r, f)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
(\<forall>x\<in>(rev \<circ> sorted_list_of_set) ` Pow (set nodes). \<forall>y\<in>(rev \<circ> sorted_list_of_set) ` Pow (set nodes). x \<sqsubseteq>\<^bsub>nodes_le\<^esub> x \<squnion>\<^bsub>inter_sorted_rev\<^esub> y) \<and> (\<forall>x\<in>(rev \<circ> sorted_list_of_set) ` Pow (set nodes). \<forall>y\<in>(rev \<circ> sorted_list_of_set) ` Pow (set nodes). y \<sqsubseteq>\<^bsub>nodes_le\<^esub> x \<squnion>\<^bsub>inter_sorted_rev\<^esub> y)

goal (1 subgoal):
 1. let A = (rev \<circ> sorted_list_of_set) ` Pow (set nodes); r = nodes_le; f = inter_sorted_rev in semilat (A, r, f)
[PROOF STEP]
have "\<forall>x\<in>?A. \<forall>y\<in>?A. \<forall>z\<in>?A. x \<sqsubseteq>\<^bsub>?r\<^esub> z \<and> y  \<sqsubseteq>\<^bsub>?r\<^esub> z \<longrightarrow> x \<squnion>\<^bsub>?f\<^esub> y \<sqsubseteq>\<^bsub>?r\<^esub>z"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>x\<in>(rev \<circ> sorted_list_of_set) ` Pow (set nodes). \<forall>y\<in>(rev \<circ> sorted_list_of_set) ` Pow (set nodes). \<forall>z\<in>(rev \<circ> sorted_list_of_set) ` Pow (set nodes). x \<sqsubseteq>\<^bsub>nodes_le\<^esub> z \<and> y \<sqsubseteq>\<^bsub>nodes_le\<^esub> z \<longrightarrow> x \<squnion>\<^bsub>inter_sorted_rev\<^esub> y \<sqsubseteq>\<^bsub>nodes_le\<^esub> z
[PROOF STEP]
proof (intro strip)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x y z. \<lbrakk>x \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes); y \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes); z \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes); x \<sqsubseteq>\<^bsub>nodes_le\<^esub> z \<and> y \<sqsubseteq>\<^bsub>nodes_le\<^esub> z\<rbrakk> \<Longrightarrow> x \<squnion>\<^bsub>inter_sorted_rev\<^esub> y \<sqsubseteq>\<^bsub>nodes_le\<^esub> z
[PROOF STEP]
fix xs ys zs
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x y z. \<lbrakk>x \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes); y \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes); z \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes); x \<sqsubseteq>\<^bsub>nodes_le\<^esub> z \<and> y \<sqsubseteq>\<^bsub>nodes_le\<^esub> z\<rbrakk> \<Longrightarrow> x \<squnion>\<^bsub>inter_sorted_rev\<^esub> y \<sqsubseteq>\<^bsub>nodes_le\<^esub> z
[PROOF STEP]
assume xin: "xs \<in> ?A" and yin: "ys \<in> ?A" and zin: "zs \<in> ?A" and "xs \<sqsubseteq>\<^bsub>?r\<^esub> zs \<and> ys \<sqsubseteq>\<^bsub>?r\<^esub> zs"
[PROOF STATE]
proof (state)
this:
xs \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes)
ys \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes)
zs \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes)
xs \<sqsubseteq>\<^bsub>nodes_le\<^esub> zs \<and> ys \<sqsubseteq>\<^bsub>nodes_le\<^esub> zs

goal (1 subgoal):
 1. \<And>x y z. \<lbrakk>x \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes); y \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes); z \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes); x \<sqsubseteq>\<^bsub>nodes_le\<^esub> z \<and> y \<sqsubseteq>\<^bsub>nodes_le\<^esub> z\<rbrakk> \<Longrightarrow> x \<squnion>\<^bsub>inter_sorted_rev\<^esub> y \<sqsubseteq>\<^bsub>nodes_le\<^esub> z
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
xs \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes)
ys \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes)
zs \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes)
xs \<sqsubseteq>\<^bsub>nodes_le\<^esub> zs \<and> ys \<sqsubseteq>\<^bsub>nodes_le\<^esub> zs
[PROOF STEP]
have xs_zs: "xs \<sqsubseteq>\<^bsub>?r\<^esub> zs" and ys_zs: "ys \<sqsubseteq>\<^bsub>?r\<^esub> zs" and sorted_xs: "sorted (rev xs)" and sorted_ys: "sorted (rev ys)"
[PROOF STATE]
proof (prove)
using this:
xs \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes)
ys \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes)
zs \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes)
xs \<sqsubseteq>\<^bsub>nodes_le\<^esub> zs \<and> ys \<sqsubseteq>\<^bsub>nodes_le\<^esub> zs

goal (1 subgoal):
 1. (xs \<sqsubseteq>\<^bsub>nodes_le\<^esub> zs &&& ys \<sqsubseteq>\<^bsub>nodes_le\<^esub> zs) &&& Sorted_Less.sorted (rev xs) &&& Sorted_Less.sorted (rev ys)
[PROOF STEP]
by (auto simp add: sorted_less_sorted_list_of_set)
[PROOF STATE]
proof (state)
this:
xs \<sqsubseteq>\<^bsub>nodes_le\<^esub> zs
ys \<sqsubseteq>\<^bsub>nodes_le\<^esub> zs
Sorted_Less.sorted (rev xs)
Sorted_Less.sorted (rev ys)

goal (1 subgoal):
 1. \<And>x y z. \<lbrakk>x \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes); y \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes); z \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes); x \<sqsubseteq>\<^bsub>nodes_le\<^esub> z \<and> y \<sqsubseteq>\<^bsub>nodes_le\<^esub> z\<rbrakk> \<Longrightarrow> x \<squnion>\<^bsub>inter_sorted_rev\<^esub> y \<sqsubseteq>\<^bsub>nodes_le\<^esub> z
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
xs \<sqsubseteq>\<^bsub>nodes_le\<^esub> zs
ys \<sqsubseteq>\<^bsub>nodes_le\<^esub> zs
Sorted_Less.sorted (rev xs)
Sorted_Less.sorted (rev ys)
[PROOF STEP]
have inter_xs_ys: "set (?f xs ys) = (set xs \<inter> set ys)" and sorted_f_xs_ys: "sorted (rev (?f xs ys))"
[PROOF STATE]
proof (prove)
using this:
xs \<sqsubseteq>\<^bsub>nodes_le\<^esub> zs
ys \<sqsubseteq>\<^bsub>nodes_le\<^esub> zs
Sorted_Less.sorted (rev xs)
Sorted_Less.sorted (rev ys)

goal (1 subgoal):
 1. set (inter_sorted_rev xs ys) = set xs \<inter> set ys &&& Sorted_Less.sorted (rev (inter_sorted_rev xs ys))
[PROOF STEP]
by (auto simp add: inter_sorted_correct)
[PROOF STATE]
proof (state)
this:
set (inter_sorted_rev xs ys) = set xs \<inter> set ys
Sorted_Less.sorted (rev (inter_sorted_rev xs ys))

goal (1 subgoal):
 1. \<And>x y z. \<lbrakk>x \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes); y \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes); z \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes); x \<sqsubseteq>\<^bsub>nodes_le\<^esub> z \<and> y \<sqsubseteq>\<^bsub>nodes_le\<^esub> z\<rbrakk> \<Longrightarrow> x \<squnion>\<^bsub>inter_sorted_rev\<^esub> y \<sqsubseteq>\<^bsub>nodes_le\<^esub> z
[PROOF STEP]
from xs_zs ys_zs sorted_xs
[PROOF STATE]
proof (chain)
picking this:
xs \<sqsubseteq>\<^bsub>nodes_le\<^esub> zs
ys \<sqsubseteq>\<^bsub>nodes_le\<^esub> zs
Sorted_Less.sorted (rev xs)
[PROOF STEP]
have sorted_zs: "sorted (rev zs)"
                                and "set zs \<subseteq> set xs"
                                and "set zs \<subseteq> set ys"
[PROOF STATE]
proof (prove)
using this:
xs \<sqsubseteq>\<^bsub>nodes_le\<^esub> zs
ys \<sqsubseteq>\<^bsub>nodes_le\<^esub> zs
Sorted_Less.sorted (rev xs)

goal (1 subgoal):
 1. Sorted_Less.sorted (rev zs) &&& set zs \<subseteq> set xs &&& set zs \<subseteq> set ys
[PROOF STEP]
by (auto simp add: lesub_def nodes_le_def)
[PROOF STATE]
proof (state)
this:
Sorted_Less.sorted (rev zs)
set zs \<subseteq> set xs
set zs \<subseteq> set ys

goal (1 subgoal):
 1. \<And>x y z. \<lbrakk>x \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes); y \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes); z \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes); x \<sqsubseteq>\<^bsub>nodes_le\<^esub> z \<and> y \<sqsubseteq>\<^bsub>nodes_le\<^esub> z\<rbrakk> \<Longrightarrow> x \<squnion>\<^bsub>inter_sorted_rev\<^esub> y \<sqsubseteq>\<^bsub>nodes_le\<^esub> z
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
Sorted_Less.sorted (rev zs)
set zs \<subseteq> set xs
set zs \<subseteq> set ys
[PROOF STEP]
have zs: "set zs \<subseteq> set xs \<inter> set ys"
[PROOF STATE]
proof (prove)
using this:
Sorted_Less.sorted (rev zs)
set zs \<subseteq> set xs
set zs \<subseteq> set ys

goal (1 subgoal):
 1. set zs \<subseteq> set xs \<inter> set ys
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
set zs \<subseteq> set xs \<inter> set ys

goal (1 subgoal):
 1. \<And>x y z. \<lbrakk>x \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes); y \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes); z \<in> (rev \<circ> sorted_list_of_set) ` Pow (set nodes); x \<sqsubseteq>\<^bsub>nodes_le\<^esub> z \<and> y \<sqsubseteq>\<^bsub>nodes_le\<^esub> z\<rbrakk> \<Longrightarrow> x \<squnion>\<^bsub>inter_sorted_rev\<^esub> y \<sqsubseteq>\<^bsub>nodes_le\<^esub> z
[PROOF STEP]
with inter_xs_ys sorted_zs sorted_f_xs_ys
[PROOF STATE]
proof (chain)
picking this:
set (inter_sorted_rev xs ys) = set xs \<inter> set ys
Sorted_Less.sorted (rev zs)
Sorted_Less.sorted (rev (inter_sorted_rev xs ys))
set zs \<subseteq> set xs \<inter> set ys
[PROOF STEP]
show "xs \<squnion>\<^bsub>?f\<^esub> ys \<sqsubseteq>\<^bsub>?r\<^esub> zs"
[PROOF STATE]
proof (prove)
using this:
set (inter_sorted_rev xs ys) = set xs \<inter> set ys
Sorted_Less.sorted (rev zs)
Sorted_Less.sorted (rev (inter_sorted_rev xs ys))
set zs \<subseteq> set xs \<inter> set ys

goal (1 subgoal):
 1. xs \<squnion>\<^bsub>inter_sorted_rev\<^esub> ys \<sqsubseteq>\<^bsub>nodes_le\<^esub> zs
[PROOF STEP]
by (auto simp add:plussub_def lesub_def  sorted_xs sorted_ys sorted_f_xs_ys sorted_zs nodes_le_def)
[PROOF STATE]
proof (state)
this:
xs \<squnion>\<^bsub>inter_sorted_rev\<^esub> ys \<sqsubseteq>\<^bsub>nodes_le\<^esub> zs

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<forall>x\<in>(rev \<circ> sorted_list_of_set) ` Pow (set nodes). \<forall>y\<in>(rev \<circ> sorted_list_of_set) ` Pow (set nodes). \<forall>z\<in>(rev \<circ> sorted_list_of_set) ` Pow (set nodes). x \<sqsubseteq>\<^bsub>nodes_le\<^esub> z \<and> y \<sqsubseteq>\<^bsub>nodes_le\<^esub> z \<longrightarrow> x \<squnion>\<^bsub>inter_sorted_rev\<^esub> y \<sqsubseteq>\<^bsub>nodes_le\<^esub> z

goal (1 subgoal):
 1. let A = (rev \<circ> sorted_list_of_set) ` Pow (set nodes); r = nodes_le; f = inter_sorted_rev in semilat (A, r, f)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
order nodes_le ((rev \<circ> sorted_list_of_set) ` Pow (set nodes))
closed ((rev \<circ> sorted_list_of_set) ` Pow (set nodes)) inter_sorted_rev
(\<forall>x\<in>(rev \<circ> sorted_list_of_set) ` Pow (set nodes). \<forall>y\<in>(rev \<circ> sorted_list_of_set) ` Pow (set nodes). x \<sqsubseteq>\<^bsub>nodes_le\<^esub> x \<squnion>\<^bsub>inter_sorted_rev\<^esub> y) \<and> (\<forall>x\<in>(rev \<circ> sorted_list_of_set) ` Pow (set nodes). \<forall>y\<in>(rev \<circ> sorted_list_of_set) ` Pow (set nodes). y \<sqsubseteq>\<^bsub>nodes_le\<^esub> x \<squnion>\<^bsub>inter_sorted_rev\<^esub> y)
\<forall>x\<in>(rev \<circ> sorted_list_of_set) ` Pow (set nodes). \<forall>y\<in>(rev \<circ> sorted_list_of_set) ` Pow (set nodes). \<forall>z\<in>(rev \<circ> sorted_list_of_set) ` Pow (set nodes). x \<sqsubseteq>\<^bsub>nodes_le\<^esub> z \<and> y \<sqsubseteq>\<^bsub>nodes_le\<^esub> z \<longrightarrow> x \<squnion>\<^bsub>inter_sorted_rev\<^esub> y \<sqsubseteq>\<^bsub>nodes_le\<^esub> z
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
order nodes_le ((rev \<circ> sorted_list_of_set) ` Pow (set nodes))
closed ((rev \<circ> sorted_list_of_set) ` Pow (set nodes)) inter_sorted_rev
(\<forall>x\<in>(rev \<circ> sorted_list_of_set) ` Pow (set nodes). \<forall>y\<in>(rev \<circ> sorted_list_of_set) ` Pow (set nodes). x \<sqsubseteq>\<^bsub>nodes_le\<^esub> x \<squnion>\<^bsub>inter_sorted_rev\<^esub> y) \<and> (\<forall>x\<in>(rev \<circ> sorted_list_of_set) ` Pow (set nodes). \<forall>y\<in>(rev \<circ> sorted_list_of_set) ` Pow (set nodes). y \<sqsubseteq>\<^bsub>nodes_le\<^esub> x \<squnion>\<^bsub>inter_sorted_rev\<^esub> y)
\<forall>x\<in>(rev \<circ> sorted_list_of_set) ` Pow (set nodes). \<forall>y\<in>(rev \<circ> sorted_list_of_set) ` Pow (set nodes). \<forall>z\<in>(rev \<circ> sorted_list_of_set) ` Pow (set nodes). x \<sqsubseteq>\<^bsub>nodes_le\<^esub> z \<and> y \<sqsubseteq>\<^bsub>nodes_le\<^esub> z \<longrightarrow> x \<squnion>\<^bsub>inter_sorted_rev\<^esub> y \<sqsubseteq>\<^bsub>nodes_le\<^esub> z

goal (1 subgoal):
 1. let A = (rev \<circ> sorted_list_of_set) ` Pow (set nodes); r = nodes_le; f = inter_sorted_rev in semilat (A, r, f)
[PROOF STEP]
by (unfold semilat_def) simp
[PROOF STATE]
proof (state)
this:
let A = (rev \<circ> sorted_list_of_set) ` Pow (set nodes); r = nodes_le; f = inter_sorted_rev in semilat (A, r, f)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma safe_max_empty: "safe_max X = None \<longleftrightarrow> X = {}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (safe_max X = None) = (X = {})
[PROOF STEP]
by (simp add: safe_max_def)


[STATEMENT]
lemma hbt_split_max:
  "\<lbrakk> hbt t; t \<noteq> Leaf \<rbrakk> \<Longrightarrow>
  hbt (fst (split_max t)) \<and>
  height t \<in> {height(fst (split_max t)), height(fst (split_max t)) + 1}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>hbt t; t \<noteq> \<langle>\<rangle>\<rbrakk> \<Longrightarrow> hbt (fst (split_max t)) \<and> height t \<in> {height (fst (split_max t)), height (fst (split_max t)) + 1}
[PROOF STEP]
by(induct t rule: split_max_induct)
  (auto simp: balL_def node_def max_absorb2 split!: prod.split if_split tree.split)


[STATEMENT]
lemma stieltjes_gamma_real_altdef:
  "(stieltjes_gamma n :: real) =
     lim (\<lambda>m. (\<Sum>k = 1..m. ln (real k) ^ n / real k) -
              ln (real m) ^ (n + 1) / real (n + 1))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. stieltjes_gamma n = lim (\<lambda>m. (\<Sum>k = 1..m. ln (real k) ^ n / real k) - ln (real m) ^ (n + 1) / real (n + 1))
[PROOF STEP]
by (rule sym, rule limI, rule stieltjes_gamma_real_limit_form)


[STATEMENT]
lemma unitarily_equiv_adjoint:
  assumes "unitarily_equiv A B U"
  shows "unitarily_equiv B A (Complex_Matrix.adjoint U)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. unitarily_equiv B A (Complex_Matrix.adjoint U)
[PROOF STEP]
unfolding unitarily_equiv_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Complex_Matrix.unitary (Complex_Matrix.adjoint U) \<and> similar_mat_wit B A (Complex_Matrix.adjoint U) (Complex_Matrix.adjoint (Complex_Matrix.adjoint U))
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. Complex_Matrix.unitary (Complex_Matrix.adjoint U)
 2. similar_mat_wit B A (Complex_Matrix.adjoint U) (Complex_Matrix.adjoint (Complex_Matrix.adjoint U))
[PROOF STEP]
show "Complex_Matrix.unitary (Complex_Matrix.adjoint U)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Complex_Matrix.unitary (Complex_Matrix.adjoint U)
[PROOF STEP]
using Complex_Matrix.unitary_def assms unitarily_equiv_def unitary_adjoint
[PROOF STATE]
proof (prove)
using this:
Complex_Matrix.unitary ?A = (?A \<in> carrier_mat (dim_row ?A) (dim_row ?A) \<and> inverts_mat ?A (Complex_Matrix.adjoint ?A))
unitarily_equiv A B U
unitarily_equiv ?A ?B ?U \<equiv> Complex_Matrix.unitary ?U \<and> similar_mat_wit ?A ?B ?U (Complex_Matrix.adjoint ?U)
\<lbrakk>?A \<in> carrier_mat ?n ?n; Complex_Matrix.unitary ?A\<rbrakk> \<Longrightarrow> Complex_Matrix.unitary (Complex_Matrix.adjoint ?A)

goal (1 subgoal):
 1. Complex_Matrix.unitary (Complex_Matrix.adjoint U)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
Complex_Matrix.unitary (Complex_Matrix.adjoint U)

goal (1 subgoal):
 1. similar_mat_wit B A (Complex_Matrix.adjoint U) (Complex_Matrix.adjoint (Complex_Matrix.adjoint U))
[PROOF STEP]
have "similar_mat_wit B A (Complex_Matrix.adjoint U) U"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. similar_mat_wit B A (Complex_Matrix.adjoint U) U
[PROOF STEP]
unfolding similar_mat_wit_def Let_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {B, A, Complex_Matrix.adjoint U, U} \<subseteq> carrier_mat (dim_row B) (dim_row B) \<and> Complex_Matrix.adjoint U * U = 1\<^sub>m (dim_row B) \<and> U * Complex_Matrix.adjoint U = 1\<^sub>m (dim_row B) \<and> B = Complex_Matrix.adjoint U * A * U
[PROOF STEP]
proof (intro conjI)
[PROOF STATE]
proof (state)
goal (4 subgoals):
 1. {B, A, Complex_Matrix.adjoint U, U} \<subseteq> carrier_mat (dim_row B) (dim_row B)
 2. Complex_Matrix.adjoint U * U = 1\<^sub>m (dim_row B)
 3. U * Complex_Matrix.adjoint U = 1\<^sub>m (dim_row B)
 4. B = Complex_Matrix.adjoint U * A * U
[PROOF STEP]
show car: "{B, A, Complex_Matrix.adjoint U, U} \<subseteq>
      carrier_mat (dim_row B) (dim_row B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {B, A, Complex_Matrix.adjoint U, U} \<subseteq> carrier_mat (dim_row B) (dim_row B)
[PROOF STEP]
by (metis assms insert_commute similar_mat_wit_def
          similar_mat_wit_dim_row unitarily_equivD(2))
[PROOF STATE]
proof (state)
this:
{B, A, Complex_Matrix.adjoint U, U} \<subseteq> carrier_mat (dim_row B) (dim_row B)

goal (3 subgoals):
 1. Complex_Matrix.adjoint U * U = 1\<^sub>m (dim_row B)
 2. U * Complex_Matrix.adjoint U = 1\<^sub>m (dim_row B)
 3. B = Complex_Matrix.adjoint U * A * U
[PROOF STEP]
show "Complex_Matrix.adjoint U * U = 1\<^sub>m (dim_row B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Complex_Matrix.adjoint U * U = 1\<^sub>m (dim_row B)
[PROOF STEP]
using car
[PROOF STATE]
proof (prove)
using this:
{B, A, Complex_Matrix.adjoint U, U} \<subseteq> carrier_mat (dim_row B) (dim_row B)

goal (1 subgoal):
 1. Complex_Matrix.adjoint U * U = 1\<^sub>m (dim_row B)
[PROOF STEP]
by (meson assms insert_subset unitarily_equivD(1) unitary_simps(1))
[PROOF STATE]
proof (state)
this:
Complex_Matrix.adjoint U * U = 1\<^sub>m (dim_row B)

goal (2 subgoals):
 1. U * Complex_Matrix.adjoint U = 1\<^sub>m (dim_row B)
 2. B = Complex_Matrix.adjoint U * A * U
[PROOF STEP]
show "U * Complex_Matrix.adjoint U = 1\<^sub>m (dim_row B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. U * Complex_Matrix.adjoint U = 1\<^sub>m (dim_row B)
[PROOF STEP]
by (meson assms similar_mat_wit_def similar_mat_wit_sym
          unitarily_equivD(2))
[PROOF STATE]
proof (state)
this:
U * Complex_Matrix.adjoint U = 1\<^sub>m (dim_row B)

goal (1 subgoal):
 1. B = Complex_Matrix.adjoint U * A * U
[PROOF STEP]
have "Complex_Matrix.adjoint U * A * U =
      Complex_Matrix.adjoint U * (U * B * Complex_Matrix.adjoint U) * U"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Complex_Matrix.adjoint U * A * U = Complex_Matrix.adjoint U * (U * B * Complex_Matrix.adjoint U) * U
[PROOF STEP]
using assms unitarily_equiv_eq
[PROOF STATE]
proof (prove)
using this:
unitarily_equiv A B U
unitarily_equiv ?A ?B ?U \<Longrightarrow> ?A = ?U * ?B * Complex_Matrix.adjoint ?U

goal (1 subgoal):
 1. Complex_Matrix.adjoint U * A * U = Complex_Matrix.adjoint U * (U * B * Complex_Matrix.adjoint U) * U
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
Complex_Matrix.adjoint U * A * U = Complex_Matrix.adjoint U * (U * B * Complex_Matrix.adjoint U) * U

goal (1 subgoal):
 1. B = Complex_Matrix.adjoint U * A * U
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
Complex_Matrix.adjoint U * A * U = Complex_Matrix.adjoint U * (U * B * Complex_Matrix.adjoint U) * U

goal (1 subgoal):
 1. B = Complex_Matrix.adjoint U * A * U
[PROOF STEP]
have "... = B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Complex_Matrix.adjoint U * (U * B * Complex_Matrix.adjoint U) * U = B
[PROOF STEP]
by (metis assms similar_mat_wit_def similar_mat_wit_sym unitarily_equivD(2))
[PROOF STATE]
proof (state)
this:
Complex_Matrix.adjoint U * (U * B * Complex_Matrix.adjoint U) * U = B

goal (1 subgoal):
 1. B = Complex_Matrix.adjoint U * A * U
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
Complex_Matrix.adjoint U * A * U = B
[PROOF STEP]
show "B = Complex_Matrix.adjoint U * A * U"
[PROOF STATE]
proof (prove)
using this:
Complex_Matrix.adjoint U * A * U = B

goal (1 subgoal):
 1. B = Complex_Matrix.adjoint U * A * U
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
B = Complex_Matrix.adjoint U * A * U

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
similar_mat_wit B A (Complex_Matrix.adjoint U) U

goal (1 subgoal):
 1. similar_mat_wit B A (Complex_Matrix.adjoint U) (Complex_Matrix.adjoint (Complex_Matrix.adjoint U))
[PROOF STEP]
thus "similar_mat_wit B A (Complex_Matrix.adjoint U)
    (Complex_Matrix.adjoint (Complex_Matrix.adjoint U))"
[PROOF STATE]
proof (prove)
using this:
similar_mat_wit B A (Complex_Matrix.adjoint U) U

goal (1 subgoal):
 1. similar_mat_wit B A (Complex_Matrix.adjoint U) (Complex_Matrix.adjoint (Complex_Matrix.adjoint U))
[PROOF STEP]
by (simp add: Complex_Matrix.adjoint_adjoint)
[PROOF STATE]
proof (state)
this:
similar_mat_wit B A (Complex_Matrix.adjoint U) (Complex_Matrix.adjoint (Complex_Matrix.adjoint U))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma mset_le_subtract_add_mset_left: "add_mset x B \<subseteq># (X::'a multiset) \<Longrightarrow> B \<subseteq># X-{#x#} \<and> {#x#}\<subseteq>#X"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. add_mset x B \<subseteq># X \<Longrightarrow> B \<subseteq># X - {#x#} \<and> {#x#} \<subseteq># X
[PROOF STEP]
by (auto dest: mset_le_subtract[of "add_mset x B" "X" "{#x#}"] mset_le_add_mset)


[STATEMENT]
lemma ElemClassEquiv: "\<lbrakk>equiv A r; C \<in> A // r\<rbrakk> \<Longrightarrow> \<forall>x \<in> C. \<forall>y \<in> C. (x, y) \<in> r"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>equiv A r; C \<in> A // r\<rbrakk> \<Longrightarrow> \<forall>x\<in>C. \<forall>y\<in>C. (x, y) \<in> r
[PROOF STEP]
unfolding equiv_def quotient_def sym_def trans_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>refl_on A r \<and> (\<forall>x y. (x, y) \<in> r \<longrightarrow> (y, x) \<in> r) \<and> (\<forall>x y z. (x, y) \<in> r \<longrightarrow> (y, z) \<in> r \<longrightarrow> (x, z) \<in> r); C \<in> (\<Union>x\<in>A. {r `` {x}})\<rbrakk> \<Longrightarrow> \<forall>x\<in>C. \<forall>y\<in>C. (x, y) \<in> r
[PROOF STEP]
by blast


[STATEMENT]
lemma "OAlist_tc_except_min (oalist_tc_of_list ([(1, 3), (0::nat, 4::nat), (0, 2), (1, 1)])) = oalist_tc_of_list [(1, 3)]"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. OAlist_tc_except_min (oalist_tc_of_list [(1, 3), (0, 4), (0, 2), (1, 1)]) = oalist_tc_of_list [(1, 3)]
[PROOF STEP]
by eval


[STATEMENT]
lemma acc_lengths_append:
  "acc_lengths acc (xs @ ys)
   = acc_lengths acc xs @ acc_lengths (acc + sum_list (map length xs)) ys"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. acc_lengths acc (xs @ ys) = acc_lengths acc xs @ acc_lengths (acc + sum_list (map length xs)) ys
[PROOF STEP]
by (induction acc xs rule: acc_lengths.induct) (auto simp: add.assoc)


[STATEMENT]
lemma bool_list_fin: "finite {bl::bool list. length bl = m}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite {bl. length bl = m}
[PROOF STEP]
using finite_lists_length_eq[of "UNIV::bool set"]
[PROOF STATE]
proof (prove)
using this:
finite UNIV \<Longrightarrow> finite {xs. set xs \<subseteq> UNIV \<and> length xs = ?n}

goal (1 subgoal):
 1. finite {bl. length bl = m}
[PROOF STEP]
by (simp add: b_val)


[STATEMENT]
lemma divide_left:
  assumes "eventually (\<lambda>x. f x \<noteq> 0) F"
  assumes "eventually (\<lambda>x. g x \<noteq> 0) F"
  assumes "g \<in> L F(f)"
  shows   "(\<lambda>x. h x / f x) \<in> L F (\<lambda>x. h x / g x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. h x / f x) \<in> L F (\<lambda>x. h x / g x)
[PROOF STEP]
by (subst (1 2) divide_inverse) (intro mult_left inverse assms)


[STATEMENT]
lemma insertion_uminus [simp]: "insertion f (-p :: 'a :: comm_ring_1 mpoly) = -insertion f p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. insertion f (- p) = - insertion f p
[PROOF STEP]
by (simp add: insertion_altdef Sum_any_uminus)


[STATEMENT]
lemma convex_inter_rel_interior_same_closure:
  assumes "\<forall>S\<in>I. convex (S :: 'n::euclidean_space set)"
    and "\<Inter>{rel_interior S |S. S \<in> I} \<noteq> {}"
  shows "closure (\<Inter>{rel_interior S |S. S \<in> I}) = closure (\<Inter>I)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. closure (\<Inter> {rel_interior S |S. S \<in> I}) = closure (\<Inter> I)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. closure (\<Inter> {rel_interior S |S. S \<in> I}) = closure (\<Inter> I)
[PROOF STEP]
have "\<Inter>{closure S |S. S \<in> I} \<le> closure (\<Inter>{rel_interior S |S. S \<in> I})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<Inter> {closure S |S. S \<in> I} \<subseteq> closure (\<Inter> {rel_interior S |S. S \<in> I})
[PROOF STEP]
using convex_closure_rel_interior_inter assms
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>\<forall>S\<in>?I. convex S; \<Inter> {rel_interior S |S. S \<in> ?I} \<noteq> {}\<rbrakk> \<Longrightarrow> \<Inter> {closure S |S. S \<in> ?I} \<subseteq> closure (\<Inter> {rel_interior S |S. S \<in> ?I})
\<forall>S\<in>I. convex S
\<Inter> {rel_interior S |S. S \<in> I} \<noteq> {}

goal (1 subgoal):
 1. \<Inter> {closure S |S. S \<in> I} \<subseteq> closure (\<Inter> {rel_interior S |S. S \<in> I})
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<Inter> {closure S |S. S \<in> I} \<subseteq> closure (\<Inter> {rel_interior S |S. S \<in> I})

goal (1 subgoal):
 1. closure (\<Inter> {rel_interior S |S. S \<in> I}) = closure (\<Inter> I)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
\<Inter> {closure S |S. S \<in> I} \<subseteq> closure (\<Inter> {rel_interior S |S. S \<in> I})

goal (1 subgoal):
 1. closure (\<Inter> {rel_interior S |S. S \<in> I}) = closure (\<Inter> I)
[PROOF STEP]
have "closure (\<Inter>{rel_interior S |S. S \<in> I}) \<le> closure (\<Inter>I)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. closure (\<Inter> {rel_interior S |S. S \<in> I}) \<subseteq> closure (\<Inter> I)
[PROOF STEP]
using rel_interior_inter_aux closure_mono[of "\<Inter>{rel_interior S |S. S \<in> I}" "\<Inter>I"]
[PROOF STATE]
proof (prove)
using this:
\<Inter> {rel_interior S |S. S \<in> ?I} \<subseteq> \<Inter> ?I
\<Inter> {rel_interior S |S. S \<in> I} \<subseteq> \<Inter> I \<Longrightarrow> closure (\<Inter> {rel_interior S |S. S \<in> I}) \<subseteq> closure (\<Inter> I)

goal (1 subgoal):
 1. closure (\<Inter> {rel_interior S |S. S \<in> I}) \<subseteq> closure (\<Inter> I)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
closure (\<Inter> {rel_interior S |S. S \<in> I}) \<subseteq> closure (\<Inter> I)

goal (1 subgoal):
 1. closure (\<Inter> {rel_interior S |S. S \<in> I}) = closure (\<Inter> I)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
\<Inter> {closure S |S. S \<in> I} \<subseteq> closure (\<Inter> {rel_interior S |S. S \<in> I})
closure (\<Inter> {rel_interior S |S. S \<in> I}) \<subseteq> closure (\<Inter> I)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<Inter> {closure S |S. S \<in> I} \<subseteq> closure (\<Inter> {rel_interior S |S. S \<in> I})
closure (\<Inter> {rel_interior S |S. S \<in> I}) \<subseteq> closure (\<Inter> I)

goal (1 subgoal):
 1. closure (\<Inter> {rel_interior S |S. S \<in> I}) = closure (\<Inter> I)
[PROOF STEP]
using closure_Int[of I]
[PROOF STATE]
proof (prove)
using this:
\<Inter> {closure S |S. S \<in> I} \<subseteq> closure (\<Inter> {rel_interior S |S. S \<in> I})
closure (\<Inter> {rel_interior S |S. S \<in> I}) \<subseteq> closure (\<Inter> I)
closure (\<Inter> I) \<subseteq> \<Inter> {closure S |S. S \<in> I}

goal (1 subgoal):
 1. closure (\<Inter> {rel_interior S |S. S \<in> I}) = closure (\<Inter> I)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
closure (\<Inter> {rel_interior S |S. S \<in> I}) = closure (\<Inter> I)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma convex_Times: "convex s \<Longrightarrow> convex t \<Longrightarrow> convex (s \<times> t)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>convex s; convex t\<rbrakk> \<Longrightarrow> convex (s \<times> t)
[PROOF STEP]
unfolding convex_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<forall>x\<in>s. \<forall>y\<in>s. \<forall>u\<ge>0. \<forall>v\<ge>0. u + v = 1 \<longrightarrow> u *\<^sub>R x + v *\<^sub>R y \<in> s; \<forall>x\<in>t. \<forall>y\<in>t. \<forall>u\<ge>0. \<forall>v\<ge>0. u + v = 1 \<longrightarrow> u *\<^sub>R x + v *\<^sub>R y \<in> t\<rbrakk> \<Longrightarrow> \<forall>x\<in>s \<times> t. \<forall>y\<in>s \<times> t. \<forall>u\<ge>0. \<forall>v\<ge>0. u + v = 1 \<longrightarrow> u *\<^sub>R x + v *\<^sub>R y \<in> s \<times> t
[PROOF STEP]
by auto


[STATEMENT]
lemma index_last_take :
  assumes "i < length xs"
  shows "xs ! i = last (take (Suc i) xs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. xs ! i = last (take (Suc i) xs)
[PROOF STEP]
by (simp add: assms take_Suc_conv_app_nth)


[STATEMENT]
lemma node_trans_sum_eq_1[simp]:
  "node_trans g x s' listening + (node_trans g x s' sending + node_trans g x s' sleeping) = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. node_trans g x s' listening + (node_trans g x s' sending + node_trans g x s' sleeping) = 1
[PROOF STEP]
by (simp add: node_trans_def split: state.split)


[STATEMENT]
lemma log_le_cancel_iff [simp]: "1 < a \<Longrightarrow> 0 < x \<Longrightarrow> 0 < y \<Longrightarrow> log a x \<le> log a y \<longleftrightarrow> x \<le> y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>1 < a; 0 < x; 0 < y\<rbrakk> \<Longrightarrow> (log a x \<le> log a y) = (x \<le> y)
[PROOF STEP]
by (simp add: linorder_not_less [symmetric])


[STATEMENT]
lemma VWF_iff_Ord_less [simp]: "\<lbrakk>Ord \<alpha>; Ord \<beta>\<rbrakk> \<Longrightarrow> (\<alpha>,\<beta>) \<in> VWF \<longleftrightarrow> \<alpha> < \<beta>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>Ord \<alpha>; Ord \<beta>\<rbrakk> \<Longrightarrow> ((\<alpha>, \<beta>) \<in> VWF) = (\<alpha> < \<beta>)
[PROOF STEP]
by (simp add: VWF_def less_V_def)


[STATEMENT]
lemma double_zero [simp]: "a + a = 0 \<longleftrightarrow> a = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (a + a = (0::'a)) = (a = (0::'a))
[PROOF STEP]
using add_nonneg_eq_0_iff order.eq_iff
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>(0::'a) \<le> ?x; (0::'a) \<le> ?y\<rbrakk> \<Longrightarrow> (?x + ?y = (0::'a)) = (?x = (0::'a) \<and> ?y = (0::'a))
(?a = ?b) = (?a \<le> ?b \<and> ?b \<le> ?a)

goal (1 subgoal):
 1. (a + a = (0::'a)) = (a = (0::'a))
[PROOF STEP]
by auto


[STATEMENT]
lemma ssorted_monoD: "ssorted s \<Longrightarrow> i \<le> j \<Longrightarrow> s !! i \<le> s !! j"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>ssorted s; i \<le> j\<rbrakk> \<Longrightarrow> s !! i \<le> s !! j
[PROOF STEP]
proof (induct "j - i" arbitrary: j)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>j. \<lbrakk>0 = j - i; ssorted s; i \<le> j\<rbrakk> \<Longrightarrow> s !! i \<le> s !! j
 2. \<And>x j. \<lbrakk>\<And>j. \<lbrakk>x = j - i; ssorted s; i \<le> j\<rbrakk> \<Longrightarrow> s !! i \<le> s !! j; Suc x = j - i; ssorted s; i \<le> j\<rbrakk> \<Longrightarrow> s !! i \<le> s !! j
[PROOF STEP]
case (Suc x)
[PROOF STATE]
proof (state)
this:
\<lbrakk>x = ?j - i; ssorted s; i \<le> ?j\<rbrakk> \<Longrightarrow> s !! i \<le> s !! ?j
Suc x = j - i
ssorted s
i \<le> j

goal (2 subgoals):
 1. \<And>j. \<lbrakk>0 = j - i; ssorted s; i \<le> j\<rbrakk> \<Longrightarrow> s !! i \<le> s !! j
 2. \<And>x j. \<lbrakk>\<And>j. \<lbrakk>x = j - i; ssorted s; i \<le> j\<rbrakk> \<Longrightarrow> s !! i \<le> s !! j; Suc x = j - i; ssorted s; i \<le> j\<rbrakk> \<Longrightarrow> s !! i \<le> s !! j
[PROOF STEP]
from Suc(1)[of "j - 1"] Suc(2-4) ssortedD[of s "j - 1"]
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>x = j - 1 - i; ssorted s; i \<le> j - 1\<rbrakk> \<Longrightarrow> s !! i \<le> s !! (j - 1)
Suc x = j - i
ssorted s
i \<le> j
ssorted s \<Longrightarrow> s !! (j - 1) \<le> stl s !! (j - 1)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>x = j - 1 - i; ssorted s; i \<le> j - 1\<rbrakk> \<Longrightarrow> s !! i \<le> s !! (j - 1)
Suc x = j - i
ssorted s
i \<le> j
ssorted s \<Longrightarrow> s !! (j - 1) \<le> stl s !! (j - 1)

goal (1 subgoal):
 1. s !! i \<le> s !! j
[PROOF STEP]
by (cases j) (auto simp: le_Suc_eq Suc_diff_le)
[PROOF STATE]
proof (state)
this:
s !! i \<le> s !! j

goal (1 subgoal):
 1. \<And>j. \<lbrakk>0 = j - i; ssorted s; i \<le> j\<rbrakk> \<Longrightarrow> s !! i \<le> s !! j
[PROOF STEP]
qed simp