[STATEMENT]
theorem treap_of_bst_of_list':
  assumes "ys = map (\<lambda>x. (x, p x)) xs" "inj_on p (set xs)" "xs' = sort_key p xs"
  shows "map_tree fst (treap_of (set ys)) = bst_of_list xs'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map_tree fst (treap_of (set ys)) = bst_of_list xs'
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
ys = map (\<lambda>x. (x, p x)) xs
inj_on p (set xs)
xs' = sort_key p xs

goal (1 subgoal):
 1. map_tree fst (treap_of (set ys)) = bst_of_list xs'
[PROOF STEP]
proof(induction xs' arbitrary: xs ys rule: bst_of_list.induct)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>xs ys. \<lbrakk>ys = map (\<lambda>x. (x, p x)) xs; inj_on p (set xs); [] = sort_key p xs\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list []
 2. \<And>x xs xsa ys. \<lbrakk>\<And>xsa ys. \<lbrakk>ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); filter (\<lambda>y. y < x) xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (filter (\<lambda>y. y < x) xs); \<And>xsa ys. \<lbrakk>ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); filter ((<) x) xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (filter ((<) x) xs); ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); x # xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (x # xs)
[PROOF STEP]
case 1
[PROOF STATE]
proof (state)
this:
ys = map (\<lambda>x. (x, p x)) xs
inj_on p (set xs)
[] = sort_key p xs

goal (2 subgoals):
 1. \<And>xs ys. \<lbrakk>ys = map (\<lambda>x. (x, p x)) xs; inj_on p (set xs); [] = sort_key p xs\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list []
 2. \<And>x xs xsa ys. \<lbrakk>\<And>xsa ys. \<lbrakk>ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); filter (\<lambda>y. y < x) xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (filter (\<lambda>y. y < x) xs); \<And>xsa ys. \<lbrakk>ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); filter ((<) x) xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (filter ((<) x) xs); ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); x # xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (x # xs)
[PROOF STEP]
from \<open>[] = sort_key p xs\<close>[symmetric] \<open>ys = map (\<lambda>x. (x, p x)) xs\<close>
[PROOF STATE]
proof (chain)
picking this:
sort_key p xs = []
ys = map (\<lambda>x. (x, p x)) xs
[PROOF STEP]
have "ys = []"
[PROOF STATE]
proof (prove)
using this:
sort_key p xs = []
ys = map (\<lambda>x. (x, p x)) xs

goal (1 subgoal):
 1. ys = []
[PROOF STEP]
by (cases xs) (auto)
[PROOF STATE]
proof (state)
this:
ys = []

goal (2 subgoals):
 1. \<And>xs ys. \<lbrakk>ys = map (\<lambda>x. (x, p x)) xs; inj_on p (set xs); [] = sort_key p xs\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list []
 2. \<And>x xs xsa ys. \<lbrakk>\<And>xsa ys. \<lbrakk>ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); filter (\<lambda>y. y < x) xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (filter (\<lambda>y. y < x) xs); \<And>xsa ys. \<lbrakk>ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); filter ((<) x) xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (filter ((<) x) xs); ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); x # xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (x # xs)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
ys = []
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
ys = []

goal (1 subgoal):
 1. map_tree fst (treap_of (set ys)) = bst_of_list []
[PROOF STEP]
by (simp add: treap_of.simps)
[PROOF STATE]
proof (state)
this:
map_tree fst (treap_of (set ys)) = bst_of_list []

goal (1 subgoal):
 1. \<And>x xs xsa ys. \<lbrakk>\<And>xsa ys. \<lbrakk>ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); filter (\<lambda>y. y < x) xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (filter (\<lambda>y. y < x) xs); \<And>xsa ys. \<lbrakk>ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); filter ((<) x) xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (filter ((<) x) xs); ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); x # xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (x # xs)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x xs xsa ys. \<lbrakk>\<And>xsa ys. \<lbrakk>ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); filter (\<lambda>y. y < x) xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (filter (\<lambda>y. y < x) xs); \<And>xsa ys. \<lbrakk>ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); filter ((<) x) xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (filter ((<) x) xs); ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); x # xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (x # xs)
[PROOF STEP]
case (2 z zs)
[PROOF STATE]
proof (state)
this:
\<lbrakk>?ys = map (\<lambda>x. (x, p x)) ?xs; inj_on p (set ?xs); filter (\<lambda>y. y < z) zs = sort_key p ?xs\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ?ys)) = bst_of_list (filter (\<lambda>y. y < z) zs)
\<lbrakk>?ys = map (\<lambda>x. (x, p x)) ?xs; inj_on p (set ?xs); filter ((<) z) zs = sort_key p ?xs\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ?ys)) = bst_of_list (filter ((<) z) zs)
ys = map (\<lambda>x. (x, p x)) xs
inj_on p (set xs)
z # zs = sort_key p xs

goal (1 subgoal):
 1. \<And>x xs xsa ys. \<lbrakk>\<And>xsa ys. \<lbrakk>ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); filter (\<lambda>y. y < x) xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (filter (\<lambda>y. y < x) xs); \<And>xsa ys. \<lbrakk>ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); filter ((<) x) xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (filter ((<) x) xs); ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); x # xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (x # xs)
[PROOF STEP]
note IH = 2(1,2)
[PROOF STATE]
proof (state)
this:
\<lbrakk>?ys = map (\<lambda>x. (x, p x)) ?xs; inj_on p (set ?xs); filter (\<lambda>y. y < z) zs = sort_key p ?xs\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ?ys)) = bst_of_list (filter (\<lambda>y. y < z) zs)
\<lbrakk>?ys = map (\<lambda>x. (x, p x)) ?xs; inj_on p (set ?xs); filter ((<) z) zs = sort_key p ?xs\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ?ys)) = bst_of_list (filter ((<) z) zs)

goal (1 subgoal):
 1. \<And>x xs xsa ys. \<lbrakk>\<And>xsa ys. \<lbrakk>ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); filter (\<lambda>y. y < x) xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (filter (\<lambda>y. y < x) xs); \<And>xsa ys. \<lbrakk>ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); filter ((<) x) xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (filter ((<) x) xs); ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); x # xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (x # xs)
[PROOF STEP]
note assms = 2(3,4,5)
[PROOF STATE]
proof (state)
this:
ys = map (\<lambda>x. (x, p x)) xs
inj_on p (set xs)
z # zs = sort_key p xs

goal (1 subgoal):
 1. \<And>x xs xsa ys. \<lbrakk>\<And>xsa ys. \<lbrakk>ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); filter (\<lambda>y. y < x) xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (filter (\<lambda>y. y < x) xs); \<And>xsa ys. \<lbrakk>ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); filter ((<) x) xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (filter ((<) x) xs); ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); x # xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (x # xs)
[PROOF STEP]
define m where "m = arg_min_on snd (set ys)"
[PROOF STATE]
proof (state)
this:
m = arg_min_on snd (set ys)

goal (1 subgoal):
 1. \<And>x xs xsa ys. \<lbrakk>\<And>xsa ys. \<lbrakk>ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); filter (\<lambda>y. y < x) xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (filter (\<lambda>y. y < x) xs); \<And>xsa ys. \<lbrakk>ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); filter ((<) x) xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (filter ((<) x) xs); ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); x # xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (x # xs)
[PROOF STEP]
define ls where "ls = map (\<lambda>x. (x, p x)) [y\<leftarrow>zs . y < z]"
[PROOF STATE]
proof (state)
this:
ls = map (\<lambda>x. (x, p x)) (filter (\<lambda>y. y < z) zs)

goal (1 subgoal):
 1. \<And>x xs xsa ys. \<lbrakk>\<And>xsa ys. \<lbrakk>ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); filter (\<lambda>y. y < x) xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (filter (\<lambda>y. y < x) xs); \<And>xsa ys. \<lbrakk>ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); filter ((<) x) xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (filter ((<) x) xs); ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); x # xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (x # xs)
[PROOF STEP]
define rs where "rs = map (\<lambda>x. (x, p x)) [y\<leftarrow>zs . y > z]"
[PROOF STATE]
proof (state)
this:
rs = map (\<lambda>x. (x, p x)) (filter ((<) z) zs)

goal (1 subgoal):
 1. \<And>x xs xsa ys. \<lbrakk>\<And>xsa ys. \<lbrakk>ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); filter (\<lambda>y. y < x) xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (filter (\<lambda>y. y < x) xs); \<And>xsa ys. \<lbrakk>ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); filter ((<) x) xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (filter ((<) x) xs); ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); x # xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (x # xs)
[PROOF STEP]
define L where "L = {p \<in> (set ys). fst p < fst m}"
[PROOF STATE]
proof (state)
this:
L = {p \<in> set ys. fst p < fst m}

goal (1 subgoal):
 1. \<And>x xs xsa ys. \<lbrakk>\<And>xsa ys. \<lbrakk>ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); filter (\<lambda>y. y < x) xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (filter (\<lambda>y. y < x) xs); \<And>xsa ys. \<lbrakk>ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); filter ((<) x) xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (filter ((<) x) xs); ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); x # xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (x # xs)
[PROOF STEP]
define R where "R = {p \<in> (set ys). fst p > fst m}"
[PROOF STATE]
proof (state)
this:
R = {p \<in> set ys. fst m < fst p}

goal (1 subgoal):
 1. \<And>x xs xsa ys. \<lbrakk>\<And>xsa ys. \<lbrakk>ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); filter (\<lambda>y. y < x) xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (filter (\<lambda>y. y < x) xs); \<And>xsa ys. \<lbrakk>ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); filter ((<) x) xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (filter ((<) x) xs); ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); x # xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (x # xs)
[PROOF STEP]
have h1: "set (z#zs) = set xs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set (z # zs) = set xs
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
ys = map (\<lambda>x. (x, p x)) xs
inj_on p (set xs)
z # zs = sort_key p xs

goal (1 subgoal):
 1. set (z # zs) = set xs
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
set (z # zs) = set xs

goal (1 subgoal):
 1. \<And>x xs xsa ys. \<lbrakk>\<And>xsa ys. \<lbrakk>ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); filter (\<lambda>y. y < x) xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (filter (\<lambda>y. y < x) xs); \<And>xsa ys. \<lbrakk>ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); filter ((<) x) xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (filter ((<) x) xs); ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); x # xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (x # xs)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
set (z # zs) = set xs
[PROOF STEP]
have h2: "inj_on p {x \<in> set zs. x < z}" "inj_on p (set (filter ((<) z) zs))"
    "inj_on p (set zs)"
[PROOF STATE]
proof (prove)
using this:
set (z # zs) = set xs

goal (1 subgoal):
 1. inj_on p {x \<in> set zs. x < z} &&& inj_on p (set (filter ((<) z) zs)) &&& inj_on p (set zs)
[PROOF STEP]
using \<open>inj_on p (set xs)\<close>
[PROOF STATE]
proof (prove)
using this:
set (z # zs) = set xs
inj_on p (set xs)

goal (1 subgoal):
 1. inj_on p {x \<in> set zs. x < z} &&& inj_on p (set (filter ((<) z) zs)) &&& inj_on p (set zs)
[PROOF STEP]
by (auto intro!: inj_on_subset[of _ "set xs"])
[PROOF STATE]
proof (state)
this:
inj_on p {x \<in> set zs. x < z}
inj_on p (set (filter ((<) z) zs))
inj_on p (set zs)

goal (1 subgoal):
 1. \<And>x xs xsa ys. \<lbrakk>\<And>xsa ys. \<lbrakk>ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); filter (\<lambda>y. y < x) xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (filter (\<lambda>y. y < x) xs); \<And>xsa ys. \<lbrakk>ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); filter ((<) x) xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (filter ((<) x) xs); ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); x # xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (x # xs)
[PROOF STEP]
have "z # zs = (let z = arg_min_on p (set xs) in z # sort_key p (remove1 z xs))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. z # zs = (let z = arg_min_on p (set xs) in z # sort_key p (remove1 z xs))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. z # zs = (let z = arg_min_on p (set xs) in z # sort_key p (remove1 z xs))
[PROOF STEP]
have "xs \<noteq> []"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. xs \<noteq> []
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
ys = map (\<lambda>x. (x, p x)) xs
inj_on p (set xs)
z # zs = sort_key p xs

goal (1 subgoal):
 1. xs \<noteq> []
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
xs \<noteq> []

goal (1 subgoal):
 1. z # zs = (let z = arg_min_on p (set xs) in z # sort_key p (remove1 z xs))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
xs \<noteq> []
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
xs \<noteq> []

goal (1 subgoal):
 1. z # zs = (let z = arg_min_on p (set xs) in z # sort_key p (remove1 z xs))
[PROOF STEP]
by (auto simp add: assms intro!: sort_key_arg_min_on)
[PROOF STATE]
proof (state)
this:
z # zs = (let z = arg_min_on p (set xs) in z # sort_key p (remove1 z xs))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
z # zs = (let z = arg_min_on p (set xs) in z # sort_key p (remove1 z xs))

goal (1 subgoal):
 1. \<And>x xs xsa ys. \<lbrakk>\<And>xsa ys. \<lbrakk>ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); filter (\<lambda>y. y < x) xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (filter (\<lambda>y. y < x) xs); \<And>xsa ys. \<lbrakk>ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); filter ((<) x) xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (filter ((<) x) xs); ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); x # xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (x # xs)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
z # zs = (let z = arg_min_on p (set xs) in z # sort_key p (remove1 z xs))
[PROOF STEP]
have h3: "z = arg_min_on p (set xs)" "zs = sort_key p (remove1 z xs)"
[PROOF STATE]
proof (prove)
using this:
z # zs = (let z = arg_min_on p (set xs) in z # sort_key p (remove1 z xs))

goal (1 subgoal):
 1. z = arg_min_on p (set xs) &&& zs = sort_key p (remove1 z xs)
