[STATEMENT]
lemma set_as_map_code[code] :
  "set_as_map (set xs) = (foldl (\<lambda> m (x,z) . case m x of
                                                None \<Rightarrow> m (x \<mapsto> {z}) |
                                                Some zs \<Rightarrow> m (x \<mapsto>  (insert z zs)))
                                Map.empty
                                xs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set_as_map (set xs) = foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. set_as_map (set xs) = foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs
[PROOF STEP]
let ?f = "\<lambda> xs . (foldl (\<lambda> m (x,z) . case m x of
                                          None \<Rightarrow> m (x \<mapsto> {z}) |
                                          Some zs \<Rightarrow> m (x \<mapsto>  (insert z zs)))
                          Map.empty
                          xs)"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. set_as_map (set xs) = foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs
[PROOF STEP]
have "(?f xs) = (\<lambda> x . if (\<exists> z . (x,z) \<in> set xs) then Some {z . (x,z) \<in> set xs} else None)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs = (\<lambda>x. if \<exists>z. (x, z) \<in> set xs then Some {z. (x, z) \<in> set xs} else None)
[PROOF STEP]
proof (induction xs rule: rev_induct)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. foldl (\<lambda>m a. case a of (x, z) \<Rightarrow> case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty [] = (\<lambda>x. if \<exists>z. (x, z) \<in> set [] then Some {z. (x, z) \<in> set []} else None)
 2. \<And>x xs. foldl (\<lambda>m a. case a of (x, z) \<Rightarrow> case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs = (\<lambda>x. if \<exists>z. (x, z) \<in> set xs then Some {z. (x, z) \<in> set xs} else None) \<Longrightarrow> foldl (\<lambda>m a. case a of (x, z) \<Rightarrow> case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [x]) = (\<lambda>xa. if \<exists>z. (xa, z) \<in> set (xs @ [x]) then Some {z. (xa, z) \<in> set (xs @ [x])} else None)
[PROOF STEP]
case Nil
[PROOF STATE]
proof (state)
this:

goal (2 subgoals):
 1. foldl (\<lambda>m a. case a of (x, z) \<Rightarrow> case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty [] = (\<lambda>x. if \<exists>z. (x, z) \<in> set [] then Some {z. (x, z) \<in> set []} else None)
 2. \<And>x xs. foldl (\<lambda>m a. case a of (x, z) \<Rightarrow> case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs = (\<lambda>x. if \<exists>z. (x, z) \<in> set xs then Some {z. (x, z) \<in> set xs} else None) \<Longrightarrow> foldl (\<lambda>m a. case a of (x, z) \<Rightarrow> case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [x]) = (\<lambda>xa. if \<exists>z. (xa, z) \<in> set (xs @ [x]) then Some {z. (xa, z) \<in> set (xs @ [x])} else None)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. foldl (\<lambda>m a. case a of (x, z) \<Rightarrow> case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty [] = (\<lambda>x. if \<exists>z. (x, z) \<in> set [] then Some {z. (x, z) \<in> set []} else None)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
foldl (\<lambda>m a. case a of (x, z) \<Rightarrow> case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty [] = (\<lambda>x. if \<exists>z. (x, z) \<in> set [] then Some {z. (x, z) \<in> set []} else None)

goal (1 subgoal):
 1. \<And>x xs. foldl (\<lambda>m a. case a of (x, z) \<Rightarrow> case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs = (\<lambda>x. if \<exists>z. (x, z) \<in> set xs then Some {z. (x, z) \<in> set xs} else None) \<Longrightarrow> foldl (\<lambda>m a. case a of (x, z) \<Rightarrow> case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [x]) = (\<lambda>xa. if \<exists>z. (xa, z) \<in> set (xs @ [x]) then Some {z. (xa, z) \<in> set (xs @ [x])} else None)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x xs. foldl (\<lambda>m a. case a of (x, z) \<Rightarrow> case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs = (\<lambda>x. if \<exists>z. (x, z) \<in> set xs then Some {z. (x, z) \<in> set xs} else None) \<Longrightarrow> foldl (\<lambda>m a. case a of (x, z) \<Rightarrow> case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [x]) = (\<lambda>xa. if \<exists>z. (xa, z) \<in> set (xs @ [x]) then Some {z. (xa, z) \<in> set (xs @ [x])} else None)
[PROOF STEP]
case (snoc xz xs)
[PROOF STATE]
proof (state)
this:
foldl (\<lambda>m a. case a of (x, z) \<Rightarrow> case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs = (\<lambda>x. if \<exists>z. (x, z) \<in> set xs then Some {z. (x, z) \<in> set xs} else None)

goal (1 subgoal):
 1. \<And>x xs. foldl (\<lambda>m a. case a of (x, z) \<Rightarrow> case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs = (\<lambda>x. if \<exists>z. (x, z) \<in> set xs then Some {z. (x, z) \<in> set xs} else None) \<Longrightarrow> foldl (\<lambda>m a. case a of (x, z) \<Rightarrow> case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [x]) = (\<lambda>xa. if \<exists>z. (xa, z) \<in> set (xs @ [x]) then Some {z. (xa, z) \<in> set (xs @ [x])} else None)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
foldl (\<lambda>m a. case a of (x, z) \<Rightarrow> case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs = (\<lambda>x. if \<exists>z. (x, z) \<in> set xs then Some {z. (x, z) \<in> set xs} else None)
[PROOF STEP]
obtain x z where "xz = (x,z)"
[PROOF STATE]
proof (prove)
using this:
foldl (\<lambda>m a. case a of (x, z) \<Rightarrow> case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs = (\<lambda>x. if \<exists>z. (x, z) \<in> set xs then Some {z. (x, z) \<in> set xs} else None)

goal (1 subgoal):
 1. (\<And>x z. xz = (x, z) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
xz = (x, z)

goal (1 subgoal):
 1. \<And>x xs. foldl (\<lambda>m a. case a of (x, z) \<Rightarrow> case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs = (\<lambda>x. if \<exists>z. (x, z) \<in> set xs then Some {z. (x, z) \<in> set xs} else None) \<Longrightarrow> foldl (\<lambda>m a. case a of (x, z) \<Rightarrow> case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [x]) = (\<lambda>xa. if \<exists>z. (xa, z) \<in> set (xs @ [x]) then Some {z. (xa, z) \<in> set (xs @ [x])} else None)
[PROOF STEP]
have *: "(?f (xs@[(x,z)])) = (case (?f xs) x of
                                None \<Rightarrow> (?f xs) (x \<mapsto> {z}) |
                                Some zs \<Rightarrow> (?f xs) (x \<mapsto> (insert z zs)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [(x, z)]) = (case foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x of None \<Rightarrow> foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> {z}) | Some zs \<Rightarrow> foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> insert z zs))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [(x, z)]) = (case foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x of None \<Rightarrow> foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> {z}) | Some zs \<Rightarrow> foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> insert z zs))

goal (1 subgoal):
 1. \<And>x xs. foldl (\<lambda>m a. case a of (x, z) \<Rightarrow> case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs = (\<lambda>x. if \<exists>z. (x, z) \<in> set xs then Some {z. (x, z) \<in> set xs} else None) \<Longrightarrow> foldl (\<lambda>m a. case a of (x, z) \<Rightarrow> case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [x]) = (\<lambda>xa. if \<exists>z. (xa, z) \<in> set (xs @ [x]) then Some {z. (xa, z) \<in> set (xs @ [x])} else None)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [(x, z)]) = (case foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x of None \<Rightarrow> foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> {z}) | Some zs \<Rightarrow> foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> insert z zs))
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [(x, z)]) = (case foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x of None \<Rightarrow> foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> {z}) | Some zs \<Rightarrow> foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> insert z zs))

goal (1 subgoal):
 1. foldl (\<lambda>m a. case a of (x, z) \<Rightarrow> case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [xz]) = (\<lambda>x. if \<exists>z. (x, z) \<in> set (xs @ [xz]) then Some {z. (x, z) \<in> set (xs @ [xz])} else None)
[PROOF STEP]
proof (cases "(?f xs) x")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<lbrakk>foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [(x, z)]) = (case foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x of None \<Rightarrow> foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> {z}) | Some zs \<Rightarrow> foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> insert z zs)); foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x = None\<rbrakk> \<Longrightarrow> foldl (\<lambda>m a. case a of (x, z) \<Rightarrow> case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [xz]) = (\<lambda>x. if \<exists>z. (x, z) \<in> set (xs @ [xz]) then Some {z. (x, z) \<in> set (xs @ [xz])} else None)
 2. \<And>a. \<lbrakk>foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [(x, z)]) = (case foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x of None \<Rightarrow> foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> {z}) | Some zs \<Rightarrow> foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> insert z zs)); foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x = Some a\<rbrakk> \<Longrightarrow> foldl (\<lambda>m a. case a of (x, z) \<Rightarrow> case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [xz]) = (\<lambda>x. if \<exists>z. (x, z) \<in> set (xs @ [xz]) then Some {z. (x, z) \<in> set (xs @ [xz])} else None)
