[STATEMENT]
lemma LIM_fun_not_zero: "f \<midarrow>c\<rightarrow> l \<Longrightarrow> l \<noteq> 0 \<Longrightarrow> \<exists>r. 0 < r \<and> (\<forall>x. x \<noteq> c \<and> \<bar>c - x\<bar> < r \<longrightarrow> f x \<noteq> 0)"
  for f :: "real \<Rightarrow> real"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>f \<midarrow>c\<rightarrow> l; l \<noteq> 0\<rbrakk> \<Longrightarrow> \<exists>r>0. \<forall>x. x \<noteq> c \<and> \<bar>c - x\<bar> < r \<longrightarrow> f x \<noteq> 0
[PROOF STEP]
using LIM_fun_gt_zero[of f l c] LIM_fun_less_zero[of f l c]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>f \<midarrow>c\<rightarrow> l; 0 < l\<rbrakk> \<Longrightarrow> \<exists>r>0. \<forall>x. x \<noteq> c \<and> \<bar>c - x\<bar> < r \<longrightarrow> 0 < f x
\<lbrakk>f \<midarrow>c\<rightarrow> l; l < 0\<rbrakk> \<Longrightarrow> \<exists>r>0. \<forall>x. x \<noteq> c \<and> \<bar>c - x\<bar> < r \<longrightarrow> f x < 0

goal (1 subgoal):
 1. \<lbrakk>f \<midarrow>c\<rightarrow> l; l \<noteq> 0\<rbrakk> \<Longrightarrow> \<exists>r>0. \<forall>x. x \<noteq> c \<and> \<bar>c - x\<bar> < r \<longrightarrow> f x \<noteq> 0
[PROOF STEP]
by (auto simp: neq_iff)


[STATEMENT]
lemma float_sub:
  fixes a b::"('e, 'f)float"
  assumes "is_finite a"
    and "is_finite b"
    and threshold: "\<bar>valof a - valof b\<bar> < threshold TYPE(('e, 'f)float)"
  shows finite_float_sub: "is_finite (a - b)"
    and error_float_sub: "valof (a - b) = valof a - valof b + error TYPE(('e, 'f)float) (valof a - valof b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. is_finite (a - b) &&& valof (a - b) = valof a - valof b + error TYPE(('e, 'f) IEEE.float) (valof a - valof b)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. is_finite (a - b)
 2. valof (a - b) = valof a - valof b + error TYPE(('e, 'f) IEEE.float) (valof a - valof b)
[PROOF STEP]
have "\<not> is_nan a" and "\<not> is_nan b" and "\<not> is_infinity a" and "\<not> is_infinity b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<not> is_nan a &&& \<not> is_nan b) &&& \<not> is_infinity a &&& \<not> is_infinity b
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
is_finite a
is_finite b
\<bar>valof a - valof b\<bar> < threshold TYPE(('e, 'f) IEEE.float)

goal (1 subgoal):
 1. (\<not> is_nan a &&& \<not> is_nan b) &&& \<not> is_infinity a &&& \<not> is_infinity b
[PROOF STEP]
by (auto simp: finite_nan finite_infinity)
[PROOF STATE]
proof (state)
this:
\<not> is_nan a
\<not> is_nan b
\<not> is_infinity a
\<not> is_infinity b

goal (2 subgoals):
 1. is_finite (a - b)
 2. valof (a - b) = valof a - valof b + error TYPE(('e, 'f) IEEE.float) (valof a - valof b)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<not> is_nan a
\<not> is_nan b
\<not> is_infinity a
\<not> is_infinity b
[PROOF STEP]
have ab: "a - b =
    (zerosign
      (if is_zero a \<and> is_zero b \<and> sign a \<noteq> sign b then sign a else 0)
      (round To_nearest (valof a - valof b)))"
[PROOF STATE]
proof (prove)
using this:
\<not> is_nan a
\<not> is_nan b
\<not> is_infinity a
\<not> is_infinity b

goal (1 subgoal):
 1. a - b = zerosign (if is_zero a \<and> is_zero b \<and> sign a \<noteq> sign b then sign a else 0) (IEEE.round To_nearest (valof a - valof b))
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
\<not> is_nan a
\<not> is_nan b
\<not> is_infinity a
\<not> is_infinity b
is_finite a
is_finite b
\<bar>valof a - valof b\<bar> < threshold TYPE(('e, 'f) IEEE.float)

goal (1 subgoal):
 1. a - b = zerosign (if is_zero a \<and> is_zero b \<and> sign a \<noteq> sign b then sign a else 0) (IEEE.round To_nearest (valof a - valof b))
[PROOF STEP]
by (auto simp add: float_defs fsub_def minus_float_def)
[PROOF STATE]
proof (state)
this:
a - b = zerosign (if is_zero a \<and> is_zero b \<and> sign a \<noteq> sign b then sign a else 0) (IEEE.round To_nearest (valof a - valof b))

goal (2 subgoals):
 1. is_finite (a - b)
 2. valof (a - b) = valof a - valof b + error TYPE(('e, 'f) IEEE.float) (valof a - valof b)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
a - b = zerosign (if is_zero a \<and> is_zero b \<and> sign a \<noteq> sign b then sign a else 0) (IEEE.round To_nearest (valof a - valof b))
[PROOF STEP]
show "is_finite (a - b)"
[PROOF STATE]
proof (prove)
using this:
a - b = zerosign (if is_zero a \<and> is_zero b \<and> sign a \<noteq> sign b then sign a else 0) (IEEE.round To_nearest (valof a - valof b))

goal (1 subgoal):
 1. is_finite (a - b)
[PROOF STEP]
by (metis threshold defloat_float_zerosign_round_finite)
[PROOF STATE]
proof (state)
this:
is_finite (a - b)

goal (1 subgoal):
 1. valof (a - b) = valof a - valof b + error TYPE(('e, 'f) IEEE.float) (valof a - valof b)
[PROOF STEP]
have val_ab: "valof (a - b) =
    valof (zerosign
      (if is_zero a \<and> is_zero b \<and> sign a \<noteq> sign b then sign a else 0)
      (round To_nearest (valof a - valof b)::('e, 'f)float))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. valof (a - b) = valof (zerosign (if is_zero a \<and> is_zero b \<and> sign a \<noteq> sign b then sign a else 0) (IEEE.round To_nearest (valof a - valof b)))
[PROOF STEP]
by (auto simp: ab is_infinity_def is_nan_def valof_def)
[PROOF STATE]
proof (state)
this:
valof (a - b) = valof (zerosign (if is_zero a \<and> is_zero b \<and> sign a \<noteq> sign b then sign a else 0) (IEEE.round To_nearest (valof a - valof b)))

goal (1 subgoal):
 1. valof (a - b) = valof a - valof b + error TYPE(('e, 'f) IEEE.float) (valof a - valof b)
[PROOF STEP]
show "valof (a - b) = valof a - valof b + error TYPE(('e, 'f)float) (valof a - valof b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. valof (a - b) = valof a - valof b + error TYPE(('e, 'f) IEEE.float) (valof a - valof b)
[PROOF STEP]
proof (cases "is_zero (round To_nearest (valof a - valof b)::('e, 'f)float)")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. is_zero (IEEE.round To_nearest (valof a - valof b)) \<Longrightarrow> valof (a - b) = valof a - valof b + error TYPE(('e, 'f) IEEE.float) (valof a - valof b)
 2. \<not> is_zero (IEEE.round To_nearest (valof a - valof b)) \<Longrightarrow> valof (a - b) = valof a - valof b + error TYPE(('e, 'f) IEEE.float) (valof a - valof b)
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
is_zero (IEEE.round To_nearest (valof a - valof b))

goal (2 subgoals):
 1. is_zero (IEEE.round To_nearest (valof a - valof b)) \<Longrightarrow> valof (a - b) = valof a - valof b + error TYPE(('e, 'f) IEEE.float) (valof a - valof b)
 2. \<not> is_zero (IEEE.round To_nearest (valof a - valof b)) \<Longrightarrow> valof (a - b) = valof a - valof b + error TYPE(('e, 'f) IEEE.float) (valof a - valof b)
[PROOF STEP]
have "valof a - valof b + error TYPE(('e, 'f)float) (valof a - valof b) =
        valof (round To_nearest (valof a - valof b)::('e, 'f)float)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. valof a - valof b + error TYPE(('e, 'f) IEEE.float) (valof a - valof b) = valof (IEEE.round To_nearest (valof a - valof b))
[PROOF STEP]
unfolding error_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. valof a - valof b + (valof (IEEE.round To_nearest (valof a - valof b)) - (valof a - valof b)) = valof (IEEE.round To_nearest (valof a - valof b))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
valof a - valof b + error TYPE(('e, 'f) IEEE.float) (valof a - valof b) = valof (IEEE.round To_nearest (valof a - valof b))

goal (2 subgoals):
 1. is_zero (IEEE.round To_nearest (valof a - valof b)) \<Longrightarrow> valof (a - b) = valof a - valof b + error TYPE(('e, 'f) IEEE.float) (valof a - valof b)
 2. \<not> is_zero (IEEE.round To_nearest (valof a - valof b)) \<Longrightarrow> valof (a - b) = valof a - valof b + error TYPE(('e, 'f) IEEE.float) (valof a - valof b)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