[PROOF STEP]
unfolding Let_def
[PROOF STATE]
proof (prove)
using this:
z # zs = arg_min_on p (set xs) # sort_key p (remove1 (arg_min_on p (set xs)) xs)

goal (1 subgoal):
 1. z = arg_min_on p (set xs) &&& zs = sort_key p (remove1 z xs)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
z = arg_min_on p (set xs)
zs = sort_key p (remove1 z xs)

goal (1 subgoal):
 1. \<And>x xs xsa ys. \<lbrakk>\<And>xsa ys. \<lbrakk>ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); filter (\<lambda>y. y < x) xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (filter (\<lambda>y. y < x) xs); \<And>xsa ys. \<lbrakk>ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); filter ((<) x) xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (filter ((<) x) xs); ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); x # xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (x # xs)
[PROOF STEP]
have h4: "sort_key p zs = zs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sort_key p zs = zs
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. sort_key p zs = zs
[PROOF STEP]
have "linorder_class.sorted (map p (z#zs))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. linorder_class.sorted (map p (z # zs))
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
ys = map (\<lambda>x. (x, p x)) xs
inj_on p (set xs)
z # zs = sort_key p xs

goal (1 subgoal):
 1. linorder_class.sorted (map p (z # zs))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
linorder_class.sorted (map p (z # zs))

goal (1 subgoal):
 1. sort_key p zs = zs
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
linorder_class.sorted (map p (z # zs))
[PROOF STEP]
have "linorder_class.sorted (map p zs)"
[PROOF STATE]
proof (prove)
using this:
linorder_class.sorted (map p (z # zs))

goal (1 subgoal):
 1. linorder_class.sorted (map p zs)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
linorder_class.sorted (map p zs)

goal (1 subgoal):
 1. sort_key p zs = zs
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
linorder_class.sorted (map p zs)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
linorder_class.sorted (map p zs)

goal (1 subgoal):
 1. sort_key p zs = zs
[PROOF STEP]
using h1 h2 sort_key_inj_key_eq
[PROOF STATE]
proof (prove)
using this:
linorder_class.sorted (map p zs)
set (z # zs) = set xs
inj_on p {x \<in> set zs. x < z}
inj_on p (set (filter ((<) z) zs))
inj_on p (set zs)
\<lbrakk>mset ?xs = mset ?ys; inj_on ?f (set ?xs); linorder_class.sorted (map ?f ?ys)\<rbrakk> \<Longrightarrow> sort_key ?f ?xs = ?ys

goal (1 subgoal):
 1. sort_key p zs = zs
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
sort_key p zs = zs

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
sort_key p zs = zs

goal (1 subgoal):
 1. \<And>x xs xsa ys. \<lbrakk>\<And>xsa ys. \<lbrakk>ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); filter (\<lambda>y. y < x) xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (filter (\<lambda>y. y < x) xs); \<And>xsa ys. \<lbrakk>ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); filter ((<) x) xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (filter ((<) x) xs); ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); x # xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (x # xs)
[PROOF STEP]
note helpers = h1 h2 h3 h4
[PROOF STATE]
proof (state)
this:
set (z # zs) = set xs
inj_on p {x \<in> set zs. x < z}
inj_on p (set (filter ((<) z) zs))
inj_on p (set zs)
z = arg_min_on p (set xs)
zs = sort_key p (remove1 z xs)
sort_key p zs = zs

goal (1 subgoal):
 1. \<And>x xs xsa ys. \<lbrakk>\<And>xsa ys. \<lbrakk>ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); filter (\<lambda>y. y < x) xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (filter (\<lambda>y. y < x) xs); \<And>xsa ys. \<lbrakk>ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); filter ((<) x) xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (filter ((<) x) xs); ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); x # xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (x # xs)
[PROOF STEP]
have "fst m = z"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fst m = z
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. fst m = z
[PROOF STEP]
have "fst m = arg_min_on p (set xs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fst m = arg_min_on p (set xs)
[PROOF STEP]
unfolding m_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fst (arg_min_on snd (set ys)) = arg_min_on p (set xs)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
ys = map (\<lambda>x. (x, p x)) xs
inj_on p (set xs)
z # zs = sort_key p xs

goal (1 subgoal):
 1. fst (arg_min_on snd (set ys)) = arg_min_on p (set xs)
[PROOF STEP]
by (auto intro!: fst_snd_arg_min_on)
[PROOF STATE]
proof (state)
this:
fst m = arg_min_on p (set xs)

goal (1 subgoal):
 1. fst m = z
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
fst m = arg_min_on p (set xs)

goal (1 subgoal):
 1. fst m = z
[PROOF STEP]
have "\<dots> = z"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. arg_min_on p (set xs) = z
[PROOF STEP]
using helpers
[PROOF STATE]
proof (prove)
using this:
set (z # zs) = set xs
inj_on p {x \<in> set zs. x < z}
inj_on p (set (filter ((<) z) zs))
inj_on p (set zs)
z = arg_min_on p (set xs)
zs = sort_key p (remove1 z xs)
sort_key p zs = zs

goal (1 subgoal):
 1. arg_min_on p (set xs) = z
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
arg_min_on p (set xs) = z

goal (1 subgoal):
 1. fst m = z
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
fst m = z
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
fst m = z

goal (1 subgoal):
 1. fst m = z
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
fst m = z

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
fst m = z

goal (1 subgoal):
 1. \<And>x xs xsa ys. \<lbrakk>\<And>xsa ys. \<lbrakk>ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); filter (\<lambda>y. y < x) xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (filter (\<lambda>y. y < x) xs); \<And>xsa ys. \<lbrakk>ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); filter ((<) x) xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (filter ((<) x) xs); ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); x # xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (x # xs)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
fst m = z

goal (1 subgoal):
 1. \<And>x xs xsa ys. \<lbrakk>\<And>xsa ys. \<lbrakk>ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); filter (\<lambda>y. y < x) xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (filter (\<lambda>y. y < x) xs); \<And>xsa ys. \<lbrakk>ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); filter ((<) x) xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (filter ((<) x) xs); ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); x # xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (x # xs)
[PROOF STEP]
have "map_tree fst (treap_of L) = bst_of_list [y\<leftarrow>zs . y < z]"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map_tree fst (treap_of L) = bst_of_list (filter (\<lambda>y. y < z) zs)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. map_tree fst (treap_of L) = bst_of_list (filter (\<lambda>y. y < z) zs)
[PROOF STEP]
have "L = set ls"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. L = set ls
[PROOF STEP]
unfolding L_def ls_def \<open>fst m = z\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {p \<in> set ys. fst p < z} = set (map (\<lambda>x. (x, p x)) (filter (\<lambda>y. y < z) zs))
[PROOF STEP]
using helpers assms
[PROOF STATE]
proof (prove)
using this:
set (z # zs) = set xs
inj_on p {x \<in> set zs. x < z}
inj_on p (set (filter ((<) z) zs))
inj_on p (set zs)
z = arg_min_on p (set xs)
zs = sort_key p (remove1 z xs)
sort_key p zs = zs
ys = map (\<lambda>x. (x, p x)) xs
inj_on p (set xs)
z # zs = sort_key p xs

goal (1 subgoal):
 1. {p \<in> set ys. fst p < z} = set (map (\<lambda>x. (x, p x)) (filter (\<lambda>y. y < z) zs))
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
L = set ls

goal (1 subgoal):
 1. map_tree fst (treap_of L) = bst_of_list (filter (\<lambda>y. y < z) zs)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
L = set ls

goal (1 subgoal):
 1. map_tree fst (treap_of L) = bst_of_list (filter (\<lambda>y. y < z) zs)
[PROOF STEP]
have "map_tree fst (treap_of (set ls)) = bst_of_list [y\<leftarrow>zs . y < z]"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map_tree fst (treap_of (set ls)) = bst_of_list (filter (\<lambda>y. y < z) zs)
[PROOF STEP]
unfolding ls_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map_tree fst (treap_of (set (map (\<lambda>x. (x, p x)) (filter (\<lambda>y. y < z) zs)))) = bst_of_list (filter (\<lambda>y. y < z) zs)
[PROOF STEP]
using helpers
[PROOF STATE]
proof (prove)
using this:
set (z # zs) = set xs
inj_on p {x \<in> set zs. x < z}
inj_on p (set (filter ((<) z) zs))
inj_on p (set zs)
z = arg_min_on p (set xs)
zs = sort_key p (remove1 z xs)
sort_key p zs = zs

goal (1 subgoal):
 1. map_tree fst (treap_of (set (map (\<lambda>x. (x, p x)) (filter (\<lambda>y. y < z) zs)))) = bst_of_list (filter (\<lambda>y. y < z) zs)
[PROOF STEP]
by (intro IH(1)[of _ "[y\<leftarrow>zs . y < z]"]) (auto simp add: filter_sort[symmetric])
[PROOF STATE]
proof (state)
this:
map_tree fst (treap_of (set ls)) = bst_of_list (filter (\<lambda>y. y < z) zs)

goal (1 subgoal):
 1. map_tree fst (treap_of L) = bst_of_list (filter (\<lambda>y. y < z) zs)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
L = set ls
map_tree fst (treap_of (set ls)) = bst_of_list (filter (\<lambda>y. y < z) zs)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
L = set ls
map_tree fst (treap_of (set ls)) = bst_of_list (filter (\<lambda>y. y < z) zs)

goal (1 subgoal):
 1. map_tree fst (treap_of L) = bst_of_list (filter (\<lambda>y. y < z) zs)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
map_tree fst (treap_of L) = bst_of_list (filter (\<lambda>y. y < z) zs)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
map_tree fst (treap_of L) = bst_of_list (filter (\<lambda>y. y < z) zs)

goal (1 subgoal):
 1. \<And>x xs xsa ys. \<lbrakk>\<And>xsa ys. \<lbrakk>ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); filter (\<lambda>y. y < x) xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (filter (\<lambda>y. y < x) xs); \<And>xsa ys. \<lbrakk>ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); filter ((<) x) xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (filter ((<) x) xs); ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); x # xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (x # xs)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
map_tree fst (treap_of L) = bst_of_list (filter (\<lambda>y. y < z) zs)

goal (1 subgoal):
 1. \<And>x xs xsa ys. \<lbrakk>\<And>xsa ys. \<lbrakk>ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); filter (\<lambda>y. y < x) xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (filter (\<lambda>y. y < x) xs); \<And>xsa ys. \<lbrakk>ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); filter ((<) x) xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (filter ((<) x) xs); ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); x # xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (x # xs)
[PROOF STEP]
have "map_tree fst (treap_of R) = bst_of_list [y\<leftarrow>zs . z < y]"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map_tree fst (treap_of R) = bst_of_list (filter ((<) z) zs)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. map_tree fst (treap_of R) = bst_of_list (filter ((<) z) zs)
[PROOF STEP]
have 0: "R = set rs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. R = set rs
[PROOF STEP]
unfolding R_def rs_def \<open>fst m = z\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {p \<in> set ys. z < fst p} = set (map (\<lambda>x. (x, p x)) (filter ((<) z) zs))
[PROOF STEP]
using helpers assms
[PROOF STATE]
proof (prove)
using this:
set (z # zs) = set xs
inj_on p {x \<in> set zs. x < z}
inj_on p (set (filter ((<) z) zs))
inj_on p (set zs)
z = arg_min_on p (set xs)
zs = sort_key p (remove1 z xs)
sort_key p zs = zs
ys = map (\<lambda>x. (x, p x)) xs
inj_on p (set xs)
z # zs = sort_key p xs

goal (1 subgoal):
 1. {p \<in> set ys. z < fst p} = set (map (\<lambda>x. (x, p x)) (filter ((<) z) zs))
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
R = set rs

goal (1 subgoal):
 1. map_tree fst (treap_of R) = bst_of_list (filter ((<) z) zs)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
R = set rs

goal (1 subgoal):
 1. map_tree fst (treap_of R) = bst_of_list (filter ((<) z) zs)
[PROOF STEP]
have "map_tree fst (treap_of (set rs)) = bst_of_list [y\<leftarrow>zs . z < y]"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map_tree fst (treap_of (set rs)) = bst_of_list (filter ((<) z) zs)
[PROOF STEP]
unfolding rs_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map_tree fst (treap_of (set (map (\<lambda>x. (x, p x)) (filter ((<) z) zs)))) = bst_of_list (filter ((<) z) zs)
[PROOF STEP]
using helpers
[PROOF STATE]
proof (prove)
using this:
set (z # zs) = set xs
inj_on p {x \<in> set zs. x < z}
inj_on p (set (filter ((<) z) zs))
inj_on p (set zs)
z = arg_min_on p (set xs)
zs = sort_key p (remove1 z xs)
sort_key p zs = zs

goal (1 subgoal):
 1. map_tree fst (treap_of (set (map (\<lambda>x. (x, p x)) (filter ((<) z) zs)))) = bst_of_list (filter ((<) z) zs)
[PROOF STEP]
by (intro IH(2)[of _ "[y\<leftarrow>zs . z < y]"]) (auto simp add: filter_sort[symmetric])
[PROOF STATE]
proof (state)
this:
map_tree fst (treap_of (set rs)) = bst_of_list (filter ((<) z) zs)

goal (1 subgoal):
 1. map_tree fst (treap_of R) = bst_of_list (filter ((<) z) zs)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
R = set rs
map_tree fst (treap_of (set rs)) = bst_of_list (filter ((<) z) zs)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
R = set rs
map_tree fst (treap_of (set rs)) = bst_of_list (filter ((<) z) zs)

goal (1 subgoal):
 1. map_tree fst (treap_of R) = bst_of_list (filter ((<) z) zs)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
map_tree fst (treap_of R) = bst_of_list (filter ((<) z) zs)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
map_tree fst (treap_of R) = bst_of_list (filter ((<) z) zs)

goal (1 subgoal):
 1. \<And>x xs xsa ys. \<lbrakk>\<And>xsa ys. \<lbrakk>ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); filter (\<lambda>y. y < x) xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (filter (\<lambda>y. y < x) xs); \<And>xsa ys. \<lbrakk>ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); filter ((<) x) xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (filter ((<) x) xs); ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); x # xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (x # xs)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