[PROOF STEP]
case None
[PROOF STATE]
proof (state)
this:
foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x = None

goal (2 subgoals):
 1. \<lbrakk>foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [(x, z)]) = (case foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x of None \<Rightarrow> foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> {z}) | Some zs \<Rightarrow> foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> insert z zs)); foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x = None\<rbrakk> \<Longrightarrow> foldl (\<lambda>m a. case a of (x, z) \<Rightarrow> case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [xz]) = (\<lambda>x. if \<exists>z. (x, z) \<in> set (xs @ [xz]) then Some {z. (x, z) \<in> set (xs @ [xz])} else None)
 2. \<And>a. \<lbrakk>foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [(x, z)]) = (case foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x of None \<Rightarrow> foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> {z}) | Some zs \<Rightarrow> foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> insert z zs)); foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x = Some a\<rbrakk> \<Longrightarrow> foldl (\<lambda>m a. case a of (x, z) \<Rightarrow> case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [xz]) = (\<lambda>x. if \<exists>z. (x, z) \<in> set (xs @ [xz]) then Some {z. (x, z) \<in> set (xs @ [xz])} else None)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x = None
[PROOF STEP]
have **: "(?f (xs@[(x,z)])) = (?f xs) (x \<mapsto> {z})"
[PROOF STATE]
proof (prove)
using this:
foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x = None

goal (1 subgoal):
 1. foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [(x, z)]) = foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> {z})
[PROOF STEP]
using *
[PROOF STATE]
proof (prove)
using this:
foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x = None
foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [(x, z)]) = (case foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x of None \<Rightarrow> foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> {z}) | Some zs \<Rightarrow> foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> insert z zs))

goal (1 subgoal):
 1. foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [(x, z)]) = foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> {z})
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [(x, z)]) = foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> {z})

goal (2 subgoals):
 1. \<lbrakk>foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [(x, z)]) = (case foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x of None \<Rightarrow> foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> {z}) | Some zs \<Rightarrow> foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> insert z zs)); foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x = None\<rbrakk> \<Longrightarrow> foldl (\<lambda>m a. case a of (x, z) \<Rightarrow> case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [xz]) = (\<lambda>x. if \<exists>z. (x, z) \<in> set (xs @ [xz]) then Some {z. (x, z) \<in> set (xs @ [xz])} else None)
 2. \<And>a. \<lbrakk>foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [(x, z)]) = (case foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x of None \<Rightarrow> foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> {z}) | Some zs \<Rightarrow> foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> insert z zs)); foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x = Some a\<rbrakk> \<Longrightarrow> foldl (\<lambda>m a. case a of (x, z) \<Rightarrow> case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [xz]) = (\<lambda>x. if \<exists>z. (x, z) \<in> set (xs @ [xz]) then Some {z. (x, z) \<in> set (xs @ [xz])} else None)
[PROOF STEP]
have scheme: "\<And> m k v . (m(k \<mapsto> v)) = (\<lambda>k' . if k' = k then Some v else m k')"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>m k v. m(k \<mapsto> v) = (\<lambda>k'. if k' = k then Some v else m k')
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
?m1(?k1 \<mapsto> ?v1) = (\<lambda>k'. if k' = ?k1 then Some ?v1 else ?m1 k')

goal (2 subgoals):
 1. \<lbrakk>foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [(x, z)]) = (case foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x of None \<Rightarrow> foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> {z}) | Some zs \<Rightarrow> foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> insert z zs)); foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x = None\<rbrakk> \<Longrightarrow> foldl (\<lambda>m a. case a of (x, z) \<Rightarrow> case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [xz]) = (\<lambda>x. if \<exists>z. (x, z) \<in> set (xs @ [xz]) then Some {z. (x, z) \<in> set (xs @ [xz])} else None)
 2. \<And>a. \<lbrakk>foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [(x, z)]) = (case foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x of None \<Rightarrow> foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> {z}) | Some zs \<Rightarrow> foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> insert z zs)); foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x = Some a\<rbrakk> \<Longrightarrow> foldl (\<lambda>m a. case a of (x, z) \<Rightarrow> case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [xz]) = (\<lambda>x. if \<exists>z. (x, z) \<in> set (xs @ [xz]) then Some {z. (x, z) \<in> set (xs @ [xz])} else None)
[PROOF STEP]
have m1: "(?f (xs@[(x,z)])) = (\<lambda> x' . if x' = x then Some {z} else (?f xs) x')"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [(x, z)]) = (\<lambda>x'. if x' = x then Some {z} else foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x')
[PROOF STEP]
unfolding **
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> {z}) = (\<lambda>x'. if x' = x then Some {z} else foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x')
[PROOF STEP]
unfolding scheme
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>k'. if k' = x then Some {z} else foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> \<lambda>k'. if k' = x then Some {z} else m k' | Some zs \<Rightarrow> \<lambda>k'. if k' = x then Some (insert z zs) else m k') Map.empty xs k') = (\<lambda>x'. if x' = x then Some {z} else foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> \<lambda>k'. if k' = x then Some {z} else m k' | Some zs \<Rightarrow> \<lambda>k'. if k' = x then Some (insert z zs) else m k') Map.empty xs x')
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [(x, z)]) = (\<lambda>x'. if x' = x then Some {z} else foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x')

goal (2 subgoals):
 1. \<lbrakk>foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [(x, z)]) = (case foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x of None \<Rightarrow> foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> {z}) | Some zs \<Rightarrow> foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> insert z zs)); foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x = None\<rbrakk> \<Longrightarrow> foldl (\<lambda>m a. case a of (x, z) \<Rightarrow> case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [xz]) = (\<lambda>x. if \<exists>z. (x, z) \<in> set (xs @ [xz]) then Some {z. (x, z) \<in> set (xs @ [xz])} else None)
 2. \<And>a. \<lbrakk>foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [(x, z)]) = (case foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x of None \<Rightarrow> foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> {z}) | Some zs \<Rightarrow> foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> insert z zs)); foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x = Some a\<rbrakk> \<Longrightarrow> foldl (\<lambda>m a. case a of (x, z) \<Rightarrow> case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [xz]) = (\<lambda>x. if \<exists>z. (x, z) \<in> set (xs @ [xz]) then Some {z. (x, z) \<in> set (xs @ [xz])} else None)
[PROOF STEP]
have "(\<lambda> x . if (\<exists> z . (x,z) \<in> set xs) then Some {z . (x,z) \<in> set xs} else None) x = None"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if \<exists>z. (x, z) \<in> set xs then Some {z. (x, z) \<in> set xs} else None) = None
[PROOF STEP]
using None snoc
[PROOF STATE]
proof (prove)
using this:
foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x = None
foldl (\<lambda>m a. case a of (x, z) \<Rightarrow> case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs = (\<lambda>x. if \<exists>z. (x, z) \<in> set xs then Some {z. (x, z) \<in> set xs} else None)

goal (1 subgoal):
 1. (if \<exists>z. (x, z) \<in> set xs then Some {z. (x, z) \<in> set xs} else None) = None
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(if \<exists>z. (x, z) \<in> set xs then Some {z. (x, z) \<in> set xs} else None) = None

goal (2 subgoals):
 1. \<lbrakk>foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [(x, z)]) = (case foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x of None \<Rightarrow> foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> {z}) | Some zs \<Rightarrow> foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> insert z zs)); foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x = None\<rbrakk> \<Longrightarrow> foldl (\<lambda>m a. case a of (x, z) \<Rightarrow> case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [xz]) = (\<lambda>x. if \<exists>z. (x, z) \<in> set (xs @ [xz]) then Some {z. (x, z) \<in> set (xs @ [xz])} else None)
 2. \<And>a. \<lbrakk>foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [(x, z)]) = (case foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x of None \<Rightarrow> foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> {z}) | Some zs \<Rightarrow> foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> insert z zs)); foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x = Some a\<rbrakk> \<Longrightarrow> foldl (\<lambda>m a. case a of (x, z) \<Rightarrow> case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [xz]) = (\<lambda>x. if \<exists>z. (x, z) \<in> set (xs @ [xz]) then Some {z. (x, z) \<in> set (xs @ [xz])} else None)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(if \<exists>z. (x, z) \<in> set xs then Some {z. (x, z) \<in> set xs} else None) = None
[PROOF STEP]
have "\<not>(\<exists> z . (x,z) \<in> set xs)"
[PROOF STATE]
proof (prove)
using this:
(if \<exists>z. (x, z) \<in> set xs then Some {z. (x, z) \<in> set xs} else None) = None

goal (1 subgoal):
 1. \<nexists>z. (x, z) \<in> set xs
[PROOF STEP]
by (metis (mono_tags, lifting) option.distinct(1))
[PROOF STATE]
proof (state)
this:
\<nexists>z. (x, z) \<in> set xs

