[STATEMENT]
lemma T1_7': "T\<^sub>p init qs Strat = T\<^sub>p_opt init qs \<Longrightarrow> length Strat = length qs
      \<Longrightarrow> n\<le>length qs \<Longrightarrow>
      x\<noteq>(y::('a::linorder)) \<Longrightarrow>
      x\<in> set init \<Longrightarrow> y \<in> set init \<Longrightarrow> distinct init \<Longrightarrow>
      set qs \<subseteq> set init \<Longrightarrow>
      (\<exists>Strat2 sws.
        \<^cancel>\<open>T\<^sub>p_opt (Lxy init {x,y}) (Lxy (take n qs) {x,y}) \<le> T\<^sub>p (Lxy init {x,y}) (Lxy (take n qs) {x,y}) Strat2
          \<and>\<close>  length Strat2 = length (Lxy (take n qs) {x,y})
          \<and>     (x < y in (steps' init (take n qs) (take n Strat) n))
              = (x < y in (swaps sws (steps' (Lxy init {x,y}) (Lxy (take n qs) {x,y}) Strat2 (length Strat2))))
          \<and> T\<^sub>p (Lxy init {x,y}) (Lxy (take n qs) {x,y}) Strat2 + length sws =
          ALGxy_det Strat (take n qs) init x y + ALG_Pxy Strat (take n qs) init x y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>T\<^sub>p init qs Strat = T\<^sub>p_opt init qs; length Strat = length qs; n \<le> length qs; x \<noteq> y; x \<in> set init; y \<in> set init; distinct init; set qs \<subseteq> set init\<rbrakk> \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take n qs) {x, y}) \<and> x < y in steps' init (take n qs) (take n Strat) n = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take n qs) init x y + ALG_Pxy Strat (take n qs) init x y
[PROOF STEP]
proof(induct n)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<lbrakk>T\<^sub>p init qs Strat = T\<^sub>p_opt init qs; length Strat = length qs; 0 \<le> length qs; x \<noteq> y; x \<in> set init; y \<in> set init; distinct init; set qs \<subseteq> set init\<rbrakk> \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take 0 qs) {x, y}) \<and> x < y in steps' init (take 0 qs) (take 0 Strat) 0 = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take 0 qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take 0 qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take 0 qs) init x y + ALG_Pxy Strat (take 0 qs) init x y
 2. \<And>n. \<lbrakk>\<lbrakk>T\<^sub>p init qs Strat = T\<^sub>p_opt init qs; length Strat = length qs; n \<le> length qs; x \<noteq> y; x \<in> set init; y \<in> set init; distinct init; set qs \<subseteq> set init\<rbrakk> \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take n qs) {x, y}) \<and> x < y in steps' init (take n qs) (take n Strat) n = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take n qs) init x y + ALG_Pxy Strat (take n qs) init x y; T\<^sub>p init qs Strat = T\<^sub>p_opt init qs; length Strat = length qs; Suc n \<le> length qs; x \<noteq> y; x \<in> set init; y \<in> set init; distinct init; set qs \<subseteq> set init\<rbrakk> \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
case (Suc n)
[PROOF STATE]
proof (state)
this:
\<lbrakk>T\<^sub>p init qs Strat = T\<^sub>p_opt init qs; length Strat = length qs; n \<le> length qs; x \<noteq> y; x \<in> set init; y \<in> set init; distinct init; set qs \<subseteq> set init\<rbrakk> \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take n qs) {x, y}) \<and> x < y in steps' init (take n qs) (take n Strat) n = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take n qs) init x y + ALG_Pxy Strat (take n qs) init x y
T\<^sub>p init qs Strat = T\<^sub>p_opt init qs
length Strat = length qs
Suc n \<le> length qs
x \<noteq> y
x \<in> set init
y \<in> set init
distinct init
set qs \<subseteq> set init

goal (2 subgoals):
 1. \<lbrakk>T\<^sub>p init qs Strat = T\<^sub>p_opt init qs; length Strat = length qs; 0 \<le> length qs; x \<noteq> y; x \<in> set init; y \<in> set init; distinct init; set qs \<subseteq> set init\<rbrakk> \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take 0 qs) {x, y}) \<and> x < y in steps' init (take 0 qs) (take 0 Strat) 0 = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take 0 qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take 0 qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take 0 qs) init x y + ALG_Pxy Strat (take 0 qs) init x y
 2. \<And>n. \<lbrakk>\<lbrakk>T\<^sub>p init qs Strat = T\<^sub>p_opt init qs; length Strat = length qs; n \<le> length qs; x \<noteq> y; x \<in> set init; y \<in> set init; distinct init; set qs \<subseteq> set init\<rbrakk> \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take n qs) {x, y}) \<and> x < y in steps' init (take n qs) (take n Strat) n = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take n qs) init x y + ALG_Pxy Strat (take n qs) init x y; T\<^sub>p init qs Strat = T\<^sub>p_opt init qs; length Strat = length qs; Suc n \<le> length qs; x \<noteq> y; x \<in> set init; y \<in> set init; distinct init; set qs \<subseteq> set init\<rbrakk> \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
from Suc(3,4)
[PROOF STATE]
proof (chain)
picking this:
length Strat = length qs
Suc n \<le> length qs
[PROOF STEP]
have ns: "n < length qs"
[PROOF STATE]
proof (prove)
using this:
length Strat = length qs
Suc n \<le> length qs

goal (1 subgoal):
 1. n < length qs
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
n < length qs

goal (2 subgoals):
 1. \<lbrakk>T\<^sub>p init qs Strat = T\<^sub>p_opt init qs; length Strat = length qs; 0 \<le> length qs; x \<noteq> y; x \<in> set init; y \<in> set init; distinct init; set qs \<subseteq> set init\<rbrakk> \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take 0 qs) {x, y}) \<and> x < y in steps' init (take 0 qs) (take 0 Strat) 0 = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take 0 qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take 0 qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take 0 qs) init x y + ALG_Pxy Strat (take 0 qs) init x y
 2. \<And>n. \<lbrakk>\<lbrakk>T\<^sub>p init qs Strat = T\<^sub>p_opt init qs; length Strat = length qs; n \<le> length qs; x \<noteq> y; x \<in> set init; y \<in> set init; distinct init; set qs \<subseteq> set init\<rbrakk> \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take n qs) {x, y}) \<and> x < y in steps' init (take n qs) (take n Strat) n = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take n qs) init x y + ALG_Pxy Strat (take n qs) init x y; T\<^sub>p init qs Strat = T\<^sub>p_opt init qs; length Strat = length qs; Suc n \<le> length qs; x \<noteq> y; x \<in> set init; y \<in> set init; distinct init; set qs \<subseteq> set init\<rbrakk> \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
n < length qs
[PROOF STEP]
have n: "n \<le> length qs"
[PROOF STATE]
proof (prove)
using this:
n < length qs

goal (1 subgoal):
 1. n \<le> length qs
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
n \<le> length qs

goal (2 subgoals):
 1. \<lbrakk>T\<^sub>p init qs Strat = T\<^sub>p_opt init qs; length Strat = length qs; 0 \<le> length qs; x \<noteq> y; x \<in> set init; y \<in> set init; distinct init; set qs \<subseteq> set init\<rbrakk> \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take 0 qs) {x, y}) \<and> x < y in steps' init (take 0 qs) (take 0 Strat) 0 = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take 0 qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take 0 qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take 0 qs) init x y + ALG_Pxy Strat (take 0 qs) init x y
 2. \<And>n. \<lbrakk>\<lbrakk>T\<^sub>p init qs Strat = T\<^sub>p_opt init qs; length Strat = length qs; n \<le> length qs; x \<noteq> y; x \<in> set init; y \<in> set init; distinct init; set qs \<subseteq> set init\<rbrakk> \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take n qs) {x, y}) \<and> x < y in steps' init (take n qs) (take n Strat) n = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take n qs) init x y + ALG_Pxy Strat (take n qs) init x y; T\<^sub>p init qs Strat = T\<^sub>p_opt init qs; length Strat = length qs; Suc n \<le> length qs; x \<noteq> y; x \<in> set init; y \<in> set init; distinct init; set qs \<subseteq> set init\<rbrakk> \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
from Suc(1)[OF Suc(2) Suc(3) n Suc(5) Suc(6) Suc(7) Suc(8) Suc(9) ]
[PROOF STATE]
proof (chain)
picking this:
\<exists>Strat2 sws. length Strat2 = length (Lxy (take n qs) {x, y}) \<and> x < y in steps' init (take n qs) (take n Strat) n = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take n qs) init x y + ALG_Pxy Strat (take n qs) init x y
[PROOF STEP]
obtain Strat2 sws where
  (*S2: "T\<^sub>p_opt (Lxy init {x,y}) (Lxy (take n qs) {x, y})
     \<le> T\<^sub>p (Lxy init {x,y}) (Lxy (take n qs) {x, y}) Strat2"
     and *) len: "length Strat2 = length (Lxy (take n qs) {x, y})"
     and iff:
      "x < y in steps' init (take n qs) (take n Strat) n
         =
       x < y in swaps sws (steps' (Lxy init {x,y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))"

     and T_Strat2: "T\<^sub>p (Lxy init {x,y}) (Lxy (take n qs) {x, y}) Strat2 + length sws =
     ALGxy_det Strat (take n qs) init x y +
     ALG_Pxy Strat (take n qs) init x y "
[PROOF STATE]
proof (prove)
using this:
\<exists>Strat2 sws. length Strat2 = length (Lxy (take n qs) {x, y}) \<and> x < y in steps' init (take n qs) (take n Strat) n = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take n qs) init x y + ALG_Pxy Strat (take n qs) init x y

goal (1 subgoal):
 1. (\<And>Strat2 sws. \<lbrakk>length Strat2 = length (Lxy (take n qs) {x, y}); x < y in steps' init (take n qs) (take n Strat) n = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)); T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take n qs) init x y + ALG_Pxy Strat (take n qs) init x y\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (auto)
[PROOF STATE]
proof (state)
this:
length Strat2 = length (Lxy (take n qs) {x, y})
x < y in steps' init (take n qs) (take n Strat) n = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))
T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take n qs) init x y + ALG_Pxy Strat (take n qs) init x y

goal (2 subgoals):
 1. \<lbrakk>T\<^sub>p init qs Strat = T\<^sub>p_opt init qs; length Strat = length qs; 0 \<le> length qs; x \<noteq> y; x \<in> set init; y \<in> set init; distinct init; set qs \<subseteq> set init\<rbrakk> \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take 0 qs) {x, y}) \<and> x < y in steps' init (take 0 qs) (take 0 Strat) 0 = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take 0 qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take 0 qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take 0 qs) init x y + ALG_Pxy Strat (take 0 qs) init x y
 2. \<And>n. \<lbrakk>\<lbrakk>T\<^sub>p init qs Strat = T\<^sub>p_opt init qs; length Strat = length qs; n \<le> length qs; x \<noteq> y; x \<in> set init; y \<in> set init; distinct init; set qs \<subseteq> set init\<rbrakk> \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take n qs) {x, y}) \<and> x < y in steps' init (take n qs) (take n Strat) n = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take n qs) init x y + ALG_Pxy Strat (take n qs) init x y; T\<^sub>p init qs Strat = T\<^sub>p_opt init qs; length Strat = length qs; Suc n \<le> length qs; x \<noteq> y; x \<in> set init; y \<in> set init; distinct init; set qs \<subseteq> set init\<rbrakk> \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
from Suc(3-4)
[PROOF STATE]
proof (chain)
picking this:
length Strat = length qs
Suc n \<le> length qs
[PROOF STEP]
have nStrat: "n < length Strat"
[PROOF STATE]
proof (prove)
using this:
length Strat = length qs
Suc n \<le> length qs

goal (1 subgoal):
 1. n < length Strat
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
n < length Strat

goal (2 subgoals):
 1. \<lbrakk>T\<^sub>p init qs Strat = T\<^sub>p_opt init qs; length Strat = length qs; 0 \<le> length qs; x \<noteq> y; x \<in> set init; y \<in> set init; distinct init; set qs \<subseteq> set init\<rbrakk> \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take 0 qs) {x, y}) \<and> x < y in steps' init (take 0 qs) (take 0 Strat) 0 = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take 0 qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take 0 qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take 0 qs) init x y + ALG_Pxy Strat (take 0 qs) init x y
 2. \<And>n. \<lbrakk>\<lbrakk>T\<^sub>p init qs Strat = T\<^sub>p_opt init qs; length Strat = length qs; n \<le> length qs; x \<noteq> y; x \<in> set init; y \<in> set init; distinct init; set qs \<subseteq> set init\<rbrakk> \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take n qs) {x, y}) \<and> x < y in steps' init (take n qs) (take n Strat) n = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take n qs) init x y + ALG_Pxy Strat (take n qs) init x y; T\<^sub>p init qs Strat = T\<^sub>p_opt init qs; length Strat = length qs; Suc n \<le> length qs; x \<noteq> y; x \<in> set init; y \<in> set init; distinct init; set qs \<subseteq> set init\<rbrakk> \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
from take_Suc_conv_app_nth[OF this]
[PROOF STATE]
proof (chain)
picking this:
take (Suc n) Strat = take n Strat @ [Strat ! n]
[PROOF STEP]
have tak2: "take (Suc n) Strat = take n Strat @ [Strat ! n]"
[PROOF STATE]
proof (prove)
using this:
take (Suc n) Strat = take n Strat @ [Strat ! n]

goal (1 subgoal):
 1. take (Suc n) Strat = take n Strat @ [Strat ! n]
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
take (Suc n) Strat = take n Strat @ [Strat ! n]

goal (2 subgoals):
 1. \<lbrakk>T\<^sub>p init qs Strat = T\<^sub>p_opt init qs; length Strat = length qs; 0 \<le> length qs; x \<noteq> y; x \<in> set init; y \<in> set init; distinct init; set qs \<subseteq> set init\<rbrakk> \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take 0 qs) {x, y}) \<and> x < y in steps' init (take 0 qs) (take 0 Strat) 0 = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take 0 qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take 0 qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take 0 qs) init x y + ALG_Pxy Strat (take 0 qs) init x y
 2. \<And>n. \<lbrakk>\<lbrakk>T\<^sub>p init qs Strat = T\<^sub>p_opt init qs; length Strat = length qs; n \<le> length qs; x \<noteq> y; x \<in> set init; y \<in> set init; distinct init; set qs \<subseteq> set init\<rbrakk> \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take n qs) {x, y}) \<and> x < y in steps' init (take n qs) (take n Strat) n = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take n qs) init x y + ALG_Pxy Strat (take n qs) init x y; T\<^sub>p init qs Strat = T\<^sub>p_opt init qs; length Strat = length qs; Suc n \<le> length qs; x \<noteq> y; x \<in> set init; y \<in> set init; distinct init; set qs \<subseteq> set init\<rbrakk> \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
from take_Suc_conv_app_nth[OF ns]
[PROOF STATE]
proof (chain)
picking this:
take (Suc n) qs = take n qs @ [qs ! n]
[PROOF STEP]
have tak: "take (Suc n) qs = take n qs @ [qs ! n]"
[PROOF STATE]
proof (prove)
using this:
take (Suc n) qs = take n qs @ [qs ! n]

goal (1 subgoal):
 1. take (Suc n) qs = take n qs @ [qs ! n]
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
take (Suc n) qs = take n qs @ [qs ! n]

goal (2 subgoals):
 1. \<lbrakk>T\<^sub>p init qs Strat = T\<^sub>p_opt init qs; length Strat = length qs; 0 \<le> length qs; x \<noteq> y; x \<in> set init; y \<in> set init; distinct init; set qs \<subseteq> set init\<rbrakk> \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take 0 qs) {x, y}) \<and> x < y in steps' init (take 0 qs) (take 0 Strat) 0 = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take 0 qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take 0 qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take 0 qs) init x y + ALG_Pxy Strat (take 0 qs) init x y
 2. \<And>n. \<lbrakk>\<lbrakk>T\<^sub>p init qs Strat = T\<^sub>p_opt init qs; length Strat = length qs; n \<le> length qs; x \<noteq> y; x \<in> set init; y \<in> set init; distinct init; set qs \<subseteq> set init\<rbrakk> \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take n qs) {x, y}) \<and> x < y in steps' init (take n qs) (take n Strat) n = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take n qs) init x y + ALG_Pxy Strat (take n qs) init x y; T\<^sub>p init qs Strat = T\<^sub>p_opt init qs; length Strat = length qs; Suc n \<le> length qs; x \<noteq> y; x \<in> set init; y \<in> set init; distinct init; set qs \<subseteq> set init\<rbrakk> \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
have aS: "length (take n Strat) = n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (take n Strat) = n
[PROOF STEP]
using Suc(3,4)
[PROOF STATE]
proof (prove)
using this:
length Strat = length qs
Suc n \<le> length qs

goal (1 subgoal):
 1. length (take n Strat) = n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
length (take n Strat) = n

goal (2 subgoals):
 1. \<lbrakk>T\<^sub>p init qs Strat = T\<^sub>p_opt init qs; length Strat = length qs; 0 \<le> length qs; x \<noteq> y; x \<in> set init; y \<in> set init; distinct init; set qs \<subseteq> set init\<rbrakk> \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take 0 qs) {x, y}) \<and> x < y in steps' init (take 0 qs) (take 0 Strat) 0 = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take 0 qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take 0 qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take 0 qs) init x y + ALG_Pxy Strat (take 0 qs) init x y
 2. \<And>n. \<lbrakk>\<lbrakk>T\<^sub>p init qs Strat = T\<^sub>p_opt init qs; length Strat = length qs; n \<le> length qs; x \<noteq> y; x \<in> set init; y \<in> set init; distinct init; set qs \<subseteq> set init\<rbrakk> \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take n qs) {x, y}) \<and> x < y in steps' init (take n qs) (take n Strat) n = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take n qs) init x y + ALG_Pxy Strat (take n qs) init x y; T\<^sub>p init qs Strat = T\<^sub>p_opt init qs; length Strat = length qs; Suc n \<le> length qs; x \<noteq> y; x \<in> set init; y \<in> set init; distinct init; set qs \<subseteq> set init\<rbrakk> \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
have aQ: "length (take n qs) = n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (take n qs) = n
[PROOF STEP]
using Suc(4)
[PROOF STATE]
proof (prove)
using this:
Suc n \<le> length qs

goal (1 subgoal):
 1. length (take n qs) = n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
length (take n qs) = n

goal (2 subgoals):
 1. \<lbrakk>T\<^sub>p init qs Strat = T\<^sub>p_opt init qs; length Strat = length qs; 0 \<le> length qs; x \<noteq> y; x \<in> set init; y \<in> set init; distinct init; set qs \<subseteq> set init\<rbrakk> \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take 0 qs) {x, y}) \<and> x < y in steps' init (take 0 qs) (take 0 Strat) 0 = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take 0 qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take 0 qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take 0 qs) init x y + ALG_Pxy Strat (take 0 qs) init x y
 2. \<And>n. \<lbrakk>\<lbrakk>T\<^sub>p init qs Strat = T\<^sub>p_opt init qs; length Strat = length qs; n \<le> length qs; x \<noteq> y; x \<in> set init; y \<in> set init; distinct init; set qs \<subseteq> set init\<rbrakk> \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take n qs) {x, y}) \<and> x < y in steps' init (take n qs) (take n Strat) n = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take n qs) init x y + ALG_Pxy Strat (take n qs) init x y; T\<^sub>p init qs Strat = T\<^sub>p_opt init qs; length Strat = length qs; Suc n \<le> length qs; x \<noteq> y; x \<in> set init; y \<in> set init; distinct init; set qs \<subseteq> set init\<rbrakk> \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
from aS aQ
[PROOF STATE]
proof (chain)
picking this:
length (take n Strat) = n
length (take n qs) = n
[PROOF STEP]
have qQS: "length (take n qs) = length (take n Strat)"
[PROOF STATE]
proof (prove)
using this:
length (take n Strat) = n
length (take n qs) = n

goal (1 subgoal):
 1. length (take n qs) = length (take n Strat)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
length (take n qs) = length (take n Strat)

goal (2 subgoals):
 1. \<lbrakk>T\<^sub>p init qs Strat = T\<^sub>p_opt init qs; length Strat = length qs; 0 \<le> length qs; x \<noteq> y; x \<in> set init; y \<in> set init; distinct init; set qs \<subseteq> set init\<rbrakk> \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take 0 qs) {x, y}) \<and> x < y in steps' init (take 0 qs) (take 0 Strat) 0 = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take 0 qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take 0 qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take 0 qs) init x y + ALG_Pxy Strat (take 0 qs) init x y
 2. \<And>n. \<lbrakk>\<lbrakk>T\<^sub>p init qs Strat = T\<^sub>p_opt init qs; length Strat = length qs; n \<le> length qs; x \<noteq> y; x \<in> set init; y \<in> set init; distinct init; set qs \<subseteq> set init\<rbrakk> \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take n qs) {x, y}) \<and> x < y in steps' init (take n qs) (take n Strat) n = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take n qs) init x y + ALG_Pxy Strat (take n qs) init x y; T\<^sub>p init qs Strat = T\<^sub>p_opt init qs; length Strat = length qs; Suc n \<le> length qs; x \<noteq> y; x \<in> set init; y \<in> set init; distinct init; set qs \<subseteq> set init\<rbrakk> \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
have xyininit: "x\<in> set init" "y : set init"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<in> set init &&& y \<in> set init
[PROOF STEP]
by fact+
[PROOF STATE]
proof (state)
this:
x \<in> set init
y \<in> set init

goal (2 subgoals):
 1. \<lbrakk>T\<^sub>p init qs Strat = T\<^sub>p_opt init qs; length Strat = length qs; 0 \<le> length qs; x \<noteq> y; x \<in> set init; y \<in> set init; distinct init; set qs \<subseteq> set init\<rbrakk> \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take 0 qs) {x, y}) \<and> x < y in steps' init (take 0 qs) (take 0 Strat) 0 = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take 0 qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take 0 qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take 0 qs) init x y + ALG_Pxy Strat (take 0 qs) init x y
 2. \<And>n. \<lbrakk>\<lbrakk>T\<^sub>p init qs Strat = T\<^sub>p_opt init qs; length Strat = length qs; n \<le> length qs; x \<noteq> y; x \<in> set init; y \<in> set init; distinct init; set qs \<subseteq> set init\<rbrakk> \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take n qs) {x, y}) \<and> x < y in steps' init (take n qs) (take n Strat) n = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take n qs) init x y + ALG_Pxy Strat (take n qs) init x y; T\<^sub>p init qs Strat = T\<^sub>p_opt init qs; length Strat = length qs; Suc n \<le> length qs; x \<noteq> y; x \<in> set init; y \<in> set init; distinct init; set qs \<subseteq> set init\<rbrakk> \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
x \<in> set init
y \<in> set init
[PROOF STEP]
have xysubs: "{x,y} \<subseteq> set init"
[PROOF STATE]
proof (prove)
using this:
x \<in> set init
y \<in> set init

goal (1 subgoal):
 1. {x, y} \<subseteq> set init
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
{x, y} \<subseteq> set init

goal (2 subgoals):
 1. \<lbrakk>T\<^sub>p init qs Strat = T\<^sub>p_opt init qs; length Strat = length qs; 0 \<le> length qs; x \<noteq> y; x \<in> set init; y \<in> set init; distinct init; set qs \<subseteq> set init\<rbrakk> \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take 0 qs) {x, y}) \<and> x < y in steps' init (take 0 qs) (take 0 Strat) 0 = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take 0 qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take 0 qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take 0 qs) init x y + ALG_Pxy Strat (take 0 qs) init x y
 2. \<And>n. \<lbrakk>\<lbrakk>T\<^sub>p init qs Strat = T\<^sub>p_opt init qs; length Strat = length qs; n \<le> length qs; x \<noteq> y; x \<in> set init; y \<in> set init; distinct init; set qs \<subseteq> set init\<rbrakk> \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take n qs) {x, y}) \<and> x < y in steps' init (take n qs) (take n Strat) n = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take n qs) init x y + ALG_Pxy Strat (take n qs) init x y; T\<^sub>p init qs Strat = T\<^sub>p_opt init qs; length Strat = length qs; Suc n \<le> length qs; x \<noteq> y; x \<in> set init; y \<in> set init; distinct init; set qs \<subseteq> set init\<rbrakk> \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
have dI:  "distinct init"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. distinct init
[PROOF STEP]
by fact
[PROOF STATE]
proof (state)
this:
distinct init

goal (2 subgoals):
 1. \<lbrakk>T\<^sub>p init qs Strat = T\<^sub>p_opt init qs; length Strat = length qs; 0 \<le> length qs; x \<noteq> y; x \<in> set init; y \<in> set init; distinct init; set qs \<subseteq> set init\<rbrakk> \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take 0 qs) {x, y}) \<and> x < y in steps' init (take 0 qs) (take 0 Strat) 0 = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take 0 qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take 0 qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take 0 qs) init x y + ALG_Pxy Strat (take 0 qs) init x y
 2. \<And>n. \<lbrakk>\<lbrakk>T\<^sub>p init qs Strat = T\<^sub>p_opt init qs; length Strat = length qs; n \<le> length qs; x \<noteq> y; x \<in> set init; y \<in> set init; distinct init; set qs \<subseteq> set init\<rbrakk> \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take n qs) {x, y}) \<and> x < y in steps' init (take n qs) (take n Strat) n = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take n qs) init x y + ALG_Pxy Strat (take n qs) init x y; T\<^sub>p init qs Strat = T\<^sub>p_opt init qs; length Strat = length qs; Suc n \<le> length qs; x \<noteq> y; x \<in> set init; y \<in> set init; distinct init; set qs \<subseteq> set init\<rbrakk> \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
have "set qs \<subseteq> set init"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set qs \<subseteq> set init
[PROOF STEP]
by fact
[PROOF STATE]
proof (state)
this:
set qs \<subseteq> set init

goal (2 subgoals):
 1. \<lbrakk>T\<^sub>p init qs Strat = T\<^sub>p_opt init qs; length Strat = length qs; 0 \<le> length qs; x \<noteq> y; x \<in> set init; y \<in> set init; distinct init; set qs \<subseteq> set init\<rbrakk> \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take 0 qs) {x, y}) \<and> x < y in steps' init (take 0 qs) (take 0 Strat) 0 = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take 0 qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take 0 qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take 0 qs) init x y + ALG_Pxy Strat (take 0 qs) init x y
 2. \<And>n. \<lbrakk>\<lbrakk>T\<^sub>p init qs Strat = T\<^sub>p_opt init qs; length Strat = length qs; n \<le> length qs; x \<noteq> y; x \<in> set init; y \<in> set init; distinct init; set qs \<subseteq> set init\<rbrakk> \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take n qs) {x, y}) \<and> x < y in steps' init (take n qs) (take n Strat) n = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take n qs) init x y + ALG_Pxy Strat (take n qs) init x y; T\<^sub>p init qs Strat = T\<^sub>p_opt init qs; length Strat = length qs; Suc n \<le> length qs; x \<noteq> y; x \<in> set init; y \<in> set init; distinct init; set qs \<subseteq> set init\<rbrakk> \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
set qs \<subseteq> set init
[PROOF STEP]
have qsnset: "qs ! n \<in> set init"
[PROOF STATE]
proof (prove)
using this:
set qs \<subseteq> set init

goal (1 subgoal):
 1. qs ! n \<in> set init
[PROOF STEP]
using ns
[PROOF STATE]
proof (prove)
using this:
set qs \<subseteq> set init
n < length qs

goal (1 subgoal):
 1. qs ! n \<in> set init
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
qs ! n \<in> set init

goal (2 subgoals):
 1. \<lbrakk>T\<^sub>p init qs Strat = T\<^sub>p_opt init qs; length Strat = length qs; 0 \<le> length qs; x \<noteq> y; x \<in> set init; y \<in> set init; distinct init; set qs \<subseteq> set init\<rbrakk> \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take 0 qs) {x, y}) \<and> x < y in steps' init (take 0 qs) (take 0 Strat) 0 = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take 0 qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take 0 qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take 0 qs) init x y + ALG_Pxy Strat (take 0 qs) init x y
 2. \<And>n. \<lbrakk>\<lbrakk>T\<^sub>p init qs Strat = T\<^sub>p_opt init qs; length Strat = length qs; n \<le> length qs; x \<noteq> y; x \<in> set init; y \<in> set init; distinct init; set qs \<subseteq> set init\<rbrakk> \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take n qs) {x, y}) \<and> x < y in steps' init (take n qs) (take n Strat) n = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take n qs) init x y + ALG_Pxy Strat (take n qs) init x y; T\<^sub>p init qs Strat = T\<^sub>p_opt init qs; length Strat = length qs; Suc n \<le> length qs; x \<noteq> y; x \<in> set init; y \<in> set init; distinct init; set qs \<subseteq> set init\<rbrakk> \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
from xyininit
[PROOF STATE]
proof (chain)
picking this:
x \<in> set init
y \<in> set init
[PROOF STEP]
have ahjer: "set (Lxy init {x, y}) = {x,y}"
[PROOF STATE]
proof (prove)
using this:
x \<in> set init
y \<in> set init

goal (1 subgoal):
 1. set (Lxy init {x, y}) = {x, y}
[PROOF STEP]
using xysubs
[PROOF STATE]
proof (prove)
using this:
x \<in> set init
y \<in> set init
{x, y} \<subseteq> set init

goal (1 subgoal):
 1. set (Lxy init {x, y}) = {x, y}
[PROOF STEP]
by (simp add: Lxy_set_filter)
[PROOF STATE]
proof (state)
this:
set (Lxy init {x, y}) = {x, y}