map_tree fst (treap_of R) = bst_of_list (filter ((<) z) zs)

goal (1 subgoal):
 1. \<And>x xs xsa ys. \<lbrakk>\<And>xsa ys. \<lbrakk>ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); filter (\<lambda>y. y < x) xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (filter (\<lambda>y. y < x) xs); \<And>xsa ys. \<lbrakk>ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); filter ((<) x) xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (filter ((<) x) xs); ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); x # xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (x # xs)
[PROOF STEP]
have "treap_of (set ys) = \<langle>treap_of L, m, treap_of R\<rangle>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. treap_of (set ys) = \<langle>treap_of L, m, treap_of R\<rangle>
[PROOF STEP]
unfolding L_def m_def R_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. treap_of (set ys) = \<langle>treap_of {p \<in> set ys. fst p < fst (arg_min_on snd (set ys))}, arg_min_on snd (set ys), treap_of {p \<in> set ys. fst (arg_min_on snd (set ys)) < fst p}\<rangle>
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
ys = map (\<lambda>x. (x, p x)) xs
inj_on p (set xs)
z # zs = sort_key p xs

goal (1 subgoal):
 1. treap_of (set ys) = \<langle>treap_of {p \<in> set ys. fst p < fst (arg_min_on snd (set ys))}, arg_min_on snd (set ys), treap_of {p \<in> set ys. fst (arg_min_on snd (set ys)) < fst p}\<rangle>
[PROOF STEP]
by (auto simp add: treap_of.simps Let_def)
[PROOF STATE]
proof (state)
this:
treap_of (set ys) = \<langle>treap_of L, m, treap_of R\<rangle>

goal (1 subgoal):
 1. \<And>x xs xsa ys. \<lbrakk>\<And>xsa ys. \<lbrakk>ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); filter (\<lambda>y. y < x) xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (filter (\<lambda>y. y < x) xs); \<And>xsa ys. \<lbrakk>ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); filter ((<) x) xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (filter ((<) x) xs); ys = map (\<lambda>x. (x, p x)) xsa; inj_on p (set xsa); x # xs = sort_key p xsa\<rbrakk> \<Longrightarrow> map_tree fst (treap_of (set ys)) = bst_of_list (x # xs)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
fst m = z
map_tree fst (treap_of L) = bst_of_list (filter (\<lambda>y. y < z) zs)
map_tree fst (treap_of R) = bst_of_list (filter ((<) z) zs)
treap_of (set ys) = \<langle>treap_of L, m, treap_of R\<rangle>
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
fst m = z
map_tree fst (treap_of L) = bst_of_list (filter (\<lambda>y. y < z) zs)
map_tree fst (treap_of R) = bst_of_list (filter ((<) z) zs)
treap_of (set ys) = \<langle>treap_of L, m, treap_of R\<rangle>

