[STATEMENT]
lemma mset_set_mset_image:
  shows "\<And> E. card E = N \<Longrightarrow> finite E \<Longrightarrow> mset_set (g ` E) \<subseteq>#  {# (g x). x \<in># mset_set (E) #}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>E. \<lbrakk>card E = N; finite E\<rbrakk> \<Longrightarrow> mset_set (g ` E) \<subseteq># image_mset g (mset_set E)
[PROOF STEP]
proof (induction N)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>E. \<lbrakk>card E = 0; finite E\<rbrakk> \<Longrightarrow> mset_set (g ` E) \<subseteq># image_mset g (mset_set E)
 2. \<And>N E. \<lbrakk>\<And>E. \<lbrakk>card E = N; finite E\<rbrakk> \<Longrightarrow> mset_set (g ` E) \<subseteq># image_mset g (mset_set E); card E = Suc N; finite E\<rbrakk> \<Longrightarrow> mset_set (g ` E) \<subseteq># image_mset g (mset_set E)
[PROOF STEP]
case 0
[PROOF STATE]
proof (state)
this:
card E = 0
finite E

goal (2 subgoals):
 1. \<And>E. \<lbrakk>card E = 0; finite E\<rbrakk> \<Longrightarrow> mset_set (g ` E) \<subseteq># image_mset g (mset_set E)
 2. \<And>N E. \<lbrakk>\<And>E. \<lbrakk>card E = N; finite E\<rbrakk> \<Longrightarrow> mset_set (g ` E) \<subseteq># image_mset g (mset_set E); card E = Suc N; finite E\<rbrakk> \<Longrightarrow> mset_set (g ` E) \<subseteq># image_mset g (mset_set E)
[PROOF STEP]
assume "card E = 0"
[PROOF STATE]
proof (state)
this:
card E = 0

goal (2 subgoals):
 1. \<And>E. \<lbrakk>card E = 0; finite E\<rbrakk> \<Longrightarrow> mset_set (g ` E) \<subseteq># image_mset g (mset_set E)
 2. \<And>N E. \<lbrakk>\<And>E. \<lbrakk>card E = N; finite E\<rbrakk> \<Longrightarrow> mset_set (g ` E) \<subseteq># image_mset g (mset_set E); card E = Suc N; finite E\<rbrakk> \<Longrightarrow> mset_set (g ` E) \<subseteq># image_mset g (mset_set E)
[PROOF STEP]
assume "finite E"
[PROOF STATE]
proof (state)
this:
finite E

goal (2 subgoals):
 1. \<And>E. \<lbrakk>card E = 0; finite E\<rbrakk> \<Longrightarrow> mset_set (g ` E) \<subseteq># image_mset g (mset_set E)
 2. \<And>N E. \<lbrakk>\<And>E. \<lbrakk>card E = N; finite E\<rbrakk> \<Longrightarrow> mset_set (g ` E) \<subseteq># image_mset g (mset_set E); card E = Suc N; finite E\<rbrakk> \<Longrightarrow> mset_set (g ` E) \<subseteq># image_mset g (mset_set E)
[PROOF STEP]
from this and \<open>card E = 0\<close>
[PROOF STATE]
proof (chain)
picking this:
finite E
card E = 0
[PROOF STEP]
have "E = {}"
[PROOF STATE]
proof (prove)
using this:
finite E
card E = 0

goal (1 subgoal):
 1. E = {}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
E = {}

goal (2 subgoals):
 1. \<And>E. \<lbrakk>card E = 0; finite E\<rbrakk> \<Longrightarrow> mset_set (g ` E) \<subseteq># image_mset g (mset_set E)
 2. \<And>N E. \<lbrakk>\<And>E. \<lbrakk>card E = N; finite E\<rbrakk> \<Longrightarrow> mset_set (g ` E) \<subseteq># image_mset g (mset_set E); card E = Suc N; finite E\<rbrakk> \<Longrightarrow> mset_set (g ` E) \<subseteq># image_mset g (mset_set E)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
E = {}
[PROOF STEP]
show "mset_set (g ` E) \<subseteq>#  {# (g x). x \<in># mset_set (E) #}"
[PROOF STATE]
proof (prove)
using this:
E = {}

goal (1 subgoal):
 1. mset_set (g ` E) \<subseteq># image_mset g (mset_set E)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
mset_set (g ` E) \<subseteq># image_mset g (mset_set E)

goal (1 subgoal):
 1. \<And>N E. \<lbrakk>\<And>E. \<lbrakk>card E = N; finite E\<rbrakk> \<Longrightarrow> mset_set (g ` E) \<subseteq># image_mset g (mset_set E); card E = Suc N; finite E\<rbrakk> \<Longrightarrow> mset_set (g ` E) \<subseteq># image_mset g (mset_set E)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>N E. \<lbrakk>\<And>E. \<lbrakk>card E = N; finite E\<rbrakk> \<Longrightarrow> mset_set (g ` E) \<subseteq># image_mset g (mset_set E); card E = Suc N; finite E\<rbrakk> \<Longrightarrow> mset_set (g ` E) \<subseteq># image_mset g (mset_set E)
[PROOF STEP]
case (Suc N)
[PROOF STATE]
proof (state)
this:
\<lbrakk>card ?E = N; finite ?E\<rbrakk> \<Longrightarrow> mset_set (g ` ?E) \<subseteq># image_mset g (mset_set ?E)
card E = Suc N
finite E

goal (1 subgoal):
 1. \<And>N E. \<lbrakk>\<And>E. \<lbrakk>card E = N; finite E\<rbrakk> \<Longrightarrow> mset_set (g ` E) \<subseteq># image_mset g (mset_set E); card E = Suc N; finite E\<rbrakk> \<Longrightarrow> mset_set (g ` E) \<subseteq># image_mset g (mset_set E)
[PROOF STEP]
assume "card E = (Suc N)"
[PROOF STATE]
proof (state)
this:
card E = Suc N

goal (1 subgoal):
 1. \<And>N E. \<lbrakk>\<And>E. \<lbrakk>card E = N; finite E\<rbrakk> \<Longrightarrow> mset_set (g ` E) \<subseteq># image_mset g (mset_set E); card E = Suc N; finite E\<rbrakk> \<Longrightarrow> mset_set (g ` E) \<subseteq># image_mset g (mset_set E)
[PROOF STEP]
assume "finite E"
[PROOF STATE]
proof (state)
this:
finite E

goal (1 subgoal):
 1. \<And>N E. \<lbrakk>\<And>E. \<lbrakk>card E = N; finite E\<rbrakk> \<Longrightarrow> mset_set (g ` E) \<subseteq># image_mset g (mset_set E); card E = Suc N; finite E\<rbrakk> \<Longrightarrow> mset_set (g ` E) \<subseteq># image_mset g (mset_set E)
[PROOF STEP]
from this and \<open>card E = (Suc N)\<close>
[PROOF STATE]
proof (chain)
picking this:
finite E
card E = Suc N
[PROOF STEP]
have "E \<noteq> {}"
[PROOF STATE]
proof (prove)
using this:
finite E
card E = Suc N

goal (1 subgoal):
 1. E \<noteq> {}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
E \<noteq> {}

goal (1 subgoal):
 1. \<And>N E. \<lbrakk>\<And>E. \<lbrakk>card E = N; finite E\<rbrakk> \<Longrightarrow> mset_set (g ` E) \<subseteq># image_mset g (mset_set E); card E = Suc N; finite E\<rbrakk> \<Longrightarrow> mset_set (g ` E) \<subseteq># image_mset g (mset_set E)
[PROOF STEP]
from this
[PROOF STATE]
proof (chain)
picking this:
E \<noteq> {}
[PROOF STEP]
obtain x where "x \<in> E"
[PROOF STATE]
proof (prove)
using this:
E \<noteq> {}