valof a - valof b + error TYPE(('e, 'f) IEEE.float) (valof a - valof b) = valof (IEEE.round To_nearest (valof a - valof b))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
valof a - valof b + error TYPE(('e, 'f) IEEE.float) (valof a - valof b) = valof (IEEE.round To_nearest (valof a - valof b))

goal (1 subgoal):
 1. valof (a - b) = valof a - valof b + error TYPE(('e, 'f) IEEE.float) (valof a - valof b)
[PROOF STEP]
by (metis True signzero_zero val_zero val_ab)
[PROOF STATE]
proof (state)
this:
valof (a - b) = valof a - valof b + error TYPE(('e, 'f) IEEE.float) (valof a - valof b)

goal (1 subgoal):
 1. \<not> is_zero (IEEE.round To_nearest (valof a - valof b)) \<Longrightarrow> valof (a - b) = valof a - valof b + error TYPE(('e, 'f) IEEE.float) (valof a - valof b)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> is_zero (IEEE.round To_nearest (valof a - valof b)) \<Longrightarrow> valof (a - b) = valof a - valof b + error TYPE(('e, 'f) IEEE.float) (valof a - valof b)
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> is_zero (IEEE.round To_nearest (valof a - valof b))

goal (1 subgoal):
 1. \<not> is_zero (IEEE.round To_nearest (valof a - valof b)) \<Longrightarrow> valof (a - b) = valof a - valof b + error TYPE(('e, 'f) IEEE.float) (valof a - valof b)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<not> is_zero (IEEE.round To_nearest (valof a - valof b))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<not> is_zero (IEEE.round To_nearest (valof a - valof b))

goal (1 subgoal):
 1. valof (a - b) = valof a - valof b + error TYPE(('e, 'f) IEEE.float) (valof a - valof b)
[PROOF STEP]
by (metis ab add.commute eq_diff_eq' error_def zerosign_def)
[PROOF STATE]
proof (state)
this:
valof (a - b) = valof a - valof b + error TYPE(('e, 'f) IEEE.float) (valof a - valof b)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
valof (a - b) = valof a - valof b + error TYPE(('e, 'f) IEEE.float) (valof a - valof b)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma vec_cmul: "vec(c * x) = c *s vec x "
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vec (c * x) = c *s vec x
[PROOF STEP]
by vector


[STATEMENT]
lemma deg_of_strict_monoI: "x < y \<Longrightarrow> deg_of x < deg_of y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x < y \<Longrightarrow> deg_of x < deg_of y
[PROOF STEP]
by (auto simp: deg_of_def intro!: divide_strict_right_mono)


[STATEMENT]
lemma pmf_Pn_pair:
  assumes "sa \<in> set_pmf (Pn p S0 n)"
  shows "pmf (Pn p S0 n) sa = pmf (Y_cond_X p S0 n (fst sa)) (snd sa) * pmf (Xn p S0 n) (fst sa)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. pmf (Pn p S0 n) sa = pmf (Y_cond_X p S0 n (fst sa)) (snd sa) * pmf (Xn p S0 n) (fst sa)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. pmf (Pn p S0 n) sa = pmf (Y_cond_X p S0 n (fst sa)) (snd sa) * pmf (Xn p S0 n) (fst sa)
[PROOF STEP]
have aux: "set_pmf (Pn p S0 n) \<inter> {(s, a). s = fst sa} \<noteq> {}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set_pmf (Pn p S0 n) \<inter> {(s, a). s = fst sa} \<noteq> {}
[PROOF STEP]
using Xn_def assms
[PROOF STATE]
proof (prove)
using this:
Xn ?p ?S0.0 ?n = map_pmf fst (Pn ?p ?S0.0 ?n)
sa \<in> set_pmf (Pn p S0 n)

goal (1 subgoal):
 1. set_pmf (Pn p S0 n) \<inter> {(s, a). s = fst sa} \<noteq> {}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
set_pmf (Pn p S0 n) \<inter> {(s, a). s = fst sa} \<noteq> {}

goal (1 subgoal):
 1. pmf (Pn p S0 n) sa = pmf (Y_cond_X p S0 n (fst sa)) (snd sa) * pmf (Xn p S0 n) (fst sa)
[PROOF STEP]
have aux': "({(s, a). s = fst sa} \<inter> snd -` {snd sa}) = {sa}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {(s, a). s = fst sa} \<inter> snd -` {snd sa} = {sa}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
{(s, a). s = fst sa} \<inter> snd -` {snd sa} = {sa}

goal (1 subgoal):
 1. pmf (Pn p S0 n) sa = pmf (Y_cond_X p S0 n (fst sa)) (snd sa) * pmf (Xn p S0 n) (fst sa)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. pmf (Pn p S0 n) sa = pmf (Y_cond_X p S0 n (fst sa)) (snd sa) * pmf (Xn p S0 n) (fst sa)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
sa \<in> set_pmf (Pn p S0 n)

goal (1 subgoal):
 1. pmf (Pn p S0 n) sa = pmf (Y_cond_X p S0 n (fst sa)) (snd sa) * pmf (Xn p S0 n) (fst sa)
[PROOF STEP]
unfolding Y_cond_X_def pmf_map cond_pmf.rep_eq[OF aux]
[PROOF STATE]
proof (prove)
using this:
sa \<in> set_pmf (Pn p S0 n)

goal (1 subgoal):
 1. pmf (Pn p S0 n) sa = Sigma_Algebra.measure (uniform_measure (measure_pmf (Pn p S0 n)) {(s, a). s = fst sa}) (snd -` {snd sa}) * pmf (Xn p S0 n) (fst sa)