goal (2 subgoals):
 1. \<lbrakk>foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [(x, z)]) = (case foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x of None \<Rightarrow> foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> {z}) | Some zs \<Rightarrow> foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> insert z zs)); foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x = None\<rbrakk> \<Longrightarrow> foldl (\<lambda>m a. case a of (x, z) \<Rightarrow> case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [xz]) = (\<lambda>x. if \<exists>z. (x, z) \<in> set (xs @ [xz]) then Some {z. (x, z) \<in> set (xs @ [xz])} else None)
 2. \<And>a. \<lbrakk>foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [(x, z)]) = (case foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x of None \<Rightarrow> foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> {z}) | Some zs \<Rightarrow> foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> insert z zs)); foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x = Some a\<rbrakk> \<Longrightarrow> foldl (\<lambda>m a. case a of (x, z) \<Rightarrow> case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [xz]) = (\<lambda>x. if \<exists>z. (x, z) \<in> set (xs @ [xz]) then Some {z. (x, z) \<in> set (xs @ [xz])} else None)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<nexists>z. (x, z) \<in> set xs
[PROOF STEP]
have "(\<exists> z . (x,z) \<in> set (xs@[(x,z)]))" and "{z' . (x,z') \<in> set (xs@[(x,z)])} = {z}"
[PROOF STATE]
proof (prove)
using this:
\<nexists>z. (x, z) \<in> set xs

goal (1 subgoal):
 1. \<exists>z. (x, z) \<in> set (xs @ [(x, z)]) &&& {z'. (x, z') \<in> set (xs @ [(x, z)])} = {z}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<exists>z. (x, z) \<in> set (xs @ [(x, z)])
{z'. (x, z') \<in> set (xs @ [(x, z)])} = {z}

goal (2 subgoals):
 1. \<lbrakk>foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [(x, z)]) = (case foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x of None \<Rightarrow> foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> {z}) | Some zs \<Rightarrow> foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> insert z zs)); foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x = None\<rbrakk> \<Longrightarrow> foldl (\<lambda>m a. case a of (x, z) \<Rightarrow> case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [xz]) = (\<lambda>x. if \<exists>z. (x, z) \<in> set (xs @ [xz]) then Some {z. (x, z) \<in> set (xs @ [xz])} else None)
 2. \<And>a. \<lbrakk>foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [(x, z)]) = (case foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x of None \<Rightarrow> foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> {z}) | Some zs \<Rightarrow> foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> insert z zs)); foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x = Some a\<rbrakk> \<Longrightarrow> foldl (\<lambda>m a. case a of (x, z) \<Rightarrow> case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [xz]) = (\<lambda>x. if \<exists>z. (x, z) \<in> set (xs @ [xz]) then Some {z. (x, z) \<in> set (xs @ [xz])} else None)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<exists>z. (x, z) \<in> set (xs @ [(x, z)])
{z'. (x, z') \<in> set (xs @ [(x, z)])} = {z}
[PROOF STEP]
have m2: "(\<lambda> x' . if (\<exists> z' . (x',z') \<in> set (xs@[(x,z)]))
                                then Some {z' . (x',z') \<in> set (xs@[(x,z)])}
                                else None)
                   = (\<lambda> x' . if x' = x
                                then Some {z} else (\<lambda> x . if (\<exists> z . (x,z) \<in> set xs)
                                                            then Some {z . (x,z) \<in> set xs}
                                                            else None) x')"
[PROOF STATE]
proof (prove)
using this:
\<exists>z. (x, z) \<in> set (xs @ [(x, z)])
{z'. (x, z') \<in> set (xs @ [(x, z)])} = {z}

goal (1 subgoal):
 1. (\<lambda>x'. if \<exists>z'. (x', z') \<in> set (xs @ [(x, z)]) then Some {z'. (x', z') \<in> set (xs @ [(x, z)])} else None) = (\<lambda>x'. if x' = x then Some {z} else if \<exists>z. (x', z) \<in> set xs then Some {z. (x', z) \<in> set xs} else None)
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
(\<lambda>x'. if \<exists>z'. (x', z') \<in> set (xs @ [(x, z)]) then Some {z'. (x', z') \<in> set (xs @ [(x, z)])} else None) = (\<lambda>x'. if x' = x then Some {z} else if \<exists>z. (x', z) \<in> set xs then Some {z. (x', z) \<in> set xs} else None)

goal (2 subgoals):
 1. \<lbrakk>foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [(x, z)]) = (case foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x of None \<Rightarrow> foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> {z}) | Some zs \<Rightarrow> foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> insert z zs)); foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x = None\<rbrakk> \<Longrightarrow> foldl (\<lambda>m a. case a of (x, z) \<Rightarrow> case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [xz]) = (\<lambda>x. if \<exists>z. (x, z) \<in> set (xs @ [xz]) then Some {z. (x, z) \<in> set (xs @ [xz])} else None)
 2. \<And>a. \<lbrakk>foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [(x, z)]) = (case foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x of None \<Rightarrow> foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> {z}) | Some zs \<Rightarrow> foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> insert z zs)); foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x = Some a\<rbrakk> \<Longrightarrow> foldl (\<lambda>m a. case a of (x, z) \<Rightarrow> case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [xz]) = (\<lambda>x. if \<exists>z. (x, z) \<in> set (xs @ [xz]) then Some {z. (x, z) \<in> set (xs @ [xz])} else None)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. foldl (\<lambda>m a. case a of (x, z) \<Rightarrow> case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [xz]) = (\<lambda>x. if \<exists>z. (x, z) \<in> set (xs @ [xz]) then Some {z. (x, z) \<in> set (xs @ [xz])} else None)
[PROOF STEP]
using m1 m2 snoc
[PROOF STATE]
proof (prove)
using this:
foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [(x, z)]) = (\<lambda>x'. if x' = x then Some {z} else foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x')
(\<lambda>x'. if \<exists>z'. (x', z') \<in> set (xs @ [(x, z)]) then Some {z'. (x', z') \<in> set (xs @ [(x, z)])} else None) = (\<lambda>x'. if x' = x then Some {z} else if \<exists>z. (x', z) \<in> set xs then Some {z. (x', z) \<in> set xs} else None)
foldl (\<lambda>m a. case a of (x, z) \<Rightarrow> case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs = (\<lambda>x. if \<exists>z. (x, z) \<in> set xs then Some {z. (x, z) \<in> set xs} else None)

goal (1 subgoal):
 1. foldl (\<lambda>m a. case a of (x, z) \<Rightarrow> case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [xz]) = (\<lambda>x. if \<exists>z. (x, z) \<in> set (xs @ [xz]) then Some {z. (x, z) \<in> set (xs @ [xz])} else None)
[PROOF STEP]
using \<open>xz = (x, z)\<close>
[PROOF STATE]
proof (prove)
using this:
foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [(x, z)]) = (\<lambda>x'. if x' = x then Some {z} else foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x')
(\<lambda>x'. if \<exists>z'. (x', z') \<in> set (xs @ [(x, z)]) then Some {z'. (x', z') \<in> set (xs @ [(x, z)])} else None) = (\<lambda>x'. if x' = x then Some {z} else if \<exists>z. (x', z) \<in> set xs then Some {z. (x', z) \<in> set xs} else None)
foldl (\<lambda>m a. case a of (x, z) \<Rightarrow> case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs = (\<lambda>x. if \<exists>z. (x, z) \<in> set xs then Some {z. (x, z) \<in> set xs} else None)
xz = (x, z)

goal (1 subgoal):
 1. foldl (\<lambda>m a. case a of (x, z) \<Rightarrow> case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [xz]) = (\<lambda>x. if \<exists>z. (x, z) \<in> set (xs @ [xz]) then Some {z. (x, z) \<in> set (xs @ [xz])} else None)
[PROOF STEP]
by presburger
[PROOF STATE]
proof (state)
this:
foldl (\<lambda>m a. case a of (x, z) \<Rightarrow> case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [xz]) = (\<lambda>x. if \<exists>z. (x, z) \<in> set (xs @ [xz]) then Some {z. (x, z) \<in> set (xs @ [xz])} else None)

goal (1 subgoal):
 1. \<And>a. \<lbrakk>foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [(x, z)]) = (case foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x of None \<Rightarrow> foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> {z}) | Some zs \<Rightarrow> foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> insert z zs)); foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x = Some a\<rbrakk> \<Longrightarrow> foldl (\<lambda>m a. case a of (x, z) \<Rightarrow> case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [xz]) = (\<lambda>x. if \<exists>z. (x, z) \<in> set (xs @ [xz]) then Some {z. (x, z) \<in> set (xs @ [xz])} else None)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a. \<lbrakk>foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [(x, z)]) = (case foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x of None \<Rightarrow> foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> {z}) | Some zs \<Rightarrow> foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> insert z zs)); foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x = Some a\<rbrakk> \<Longrightarrow> foldl (\<lambda>m a. case a of (x, z) \<Rightarrow> case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [xz]) = (\<lambda>x. if \<exists>z. (x, z) \<in> set (xs @ [xz]) then Some {z. (x, z) \<in> set (xs @ [xz])} else None)
[PROOF STEP]
case (Some zs)
[PROOF STATE]
proof (state)
this:
foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x = Some zs

goal (1 subgoal):
 1. \<And>a. \<lbrakk>foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [(x, z)]) = (case foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x of None \<Rightarrow> foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> {z}) | Some zs \<Rightarrow> foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> insert z zs)); foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x = Some a\<rbrakk> \<Longrightarrow> foldl (\<lambda>m a. case a of (x, z) \<Rightarrow> case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [xz]) = (\<lambda>x. if \<exists>z. (x, z) \<in> set (xs @ [xz]) then Some {z. (x, z) \<in> set (xs @ [xz])} else None)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x = Some zs