goal (2 subgoals):
 1. \<lbrakk>T\<^sub>p init qs Strat = T\<^sub>p_opt init qs; length Strat = length qs; 0 \<le> length qs; x \<noteq> y; x \<in> set init; y \<in> set init; distinct init; set qs \<subseteq> set init\<rbrakk> \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take 0 qs) {x, y}) \<and> x < y in steps' init (take 0 qs) (take 0 Strat) 0 = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take 0 qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take 0 qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take 0 qs) init x y + ALG_Pxy Strat (take 0 qs) init x y
 2. \<And>n. \<lbrakk>\<lbrakk>T\<^sub>p init qs Strat = T\<^sub>p_opt init qs; length Strat = length qs; n \<le> length qs; x \<noteq> y; x \<in> set init; y \<in> set init; distinct init; set qs \<subseteq> set init\<rbrakk> \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take n qs) {x, y}) \<and> x < y in steps' init (take n qs) (take n Strat) n = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take n qs) init x y + ALG_Pxy Strat (take n qs) init x y; T\<^sub>p init qs Strat = T\<^sub>p_opt init qs; length Strat = length qs; Suc n \<le> length qs; x \<noteq> y; x \<in> set init; y \<in> set init; distinct init; set qs \<subseteq> set init\<rbrakk> \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
with Suc(5)
[PROOF STATE]
proof (chain)
picking this:
x \<noteq> y
set (Lxy init {x, y}) = {x, y}
[PROOF STEP]
have ah: "card (set (Lxy init {x, y})) = 2"
[PROOF STATE]
proof (prove)
using this:
x \<noteq> y
set (Lxy init {x, y}) = {x, y}

goal (1 subgoal):
 1. card (set (Lxy init {x, y})) = 2
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
card (set (Lxy init {x, y})) = 2

goal (2 subgoals):
 1. \<lbrakk>T\<^sub>p init qs Strat = T\<^sub>p_opt init qs; length Strat = length qs; 0 \<le> length qs; x \<noteq> y; x \<in> set init; y \<in> set init; distinct init; set qs \<subseteq> set init\<rbrakk> \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take 0 qs) {x, y}) \<and> x < y in steps' init (take 0 qs) (take 0 Strat) 0 = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take 0 qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take 0 qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take 0 qs) init x y + ALG_Pxy Strat (take 0 qs) init x y
 2. \<And>n. \<lbrakk>\<lbrakk>T\<^sub>p init qs Strat = T\<^sub>p_opt init qs; length Strat = length qs; n \<le> length qs; x \<noteq> y; x \<in> set init; y \<in> set init; distinct init; set qs \<subseteq> set init\<rbrakk> \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take n qs) {x, y}) \<and> x < y in steps' init (take n qs) (take n Strat) n = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take n qs) init x y + ALG_Pxy Strat (take n qs) init x y; T\<^sub>p init qs Strat = T\<^sub>p_opt init qs; length Strat = length qs; Suc n \<le> length qs; x \<noteq> y; x \<in> set init; y \<in> set init; distinct init; set qs \<subseteq> set init\<rbrakk> \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
have ahjer3: "distinct (Lxy init {x,y})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. distinct (Lxy init {x, y})
[PROOF STEP]
apply(rule Lxy_distinct)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. distinct init
[PROOF STEP]
by fact
[PROOF STATE]
proof (state)
this:
distinct (Lxy init {x, y})

goal (2 subgoals):
 1. \<lbrakk>T\<^sub>p init qs Strat = T\<^sub>p_opt init qs; length Strat = length qs; 0 \<le> length qs; x \<noteq> y; x \<in> set init; y \<in> set init; distinct init; set qs \<subseteq> set init\<rbrakk> \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take 0 qs) {x, y}) \<and> x < y in steps' init (take 0 qs) (take 0 Strat) 0 = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take 0 qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take 0 qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take 0 qs) init x y + ALG_Pxy Strat (take 0 qs) init x y
 2. \<And>n. \<lbrakk>\<lbrakk>T\<^sub>p init qs Strat = T\<^sub>p_opt init qs; length Strat = length qs; n \<le> length qs; x \<noteq> y; x \<in> set init; y \<in> set init; distinct init; set qs \<subseteq> set init\<rbrakk> \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take n qs) {x, y}) \<and> x < y in steps' init (take n qs) (take n Strat) n = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take n qs) init x y + ALG_Pxy Strat (take n qs) init x y; T\<^sub>p init qs Strat = T\<^sub>p_opt init qs; length Strat = length qs; Suc n \<le> length qs; x \<noteq> y; x \<in> set init; y \<in> set init; distinct init; set qs \<subseteq> set init\<rbrakk> \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
from ah
[PROOF STATE]
proof (chain)
picking this:
card (set (Lxy init {x, y})) = 2
[PROOF STEP]
have ahjer2: "length (Lxy init {x,y}) = 2"
[PROOF STATE]
proof (prove)
using this:
card (set (Lxy init {x, y})) = 2

goal (1 subgoal):
 1. length (Lxy init {x, y}) = 2
[PROOF STEP]
using distinct_card[OF ahjer3]
[PROOF STATE]
proof (prove)
using this:
card (set (Lxy init {x, y})) = 2
card (set (Lxy init {x, y})) = length (Lxy init {x, y})

goal (1 subgoal):
 1. length (Lxy init {x, y}) = 2
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
length (Lxy init {x, y}) = 2

goal (2 subgoals):
 1. \<lbrakk>T\<^sub>p init qs Strat = T\<^sub>p_opt init qs; length Strat = length qs; 0 \<le> length qs; x \<noteq> y; x \<in> set init; y \<in> set init; distinct init; set qs \<subseteq> set init\<rbrakk> \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take 0 qs) {x, y}) \<and> x < y in steps' init (take 0 qs) (take 0 Strat) 0 = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take 0 qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take 0 qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take 0 qs) init x y + ALG_Pxy Strat (take 0 qs) init x y
 2. \<And>n. \<lbrakk>\<lbrakk>T\<^sub>p init qs Strat = T\<^sub>p_opt init qs; length Strat = length qs; n \<le> length qs; x \<noteq> y; x \<in> set init; y \<in> set init; distinct init; set qs \<subseteq> set init\<rbrakk> \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take n qs) {x, y}) \<and> x < y in steps' init (take n qs) (take n Strat) n = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take n qs) init x y + ALG_Pxy Strat (take n qs) init x y; T\<^sub>p init qs Strat = T\<^sub>p_opt init qs; length Strat = length qs; Suc n \<le> length qs; x \<noteq> y; x \<in> set init; y \<in> set init; distinct init; set qs \<subseteq> set init\<rbrakk> \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
proof (cases "qs ! n \<in> {x,y}")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
 2. qs ! n \<notin> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
qs ! n \<notin> {x, y}

goal (2 subgoals):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
 2. qs ! n \<notin> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
with tak
[PROOF STATE]
proof (chain)
picking this:
take (Suc n) qs = take n qs @ [qs ! n]
qs ! n \<notin> {x, y}
[PROOF STEP]
have nixzutun: "Lxy (take (Suc n) qs) {x,y}  = Lxy (take n qs) {x,y}"
[PROOF STATE]
proof (prove)
using this:
take (Suc n) qs = take n qs @ [qs ! n]
qs ! n \<notin> {x, y}

goal (1 subgoal):
 1. Lxy (take (Suc n) qs) {x, y} = Lxy (take n qs) {x, y}
[PROOF STEP]
unfolding Lxy_def
[PROOF STATE]
proof (prove)
using this:
take (Suc n) qs = take n qs @ [qs ! n]
qs ! n \<notin> {x, y}

goal (1 subgoal):
 1. filter (\<lambda>z. z \<in> {x, y}) (take (Suc n) qs) = filter (\<lambda>z. z \<in> {x, y}) (take n qs)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
Lxy (take (Suc n) qs) {x, y} = Lxy (take n qs) {x, y}

goal (2 subgoals):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
 2. qs ! n \<notin> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
let ?m="ALG_P' (take n Strat @ [Strat ! n]) (take n qs @ [qs ! n]) init n x y"
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
 2. qs ! n \<notin> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