goal (1 subgoal):
 1. map_tree fst (treap_of (set ys)) = bst_of_list (z # zs)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
map_tree fst (treap_of (set ys)) = bst_of_list (z # zs)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma take_bit_numeral_minus_bit1:
  \<open>take_bit (numeral l) (- numeral (Num.Bit1 k)) = take_bit (pred_numeral l) (- numeral (Num.inc k)) * 2 + (1 :: int)\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. take_bit (numeral l) (- numeral (num.Bit1 k)) = take_bit (pred_numeral l) (- numeral (Num.inc k)) * 2 + 1
[PROOF STEP]
by (simp add: numeral_eq_Suc numeral_Bit1_div_2 take_bit_Suc_minus_bit1)


[STATEMENT]
lemma congs_map_eq_iff:
 "inj_on f (set xs \<union> set ys) \<Longrightarrow> (map f xs \<cong> map f ys) = (xs \<cong> ys)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inj_on f (set xs \<union> set ys) \<Longrightarrow> map f xs \<cong> map f ys = xs \<cong> ys
[PROOF STEP]
apply(simp add:congs_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inj_on f (set xs \<union> set ys) \<Longrightarrow> (\<exists>n. map f ys = rotate n (map f xs)) = (\<exists>n. ys = rotate n xs)
[PROOF STEP]
apply(rule iffI)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>inj_on f (set xs \<union> set ys); \<exists>n. map f ys = rotate n (map f xs)\<rbrakk> \<Longrightarrow> \<exists>n. ys = rotate n xs
 2. \<lbrakk>inj_on f (set xs \<union> set ys); \<exists>n. ys = rotate n xs\<rbrakk> \<Longrightarrow> \<exists>n. map f ys = rotate n (map f xs)
[PROOF STEP]
apply(clarsimp simp: rotate_map)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>n. \<lbrakk>inj_on f (set xs \<union> set ys); map f ys = map f (rotate n xs)\<rbrakk> \<Longrightarrow> \<exists>n. ys = rotate n xs
 2. \<lbrakk>inj_on f (set xs \<union> set ys); \<exists>n. ys = rotate n xs\<rbrakk> \<Longrightarrow> \<exists>n. map f ys = rotate n (map f xs)
[PROOF STEP]
apply(drule map_inj_on)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. \<And>n. inj_on f (set xs \<union> set ys) \<Longrightarrow> inj_on f (set ys \<union> set (rotate n xs))
 2. \<And>n. \<lbrakk>inj_on f (set xs \<union> set ys); ys = rotate n xs\<rbrakk> \<Longrightarrow> \<exists>n. ys = rotate n xs
 3. \<lbrakk>inj_on f (set xs \<union> set ys); \<exists>n. ys = rotate n xs\<rbrakk> \<Longrightarrow> \<exists>n. map f ys = rotate n (map f xs)
[PROOF STEP]
apply(simp add:Un_commute)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>n. \<lbrakk>inj_on f (set xs \<union> set ys); ys = rotate n xs\<rbrakk> \<Longrightarrow> \<exists>n. ys = rotate n xs
 2. \<lbrakk>inj_on f (set xs \<union> set ys); \<exists>n. ys = rotate n xs\<rbrakk> \<Longrightarrow> \<exists>n. map f ys = rotate n (map f xs)
[PROOF STEP]
apply (fastforce)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>inj_on f (set xs \<union> set ys); \<exists>n. ys = rotate n xs\<rbrakk> \<Longrightarrow> \<exists>n. map f ys = rotate n (map f xs)
[PROOF STEP]
apply clarsimp
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>n. \<lbrakk>inj_on f (set xs); ys = rotate n xs\<rbrakk> \<Longrightarrow> \<exists>na. map f (rotate n xs) = rotate na (map f xs)
[PROOF STEP]
apply(fastforce simp: rotate_map)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma circlepath_minus: "circlepath z (-r) x = circlepath z r (x + 1/2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. circlepath z (- r) x = circlepath z r (x + 1 / 2)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. circlepath z (- r) x = circlepath z r (x + 1 / 2)
[PROOF STEP]
have "z + of_real r * exp (2 * pi * \<i> * (x + 1/2)) =
        z + of_real r * exp (2 * pi * \<i> * x + pi * \<i>)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. z + complex_of_real r * exp (complex_of_real (2 * pi) * \<i> * complex_of_real (x + 1 / 2)) = z + complex_of_real r * exp (complex_of_real (2 * pi) * \<i> * complex_of_real x + complex_of_real pi * \<i>)
[PROOF STEP]
by (simp add: divide_simps) (simp add: algebra_simps)
[PROOF STATE]
proof (state)
this:
z + complex_of_real r * exp (complex_of_real (2 * pi) * \<i> * complex_of_real (x + 1 / 2)) = z + complex_of_real r * exp (complex_of_real (2 * pi) * \<i> * complex_of_real x + complex_of_real pi * \<i>)

goal (1 subgoal):
 1. circlepath z (- r) x = circlepath z r (x + 1 / 2)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
z + complex_of_real r * exp (complex_of_real (2 * pi) * \<i> * complex_of_real (x + 1 / 2)) = z + complex_of_real r * exp (complex_of_real (2 * pi) * \<i> * complex_of_real x + complex_of_real pi * \<i>)

goal (1 subgoal):
 1. circlepath z (- r) x = circlepath z r (x + 1 / 2)
[PROOF STEP]
have "\<dots> = z - r * exp (2 * pi * \<i> * x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. z + complex_of_real r * exp (complex_of_real (2 * pi) * \<i> * complex_of_real x + complex_of_real pi * \<i>) = z - complex_of_real r * exp (complex_of_real (2 * pi) * \<i> * complex_of_real x)
[PROOF STEP]
by (simp add: exp_add)
[PROOF STATE]
proof (state)
this:
z + complex_of_real r * exp (complex_of_real (2 * pi) * \<i> * complex_of_real x + complex_of_real pi * \<i>) = z - complex_of_real r * exp (complex_of_real (2 * pi) * \<i> * complex_of_real x)

goal (1 subgoal):
 1. circlepath z (- r) x = circlepath z r (x + 1 / 2)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
z + complex_of_real r * exp (complex_of_real (2 * pi) * \<i> * complex_of_real (x + 1 / 2)) = z - complex_of_real r * exp (complex_of_real (2 * pi) * \<i> * complex_of_real x)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
z + complex_of_real r * exp (complex_of_real (2 * pi) * \<i> * complex_of_real (x + 1 / 2)) = z - complex_of_real r * exp (complex_of_real (2 * pi) * \<i> * complex_of_real x)

goal (1 subgoal):
 1. circlepath z (- r) x = circlepath z r (x + 1 / 2)
[PROOF STEP]
by (simp add: circlepath path_image_def sphere_def dist_norm)
[PROOF STATE]
proof (state)
this:
circlepath z (- r) x = circlepath z r (x + 1 / 2)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma div_le_mod_le_imp_le: "
  \<lbrakk> (a::nat) div m \<le> b div m; a mod m \<le> b mod m \<rbrakk> \<Longrightarrow> a \<le> b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>a div m \<le> b div m; a mod m \<le> b mod m\<rbrakk> \<Longrightarrow> a \<le> b
[PROOF STEP]
apply (rule subst[OF mult_div_mod_eq[of m a]])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>a div m \<le> b div m; a mod m \<le> b mod m\<rbrakk> \<Longrightarrow> m * (a div m) + a mod m \<le> b
[PROOF STEP]
apply (rule subst[OF mult_div_mod_eq[of m b]])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>a div m \<le> b div m; a mod m \<le> b mod m\<rbrakk> \<Longrightarrow> m * (a div m) + a mod m \<le> m * (b div m) + b mod m
[PROOF STEP]
apply (rule add_le_mono)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>a div m \<le> b div m; a mod m \<le> b mod m\<rbrakk> \<Longrightarrow> m * (a div m) \<le> m * (b div m)
 2. \<lbrakk>a div m \<le> b div m; a mod m \<le> b mod m\<rbrakk> \<Longrightarrow> a mod m \<le> b mod m
[PROOF STEP]
apply (rule mult_le_mono2)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>a div m \<le> b div m; a mod m \<le> b mod m\<rbrakk> \<Longrightarrow> a div m \<le> b div m
 2. \<lbrakk>a div m \<le> b div m; a mod m \<le> b mod m\<rbrakk> \<Longrightarrow> a mod m \<le> b mod m
[PROOF STEP]
apply assumption+
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma chain_map_diff:
   "chain_map p g (a-b) = chain_map p g a - chain_map p g b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. chain_map p g (a - b) = chain_map p g a - chain_map p g b
[PROOF STEP]
by (simp add: frag_extend_diff chain_map_def)


[STATEMENT]
lemma lebesgue_on_UNIV_eq: "lebesgue_on UNIV = lebesgue"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. lebesgue_on UNIV = lebesgue
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. lebesgue_on UNIV = lebesgue
[PROOF STEP]
have "measure_of UNIV (sets lebesgue) (emeasure lebesgue) = lebesgue"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. measure_of UNIV (sets lebesgue) (emeasure lebesgue) = lebesgue
[PROOF STEP]
by (metis measure_of_of_measure space_borel space_completion space_lborel)
[PROOF STATE]
proof (state)
this:
measure_of UNIV (sets lebesgue) (emeasure lebesgue) = lebesgue

goal (1 subgoal):
 1. lebesgue_on UNIV = lebesgue
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
measure_of UNIV (sets lebesgue) (emeasure lebesgue) = lebesgue
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
measure_of UNIV (sets lebesgue) (emeasure lebesgue) = lebesgue

goal (1 subgoal):
 1. lebesgue_on UNIV = lebesgue
[PROOF STEP]
by (auto simp: restrict_space_def)
[PROOF STATE]
proof (state)
this:
lebesgue_on UNIV = lebesgue

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma neg_numeral_le_floor [simp]: "- numeral v \<le> \<lfloor>x\<rfloor> \<longleftrightarrow> - numeral v \<le> x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (- numeral v \<le> \<lfloor>x\<rfloor>) = (- numeral v \<le> x)
[PROOF STEP]
by (simp add: le_floor_iff)


[STATEMENT]
lemma length_row_mat_to_cols_list [simp]:
  assumes "i < dim_row A"
  shows "length (row (mat_to_cols_list A) i) = dim_col A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (Matrix_Legacy.row (mat_to_cols_list A) i) = dim_col A
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
i < dim_row A

goal (1 subgoal):
 1. length (Matrix_Legacy.row (mat_to_cols_list A) i) = dim_col A
[PROOF STEP]
by (simp add: row_def)


[STATEMENT]
lemma column_leading_coefficient_component_1:
  fixes A::"'a::{field}^'m::{mod_type}^'n::{finite,one,plus,ord}"
  assumes rref_A: "reduced_row_echelon_form A"
  and v: "v \<in> {column (LEAST n. A $ i $ n \<noteq> 0) A |i. row i A \<noteq> 0}"
  and vx: "v $ x \<noteq> 0"
  shows "v $ x = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. v $ x = (1::'a)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. v $ x = (1::'a)
[PROOF STEP]
obtain b where b: "v = column (LEAST n. A $ b $ n \<noteq> 0) A" and row_b: "row b A \<noteq> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>b. \<lbrakk>v = column (LEAST n. A $ b $ n \<noteq> (0::'a)) A; row b A \<noteq> 0\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using v
[PROOF STATE]
proof (prove)
using this:
v \<in> {column (LEAST n. A $ i $ n \<noteq> (0::'a)) A |i. row i A \<noteq> 0}

goal (1 subgoal):
 1. (\<And>b. \<lbrakk>v = column (LEAST n. A $ b $ n \<noteq> (0::'a)) A; row b A \<noteq> 0\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
v = column (LEAST n. A $ b $ n \<noteq> (0::'a)) A
row b A \<noteq> 0

goal (1 subgoal):
 1. v $ x = (1::'a)
[PROOF STEP]
have vb_not_zero: "v $ b \<noteq> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. v $ b \<noteq> (0::'a)
[PROOF STEP]
unfolding b column_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<chi>i. A $ i $ (LEAST n. A $ b $ n \<noteq> (0::'a))) $ b \<noteq> (0::'a)
[PROOF STEP]
by (auto, metis is_zero_row_eq_row_zero row_b rref_A rref_condition2 zero_neq_one)
[PROOF STATE]
proof (state)
this:
v $ b \<noteq> (0::'a)

goal (1 subgoal):
 1. v $ x = (1::'a)
[PROOF STEP]
have b_eq_x: "b = x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. b = x
[PROOF STEP]
by (metis b column_def is_zero_row_eq_row_zero row_b rref_A rref_condition4 transpose_row_code transpose_row_def vx)
[PROOF STATE]
proof (state)
this:
b = x

goal (1 subgoal):
 1. v $ x = (1::'a)
[PROOF STEP]
show?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. v $ x = (1::'a)
[PROOF STEP]
using rref_condition2_explicit[OF rref_A, of b] row_b
[PROOF STATE]
proof (prove)
using this:
\<not> is_zero_row b A \<Longrightarrow> A $ b $ (LEAST k. A $ b $ k \<noteq> (0::'a)) = (1::'a)
row b A \<noteq> 0

goal (1 subgoal):
 1. v $ x = (1::'a)
[PROOF STEP]
unfolding b column_def is_zero_row_def'
[PROOF STATE]
proof (prove)
using this:
\<not> (\<forall>j. A $ b $ j = (0::'a)) \<Longrightarrow> A $ b $ (LEAST k. A $ b $ k \<noteq> (0::'a)) = (1::'a)
row b A \<noteq> 0

goal (1 subgoal):
 1. (\<chi>i. A $ i $ (LEAST n. A $ b $ n \<noteq> (0::'a))) $ x = (1::'a)
[PROOF STEP]
by (metis (mono_tags) \<open>\<not> is_zero_row b A \<Longrightarrow> A $ b $ (LEAST k. A $ b $ k \<noteq> 0) = 1\<close>
          b_eq_x is_zero_row_eq_row_zero vec_lambda_beta)
[PROOF STATE]
proof (state)
this:
v $ x = (1::'a)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma pmf_prob_compl: "pmf_prob p (-A) = 1 - pmf_prob p A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. pmf_prob p (- A) = 1 - pmf_prob p A
[PROOF STEP]
using measure_pmf.prob_compl[of A p]
[PROOF STATE]
proof (prove)
using this:
A \<in> measure_pmf.events p \<Longrightarrow> measure_pmf.prob p (space (measure_pmf p) - A) = 1 - measure_pmf.prob p A

goal (1 subgoal):
 1. pmf_prob p (- A) = 1 - pmf_prob p A
[PROOF STEP]
by (simp add: pmf_prob_def Compl_eq_Diff_UNIV)


[STATEMENT]
lemma proj2_Col_iff_not_invertible:
  "proj2_Col p q r
  \<longleftrightarrow> \<not> invertible (vector [proj2_rep p, proj2_rep q, proj2_rep r] :: real^3^3)"
  (is "_ \<longleftrightarrow> \<not> invertible (vector [?u, ?v, ?w])")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. proj2_Col p q r = (\<not> invertible (vector [proj2_rep p, proj2_rep q, proj2_rep r]))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. proj2_Col p q r = (\<not> invertible (vector [proj2_rep p, proj2_rep q, proj2_rep r]))
[PROOF STEP]
let ?M = "vector [?u,?v,?w] :: real^3^3"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. proj2_Col p q r = (\<not> invertible (vector [proj2_rep p, proj2_rep q, proj2_rep r]))
[PROOF STEP]
have "proj2_Col p q r \<longleftrightarrow> (\<exists> x. x \<noteq> 0 \<and> x v* ?M = 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. proj2_Col p q r = (\<exists>x. x \<noteq> 0 \<and> x v* vector [proj2_rep p, proj2_rep q, proj2_rep r] = 0)
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. proj2_Col p q r \<Longrightarrow> \<exists>x. x \<noteq> 0 \<and> x v* vector [proj2_rep p, proj2_rep q, proj2_rep r] = 0
 2. \<exists>x. x \<noteq> 0 \<and> x v* vector [proj2_rep p, proj2_rep q, proj2_rep r] = 0 \<Longrightarrow> proj2_Col p q r
[PROOF STEP]
assume "proj2_Col p q r"
[PROOF STATE]
proof (state)
this:
proj2_Col p q r

goal (2 subgoals):
 1. proj2_Col p q r \<Longrightarrow> \<exists>x. x \<noteq> 0 \<and> x v* vector [proj2_rep p, proj2_rep q, proj2_rep r] = 0
 2. \<exists>x. x \<noteq> 0 \<and> x v* vector [proj2_rep p, proj2_rep q, proj2_rep r] = 0 \<Longrightarrow> proj2_Col p q r
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
proj2_Col p q r
[PROOF STEP]
obtain i and j and k
      where "i \<noteq> 0 \<or> j \<noteq> 0 \<or> k \<noteq> 0" and "i *\<^sub>R ?u + j *\<^sub>R ?v + k *\<^sub>R ?w = 0"
[PROOF STATE]
proof (prove)
using this:
proj2_Col p q r

goal (1 subgoal):
 1. (\<And>i j k. \<lbrakk>i \<noteq> 0 \<or> j \<noteq> 0 \<or> k \<noteq> 0; i *\<^sub>R proj2_rep p + j *\<^sub>R proj2_rep q + k *\<^sub>R proj2_rep r = 0\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
unfolding proj2_Col_def
[PROOF STATE]
proof (prove)
using this:
\<exists>i j k. i *\<^sub>R proj2_rep p + j *\<^sub>R proj2_rep q + k *\<^sub>R proj2_rep r = 0 \<and> (i \<noteq> 0 \<or> j \<noteq> 0 \<or> k \<noteq> 0)

goal (1 subgoal):
 1. (\<And>i j k. \<lbrakk>i \<noteq> 0 \<or> j \<noteq> 0 \<or> k \<noteq> 0; i *\<^sub>R proj2_rep p + j *\<^sub>R proj2_rep q + k *\<^sub>R proj2_rep r = 0\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
i \<noteq> 0 \<or> j \<noteq> 0 \<or> k \<noteq> 0
i *\<^sub>R proj2_rep p + j *\<^sub>R proj2_rep q + k *\<^sub>R proj2_rep r = 0

goal (2 subgoals):
 1. proj2_Col p q r \<Longrightarrow> \<exists>x. x \<noteq> 0 \<and> x v* vector [proj2_rep p, proj2_rep q, proj2_rep r] = 0
 2. \<exists>x. x \<noteq> 0 \<and> x v* vector [proj2_rep p, proj2_rep q, proj2_rep r] = 0 \<Longrightarrow> proj2_Col p q r
[PROOF STEP]
let ?x = "vector [i,j,k] :: real^3"
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. proj2_Col p q r \<Longrightarrow> \<exists>x. x \<noteq> 0 \<and> x v* vector [proj2_rep p, proj2_rep q, proj2_rep r] = 0
 2. \<exists>x. x \<noteq> 0 \<and> x v* vector [proj2_rep p, proj2_rep q, proj2_rep r] = 0 \<Longrightarrow> proj2_Col p q r
[PROOF STEP]
from \<open>i \<noteq> 0 \<or> j \<noteq> 0 \<or> k \<noteq> 0\<close>
[PROOF STATE]
proof (chain)
picking this:
i \<noteq> 0 \<or> j \<noteq> 0 \<or> k \<noteq> 0
[PROOF STEP]
have "?x \<noteq> 0"
[PROOF STATE]
proof (prove)
using this:
i \<noteq> 0 \<or> j \<noteq> 0 \<or> k \<noteq> 0

goal (1 subgoal):
 1. vector [i, j, k] \<noteq> 0
[PROOF STEP]
unfolding vector_def
[PROOF STATE]
proof (prove)
using this:
i \<noteq> 0 \<or> j \<noteq> 0 \<or> k \<noteq> 0

goal (1 subgoal):
 1. vec_lambda (foldr (\<lambda>x f n. (f (n + 1))(n := x)) [i, j, k] (\<lambda>n x. 0) 1) \<noteq> 0
[PROOF STEP]
by (simp add: vec_eq_iff forall_3)
[PROOF STATE]
proof (state)
this:
vector [i, j, k] \<noteq> 0

goal (2 subgoals):
 1. proj2_Col p q r \<Longrightarrow> \<exists>x. x \<noteq> 0 \<and> x v* vector [proj2_rep p, proj2_rep q, proj2_rep r] = 0
 2. \<exists>x. x \<noteq> 0 \<and> x v* vector [proj2_rep p, proj2_rep q, proj2_rep r] = 0 \<Longrightarrow> proj2_Col p q r
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
vector [i, j, k] \<noteq> 0

goal (2 subgoals):
 1. proj2_Col p q r \<Longrightarrow> \<exists>x. x \<noteq> 0 \<and> x v* vector [proj2_rep p, proj2_rep q, proj2_rep r] = 0
 2. \<exists>x. x \<noteq> 0 \<and> x v* vector [proj2_rep p, proj2_rep q, proj2_rep r] = 0 \<Longrightarrow> proj2_Col p q r
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
vector [i, j, k] \<noteq> 0

goal (2 subgoals):
 1. proj2_Col p q r \<Longrightarrow> \<exists>x. x \<noteq> 0 \<and> x v* vector [proj2_rep p, proj2_rep q, proj2_rep r] = 0
 2. \<exists>x. x \<noteq> 0 \<and> x v* vector [proj2_rep p, proj2_rep q, proj2_rep r] = 0 \<Longrightarrow> proj2_Col p q r
[PROOF STEP]
from \<open>i *\<^sub>R ?u + j *\<^sub>R ?v + k *\<^sub>R ?w = 0\<close>
[PROOF STATE]
proof (chain)
picking this:
i *\<^sub>R proj2_rep p + j *\<^sub>R proj2_rep q + k *\<^sub>R proj2_rep r = 0
[PROOF STEP]
have "?x v* ?M = 0"
[PROOF STATE]
proof (prove)
using this:
i *\<^sub>R proj2_rep p + j *\<^sub>R proj2_rep q + k *\<^sub>R proj2_rep r = 0

goal (1 subgoal):
 1. vector [i, j, k] v* vector [proj2_rep p, proj2_rep q, proj2_rep r] = 0
[PROOF STEP]
unfolding vector_def and vector_matrix_mult_def
[PROOF STATE]
proof (prove)
using this:
i *\<^sub>R proj2_rep p + j *\<^sub>R proj2_rep q + k *\<^sub>R proj2_rep r = 0

goal (1 subgoal):
 1. (\<chi>ja. \<Sum>ia\<in>UNIV. vec_lambda (foldr (\<lambda>x f n. (f (n + 1))(n := x)) [proj2_rep p, proj2_rep q, proj2_rep r] (\<lambda>n x. 0) 1) $ ia $ ja * vec_lambda (foldr (\<lambda>x f n. (f (n + 1))(n := x)) [i, j, k] (\<lambda>n x. 0) 1) $ ia) = 0
[PROOF STEP]
by (simp add: sum_3 vec_eq_iff algebra_simps)
[PROOF STATE]
proof (state)
this:
vector [i, j, k] v* vector [proj2_rep p, proj2_rep q, proj2_rep r] = 0

goal (2 subgoals):
 1. proj2_Col p q r \<Longrightarrow> \<exists>x. x \<noteq> 0 \<and> x v* vector [proj2_rep p, proj2_rep q, proj2_rep r] = 0
 2. \<exists>x. x \<noteq> 0 \<and> x v* vector [proj2_rep p, proj2_rep q, proj2_rep r] = 0 \<Longrightarrow> proj2_Col p q r
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
vector [i, j, k] v* vector [proj2_rep p, proj2_rep q, proj2_rep r] = 0

goal (2 subgoals):
 1. proj2_Col p q r \<Longrightarrow> \<exists>x. x \<noteq> 0 \<and> x v* vector [proj2_rep p, proj2_rep q, proj2_rep r] = 0
 2. \<exists>x. x \<noteq> 0 \<and> x v* vector [proj2_rep p, proj2_rep q, proj2_rep r] = 0 \<Longrightarrow> proj2_Col p q r
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
vector [i, j, k] \<noteq> 0
vector [i, j, k] v* vector [proj2_rep p, proj2_rep q, proj2_rep r] = 0
[PROOF STEP]
show "\<exists> x. x \<noteq> 0 \<and> x v* ?M = 0"
[PROOF STATE]
proof (prove)
using this:
vector [i, j, k] \<noteq> 0
vector [i, j, k] v* vector [proj2_rep p, proj2_rep q, proj2_rep r] = 0

goal (1 subgoal):
 1. \<exists>x. x \<noteq> 0 \<and> x v* vector [proj2_rep p, proj2_rep q, proj2_rep r] = 0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<exists>x. x \<noteq> 0 \<and> x v* vector [proj2_rep p, proj2_rep q, proj2_rep r] = 0

goal (1 subgoal):
 1. \<exists>x. x \<noteq> 0 \<and> x v* vector [proj2_rep p, proj2_rep q, proj2_rep r] = 0 \<Longrightarrow> proj2_Col p q r
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>x. x \<noteq> 0 \<and> x v* vector [proj2_rep p, proj2_rep q, proj2_rep r] = 0 \<Longrightarrow> proj2_Col p q r
[PROOF STEP]
assume "\<exists> x. x \<noteq> 0 \<and> x v* ?M = 0"
[PROOF STATE]
proof (state)
this:
\<exists>x. x \<noteq> 0 \<and> x v* vector [proj2_rep p, proj2_rep q, proj2_rep r] = 0

goal (1 subgoal):
 1. \<exists>x. x \<noteq> 0 \<and> x v* vector [proj2_rep p, proj2_rep q, proj2_rep r] = 0 \<Longrightarrow> proj2_Col p q r
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<exists>x. x \<noteq> 0 \<and> x v* vector [proj2_rep p, proj2_rep q, proj2_rep r] = 0
[PROOF STEP]
obtain x where "x \<noteq> 0" and "x v* ?M = 0"
[PROOF STATE]
proof (prove)
using this:
\<exists>x. x \<noteq> 0 \<and> x v* vector [proj2_rep p, proj2_rep q, proj2_rep r] = 0

goal (1 subgoal):
 1. (\<And>x. \<lbrakk>x \<noteq> 0; x v* vector [proj2_rep p, proj2_rep q, proj2_rep r] = 0\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
x \<noteq> 0
x v* vector [proj2_rep p, proj2_rep q, proj2_rep r] = 0

goal (1 subgoal):
 1. \<exists>x. x \<noteq> 0 \<and> x v* vector [proj2_rep p, proj2_rep q, proj2_rep r] = 0 \<Longrightarrow> proj2_Col p q r
[PROOF STEP]
let ?i = "x$1"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>x. x \<noteq> 0 \<and> x v* vector [proj2_rep p, proj2_rep q, proj2_rep r] = 0 \<Longrightarrow> proj2_Col p q r
[PROOF STEP]
let ?j = "x$2"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>x. x \<noteq> 0 \<and> x v* vector [proj2_rep p, proj2_rep q, proj2_rep r] = 0 \<Longrightarrow> proj2_Col p q r
[PROOF STEP]
let ?k = "x$3"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>x. x \<noteq> 0 \<and> x v* vector [proj2_rep p, proj2_rep q, proj2_rep r] = 0 \<Longrightarrow> proj2_Col p q r
[PROOF STEP]
from \<open>x \<noteq> 0\<close>
[PROOF STATE]
proof (chain)
picking this:
x \<noteq> 0
[PROOF STEP]
have "?i \<noteq> 0 \<or> ?j \<noteq> 0 \<or> ?k \<noteq> 0"
[PROOF STATE]
proof (prove)
using this:
x \<noteq> 0

goal (1 subgoal):
 1. x $ 1 \<noteq> 0 \<or> x $ 2 \<noteq> 0 \<or> x $ 3 \<noteq> 0
[PROOF STEP]
by (simp add: vec_eq_iff forall_3)
[PROOF STATE]
proof (state)
this:
x $ 1 \<noteq> 0 \<or> x $ 2 \<noteq> 0 \<or> x $ 3 \<noteq> 0

goal (1 subgoal):
 1. \<exists>x. x \<noteq> 0 \<and> x v* vector [proj2_rep p, proj2_rep q, proj2_rep r] = 0 \<Longrightarrow> proj2_Col p q r
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
x $ 1 \<noteq> 0 \<or> x $ 2 \<noteq> 0 \<or> x $ 3 \<noteq> 0

goal (1 subgoal):
 1. \<exists>x. x \<noteq> 0 \<and> x v* vector [proj2_rep p, proj2_rep q, proj2_rep r] = 0 \<Longrightarrow> proj2_Col p q r
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
x $ 1 \<noteq> 0 \<or> x $ 2 \<noteq> 0 \<or> x $ 3 \<noteq> 0

goal (1 subgoal):
 1. \<exists>x. x \<noteq> 0 \<and> x v* vector [proj2_rep p, proj2_rep q, proj2_rep r] = 0 \<Longrightarrow> proj2_Col p q r
[PROOF STEP]
from \<open>x v* ?M = 0\<close>
[PROOF STATE]
proof (chain)
picking this:
x v* vector [proj2_rep p, proj2_rep q, proj2_rep r] = 0
[PROOF STEP]
have "?i *\<^sub>R ?u + ?j *\<^sub>R ?v + ?k *\<^sub>R ?w = 0"
[PROOF STATE]
proof (prove)
using this:
x v* vector [proj2_rep p, proj2_rep q, proj2_rep r] = 0

goal (1 subgoal):
 1. x $ 1 *\<^sub>R proj2_rep p + x $ 2 *\<^sub>R proj2_rep q + x $ 3 *\<^sub>R proj2_rep r = 0
[PROOF STEP]
unfolding vector_matrix_mult_def and sum_3 and vector_def
[PROOF STATE]
proof (prove)
using this:
(\<chi>j. vec_lambda (foldr (\<lambda>x f n. (f (n + 1))(n := x)) [proj2_rep p, proj2_rep q, proj2_rep r] (\<lambda>n x. 0) 1) $ 1 $ j * x $ 1 + vec_lambda (foldr (\<lambda>x f n. (f (n + 1))(n := x)) [proj2_rep p, proj2_rep q, proj2_rep r] (\<lambda>n x. 0) 1) $ 2 $ j * x $ 2 + vec_lambda (foldr (\<lambda>x f n. (f (n + 1))(n := x)) [proj2_rep p, proj2_rep q, proj2_rep r] (\<lambda>n x. 0) 1) $ 3 $ j * x $ 3) = 0

goal (1 subgoal):
 1. x $ 1 *\<^sub>R proj2_rep p + x $ 2 *\<^sub>R proj2_rep q + x $ 3 *\<^sub>R proj2_rep r = 0
[PROOF STEP]
by (simp add: vec_eq_iff algebra_simps)
[PROOF STATE]
proof (state)
this:
x $ 1 *\<^sub>R proj2_rep p + x $ 2 *\<^sub>R proj2_rep q + x $ 3 *\<^sub>R proj2_rep r = 0

goal (1 subgoal):
 1. \<exists>x. x \<noteq> 0 \<and> x v* vector [proj2_rep p, proj2_rep q, proj2_rep r] = 0 \<Longrightarrow> proj2_Col p q r
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
x $ 1 *\<^sub>R proj2_rep p + x $ 2 *\<^sub>R proj2_rep q + x $ 3 *\<^sub>R proj2_rep r = 0

goal (1 subgoal):
 1. \<exists>x. x \<noteq> 0 \<and> x v* vector [proj2_rep p, proj2_rep q, proj2_rep r] = 0 \<Longrightarrow> proj2_Col p q r
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
x $ 1 \<noteq> 0 \<or> x $ 2 \<noteq> 0 \<or> x $ 3 \<noteq> 0
x $ 1 *\<^sub>R proj2_rep p + x $ 2 *\<^sub>R proj2_rep q + x $ 3 *\<^sub>R proj2_rep r = 0
[PROOF STEP]
show "proj2_Col p q r"
[PROOF STATE]
proof (prove)
using this:
x $ 1 \<noteq> 0 \<or> x $ 2 \<noteq> 0 \<or> x $ 3 \<noteq> 0
x $ 1 *\<^sub>R proj2_rep p + x $ 2 *\<^sub>R proj2_rep q + x $ 3 *\<^sub>R proj2_rep r = 0

goal (1 subgoal):
 1. proj2_Col p q r
[PROOF STEP]
unfolding proj2_Col_def
[PROOF STATE]
proof (prove)
using this:
x $ 1 \<noteq> 0 \<or> x $ 2 \<noteq> 0 \<or> x $ 3 \<noteq> 0
x $ 1 *\<^sub>R proj2_rep p + x $ 2 *\<^sub>R proj2_rep q + x $ 3 *\<^sub>R proj2_rep r = 0

goal (1 subgoal):
 1. \<exists>i j k. i *\<^sub>R proj2_rep p + j *\<^sub>R proj2_rep q + k *\<^sub>R proj2_rep r = 0 \<and> (i \<noteq> 0 \<or> j \<noteq> 0 \<or> k \<noteq> 0)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
proj2_Col p q r

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
proj2_Col p q r = (\<exists>x. x \<noteq> 0 \<and> x v* vector [proj2_rep p, proj2_rep q, proj2_rep r] = 0)

goal (1 subgoal):
 1. proj2_Col p q r = (\<not> invertible (vector [proj2_rep p, proj2_rep q, proj2_rep r]))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
proj2_Col p q r = (\<exists>x. x \<noteq> 0 \<and> x v* vector [proj2_rep p, proj2_rep q, proj2_rep r] = 0)

goal (1 subgoal):
 1. proj2_Col p q r = (\<not> invertible (vector [proj2_rep p, proj2_rep q, proj2_rep r]))
[PROOF STEP]
from matrix_right_invertible_ker [of ?M]
[PROOF STATE]
proof (chain)
picking this:
(\<exists>M'. vector [proj2_rep p, proj2_rep q, proj2_rep r] ** M' = mat 1) = (\<forall>x. x v* vector [proj2_rep p, proj2_rep q, proj2_rep r] = 0 \<longrightarrow> x = 0)
[PROOF STEP]
have "\<dots> \<longleftrightarrow> \<not> (\<exists> M'. ?M ** M' = mat 1)"
[PROOF STATE]
proof (prove)
using this:
(\<exists>M'. vector [proj2_rep p, proj2_rep q, proj2_rep r] ** M' = mat 1) = (\<forall>x. x v* vector [proj2_rep p, proj2_rep q, proj2_rep r] = 0 \<longrightarrow> x = 0)

goal (1 subgoal):
 1. (\<exists>x. x \<noteq> 0 \<and> x v* vector [proj2_rep p, proj2_rep q, proj2_rep r] = 0) = (\<nexists>M'. vector [proj2_rep p, proj2_rep q, proj2_rep r] ** M' = mat 1)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<exists>x. x \<noteq> 0 \<and> x v* vector [proj2_rep p, proj2_rep q, proj2_rep r] = 0) = (\<nexists>M'. vector [proj2_rep p, proj2_rep q, proj2_rep r] ** M' = mat 1)

goal (1 subgoal):
 1. proj2_Col p q r = (\<not> invertible (vector [proj2_rep p, proj2_rep q, proj2_rep r]))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<exists>x. x \<noteq> 0 \<and> x v* vector [proj2_rep p, proj2_rep q, proj2_rep r] = 0) = (\<nexists>M'. vector [proj2_rep p, proj2_rep q, proj2_rep r] ** M' = mat 1)

goal (1 subgoal):
 1. proj2_Col p q r = (\<not> invertible (vector [proj2_rep p, proj2_rep q, proj2_rep r]))
[PROOF STEP]
from matrix_left_right_inverse
[PROOF STATE]
proof (chain)
picking this:
(?A ** ?A' = mat (1::?'a)) = (?A' ** ?A = mat (1::?'a))
[PROOF STEP]
have "\<dots> \<longleftrightarrow> \<not> invertible ?M"
[PROOF STATE]
proof (prove)
using this:
(?A ** ?A' = mat (1::?'a)) = (?A' ** ?A = mat (1::?'a))

goal (1 subgoal):
 1. (\<nexists>M'. vector [proj2_rep p, proj2_rep q, proj2_rep r] ** M' = mat 1) = (\<not> invertible (vector [proj2_rep p, proj2_rep q, proj2_rep r]))
[PROOF STEP]
unfolding invertible_def
[PROOF STATE]
proof (prove)
using this:
(?A ** ?A' = mat (1::?'a)) = (?A' ** ?A = mat (1::?'a))

goal (1 subgoal):
 1. (\<nexists>M'. vector [proj2_rep p, proj2_rep q, proj2_rep r] ** M' = mat 1) = (\<nexists>A'. vector [proj2_rep p, proj2_rep q, proj2_rep r] ** A' = mat 1 \<and> A' ** vector [proj2_rep p, proj2_rep q, proj2_rep r] = mat 1)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<nexists>M'. vector [proj2_rep p, proj2_rep q, proj2_rep r] ** M' = mat 1) = (\<not> invertible (vector [proj2_rep p, proj2_rep q, proj2_rep r]))

goal (1 subgoal):
 1. proj2_Col p q r = (\<not> invertible (vector [proj2_rep p, proj2_rep q, proj2_rep r]))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
proj2_Col p q r = (\<not> invertible (vector [proj2_rep p, proj2_rep q, proj2_rep r]))
[PROOF STEP]
show "proj2_Col p q r \<longleftrightarrow> \<not> invertible ?M"
[PROOF STATE]
proof (prove)
using this:
proj2_Col p q r = (\<not> invertible (vector [proj2_rep p, proj2_rep q, proj2_rep r]))

goal (1 subgoal):
 1. proj2_Col p q r = (\<not> invertible (vector [proj2_rep p, proj2_rep q, proj2_rep r]))
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
proj2_Col p q r = (\<not> invertible (vector [proj2_rep p, proj2_rep q, proj2_rep r]))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma Bounded_mat_of_int: assumes "A \<in> Bounded_mat bnd"
  shows "(map_mat of_int A :: 'a mat) \<in> \<int>\<^sub>m \<inter> Bounded_mat (of_int bnd)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. of_int_hom.mat_hom A \<in> \<int>\<^sub>m \<inter> Bounded_mat (of_int bnd)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
A \<in> Bounded_mat bnd

goal (1 subgoal):
 1. of_int_hom.mat_hom A \<in> \<int>\<^sub>m \<inter> Bounded_mat (of_int bnd)
[PROOF STEP]
apply (simp add: Ints_mat_elements_mat Bounded_mat_elements_mat Ints_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>x\<in>elements_mat A. \<bar>x\<bar> \<le> bnd \<Longrightarrow> of_int ` elements_mat A \<subseteq> range of_int \<and> (\<forall>x\<in>elements_mat A. \<bar>of_int x\<bar> \<le> of_int bnd)
[PROOF STEP]
apply (intro conjI, force)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>x\<in>elements_mat A. \<bar>x\<bar> \<le> bnd \<Longrightarrow> \<forall>x\<in>elements_mat A. \<bar>of_int x\<bar> \<le> of_int bnd
[PROOF STEP]
apply (clarsimp)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. \<lbrakk>\<forall>x\<in>elements_mat A. \<bar>x\<bar> \<le> bnd; x \<in> elements_mat A\<rbrakk> \<Longrightarrow> \<bar>of_int x\<bar> \<le> of_int bnd
[PROOF STEP]
subgoal for x
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<forall>x\<in>elements_mat A. \<bar>x\<bar> \<le> bnd; x \<in> elements_mat A\<rbrakk> \<Longrightarrow> \<bar>of_int x\<bar> \<le> of_int bnd
[PROOF STEP]
apply (elim ballE[of _ _ x], auto)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>x \<in> elements_mat A; \<bar>x\<bar> \<le> bnd\<rbrakk> \<Longrightarrow> \<bar>of_int x\<bar> \<le> of_int bnd
[PROOF STEP]
by (metis of_int_abs of_int_le_iff)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma (in weak_lower_semilattice) finite_inf_closed [simp]:
  "[| finite A; A \<subseteq> carrier L; A \<noteq> {} |] ==> \<Sqinter>A \<in> carrier L"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>finite A; A \<subseteq> carrier L; A \<noteq> {}\<rbrakk> \<Longrightarrow> \<Sqinter>A \<in> carrier L
[PROOF STEP]
proof (induct set: finite)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<lbrakk>{} \<subseteq> carrier L; {} \<noteq> {}\<rbrakk> \<Longrightarrow> \<Sqinter>{} \<in> carrier L
 2. \<And>x F. \<lbrakk>finite F; x \<notin> F; \<lbrakk>F \<subseteq> carrier L; F \<noteq> {}\<rbrakk> \<Longrightarrow> \<Sqinter>F \<in> carrier L; insert x F \<subseteq> carrier L; insert x F \<noteq> {}\<rbrakk> \<Longrightarrow> \<Sqinter>insert x F \<in> carrier L
[PROOF STEP]
case empty
[PROOF STATE]
proof (state)
this:
{} \<subseteq> carrier L
{} \<noteq> {}

goal (2 subgoals):
 1. \<lbrakk>{} \<subseteq> carrier L; {} \<noteq> {}\<rbrakk> \<Longrightarrow> \<Sqinter>{} \<in> carrier L
 2. \<And>x F. \<lbrakk>finite F; x \<notin> F; \<lbrakk>F \<subseteq> carrier L; F \<noteq> {}\<rbrakk> \<Longrightarrow> \<Sqinter>F \<in> carrier L; insert x F \<subseteq> carrier L; insert x F \<noteq> {}\<rbrakk> \<Longrightarrow> \<Sqinter>insert x F \<in> carrier L
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
{} \<subseteq> carrier L
{} \<noteq> {}
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
{} \<subseteq> carrier L
{} \<noteq> {}

goal (1 subgoal):
 1. \<Sqinter>{} \<in> carrier L
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<Sqinter>{} \<in> carrier L

goal (1 subgoal):
 1. \<And>x F. \<lbrakk>finite F; x \<notin> F; \<lbrakk>F \<subseteq> carrier L; F \<noteq> {}\<rbrakk> \<Longrightarrow> \<Sqinter>F \<in> carrier L; insert x F \<subseteq> carrier L; insert x F \<noteq> {}\<rbrakk> \<Longrightarrow> \<Sqinter>insert x F \<in> carrier L
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x F. \<lbrakk>finite F; x \<notin> F; \<lbrakk>F \<subseteq> carrier L; F \<noteq> {}\<rbrakk> \<Longrightarrow> \<Sqinter>F \<in> carrier L; insert x F \<subseteq> carrier L; insert x F \<noteq> {}\<rbrakk> \<Longrightarrow> \<Sqinter>insert x F \<in> carrier L
[PROOF STEP]
case insert
[PROOF STATE]
proof (state)
this:
finite F_
x_ \<notin> F_
\<lbrakk>F_ \<subseteq> carrier L; F_ \<noteq> {}\<rbrakk> \<Longrightarrow> \<Sqinter>F_ \<in> carrier L
insert x_ F_ \<subseteq> carrier L
insert x_ F_ \<noteq> {}

goal (1 subgoal):
 1. \<And>x F. \<lbrakk>finite F; x \<notin> F; \<lbrakk>F \<subseteq> carrier L; F \<noteq> {}\<rbrakk> \<Longrightarrow> \<Sqinter>F \<in> carrier L; insert x F \<subseteq> carrier L; insert x F \<noteq> {}\<rbrakk> \<Longrightarrow> \<Sqinter>insert x F \<in> carrier L
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
finite F_
x_ \<notin> F_
\<lbrakk>F_ \<subseteq> carrier L; F_ \<noteq> {}\<rbrakk> \<Longrightarrow> \<Sqinter>F_ \<in> carrier L
insert x_ F_ \<subseteq> carrier L
insert x_ F_ \<noteq> {}
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
finite F_
x_ \<notin> F_
\<lbrakk>F_ \<subseteq> carrier L; F_ \<noteq> {}\<rbrakk> \<Longrightarrow> \<Sqinter>F_ \<in> carrier L
insert x_ F_ \<subseteq> carrier L
insert x_ F_ \<noteq> {}

goal (1 subgoal):
 1. \<Sqinter>insert x_ F_ \<in> carrier L
[PROOF STEP]
by (rule_tac finite_inf_insertI) (simp_all)
[PROOF STATE]
proof (state)
this:
\<Sqinter>insert x_ F_ \<in> carrier L

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma porder_order: "porder ((\<le>) :: 'a::order \<Rightarrow> 'a \<Rightarrow> bool)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. porder (\<le>)
[PROOF STEP]
apply (rule porder.intro)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. \<And>x. x \<le> x
 2. \<And>x y z. \<lbrakk>x \<le> y; y \<le> z\<rbrakk> \<Longrightarrow> x \<le> z
 3. \<And>x y. \<lbrakk>x \<le> y; y \<le> x\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
apply (rule order_refl)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>x y z. \<lbrakk>x \<le> y; y \<le> z\<rbrakk> \<Longrightarrow> x \<le> z
 2. \<And>x y. \<lbrakk>x \<le> y; y \<le> x\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
apply (rule order_trans, assumption+)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x \<le> y; y \<le> x\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
apply (rule order_antisym, assumption+)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma has_derivative_unique:
  assumes "(f has_derivative F) (at x)"
    and "(f has_derivative F') (at x)"
  shows "F = F'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. F = F'
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. F = F'
[PROOF STEP]
have "((\<lambda>x. 0) has_derivative (\<lambda>h. F h - F' h)) (at x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>x. 0::'b) has_derivative (\<lambda>h. F h - F' h)) (at x)
[PROOF STEP]
using has_derivative_diff [OF assms]
[PROOF STATE]
proof (prove)
using this:
((\<lambda>x. f x - f x) has_derivative (\<lambda>x. F x - F' x)) (at x)

goal (1 subgoal):
 1. ((\<lambda>x. 0::'b) has_derivative (\<lambda>h. F h - F' h)) (at x)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
((\<lambda>x. 0::'b) has_derivative (\<lambda>h. F h - F' h)) (at x)

goal (1 subgoal):
 1. F = F'
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
((\<lambda>x. 0::'b) has_derivative (\<lambda>h. F h - F' h)) (at x)
[PROOF STEP]
have "(\<lambda>h. F h - F' h) = (\<lambda>h. 0)"
[PROOF STATE]
proof (prove)
using this:
((\<lambda>x. 0::'b) has_derivative (\<lambda>h. F h - F' h)) (at x)

goal (1 subgoal):
 1. (\<lambda>h. F h - F' h) = (\<lambda>h. 0::'b)
[PROOF STEP]
by (rule has_derivative_zero_unique)
[PROOF STATE]
proof (state)
this:
(\<lambda>h. F h - F' h) = (\<lambda>h. 0::'b)

goal (1 subgoal):
 1. F = F'
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(\<lambda>h. F h - F' h) = (\<lambda>h. 0::'b)
[PROOF STEP]
show "F = F'"
[PROOF STATE]
proof (prove)
using this:
(\<lambda>h. F h - F' h) = (\<lambda>h. 0::'b)

goal (1 subgoal):
 1. F = F'
[PROOF STEP]
unfolding fun_eq_iff right_minus_eq
[PROOF STATE]
proof (prove)
using this:
\<forall>x. F x = F' x

goal (1 subgoal):
 1. \<forall>x. F x = F' x
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
F = F'

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma tendsto_integral_at_top:
  fixes f :: "real \<Rightarrow> 'a::{banach, second_countable_topology}"
  assumes [measurable_cong]: "sets M = sets borel" and f[measurable]: "integrable M f"
  shows "((\<lambda>y. \<integral> x. indicator {.. y} x *\<^sub>R f x \<partial>M) \<longlongrightarrow> \<integral> x. f x \<partial>M) at_top"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>y. LINT x|M. indicat_real {..y} x *\<^sub>R f x) \<longlongrightarrow> integral\<^sup>L M f) at_top
[PROOF STEP]
proof (rule tendsto_at_topI_sequentially)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>X. filterlim X at_top sequentially \<Longrightarrow> (\<lambda>n. LINT x|M. indicat_real {..X n} x *\<^sub>R f x) \<longlonglongrightarrow> integral\<^sup>L M f
[PROOF STEP]
fix X :: "nat \<Rightarrow> real"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>X. filterlim X at_top sequentially \<Longrightarrow> (\<lambda>n. LINT x|M. indicat_real {..X n} x *\<^sub>R f x) \<longlonglongrightarrow> integral\<^sup>L M f
[PROOF STEP]
assume "filterlim X at_top sequentially"
[PROOF STATE]
proof (state)
this:
filterlim X at_top sequentially

goal (1 subgoal):
 1. \<And>X. filterlim X at_top sequentially \<Longrightarrow> (\<lambda>n. LINT x|M. indicat_real {..X n} x *\<^sub>R f x) \<longlonglongrightarrow> integral\<^sup>L M f
[PROOF STEP]
show "(\<lambda>n. \<integral>x. indicator {..X n} x *\<^sub>R f x \<partial>M) \<longlonglongrightarrow> integral\<^sup>L M f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>n. LINT x|M. indicat_real {..X n} x *\<^sub>R f x) \<longlonglongrightarrow> integral\<^sup>L M f
[PROOF STEP]
proof (rule integral_dominated_convergence)
[PROOF STATE]
proof (state)
goal (5 subgoals):
 1. f \<in> borel_measurable M
 2. \<And>n. (\<lambda>x. indicat_real {..X n} x *\<^sub>R f x) \<in> borel_measurable M
 3. integrable M ?w
 4. AE x in M. (\<lambda>n. indicat_real {..X n} x *\<^sub>R f x) \<longlonglongrightarrow> f x
 5. \<And>n. AE x in M. norm (indicat_real {..X n} x *\<^sub>R f x) \<le> ?w x
[PROOF STEP]
show "integrable M (\<lambda>x. norm (f x))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. integrable M (\<lambda>x. norm (f x))
[PROOF STEP]
by (rule integrable_norm) fact
[PROOF STATE]
proof (state)
this:
integrable M (\<lambda>x. norm (f x))

goal (4 subgoals):
 1. f \<in> borel_measurable M
 2. \<And>n. (\<lambda>x. indicat_real {..X n} x *\<^sub>R f x) \<in> borel_measurable M
 3. AE x in M. (\<lambda>n. indicat_real {..X n} x *\<^sub>R f x) \<longlonglongrightarrow> f x
 4. \<And>n. AE x in M. norm (indicat_real {..X n} x *\<^sub>R f x) \<le> norm (f x)
[PROOF STEP]
show "AE x in M. (\<lambda>n. indicator {..X n} x *\<^sub>R f x) \<longlonglongrightarrow> f x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. AE x in M. (\<lambda>n. indicat_real {..X n} x *\<^sub>R f x) \<longlonglongrightarrow> f x
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> space M \<Longrightarrow> (\<lambda>n. indicat_real {..X n} x *\<^sub>R f x) \<longlonglongrightarrow> f x
[PROOF STEP]
fix x
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> space M \<Longrightarrow> (\<lambda>n. indicat_real {..X n} x *\<^sub>R f x) \<longlonglongrightarrow> f x
[PROOF STEP]
from \<open>filterlim X at_top sequentially\<close>
[PROOF STATE]
proof (chain)
picking this:
filterlim X at_top sequentially
[PROOF STEP]
have "eventually (\<lambda>n. x \<le> X n) sequentially"
[PROOF STATE]
proof (prove)
using this:
filterlim X at_top sequentially

goal (1 subgoal):
 1. \<forall>\<^sub>F n in sequentially. x \<le> X n
[PROOF STEP]
unfolding filterlim_at_top_ge[where c=x]
[PROOF STATE]
proof (prove)
using this:
\<forall>Z\<ge>x. \<forall>\<^sub>F x in sequentially. Z \<le> X x

goal (1 subgoal):
 1. \<forall>\<^sub>F n in sequentially. x \<le> X n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<forall>\<^sub>F n in sequentially. x \<le> X n

goal (1 subgoal):
 1. \<And>x. x \<in> space M \<Longrightarrow> (\<lambda>n. indicat_real {..X n} x *\<^sub>R f x) \<longlonglongrightarrow> f x
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<forall>\<^sub>F n in sequentially. x \<le> X n
[PROOF STEP]
show "(\<lambda>n. indicator {..X n} x *\<^sub>R f x) \<longlonglongrightarrow> f x"
[PROOF STATE]
proof (prove)
using this:
\<forall>\<^sub>F n in sequentially. x \<le> X n

goal (1 subgoal):
 1. (\<lambda>n. indicat_real {..X n} x *\<^sub>R f x) \<longlonglongrightarrow> f x
[PROOF STEP]
by (intro tendsto_eventually) (auto split: split_indicator elim!: eventually_mono)
[PROOF STATE]
proof (state)
this:
(\<lambda>n. indicat_real {..X n} x *\<^sub>R f x) \<longlonglongrightarrow> f x

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
AE x in M. (\<lambda>n. indicat_real {..X n} x *\<^sub>R f x) \<longlonglongrightarrow> f x

goal (3 subgoals):
 1. f \<in> borel_measurable M
 2. \<And>n. (\<lambda>x. indicat_real {..X n} x *\<^sub>R f x) \<in> borel_measurable M
 3. \<And>n. AE x in M. norm (indicat_real {..X n} x *\<^sub>R f x) \<le> norm (f x)
[PROOF STEP]
fix n
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. f \<in> borel_measurable M
 2. \<And>n. (\<lambda>x. indicat_real {..X n} x *\<^sub>R f x) \<in> borel_measurable M
 3. \<And>n. AE x in M. norm (indicat_real {..X n} x *\<^sub>R f x) \<le> norm (f x)
[PROOF STEP]
show "AE x in M. norm (indicator {..X n} x *\<^sub>R f x) \<le> norm (f x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. AE x in M. norm (indicat_real {..X n} x *\<^sub>R f x) \<le> norm (f x)
[PROOF STEP]
by (auto split: split_indicator)
[PROOF STATE]
proof (state)
this:
AE x in M. norm (indicat_real {..X n} x *\<^sub>R f x) \<le> norm (f x)

goal (2 subgoals):
 1. f \<in> borel_measurable M
 2. \<And>n. (\<lambda>x. indicat_real {..X n} x *\<^sub>R f x) \<in> borel_measurable M
[PROOF STEP]
qed auto
[PROOF STATE]
proof (state)
this:
(\<lambda>n. LINT x|M. indicat_real {..X n} x *\<^sub>R f x) \<longlonglongrightarrow> integral\<^sup>L M f

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma abundant_Esigma:
  assumes "Esigma m > 2*m" and "m \<ge>1"
  shows "abundant_number m"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. abundant_number m
[PROOF STEP]
using Esigma_properdiv_set assms abundant_number_def
[PROOF STATE]
proof (prove)
using this:
1 \<le> ?m \<Longrightarrow> Esigma ?m = aliquot_sum ?m + ?m
2 * m < Esigma m
1 \<le> m
abundant_number ?n \<equiv> ?n < aliquot_sum ?n

goal (1 subgoal):
 1. abundant_number m
[PROOF STEP]
by auto


[STATEMENT]
theorem finite_domains_are_fields:
  assumes "domain R"
  assumes "finite (carrier R)"
  shows "finite_field R"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite_field R
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. finite_field R
[PROOF STEP]
interpret domain R
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. domain R
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
domain R
finite (carrier R)

goal (1 subgoal):
 1. domain R
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. finite_field R
[PROOF STEP]
have "Units R = carrier R - {\<zero>\<^bsub>R\<^esub>}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Units R = carrier R - {\<zero>\<^bsub>R\<^esub>}
[PROOF STEP]
using finite_domain_units[OF assms(2)]
[PROOF STATE]
proof (prove)
using this:
Units R = carrier R - {\<zero>\<^bsub>R\<^esub>}

goal (1 subgoal):
 1. Units R = carrier R - {\<zero>\<^bsub>R\<^esub>}
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
Units R = carrier R - {\<zero>\<^bsub>R\<^esub>}

goal (1 subgoal):
 1. finite_field R
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
Units R = carrier R - {\<zero>\<^bsub>R\<^esub>}
[PROOF STEP]
have "field R"
[PROOF STATE]
proof (prove)
using this:
Units R = carrier R - {\<zero>\<^bsub>R\<^esub>}

goal (1 subgoal):
 1. field R
[PROOF STEP]
by (simp add: assms(1) field.intro field_axioms.intro)
[PROOF STATE]
proof (state)
this:
field R

goal (1 subgoal):
 1. finite_field R
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
field R

goal (1 subgoal):
 1. finite_field R
[PROOF STEP]
using assms(2) finite_fieldI
[PROOF STATE]
proof (prove)
using this:
field R
finite (carrier R)
\<lbrakk>field ?R; finite (carrier ?R)\<rbrakk> \<Longrightarrow> finite_field ?R

goal (1 subgoal):
 1. finite_field R
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
finite_field R

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma matrix_mul_lid [simp]:
  fixes A :: "'a::semiring_1 ^ 'm ^ 'n"
  shows "mat 1 ** A = A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mat (1::'a) ** A = A
[PROOF STEP]
unfolding matrix_matrix_mult_def mat_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<chi>i j. \<Sum>k\<in>UNIV. (\<chi>i j. if i = j then 1::'a else (0::'a)) $ i $ k * A $ k $ j) = A
[PROOF STEP]
by (auto simp: if_distrib if_distribR sum.delta'[OF finite] cong: if_cong)


[STATEMENT]
lemma unit_vectors_is_basis [simp]:
  "vectorspace.basis cpx_rng (module_cpx_vec n) (unit_vectors n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vectorspace.basis cpx_rng (module_cpx_vec n) (unit_vectors n)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. vectorspace.basis cpx_rng (module_cpx_vec n) (unit_vectors n)
[PROOF STEP]
fix n
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. vectorspace.basis cpx_rng (module_cpx_vec n) (unit_vectors n)
[PROOF STEP]
have "unit_vectors n \<subseteq> carrier (module_cpx_vec n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. unit_vectors n \<subseteq> carrier (module_cpx_vec n)
[PROOF STEP]
using unit_vectors_def module_cpx_vec_def module_vec_simps(3)
[PROOF STATE]
proof (prove)
using this:
unit_vectors ?n \<equiv> {unit_vec ?n i |i. 0 \<le> i \<and> i < ?n}
module_cpx_vec ?n \<equiv> module_vec TYPE(complex) ?n
carrier (module_vec ?ty ?n) = carrier_vec ?n

goal (1 subgoal):
 1. unit_vectors n \<subseteq> carrier (module_cpx_vec n)
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
unit_vectors n \<subseteq> carrier (module_cpx_vec n)

goal (1 subgoal):
 1. vectorspace.basis cpx_rng (module_cpx_vec n) (unit_vectors n)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
unit_vectors n \<subseteq> carrier (module_cpx_vec n)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
unit_vectors n \<subseteq> carrier (module_cpx_vec n)

goal (1 subgoal):
 1. vectorspace.basis cpx_rng (module_cpx_vec n) (unit_vectors n)
[PROOF STEP]
using vectorspace.basis_def unit_vectors_is_lin_indpt unit_vectors_is_genset vecspace_cpx_vec
[PROOF STATE]
proof (prove)
using this:
unit_vectors n \<subseteq> carrier (module_cpx_vec n)
vectorspace ?K ?V \<Longrightarrow> vectorspace.basis ?K ?V ?A = (\<not> module.lin_dep ?K ?V ?A \<and> LinearCombinations.module.span ?K ?V ?A = carrier ?V \<and> ?A \<subseteq> carrier ?V)
\<not> module.lin_dep cpx_rng (module_cpx_vec ?n) (unit_vectors ?n)
LinearCombinations.module.span cpx_rng (module_cpx_vec ?n) (unit_vectors ?n) = carrier (module_cpx_vec ?n)
vectorspace cpx_rng (module_cpx_vec ?n)

goal (1 subgoal):
 1. vectorspace.basis cpx_rng (module_cpx_vec n) (unit_vectors n)
[PROOF STEP]
by(smt carrier_dim_vec index_unit_vec(3) mem_Collect_eq module_cpx_vec_def module_vec_simps(3)
        subsetI unit_vectors_def)
[PROOF STATE]
proof (state)
this:
vectorspace.basis cpx_rng (module_cpx_vec n) (unit_vectors n)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma lcoset_rel_sym: "sym (lcoset_rel G)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sym (lcoset_rel G)
[PROOF STEP]
proof (rule symI)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a b. (a, b) \<in> lcoset_rel G \<Longrightarrow> (b, a) \<in> lcoset_rel G
[PROOF STEP]
fix a b
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a b. (a, b) \<in> lcoset_rel G \<Longrightarrow> (b, a) \<in> lcoset_rel G
[PROOF STEP]
show "(a,b) \<in> lcoset_rel G \<Longrightarrow> (b,a) \<in> lcoset_rel G"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (a, b) \<in> lcoset_rel G \<Longrightarrow> (b, a) \<in> lcoset_rel G
[PROOF STEP]
using uminus_closed minus_add[of "-a" b] lcoset_rel_def[of G]
[PROOF STATE]
proof (prove)
using this:
?g \<in> G \<Longrightarrow> - ?g \<in> G
- (- a + b) = - b + - (- a)
lcoset_rel G \<equiv> {(x, y). - x + y \<in> G}

goal (1 subgoal):
 1. (a, b) \<in> lcoset_rel G \<Longrightarrow> (b, a) \<in> lcoset_rel G
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
(a, b) \<in> lcoset_rel G \<Longrightarrow> (b, a) \<in> lcoset_rel G

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma lincomb_scalar_prod_left: assumes "W \<subseteq> carrier_vec n" "v \<in> carrier_vec n"
  shows "lincomb a W \<bullet> v = (\<Sum>w\<in>W. a w * (w \<bullet> v))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. lincomb a W \<bullet> v = (\<Sum>w\<in>W. a w * (w \<bullet> v))
[PROOF STEP]
unfolding lincomb_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Oplus>\<^bsub>V\<^esub>v\<in>W. a v \<cdot>\<^sub>v v) \<bullet> v = (\<Sum>w\<in>W. a w * (w \<bullet> v))
[PROOF STEP]
by (subst finsum_scalar_prod_sum, insert assms, auto intro!: sum.cong)


[STATEMENT]
lemma beukers_nn_integral1_different:
  assumes "r > s"
  shows   "beukers_nn_integral1 r s = ennreal ((\<Sum>k\<in>{s<..r}. 1 / k ^ 2) / (r - s))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. beukers_nn_integral1 r s = ennreal ((\<Sum>k\<in>{s<..r}. 1 / real (k\<^sup>2)) / real (r - s))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. beukers_nn_integral1 r s = ennreal ((\<Sum>k\<in>{s<..r}. 1 / real (k\<^sup>2)) / real (r - s))
[PROOF STEP]
have "(\<lambda>k. 1 / (r - s) * (1 / (s + k + 1) ^ 2 - 1 / (r + k + 1) ^ 2))
          sums (1 / (r - s) * ((Re (zeta (of_nat 2)) - (\<Sum>k=1..s. 1/k^2)) -
                               (Re (zeta (of_nat 2)) - (\<Sum>k=1..r. 1/k^2))))"
    (is "_ sums ?S")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>k. 1 / real (r - s) * (1 / real ((s + k + 1)\<^sup>2) - 1 / real ((r + k + 1)\<^sup>2))) sums (1 / real (r - s) * (Re (zeta (of_nat 2)) - (\<Sum>k = 1..s. 1 / real (k\<^sup>2)) - (Re (zeta (of_nat 2)) - (\<Sum>k = 1..r. 1 / real (k\<^sup>2)))))
[PROOF STEP]
by (intro sums_mult sums_diff sums_Re_zeta_of_nat_offset) auto
[PROOF STATE]
proof (state)
this:
(\<lambda>k. 1 / real (r - s) * (1 / real ((s + k + 1)\<^sup>2) - 1 / real ((r + k + 1)\<^sup>2))) sums (1 / real (r - s) * (Re (zeta (of_nat 2)) - (\<Sum>k = 1..s. 1 / real (k\<^sup>2)) - (Re (zeta (of_nat 2)) - (\<Sum>k = 1..r. 1 / real (k\<^sup>2)))))

goal (1 subgoal):
 1. beukers_nn_integral1 r s = ennreal ((\<Sum>k\<in>{s<..r}. 1 / real (k\<^sup>2)) / real (r - s))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<lambda>k. 1 / real (r - s) * (1 / real ((s + k + 1)\<^sup>2) - 1 / real ((r + k + 1)\<^sup>2))) sums (1 / real (r - s) * (Re (zeta (of_nat 2)) - (\<Sum>k = 1..s. 1 / real (k\<^sup>2)) - (Re (zeta (of_nat 2)) - (\<Sum>k = 1..r. 1 / real (k\<^sup>2)))))

goal (1 subgoal):
 1. beukers_nn_integral1 r s = ennreal ((\<Sum>k\<in>{s<..r}. 1 / real (k\<^sup>2)) / real (r - s))
[PROOF STEP]
have "?S = ((\<Sum>k=1..r. 1/k^2) - (\<Sum>k=1..s. 1/k^2)) / (r - s)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 / real (r - s) * (Re (zeta (of_nat 2)) - (\<Sum>k = 1..s. 1 / real (k\<^sup>2)) - (Re (zeta (of_nat 2)) - (\<Sum>k = 1..r. 1 / real (k\<^sup>2)))) = ((\<Sum>k = 1..r. 1 / real (k\<^sup>2)) - (\<Sum>k = 1..s. 1 / real (k\<^sup>2))) / real (r - s)
[PROOF STEP]
by (simp add: algebra_simps diff_divide_distrib)
[PROOF STATE]
proof (state)
this:
1 / real (r - s) * (Re (zeta (of_nat 2)) - (\<Sum>k = 1..s. 1 / real (k\<^sup>2)) - (Re (zeta (of_nat 2)) - (\<Sum>k = 1..r. 1 / real (k\<^sup>2)))) = ((\<Sum>k = 1..r. 1 / real (k\<^sup>2)) - (\<Sum>k = 1..s. 1 / real (k\<^sup>2))) / real (r - s)

goal (1 subgoal):
 1. beukers_nn_integral1 r s = ennreal ((\<Sum>k\<in>{s<..r}. 1 / real (k\<^sup>2)) / real (r - s))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
1 / real (r - s) * (Re (zeta (of_nat 2)) - (\<Sum>k = 1..s. 1 / real (k\<^sup>2)) - (Re (zeta (of_nat 2)) - (\<Sum>k = 1..r. 1 / real (k\<^sup>2)))) = ((\<Sum>k = 1..r. 1 / real (k\<^sup>2)) - (\<Sum>k = 1..s. 1 / real (k\<^sup>2))) / real (r - s)

goal (1 subgoal):
 1. beukers_nn_integral1 r s = ennreal ((\<Sum>k\<in>{s<..r}. 1 / real (k\<^sup>2)) / real (r - s))
[PROOF STEP]
have "(\<Sum>k=1..r. 1/k^2) - (\<Sum>k=1..s. 1/k^2) = (\<Sum>k\<in>{1..r}-{1..s}. 1/k^2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>k = 1..r. 1 / real (k\<^sup>2)) - (\<Sum>k = 1..s. 1 / real (k\<^sup>2)) = (\<Sum>k\<in>{1..r} - {1..s}. 1 / real (k\<^sup>2))
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
s < r

goal (1 subgoal):
 1. (\<Sum>k = 1..r. 1 / real (k\<^sup>2)) - (\<Sum>k = 1..s. 1 / real (k\<^sup>2)) = (\<Sum>k\<in>{1..r} - {1..s}. 1 / real (k\<^sup>2))
[PROOF STEP]
by (subst Groups_Big.sum_diff) auto
[PROOF STATE]
proof (state)
this:
(\<Sum>k = 1..r. 1 / real (k\<^sup>2)) - (\<Sum>k = 1..s. 1 / real (k\<^sup>2)) = (\<Sum>k\<in>{1..r} - {1..s}. 1 / real (k\<^sup>2))

goal (1 subgoal):
 1. beukers_nn_integral1 r s = ennreal ((\<Sum>k\<in>{s<..r}. 1 / real (k\<^sup>2)) / real (r - s))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>k = 1..r. 1 / real (k\<^sup>2)) - (\<Sum>k = 1..s. 1 / real (k\<^sup>2)) = (\<Sum>k\<in>{1..r} - {1..s}. 1 / real (k\<^sup>2))

goal (1 subgoal):
 1. beukers_nn_integral1 r s = ennreal ((\<Sum>k\<in>{s<..r}. 1 / real (k\<^sup>2)) / real (r - s))
[PROOF STEP]
have "{1..r} - {1..s} = {s<..r}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {1..r} - {1..s} = {s<..r}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
{1..r} - {1..s} = {s<..r}

goal (1 subgoal):
 1. beukers_nn_integral1 r s = ennreal ((\<Sum>k\<in>{s<..r}. 1 / real (k\<^sup>2)) / real (r - s))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
{1..r} - {1..s} = {s<..r}

goal (1 subgoal):
 1. beukers_nn_integral1 r s = ennreal ((\<Sum>k\<in>{s<..r}. 1 / real (k\<^sup>2)) / real (r - s))
[PROOF STEP]
have "(\<lambda>k. 1 / (r - s) * (1 / (s + k + 1) ^ 2 - 1 / (r + k + 1) ^ 2)) =
               (\<lambda>k. 1 / ((k+r+1) * (k+s+1)^2) + 1 / ((k+r+1)^2 * (k+s+1)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>k. 1 / real (r - s) * (1 / real ((s + k + 1)\<^sup>2) - 1 / real ((r + k + 1)\<^sup>2))) = (\<lambda>k. 1 / real ((k + r + 1) * (k + s + 1)\<^sup>2) + 1 / real ((k + r + 1)\<^sup>2 * (k + s + 1)))
[PROOF STEP]
proof (intro ext, goal_cases)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>k. 1 / real (r - s) * (1 / real ((s + k + 1)\<^sup>2) - 1 / real ((r + k + 1)\<^sup>2)) = 1 / real ((k + r + 1) * (k + s + 1)\<^sup>2) + 1 / real ((k + r + 1)\<^sup>2 * (k + s + 1))
[PROOF STEP]
case (1 k)
[PROOF STATE]
proof (state)
this:

goal (1 subgoal):
 1. \<And>k. 1 / real (r - s) * (1 / real ((s + k + 1)\<^sup>2) - 1 / real ((r + k + 1)\<^sup>2)) = 1 / real ((k + r + 1) * (k + s + 1)\<^sup>2) + 1 / real ((k + r + 1)\<^sup>2 * (k + s + 1))
[PROOF STEP]
define x where "x = real (k + r + 1)"
[PROOF STATE]
proof (state)
this:
x = real (k + r + 1)

goal (1 subgoal):
 1. \<And>k. 1 / real (r - s) * (1 / real ((s + k + 1)\<^sup>2) - 1 / real ((r + k + 1)\<^sup>2)) = 1 / real ((k + r + 1) * (k + s + 1)\<^sup>2) + 1 / real ((k + r + 1)\<^sup>2 * (k + s + 1))
[PROOF STEP]
define y where "y = real (k + s + 1)"
[PROOF STATE]
proof (state)
this:
y = real (k + s + 1)

goal (1 subgoal):
 1. \<And>k. 1 / real (r - s) * (1 / real ((s + k + 1)\<^sup>2) - 1 / real ((r + k + 1)\<^sup>2)) = 1 / real ((k + r + 1) * (k + s + 1)\<^sup>2) + 1 / real ((k + r + 1)\<^sup>2 * (k + s + 1))
[PROOF STEP]
have [simp]: "x \<noteq> 0" "y \<noteq> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<noteq> 0 &&& y \<noteq> 0
[PROOF STEP]
by (auto simp: x_def y_def)
[PROOF STATE]
proof (state)
this:
x \<noteq> 0
y \<noteq> 0

goal (1 subgoal):
 1. \<And>k. 1 / real (r - s) * (1 / real ((s + k + 1)\<^sup>2) - 1 / real ((r + k + 1)\<^sup>2)) = 1 / real ((k + r + 1) * (k + s + 1)\<^sup>2) + 1 / real ((k + r + 1)\<^sup>2 * (k + s + 1))
[PROOF STEP]
have "(x\<^sup>2 * y + x * y\<^sup>2) * (real r - real s) = x * y * (x\<^sup>2 - y\<^sup>2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (x\<^sup>2 * y + x * y\<^sup>2) * (real r - real s) = x * y * (x\<^sup>2 - y\<^sup>2)
[PROOF STEP]
by (simp add: algebra_simps power2_eq_square x_def y_def)
[PROOF STATE]
proof (state)
this:
(x\<^sup>2 * y + x * y\<^sup>2) * (real r - real s) = x * y * (x\<^sup>2 - y\<^sup>2)

goal (1 subgoal):
 1. \<And>k. 1 / real (r - s) * (1 / real ((s + k + 1)\<^sup>2) - 1 / real ((r + k + 1)\<^sup>2)) = 1 / real ((k + r + 1) * (k + s + 1)\<^sup>2) + 1 / real ((k + r + 1)\<^sup>2 * (k + s + 1))
[PROOF STEP]
hence "1 / (x*y^2) + 1 / (x^2*y) = 1 / (r - s) * (1 / y^2 - 1 / x^2)"
[PROOF STATE]
proof (prove)
using this:
(x\<^sup>2 * y + x * y\<^sup>2) * (real r - real s) = x * y * (x\<^sup>2 - y\<^sup>2)

goal (1 subgoal):
 1. 1 / (x * y\<^sup>2) + 1 / (x\<^sup>2 * y) = 1 / real (r - s) * (1 / y\<^sup>2 - 1 / x\<^sup>2)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
(x\<^sup>2 * y + x * y\<^sup>2) * (real r - real s) = x * y * (x\<^sup>2 - y\<^sup>2)
s < r

goal (1 subgoal):
 1. 1 / (x * y\<^sup>2) + 1 / (x\<^sup>2 * y) = 1 / real (r - s) * (1 / y\<^sup>2 - 1 / x\<^sup>2)
[PROOF STEP]
by (simp add: divide_simps of_nat_diff)
[PROOF STATE]
proof (state)
this:
1 / (x * y\<^sup>2) + 1 / (x\<^sup>2 * y) = 1 / real (r - s) * (1 / y\<^sup>2 - 1 / x\<^sup>2)

goal (1 subgoal):
 1. \<And>k. 1 / real (r - s) * (1 / real ((s + k + 1)\<^sup>2) - 1 / real ((r + k + 1)\<^sup>2)) = 1 / real ((k + r + 1) * (k + s + 1)\<^sup>2) + 1 / real ((k + r + 1)\<^sup>2 * (k + s + 1))
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
using this:
1 / (x * y\<^sup>2) + 1 / (x\<^sup>2 * y) = 1 / real (r - s) * (1 / y\<^sup>2 - 1 / x\<^sup>2)

goal (1 subgoal):
 1. 1 / real (r - s) * (1 / real ((s + k + 1)\<^sup>2) - 1 / real ((r + k + 1)\<^sup>2)) = 1 / real ((k + r + 1) * (k + s + 1)\<^sup>2) + 1 / real ((k + r + 1)\<^sup>2 * (k + s + 1))
[PROOF STEP]
by (simp add: x_def y_def algebra_simps)
[PROOF STATE]
proof (state)
this:
1 / real (r - s) * (1 / real ((s + k + 1)\<^sup>2) - 1 / real ((r + k + 1)\<^sup>2)) = 1 / real ((k + r + 1) * (k + s + 1)\<^sup>2) + 1 / real ((k + r + 1)\<^sup>2 * (k + s + 1))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<lambda>k. 1 / real (r - s) * (1 / real ((s + k + 1)\<^sup>2) - 1 / real ((r + k + 1)\<^sup>2))) = (\<lambda>k. 1 / real ((k + r + 1) * (k + s + 1)\<^sup>2) + 1 / real ((k + r + 1)\<^sup>2 * (k + s + 1)))

goal (1 subgoal):
 1. beukers_nn_integral1 r s = ennreal ((\<Sum>k\<in>{s<..r}. 1 / real (k\<^sup>2)) / real (r - s))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(\<lambda>k. 1 / real ((k + r + 1) * (k + s + 1)\<^sup>2) + 1 / real ((k + r + 1)\<^sup>2 * (k + s + 1))) sums ((\<Sum>k\<in>{s<..r}. 1 / real (k\<^sup>2)) / real (r - s))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(\<lambda>k. 1 / real ((k + r + 1) * (k + s + 1)\<^sup>2) + 1 / real ((k + r + 1)\<^sup>2 * (k + s + 1))) sums ((\<Sum>k\<in>{s<..r}. 1 / real (k\<^sup>2)) / real (r - s))

goal (1 subgoal):
 1. beukers_nn_integral1 r s = ennreal ((\<Sum>k\<in>{s<..r}. 1 / real (k\<^sup>2)) / real (r - s))
[PROOF STEP]
unfolding beukers_nn_integral1_series
[PROOF STATE]
proof (prove)
using this:
(\<lambda>k. 1 / real ((k + r + 1) * (k + s + 1)\<^sup>2) + 1 / real ((k + r + 1)\<^sup>2 * (k + s + 1))) sums ((\<Sum>k\<in>{s<..r}. 1 / real (k\<^sup>2)) / real (r - s))

goal (1 subgoal):
 1. (\<Sum>k. ennreal (1 / real ((k + r + 1)\<^sup>2 * (k + s + 1)) + 1 / real ((k + r + 1) * (k + s + 1)\<^sup>2))) = ennreal ((\<Sum>k\<in>{s<..r}. 1 / real (k\<^sup>2)) / real (r - s))
[PROOF STEP]
by (intro suminf_ennreal_eq) (auto simp: add_ac)
[PROOF STATE]
proof (state)
this:
beukers_nn_integral1 r s = ennreal ((\<Sum>k\<in>{s<..r}. 1 / real (k\<^sup>2)) / real (r - s))

goal:
No subgoals!
[PROOF STEP]
qed