[PROOF STEP]
have **: "(?f (xs@[(x,z)])) = (?f xs) (x \<mapsto> (insert z zs))"
[PROOF STATE]
proof (prove)
using this:
foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x = Some zs

goal (1 subgoal):
 1. foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [(x, z)]) = foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> insert z zs)
[PROOF STEP]
using *
[PROOF STATE]
proof (prove)
using this:
foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x = Some zs
foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [(x, z)]) = (case foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x of None \<Rightarrow> foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> {z}) | Some zs \<Rightarrow> foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> insert z zs))

goal (1 subgoal):
 1. foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [(x, z)]) = foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> insert z zs)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [(x, z)]) = foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> insert z zs)

goal (1 subgoal):
 1. \<And>a. \<lbrakk>foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [(x, z)]) = (case foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x of None \<Rightarrow> foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> {z}) | Some zs \<Rightarrow> foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> insert z zs)); foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x = Some a\<rbrakk> \<Longrightarrow> foldl (\<lambda>m a. case a of (x, z) \<Rightarrow> case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [xz]) = (\<lambda>x. if \<exists>z. (x, z) \<in> set (xs @ [xz]) then Some {z. (x, z) \<in> set (xs @ [xz])} else None)
[PROOF STEP]
have scheme: "\<And> m k v . (m(k \<mapsto> v)) = (\<lambda>k' . if k' = k then Some v else m k')"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>m k v. m(k \<mapsto> v) = (\<lambda>k'. if k' = k then Some v else m k')
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
?m1(?k1 \<mapsto> ?v1) = (\<lambda>k'. if k' = ?k1 then Some ?v1 else ?m1 k')

goal (1 subgoal):
 1. \<And>a. \<lbrakk>foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [(x, z)]) = (case foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x of None \<Rightarrow> foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> {z}) | Some zs \<Rightarrow> foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> insert z zs)); foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x = Some a\<rbrakk> \<Longrightarrow> foldl (\<lambda>m a. case a of (x, z) \<Rightarrow> case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [xz]) = (\<lambda>x. if \<exists>z. (x, z) \<in> set (xs @ [xz]) then Some {z. (x, z) \<in> set (xs @ [xz])} else None)
[PROOF STEP]
have m1: "(?f (xs@[(x,z)])) = (\<lambda> x' . if x' = x then Some (insert z zs) else (?f xs) x')"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [(x, z)]) = (\<lambda>x'. if x' = x then Some (insert z zs) else foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x')
[PROOF STEP]
unfolding **
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> insert z zs) = (\<lambda>x'. if x' = x then Some (insert z zs) else foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x')
[PROOF STEP]
unfolding scheme
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>k'. if k' = x then Some (insert z zs) else foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> \<lambda>k'. if k' = x then Some {z} else m k' | Some zs \<Rightarrow> \<lambda>k'. if k' = x then Some (insert z zs) else m k') Map.empty xs k') = (\<lambda>x'. if x' = x then Some (insert z zs) else foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> \<lambda>k'. if k' = x then Some {z} else m k' | Some zs \<Rightarrow> \<lambda>k'. if k' = x then Some (insert z zs) else m k') Map.empty xs x')
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [(x, z)]) = (\<lambda>x'. if x' = x then Some (insert z zs) else foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x')

goal (1 subgoal):
 1. \<And>a. \<lbrakk>foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [(x, z)]) = (case foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x of None \<Rightarrow> foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> {z}) | Some zs \<Rightarrow> foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> insert z zs)); foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x = Some a\<rbrakk> \<Longrightarrow> foldl (\<lambda>m a. case a of (x, z) \<Rightarrow> case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [xz]) = (\<lambda>x. if \<exists>z. (x, z) \<in> set (xs @ [xz]) then Some {z. (x, z) \<in> set (xs @ [xz])} else None)
[PROOF STEP]
have "(\<lambda> x . if (\<exists> z . (x,z) \<in> set xs) then Some {z . (x,z) \<in> set xs} else None) x = Some zs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if \<exists>z. (x, z) \<in> set xs then Some {z. (x, z) \<in> set xs} else None) = Some zs
[PROOF STEP]
using Some snoc
[PROOF STATE]
proof (prove)
using this:
foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x = Some zs
foldl (\<lambda>m a. case a of (x, z) \<Rightarrow> case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs = (\<lambda>x. if \<exists>z. (x, z) \<in> set xs then Some {z. (x, z) \<in> set xs} else None)

goal (1 subgoal):
 1. (if \<exists>z. (x, z) \<in> set xs then Some {z. (x, z) \<in> set xs} else None) = Some zs
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(if \<exists>z. (x, z) \<in> set xs then Some {z. (x, z) \<in> set xs} else None) = Some zs

goal (1 subgoal):
 1. \<And>a. \<lbrakk>foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [(x, z)]) = (case foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x of None \<Rightarrow> foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> {z}) | Some zs \<Rightarrow> foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> insert z zs)); foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x = Some a\<rbrakk> \<Longrightarrow> foldl (\<lambda>m a. case a of (x, z) \<Rightarrow> case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [xz]) = (\<lambda>x. if \<exists>z. (x, z) \<in> set (xs @ [xz]) then Some {z. (x, z) \<in> set (xs @ [xz])} else None)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(if \<exists>z. (x, z) \<in> set xs then Some {z. (x, z) \<in> set xs} else None) = Some zs
[PROOF STEP]
have "(\<exists> z . (x,z) \<in> set xs)"
[PROOF STATE]
proof (prove)
using this:
(if \<exists>z. (x, z) \<in> set xs then Some {z. (x, z) \<in> set xs} else None) = Some zs

goal (1 subgoal):
 1. \<exists>z. (x, z) \<in> set xs
[PROOF STEP]
unfolding case_prod_conv
[PROOF STATE]
proof (prove)
using this:
(if \<exists>z. (x, z) \<in> set xs then Some {z. (x, z) \<in> set xs} else None) = Some zs

goal (1 subgoal):
 1. \<exists>z. (x, z) \<in> set xs
[PROOF STEP]
using  option.distinct(2)
[PROOF STATE]
proof (prove)
using this:
(if \<exists>z. (x, z) \<in> set xs then Some {z. (x, z) \<in> set xs} else None) = Some zs
Some ?x2.0 \<noteq> None

goal (1 subgoal):
 1. \<exists>z. (x, z) \<in> set xs
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
\<exists>z. (x, z) \<in> set xs

goal (1 subgoal):
 1. \<And>a. \<lbrakk>foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [(x, z)]) = (case foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x of None \<Rightarrow> foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> {z}) | Some zs \<Rightarrow> foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> insert z zs)); foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x = Some a\<rbrakk> \<Longrightarrow> foldl (\<lambda>m a. case a of (x, z) \<Rightarrow> case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [xz]) = (\<lambda>x. if \<exists>z. (x, z) \<in> set (xs @ [xz]) then Some {z. (x, z) \<in> set (xs @ [xz])} else None)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<exists>z. (x, z) \<in> set xs
[PROOF STEP]
have "(\<exists> z . (x,z) \<in> set (xs@[(x,z)]))"
[PROOF STATE]
proof (prove)
using this:
\<exists>z. (x, z) \<in> set xs

goal (1 subgoal):
 1. \<exists>z. (x, z) \<in> set (xs @ [(x, z)])
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<exists>z. (x, z) \<in> set (xs @ [(x, z)])

goal (1 subgoal):
 1. \<And>a. \<lbrakk>foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [(x, z)]) = (case foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x of None \<Rightarrow> foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> {z}) | Some zs \<Rightarrow> foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> insert z zs)); foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x = Some a\<rbrakk> \<Longrightarrow> foldl (\<lambda>m a. case a of (x, z) \<Rightarrow> case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [xz]) = (\<lambda>x. if \<exists>z. (x, z) \<in> set (xs @ [xz]) then Some {z. (x, z) \<in> set (xs @ [xz])} else None)