let ?L="replicate ?m 0 @ sws"
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
 2. qs ! n \<notin> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
{
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
 2. qs ! n \<notin> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
fix xs::"('a::linorder) list"
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
 2. qs ! n \<notin> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
fix m::nat
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
 2. qs ! n \<notin> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
fix q::'a
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
 2. qs ! n \<notin> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
assume "q \<notin> {x,y}"
[PROOF STATE]
proof (state)
this:
q \<notin> {x, y}

goal (2 subgoals):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
 2. qs ! n \<notin> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
q \<notin> {x, y}
[PROOF STEP]
have 5: "y \<noteq> q"
[PROOF STATE]
proof (prove)
using this:
q \<notin> {x, y}

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

goal (2 subgoals):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
 2. qs ! n \<notin> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
assume 1: "q \<in> set xs"
[PROOF STATE]
proof (state)
this:
q \<in> set xs

goal (2 subgoals):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
 2. qs ! n \<notin> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
assume 2: "distinct xs"
[PROOF STATE]
proof (state)
this:
distinct xs

goal (2 subgoals):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
 2. qs ! n \<notin> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
assume 3: "x \<in> set xs"
[PROOF STATE]
proof (state)
this:
x \<in> set xs

goal (2 subgoals):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
 2. qs ! n \<notin> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
assume 4: "y \<in> set xs"
[PROOF STATE]
proof (state)
this:
y \<in> set xs

goal (2 subgoals):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
 2. qs ! n \<notin> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
have "(x < y in xs) = (x < y in (mtf2 m q xs))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x < y in xs = x < y in mtf2 m q xs
[PROOF STEP]
by (metis "1" "2" "3" "4" \<open>q \<notin> {x, y}\<close> insertCI not_before_in set_mtf2 swapped_by_mtf2)
[PROOF STATE]
proof (state)
this:
x < y in xs = x < y in mtf2 m q xs

goal (2 subgoals):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
 2. qs ! n \<notin> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
\<lbrakk>?q2 \<notin> {x, y}; ?q2 \<in> set ?xs2; distinct ?xs2; x \<in> set ?xs2; y \<in> set ?xs2\<rbrakk> \<Longrightarrow> x < y in ?xs2 = x < y in mtf2 ?m2 ?q2 ?xs2

goal (2 subgoals):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
 2. qs ! n \<notin> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
note f=this
[PROOF STATE]
proof (state)
this:
\<lbrakk>?q2 \<notin> {x, y}; ?q2 \<in> set ?xs2; distinct ?xs2; x \<in> set ?xs2; y \<in> set ?xs2\<rbrakk> \<Longrightarrow> x < y in ?xs2 = x < y in mtf2 ?m2 ?q2 ?xs2

goal (2 subgoals):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
 2. qs ! n \<notin> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
(* taktik, erstmal das mtf weg bekommen,
       dann induct ?ber snd (Strat!n) *)
[PROOF STATE]
proof (state)
this:
\<lbrakk>?q2 \<notin> {x, y}; ?q2 \<in> set ?xs2; distinct ?xs2; x \<in> set ?xs2; y \<in> set ?xs2\<rbrakk> \<Longrightarrow> x < y in ?xs2 = x < y in mtf2 ?m2 ?q2 ?xs2

goal (2 subgoals):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
 2. qs ! n \<notin> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
have "(x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n))
            = (x < y in mtf2 (fst (Strat ! n)) (qs ! n)
             (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
[PROOF STEP]
unfolding tak2 tak
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x < y in steps' init (take n qs @ [qs ! n]) (take n Strat @ [Strat ! n]) (Suc n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
[PROOF STEP]
apply(simp only: steps'_append[OF qQS aQ] )
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x < y in step (steps' init (take n qs) (take n Strat) n) (qs ! n) (Strat ! n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
[PROOF STEP]
by (simp add: step_def split_def)
[PROOF STATE]
proof (state)
this:
x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))

goal (2 subgoals):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
 2. qs ! n \<notin> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))

goal (2 subgoals):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
 2. qs ! n \<notin> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
have "\<dots> = (x < y in (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) = x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)
[PROOF STEP]
apply(rule f[symmetric])
[PROOF STATE]
proof (prove)
goal (5 subgoals):
 1. qs ! n \<notin> {x, y}
 2. qs ! n \<in> set (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
 3. distinct (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
 4. x \<in> set (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
 5. y \<in> set (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
[PROOF STEP]
apply(fact)
[PROOF STATE]
proof (prove)
goal (4 subgoals):
 1. qs ! n \<in> set (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
 2. distinct (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
 3. x \<in> set (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
 4. y \<in> set (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
[PROOF STEP]
using qsnset steps'_set[OF qQS] aS
[PROOF STATE]
proof (prove)
using this:
qs ! n \<in> set init
?n \<le> length (take n Strat) \<Longrightarrow> set (steps' ?s (take n qs) (take n Strat) ?n) = set ?s
length (take n Strat) = n

goal (4 subgoals):
 1. qs ! n \<in> set (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
 2. distinct (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
 3. x \<in> set (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
 4. y \<in> set (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
[PROOF STEP]
apply(simp)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. distinct (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
 2. x \<in> set (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
 3. y \<in> set (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
[PROOF STEP]
using steps'_distinct[OF qQS] aS dI
[PROOF STATE]
proof (prove)
using this:
length (take n Strat) = ?n \<Longrightarrow> distinct (steps' ?s (take n qs) (take n Strat) ?n) = distinct ?s
length (take n Strat) = n
distinct init

goal (3 subgoals):
 1. distinct (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
 2. x \<in> set (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
 3. y \<in> set (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
[PROOF STEP]
apply(simp)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. x \<in> set (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
 2. y \<in> set (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
[PROOF STEP]
using steps'_set[OF qQS] aS xyininit
[PROOF STATE]
proof (prove)
using this:
?n \<le> length (take n Strat) \<Longrightarrow> set (steps' ?s (take n qs) (take n Strat) ?n) = set ?s
length (take n Strat) = n
x \<in> set init
y \<in> set init

goal (2 subgoals):
 1. x \<in> set (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
 2. y \<in> set (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
[PROOF STEP]
by simp_all
[PROOF STATE]
proof (state)
this:
x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) = x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)

goal (2 subgoals):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
 2. qs ! n \<notin> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) = x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)

goal (2 subgoals):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
 2. qs ! n \<notin> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
have "\<dots> =  x < y in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n))
                                    (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
[PROOF STEP]
apply(rule projected_paid_same_effect)
[PROOF STATE]
proof (prove)
goal (6 subgoals):
 1. dist_perm (steps' init (take n qs) (take n Strat) n) (steps' init (take n qs) (take n Strat) n)
 2. x \<noteq> y
 3. set (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) = {x, y}
 4. length (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) = 2
 5. dist_perm (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
 6. x < y in steps' init (take n qs) (take n Strat) n = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))
[PROOF STEP]
apply(rule steps'_dist_perm)
[PROOF STATE]
proof (prove)
goal (8 subgoals):
 1. length (take n qs) = length (take n Strat)
 2. length (take n Strat) = n
 3. dist_perm init init
 4. x \<noteq> y
 5. set (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) = {x, y}
 6. length (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) = 2
 7. dist_perm (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
 8. x < y in steps' init (take n qs) (take n Strat) n = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))
[PROOF STEP]
apply(fact qQS)
[PROOF STATE]
proof (prove)
goal (7 subgoals):
 1. length (take n Strat) = n
 2. dist_perm init init
 3. x \<noteq> y
 4. set (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) = {x, y}
 5. length (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) = 2
 6. dist_perm (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
 7. x < y in steps' init (take n qs) (take n Strat) n = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))
[PROOF STEP]
apply(fact aS)
[PROOF STATE]
proof (prove)
goal (6 subgoals):
 1. dist_perm init init
 2. x \<noteq> y
 3. set (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) = {x, y}
 4. length (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) = 2
 5. dist_perm (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
 6. x < y in steps' init (take n qs) (take n Strat) n = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))
[PROOF STEP]
using dI
[PROOF STATE]
proof (prove)
using this:
distinct init

goal (6 subgoals):
 1. dist_perm init init
 2. x \<noteq> y
 3. set (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) = {x, y}
 4. length (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) = 2
 5. dist_perm (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
 6. x < y in steps' init (take n qs) (take n Strat) n = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))
[PROOF STEP]
apply(simp)
[PROOF STATE]
proof (prove)
goal (5 subgoals):
 1. x \<noteq> y
 2. set (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) = {x, y}
 3. length (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) = 2
 4. dist_perm (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
 5. x < y in steps' init (take n qs) (take n Strat) n = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))
[PROOF STEP]
apply(fact Suc(5))
[PROOF STATE]
proof (prove)
goal (4 subgoals):
 1. set (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) = {x, y}
 2. length (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) = 2
 3. dist_perm (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
 4. x < y in steps' init (take n qs) (take n Strat) n = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))
[PROOF STEP]
apply(simp)
[PROOF STATE]
proof (prove)
goal (4 subgoals):
 1. set (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)) = {x, y}
 2. length (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) = 2
 3. dist_perm (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
 4. x < y in steps' init (take n qs) (take n Strat) n = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))
[PROOF STEP]
apply(rule steps'_set[where s="Lxy init {x,y}", unfolded ahjer])
[PROOF STATE]
proof (prove)
goal (5 subgoals):
 1. length (Lxy (take n qs) {x, y}) = length Strat2
 2. length Strat2 \<le> length Strat2
 3. length (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) = 2
 4. dist_perm (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
 5. x < y in steps' init (take n qs) (take n Strat) n = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))
[PROOF STEP]
using len
[PROOF STATE]
proof (prove)
using this:
length Strat2 = length (Lxy (take n qs) {x, y})

goal (5 subgoals):
 1. length (Lxy (take n qs) {x, y}) = length Strat2
 2. length Strat2 \<le> length Strat2
 3. length (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) = 2
 4. dist_perm (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
 5. x < y in steps' init (take n qs) (take n Strat) n = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))
[PROOF STEP]
apply(simp)
[PROOF STATE]
proof (prove)
goal (4 subgoals):
 1. length Strat2 \<le> length Strat2
 2. length (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) = 2
 3. dist_perm (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
 4. x < y in steps' init (take n qs) (take n Strat) n = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))
[PROOF STEP]
apply(simp)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. length (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) = 2
 2. dist_perm (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
 3. x < y in steps' init (take n qs) (take n Strat) n = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))
[PROOF STEP]
apply(simp)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. length (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)) = 2
 2. dist_perm (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
 3. x < y in steps' init (take n qs) (take n Strat) n = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))
[PROOF STEP]
apply(rule steps'_length[where s="Lxy init {x,y}", unfolded ahjer2])
[PROOF STATE]
proof (prove)
goal (4 subgoals):
 1. length (Lxy (take n qs) {x, y}) = length Strat2
 2. length Strat2 \<le> length Strat2
 3. dist_perm (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
 4. x < y in steps' init (take n qs) (take n Strat) n = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))
[PROOF STEP]
using len
[PROOF STATE]
proof (prove)
using this:
length Strat2 = length (Lxy (take n qs) {x, y})

goal (4 subgoals):
 1. length (Lxy (take n qs) {x, y}) = length Strat2
 2. length Strat2 \<le> length Strat2
 3. dist_perm (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
 4. x < y in steps' init (take n qs) (take n Strat) n = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))
[PROOF STEP]
apply(simp)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. length Strat2 \<le> length Strat2
 2. dist_perm (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
 3. x < y in steps' init (take n qs) (take n Strat) n = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))
[PROOF STEP]
apply(simp)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. dist_perm (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
 2. x < y in steps' init (take n qs) (take n Strat) n = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))
[PROOF STEP]
apply(simp)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. distinct (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))
 2. x < y in steps' init (take n qs) (take n Strat) n = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))
[PROOF STEP]
apply(rule steps'_distinct2[where s="Lxy init {x,y}"])
[PROOF STATE]
proof (prove)
goal (4 subgoals):
 1. length (Lxy (take n qs) {x, y}) = length Strat2
 2. length Strat2 \<le> length Strat2
 3. distinct (Lxy init {x, y})
 4. x < y in steps' init (take n qs) (take n Strat) n = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))
[PROOF STEP]
using len
[PROOF STATE]
proof (prove)
using this:
length Strat2 = length (Lxy (take n qs) {x, y})

goal (4 subgoals):
 1. length (Lxy (take n qs) {x, y}) = length Strat2
 2. length Strat2 \<le> length Strat2
 3. distinct (Lxy init {x, y})
 4. x < y in steps' init (take n qs) (take n Strat) n = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))
[PROOF STEP]
apply(simp)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. length Strat2 \<le> length Strat2
 2. distinct (Lxy init {x, y})
 3. x < y in steps' init (take n qs) (take n Strat) n = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))
[PROOF STEP]
apply(simp)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. distinct (Lxy init {x, y})
 2. x < y in steps' init (take n qs) (take n Strat) n = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))
[PROOF STEP]
apply(fact)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x < y in steps' init (take n qs) (take n Strat) n = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))
[PROOF STEP]
using iff
[PROOF STATE]
proof (prove)
using this:
x < y in steps' init (take n qs) (take n Strat) n = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))

goal (1 subgoal):
 1. x < y in steps' init (take n qs) (take n Strat) n = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))

goal (2 subgoals):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
 2. qs ! n \<notin> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
[PROOF STEP]
have umfa: "x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) =
  x < y
  in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n))
      (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))"
[PROOF STATE]
proof (prove)
using this:
x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))

goal (1 subgoal):
 1. x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))

goal (2 subgoals):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
 2. qs ! n \<notin> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
from Suc(3,4)
[PROOF STATE]
proof (chain)
picking this:
length Strat = length qs
Suc n \<le> length qs
[PROOF STEP]
have lS: "length (take n Strat) = n"
[PROOF STATE]
proof (prove)
using this:
length Strat = length qs
Suc n \<le> length qs

goal (1 subgoal):
 1. length (take n Strat) = n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
length (take n Strat) = n

goal (2 subgoals):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
 2. qs ! n \<notin> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
have "(take n Strat @ [Strat ! n]) ! n =
              (take n Strat @ (Strat ! n) # []) ! length (take n Strat)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (take n Strat @ [Strat ! n]) ! n = (take n Strat @ [Strat ! n]) ! length (take n Strat)
[PROOF STEP]
using lS
[PROOF STATE]
proof (prove)
using this:
length (take n Strat) = n

goal (1 subgoal):
 1. (take n Strat @ [Strat ! n]) ! n = (take n Strat @ [Strat ! n]) ! length (take n Strat)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(take n Strat @ [Strat ! n]) ! n = (take n Strat @ [Strat ! n]) ! length (take n Strat)

goal (2 subgoals):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
 2. qs ! n \<notin> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(take n Strat @ [Strat ! n]) ! n = (take n Strat @ [Strat ! n]) ! length (take n Strat)

goal (2 subgoals):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
 2. qs ! n \<notin> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
have "\<dots> = Strat ! n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (take n Strat @ [Strat ! n]) ! length (take n Strat) = Strat ! n
[PROOF STEP]
by(rule nth_append_length)
[PROOF STATE]
proof (state)
this:
(take n Strat @ [Strat ! n]) ! length (take n Strat) = Strat ! n

goal (2 subgoals):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
 2. qs ! n \<notin> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(take n Strat @ [Strat ! n]) ! n = Strat ! n
[PROOF STEP]
have tt: "(take n Strat @ [Strat ! n]) ! n = Strat ! n"
[PROOF STATE]
proof (prove)
using this:
(take n Strat @ [Strat ! n]) ! n = Strat ! n

goal (1 subgoal):
 1. (take n Strat @ [Strat ! n]) ! n = Strat ! n
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
(take n Strat @ [Strat ! n]) ! n = Strat ! n

goal (2 subgoals):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
 2. qs ! n \<notin> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
apply(rule exI[where x="Strat2"])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
apply(rule exI[where x="?L"])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps (replicate (ALG_P' (take n Strat @ [Strat ! n]) (take n qs @ [qs ! n]) init n x y) 0 @ sws) (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length (replicate (ALG_P' (take n Strat @ [Strat ! n]) (take n qs @ [qs ! n]) init n x y) 0 @ sws) = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
unfolding nixzutun
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length Strat2 = length (Lxy (take n qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps (replicate (ALG_P' (take n Strat @ [Strat ! n]) (take n qs @ [qs ! n]) init n x y) 0 @ sws) (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + length (replicate (ALG_P' (take n Strat @ [Strat ! n]) (take n qs @ [qs ! n]) init n x y) 0 @ sws) = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
apply(safe)
[PROOF STATE]
proof (prove)
goal (4 subgoals):
 1. length Strat2 = length (Lxy (take n qs) {x, y})
 2. x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) \<Longrightarrow> x < y in swaps (replicate (ALG_P' (take n Strat @ [Strat ! n]) (take n qs @ [qs ! n]) init n x y) 0 @ sws) (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))
 3. x < y in swaps (replicate (ALG_P' (take n Strat @ [Strat ! n]) (take n qs @ [qs ! n]) init n x y) 0 @ sws) (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)) \<Longrightarrow> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n)
 4. T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + length (replicate (ALG_P' (take n Strat @ [Strat ! n]) (take n qs @ [qs ! n]) init n x y) 0 @ sws) = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
apply(fact)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) \<Longrightarrow> x < y in swaps (replicate (ALG_P' (take n Strat @ [Strat ! n]) (take n qs @ [qs ! n]) init n x y) 0 @ sws) (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))
 2. x < y in swaps (replicate (ALG_P' (take n Strat @ [Strat ! n]) (take n qs @ [qs ! n]) init n x y) 0 @ sws) (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)) \<Longrightarrow> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n)
 3. T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + length (replicate (ALG_P' (take n Strat @ [Strat ! n]) (take n qs @ [qs ! n]) init n x y) 0 @ sws) = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
proof goal_cases
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) \<Longrightarrow> x < y in swaps (replicate (ALG_P' (take n Strat @ [Strat ! n]) (take n qs @ [qs ! n]) init n x y) 0 @ sws) (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))
 2. x < y in swaps (replicate (ALG_P' (take n Strat @ [Strat ! n]) (take n qs @ [qs ! n]) init n x y) 0 @ sws) (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)) \<Longrightarrow> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n)
 3. T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + length (replicate (ALG_P' (take n Strat @ [Strat ! n]) (take n qs @ [qs ! n]) init n x y) 0 @ sws) = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
case 1
[PROOF STATE]
proof (state)
this:
x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n)

goal (3 subgoals):
 1. x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) \<Longrightarrow> x < y in swaps (replicate (ALG_P' (take n Strat @ [Strat ! n]) (take n qs @ [qs ! n]) init n x y) 0 @ sws) (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))
 2. x < y in swaps (replicate (ALG_P' (take n Strat @ [Strat ! n]) (take n qs @ [qs ! n]) init n x y) 0 @ sws) (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)) \<Longrightarrow> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n)
 3. T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + length (replicate (ALG_P' (take n Strat @ [Strat ! n]) (take n qs @ [qs ! n]) init n x y) 0 @ sws) = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x < y in swaps (replicate (ALG_P' (take n Strat @ [Strat ! n]) (take n qs @ [qs ! n]) init n x y) 0 @ sws) (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))
[PROOF STEP]
unfolding tak2 tak
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x < y in swaps (replicate (ALG_P' (take n Strat @ [Strat ! n]) (take n qs @ [qs ! n]) init n x y) 0 @ sws) (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))
[PROOF STEP]
apply(simp add: step_def split_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x < y in (swap 0 ^^ ALG_P' (take n Strat @ [Strat ! n]) (take n qs @ [qs ! n]) init n x y) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
[PROOF STEP]
unfolding ALG_P'_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x < y in (swap 0 ^^ ALG_P (snd ((take n Strat @ [Strat ! n]) ! n)) x y (steps' init (take n qs @ [qs ! n]) (take n Strat @ [Strat ! n]) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
[PROOF STEP]
unfolding tt
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x < y in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs @ [qs ! n]) (take n Strat @ [Strat ! n]) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
[PROOF STEP]
using aS
[PROOF STATE]
proof (prove)
using this:
length (take n Strat) = n

goal (1 subgoal):
 1. x < y in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs @ [qs ! n]) (take n Strat @ [Strat ! n]) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
[PROOF STEP]
apply(simp only: steps'_rests[OF qQS, symmetric])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (take n Strat) = n \<Longrightarrow> x < y in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
[PROOF STEP]
using 1(1) umfa
[PROOF STATE]
proof (prove)
using this:
x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n)
x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))

goal (1 subgoal):
 1. length (take n Strat) = n \<Longrightarrow> x < y in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
x < y in swaps (replicate (ALG_P' (take n Strat @ [Strat ! n]) (take n qs @ [qs ! n]) init n x y) 0 @ sws) (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))

goal (2 subgoals):
 1. x < y in swaps (replicate (ALG_P' (take n Strat @ [Strat ! n]) (take n qs @ [qs ! n]) init n x y) 0 @ sws) (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)) \<Longrightarrow> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n)
 2. T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + length (replicate (ALG_P' (take n Strat @ [Strat ! n]) (take n qs @ [qs ! n]) init n x y) 0 @ sws) = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. x < y in swaps (replicate (ALG_P' (take n Strat @ [Strat ! n]) (take n qs @ [qs ! n]) init n x y) 0 @ sws) (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)) \<Longrightarrow> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n)
 2. T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + length (replicate (ALG_P' (take n Strat @ [Strat ! n]) (take n qs @ [qs ! n]) init n x y) 0 @ sws) = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
case 2
[PROOF STATE]
proof (state)
this:
x < y in swaps (replicate (ALG_P' (take n Strat @ [Strat ! n]) (take n qs @ [qs ! n]) init n x y) 0 @ sws) (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))

goal (2 subgoals):
 1. x < y in swaps (replicate (ALG_P' (take n Strat @ [Strat ! n]) (take n qs @ [qs ! n]) init n x y) 0 @ sws) (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)) \<Longrightarrow> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n)
 2. T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + length (replicate (ALG_P' (take n Strat @ [Strat ! n]) (take n qs @ [qs ! n]) init n x y) 0 @ sws) = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
x < y in swaps (replicate (ALG_P' (take n Strat @ [Strat ! n]) (take n qs @ [qs ! n]) init n x y) 0 @ sws) (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
x < y in swaps (replicate (ALG_P' (take n Strat @ [Strat ! n]) (take n qs @ [qs ! n]) init n x y) 0 @ sws) (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))

goal (1 subgoal):
 1. x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n)
[PROOF STEP]
apply(simp add: step_def split_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x < y in (swap 0 ^^ ALG_P' (take n Strat @ [Strat ! n]) (take n qs @ [qs ! n]) init n x y) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) \<Longrightarrow> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n)
[PROOF STEP]
unfolding ALG_P'_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x < y in (swap 0 ^^ ALG_P (snd ((take n Strat @ [Strat ! n]) ! n)) x y (steps' init (take n qs @ [qs ! n]) (take n Strat @ [Strat ! n]) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) \<Longrightarrow> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n)
[PROOF STEP]
unfolding tt
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x < y in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs @ [qs ! n]) (take n Strat @ [Strat ! n]) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) \<Longrightarrow> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n)
[PROOF STEP]
using aS
[PROOF STATE]
proof (prove)
using this:
length (take n Strat) = n

goal (1 subgoal):
 1. x < y in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs @ [qs ! n]) (take n Strat @ [Strat ! n]) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) \<Longrightarrow> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n)
[PROOF STEP]
apply(simp only: steps'_rests[OF qQS, symmetric])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>x < y in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))); length (take n Strat) = n\<rbrakk> \<Longrightarrow> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n)
[PROOF STEP]
using umfa[symmetric]
[PROOF STATE]
proof (prove)
using this:
x < y in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) = x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n)

goal (1 subgoal):
 1. \<lbrakk>x < y in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))); length (take n Strat) = n\<rbrakk> \<Longrightarrow> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n)

goal (1 subgoal):
 1. T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + length (replicate (ALG_P' (take n Strat @ [Strat ! n]) (take n qs @ [qs ! n]) init n x y) 0 @ sws) = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + length (replicate (ALG_P' (take n Strat @ [Strat ! n]) (take n qs @ [qs ! n]) init n x y) 0 @ sws) = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
case 3
[PROOF STATE]
proof (state)
this:

goal (1 subgoal):
 1. T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + length (replicate (ALG_P' (take n Strat @ [Strat ! n]) (take n qs @ [qs ! n]) init n x y) 0 @ sws) = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
have ns2: "n < length (take n qs @ [qs ! n])"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n < length (take n qs @ [qs ! n])
[PROOF STEP]
using ns
[PROOF STATE]
proof (prove)
using this:
n < length qs

goal (1 subgoal):
 1. n < length (take n qs @ [qs ! n])
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
n < length (take n qs @ [qs ! n])

goal (1 subgoal):
 1. T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + length (replicate (ALG_P' (take n Strat @ [Strat ! n]) (take n qs @ [qs ! n]) init n x y) 0 @ sws) = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
have er: "length (take n qs) < length Strat"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (take n qs) < length Strat
[PROOF STEP]
using Suc.prems(2) aQ ns
[PROOF STATE]
proof (prove)
using this:
length Strat = length qs
length (take n qs) = n
n < length qs

goal (1 subgoal):
 1. length (take n qs) < length Strat
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
length (take n qs) < length Strat

goal (1 subgoal):
 1. T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + length (replicate (ALG_P' (take n Strat @ [Strat ! n]) (take n qs @ [qs ! n]) init n x y) 0 @ sws) = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
have "T\<^sub>p (Lxy init {x,y}) (Lxy (take n qs) {x, y}) Strat2
      + length (replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)
      = ( T\<^sub>p (Lxy init {x,y}) (Lxy (take n qs) {x, y}) Strat2 + length sws)
          + ALG_P' Strat (take n qs @ [qs ! n])  init n x y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + length (replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws) = T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + length sws + ALG_P' Strat (take n qs @ [qs ! n]) init n x y
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + length (replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws) = T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + length sws + ALG_P' Strat (take n qs @ [qs ! n]) init n x y

goal (1 subgoal):
 1. T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + length (replicate (ALG_P' (take n Strat @ [Strat ! n]) (take n qs @ [qs ! n]) init n x y) 0 @ sws) = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + length (replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws) = T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + length sws + ALG_P' Strat (take n qs @ [qs ! n]) init n x y

goal (1 subgoal):
 1. T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + length (replicate (ALG_P' (take n Strat @ [Strat ! n]) (take n qs @ [qs ! n]) init n x y) 0 @ sws) = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
have "\<dots> =  ALGxy_det Strat (take n qs) init x y +
                  ALG_Pxy Strat (take n qs) init x y +
                  ALG_P' Strat (take n qs @ [qs ! n]) init n x y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + length sws + ALG_P' Strat (take n qs @ [qs ! n]) init n x y = ALGxy_det Strat (take n qs) init x y + ALG_Pxy Strat (take n qs) init x y + ALG_P' Strat (take n qs @ [qs ! n]) init n x y
[PROOF STEP]
unfolding T_Strat2
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ALGxy_det Strat (take n qs) init x y + ALG_Pxy Strat (take n qs) init x y + ALG_P' Strat (take n qs @ [qs ! n]) init n x y = ALGxy_det Strat (take n qs) init x y + ALG_Pxy Strat (take n qs) init x y + ALG_P' Strat (take n qs @ [qs ! n]) init n x y
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + length sws + ALG_P' Strat (take n qs @ [qs ! n]) init n x y = ALGxy_det Strat (take n qs) init x y + ALG_Pxy Strat (take n qs) init x y + ALG_P' Strat (take n qs @ [qs ! n]) init n x y

goal (1 subgoal):
 1. T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + length (replicate (ALG_P' (take n Strat @ [Strat ! n]) (take n qs @ [qs ! n]) init n x y) 0 @ sws) = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + length sws + ALG_P' Strat (take n qs @ [qs ! n]) init n x y = ALGxy_det Strat (take n qs) init x y + ALG_Pxy Strat (take n qs) init x y + ALG_P' Strat (take n qs @ [qs ! n]) init n x y

goal (1 subgoal):
 1. T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + length (replicate (ALG_P' (take n Strat @ [Strat ! n]) (take n qs @ [qs ! n]) init n x y) 0 @ sws) = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
have "\<dots> = ALGxy_det Strat (take (Suc n) qs) init x y
              + ALG_Pxy Strat (take (Suc n) qs) init x y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ALGxy_det Strat (take n qs) init x y + ALG_Pxy Strat (take n qs) init x y + ALG_P' Strat (take n qs @ [qs ! n]) init n x y = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
unfolding tak
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ALGxy_det Strat (take n qs) init x y + ALG_Pxy Strat (take n qs) init x y + ALG_P' Strat (take n qs @ [qs ! n]) init n x y = ALGxy_det Strat (take n qs @ [qs ! n]) init x y + ALG_Pxy Strat (take n qs @ [qs ! n]) init x y
[PROOF STEP]
unfolding wegdamit[OF er False]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ALGxy_det Strat (take n qs) init x y + ALG_Pxy Strat (take n qs) init x y + ALG_P' Strat (take n qs @ [qs ! n]) init n x y = ALGxy_det Strat (take n qs) init x y + ALG_Pxy Strat (take n qs @ [qs ! n]) init x y
[PROOF STEP]
apply(simp)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ALG_Pxy Strat (take n qs) init x y + ALG_P' Strat (take n qs @ [qs ! n]) init n x y = ALG_Pxy Strat (take n qs @ [qs ! n]) init x y
[PROOF STEP]
unfolding ALG_P_split[of "take n qs" Strat "qs ! n" init x y, unfolded aQ, OF nStrat]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ALG_Pxy Strat (take n qs) init x y + ALG_P' Strat (take n qs @ [qs ! n]) init n x y = ALG_Pxy Strat (take n qs) init x y + ALG_P' Strat (take n qs @ [qs ! n]) init n x y
[PROOF STEP]
by(simp)
[PROOF STATE]
proof (state)
this:
ALGxy_det Strat (take n qs) init x y + ALG_Pxy Strat (take n qs) init x y + ALG_P' Strat (take n qs @ [qs ! n]) init n x y = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y

goal (1 subgoal):
 1. T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + length (replicate (ALG_P' (take n Strat @ [Strat ! n]) (take n qs @ [qs ! n]) init n x y) 0 @ sws) = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + length (replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws) = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + length (replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws) = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y

goal (1 subgoal):
 1. T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + length (replicate (ALG_P' (take n Strat @ [Strat ! n]) (take n qs @ [qs ! n]) init n x y) 0 @ sws) = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
unfolding tak
[PROOF STATE]
proof (prove)
using this:
T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + length (replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws) = ALGxy_det Strat (take n qs @ [qs ! n]) init x y + ALG_Pxy Strat (take n qs @ [qs ! n]) init x y

goal (1 subgoal):
 1. T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + length (replicate (ALG_P' (take n Strat @ [Strat ! n]) (take n qs @ [qs ! n]) init n x y) 0 @ sws) = ALGxy_det Strat (take n qs @ [qs ! n]) init x y + ALG_Pxy Strat (take n qs @ [qs ! n]) init x y
[PROOF STEP]
using ALG_P'_rest[OF ns nStrat]
[PROOF STATE]
proof (prove)
using this:
T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + length (replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws) = ALGxy_det Strat (take n qs @ [qs ! n]) init x y + ALG_Pxy Strat (take n qs @ [qs ! n]) init x y
ALG_P' Strat (take n qs @ [qs ! n]) ?init n ?x ?y = ALG_P' (take n Strat @ [Strat ! n]) (take n qs @ [qs ! n]) ?init n ?x ?y

goal (1 subgoal):
 1. T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + length (replicate (ALG_P' (take n Strat @ [Strat ! n]) (take n qs @ [qs ! n]) init n x y) 0 @ sws) = ALGxy_det Strat (take n qs @ [qs ! n]) init x y + ALG_Pxy Strat (take n qs @ [qs ! n]) init x y
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + length (replicate (ALG_P' (take n Strat @ [Strat ! n]) (take n qs @ [qs ! n]) init n x y) 0 @ sws) = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y

goal (1 subgoal):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
qs ! n \<in> {x, y}

goal (1 subgoal):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
note qsinxy=this
[PROOF STATE]
proof (state)
this:
qs ! n \<in> {x, y}

goal (1 subgoal):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
qs ! n \<in> {x, y}
[PROOF STEP]
have yeh: "Lxy (take (Suc n) qs) {x, y} = Lxy (take n qs) {x,y} @ [qs!n]"
[PROOF STATE]
proof (prove)
using this:
qs ! n \<in> {x, y}

goal (1 subgoal):
 1. Lxy (take (Suc n) qs) {x, y} = Lxy (take n qs) {x, y} @ [qs ! n]
[PROOF STEP]
unfolding tak Lxy_def
[PROOF STATE]
proof (prove)
using this:
qs ! n \<in> {x, y}

goal (1 subgoal):
 1. filter (\<lambda>z. z \<in> {x, y}) (take n qs @ [qs ! n]) = filter (\<lambda>z. z \<in> {x, y}) (take n qs) @ [qs ! n]
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
Lxy (take (Suc n) qs) {x, y} = Lxy (take n qs) {x, y} @ [qs ! n]

goal (1 subgoal):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
from True
[PROOF STATE]
proof (chain)
picking this:
qs ! n \<in> {x, y}
[PROOF STEP]
have garar: "(take n qs @ [qs ! n]) ! n \<in> {y, x}"
[PROOF STATE]
proof (prove)
using this:
qs ! n \<in> {x, y}

goal (1 subgoal):
 1. (take n qs @ [qs ! n]) ! n \<in> {y, x}
[PROOF STEP]
using tak[symmetric]
[PROOF STATE]
proof (prove)
using this:
qs ! n \<in> {x, y}
take n qs @ [qs ! n] = take (Suc n) qs

goal (1 subgoal):
 1. (take n qs @ [qs ! n]) ! n \<in> {y, x}
[PROOF STEP]
by(auto)
[PROOF STATE]
proof (state)
this:
(take n qs @ [qs ! n]) ! n \<in> {y, x}

goal (1 subgoal):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
have aer: "\<forall>i<n.
        ((take n qs @ [qs ! n]) ! i \<in> {y, x})
          = (take n qs ! i \<in> {y, x})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>i<n. ((take n qs @ [qs ! n]) ! i \<in> {y, x}) = (take n qs ! i \<in> {y, x})
[PROOF STEP]
using ns
[PROOF STATE]
proof (prove)
using this:
n < length qs

goal (1 subgoal):
 1. \<forall>i<n. ((take n qs @ [qs ! n]) ! i \<in> {y, x}) = (take n qs ! i \<in> {y, x})
[PROOF STEP]
by (metis less_SucI nth_take tak)
[PROOF STATE]
proof (state)
this:
\<forall>i<n. ((take n qs @ [qs ! n]) ! i \<in> {y, x}) = (take n qs ! i \<in> {y, x})

goal (1 subgoal):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
(* erst definiere ich die zwischenzeitlichen Configurationen
               ?xs  \<rightarrow> ?xs'  \<rightarrow> ?xs''
        und
        ?ys \<rightarrow> ?ys' \<rightarrow> ?ys'' \<rightarrow> ?ys'''

        und einige Eigenschaften ?ber sie
    *)

    (* what is the mtf action taken by Strat? *)
[PROOF STATE]
proof (state)
this:
\<forall>i<n. ((take n qs @ [qs ! n]) ! i \<in> {y, x}) = (take n qs ! i \<in> {y, x})

goal (1 subgoal):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
let ?Strat_mft =  "fst (Strat ! n)"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
let ?Strat_sws =  "snd (Strat ! n)"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
(* what is the configuration before the step? *)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
let ?xs = "steps' init (take n qs) (take n Strat) n"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
(* what is the configuration before the mtf *)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
let ?xs' = "(swaps (snd (Strat!n)) ?xs)"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
let ?xs'' = "steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n)"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
let ?xs''2 = "mtf2 ?Strat_mft (qs!n) ?xs'"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
(* position of requested element *)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
let ?no_swap_occurs = "(x < y in ?xs') = (x < y in ?xs''2)"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
let ?mtf="(if ?no_swap_occurs then 0 else 1::nat)"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
let ?m="ALG_P' Strat (take n qs @ [qs ! n]) init n x y"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
let ?L="replicate ?m 0 @ sws"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
let ?newStrat="Strat2@[(?mtf,?L)]"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
have "?xs'' =  step ?xs (qs!n) (Strat!n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = step (steps' init (take n qs) (take n Strat) n) (qs ! n) (Strat ! n)
[PROOF STEP]
unfolding tak tak2
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. steps' init (take n qs @ [qs ! n]) (take n Strat @ [Strat ! n]) (Suc n) = step (steps' init (take n qs) (take n Strat) n) (qs ! n) (Strat ! n)
[PROOF STEP]
apply(rule steps'_append)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. length (take n qs) = length (take n Strat)
 2. length (take n qs) = n
[PROOF STEP]
by fact+
[PROOF STATE]
proof (state)
this:
steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = step (steps' init (take n qs) (take n Strat) n) (qs ! n) (Strat ! n)

goal (1 subgoal):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = step (steps' init (take n qs) (take n Strat) n) (qs ! n) (Strat ! n)

goal (1 subgoal):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
have "\<dots> = mtf2 (fst (Strat!n)) (qs!n) (swaps (snd (Strat!n)) ?xs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. step (steps' init (take n qs) (take n Strat) n) (qs ! n) (Strat ! n) = mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
[PROOF STEP]
unfolding step_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (let (k, sws) = Strat ! n in mtf2 k (qs ! n) (swaps sws (steps' init (take n qs) (take n Strat) n))) = mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
[PROOF STEP]
by (auto simp: split_def)
[PROOF STATE]
proof (state)
this:
step (steps' init (take n qs) (take n Strat) n) (qs ! n) (Strat ! n) = mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))

goal (1 subgoal):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
[PROOF STEP]
have A: "?xs'' = mtf2 (fst (Strat!n)) (qs!n) ?xs'"
[PROOF STATE]
proof (prove)
using this:
steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))

goal (1 subgoal):
 1. steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))

goal (1 subgoal):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
let ?ys = "(steps' (Lxy init {x, y})
                  (Lxy (take n qs) {x, y}) Strat2 (length Strat2))"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
let ?ys' = "( swaps sws (steps' (Lxy init {x, y})
                  (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
let ?ys'' = " (swap 0 ^^ ALG_P (snd (Strat!n)) x y ?xs) ?ys'"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
let ?ys''' = "(steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) ?newStrat (length ?newStrat))"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
have gr: "Lxy (take n qs @ [qs ! n]) {x, y} =
        Lxy (take n qs) {x, y} @ [qs ! n]"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Lxy (take n qs @ [qs ! n]) {x, y} = Lxy (take n qs) {x, y} @ [qs ! n]
[PROOF STEP]
unfolding Lxy_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. filter (\<lambda>z. z \<in> {x, y}) (take n qs @ [qs ! n]) = filter (\<lambda>z. z \<in> {x, y}) (take n qs) @ [qs ! n]
[PROOF STEP]
using True
[PROOF STATE]
proof (prove)
using this:
qs ! n \<in> {x, y}

goal (1 subgoal):
 1. filter (\<lambda>z. z \<in> {x, y}) (take n qs @ [qs ! n]) = filter (\<lambda>z. z \<in> {x, y}) (take n qs) @ [qs ! n]
[PROOF STEP]
by(simp)
[PROOF STATE]
proof (state)
this:
Lxy (take n qs @ [qs ! n]) {x, y} = Lxy (take n qs) {x, y} @ [qs ! n]

goal (1 subgoal):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
have "steps' init (take n qs @ [qs ! n]) Strat n
      = steps' init (take n qs @ [qs ! n]) (take n Strat @ drop n Strat) n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. steps' init (take n qs @ [qs ! n]) Strat n = steps' init (take n qs @ [qs ! n]) (take n Strat @ drop n Strat) n
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
steps' init (take n qs @ [qs ! n]) Strat n = steps' init (take n qs @ [qs ! n]) (take n Strat @ drop n Strat) n

goal (1 subgoal):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
steps' init (take n qs @ [qs ! n]) Strat n = steps' init (take n qs @ [qs ! n]) (take n Strat @ drop n Strat) n

goal (1 subgoal):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
have "\<dots> = steps' init (take n qs) (take n Strat) n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. steps' init (take n qs @ [qs ! n]) (take n Strat @ drop n Strat) n = steps' init (take n qs) (take n Strat) n
[PROOF STEP]
apply(subst steps'_rests[symmetric])
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. length (take n qs) = length (take n Strat)
 2. n \<le> length (take n Strat)
 3. steps' init (take n qs) (take n Strat) n = steps' init (take n qs) (take n Strat) n
[PROOF STEP]
using aS qQS
[PROOF STATE]
proof (prove)
using this:
length (take n Strat) = n
length (take n qs) = length (take n Strat)

goal (3 subgoals):
 1. length (take n qs) = length (take n Strat)
 2. n \<le> length (take n Strat)
 3. steps' init (take n qs) (take n Strat) n = steps' init (take n qs) (take n Strat) n
[PROOF STEP]
by(simp_all)
[PROOF STATE]
proof (state)
this:
steps' init (take n qs @ [qs ! n]) (take n Strat @ drop n Strat) n = steps' init (take n qs) (take n Strat) n

goal (1 subgoal):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
steps' init (take n qs @ [qs ! n]) Strat n = steps' init (take n qs) (take n Strat) n
[PROOF STEP]
have t: "steps' init (take n qs @ [qs ! n]) Strat n
        = steps' init (take n qs) (take n Strat) n"
[PROOF STATE]
proof (prove)
using this:
steps' init (take n qs @ [qs ! n]) Strat n = steps' init (take n qs) (take n Strat) n

goal (1 subgoal):
 1. steps' init (take n qs @ [qs ! n]) Strat n = steps' init (take n qs) (take n Strat) n
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
steps' init (take n qs @ [qs ! n]) Strat n = steps' init (take n qs) (take n Strat) n

goal (1 subgoal):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
have gge: "swaps (replicate ?m 0) ?ys'
        =  (swap 0 ^^ ALG_P (snd (Strat!n)) x y ?xs) ?ys'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. swaps (replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) = (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
[PROOF STEP]
unfolding ALG_P'_def t
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. swaps (replicate (ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) 0) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) = (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
swaps (replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) = (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))

goal (1 subgoal):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
have gg: "length ?newStrat = Suc (length Strat2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) = Suc (length Strat2)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) = Suc (length Strat2)

goal (1 subgoal):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
have "?ys''' =  step ?ys (qs!n) (?mtf,?L)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)])) = step (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)) (qs ! n) (if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)
[PROOF STEP]
unfolding tak gr
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y} @ [qs ! n]) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)])) = step (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)) (qs ! n) (if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)
[PROOF STEP]
unfolding gg
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y} @ [qs ! n]) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (Suc (length Strat2)) = step (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)) (qs ! n) (if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)
[PROOF STEP]
apply(rule steps'_append)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. length (Lxy (take n qs) {x, y}) = length Strat2
 2. length (Lxy (take n qs) {x, y}) = length Strat2
[PROOF STEP]
using len
[PROOF STATE]
proof (prove)
using this:
length Strat2 = length (Lxy (take n qs) {x, y})

goal (2 subgoals):
 1. length (Lxy (take n qs) {x, y}) = length Strat2
 2. length (Lxy (take n qs) {x, y}) = length Strat2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)])) = step (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)) (qs ! n) (if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)

goal (1 subgoal):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)])) = step (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)) (qs ! n) (if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)

goal (1 subgoal):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
have "\<dots> = mtf2 ?mtf (qs!n) (swaps ?L ?ys)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. step (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)) (qs ! n) (if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws) = mtf2 (if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1) (qs ! n) (swaps (replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws) (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
[PROOF STEP]
unfolding step_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (let (k, sws) = (if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws) in mtf2 k (qs ! n) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) = mtf2 (if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1) (qs ! n) (swaps (replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws) (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
[PROOF STEP]
by (simp add: split_def)
[PROOF STATE]
proof (state)
this:
step (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)) (qs ! n) (if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws) = mtf2 (if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1) (qs ! n) (swaps (replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws) (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))

goal (1 subgoal):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
step (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)) (qs ! n) (if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws) = mtf2 (if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1) (qs ! n) (swaps (replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws) (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))

goal (1 subgoal):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
have "\<dots> = mtf2 ?mtf (qs!n) (swaps (replicate ?m 0) ?ys')"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mtf2 (if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1) (qs ! n) (swaps (replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws) (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) = mtf2 (if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1) (qs ! n) (swaps (replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))
[PROOF STEP]
by (simp)
[PROOF STATE]
proof (state)
this:
mtf2 (if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1) (qs ! n) (swaps (replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws) (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) = mtf2 (if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1) (qs ! n) (swaps (replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))

goal (1 subgoal):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
mtf2 (if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1) (qs ! n) (swaps (replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws) (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) = mtf2 (if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1) (qs ! n) (swaps (replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))

goal (1 subgoal):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
have "\<dots> = mtf2 ?mtf (qs!n) ?ys''"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mtf2 (if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1) (qs ! n) (swaps (replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) = mtf2 (if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1) (qs ! n) ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))
[PROOF STEP]
using gge
[PROOF STATE]
proof (prove)
using this:
swaps (replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) = (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))

goal (1 subgoal):
 1. mtf2 (if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1) (qs ! n) (swaps (replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) = mtf2 (if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1) (qs ! n) ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))
[PROOF STEP]
by (simp)
[PROOF STATE]
proof (state)
this:
mtf2 (if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1) (qs ! n) (swaps (replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) = mtf2 (if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1) (qs ! n) ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))

goal (1 subgoal):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)])) = mtf2 (if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1) (qs ! n) ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))
[PROOF STEP]
have B: "?ys''' = mtf2 ?mtf (qs!n) ?ys''"
[PROOF STATE]
proof (prove)
using this:
steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)])) = mtf2 (if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1) (qs ! n) ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))

goal (1 subgoal):
 1. steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)])) = mtf2 (if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1) (qs ! n) ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)])) = mtf2 (if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1) (qs ! n) ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))

goal (1 subgoal):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
have 3: "set ?ys' = {x,y}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) = {x, y}
[PROOF STEP]
apply(simp add: swaps_inv)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)) = {x, y}
[PROOF STEP]
apply(subst steps'_set)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. length (Lxy (take n qs) {x, y}) = length Strat2
 2. length Strat2 \<le> length Strat2
 3. set (Lxy init {x, y}) = {x, y}
[PROOF STEP]
using ahjer len
[PROOF STATE]
proof (prove)
using this:
set (Lxy init {x, y}) = {x, y}
length Strat2 = length (Lxy (take n qs) {x, y})

goal (3 subgoals):
 1. length (Lxy (take n qs) {x, y}) = length Strat2
 2. length Strat2 \<le> length Strat2
 3. set (Lxy init {x, y}) = {x, y}
[PROOF STEP]
by(simp_all)
[PROOF STATE]
proof (state)
this:
set (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) = {x, y}

goal (1 subgoal):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
have k: "?ys'' = swaps (replicate (ALG_P (snd (Strat!n)) x y ?xs) 0) ?ys'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) = swaps (replicate (ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) 0) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
[PROOF STEP]
by (auto)
[PROOF STATE]
proof (state)
this:
(swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) = swaps (replicate (ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) 0) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))

goal (1 subgoal):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
have 6: "set ?ys'' = {x,y}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) = {x, y}
[PROOF STEP]
unfolding k
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set (swaps (replicate (ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) 0) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) = {x, y}
[PROOF STEP]
using 3 swaps_inv
[PROOF STATE]
proof (prove)
using this:
set (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) = {x, y}
set (swaps ?sws ?xs) = set ?xs \<and> length (swaps ?sws ?xs) = length ?xs \<and> distinct (swaps ?sws ?xs) = distinct ?xs

goal (1 subgoal):
 1. set (swaps (replicate (ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) 0) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) = {x, y}
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
set ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) = {x, y}

goal (1 subgoal):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
have 7: "set ?ys''' = {x,y}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))) = {x, y}
[PROOF STEP]
unfolding B
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set (mtf2 (if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1) (qs ! n) ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))) = {x, y}
[PROOF STEP]
using set_mtf2 6
[PROOF STATE]
proof (prove)
using this:
set (mtf2 ?n ?x ?xs) = set ?xs
set ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) = {x, y}

goal (1 subgoal):
 1. set (mtf2 (if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1) (qs ! n) ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))) = {x, y}
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
set (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))) = {x, y}

goal (1 subgoal):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
have 22: "x \<in> set ?ys''" "y \<in> set ?ys''"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<in> set ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) &&& y \<in> set ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))
[PROOF STEP]
using 6
[PROOF STATE]
proof (prove)
using this:
set ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) = {x, y}

goal (1 subgoal):
 1. x \<in> set ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) &&& y \<in> set ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
x \<in> set ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))
y \<in> set ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))

goal (1 subgoal):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
have 23: "x \<in> set ?ys'''" "y \<in> set ?ys'''"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<in> set (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))) &&& y \<in> set (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)])))
[PROOF STEP]
using 7
[PROOF STATE]
proof (prove)
using this:
set (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))) = {x, y}

goal (1 subgoal):
 1. x \<in> set (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))) &&& y \<in> set (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)])))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
x \<in> set (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)])))
y \<in> set (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)])))

goal (1 subgoal):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
have 26: "(qs!n) \<in> set ?ys''"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. qs ! n \<in> set ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))
[PROOF STEP]
using 6 True
[PROOF STATE]
proof (prove)
using this:
set ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) = {x, y}
qs ! n \<in> {x, y}

goal (1 subgoal):
 1. qs ! n \<in> set ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
qs ! n \<in> set ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))

goal (1 subgoal):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
have "distinct ?ys"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. distinct (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))
[PROOF STEP]
apply(rule steps'_distinct2)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. length (Lxy (take n qs) {x, y}) = length Strat2
 2. length Strat2 \<le> length Strat2
 3. distinct (Lxy init {x, y})
[PROOF STEP]
using len ahjer3
[PROOF STATE]
proof (prove)
using this:
length Strat2 = length (Lxy (take n qs) {x, y})
distinct (Lxy init {x, y})

goal (3 subgoals):
 1. length (Lxy (take n qs) {x, y}) = length Strat2
 2. length Strat2 \<le> length Strat2
 3. distinct (Lxy init {x, y})
[PROOF STEP]
by(simp)+
[PROOF STATE]
proof (state)
this:
distinct (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))

goal (1 subgoal):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
distinct (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))
[PROOF STEP]
have 9: "distinct ?ys'"
[PROOF STATE]
proof (prove)
using this:
distinct (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))

goal (1 subgoal):
 1. distinct (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
[PROOF STEP]
using swaps_inv
[PROOF STATE]
proof (prove)
using this:
distinct (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))
set (swaps ?sws ?xs) = set ?xs \<and> length (swaps ?sws ?xs) = length ?xs \<and> distinct (swaps ?sws ?xs) = distinct ?xs

goal (1 subgoal):
 1. distinct (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
distinct (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))