[PROOF STEP]
by (auto simp: Xn_def pmf_eq_0_set_pmf measure_pmf.emeasure_eq_measure aux' measure_pmf_single)
[PROOF STATE]
proof (state)
this:
pmf (Pn p S0 n) sa = pmf (Y_cond_X p S0 n (fst sa)) (snd sa) * pmf (Xn p S0 n) (fst sa)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma Card_order_Un1:
shows "Card_order r \<Longrightarrow> |Field r| \<le>o |(Field r) \<union> B| "
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Card_order r \<Longrightarrow> |Field r| \<le>o |Field r \<union> B|
[PROOF STEP]
using card_of_Un1 card_of_Field_ordIso ordIso_symmetric ordIso_ordLeq_trans
[PROOF STATE]
proof (prove)
using this:
|?A| \<le>o |?A \<union> ?B|
Card_order ?r \<Longrightarrow> |Field ?r| =o ?r
?r =o ?r' \<Longrightarrow> ?r' =o ?r
\<lbrakk>?r =o ?r'; ?r' \<le>o ?r''\<rbrakk> \<Longrightarrow> ?r \<le>o ?r''

goal (1 subgoal):
 1. Card_order r \<Longrightarrow> |Field r| \<le>o |Field r \<union> B|
[PROOF STEP]
by auto


[STATEMENT]
lemma vec_extensionality:"(\<And>i. v$i = w$i) \<Longrightarrow> (v = w)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>i. v $ i = w $ i) \<Longrightarrow> v = w
[PROOF STEP]
by (simp add: vec_eq_iff)


[STATEMENT]
lemma Vset_Transset: "Ord m \<Longrightarrow> Transset (Vset m)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Ord m \<Longrightarrow> Transset (Vset m)
[PROOF STEP]
by (induct rule: Ord_induct2) (auto simp: Transset_def)


[STATEMENT]
lemma openin_product_topology:
   "openin (product_topology X I) =
    arbitrary union_of
          ((finite intersection_of (\<lambda>F. (\<exists>i U. F = {f. f i \<in> U} \<and> i \<in> I \<and> openin (X i) U)))
           relative_to topspace (product_topology X I))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. openin (product_topology X I) = arbitrary union_of (finite intersection_of (\<lambda>F. \<exists>i U. F = {f. f i \<in> U} \<and> i \<in> I \<and> openin (X i) U) relative_to topspace (product_topology X I))
[PROOF STEP]
apply (subst product_topology)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. openin (topology (arbitrary union_of (finite intersection_of (\<lambda>F. \<exists>i U. F = {f. f i \<in> U} \<and> i \<in> I \<and> openin (X i) U) relative_to (\<Pi>\<^sub>E i\<in>I. topspace (X i))))) = arbitrary union_of (finite intersection_of (\<lambda>F. \<exists>i U. F = {f. f i \<in> U} \<and> i \<in> I \<and> openin (X i) U) relative_to topspace (product_topology X I))
[PROOF STEP]
apply (simp add: topology_inverse' [OF istopology_subbase])
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma hypext_inverse_Hyperdual_parts:
  "a \<noteq> 0 \<Longrightarrow>
    (*h* inverse) (a *\<^sub>H ba + b *\<^sub>H e1 + c *\<^sub>H e2 + d *\<^sub>H e12) =
    inverse a *\<^sub>H ba + - (b / a\<^sup>2) *\<^sub>H e1 + - (c / a\<^sup>2) *\<^sub>H e2 + (2 * b * c / a ^ 3 - d / a\<^sup>2) *\<^sub>H e12"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a \<noteq> (0::'a) \<Longrightarrow> (*h* inverse) (a *\<^sub>H ba + b *\<^sub>H e1 + c *\<^sub>H e2 + d *\<^sub>H e12) = inverse a *\<^sub>H ba + - (b / a\<^sup>2) *\<^sub>H e1 + - (c / a\<^sup>2) *\<^sub>H e2 + ((2::'a) * b * c / a ^ 3 - d / a\<^sup>2) *\<^sub>H e12
[PROOF STEP]
by (metis Hyperdual_eq hypext_inverse_Hyperdual)


[STATEMENT]
lemma nths_weave:
assumes "length xs = card {a\<in>A. a < length xs + length ys}"
assumes "length ys = card {a\<in>(-A). a < length xs + length ys}"
shows "nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (-A) = ys"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
length xs = card {a \<in> A. a < length xs + length ys}
length ys = card {a \<in> - A. a < length xs + length ys}

goal (1 subgoal):
 1. nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
[PROOF STEP]
proof (induction "length xs + length ys" arbitrary: xs ys)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>xs ys. \<lbrakk>0 = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
 2. \<And>x xs ys. \<lbrakk>\<And>xs ys. \<lbrakk>x = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc x = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
[PROOF STEP]
case 0
[PROOF STATE]
proof (state)
this:
0 = length xs + length ys
length xs = card {a \<in> A. a < length xs + length ys}
length ys = card {a \<in> - A. a < length xs + length ys}

goal (2 subgoals):
 1. \<And>xs ys. \<lbrakk>0 = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
 2. \<And>x xs ys. \<lbrakk>\<And>xs ys. \<lbrakk>x = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc x = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
0 = length xs + length ys
length xs = card {a \<in> A. a < length xs + length ys}
length ys = card {a \<in> - A. a < length xs + length ys}
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
0 = length xs + length ys
length xs = card {a \<in> A. a < length xs + length ys}
length ys = card {a \<in> - A. a < length xs + length ys}

goal (1 subgoal):
 1. nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
[PROOF STEP]
unfolding weave_def nths_map
[PROOF STATE]
proof (prove)
using this:
0 = length xs + length ys
length xs = card {a \<in> A. a < length xs + length ys}
length ys = card {a \<in> - A. a < length xs + length ys}

goal (1 subgoal):
 1. map (\<lambda>i. if i \<in> A then xs ! card {a \<in> A. a < i} else ys ! card {a \<in> - A. a < i}) (nths [0..<length xs + length ys] A) = xs \<and> map (\<lambda>i. if i \<in> A then xs ! card {a \<in> A. a < i} else ys ! card {a \<in> - A. a < i}) (nths [0..<length xs + length ys] (- A)) = ys
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys

goal (1 subgoal):
 1. \<And>x xs ys. \<lbrakk>\<And>xs ys. \<lbrakk>x = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc x = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x xs ys. \<lbrakk>\<And>xs ys. \<lbrakk>x = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc x = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
[PROOF STEP]
case (Suc l)
[PROOF STATE]
proof (state)
this:
\<lbrakk>l = length ?xs + length ?ys; length ?xs = card {a \<in> A. a < length ?xs + length ?ys}; length ?ys = card {a \<in> - A. a < length ?xs + length ?ys}\<rbrakk> \<Longrightarrow> nths (weave A ?xs ?ys) A = ?xs \<and> nths (weave A ?xs ?ys) (- A) = ?ys
Suc l = length xs + length ys
length xs = card {a \<in> A. a < length xs + length ys}
length ys = card {a \<in> - A. a < length xs + length ys}

goal (1 subgoal):
 1. \<And>x xs ys. \<lbrakk>\<And>xs ys. \<lbrakk>x = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc x = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>l = length ?xs + length ?ys; length ?xs = card {a \<in> A. a < length ?xs + length ?ys}; length ?ys = card {a \<in> - A. a < length ?xs + length ?ys}\<rbrakk> \<Longrightarrow> nths (weave A ?xs ?ys) A = ?xs \<and> nths (weave A ?xs ?ys) (- A) = ?ys
Suc l = length xs + length ys
length xs = card {a \<in> A. a < length xs + length ys}
length ys = card {a \<in> - A. a < length xs + length ys}
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>l = length ?xs + length ?ys; length ?xs = card {a \<in> A. a < length ?xs + length ?ys}; length ?ys = card {a \<in> - A. a < length ?xs + length ?ys}\<rbrakk> \<Longrightarrow> nths (weave A ?xs ?ys) A = ?xs \<and> nths (weave A ?xs ?ys) (- A) = ?ys
Suc l = length xs + length ys
length xs = card {a \<in> A. a < length xs + length ys}
length ys = card {a \<in> - A. a < length xs + length ys}

goal (1 subgoal):
 1. nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
[PROOF STEP]
proof (cases "l\<in>A")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<lbrakk>\<And>xs ys. \<lbrakk>l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}; l \<in> A\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
 2. \<lbrakk>\<And>xs ys. \<lbrakk>l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}; l \<notin> A\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
l \<in> A

goal (2 subgoals):
 1. \<lbrakk>\<And>xs ys. \<lbrakk>l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}; l \<in> A\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
 2. \<lbrakk>\<And>xs ys. \<lbrakk>l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}; l \<notin> A\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
l \<in> A
[PROOF STEP]
have "l\<in>{a \<in> A. a < length xs + length ys}"
[PROOF STATE]
proof (prove)
using this:
l \<in> A

goal (1 subgoal):
 1. l \<in> {a \<in> A. a < length xs + length ys}
[PROOF STEP]
using Suc.hyps mem_Collect_eq zero_less_Suc
[PROOF STATE]
proof (prove)
using this:
l \<in> A
\<lbrakk>l = length ?xs + length ?ys; length ?xs = card {a \<in> A. a < length ?xs + length ?ys}; length ?ys = card {a \<in> - A. a < length ?xs + length ?ys}\<rbrakk> \<Longrightarrow> nths (weave A ?xs ?ys) A = ?xs \<and> nths (weave A ?xs ?ys) (- A) = ?ys
Suc l = length xs + length ys
(?a \<in> Collect ?P) = ?P ?a
0 < Suc ?n

goal (1 subgoal):
 1. l \<in> {a \<in> A. a < length xs + length ys}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
l \<in> {a \<in> A. a < length xs + length ys}

goal (2 subgoals):
 1. \<lbrakk>\<And>xs ys. \<lbrakk>l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}; l \<in> A\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
 2. \<lbrakk>\<And>xs ys. \<lbrakk>l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}; l \<notin> A\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
l \<in> {a \<in> A. a < length xs + length ys}
[PROOF STEP]
have "length xs > 0"
[PROOF STATE]
proof (prove)
using this:
l \<in> {a \<in> A. a < length xs + length ys}

goal (1 subgoal):
 1. 0 < length xs
[PROOF STEP]
using Suc
[PROOF STATE]
proof (prove)
using this:
l \<in> {a \<in> A. a < length xs + length ys}
\<lbrakk>l = length ?xs + length ?ys; length ?xs = card {a \<in> A. a < length ?xs + length ?ys}; length ?ys = card {a \<in> - A. a < length ?xs + length ?ys}\<rbrakk> \<Longrightarrow> nths (weave A ?xs ?ys) A = ?xs \<and> nths (weave A ?xs ?ys) (- A) = ?ys
Suc l = length xs + length ys
length xs = card {a \<in> A. a < length xs + length ys}
length ys = card {a \<in> - A. a < length xs + length ys}

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

goal (2 subgoals):
 1. \<lbrakk>\<And>xs ys. \<lbrakk>l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}; l \<in> A\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
 2. \<lbrakk>\<And>xs ys. \<lbrakk>l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}; l \<notin> A\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
0 < length xs
[PROOF STEP]
obtain xs' x where "xs = xs' @ [x]"
[PROOF STATE]
proof (prove)
using this:
0 < length xs

goal (1 subgoal):
 1. (\<And>xs' x. xs = xs' @ [x] \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (metis append_butlast_last_id length_greater_0_conv)
[PROOF STATE]
proof (state)
this:
xs = xs' @ [x]

goal (2 subgoals):
 1. \<lbrakk>\<And>xs ys. \<lbrakk>l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}; l \<in> A\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
 2. \<lbrakk>\<And>xs ys. \<lbrakk>l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}; l \<notin> A\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
xs = xs' @ [x]
[PROOF STEP]
have "l = length xs' + length ys"
[PROOF STATE]
proof (prove)
using this:
xs = xs' @ [x]

goal (1 subgoal):
 1. l = length xs' + length ys