[PROOF STEP]
have "{z' . (x,z') \<in> set (xs@[(x,z)])} = insert z zs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {z'. (x, z') \<in> set (xs @ [(x, z)])} = insert z zs
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. {z'. (x, z') \<in> set (xs @ [(x, z)])} = insert z zs
[PROOF STEP]
have "Some {z . (x,z) \<in> set xs} = Some zs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Some {z. (x, z) \<in> set xs} = Some zs
[PROOF STEP]
using \<open>(\<lambda> x . if (\<exists> z . (x,z) \<in> set xs) then Some {z . (x,z) \<in> set xs} else None) x
                  = Some zs\<close>
[PROOF STATE]
proof (prove)
using this:
(if \<exists>z. (x, z) \<in> set xs then Some {z. (x, z) \<in> set xs} else None) = Some zs

goal (1 subgoal):
 1. Some {z. (x, z) \<in> set xs} = Some zs
[PROOF STEP]
unfolding case_prod_conv
[PROOF STATE]
proof (prove)
using this:
(if \<exists>z. (x, z) \<in> set xs then Some {z. (x, z) \<in> set xs} else None) = Some zs

goal (1 subgoal):
 1. Some {z. (x, z) \<in> set xs} = Some zs
[PROOF STEP]
using  option.distinct(2)
[PROOF STATE]
proof (prove)
using this:
(if \<exists>z. (x, z) \<in> set xs then Some {z. (x, z) \<in> set xs} else None) = Some zs
Some ?x2.0 \<noteq> None

goal (1 subgoal):
 1. Some {z. (x, z) \<in> set xs} = Some zs
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
Some {z. (x, z) \<in> set xs} = Some zs

goal (1 subgoal):
 1. {z'. (x, z') \<in> set (xs @ [(x, z)])} = insert z zs
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
Some {z. (x, z) \<in> set xs} = Some zs
[PROOF STEP]
have "{z . (x,z) \<in> set xs} = zs"
[PROOF STATE]
proof (prove)
using this:
Some {z. (x, z) \<in> set xs} = Some zs

goal (1 subgoal):
 1. {z. (x, z) \<in> set xs} = zs
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
{z. (x, z) \<in> set xs} = zs

goal (1 subgoal):
 1. {z'. (x, z') \<in> set (xs @ [(x, z)])} = insert z zs
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
{z. (x, z) \<in> set xs} = zs
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
{z. (x, z) \<in> set xs} = zs

goal (1 subgoal):
 1. {z'. (x, z') \<in> set (xs @ [(x, z)])} = insert z zs
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
{z'. (x, z') \<in> set (xs @ [(x, z)])} = insert z zs

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
{z'. (x, z') \<in> set (xs @ [(x, z)])} = insert z zs

goal (1 subgoal):
 1. \<And>a. \<lbrakk>foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [(x, z)]) = (case foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x of None \<Rightarrow> foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> {z}) | Some zs \<Rightarrow> foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> insert z zs)); foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x = Some a\<rbrakk> \<Longrightarrow> foldl (\<lambda>m a. case a of (x, z) \<Rightarrow> case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [xz]) = (\<lambda>x. if \<exists>z. (x, z) \<in> set (xs @ [xz]) then Some {z. (x, z) \<in> set (xs @ [xz])} else None)
[PROOF STEP]
have "\<And> a  . (\<lambda> x' . if (\<exists> z' . (x',z') \<in> set (xs@[(x,z)]))
                              then Some {z' . (x',z') \<in> set (xs@[(x,z)])} else None) a
                   = (\<lambda> x' . if x' = x
                              then Some (insert z zs)
                              else (\<lambda> x . if (\<exists> z . (x,z) \<in> set xs)
                                            then Some {z . (x,z) \<in> set xs} else None) x') a"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>a. (if \<exists>z'. (a, z') \<in> set (xs @ [(x, z)]) then Some {z'. (a, z') \<in> set (xs @ [(x, z)])} else None) = (if a = x then Some (insert z zs) else if \<exists>z. (a, z) \<in> set xs then Some {z. (a, z) \<in> set xs} else None)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a. (if \<exists>z'. (a, z') \<in> set (xs @ [(x, z)]) then Some {z'. (a, z') \<in> set (xs @ [(x, z)])} else None) = (if a = x then Some (insert z zs) else if \<exists>z. (a, z) \<in> set xs then Some {z. (a, z) \<in> set xs} else None)
[PROOF STEP]
fix a
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a. (if \<exists>z'. (a, z') \<in> set (xs @ [(x, z)]) then Some {z'. (a, z') \<in> set (xs @ [(x, z)])} else None) = (if a = x then Some (insert z zs) else if \<exists>z. (a, z) \<in> set xs then Some {z. (a, z) \<in> set xs} else None)
[PROOF STEP]
show "(\<lambda> x' . if (\<exists> z' . (x',z') \<in> set (xs@[(x,z)]))
                              then Some {z' . (x',z') \<in> set (xs@[(x,z)])} else None) a
                   = (\<lambda> x' . if x' = x
                              then Some (insert z zs)
                              else (\<lambda> x . if (\<exists> z . (x,z) \<in> set xs)
                                            then Some {z . (x,z) \<in> set xs} else None) x') a"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if \<exists>z'. (a, z') \<in> set (xs @ [(x, z)]) then Some {z'. (a, z') \<in> set (xs @ [(x, z)])} else None) = (if a = x then Some (insert z zs) else if \<exists>z. (a, z) \<in> set xs then Some {z. (a, z) \<in> set xs} else None)
[PROOF STEP]
using \<open>{z' . (x,z') \<in> set (xs@[(x,z)])} = insert z zs\<close> \<open>(\<exists> z . (x,z) \<in> set (xs@[(x,z)]))\<close>
[PROOF STATE]
proof (prove)
using this:
{z'. (x, z') \<in> set (xs @ [(x, z)])} = insert z zs
\<exists>z. (x, z) \<in> set (xs @ [(x, z)])

goal (1 subgoal):
 1. (if \<exists>z'. (a, z') \<in> set (xs @ [(x, z)]) then Some {z'. (a, z') \<in> set (xs @ [(x, z)])} else None) = (if a = x then Some (insert z zs) else if \<exists>z. (a, z) \<in> set xs then Some {z. (a, z) \<in> set xs} else None)
[PROOF STEP]
by (cases "a = x"; auto)
[PROOF STATE]
proof (state)
this:
(if \<exists>z'. (a, z') \<in> set (xs @ [(x, z)]) then Some {z'. (a, z') \<in> set (xs @ [(x, z)])} else None) = (if a = x then Some (insert z zs) else if \<exists>z. (a, z) \<in> set xs then Some {z. (a, z) \<in> set xs} else None)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(if \<exists>z'. (?a2, z') \<in> set (xs @ [(x, z)]) then Some {z'. (?a2, z') \<in> set (xs @ [(x, z)])} else None) = (if ?a2 = x then Some (insert z zs) else if \<exists>z. (?a2, z) \<in> set xs then Some {z. (?a2, z) \<in> set xs} else None)

goal (1 subgoal):
 1. \<And>a. \<lbrakk>foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [(x, z)]) = (case foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x of None \<Rightarrow> foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> {z}) | Some zs \<Rightarrow> foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> insert z zs)); foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x = Some a\<rbrakk> \<Longrightarrow> foldl (\<lambda>m a. case a of (x, z) \<Rightarrow> case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [xz]) = (\<lambda>x. if \<exists>z. (x, z) \<in> set (xs @ [xz]) then Some {z. (x, z) \<in> set (xs @ [xz])} else None)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(if \<exists>z'. (?a2, z') \<in> set (xs @ [(x, z)]) then Some {z'. (?a2, z') \<in> set (xs @ [(x, z)])} else None) = (if ?a2 = x then Some (insert z zs) else if \<exists>z. (?a2, z) \<in> set xs then Some {z. (?a2, z) \<in> set xs} else None)
[PROOF STEP]
have m2: "(\<lambda> x' . if (\<exists> z' . (x',z') \<in> set (xs@[(x,z)]))
                                then Some {z' . (x',z') \<in> set (xs@[(x,z)])} else None)
                   = (\<lambda> x' . if x' = x
                                then Some (insert z zs)
                                else (\<lambda> x . if (\<exists> z . (x,z) \<in> set xs)
                                              then Some {z . (x,z) \<in> set xs} else None) x')"
[PROOF STATE]
proof (prove)
using this:
(if \<exists>z'. (?a2, z') \<in> set (xs @ [(x, z)]) then Some {z'. (?a2, z') \<in> set (xs @ [(x, z)])} else None) = (if ?a2 = x then Some (insert z zs) else if \<exists>z. (?a2, z) \<in> set xs then Some {z. (?a2, z) \<in> set xs} else None)

goal (1 subgoal):
 1. (\<lambda>x'. if \<exists>z'. (x', z') \<in> set (xs @ [(x, z)]) then Some {z'. (x', z') \<in> set (xs @ [(x, z)])} else None) = (\<lambda>x'. if x' = x then Some (insert z zs) else if \<exists>z. (x', z) \<in> set xs then Some {z. (x', z) \<in> set xs} else None)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<lambda>x'. if \<exists>z'. (x', z') \<in> set (xs @ [(x, z)]) then Some {z'. (x', z') \<in> set (xs @ [(x, z)])} else None) = (\<lambda>x'. if x' = x then Some (insert z zs) else if \<exists>z. (x', z) \<in> set xs then Some {z. (x', z) \<in> set xs} else None)