goal (1 subgoal):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
distinct (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
[PROOF STEP]
have 27: "distinct ?ys''"
[PROOF STATE]
proof (prove)
using this:
distinct (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))

goal (1 subgoal):
 1. distinct ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))
[PROOF STEP]
unfolding k
[PROOF STATE]
proof (prove)
using this:
distinct (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))

goal (1 subgoal):
 1. distinct (swaps (replicate (ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) 0) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))
[PROOF STEP]
using swaps_inv
[PROOF STATE]
proof (prove)
using this:
distinct (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
set (swaps ?sws ?xs) = set ?xs \<and> length (swaps ?sws ?xs) = length ?xs \<and> distinct (swaps ?sws ?xs) = distinct ?xs

goal (1 subgoal):
 1. distinct (swaps (replicate (ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) 0) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
distinct ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))

goal (1 subgoal):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
from 3 Suc(5)
[PROOF STATE]
proof (chain)
picking this:
set (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) = {x, y}
x \<noteq> y
[PROOF STEP]
have "card (set ?ys') = 2"
[PROOF STATE]
proof (prove)
using this:
set (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) = {x, y}
x \<noteq> y

goal (1 subgoal):
 1. card (set (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) = 2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
card (set (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) = 2

goal (1 subgoal):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
card (set (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) = 2
[PROOF STEP]
have 4: "length ?ys' = 2"
[PROOF STATE]
proof (prove)
using this:
card (set (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) = 2

goal (1 subgoal):
 1. length (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) = 2
[PROOF STEP]
using distinct_card[OF 9]
[PROOF STATE]
proof (prove)
using this:
card (set (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) = 2
card (set (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) = length (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))

goal (1 subgoal):
 1. length (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) = 2
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
length (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) = 2

goal (1 subgoal):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
have "length ?ys'' = 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) = 2
[PROOF STEP]
unfolding k
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (swaps (replicate (ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) 0) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) = 2
[PROOF STEP]
using 4 swaps_inv
[PROOF STATE]
proof (prove)
using this:
length (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) = 2
set (swaps ?sws ?xs) = set ?xs \<and> length (swaps ?sws ?xs) = length ?xs \<and> distinct (swaps ?sws ?xs) = distinct ?xs

goal (1 subgoal):
 1. length (swaps (replicate (ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) 0) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) = 2
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
length ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) = 2

goal (1 subgoal):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
have 5: "dist_perm ?ys' ?ys'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dist_perm (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
[PROOF STEP]
using 9
[PROOF STATE]
proof (prove)
using this:
distinct (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))

goal (1 subgoal):
 1. dist_perm (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
dist_perm (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))

goal (1 subgoal):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
have sxs: "set ?xs = set init"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set (steps' init (take n qs) (take n Strat) n) = set init
[PROOF STEP]
apply(rule steps'_set)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. length (take n qs) = length (take n Strat)
 2. n \<le> length (take n Strat)
[PROOF STEP]
using qQS n Suc(3)
[PROOF STATE]
proof (prove)
using this:
length (take n qs) = length (take n Strat)
n \<le> length qs
length Strat = length qs

goal (2 subgoals):
 1. length (take n qs) = length (take n Strat)
 2. n \<le> length (take n Strat)
[PROOF STEP]
by(auto)
[PROOF STATE]
proof (state)
this:
set (steps' init (take n qs) (take n Strat) n) = set init

goal (1 subgoal):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
have sxs': "set ?xs' = set ?xs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) = set (steps' init (take n qs) (take n Strat) n)
[PROOF STEP]
using swaps_inv
[PROOF STATE]
proof (prove)
using this:
set (swaps ?sws ?xs) = set ?xs \<and> length (swaps ?sws ?xs) = length ?xs \<and> distinct (swaps ?sws ?xs) = distinct ?xs

goal (1 subgoal):
 1. set (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) = set (steps' init (take n qs) (take n Strat) n)
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
set (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) = set (steps' init (take n qs) (take n Strat) n)

goal (1 subgoal):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
have sxs'': "set ?xs'' = set ?xs'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set (steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n)) = set (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
[PROOF STEP]
unfolding A
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set (mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))) = set (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
[PROOF STEP]
using set_mtf2
[PROOF STATE]
proof (prove)
using this:
set (mtf2 ?n ?x ?xs) = set ?xs

goal (1 subgoal):
 1. set (mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))) = set (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
set (steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n)) = set (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))

goal (1 subgoal):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
have 24: "x \<in> set ?xs'" "y\<in>set ?xs'" "(qs!n) \<in> set ?xs'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<in> set (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) &&& y \<in> set (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) &&& qs ! n \<in> set (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
[PROOF STEP]
using xysubs True sxs sxs'
[PROOF STATE]
proof (prove)
using this:
{x, y} \<subseteq> set init
qs ! n \<in> {x, y}
set (steps' init (take n qs) (take n Strat) n) = set init
set (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) = set (steps' init (take n qs) (take n Strat) n)

goal (1 subgoal):
 1. x \<in> set (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) &&& y \<in> set (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) &&& qs ! n \<in> set (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
x \<in> set (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
y \<in> set (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
qs ! n \<in> set (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))

goal (1 subgoal):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
have 28: "x \<in> set ?xs''" "y\<in>set ?xs''" "(qs!n) \<in> set ?xs''"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<in> set (steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n)) &&& y \<in> set (steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n)) &&& qs ! n \<in> set (steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n))
[PROOF STEP]
using xysubs True sxs sxs' sxs''
[PROOF STATE]
proof (prove)
using this:
{x, y} \<subseteq> set init
qs ! n \<in> {x, y}
set (steps' init (take n qs) (take n Strat) n) = set init
set (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) = set (steps' init (take n qs) (take n Strat) n)
set (steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n)) = set (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))

goal (1 subgoal):
 1. x \<in> set (steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n)) &&& y \<in> set (steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n)) &&& qs ! n \<in> set (steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
x \<in> set (steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n))
y \<in> set (steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n))
qs ! n \<in> set (steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n))

goal (1 subgoal):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
have 0: "dist_perm init init"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dist_perm init init
[PROOF STEP]
using dI
[PROOF STATE]
proof (prove)
using this:
distinct init

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

goal (1 subgoal):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
have 1: "dist_perm ?xs ?xs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dist_perm (steps' init (take n qs) (take n Strat) n) (steps' init (take n qs) (take n Strat) n)
[PROOF STEP]
apply(rule steps'_dist_perm)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. length (take n qs) = length (take n Strat)
 2. length (take n Strat) = n
 3. dist_perm init init
[PROOF STEP]
by fact+
[PROOF STATE]
proof (state)
this:
dist_perm (steps' init (take n qs) (take n Strat) n) (steps' init (take n qs) (take n Strat) n)

goal (1 subgoal):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
dist_perm (steps' init (take n qs) (take n Strat) n) (steps' init (take n qs) (take n Strat) n)
[PROOF STEP]
have 25: "distinct ?xs'"
[PROOF STATE]
proof (prove)
using this:
dist_perm (steps' init (take n qs) (take n Strat) n) (steps' init (take n qs) (take n Strat) n)

goal (1 subgoal):
 1. distinct (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
[PROOF STEP]
using swaps_inv
[PROOF STATE]
proof (prove)
using this:
dist_perm (steps' init (take n qs) (take n Strat) n) (steps' init (take n qs) (take n Strat) n)
set (swaps ?sws ?xs) = set ?xs \<and> length (swaps ?sws ?xs) = length ?xs \<and> distinct (swaps ?sws ?xs) = distinct ?xs

goal (1 subgoal):
 1. distinct (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
distinct (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))

goal (1 subgoal):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
(* aus der Induktionsvorraussetzung (iff) wei? ich bereits
        dass die Ordnung erhalten wird bis zum nten Schritt,
        mit Theorem "projected_paid_same_effect" kann ich auch die paid exchanges abarbeiten ...*)
[PROOF STATE]
proof (state)
this:
distinct (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))

goal (1 subgoal):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
from projected_paid_same_effect[OF 1 Suc(5) 3 4 5, OF iff, where acs="snd (Strat ! n)"]
[PROOF STATE]
proof (chain)
picking this:
x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
[PROOF STEP]
have aaa: "x < y in ?xs'  = x < y in ?ys''"
[PROOF STATE]
proof (prove)
using this:
x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))

goal (1 subgoal):
 1. x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))

goal (1 subgoal):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
(* ... was nun noch fehlt ist, dass die moveToFront anweisungen von Strat
        und Strat2 sich in gleicher Art auf die Ordnung von x und y auswirken
    *)
[PROOF STATE]
proof (state)
this:
x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))

goal (1 subgoal):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
have t: "?mtf = (if (x<y in ?xs') = (x<y in ?xs'') then 0 else 1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1) = (if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) then 0 else 1)
[PROOF STEP]
by (simp add: A)
[PROOF STATE]
proof (state)
this:
(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1) = (if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) then 0 else 1)

goal (1 subgoal):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
have central: "x < y in ?xs'' = x < y  in ?ys'''"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))
[PROOF STEP]
proof (cases "(x<y in ?xs') = (x<y in ?xs'')")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) \<Longrightarrow> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))
 2. x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) \<noteq> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) \<Longrightarrow> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n)

goal (2 subgoals):
 1. x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) \<Longrightarrow> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))
 2. x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) \<noteq> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) \<Longrightarrow> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n)
[PROOF STEP]
have "?mtf = 0"
[PROOF STATE]
proof (prove)
using this:
x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n)

goal (1 subgoal):
 1. (if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1) = 0
[PROOF STEP]
using t
[PROOF STATE]
proof (prove)
using this:
x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n)
(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1) = (if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) then 0 else 1)

goal (1 subgoal):
 1. (if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1) = 0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1) = 0

goal (2 subgoals):
 1. x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) \<Longrightarrow> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))
 2. x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) \<noteq> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) \<Longrightarrow> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))
[PROOF STEP]
with B
[PROOF STATE]
proof (chain)
picking this:
steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)])) = mtf2 (if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1) (qs ! n) ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))
(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1) = 0
[PROOF STEP]
have "?ys''' = ?ys''"
[PROOF STATE]
proof (prove)
using this:
steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)])) = mtf2 (if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1) (qs ! n) ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))
(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1) = 0

goal (1 subgoal):
 1. steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)])) = (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)])) = (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))

goal (2 subgoals):
 1. x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) \<Longrightarrow> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))
 2. x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) \<noteq> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) \<Longrightarrow> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))
[PROOF STEP]
with aaa True
[PROOF STATE]
proof (chain)
picking this:
x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n)
steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)])) = (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n)
steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)])) = (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))

goal (1 subgoal):
 1. x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))

goal (1 subgoal):
 1. x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) \<noteq> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) \<Longrightarrow> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) \<noteq> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) \<Longrightarrow> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) \<noteq> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n)

goal (1 subgoal):
 1. x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) \<noteq> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) \<Longrightarrow> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) \<noteq> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n)
[PROOF STEP]
have k: "?mtf = 1"
[PROOF STATE]
proof (prove)
using this:
x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) \<noteq> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n)

goal (1 subgoal):
 1. (if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1) = 1
[PROOF STEP]
using t
[PROOF STATE]
proof (prove)
using this:
x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) \<noteq> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n)
(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1) = (if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) then 0 else 1)

goal (1 subgoal):
 1. (if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1) = 1
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1) = 1

goal (1 subgoal):
 1. x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) \<noteq> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) \<Longrightarrow> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))
[PROOF STEP]
from False
[PROOF STATE]
proof (chain)
picking this:
x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) \<noteq> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n)
[PROOF STEP]
have i: "(x<y in ?xs') = (~x<y in ?xs'')"
[PROOF STATE]
proof (prove)
using this:
x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) \<noteq> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n)

goal (1 subgoal):
 1. x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = (\<not> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = (\<not> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n))

goal (1 subgoal):
 1. x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) \<noteq> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) \<Longrightarrow> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))
[PROOF STEP]
have gn: "\<And>a b. a\<in>{x,y} \<Longrightarrow> b\<in>{x,y} \<Longrightarrow> set ?ys'' = {x,y} \<Longrightarrow>
                  a\<noteq>b \<Longrightarrow> distinct ?ys'' \<Longrightarrow>
                  a<b in ?ys'' \<Longrightarrow> ~a<b in mtf2 1 b ?ys''"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>a b. \<lbrakk>a \<in> {x, y}; b \<in> {x, y}; set ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) = {x, y}; a \<noteq> b; distinct ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))); a < b in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))\<rbrakk> \<Longrightarrow> \<not> a < b in mtf2 1 b ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))
[PROOF STEP]
proof goal_cases
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a b. \<lbrakk>a \<in> {x, y}; b \<in> {x, y}; set ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) = {x, y}; a \<noteq> b; distinct ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))); a < b in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))\<rbrakk> \<Longrightarrow> \<not> a < b in mtf2 1 b ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))
[PROOF STEP]
case (1 a b)
[PROOF STATE]
proof (state)
this:
a \<in> {x, y}
b \<in> {x, y}
set ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) = {x, y}
a \<noteq> b
distinct ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))
a < b in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))

goal (1 subgoal):
 1. \<And>a b. \<lbrakk>a \<in> {x, y}; b \<in> {x, y}; set ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) = {x, y}; a \<noteq> b; distinct ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))); a < b in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))\<rbrakk> \<Longrightarrow> \<not> a < b in mtf2 1 b ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))
[PROOF STEP]
from 1
[PROOF STATE]
proof (chain)
picking this:
a \<in> {x, y}
b \<in> {x, y}
set ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) = {x, y}
a \<noteq> b
distinct ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))
a < b in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
[PROOF STEP]
have f: "set ?ys'' = {a,b}"
[PROOF STATE]
proof (prove)
using this:
a \<in> {x, y}
b \<in> {x, y}
set ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) = {x, y}
a \<noteq> b
distinct ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))
a < b in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))

goal (1 subgoal):
 1. set ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) = {a, b}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
set ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) = {a, b}

goal (1 subgoal):
 1. \<And>a b. \<lbrakk>a \<in> {x, y}; b \<in> {x, y}; set ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) = {x, y}; a \<noteq> b; distinct ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))); a < b in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))\<rbrakk> \<Longrightarrow> \<not> a < b in mtf2 1 b ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))
[PROOF STEP]
with 1
[PROOF STATE]
proof (chain)
picking this:
a \<in> {x, y}
b \<in> {x, y}
set ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) = {x, y}
a \<noteq> b
distinct ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))
a < b in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
set ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) = {a, b}
[PROOF STEP]
have i: "card (set ?ys'') = 2"
[PROOF STATE]
proof (prove)
using this:
a \<in> {x, y}
b \<in> {x, y}
set ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) = {x, y}
a \<noteq> b
distinct ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))
a < b in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
set ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) = {a, b}

goal (1 subgoal):
 1. card (set ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))) = 2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
card (set ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))) = 2

goal (1 subgoal):
 1. \<And>a b. \<lbrakk>a \<in> {x, y}; b \<in> {x, y}; set ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) = {x, y}; a \<noteq> b; distinct ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))); a < b in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))\<rbrakk> \<Longrightarrow> \<not> a < b in mtf2 1 b ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))
[PROOF STEP]
from 1(5)
[PROOF STATE]
proof (chain)
picking this:
distinct ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))
[PROOF STEP]
have "dist_perm ?ys'' ?ys''"
[PROOF STATE]
proof (prove)
using this:
distinct ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))

goal (1 subgoal):
 1. dist_perm ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
dist_perm ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))

goal (1 subgoal):
 1. \<And>a b. \<lbrakk>a \<in> {x, y}; b \<in> {x, y}; set ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) = {x, y}; a \<noteq> b; distinct ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))); a < b in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))\<rbrakk> \<Longrightarrow> \<not> a < b in mtf2 1 b ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))
[PROOF STEP]
from i distinct_card 1(5)
[PROOF STATE]
proof (chain)
picking this:
card (set ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))) = 2
distinct ?xs \<Longrightarrow> card (set ?xs) = length ?xs
distinct ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))
[PROOF STEP]
have g: "length ?ys'' = 2"
[PROOF STATE]
proof (prove)
using this:
card (set ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))) = 2
distinct ?xs \<Longrightarrow> card (set ?xs) = length ?xs
distinct ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))

goal (1 subgoal):
 1. length ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) = 2
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
length ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) = 2

goal (1 subgoal):
 1. \<And>a b. \<lbrakk>a \<in> {x, y}; b \<in> {x, y}; set ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) = {x, y}; a \<noteq> b; distinct ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))); a < b in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))\<rbrakk> \<Longrightarrow> \<not> a < b in mtf2 1 b ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))
[PROOF STEP]
with 1(6)
[PROOF STATE]
proof (chain)
picking this:
a < b in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
length ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) = 2
[PROOF STEP]
have d: "index ?ys'' b = 1"
[PROOF STATE]
proof (prove)
using this:
a < b in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
length ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) = 2

goal (1 subgoal):
 1. index ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) b = 1
[PROOF STEP]
using before_in_index2 f 1(4)
[PROOF STATE]
proof (prove)
using this:
a < b in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
length ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) = 2
\<lbrakk>set ?l = {?x, ?y}; length ?l = 2; ?x \<noteq> ?y\<rbrakk> \<Longrightarrow> (if ?x < ?y in ?l then 1 else 0) = index ?l ?y
set ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) = {a, b}
a \<noteq> b

goal (1 subgoal):
 1. index ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) b = 1
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
index ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) b = 1

goal (1 subgoal):
 1. \<And>a b. \<lbrakk>a \<in> {x, y}; b \<in> {x, y}; set ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) = {x, y}; a \<noteq> b; distinct ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))); a < b in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))\<rbrakk> \<Longrightarrow> \<not> a < b in mtf2 1 b ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))
[PROOF STEP]
from 1(2,3)
[PROOF STATE]
proof (chain)
picking this:
b \<in> {x, y}
set ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) = {x, y}
[PROOF STEP]
have e: "b \<in> set ?ys''"
[PROOF STATE]
proof (prove)
using this:
b \<in> {x, y}
set ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) = {x, y}

goal (1 subgoal):
 1. b \<in> set ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
b \<in> set ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))

goal (1 subgoal):
 1. \<And>a b. \<lbrakk>a \<in> {x, y}; b \<in> {x, y}; set ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) = {x, y}; a \<noteq> b; distinct ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))); a < b in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))\<rbrakk> \<Longrightarrow> \<not> a < b in mtf2 1 b ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))
[PROOF STEP]
from d e
[PROOF STATE]
proof (chain)
picking this:
index ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) b = 1
b \<in> set ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))
[PROOF STEP]
have p: "mtf2 1 b ?ys'' = swap 0 ?ys''"
[PROOF STATE]
proof (prove)
using this:
index ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) b = 1
b \<in> set ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))

goal (1 subgoal):
 1. mtf2 1 b ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) = swap 0 ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))
[PROOF STEP]
unfolding mtf2_def
[PROOF STATE]
proof (prove)
using this:
index ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) b = 1
b \<in> set ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))

goal (1 subgoal):
 1. (if b \<in> set ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) then swaps [index ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) b - 1..<index ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) b] ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) else (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) = swap 0 ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
mtf2 1 b ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) = swap 0 ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))

goal (1 subgoal):
 1. \<And>a b. \<lbrakk>a \<in> {x, y}; b \<in> {x, y}; set ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) = {x, y}; a \<noteq> b; distinct ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))); a < b in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))\<rbrakk> \<Longrightarrow> \<not> a < b in mtf2 1 b ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))
[PROOF STEP]
have q: "a < b in swap 0 ?ys'' = (\<not> a < b in ?ys'')"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a < b in swap 0 ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) = (\<not> a < b in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))
[PROOF STEP]
apply(rule swap0in2)
[PROOF STATE]
proof (prove)
goal (4 subgoals):
 1. set ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) = {a, b}
 2. a \<noteq> b
 3. length ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) = 2
 4. dist_perm ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))
[PROOF STEP]
by(fact)+
[PROOF STATE]
proof (state)
this:
a < b in swap 0 ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) = (\<not> a < b in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))

goal (1 subgoal):
 1. \<And>a b. \<lbrakk>a \<in> {x, y}; b \<in> {x, y}; set ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) = {x, y}; a \<noteq> b; distinct ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))); a < b in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))\<rbrakk> \<Longrightarrow> \<not> a < b in mtf2 1 b ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))
[PROOF STEP]
from 1(6) p q
[PROOF STATE]
proof (chain)
picking this:
a < b in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
mtf2 1 b ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) = swap 0 ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))
a < b in swap 0 ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) = (\<not> a < b in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
a < b in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
mtf2 1 b ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) = swap 0 ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))
a < b in swap 0 ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) = (\<not> a < b in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))

goal (1 subgoal):
 1. \<not> a < b in mtf2 1 b ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
\<not> a < b in mtf2 1 b ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<lbrakk>?a \<in> {x, y}; ?b \<in> {x, y}; set ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) = {x, y}; ?a \<noteq> ?b; distinct ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))); ?a < ?b in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))\<rbrakk> \<Longrightarrow> \<not> ?a < ?b in mtf2 1 ?b ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))

goal (1 subgoal):
 1. x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) \<noteq> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) \<Longrightarrow> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))
[PROOF STEP]
proof (cases "x<y in ?xs'")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) \<Longrightarrow> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))
 2. \<not> x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) \<Longrightarrow> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)

goal (2 subgoals):
 1. x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) \<Longrightarrow> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))
 2. \<not> x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) \<Longrightarrow> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))
[PROOF STEP]
with aaa
[PROOF STATE]
proof (chain)
picking this:
x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)
[PROOF STEP]
have st: "x < y in ?ys''"
[PROOF STATE]
proof (prove)
using this:
x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)

goal (1 subgoal):
 1. x < y in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
x < y in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))

goal (2 subgoals):
 1. x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) \<Longrightarrow> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))
 2. \<not> x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) \<Longrightarrow> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))
[PROOF STEP]
from True False
[PROOF STATE]
proof (chain)
picking this:
x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)
x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) \<noteq> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n)
[PROOF STEP]
have "~ x<y in ?xs''"
[PROOF STATE]
proof (prove)
using this:
x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)
x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) \<noteq> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n)

goal (1 subgoal):
 1. \<not> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<not> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n)

goal (2 subgoals):
 1. x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) \<Longrightarrow> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))
 2. \<not> x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) \<Longrightarrow> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))
[PROOF STEP]
with Suc(5) 28 not_before_in A
[PROOF STATE]
proof (chain)
picking this:
x \<noteq> y
x \<in> set (steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n))
y \<in> set (steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n))
qs ! n \<in> set (steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n))
\<lbrakk>?x \<in> set ?xs; ?y \<in> set ?xs\<rbrakk> \<Longrightarrow> (\<not> ?x < ?y in ?xs) = (?y < ?x in ?xs \<or> ?x = ?y)
steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
\<not> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n)
[PROOF STEP]
have "y < x in ?xs''"
[PROOF STATE]
proof (prove)
using this:
x \<noteq> y
x \<in> set (steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n))
y \<in> set (steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n))
qs ! n \<in> set (steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n))
\<lbrakk>?x \<in> set ?xs; ?y \<in> set ?xs\<rbrakk> \<Longrightarrow> (\<not> ?x < ?y in ?xs) = (?y < ?x in ?xs \<or> ?x = ?y)
steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
\<not> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n)

goal (1 subgoal):
 1. y < x in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n)
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
y < x in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n)

goal (2 subgoals):
 1. x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) \<Longrightarrow> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))
 2. \<not> x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) \<Longrightarrow> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))
[PROOF STEP]
with A
[PROOF STATE]
proof (chain)
picking this:
steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
y < x in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n)
[PROOF STEP]
have "y < x in mtf2 (fst (Strat!n)) (qs!n) ?xs'"
[PROOF STATE]
proof (prove)
using this:
steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
y < x in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n)

goal (1 subgoal):
 1. y < x in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
y < x in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))

goal (2 subgoals):
 1. x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) \<Longrightarrow> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))
 2. \<not> x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) \<Longrightarrow> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))
[PROOF STEP]
(*from True swapped_by_mtf2*)
[PROOF STATE]
proof (state)
this:
y < x in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))

goal (2 subgoals):
 1. x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) \<Longrightarrow> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))
 2. \<not> x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) \<Longrightarrow> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))
[PROOF STEP]
have itisy: "y = (qs!n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. y = qs ! n
[PROOF STEP]
apply(rule swapped_by_mtf2[where xs= ?xs'])
[PROOF STATE]
proof (prove)
goal (6 subgoals):
 1. qs ! n \<in> set (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
 2. distinct (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
 3. ?x \<in> set (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
 4. y \<in> set (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
 5. ?x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)
 6. y < ?x in mtf2 ?n (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
[PROOF STEP]
apply(fact)
[PROOF STATE]
proof (prove)
goal (5 subgoals):
 1. distinct (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
 2. ?x \<in> set (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
 3. y \<in> set (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
 4. ?x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)
 5. y < ?x in mtf2 ?n (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
[PROOF STEP]
apply(fact)
[PROOF STATE]
proof (prove)
goal (4 subgoals):
 1. ?x \<in> set (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
 2. y \<in> set (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
 3. ?x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)
 4. y < ?x in mtf2 ?n (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
[PROOF STEP]
apply(fact 24)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. y \<in> set (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
 2. x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)
 3. y < x in mtf2 ?n (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
[PROOF STEP]
apply(fact 24)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)
 2. y < x in mtf2 ?n (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
[PROOF STEP]
by(fact)+
[PROOF STATE]
proof (state)
this:
y = qs ! n

goal (2 subgoals):
 1. x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) \<Longrightarrow> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))
 2. \<not> x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) \<Longrightarrow> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))
[PROOF STEP]
have "~x<y in mtf2 1 y ?ys''"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<not> x < y in mtf2 1 y ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))
[PROOF STEP]
apply(rule gn)
[PROOF STATE]
proof (prove)
goal (6 subgoals):
 1. x \<in> {x, y}
 2. y \<in> {x, y}
 3. set ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) = {x, y}
 4. x \<noteq> y
 5. distinct ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))
 6. x < y in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
[PROOF STEP]
apply(simp)
[PROOF STATE]
proof (prove)
goal (5 subgoals):
 1. y \<in> {x, y}
 2. set ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) = {x, y}
 3. x \<noteq> y
 4. distinct ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))
 5. x < y in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
[PROOF STEP]
apply(simp)
[PROOF STATE]
proof (prove)
goal (4 subgoals):
 1. set ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) = {x, y}
 2. x \<noteq> y
 3. distinct ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))
 4. x < y in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
[PROOF STEP]
apply(simp add: 6)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. x \<noteq> y
 2. distinct ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))
 3. x < y in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
[PROOF STEP]
by(fact)+
[PROOF STATE]
proof (state)
this:
\<not> x < y in mtf2 1 y ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))

goal (2 subgoals):
 1. x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) \<Longrightarrow> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))
 2. \<not> x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) \<Longrightarrow> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<not> x < y in mtf2 1 y ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))
[PROOF STEP]
have ts: "~x<y in ?ys'''"
[PROOF STATE]
proof (prove)
using this:
\<not> x < y in mtf2 1 y ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))

goal (1 subgoal):
 1. \<not> x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))
[PROOF STEP]
using B itisy k
[PROOF STATE]
proof (prove)
using this:
\<not> x < y in mtf2 1 y ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))
steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)])) = mtf2 (if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1) (qs ! n) ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))
y = qs ! n
(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1) = 1

goal (1 subgoal):
 1. \<not> x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<not> x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))

goal (2 subgoals):
 1. x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) \<Longrightarrow> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))
 2. \<not> x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) \<Longrightarrow> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))
[PROOF STEP]
have ii: "(x<y in ?ys'') = (~x<y in ?ys''')"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x < y in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) = (\<not> x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)])))
[PROOF STEP]
using st ts
[PROOF STATE]
proof (prove)
using this:
x < y in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
\<not> x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))

goal (1 subgoal):
 1. x < y in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) = (\<not> x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)])))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
x < y in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) = (\<not> x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)])))

goal (2 subgoals):
 1. x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) \<Longrightarrow> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))
 2. \<not> x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) \<Longrightarrow> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))
[PROOF STEP]
from i ii aaa
[PROOF STATE]
proof (chain)
picking this:
x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = (\<not> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n))
x < y in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) = (\<not> x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)])))
x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = (\<not> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n))
x < y in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) = (\<not> x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)])))
x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))

goal (1 subgoal):
 1. x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))

goal (1 subgoal):
 1. \<not> x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) \<Longrightarrow> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) \<Longrightarrow> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)

goal (1 subgoal):
 1. \<not> x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) \<Longrightarrow> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))
[PROOF STEP]
with aaa
[PROOF STATE]
proof (chain)
picking this:
x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
\<not> x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)
[PROOF STEP]
have st: "~ x < y in ?ys''"
[PROOF STATE]
proof (prove)
using this:
x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
\<not> x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)

goal (1 subgoal):
 1. \<not> x < y in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<not> x < y in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))

goal (1 subgoal):
 1. \<not> x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) \<Longrightarrow> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))
[PROOF STEP]
with Suc(5) 22 not_before_in
[PROOF STATE]
proof (chain)
picking this:
x \<noteq> y
x \<in> set ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))
y \<in> set ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))
\<lbrakk>?x \<in> set ?xs; ?y \<in> set ?xs\<rbrakk> \<Longrightarrow> (\<not> ?x < ?y in ?xs) = (?y < ?x in ?xs \<or> ?x = ?y)
\<not> x < y in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
[PROOF STEP]
have st: "y < x in ?ys''"
[PROOF STATE]
proof (prove)
using this:
x \<noteq> y
x \<in> set ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))
y \<in> set ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))
\<lbrakk>?x \<in> set ?xs; ?y \<in> set ?xs\<rbrakk> \<Longrightarrow> (\<not> ?x < ?y in ?xs) = (?y < ?x in ?xs \<or> ?x = ?y)
\<not> x < y in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))