[PROOF STEP]
using Suc.hyps
[PROOF STATE]
proof (prove)
using this:
xs = xs' @ [x]
\<lbrakk>l = length ?xs + length ?ys; length ?xs = card {a \<in> A. a < length ?xs + length ?ys}; length ?ys = card {a \<in> - A. a < length ?xs + length ?ys}\<rbrakk> \<Longrightarrow> nths (weave A ?xs ?ys) A = ?xs \<and> nths (weave A ?xs ?ys) (- A) = ?ys
Suc l = length xs + length ys

goal (1 subgoal):
 1. l = length xs' + length ys
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
l = length xs' + length ys

goal (2 subgoals):
 1. \<lbrakk>\<And>xs ys. \<lbrakk>l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}; l \<in> A\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
 2. \<lbrakk>\<And>xs ys. \<lbrakk>l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}; l \<notin> A\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
[PROOF STEP]
have length_xs':"length xs' = card {a \<in> A. a < length xs' + length ys}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length xs' = card {a \<in> A. a < length xs' + length ys}
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. length xs' = card {a \<in> A. a < length xs' + length ys}
[PROOF STEP]
have "{a \<in> A. a < length xs + length ys} = {a \<in> A. a < length xs' + length ys} \<union> {l}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {a \<in> A. a < length xs + length ys} = {a \<in> A. a < length xs' + length ys} \<union> {l}
[PROOF STEP]
using \<open>xs = xs' @ [x]\<close> \<open>l\<in>{a \<in> A. a < length xs + length ys}\<close> \<open>l = length xs' + length ys\<close>
[PROOF STATE]
proof (prove)
using this:
xs = xs' @ [x]
l \<in> {a \<in> A. a < length xs + length ys}
l = length xs' + length ys

goal (1 subgoal):
 1. {a \<in> A. a < length xs + length ys} = {a \<in> A. a < length xs' + length ys} \<union> {l}
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
{a \<in> A. a < length xs + length ys} = {a \<in> A. a < length xs' + length ys} \<union> {l}

goal (1 subgoal):
 1. length xs' = card {a \<in> A. a < length xs' + length ys}
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
{a \<in> A. a < length xs + length ys} = {a \<in> A. a < length xs' + length ys} \<union> {l}
[PROOF STEP]
have "card {a \<in> A. a < length xs + length ys} = card {a \<in> A. a < length xs' + length ys} + 1"
[PROOF STATE]
proof (prove)
using this:
{a \<in> A. a < length xs + length ys} = {a \<in> A. a < length xs' + length ys} \<union> {l}

goal (1 subgoal):
 1. card {a \<in> A. a < length xs + length ys} = card {a \<in> A. a < length xs' + length ys} + 1
[PROOF STEP]
using \<open>l = length xs' + length ys\<close>
[PROOF STATE]
proof (prove)
using this:
{a \<in> A. a < length xs + length ys} = {a \<in> A. a < length xs' + length ys} \<union> {l}
l = length xs' + length ys

goal (1 subgoal):
 1. card {a \<in> A. a < length xs + length ys} = card {a \<in> A. a < length xs' + length ys} + 1
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
card {a \<in> A. a < length xs + length ys} = card {a \<in> A. a < length xs' + length ys} + 1

goal (1 subgoal):
 1. length xs' = card {a \<in> A. a < length xs' + length ys}
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
card {a \<in> A. a < length xs + length ys} = card {a \<in> A. a < length xs' + length ys} + 1
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
card {a \<in> A. a < length xs + length ys} = card {a \<in> A. a < length xs' + length ys} + 1

goal (1 subgoal):
 1. length xs' = card {a \<in> A. a < length xs' + length ys}
[PROOF STEP]
by (metis One_nat_def Suc.prems(1) \<open>xs = xs' @ [x]\<close> add_right_imp_eq
        length_Cons length_append list.size(3))
[PROOF STATE]
proof (state)
this:
length xs' = card {a \<in> A. a < length xs' + length ys}

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
length xs' = card {a \<in> A. a < length xs' + length ys}

goal (2 subgoals):
 1. \<lbrakk>\<And>xs ys. \<lbrakk>l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}; l \<in> A\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
 2. \<lbrakk>\<And>xs ys. \<lbrakk>l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}; l \<notin> A\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
[PROOF STEP]
have length_ys:"length ys = card {a \<in> - A. a < length xs' + length ys}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length ys = card {a \<in> - A. a < length xs' + length ys}
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. length ys = card {a \<in> - A. a < length xs' + length ys}
[PROOF STEP]
have "l\<notin>{a \<in> - A. a < length xs + length ys}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. l \<notin> {a \<in> - A. a < length xs + length ys}
[PROOF STEP]
using \<open>l\<in>A\<close> \<open>l = length xs' + length ys\<close>
[PROOF STATE]
proof (prove)
using this:
l \<in> A
l = length xs' + length ys

goal (1 subgoal):
 1. l \<notin> {a \<in> - A. a < length xs + length ys}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
l \<notin> {a \<in> - A. a < length xs + length ys}

goal (1 subgoal):
 1. length ys = card {a \<in> - A. a < length xs' + length ys}
[PROOF STEP]
have "{a \<in> -A. a < length xs + length ys} = {a \<in> -A. a < length xs' + length ys}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {a \<in> - A. a < length xs + length ys} = {a \<in> - A. a < length xs' + length ys}
[PROOF STEP]
apply (rule subset_antisym)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. {a \<in> - A. a < length xs + length ys} \<subseteq> {a \<in> - A. a < length xs' + length ys}
 2. {a \<in> - A. a < length xs' + length ys} \<subseteq> {a \<in> - A. a < length xs + length ys}
[PROOF STEP]
using  \<open>l = length xs' + length ys\<close> \<open>Suc l = length xs + length ys\<close> \<open>l\<notin>{a \<in> - A. a < length xs + length ys}\<close>
[PROOF STATE]
proof (prove)
using this:
l = length xs' + length ys
Suc l = length xs + length ys
l \<notin> {a \<in> - A. a < length xs + length ys}

goal (2 subgoals):
 1. {a \<in> - A. a < length xs + length ys} \<subseteq> {a \<in> - A. a < length xs' + length ys}
 2. {a \<in> - A. a < length xs' + length ys} \<subseteq> {a \<in> - A. a < length xs + length ys}
[PROOF STEP]
apply (metis (no_types, lifting) Collect_mono less_Suc_eq mem_Collect_eq)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {a \<in> - A. a < length xs' + length ys} \<subseteq> {a \<in> - A. a < length xs + length ys}
[PROOF STEP]
using Collect_mono Suc.hyps(2) \<open>l = length xs' + length ys\<close>
[PROOF STATE]
proof (prove)
using this:
(\<And>x. ?P x \<longrightarrow> ?Q x) \<Longrightarrow> Collect ?P \<subseteq> Collect ?Q
Suc l = length xs + length ys
l = length xs' + length ys

goal (1 subgoal):
 1. {a \<in> - A. a < length xs' + length ys} \<subseteq> {a \<in> - A. a < length xs + length ys}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
{a \<in> - A. a < length xs + length ys} = {a \<in> - A. a < length xs' + length ys}

goal (1 subgoal):
 1. length ys = card {a \<in> - A. a < length xs' + length ys}
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
{a \<in> - A. a < length xs + length ys} = {a \<in> - A. a < length xs' + length ys}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
{a \<in> - A. a < length xs + length ys} = {a \<in> - A. a < length xs' + length ys}

goal (1 subgoal):
 1. length ys = card {a \<in> - A. a < length xs' + length ys}
[PROOF STEP]
using Suc.prems(2)
[PROOF STATE]
proof (prove)
using this:
{a \<in> - A. a < length xs + length ys} = {a \<in> - A. a < length xs' + length ys}
length ys = card {a \<in> - A. a < length xs + length ys}

goal (1 subgoal):
 1. length ys = card {a \<in> - A. a < length xs' + length ys}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
length ys = card {a \<in> - A. a < length xs' + length ys}

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
length ys = card {a \<in> - A. a < length xs' + length ys}

goal (2 subgoals):
 1. \<lbrakk>\<And>xs ys. \<lbrakk>l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}; l \<in> A\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
 2. \<lbrakk>\<And>xs ys. \<lbrakk>l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}; l \<notin> A\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
[PROOF STEP]
have "length xs' + length ys \<in> A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length xs' + length ys \<in> A
[PROOF STEP]
using \<open>l\<in>A\<close> \<open>l = length xs' + length ys\<close>
[PROOF STATE]
proof (prove)
using this:
l \<in> A
l = length xs' + length ys

goal (1 subgoal):
 1. length xs' + length ys \<in> A
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
length xs' + length ys \<in> A

goal (2 subgoals):
 1. \<lbrakk>\<And>xs ys. \<lbrakk>l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}; l \<in> A\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
 2. \<lbrakk>\<And>xs ys. \<lbrakk>l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}; l \<notin> A\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
length xs' + length ys \<in> A
[PROOF STEP]
have "nths (weave A xs ys) A = nths (weave A xs' ys @ [x]) A"
[PROOF STATE]
proof (prove)
using this:
length xs' + length ys \<in> A

goal (1 subgoal):
 1. nths (weave A xs ys) A = nths (weave A xs' ys @ [x]) A
[PROOF STEP]
unfolding
       \<open>xs = xs' @ [x]\<close>
[PROOF STATE]
proof (prove)
using this:
length xs' + length ys \<in> A

goal (1 subgoal):
 1. nths (weave A (xs' @ [x]) ys) A = nths (weave A xs' ys @ [x]) A
[PROOF STEP]
using weave_append1[OF \<open>length xs' + length ys \<in> A\<close> length_xs']
[PROOF STATE]
proof (prove)
using this:
length xs' + length ys \<in> A
weave A (xs' @ [?x]) ys = weave A xs' ys @ [?x]

goal (1 subgoal):
 1. nths (weave A (xs' @ [x]) ys) A = nths (weave A xs' ys @ [x]) A
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
nths (weave A xs ys) A = nths (weave A xs' ys @ [x]) A

goal (2 subgoals):
 1. \<lbrakk>\<And>xs ys. \<lbrakk>l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}; l \<in> A\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
 2. \<lbrakk>\<And>xs ys. \<lbrakk>l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}; l \<notin> A\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
nths (weave A xs ys) A = nths (weave A xs' ys @ [x]) A

goal (2 subgoals):
 1. \<lbrakk>\<And>xs ys. \<lbrakk>l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}; l \<in> A\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
 2. \<lbrakk>\<And>xs ys. \<lbrakk>l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}; l \<notin> A\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
[PROOF STEP]
have "... = nths (weave A xs' ys) A @ nths [x] {a. a + (length xs' + length ys) \<in> A}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. nths (weave A xs' ys @ [x]) A = nths (weave A xs' ys) A @ nths [x] {a. a + (length xs' + length ys) \<in> A}
[PROOF STEP]
using nths_append length_weave
[PROOF STATE]
proof (prove)
using this:
nths (?l @ ?l') ?A = nths ?l ?A @ nths ?l' {j. j + length ?l \<in> ?A}
length (weave ?A ?xs ?ys) = length ?xs + length ?ys

goal (1 subgoal):
 1. nths (weave A xs' ys @ [x]) A = nths (weave A xs' ys) A @ nths [x] {a. a + (length xs' + length ys) \<in> A}
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
nths (weave A xs' ys @ [x]) A = nths (weave A xs' ys) A @ nths [x] {a. a + (length xs' + length ys) \<in> A}

goal (2 subgoals):
 1. \<lbrakk>\<And>xs ys. \<lbrakk>l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}; l \<in> A\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
 2. \<lbrakk>\<And>xs ys. \<lbrakk>l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}; l \<notin> A\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
nths (weave A xs' ys @ [x]) A = nths (weave A xs' ys) A @ nths [x] {a. a + (length xs' + length ys) \<in> A}

goal (2 subgoals):
 1. \<lbrakk>\<And>xs ys. \<lbrakk>l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}; l \<in> A\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
 2. \<lbrakk>\<And>xs ys. \<lbrakk>l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}; l \<notin> A\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
[PROOF STEP]
have "... = nths (weave A xs' ys) A @ [x]"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. nths (weave A xs' ys) A @ nths [x] {a. a + (length xs' + length ys) \<in> A} = nths (weave A xs' ys) A @ [x]
[PROOF STEP]
using nths_singleton \<open>length xs' + length ys \<in> A\<close>
[PROOF STATE]
proof (prove)
using this:
nths [?x] ?A = (if 0 \<in> ?A then [?x] else [])
length xs' + length ys \<in> A

goal (1 subgoal):
 1. nths (weave A xs' ys) A @ nths [x] {a. a + (length xs' + length ys) \<in> A} = nths (weave A xs' ys) A @ [x]
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
nths (weave A xs' ys) A @ nths [x] {a. a + (length xs' + length ys) \<in> A} = nths (weave A xs' ys) A @ [x]

goal (2 subgoals):
 1. \<lbrakk>\<And>xs ys. \<lbrakk>l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}; l \<in> A\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
 2. \<lbrakk>\<And>xs ys. \<lbrakk>l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}; l \<notin> A\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
nths (weave A xs' ys) A @ nths [x] {a. a + (length xs' + length ys) \<in> A} = nths (weave A xs' ys) A @ [x]

goal (2 subgoals):
 1. \<lbrakk>\<And>xs ys. \<lbrakk>l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}; l \<in> A\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
 2. \<lbrakk>\<And>xs ys. \<lbrakk>l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}; l \<notin> A\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
[PROOF STEP]
have "... = xs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. nths (weave A xs' ys) A @ [x] = xs
[PROOF STEP]
using Suc.hyps(1)[OF \<open>l = length xs' + length ys\<close> length_xs' length_ys]
     \<open>xs = xs' @ [x]\<close>
[PROOF STATE]
proof (prove)
using this:
nths (weave A xs' ys) A = xs' \<and> nths (weave A xs' ys) (- A) = ys
xs = xs' @ [x]

goal (1 subgoal):
 1. nths (weave A xs' ys) A @ [x] = xs
[PROOF STEP]
by presburger
[PROOF STATE]
proof (state)
this:
nths (weave A xs' ys) A @ [x] = xs

goal (2 subgoals):
 1. \<lbrakk>\<And>xs ys. \<lbrakk>l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}; l \<in> A\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
 2. \<lbrakk>\<And>xs ys. \<lbrakk>l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}; l \<notin> A\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
nths (weave A xs ys) A = xs
[PROOF STEP]
have "nths (weave A xs ys) A = xs"
[PROOF STATE]
proof (prove)
using this:
nths (weave A xs ys) A = xs

goal (1 subgoal):
 1. nths (weave A xs ys) A = xs
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
nths (weave A xs ys) A = xs

goal (2 subgoals):
 1. \<lbrakk>\<And>xs ys. \<lbrakk>l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}; l \<in> A\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
 2. \<lbrakk>\<And>xs ys. \<lbrakk>l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}; l \<notin> A\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
[PROOF STEP]
have "nths (weave A xs ys) (-A) = nths (weave A xs' ys @ [x]) (-A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. nths (weave A xs ys) (- A) = nths (weave A xs' ys @ [x]) (- A)
[PROOF STEP]
unfolding
       \<open>xs = xs' @ [x]\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. nths (weave A (xs' @ [x]) ys) (- A) = nths (weave A xs' ys @ [x]) (- A)
[PROOF STEP]
using weave_append1[OF \<open>length xs' + length ys \<in> A\<close> length_xs']
[PROOF STATE]
proof (prove)
using this:
weave A (xs' @ [?x]) ys = weave A xs' ys @ [?x]

goal (1 subgoal):
 1. nths (weave A (xs' @ [x]) ys) (- A) = nths (weave A xs' ys @ [x]) (- A)
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
nths (weave A xs ys) (- A) = nths (weave A xs' ys @ [x]) (- A)

goal (2 subgoals):
 1. \<lbrakk>\<And>xs ys. \<lbrakk>l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}; l \<in> A\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
 2. \<lbrakk>\<And>xs ys. \<lbrakk>l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}; l \<notin> A\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
nths (weave A xs ys) (- A) = nths (weave A xs' ys @ [x]) (- A)

goal (2 subgoals):
 1. \<lbrakk>\<And>xs ys. \<lbrakk>l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}; l \<in> A\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
 2. \<lbrakk>\<And>xs ys. \<lbrakk>l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}; l \<notin> A\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
[PROOF STEP]
have "... = nths (weave A xs' ys) (-A) @ nths [x] {a. a + (length xs' + length ys) \<in> (-A)}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. nths (weave A xs' ys @ [x]) (- A) = nths (weave A xs' ys) (- A) @ nths [x] {a. a + (length xs' + length ys) \<in> - A}
[PROOF STEP]
using nths_append length_weave
[PROOF STATE]
proof (prove)
using this:
nths (?l @ ?l') ?A = nths ?l ?A @ nths ?l' {j. j + length ?l \<in> ?A}
length (weave ?A ?xs ?ys) = length ?xs + length ?ys

goal (1 subgoal):
 1. nths (weave A xs' ys @ [x]) (- A) = nths (weave A xs' ys) (- A) @ nths [x] {a. a + (length xs' + length ys) \<in> - A}
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
nths (weave A xs' ys @ [x]) (- A) = nths (weave A xs' ys) (- A) @ nths [x] {a. a + (length xs' + length ys) \<in> - A}

goal (2 subgoals):
 1. \<lbrakk>\<And>xs ys. \<lbrakk>l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}; l \<in> A\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
 2. \<lbrakk>\<And>xs ys. \<lbrakk>l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}; l \<notin> A\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
nths (weave A xs' ys @ [x]) (- A) = nths (weave A xs' ys) (- A) @ nths [x] {a. a + (length xs' + length ys) \<in> - A}

goal (2 subgoals):
 1. \<lbrakk>\<And>xs ys. \<lbrakk>l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}; l \<in> A\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
 2. \<lbrakk>\<And>xs ys. \<lbrakk>l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}; l \<notin> A\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
[PROOF STEP]
have "... = nths (weave A xs' ys) (-A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. nths (weave A xs' ys) (- A) @ nths [x] {a. a + (length xs' + length ys) \<in> - A} = nths (weave A xs' ys) (- A)
[PROOF STEP]
using nths_singleton \<open>length xs' + length ys \<in> A\<close>
[PROOF STATE]
proof (prove)
using this:
nths [?x] ?A = (if 0 \<in> ?A then [?x] else [])
length xs' + length ys \<in> A

goal (1 subgoal):
 1. nths (weave A xs' ys) (- A) @ nths [x] {a. a + (length xs' + length ys) \<in> - A} = nths (weave A xs' ys) (- A)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
nths (weave A xs' ys) (- A) @ nths [x] {a. a + (length xs' + length ys) \<in> - A} = nths (weave A xs' ys) (- A)

goal (2 subgoals):
 1. \<lbrakk>\<And>xs ys. \<lbrakk>l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}; l \<in> A\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
 2. \<lbrakk>\<And>xs ys. \<lbrakk>l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}; l \<notin> A\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
nths (weave A xs' ys) (- A) @ nths [x] {a. a + (length xs' + length ys) \<in> - A} = nths (weave A xs' ys) (- A)

goal (2 subgoals):
 1. \<lbrakk>\<And>xs ys. \<lbrakk>l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}; l \<in> A\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
 2. \<lbrakk>\<And>xs ys. \<lbrakk>l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}; l \<notin> A\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
[PROOF STEP]
have "... = ys"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. nths (weave A xs' ys) (- A) = ys
[PROOF STEP]
using Suc.hyps(1)[OF \<open>l = length xs' + length ys\<close> length_xs' length_ys]
[PROOF STATE]
proof (prove)
using this:
nths (weave A xs' ys) A = xs' \<and> nths (weave A xs' ys) (- A) = ys

goal (1 subgoal):
 1. nths (weave A xs' ys) (- A) = ys
[PROOF STEP]
by presburger
[PROOF STATE]
proof (state)
this:
nths (weave A xs' ys) (- A) = ys

goal (2 subgoals):
 1. \<lbrakk>\<And>xs ys. \<lbrakk>l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}; l \<in> A\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
 2. \<lbrakk>\<And>xs ys. \<lbrakk>l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}; l \<notin> A\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
nths (weave A xs ys) (- A) = ys
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
nths (weave A xs ys) (- A) = ys

goal (1 subgoal):
 1. nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
[PROOF STEP]
using \<open>nths (weave A xs ys) A = xs\<close>
[PROOF STATE]
proof (prove)
using this:
nths (weave A xs ys) (- A) = ys
nths (weave A xs ys) A = xs

goal (1 subgoal):
 1. nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys

goal (1 subgoal):
 1. \<lbrakk>\<And>xs ys. \<lbrakk>l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}; l \<notin> A\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<lbrakk>\<And>xs ys. \<lbrakk>l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}; l \<notin> A\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
l \<notin> A

goal (1 subgoal):
 1. \<lbrakk>\<And>xs ys. \<lbrakk>l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}; l \<notin> A\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
l \<notin> A
[PROOF STEP]
have "l\<notin>{a \<in> A. a < length xs + length ys}"
[PROOF STATE]
proof (prove)
using this:
l \<notin> A

goal (1 subgoal):
 1. l \<notin> {a \<in> A. a < length xs + length ys}
[PROOF STEP]
using Suc.hyps mem_Collect_eq zero_less_Suc
[PROOF STATE]
proof (prove)
using this:
l \<notin> A
\<lbrakk>l = length ?xs + length ?ys; length ?xs = card {a \<in> A. a < length ?xs + length ?ys}; length ?ys = card {a \<in> - A. a < length ?xs + length ?ys}\<rbrakk> \<Longrightarrow> nths (weave A ?xs ?ys) A = ?xs \<and> nths (weave A ?xs ?ys) (- A) = ?ys
Suc l = length xs + length ys
(?a \<in> Collect ?P) = ?P ?a
0 < Suc ?n

goal (1 subgoal):
 1. l \<notin> {a \<in> A. a < length xs + length ys}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
l \<notin> {a \<in> A. a < length xs + length ys}

goal (1 subgoal):
 1. \<lbrakk>\<And>xs ys. \<lbrakk>l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}; l \<notin> A\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
l \<notin> {a \<in> A. a < length xs + length ys}
[PROOF STEP]
have "length ys > 0"
[PROOF STATE]
proof (prove)
using this:
l \<notin> {a \<in> A. a < length xs + length ys}

goal (1 subgoal):
 1. 0 < length ys
[PROOF STEP]
using Suc
[PROOF STATE]
proof (prove)
using this:
l \<notin> {a \<in> A. a < length xs + length ys}
\<lbrakk>l = length ?xs + length ?ys; length ?xs = card {a \<in> A. a < length ?xs + length ?ys}; length ?ys = card {a \<in> - A. a < length ?xs + length ?ys}\<rbrakk> \<Longrightarrow> nths (weave A ?xs ?ys) A = ?xs \<and> nths (weave A ?xs ?ys) (- A) = ?ys
Suc l = length xs + length ys
length xs = card {a \<in> A. a < length xs + length ys}
length ys = card {a \<in> - A. a < length xs + length ys}

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

goal (1 subgoal):
 1. \<lbrakk>\<And>xs ys. \<lbrakk>l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}; l \<notin> A\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
0 < length ys
[PROOF STEP]
obtain ys' y where "ys = ys' @ [y]"
[PROOF STATE]
proof (prove)
using this:
0 < length ys

goal (1 subgoal):
 1. (\<And>ys' y. ys = ys' @ [y] \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (metis append_butlast_last_id length_greater_0_conv)
[PROOF STATE]
proof (state)
this:
ys = ys' @ [y]

goal (1 subgoal):
 1. \<lbrakk>\<And>xs ys. \<lbrakk>l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}; l \<notin> A\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
ys = ys' @ [y]
[PROOF STEP]
have "l = length xs + length ys'"
[PROOF STATE]
proof (prove)
using this:
ys = ys' @ [y]

goal (1 subgoal):
 1. l = length xs + length ys'
[PROOF STEP]
using Suc.hyps
[PROOF STATE]
proof (prove)
using this:
ys = ys' @ [y]
\<lbrakk>l = length ?xs + length ?ys; length ?xs = card {a \<in> A. a < length ?xs + length ?ys}; length ?ys = card {a \<in> - A. a < length ?xs + length ?ys}\<rbrakk> \<Longrightarrow> nths (weave A ?xs ?ys) A = ?xs \<and> nths (weave A ?xs ?ys) (- A) = ?ys
Suc l = length xs + length ys

goal (1 subgoal):
 1. l = length xs + length ys'
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
l = length xs + length ys'

goal (1 subgoal):
 1. \<lbrakk>\<And>xs ys. \<lbrakk>l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}; l \<notin> A\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
[PROOF STEP]
have length_ys':"length ys' = card {a \<in> -A. a < length xs + length ys'}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length ys' = card {a \<in> - A. a < length xs + length ys'}
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. length ys' = card {a \<in> - A. a < length xs + length ys'}
[PROOF STEP]
have "{a \<in> -A. a < length xs + length ys} = {a \<in> -A. a < length xs + length ys'} \<union> {l}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {a \<in> - A. a < length xs + length ys} = {a \<in> - A. a < length xs + length ys'} \<union> {l}
[PROOF STEP]
using \<open>ys = ys' @ [y]\<close> \<open>l\<notin>{a \<in> A. a < length xs + length ys}\<close> \<open>l = length xs + length ys'\<close>
[PROOF STATE]
proof (prove)
using this:
ys = ys' @ [y]
l \<notin> {a \<in> A. a < length xs + length ys}
l = length xs + length ys'

goal (1 subgoal):
 1. {a \<in> - A. a < length xs + length ys} = {a \<in> - A. a < length xs + length ys'} \<union> {l}
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
{a \<in> - A. a < length xs + length ys} = {a \<in> - A. a < length xs + length ys'} \<union> {l}

goal (1 subgoal):
 1. length ys' = card {a \<in> - A. a < length xs + length ys'}
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
{a \<in> - A. a < length xs + length ys} = {a \<in> - A. a < length xs + length ys'} \<union> {l}
[PROOF STEP]
have "card {a \<in> -A. a < length xs + length ys} = card {a \<in> -A. a < length xs + length ys'} + 1"
[PROOF STATE]
proof (prove)
using this:
{a \<in> - A. a < length xs + length ys} = {a \<in> - A. a < length xs + length ys'} \<union> {l}

goal (1 subgoal):
 1. card {a \<in> - A. a < length xs + length ys} = card {a \<in> - A. a < length xs + length ys'} + 1
[PROOF STEP]
using \<open>l = length xs + length ys'\<close>
[PROOF STATE]
proof (prove)
using this:
{a \<in> - A. a < length xs + length ys} = {a \<in> - A. a < length xs + length ys'} \<union> {l}
l = length xs + length ys'

goal (1 subgoal):
 1. card {a \<in> - A. a < length xs + length ys} = card {a \<in> - A. a < length xs + length ys'} + 1
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
card {a \<in> - A. a < length xs + length ys} = card {a \<in> - A. a < length xs + length ys'} + 1

goal (1 subgoal):
 1. length ys' = card {a \<in> - A. a < length xs + length ys'}
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
card {a \<in> - A. a < length xs + length ys} = card {a \<in> - A. a < length xs + length ys'} + 1
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
card {a \<in> - A. a < length xs + length ys} = card {a \<in> - A. a < length xs + length ys'} + 1

goal (1 subgoal):
 1. length ys' = card {a \<in> - A. a < length xs + length ys'}
[PROOF STEP]
by (metis One_nat_def Suc.prems(2) \<open>ys = ys' @ [y]\<close> add_right_imp_eq
        length_Cons length_append list.size(3))
[PROOF STATE]
proof (state)
this:
length ys' = card {a \<in> - A. a < length xs + length ys'}

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
length ys' = card {a \<in> - A. a < length xs + length ys'}

goal (1 subgoal):
 1. \<lbrakk>\<And>xs ys. \<lbrakk>l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}; l \<notin> A\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
[PROOF STEP]
have length_xs:"length xs = card {a \<in> A. a < length xs + length ys'}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length xs = card {a \<in> A. a < length xs + length ys'}
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. length xs = card {a \<in> A. a < length xs + length ys'}
[PROOF STEP]
have "l\<notin>{a \<in> A. a < length xs + length ys}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. l \<notin> {a \<in> A. a < length xs + length ys}
[PROOF STEP]
using \<open>l\<notin>A\<close> \<open>l = length xs + length ys'\<close>
[PROOF STATE]
proof (prove)
using this:
l \<notin> A
l = length xs + length ys'

goal (1 subgoal):
 1. l \<notin> {a \<in> A. a < length xs + length ys}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
l \<notin> {a \<in> A. a < length xs + length ys}

goal (1 subgoal):
 1. length xs = card {a \<in> A. a < length xs + length ys'}
[PROOF STEP]
have "{a \<in> A. a < length xs + length ys} = {a \<in> A. a < length xs + length ys'}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {a \<in> A. a < length xs + length ys} = {a \<in> A. a < length xs + length ys'}
[PROOF STEP]
apply (rule subset_antisym)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. {a \<in> A. a < length xs + length ys} \<subseteq> {a \<in> A. a < length xs + length ys'}
 2. {a \<in> A. a < length xs + length ys'} \<subseteq> {a \<in> A. a < length xs + length ys}
[PROOF STEP]
using  \<open>l = length xs + length ys'\<close> \<open>Suc l = length xs + length ys\<close> \<open>l\<notin>{a \<in> A. a < length xs + length ys}\<close>
[PROOF STATE]
proof (prove)
using this:
l = length xs + length ys'
Suc l = length xs + length ys
l \<notin> {a \<in> A. a < length xs + length ys}

goal (2 subgoals):
 1. {a \<in> A. a < length xs + length ys} \<subseteq> {a \<in> A. a < length xs + length ys'}
 2. {a \<in> A. a < length xs + length ys'} \<subseteq> {a \<in> A. a < length xs + length ys}
[PROOF STEP]
apply (metis (no_types, lifting) Collect_mono less_Suc_eq mem_Collect_eq)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {a \<in> A. a < length xs + length ys'} \<subseteq> {a \<in> A. a < length xs + length ys}
[PROOF STEP]
using Collect_mono Suc.hyps(2) \<open>l = length xs + length ys'\<close>
[PROOF STATE]
proof (prove)
using this:
(\<And>x. ?P x \<longrightarrow> ?Q x) \<Longrightarrow> Collect ?P \<subseteq> Collect ?Q
Suc l = length xs + length ys
l = length xs + length ys'

goal (1 subgoal):
 1. {a \<in> A. a < length xs + length ys'} \<subseteq> {a \<in> A. a < length xs + length ys}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
{a \<in> A. a < length xs + length ys} = {a \<in> A. a < length xs + length ys'}

goal (1 subgoal):
 1. length xs = card {a \<in> A. a < length xs + length ys'}
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
{a \<in> A. a < length xs + length ys} = {a \<in> A. a < length xs + length ys'}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
{a \<in> A. a < length xs + length ys} = {a \<in> A. a < length xs + length ys'}

goal (1 subgoal):
 1. length xs = card {a \<in> A. a < length xs + length ys'}
[PROOF STEP]
using Suc.prems(1)
[PROOF STATE]
proof (prove)
using this:
{a \<in> A. a < length xs + length ys} = {a \<in> A. a < length xs + length ys'}
length xs = card {a \<in> A. a < length xs + length ys}

goal (1 subgoal):
 1. length xs = card {a \<in> A. a < length xs + length ys'}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
length xs = card {a \<in> A. a < length xs + length ys'}

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
length xs = card {a \<in> A. a < length xs + length ys'}

goal (1 subgoal):
 1. \<lbrakk>\<And>xs ys. \<lbrakk>l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}; l \<notin> A\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
[PROOF STEP]
have "length xs + length ys' \<notin> A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length xs + length ys' \<notin> A
[PROOF STEP]
using \<open>l\<notin>A\<close> \<open>l = length xs + length ys'\<close>
[PROOF STATE]
proof (prove)
using this:
l \<notin> A
l = length xs + length ys'

goal (1 subgoal):
 1. length xs + length ys' \<notin> A
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
length xs + length ys' \<notin> A

goal (1 subgoal):
 1. \<lbrakk>\<And>xs ys. \<lbrakk>l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}; l \<notin> A\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
length xs + length ys' \<notin> A
[PROOF STEP]
have "nths (weave A xs ys) A = nths (weave A xs ys' @ [y]) A"
[PROOF STATE]
proof (prove)
using this:
length xs + length ys' \<notin> A

goal (1 subgoal):
 1. nths (weave A xs ys) A = nths (weave A xs ys' @ [y]) A
[PROOF STEP]
unfolding
       \<open>ys = ys' @ [y]\<close>
[PROOF STATE]
proof (prove)
using this:
length xs + length ys' \<notin> A

goal (1 subgoal):
 1. nths (weave A xs (ys' @ [y])) A = nths (weave A xs ys' @ [y]) A
[PROOF STEP]
using weave_append2[OF \<open>length xs + length ys' \<notin> A\<close> length_ys']
[PROOF STATE]
proof (prove)
using this:
length xs + length ys' \<notin> A
weave A xs (ys' @ [?y]) = weave A xs ys' @ [?y]

goal (1 subgoal):
 1. nths (weave A xs (ys' @ [y])) A = nths (weave A xs ys' @ [y]) A
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
nths (weave A xs ys) A = nths (weave A xs ys' @ [y]) A

goal (1 subgoal):
 1. \<lbrakk>\<And>xs ys. \<lbrakk>l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}; l \<notin> A\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
nths (weave A xs ys) A = nths (weave A xs ys' @ [y]) A

goal (1 subgoal):
 1. \<lbrakk>\<And>xs ys. \<lbrakk>l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}; l \<notin> A\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
[PROOF STEP]
have "... = nths (weave A xs ys') A @ nths [y] {a. a + (length xs + length ys') \<in> A}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. nths (weave A xs ys' @ [y]) A = nths (weave A xs ys') A @ nths [y] {a. a + (length xs + length ys') \<in> A}
[PROOF STEP]
using nths_append length_weave
[PROOF STATE]
proof (prove)
using this:
nths (?l @ ?l') ?A = nths ?l ?A @ nths ?l' {j. j + length ?l \<in> ?A}
length (weave ?A ?xs ?ys) = length ?xs + length ?ys

goal (1 subgoal):
 1. nths (weave A xs ys' @ [y]) A = nths (weave A xs ys') A @ nths [y] {a. a + (length xs + length ys') \<in> A}
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
nths (weave A xs ys' @ [y]) A = nths (weave A xs ys') A @ nths [y] {a. a + (length xs + length ys') \<in> A}

goal (1 subgoal):
 1. \<lbrakk>\<And>xs ys. \<lbrakk>l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}; l \<notin> A\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
nths (weave A xs ys' @ [y]) A = nths (weave A xs ys') A @ nths [y] {a. a + (length xs + length ys') \<in> A}

goal (1 subgoal):
 1. \<lbrakk>\<And>xs ys. \<lbrakk>l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}; l \<notin> A\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
[PROOF STEP]
have "... = nths (weave A xs ys') A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. nths (weave A xs ys') A @ nths [y] {a. a + (length xs + length ys') \<in> A} = nths (weave A xs ys') A
[PROOF STEP]
using nths_singleton \<open>length xs + length ys' \<notin> A\<close>
[PROOF STATE]
proof (prove)
using this:
nths [?x] ?A = (if 0 \<in> ?A then [?x] else [])
length xs + length ys' \<notin> A

goal (1 subgoal):
 1. nths (weave A xs ys') A @ nths [y] {a. a + (length xs + length ys') \<in> A} = nths (weave A xs ys') A
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
nths (weave A xs ys') A @ nths [y] {a. a + (length xs + length ys') \<in> A} = nths (weave A xs ys') A

goal (1 subgoal):
 1. \<lbrakk>\<And>xs ys. \<lbrakk>l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}; l \<notin> A\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
nths (weave A xs ys') A @ nths [y] {a. a + (length xs + length ys') \<in> A} = nths (weave A xs ys') A

goal (1 subgoal):
 1. \<lbrakk>\<And>xs ys. \<lbrakk>l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}; l \<notin> A\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
[PROOF STEP]
have "... = xs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. nths (weave A xs ys') A = xs
[PROOF STEP]
using Suc.hyps(1)[OF \<open>l = length xs + length ys'\<close> length_xs length_ys']
[PROOF STATE]
proof (prove)
using this:
nths (weave A xs ys') A = xs \<and> nths (weave A xs ys') (- A) = ys'

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

goal (1 subgoal):
 1. \<lbrakk>\<And>xs ys. \<lbrakk>l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}; l \<notin> A\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
nths (weave A xs ys) A = xs
[PROOF STEP]
have "nths (weave A xs ys) A = xs"
[PROOF STATE]
proof (prove)
using this:
nths (weave A xs ys) A = xs

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

goal (1 subgoal):
 1. \<lbrakk>\<And>xs ys. \<lbrakk>l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}; l \<notin> A\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
[PROOF STEP]
have "nths (weave A xs ys) (-A) = nths (weave A xs ys' @ [y]) (-A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. nths (weave A xs ys) (- A) = nths (weave A xs ys' @ [y]) (- A)
[PROOF STEP]
unfolding
       \<open>ys = ys' @ [y]\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. nths (weave A xs (ys' @ [y])) (- A) = nths (weave A xs ys' @ [y]) (- A)
[PROOF STEP]
using weave_append2[OF \<open>length xs + length ys' \<notin> A\<close> length_ys']
[PROOF STATE]
proof (prove)
using this:
weave A xs (ys' @ [?y]) = weave A xs ys' @ [?y]

goal (1 subgoal):
 1. nths (weave A xs (ys' @ [y])) (- A) = nths (weave A xs ys' @ [y]) (- A)
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
nths (weave A xs ys) (- A) = nths (weave A xs ys' @ [y]) (- A)

goal (1 subgoal):
 1. \<lbrakk>\<And>xs ys. \<lbrakk>l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}; l \<notin> A\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
nths (weave A xs ys) (- A) = nths (weave A xs ys' @ [y]) (- A)

goal (1 subgoal):
 1. \<lbrakk>\<And>xs ys. \<lbrakk>l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}; l \<notin> A\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
[PROOF STEP]
have "... = nths (weave A xs ys') (-A) @ nths [y] {a. a + (length xs + length ys') \<in> (-A)}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. nths (weave A xs ys' @ [y]) (- A) = nths (weave A xs ys') (- A) @ nths [y] {a. a + (length xs + length ys') \<in> - A}
[PROOF STEP]
using nths_append length_weave
[PROOF STATE]
proof (prove)
using this:
nths (?l @ ?l') ?A = nths ?l ?A @ nths ?l' {j. j + length ?l \<in> ?A}
length (weave ?A ?xs ?ys) = length ?xs + length ?ys

goal (1 subgoal):
 1. nths (weave A xs ys' @ [y]) (- A) = nths (weave A xs ys') (- A) @ nths [y] {a. a + (length xs + length ys') \<in> - A}
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
nths (weave A xs ys' @ [y]) (- A) = nths (weave A xs ys') (- A) @ nths [y] {a. a + (length xs + length ys') \<in> - A}

goal (1 subgoal):
 1. \<lbrakk>\<And>xs ys. \<lbrakk>l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}; l \<notin> A\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
nths (weave A xs ys' @ [y]) (- A) = nths (weave A xs ys') (- A) @ nths [y] {a. a + (length xs + length ys') \<in> - A}

goal (1 subgoal):
 1. \<lbrakk>\<And>xs ys. \<lbrakk>l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}; l \<notin> A\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
[PROOF STEP]
have "... = nths (weave A xs ys') (-A) @ [y]"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. nths (weave A xs ys') (- A) @ nths [y] {a. a + (length xs + length ys') \<in> - A} = nths (weave A xs ys') (- A) @ [y]
[PROOF STEP]
using nths_singleton \<open>length xs + length ys' \<notin> A\<close>
[PROOF STATE]
proof (prove)
using this:
nths [?x] ?A = (if 0 \<in> ?A then [?x] else [])
length xs + length ys' \<notin> A

goal (1 subgoal):
 1. nths (weave A xs ys') (- A) @ nths [y] {a. a + (length xs + length ys') \<in> - A} = nths (weave A xs ys') (- A) @ [y]
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
nths (weave A xs ys') (- A) @ nths [y] {a. a + (length xs + length ys') \<in> - A} = nths (weave A xs ys') (- A) @ [y]

goal (1 subgoal):
 1. \<lbrakk>\<And>xs ys. \<lbrakk>l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}; l \<notin> A\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
nths (weave A xs ys') (- A) @ nths [y] {a. a + (length xs + length ys') \<in> - A} = nths (weave A xs ys') (- A) @ [y]

goal (1 subgoal):
 1. \<lbrakk>\<And>xs ys. \<lbrakk>l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}; l \<notin> A\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
[PROOF STEP]
have "... = ys"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. nths (weave A xs ys') (- A) @ [y] = ys
[PROOF STEP]
using Suc.hyps(1)[OF \<open>l = length xs + length ys'\<close> length_xs length_ys'] \<open>ys = ys' @ [y]\<close>
[PROOF STATE]
proof (prove)
using this:
nths (weave A xs ys') A = xs \<and> nths (weave A xs ys') (- A) = ys'
ys = ys' @ [y]

goal (1 subgoal):
 1. nths (weave A xs ys') (- A) @ [y] = ys
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
nths (weave A xs ys') (- A) @ [y] = ys

goal (1 subgoal):
 1. \<lbrakk>\<And>xs ys. \<lbrakk>l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys; Suc l = length xs + length ys; length xs = card {a \<in> A. a < length xs + length ys}; length ys = card {a \<in> - A. a < length xs + length ys}; l \<notin> A\<rbrakk> \<Longrightarrow> nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
nths (weave A xs ys) (- A) = ys
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
nths (weave A xs ys) (- A) = ys

goal (1 subgoal):
 1. nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
[PROOF STEP]
using \<open>nths (weave A xs ys) A = xs\<close>
[PROOF STATE]
proof (prove)
using this:
nths (weave A xs ys) (- A) = ys
nths (weave A xs ys) A = xs

goal (1 subgoal):
 1. nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
nths (weave A xs ys) A = xs \<and> nths (weave A xs ys) (- A) = ys

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma HXH_is_Z [simp]:
  "H * X * H = Z"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. H * X * H = Z
[PROOF STEP]
apply(simp add: X_def Z_def H_def times_mat_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mat 2 2 (\<lambda>(i, j). row (mat 2 2 (\<lambda>(i, j). row (1 / complex_of_real (sqrt 2) \<cdot>\<^sub>m mat 2 2 (\<lambda>(i, j). if i \<noteq> j then 1 else if i = 0 then 1 else - 1)) i \<bullet> col (mat 2 2 (\<lambda>(i, j). if i = j then 0 else 1)) j)) i \<bullet> col (1 / complex_of_real (sqrt 2) \<cdot>\<^sub>m mat 2 2 (\<lambda>(i, j). if i \<noteq> j then 1 else if i = 0 then 1 else - 1)) j) = mat 2 2 (\<lambda>(i, j). if i \<noteq> j then 0 else if i = 0 then 1 else - 1)
[PROOF STEP]
apply(rule cong_mat)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. 2 = 2
 2. 2 = 2
 3. \<And>i j. \<lbrakk>i < 2; j < 2\<rbrakk> \<Longrightarrow> (case (i, j) of (i, j) \<Rightarrow> row (mat 2 2 (\<lambda>(i, j). row (1 / complex_of_real (sqrt 2) \<cdot>\<^sub>m mat 2 2 (\<lambda>(i, j). if i \<noteq> j then 1 else if i = 0 then 1 else - 1)) i \<bullet> col (mat 2 2 (\<lambda>(i, j). if i = j then 0 else 1)) j)) i \<bullet> col (1 / complex_of_real (sqrt 2) \<cdot>\<^sub>m mat 2 2 (\<lambda>(i, j). if i \<noteq> j then 1 else if i = 0 then 1 else - 1)) j) = (case (i, j) of (i, j) \<Rightarrow> if i \<noteq> j then 0 else if i = 0 then 1 else - 1)
[PROOF STEP]
by(auto simp add: scalar_prod_def complex_eqI)


[STATEMENT]
lemma Suc_diff_int:"0 < n \<Longrightarrow> int (n - Suc 0) = int n - 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < n \<Longrightarrow> int (n - Suc 0) = int n - 1
[PROOF STEP]
by (cut_tac of_nat_Suc[of "n - Suc 0"], simp)