goal (1 subgoal):
 1. \<And>a. \<lbrakk>foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [(x, z)]) = (case foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x of None \<Rightarrow> foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> {z}) | Some zs \<Rightarrow> foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs(x \<mapsto> insert z zs)); foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x = Some a\<rbrakk> \<Longrightarrow> foldl (\<lambda>m a. case a of (x, z) \<Rightarrow> case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [xz]) = (\<lambda>x. if \<exists>z. (x, z) \<in> set (xs @ [xz]) then Some {z. (x, z) \<in> set (xs @ [xz])} else None)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. foldl (\<lambda>m a. case a of (x, z) \<Rightarrow> case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [xz]) = (\<lambda>x. if \<exists>z. (x, z) \<in> set (xs @ [xz]) then Some {z. (x, z) \<in> set (xs @ [xz])} else None)
[PROOF STEP]
using m1 m2 snoc
[PROOF STATE]
proof (prove)
using this:
foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [(x, z)]) = (\<lambda>x'. if x' = x then Some (insert z zs) else foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x')
(\<lambda>x'. if \<exists>z'. (x', z') \<in> set (xs @ [(x, z)]) then Some {z'. (x', z') \<in> set (xs @ [(x, z)])} else None) = (\<lambda>x'. if x' = x then Some (insert z zs) else if \<exists>z. (x', z) \<in> set xs then Some {z. (x', z) \<in> set xs} else None)
foldl (\<lambda>m a. case a of (x, z) \<Rightarrow> case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs = (\<lambda>x. if \<exists>z. (x, z) \<in> set xs then Some {z. (x, z) \<in> set xs} else None)

goal (1 subgoal):
 1. foldl (\<lambda>m a. case a of (x, z) \<Rightarrow> case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [xz]) = (\<lambda>x. if \<exists>z. (x, z) \<in> set (xs @ [xz]) then Some {z. (x, z) \<in> set (xs @ [xz])} else None)
[PROOF STEP]
using \<open>xz = (x, z)\<close>
[PROOF STATE]
proof (prove)
using this:
foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [(x, z)]) = (\<lambda>x'. if x' = x then Some (insert z zs) else foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs x')
(\<lambda>x'. if \<exists>z'. (x', z') \<in> set (xs @ [(x, z)]) then Some {z'. (x', z') \<in> set (xs @ [(x, z)])} else None) = (\<lambda>x'. if x' = x then Some (insert z zs) else if \<exists>z. (x', z) \<in> set xs then Some {z. (x', z) \<in> set xs} else None)
foldl (\<lambda>m a. case a of (x, z) \<Rightarrow> case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs = (\<lambda>x. if \<exists>z. (x, z) \<in> set xs then Some {z. (x, z) \<in> set xs} else None)
xz = (x, z)

goal (1 subgoal):
 1. foldl (\<lambda>m a. case a of (x, z) \<Rightarrow> case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [xz]) = (\<lambda>x. if \<exists>z. (x, z) \<in> set (xs @ [xz]) then Some {z. (x, z) \<in> set (xs @ [xz])} else None)
[PROOF STEP]
by presburger
[PROOF STATE]
proof (state)
this:
foldl (\<lambda>m a. case a of (x, z) \<Rightarrow> case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [xz]) = (\<lambda>x. if \<exists>z. (x, z) \<in> set (xs @ [xz]) then Some {z. (x, z) \<in> set (xs @ [xz])} else None)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
foldl (\<lambda>m a. case a of (x, z) \<Rightarrow> case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty (xs @ [xz]) = (\<lambda>x. if \<exists>z. (x, z) \<in> set (xs @ [xz]) then Some {z. (x, z) \<in> set (xs @ [xz])} else None)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs = (\<lambda>x. if \<exists>z. (x, z) \<in> set xs then Some {z. (x, z) \<in> set xs} else None)

goal (1 subgoal):
 1. set_as_map (set xs) = foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs = (\<lambda>x. if \<exists>z. (x, z) \<in> set xs then Some {z. (x, z) \<in> set xs} else None)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs = (\<lambda>x. if \<exists>z. (x, z) \<in> set xs then Some {z. (x, z) \<in> set xs} else None)

goal (1 subgoal):
 1. set_as_map (set xs) = foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs
[PROOF STEP]
unfolding set_as_map_def
[PROOF STATE]
proof (prove)
using this:
foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs = (\<lambda>x. if \<exists>z. (x, z) \<in> set xs then Some {z. (x, z) \<in> set xs} else None)

goal (1 subgoal):
 1. (\<lambda>x. if \<exists>z. (x, z) \<in> set xs then Some {z. (x, z) \<in> set xs} else None) = foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
set_as_map (set xs) = foldl (\<lambda>m (x, z). case m x of None \<Rightarrow> m(x \<mapsto> {z}) | Some zs \<Rightarrow> m(x \<mapsto> insert z zs)) Map.empty xs

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma interleave_not_empty: "a\<otimes>b ~= {}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a \<otimes> b \<noteq> {}
[PROOF STEP]
apply(induct rule: interleave.induct)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. \<And>b. [] \<otimes> b \<noteq> {}
 2. \<And>a. a \<otimes> [] \<noteq> {}
 3. \<And>a l b r. \<lbrakk>l \<otimes> b # r \<noteq> {}; a # l \<otimes> r \<noteq> {}\<rbrakk> \<Longrightarrow> a # l \<otimes> b # r \<noteq> {}
[PROOF STEP]
apply(auto)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma undirected_nodes_set: "set (edgesL (undirected G)) = set (edgesL G) \<union> {(e2, e1). (e1, e2) \<in> set (edgesL G)}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set (edgesL (FiniteListGraph.undirected G)) = set (edgesL G) \<union> {(e2, e1). (e1, e2) \<in> set (edgesL G)}
[PROOF STEP]
unfolding undirected_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set (edgesL \<lparr>nodesL = nodesL G, edgesL = remdups (edgesL G @ backlinks (edgesL G))\<rparr>) = set (edgesL G) \<union> {(e2, e1). (e1, e2) \<in> set (edgesL G)}
[PROOF STEP]
by (simp add: backlinks_set)


[STATEMENT]
lemma piecewise_C1_differentiable_compose [derivative_intros]:
  assumes fg: "f piecewise_C1_differentiable_on S" "g piecewise_C1_differentiable_on (f ` S)" and fin: "\<And>x. finite (S \<inter> f-`{x})"
  shows "(g \<circ> f) piecewise_C1_differentiable_on S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. g \<circ> f piecewise_C1_differentiable_on S
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. g \<circ> f piecewise_C1_differentiable_on S
[PROOF STEP]
have "continuous_on S (\<lambda>x. g (f x))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. continuous_on S (\<lambda>x. g (f x))
[PROOF STEP]
by (metis continuous_on_compose2 fg order_refl piecewise_C1_differentiable_on_def)
[PROOF STATE]
proof (state)
this:
continuous_on S (\<lambda>x. g (f x))

goal (1 subgoal):
 1. g \<circ> f piecewise_C1_differentiable_on S
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
continuous_on S (\<lambda>x. g (f x))

goal (1 subgoal):
 1. g \<circ> f piecewise_C1_differentiable_on S
[PROOF STEP]
have "\<exists>T. finite T \<and> g \<circ> f C1_differentiable_on S - T"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>T. finite T \<and> g \<circ> f C1_differentiable_on S - T
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>T. finite T \<and> g \<circ> f C1_differentiable_on S - T
[PROOF STEP]
obtain F where "finite F" and F: "f C1_differentiable_on S - F" and f: "f piecewise_C1_differentiable_on S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>F. \<lbrakk>finite F; f C1_differentiable_on S - F; f piecewise_C1_differentiable_on S\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using fg
[PROOF STATE]
proof (prove)
using this:
f piecewise_C1_differentiable_on S
g piecewise_C1_differentiable_on f ` S

goal (1 subgoal):
 1. (\<And>F. \<lbrakk>finite F; f C1_differentiable_on S - F; f piecewise_C1_differentiable_on S\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (auto simp: piecewise_C1_differentiable_on_def)
[PROOF STATE]
proof (state)
this:
finite F
f C1_differentiable_on S - F
f piecewise_C1_differentiable_on S

goal (1 subgoal):
 1. \<exists>T. finite T \<and> g \<circ> f C1_differentiable_on S - T
[PROOF STEP]
obtain G where "finite G" and G: "g C1_differentiable_on f ` S - G" and g: "g piecewise_C1_differentiable_on f ` S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>G. \<lbrakk>finite G; g C1_differentiable_on f ` S - G; g piecewise_C1_differentiable_on f ` S\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using fg
[PROOF STATE]
proof (prove)
using this:
f piecewise_C1_differentiable_on S
g piecewise_C1_differentiable_on f ` S

goal (1 subgoal):
 1. (\<And>G. \<lbrakk>finite G; g C1_differentiable_on f ` S - G; g piecewise_C1_differentiable_on f ` S\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (auto simp: piecewise_C1_differentiable_on_def)
[PROOF STATE]
proof (state)
this:
finite G
g C1_differentiable_on f ` S - G
g piecewise_C1_differentiable_on f ` S

goal (1 subgoal):
 1. \<exists>T. finite T \<and> g \<circ> f C1_differentiable_on S - T
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>T. finite T \<and> g \<circ> f C1_differentiable_on S - T
[PROOF STEP]
proof (intro exI conjI)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. finite ?T
 2. g \<circ> f C1_differentiable_on S - ?T
[PROOF STEP]
show "finite (F \<union> (\<Union>x\<in>G. S \<inter> f-`{x}))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite (F \<union> (\<Union>x\<in>G. S \<inter> f -` {x}))
[PROOF STEP]
using fin
[PROOF STATE]
proof (prove)
using this:
finite (S \<inter> f -` {?x})

goal (1 subgoal):
 1. finite (F \<union> (\<Union>x\<in>G. S \<inter> f -` {x}))
[PROOF STEP]
by (auto simp only: Int_Union \<open>finite F\<close> \<open>finite G\<close> finite_UN finite_imageI)
[PROOF STATE]
proof (state)
this:
finite (F \<union> (\<Union>x\<in>G. S \<inter> f -` {x}))

goal (1 subgoal):
 1. g \<circ> f C1_differentiable_on S - (F \<union> (\<Union>x\<in>G. S \<inter> f -` {x}))
[PROOF STEP]
show "g \<circ> f C1_differentiable_on S - (F \<union> (\<Union>x\<in>G. S \<inter> f -` {x}))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. g \<circ> f C1_differentiable_on S - (F \<union> (\<Union>x\<in>G. S \<inter> f -` {x}))
[PROOF STEP]
apply (rule C1_differentiable_compose)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. f C1_differentiable_on S - (F \<union> (\<Union>x\<in>G. S \<inter> f -` {x}))
 2. g C1_differentiable_on f ` (S - (F \<union> (\<Union>x\<in>G. S \<inter> f -` {x})))
 3. \<And>x. finite ((S - (F \<union> (\<Union>x\<in>G. S \<inter> f -` {x}))) \<inter> f -` {x})
[PROOF STEP]
apply (blast intro: C1_differentiable_on_subset [OF F])
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. g C1_differentiable_on f ` (S - (F \<union> (\<Union>x\<in>G. S \<inter> f -` {x})))
 2. \<And>x. finite ((S - (F \<union> (\<Union>x\<in>G. S \<inter> f -` {x}))) \<inter> f -` {x})
[PROOF STEP]
apply (blast intro: C1_differentiable_on_subset [OF G])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. finite ((S - (F \<union> (\<Union>x\<in>G. S \<inter> f -` {x}))) \<inter> f -` {x})
[PROOF STEP]
by (simp add:  C1_differentiable_on_subset G Diff_Int_distrib2 fin)
[PROOF STATE]
proof (state)
this:
g \<circ> f C1_differentiable_on S - (F \<union> (\<Union>x\<in>G. S \<inter> f -` {x}))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<exists>T. finite T \<and> g \<circ> f C1_differentiable_on S - T

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<exists>T. finite T \<and> g \<circ> f C1_differentiable_on S - T

goal (1 subgoal):
 1. g \<circ> f piecewise_C1_differentiable_on S
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
continuous_on S (\<lambda>x. g (f x))
\<exists>T. finite T \<and> g \<circ> f C1_differentiable_on S - T
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
continuous_on S (\<lambda>x. g (f x))
\<exists>T. finite T \<and> g \<circ> f C1_differentiable_on S - T

goal (1 subgoal):
 1. g \<circ> f piecewise_C1_differentiable_on S
[PROOF STEP]
by (simp add: piecewise_C1_differentiable_on_def)
[PROOF STATE]
proof (state)
this:
g \<circ> f piecewise_C1_differentiable_on S

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma lfilter_lmap: "lfilter P (lmap f xs) = lmap f (lfilter (P o f) xs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. lfilter P (lmap f xs) = lmap f (lfilter (P \<circ> f) xs)
[PROOF STEP]
by(induct xs) simp_all


[STATEMENT]
lemma nonneg_matpow: "0 \<le> X \<Longrightarrow> 0 \<le> matpow (X :: real ^ _ ^ _) i"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 \<le> X \<Longrightarrow> 0 \<le> matpow X i
[PROOF STEP]
by (induction i) (auto simp: nonneg_matrix_mult)


[STATEMENT]
lemma inverse_fps_of_nat:
  "inverse (of_nat n :: 'a :: {semiring_1,times,uminus,inverse} fps) =
    fps_const (inverse (of_nat n))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inverse (of_nat n) = fps_const (inverse (of_nat n))
[PROOF STEP]
by (simp add: fps_of_nat fps_const_inverse[symmetric])


[STATEMENT]
lemma no_sbintr_alt2: "(signed_take_bit :: nat \<Rightarrow> int \<Rightarrow> int) n = (\<lambda>w. (w + 2 ^ n) mod 2 ^ Suc n - 2 ^ n :: int)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. signed_take_bit n = (\<lambda>w. (w + 2 ^ n) mod 2 ^ Suc n - 2 ^ n)
[PROOF STEP]
by (rule ext) (simp add : sbintrunc_mod2p)


[STATEMENT]
lemma subset_interval_imp_cart:
  fixes a :: "real^'n"
  shows "(\<forall>i. a$i \<le> c$i \<and> d$i \<le> b$i) \<Longrightarrow> cbox c d \<subseteq> cbox a b"
    and "(\<forall>i. a$i < c$i \<and> d$i < b$i) \<Longrightarrow> cbox c d \<subseteq> box a b"
    and "(\<forall>i. a$i \<le> c$i \<and> d$i \<le> b$i) \<Longrightarrow> box c d \<subseteq> cbox a b"
    and "(\<forall>i. a$i \<le> c$i \<and> d$i \<le> b$i) \<Longrightarrow> box c d \<subseteq> box a b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<forall>i. a $ i \<le> c $ i \<and> d $ i \<le> b $ i \<Longrightarrow> cbox c d \<subseteq> cbox a b) &&& (\<forall>i. a $ i < c $ i \<and> d $ i < b $ i \<Longrightarrow> cbox c d \<subseteq> box a b)) &&& (\<forall>i. a $ i \<le> c $ i \<and> d $ i \<le> b $ i \<Longrightarrow> box c d \<subseteq> cbox a b) &&& (\<forall>i. a $ i \<le> c $ i \<and> d $ i \<le> b $ i \<Longrightarrow> box c d \<subseteq> box a b)
[PROOF STEP]
unfolding subset_eq[unfolded Ball_def]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<forall>i. a $ i \<le> c $ i \<and> d $ i \<le> b $ i \<Longrightarrow> \<forall>x. x \<in> cbox c d \<longrightarrow> x \<in> cbox a b) &&& (\<forall>i. a $ i < c $ i \<and> d $ i < b $ i \<Longrightarrow> \<forall>x. x \<in> cbox c d \<longrightarrow> x \<in> box a b)) &&& (\<forall>i. a $ i \<le> c $ i \<and> d $ i \<le> b $ i \<Longrightarrow> \<forall>x. x \<in> box c d \<longrightarrow> x \<in> cbox a b) &&& (\<forall>i. a $ i \<le> c $ i \<and> d $ i \<le> b $ i \<Longrightarrow> \<forall>x. x \<in> box c d \<longrightarrow> x \<in> box a b)
[PROOF STEP]
unfolding mem_box_cart
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<forall>i. a $ i \<le> c $ i \<and> d $ i \<le> b $ i \<Longrightarrow> \<forall>x. (\<forall>i. c $ i \<le> x $ i \<and> x $ i \<le> d $ i) \<longrightarrow> (\<forall>i. a $ i \<le> x $ i \<and> x $ i \<le> b $ i)) &&& (\<forall>i. a $ i < c $ i \<and> d $ i < b $ i \<Longrightarrow> \<forall>x. (\<forall>i. c $ i \<le> x $ i \<and> x $ i \<le> d $ i) \<longrightarrow> (\<forall>i. a $ i < x $ i \<and> x $ i < b $ i))) &&& (\<forall>i. a $ i \<le> c $ i \<and> d $ i \<le> b $ i \<Longrightarrow> \<forall>x. (\<forall>i. c $ i < x $ i \<and> x $ i < d $ i) \<longrightarrow> (\<forall>i. a $ i \<le> x $ i \<and> x $ i \<le> b $ i)) &&& (\<forall>i. a $ i \<le> c $ i \<and> d $ i \<le> b $ i \<Longrightarrow> \<forall>x. (\<forall>i. c $ i < x $ i \<and> x $ i < d $ i) \<longrightarrow> (\<forall>i. a $ i < x $ i \<and> x $ i < b $ i))
[PROOF STEP]
by (auto intro: order_trans less_le_trans le_less_trans less_imp_le)


[STATEMENT]
lemma path_lverts_simps1_sucs:
  "\<lbrakk>x \<notin> set (root t1); sucs t1 = {|(t2,e2)|}\<rbrakk>
    \<Longrightarrow> set (root t1) \<union> path_lverts t2 x = path_lverts t1 x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>x \<notin> set (dtree.root t1); sucs t1 = {|(t2, e2)|}\<rbrakk> \<Longrightarrow> set (dtree.root t1) \<union> path_lverts t2 x = path_lverts t1 x
[PROOF STEP]
using path_lverts.simps(1)[of "root t1" t2 e2 x] dtree.exhaust_sel[of t1]
[PROOF STATE]
proof (prove)
using this:
path_lverts (Node (dtree.root t1) {|(t2, e2)|}) x = (if x \<in> set (dtree.root t1) then {} else set (dtree.root t1) \<union> path_lverts t2 x)
(t1 = Node (dtree.root t1) (sucs t1) \<Longrightarrow> ?P) \<Longrightarrow> ?P

goal (1 subgoal):
 1. \<lbrakk>x \<notin> set (dtree.root t1); sucs t1 = {|(t2, e2)|}\<rbrakk> \<Longrightarrow> set (dtree.root t1) \<union> path_lverts t2 x = path_lverts t1 x
[PROOF STEP]
by argo


[STATEMENT]
lemma dense_pairs:
  "dense_pairs = { (x,y) . x = top \<and> is_principal_up_filter y }"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {(x, y). (x, y) \<in> pairs \<and> pairs_uminus (x, y) = pairs_bot} = {(x, y). x = top \<and> (\<exists>ya. y = up_filter ya)}
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. {(x, y). (x, y) \<in> pairs \<and> pairs_uminus (x, y) = pairs_bot} = {(x, y). x = top \<and> (\<exists>ya. y = up_filter ya)}
[PROOF STEP]
have "dense_pairs = { (x,y) . (x,y) \<in> pairs \<and> x = top }"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {(x, y). (x, y) \<in> pairs \<and> pairs_uminus (x, y) = pairs_bot} = {(x, y). (x, y) \<in> pairs \<and> x = top}
[PROOF STEP]
by (metis Pair_inject compl_bot_eq double_compl pairs_uminus.simps phi_top)
[PROOF STATE]
proof (state)
this:
{(x, y). (x, y) \<in> pairs \<and> pairs_uminus (x, y) = pairs_bot} = {(x, y). (x, y) \<in> pairs \<and> x = top}

goal (1 subgoal):
 1. {(x, y). (x, y) \<in> pairs \<and> pairs_uminus (x, y) = pairs_bot} = {(x, y). x = top \<and> (\<exists>ya. y = up_filter ya)}
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
{(x, y). (x, y) \<in> pairs \<and> pairs_uminus (x, y) = pairs_bot} = {(x, y). (x, y) \<in> pairs \<and> x = top}

goal (1 subgoal):
 1. {(x, y). (x, y) \<in> pairs \<and> pairs_uminus (x, y) = pairs_bot} = {(x, y). x = top \<and> (\<exists>ya. y = up_filter ya)}
[PROOF STEP]
have "... = { (x,y) . (\<exists>z . y = up_filter z) \<and> x = top }"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {(x, y). (x, y) \<in> pairs \<and> x = top} = {(x, y). (\<exists>z. y = up_filter z) \<and> x = top}
[PROOF STEP]
using hom pairs_def
[PROOF STATE]
proof (prove)
using this:
bounded_lattice_homomorphism phi
pairs = {(x, y). \<exists>z. y = phi (- x) \<squnion> up_filter z}

goal (1 subgoal):
 1. {(x, y). (x, y) \<in> pairs \<and> x = top} = {(x, y). (\<exists>z. y = up_filter z) \<and> x = top}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
{(x, y). (x, y) \<in> pairs \<and> x = top} = {(x, y). (\<exists>z. y = up_filter z) \<and> x = top}

goal (1 subgoal):
 1. {(x, y). (x, y) \<in> pairs \<and> pairs_uminus (x, y) = pairs_bot} = {(x, y). x = top \<and> (\<exists>ya. y = up_filter ya)}
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
{(x, y). (x, y) \<in> pairs \<and> pairs_uminus (x, y) = pairs_bot} = {(x, y). (\<exists>z. y = up_filter z) \<and> x = top}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
{(x, y). (x, y) \<in> pairs \<and> pairs_uminus (x, y) = pairs_bot} = {(x, y). (\<exists>z. y = up_filter z) \<and> x = top}

goal (1 subgoal):
 1. {(x, y). (x, y) \<in> pairs \<and> pairs_uminus (x, y) = pairs_bot} = {(x, y). x = top \<and> (\<exists>ya. y = up_filter ya)}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
{(x, y). (x, y) \<in> pairs \<and> pairs_uminus (x, y) = pairs_bot} = {(x, y). x = top \<and> (\<exists>ya. y = up_filter ya)}

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma Suc_5_induct:
  "\<lbrakk>i < Suc (Suc (Suc (Suc (Suc 0)))); i = 0 \<Longrightarrow> P 0;
  i = 1 \<Longrightarrow> P 1; i = 2 \<Longrightarrow> P 2; i = 3 \<Longrightarrow> P 3; i = 4 \<Longrightarrow> P 4\<rbrakk> \<Longrightarrow> P i"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>i < Suc (Suc (Suc (Suc (Suc 0)))); i = 0 \<Longrightarrow> P 0; i = 1 \<Longrightarrow> P 1; i = 2 \<Longrightarrow> P 2; i = 3 \<Longrightarrow> P 3; i = 4 \<Longrightarrow> P 4\<rbrakk> \<Longrightarrow> P i
[PROOF STEP]
apply(cases i, force)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>nat. \<lbrakk>i < Suc (Suc (Suc (Suc (Suc 0)))); i = 0 \<Longrightarrow> P 0; i = 1 \<Longrightarrow> P 1; i = 2 \<Longrightarrow> P 2; i = 3 \<Longrightarrow> P 3; i = 4 \<Longrightarrow> P 4; i = Suc nat\<rbrakk> \<Longrightarrow> P i
[PROOF STEP]
apply(cases "i-1", force)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>nat nata. \<lbrakk>i < Suc (Suc (Suc (Suc (Suc 0)))); i = 0 \<Longrightarrow> P 0; i = 1 \<Longrightarrow> P 1; i = 2 \<Longrightarrow> P 2; i = 3 \<Longrightarrow> P 3; i = 4 \<Longrightarrow> P 4; i = Suc nat; i - 1 = Suc nata\<rbrakk> \<Longrightarrow> P i
[PROOF STEP]
apply(cases "i-1-1")
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>nat nata. \<lbrakk>i < Suc (Suc (Suc (Suc (Suc 0)))); i = 0 \<Longrightarrow> P 0; i = 1 \<Longrightarrow> P 1; i = 2 \<Longrightarrow> P 2; i = 3 \<Longrightarrow> P 3; i = 4 \<Longrightarrow> P 4; i = Suc nat; i - 1 = Suc nata; i - 1 - 1 = 0\<rbrakk> \<Longrightarrow> P i
 2. \<And>nat nata natb. \<lbrakk>i < Suc (Suc (Suc (Suc (Suc 0)))); i = 0 \<Longrightarrow> P 0; i = 1 \<Longrightarrow> P 1; i = 2 \<Longrightarrow> P 2; i = 3 \<Longrightarrow> P 3; i = 4 \<Longrightarrow> P 4; i = Suc nat; i - 1 = Suc nata; i - 1 - 1 = Suc natb\<rbrakk> \<Longrightarrow> P i
[PROOF STEP]
using less_2_cases numeral_eqs_upto_12
[PROOF STATE]
proof (prove)
using this:
?n < 2 \<Longrightarrow> ?n = 0 \<or> ?n = Suc 0
2 = Suc 1
3 = Suc 2
4 = Suc 3
5 = Suc 4
6 = Suc 5
7 = Suc 6
8 = Suc 7
9 = Suc 8
10 = Suc 9
11 = Suc 10
12 = Suc 11

goal (2 subgoals):
 1. \<And>nat nata. \<lbrakk>i < Suc (Suc (Suc (Suc (Suc 0)))); i = 0 \<Longrightarrow> P 0; i = 1 \<Longrightarrow> P 1; i = 2 \<Longrightarrow> P 2; i = 3 \<Longrightarrow> P 3; i = 4 \<Longrightarrow> P 4; i = Suc nat; i - 1 = Suc nata; i - 1 - 1 = 0\<rbrakk> \<Longrightarrow> P i
 2. \<And>nat nata natb. \<lbrakk>i < Suc (Suc (Suc (Suc (Suc 0)))); i = 0 \<Longrightarrow> P 0; i = 1 \<Longrightarrow> P 1; i = 2 \<Longrightarrow> P 2; i = 3 \<Longrightarrow> P 3; i = 4 \<Longrightarrow> P 4; i = Suc nat; i - 1 = Suc nata; i - 1 - 1 = Suc natb\<rbrakk> \<Longrightarrow> P i
[PROOF STEP]
by auto