goal (1 subgoal):
 1. y < x in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
y < x in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))

goal (1 subgoal):
 1. \<not> x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) \<Longrightarrow> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))
[PROOF STEP]
from i False
[PROOF STATE]
proof (chain)
picking this:
x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = (\<not> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n))
\<not> x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)
[PROOF STEP]
have kl: "x<y in ?xs''"
[PROOF STATE]
proof (prove)
using this:
x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = (\<not> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n))
\<not> x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)

goal (1 subgoal):
 1. x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n)

goal (1 subgoal):
 1. \<not> x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) \<Longrightarrow> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))
[PROOF STEP]
with A
[PROOF STATE]
proof (chain)
picking this:
steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n)
[PROOF STEP]
have "x < y in mtf2 (fst (Strat!n)) (qs!n) ?xs'"
[PROOF STATE]
proof (prove)
using this:
steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n)

goal (1 subgoal):
 1. x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))

goal (1 subgoal):
 1. \<not> x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) \<Longrightarrow> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))
[PROOF STEP]
from False Suc(5) 24 not_before_in
[PROOF STATE]
proof (chain)
picking this:
\<not> x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)
x \<noteq> y
x \<in> set (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
y \<in> set (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
qs ! n \<in> set (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
\<lbrakk>?x \<in> set ?xs; ?y \<in> set ?xs\<rbrakk> \<Longrightarrow> (\<not> ?x < ?y in ?xs) = (?y < ?x in ?xs \<or> ?x = ?y)
[PROOF STEP]
have "y < x in ?xs'"
[PROOF STATE]
proof (prove)
using this:
\<not> x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)
x \<noteq> y
x \<in> set (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
y \<in> set (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
qs ! n \<in> set (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
\<lbrakk>?x \<in> set ?xs; ?y \<in> set ?xs\<rbrakk> \<Longrightarrow> (\<not> ?x < ?y in ?xs) = (?y < ?x in ?xs \<or> ?x = ?y)

goal (1 subgoal):
 1. y < x in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
y < x in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)

goal (1 subgoal):
 1. \<not> x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) \<Longrightarrow> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))
[PROOF STEP]
have itisx: "x = (qs!n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x = qs ! n
[PROOF STEP]
apply(rule swapped_by_mtf2[where xs= ?xs'])
[PROOF STATE]
proof (prove)
goal (6 subgoals):
 1. qs ! n \<in> set (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
 2. distinct (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
 3. ?x \<in> set (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
 4. x \<in> set (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
 5. ?x < x in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)
 6. x < ?x in mtf2 ?n (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
[PROOF STEP]
apply(fact)
[PROOF STATE]
proof (prove)
goal (5 subgoals):
 1. distinct (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
 2. ?x \<in> set (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
 3. x \<in> set (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
 4. ?x < x in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)
 5. x < ?x in mtf2 ?n (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
[PROOF STEP]
apply(fact)
[PROOF STATE]
proof (prove)
goal (4 subgoals):
 1. ?x \<in> set (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
 2. x \<in> set (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
 3. ?x < x in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)
 4. x < ?x in mtf2 ?n (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
[PROOF STEP]
apply(fact 24(2))
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. x \<in> set (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
 2. y < x in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)
 3. x < y in mtf2 ?n (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
[PROOF STEP]
apply(fact 24)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. y < x in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)
 2. x < y in mtf2 ?n (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n))
[PROOF STEP]
by(fact)+
[PROOF STATE]
proof (state)
this:
x = qs ! n

goal (1 subgoal):
 1. \<not> x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) \<Longrightarrow> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))
[PROOF STEP]
have "~y<x in mtf2 1 x ?ys''"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<not> y < x in mtf2 1 x ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))
[PROOF STEP]
apply(rule gn)
[PROOF STATE]
proof (prove)
goal (6 subgoals):
 1. y \<in> {x, y}
 2. x \<in> {x, y}
 3. set ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) = {x, y}
 4. y \<noteq> x
 5. distinct ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))
 6. y < x in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
[PROOF STEP]
apply(simp)
[PROOF STATE]
proof (prove)
goal (5 subgoals):
 1. x \<in> {x, y}
 2. set ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) = {x, y}
 3. y \<noteq> x
 4. distinct ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))
 5. y < x in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
[PROOF STEP]
apply(simp)
[PROOF STATE]
proof (prove)
goal (4 subgoals):
 1. set ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) = {x, y}
 2. y \<noteq> x
 3. distinct ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))
 4. y < x in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
[PROOF STEP]
apply(simp add: 6)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. y \<noteq> x
 2. distinct ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))
 3. y < x in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
[PROOF STEP]
apply(metis Suc(5))
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. distinct ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))
 2. y < x in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
[PROOF STEP]
by(fact)+
[PROOF STATE]
proof (state)
this:
\<not> y < x in mtf2 1 x ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))

goal (1 subgoal):
 1. \<not> x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) \<Longrightarrow> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<not> y < x in mtf2 1 x ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))
[PROOF STEP]
have "~y<x in ?ys'''"
[PROOF STATE]
proof (prove)
using this:
\<not> y < x in mtf2 1 x ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))

goal (1 subgoal):
 1. \<not> y < x in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))
[PROOF STEP]
using itisx k B
[PROOF STATE]
proof (prove)
using this:
\<not> y < x in mtf2 1 x ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))
x = qs ! n
(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1) = 1
steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)])) = mtf2 (if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1) (qs ! n) ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))

goal (1 subgoal):
 1. \<not> y < x in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<not> y < x in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))

goal (1 subgoal):
 1. \<not> x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) \<Longrightarrow> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))
[PROOF STEP]
with Suc(5) not_before_in 23
[PROOF STATE]
proof (chain)
picking this:
x \<noteq> y
\<lbrakk>?x \<in> set ?xs; ?y \<in> set ?xs\<rbrakk> \<Longrightarrow> (\<not> ?x < ?y in ?xs) = (?y < ?x in ?xs \<or> ?x = ?y)
x \<in> set (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)])))
y \<in> set (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)])))
\<not> y < x in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))
[PROOF STEP]
have "x<y in ?ys'''"
[PROOF STATE]
proof (prove)
using this:
x \<noteq> y
\<lbrakk>?x \<in> set ?xs; ?y \<in> set ?xs\<rbrakk> \<Longrightarrow> (\<not> ?x < ?y in ?xs) = (?y < ?x in ?xs \<or> ?x = ?y)
x \<in> set (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)])))
y \<in> set (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)])))
\<not> y < x in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))

goal (1 subgoal):
 1. x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))

goal (1 subgoal):
 1. \<not> x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) \<Longrightarrow> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))
[PROOF STEP]
with st
[PROOF STATE]
proof (chain)
picking this:
y < x in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))
[PROOF STEP]
have "(x<y in ?ys'') = (~x<y in ?ys''')"
[PROOF STATE]
proof (prove)
using this:
y < x in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))

goal (1 subgoal):
 1. x < y in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) = (\<not> x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)])))
[PROOF STEP]
using  B k
[PROOF STATE]
proof (prove)
using this:
y < x in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))
steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)])) = mtf2 (if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1) (qs ! n) ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))))
(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1) = 1

goal (1 subgoal):
 1. x < y in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) = (\<not> x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)])))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
x < y in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) = (\<not> x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)])))

goal (1 subgoal):
 1. \<not> x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) \<Longrightarrow> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))
[PROOF STEP]
with i aaa
[PROOF STATE]
proof (chain)
picking this:
x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = (\<not> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n))
x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
x < y in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) = (\<not> x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)])))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = (\<not> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n))
x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
x < y in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) = (\<not> x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)])))

goal (1 subgoal):
 1. x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))

goal (1 subgoal):
 1. qs ! n \<in> {x, y} \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
apply(rule exI[where x="?newStrat"])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>swsa. length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps swsa (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) + length swsa = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
apply(rule exI[where x="[]"])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps [] (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) + length [] = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
proof (standard, goal_cases)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) = length (Lxy (take (Suc n) qs) {x, y})
 2. x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps [] (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) + length [] = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
case 1
[PROOF STATE]
proof (state)
this:

goal (2 subgoals):
 1. length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) = length (Lxy (take (Suc n) qs) {x, y})
 2. x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps [] (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) + length [] = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) = length (Lxy (take (Suc n) qs) {x, y})
[PROOF STEP]
unfolding yeh
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) = length (Lxy (take n qs) {x, y} @ [qs ! n])
[PROOF STEP]
using len
[PROOF STATE]
proof (prove)
using this:
length Strat2 = length (Lxy (take n qs) {x, y})

goal (1 subgoal):
 1. length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) = length (Lxy (take n qs) {x, y} @ [qs ! n])
[PROOF STEP]
by(simp)
[PROOF STATE]
proof (state)
this:
length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) = length (Lxy (take (Suc n) qs) {x, y})

goal (1 subgoal):
 1. x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps [] (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) + length [] = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps [] (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) + length [] = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
case 2
[PROOF STATE]
proof (state)
this:

goal (1 subgoal):
 1. x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps [] (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) + length [] = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps [] (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) + length [] = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
proof (standard, goal_cases)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps [] (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)])))
 2. T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) + length [] = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
case 1
[PROOF STATE]
proof (state)
this:

goal (2 subgoals):
 1. x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps [] (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)])))
 2. T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) + length [] = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
(* hier beweise ich also, dass die ordnung von x und y in der projezierten
             Ausf?hrung (von Strat2) der Ordnung von x und y in der Ausf?hrung
             von Strat entspricht *)
[PROOF STATE]
proof (state)
this:

goal (2 subgoals):
 1. x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps [] (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)])))
 2. T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) + length [] = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
from central
[PROOF STATE]
proof (chain)
picking this:
x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))

goal (1 subgoal):
 1. x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps [] (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)])))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps [] (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)])))

goal (1 subgoal):
 1. T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) + length [] = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) + length [] = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
case 2
[PROOF STATE]
proof (state)
this:

goal (1 subgoal):
 1. T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) + length [] = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
(* nun muss noch bewiesen werden, dass die Kosten sich richtig aufspalten:
             Kosten f?r Strat2 + |sws|
             = blocking kosten von x,y + paid exchange kosten von x,y
          *)
[PROOF STATE]
proof (state)
this:

goal (1 subgoal):
 1. T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) + length [] = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
have j: "ALGxy_det Strat (take (Suc n) qs) init x y =
            ALGxy_det Strat (take n qs) init x y
                  + (ALG'_det Strat qs init n y + ALG'_det Strat qs init n x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ALGxy_det Strat (take (Suc n) qs) init x y = ALGxy_det Strat (take n qs) init x y + (ALG'_det Strat qs init n y + ALG'_det Strat qs init n x)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. ALGxy_det Strat (take (Suc n) qs) init x y = ALGxy_det Strat (take n qs) init x y + (ALG'_det Strat qs init n y + ALG'_det Strat qs init n x)
[PROOF STEP]
have "ALGxy_det Strat (take (Suc n) qs) init x y =
              (\<Sum>i\<in>{..<length (take n qs @ [qs ! n])}.
              if (take n qs @ [qs ! n]) ! i \<in> {y, x}
              then ALG'_det Strat (take n qs @ [qs ! n]) init i y
                + ALG'_det Strat (take n qs @ [qs ! n]) init i x
              else 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ALGxy_det Strat (take (Suc n) qs) init x y = (\<Sum>i<length (take n qs @ [qs ! n]). if (take n qs @ [qs ! n]) ! i \<in> {y, x} then ALG'_det Strat (take n qs @ [qs ! n]) init i y + ALG'_det Strat (take n qs @ [qs ! n]) init i x else 0)
[PROOF STEP]
unfolding ALGxy_det_def tak
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i<length (take n qs @ [qs ! n]). if (take n qs @ [qs ! n]) ! i \<in> {y, x} then ALG'_det Strat (take n qs @ [qs ! n]) init i y + ALG'_det Strat (take n qs @ [qs ! n]) init i x else 0) = (\<Sum>i<length (take n qs @ [qs ! n]). if (take n qs @ [qs ! n]) ! i \<in> {y, x} then ALG'_det Strat (take n qs @ [qs ! n]) init i y + ALG'_det Strat (take n qs @ [qs ! n]) init i x else 0)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
ALGxy_det Strat (take (Suc n) qs) init x y = (\<Sum>i<length (take n qs @ [qs ! n]). if (take n qs @ [qs ! n]) ! i \<in> {y, x} then ALG'_det Strat (take n qs @ [qs ! n]) init i y + ALG'_det Strat (take n qs @ [qs ! n]) init i x else 0)

goal (1 subgoal):
 1. ALGxy_det Strat (take (Suc n) qs) init x y = ALGxy_det Strat (take n qs) init x y + (ALG'_det Strat qs init n y + ALG'_det Strat qs init n x)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
ALGxy_det Strat (take (Suc n) qs) init x y = (\<Sum>i<length (take n qs @ [qs ! n]). if (take n qs @ [qs ! n]) ! i \<in> {y, x} then ALG'_det Strat (take n qs @ [qs ! n]) init i y + ALG'_det Strat (take n qs @ [qs ! n]) init i x else 0)

goal (1 subgoal):
 1. ALGxy_det Strat (take (Suc n) qs) init x y = ALGxy_det Strat (take n qs) init x y + (ALG'_det Strat qs init n y + ALG'_det Strat qs init n x)
[PROOF STEP]
have "\<dots>
              =  (\<Sum>i\<in>{..<Suc n}.
              if (take n qs @ [qs ! n]) ! i \<in> {y, x}
              then ALG'_det Strat (take n qs @ [qs ! n]) init i y
                + ALG'_det Strat (take n qs @ [qs ! n]) init i x
              else 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i<length (take n qs @ [qs ! n]). if (take n qs @ [qs ! n]) ! i \<in> {y, x} then ALG'_det Strat (take n qs @ [qs ! n]) init i y + ALG'_det Strat (take n qs @ [qs ! n]) init i x else 0) = (\<Sum>i<Suc n. if (take n qs @ [qs ! n]) ! i \<in> {y, x} then ALG'_det Strat (take n qs @ [qs ! n]) init i y + ALG'_det Strat (take n qs @ [qs ! n]) init i x else 0)
[PROOF STEP]
using ns
[PROOF STATE]
proof (prove)
using this:
n < length qs

goal (1 subgoal):
 1. (\<Sum>i<length (take n qs @ [qs ! n]). if (take n qs @ [qs ! n]) ! i \<in> {y, x} then ALG'_det Strat (take n qs @ [qs ! n]) init i y + ALG'_det Strat (take n qs @ [qs ! n]) init i x else 0) = (\<Sum>i<Suc n. if (take n qs @ [qs ! n]) ! i \<in> {y, x} then ALG'_det Strat (take n qs @ [qs ! n]) init i y + ALG'_det Strat (take n qs @ [qs ! n]) init i x else 0)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<Sum>i<length (take n qs @ [qs ! n]). if (take n qs @ [qs ! n]) ! i \<in> {y, x} then ALG'_det Strat (take n qs @ [qs ! n]) init i y + ALG'_det Strat (take n qs @ [qs ! n]) init i x else 0) = (\<Sum>i<Suc n. if (take n qs @ [qs ! n]) ! i \<in> {y, x} then ALG'_det Strat (take n qs @ [qs ! n]) init i y + ALG'_det Strat (take n qs @ [qs ! n]) init i x else 0)

goal (1 subgoal):
 1. ALGxy_det Strat (take (Suc n) qs) init x y = ALGxy_det Strat (take n qs) init x y + (ALG'_det Strat qs init n y + ALG'_det Strat qs init n x)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>i<length (take n qs @ [qs ! n]). if (take n qs @ [qs ! n]) ! i \<in> {y, x} then ALG'_det Strat (take n qs @ [qs ! n]) init i y + ALG'_det Strat (take n qs @ [qs ! n]) init i x else 0) = (\<Sum>i<Suc n. if (take n qs @ [qs ! n]) ! i \<in> {y, x} then ALG'_det Strat (take n qs @ [qs ! n]) init i y + ALG'_det Strat (take n qs @ [qs ! n]) init i x else 0)

goal (1 subgoal):
 1. ALGxy_det Strat (take (Suc n) qs) init x y = ALGxy_det Strat (take n qs) init x y + (ALG'_det Strat qs init n y + ALG'_det Strat qs init n x)
[PROOF STEP]
have "\<dots> = (\<Sum>i\<in>{..<n}.
               if (take n qs @ [qs ! n]) ! i \<in> {y, x}
               then ALG'_det Strat (take n qs @ [qs ! n]) init i y
                + ALG'_det Strat (take n qs @ [qs ! n]) init i x
               else 0)
               + (if (take n qs @ [qs ! n]) ! n \<in> {y, x}
                  then ALG'_det Strat (take n qs @ [qs ! n]) init n y
                    + ALG'_det Strat (take n qs @ [qs ! n]) init n x
                  else 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i<Suc n. if (take n qs @ [qs ! n]) ! i \<in> {y, x} then ALG'_det Strat (take n qs @ [qs ! n]) init i y + ALG'_det Strat (take n qs @ [qs ! n]) init i x else 0) = (\<Sum>i<n. if (take n qs @ [qs ! n]) ! i \<in> {y, x} then ALG'_det Strat (take n qs @ [qs ! n]) init i y + ALG'_det Strat (take n qs @ [qs ! n]) init i x else 0) + (if (take n qs @ [qs ! n]) ! n \<in> {y, x} then ALG'_det Strat (take n qs @ [qs ! n]) init n y + ALG'_det Strat (take n qs @ [qs ! n]) init n x else 0)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<Sum>i<Suc n. if (take n qs @ [qs ! n]) ! i \<in> {y, x} then ALG'_det Strat (take n qs @ [qs ! n]) init i y + ALG'_det Strat (take n qs @ [qs ! n]) init i x else 0) = (\<Sum>i<n. if (take n qs @ [qs ! n]) ! i \<in> {y, x} then ALG'_det Strat (take n qs @ [qs ! n]) init i y + ALG'_det Strat (take n qs @ [qs ! n]) init i x else 0) + (if (take n qs @ [qs ! n]) ! n \<in> {y, x} then ALG'_det Strat (take n qs @ [qs ! n]) init n y + ALG'_det Strat (take n qs @ [qs ! n]) init n x else 0)

goal (1 subgoal):
 1. ALGxy_det Strat (take (Suc n) qs) init x y = ALGxy_det Strat (take n qs) init x y + (ALG'_det Strat qs init n y + ALG'_det Strat qs init n x)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>i<Suc n. if (take n qs @ [qs ! n]) ! i \<in> {y, x} then ALG'_det Strat (take n qs @ [qs ! n]) init i y + ALG'_det Strat (take n qs @ [qs ! n]) init i x else 0) = (\<Sum>i<n. if (take n qs @ [qs ! n]) ! i \<in> {y, x} then ALG'_det Strat (take n qs @ [qs ! n]) init i y + ALG'_det Strat (take n qs @ [qs ! n]) init i x else 0) + (if (take n qs @ [qs ! n]) ! n \<in> {y, x} then ALG'_det Strat (take n qs @ [qs ! n]) init n y + ALG'_det Strat (take n qs @ [qs ! n]) init n x else 0)

goal (1 subgoal):
 1. ALGxy_det Strat (take (Suc n) qs) init x y = ALGxy_det Strat (take n qs) init x y + (ALG'_det Strat qs init n y + ALG'_det Strat qs init n x)
[PROOF STEP]
have "\<dots> = (\<Sum>i\<in>{..< n}.
              if take n qs ! i \<in> {y, x}
              then ALG'_det Strat (take n qs @ [qs ! n]) init i y
                + ALG'_det Strat (take n qs @ [qs ! n]) init i x
              else 0)
                + ALG'_det Strat (take n qs @ [qs ! n]) init n y
                + ALG'_det Strat (take n qs @ [qs ! n]) init n x "
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i<n. if (take n qs @ [qs ! n]) ! i \<in> {y, x} then ALG'_det Strat (take n qs @ [qs ! n]) init i y + ALG'_det Strat (take n qs @ [qs ! n]) init i x else 0) + (if (take n qs @ [qs ! n]) ! n \<in> {y, x} then ALG'_det Strat (take n qs @ [qs ! n]) init n y + ALG'_det Strat (take n qs @ [qs ! n]) init n x else 0) = (\<Sum>i<n. if take n qs ! i \<in> {y, x} then ALG'_det Strat (take n qs @ [qs ! n]) init i y + ALG'_det Strat (take n qs @ [qs ! n]) init i x else 0) + ALG'_det Strat (take n qs @ [qs ! n]) init n y + ALG'_det Strat (take n qs @ [qs ! n]) init n x
[PROOF STEP]
using aer
[PROOF STATE]
proof (prove)
using this:
\<forall>i<n. ((take n qs @ [qs ! n]) ! i \<in> {y, x}) = (take n qs ! i \<in> {y, x})

goal (1 subgoal):
 1. (\<Sum>i<n. if (take n qs @ [qs ! n]) ! i \<in> {y, x} then ALG'_det Strat (take n qs @ [qs ! n]) init i y + ALG'_det Strat (take n qs @ [qs ! n]) init i x else 0) + (if (take n qs @ [qs ! n]) ! n \<in> {y, x} then ALG'_det Strat (take n qs @ [qs ! n]) init n y + ALG'_det Strat (take n qs @ [qs ! n]) init n x else 0) = (\<Sum>i<n. if take n qs ! i \<in> {y, x} then ALG'_det Strat (take n qs @ [qs ! n]) init i y + ALG'_det Strat (take n qs @ [qs ! n]) init i x else 0) + ALG'_det Strat (take n qs @ [qs ! n]) init n y + ALG'_det Strat (take n qs @ [qs ! n]) init n x
[PROOF STEP]
using garar
[PROOF STATE]
proof (prove)
using this:
\<forall>i<n. ((take n qs @ [qs ! n]) ! i \<in> {y, x}) = (take n qs ! i \<in> {y, x})
(take n qs @ [qs ! n]) ! n \<in> {y, x}

goal (1 subgoal):
 1. (\<Sum>i<n. if (take n qs @ [qs ! n]) ! i \<in> {y, x} then ALG'_det Strat (take n qs @ [qs ! n]) init i y + ALG'_det Strat (take n qs @ [qs ! n]) init i x else 0) + (if (take n qs @ [qs ! n]) ! n \<in> {y, x} then ALG'_det Strat (take n qs @ [qs ! n]) init n y + ALG'_det Strat (take n qs @ [qs ! n]) init n x else 0) = (\<Sum>i<n. if take n qs ! i \<in> {y, x} then ALG'_det Strat (take n qs @ [qs ! n]) init i y + ALG'_det Strat (take n qs @ [qs ! n]) init i x else 0) + ALG'_det Strat (take n qs @ [qs ! n]) init n y + ALG'_det Strat (take n qs @ [qs ! n]) init n x
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<Sum>i<n. if (take n qs @ [qs ! n]) ! i \<in> {y, x} then ALG'_det Strat (take n qs @ [qs ! n]) init i y + ALG'_det Strat (take n qs @ [qs ! n]) init i x else 0) + (if (take n qs @ [qs ! n]) ! n \<in> {y, x} then ALG'_det Strat (take n qs @ [qs ! n]) init n y + ALG'_det Strat (take n qs @ [qs ! n]) init n x else 0) = (\<Sum>i<n. if take n qs ! i \<in> {y, x} then ALG'_det Strat (take n qs @ [qs ! n]) init i y + ALG'_det Strat (take n qs @ [qs ! n]) init i x else 0) + ALG'_det Strat (take n qs @ [qs ! n]) init n y + ALG'_det Strat (take n qs @ [qs ! n]) init n x

goal (1 subgoal):
 1. ALGxy_det Strat (take (Suc n) qs) init x y = ALGxy_det Strat (take n qs) init x y + (ALG'_det Strat qs init n y + ALG'_det Strat qs init n x)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>i<n. if (take n qs @ [qs ! n]) ! i \<in> {y, x} then ALG'_det Strat (take n qs @ [qs ! n]) init i y + ALG'_det Strat (take n qs @ [qs ! n]) init i x else 0) + (if (take n qs @ [qs ! n]) ! n \<in> {y, x} then ALG'_det Strat (take n qs @ [qs ! n]) init n y + ALG'_det Strat (take n qs @ [qs ! n]) init n x else 0) = (\<Sum>i<n. if take n qs ! i \<in> {y, x} then ALG'_det Strat (take n qs @ [qs ! n]) init i y + ALG'_det Strat (take n qs @ [qs ! n]) init i x else 0) + ALG'_det Strat (take n qs @ [qs ! n]) init n y + ALG'_det Strat (take n qs @ [qs ! n]) init n x

goal (1 subgoal):
 1. ALGxy_det Strat (take (Suc n) qs) init x y = ALGxy_det Strat (take n qs) init x y + (ALG'_det Strat qs init n y + ALG'_det Strat qs init n x)
[PROOF STEP]
have "\<dots> = (\<Sum>i\<in>{..< n}.
              if take n qs ! i \<in> {y, x}
              then ALG'_det Strat (take n qs @ [qs ! n]) init i y
                + ALG'_det Strat (take n qs @ [qs ! n]) init i x
              else 0)
                + ALG'_det Strat qs init n y + ALG'_det Strat qs init n x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i<n. if take n qs ! i \<in> {y, x} then ALG'_det Strat (take n qs @ [qs ! n]) init i y + ALG'_det Strat (take n qs @ [qs ! n]) init i x else 0) + ALG'_det Strat (take n qs @ [qs ! n]) init n y + ALG'_det Strat (take n qs @ [qs ! n]) init n x = (\<Sum>i<n. if take n qs ! i \<in> {y, x} then ALG'_det Strat (take n qs @ [qs ! n]) init i y + ALG'_det Strat (take n qs @ [qs ! n]) init i x else 0) + ALG'_det Strat qs init n y + ALG'_det Strat qs init n x
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<Sum>i<n. if take n qs ! i \<in> {y, x} then ALG'_det Strat (take n qs @ [qs ! n]) init i y + ALG'_det Strat (take n qs @ [qs ! n]) init i x else 0) + ALG'_det Strat (take n qs @ [qs ! n]) init n y + ALG'_det Strat (take n qs @ [qs ! n]) init n x = (\<Sum>i<n. if take n qs ! i \<in> {y, x} then ALG'_det Strat (take n qs @ [qs ! n]) init i y + ALG'_det Strat (take n qs @ [qs ! n]) init i x else 0) + ALG'_det Strat qs init n y + ALG'_det Strat qs init n x
[PROOF STEP]
have "ALG'_det Strat qs init n y
                = ALG'_det Strat ((take n qs @ [qs ! n]) @ drop (Suc n) qs) init n y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ALG'_det Strat qs init n y = ALG'_det Strat ((take n qs @ [qs ! n]) @ drop (Suc n) qs) init n y
[PROOF STEP]
unfolding tak[symmetric]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ALG'_det Strat qs init n y = ALG'_det Strat (take (Suc n) qs @ drop (Suc n) qs) init n y
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
ALG'_det Strat qs init n y = ALG'_det Strat ((take n qs @ [qs ! n]) @ drop (Suc n) qs) init n y

goal (1 subgoal):
 1. (\<Sum>i<n. if take n qs ! i \<in> {y, x} then ALG'_det Strat (take n qs @ [qs ! n]) init i y + ALG'_det Strat (take n qs @ [qs ! n]) init i x else 0) + ALG'_det Strat (take n qs @ [qs ! n]) init n y + ALG'_det Strat (take n qs @ [qs ! n]) init n x = (\<Sum>i<n. if take n qs ! i \<in> {y, x} then ALG'_det Strat (take n qs @ [qs ! n]) init i y + ALG'_det Strat (take n qs @ [qs ! n]) init i x else 0) + ALG'_det Strat qs init n y + ALG'_det Strat qs init n x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
ALG'_det Strat qs init n y = ALG'_det Strat ((take n qs @ [qs ! n]) @ drop (Suc n) qs) init n y

goal (1 subgoal):
 1. (\<Sum>i<n. if take n qs ! i \<in> {y, x} then ALG'_det Strat (take n qs @ [qs ! n]) init i y + ALG'_det Strat (take n qs @ [qs ! n]) init i x else 0) + ALG'_det Strat (take n qs @ [qs ! n]) init n y + ALG'_det Strat (take n qs @ [qs ! n]) init n x = (\<Sum>i<n. if take n qs ! i \<in> {y, x} then ALG'_det Strat (take n qs @ [qs ! n]) init i y + ALG'_det Strat (take n qs @ [qs ! n]) init i x else 0) + ALG'_det Strat qs init n y + ALG'_det Strat qs init n x