goal (1 subgoal):
 1. (\<And>x. x \<in> E \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
x \<in> E

goal (1 subgoal):
 1. \<And>N E. \<lbrakk>\<And>E. \<lbrakk>card E = N; finite E\<rbrakk> \<Longrightarrow> mset_set (g ` E) \<subseteq># image_mset g (mset_set E); card E = Suc N; finite E\<rbrakk> \<Longrightarrow> mset_set (g ` E) \<subseteq># image_mset g (mset_set E)
[PROOF STEP]
let ?E = "E - { x }"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>N E. \<lbrakk>\<And>E. \<lbrakk>card E = N; finite E\<rbrakk> \<Longrightarrow> mset_set (g ` E) \<subseteq># image_mset g (mset_set E); card E = Suc N; finite E\<rbrakk> \<Longrightarrow> mset_set (g ` E) \<subseteq># image_mset g (mset_set E)
[PROOF STEP]
from \<open>finite E\<close> \<open>card E = (Suc N)\<close> and \<open>x \<in> E\<close>
[PROOF STATE]
proof (chain)
picking this:
finite E
card E = Suc N
x \<in> E
[PROOF STEP]
have "card ?E = N"
[PROOF STATE]
proof (prove)
using this:
finite E
card E = Suc N
x \<in> E

goal (1 subgoal):
 1. card (E - {x}) = N
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
card (E - {x}) = N

goal (1 subgoal):
 1. \<And>N E. \<lbrakk>\<And>E. \<lbrakk>card E = N; finite E\<rbrakk> \<Longrightarrow> mset_set (g ` E) \<subseteq># image_mset g (mset_set E); card E = Suc N; finite E\<rbrakk> \<Longrightarrow> mset_set (g ` E) \<subseteq># image_mset g (mset_set E)
[PROOF STEP]
from \<open>finite E\<close>
[PROOF STATE]
proof (chain)
picking this:
finite E
[PROOF STEP]
have "finite ?E"
[PROOF STATE]
proof (prove)
using this:
finite E

goal (1 subgoal):
 1. finite (E - {x})
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
finite (E - {x})

goal (1 subgoal):
 1. \<And>N E. \<lbrakk>\<And>E. \<lbrakk>card E = N; finite E\<rbrakk> \<Longrightarrow> mset_set (g ` E) \<subseteq># image_mset g (mset_set E); card E = Suc N; finite E\<rbrakk> \<Longrightarrow> mset_set (g ` E) \<subseteq># image_mset g (mset_set E)
[PROOF STEP]
from this and "Suc.IH" [of ?E] and \<open>card ?E = N\<close>
[PROOF STATE]
proof (chain)
picking this:
finite (E - {x})
\<lbrakk>card (E - {x}) = N; finite (E - {x})\<rbrakk> \<Longrightarrow> mset_set (g ` (E - {x})) \<subseteq># image_mset g (mset_set (E - {x}))
card (E - {x}) = N
[PROOF STEP]
have ind: "mset_set (g ` ?E) \<subseteq>#  {# (g x). x \<in># mset_set (?E) #}"
[PROOF STATE]
proof (prove)
using this:
finite (E - {x})
\<lbrakk>card (E - {x}) = N; finite (E - {x})\<rbrakk> \<Longrightarrow> mset_set (g ` (E - {x})) \<subseteq># image_mset g (mset_set (E - {x}))
card (E - {x}) = N

goal (1 subgoal):
 1. mset_set (g ` (E - {x})) \<subseteq># image_mset g (mset_set (E - {x}))
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
mset_set (g ` (E - {x})) \<subseteq># image_mset g (mset_set (E - {x}))

goal (1 subgoal):
 1. \<And>N E. \<lbrakk>\<And>E. \<lbrakk>card E = N; finite E\<rbrakk> \<Longrightarrow> mset_set (g ` E) \<subseteq># image_mset g (mset_set E); card E = Suc N; finite E\<rbrakk> \<Longrightarrow> mset_set (g ` E) \<subseteq># image_mset g (mset_set E)
[PROOF STEP]
from \<open>x \<in> E\<close>
[PROOF STATE]
proof (chain)
picking this:
x \<in> E
[PROOF STEP]
have "E = ?E \<union> { x }"
[PROOF STATE]
proof (prove)
using this:
x \<in> E

goal (1 subgoal):
 1. E = E - {x} \<union> {x}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
E = E - {x} \<union> {x}

goal (1 subgoal):
 1. \<And>N E. \<lbrakk>\<And>E. \<lbrakk>card E = N; finite E\<rbrakk> \<Longrightarrow> mset_set (g ` E) \<subseteq># image_mset g (mset_set E); card E = Suc N; finite E\<rbrakk> \<Longrightarrow> mset_set (g ` E) \<subseteq># image_mset g (mset_set E)
[PROOF STEP]
have "x \<notin> ?E"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<notin> E - {x}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
x \<notin> E - {x}

goal (1 subgoal):
 1. \<And>N E. \<lbrakk>\<And>E. \<lbrakk>card E = N; finite E\<rbrakk> \<Longrightarrow> mset_set (g ` E) \<subseteq># image_mset g (mset_set E); card E = Suc N; finite E\<rbrakk> \<Longrightarrow> mset_set (g ` E) \<subseteq># image_mset g (mset_set E)
[PROOF STEP]
from \<open>finite ?E\<close> \<open>E = ?E \<union> { x }\<close> and \<open>x \<notin> ?E\<close>
[PROOF STATE]
proof (chain)
picking this:
finite (E - {x})
E = E - {x} \<union> {x}
x \<notin> E - {x}
[PROOF STEP]
have "mset_set (?E \<union> { x }) = mset_set ?E + {# x #}"
[PROOF STATE]
proof (prove)
using this:
finite (E - {x})
E = E - {x} \<union> {x}
x \<notin> E - {x}

goal (1 subgoal):
 1. mset_set (E - {x} \<union> {x}) = mset_set (E - {x}) + {#x#}
[PROOF STEP]
using mset_set_insert [of x ?E]
[PROOF STATE]
proof (prove)
using this:
finite (E - {x})
E = E - {x} \<union> {x}
x \<notin> E - {x}
\<lbrakk>x \<notin> E - {x}; finite (E - {x})\<rbrakk> \<Longrightarrow> mset_set (E - {x} \<union> {x}) = mset_set (E - {x}) + {#x#}

goal (1 subgoal):
 1. mset_set (E - {x} \<union> {x}) = mset_set (E - {x}) + {#x#}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
mset_set (E - {x} \<union> {x}) = mset_set (E - {x}) + {#x#}

goal (1 subgoal):
 1. \<And>N E. \<lbrakk>\<And>E. \<lbrakk>card E = N; finite E\<rbrakk> \<Longrightarrow> mset_set (g ` E) \<subseteq># image_mset g (mset_set E); card E = Suc N; finite E\<rbrakk> \<Longrightarrow> mset_set (g ` E) \<subseteq># image_mset g (mset_set E)
[PROOF STEP]
from this
[PROOF STATE]
proof (chain)
picking this:
mset_set (E - {x} \<union> {x}) = mset_set (E - {x}) + {#x#}
[PROOF STEP]
have
    "{# (g x). x \<in># mset_set (?E \<union> { x }) #} = {# (g x). x \<in># mset_set ?E #} + {# (g x) #}"
[PROOF STATE]
proof (prove)
using this:
mset_set (E - {x} \<union> {x}) = mset_set (E - {x}) + {#x#}

goal (1 subgoal):
 1. image_mset g (mset_set (E - {x} \<union> {x})) = image_mset g (mset_set (E - {x})) + {#g x#}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
image_mset g (mset_set (E - {x} \<union> {x})) = image_mset g (mset_set (E - {x})) + {#g x#}

goal (1 subgoal):
 1. \<And>N E. \<lbrakk>\<And>E. \<lbrakk>card E = N; finite E\<rbrakk> \<Longrightarrow> mset_set (g ` E) \<subseteq># image_mset g (mset_set E); card E = Suc N; finite E\<rbrakk> \<Longrightarrow> mset_set (g ` E) \<subseteq># image_mset g (mset_set E)
[PROOF STEP]
have "(g ` (?E \<union> { x }) = (g ` ?E) \<union> { g x })"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. g ` (E - {x} \<union> {x}) = g ` (E - {x}) \<union> {g x}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
g ` (E - {x} \<union> {x}) = g ` (E - {x}) \<union> {g x}

goal (1 subgoal):
 1. \<And>N E. \<lbrakk>\<And>E. \<lbrakk>card E = N; finite E\<rbrakk> \<Longrightarrow> mset_set (g ` E) \<subseteq># image_mset g (mset_set E); card E = Suc N; finite E\<rbrakk> \<Longrightarrow> mset_set (g ` E) \<subseteq># image_mset g (mset_set E)
[PROOF STEP]
from this
[PROOF STATE]
proof (chain)
picking this:
g ` (E - {x} \<union> {x}) = g ` (E - {x}) \<union> {g x}
[PROOF STEP]
have i: "mset_set (g ` (?E \<union> { x })) = mset_set ( (g ` ?E) \<union> { g x } )"
[PROOF STATE]
proof (prove)
using this:
g ` (E - {x} \<union> {x}) = g ` (E - {x}) \<union> {g x}

goal (1 subgoal):
 1. mset_set (g ` (E - {x} \<union> {x})) = mset_set (g ` (E - {x}) \<union> {g x})
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
mset_set (g ` (E - {x} \<union> {x})) = mset_set (g ` (E - {x}) \<union> {g x})

goal (1 subgoal):
 1. \<And>N E. \<lbrakk>\<And>E. \<lbrakk>card E = N; finite E\<rbrakk> \<Longrightarrow> mset_set (g ` E) \<subseteq># image_mset g (mset_set E); card E = Suc N; finite E\<rbrakk> \<Longrightarrow> mset_set (g ` E) \<subseteq># image_mset g (mset_set E)
[PROOF STEP]
from \<open>finite ?E\<close>
[PROOF STATE]
proof (chain)
picking this:
finite (E - {x})
[PROOF STEP]
have "finite (g ` ?E)"
[PROOF STATE]
proof (prove)
using this:
finite (E - {x})

goal (1 subgoal):
 1. finite (g ` (E - {x}))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
finite (g ` (E - {x}))

goal (1 subgoal):
 1. \<And>N E. \<lbrakk>\<And>E. \<lbrakk>card E = N; finite E\<rbrakk> \<Longrightarrow> mset_set (g ` E) \<subseteq># image_mset g (mset_set E); card E = Suc N; finite E\<rbrakk> \<Longrightarrow> mset_set (g ` E) \<subseteq># image_mset g (mset_set E)
[PROOF STEP]
from this
[PROOF STATE]
proof (chain)
picking this:
finite (g ` (E - {x}))
[PROOF STEP]
have "mset_set ( (g ` ?E) \<union> { g x } ) \<subseteq># mset_set (g ` ?E) + {# (g x) #}"
[PROOF STATE]
proof (prove)
using this:
finite (g ` (E - {x}))

goal (1 subgoal):
 1. mset_set (g ` (E - {x}) \<union> {g x}) \<subseteq># mset_set (g ` (E - {x})) + {#g x#}
[PROOF STEP]
using  mset_set_insert_eq [of "(g ` ?E)" "(g x)" ]
[PROOF STATE]
proof (prove)
using this:
finite (g ` (E - {x}))
finite (g ` (E - {x})) \<Longrightarrow> mset_set (g ` (E - {x}) \<union> {g x}) \<subseteq># mset_set (g ` (E - {x})) + {#g x#}

goal (1 subgoal):
 1. mset_set (g ` (E - {x}) \<union> {g x}) \<subseteq># mset_set (g ` (E - {x})) + {#g x#}
[PROOF STEP]
by meson
[PROOF STATE]
proof (state)
this:
mset_set (g ` (E - {x}) \<union> {g x}) \<subseteq># mset_set (g ` (E - {x})) + {#g x#}

goal (1 subgoal):
 1. \<And>N E. \<lbrakk>\<And>E. \<lbrakk>card E = N; finite E\<rbrakk> \<Longrightarrow> mset_set (g ` E) \<subseteq># image_mset g (mset_set E); card E = Suc N; finite E\<rbrakk> \<Longrightarrow> mset_set (g ` E) \<subseteq># image_mset g (mset_set E)
[PROOF STEP]
from this i
[PROOF STATE]
proof (chain)
picking this:
mset_set (g ` (E - {x}) \<union> {g x}) \<subseteq># mset_set (g ` (E - {x})) + {#g x#}
mset_set (g ` (E - {x} \<union> {x})) = mset_set (g ` (E - {x}) \<union> {g x})
[PROOF STEP]
have ii: "mset_set (g ` (?E \<union> { x })) \<subseteq># mset_set (g ` ?E) + {# (g x) #}"
[PROOF STATE]
proof (prove)
using this:
mset_set (g ` (E - {x}) \<union> {g x}) \<subseteq># mset_set (g ` (E - {x})) + {#g x#}
mset_set (g ` (E - {x} \<union> {x})) = mset_set (g ` (E - {x}) \<union> {g x})

goal (1 subgoal):
 1. mset_set (g ` (E - {x} \<union> {x})) \<subseteq># mset_set (g ` (E - {x})) + {#g x#}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
mset_set (g ` (E - {x} \<union> {x})) \<subseteq># mset_set (g ` (E - {x})) + {#g x#}

goal (1 subgoal):
 1. \<And>N E. \<lbrakk>\<And>E. \<lbrakk>card E = N; finite E\<rbrakk> \<Longrightarrow> mset_set (g ` E) \<subseteq># image_mset g (mset_set E); card E = Suc N; finite E\<rbrakk> \<Longrightarrow> mset_set (g ` E) \<subseteq># image_mset g (mset_set E)
[PROOF STEP]
from ind
[PROOF STATE]
proof (chain)
picking this:
mset_set (g ` (E - {x})) \<subseteq># image_mset g (mset_set (E - {x}))
[PROOF STEP]
have "mset_set (g ` ?E) + {# (g x) #} \<subseteq>#  {# (g x). x \<in># mset_set (?E) #} + {# (g x) #}"
[PROOF STATE]
proof (prove)
using this:
mset_set (g ` (E - {x})) \<subseteq># image_mset g (mset_set (E - {x}))

goal (1 subgoal):
 1. mset_set (g ` (E - {x})) + {#g x#} \<subseteq># image_mset g (mset_set (E - {x})) + {#g x#}
[PROOF STEP]
using Multiset.subset_mset.add_right_mono
[PROOF STATE]
proof (prove)
using this:
mset_set (g ` (E - {x})) \<subseteq># image_mset g (mset_set (E - {x}))
?a \<subseteq># ?b \<Longrightarrow> ?a + ?c \<subseteq># ?b + ?c

goal (1 subgoal):
 1. mset_set (g ` (E - {x})) + {#g x#} \<subseteq># image_mset g (mset_set (E - {x})) + {#g x#}
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
mset_set (g ` (E - {x})) + {#g x#} \<subseteq># image_mset g (mset_set (E - {x})) + {#g x#}

goal (1 subgoal):
 1. \<And>N E. \<lbrakk>\<And>E. \<lbrakk>card E = N; finite E\<rbrakk> \<Longrightarrow> mset_set (g ` E) \<subseteq># image_mset g (mset_set E); card E = Suc N; finite E\<rbrakk> \<Longrightarrow> mset_set (g ` E) \<subseteq># image_mset g (mset_set E)
[PROOF STEP]
from this and ii
[PROOF STATE]
proof (chain)
picking this:
mset_set (g ` (E - {x})) + {#g x#} \<subseteq># image_mset g (mset_set (E - {x})) + {#g x#}
mset_set (g ` (E - {x} \<union> {x})) \<subseteq># mset_set (g ` (E - {x})) + {#g x#}
[PROOF STEP]
have "mset_set (g ` (?E \<union> { x })) \<subseteq># {# (g x). x \<in># mset_set (?E) #} + {# (g x) #}"
[PROOF STATE]
proof (prove)
using this:
mset_set (g ` (E - {x})) + {#g x#} \<subseteq># image_mset g (mset_set (E - {x})) + {#g x#}
mset_set (g ` (E - {x} \<union> {x})) \<subseteq># mset_set (g ` (E - {x})) + {#g x#}

goal (1 subgoal):
 1. mset_set (g ` (E - {x} \<union> {x})) \<subseteq># image_mset g (mset_set (E - {x})) + {#g x#}
[PROOF STEP]
using subset_mset.trans [of "mset_set (g ` (?E \<union> { x }))" ]
[PROOF STATE]
proof (prove)
using this:
mset_set (g ` (E - {x})) + {#g x#} \<subseteq># image_mset g (mset_set (E - {x})) + {#g x#}
mset_set (g ` (E - {x} \<union> {x})) \<subseteq># mset_set (g ` (E - {x})) + {#g x#}
\<lbrakk>mset_set (g ` (E - {x} \<union> {x})) \<subseteq># ?b; ?b \<subseteq># ?c\<rbrakk> \<Longrightarrow> mset_set (g ` (E - {x} \<union> {x})) \<subseteq># ?c

goal (1 subgoal):
 1. mset_set (g ` (E - {x} \<union> {x})) \<subseteq># image_mset g (mset_set (E - {x})) + {#g x#}
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
mset_set (g ` (E - {x} \<union> {x})) \<subseteq># image_mset g (mset_set (E - {x})) + {#g x#}

goal (1 subgoal):
 1. \<And>N E. \<lbrakk>\<And>E. \<lbrakk>card E = N; finite E\<rbrakk> \<Longrightarrow> mset_set (g ` E) \<subseteq># image_mset g (mset_set E); card E = Suc N; finite E\<rbrakk> \<Longrightarrow> mset_set (g ` E) \<subseteq># image_mset g (mset_set E)
[PROOF STEP]
from this and \<open>E = ?E \<union> { x }\<close> \<open>{# (g x). x \<in># mset_set (?E \<union> { x }) #} = {# (g x). x \<in># mset_set ?E #} + {# (g x) #}\<close>
[PROOF STATE]
proof (chain)
picking this:
mset_set (g ` (E - {x} \<union> {x})) \<subseteq># image_mset g (mset_set (E - {x})) + {#g x#}
E = E - {x} \<union> {x}
image_mset g (mset_set (E - {x} \<union> {x})) = image_mset g (mset_set (E - {x})) + {#g x#}
[PROOF STEP]
show "mset_set (g ` E) \<subseteq># {# (g x). x \<in># mset_set E #}"
[PROOF STATE]
proof (prove)
using this:
mset_set (g ` (E - {x} \<union> {x})) \<subseteq># image_mset g (mset_set (E - {x})) + {#g x#}
E = E - {x} \<union> {x}
image_mset g (mset_set (E - {x} \<union> {x})) = image_mset g (mset_set (E - {x})) + {#g x#}

goal (1 subgoal):
 1. mset_set (g ` E) \<subseteq># image_mset g (mset_set E)
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
mset_set (g ` E) \<subseteq># image_mset g (mset_set E)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma rsa_inv_set_spmf_I:
  assumes "((N, e), d) \<in> set_spmf I"
  shows "((((x::nat) ^ e) mod N) ^ d) mod N = x mod N"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (x ^ e mod N) ^ d mod N = x mod N
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (x ^ e mod N) ^ d mod N = x mod N
[PROOF STEP]
obtain P Q where "N = P * Q" and "d = nat (fst (bezw e ((P-1)*(Q-1))) mod int ((P-1)*(Q-1)))"
    and "prime P"
    and "prime Q"
    and "coprime e ((P - 1)*(Q - 1))"
    and "P \<noteq> Q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>P Q. \<lbrakk>N = P * Q; d = nat (fst (bezw e ((P - 1) * (Q - 1))) mod int ((P - 1) * (Q - 1))); prime P; prime Q; coprime e ((P - 1) * (Q - 1)); P \<noteq> Q\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using assms set_spmf_I_N
[PROOF STATE]
proof (prove)
using this:
((N, e), d) \<in> set_spmf I
\<lbrakk>((?N, ?e), ?d) \<in> set_spmf I; \<And>P Q. \<lbrakk>?N = P * Q; P \<noteq> Q; prime P; prime Q; coprime ?e ((P - 1) * (Q - 1)); ?d = nat (fst (bezw ?e ((P - 1) * (Q - 1))) mod int ((P - 1) * (Q - 1)))\<rbrakk> \<Longrightarrow> ?thesis\<rbrakk> \<Longrightarrow> ?thesis

goal (1 subgoal):
 1. (\<And>P Q. \<lbrakk>N = P * Q; d = nat (fst (bezw e ((P - 1) * (Q - 1))) mod int ((P - 1) * (Q - 1))); prime P; prime Q; coprime e ((P - 1) * (Q - 1)); P \<noteq> Q\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
N = P * Q
d = nat (fst (bezw e ((P - 1) * (Q - 1))) mod int ((P - 1) * (Q - 1)))
prime P
prime Q
coprime e ((P - 1) * (Q - 1))
P \<noteq> Q

goal (1 subgoal):
 1. (x ^ e mod N) ^ d mod N = x mod N
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
N = P * Q
d = nat (fst (bezw e ((P - 1) * (Q - 1))) mod int ((P - 1) * (Q - 1)))
prime P
prime Q
coprime e ((P - 1) * (Q - 1))
P \<noteq> Q

goal (1 subgoal):
 1. (x ^ e mod N) ^ d mod N = x mod N
[PROOF STEP]
have "e > 1" and "d > 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 < e &&& 1 < d
[PROOF STEP]
using set_spmf_I_e_d assms
[PROOF STATE]
proof (prove)
using this:
((?N, ?e), ?d) \<in> set_spmf I \<Longrightarrow> 1 < ?e
((?N, ?e), ?d) \<in> set_spmf I \<Longrightarrow> 1 < ?d
((N, e), d) \<in> set_spmf I

goal (1 subgoal):
 1. 1 < e &&& 1 < d
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
1 < e
1 < d

goal (1 subgoal):
 1. (x ^ e mod N) ^ d mod N = x mod N
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
N = P * Q
d = nat (fst (bezw e ((P - 1) * (Q - 1))) mod int ((P - 1) * (Q - 1)))
prime P
prime Q
coprime e ((P - 1) * (Q - 1))
P \<noteq> Q
1 < e
1 < d
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
N = P * Q
d = nat (fst (bezw e ((P - 1) * (Q - 1))) mod int ((P - 1) * (Q - 1)))
prime P
prime Q
coprime e ((P - 1) * (Q - 1))
P \<noteq> Q
1 < e
1 < d

goal (1 subgoal):
 1. (x ^ e mod N) ^ d mod N = x mod N
[PROOF STEP]
using rsa_inv
[PROOF STATE]
proof (prove)
using this:
N = P * Q
d = nat (fst (bezw e ((P - 1) * (Q - 1))) mod int ((P - 1) * (Q - 1)))
prime P
prime Q
coprime e ((P - 1) * (Q - 1))
P \<noteq> Q
1 < e
1 < d
\<lbrakk>?d = nat (fst (bezw ?e ((?P - 1) * (?Q - 1))) mod int ((?P - 1) * (?Q - 1))); coprime ?e ((?P - 1) * (?Q - 1)); prime ?P; prime ?Q; ?P \<noteq> ?Q; 1 < ?e; 1 < ?d\<rbrakk> \<Longrightarrow> (?x ^ ?e mod (?P * ?Q)) ^ ?d mod (?P * ?Q) = ?x mod (?P * ?Q)

goal (1 subgoal):
 1. (x ^ e mod N) ^ d mod N = x mod N
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
(x ^ e mod N) ^ d mod N = x mod N

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
theorem omega_exists: "\<exists> \<omega> ::(('a::prime_card) mod_ring) .
                              \<omega>^n = 1 \<and> \<omega> \<noteq> 1 \<and> (\<forall> m. \<omega>^m = 1 \<and> m\<noteq>0 \<longrightarrow> m \<ge> n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>\<omega>. \<omega> ^ n = 1 \<and> \<omega> \<noteq> 1 \<and> (\<forall>m. \<omega> ^ m = 1 \<and> m \<noteq> 0 \<longrightarrow> n \<le> m)
[PROOF STEP]
using omega_properties_ex
[PROOF STATE]
proof (prove)
using this:
(\<And>\<omega>. \<lbrakk>\<omega> ^ n = 1; \<omega> \<noteq> 1; \<forall>m. \<omega> ^ m = 1 \<and> m \<noteq> 0 \<longrightarrow> n \<le> m\<rbrakk> \<Longrightarrow> ?thesis) \<Longrightarrow> ?thesis

goal (1 subgoal):
 1. \<exists>\<omega>. \<omega> ^ n = 1 \<and> \<omega> \<noteq> 1 \<and> (\<forall>m. \<omega> ^ m = 1 \<and> m \<noteq> 0 \<longrightarrow> n \<le> m)
[PROOF STEP]
by metis


[STATEMENT]
lemma choose_alternating_sum:
  "n > 0 \<Longrightarrow> (\<Sum>i\<le>n. (-1)^i * of_nat (n choose i)) = (0 :: 'a::comm_ring_1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < n \<Longrightarrow> (\<Sum>i\<le>n. (- (1::'a)) ^ i * of_nat (n choose i)) = (0::'a)
[PROOF STEP]
using binomial_ring[of "-1 :: 'a" 1 n]
[PROOF STATE]
proof (prove)
using this:
(- (1::'a) + (1::'a)) ^ n = (\<Sum>k\<le>n. of_nat (n choose k) * (- (1::'a)) ^ k * (1::'a) ^ (n - k))

goal (1 subgoal):
 1. 0 < n \<Longrightarrow> (\<Sum>i\<le>n. (- (1::'a)) ^ i * of_nat (n choose i)) = (0::'a)
[PROOF STEP]
by (simp add: atLeast0AtMost mult_of_nat_commute zero_power)


[STATEMENT]
lemma card_UNIV_finfun:
  defines "F == finfun :: ('a \<Rightarrow> 'b) set"
  shows "CARD('a \<Rightarrow>f 'b) = (if CARD('a) \<noteq> 0 \<and> CARD('b) \<noteq> 0 \<or> CARD('b) = 1 then CARD('b) ^ CARD('a) else 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. CARD('a \<Rightarrow>f 'b) = (if CARD('a) \<noteq> 0 \<and> CARD('b) \<noteq> 0 \<or> CARD('b) = 1 then CARD('b) ^ CARD('a) else 0)
[PROOF STEP]
proof(cases "0 < CARD('a) \<and> 0 < CARD('b) \<or> CARD('b) = 1")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. 0 < CARD('a) \<and> 0 < CARD('b) \<or> CARD('b) = 1 \<Longrightarrow> CARD('a \<Rightarrow>f 'b) = (if CARD('a) \<noteq> 0 \<and> CARD('b) \<noteq> 0 \<or> CARD('b) = 1 then CARD('b) ^ CARD('a) else 0)
 2. \<not> (0 < CARD('a) \<and> 0 < CARD('b) \<or> CARD('b) = 1) \<Longrightarrow> CARD('a \<Rightarrow>f 'b) = (if CARD('a) \<noteq> 0 \<and> CARD('b) \<noteq> 0 \<or> CARD('b) = 1 then CARD('b) ^ CARD('a) else 0)
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
0 < CARD('a) \<and> 0 < CARD('b) \<or> CARD('b) = 1

goal (2 subgoals):
 1. 0 < CARD('a) \<and> 0 < CARD('b) \<or> CARD('b) = 1 \<Longrightarrow> CARD('a \<Rightarrow>f 'b) = (if CARD('a) \<noteq> 0 \<and> CARD('b) \<noteq> 0 \<or> CARD('b) = 1 then CARD('b) ^ CARD('a) else 0)
 2. \<not> (0 < CARD('a) \<and> 0 < CARD('b) \<or> CARD('b) = 1) \<Longrightarrow> CARD('a \<Rightarrow>f 'b) = (if CARD('a) \<noteq> 0 \<and> CARD('b) \<noteq> 0 \<or> CARD('b) = 1 then CARD('b) ^ CARD('a) else 0)
[PROOF STEP]
from True
[PROOF STATE]
proof (chain)
picking this:
0 < CARD('a) \<and> 0 < CARD('b) \<or> CARD('b) = 1
[PROOF STEP]
have "F = UNIV"
[PROOF STATE]
proof (prove)
using this:
0 < CARD('a) \<and> 0 < CARD('b) \<or> CARD('b) = 1

goal (1 subgoal):
 1. F = UNIV
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. 0 < CARD('a) \<and> 0 < CARD('b) \<Longrightarrow> F = UNIV
 2. CARD('b) = 1 \<Longrightarrow> F = UNIV
[PROOF STEP]
assume b: "CARD('b) = 1"
[PROOF STATE]
proof (state)
this:
CARD('b) = 1

goal (2 subgoals):
 1. 0 < CARD('a) \<and> 0 < CARD('b) \<Longrightarrow> F = UNIV
 2. CARD('b) = 1 \<Longrightarrow> F = UNIV
[PROOF STEP]
hence "\<forall>x :: 'b. x = undefined"
[PROOF STATE]
proof (prove)
using this:
CARD('b) = 1

goal (1 subgoal):
 1. \<forall>x. x = undefined
[PROOF STEP]
by(auto simp add: card_eq_1_iff simp del: One_nat_def)
[PROOF STATE]
proof (state)
this:
\<forall>x. x = undefined

goal (2 subgoals):
 1. 0 < CARD('a) \<and> 0 < CARD('b) \<Longrightarrow> F = UNIV
 2. CARD('b) = 1 \<Longrightarrow> F = UNIV
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
\<forall>x. x = undefined

goal (1 subgoal):
 1. F = UNIV
[PROOF STEP]
by(auto simp add: finfun_def F_def intro: exI[where x=undefined])
[PROOF STATE]
proof (state)
this:
F = UNIV

goal (1 subgoal):
 1. 0 < CARD('a) \<and> 0 < CARD('b) \<Longrightarrow> F = UNIV
[PROOF STEP]
qed(auto simp add: finfun_def card_gt_0_iff F_def intro: finite_subset[where B=UNIV])
[PROOF STATE]
proof (state)
this:
F = UNIV

goal (2 subgoals):
 1. 0 < CARD('a) \<and> 0 < CARD('b) \<or> CARD('b) = 1 \<Longrightarrow> CARD('a \<Rightarrow>f 'b) = (if CARD('a) \<noteq> 0 \<and> CARD('b) \<noteq> 0 \<or> CARD('b) = 1 then CARD('b) ^ CARD('a) else 0)
 2. \<not> (0 < CARD('a) \<and> 0 < CARD('b) \<or> CARD('b) = 1) \<Longrightarrow> CARD('a \<Rightarrow>f 'b) = (if CARD('a) \<noteq> 0 \<and> CARD('b) \<noteq> 0 \<or> CARD('b) = 1 then CARD('b) ^ CARD('a) else 0)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
F = UNIV

goal (2 subgoals):
 1. 0 < CARD('a) \<and> 0 < CARD('b) \<or> CARD('b) = 1 \<Longrightarrow> CARD('a \<Rightarrow>f 'b) = (if CARD('a) \<noteq> 0 \<and> CARD('b) \<noteq> 0 \<or> CARD('b) = 1 then CARD('b) ^ CARD('a) else 0)
 2. \<not> (0 < CARD('a) \<and> 0 < CARD('b) \<or> CARD('b) = 1) \<Longrightarrow> CARD('a \<Rightarrow>f 'b) = (if CARD('a) \<noteq> 0 \<and> CARD('b) \<noteq> 0 \<or> CARD('b) = 1 then CARD('b) ^ CARD('a) else 0)
[PROOF STEP]
have "CARD('a \<Rightarrow>f 'b) = card F"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. CARD('a \<Rightarrow>f 'b) = card F
[PROOF STEP]
unfolding type_definition.Abs_image[OF type_definition_finfun, symmetric]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card (Abs_finfun ` finfun) = card F
[PROOF STEP]
by(auto intro!: card_image inj_onI simp add: Abs_finfun_inject F_def)
[PROOF STATE]
proof (state)
this:
CARD('a \<Rightarrow>f 'b) = card F

goal (2 subgoals):
 1. 0 < CARD('a) \<and> 0 < CARD('b) \<or> CARD('b) = 1 \<Longrightarrow> CARD('a \<Rightarrow>f 'b) = (if CARD('a) \<noteq> 0 \<and> CARD('b) \<noteq> 0 \<or> CARD('b) = 1 then CARD('b) ^ CARD('a) else 0)
 2. \<not> (0 < CARD('a) \<and> 0 < CARD('b) \<or> CARD('b) = 1) \<Longrightarrow> CARD('a \<Rightarrow>f 'b) = (if CARD('a) \<noteq> 0 \<and> CARD('b) \<noteq> 0 \<or> CARD('b) = 1 then CARD('b) ^ CARD('a) else 0)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
F = UNIV
CARD('a \<Rightarrow>f 'b) = card F
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
F = UNIV
CARD('a \<Rightarrow>f 'b) = card F

goal (1 subgoal):
 1. CARD('a \<Rightarrow>f 'b) = (if CARD('a) \<noteq> 0 \<and> CARD('b) \<noteq> 0 \<or> CARD('b) = 1 then CARD('b) ^ CARD('a) else 0)
[PROOF STEP]
by(simp add: card_fun)
[PROOF STATE]
proof (state)
this:
CARD('a \<Rightarrow>f 'b) = (if CARD('a) \<noteq> 0 \<and> CARD('b) \<noteq> 0 \<or> CARD('b) = 1 then CARD('b) ^ CARD('a) else 0)

goal (1 subgoal):
 1. \<not> (0 < CARD('a) \<and> 0 < CARD('b) \<or> CARD('b) = 1) \<Longrightarrow> CARD('a \<Rightarrow>f 'b) = (if CARD('a) \<noteq> 0 \<and> CARD('b) \<noteq> 0 \<or> CARD('b) = 1 then CARD('b) ^ CARD('a) else 0)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> (0 < CARD('a) \<and> 0 < CARD('b) \<or> CARD('b) = 1) \<Longrightarrow> CARD('a \<Rightarrow>f 'b) = (if CARD('a) \<noteq> 0 \<and> CARD('b) \<noteq> 0 \<or> CARD('b) = 1 then CARD('b) ^ CARD('a) else 0)
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> (0 < CARD('a) \<and> 0 < CARD('b) \<or> CARD('b) = 1)

goal (1 subgoal):
 1. \<not> (0 < CARD('a) \<and> 0 < CARD('b) \<or> CARD('b) = 1) \<Longrightarrow> CARD('a \<Rightarrow>f 'b) = (if CARD('a) \<noteq> 0 \<and> CARD('b) \<noteq> 0 \<or> CARD('b) = 1 then CARD('b) ^ CARD('a) else 0)
[PROOF STEP]
hence infinite: "\<not> (finite (UNIV :: 'a set) \<and> finite (UNIV :: 'b set))"
    and b: "CARD('b) \<noteq> 1"
[PROOF STATE]
proof (prove)
using this:
\<not> (0 < CARD('a) \<and> 0 < CARD('b) \<or> CARD('b) = 1)

goal (1 subgoal):
 1. \<not> (finite UNIV \<and> finite UNIV) &&& CARD('b) \<noteq> 1
[PROOF STEP]
by(simp_all add: card_eq_0_iff)
[PROOF STATE]
proof (state)
this:
\<not> (finite UNIV \<and> finite UNIV)
CARD('b) \<noteq> 1

goal (1 subgoal):
 1. \<not> (0 < CARD('a) \<and> 0 < CARD('b) \<or> CARD('b) = 1) \<Longrightarrow> CARD('a \<Rightarrow>f 'b) = (if CARD('a) \<noteq> 0 \<and> CARD('b) \<noteq> 0 \<or> CARD('b) = 1 then CARD('b) ^ CARD('a) else 0)
[PROOF STEP]
from b
[PROOF STATE]
proof (chain)
picking this:
CARD('b) \<noteq> 1
[PROOF STEP]
obtain b1 b2 :: 'b where "b1 \<noteq> b2"
[PROOF STATE]
proof (prove)
using this:
CARD('b) \<noteq> 1

goal (1 subgoal):
 1. (\<And>b1 b2. b1 \<noteq> b2 \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by(auto simp add: card_eq_1_iff simp del: One_nat_def)
[PROOF STATE]
proof (state)
this:
b1 \<noteq> b2

goal (1 subgoal):
 1. \<not> (0 < CARD('a) \<and> 0 < CARD('b) \<or> CARD('b) = 1) \<Longrightarrow> CARD('a \<Rightarrow>f 'b) = (if CARD('a) \<noteq> 0 \<and> CARD('b) \<noteq> 0 \<or> CARD('b) = 1 then CARD('b) ^ CARD('a) else 0)
[PROOF STEP]
let ?f = "\<lambda>a a' :: 'a. if a = a' then b1 else b2"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> (0 < CARD('a) \<and> 0 < CARD('b) \<or> CARD('b) = 1) \<Longrightarrow> CARD('a \<Rightarrow>f 'b) = (if CARD('a) \<noteq> 0 \<and> CARD('b) \<noteq> 0 \<or> CARD('b) = 1 then CARD('b) ^ CARD('a) else 0)
[PROOF STEP]
from infinite
[PROOF STATE]
proof (chain)
picking this:
\<not> (finite UNIV \<and> finite UNIV)
[PROOF STEP]
have "\<not> finite (UNIV :: ('a \<Rightarrow>f 'b) set)"
[PROOF STATE]
proof (prove)
using this:
\<not> (finite UNIV \<and> finite UNIV)

goal (1 subgoal):
 1. infinite UNIV
[PROOF STEP]
proof(rule contrapos_nn[OF _ conjI])
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. finite UNIV \<Longrightarrow> finite UNIV
 2. finite UNIV \<Longrightarrow> finite UNIV
[PROOF STEP]
assume finite: "finite (UNIV :: ('a \<Rightarrow>f 'b) set)"
[PROOF STATE]
proof (state)
this:
finite UNIV

goal (2 subgoals):
 1. finite UNIV \<Longrightarrow> finite UNIV
 2. finite UNIV \<Longrightarrow> finite UNIV
[PROOF STEP]
hence "finite F"
[PROOF STATE]
proof (prove)
using this:
finite UNIV

goal (1 subgoal):
 1. finite F
[PROOF STEP]
unfolding type_definition.Abs_image[OF type_definition_finfun, symmetric] F_def
[PROOF STATE]
proof (prove)
using this:
finite (Abs_finfun ` finfun)

goal (1 subgoal):
 1. finite finfun
[PROOF STEP]
by(rule finite_imageD)(auto intro: inj_onI simp add: Abs_finfun_inject)
[PROOF STATE]
proof (state)
this:
finite F

goal (2 subgoals):
 1. finite UNIV \<Longrightarrow> finite UNIV
 2. finite UNIV \<Longrightarrow> finite UNIV
[PROOF STEP]
hence "finite (range ?f)"
[PROOF STATE]
proof (prove)
using this:
finite F

goal (1 subgoal):
 1. finite (range (\<lambda>a a'. if a = a' then b1 else b2))
[PROOF STEP]
by(rule finite_subset[rotated 1])(auto simp add: F_def finfun_def \<open>b1 \<noteq> b2\<close> intro!: exI[where x=b2])
[PROOF STATE]
proof (state)
this:
finite (range (\<lambda>a a'. if a = a' then b1 else b2))

goal (2 subgoals):
 1. finite UNIV \<Longrightarrow> finite UNIV
 2. finite UNIV \<Longrightarrow> finite UNIV
[PROOF STEP]
thus "finite (UNIV :: 'a set)"
[PROOF STATE]
proof (prove)
using this:
finite (range (\<lambda>a a'. if a = a' then b1 else b2))

goal (1 subgoal):
 1. finite UNIV
[PROOF STEP]
by(rule finite_imageD)(auto intro: inj_onI simp add: fun_eq_iff \<open>b1 \<noteq> b2\<close> split: if_split_asm)
[PROOF STATE]
proof (state)
this:
finite UNIV

goal (1 subgoal):
 1. finite UNIV \<Longrightarrow> finite UNIV
[PROOF STEP]
from finite
[PROOF STATE]
proof (chain)
picking this:
finite UNIV
[PROOF STEP]
have "finite (range (\<lambda>b. ((K$ b) :: 'a \<Rightarrow>f 'b)))"
[PROOF STATE]
proof (prove)
using this:
finite UNIV

goal (1 subgoal):
 1. finite (range finfun_const)
[PROOF STEP]
by(rule finite_subset[rotated 1]) simp
[PROOF STATE]
proof (state)
this:
finite (range finfun_const)

goal (1 subgoal):
 1. finite UNIV \<Longrightarrow> finite UNIV
[PROOF STEP]
thus "finite (UNIV :: 'b set)"
[PROOF STATE]
proof (prove)
using this:
finite (range finfun_const)

goal (1 subgoal):
 1. finite UNIV
[PROOF STEP]
by(rule finite_imageD)(auto intro!: inj_onI)
[PROOF STATE]
proof (state)
this:
finite UNIV

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

goal (1 subgoal):
 1. \<not> (0 < CARD('a) \<and> 0 < CARD('b) \<or> CARD('b) = 1) \<Longrightarrow> CARD('a \<Rightarrow>f 'b) = (if CARD('a) \<noteq> 0 \<and> CARD('b) \<noteq> 0 \<or> CARD('b) = 1 then CARD('b) ^ CARD('a) else 0)
[PROOF STEP]
with False
[PROOF STATE]
proof (chain)
picking this:
\<not> (0 < CARD('a) \<and> 0 < CARD('b) \<or> CARD('b) = 1)
infinite UNIV
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<not> (0 < CARD('a) \<and> 0 < CARD('b) \<or> CARD('b) = 1)
infinite UNIV

goal (1 subgoal):
 1. CARD('a \<Rightarrow>f 'b) = (if CARD('a) \<noteq> 0 \<and> CARD('b) \<noteq> 0 \<or> CARD('b) = 1 then CARD('b) ^ CARD('a) else 0)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
CARD('a \<Rightarrow>f 'b) = (if CARD('a) \<noteq> 0 \<and> CARD('b) \<noteq> 0 \<or> CARD('b) = 1 then CARD('b) ^ CARD('a) else 0)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma gfp_lfp_prop: "sup (gfp (\<lambda>(y :: 'a :: proto_quantale). x \<cdot> y)) (lfp (\<lambda>y. sup z (x \<cdot> y))) \<le> gfp (\<lambda>y. sup z  (x \<cdot> y))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sup (gfp ((\<cdot>) x)) (lfp (\<lambda>y. sup z (x \<cdot> y))) \<le> gfp (\<lambda>y. sup z (x \<cdot> y))
[PROOF STEP]
apply (simp, rule conjI)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. gfp ((\<cdot>) x) \<le> gfp (\<lambda>y. sup z (x \<cdot> y))
 2. lfp (\<lambda>y. sup z (x \<cdot> y)) \<le> gfp (\<lambda>y. sup z (x \<cdot> y))
[PROOF STEP]
apply (simp add: gfp_mono)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. lfp (\<lambda>y. sup z (x \<cdot> y)) \<le> gfp (\<lambda>y. sup z (x \<cdot> y))
[PROOF STEP]
by (simp add: lfp_le_gfp mono_aux)


[STATEMENT]
lemma infsum_Sigma_banach:
  fixes A :: "'a set" and B :: "'a \<Rightarrow> 'b set"
    and f :: \<open>'a \<times> 'b \<Rightarrow> 'c::banach\<close>
  assumes [simp]: "f summable_on (Sigma A B)"
  shows \<open>infsum (\<lambda>x. infsum (\<lambda>y. f (x,y)) (B x)) A = infsum f (Sigma A B)\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>\<^sub>\<infinity>x\<in>A. \<Sum>\<^sub>\<infinity>y\<in>B x. f (x, y)) = infsum f (Sigma A B)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
f summable_on Sigma A B

goal (1 subgoal):
 1. (\<Sum>\<^sub>\<infinity>x\<in>A. \<Sum>\<^sub>\<infinity>y\<in>B x. f (x, y)) = infsum f (Sigma A B)
[PROOF STEP]
by (subst infsum_Sigma'_banach) auto


[STATEMENT]
lemma aux_range:
  fixes k:: nat
  assumes "k < 2^(Suc n + 1)" and "k \<ge> 2"
  shows "k = 2 \<or> k = 3 \<or> (\<exists>l. l\<ge>2 \<and> l\<le>2^(n+1)-1 \<and> (k = 2*l \<or> k = 2*l + 1))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. k = 2 \<or> k = 3 \<or> (\<exists>l\<ge>2. l \<le> 2 ^ (n + 1) - 1 \<and> (k = 2 * l \<or> k = 2 * l + 1))
[PROOF STEP]
proof(rule disjCI)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> (k = 3 \<or> (\<exists>l\<ge>2. l \<le> 2 ^ (n + 1) - 1 \<and> (k = 2 * l \<or> k = 2 * l + 1))) \<Longrightarrow> k = 2
[PROOF STEP]
assume "\<not> (k = 3 \<or> (\<exists>l\<ge>2. l \<le> 2^(n + 1) - 1 \<and> (k = 2 * l \<or> k = 2 * l + 1)))"
[PROOF STATE]
proof (state)
this:
\<not> (k = 3 \<or> (\<exists>l\<ge>2. l \<le> 2 ^ (n + 1) - 1 \<and> (k = 2 * l \<or> k = 2 * l + 1)))

goal (1 subgoal):
 1. \<not> (k = 3 \<or> (\<exists>l\<ge>2. l \<le> 2 ^ (n + 1) - 1 \<and> (k = 2 * l \<or> k = 2 * l + 1))) \<Longrightarrow> k = 2
[PROOF STEP]
have "k > 3 \<longrightarrow> (\<exists>l\<ge>2. l \<le> 2^(n + 1) - 1 \<and> (k = 2 * l \<or> k = 2 * l + 1))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 3 < k \<longrightarrow> (\<exists>l\<ge>2. l \<le> 2 ^ (n + 1) - 1 \<and> (k = 2 * l \<or> k = 2 * l + 1))
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. 3 < k \<Longrightarrow> \<exists>l\<ge>2. l \<le> 2 ^ (n + 1) - 1 \<and> (k = 2 * l \<or> k = 2 * l + 1)
[PROOF STEP]
assume asm:"k > 3"
[PROOF STATE]
proof (state)
this:
3 < k

goal (1 subgoal):
 1. 3 < k \<Longrightarrow> \<exists>l\<ge>2. l \<le> 2 ^ (n + 1) - 1 \<and> (k = 2 * l \<or> k = 2 * l + 1)
[PROOF STEP]
have "even k \<or> odd k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. even k \<or> odd k
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
even k \<or> odd k

goal (1 subgoal):
 1. 3 < k \<Longrightarrow> \<exists>l\<ge>2. l \<le> 2 ^ (n + 1) - 1 \<and> (k = 2 * l \<or> k = 2 * l + 1)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
even k \<or> odd k
[PROOF STEP]
obtain l where "k = 2*l \<or> k = 2*l+1"
[PROOF STATE]
proof (prove)
using this:
even k \<or> odd k

goal (1 subgoal):
 1. (\<And>l. k = 2 * l \<or> k = 2 * l + 1 \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (meson evenE oddE)
[PROOF STATE]
proof (state)
this:
k = 2 * l \<or> k = 2 * l + 1

goal (1 subgoal):
 1. 3 < k \<Longrightarrow> \<exists>l\<ge>2. l \<le> 2 ^ (n + 1) - 1 \<and> (k = 2 * l \<or> k = 2 * l + 1)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
k = 2 * l \<or> k = 2 * l + 1

goal (1 subgoal):
 1. 3 < k \<Longrightarrow> \<exists>l\<ge>2. l \<le> 2 ^ (n + 1) - 1 \<and> (k = 2 * l \<or> k = 2 * l + 1)
[PROOF STEP]
have "l \<ge> 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 \<le> l
[PROOF STEP]
using asm calculation
[PROOF STATE]
proof (prove)
using this:
3 < k
k = 2 * l \<or> k = 2 * l + 1

goal (1 subgoal):
 1. 2 \<le> l
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
2 \<le> l

goal (1 subgoal):
 1. 3 < k \<Longrightarrow> \<exists>l\<ge>2. l \<le> 2 ^ (n + 1) - 1 \<and> (k = 2 * l \<or> k = 2 * l + 1)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
2 \<le> l

goal (1 subgoal):
 1. 3 < k \<Longrightarrow> \<exists>l\<ge>2. l \<le> 2 ^ (n + 1) - 1 \<and> (k = 2 * l \<or> k = 2 * l + 1)
[PROOF STEP]
have "l \<le> 2^(n+1) - 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. l \<le> 2 ^ (n + 1) - 1
[PROOF STEP]
using assms(1)
[PROOF STATE]
proof (prove)
using this:
k < 2 ^ (Suc n + 1)

goal (1 subgoal):
 1. l \<le> 2 ^ (n + 1) - 1
[PROOF STEP]
by (metis Suc_diff_1 Suc_eq_plus1 calculation(1) dvd_triv_left even_Suc_div_two less_Suc_eq_le less_power_add_imp_div_less nonzero_mult_div_cancel_left pos2 power_one_right zero_less_power zero_neq_numeral)
[PROOF STATE]
proof (state)
this:
l \<le> 2 ^ (n + 1) - 1

goal (1 subgoal):
 1. 3 < k \<Longrightarrow> \<exists>l\<ge>2. l \<le> 2 ^ (n + 1) - 1 \<and> (k = 2 * l \<or> k = 2 * l + 1)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
k = 2 * l \<or> k = 2 * l + 1
2 \<le> l
l \<le> 2 ^ (n + 1) - 1
[PROOF STEP]
show "\<exists>l\<ge>2. l \<le> 2^(n + 1) - 1 \<and> (k = 2 * l \<or> k = 2 * l + 1)"
[PROOF STATE]
proof (prove)
using this:
k = 2 * l \<or> k = 2 * l + 1
2 \<le> l
l \<le> 2 ^ (n + 1) - 1

goal (1 subgoal):
 1. \<exists>l\<ge>2. l \<le> 2 ^ (n + 1) - 1 \<and> (k = 2 * l \<or> k = 2 * l + 1)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<exists>l\<ge>2. l \<le> 2 ^ (n + 1) - 1 \<and> (k = 2 * l \<or> k = 2 * l + 1)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
3 < k \<longrightarrow> (\<exists>l\<ge>2. l \<le> 2 ^ (n + 1) - 1 \<and> (k = 2 * l \<or> k = 2 * l + 1))

goal (1 subgoal):
 1. \<not> (k = 3 \<or> (\<exists>l\<ge>2. l \<le> 2 ^ (n + 1) - 1 \<and> (k = 2 * l \<or> k = 2 * l + 1))) \<Longrightarrow> k = 2
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
3 < k \<longrightarrow> (\<exists>l\<ge>2. l \<le> 2 ^ (n + 1) - 1 \<and> (k = 2 * l \<or> k = 2 * l + 1))
[PROOF STEP]
have "k \<le> 2"
[PROOF STATE]
proof (prove)
using this:
3 < k \<longrightarrow> (\<exists>l\<ge>2. l \<le> 2 ^ (n + 1) - 1 \<and> (k = 2 * l \<or> k = 2 * l + 1))

goal (1 subgoal):
 1. k \<le> 2
[PROOF STEP]
using \<open>\<not> (k = 3 \<or> (\<exists>l\<ge>2. l \<le> 2 ^ (n + 1) - 1 \<and> (k = 2 * l \<or> k = 2 * l + 1)))\<close> less_Suc_eq_le
[PROOF STATE]
proof (prove)
using this:
3 < k \<longrightarrow> (\<exists>l\<ge>2. l \<le> 2 ^ (n + 1) - 1 \<and> (k = 2 * l \<or> k = 2 * l + 1))
\<not> (k = 3 \<or> (\<exists>l\<ge>2. l \<le> 2 ^ (n + 1) - 1 \<and> (k = 2 * l \<or> k = 2 * l + 1)))
(?m < Suc ?n) = (?m \<le> ?n)

goal (1 subgoal):
 1. k \<le> 2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
k \<le> 2

goal (1 subgoal):
 1. \<not> (k = 3 \<or> (\<exists>l\<ge>2. l \<le> 2 ^ (n + 1) - 1 \<and> (k = 2 * l \<or> k = 2 * l + 1))) \<Longrightarrow> k = 2
[PROOF STEP]
thus "k = 2"
[PROOF STATE]
proof (prove)
using this:
k \<le> 2

goal (1 subgoal):
 1. k = 2
[PROOF STEP]
using assms(2)
[PROOF STATE]
proof (prove)
using this:
k \<le> 2
2 \<le> k

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

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma is_path_undir_subgraph:
    assumes "is_path_undir H x p y"
    assumes "subgraph H G"
    shows "is_path_undir G x p y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. is_path_undir G x p y
[PROOF STEP]
using assms is_path_undir.simps
[PROOF STATE]
proof (prove)
using this:
is_path_undir H x p y
subgraph H G
is_path_undir ?G ?v [] ?v' = (?v = ?v' \<and> ?v' \<in> nodes ?G)
is_path_undir ?G ?v ((?v1.0, ?w, ?v2.0) # ?p) ?v' = (?v = ?v1.0 \<and> ((?v1.0, ?w, ?v2.0) \<in> edges ?G \<or> (?v2.0, ?w, ?v1.0) \<in> edges ?G) \<and> is_path_undir ?G ?v2.0 ?p ?v')

goal (1 subgoal):
 1. is_path_undir G x p y
[PROOF STEP]
unfolding subgraph_def
[PROOF STATE]
proof (prove)
using this:
is_path_undir H x p y
nodes H = V \<and> edges H \<subseteq> E
is_path_undir ?G ?v [] ?v' = (?v = ?v' \<and> ?v' \<in> nodes ?G)
is_path_undir ?G ?v ((?v1.0, ?w, ?v2.0) # ?p) ?v' = (?v = ?v1.0 \<and> ((?v1.0, ?w, ?v2.0) \<in> edges ?G \<or> (?v2.0, ?w, ?v1.0) \<in> edges ?G) \<and> is_path_undir ?G ?v2.0 ?p ?v')

goal (1 subgoal):
 1. is_path_undir G x p y
[PROOF STEP]
by (induction p arbitrary: x y) auto


[STATEMENT]
lemma upper_asymptotic_density_finite_Union:
  assumes "finite I"
  shows "upper_asymptotic_density (\<Union>i\<in>I. A i) \<le> (\<Sum>i\<in>I. upper_asymptotic_density (A i))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. upper_asymptotic_density (\<Union> (A ` I)) \<le> (\<Sum>i\<in>I. upper_asymptotic_density (A i))
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
finite I

goal (1 subgoal):
 1. upper_asymptotic_density (\<Union> (A ` I)) \<le> (\<Sum>i\<in>I. upper_asymptotic_density (A i))
[PROOF STEP]
apply (induction I rule: finite_induct)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. upper_asymptotic_density (\<Union> (A ` {})) \<le> (\<Sum>i\<in>{}. upper_asymptotic_density (A i))
 2. \<And>x F. \<lbrakk>finite F; x \<notin> F; upper_asymptotic_density (\<Union> (A ` F)) \<le> (\<Sum>i\<in>F. upper_asymptotic_density (A i))\<rbrakk> \<Longrightarrow> upper_asymptotic_density (\<Union> (A ` insert x F)) \<le> (\<Sum>i\<in>insert x F. upper_asymptotic_density (A i))
[PROOF STEP]
using order_trans[OF upper_asymptotic_density_union]
[PROOF STATE]
proof (prove)
using this:
upper_asymptotic_density ?A1 + upper_asymptotic_density ?B1 \<le> ?z \<Longrightarrow> upper_asymptotic_density (?A1 \<union> ?B1) \<le> ?z

goal (2 subgoals):
 1. upper_asymptotic_density (\<Union> (A ` {})) \<le> (\<Sum>i\<in>{}. upper_asymptotic_density (A i))
 2. \<And>x F. \<lbrakk>finite F; x \<notin> F; upper_asymptotic_density (\<Union> (A ` F)) \<le> (\<Sum>i\<in>F. upper_asymptotic_density (A i))\<rbrakk> \<Longrightarrow> upper_asymptotic_density (\<Union> (A ` insert x F)) \<le> (\<Sum>i\<in>insert x F. upper_asymptotic_density (A i))
[PROOF STEP]
by auto


[STATEMENT]
lemma summableI_nonneg_bounded:
  fixes f :: "nat \<Rightarrow> 'a::{ordered_comm_monoid_add,linorder_topology,conditionally_complete_linorder}"
  assumes pos[simp]: "\<And>n. 0 \<le> f n"
    and le: "\<And>n. (\<Sum>i<n. f i) \<le> x"
  shows "summable f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. summable f
[PROOF STEP]
unfolding summable_def sums_def [abs_def]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>s. (\<lambda>n. sum f {..<n}) \<longlonglongrightarrow> s
[PROOF STEP]
proof (rule exI LIMSEQ_incseq_SUP)+
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. bdd_above (range (\<lambda>n. sum f {..<n}))
 2. incseq (\<lambda>n. sum f {..<n})
[PROOF STEP]
show "bdd_above (range (\<lambda>n. sum f {..<n}))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bdd_above (range (\<lambda>n. sum f {..<n}))
[PROOF STEP]
using le
[PROOF STATE]
proof (prove)
using this:
sum f {..<?n} \<le> x

goal (1 subgoal):
 1. bdd_above (range (\<lambda>n. sum f {..<n}))
[PROOF STEP]
by (auto simp: bdd_above_def)
[PROOF STATE]
proof (state)
this:
bdd_above (range (\<lambda>n. sum f {..<n}))

goal (1 subgoal):
 1. incseq (\<lambda>n. sum f {..<n})
[PROOF STEP]
show "incseq (\<lambda>n. sum f {..<n})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. incseq (\<lambda>n. sum f {..<n})
[PROOF STEP]
by (auto simp: mono_def intro!: sum_mono2)
[PROOF STATE]
proof (state)
this:
incseq (\<lambda>n. sum f {..<n})

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma outer_prod_minus_right:
  fixes v::"complex Matrix.vec"
  assumes "dim_vec w = dim_vec x"
  shows "outer_prod v (w - x) = outer_prod v w - (outer_prod v x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. outer_prod v (w - x) = outer_prod v w - outer_prod v x
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. outer_prod v (w - x) = outer_prod v w - outer_prod v x
[PROOF STEP]
define paw where "paw = outer_prod v (w-x)"
[PROOF STATE]
proof (state)
this:
paw = outer_prod v (w - x)

goal (1 subgoal):
 1. outer_prod v (w - x) = outer_prod v w - outer_prod v x
[PROOF STEP]
define apw where "apw = outer_prod v w - (outer_prod v x)"
[PROOF STATE]
proof (state)
this:
apw = outer_prod v w - outer_prod v x

goal (1 subgoal):
 1. outer_prod v (w - x) = outer_prod v w - outer_prod v x
[PROOF STEP]
have "paw = apw"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. paw = apw
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < dim_row apw; j < dim_col apw\<rbrakk> \<Longrightarrow> paw $$ (i, j) = apw $$ (i, j)
 2. dim_row paw = dim_row apw
 3. dim_col paw = dim_col apw
[PROOF STEP]
have rv: "dim_row paw = dim_vec v"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_row paw = dim_vec v
[PROOF STEP]
unfolding paw_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_row (outer_prod v (w - x)) = dim_vec v
[PROOF STEP]
using outer_prod_dim assms
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?v \<in> carrier_vec ?n; ?w \<in> carrier_vec ?m\<rbrakk> \<Longrightarrow> outer_prod ?v ?w \<in> carrier_mat ?n ?m
dim_vec w = dim_vec x

goal (1 subgoal):
 1. dim_row (outer_prod v (w - x)) = dim_vec v
[PROOF STEP]
by (metis carrier_matD(1) carrier_vec_dim_vec paw_def)
[PROOF STATE]
proof (state)
this:
dim_row paw = dim_vec v

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < dim_row apw; j < dim_col apw\<rbrakk> \<Longrightarrow> paw $$ (i, j) = apw $$ (i, j)
 2. dim_row paw = dim_row apw
 3. dim_col paw = dim_col apw
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
dim_row paw = dim_vec v

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < dim_row apw; j < dim_col apw\<rbrakk> \<Longrightarrow> paw $$ (i, j) = apw $$ (i, j)
 2. dim_row paw = dim_row apw
 3. dim_col paw = dim_col apw
[PROOF STEP]
have "... = dim_row apw"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_vec v = dim_row apw
[PROOF STEP]
unfolding apw_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_vec v = dim_row (outer_prod v w - outer_prod v x)
[PROOF STEP]
using outer_prod_dim assms
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?v \<in> carrier_vec ?n; ?w \<in> carrier_vec ?m\<rbrakk> \<Longrightarrow> outer_prod ?v ?w \<in> carrier_mat ?n ?m
dim_vec w = dim_vec x

goal (1 subgoal):
 1. dim_vec v = dim_row (outer_prod v w - outer_prod v x)
[PROOF STEP]
by (metis carrier_matD(1) carrier_vec_dim_vec index_minus_mat(2))
[PROOF STATE]
proof (state)
this:
dim_vec v = dim_row apw

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < dim_row apw; j < dim_col apw\<rbrakk> \<Longrightarrow> paw $$ (i, j) = apw $$ (i, j)
 2. dim_row paw = dim_row apw
 3. dim_col paw = dim_col apw
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
dim_row paw = dim_row apw
[PROOF STEP]
show dr: "dim_row paw = dim_row apw"
[PROOF STATE]
proof (prove)
using this:
dim_row paw = dim_row apw

goal (1 subgoal):
 1. dim_row paw = dim_row apw
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
dim_row paw = dim_row apw

goal (2 subgoals):
 1. \<And>i j. \<lbrakk>i < dim_row apw; j < dim_col apw\<rbrakk> \<Longrightarrow> paw $$ (i, j) = apw $$ (i, j)
 2. dim_col paw = dim_col apw
[PROOF STEP]
have cw: "dim_col paw = dim_vec w"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_col paw = dim_vec w
[PROOF STEP]
unfolding paw_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_col (outer_prod v (w - x)) = dim_vec w
[PROOF STEP]
using outer_prod_dim assms
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?v \<in> carrier_vec ?n; ?w \<in> carrier_vec ?m\<rbrakk> \<Longrightarrow> outer_prod ?v ?w \<in> carrier_mat ?n ?m
dim_vec w = dim_vec x

goal (1 subgoal):
 1. dim_col (outer_prod v (w - x)) = dim_vec w
[PROOF STEP]
using carrier_vec_dim_vec
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?v \<in> carrier_vec ?n; ?w \<in> carrier_vec ?m\<rbrakk> \<Longrightarrow> outer_prod ?v ?w \<in> carrier_mat ?n ?m
dim_vec w = dim_vec x
?v \<in> carrier_vec (dim_vec ?v)

goal (1 subgoal):
 1. dim_col (outer_prod v (w - x)) = dim_vec w
[PROOF STEP]
by (metis carrier_matD(2) index_minus_vec(2) paw_def)
[PROOF STATE]
proof (state)
this:
dim_col paw = dim_vec w

goal (2 subgoals):
 1. \<And>i j. \<lbrakk>i < dim_row apw; j < dim_col apw\<rbrakk> \<Longrightarrow> paw $$ (i, j) = apw $$ (i, j)
 2. dim_col paw = dim_col apw
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
dim_col paw = dim_vec w

goal (2 subgoals):
 1. \<And>i j. \<lbrakk>i < dim_row apw; j < dim_col apw\<rbrakk> \<Longrightarrow> paw $$ (i, j) = apw $$ (i, j)
 2. dim_col paw = dim_col apw
[PROOF STEP]
have "... = dim_col apw"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_vec w = dim_col apw
[PROOF STEP]
unfolding apw_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_vec w = dim_col (outer_prod v w - outer_prod v x)
[PROOF STEP]
using outer_prod_dim
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?v \<in> carrier_vec ?n; ?w \<in> carrier_vec ?m\<rbrakk> \<Longrightarrow> outer_prod ?v ?w \<in> carrier_mat ?n ?m

goal (1 subgoal):
 1. dim_vec w = dim_col (outer_prod v w - outer_prod v x)
[PROOF STEP]
by (metis assms carrier_matD(2) carrier_vec_dim_vec index_minus_mat(3))
[PROOF STATE]
proof (state)
this:
dim_vec w = dim_col apw

goal (2 subgoals):
 1. \<And>i j. \<lbrakk>i < dim_row apw; j < dim_col apw\<rbrakk> \<Longrightarrow> paw $$ (i, j) = apw $$ (i, j)
 2. dim_col paw = dim_col apw
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
dim_col paw = dim_col apw
[PROOF STEP]
show dc: "dim_col paw = dim_col apw"
[PROOF STATE]
proof (prove)
using this:
dim_col paw = dim_col apw

goal (1 subgoal):
 1. dim_col paw = dim_col apw
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
dim_col paw = dim_col apw

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row apw; j < dim_col apw\<rbrakk> \<Longrightarrow> paw $$ (i, j) = apw $$ (i, j)
[PROOF STEP]
show "\<And>i j. i < dim_row apw \<Longrightarrow> j < dim_col apw \<Longrightarrow> paw $$ (i, j) = apw $$ (i, j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row apw; j < dim_col apw\<rbrakk> \<Longrightarrow> paw $$ (i, j) = apw $$ (i, j)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row apw; j < dim_col apw\<rbrakk> \<Longrightarrow> paw $$ (i, j) = apw $$ (i, j)
[PROOF STEP]
fix i j
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row apw; j < dim_col apw\<rbrakk> \<Longrightarrow> paw $$ (i, j) = apw $$ (i, j)
[PROOF STEP]
assume  "i < dim_row apw" and "j < dim_col apw"
[PROOF STATE]
proof (state)
this:
i < dim_row apw
j < dim_col apw

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row apw; j < dim_col apw\<rbrakk> \<Longrightarrow> paw $$ (i, j) = apw $$ (i, j)
[PROOF STEP]
note ij = this
[PROOF STATE]
proof (state)
this:
i < dim_row apw
j < dim_col apw

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row apw; j < dim_col apw\<rbrakk> \<Longrightarrow> paw $$ (i, j) = apw $$ (i, j)
[PROOF STEP]
hence "paw $$ (i,j) = Matrix.vec_index v i *
        (cnj (Matrix.vec_index w j - (Matrix.vec_index x j)))"
[PROOF STATE]
proof (prove)
using this:
i < dim_row apw
j < dim_col apw

goal (1 subgoal):
 1. paw $$ (i, j) = v $ i * cnj (w $ j - x $ j)
[PROOF STEP]
using dr dc
[PROOF STATE]
proof (prove)
using this:
i < dim_row apw
j < dim_col apw
dim_row paw = dim_row apw
dim_col paw = dim_col apw

goal (1 subgoal):
 1. paw $$ (i, j) = v $ i * cnj (w $ j - x $ j)
[PROOF STEP]
unfolding  paw_def outer_prod_def
[PROOF STATE]
proof (prove)
using this:
i < dim_row apw
j < dim_col apw
dim_row (Matrix.mat (dim_vec v) 1 (\<lambda>(i, j). v $ i) * Matrix.mat 1 (dim_vec (w - x)) (\<lambda>(i, y). conjugate (w - x) $ y)) = dim_row apw
dim_col (Matrix.mat (dim_vec v) 1 (\<lambda>(i, j). v $ i) * Matrix.mat 1 (dim_vec (w - x)) (\<lambda>(i, y). conjugate (w - x) $ y)) = dim_col apw

goal (1 subgoal):
 1. (Matrix.mat (dim_vec v) 1 (\<lambda>(i, j). v $ i) * Matrix.mat 1 (dim_vec (w - x)) (\<lambda>(i, y). conjugate (w - x) $ y)) $$ (i, j) = v $ i * cnj (w $ j - x $ j)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
paw $$ (i, j) = v $ i * cnj (w $ j - x $ j)

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row apw; j < dim_col apw\<rbrakk> \<Longrightarrow> paw $$ (i, j) = apw $$ (i, j)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
paw $$ (i, j) = v $ i * cnj (w $ j - x $ j)

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row apw; j < dim_col apw\<rbrakk> \<Longrightarrow> paw $$ (i, j) = apw $$ (i, j)
[PROOF STEP]
have "... = Matrix.vec_index v i * cnj (Matrix.vec_index w j) -
        Matrix.vec_index v i * cnj (Matrix.vec_index x j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. v $ i * cnj (w $ j - x $ j) = v $ i * cnj (w $ j) - v $ i * cnj (x $ j)
[PROOF STEP]
by (simp add: ring_class.ring_distribs)
[PROOF STATE]
proof (state)
this:
v $ i * cnj (w $ j - x $ j) = v $ i * cnj (w $ j) - v $ i * cnj (x $ j)

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row apw; j < dim_col apw\<rbrakk> \<Longrightarrow> paw $$ (i, j) = apw $$ (i, j)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
v $ i * cnj (w $ j - x $ j) = v $ i * cnj (w $ j) - v $ i * cnj (x $ j)

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row apw; j < dim_col apw\<rbrakk> \<Longrightarrow> paw $$ (i, j) = apw $$ (i, j)
[PROOF STEP]
have "... = (outer_prod v w) $$ (i,j) - (outer_prod v x) $$ (i,j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. v $ i * cnj (w $ j) - v $ i * cnj (x $ j) = outer_prod v w $$ (i, j) - outer_prod v x $$ (i, j)
[PROOF STEP]
using rv cw dr dc ij assms
[PROOF STATE]
proof (prove)
using this:
dim_row paw = dim_vec v
dim_col paw = dim_vec w
dim_row paw = dim_row apw
dim_col paw = dim_col apw
i < dim_row apw
j < dim_col apw
dim_vec w = dim_vec x

goal (1 subgoal):
 1. v $ i * cnj (w $ j) - v $ i * cnj (x $ j) = outer_prod v w $$ (i, j) - outer_prod v x $$ (i, j)
[PROOF STEP]
unfolding outer_prod_def
[PROOF STATE]
proof (prove)
using this:
dim_row paw = dim_vec v
dim_col paw = dim_vec w
dim_row paw = dim_row apw
dim_col paw = dim_col apw
i < dim_row apw
j < dim_col apw
dim_vec w = dim_vec x

goal (1 subgoal):
 1. v $ i * cnj (w $ j) - v $ i * cnj (x $ j) = (Matrix.mat (dim_vec v) 1 (\<lambda>(i, j). v $ i) * Matrix.mat 1 (dim_vec w) (\<lambda>(i, y). conjugate w $ y)) $$ (i, j) - (Matrix.mat (dim_vec v) 1 (\<lambda>(i, j). v $ i) * Matrix.mat 1 (dim_vec x) (\<lambda>(i, y). conjugate x $ y)) $$ (i, j)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
v $ i * cnj (w $ j) - v $ i * cnj (x $ j) = outer_prod v w $$ (i, j) - outer_prod v x $$ (i, j)

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row apw; j < dim_col apw\<rbrakk> \<Longrightarrow> paw $$ (i, j) = apw $$ (i, j)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
v $ i * cnj (w $ j) - v $ i * cnj (x $ j) = outer_prod v w $$ (i, j) - outer_prod v x $$ (i, j)

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row apw; j < dim_col apw\<rbrakk> \<Longrightarrow> paw $$ (i, j) = apw $$ (i, j)
[PROOF STEP]
have "... = apw $$ (i,j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. outer_prod v w $$ (i, j) - outer_prod v x $$ (i, j) = apw $$ (i, j)
[PROOF STEP]
using dr dc ij
[PROOF STATE]
proof (prove)
using this:
dim_row paw = dim_row apw
dim_col paw = dim_col apw
i < dim_row apw
j < dim_col apw

goal (1 subgoal):
 1. outer_prod v w $$ (i, j) - outer_prod v x $$ (i, j) = apw $$ (i, j)
[PROOF STEP]
unfolding apw_def outer_prod_def
[PROOF STATE]
proof (prove)
using this:
dim_row paw = dim_row (Matrix.mat (dim_vec v) 1 (\<lambda>(i, j). v $ i) * Matrix.mat 1 (dim_vec w) (\<lambda>(i, y). conjugate w $ y) - Matrix.mat (dim_vec v) 1 (\<lambda>(i, j). v $ i) * Matrix.mat 1 (dim_vec x) (\<lambda>(i, y). conjugate x $ y))
dim_col paw = dim_col (Matrix.mat (dim_vec v) 1 (\<lambda>(i, j). v $ i) * Matrix.mat 1 (dim_vec w) (\<lambda>(i, y). conjugate w $ y) - Matrix.mat (dim_vec v) 1 (\<lambda>(i, j). v $ i) * Matrix.mat 1 (dim_vec x) (\<lambda>(i, y). conjugate x $ y))
i < dim_row (Matrix.mat (dim_vec v) 1 (\<lambda>(i, j). v $ i) * Matrix.mat 1 (dim_vec w) (\<lambda>(i, y). conjugate w $ y) - Matrix.mat (dim_vec v) 1 (\<lambda>(i, j). v $ i) * Matrix.mat 1 (dim_vec x) (\<lambda>(i, y). conjugate x $ y))
j < dim_col (Matrix.mat (dim_vec v) 1 (\<lambda>(i, j). v $ i) * Matrix.mat 1 (dim_vec w) (\<lambda>(i, y). conjugate w $ y) - Matrix.mat (dim_vec v) 1 (\<lambda>(i, j). v $ i) * Matrix.mat 1 (dim_vec x) (\<lambda>(i, y). conjugate x $ y))

goal (1 subgoal):
 1. (Matrix.mat (dim_vec v) 1 (\<lambda>(i, j). v $ i) * Matrix.mat 1 (dim_vec w) (\<lambda>(i, y). conjugate w $ y)) $$ (i, j) - (Matrix.mat (dim_vec v) 1 (\<lambda>(i, j). v $ i) * Matrix.mat 1 (dim_vec x) (\<lambda>(i, y). conjugate x $ y)) $$ (i, j) = (Matrix.mat (dim_vec v) 1 (\<lambda>(i, j). v $ i) * Matrix.mat 1 (dim_vec w) (\<lambda>(i, y). conjugate w $ y) - Matrix.mat (dim_vec v) 1 (\<lambda>(i, j). v $ i) * Matrix.mat 1 (dim_vec x) (\<lambda>(i, y). conjugate x $ y)) $$ (i, j)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
outer_prod v w $$ (i, j) - outer_prod v x $$ (i, j) = apw $$ (i, j)

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row apw; j < dim_col apw\<rbrakk> \<Longrightarrow> paw $$ (i, j) = apw $$ (i, j)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
paw $$ (i, j) = apw $$ (i, j)
[PROOF STEP]
show "paw $$ (i, j) = apw $$ (i, j)"
[PROOF STATE]
proof (prove)
using this:
paw $$ (i, j) = apw $$ (i, j)

goal (1 subgoal):
 1. paw $$ (i, j) = apw $$ (i, j)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
paw $$ (i, j) = apw $$ (i, j)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<lbrakk>?i < dim_row apw; ?j < dim_col apw\<rbrakk> \<Longrightarrow> paw $$ (?i, ?j) = apw $$ (?i, ?j)

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

goal (1 subgoal):
 1. outer_prod v (w - x) = outer_prod v w - outer_prod v x
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
paw = apw

goal (1 subgoal):
 1. outer_prod v (w - x) = outer_prod v w - outer_prod v x
[PROOF STEP]
unfolding paw_def apw_def
[PROOF STATE]
proof (prove)
using this:
outer_prod v (w - x) = outer_prod v w - outer_prod v x

goal (1 subgoal):
 1. outer_prod v (w - x) = outer_prod v w - outer_prod v x
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
outer_prod v (w - x) = outer_prod v w - outer_prod v x

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma ex_k_mod:
  assumes coprime: "coprime (e :: nat) ((P-1)*(Q-1))"
    and "P \<noteq> Q"
    and "prime P"
    and "prime Q"
    and "d \<noteq> 0"
    and " [e*d = 1] (mod (P-1))"
  shows "\<exists> k. e*d = 1 + k*(P-1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>k. e * d = 1 + k * (P - 1)
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>k. e * d = 1 + k * (P - 1)
[PROOF STEP]
have "e > 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < e
[PROOF STEP]
using assms(1) assms(2) prime_gt_0_nat
[PROOF STATE]
proof (prove)
using this:
coprime e ((P - 1) * (Q - 1))
P \<noteq> Q
prime ?p \<Longrightarrow> 0 < ?p

goal (1 subgoal):
 1. 0 < e
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
0 < e

goal (1 subgoal):
 1. \<exists>k. e * d = 1 + k * (P - 1)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
0 < e
[PROOF STEP]
have "e*d \<ge> 1"
[PROOF STATE]
proof (prove)
using this:
0 < e

goal (1 subgoal):
 1. 1 \<le> e * d
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
0 < e
coprime e ((P - 1) * (Q - 1))
P \<noteq> Q
prime P
prime Q
d \<noteq> 0
[e * d = 1] (mod P - 1)

goal (1 subgoal):
 1. 1 \<le> e * d
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
1 \<le> e * d

goal (1 subgoal):
 1. \<exists>k. e * d = 1 + k * (P - 1)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
1 \<le> e * d
[PROOF STEP]
obtain k where k: "e*d = 1 + k*(P-1)"
[PROOF STATE]
proof (prove)
using this:
1 \<le> e * d

goal (1 subgoal):
 1. (\<And>k. e * d = 1 + k * (P - 1) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using assms(6) cong_to_1'_nat
[PROOF STATE]
proof (prove)
using this:
1 \<le> e * d
[e * d = 1] (mod P - 1)
[?a = 1] (mod ?n) = (?a = 0 \<and> ?n = 1 \<or> (\<exists>m. ?a = 1 + m * ?n))

goal (1 subgoal):
 1. (\<And>k. e * d = 1 + k * (P - 1) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
e * d = 1 + k * (P - 1)

goal (1 subgoal):
 1. \<exists>k. e * d = 1 + k * (P - 1)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
e * d = 1 + k * (P - 1)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
e * d = 1 + k * (P - 1)

goal (1 subgoal):
 1. \<exists>k. e * d = 1 + k * (P - 1)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<exists>k. e * d = 1 + k * (P - 1)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma n_nodes_reflect: "n_nodes (reflect t) = n_nodes t"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n_nodes (reflect t) = n_nodes t
[PROOF STEP]
proof (induct t)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. n_nodes (reflect Lf) = n_nodes Lf
 2. \<And>x1 t1 t2. \<lbrakk>n_nodes (reflect t1) = n_nodes t1; n_nodes (reflect t2) = n_nodes t2\<rbrakk> \<Longrightarrow> n_nodes (reflect (Br x1 t1 t2)) = n_nodes (Br x1 t1 t2)
[PROOF STEP]
case Lf
[PROOF STATE]
proof (state)
this:

goal (2 subgoals):
 1. n_nodes (reflect Lf) = n_nodes Lf
 2. \<And>x1 t1 t2. \<lbrakk>n_nodes (reflect t1) = n_nodes t1; n_nodes (reflect t2) = n_nodes t2\<rbrakk> \<Longrightarrow> n_nodes (reflect (Br x1 t1 t2)) = n_nodes (Br x1 t1 t2)
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n_nodes (reflect Lf) = n_nodes Lf
[PROOF STEP]
by (metis reflect.simps(1))
[PROOF STATE]
proof (state)
this:
n_nodes (reflect Lf) = n_nodes Lf

goal (1 subgoal):
 1. \<And>x1 t1 t2. \<lbrakk>n_nodes (reflect t1) = n_nodes t1; n_nodes (reflect t2) = n_nodes t2\<rbrakk> \<Longrightarrow> n_nodes (reflect (Br x1 t1 t2)) = n_nodes (Br x1 t1 t2)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x1 t1 t2. \<lbrakk>n_nodes (reflect t1) = n_nodes t1; n_nodes (reflect t2) = n_nodes t2\<rbrakk> \<Longrightarrow> n_nodes (reflect (Br x1 t1 t2)) = n_nodes (Br x1 t1 t2)
[PROOF STEP]
case (Br a t1 t2)
[PROOF STATE]
proof (state)
this:
n_nodes (reflect t1) = n_nodes t1
n_nodes (reflect t2) = n_nodes t2

goal (1 subgoal):
 1. \<And>x1 t1 t2. \<lbrakk>n_nodes (reflect t1) = n_nodes t1; n_nodes (reflect t2) = n_nodes t2\<rbrakk> \<Longrightarrow> n_nodes (reflect (Br x1 t1 t2)) = n_nodes (Br x1 t1 t2)
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
using this:
n_nodes (reflect t1) = n_nodes t1
n_nodes (reflect t2) = n_nodes t2

goal (1 subgoal):
 1. n_nodes (reflect (Br a t1 t2)) = n_nodes (Br a t1 t2)
[PROOF STEP]
by (metis add.commute n_nodes.simps(2) reflect.simps(2))
[PROOF STATE]
proof (state)
this:
n_nodes (reflect (Br a t1 t2)) = n_nodes (Br a t1 t2)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma sorted_list_of_set_split':
  assumes "finite X"
  shows "sorted_list_of_set X = sorted_list_of_set {x \<in> X. x \<le> y} @ sorted_list_of_set {x \<in> X. y < x}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sorted_list_of_set X = sorted_list_of_set {x \<in> X. x \<le> y} @ sorted_list_of_set {x \<in> X. y < x}
[PROOF STEP]
using sorted_list_of_set_split[of X]
[PROOF STATE]
proof (prove)
using this:
finite X \<Longrightarrow> sorted_list_of_set X = sorted_list_of_set {x \<in> X. x < ?y} @ sorted_list_of_set {x \<in> X. ?y \<le> x}

goal (1 subgoal):
 1. sorted_list_of_set X = sorted_list_of_set {x \<in> X. x \<le> y} @ sorted_list_of_set {x \<in> X. y < x}
[PROOF STEP]
proof (cases "\<exists>x \<in> X. y < x")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<lbrakk>\<And>y. finite X \<Longrightarrow> sorted_list_of_set X = sorted_list_of_set {x \<in> X. x < y} @ sorted_list_of_set {x \<in> X. y \<le> x}; \<exists>x\<in>X. y < x\<rbrakk> \<Longrightarrow> sorted_list_of_set X = sorted_list_of_set {x \<in> X. x \<le> y} @ sorted_list_of_set {x \<in> X. y < x}
 2. \<lbrakk>\<And>y. finite X \<Longrightarrow> sorted_list_of_set X = sorted_list_of_set {x \<in> X. x < y} @ sorted_list_of_set {x \<in> X. y \<le> x}; \<not> (\<exists>x\<in>X. y < x)\<rbrakk> \<Longrightarrow> sorted_list_of_set X = sorted_list_of_set {x \<in> X. x \<le> y} @ sorted_list_of_set {x \<in> X. y < x}
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
\<exists>x\<in>X. y < x

goal (2 subgoals):
 1. \<lbrakk>\<And>y. finite X \<Longrightarrow> sorted_list_of_set X = sorted_list_of_set {x \<in> X. x < y} @ sorted_list_of_set {x \<in> X. y \<le> x}; \<exists>x\<in>X. y < x\<rbrakk> \<Longrightarrow> sorted_list_of_set X = sorted_list_of_set {x \<in> X. x \<le> y} @ sorted_list_of_set {x \<in> X. y < x}
 2. \<lbrakk>\<And>y. finite X \<Longrightarrow> sorted_list_of_set X = sorted_list_of_set {x \<in> X. x < y} @ sorted_list_of_set {x \<in> X. y \<le> x}; \<not> (\<exists>x\<in>X. y < x)\<rbrakk> \<Longrightarrow> sorted_list_of_set X = sorted_list_of_set {x \<in> X. x \<le> y} @ sorted_list_of_set {x \<in> X. y < x}
[PROOF STEP]
hence "{x \<in> X. x \<le> y} = {x \<in> X. x < Min {x \<in> X. y < x}}"
[PROOF STATE]
proof (prove)
using this:
\<exists>x\<in>X. y < x

goal (1 subgoal):
 1. {x \<in> X. x \<le> y} = {x \<in> X. x < Min {x \<in> X. y < x}}
[PROOF STEP]
using assms True
[PROOF STATE]
proof (prove)
using this:
\<exists>x\<in>X. y < x
finite X
\<exists>x\<in>X. y < x

goal (1 subgoal):
 1. {x \<in> X. x \<le> y} = {x \<in> X. x < Min {x \<in> X. y < x}}
[PROOF STEP]
by (subst Min_gr_iff) auto
[PROOF STATE]
proof (state)
this:
{x \<in> X. x \<le> y} = {x \<in> X. x < Min {x \<in> X. y < x}}

goal (2 subgoals):
 1. \<lbrakk>\<And>y. finite X \<Longrightarrow> sorted_list_of_set X = sorted_list_of_set {x \<in> X. x < y} @ sorted_list_of_set {x \<in> X. y \<le> x}; \<exists>x\<in>X. y < x\<rbrakk> \<Longrightarrow> sorted_list_of_set X = sorted_list_of_set {x \<in> X. x \<le> y} @ sorted_list_of_set {x \<in> X. y < x}
 2. \<lbrakk>\<And>y. finite X \<Longrightarrow> sorted_list_of_set X = sorted_list_of_set {x \<in> X. x < y} @ sorted_list_of_set {x \<in> X. y \<le> x}; \<not> (\<exists>x\<in>X. y < x)\<rbrakk> \<Longrightarrow> sorted_list_of_set X = sorted_list_of_set {x \<in> X. x \<le> y} @ sorted_list_of_set {x \<in> X. y < x}
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
{x \<in> X. x \<le> y} = {x \<in> X. x < Min {x \<in> X. y < x}}

goal (2 subgoals):
 1. \<lbrakk>\<And>y. finite X \<Longrightarrow> sorted_list_of_set X = sorted_list_of_set {x \<in> X. x < y} @ sorted_list_of_set {x \<in> X. y \<le> x}; \<exists>x\<in>X. y < x\<rbrakk> \<Longrightarrow> sorted_list_of_set X = sorted_list_of_set {x \<in> X. x \<le> y} @ sorted_list_of_set {x \<in> X. y < x}
 2. \<lbrakk>\<And>y. finite X \<Longrightarrow> sorted_list_of_set X = sorted_list_of_set {x \<in> X. x < y} @ sorted_list_of_set {x \<in> X. y \<le> x}; \<not> (\<exists>x\<in>X. y < x)\<rbrakk> \<Longrightarrow> sorted_list_of_set X = sorted_list_of_set {x \<in> X. x \<le> y} @ sorted_list_of_set {x \<in> X. y < x}
[PROOF STEP]
have "{x \<in> X. y < x} = {x \<in> X. Min {x \<in> X. y < x} \<le>  x}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {x \<in> X. y < x} = {x \<in> X. Min {x \<in> X. y < x} \<le> x}
[PROOF STEP]
using assms True
[PROOF STATE]
proof (prove)
using this:
finite X
\<exists>x\<in>X. y < x

goal (1 subgoal):
 1. {x \<in> X. y < x} = {x \<in> X. Min {x \<in> X. y < x} \<le> x}
[PROOF STEP]
by (subst Min_le_iff) auto
[PROOF STATE]
proof (state)
this:
{x \<in> X. y < x} = {x \<in> X. Min {x \<in> X. y < x} \<le> x}

goal (2 subgoals):
 1. \<lbrakk>\<And>y. finite X \<Longrightarrow> sorted_list_of_set X = sorted_list_of_set {x \<in> X. x < y} @ sorted_list_of_set {x \<in> X. y \<le> x}; \<exists>x\<in>X. y < x\<rbrakk> \<Longrightarrow> sorted_list_of_set X = sorted_list_of_set {x \<in> X. x \<le> y} @ sorted_list_of_set {x \<in> X. y < x}
 2. \<lbrakk>\<And>y. finite X \<Longrightarrow> sorted_list_of_set X = sorted_list_of_set {x \<in> X. x < y} @ sorted_list_of_set {x \<in> X. y \<le> x}; \<not> (\<exists>x\<in>X. y < x)\<rbrakk> \<Longrightarrow> sorted_list_of_set X = sorted_list_of_set {x \<in> X. x \<le> y} @ sorted_list_of_set {x \<in> X. y < x}
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
{x \<in> X. x \<le> y} = {x \<in> X. x < Min {x \<in> X. y < x}}
{x \<in> X. y < x} = {x \<in> X. Min {x \<in> X. y < x} \<le> x}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
{x \<in> X. x \<le> y} = {x \<in> X. x < Min {x \<in> X. y < x}}
{x \<in> X. y < x} = {x \<in> X. Min {x \<in> X. y < x} \<le> x}

goal (1 subgoal):
 1. sorted_list_of_set X = sorted_list_of_set {x \<in> X. x \<le> y} @ sorted_list_of_set {x \<in> X. y < x}
[PROOF STEP]
using sorted_list_of_set_split[OF assms, of "Min {x \<in> X. y < x}"]
[PROOF STATE]
proof (prove)
using this:
{x \<in> X. x \<le> y} = {x \<in> X. x < Min {x \<in> X. y < x}}
{x \<in> X. y < x} = {x \<in> X. Min {x \<in> X. y < x} \<le> x}
sorted_list_of_set X = sorted_list_of_set {x \<in> X. x < Min {x \<in> X. y < x}} @ sorted_list_of_set {x \<in> X. Min {x \<in> X. y < x} \<le> x}

goal (1 subgoal):
 1. sorted_list_of_set X = sorted_list_of_set {x \<in> X. x \<le> y} @ sorted_list_of_set {x \<in> X. y < x}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
sorted_list_of_set X = sorted_list_of_set {x \<in> X. x \<le> y} @ sorted_list_of_set {x \<in> X. y < x}

goal (1 subgoal):
 1. \<lbrakk>\<And>y. finite X \<Longrightarrow> sorted_list_of_set X = sorted_list_of_set {x \<in> X. x < y} @ sorted_list_of_set {x \<in> X. y \<le> x}; \<not> (\<exists>x\<in>X. y < x)\<rbrakk> \<Longrightarrow> sorted_list_of_set X = sorted_list_of_set {x \<in> X. x \<le> y} @ sorted_list_of_set {x \<in> X. y < x}
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<lbrakk>\<And>y. finite X \<Longrightarrow> sorted_list_of_set X = sorted_list_of_set {x \<in> X. x < y} @ sorted_list_of_set {x \<in> X. y \<le> x}; \<not> (\<exists>x\<in>X. y < x)\<rbrakk> \<Longrightarrow> sorted_list_of_set X = sorted_list_of_set {x \<in> X. x \<le> y} @ sorted_list_of_set {x \<in> X. y < x}
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> (\<exists>x\<in>X. y < x)

goal (1 subgoal):
 1. \<lbrakk>\<And>y. finite X \<Longrightarrow> sorted_list_of_set X = sorted_list_of_set {x \<in> X. x < y} @ sorted_list_of_set {x \<in> X. y \<le> x}; \<not> (\<exists>x\<in>X. y < x)\<rbrakk> \<Longrightarrow> sorted_list_of_set X = sorted_list_of_set {x \<in> X. x \<le> y} @ sorted_list_of_set {x \<in> X. y < x}
[PROOF STEP]
hence *: "{x \<in> X. y < x} = {}" "{x \<in> X. x \<le> y} = X"
[PROOF STATE]
proof (prove)
using this:
\<not> (\<exists>x\<in>X. y < x)

goal (1 subgoal):
 1. {x \<in> X. y < x} = {} &&& {x \<in> X. x \<le> y} = X
[PROOF STEP]
by (auto simp add:linorder_class.not_less)
[PROOF STATE]
proof (state)
this:
{x \<in> X. y < x} = {}
{x \<in> X. x \<le> y} = X

goal (1 subgoal):
 1. \<lbrakk>\<And>y. finite X \<Longrightarrow> sorted_list_of_set X = sorted_list_of_set {x \<in> X. x < y} @ sorted_list_of_set {x \<in> X. y \<le> x}; \<not> (\<exists>x\<in>X. y < x)\<rbrakk> \<Longrightarrow> sorted_list_of_set X = sorted_list_of_set {x \<in> X. x \<le> y} @ sorted_list_of_set {x \<in> X. y < x}
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
{x \<in> X. y < x} = {}
{x \<in> X. x \<le> y} = X

goal (1 subgoal):
 1. sorted_list_of_set X = sorted_list_of_set {x \<in> X. x \<le> y} @ sorted_list_of_set {x \<in> X. y < x}
[PROOF STEP]
using False
[PROOF STATE]
proof (prove)
using this:
{x \<in> X. y < x} = {}
{x \<in> X. x \<le> y} = X
\<not> (\<exists>x\<in>X. y < x)

goal (1 subgoal):
 1. sorted_list_of_set X = sorted_list_of_set {x \<in> X. x \<le> y} @ sorted_list_of_set {x \<in> X. y < x}
[PROOF STEP]
by (auto simp: *)
[PROOF STATE]
proof (state)
this:
sorted_list_of_set X = sorted_list_of_set {x \<in> X. x \<le> y} @ sorted_list_of_set {x \<in> X. y < x}

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma homeomorphism_compose:
  assumes "homeomorphism S T f g" "homeomorphism T U h k"
    shows "homeomorphism S U (h o f) (g o k)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. homeomorphism S U (h \<circ> f) (g \<circ> k)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
homeomorphism S T f g
homeomorphism T U h k

goal (1 subgoal):
 1. homeomorphism S U (h \<circ> f) (g \<circ> k)
[PROOF STEP]
unfolding homeomorphism_def
[PROOF STATE]
proof (prove)
using this:
(\<forall>x\<in>S. g (f x) = x) \<and> f ` S = T \<and> continuous_on S f \<and> (\<forall>y\<in>T. f (g y) = y) \<and> g ` T = S \<and> continuous_on T g
(\<forall>x\<in>T. k (h x) = x) \<and> h ` T = U \<and> continuous_on T h \<and> (\<forall>y\<in>U. h (k y) = y) \<and> k ` U = T \<and> continuous_on U k

goal (1 subgoal):
 1. (\<forall>x\<in>S. (g \<circ> k) ((h \<circ> f) x) = x) \<and> (h \<circ> f) ` S = U \<and> continuous_on S (h \<circ> f) \<and> (\<forall>y\<in>U. (h \<circ> f) ((g \<circ> k) y) = y) \<and> (g \<circ> k) ` U = S \<and> continuous_on U (g \<circ> k)
[PROOF STEP]
by (intro conjI ballI continuous_on_compose) (auto simp: image_iff)


[STATEMENT]
lemma mult_all1_matrix:
assumes "i < nr"
shows "((all1_matrix nr (dim_vec v)) *\<^sub>v v) $ i = sum_list (list_of_vec v)" (is "?a $ i = sum_list (list_of_vec v)")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (all1_matrix nr (dim_vec v) *\<^sub>v v) $ i = sum_list (list_of_vec v)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (all1_matrix nr (dim_vec v) *\<^sub>v v) $ i = sum_list (list_of_vec v)
[PROOF STEP]
have "?a $ i = row (all1_matrix nr (dim_vec v)) i \<bullet> v"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (all1_matrix nr (dim_vec v) *\<^sub>v v) $ i = row (all1_matrix nr (dim_vec v)) i \<bullet> v
[PROOF STEP]
using index_mult_mat_vec assms all1_matrix_dim
[PROOF STATE]
proof (prove)
using this:
?i < dim_row ?A \<Longrightarrow> (?A *\<^sub>v ?v) $ ?i = row ?A ?i \<bullet> ?v
i < nr
dim_row (all1_matrix ?nr ?nc) = ?nr
dim_col (all1_matrix ?nr ?nc) = ?nc

goal (1 subgoal):
 1. (all1_matrix nr (dim_vec v) *\<^sub>v v) $ i = row (all1_matrix nr (dim_vec v)) i \<bullet> v
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(all1_matrix nr (dim_vec v) *\<^sub>v v) $ i = row (all1_matrix nr (dim_vec v)) i \<bullet> v

goal (1 subgoal):
 1. (all1_matrix nr (dim_vec v) *\<^sub>v v) $ i = sum_list (list_of_vec v)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(all1_matrix nr (dim_vec v) *\<^sub>v v) $ i = row (all1_matrix nr (dim_vec v)) i \<bullet> v

goal (1 subgoal):
 1. (all1_matrix nr (dim_vec v) *\<^sub>v v) $ i = sum_list (list_of_vec v)
[PROOF STEP]
have "... = sum_list (list_of_vec v)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. row (all1_matrix nr (dim_vec v)) i \<bullet> v = sum_list (list_of_vec v)
[PROOF STEP]
unfolding row_all1_matrix[OF assms]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. all1_vec (dim_vec v) \<bullet> v = sum_list (list_of_vec v)
[PROOF STEP]
using all1_vec_scalar_prod[of "list_of_vec v"]
[PROOF STATE]
proof (prove)
using this:
all1_vec (length (list_of_vec v)) \<bullet> vec_of_list (list_of_vec v) = sum_list (list_of_vec v)

goal (1 subgoal):
 1. all1_vec (dim_vec v) \<bullet> v = sum_list (list_of_vec v)
[PROOF STEP]
by (metis vec.abs_eq dim_vec vec_list vec_of_list.abs_eq)
[PROOF STATE]
proof (state)
this:
row (all1_matrix nr (dim_vec v)) i \<bullet> v = sum_list (list_of_vec v)

goal (1 subgoal):
 1. (all1_matrix nr (dim_vec v) *\<^sub>v v) $ i = sum_list (list_of_vec v)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(all1_matrix nr (dim_vec v) *\<^sub>v v) $ i = sum_list (list_of_vec v)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(all1_matrix nr (dim_vec v) *\<^sub>v v) $ i = sum_list (list_of_vec v)

goal (1 subgoal):
 1. (all1_matrix nr (dim_vec v) *\<^sub>v v) $ i = sum_list (list_of_vec v)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(all1_matrix nr (dim_vec v) *\<^sub>v v) $ i = sum_list (list_of_vec v)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma Sum_any_uminus: "Sum_any (\<lambda>x. -f x :: 'a :: ab_group_add) = -Sum_any f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>x. - f x) = - Sum_any f
[PROOF STEP]
by (simp add: Sum_any.expand_set sum_negf)


[STATEMENT]
lemma i_set_mult_subset_imp_mod_0: "
  \<lbrakk> a \<noteq> Suc 0; (i_set_mult a \<subseteq> i_set_mult b) \<rbrakk> \<Longrightarrow> a mod b = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>a \<noteq> Suc 0; i_set_mult a \<subseteq> i_set_mult b\<rbrakk> \<Longrightarrow> a mod b = 0
[PROOF STEP]
apply (simp add: subset_iff)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>a \<noteq> Suc 0; \<forall>t. t \<in> i_set_mult a \<longrightarrow> t \<in> i_set_mult b\<rbrakk> \<Longrightarrow> a mod b = 0
[PROOF STEP]
apply (erule_tac x="[0, mod a]" in allE)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>a \<noteq> Suc 0; [ 0, mod a ] \<in> i_set_mult a \<longrightarrow> [ 0, mod a ] \<in> i_set_mult b\<rbrakk> \<Longrightarrow> a mod b = 0
[PROOF STEP]
apply (simp add: divisor_mod_0_imp_iMOD_in_i_set_mult)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>a \<noteq> Suc 0; [ 0, mod a ] \<in> i_set_mult b\<rbrakk> \<Longrightarrow> a mod b = 0
[PROOF STEP]
apply (simp add: iMOD_in_i_set_mult_imp_divisor_mod_0[of _ 0 b])
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma transfer_group:
  assumes "Derive.iso f g"
  shows "group_law INVERSE NEUTRAL MULT \<Longrightarrow> group_law (\<lambda> x. g (INVERSE (f x))) (g NEUTRAL) (\<lambda>x y. g (MULT (f x) (f y)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. group_law INVERSE NEUTRAL MULT \<Longrightarrow> group_law (\<lambda>x. g (INVERSE (f x))) (g NEUTRAL) (\<lambda>x y. g (MULT (f x) (f y)))
[PROOF STEP]
unfolding group_law_def monoidl_law_def semigroup_law_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<forall>x. MULT (INVERSE x) x = NEUTRAL) \<and> (\<forall>x. MULT NEUTRAL x = x) \<and> (\<forall>x y z. MULT (MULT x y) z = MULT x (MULT y z)) \<Longrightarrow> (\<forall>x. g (MULT (f (g (INVERSE (f x)))) (f x)) = g NEUTRAL) \<and> (\<forall>x. g (MULT (f (g NEUTRAL)) (f x)) = x) \<and> (\<forall>x y z. g (MULT (f (g (MULT (f x) (f y)))) (f z)) = g (MULT (f x) (f (g (MULT (f y) (f z))))))
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
Derive.iso f g

goal (1 subgoal):
 1. (\<forall>x. MULT (INVERSE x) x = NEUTRAL) \<and> (\<forall>x. MULT NEUTRAL x = x) \<and> (\<forall>x y z. MULT (MULT x y) z = MULT x (MULT y z)) \<Longrightarrow> (\<forall>x. g (MULT (f (g (INVERSE (f x)))) (f x)) = g NEUTRAL) \<and> (\<forall>x. g (MULT (f (g NEUTRAL)) (f x)) = x) \<and> (\<forall>x y z. g (MULT (f (g (MULT (f x) (f y)))) (f z)) = g (MULT (f x) (f (g (MULT (f y) (f z))))))
[PROOF STEP]
unfolding Derive.iso_def
[PROOF STATE]
proof (prove)
using this:
(\<forall>a. g (f a) = a) \<and> (\<forall>b. f (g b) = b)

goal (1 subgoal):
 1. (\<forall>x. MULT (INVERSE x) x = NEUTRAL) \<and> (\<forall>x. MULT NEUTRAL x = x) \<and> (\<forall>x y z. MULT (MULT x y) z = MULT x (MULT y z)) \<Longrightarrow> (\<forall>x. g (MULT (f (g (INVERSE (f x)))) (f x)) = g NEUTRAL) \<and> (\<forall>x. g (MULT (f (g NEUTRAL)) (f x)) = x) \<and> (\<forall>x y z. g (MULT (f (g (MULT (f x) (f y)))) (f z)) = g (MULT (f x) (f (g (MULT (f y) (f z))))))
[PROOF STEP]
by simp


[STATEMENT]
lemma linear_singular_image_hyperplane:
  fixes f :: "'n::euclidean_space \<Rightarrow> 'n"
  assumes "linear f" "\<not>inj f"
  obtains a where "a \<noteq> 0" "\<And>S. f ` S \<subseteq> {x. a \<bullet> x = 0}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>a. \<lbrakk>a \<noteq> (0::'n); \<And>S. f ` S \<subseteq> {x. a \<bullet> x = 0}\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
linear f
\<not> inj f

goal (1 subgoal):
 1. (\<And>a. \<lbrakk>a \<noteq> (0::'n); \<And>S. f ` S \<subseteq> {x. a \<bullet> x = 0}\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (fastforce simp add: linear_singular_into_hyperplane)


[STATEMENT]
lemma mat_append_col_vec_index:
  assumes "i < dim_row A"
    and "dim_row A = dim_vec b"
  shows "(row (mat_append_col A b) i) $ (dim_col A) = b $ i"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. row (mat_append_col A b) i $ dim_col A = b $ i
[PROOF STEP]
using mat_append_col_col
[PROOF STATE]
proof (prove)
using this:
dim_row ?A = dim_vec ?b \<Longrightarrow> col (mat_append_col ?A ?b) (dim_col ?A) = ?b

goal (1 subgoal):
 1. row (mat_append_col A b) i $ dim_col A = b $ i
[PROOF STEP]
by (metis (no_types, lifting) One_nat_def add_Suc_right assms(1) assms(2) carrier_matD(2)
      col_def dim_row_mat(1) index_row(1) index_vec lessI mat_append_col.simps
      mat_append_col_dims mat_of_cols_def semiring_norm(51))


[STATEMENT]
lemma powr_powr_swap: "(x powr a) powr b = (x powr b) powr a"
  for a b x :: real
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (x powr a) powr b = (x powr b) powr a
[PROOF STEP]
by (simp add: powr_powr mult.commute)


[STATEMENT]
lemma ccINF_commute: "countable A \<Longrightarrow> countable B \<Longrightarrow> (INF i\<in>A. INF j\<in>B. f i j) = (INF j\<in>B. INF i\<in>A. f i j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>countable A; countable B\<rbrakk> \<Longrightarrow> (INF i\<in>A. Inf (f i ` B)) = (INF j\<in>B. INF i\<in>A. f i j)
[PROOF STEP]
by (iprover intro: ccINF_lower ccINF_greatest order_trans order.antisym)


[STATEMENT]
lemma degree_prod_monom: "degree (\<Prod>i = 0..<n. monom 1 1) = n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. degree (\<Prod>i = 0..<n. monom (1::'a) 1) = n
[PROOF STEP]
by (metis degree_monom_eq prod_pow x_pow_n zero_neq_one)


[STATEMENT]
lemma of_nat_times_monomial: "of_nat p * monomial c i = monomial (p*c) i"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. of_nat p * monomial c i = monomial (p * c) i
[PROOF STEP]
by (auto simp: poly_mapping_eq_iff prod_fun_def fun_eq_iff of_nat_monomial
      lookup_single mult_single)


[STATEMENT]
lemma qf3_even_general: "\<lbrakk> is_qfN A 3; even A \<rbrakk>
  \<Longrightarrow> \<exists> B. A = 4*B \<and> is_qfN B 3"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>is_qfN A 3; even A\<rbrakk> \<Longrightarrow> \<exists>B. A = 4 * B \<and> is_qfN B 3
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<lbrakk>is_qfN A 3; even A\<rbrakk> \<Longrightarrow> \<exists>B. A = 4 * B \<and> is_qfN B 3
[PROOF STEP]
assume "even A" and "is_qfN A 3"
[PROOF STATE]
proof (state)
this:
even A
is_qfN A 3

goal (1 subgoal):
 1. \<lbrakk>is_qfN A 3; even A\<rbrakk> \<Longrightarrow> \<exists>B. A = 4 * B \<and> is_qfN B 3
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
even A
is_qfN A 3
[PROOF STEP]
obtain a b where "A = a^2 + 3*b^2"
    and "even (a^2 + 3*b^2)"
[PROOF STATE]
proof (prove)
using this:
even A
is_qfN A 3

goal (1 subgoal):
 1. (\<And>a b. \<lbrakk>A = a\<^sup>2 + 3 * b\<^sup>2; even (a\<^sup>2 + 3 * b\<^sup>2)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (unfold is_qfN_def, auto)
[PROOF STATE]
proof (state)
this:
A = a\<^sup>2 + 3 * b\<^sup>2
even (a\<^sup>2 + 3 * b\<^sup>2)

goal (1 subgoal):
 1. \<lbrakk>is_qfN A 3; even A\<rbrakk> \<Longrightarrow> \<exists>B. A = 4 * B \<and> is_qfN B 3
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
A = a\<^sup>2 + 3 * b\<^sup>2
even (a\<^sup>2 + 3 * b\<^sup>2)

goal (1 subgoal):
 1. \<exists>B. A = 4 * B \<and> is_qfN B 3
[PROOF STEP]
by (auto simp add: qf3_even)
[PROOF STATE]
proof (state)
this:
\<exists>B. A = 4 * B \<and> is_qfN B 3

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma rtrancl_unfold: "(x, z) \<in> rtrancl R \<Longrightarrow>
  x = z \<or> (\<exists>y. (x, y) \<in> R \<and> x \<noteq> y \<and> (y, z) \<in> rtrancl R)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (x, z) \<in> R\<^sup>* \<Longrightarrow> x = z \<or> (\<exists>y. (x, y) \<in> R \<and> x \<noteq> y \<and> (y, z) \<in> R\<^sup>*)
[PROOF STEP]
by (induction x z rule: rtrancl.induct) auto


[STATEMENT]
lemma prime_factors_lcm [simp]:
  "a \<noteq> 0 \<Longrightarrow> b \<noteq> 0 \<Longrightarrow> prime_factors (lcm a b) =
     prime_factors a \<union> prime_factors b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>a \<noteq> (0::'a); b \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> prime_factors (lcm a b) = prime_factors a \<union> prime_factors b
[PROOF STEP]
by (subst prime_factorization_lcm) auto


[STATEMENT]
lemma has_fps_expansion_minus [fps_expansion_intros]:
  assumes "f has_fps_expansion F"
  shows   "(\<lambda>x. - f x) has_fps_expansion -F"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. - f x) has_fps_expansion - F
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<lambda>x. - f x) has_fps_expansion - F
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
f has_fps_expansion F
[PROOF STEP]
have "eventually (\<lambda>x. x \<in> eball 0 (fps_conv_radius F)) (nhds 0)"
[PROOF STATE]
proof (prove)
using this:
f has_fps_expansion F

goal (1 subgoal):
 1. \<forall>\<^sub>F x in nhds (0::'b). x \<in> eball (0::'b) (fps_conv_radius F)
[PROOF STEP]
by (intro eventually_nhds_in_open) (auto simp: has_fps_expansion_def zero_ereal_def)
[PROOF STATE]
proof (state)
this:
\<forall>\<^sub>F x in nhds (0::?'b1). x \<in> eball (0::?'b1) (fps_conv_radius F)

goal (1 subgoal):
 1. (\<lambda>x. - f x) has_fps_expansion - F
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
\<forall>\<^sub>F x in nhds (0::?'b1). x \<in> eball (0::?'b1) (fps_conv_radius F)

goal (1 subgoal):
 1. (\<lambda>x. - f x) has_fps_expansion - F
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
f has_fps_expansion F
[PROOF STEP]
have "eventually (\<lambda>x. eval_fps F x = f x) (nhds 0)"
[PROOF STATE]
proof (prove)
using this:
f has_fps_expansion F

goal (1 subgoal):
 1. \<forall>\<^sub>F x in nhds (0::'a). eval_fps F x = f x
[PROOF STEP]
by (auto simp: has_fps_expansion_def)
[PROOF STATE]
proof (state)
this:
\<forall>\<^sub>F x in nhds (0::'a). eval_fps F x = f x

goal (1 subgoal):
 1. (\<lambda>x. - f x) has_fps_expansion - F
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
\<forall>\<^sub>F x in nhds (0::?'b1). x \<in> eball (0::?'b1) (fps_conv_radius F)
\<forall>\<^sub>F x in nhds (0::'a). eval_fps F x = f x
[PROOF STEP]
have "eventually (\<lambda>x. eval_fps (-F) x = -f x) (nhds 0)"
[PROOF STATE]
proof (prove)
using this:
\<forall>\<^sub>F x in nhds (0::?'b1). x \<in> eball (0::?'b1) (fps_conv_radius F)
\<forall>\<^sub>F x in nhds (0::'a). eval_fps F x = f x

goal (1 subgoal):
 1. \<forall>\<^sub>F x in nhds (0::'a). eval_fps (- F) x = - f x
[PROOF STEP]
by eventually_elim (auto simp: eval_fps_minus)
[PROOF STATE]
proof (state)
this:
\<forall>\<^sub>F x in nhds (0::'a). eval_fps (- F) x = - f x

goal (1 subgoal):
 1. (\<lambda>x. - f x) has_fps_expansion - F
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
\<forall>\<^sub>F x in nhds (0::'a). eval_fps (- F) x = - f x

goal (1 subgoal):
 1. (\<lambda>x. - f x) has_fps_expansion - F
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
\<forall>\<^sub>F x in nhds (0::'a). eval_fps (- F) x = - f x
f has_fps_expansion F

goal (1 subgoal):
 1. (\<lambda>x. - f x) has_fps_expansion - F
[PROOF STEP]
by (auto simp: has_fps_expansion_def)
[PROOF STATE]
proof (state)
this:
(\<lambda>x. - f x) has_fps_expansion - F

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma expand_powers: fixes f :: "'a \<Rightarrow> 'b :: comm_ring_1"
  shows "(\<Prod> (n,a) \<leftarrow> n_as. f a ^ n) = (\<Prod> a \<leftarrow> expand_powers n_as. f a)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Prod>(n, a)\<leftarrow>n_as. f a ^ n) = prod_list (map f (expand_powers n_as))
[PROOF STEP]
by (rule sym, induct n_as rule: expand_powers.induct, auto)


[STATEMENT]
lemma sum_split2:
  assumes "finite I"
  shows "(\<Sum>i | i \<in> I \<and> P i. if Q i then f i else g i) = (\<Sum>i | i \<in> I \<and> P i \<and> Q i. f i) + (\<Sum>i | i \<in> I \<and> P i \<and> \<not>Q i. g i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i | i \<in> I \<and> P i. if Q i then f i else g i) = (\<Sum>i | i \<in> I \<and> P i \<and> Q i. f i) + (\<Sum>i | i \<in> I \<and> P i \<and> \<not> Q i. g i)
[PROOF STEP]
proof (subst sum.If_cases)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. finite {i \<in> I. P i}
 2. sum f ({i \<in> I. P i} \<inter> Collect Q) + sum g ({i \<in> I. P i} \<inter> - Collect Q) = sum f {i \<in> I. P i \<and> Q i} + sum g {i \<in> I. P i \<and> \<not> Q i}
[PROOF STEP]
show "finite {i \<in> I. P i}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite {i \<in> I. P i}
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
finite I

goal (1 subgoal):
 1. finite {i \<in> I. P i}
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
finite {i \<in> I. P i}

goal (1 subgoal):
 1. sum f ({i \<in> I. P i} \<inter> Collect Q) + sum g ({i \<in> I. P i} \<inter> - Collect Q) = sum f {i \<in> I. P i \<and> Q i} + sum g {i \<in> I. P i \<and> \<not> Q i}
[PROOF STEP]
have "{i \<in> I. P i} \<inter> Collect Q = {i \<in> I. P i \<and> Q i}" "{i \<in> I. P i} \<inter> - Collect Q =  {i \<in> I. P i \<and> \<not> Q i}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {i \<in> I. P i} \<inter> Collect Q = {i \<in> I. P i \<and> Q i} &&& {i \<in> I. P i} \<inter> - Collect Q = {i \<in> I. P i \<and> \<not> Q i}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
{i \<in> I. P i} \<inter> Collect Q = {i \<in> I. P i \<and> Q i}
{i \<in> I. P i} \<inter> - Collect Q = {i \<in> I. P i \<and> \<not> Q i}

goal (1 subgoal):
 1. sum f ({i \<in> I. P i} \<inter> Collect Q) + sum g ({i \<in> I. P i} \<inter> - Collect Q) = sum f {i \<in> I. P i \<and> Q i} + sum g {i \<in> I. P i \<and> \<not> Q i}
[PROOF STEP]
thus "sum f ({i \<in> I. P i} \<inter> Collect Q) + sum g ({i \<in> I. P i} \<inter> - Collect Q) = sum f {i \<in> I. P i \<and> Q i} + sum g {i \<in> I. P i \<and> \<not> Q i}"
[PROOF STATE]
proof (prove)
using this:
{i \<in> I. P i} \<inter> Collect Q = {i \<in> I. P i \<and> Q i}
{i \<in> I. P i} \<inter> - Collect Q = {i \<in> I. P i \<and> \<not> Q i}

goal (1 subgoal):
 1. sum f ({i \<in> I. P i} \<inter> Collect Q) + sum g ({i \<in> I. P i} \<inter> - Collect Q) = sum f {i \<in> I. P i \<and> Q i} + sum g {i \<in> I. P i \<and> \<not> Q i}
[PROOF STEP]
by presburger
[PROOF STATE]
proof (state)
this:
sum f ({i \<in> I. P i} \<inter> Collect Q) + sum g ({i \<in> I. P i} \<inter> - Collect Q) = sum f {i \<in> I. P i \<and> Q i} + sum g {i \<in> I. P i \<and> \<not> Q i}

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma ex1_imp_Collect_singleton: "(\<exists>!x. P x) \<and> P x \<longleftrightarrow> Collect P = {x}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<exists>!x. P x) \<and> P x) = (Collect P = {x})
[PROOF STEP]
proof(intro iffI conjI, unfold conj_imp_eq_imp_imp)
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. \<lbrakk>Ex1 P; P x\<rbrakk> \<Longrightarrow> Collect P = {x}
 2. Collect P = {x} \<Longrightarrow> \<exists>!x. P x
 3. Collect P = {x} \<Longrightarrow> P x
[PROOF STEP]
assume "Ex1 P" "P x"
[PROOF STATE]
proof (state)
this:
Ex1 P
P x

goal (3 subgoals):
 1. \<lbrakk>Ex1 P; P x\<rbrakk> \<Longrightarrow> Collect P = {x}
 2. Collect P = {x} \<Longrightarrow> \<exists>!x. P x
 3. Collect P = {x} \<Longrightarrow> P x
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
Ex1 P
P x
[PROOF STEP]
show "Collect P = {x}"
[PROOF STATE]
proof (prove)
using this:
Ex1 P
P x

goal (1 subgoal):
 1. Collect P = {x}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
Collect P = {x}

goal (2 subgoals):
 1. Collect P = {x} \<Longrightarrow> \<exists>!x. P x
 2. Collect P = {x} \<Longrightarrow> P x
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. Collect P = {x} \<Longrightarrow> \<exists>!x. P x
 2. Collect P = {x} \<Longrightarrow> P x
[PROOF STEP]
assume Px: "Collect P = {x}"
[PROOF STATE]
proof (state)
this:
Collect P = {x}

goal (2 subgoals):
 1. Collect P = {x} \<Longrightarrow> \<exists>!x. P x
 2. Collect P = {x} \<Longrightarrow> P x
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
Collect P = {x}
[PROOF STEP]
have "P y \<longleftrightarrow> x = y" for y
[PROOF STATE]
proof (prove)
using this:
Collect P = {x}

goal (1 subgoal):
 1. P y = (x = y)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
P ?y = (x = ?y)

goal (2 subgoals):
 1. Collect P = {x} \<Longrightarrow> \<exists>!x. P x
 2. Collect P = {x} \<Longrightarrow> P x
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
P ?y = (x = ?y)
[PROOF STEP]
show "Ex1 P"
[PROOF STATE]
proof (prove)
using this:
P ?y = (x = ?y)

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

goal (1 subgoal):
 1. Collect P = {x} \<Longrightarrow> P x
[PROOF STEP]
from Px
[PROOF STATE]
proof (chain)
picking this:
Collect P = {x}
[PROOF STEP]
show "P x"
[PROOF STATE]
proof (prove)
using this:
Collect P = {x}

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

goal:
No subgoals!
[PROOF STEP]
qed