[PROOF STEP]
have "\<dots> = ALG'_det Strat (take n qs @ [qs ! n]) init n y "
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ALG'_det Strat ((take n qs @ [qs ! n]) @ drop (Suc n) qs) init n y = ALG'_det Strat (take n qs @ [qs ! n]) init n y
[PROOF STEP]
apply(rule ALG'_det_append)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. n < length Strat
 2. n < length (take n qs @ [qs ! n])
[PROOF STEP]
using nStrat ns
[PROOF STATE]
proof (prove)
using this:
n < length Strat
n < length qs

goal (2 subgoals):
 1. n < length Strat
 2. n < length (take n qs @ [qs ! n])
[PROOF STEP]
by(auto)
[PROOF STATE]
proof (state)
this:
ALG'_det Strat ((take n qs @ [qs ! n]) @ drop (Suc n) qs) init n y = ALG'_det Strat (take n qs @ [qs ! n]) init n y

goal (1 subgoal):
 1. (\<Sum>i<n. if take n qs ! i \<in> {y, x} then ALG'_det Strat (take n qs @ [qs ! n]) init i y + ALG'_det Strat (take n qs @ [qs ! n]) init i x else 0) + ALG'_det Strat (take n qs @ [qs ! n]) init n y + ALG'_det Strat (take n qs @ [qs ! n]) init n x = (\<Sum>i<n. if take n qs ! i \<in> {y, x} then ALG'_det Strat (take n qs @ [qs ! n]) init i y + ALG'_det Strat (take n qs @ [qs ! n]) init i x else 0) + ALG'_det Strat qs init n y + ALG'_det Strat qs init n x
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
ALG'_det Strat qs init n y = ALG'_det Strat (take n qs @ [qs ! n]) init n y
[PROOF STEP]
have 1: "ALG'_det Strat qs init n y = ALG'_det Strat (take n qs @ [qs ! n]) init n y"
[PROOF STATE]
proof (prove)
using this:
ALG'_det Strat qs init n y = ALG'_det Strat (take n qs @ [qs ! n]) init n y

goal (1 subgoal):
 1. ALG'_det Strat qs init n y = ALG'_det Strat (take n qs @ [qs ! n]) init n y
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
ALG'_det Strat qs init n y = ALG'_det Strat (take n qs @ [qs ! n]) init n y

goal (1 subgoal):
 1. (\<Sum>i<n. if take n qs ! i \<in> {y, x} then ALG'_det Strat (take n qs @ [qs ! n]) init i y + ALG'_det Strat (take n qs @ [qs ! n]) init i x else 0) + ALG'_det Strat (take n qs @ [qs ! n]) init n y + ALG'_det Strat (take n qs @ [qs ! n]) init n x = (\<Sum>i<n. if take n qs ! i \<in> {y, x} then ALG'_det Strat (take n qs @ [qs ! n]) init i y + ALG'_det Strat (take n qs @ [qs ! n]) init i x else 0) + ALG'_det Strat qs init n y + ALG'_det Strat qs init n x
[PROOF STEP]
have "ALG'_det Strat qs init n x
                  = ALG'_det Strat ((take n qs @ [qs ! n]) @ drop (Suc n) qs) init n x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ALG'_det Strat qs init n x = ALG'_det Strat ((take n qs @ [qs ! n]) @ drop (Suc n) qs) init n x
[PROOF STEP]
unfolding tak[symmetric]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ALG'_det Strat qs init n x = ALG'_det Strat (take (Suc n) qs @ drop (Suc n) qs) init n x
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
ALG'_det Strat qs init n x = ALG'_det Strat ((take n qs @ [qs ! n]) @ drop (Suc n) qs) init n x

goal (1 subgoal):
 1. (\<Sum>i<n. if take n qs ! i \<in> {y, x} then ALG'_det Strat (take n qs @ [qs ! n]) init i y + ALG'_det Strat (take n qs @ [qs ! n]) init i x else 0) + ALG'_det Strat (take n qs @ [qs ! n]) init n y + ALG'_det Strat (take n qs @ [qs ! n]) init n x = (\<Sum>i<n. if take n qs ! i \<in> {y, x} then ALG'_det Strat (take n qs @ [qs ! n]) init i y + ALG'_det Strat (take n qs @ [qs ! n]) init i x else 0) + ALG'_det Strat qs init n y + ALG'_det Strat qs init n x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
ALG'_det Strat qs init n x = ALG'_det Strat ((take n qs @ [qs ! n]) @ drop (Suc n) qs) init n x

goal (1 subgoal):
 1. (\<Sum>i<n. if take n qs ! i \<in> {y, x} then ALG'_det Strat (take n qs @ [qs ! n]) init i y + ALG'_det Strat (take n qs @ [qs ! n]) init i x else 0) + ALG'_det Strat (take n qs @ [qs ! n]) init n y + ALG'_det Strat (take n qs @ [qs ! n]) init n x = (\<Sum>i<n. if take n qs ! i \<in> {y, x} then ALG'_det Strat (take n qs @ [qs ! n]) init i y + ALG'_det Strat (take n qs @ [qs ! n]) init i x else 0) + ALG'_det Strat qs init n y + ALG'_det Strat qs init n x
[PROOF STEP]
have "\<dots> = ALG'_det Strat (take n qs @ [qs ! n]) init n x "
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ALG'_det Strat ((take n qs @ [qs ! n]) @ drop (Suc n) qs) init n x = ALG'_det Strat (take n qs @ [qs ! n]) init n x
[PROOF STEP]
apply(rule ALG'_det_append)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. n < length Strat
 2. n < length (take n qs @ [qs ! n])
[PROOF STEP]
using nStrat ns
[PROOF STATE]
proof (prove)
using this:
n < length Strat
n < length qs

goal (2 subgoals):
 1. n < length Strat
 2. n < length (take n qs @ [qs ! n])
[PROOF STEP]
by(auto)
[PROOF STATE]
proof (state)
this:
ALG'_det Strat ((take n qs @ [qs ! n]) @ drop (Suc n) qs) init n x = ALG'_det Strat (take n qs @ [qs ! n]) init n x

goal (1 subgoal):
 1. (\<Sum>i<n. if take n qs ! i \<in> {y, x} then ALG'_det Strat (take n qs @ [qs ! n]) init i y + ALG'_det Strat (take n qs @ [qs ! n]) init i x else 0) + ALG'_det Strat (take n qs @ [qs ! n]) init n y + ALG'_det Strat (take n qs @ [qs ! n]) init n x = (\<Sum>i<n. if take n qs ! i \<in> {y, x} then ALG'_det Strat (take n qs @ [qs ! n]) init i y + ALG'_det Strat (take n qs @ [qs ! n]) init i x else 0) + ALG'_det Strat qs init n y + ALG'_det Strat qs init n x
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
ALG'_det Strat qs init n x = ALG'_det Strat (take n qs @ [qs ! n]) init n x
[PROOF STEP]
have 2: "ALG'_det Strat qs init n x = ALG'_det Strat (take n qs @ [qs ! n]) init n x"
[PROOF STATE]
proof (prove)
using this:
ALG'_det Strat qs init n x = ALG'_det Strat (take n qs @ [qs ! n]) init n x

goal (1 subgoal):
 1. ALG'_det Strat qs init n x = ALG'_det Strat (take n qs @ [qs ! n]) init n x
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
ALG'_det Strat qs init n x = ALG'_det Strat (take n qs @ [qs ! n]) init n x

goal (1 subgoal):
 1. (\<Sum>i<n. if take n qs ! i \<in> {y, x} then ALG'_det Strat (take n qs @ [qs ! n]) init i y + ALG'_det Strat (take n qs @ [qs ! n]) init i x else 0) + ALG'_det Strat (take n qs @ [qs ! n]) init n y + ALG'_det Strat (take n qs @ [qs ! n]) init n x = (\<Sum>i<n. if take n qs ! i \<in> {y, x} then ALG'_det Strat (take n qs @ [qs ! n]) init i y + ALG'_det Strat (take n qs @ [qs ! n]) init i x else 0) + ALG'_det Strat qs init n y + ALG'_det Strat qs init n x
[PROOF STEP]
from 1 2
[PROOF STATE]
proof (chain)
picking this:
ALG'_det Strat qs init n y = ALG'_det Strat (take n qs @ [qs ! n]) init n y
ALG'_det Strat qs init n x = ALG'_det Strat (take n qs @ [qs ! n]) init n x
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
ALG'_det Strat qs init n y = ALG'_det Strat (take n qs @ [qs ! n]) init n y
ALG'_det Strat qs init n x = ALG'_det Strat (take n qs @ [qs ! n]) init n x

goal (1 subgoal):
 1. (\<Sum>i<n. if take n qs ! i \<in> {y, x} then ALG'_det Strat (take n qs @ [qs ! n]) init i y + ALG'_det Strat (take n qs @ [qs ! n]) init i x else 0) + ALG'_det Strat (take n qs @ [qs ! n]) init n y + ALG'_det Strat (take n qs @ [qs ! n]) init n x = (\<Sum>i<n. if take n qs ! i \<in> {y, x} then ALG'_det Strat (take n qs @ [qs ! n]) init i y + ALG'_det Strat (take n qs @ [qs ! n]) init i x else 0) + ALG'_det Strat qs init n y + ALG'_det Strat qs init n x
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<Sum>i<n. if take n qs ! i \<in> {y, x} then ALG'_det Strat (take n qs @ [qs ! n]) init i y + ALG'_det Strat (take n qs @ [qs ! n]) init i x else 0) + ALG'_det Strat (take n qs @ [qs ! n]) init n y + ALG'_det Strat (take n qs @ [qs ! n]) init n x = (\<Sum>i<n. if take n qs ! i \<in> {y, x} then ALG'_det Strat (take n qs @ [qs ! n]) init i y + ALG'_det Strat (take n qs @ [qs ! n]) init i x else 0) + ALG'_det Strat qs init n y + ALG'_det Strat qs init n x

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<Sum>i<n. if take n qs ! i \<in> {y, x} then ALG'_det Strat (take n qs @ [qs ! n]) init i y + ALG'_det Strat (take n qs @ [qs ! n]) init i x else 0) + ALG'_det Strat (take n qs @ [qs ! n]) init n y + ALG'_det Strat (take n qs @ [qs ! n]) init n x = (\<Sum>i<n. if take n qs ! i \<in> {y, x} then ALG'_det Strat (take n qs @ [qs ! n]) init i y + ALG'_det Strat (take n qs @ [qs ! n]) init i x else 0) + ALG'_det Strat qs init n y + ALG'_det Strat qs init n x

goal (1 subgoal):
 1. ALGxy_det Strat (take (Suc n) qs) init x y = ALGxy_det Strat (take n qs) init x y + (ALG'_det Strat qs init n y + ALG'_det Strat qs init n x)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>i<n. if take n qs ! i \<in> {y, x} then ALG'_det Strat (take n qs @ [qs ! n]) init i y + ALG'_det Strat (take n qs @ [qs ! n]) init i x else 0) + ALG'_det Strat (take n qs @ [qs ! n]) init n y + ALG'_det Strat (take n qs @ [qs ! n]) init n x = (\<Sum>i<n. if take n qs ! i \<in> {y, x} then ALG'_det Strat (take n qs @ [qs ! n]) init i y + ALG'_det Strat (take n qs @ [qs ! n]) init i x else 0) + ALG'_det Strat qs init n y + ALG'_det Strat qs init n x

goal (1 subgoal):
 1. ALGxy_det Strat (take (Suc n) qs) init x y = ALGxy_det Strat (take n qs) init x y + (ALG'_det Strat qs init n y + ALG'_det Strat qs init n x)
[PROOF STEP]
have "\<dots> = (\<Sum>i\<in>{..< n}.
              if take n qs ! i \<in> {y, x}
              then ALG'_det Strat (take n qs) init i y
                  + ALG'_det Strat (take n qs) init i x
              else 0)
              + ALG'_det Strat qs init n y + ALG'_det Strat qs init n x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i<n. if take n qs ! i \<in> {y, x} then ALG'_det Strat (take n qs @ [qs ! n]) init i y + ALG'_det Strat (take n qs @ [qs ! n]) init i x else 0) + ALG'_det Strat qs init n y + ALG'_det Strat qs init n x = (\<Sum>i<n. if take n qs ! i \<in> {y, x} then ALG'_det Strat (take n qs) init i y + ALG'_det Strat (take n qs) init i x else 0) + ALG'_det Strat qs init n y + ALG'_det Strat qs init n x
[PROOF STEP]
apply(simp)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i<n. if qs ! i = y \<or> qs ! i = x then ALG'_det Strat (take n qs @ [qs ! n]) init i y + ALG'_det Strat (take n qs @ [qs ! n]) init i x else 0) = (\<Sum>i<n. if qs ! i = y \<or> qs ! i = x then ALG'_det Strat (take n qs) init i y + ALG'_det Strat (take n qs) init i x else 0)
[PROOF STEP]
apply(rule sum.cong)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. {..<n} = {..<n}
 2. \<And>xa. xa \<in> {..<n} \<Longrightarrow> (if qs ! xa = y \<or> qs ! xa = x then ALG'_det Strat (take n qs @ [qs ! n]) init xa y + ALG'_det Strat (take n qs @ [qs ! n]) init xa x else 0) = (if qs ! xa = y \<or> qs ! xa = x then ALG'_det Strat (take n qs) init xa y + ALG'_det Strat (take n qs) init xa x else 0)
[PROOF STEP]
apply(simp)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>xa. xa \<in> {..<n} \<Longrightarrow> (if qs ! xa = y \<or> qs ! xa = x then ALG'_det Strat (take n qs @ [qs ! n]) init xa y + ALG'_det Strat (take n qs @ [qs ! n]) init xa x else 0) = (if qs ! xa = y \<or> qs ! xa = x then ALG'_det Strat (take n qs) init xa y + ALG'_det Strat (take n qs) init xa x else 0)
[PROOF STEP]
apply(simp)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>xa. xa < n \<Longrightarrow> (qs ! xa = y \<longrightarrow> ALG'_det Strat (take n qs @ [qs ! n]) init xa y + ALG'_det Strat (take n qs @ [qs ! n]) init xa x = ALG'_det Strat (take n qs) init xa y + ALG'_det Strat (take n qs) init xa x) \<and> (qs ! xa = x \<longrightarrow> ALG'_det Strat (take n qs @ [qs ! n]) init xa y + ALG'_det Strat (take n qs @ [qs ! n]) init xa x = ALG'_det Strat (take n qs) init xa y + ALG'_det Strat (take n qs) init xa x)
[PROOF STEP]
using ALG'_det_append[where qs="take n qs"] Suc.prems(2) ns
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?n < length ?Strat; ?n < length (take n qs)\<rbrakk> \<Longrightarrow> ALG'_det ?Strat (take n qs @ ?a) ?init ?n ?x = ALG'_det ?Strat (take n qs) ?init ?n ?x
length Strat = length qs
n < length qs

goal (1 subgoal):
 1. \<And>xa. xa < n \<Longrightarrow> (qs ! xa = y \<longrightarrow> ALG'_det Strat (take n qs @ [qs ! n]) init xa y + ALG'_det Strat (take n qs @ [qs ! n]) init xa x = ALG'_det Strat (take n qs) init xa y + ALG'_det Strat (take n qs) init xa x) \<and> (qs ! xa = x \<longrightarrow> ALG'_det Strat (take n qs @ [qs ! n]) init xa y + ALG'_det Strat (take n qs @ [qs ! n]) init xa x = ALG'_det Strat (take n qs) init xa y + ALG'_det Strat (take n qs) init xa x)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<Sum>i<n. if take n qs ! i \<in> {y, x} then ALG'_det Strat (take n qs @ [qs ! n]) init i y + ALG'_det Strat (take n qs @ [qs ! n]) init i x else 0) + ALG'_det Strat qs init n y + ALG'_det Strat qs init n x = (\<Sum>i<n. if take n qs ! i \<in> {y, x} then ALG'_det Strat (take n qs) init i y + ALG'_det Strat (take n qs) init i x else 0) + ALG'_det Strat qs init n y + ALG'_det Strat qs init n x

goal (1 subgoal):
 1. ALGxy_det Strat (take (Suc n) qs) init x y = ALGxy_det Strat (take n qs) init x y + (ALG'_det Strat qs init n y + ALG'_det Strat qs init n x)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>i<n. if take n qs ! i \<in> {y, x} then ALG'_det Strat (take n qs @ [qs ! n]) init i y + ALG'_det Strat (take n qs @ [qs ! n]) init i x else 0) + ALG'_det Strat qs init n y + ALG'_det Strat qs init n x = (\<Sum>i<n. if take n qs ! i \<in> {y, x} then ALG'_det Strat (take n qs) init i y + ALG'_det Strat (take n qs) init i x else 0) + ALG'_det Strat qs init n y + ALG'_det Strat qs init n x

goal (1 subgoal):
 1. ALGxy_det Strat (take (Suc n) qs) init x y = ALGxy_det Strat (take n qs) init x y + (ALG'_det Strat qs init n y + ALG'_det Strat qs init n x)
[PROOF STEP]
have "\<dots> = (\<Sum>i\<in>{..< length(take n qs)}.
              if take n qs ! i \<in> {y, x}
              then ALG'_det Strat (take n qs) init i y
                   + ALG'_det Strat (take n qs) init i x
              else 0)
              + ALG'_det Strat qs init n y + ALG'_det Strat qs init n x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i<n. if take n qs ! i \<in> {y, x} then ALG'_det Strat (take n qs) init i y + ALG'_det Strat (take n qs) init i x else 0) + ALG'_det Strat qs init n y + ALG'_det Strat qs init n x = (\<Sum>i<length (take n qs). if take n qs ! i \<in> {y, x} then ALG'_det Strat (take n qs) init i y + ALG'_det Strat (take n qs) init i x else 0) + ALG'_det Strat qs init n y + ALG'_det Strat qs init n x
[PROOF STEP]
using aQ
[PROOF STATE]
proof (prove)
using this:
length (take n qs) = n

goal (1 subgoal):
 1. (\<Sum>i<n. if take n qs ! i \<in> {y, x} then ALG'_det Strat (take n qs) init i y + ALG'_det Strat (take n qs) init i x else 0) + ALG'_det Strat qs init n y + ALG'_det Strat qs init n x = (\<Sum>i<length (take n qs). if take n qs ! i \<in> {y, x} then ALG'_det Strat (take n qs) init i y + ALG'_det Strat (take n qs) init i x else 0) + ALG'_det Strat qs init n y + ALG'_det Strat qs init n x
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<Sum>i<n. if take n qs ! i \<in> {y, x} then ALG'_det Strat (take n qs) init i y + ALG'_det Strat (take n qs) init i x else 0) + ALG'_det Strat qs init n y + ALG'_det Strat qs init n x = (\<Sum>i<length (take n qs). if take n qs ! i \<in> {y, x} then ALG'_det Strat (take n qs) init i y + ALG'_det Strat (take n qs) init i x else 0) + ALG'_det Strat qs init n y + ALG'_det Strat qs init n x

goal (1 subgoal):
 1. ALGxy_det Strat (take (Suc n) qs) init x y = ALGxy_det Strat (take n qs) init x y + (ALG'_det Strat qs init n y + ALG'_det Strat qs init n x)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>i<n. if take n qs ! i \<in> {y, x} then ALG'_det Strat (take n qs) init i y + ALG'_det Strat (take n qs) init i x else 0) + ALG'_det Strat qs init n y + ALG'_det Strat qs init n x = (\<Sum>i<length (take n qs). if take n qs ! i \<in> {y, x} then ALG'_det Strat (take n qs) init i y + ALG'_det Strat (take n qs) init i x else 0) + ALG'_det Strat qs init n y + ALG'_det Strat qs init n x

goal (1 subgoal):
 1. ALGxy_det Strat (take (Suc n) qs) init x y = ALGxy_det Strat (take n qs) init x y + (ALG'_det Strat qs init n y + ALG'_det Strat qs init n x)
[PROOF STEP]
have "\<dots> = ALGxy_det Strat (take n qs) init x y
                  + (ALG'_det Strat qs init n y + ALG'_det Strat qs init n x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i<length (take n qs). if take n qs ! i \<in> {y, x} then ALG'_det Strat (take n qs) init i y + ALG'_det Strat (take n qs) init i x else 0) + ALG'_det Strat qs init n y + ALG'_det Strat qs init n x = ALGxy_det Strat (take n qs) init x y + (ALG'_det Strat qs init n y + ALG'_det Strat qs init n x)
[PROOF STEP]
unfolding ALGxy_det_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i<length (take n qs). if take n qs ! i \<in> {y, x} then ALG'_det Strat (take n qs) init i y + ALG'_det Strat (take n qs) init i x else 0) + ALG'_det Strat qs init n y + ALG'_det Strat qs init n x = (\<Sum>i<length (take n qs). if take n qs ! i \<in> {y, x} then ALG'_det Strat (take n qs) init i y + ALG'_det Strat (take n qs) init i x else 0) + (ALG'_det Strat qs init n y + ALG'_det Strat qs init n x)
[PROOF STEP]
by(simp)
[PROOF STATE]
proof (state)
this:
(\<Sum>i<length (take n qs). if take n qs ! i \<in> {y, x} then ALG'_det Strat (take n qs) init i y + ALG'_det Strat (take n qs) init i x else 0) + ALG'_det Strat qs init n y + ALG'_det Strat qs init n x = ALGxy_det Strat (take n qs) init x y + (ALG'_det Strat qs init n y + ALG'_det Strat qs init n x)

goal (1 subgoal):
 1. ALGxy_det Strat (take (Suc n) qs) init x y = ALGxy_det Strat (take n qs) init x y + (ALG'_det Strat qs init n y + ALG'_det Strat qs init n x)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
ALGxy_det Strat (take (Suc n) qs) init x y = ALGxy_det Strat (take n qs) init x y + (ALG'_det Strat qs init n y + ALG'_det Strat qs init n x)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
ALGxy_det Strat (take (Suc n) qs) init x y = ALGxy_det Strat (take n qs) init x y + (ALG'_det Strat qs init n y + ALG'_det Strat qs init n x)

goal (1 subgoal):
 1. ALGxy_det Strat (take (Suc n) qs) init x y = ALGxy_det Strat (take n qs) init x y + (ALG'_det Strat qs init n y + ALG'_det Strat qs init n x)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
ALGxy_det Strat (take (Suc n) qs) init x y = ALGxy_det Strat (take n qs) init x y + (ALG'_det Strat qs init n y + ALG'_det Strat qs init n x)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
ALGxy_det Strat (take (Suc n) qs) init x y = ALGxy_det Strat (take n qs) init x y + (ALG'_det Strat qs init n y + ALG'_det Strat qs init n x)

goal (1 subgoal):
 1. T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) + length [] = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
(*
              aaa:      x < y in ?xs'  = x < y in ?ys''
              central:  x < y in ?xs'' = x < y  in ?ys'''
           *)
[PROOF STATE]
proof (state)
this:
ALGxy_det Strat (take (Suc n) qs) init x y = ALGxy_det Strat (take n qs) init x y + (ALG'_det Strat qs init n y + ALG'_det Strat qs init n x)

goal (1 subgoal):
 1. T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) + length [] = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
have list: "?ys' = swaps sws (steps (Lxy init {x, y})  (Lxy (take n qs) {x, y}) Strat2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)) = swaps sws (Partial_Cost_Model.steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2)
[PROOF STEP]
unfolding steps_steps'[OF len[symmetric], of "(Lxy init {x, y})"]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)) = swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)) = swaps sws (Partial_Cost_Model.steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2)

goal (1 subgoal):
 1. T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) + length [] = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
have j2: "steps' init (take n qs @ [qs ! n]) Strat n
                  = steps' init (take n qs) (take n Strat) n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. steps' init (take n qs @ [qs ! n]) Strat n = steps' init (take n qs) (take n Strat) n
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. steps' init (take n qs @ [qs ! n]) Strat n = steps' init (take n qs) (take n Strat) n
[PROOF STEP]
have "steps' init (take n qs @ [qs ! n]) Strat n
                = steps' init (take n qs @ [qs ! n]) (take n Strat @ drop n Strat) n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. steps' init (take n qs @ [qs ! n]) Strat n = steps' init (take n qs @ [qs ! n]) (take n Strat @ drop n Strat) n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
steps' init (take n qs @ [qs ! n]) Strat n = steps' init (take n qs @ [qs ! n]) (take n Strat @ drop n Strat) n

goal (1 subgoal):
 1. steps' init (take n qs @ [qs ! n]) Strat n = steps' init (take n qs) (take n Strat) n
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
steps' init (take n qs @ [qs ! n]) Strat n = steps' init (take n qs @ [qs ! n]) (take n Strat @ drop n Strat) n

goal (1 subgoal):
 1. steps' init (take n qs @ [qs ! n]) Strat n = steps' init (take n qs) (take n Strat) n
[PROOF STEP]
have "\<dots> = steps' init (take n qs) (take n Strat) n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. steps' init (take n qs @ [qs ! n]) (take n Strat @ drop n Strat) n = steps' init (take n qs) (take n Strat) n
[PROOF STEP]
apply(rule steps'_rests[symmetric])
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. length (take n qs) = length (take n Strat)
 2. n \<le> length (take n Strat)
[PROOF STEP]
apply fact
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n \<le> length (take n Strat)
[PROOF STEP]
using aS
[PROOF STATE]
proof (prove)
using this:
length (take n Strat) = n

goal (1 subgoal):
 1. n \<le> length (take n Strat)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
steps' init (take n qs @ [qs ! n]) (take n Strat @ drop n Strat) n = steps' init (take n qs) (take n Strat) n

goal (1 subgoal):
 1. steps' init (take n qs @ [qs ! n]) Strat n = steps' init (take n qs) (take n Strat) n
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
steps' init (take n qs @ [qs ! n]) Strat n = steps' init (take n qs) (take n Strat) n
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
steps' init (take n qs @ [qs ! n]) Strat n = steps' init (take n qs) (take n Strat) n

goal (1 subgoal):
 1. steps' init (take n qs @ [qs ! n]) Strat n = steps' init (take n qs) (take n Strat) n
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
steps' init (take n qs @ [qs ! n]) Strat n = steps' init (take n qs) (take n Strat) n

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
steps' init (take n qs @ [qs ! n]) Strat n = steps' init (take n qs) (take n Strat) n

goal (1 subgoal):
 1. T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) + length [] = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
have arghschonwieder: "steps' init (take n qs) (take n Strat) n
                  = steps' init qs Strat n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. steps' init (take n qs) (take n Strat) n = steps' init qs Strat n
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. steps' init (take n qs) (take n Strat) n = steps' init qs Strat n
[PROOF STEP]
have "steps' init qs Strat n
                = steps' init (take n qs @ drop n qs) (take n Strat @ drop n Strat) n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. steps' init qs Strat n = steps' init (take n qs @ drop n qs) (take n Strat @ drop n Strat) n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
steps' init qs Strat n = steps' init (take n qs @ drop n qs) (take n Strat @ drop n Strat) n

goal (1 subgoal):
 1. steps' init (take n qs) (take n Strat) n = steps' init qs Strat n
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
steps' init qs Strat n = steps' init (take n qs @ drop n qs) (take n Strat @ drop n Strat) n

goal (1 subgoal):
 1. steps' init (take n qs) (take n Strat) n = steps' init qs Strat n
[PROOF STEP]
have "\<dots> = steps' init (take n qs) (take n Strat) n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. steps' init (take n qs @ drop n qs) (take n Strat @ drop n Strat) n = steps' init (take n qs) (take n Strat) n
[PROOF STEP]
apply(rule steps'_rests[symmetric])
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. length (take n qs) = length (take n Strat)
 2. n \<le> length (take n Strat)
[PROOF STEP]
apply fact
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n \<le> length (take n Strat)
[PROOF STEP]
using aS
[PROOF STATE]
proof (prove)
using this:
length (take n Strat) = n

goal (1 subgoal):
 1. n \<le> length (take n Strat)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
steps' init (take n qs @ drop n qs) (take n Strat @ drop n Strat) n = steps' init (take n qs) (take n Strat) n

goal (1 subgoal):
 1. steps' init (take n qs) (take n Strat) n = steps' init qs Strat n
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
steps' init qs Strat n = steps' init (take n qs) (take n Strat) n
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
steps' init qs Strat n = steps' init (take n qs) (take n Strat) n

goal (1 subgoal):
 1. steps' init (take n qs) (take n Strat) n = steps' init qs Strat n
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
steps' init (take n qs) (take n Strat) n = steps' init qs Strat n

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
steps' init (take n qs) (take n Strat) n = steps' init qs Strat n

goal (1 subgoal):
 1. T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) + length [] = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
have indexe: "((swap 0 ^^ ?m) (swaps sws
                      (steps (Lxy init {x,y}) (Lxy (take n qs) {x, y}) Strat2)))
              = ?ys''"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (swap 0 ^^ ALG_P' Strat (take n qs @ [qs ! n]) init n x y) (swaps sws (Partial_Cost_Model.steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2)) = (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
[PROOF STEP]
unfolding ALG_P'_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs @ [qs ! n]) Strat n)) (swaps sws (Partial_Cost_Model.steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2)) = (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))
[PROOF STEP]
unfolding list
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs @ [qs ! n]) Strat n)) (swaps sws (Partial_Cost_Model.steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2)) = (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (Partial_Cost_Model.steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2))
[PROOF STEP]
using j2
[PROOF STATE]
proof (prove)
using this:
steps' init (take n qs @ [qs ! n]) Strat n = steps' init (take n qs) (take n Strat) n

goal (1 subgoal):
 1. (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs @ [qs ! n]) Strat n)) (swaps sws (Partial_Cost_Model.steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2)) = (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (Partial_Cost_Model.steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(swap 0 ^^ ALG_P' Strat (take n qs @ [qs ! n]) init n x y) (swaps sws (Partial_Cost_Model.steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2)) = (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))

goal (1 subgoal):
 1. T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) + length [] = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
have blocky: "ALG'_det Strat qs init n y
                = (if y < qs ! n in ?xs' then 1 else 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ALG'_det Strat qs init n y = (if y < qs ! n in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) then 1 else 0)
[PROOF STEP]
unfolding ALG'_det_def ALG.simps
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if y < qs ! n in fst (swaps (snd (Strat ! n)) (steps' init qs Strat n), ()) then 1 else 0) = (if y < qs ! n in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) then 1 else 0)
[PROOF STEP]
by(auto simp: arghschonwieder split_def)
[PROOF STATE]
proof (state)
this:
ALG'_det Strat qs init n y = (if y < qs ! n in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) then 1 else 0)

goal (1 subgoal):
 1. T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) + length [] = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
have blockx: "ALG'_det Strat qs init n x
                = (if x < qs ! n in ?xs' then 1 else 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ALG'_det Strat qs init n x = (if x < qs ! n in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) then 1 else 0)
[PROOF STEP]
unfolding ALG'_det_def ALG.simps
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if x < qs ! n in fst (swaps (snd (Strat ! n)) (steps' init qs Strat n), ()) then 1 else 0) = (if x < qs ! n in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) then 1 else 0)
[PROOF STEP]
by(auto simp: arghschonwieder split_def)
[PROOF STATE]
proof (state)
this:
ALG'_det Strat qs init n x = (if x < qs ! n in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) then 1 else 0)

goal (1 subgoal):
 1. T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) + length [] = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
have index_is_blocking_cost: "index  ((swap 0 ^^ ?m) (swaps sws
                        (steps (Lxy init {x,y}) (Lxy (take n qs) {x, y}) Strat2))) (qs ! n)
                      = ALG'_det Strat qs init n y + ALG'_det Strat qs init n x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. index ((swap 0 ^^ ALG_P' Strat (take n qs @ [qs ! n]) init n x y) (swaps sws (Partial_Cost_Model.steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2))) (qs ! n) = ALG'_det Strat qs init n y + ALG'_det Strat qs init n x
[PROOF STEP]
proof (cases "x= qs!n")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. x = qs ! n \<Longrightarrow> index ((swap 0 ^^ ALG_P' Strat (take n qs @ [qs ! n]) init n x y) (swaps sws (Partial_Cost_Model.steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2))) (qs ! n) = ALG'_det Strat qs init n y + ALG'_det Strat qs init n x
 2. x \<noteq> qs ! n \<Longrightarrow> index ((swap 0 ^^ ALG_P' Strat (take n qs @ [qs ! n]) init n x y) (swaps sws (Partial_Cost_Model.steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2))) (qs ! n) = ALG'_det Strat qs init n y + ALG'_det Strat qs init n x
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
x = qs ! n

goal (2 subgoals):
 1. x = qs ! n \<Longrightarrow> index ((swap 0 ^^ ALG_P' Strat (take n qs @ [qs ! n]) init n x y) (swaps sws (Partial_Cost_Model.steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2))) (qs ! n) = ALG'_det Strat qs init n y + ALG'_det Strat qs init n x
 2. x \<noteq> qs ! n \<Longrightarrow> index ((swap 0 ^^ ALG_P' Strat (take n qs @ [qs ! n]) init n x y) (swaps sws (Partial_Cost_Model.steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2))) (qs ! n) = ALG'_det Strat qs init n y + ALG'_det Strat qs init n x
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
x = qs ! n
[PROOF STEP]
have "ALG'_det Strat qs init n x = 0"
[PROOF STATE]
proof (prove)
using this:
x = qs ! n

goal (1 subgoal):
 1. ALG'_det Strat qs init n x = 0
[PROOF STEP]
unfolding blockx
[PROOF STATE]
proof (prove)
using this:
x = qs ! n

goal (1 subgoal):
 1. (if x < qs ! n in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) then 1 else 0) = 0
[PROOF STEP]
apply(simp)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x = qs ! n \<Longrightarrow> \<not> qs ! n < qs ! n in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)
[PROOF STEP]
using before_in_irefl
[PROOF STATE]
proof (prove)
using this:
?x < ?x in ?xs = False

goal (1 subgoal):
 1. x = qs ! n \<Longrightarrow> \<not> qs ! n < qs ! n in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
ALG'_det Strat qs init n x = 0

goal (2 subgoals):
 1. x = qs ! n \<Longrightarrow> index ((swap 0 ^^ ALG_P' Strat (take n qs @ [qs ! n]) init n x y) (swaps sws (Partial_Cost_Model.steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2))) (qs ! n) = ALG'_det Strat qs init n y + ALG'_det Strat qs init n x
 2. x \<noteq> qs ! n \<Longrightarrow> index ((swap 0 ^^ ALG_P' Strat (take n qs @ [qs ! n]) init n x y) (swaps sws (Partial_Cost_Model.steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2))) (qs ! n) = ALG'_det Strat qs init n y + ALG'_det Strat qs init n x
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
ALG'_det Strat qs init n x = 0
[PROOF STEP]
have "ALG'_det Strat qs init n y + ALG'_det Strat qs init n x
                  = (if y < x in ?xs' then 1 else 0)"
[PROOF STATE]
proof (prove)
using this:
ALG'_det Strat qs init n x = 0

goal (1 subgoal):
 1. ALG'_det Strat qs init n y + ALG'_det Strat qs init n x = (if y < x in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) then 1 else 0)
[PROOF STEP]
unfolding blocky
[PROOF STATE]
proof (prove)
using this:
ALG'_det Strat qs init n x = 0

goal (1 subgoal):
 1. (if y < qs ! n in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) then 1 else 0) + ALG'_det Strat qs init n x = (if y < x in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) then 1 else 0)
[PROOF STEP]
using True
[PROOF STATE]
proof (prove)
using this:
ALG'_det Strat qs init n x = 0
x = qs ! n

goal (1 subgoal):
 1. (if y < qs ! n in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) then 1 else 0) + ALG'_det Strat qs init n x = (if y < x in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) then 1 else 0)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
ALG'_det Strat qs init n y + ALG'_det Strat qs init n x = (if y < x in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) then 1 else 0)

goal (2 subgoals):
 1. x = qs ! n \<Longrightarrow> index ((swap 0 ^^ ALG_P' Strat (take n qs @ [qs ! n]) init n x y) (swaps sws (Partial_Cost_Model.steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2))) (qs ! n) = ALG'_det Strat qs init n y + ALG'_det Strat qs init n x
 2. x \<noteq> qs ! n \<Longrightarrow> index ((swap 0 ^^ ALG_P' Strat (take n qs @ [qs ! n]) init n x y) (swaps sws (Partial_Cost_Model.steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2))) (qs ! n) = ALG'_det Strat qs init n y + ALG'_det Strat qs init n x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
ALG'_det Strat qs init n y + ALG'_det Strat qs init n x = (if y < x in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) then 1 else 0)

goal (2 subgoals):
 1. x = qs ! n \<Longrightarrow> index ((swap 0 ^^ ALG_P' Strat (take n qs @ [qs ! n]) init n x y) (swaps sws (Partial_Cost_Model.steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2))) (qs ! n) = ALG'_det Strat qs init n y + ALG'_det Strat qs init n x
 2. x \<noteq> qs ! n \<Longrightarrow> index ((swap 0 ^^ ALG_P' Strat (take n qs @ [qs ! n]) init n x y) (swaps sws (Partial_Cost_Model.steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2))) (qs ! n) = ALG'_det Strat qs init n y + ALG'_det Strat qs init n x
[PROOF STEP]
have "\<dots> = (if ~y < x in ?xs' then 0 else 1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if y < x in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) then 1 else 0) = (if \<not> y < x in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) then 0 else 1)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(if y < x in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) then 1 else 0) = (if \<not> y < x in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) then 0 else 1)

goal (2 subgoals):
 1. x = qs ! n \<Longrightarrow> index ((swap 0 ^^ ALG_P' Strat (take n qs @ [qs ! n]) init n x y) (swaps sws (Partial_Cost_Model.steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2))) (qs ! n) = ALG'_det Strat qs init n y + ALG'_det Strat qs init n x
 2. x \<noteq> qs ! n \<Longrightarrow> index ((swap 0 ^^ ALG_P' Strat (take n qs @ [qs ! n]) init n x y) (swaps sws (Partial_Cost_Model.steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2))) (qs ! n) = ALG'_det Strat qs init n y + ALG'_det Strat qs init n x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(if y < x in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) then 1 else 0) = (if \<not> y < x in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) then 0 else 1)

goal (2 subgoals):
 1. x = qs ! n \<Longrightarrow> index ((swap 0 ^^ ALG_P' Strat (take n qs @ [qs ! n]) init n x y) (swaps sws (Partial_Cost_Model.steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2))) (qs ! n) = ALG'_det Strat qs init n y + ALG'_det Strat qs init n x
 2. x \<noteq> qs ! n \<Longrightarrow> index ((swap 0 ^^ ALG_P' Strat (take n qs @ [qs ! n]) init n x y) (swaps sws (Partial_Cost_Model.steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2))) (qs ! n) = ALG'_det Strat qs init n y + ALG'_det Strat qs init n x
[PROOF STEP]
have "\<dots> = (if x < y in ?xs' then 0 else 1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if \<not> y < x in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) then 0 else 1) = (if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) then 0 else 1)
[PROOF STEP]
apply(simp)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<not> y < x in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) \<longrightarrow> x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)
[PROOF STEP]
by (meson 24 Suc.prems(4) not_before_in)
[PROOF STATE]
proof (state)
this:
(if \<not> y < x in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) then 0 else 1) = (if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) then 0 else 1)

goal (2 subgoals):
 1. x = qs ! n \<Longrightarrow> index ((swap 0 ^^ ALG_P' Strat (take n qs @ [qs ! n]) init n x y) (swaps sws (Partial_Cost_Model.steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2))) (qs ! n) = ALG'_det Strat qs init n y + ALG'_det Strat qs init n x
 2. x \<noteq> qs ! n \<Longrightarrow> index ((swap 0 ^^ ALG_P' Strat (take n qs @ [qs ! n]) init n x y) (swaps sws (Partial_Cost_Model.steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2))) (qs ! n) = ALG'_det Strat qs init n y + ALG'_det Strat qs init n x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(if \<not> y < x in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) then 0 else 1) = (if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) then 0 else 1)

goal (2 subgoals):
 1. x = qs ! n \<Longrightarrow> index ((swap 0 ^^ ALG_P' Strat (take n qs @ [qs ! n]) init n x y) (swaps sws (Partial_Cost_Model.steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2))) (qs ! n) = ALG'_det Strat qs init n y + ALG'_det Strat qs init n x
 2. x \<noteq> qs ! n \<Longrightarrow> index ((swap 0 ^^ ALG_P' Strat (take n qs @ [qs ! n]) init n x y) (swaps sws (Partial_Cost_Model.steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2))) (qs ! n) = ALG'_det Strat qs init n y + ALG'_det Strat qs init n x
[PROOF STEP]
have "\<dots> = (if x < y in ?ys'' then 0 else 1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) then 0 else 1) = (if x < y in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) then 0 else 1)
[PROOF STEP]
using aaa
[PROOF STATE]
proof (prove)
using this:
x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))

goal (1 subgoal):
 1. (if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) then 0 else 1) = (if x < y in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) then 0 else 1)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) then 0 else 1) = (if x < y in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) then 0 else 1)

goal (2 subgoals):
 1. x = qs ! n \<Longrightarrow> index ((swap 0 ^^ ALG_P' Strat (take n qs @ [qs ! n]) init n x y) (swaps sws (Partial_Cost_Model.steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2))) (qs ! n) = ALG'_det Strat qs init n y + ALG'_det Strat qs init n x
 2. x \<noteq> qs ! n \<Longrightarrow> index ((swap 0 ^^ ALG_P' Strat (take n qs @ [qs ! n]) init n x y) (swaps sws (Partial_Cost_Model.steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2))) (qs ! n) = ALG'_det Strat qs init n y + ALG'_det Strat qs init n x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) then 0 else 1) = (if x < y in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) then 0 else 1)

goal (2 subgoals):
 1. x = qs ! n \<Longrightarrow> index ((swap 0 ^^ ALG_P' Strat (take n qs @ [qs ! n]) init n x y) (swaps sws (Partial_Cost_Model.steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2))) (qs ! n) = ALG'_det Strat qs init n y + ALG'_det Strat qs init n x
 2. x \<noteq> qs ! n \<Longrightarrow> index ((swap 0 ^^ ALG_P' Strat (take n qs @ [qs ! n]) init n x y) (swaps sws (Partial_Cost_Model.steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2))) (qs ! n) = ALG'_det Strat qs init n y + ALG'_det Strat qs init n x
[PROOF STEP]
have "\<dots> = index ?ys'' x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if x < y in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) then 0 else 1) = index ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) x
[PROOF STEP]
apply(rule before_in_index1)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. set ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) = {x, y}
 2. length ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) = 2
 3. x \<noteq> y
[PROOF STEP]
by(fact)+
[PROOF STATE]
proof (state)
this:
(if x < y in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) then 0 else 1) = index ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) x

goal (2 subgoals):
 1. x = qs ! n \<Longrightarrow> index ((swap 0 ^^ ALG_P' Strat (take n qs @ [qs ! n]) init n x y) (swaps sws (Partial_Cost_Model.steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2))) (qs ! n) = ALG'_det Strat qs init n y + ALG'_det Strat qs init n x
 2. x \<noteq> qs ! n \<Longrightarrow> index ((swap 0 ^^ ALG_P' Strat (take n qs @ [qs ! n]) init n x y) (swaps sws (Partial_Cost_Model.steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2))) (qs ! n) = ALG'_det Strat qs init n y + ALG'_det Strat qs init n x
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
ALG'_det Strat qs init n y + ALG'_det Strat qs init n x = index ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) x
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
ALG'_det Strat qs init n y + ALG'_det Strat qs init n x = index ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) x

goal (1 subgoal):
 1. index ((swap 0 ^^ ALG_P' Strat (take n qs @ [qs ! n]) init n x y) (swaps sws (Partial_Cost_Model.steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2))) (qs ! n) = ALG'_det Strat qs init n y + ALG'_det Strat qs init n x
[PROOF STEP]
unfolding indexe
[PROOF STATE]
proof (prove)
using this:
ALG'_det Strat qs init n y + ALG'_det Strat qs init n x = index ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) x

goal (1 subgoal):
 1. index ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) (qs ! n) = ALG'_det Strat qs init n y + ALG'_det Strat qs init n x
[PROOF STEP]
using True
[PROOF STATE]
proof (prove)
using this:
ALG'_det Strat qs init n y + ALG'_det Strat qs init n x = index ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) x
x = qs ! n

goal (1 subgoal):
 1. index ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) (qs ! n) = ALG'_det Strat qs init n y + ALG'_det Strat qs init n x
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
index ((swap 0 ^^ ALG_P' Strat (take n qs @ [qs ! n]) init n x y) (swaps sws (Partial_Cost_Model.steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2))) (qs ! n) = ALG'_det Strat qs init n y + ALG'_det Strat qs init n x

goal (1 subgoal):
 1. x \<noteq> qs ! n \<Longrightarrow> index ((swap 0 ^^ ALG_P' Strat (take n qs @ [qs ! n]) init n x y) (swaps sws (Partial_Cost_Model.steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2))) (qs ! n) = ALG'_det Strat qs init n y + ALG'_det Strat qs init n x
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. x \<noteq> qs ! n \<Longrightarrow> index ((swap 0 ^^ ALG_P' Strat (take n qs @ [qs ! n]) init n x y) (swaps sws (Partial_Cost_Model.steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2))) (qs ! n) = ALG'_det Strat qs init n y + ALG'_det Strat qs init n x
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
x \<noteq> qs ! n

goal (1 subgoal):
 1. x \<noteq> qs ! n \<Longrightarrow> index ((swap 0 ^^ ALG_P' Strat (take n qs @ [qs ! n]) init n x y) (swaps sws (Partial_Cost_Model.steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2))) (qs ! n) = ALG'_det Strat qs init n y + ALG'_det Strat qs init n x
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
x \<noteq> qs ! n
[PROOF STEP]
have q: "y = qs!n"
[PROOF STATE]
proof (prove)
using this:
x \<noteq> qs ! n

goal (1 subgoal):
 1. y = qs ! n
[PROOF STEP]
using qsinxy
[PROOF STATE]
proof (prove)
using this:
x \<noteq> qs ! n
qs ! n \<in> {x, y}

goal (1 subgoal):
 1. y = qs ! n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
y = qs ! n

goal (1 subgoal):
 1. x \<noteq> qs ! n \<Longrightarrow> index ((swap 0 ^^ ALG_P' Strat (take n qs @ [qs ! n]) init n x y) (swaps sws (Partial_Cost_Model.steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2))) (qs ! n) = ALG'_det Strat qs init n y + ALG'_det Strat qs init n x
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
y = qs ! n
[PROOF STEP]
have "ALG'_det Strat qs init n y = 0"
[PROOF STATE]
proof (prove)
using this:
y = qs ! n

goal (1 subgoal):
 1. ALG'_det Strat qs init n y = 0
[PROOF STEP]
unfolding blocky
[PROOF STATE]
proof (prove)
using this:
y = qs ! n

goal (1 subgoal):
 1. (if y < qs ! n in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) then 1 else 0) = 0
[PROOF STEP]
apply(simp)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. y = qs ! n \<Longrightarrow> \<not> qs ! n < qs ! n in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)
[PROOF STEP]
using before_in_irefl
[PROOF STATE]
proof (prove)
using this:
?x < ?x in ?xs = False

goal (1 subgoal):
 1. y = qs ! n \<Longrightarrow> \<not> qs ! n < qs ! n in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
ALG'_det Strat qs init n y = 0

goal (1 subgoal):
 1. x \<noteq> qs ! n \<Longrightarrow> index ((swap 0 ^^ ALG_P' Strat (take n qs @ [qs ! n]) init n x y) (swaps sws (Partial_Cost_Model.steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2))) (qs ! n) = ALG'_det Strat qs init n y + ALG'_det Strat qs init n x
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
ALG'_det Strat qs init n y = 0
[PROOF STEP]
have "ALG'_det Strat qs init n y + ALG'_det Strat qs init n x
                  = (if x < y in ?xs' then 1 else 0)"
[PROOF STATE]
proof (prove)
using this:
ALG'_det Strat qs init n y = 0

goal (1 subgoal):
 1. ALG'_det Strat qs init n y + ALG'_det Strat qs init n x = (if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) then 1 else 0)
[PROOF STEP]
unfolding blockx
[PROOF STATE]
proof (prove)
using this:
ALG'_det Strat qs init n y = 0

goal (1 subgoal):
 1. ALG'_det Strat qs init n y + (if x < qs ! n in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) then 1 else 0) = (if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) then 1 else 0)
[PROOF STEP]
using q
[PROOF STATE]
proof (prove)
using this:
ALG'_det Strat qs init n y = 0
y = qs ! n

goal (1 subgoal):
 1. ALG'_det Strat qs init n y + (if x < qs ! n in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) then 1 else 0) = (if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) then 1 else 0)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
ALG'_det Strat qs init n y + ALG'_det Strat qs init n x = (if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) then 1 else 0)

goal (1 subgoal):
 1. x \<noteq> qs ! n \<Longrightarrow> index ((swap 0 ^^ ALG_P' Strat (take n qs @ [qs ! n]) init n x y) (swaps sws (Partial_Cost_Model.steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2))) (qs ! n) = ALG'_det Strat qs init n y + ALG'_det Strat qs init n x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
ALG'_det Strat qs init n y + ALG'_det Strat qs init n x = (if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) then 1 else 0)

goal (1 subgoal):
 1. x \<noteq> qs ! n \<Longrightarrow> index ((swap 0 ^^ ALG_P' Strat (take n qs @ [qs ! n]) init n x y) (swaps sws (Partial_Cost_Model.steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2))) (qs ! n) = ALG'_det Strat qs init n y + ALG'_det Strat qs init n x
[PROOF STEP]
have "\<dots> = (if x < y in ?ys'' then 1 else 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) then 1 else 0) = (if x < y in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) then 1 else 0)
[PROOF STEP]
using aaa
[PROOF STATE]
proof (prove)
using this:
x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))

goal (1 subgoal):
 1. (if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) then 1 else 0) = (if x < y in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) then 1 else 0)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) then 1 else 0) = (if x < y in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) then 1 else 0)

goal (1 subgoal):
 1. x \<noteq> qs ! n \<Longrightarrow> index ((swap 0 ^^ ALG_P' Strat (take n qs @ [qs ! n]) init n x y) (swaps sws (Partial_Cost_Model.steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2))) (qs ! n) = ALG'_det Strat qs init n y + ALG'_det Strat qs init n x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) then 1 else 0) = (if x < y in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) then 1 else 0)

goal (1 subgoal):
 1. x \<noteq> qs ! n \<Longrightarrow> index ((swap 0 ^^ ALG_P' Strat (take n qs @ [qs ! n]) init n x y) (swaps sws (Partial_Cost_Model.steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2))) (qs ! n) = ALG'_det Strat qs init n y + ALG'_det Strat qs init n x
[PROOF STEP]
have "\<dots> = index ?ys'' y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if x < y in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) then 1 else 0) = index ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) y
[PROOF STEP]
apply(rule before_in_index2)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. set ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) = {x, y}
 2. length ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) = 2
 3. x \<noteq> y
[PROOF STEP]
by(fact)+
[PROOF STATE]
proof (state)
this:
(if x < y in (swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2))) then 1 else 0) = index ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) y

goal (1 subgoal):
 1. x \<noteq> qs ! n \<Longrightarrow> index ((swap 0 ^^ ALG_P' Strat (take n qs @ [qs ! n]) init n x y) (swaps sws (Partial_Cost_Model.steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2))) (qs ! n) = ALG'_det Strat qs init n y + ALG'_det Strat qs init n x
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
ALG'_det Strat qs init n y + ALG'_det Strat qs init n x = index ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) y
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
ALG'_det Strat qs init n y + ALG'_det Strat qs init n x = index ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) y

goal (1 subgoal):
 1. index ((swap 0 ^^ ALG_P' Strat (take n qs @ [qs ! n]) init n x y) (swaps sws (Partial_Cost_Model.steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2))) (qs ! n) = ALG'_det Strat qs init n y + ALG'_det Strat qs init n x
[PROOF STEP]
unfolding indexe
[PROOF STATE]
proof (prove)
using this:
ALG'_det Strat qs init n y + ALG'_det Strat qs init n x = index ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) y

goal (1 subgoal):
 1. index ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) (qs ! n) = ALG'_det Strat qs init n y + ALG'_det Strat qs init n x
[PROOF STEP]
using q
[PROOF STATE]
proof (prove)
using this:
ALG'_det Strat qs init n y + ALG'_det Strat qs init n x = index ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) y
y = qs ! n

goal (1 subgoal):
 1. index ((swap 0 ^^ ALG_P (snd (Strat ! n)) x y (steps' init (take n qs) (take n Strat) n)) (swaps sws (steps' (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 (length Strat2)))) (qs ! n) = ALG'_det Strat qs init n y + ALG'_det Strat qs init n x
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
index ((swap 0 ^^ ALG_P' Strat (take n qs @ [qs ! n]) init n x y) (swaps sws (Partial_Cost_Model.steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2))) (qs ! n) = ALG'_det Strat qs init n y + ALG'_det Strat qs init n x

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
index ((swap 0 ^^ ALG_P' Strat (take n qs @ [qs ! n]) init n x y) (swaps sws (Partial_Cost_Model.steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2))) (qs ! n) = ALG'_det Strat qs init n y + ALG'_det Strat qs init n x

goal (1 subgoal):
 1. T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) + length [] = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
have jj: "ALG_Pxy Strat (take (Suc n) qs) init x y =
                ALG_Pxy Strat (take n qs) init x y
                  + ALG_P' Strat (take n qs @ [qs ! n]) init n x y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ALG_Pxy Strat (take (Suc n) qs) init x y = ALG_Pxy Strat (take n qs) init x y + ALG_P' Strat (take n qs @ [qs ! n]) init n x y
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. ALG_Pxy Strat (take (Suc n) qs) init x y = ALG_Pxy Strat (take n qs) init x y + ALG_P' Strat (take n qs @ [qs ! n]) init n x y
[PROOF STEP]
have "ALG_Pxy Strat (take (Suc n) qs) init x y
                  = (\<Sum>i<length (take (Suc n) qs). ALG_P' Strat (take (Suc n) qs) init i x y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ALG_Pxy Strat (take (Suc n) qs) init x y = (\<Sum>i<length (take (Suc n) qs). ALG_P' Strat (take (Suc n) qs) init i x y)
[PROOF STEP]
unfolding ALG_Pxy_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i<length (take (Suc n) qs). ALG_P' Strat (take (Suc n) qs) init i x y) = (\<Sum>i<length (take (Suc n) qs). ALG_P' Strat (take (Suc n) qs) init i x y)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
ALG_Pxy Strat (take (Suc n) qs) init x y = (\<Sum>i<length (take (Suc n) qs). ALG_P' Strat (take (Suc n) qs) init i x y)

goal (1 subgoal):
 1. ALG_Pxy Strat (take (Suc n) qs) init x y = ALG_Pxy Strat (take n qs) init x y + ALG_P' Strat (take n qs @ [qs ! n]) init n x y
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
ALG_Pxy Strat (take (Suc n) qs) init x y = (\<Sum>i<length (take (Suc n) qs). ALG_P' Strat (take (Suc n) qs) init i x y)

goal (1 subgoal):
 1. ALG_Pxy Strat (take (Suc n) qs) init x y = ALG_Pxy Strat (take n qs) init x y + ALG_P' Strat (take n qs @ [qs ! n]) init n x y
[PROOF STEP]
have "\<dots> = (\<Sum>i< Suc n. ALG_P' Strat (take (Suc n) qs) init i x y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i<length (take (Suc n) qs). ALG_P' Strat (take (Suc n) qs) init i x y) = (\<Sum>i<Suc n. ALG_P' Strat (take (Suc n) qs) init i x y)
[PROOF STEP]
unfolding tak
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i<length (take n qs @ [qs ! n]). ALG_P' Strat (take n qs @ [qs ! n]) init i x y) = (\<Sum>i<Suc n. ALG_P' Strat (take n qs @ [qs ! n]) init i x y)
[PROOF STEP]
using ns
[PROOF STATE]
proof (prove)
using this:
n < length qs

goal (1 subgoal):
 1. (\<Sum>i<length (take n qs @ [qs ! n]). ALG_P' Strat (take n qs @ [qs ! n]) init i x y) = (\<Sum>i<Suc n. ALG_P' Strat (take n qs @ [qs ! n]) init i x y)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<Sum>i<length (take (Suc n) qs). ALG_P' Strat (take (Suc n) qs) init i x y) = (\<Sum>i<Suc n. ALG_P' Strat (take (Suc n) qs) init i x y)

goal (1 subgoal):
 1. ALG_Pxy Strat (take (Suc n) qs) init x y = ALG_Pxy Strat (take n qs) init x y + ALG_P' Strat (take n qs @ [qs ! n]) init n x y
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>i<length (take (Suc n) qs). ALG_P' Strat (take (Suc n) qs) init i x y) = (\<Sum>i<Suc n. ALG_P' Strat (take (Suc n) qs) init i x y)

goal (1 subgoal):
 1. ALG_Pxy Strat (take (Suc n) qs) init x y = ALG_Pxy Strat (take n qs) init x y + ALG_P' Strat (take n qs @ [qs ! n]) init n x y
[PROOF STEP]
have "\<dots> = (\<Sum>i<n. ALG_P' Strat (take (Suc n) qs) init i x y)
                  + ALG_P' Strat (take (Suc n) qs) init n x y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i<Suc n. ALG_P' Strat (take (Suc n) qs) init i x y) = (\<Sum>i<n. ALG_P' Strat (take (Suc n) qs) init i x y) + ALG_P' Strat (take (Suc n) qs) init n x y
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<Sum>i<Suc n. ALG_P' Strat (take (Suc n) qs) init i x y) = (\<Sum>i<n. ALG_P' Strat (take (Suc n) qs) init i x y) + ALG_P' Strat (take (Suc n) qs) init n x y

goal (1 subgoal):
 1. ALG_Pxy Strat (take (Suc n) qs) init x y = ALG_Pxy Strat (take n qs) init x y + ALG_P' Strat (take n qs @ [qs ! n]) init n x y
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>i<Suc n. ALG_P' Strat (take (Suc n) qs) init i x y) = (\<Sum>i<n. ALG_P' Strat (take (Suc n) qs) init i x y) + ALG_P' Strat (take (Suc n) qs) init n x y

goal (1 subgoal):
 1. ALG_Pxy Strat (take (Suc n) qs) init x y = ALG_Pxy Strat (take n qs) init x y + ALG_P' Strat (take n qs @ [qs ! n]) init n x y
[PROOF STEP]
have "\<dots> = (\<Sum>i<length (take n qs). ALG_P' Strat (take n qs @ [qs ! n]) init i x y)
                  + ALG_P' Strat (take n qs @ [qs ! n]) init n x y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i<n. ALG_P' Strat (take (Suc n) qs) init i x y) + ALG_P' Strat (take (Suc n) qs) init n x y = (\<Sum>i<length (take n qs). ALG_P' Strat (take n qs @ [qs ! n]) init i x y) + ALG_P' Strat (take n qs @ [qs ! n]) init n x y
[PROOF STEP]
unfolding tak
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i<n. ALG_P' Strat (take n qs @ [qs ! n]) init i x y) + ALG_P' Strat (take n qs @ [qs ! n]) init n x y = (\<Sum>i<length (take n qs). ALG_P' Strat (take n qs @ [qs ! n]) init i x y) + ALG_P' Strat (take n qs @ [qs ! n]) init n x y
[PROOF STEP]
using ns
[PROOF STATE]
proof (prove)
using this:
n < length qs

goal (1 subgoal):
 1. (\<Sum>i<n. ALG_P' Strat (take n qs @ [qs ! n]) init i x y) + ALG_P' Strat (take n qs @ [qs ! n]) init n x y = (\<Sum>i<length (take n qs). ALG_P' Strat (take n qs @ [qs ! n]) init i x y) + ALG_P' Strat (take n qs @ [qs ! n]) init n x y
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<Sum>i<n. ALG_P' Strat (take (Suc n) qs) init i x y) + ALG_P' Strat (take (Suc n) qs) init n x y = (\<Sum>i<length (take n qs). ALG_P' Strat (take n qs @ [qs ! n]) init i x y) + ALG_P' Strat (take n qs @ [qs ! n]) init n x y

goal (1 subgoal):
 1. ALG_Pxy Strat (take (Suc n) qs) init x y = ALG_Pxy Strat (take n qs) init x y + ALG_P' Strat (take n qs @ [qs ! n]) init n x y
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>i<n. ALG_P' Strat (take (Suc n) qs) init i x y) + ALG_P' Strat (take (Suc n) qs) init n x y = (\<Sum>i<length (take n qs). ALG_P' Strat (take n qs @ [qs ! n]) init i x y) + ALG_P' Strat (take n qs @ [qs ! n]) init n x y

goal (1 subgoal):
 1. ALG_Pxy Strat (take (Suc n) qs) init x y = ALG_Pxy Strat (take n qs) init x y + ALG_P' Strat (take n qs @ [qs ! n]) init n x y
[PROOF STEP]
have "\<dots> = (\<Sum>i<length (take n qs). ALG_P' Strat (take n qs) init i x y)
                  + ALG_P' Strat (take n qs @ [qs ! n]) init n x y" (is "?A + ?B = ?A' + ?B")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i<length (take n qs). ALG_P' Strat (take n qs @ [qs ! n]) init i x y) + ALG_P' Strat (take n qs @ [qs ! n]) init n x y = (\<Sum>i<length (take n qs). ALG_P' Strat (take n qs) init i x y) + ALG_P' Strat (take n qs @ [qs ! n]) init n x y
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<Sum>i<length (take n qs). ALG_P' Strat (take n qs @ [qs ! n]) init i x y) + ALG_P' Strat (take n qs @ [qs ! n]) init n x y = (\<Sum>i<length (take n qs). ALG_P' Strat (take n qs) init i x y) + ALG_P' Strat (take n qs @ [qs ! n]) init n x y
[PROOF STEP]
have "?A = ?A'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i<length (take n qs). ALG_P' Strat (take n qs @ [qs ! n]) init i x y) = (\<Sum>i<length (take n qs). ALG_P' Strat (take n qs) init i x y)
[PROOF STEP]
apply(rule sum.cong)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. {..<length (take n qs)} = {..<length (take n qs)}
 2. \<And>xa. xa \<in> {..<length (take n qs)} \<Longrightarrow> ALG_P' Strat (take n qs @ [qs ! n]) init xa x y = ALG_P' Strat (take n qs) init xa x y
[PROOF STEP]
apply(simp)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>xa. xa \<in> {..<length (take n qs)} \<Longrightarrow> ALG_P' Strat (take n qs @ [qs ! n]) init xa x y = ALG_P' Strat (take n qs) init xa x y
[PROOF STEP]
proof goal_cases
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>xa. xa \<in> {..<length (take n qs)} \<Longrightarrow> ALG_P' Strat (take n qs @ [qs ! n]) init xa x y = ALG_P' Strat (take n qs) init xa x y
[PROOF STEP]
case 1
[PROOF STATE]
proof (state)
this:
x_ \<in> {..<length (take n qs)}

goal (1 subgoal):
 1. \<And>xa. xa \<in> {..<length (take n qs)} \<Longrightarrow> ALG_P' Strat (take n qs @ [qs ! n]) init xa x y = ALG_P' Strat (take n qs) init xa x y
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ALG_P' Strat (take n qs @ [qs ! n]) init x_ x y = ALG_P' Strat (take n qs) init x_ x y
[PROOF STEP]
apply(rule ALG_P'_rest2[symmetric, where ?r1.0="[]", simplified])
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. x_ < length (take n qs)
 2. x_ < length Strat
[PROOF STEP]
using 1
[PROOF STATE]
proof (prove)
using this:
x_ \<in> {..<length (take n qs)}

goal (2 subgoals):
 1. x_ < length (take n qs)
 2. x_ < length Strat
[PROOF STEP]
apply(simp)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x_ < length Strat
[PROOF STEP]
using 1 nStrat
[PROOF STATE]
proof (prove)
using this:
x_ \<in> {..<length (take n qs)}
n < length Strat

goal (1 subgoal):
 1. x_ < length Strat
[PROOF STEP]
by(simp)
[PROOF STATE]
proof (state)
this:
ALG_P' Strat (take n qs @ [qs ! n]) init x_ x y = ALG_P' Strat (take n qs) init x_ x y

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<Sum>i<length (take n qs). ALG_P' Strat (take n qs @ [qs ! n]) init i x y) = (\<Sum>i<length (take n qs). ALG_P' Strat (take n qs) init i x y)

goal (1 subgoal):
 1. (\<Sum>i<length (take n qs). ALG_P' Strat (take n qs @ [qs ! n]) init i x y) + ALG_P' Strat (take n qs @ [qs ! n]) init n x y = (\<Sum>i<length (take n qs). ALG_P' Strat (take n qs) init i x y) + ALG_P' Strat (take n qs @ [qs ! n]) init n x y
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(\<Sum>i<length (take n qs). ALG_P' Strat (take n qs @ [qs ! n]) init i x y) = (\<Sum>i<length (take n qs). ALG_P' Strat (take n qs) init i x y)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(\<Sum>i<length (take n qs). ALG_P' Strat (take n qs @ [qs ! n]) init i x y) = (\<Sum>i<length (take n qs). ALG_P' Strat (take n qs) init i x y)

goal (1 subgoal):
 1. (\<Sum>i<length (take n qs). ALG_P' Strat (take n qs @ [qs ! n]) init i x y) + ALG_P' Strat (take n qs @ [qs ! n]) init n x y = (\<Sum>i<length (take n qs). ALG_P' Strat (take n qs) init i x y) + ALG_P' Strat (take n qs @ [qs ! n]) init n x y
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<Sum>i<length (take n qs). ALG_P' Strat (take n qs @ [qs ! n]) init i x y) + ALG_P' Strat (take n qs @ [qs ! n]) init n x y = (\<Sum>i<length (take n qs). ALG_P' Strat (take n qs) init i x y) + ALG_P' Strat (take n qs @ [qs ! n]) init n x y

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<Sum>i<length (take n qs). ALG_P' Strat (take n qs @ [qs ! n]) init i x y) + ALG_P' Strat (take n qs @ [qs ! n]) init n x y = (\<Sum>i<length (take n qs). ALG_P' Strat (take n qs) init i x y) + ALG_P' Strat (take n qs @ [qs ! n]) init n x y

goal (1 subgoal):
 1. ALG_Pxy Strat (take (Suc n) qs) init x y = ALG_Pxy Strat (take n qs) init x y + ALG_P' Strat (take n qs @ [qs ! n]) init n x y
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>i<length (take n qs). ALG_P' Strat (take n qs @ [qs ! n]) init i x y) + ALG_P' Strat (take n qs @ [qs ! n]) init n x y = (\<Sum>i<length (take n qs). ALG_P' Strat (take n qs) init i x y) + ALG_P' Strat (take n qs @ [qs ! n]) init n x y

goal (1 subgoal):
 1. ALG_Pxy Strat (take (Suc n) qs) init x y = ALG_Pxy Strat (take n qs) init x y + ALG_P' Strat (take n qs @ [qs ! n]) init n x y
[PROOF STEP]
have "\<dots> = ALG_Pxy Strat (take n qs) init x y
                  + ALG_P' Strat (take n qs @ [qs ! n]) init n x y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i<length (take n qs). ALG_P' Strat (take n qs) init i x y) + ALG_P' Strat (take n qs @ [qs ! n]) init n x y = ALG_Pxy Strat (take n qs) init x y + ALG_P' Strat (take n qs @ [qs ! n]) init n x y
[PROOF STEP]
unfolding ALG_Pxy_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i<length (take n qs). ALG_P' Strat (take n qs) init i x y) + ALG_P' Strat (take n qs @ [qs ! n]) init n x y = (\<Sum>i<length (take n qs). ALG_P' Strat (take n qs) init i x y) + ALG_P' Strat (take n qs @ [qs ! n]) init n x y
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<Sum>i<length (take n qs). ALG_P' Strat (take n qs) init i x y) + ALG_P' Strat (take n qs @ [qs ! n]) init n x y = ALG_Pxy Strat (take n qs) init x y + ALG_P' Strat (take n qs @ [qs ! n]) init n x y

goal (1 subgoal):
 1. ALG_Pxy Strat (take (Suc n) qs) init x y = ALG_Pxy Strat (take n qs) init x y + ALG_P' Strat (take n qs @ [qs ! n]) init n x y
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
ALG_Pxy Strat (take (Suc n) qs) init x y = ALG_Pxy Strat (take n qs) init x y + ALG_P' Strat (take n qs @ [qs ! n]) init n x y
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
ALG_Pxy Strat (take (Suc n) qs) init x y = ALG_Pxy Strat (take n qs) init x y + ALG_P' Strat (take n qs @ [qs ! n]) init n x y

goal (1 subgoal):
 1. ALG_Pxy Strat (take (Suc n) qs) init x y = ALG_Pxy Strat (take n qs) init x y + ALG_P' Strat (take n qs @ [qs ! n]) init n x y
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
ALG_Pxy Strat (take (Suc n) qs) init x y = ALG_Pxy Strat (take n qs) init x y + ALG_P' Strat (take n qs @ [qs ! n]) init n x y

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
ALG_Pxy Strat (take (Suc n) qs) init x y = ALG_Pxy Strat (take n qs) init x y + ALG_P' Strat (take n qs @ [qs ! n]) init n x y

goal (1 subgoal):
 1. T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) + length [] = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
have tw: "length (Lxy (take n qs) {x, y}) = length Strat2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (Lxy (take n qs) {x, y}) = length Strat2
[PROOF STEP]
using len
[PROOF STATE]
proof (prove)
using this:
length Strat2 = length (Lxy (take n qs) {x, y})

goal (1 subgoal):
 1. length (Lxy (take n qs) {x, y}) = length Strat2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
length (Lxy (take n qs) {x, y}) = length Strat2

goal (1 subgoal):
 1. T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) + length [] = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
have "T\<^sub>p (Lxy init {x,y}) (Lxy (take (Suc n) qs) {x, y}) ?newStrat + length []
                 = T\<^sub>p (Lxy init {x,y}) (Lxy (take n qs) {x, y}) Strat2
                  + t\<^sub>p (steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2) (qs ! n) (?mtf,?L)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) + length [] = T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + t\<^sub>p (Partial_Cost_Model.steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2) (qs ! n) (if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)
[PROOF STEP]
unfolding yeh
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y} @ [qs ! n]) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) + length [] = T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + t\<^sub>p (Partial_Cost_Model.steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2) (qs ! n) (if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)
[PROOF STEP]
by(simp add: T_append[OF tw, of "(Lxy init) {x,y}"])
[PROOF STATE]
proof (state)
this:
T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) + length [] = T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + t\<^sub>p (Partial_Cost_Model.steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2) (qs ! n) (if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)

goal (1 subgoal):
 1. T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) + length [] = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) + length [] = T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + t\<^sub>p (Partial_Cost_Model.steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2) (qs ! n) (if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)

goal (1 subgoal):
 1. T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) + length [] = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
have "\<dots> =
                 T\<^sub>p (Lxy init {x,y}) (Lxy (take n qs) {x, y}) Strat2
                  + length sws
                  + index ((swap 0 ^^ ?m) (swaps sws
                        (steps (Lxy init {x,y}) (Lxy (take n qs) {x, y}) Strat2))) (qs ! n)
                  + ALG_P' Strat (take n qs @ [qs ! n]) init n x y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + t\<^sub>p (Partial_Cost_Model.steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2) (qs ! n) (if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws) = T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + length sws + index ((swap 0 ^^ ALG_P' Strat (take n qs @ [qs ! n]) init n x y) (swaps sws (Partial_Cost_Model.steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2))) (qs ! n) + ALG_P' Strat (take n qs @ [qs ! n]) init n x y
[PROOF STEP]
by(simp add: t\<^sub>p_def)
[PROOF STATE]
proof (state)
this:
T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + t\<^sub>p (Partial_Cost_Model.steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2) (qs ! n) (if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws) = T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + length sws + index ((swap 0 ^^ ALG_P' Strat (take n qs @ [qs ! n]) init n x y) (swaps sws (Partial_Cost_Model.steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2))) (qs ! n) + ALG_P' Strat (take n qs @ [qs ! n]) init n x y

goal (1 subgoal):
 1. T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) + length [] = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
(* now use iH *)
[PROOF STATE]
proof (state)
this:
T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + t\<^sub>p (Partial_Cost_Model.steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2) (qs ! n) (if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws) = T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + length sws + index ((swap 0 ^^ ALG_P' Strat (take n qs @ [qs ! n]) init n x y) (swaps sws (Partial_Cost_Model.steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2))) (qs ! n) + ALG_P' Strat (take n qs @ [qs ! n]) init n x y

goal (1 subgoal):
 1. T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) + length [] = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + t\<^sub>p (Partial_Cost_Model.steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2) (qs ! n) (if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws) = T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + length sws + index ((swap 0 ^^ ALG_P' Strat (take n qs @ [qs ! n]) init n x y) (swaps sws (Partial_Cost_Model.steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2))) (qs ! n) + ALG_P' Strat (take n qs @ [qs ! n]) init n x y

goal (1 subgoal):
 1. T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) + length [] = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
have "\<dots> = (ALGxy_det Strat (take n qs) init x y
                  + index ((swap 0 ^^ ?m) (swaps sws
                        (steps (Lxy init {x,y}) (Lxy (take n qs) {x, y}) Strat2))) (qs ! n))
                  + (ALG_Pxy Strat (take n qs) init x y
                  + ALG_P' Strat (take n qs @ [qs ! n]) init n x y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + length sws + index ((swap 0 ^^ ALG_P' Strat (take n qs @ [qs ! n]) init n x y) (swaps sws (Partial_Cost_Model.steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2))) (qs ! n) + ALG_P' Strat (take n qs @ [qs ! n]) init n x y = ALGxy_det Strat (take n qs) init x y + index ((swap 0 ^^ ALG_P' Strat (take n qs @ [qs ! n]) init n x y) (swaps sws (Partial_Cost_Model.steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2))) (qs ! n) + (ALG_Pxy Strat (take n qs) init x y + ALG_P' Strat (take n qs @ [qs ! n]) init n x y)
[PROOF STEP]
by (simp only: T_Strat2)
[PROOF STATE]
proof (state)
this:
T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + length sws + index ((swap 0 ^^ ALG_P' Strat (take n qs @ [qs ! n]) init n x y) (swaps sws (Partial_Cost_Model.steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2))) (qs ! n) + ALG_P' Strat (take n qs @ [qs ! n]) init n x y = ALGxy_det Strat (take n qs) init x y + index ((swap 0 ^^ ALG_P' Strat (take n qs @ [qs ! n]) init n x y) (swaps sws (Partial_Cost_Model.steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2))) (qs ! n) + (ALG_Pxy Strat (take n qs) init x y + ALG_P' Strat (take n qs @ [qs ! n]) init n x y)

goal (1 subgoal):
 1. T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) + length [] = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
(* the current cost are equal to the blocking costs: *)
[PROOF STATE]
proof (state)
this:
T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + length sws + index ((swap 0 ^^ ALG_P' Strat (take n qs @ [qs ! n]) init n x y) (swaps sws (Partial_Cost_Model.steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2))) (qs ! n) + ALG_P' Strat (take n qs @ [qs ! n]) init n x y = ALGxy_det Strat (take n qs) init x y + index ((swap 0 ^^ ALG_P' Strat (take n qs @ [qs ! n]) init n x y) (swaps sws (Partial_Cost_Model.steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2))) (qs ! n) + (ALG_Pxy Strat (take n qs) init x y + ALG_P' Strat (take n qs @ [qs ! n]) init n x y)

goal (1 subgoal):
 1. T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) + length [] = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
T\<^sub>p (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2 + length sws + index ((swap 0 ^^ ALG_P' Strat (take n qs @ [qs ! n]) init n x y) (swaps sws (Partial_Cost_Model.steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2))) (qs ! n) + ALG_P' Strat (take n qs @ [qs ! n]) init n x y = ALGxy_det Strat (take n qs) init x y + index ((swap 0 ^^ ALG_P' Strat (take n qs @ [qs ! n]) init n x y) (swaps sws (Partial_Cost_Model.steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2))) (qs ! n) + (ALG_Pxy Strat (take n qs) init x y + ALG_P' Strat (take n qs @ [qs ! n]) init n x y)

goal (1 subgoal):
 1. T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) + length [] = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
from index_is_blocking_cost
[PROOF STATE]
proof (chain)
picking this:
index ((swap 0 ^^ ALG_P' Strat (take n qs @ [qs ! n]) init n x y) (swaps sws (Partial_Cost_Model.steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2))) (qs ! n) = ALG'_det Strat qs init n y + ALG'_det Strat qs init n x
[PROOF STEP]
have "\<dots> = (ALGxy_det Strat (take n qs) init x y
                  + ALG'_det Strat qs init n y + ALG'_det Strat qs init n x)
                  + (ALG_Pxy Strat (take n qs) init x y
                  + ALG_P' Strat (take n qs @ [qs ! n]) init n x y)"
[PROOF STATE]
proof (prove)
using this:
index ((swap 0 ^^ ALG_P' Strat (take n qs @ [qs ! n]) init n x y) (swaps sws (Partial_Cost_Model.steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2))) (qs ! n) = ALG'_det Strat qs init n y + ALG'_det Strat qs init n x

goal (1 subgoal):
 1. ALGxy_det Strat (take n qs) init x y + index ((swap 0 ^^ ALG_P' Strat (take n qs @ [qs ! n]) init n x y) (swaps sws (Partial_Cost_Model.steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2))) (qs ! n) + (ALG_Pxy Strat (take n qs) init x y + ALG_P' Strat (take n qs @ [qs ! n]) init n x y) = ALGxy_det Strat (take n qs) init x y + ALG'_det Strat qs init n y + ALG'_det Strat qs init n x + (ALG_Pxy Strat (take n qs) init x y + ALG_P' Strat (take n qs @ [qs ! n]) init n x y)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
ALGxy_det Strat (take n qs) init x y + index ((swap 0 ^^ ALG_P' Strat (take n qs @ [qs ! n]) init n x y) (swaps sws (Partial_Cost_Model.steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2))) (qs ! n) + (ALG_Pxy Strat (take n qs) init x y + ALG_P' Strat (take n qs @ [qs ! n]) init n x y) = ALGxy_det Strat (take n qs) init x y + ALG'_det Strat qs init n y + ALG'_det Strat qs init n x + (ALG_Pxy Strat (take n qs) init x y + ALG_P' Strat (take n qs @ [qs ! n]) init n x y)

goal (1 subgoal):
 1. T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) + length [] = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
ALGxy_det Strat (take n qs) init x y + index ((swap 0 ^^ ALG_P' Strat (take n qs @ [qs ! n]) init n x y) (swaps sws (Partial_Cost_Model.steps (Lxy init {x, y}) (Lxy (take n qs) {x, y}) Strat2))) (qs ! n) + (ALG_Pxy Strat (take n qs) init x y + ALG_P' Strat (take n qs @ [qs ! n]) init n x y) = ALGxy_det Strat (take n qs) init x y + ALG'_det Strat qs init n y + ALG'_det Strat qs init n x + (ALG_Pxy Strat (take n qs) init x y + ALG_P' Strat (take n qs @ [qs ! n]) init n x y)

goal (1 subgoal):
 1. T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) + length [] = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
have "\<dots> = ALGxy_det Strat (take (Suc n) qs) init x y
                  + (ALG_Pxy Strat (take n qs) init x y
                  + ALG_P' Strat (take n qs @ [qs ! n]) init n x y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ALGxy_det Strat (take n qs) init x y + ALG'_det Strat qs init n y + ALG'_det Strat qs init n x + (ALG_Pxy Strat (take n qs) init x y + ALG_P' Strat (take n qs @ [qs ! n]) init n x y) = ALGxy_det Strat (take (Suc n) qs) init x y + (ALG_Pxy Strat (take n qs) init x y + ALG_P' Strat (take n qs @ [qs ! n]) init n x y)
[PROOF STEP]
using j
[PROOF STATE]
proof (prove)
using this:
ALGxy_det Strat (take (Suc n) qs) init x y = ALGxy_det Strat (take n qs) init x y + (ALG'_det Strat qs init n y + ALG'_det Strat qs init n x)

goal (1 subgoal):
 1. ALGxy_det Strat (take n qs) init x y + ALG'_det Strat qs init n y + ALG'_det Strat qs init n x + (ALG_Pxy Strat (take n qs) init x y + ALG_P' Strat (take n qs @ [qs ! n]) init n x y) = ALGxy_det Strat (take (Suc n) qs) init x y + (ALG_Pxy Strat (take n qs) init x y + ALG_P' Strat (take n qs @ [qs ! n]) init n x y)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
ALGxy_det Strat (take n qs) init x y + ALG'_det Strat qs init n y + ALG'_det Strat qs init n x + (ALG_Pxy Strat (take n qs) init x y + ALG_P' Strat (take n qs @ [qs ! n]) init n x y) = ALGxy_det Strat (take (Suc n) qs) init x y + (ALG_Pxy Strat (take n qs) init x y + ALG_P' Strat (take n qs @ [qs ! n]) init n x y)

goal (1 subgoal):
 1. T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) + length [] = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
ALGxy_det Strat (take n qs) init x y + ALG'_det Strat qs init n y + ALG'_det Strat qs init n x + (ALG_Pxy Strat (take n qs) init x y + ALG_P' Strat (take n qs @ [qs ! n]) init n x y) = ALGxy_det Strat (take (Suc n) qs) init x y + (ALG_Pxy Strat (take n qs) init x y + ALG_P' Strat (take n qs @ [qs ! n]) init n x y)

goal (1 subgoal):
 1. T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) + length [] = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
have "\<dots> = ALGxy_det Strat (take (Suc n) qs) init x y
                  + ALG_Pxy Strat (take (Suc n) qs) init x y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ALGxy_det Strat (take (Suc n) qs) init x y + (ALG_Pxy Strat (take n qs) init x y + ALG_P' Strat (take n qs @ [qs ! n]) init n x y) = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
using jj
[PROOF STATE]
proof (prove)
using this:
ALG_Pxy Strat (take (Suc n) qs) init x y = ALG_Pxy Strat (take n qs) init x y + ALG_P' Strat (take n qs @ [qs ! n]) init n x y

goal (1 subgoal):
 1. ALGxy_det Strat (take (Suc n) qs) init x y + (ALG_Pxy Strat (take n qs) init x y + ALG_P' Strat (take n qs @ [qs ! n]) init n x y) = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
ALGxy_det Strat (take (Suc n) qs) init x y + (ALG_Pxy Strat (take n qs) init x y + ALG_P' Strat (take n qs @ [qs ! n]) init n x y) = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y

goal (1 subgoal):
 1. T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) + length [] = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) + length [] = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) + length [] = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y

goal (1 subgoal):
 1. T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) + length [] = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) + length [] = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps [] (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) (length (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]))) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) (Strat2 @ [(if x < y in swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n) = x < y in mtf2 (fst (Strat ! n)) (qs ! n) (swaps (snd (Strat ! n)) (steps' init (take n qs) (take n Strat) n)) then 0 else 1, replicate (ALG_P' Strat (take n qs @ [qs ! n]) init n x y) 0 @ sws)]) + length [] = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<exists>Strat2 sws. length Strat2 = length (Lxy (take (Suc n) qs) {x, y}) \<and> x < y in steps' init (take (Suc n) qs) (take (Suc n) Strat) (Suc n) = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take (Suc n) qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take (Suc n) qs) init x y + ALG_Pxy Strat (take (Suc n) qs) init x y

goal (1 subgoal):
 1. \<lbrakk>T\<^sub>p init qs Strat = T\<^sub>p_opt init qs; length Strat = length qs; 0 \<le> length qs; x \<noteq> y; x \<in> set init; y \<in> set init; distinct init; set qs \<subseteq> set init\<rbrakk> \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take 0 qs) {x, y}) \<and> x < y in steps' init (take 0 qs) (take 0 Strat) 0 = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take 0 qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take 0 qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take 0 qs) init x y + ALG_Pxy Strat (take 0 qs) init x y
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<lbrakk>T\<^sub>p init qs Strat = T\<^sub>p_opt init qs; length Strat = length qs; 0 \<le> length qs; x \<noteq> y; x \<in> set init; y \<in> set init; distinct init; set qs \<subseteq> set init\<rbrakk> \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take 0 qs) {x, y}) \<and> x < y in steps' init (take 0 qs) (take 0 Strat) 0 = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take 0 qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take 0 qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take 0 qs) init x y + ALG_Pxy Strat (take 0 qs) init x y
[PROOF STEP]
case 0
[PROOF STATE]
proof (state)
this:
T\<^sub>p init qs Strat = T\<^sub>p_opt init qs
length Strat = length qs
0 \<le> length qs
x \<noteq> y
x \<in> set init
y \<in> set init
distinct init
set qs \<subseteq> set init

goal (1 subgoal):
 1. \<lbrakk>T\<^sub>p init qs Strat = T\<^sub>p_opt init qs; length Strat = length qs; 0 \<le> length qs; x \<noteq> y; x \<in> set init; y \<in> set init; distinct init; set qs \<subseteq> set init\<rbrakk> \<Longrightarrow> \<exists>Strat2 sws. length Strat2 = length (Lxy (take 0 qs) {x, y}) \<and> x < y in steps' init (take 0 qs) (take 0 Strat) 0 = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take 0 qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take 0 qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take 0 qs) init x y + ALG_Pxy Strat (take 0 qs) init x y
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
T\<^sub>p init qs Strat = T\<^sub>p_opt init qs
length Strat = length qs
0 \<le> length qs
x \<noteq> y
x \<in> set init
y \<in> set init
distinct init
set qs \<subseteq> set init
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
T\<^sub>p init qs Strat = T\<^sub>p_opt init qs
length Strat = length qs
0 \<le> length qs
x \<noteq> y
x \<in> set init
y \<in> set init
distinct init
set qs \<subseteq> set init

goal (1 subgoal):
 1. \<exists>Strat2 sws. length Strat2 = length (Lxy (take 0 qs) {x, y}) \<and> x < y in steps' init (take 0 qs) (take 0 Strat) 0 = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take 0 qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take 0 qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take 0 qs) init x y + ALG_Pxy Strat (take 0 qs) init x y
[PROOF STEP]
apply (simp add: Lxy_def ALGxy_det_def ALG_Pxy_def T_opt_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>T\<^sub>p init qs Strat = \<Sqinter> {T\<^sub>p init qs as |as. length as = length qs}; length Strat = length qs; x \<noteq> y; x \<in> set init; y \<in> set init; distinct init; set qs \<subseteq> set init\<rbrakk> \<Longrightarrow> x < y in init = x < y in filter (\<lambda>z. z = x \<or> z = y) init
[PROOF STEP]
proof goal_cases
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<lbrakk>T\<^sub>p init qs Strat = \<Sqinter> {T\<^sub>p init qs as |as. length as = length qs}; length Strat = length qs; x \<noteq> y; x \<in> set init; y \<in> set init; distinct init; set qs \<subseteq> set init\<rbrakk> \<Longrightarrow> x < y in init = x < y in filter (\<lambda>z. z = x \<or> z = y) init
[PROOF STEP]
case 1
[PROOF STATE]
proof (state)
this:
T\<^sub>p init qs Strat = \<Sqinter> {T\<^sub>p init qs as |as. length as = length qs}
length Strat = length qs
x \<noteq> y
x \<in> set init
y \<in> set init
distinct init
set qs \<subseteq> set init

goal (1 subgoal):
 1. \<lbrakk>T\<^sub>p init qs Strat = \<Sqinter> {T\<^sub>p init qs as |as. length as = length qs}; length Strat = length qs; x \<noteq> y; x \<in> set init; y \<in> set init; distinct init; set qs \<subseteq> set init\<rbrakk> \<Longrightarrow> x < y in init = x < y in filter (\<lambda>z. z = x \<or> z = y) init
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x < y in init = x < y in filter (\<lambda>z. z = x \<or> z = y) init
[PROOF STEP]
apply(rule Lxy_mono[unfolded Lxy_def, simplified])
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. x \<in> set init \<and> y \<in> set init
 2. distinct init
[PROOF STEP]
using 1
[PROOF STATE]
proof (prove)
using this:
T\<^sub>p init qs Strat = \<Sqinter> {T\<^sub>p init qs as |as. length as = length qs}
length Strat = length qs
x \<noteq> y
x \<in> set init
y \<in> set init
distinct init
set qs \<subseteq> set init

goal (2 subgoals):
 1. x \<in> set init \<and> y \<in> set init
 2. distinct init
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
x < y in init = x < y in filter (\<lambda>z. z = x \<or> z = y) init

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<exists>Strat2 sws. length Strat2 = length (Lxy (take 0 qs) {x, y}) \<and> x < y in steps' init (take 0 qs) (take 0 Strat) 0 = x < y in swaps sws (steps' (Lxy init {x, y}) (Lxy (take 0 qs) {x, y}) Strat2 (length Strat2)) \<and> T\<^sub>p (Lxy init {x, y}) (Lxy (take 0 qs) {x, y}) Strat2 + length sws = ALGxy_det Strat (take 0 qs) init x y + ALG_Pxy Strat (take 0 qs) init x y

goal:
No subgoals!
[PROOF STEP]
qed