[STATEMENT]
lemma polydivide_aux_properties:
  assumes "SORT_CONSTRAINT('a::field_char_0)"
    and np: "isnpolyh p n0"
    and ns: "isnpolyh s n1"
    and ap: "head p = a"
    and ndp: "degree p = n"
    and pnz: "p \<noteq> 0\<^sub>p"
  shows "polydivide_aux a n p k s = (k', r) \<longrightarrow> k' \<ge> k \<and> (degree r = 0 \<or> degree r < degree p) \<and>
    (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> (polypow (k' - k) a) *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
using ns
[PROOF STATE]
proof (prove)
using this:
isnpolyh s n1

goal (1 subgoal):
 1. polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
proof (induct "degree s" arbitrary: s k k' r n1 rule: less_induct)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>s k k' r n1. \<lbrakk>\<And>sa k k' r n1. \<lbrakk>Reflected_Multivariate_Polynomial.degree sa < Reflected_Multivariate_Polynomial.degree s; isnpolyh sa n1\<rbrakk> \<Longrightarrow> polydivide_aux a n p k sa = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> Ex (isnpolyh r) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p sa = p *\<^sub>p q +\<^sub>p r); isnpolyh s n1\<rbrakk> \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> Ex (isnpolyh r) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
case less
[PROOF STATE]
proof (state)
this:
\<lbrakk>Reflected_Multivariate_Polynomial.degree ?s < Reflected_Multivariate_Polynomial.degree s; isnpolyh ?s ?n1.0\<rbrakk> \<Longrightarrow> polydivide_aux a n p ?k ?s = (?k', ?r) \<longrightarrow> ?k \<le> ?k' \<and> (Reflected_Multivariate_Polynomial.degree ?r = 0 \<or> Reflected_Multivariate_Polynomial.degree ?r < Reflected_Multivariate_Polynomial.degree p) \<and> Ex (isnpolyh ?r) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p ?k' - ?k *\<^sub>p ?s = p *\<^sub>p q +\<^sub>p ?r)
isnpolyh s n1

goal (1 subgoal):
 1. \<And>s k k' r n1. \<lbrakk>\<And>sa k k' r n1. \<lbrakk>Reflected_Multivariate_Polynomial.degree sa < Reflected_Multivariate_Polynomial.degree s; isnpolyh sa n1\<rbrakk> \<Longrightarrow> polydivide_aux a n p k sa = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> Ex (isnpolyh r) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p sa = p *\<^sub>p q +\<^sub>p r); isnpolyh s n1\<rbrakk> \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> Ex (isnpolyh r) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
let ?qths = "\<exists>q n1. isnpolyh q n1 \<and> (a ^\<^sub>p (k' - k) *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>s k k' r n1. \<lbrakk>\<And>sa k k' r n1. \<lbrakk>Reflected_Multivariate_Polynomial.degree sa < Reflected_Multivariate_Polynomial.degree s; isnpolyh sa n1\<rbrakk> \<Longrightarrow> polydivide_aux a n p k sa = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> Ex (isnpolyh r) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p sa = p *\<^sub>p q +\<^sub>p r); isnpolyh s n1\<rbrakk> \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> Ex (isnpolyh r) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
let ?ths = "polydivide_aux a n p k s = (k', r) \<longrightarrow>  k \<le> k' \<and>
    (degree r = 0 \<or> degree r < degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> ?qths"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>s k k' r n1. \<lbrakk>\<And>sa k k' r n1. \<lbrakk>Reflected_Multivariate_Polynomial.degree sa < Reflected_Multivariate_Polynomial.degree s; isnpolyh sa n1\<rbrakk> \<Longrightarrow> polydivide_aux a n p k sa = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> Ex (isnpolyh r) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p sa = p *\<^sub>p q +\<^sub>p r); isnpolyh s n1\<rbrakk> \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> Ex (isnpolyh r) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
let ?b = "head s"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>s k k' r n1. \<lbrakk>\<And>sa k k' r n1. \<lbrakk>Reflected_Multivariate_Polynomial.degree sa < Reflected_Multivariate_Polynomial.degree s; isnpolyh sa n1\<rbrakk> \<Longrightarrow> polydivide_aux a n p k sa = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> Ex (isnpolyh r) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p sa = p *\<^sub>p q +\<^sub>p r); isnpolyh s n1\<rbrakk> \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> Ex (isnpolyh r) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
let ?p' = "funpow (degree s - n) shift1 p"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>s k k' r n1. \<lbrakk>\<And>sa k k' r n1. \<lbrakk>Reflected_Multivariate_Polynomial.degree sa < Reflected_Multivariate_Polynomial.degree s; isnpolyh sa n1\<rbrakk> \<Longrightarrow> polydivide_aux a n p k sa = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> Ex (isnpolyh r) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p sa = p *\<^sub>p q +\<^sub>p r); isnpolyh s n1\<rbrakk> \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> Ex (isnpolyh r) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
let ?xdn = "funpow (degree s - n) shift1 (1)\<^sub>p"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>s k k' r n1. \<lbrakk>\<And>sa k k' r n1. \<lbrakk>Reflected_Multivariate_Polynomial.degree sa < Reflected_Multivariate_Polynomial.degree s; isnpolyh sa n1\<rbrakk> \<Longrightarrow> polydivide_aux a n p k sa = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> Ex (isnpolyh r) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p sa = p *\<^sub>p q +\<^sub>p r); isnpolyh s n1\<rbrakk> \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> Ex (isnpolyh r) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
let ?akk' = "a ^\<^sub>p (k' - k)"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>s k k' r n1. \<lbrakk>\<And>sa k k' r n1. \<lbrakk>Reflected_Multivariate_Polynomial.degree sa < Reflected_Multivariate_Polynomial.degree s; isnpolyh sa n1\<rbrakk> \<Longrightarrow> polydivide_aux a n p k sa = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> Ex (isnpolyh r) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p sa = p *\<^sub>p q +\<^sub>p r); isnpolyh s n1\<rbrakk> \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> Ex (isnpolyh r) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
note ns = \<open>isnpolyh s n1\<close>
[PROOF STATE]
proof (state)
this:
isnpolyh s n1

goal (1 subgoal):
 1. \<And>s k k' r n1. \<lbrakk>\<And>sa k k' r n1. \<lbrakk>Reflected_Multivariate_Polynomial.degree sa < Reflected_Multivariate_Polynomial.degree s; isnpolyh sa n1\<rbrakk> \<Longrightarrow> polydivide_aux a n p k sa = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> Ex (isnpolyh r) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p sa = p *\<^sub>p q +\<^sub>p r); isnpolyh s n1\<rbrakk> \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> Ex (isnpolyh r) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
from np
[PROOF STATE]
proof (chain)
picking this:
isnpolyh p n0
[PROOF STEP]
have np0: "isnpolyh p 0"
[PROOF STATE]
proof (prove)
using this:
isnpolyh p n0

goal (1 subgoal):
 1. isnpolyh p 0
[PROOF STEP]
using isnpolyh_mono[where n="n0" and n'="0" and p="p"]
[PROOF STATE]
proof (prove)
using this:
isnpolyh p n0
\<lbrakk>0 \<le> n0; isnpolyh p n0\<rbrakk> \<Longrightarrow> isnpolyh p 0

goal (1 subgoal):
 1. isnpolyh p 0
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
isnpolyh p 0

goal (1 subgoal):
 1. \<And>s k k' r n1. \<lbrakk>\<And>sa k k' r n1. \<lbrakk>Reflected_Multivariate_Polynomial.degree sa < Reflected_Multivariate_Polynomial.degree s; isnpolyh sa n1\<rbrakk> \<Longrightarrow> polydivide_aux a n p k sa = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> Ex (isnpolyh r) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p sa = p *\<^sub>p q +\<^sub>p r); isnpolyh s n1\<rbrakk> \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> Ex (isnpolyh r) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
have np': "isnpolyh ?p' 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. isnpolyh ((shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p) 0
[PROOF STEP]
using funpow_shift1_isnpoly[OF np0[simplified isnpoly_def[symmetric]] pnz, where n="degree s - n"] isnpoly_def
[PROOF STATE]
proof (prove)
using this:
isnpoly ((shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p)
isnpoly ?p = isnpolyh ?p 0

goal (1 subgoal):
 1. isnpolyh ((shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p) 0
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
isnpolyh ((shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p) 0

goal (1 subgoal):
 1. \<And>s k k' r n1. \<lbrakk>\<And>sa k k' r n1. \<lbrakk>Reflected_Multivariate_Polynomial.degree sa < Reflected_Multivariate_Polynomial.degree s; isnpolyh sa n1\<rbrakk> \<Longrightarrow> polydivide_aux a n p k sa = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> Ex (isnpolyh r) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p sa = p *\<^sub>p q +\<^sub>p r); isnpolyh s n1\<rbrakk> \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> Ex (isnpolyh r) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
have headp': "head ?p' = head p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. head ((shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p) = head p
[PROOF STEP]
using funpow_shift1_head[OF np pnz]
[PROOF STATE]
proof (prove)
using this:
head ((shift1 ^^ ?k) p) = head p

goal (1 subgoal):
 1. head ((shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p) = head p
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
head ((shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p) = head p

goal (1 subgoal):
 1. \<And>s k k' r n1. \<lbrakk>\<And>sa k k' r n1. \<lbrakk>Reflected_Multivariate_Polynomial.degree sa < Reflected_Multivariate_Polynomial.degree s; isnpolyh sa n1\<rbrakk> \<Longrightarrow> polydivide_aux a n p k sa = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> Ex (isnpolyh r) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p sa = p *\<^sub>p q +\<^sub>p r); isnpolyh s n1\<rbrakk> \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> Ex (isnpolyh r) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
from funpow_shift1_isnpoly[where p="(1)\<^sub>p"]
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>isnpoly (1)\<^sub>p; (1)\<^sub>p \<noteq> 0\<^sub>p\<rbrakk> \<Longrightarrow> isnpoly ((shift1 ^^ ?n) (1)\<^sub>p)
[PROOF STEP]
have nxdn: "isnpolyh ?xdn 0"
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>isnpoly (1)\<^sub>p; (1)\<^sub>p \<noteq> 0\<^sub>p\<rbrakk> \<Longrightarrow> isnpoly ((shift1 ^^ ?n) (1)\<^sub>p)

goal (1 subgoal):
 1. isnpolyh ((shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p) 0
[PROOF STEP]
by (simp add: isnpoly_def)
[PROOF STATE]
proof (state)
this:
isnpolyh ((shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p) 0

goal (1 subgoal):
 1. \<And>s k k' r n1. \<lbrakk>\<And>sa k k' r n1. \<lbrakk>Reflected_Multivariate_Polynomial.degree sa < Reflected_Multivariate_Polynomial.degree s; isnpolyh sa n1\<rbrakk> \<Longrightarrow> polydivide_aux a n p k sa = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> Ex (isnpolyh r) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p sa = p *\<^sub>p q +\<^sub>p r); isnpolyh s n1\<rbrakk> \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> Ex (isnpolyh r) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
from polypow_normh [OF head_isnpolyh[OF np0], where k="k' - k"] ap
[PROOF STATE]
proof (chain)
picking this:
isnpolyh (head p ^\<^sub>p k' - k) 0
head p = a
[PROOF STEP]
have nakk':"isnpolyh ?akk' 0"
[PROOF STATE]
proof (prove)
using this:
isnpolyh (head p ^\<^sub>p k' - k) 0
head p = a

goal (1 subgoal):
 1. isnpolyh (a ^\<^sub>p k' - k) 0
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
isnpolyh (a ^\<^sub>p k' - k) 0

goal (1 subgoal):
 1. \<And>s k k' r n1. \<lbrakk>\<And>sa k k' r n1. \<lbrakk>Reflected_Multivariate_Polynomial.degree sa < Reflected_Multivariate_Polynomial.degree s; isnpolyh sa n1\<rbrakk> \<Longrightarrow> polydivide_aux a n p k sa = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> Ex (isnpolyh r) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p sa = p *\<^sub>p q +\<^sub>p r); isnpolyh s n1\<rbrakk> \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> Ex (isnpolyh r) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
show ?ths
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
proof (cases "s = 0\<^sub>p")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. s = 0\<^sub>p \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
 2. s \<noteq> 0\<^sub>p \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
s = 0\<^sub>p

goal (2 subgoals):
 1. s = 0\<^sub>p \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
 2. s \<noteq> 0\<^sub>p \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
with np
[PROOF STATE]
proof (chain)
picking this:
isnpolyh p n0
s = 0\<^sub>p
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
isnpolyh p n0
s = 0\<^sub>p

goal (1 subgoal):
 1. polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
apply (clarsimp simp: polydivide_aux.simps)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>isnpolyh p n0; s = 0\<^sub>p; k = k'; r = 0\<^sub>p\<rbrakk> \<Longrightarrow> \<exists>q. Ex (isnpolyh q) \<and> 0\<^sub>p = p *\<^sub>p q +\<^sub>p 0\<^sub>p
[PROOF STEP]
apply (rule exI[where x="0\<^sub>p"])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>isnpolyh p n0; s = 0\<^sub>p; k = k'; r = 0\<^sub>p\<rbrakk> \<Longrightarrow> Ex (isnpolyh 0\<^sub>p) \<and> 0\<^sub>p = p *\<^sub>p 0\<^sub>p +\<^sub>p 0\<^sub>p
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)

goal (1 subgoal):
 1. s \<noteq> 0\<^sub>p \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. s \<noteq> 0\<^sub>p \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
case sz: False
[PROOF STATE]
proof (state)
this:
s \<noteq> 0\<^sub>p

goal (1 subgoal):
 1. s \<noteq> 0\<^sub>p \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
proof (cases "degree s < n")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. Reflected_Multivariate_Polynomial.degree s < n \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
 2. \<not> Reflected_Multivariate_Polynomial.degree s < n \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
Reflected_Multivariate_Polynomial.degree s < n

goal (2 subgoals):
 1. Reflected_Multivariate_Polynomial.degree s < n \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
 2. \<not> Reflected_Multivariate_Polynomial.degree s < n \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
Reflected_Multivariate_Polynomial.degree s < n
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
Reflected_Multivariate_Polynomial.degree s < n

goal (1 subgoal):
 1. polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
using ns ndp np polydivide_aux.simps
[PROOF STATE]
proof (prove)
using this:
Reflected_Multivariate_Polynomial.degree s < n
isnpolyh s n1
Reflected_Multivariate_Polynomial.degree p = n
isnpolyh p n0
polydivide_aux ?a ?n ?p ?k ?s = (if ?s = 0\<^sub>p then (?k, ?s) else let b = head ?s; m = Reflected_Multivariate_Polynomial.degree ?s in if m < ?n then (?k, ?s) else let p' = (shift1 ^^ (m - ?n)) ?p in if ?a = b then polydivide_aux ?a ?n ?p ?k (?s -\<^sub>p p') else polydivide_aux ?a ?n ?p (Suc ?k) (?a *\<^sub>p ?s -\<^sub>p (b *\<^sub>p p')))

goal (1 subgoal):
 1. polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
apply auto
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p; isnpolyh r n1; isnpolyh p n0; \<And>a n p k s. polydivide_aux a n p k s = (if s = 0\<^sub>p then (k, s) else let b = head s; m = Reflected_Multivariate_Polynomial.degree s in if m < n then (k, s) else let p' = (shift1 ^^ (m - n)) p in if a = b then polydivide_aux a n p k (s -\<^sub>p p') else polydivide_aux a n p (Suc k) (a *\<^sub>p s -\<^sub>p (b *\<^sub>p p'))); n = Reflected_Multivariate_Polynomial.degree p; r \<noteq> 0\<^sub>p; k = k'; s = r\<rbrakk> \<Longrightarrow> \<exists>q. Ex (isnpolyh q) \<and> r = p *\<^sub>p q +\<^sub>p r
[PROOF STEP]
apply (rule exI[where x="0\<^sub>p"])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p; isnpolyh r n1; isnpolyh p n0; \<And>a n p k s. polydivide_aux a n p k s = (if s = 0\<^sub>p then (k, s) else let b = head s; m = Reflected_Multivariate_Polynomial.degree s in if m < n then (k, s) else let p' = (shift1 ^^ (m - n)) p in if a = b then polydivide_aux a n p k (s -\<^sub>p p') else polydivide_aux a n p (Suc k) (a *\<^sub>p s -\<^sub>p (b *\<^sub>p p'))); n = Reflected_Multivariate_Polynomial.degree p; r \<noteq> 0\<^sub>p; k = k'; s = r\<rbrakk> \<Longrightarrow> Ex (isnpolyh 0\<^sub>p) \<and> r = p *\<^sub>p 0\<^sub>p +\<^sub>p r
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)

goal (1 subgoal):
 1. \<not> Reflected_Multivariate_Polynomial.degree s < n \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> Reflected_Multivariate_Polynomial.degree s < n \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
case dn': False
[PROOF STATE]
proof (state)
this:
\<not> Reflected_Multivariate_Polynomial.degree s < n

goal (1 subgoal):
 1. \<not> Reflected_Multivariate_Polynomial.degree s < n \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<not> Reflected_Multivariate_Polynomial.degree s < n
[PROOF STEP]
have dn: "degree s \<ge> n"
[PROOF STATE]
proof (prove)
using this:
\<not> Reflected_Multivariate_Polynomial.degree s < n

goal (1 subgoal):
 1. n \<le> Reflected_Multivariate_Polynomial.degree s
[PROOF STEP]
by arith
[PROOF STATE]
proof (state)
this:
n \<le> Reflected_Multivariate_Polynomial.degree s

goal (1 subgoal):
 1. \<not> Reflected_Multivariate_Polynomial.degree s < n \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
have degsp': "degree s = degree ?p'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Reflected_Multivariate_Polynomial.degree s = Reflected_Multivariate_Polynomial.degree ((shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p)
[PROOF STEP]
using dn ndp funpow_shift1_degree[where k = "degree s - n" and p="p"]
[PROOF STATE]
proof (prove)
using this:
n \<le> Reflected_Multivariate_Polynomial.degree s
Reflected_Multivariate_Polynomial.degree p = n
Reflected_Multivariate_Polynomial.degree ((shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p) = Reflected_Multivariate_Polynomial.degree s - n + Reflected_Multivariate_Polynomial.degree p

goal (1 subgoal):
 1. Reflected_Multivariate_Polynomial.degree s = Reflected_Multivariate_Polynomial.degree ((shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
Reflected_Multivariate_Polynomial.degree s = Reflected_Multivariate_Polynomial.degree ((shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p)

goal (1 subgoal):
 1. \<not> Reflected_Multivariate_Polynomial.degree s < n \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
proof (cases "?b = a")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. head s = a \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
 2. head s \<noteq> a \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
case ba: True
[PROOF STATE]
proof (state)
this:
head s = a

goal (2 subgoals):
 1. head s = a \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
 2. head s \<noteq> a \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
head s = a
[PROOF STEP]
have headsp': "head s = head ?p'"
[PROOF STATE]
proof (prove)
using this:
head s = a

goal (1 subgoal):
 1. head s = head ((shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p)
[PROOF STEP]
using ap headp'
[PROOF STATE]
proof (prove)
using this:
head s = a
head p = a
head ((shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p) = head p

goal (1 subgoal):
 1. head s = head ((shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
head s = head ((shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p)

goal (2 subgoals):
 1. head s = a \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
 2. head s \<noteq> a \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
have nr: "isnpolyh (s -\<^sub>p ?p') 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. isnpolyh (s -\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p) 0
[PROOF STEP]
using polysub_normh[OF ns np']
[PROOF STATE]
proof (prove)
using this:
isnpolyh (s -\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p) (min n1 0)

goal (1 subgoal):
 1. isnpolyh (s -\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p) 0
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
isnpolyh (s -\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p) 0

goal (2 subgoals):
 1. head s = a \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
 2. head s \<noteq> a \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
from degree_polysub_samehead[OF ns np' headsp' degsp']
[PROOF STATE]
proof (chain)
picking this:
Reflected_Multivariate_Polynomial.degree (s -\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p) < Reflected_Multivariate_Polynomial.degree s \<or> s -\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p = 0\<^sub>p
[PROOF STEP]
consider "degree (s -\<^sub>p ?p') < degree s" | "s -\<^sub>p ?p' = 0\<^sub>p"
[PROOF STATE]
proof (prove)
using this:
Reflected_Multivariate_Polynomial.degree (s -\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p) < Reflected_Multivariate_Polynomial.degree s \<or> s -\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p = 0\<^sub>p

goal (1 subgoal):
 1. \<lbrakk>Reflected_Multivariate_Polynomial.degree (s -\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p) < Reflected_Multivariate_Polynomial.degree s \<Longrightarrow> thesis; s -\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p = 0\<^sub>p \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<lbrakk>Reflected_Multivariate_Polynomial.degree (s -\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p) < Reflected_Multivariate_Polynomial.degree s \<Longrightarrow> ?thesis; s -\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p = 0\<^sub>p \<Longrightarrow> ?thesis\<rbrakk> \<Longrightarrow> ?thesis

goal (2 subgoals):
 1. head s = a \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
 2. head s \<noteq> a \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>Reflected_Multivariate_Polynomial.degree (s -\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p) < Reflected_Multivariate_Polynomial.degree s \<Longrightarrow> ?thesis; s -\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p = 0\<^sub>p \<Longrightarrow> ?thesis\<rbrakk> \<Longrightarrow> ?thesis
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>Reflected_Multivariate_Polynomial.degree (s -\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p) < Reflected_Multivariate_Polynomial.degree s \<Longrightarrow> ?thesis; s -\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p = 0\<^sub>p \<Longrightarrow> ?thesis\<rbrakk> \<Longrightarrow> ?thesis

goal (1 subgoal):
 1. polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
proof cases
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. Reflected_Multivariate_Polynomial.degree (s -\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p) < Reflected_Multivariate_Polynomial.degree s \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
 2. s -\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p = 0\<^sub>p \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
case deglt: 1
[PROOF STATE]
proof (state)
this:
Reflected_Multivariate_Polynomial.degree (s -\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p) < Reflected_Multivariate_Polynomial.degree s

goal (2 subgoals):
 1. Reflected_Multivariate_Polynomial.degree (s -\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p) < Reflected_Multivariate_Polynomial.degree s \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
 2. s -\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p = 0\<^sub>p \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
from polydivide_aux.simps sz dn' ba
[PROOF STATE]
proof (chain)
picking this:
polydivide_aux ?a ?n ?p ?k ?s = (if ?s = 0\<^sub>p then (?k, ?s) else let b = head ?s; m = Reflected_Multivariate_Polynomial.degree ?s in if m < ?n then (?k, ?s) else let p' = (shift1 ^^ (m - ?n)) ?p in if ?a = b then polydivide_aux ?a ?n ?p ?k (?s -\<^sub>p p') else polydivide_aux ?a ?n ?p (Suc ?k) (?a *\<^sub>p ?s -\<^sub>p (b *\<^sub>p p')))
s \<noteq> 0\<^sub>p
\<not> Reflected_Multivariate_Polynomial.degree s < n
head s = a
[PROOF STEP]
have eq: "polydivide_aux a n p k s = polydivide_aux a n p k (s -\<^sub>p ?p')"
[PROOF STATE]
proof (prove)
using this:
polydivide_aux ?a ?n ?p ?k ?s = (if ?s = 0\<^sub>p then (?k, ?s) else let b = head ?s; m = Reflected_Multivariate_Polynomial.degree ?s in if m < ?n then (?k, ?s) else let p' = (shift1 ^^ (m - ?n)) ?p in if ?a = b then polydivide_aux ?a ?n ?p ?k (?s -\<^sub>p p') else polydivide_aux ?a ?n ?p (Suc ?k) (?a *\<^sub>p ?s -\<^sub>p (b *\<^sub>p p')))
s \<noteq> 0\<^sub>p
\<not> Reflected_Multivariate_Polynomial.degree s < n
head s = a

goal (1 subgoal):
 1. polydivide_aux a n p k s = polydivide_aux a n p k (s -\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p)
[PROOF STEP]
by (simp add: Let_def)
[PROOF STATE]
proof (state)
this:
polydivide_aux a n p k s = polydivide_aux a n p k (s -\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p)

goal (2 subgoals):
 1. Reflected_Multivariate_Polynomial.degree (s -\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p) < Reflected_Multivariate_Polynomial.degree s \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
 2. s -\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p = 0\<^sub>p \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
have "k \<le> k' \<and> (degree r = 0 \<or> degree r < degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> ?qths"
            if h1: "polydivide_aux a n p k s = (k', r)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
from less(1)[OF deglt nr, of k k' r] trans[OF eq[symmetric] h1]
[PROOF STATE]
proof (chain)
picking this:
polydivide_aux a n p k (s -\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p) = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> Ex (isnpolyh r) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p (s -\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p) = p *\<^sub>p q +\<^sub>p r)
polydivide_aux a n p k (s -\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p) = (k', r)
[PROOF STEP]
have kk': "k \<le> k'"
              and nr: "\<exists>nr. isnpolyh r nr"
              and dr: "degree r = 0 \<or> degree r < degree p"
              and q1: "\<exists>q nq. isnpolyh q nq \<and> a ^\<^sub>p k' - k *\<^sub>p (s -\<^sub>p ?p') = p *\<^sub>p q +\<^sub>p r"
[PROOF STATE]
proof (prove)
using this:
polydivide_aux a n p k (s -\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p) = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> Ex (isnpolyh r) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p (s -\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p) = p *\<^sub>p q +\<^sub>p r)
polydivide_aux a n p k (s -\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p) = (k', r)

goal (1 subgoal):
 1. (k \<le> k' &&& \<exists>nr. isnpolyh r nr) &&& Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p &&& \<exists>q nq. isnpolyh q nq \<and> a ^\<^sub>p k' - k *\<^sub>p (s -\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p) = p *\<^sub>p q +\<^sub>p r
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
k \<le> k'
\<exists>nr. isnpolyh r nr
Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p
\<exists>q nq. isnpolyh q nq \<and> a ^\<^sub>p k' - k *\<^sub>p (s -\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p) = p *\<^sub>p q +\<^sub>p r

goal (1 subgoal):
 1. k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
from q1
[PROOF STATE]
proof (chain)
picking this:
\<exists>q nq. isnpolyh q nq \<and> a ^\<^sub>p k' - k *\<^sub>p (s -\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p) = p *\<^sub>p q +\<^sub>p r
[PROOF STEP]
obtain q n1 where nq: "isnpolyh q n1"
              and asp: "a^\<^sub>p (k' - k) *\<^sub>p (s -\<^sub>p ?p') = p *\<^sub>p q +\<^sub>p r"
[PROOF STATE]
proof (prove)
using this:
\<exists>q nq. isnpolyh q nq \<and> a ^\<^sub>p k' - k *\<^sub>p (s -\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p) = p *\<^sub>p q +\<^sub>p r

goal (1 subgoal):
 1. (\<And>q n1. \<lbrakk>isnpolyh q n1; a ^\<^sub>p k' - k *\<^sub>p (s -\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p) = p *\<^sub>p q +\<^sub>p r\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
isnpolyh q n1
a ^\<^sub>p k' - k *\<^sub>p (s -\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p) = p *\<^sub>p q +\<^sub>p r

goal (1 subgoal):
 1. k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
from nr
[PROOF STATE]
proof (chain)
picking this:
\<exists>nr. isnpolyh r nr
[PROOF STEP]
obtain nr where nr': "isnpolyh r nr"
[PROOF STATE]
proof (prove)
using this:
\<exists>nr. isnpolyh r nr

goal (1 subgoal):
 1. (\<And>nr. isnpolyh r nr \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
isnpolyh r nr

goal (1 subgoal):
 1. k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
from polymul_normh[OF nakk' ns]
[PROOF STATE]
proof (chain)
picking this:
isnpolyh (a ^\<^sub>p k' - k *\<^sub>p s) (min 0 n1a__)
[PROOF STEP]
have nakks': "isnpolyh (a ^\<^sub>p (k' - k) *\<^sub>p s) 0"
[PROOF STATE]
proof (prove)
using this:
isnpolyh (a ^\<^sub>p k' - k *\<^sub>p s) (min 0 n1a__)

goal (1 subgoal):
 1. isnpolyh (a ^\<^sub>p k' - k *\<^sub>p s) 0
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
isnpolyh (a ^\<^sub>p k' - k *\<^sub>p s) 0

goal (1 subgoal):
 1. k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
from polyadd_normh[OF polymul_normh[OF nakk' nxdn] nq]
[PROOF STATE]
proof (chain)
picking this:
isnpolyh (a ^\<^sub>p k' - k *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p +\<^sub>p q) (min (min 0 0) n1)
[PROOF STEP]
have nq': "isnpolyh (?akk' *\<^sub>p ?xdn +\<^sub>p q) 0"
[PROOF STATE]
proof (prove)
using this:
isnpolyh (a ^\<^sub>p k' - k *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p +\<^sub>p q) (min (min 0 0) n1)

goal (1 subgoal):
 1. isnpolyh (a ^\<^sub>p k' - k *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p +\<^sub>p q) 0
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
isnpolyh (a ^\<^sub>p k' - k *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p +\<^sub>p q) 0

goal (1 subgoal):
 1. k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
from polyadd_normh[OF polymul_normh[OF np
              polyadd_normh[OF polymul_normh[OF nakk' nxdn] nq]] nr']
[PROOF STATE]
proof (chain)
picking this:
isnpolyh (p *\<^sub>p (a ^\<^sub>p k' - k *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p +\<^sub>p q) +\<^sub>p r) (min (min n0 (min (min 0 0) n1)) nr)
[PROOF STEP]
have nqr': "isnpolyh (p *\<^sub>p (?akk' *\<^sub>p ?xdn +\<^sub>p q) +\<^sub>p r) 0"
[PROOF STATE]
proof (prove)
using this:
isnpolyh (p *\<^sub>p (a ^\<^sub>p k' - k *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p +\<^sub>p q) +\<^sub>p r) (min (min n0 (min (min 0 0) n1)) nr)

goal (1 subgoal):
 1. isnpolyh (p *\<^sub>p (a ^\<^sub>p k' - k *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p +\<^sub>p q) +\<^sub>p r) 0
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
isnpolyh (p *\<^sub>p (a ^\<^sub>p k' - k *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p +\<^sub>p q) +\<^sub>p r) 0

goal (1 subgoal):
 1. k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
from asp
[PROOF STATE]
proof (chain)
picking this:
a ^\<^sub>p k' - k *\<^sub>p (s -\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p) = p *\<^sub>p q +\<^sub>p r
[PROOF STEP]
have "\<forall>bs :: 'a::field_char_0 list.
              Ipoly bs (a^\<^sub>p (k' - k) *\<^sub>p (s -\<^sub>p ?p')) = Ipoly bs (p *\<^sub>p q +\<^sub>p r)"
[PROOF STATE]
proof (prove)
using this:
a ^\<^sub>p k' - k *\<^sub>p (s -\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p) = p *\<^sub>p q +\<^sub>p r

goal (1 subgoal):
 1. \<forall>bs. \<lparr>a ^\<^sub>p k' - k *\<^sub>p (s -\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p)\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>p *\<^sub>p q +\<^sub>p r\<rparr>\<^sub>p\<^bsup>bs\<^esup>
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<forall>bs. \<lparr>a ^\<^sub>p k' - k *\<^sub>p (s -\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p)\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>p *\<^sub>p q +\<^sub>p r\<rparr>\<^sub>p\<^bsup>bs\<^esup>

goal (1 subgoal):
 1. k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<forall>bs. \<lparr>a ^\<^sub>p k' - k *\<^sub>p (s -\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p)\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>p *\<^sub>p q +\<^sub>p r\<rparr>\<^sub>p\<^bsup>bs\<^esup>
[PROOF STEP]
have "\<forall>bs :: 'a::field_char_0 list.
              Ipoly bs (a^\<^sub>p (k' - k)*\<^sub>p s) =
              Ipoly bs (a^\<^sub>p (k' - k)) * Ipoly bs ?p' + Ipoly bs p * Ipoly bs q + Ipoly bs r"
[PROOF STATE]
proof (prove)
using this:
\<forall>bs. \<lparr>a ^\<^sub>p k' - k *\<^sub>p (s -\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p)\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>p *\<^sub>p q +\<^sub>p r\<rparr>\<^sub>p\<^bsup>bs\<^esup>

goal (1 subgoal):
 1. \<forall>bs. \<lparr>a ^\<^sub>p k' - k *\<^sub>p s\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>a ^\<^sub>p k' - k\<rparr>\<^sub>p\<^bsup>bs\<^esup> * \<lparr>(shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p\<rparr>\<^sub>p\<^bsup>bs\<^esup> + \<lparr>p\<rparr>\<^sub>p\<^bsup>bs\<^esup> * \<lparr>q\<rparr>\<^sub>p\<^bsup>bs\<^esup> + \<lparr>r\<rparr>\<^sub>p\<^bsup>bs\<^esup>
[PROOF STEP]
by (simp add: field_simps)
[PROOF STATE]
proof (state)
this:
\<forall>bs. \<lparr>a ^\<^sub>p k' - k *\<^sub>p s\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>a ^\<^sub>p k' - k\<rparr>\<^sub>p\<^bsup>bs\<^esup> * \<lparr>(shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p\<rparr>\<^sub>p\<^bsup>bs\<^esup> + \<lparr>p\<rparr>\<^sub>p\<^bsup>bs\<^esup> * \<lparr>q\<rparr>\<^sub>p\<^bsup>bs\<^esup> + \<lparr>r\<rparr>\<^sub>p\<^bsup>bs\<^esup>

goal (1 subgoal):
 1. k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<forall>bs. \<lparr>a ^\<^sub>p k' - k *\<^sub>p s\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>a ^\<^sub>p k' - k\<rparr>\<^sub>p\<^bsup>bs\<^esup> * \<lparr>(shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p\<rparr>\<^sub>p\<^bsup>bs\<^esup> + \<lparr>p\<rparr>\<^sub>p\<^bsup>bs\<^esup> * \<lparr>q\<rparr>\<^sub>p\<^bsup>bs\<^esup> + \<lparr>r\<rparr>\<^sub>p\<^bsup>bs\<^esup>
[PROOF STEP]
have "\<forall>bs :: 'a::field_char_0 list.
              Ipoly bs (a ^\<^sub>p (k' - k) *\<^sub>p s) =
              Ipoly bs (a^\<^sub>p (k' - k)) * Ipoly bs (funpow (degree s - n) shift1 (1)\<^sub>p *\<^sub>p p) +
              Ipoly bs p * Ipoly bs q + Ipoly bs r"
[PROOF STATE]
proof (prove)
using this:
\<forall>bs. \<lparr>a ^\<^sub>p k' - k *\<^sub>p s\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>a ^\<^sub>p k' - k\<rparr>\<^sub>p\<^bsup>bs\<^esup> * \<lparr>(shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p\<rparr>\<^sub>p\<^bsup>bs\<^esup> + \<lparr>p\<rparr>\<^sub>p\<^bsup>bs\<^esup> * \<lparr>q\<rparr>\<^sub>p\<^bsup>bs\<^esup> + \<lparr>r\<rparr>\<^sub>p\<^bsup>bs\<^esup>

goal (1 subgoal):
 1. \<forall>bs. \<lparr>a ^\<^sub>p k' - k *\<^sub>p s\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>a ^\<^sub>p k' - k\<rparr>\<^sub>p\<^bsup>bs\<^esup> * \<lparr>(shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p *\<^sub>p p\<rparr>\<^sub>p\<^bsup>bs\<^esup> + \<lparr>p\<rparr>\<^sub>p\<^bsup>bs\<^esup> * \<lparr>q\<rparr>\<^sub>p\<^bsup>bs\<^esup> + \<lparr>r\<rparr>\<^sub>p\<^bsup>bs\<^esup>
[PROOF STEP]
by (auto simp only: funpow_shift1_1)
[PROOF STATE]
proof (state)
this:
\<forall>bs. \<lparr>a ^\<^sub>p k' - k *\<^sub>p s\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>a ^\<^sub>p k' - k\<rparr>\<^sub>p\<^bsup>bs\<^esup> * \<lparr>(shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p *\<^sub>p p\<rparr>\<^sub>p\<^bsup>bs\<^esup> + \<lparr>p\<rparr>\<^sub>p\<^bsup>bs\<^esup> * \<lparr>q\<rparr>\<^sub>p\<^bsup>bs\<^esup> + \<lparr>r\<rparr>\<^sub>p\<^bsup>bs\<^esup>

goal (1 subgoal):
 1. k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<forall>bs. \<lparr>a ^\<^sub>p k' - k *\<^sub>p s\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>a ^\<^sub>p k' - k\<rparr>\<^sub>p\<^bsup>bs\<^esup> * \<lparr>(shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p *\<^sub>p p\<rparr>\<^sub>p\<^bsup>bs\<^esup> + \<lparr>p\<rparr>\<^sub>p\<^bsup>bs\<^esup> * \<lparr>q\<rparr>\<^sub>p\<^bsup>bs\<^esup> + \<lparr>r\<rparr>\<^sub>p\<^bsup>bs\<^esup>
[PROOF STEP]
have "\<forall>bs:: 'a::field_char_0 list.
              Ipoly bs (a ^\<^sub>p (k' - k) *\<^sub>p s) =
              Ipoly bs p * (Ipoly bs (a^\<^sub>p (k' - k)) * Ipoly bs (funpow (degree s - n) shift1 (1)\<^sub>p) +
              Ipoly bs q) + Ipoly bs r"
[PROOF STATE]
proof (prove)
using this:
\<forall>bs. \<lparr>a ^\<^sub>p k' - k *\<^sub>p s\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>a ^\<^sub>p k' - k\<rparr>\<^sub>p\<^bsup>bs\<^esup> * \<lparr>(shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p *\<^sub>p p\<rparr>\<^sub>p\<^bsup>bs\<^esup> + \<lparr>p\<rparr>\<^sub>p\<^bsup>bs\<^esup> * \<lparr>q\<rparr>\<^sub>p\<^bsup>bs\<^esup> + \<lparr>r\<rparr>\<^sub>p\<^bsup>bs\<^esup>

goal (1 subgoal):
 1. \<forall>bs. \<lparr>a ^\<^sub>p k' - k *\<^sub>p s\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>p\<rparr>\<^sub>p\<^bsup>bs\<^esup> * (\<lparr>a ^\<^sub>p k' - k\<rparr>\<^sub>p\<^bsup>bs\<^esup> * \<lparr>(shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p\<rparr>\<^sub>p\<^bsup>bs\<^esup> + \<lparr>q\<rparr>\<^sub>p\<^bsup>bs\<^esup>) + \<lparr>r\<rparr>\<^sub>p\<^bsup>bs\<^esup>
[PROOF STEP]
by (simp add: field_simps)
[PROOF STATE]
proof (state)
this:
\<forall>bs. \<lparr>a ^\<^sub>p k' - k *\<^sub>p s\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>p\<rparr>\<^sub>p\<^bsup>bs\<^esup> * (\<lparr>a ^\<^sub>p k' - k\<rparr>\<^sub>p\<^bsup>bs\<^esup> * \<lparr>(shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p\<rparr>\<^sub>p\<^bsup>bs\<^esup> + \<lparr>q\<rparr>\<^sub>p\<^bsup>bs\<^esup>) + \<lparr>r\<rparr>\<^sub>p\<^bsup>bs\<^esup>

goal (1 subgoal):
 1. k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<forall>bs. \<lparr>a ^\<^sub>p k' - k *\<^sub>p s\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>p\<rparr>\<^sub>p\<^bsup>bs\<^esup> * (\<lparr>a ^\<^sub>p k' - k\<rparr>\<^sub>p\<^bsup>bs\<^esup> * \<lparr>(shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p\<rparr>\<^sub>p\<^bsup>bs\<^esup> + \<lparr>q\<rparr>\<^sub>p\<^bsup>bs\<^esup>) + \<lparr>r\<rparr>\<^sub>p\<^bsup>bs\<^esup>
[PROOF STEP]
have "\<forall>bs:: 'a::field_char_0 list.
              Ipoly bs (a ^\<^sub>p (k' - k) *\<^sub>p s) =
              Ipoly bs (p *\<^sub>p ((a^\<^sub>p (k' - k)) *\<^sub>p (funpow (degree s - n) shift1 (1)\<^sub>p) +\<^sub>p q) +\<^sub>p r)"
[PROOF STATE]
proof (prove)
using this:
\<forall>bs. \<lparr>a ^\<^sub>p k' - k *\<^sub>p s\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>p\<rparr>\<^sub>p\<^bsup>bs\<^esup> * (\<lparr>a ^\<^sub>p k' - k\<rparr>\<^sub>p\<^bsup>bs\<^esup> * \<lparr>(shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p\<rparr>\<^sub>p\<^bsup>bs\<^esup> + \<lparr>q\<rparr>\<^sub>p\<^bsup>bs\<^esup>) + \<lparr>r\<rparr>\<^sub>p\<^bsup>bs\<^esup>

goal (1 subgoal):
 1. \<forall>bs. \<lparr>a ^\<^sub>p k' - k *\<^sub>p s\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>p *\<^sub>p (a ^\<^sub>p k' - k *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p +\<^sub>p q) +\<^sub>p r\<rparr>\<^sub>p\<^bsup>bs\<^esup>
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<forall>bs. \<lparr>a ^\<^sub>p k' - k *\<^sub>p s\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>p *\<^sub>p (a ^\<^sub>p k' - k *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p +\<^sub>p q) +\<^sub>p r\<rparr>\<^sub>p\<^bsup>bs\<^esup>

goal (1 subgoal):
 1. k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
with isnpolyh_unique[OF nakks' nqr']
[PROOF STATE]
proof (chain)
picking this:
(\<forall>bs. \<lparr>a ^\<^sub>p k' - k *\<^sub>p s\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>p *\<^sub>p (a ^\<^sub>p k' - k *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p +\<^sub>p q) +\<^sub>p r\<rparr>\<^sub>p\<^bsup>bs\<^esup>) = (a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p (a ^\<^sub>p k' - k *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p +\<^sub>p q) +\<^sub>p r)
\<forall>bs. \<lparr>a ^\<^sub>p k' - k *\<^sub>p s\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>p *\<^sub>p (a ^\<^sub>p k' - k *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p +\<^sub>p q) +\<^sub>p r\<rparr>\<^sub>p\<^bsup>bs\<^esup>
[PROOF STEP]
have "a ^\<^sub>p (k' - k) *\<^sub>p s =
              p *\<^sub>p ((a^\<^sub>p (k' - k)) *\<^sub>p (funpow (degree s - n) shift1 (1)\<^sub>p) +\<^sub>p q) +\<^sub>p r"
[PROOF STATE]
proof (prove)
using this:
(\<forall>bs. \<lparr>a ^\<^sub>p k' - k *\<^sub>p s\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>p *\<^sub>p (a ^\<^sub>p k' - k *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p +\<^sub>p q) +\<^sub>p r\<rparr>\<^sub>p\<^bsup>bs\<^esup>) = (a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p (a ^\<^sub>p k' - k *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p +\<^sub>p q) +\<^sub>p r)
\<forall>bs. \<lparr>a ^\<^sub>p k' - k *\<^sub>p s\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>p *\<^sub>p (a ^\<^sub>p k' - k *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p +\<^sub>p q) +\<^sub>p r\<rparr>\<^sub>p\<^bsup>bs\<^esup>

goal (1 subgoal):
 1. a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p (a ^\<^sub>p k' - k *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p +\<^sub>p q) +\<^sub>p r
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p (a ^\<^sub>p k' - k *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p +\<^sub>p q) +\<^sub>p r

goal (1 subgoal):
 1. k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
with nq'
[PROOF STATE]
proof (chain)
picking this:
isnpolyh (a ^\<^sub>p k' - k *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p +\<^sub>p q) 0
a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p (a ^\<^sub>p k' - k *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p +\<^sub>p q) +\<^sub>p r
[PROOF STEP]
have ?qths
[PROOF STATE]
proof (prove)
using this:
isnpolyh (a ^\<^sub>p k' - k *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p +\<^sub>p q) 0
a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p (a ^\<^sub>p k' - k *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p +\<^sub>p q) +\<^sub>p r

goal (1 subgoal):
 1. \<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r
[PROOF STEP]
apply (rule_tac x="(a^\<^sub>p (k' - k)) *\<^sub>p (funpow (degree s - n) shift1 (1)\<^sub>p) +\<^sub>p q" in exI)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>isnpolyh (a ^\<^sub>p k' - k *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p +\<^sub>p q) 0; a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p (a ^\<^sub>p k' - k *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p +\<^sub>p q) +\<^sub>p r\<rbrakk> \<Longrightarrow> \<exists>n1. isnpolyh (a ^\<^sub>p k' - k *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p +\<^sub>p q) n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p (a ^\<^sub>p k' - k *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p +\<^sub>p q) +\<^sub>p r
[PROOF STEP]
apply (rule_tac x="0" in exI)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>isnpolyh (a ^\<^sub>p k' - k *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p +\<^sub>p q) 0; a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p (a ^\<^sub>p k' - k *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p +\<^sub>p q) +\<^sub>p r\<rbrakk> \<Longrightarrow> isnpolyh (a ^\<^sub>p k' - k *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p +\<^sub>p q) 0 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p (a ^\<^sub>p k' - k *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p +\<^sub>p q) +\<^sub>p r
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r

goal (1 subgoal):
 1. k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
with kk' nr dr
[PROOF STATE]
proof (chain)
picking this:
k \<le> k'
\<exists>nr. isnpolyh r nr
Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p
\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
k \<le> k'
\<exists>nr. isnpolyh r nr
Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p
\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r

goal (1 subgoal):
 1. k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
polydivide_aux a n p k s = (k', r) \<Longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)

goal (2 subgoals):
 1. Reflected_Multivariate_Polynomial.degree (s -\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p) < Reflected_Multivariate_Polynomial.degree s \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
 2. s -\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p = 0\<^sub>p \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
polydivide_aux a n p k s = (k', r) \<Longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
polydivide_aux a n p k s = (k', r) \<Longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)

goal (1 subgoal):
 1. polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)

goal (1 subgoal):
 1. s -\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p = 0\<^sub>p \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. s -\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p = 0\<^sub>p \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
case spz: 2
[PROOF STATE]
proof (state)
this:
s -\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p = 0\<^sub>p

goal (1 subgoal):
 1. s -\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p = 0\<^sub>p \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
from spz isnpolyh_unique[OF polysub_normh[OF ns np'], where q="0\<^sub>p", symmetric, where ?'a = "'a::field_char_0"]
[PROOF STATE]
proof (chain)
picking this:
s -\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p = 0\<^sub>p
isnpolyh 0\<^sub>p ?n1.0 \<Longrightarrow> (s -\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p = 0\<^sub>p) = (\<forall>bs. \<lparr>s -\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>0\<^sub>p\<rparr>\<^sub>p\<^bsup>bs\<^esup>)
[PROOF STEP]
have "\<forall>bs:: 'a::field_char_0 list. Ipoly bs s = Ipoly bs ?p'"
[PROOF STATE]
proof (prove)
using this:
s -\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p = 0\<^sub>p
isnpolyh 0\<^sub>p ?n1.0 \<Longrightarrow> (s -\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p = 0\<^sub>p) = (\<forall>bs. \<lparr>s -\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>0\<^sub>p\<rparr>\<^sub>p\<^bsup>bs\<^esup>)

goal (1 subgoal):
 1. \<forall>bs. \<lparr>s\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>(shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p\<rparr>\<^sub>p\<^bsup>bs\<^esup>
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<forall>bs. \<lparr>s\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>(shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p\<rparr>\<^sub>p\<^bsup>bs\<^esup>

goal (1 subgoal):
 1. s -\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p = 0\<^sub>p \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
with np nxdn
[PROOF STATE]
proof (chain)
picking this:
isnpolyh p n0
isnpolyh ((shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p) 0
\<forall>bs. \<lparr>s\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>(shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p\<rparr>\<^sub>p\<^bsup>bs\<^esup>
[PROOF STEP]
have "\<forall>bs:: 'a::field_char_0 list. Ipoly bs s = Ipoly bs (?xdn *\<^sub>p p)"
[PROOF STATE]
proof (prove)
using this:
isnpolyh p n0
isnpolyh ((shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p) 0
\<forall>bs. \<lparr>s\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>(shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p\<rparr>\<^sub>p\<^bsup>bs\<^esup>

goal (1 subgoal):
 1. \<forall>bs. \<lparr>s\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>(shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p *\<^sub>p p\<rparr>\<^sub>p\<^bsup>bs\<^esup>
[PROOF STEP]
by (simp only: funpow_shift1_1) simp
[PROOF STATE]
proof (state)
this:
\<forall>bs. \<lparr>s\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>(shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p *\<^sub>p p\<rparr>\<^sub>p\<^bsup>bs\<^esup>

goal (1 subgoal):
 1. s -\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p = 0\<^sub>p \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<forall>bs. \<lparr>s\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>(shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p *\<^sub>p p\<rparr>\<^sub>p\<^bsup>bs\<^esup>
[PROOF STEP]
have sp': "s = ?xdn *\<^sub>p p"
[PROOF STATE]
proof (prove)
using this:
\<forall>bs. \<lparr>s\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>(shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p *\<^sub>p p\<rparr>\<^sub>p\<^bsup>bs\<^esup>

goal (1 subgoal):
 1. s = (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p *\<^sub>p p
[PROOF STEP]
using isnpolyh_unique[OF ns polymul_normh[OF nxdn np]]
[PROOF STATE]
proof (prove)
using this:
\<forall>bs. \<lparr>s\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>(shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p *\<^sub>p p\<rparr>\<^sub>p\<^bsup>bs\<^esup>
(\<forall>bs. \<lparr>s\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>(shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p *\<^sub>p p\<rparr>\<^sub>p\<^bsup>bs\<^esup>) = (s = (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p *\<^sub>p p)

goal (1 subgoal):
 1. s = (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p *\<^sub>p p
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
s = (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p *\<^sub>p p

goal (1 subgoal):
 1. s -\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p = 0\<^sub>p \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
have ?thesis if h1: "polydivide_aux a n p k s = (k', r)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
from sz dn' ba
[PROOF STATE]
proof (chain)
picking this:
s \<noteq> 0\<^sub>p
\<not> Reflected_Multivariate_Polynomial.degree s < n
head s = a
[PROOF STEP]
have "polydivide_aux a n p k s = polydivide_aux a n p k (s -\<^sub>p ?p')"
[PROOF STATE]
proof (prove)
using this:
s \<noteq> 0\<^sub>p
\<not> Reflected_Multivariate_Polynomial.degree s < n
head s = a

goal (1 subgoal):
 1. polydivide_aux a n p k s = polydivide_aux a n p k (s -\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p)
[PROOF STEP]
by (simp add: Let_def polydivide_aux.simps)
[PROOF STATE]
proof (state)
this:
polydivide_aux a n p k s = polydivide_aux a n p k (s -\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p)

goal (1 subgoal):
 1. polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
polydivide_aux a n p k s = polydivide_aux a n p k (s -\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p)

goal (1 subgoal):
 1. polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
have "\<dots> = (k,0\<^sub>p)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. polydivide_aux a n p k (s -\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p) = (k, 0\<^sub>p)
[PROOF STEP]
using spz
[PROOF STATE]
proof (prove)
using this:
s -\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p = 0\<^sub>p

goal (1 subgoal):
 1. polydivide_aux a n p k (s -\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p) = (k, 0\<^sub>p)
[PROOF STEP]
by (simp add: polydivide_aux.simps)
[PROOF STATE]
proof (state)
this:
polydivide_aux a n p k (s -\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p) = (k, 0\<^sub>p)

goal (1 subgoal):
 1. polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
polydivide_aux a n p k s = (k, 0\<^sub>p)
[PROOF STEP]
have "(k', r) = (k, 0\<^sub>p)"
[PROOF STATE]
proof (prove)
using this:
polydivide_aux a n p k s = (k, 0\<^sub>p)

goal (1 subgoal):
 1. (k', r) = (k, 0\<^sub>p)
[PROOF STEP]
by (simp add: h1)
[PROOF STATE]
proof (state)
this:
(k', r) = (k, 0\<^sub>p)

goal (1 subgoal):
 1. polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
with sp'[symmetric] ns np nxdn polyadd_0(1)[OF polymul_normh[OF np nxdn]]
              polyadd_0(2)[OF polymul_normh[OF np nxdn]]
[PROOF STATE]
proof (chain)
picking this:
(shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p *\<^sub>p p = s
isnpolyh s n1
isnpolyh p n0
isnpolyh ((shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p) 0
p *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p +\<^sub>p 0\<^sub>p = p *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p
0\<^sub>p +\<^sub>p (p *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p) = p *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p
(k', r) = (k, 0\<^sub>p)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p *\<^sub>p p = s
isnpolyh s n1
isnpolyh p n0
isnpolyh ((shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p) 0
p *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p +\<^sub>p 0\<^sub>p = p *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p
0\<^sub>p +\<^sub>p (p *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p) = p *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p
(k', r) = (k, 0\<^sub>p)

goal (1 subgoal):
 1. polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
apply auto
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>(shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p *\<^sub>p p = s; isnpolyh s n1; isnpolyh p n0; isnpolyh ((shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p) 0; p *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p +\<^sub>p 0\<^sub>p = p *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p; 0\<^sub>p +\<^sub>p (p *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p) = p *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p; k' = k; r = 0\<^sub>p; polydivide_aux a n p k s = (k, 0\<^sub>p)\<rbrakk> \<Longrightarrow> \<exists>q. Ex (isnpolyh q) \<and> s = p *\<^sub>p q +\<^sub>p 0\<^sub>p
[PROOF STEP]
apply (rule exI[where x="?xdn"])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>(shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p *\<^sub>p p = s; isnpolyh s n1; isnpolyh p n0; isnpolyh ((shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p) 0; p *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p +\<^sub>p 0\<^sub>p = p *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p; 0\<^sub>p +\<^sub>p (p *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p) = p *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p; k' = k; r = 0\<^sub>p; polydivide_aux a n p k s = (k, 0\<^sub>p)\<rbrakk> \<Longrightarrow> Ex (isnpolyh ((shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p)) \<and> s = p *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p +\<^sub>p 0\<^sub>p
[PROOF STEP]
apply (auto simp add: polymul_commute[of p])
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
polydivide_aux a n p k s = (k', r) \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)

goal (1 subgoal):
 1. s -\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p = 0\<^sub>p \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
polydivide_aux a n p k s = (k', r) \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
polydivide_aux a n p k s = (k', r) \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)

goal (1 subgoal):
 1. polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)

goal (1 subgoal):
 1. head s \<noteq> a \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. head s \<noteq> a \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
case ba: False
[PROOF STATE]
proof (state)
this:
head s \<noteq> a

goal (1 subgoal):
 1. head s \<noteq> a \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
from polysub_normh[OF polymul_normh[OF head_isnpolyh[OF np0, simplified ap] ns]
          polymul_normh[OF head_isnpolyh[OF ns] np']]
[PROOF STATE]
proof (chain)
picking this:
isnpolyh (a *\<^sub>p s -\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p)) (min (min 0 n1) (min n1 0))
[PROOF STEP]
have nth: "isnpolyh ((a *\<^sub>p s) -\<^sub>p (?b *\<^sub>p ?p')) 0"
[PROOF STATE]
proof (prove)
using this:
isnpolyh (a *\<^sub>p s -\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p)) (min (min 0 n1) (min n1 0))

goal (1 subgoal):
 1. isnpolyh (a *\<^sub>p s -\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p)) 0
[PROOF STEP]
by (simp add: min_def)
[PROOF STATE]
proof (state)
this:
isnpolyh (a *\<^sub>p s -\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p)) 0

goal (1 subgoal):
 1. head s \<noteq> a \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
have nzths: "a *\<^sub>p s \<noteq> 0\<^sub>p" "?b *\<^sub>p ?p' \<noteq> 0\<^sub>p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a *\<^sub>p s \<noteq> 0\<^sub>p &&& head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p \<noteq> 0\<^sub>p
[PROOF STEP]
using polymul_eq0_iff[OF head_isnpolyh[OF np0, simplified ap] ns]
            polymul_eq0_iff[OF head_isnpolyh[OF ns] np']head_nz[OF np0] ap pnz sz head_nz[OF ns]
            funpow_shift1_nz[OF pnz]
[PROOF STATE]
proof (prove)
using this:
(a *\<^sub>p s = 0\<^sub>p) = (a = 0\<^sub>p \<or> s = 0\<^sub>p)
(head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p = 0\<^sub>p) = (head s = 0\<^sub>p \<or> (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p = 0\<^sub>p)
(head p = 0\<^sub>p) = (p = 0\<^sub>p)
head p = a
p \<noteq> 0\<^sub>p
s \<noteq> 0\<^sub>p
(head s = 0\<^sub>p) = (s = 0\<^sub>p)
(shift1 ^^ ?n) p \<noteq> 0\<^sub>p

goal (1 subgoal):
 1. a *\<^sub>p s \<noteq> 0\<^sub>p &&& head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p \<noteq> 0\<^sub>p
[PROOF STEP]
by simp_all
[PROOF STATE]
proof (state)
this:
a *\<^sub>p s \<noteq> 0\<^sub>p
head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p \<noteq> 0\<^sub>p

goal (1 subgoal):
 1. head s \<noteq> a \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
from polymul_head_polyeq[OF head_isnpolyh[OF np] ns] head_nz[OF np] sz ap head_head[OF np] pnz
          polymul_head_polyeq[OF head_isnpolyh[OF ns] np'] head_nz [OF ns] sz
          funpow_shift1_nz[OF pnz, where n="degree s - n"]
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>head p \<noteq> 0\<^sub>p; s \<noteq> 0\<^sub>p\<rbrakk> \<Longrightarrow> head (head p *\<^sub>p s) = head (head p) *\<^sub>p head s
(head p = 0\<^sub>p) = (p = 0\<^sub>p)
s \<noteq> 0\<^sub>p
head p = a
head (head p) = head p
p \<noteq> 0\<^sub>p
\<lbrakk>head s \<noteq> 0\<^sub>p; (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p \<noteq> 0\<^sub>p\<rbrakk> \<Longrightarrow> head (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p) = head (head s) *\<^sub>p head ((shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p)
(head s = 0\<^sub>p) = (s = 0\<^sub>p)
s \<noteq> 0\<^sub>p
(shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p \<noteq> 0\<^sub>p
[PROOF STEP]
have hdth: "head (a *\<^sub>p s) = head (?b *\<^sub>p ?p')"
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>head p \<noteq> 0\<^sub>p; s \<noteq> 0\<^sub>p\<rbrakk> \<Longrightarrow> head (head p *\<^sub>p s) = head (head p) *\<^sub>p head s
(head p = 0\<^sub>p) = (p = 0\<^sub>p)
s \<noteq> 0\<^sub>p
head p = a
head (head p) = head p
p \<noteq> 0\<^sub>p
\<lbrakk>head s \<noteq> 0\<^sub>p; (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p \<noteq> 0\<^sub>p\<rbrakk> \<Longrightarrow> head (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p) = head (head s) *\<^sub>p head ((shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p)
(head s = 0\<^sub>p) = (s = 0\<^sub>p)
s \<noteq> 0\<^sub>p
(shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p \<noteq> 0\<^sub>p

goal (1 subgoal):
 1. head (a *\<^sub>p s) = head (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p)
[PROOF STEP]
using head_head[OF ns] funpow_shift1_head[OF np pnz]
            polymul_commute[OF head_isnpolyh[OF np] head_isnpolyh[OF ns]]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>head p \<noteq> 0\<^sub>p; s \<noteq> 0\<^sub>p\<rbrakk> \<Longrightarrow> head (head p *\<^sub>p s) = head (head p) *\<^sub>p head s
(head p = 0\<^sub>p) = (p = 0\<^sub>p)
s \<noteq> 0\<^sub>p
head p = a
head (head p) = head p
p \<noteq> 0\<^sub>p
\<lbrakk>head s \<noteq> 0\<^sub>p; (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p \<noteq> 0\<^sub>p\<rbrakk> \<Longrightarrow> head (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p) = head (head s) *\<^sub>p head ((shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p)
(head s = 0\<^sub>p) = (s = 0\<^sub>p)
s \<noteq> 0\<^sub>p
(shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p \<noteq> 0\<^sub>p
head (head s) = head s
head ((shift1 ^^ ?k) p) = head p
head p *\<^sub>p head s = head s *\<^sub>p head p

goal (1 subgoal):
 1. head (a *\<^sub>p s) = head (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p)
[PROOF STEP]
by (simp add: ap)
[PROOF STATE]
proof (state)
this:
head (a *\<^sub>p s) = head (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p)

goal (1 subgoal):
 1. head s \<noteq> a \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
from polymul_degreen[OF head_isnpolyh[OF np] ns, where m="0"]
          head_nz[OF np] pnz sz ap[symmetric]
          funpow_shift1_nz[OF pnz, where n="degree s - n"]
          polymul_degreen[OF head_isnpolyh[OF ns] np', where m="0"] head_nz[OF ns]
          ndp dn
[PROOF STATE]
proof (chain)
picking this:
0 \<le> min n0 n1 \<Longrightarrow> degreen (head p *\<^sub>p s) 0 = (if head p = 0\<^sub>p \<or> s = 0\<^sub>p then 0 else degreen (head p) 0 + degreen s 0)
(head p = 0\<^sub>p) = (p = 0\<^sub>p)
p \<noteq> 0\<^sub>p
s \<noteq> 0\<^sub>p
a = head p
(shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p \<noteq> 0\<^sub>p
0 \<le> min n1 0 \<Longrightarrow> degreen (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p) 0 = (if head s = 0\<^sub>p \<or> (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p = 0\<^sub>p then 0 else degreen (head s) 0 + degreen ((shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p) 0)
(head s = 0\<^sub>p) = (s = 0\<^sub>p)
Reflected_Multivariate_Polynomial.degree p = n
n \<le> Reflected_Multivariate_Polynomial.degree s
[PROOF STEP]
have degth: "degree (a *\<^sub>p s) = degree (?b *\<^sub>p ?p')"
[PROOF STATE]
proof (prove)
using this:
0 \<le> min n0 n1 \<Longrightarrow> degreen (head p *\<^sub>p s) 0 = (if head p = 0\<^sub>p \<or> s = 0\<^sub>p then 0 else degreen (head p) 0 + degreen s 0)
(head p = 0\<^sub>p) = (p = 0\<^sub>p)
p \<noteq> 0\<^sub>p
s \<noteq> 0\<^sub>p
a = head p
(shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p \<noteq> 0\<^sub>p
0 \<le> min n1 0 \<Longrightarrow> degreen (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p) 0 = (if head s = 0\<^sub>p \<or> (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p = 0\<^sub>p then 0 else degreen (head s) 0 + degreen ((shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p) 0)
(head s = 0\<^sub>p) = (s = 0\<^sub>p)
Reflected_Multivariate_Polynomial.degree p = n
n \<le> Reflected_Multivariate_Polynomial.degree s

goal (1 subgoal):
 1. Reflected_Multivariate_Polynomial.degree (a *\<^sub>p s) = Reflected_Multivariate_Polynomial.degree (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p)
[PROOF STEP]
by (simp add: degree_eq_degreen0[symmetric] funpow_shift1_degree)
[PROOF STATE]
proof (state)
this:
Reflected_Multivariate_Polynomial.degree (a *\<^sub>p s) = Reflected_Multivariate_Polynomial.degree (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p)

goal (1 subgoal):
 1. head s \<noteq> a \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
consider "degree ((a *\<^sub>p s) -\<^sub>p (?b *\<^sub>p ?p')) < degree s" | "a *\<^sub>p s -\<^sub>p (?b *\<^sub>p ?p') = 0\<^sub>p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>Reflected_Multivariate_Polynomial.degree (a *\<^sub>p s -\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p)) < Reflected_Multivariate_Polynomial.degree s \<Longrightarrow> thesis; a *\<^sub>p s -\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p) = 0\<^sub>p \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
using degree_polysub_samehead[OF polymul_normh[OF head_isnpolyh[OF np0, simplified ap] ns]
            polymul_normh[OF head_isnpolyh[OF ns] np'] hdth degth]
            polymul_degreen[OF head_isnpolyh[OF np] ns, where m="0"]
            head_nz[OF np] pnz sz ap[symmetric]
[PROOF STATE]
proof (prove)
using this:
Reflected_Multivariate_Polynomial.degree (a *\<^sub>p s -\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p)) < Reflected_Multivariate_Polynomial.degree (a *\<^sub>p s) \<or> a *\<^sub>p s -\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p) = 0\<^sub>p
0 \<le> min n0 n1 \<Longrightarrow> degreen (head p *\<^sub>p s) 0 = (if head p = 0\<^sub>p \<or> s = 0\<^sub>p then 0 else degreen (head p) 0 + degreen s 0)
(head p = 0\<^sub>p) = (p = 0\<^sub>p)
p \<noteq> 0\<^sub>p
s \<noteq> 0\<^sub>p
a = head p

goal (1 subgoal):
 1. \<lbrakk>Reflected_Multivariate_Polynomial.degree (a *\<^sub>p s -\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p)) < Reflected_Multivariate_Polynomial.degree s \<Longrightarrow> thesis; a *\<^sub>p s -\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p) = 0\<^sub>p \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
by (auto simp add: degree_eq_degreen0[symmetric])
[PROOF STATE]
proof (state)
this:
\<lbrakk>Reflected_Multivariate_Polynomial.degree (a *\<^sub>p s -\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p)) < Reflected_Multivariate_Polynomial.degree s \<Longrightarrow> ?thesis; a *\<^sub>p s -\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p) = 0\<^sub>p \<Longrightarrow> ?thesis\<rbrakk> \<Longrightarrow> ?thesis

goal (1 subgoal):
 1. head s \<noteq> a \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>Reflected_Multivariate_Polynomial.degree (a *\<^sub>p s -\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p)) < Reflected_Multivariate_Polynomial.degree s \<Longrightarrow> ?thesis; a *\<^sub>p s -\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p) = 0\<^sub>p \<Longrightarrow> ?thesis\<rbrakk> \<Longrightarrow> ?thesis
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>Reflected_Multivariate_Polynomial.degree (a *\<^sub>p s -\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p)) < Reflected_Multivariate_Polynomial.degree s \<Longrightarrow> ?thesis; a *\<^sub>p s -\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p) = 0\<^sub>p \<Longrightarrow> ?thesis\<rbrakk> \<Longrightarrow> ?thesis

goal (1 subgoal):
 1. polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
proof cases
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. Reflected_Multivariate_Polynomial.degree (a *\<^sub>p s -\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p)) < Reflected_Multivariate_Polynomial.degree s \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
 2. a *\<^sub>p s -\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p) = 0\<^sub>p \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
case dth: 1
[PROOF STATE]
proof (state)
this:
Reflected_Multivariate_Polynomial.degree (a *\<^sub>p s -\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p)) < Reflected_Multivariate_Polynomial.degree s

goal (2 subgoals):
 1. Reflected_Multivariate_Polynomial.degree (a *\<^sub>p s -\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p)) < Reflected_Multivariate_Polynomial.degree s \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
 2. a *\<^sub>p s -\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p) = 0\<^sub>p \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
from polysub_normh[OF polymul_normh[OF head_isnpolyh[OF np] ns]
            polymul_normh[OF head_isnpolyh[OF ns]np']] ap
[PROOF STATE]
proof (chain)
picking this:
isnpolyh (head p *\<^sub>p s -\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p)) (min (min n0 n1) (min n1 0))
head p = a
[PROOF STEP]
have nasbp': "isnpolyh ((a *\<^sub>p s) -\<^sub>p (?b *\<^sub>p ?p')) 0"
[PROOF STATE]
proof (prove)
using this:
isnpolyh (head p *\<^sub>p s -\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p)) (min (min n0 n1) (min n1 0))
head p = a

goal (1 subgoal):
 1. isnpolyh (a *\<^sub>p s -\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p)) 0
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
isnpolyh (a *\<^sub>p s -\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p)) 0

goal (2 subgoals):
 1. Reflected_Multivariate_Polynomial.degree (a *\<^sub>p s -\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p)) < Reflected_Multivariate_Polynomial.degree s \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
 2. a *\<^sub>p s -\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p) = 0\<^sub>p \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
have ?thesis if h1: "polydivide_aux a n p k s = (k', r)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
from h1 polydivide_aux.simps sz dn' ba
[PROOF STATE]
proof (chain)
picking this:
polydivide_aux a n p k s = (k', r)
polydivide_aux ?a ?n ?p ?k ?s = (if ?s = 0\<^sub>p then (?k, ?s) else let b = head ?s; m = Reflected_Multivariate_Polynomial.degree ?s in if m < ?n then (?k, ?s) else let p' = (shift1 ^^ (m - ?n)) ?p in if ?a = b then polydivide_aux ?a ?n ?p ?k (?s -\<^sub>p p') else polydivide_aux ?a ?n ?p (Suc ?k) (?a *\<^sub>p ?s -\<^sub>p (b *\<^sub>p p')))
s \<noteq> 0\<^sub>p
\<not> Reflected_Multivariate_Polynomial.degree s < n
head s \<noteq> a
[PROOF STEP]
have eq:"polydivide_aux a n p (Suc k) ((a *\<^sub>p s) -\<^sub>p (?b *\<^sub>p ?p')) = (k',r)"
[PROOF STATE]
proof (prove)
using this:
polydivide_aux a n p k s = (k', r)
polydivide_aux ?a ?n ?p ?k ?s = (if ?s = 0\<^sub>p then (?k, ?s) else let b = head ?s; m = Reflected_Multivariate_Polynomial.degree ?s in if m < ?n then (?k, ?s) else let p' = (shift1 ^^ (m - ?n)) ?p in if ?a = b then polydivide_aux ?a ?n ?p ?k (?s -\<^sub>p p') else polydivide_aux ?a ?n ?p (Suc ?k) (?a *\<^sub>p ?s -\<^sub>p (b *\<^sub>p p')))
s \<noteq> 0\<^sub>p
\<not> Reflected_Multivariate_Polynomial.degree s < n
head s \<noteq> a

goal (1 subgoal):
 1. polydivide_aux a n p (Suc k) (a *\<^sub>p s -\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p)) = (k', r)
[PROOF STEP]
by (simp add: Let_def)
[PROOF STATE]
proof (state)
this:
polydivide_aux a n p (Suc k) (a *\<^sub>p s -\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p)) = (k', r)

goal (1 subgoal):
 1. polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
with less(1)[OF dth nasbp', of "Suc k" k' r]
[PROOF STATE]
proof (chain)
picking this:
polydivide_aux a n p (Suc k) (a *\<^sub>p s -\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p)) = (k', r) \<longrightarrow> Suc k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> Ex (isnpolyh r) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - Suc k *\<^sub>p (a *\<^sub>p s -\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p)) = p *\<^sub>p q +\<^sub>p r)
polydivide_aux a n p (Suc k) (a *\<^sub>p s -\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p)) = (k', r)
[PROOF STEP]
obtain q nq nr where kk': "Suc k \<le> k'"
              and nr: "isnpolyh r nr"
              and nq: "isnpolyh q nq"
              and dr: "degree r = 0 \<or> degree r < degree p"
              and qr: "a ^\<^sub>p (k' - Suc k) *\<^sub>p ((a *\<^sub>p s) -\<^sub>p (?b *\<^sub>p ?p')) = p *\<^sub>p q +\<^sub>p r"
[PROOF STATE]
proof (prove)
using this:
polydivide_aux a n p (Suc k) (a *\<^sub>p s -\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p)) = (k', r) \<longrightarrow> Suc k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> Ex (isnpolyh r) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - Suc k *\<^sub>p (a *\<^sub>p s -\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p)) = p *\<^sub>p q +\<^sub>p r)
polydivide_aux a n p (Suc k) (a *\<^sub>p s -\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p)) = (k', r)

goal (1 subgoal):
 1. (\<And>nr q nq. \<lbrakk>Suc k \<le> k'; isnpolyh r nr; isnpolyh q nq; Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p; a ^\<^sub>p k' - Suc k *\<^sub>p (a *\<^sub>p s -\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p)) = p *\<^sub>p q +\<^sub>p r\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
Suc k \<le> k'
isnpolyh r nr
isnpolyh q nq
Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p
a ^\<^sub>p k' - Suc k *\<^sub>p (a *\<^sub>p s -\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p)) = p *\<^sub>p q +\<^sub>p r

goal (1 subgoal):
 1. polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
from kk'
[PROOF STATE]
proof (chain)
picking this:
Suc k \<le> k'
[PROOF STEP]
have kk'': "Suc (k' - Suc k) = k' - k"
[PROOF STATE]
proof (prove)
using this:
Suc k \<le> k'

goal (1 subgoal):
 1. Suc (k' - Suc k) = k' - k
[PROOF STEP]
by arith
[PROOF STATE]
proof (state)
this:
Suc (k' - Suc k) = k' - k

goal (1 subgoal):
 1. polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
have "Ipoly bs (a ^\<^sub>p (k' - k) *\<^sub>p s) =
                Ipoly bs p * (Ipoly bs q + Ipoly bs a ^ (k' - Suc k) * Ipoly bs ?b * Ipoly bs ?xdn) + Ipoly bs r"
              for bs :: "'a::field_char_0 list"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lparr>a ^\<^sub>p k' - k *\<^sub>p s\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>p\<rparr>\<^sub>p\<^bsup>bs\<^esup> * (\<lparr>q\<rparr>\<^sub>p\<^bsup>bs\<^esup> + \<lparr>a\<rparr>\<^sub>p\<^bsup>bs\<^esup> ^ (k' - Suc k) * \<lparr>head s\<rparr>\<^sub>p\<^bsup>bs\<^esup> * \<lparr>(shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p\<rparr>\<^sub>p\<^bsup>bs\<^esup>) + \<lparr>r\<rparr>\<^sub>p\<^bsup>bs\<^esup>
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<lparr>a ^\<^sub>p k' - k *\<^sub>p s\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>p\<rparr>\<^sub>p\<^bsup>bs\<^esup> * (\<lparr>q\<rparr>\<^sub>p\<^bsup>bs\<^esup> + \<lparr>a\<rparr>\<^sub>p\<^bsup>bs\<^esup> ^ (k' - Suc k) * \<lparr>head s\<rparr>\<^sub>p\<^bsup>bs\<^esup> * \<lparr>(shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p\<rparr>\<^sub>p\<^bsup>bs\<^esup>) + \<lparr>r\<rparr>\<^sub>p\<^bsup>bs\<^esup>
[PROOF STEP]
from qr isnpolyh_unique[OF polypow_normh[OF head_isnpolyh[OF np], where k="k' - Suc k", simplified ap] nasbp', symmetric]
[PROOF STATE]
proof (chain)
picking this:
a ^\<^sub>p k' - Suc k *\<^sub>p (a *\<^sub>p s -\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p)) = p *\<^sub>p q +\<^sub>p r
(a ^\<^sub>p k' - Suc k = a *\<^sub>p s -\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p)) = (\<forall>bs. \<lparr>a ^\<^sub>p k' - Suc k\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>a *\<^sub>p s -\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p)\<rparr>\<^sub>p\<^bsup>bs\<^esup>)
[PROOF STEP]
have "Ipoly bs (a ^\<^sub>p (k' - Suc k) *\<^sub>p ((a *\<^sub>p s) -\<^sub>p (?b *\<^sub>p ?p'))) = Ipoly bs (p *\<^sub>p q +\<^sub>p r)"
[PROOF STATE]
proof (prove)
using this:
a ^\<^sub>p k' - Suc k *\<^sub>p (a *\<^sub>p s -\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p)) = p *\<^sub>p q +\<^sub>p r
(a ^\<^sub>p k' - Suc k = a *\<^sub>p s -\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p)) = (\<forall>bs. \<lparr>a ^\<^sub>p k' - Suc k\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>a *\<^sub>p s -\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p)\<rparr>\<^sub>p\<^bsup>bs\<^esup>)

goal (1 subgoal):
 1. \<lparr>a ^\<^sub>p k' - Suc k *\<^sub>p (a *\<^sub>p s -\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p))\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>p *\<^sub>p q +\<^sub>p r\<rparr>\<^sub>p\<^bsup>bs\<^esup>
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<lparr>a ^\<^sub>p k' - Suc k *\<^sub>p (a *\<^sub>p s -\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p))\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>p *\<^sub>p q +\<^sub>p r\<rparr>\<^sub>p\<^bsup>bs\<^esup>

goal (1 subgoal):
 1. \<lparr>a ^\<^sub>p k' - k *\<^sub>p s\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>p\<rparr>\<^sub>p\<^bsup>bs\<^esup> * (\<lparr>q\<rparr>\<^sub>p\<^bsup>bs\<^esup> + \<lparr>a\<rparr>\<^sub>p\<^bsup>bs\<^esup> ^ (k' - Suc k) * \<lparr>head s\<rparr>\<^sub>p\<^bsup>bs\<^esup> * \<lparr>(shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p\<rparr>\<^sub>p\<^bsup>bs\<^esup>) + \<lparr>r\<rparr>\<^sub>p\<^bsup>bs\<^esup>
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<lparr>a ^\<^sub>p k' - Suc k *\<^sub>p (a *\<^sub>p s -\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p))\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>p *\<^sub>p q +\<^sub>p r\<rparr>\<^sub>p\<^bsup>bs\<^esup>
[PROOF STEP]
have "Ipoly bs a ^ (Suc (k' - Suc k)) * Ipoly bs s =
                Ipoly bs p * Ipoly bs q + Ipoly bs a ^ (k' - Suc k) * Ipoly bs ?b * Ipoly bs ?p' + Ipoly bs r"
[PROOF STATE]
proof (prove)
using this:
\<lparr>a ^\<^sub>p k' - Suc k *\<^sub>p (a *\<^sub>p s -\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p))\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>p *\<^sub>p q +\<^sub>p r\<rparr>\<^sub>p\<^bsup>bs\<^esup>

goal (1 subgoal):
 1. \<lparr>a\<rparr>\<^sub>p\<^bsup>bs\<^esup> ^ Suc (k' - Suc k) * \<lparr>s\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>p\<rparr>\<^sub>p\<^bsup>bs\<^esup> * \<lparr>q\<rparr>\<^sub>p\<^bsup>bs\<^esup> + \<lparr>a\<rparr>\<^sub>p\<^bsup>bs\<^esup> ^ (k' - Suc k) * \<lparr>head s\<rparr>\<^sub>p\<^bsup>bs\<^esup> * \<lparr>(shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p\<rparr>\<^sub>p\<^bsup>bs\<^esup> + \<lparr>r\<rparr>\<^sub>p\<^bsup>bs\<^esup>
[PROOF STEP]
by (simp add: field_simps)
[PROOF STATE]
proof (state)
this:
\<lparr>a\<rparr>\<^sub>p\<^bsup>bs\<^esup> ^ Suc (k' - Suc k) * \<lparr>s\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>p\<rparr>\<^sub>p\<^bsup>bs\<^esup> * \<lparr>q\<rparr>\<^sub>p\<^bsup>bs\<^esup> + \<lparr>a\<rparr>\<^sub>p\<^bsup>bs\<^esup> ^ (k' - Suc k) * \<lparr>head s\<rparr>\<^sub>p\<^bsup>bs\<^esup> * \<lparr>(shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p\<rparr>\<^sub>p\<^bsup>bs\<^esup> + \<lparr>r\<rparr>\<^sub>p\<^bsup>bs\<^esup>

goal (1 subgoal):
 1. \<lparr>a ^\<^sub>p k' - k *\<^sub>p s\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>p\<rparr>\<^sub>p\<^bsup>bs\<^esup> * (\<lparr>q\<rparr>\<^sub>p\<^bsup>bs\<^esup> + \<lparr>a\<rparr>\<^sub>p\<^bsup>bs\<^esup> ^ (k' - Suc k) * \<lparr>head s\<rparr>\<^sub>p\<^bsup>bs\<^esup> * \<lparr>(shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p\<rparr>\<^sub>p\<^bsup>bs\<^esup>) + \<lparr>r\<rparr>\<^sub>p\<^bsup>bs\<^esup>
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<lparr>a\<rparr>\<^sub>p\<^bsup>bs\<^esup> ^ Suc (k' - Suc k) * \<lparr>s\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>p\<rparr>\<^sub>p\<^bsup>bs\<^esup> * \<lparr>q\<rparr>\<^sub>p\<^bsup>bs\<^esup> + \<lparr>a\<rparr>\<^sub>p\<^bsup>bs\<^esup> ^ (k' - Suc k) * \<lparr>head s\<rparr>\<^sub>p\<^bsup>bs\<^esup> * \<lparr>(shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p\<rparr>\<^sub>p\<^bsup>bs\<^esup> + \<lparr>r\<rparr>\<^sub>p\<^bsup>bs\<^esup>
[PROOF STEP]
have "Ipoly bs a ^ (k' - k)  * Ipoly bs s =
                Ipoly bs p * Ipoly bs q + Ipoly bs a ^ (k' - Suc k) * Ipoly bs ?b * Ipoly bs ?xdn * Ipoly bs p + Ipoly bs r"
[PROOF STATE]
proof (prove)
using this:
\<lparr>a\<rparr>\<^sub>p\<^bsup>bs\<^esup> ^ Suc (k' - Suc k) * \<lparr>s\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>p\<rparr>\<^sub>p\<^bsup>bs\<^esup> * \<lparr>q\<rparr>\<^sub>p\<^bsup>bs\<^esup> + \<lparr>a\<rparr>\<^sub>p\<^bsup>bs\<^esup> ^ (k' - Suc k) * \<lparr>head s\<rparr>\<^sub>p\<^bsup>bs\<^esup> * \<lparr>(shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p\<rparr>\<^sub>p\<^bsup>bs\<^esup> + \<lparr>r\<rparr>\<^sub>p\<^bsup>bs\<^esup>

goal (1 subgoal):
 1. \<lparr>a\<rparr>\<^sub>p\<^bsup>bs\<^esup> ^ (k' - k) * \<lparr>s\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>p\<rparr>\<^sub>p\<^bsup>bs\<^esup> * \<lparr>q\<rparr>\<^sub>p\<^bsup>bs\<^esup> + \<lparr>a\<rparr>\<^sub>p\<^bsup>bs\<^esup> ^ (k' - Suc k) * \<lparr>head s\<rparr>\<^sub>p\<^bsup>bs\<^esup> * \<lparr>(shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p\<rparr>\<^sub>p\<^bsup>bs\<^esup> * \<lparr>p\<rparr>\<^sub>p\<^bsup>bs\<^esup> + \<lparr>r\<rparr>\<^sub>p\<^bsup>bs\<^esup>
[PROOF STEP]
by (simp add: kk'' funpow_shift1_1[where n="degree s - n" and p="p"])
[PROOF STATE]
proof (state)
this:
\<lparr>a\<rparr>\<^sub>p\<^bsup>bs\<^esup> ^ (k' - k) * \<lparr>s\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>p\<rparr>\<^sub>p\<^bsup>bs\<^esup> * \<lparr>q\<rparr>\<^sub>p\<^bsup>bs\<^esup> + \<lparr>a\<rparr>\<^sub>p\<^bsup>bs\<^esup> ^ (k' - Suc k) * \<lparr>head s\<rparr>\<^sub>p\<^bsup>bs\<^esup> * \<lparr>(shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p\<rparr>\<^sub>p\<^bsup>bs\<^esup> * \<lparr>p\<rparr>\<^sub>p\<^bsup>bs\<^esup> + \<lparr>r\<rparr>\<^sub>p\<^bsup>bs\<^esup>

goal (1 subgoal):
 1. \<lparr>a ^\<^sub>p k' - k *\<^sub>p s\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>p\<rparr>\<^sub>p\<^bsup>bs\<^esup> * (\<lparr>q\<rparr>\<^sub>p\<^bsup>bs\<^esup> + \<lparr>a\<rparr>\<^sub>p\<^bsup>bs\<^esup> ^ (k' - Suc k) * \<lparr>head s\<rparr>\<^sub>p\<^bsup>bs\<^esup> * \<lparr>(shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p\<rparr>\<^sub>p\<^bsup>bs\<^esup>) + \<lparr>r\<rparr>\<^sub>p\<^bsup>bs\<^esup>
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<lparr>a\<rparr>\<^sub>p\<^bsup>bs\<^esup> ^ (k' - k) * \<lparr>s\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>p\<rparr>\<^sub>p\<^bsup>bs\<^esup> * \<lparr>q\<rparr>\<^sub>p\<^bsup>bs\<^esup> + \<lparr>a\<rparr>\<^sub>p\<^bsup>bs\<^esup> ^ (k' - Suc k) * \<lparr>head s\<rparr>\<^sub>p\<^bsup>bs\<^esup> * \<lparr>(shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p\<rparr>\<^sub>p\<^bsup>bs\<^esup> * \<lparr>p\<rparr>\<^sub>p\<^bsup>bs\<^esup> + \<lparr>r\<rparr>\<^sub>p\<^bsup>bs\<^esup>
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<lparr>a\<rparr>\<^sub>p\<^bsup>bs\<^esup> ^ (k' - k) * \<lparr>s\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>p\<rparr>\<^sub>p\<^bsup>bs\<^esup> * \<lparr>q\<rparr>\<^sub>p\<^bsup>bs\<^esup> + \<lparr>a\<rparr>\<^sub>p\<^bsup>bs\<^esup> ^ (k' - Suc k) * \<lparr>head s\<rparr>\<^sub>p\<^bsup>bs\<^esup> * \<lparr>(shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p\<rparr>\<^sub>p\<^bsup>bs\<^esup> * \<lparr>p\<rparr>\<^sub>p\<^bsup>bs\<^esup> + \<lparr>r\<rparr>\<^sub>p\<^bsup>bs\<^esup>

goal (1 subgoal):
 1. \<lparr>a ^\<^sub>p k' - k *\<^sub>p s\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>p\<rparr>\<^sub>p\<^bsup>bs\<^esup> * (\<lparr>q\<rparr>\<^sub>p\<^bsup>bs\<^esup> + \<lparr>a\<rparr>\<^sub>p\<^bsup>bs\<^esup> ^ (k' - Suc k) * \<lparr>head s\<rparr>\<^sub>p\<^bsup>bs\<^esup> * \<lparr>(shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p\<rparr>\<^sub>p\<^bsup>bs\<^esup>) + \<lparr>r\<rparr>\<^sub>p\<^bsup>bs\<^esup>
[PROOF STEP]
by (simp add: field_simps)
[PROOF STATE]
proof (state)
this:
\<lparr>a ^\<^sub>p k' - k *\<^sub>p s\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>p\<rparr>\<^sub>p\<^bsup>bs\<^esup> * (\<lparr>q\<rparr>\<^sub>p\<^bsup>bs\<^esup> + \<lparr>a\<rparr>\<^sub>p\<^bsup>bs\<^esup> ^ (k' - Suc k) * \<lparr>head s\<rparr>\<^sub>p\<^bsup>bs\<^esup> * \<lparr>(shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p\<rparr>\<^sub>p\<^bsup>bs\<^esup>) + \<lparr>r\<rparr>\<^sub>p\<^bsup>bs\<^esup>

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<lparr>a ^\<^sub>p k' - k *\<^sub>p s\<rparr>\<^sub>p\<^bsup>?bs\<^esup> = \<lparr>p\<rparr>\<^sub>p\<^bsup>?bs\<^esup> * (\<lparr>q\<rparr>\<^sub>p\<^bsup>?bs\<^esup> + \<lparr>a\<rparr>\<^sub>p\<^bsup>?bs\<^esup> ^ (k' - Suc k) * \<lparr>head s\<rparr>\<^sub>p\<^bsup>?bs\<^esup> * \<lparr>(shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p\<rparr>\<^sub>p\<^bsup>?bs\<^esup>) + \<lparr>r\<rparr>\<^sub>p\<^bsup>?bs\<^esup>

goal (1 subgoal):
 1. polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<lparr>a ^\<^sub>p k' - k *\<^sub>p s\<rparr>\<^sub>p\<^bsup>?bs\<^esup> = \<lparr>p\<rparr>\<^sub>p\<^bsup>?bs\<^esup> * (\<lparr>q\<rparr>\<^sub>p\<^bsup>?bs\<^esup> + \<lparr>a\<rparr>\<^sub>p\<^bsup>?bs\<^esup> ^ (k' - Suc k) * \<lparr>head s\<rparr>\<^sub>p\<^bsup>?bs\<^esup> * \<lparr>(shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p\<rparr>\<^sub>p\<^bsup>?bs\<^esup>) + \<lparr>r\<rparr>\<^sub>p\<^bsup>?bs\<^esup>
[PROOF STEP]
have ieq: "\<forall>bs :: 'a::field_char_0 list.
                Ipoly bs (a ^\<^sub>p (k' - k) *\<^sub>p s) =
                Ipoly bs (p *\<^sub>p (q +\<^sub>p (a ^\<^sub>p (k' - Suc k) *\<^sub>p ?b *\<^sub>p ?xdn)) +\<^sub>p r)"
[PROOF STATE]
proof (prove)
using this:
\<lparr>a ^\<^sub>p k' - k *\<^sub>p s\<rparr>\<^sub>p\<^bsup>?bs\<^esup> = \<lparr>p\<rparr>\<^sub>p\<^bsup>?bs\<^esup> * (\<lparr>q\<rparr>\<^sub>p\<^bsup>?bs\<^esup> + \<lparr>a\<rparr>\<^sub>p\<^bsup>?bs\<^esup> ^ (k' - Suc k) * \<lparr>head s\<rparr>\<^sub>p\<^bsup>?bs\<^esup> * \<lparr>(shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p\<rparr>\<^sub>p\<^bsup>?bs\<^esup>) + \<lparr>r\<rparr>\<^sub>p\<^bsup>?bs\<^esup>

goal (1 subgoal):
 1. \<forall>bs. \<lparr>a ^\<^sub>p k' - k *\<^sub>p s\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>p *\<^sub>p (q +\<^sub>p (a ^\<^sub>p k' - Suc k *\<^sub>p head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p)) +\<^sub>p r\<rparr>\<^sub>p\<^bsup>bs\<^esup>
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<forall>bs. \<lparr>a ^\<^sub>p k' - k *\<^sub>p s\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>p *\<^sub>p (q +\<^sub>p (a ^\<^sub>p k' - Suc k *\<^sub>p head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p)) +\<^sub>p r\<rparr>\<^sub>p\<^bsup>bs\<^esup>

goal (1 subgoal):
 1. polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
let ?q = "q +\<^sub>p (a ^\<^sub>p (k' - Suc k) *\<^sub>p ?b *\<^sub>p ?xdn)"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
from polyadd_normh[OF nq polymul_normh[OF polymul_normh[OF polypow_normh[OF head_isnpolyh[OF np], where k="k' - Suc k"] head_isnpolyh[OF ns], simplified ap] nxdn]]
[PROOF STATE]
proof (chain)
picking this:
isnpolyh (q +\<^sub>p (a ^\<^sub>p k' - Suc k *\<^sub>p head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p)) (min nq (min (min n0 n1) 0))
[PROOF STEP]
have nqw: "isnpolyh ?q 0"
[PROOF STATE]
proof (prove)
using this:
isnpolyh (q +\<^sub>p (a ^\<^sub>p k' - Suc k *\<^sub>p head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p)) (min nq (min (min n0 n1) 0))

goal (1 subgoal):
 1. isnpolyh (q +\<^sub>p (a ^\<^sub>p k' - Suc k *\<^sub>p head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p)) 0
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
isnpolyh (q +\<^sub>p (a ^\<^sub>p k' - Suc k *\<^sub>p head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p)) 0

goal (1 subgoal):
 1. polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
from ieq isnpolyh_unique[OF polymul_normh[OF polypow_normh[OF head_isnpolyh[OF np], where k="k' - k"] ns, simplified ap] polyadd_normh[OF polymul_normh[OF np nqw] nr]]
[PROOF STATE]
proof (chain)
picking this:
\<forall>bs. \<lparr>a ^\<^sub>p k' - k *\<^sub>p s\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>p *\<^sub>p (q +\<^sub>p (a ^\<^sub>p k' - Suc k *\<^sub>p head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p)) +\<^sub>p r\<rparr>\<^sub>p\<^bsup>bs\<^esup>
(\<forall>bs. \<lparr>a ^\<^sub>p k' - k *\<^sub>p s\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>p *\<^sub>p (q +\<^sub>p (a ^\<^sub>p k' - Suc k *\<^sub>p head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p)) +\<^sub>p r\<rparr>\<^sub>p\<^bsup>bs\<^esup>) = (a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p (q +\<^sub>p (a ^\<^sub>p k' - Suc k *\<^sub>p head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p)) +\<^sub>p r)
[PROOF STEP]
have asth: "(a ^\<^sub>p (k' - k) *\<^sub>p s) = p *\<^sub>p (q +\<^sub>p (a ^\<^sub>p (k' - Suc k) *\<^sub>p ?b *\<^sub>p ?xdn)) +\<^sub>p r"
[PROOF STATE]
proof (prove)
using this:
\<forall>bs. \<lparr>a ^\<^sub>p k' - k *\<^sub>p s\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>p *\<^sub>p (q +\<^sub>p (a ^\<^sub>p k' - Suc k *\<^sub>p head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p)) +\<^sub>p r\<rparr>\<^sub>p\<^bsup>bs\<^esup>
(\<forall>bs. \<lparr>a ^\<^sub>p k' - k *\<^sub>p s\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>p *\<^sub>p (q +\<^sub>p (a ^\<^sub>p k' - Suc k *\<^sub>p head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p)) +\<^sub>p r\<rparr>\<^sub>p\<^bsup>bs\<^esup>) = (a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p (q +\<^sub>p (a ^\<^sub>p k' - Suc k *\<^sub>p head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p)) +\<^sub>p r)

goal (1 subgoal):
 1. a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p (q +\<^sub>p (a ^\<^sub>p k' - Suc k *\<^sub>p head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p)) +\<^sub>p r
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p (q +\<^sub>p (a ^\<^sub>p k' - Suc k *\<^sub>p head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p)) +\<^sub>p r

goal (1 subgoal):
 1. polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
from dr kk' nr h1 asth nqw
[PROOF STATE]
proof (chain)
picking this:
Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p
Suc k \<le> k'
isnpolyh r nr
polydivide_aux a n p k s = (k', r)
a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p (q +\<^sub>p (a ^\<^sub>p k' - Suc k *\<^sub>p head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p)) +\<^sub>p r
isnpolyh (q +\<^sub>p (a ^\<^sub>p k' - Suc k *\<^sub>p head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p)) 0
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p
Suc k \<le> k'
isnpolyh r nr
polydivide_aux a n p k s = (k', r)
a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p (q +\<^sub>p (a ^\<^sub>p k' - Suc k *\<^sub>p head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p)) +\<^sub>p r
isnpolyh (q +\<^sub>p (a ^\<^sub>p k' - Suc k *\<^sub>p head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p)) 0

goal (1 subgoal):
 1. polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p; Suc k \<le> k'; isnpolyh r nr; polydivide_aux a n p k s = (k', r); a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p (q +\<^sub>p (a ^\<^sub>p k' - Suc k *\<^sub>p head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p)) +\<^sub>p r; isnpolyh (q +\<^sub>p (a ^\<^sub>p k' - Suc k *\<^sub>p head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p)) 0\<rbrakk> \<Longrightarrow> Ex (isnpolyh r) \<and> (\<exists>qa. Ex (isnpolyh qa) \<and> p *\<^sub>p (q +\<^sub>p (a ^\<^sub>p k' - Suc k *\<^sub>p head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p)) +\<^sub>p r = p *\<^sub>p qa +\<^sub>p r)
[PROOF STEP]
apply (rule conjI)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p; Suc k \<le> k'; isnpolyh r nr; polydivide_aux a n p k s = (k', r); a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p (q +\<^sub>p (a ^\<^sub>p k' - Suc k *\<^sub>p head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p)) +\<^sub>p r; isnpolyh (q +\<^sub>p (a ^\<^sub>p k' - Suc k *\<^sub>p head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p)) 0\<rbrakk> \<Longrightarrow> Ex (isnpolyh r)
 2. \<lbrakk>Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p; Suc k \<le> k'; isnpolyh r nr; polydivide_aux a n p k s = (k', r); a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p (q +\<^sub>p (a ^\<^sub>p k' - Suc k *\<^sub>p head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p)) +\<^sub>p r; isnpolyh (q +\<^sub>p (a ^\<^sub>p k' - Suc k *\<^sub>p head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p)) 0\<rbrakk> \<Longrightarrow> \<exists>qa. Ex (isnpolyh qa) \<and> p *\<^sub>p (q +\<^sub>p (a ^\<^sub>p k' - Suc k *\<^sub>p head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p)) +\<^sub>p r = p *\<^sub>p qa +\<^sub>p r
[PROOF STEP]
apply (rule exI[where x="nr"], simp)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p; Suc k \<le> k'; isnpolyh r nr; polydivide_aux a n p k s = (k', r); a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p (q +\<^sub>p (a ^\<^sub>p k' - Suc k *\<^sub>p head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p)) +\<^sub>p r; isnpolyh (q +\<^sub>p (a ^\<^sub>p k' - Suc k *\<^sub>p head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p)) 0\<rbrakk> \<Longrightarrow> \<exists>qa. Ex (isnpolyh qa) \<and> p *\<^sub>p (q +\<^sub>p (a ^\<^sub>p k' - Suc k *\<^sub>p head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p)) +\<^sub>p r = p *\<^sub>p qa +\<^sub>p r
[PROOF STEP]
apply (rule exI[where x="(q +\<^sub>p (a ^\<^sub>p (k' - Suc k) *\<^sub>p ?b *\<^sub>p ?xdn))"], simp)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p; Suc k \<le> k'; isnpolyh r nr; polydivide_aux a n p k s = (k', r); a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p (q +\<^sub>p (a ^\<^sub>p k' - Suc k *\<^sub>p head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p)) +\<^sub>p r; isnpolyh (q +\<^sub>p (a ^\<^sub>p k' - Suc k *\<^sub>p head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p)) 0\<rbrakk> \<Longrightarrow> Ex (isnpolyh (q +\<^sub>p (a ^\<^sub>p k' - Suc k *\<^sub>p head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p)))
[PROOF STEP]
apply (rule exI[where x="0"], simp)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
polydivide_aux a n p k s = (k', r) \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)

goal (2 subgoals):
 1. Reflected_Multivariate_Polynomial.degree (a *\<^sub>p s -\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p)) < Reflected_Multivariate_Polynomial.degree s \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
 2. a *\<^sub>p s -\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p) = 0\<^sub>p \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
polydivide_aux a n p k s = (k', r) \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
polydivide_aux a n p k s = (k', r) \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)

goal (1 subgoal):
 1. polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)

goal (1 subgoal):
 1. a *\<^sub>p s -\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p) = 0\<^sub>p \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. a *\<^sub>p s -\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p) = 0\<^sub>p \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
case spz: 2
[PROOF STATE]
proof (state)
this:
a *\<^sub>p s -\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p) = 0\<^sub>p

goal (1 subgoal):
 1. a *\<^sub>p s -\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p) = 0\<^sub>p \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
have hth: "\<forall>bs :: 'a::field_char_0 list.
            Ipoly bs (a *\<^sub>p s) = Ipoly bs (p *\<^sub>p (?b *\<^sub>p ?xdn))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>bs. \<lparr>a *\<^sub>p s\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>p *\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p)\<rparr>\<^sub>p\<^bsup>bs\<^esup>
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>bs. \<lparr>a *\<^sub>p s\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>p *\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p)\<rparr>\<^sub>p\<^bsup>bs\<^esup>
[PROOF STEP]
fix bs :: "'a::field_char_0 list"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>bs. \<lparr>a *\<^sub>p s\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>p *\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p)\<rparr>\<^sub>p\<^bsup>bs\<^esup>
[PROOF STEP]
from isnpolyh_unique[OF nth, where ?'a="'a" and q="0\<^sub>p",simplified,symmetric] spz
[PROOF STATE]
proof (chain)
picking this:
(a *\<^sub>p s -\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p) = 0\<^sub>p) = (\<forall>bs. \<lparr>a\<rparr>\<^sub>p\<^bsup>bs\<^esup> * \<lparr>s\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>head s\<rparr>\<^sub>p\<^bsup>bs\<^esup> * \<lparr>(shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p\<rparr>\<^sub>p\<^bsup>bs\<^esup>)
a *\<^sub>p s -\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p) = 0\<^sub>p
[PROOF STEP]
have "Ipoly bs (a*\<^sub>p s) = Ipoly bs ?b * Ipoly bs ?p'"
[PROOF STATE]
proof (prove)
using this:
(a *\<^sub>p s -\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p) = 0\<^sub>p) = (\<forall>bs. \<lparr>a\<rparr>\<^sub>p\<^bsup>bs\<^esup> * \<lparr>s\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>head s\<rparr>\<^sub>p\<^bsup>bs\<^esup> * \<lparr>(shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p\<rparr>\<^sub>p\<^bsup>bs\<^esup>)
a *\<^sub>p s -\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p) = 0\<^sub>p

goal (1 subgoal):
 1. \<lparr>a *\<^sub>p s\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>head s\<rparr>\<^sub>p\<^bsup>bs\<^esup> * \<lparr>(shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p\<rparr>\<^sub>p\<^bsup>bs\<^esup>
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<lparr>a *\<^sub>p s\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>head s\<rparr>\<^sub>p\<^bsup>bs\<^esup> * \<lparr>(shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p\<rparr>\<^sub>p\<^bsup>bs\<^esup>

goal (1 subgoal):
 1. \<And>bs. \<lparr>a *\<^sub>p s\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>p *\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p)\<rparr>\<^sub>p\<^bsup>bs\<^esup>
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<lparr>a *\<^sub>p s\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>head s\<rparr>\<^sub>p\<^bsup>bs\<^esup> * \<lparr>(shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p\<rparr>\<^sub>p\<^bsup>bs\<^esup>
[PROOF STEP]
have "Ipoly bs (a*\<^sub>p s) = Ipoly bs (?b *\<^sub>p ?xdn) * Ipoly bs p"
[PROOF STATE]
proof (prove)
using this:
\<lparr>a *\<^sub>p s\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>head s\<rparr>\<^sub>p\<^bsup>bs\<^esup> * \<lparr>(shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p\<rparr>\<^sub>p\<^bsup>bs\<^esup>

goal (1 subgoal):
 1. \<lparr>a *\<^sub>p s\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p\<rparr>\<^sub>p\<^bsup>bs\<^esup> * \<lparr>p\<rparr>\<^sub>p\<^bsup>bs\<^esup>
[PROOF STEP]
by (simp add: funpow_shift1_1[where n="degree s - n" and p="p"])
[PROOF STATE]
proof (state)
this:
\<lparr>a *\<^sub>p s\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p\<rparr>\<^sub>p\<^bsup>bs\<^esup> * \<lparr>p\<rparr>\<^sub>p\<^bsup>bs\<^esup>

goal (1 subgoal):
 1. \<And>bs. \<lparr>a *\<^sub>p s\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>p *\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p)\<rparr>\<^sub>p\<^bsup>bs\<^esup>
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<lparr>a *\<^sub>p s\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p\<rparr>\<^sub>p\<^bsup>bs\<^esup> * \<lparr>p\<rparr>\<^sub>p\<^bsup>bs\<^esup>
[PROOF STEP]
show "Ipoly bs (a*\<^sub>p s) = Ipoly bs (p *\<^sub>p (?b *\<^sub>p ?xdn))"
[PROOF STATE]
proof (prove)
using this:
\<lparr>a *\<^sub>p s\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p\<rparr>\<^sub>p\<^bsup>bs\<^esup> * \<lparr>p\<rparr>\<^sub>p\<^bsup>bs\<^esup>

goal (1 subgoal):
 1. \<lparr>a *\<^sub>p s\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>p *\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p)\<rparr>\<^sub>p\<^bsup>bs\<^esup>
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<lparr>a *\<^sub>p s\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>p *\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p)\<rparr>\<^sub>p\<^bsup>bs\<^esup>

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<forall>bs. \<lparr>a *\<^sub>p s\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>p *\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p)\<rparr>\<^sub>p\<^bsup>bs\<^esup>

goal (1 subgoal):
 1. a *\<^sub>p s -\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p) = 0\<^sub>p \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
from hth
[PROOF STATE]
proof (chain)
picking this:
\<forall>bs. \<lparr>a *\<^sub>p s\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>p *\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p)\<rparr>\<^sub>p\<^bsup>bs\<^esup>
[PROOF STEP]
have asq: "a *\<^sub>p s = p *\<^sub>p (?b *\<^sub>p ?xdn)"
[PROOF STATE]
proof (prove)
using this:
\<forall>bs. \<lparr>a *\<^sub>p s\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>p *\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p)\<rparr>\<^sub>p\<^bsup>bs\<^esup>

goal (1 subgoal):
 1. a *\<^sub>p s = p *\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p)
[PROOF STEP]
using isnpolyh_unique[where ?'a = "'a::field_char_0", OF polymul_normh[OF head_isnpolyh[OF np] ns]
                    polymul_normh[OF np polymul_normh[OF head_isnpolyh[OF ns] nxdn]],
              simplified ap]
[PROOF STATE]
proof (prove)
using this:
\<forall>bs. \<lparr>a *\<^sub>p s\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>p *\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p)\<rparr>\<^sub>p\<^bsup>bs\<^esup>
(\<forall>bs. \<lparr>a *\<^sub>p s\<rparr>\<^sub>p\<^bsup>bs\<^esup> = \<lparr>p *\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p)\<rparr>\<^sub>p\<^bsup>bs\<^esup>) = (a *\<^sub>p s = p *\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p))

goal (1 subgoal):
 1. a *\<^sub>p s = p *\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
a *\<^sub>p s = p *\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p)

goal (1 subgoal):
 1. a *\<^sub>p s -\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p) = 0\<^sub>p \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
have ?ths if h1: "polydivide_aux a n p k s = (k', r)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
from h1 sz ba dn' spz polydivide_aux.simps polydivide_aux.simps
[PROOF STATE]
proof (chain)
picking this:
polydivide_aux a n p k s = (k', r)
s \<noteq> 0\<^sub>p
head s \<noteq> a
\<not> Reflected_Multivariate_Polynomial.degree s < n
a *\<^sub>p s -\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p) = 0\<^sub>p
polydivide_aux ?a ?n ?p ?k ?s = (if ?s = 0\<^sub>p then (?k, ?s) else let b = head ?s; m = Reflected_Multivariate_Polynomial.degree ?s in if m < ?n then (?k, ?s) else let p' = (shift1 ^^ (m - ?n)) ?p in if ?a = b then polydivide_aux ?a ?n ?p ?k (?s -\<^sub>p p') else polydivide_aux ?a ?n ?p (Suc ?k) (?a *\<^sub>p ?s -\<^sub>p (b *\<^sub>p p')))
polydivide_aux ?a ?n ?p ?k ?s = (if ?s = 0\<^sub>p then (?k, ?s) else let b = head ?s; m = Reflected_Multivariate_Polynomial.degree ?s in if m < ?n then (?k, ?s) else let p' = (shift1 ^^ (m - ?n)) ?p in if ?a = b then polydivide_aux ?a ?n ?p ?k (?s -\<^sub>p p') else polydivide_aux ?a ?n ?p (Suc ?k) (?a *\<^sub>p ?s -\<^sub>p (b *\<^sub>p p')))
[PROOF STEP]
have "(k', r) = (Suc k, 0\<^sub>p)"
[PROOF STATE]
proof (prove)
using this:
polydivide_aux a n p k s = (k', r)
s \<noteq> 0\<^sub>p
head s \<noteq> a
\<not> Reflected_Multivariate_Polynomial.degree s < n
a *\<^sub>p s -\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p) = 0\<^sub>p
polydivide_aux ?a ?n ?p ?k ?s = (if ?s = 0\<^sub>p then (?k, ?s) else let b = head ?s; m = Reflected_Multivariate_Polynomial.degree ?s in if m < ?n then (?k, ?s) else let p' = (shift1 ^^ (m - ?n)) ?p in if ?a = b then polydivide_aux ?a ?n ?p ?k (?s -\<^sub>p p') else polydivide_aux ?a ?n ?p (Suc ?k) (?a *\<^sub>p ?s -\<^sub>p (b *\<^sub>p p')))
polydivide_aux ?a ?n ?p ?k ?s = (if ?s = 0\<^sub>p then (?k, ?s) else let b = head ?s; m = Reflected_Multivariate_Polynomial.degree ?s in if m < ?n then (?k, ?s) else let p' = (shift1 ^^ (m - ?n)) ?p in if ?a = b then polydivide_aux ?a ?n ?p ?k (?s -\<^sub>p p') else polydivide_aux ?a ?n ?p (Suc ?k) (?a *\<^sub>p ?s -\<^sub>p (b *\<^sub>p p')))

goal (1 subgoal):
 1. (k', r) = (Suc k, 0\<^sub>p)
[PROOF STEP]
by (simp add: Let_def)
[PROOF STATE]
proof (state)
this:
(k', r) = (Suc k, 0\<^sub>p)

goal (1 subgoal):
 1. polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
with h1 np head_isnpolyh[OF np, simplified ap] ns polymul_normh[OF head_isnpolyh[OF ns] nxdn]
              polymul_normh[OF np polymul_normh[OF head_isnpolyh[OF ns] nxdn]] asq
[PROOF STATE]
proof (chain)
picking this:
polydivide_aux a n p k s = (k', r)
isnpolyh p n0
isnpolyh a n0
isnpolyh s n1
isnpolyh (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p) (min n1 0)
isnpolyh (p *\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p)) (min n0 (min n1 0))
a *\<^sub>p s = p *\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p)
(k', r) = (Suc k, 0\<^sub>p)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
polydivide_aux a n p k s = (k', r)
isnpolyh p n0
isnpolyh a n0
isnpolyh s n1
isnpolyh (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p) (min n1 0)
isnpolyh (p *\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p)) (min n0 (min n1 0))
a *\<^sub>p s = p *\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p)
(k', r) = (Suc k, 0\<^sub>p)

goal (1 subgoal):
 1. polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
apply (clarsimp simp add: Let_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>polydivide_aux a n p k s = (Suc k, 0\<^sub>p); isnpolyh p n0; isnpolyh a n0; isnpolyh s n1; isnpolyh (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p) 0; isnpolyh (p *\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p)) 0; a *\<^sub>p s = p *\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p); k' = Suc k; r = 0\<^sub>p\<rbrakk> \<Longrightarrow> \<exists>q. Ex (isnpolyh q) \<and> p *\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p) = p *\<^sub>p q +\<^sub>p 0\<^sub>p
[PROOF STEP]
apply (rule exI[where x="?b *\<^sub>p ?xdn"])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>polydivide_aux a n p k s = (Suc k, 0\<^sub>p); isnpolyh p n0; isnpolyh a n0; isnpolyh s n1; isnpolyh (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p) 0; isnpolyh (p *\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p)) 0; a *\<^sub>p s = p *\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p); k' = Suc k; r = 0\<^sub>p\<rbrakk> \<Longrightarrow> Ex (isnpolyh (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p)) \<and> p *\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p) = p *\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p) +\<^sub>p 0\<^sub>p
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>polydivide_aux a n p k s = (Suc k, 0\<^sub>p); isnpolyh p n0; isnpolyh a n0; isnpolyh s n1; isnpolyh (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p) 0; isnpolyh (p *\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p)) 0; a *\<^sub>p s = p *\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p); k' = Suc k; r = 0\<^sub>p\<rbrakk> \<Longrightarrow> Ex (isnpolyh (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) (1)\<^sub>p))
[PROOF STEP]
apply (rule exI[where x="0"], simp)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
polydivide_aux a n p k s = (k', r) \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)

goal (1 subgoal):
 1. a *\<^sub>p s -\<^sub>p (head s *\<^sub>p (shift1 ^^ (Reflected_Multivariate_Polynomial.degree s - n)) p) = 0\<^sub>p \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
polydivide_aux a n p k s = (k', r) \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
polydivide_aux a n p k s = (k', r) \<Longrightarrow> polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)

goal (1 subgoal):
 1. polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
polydivide_aux a n p k s = (k', r) \<longrightarrow> k \<le> k' \<and> (Reflected_Multivariate_Polynomial.degree r = 0 \<or> Reflected_Multivariate_Polynomial.degree r < Reflected_Multivariate_Polynomial.degree p) \<and> (\<exists>nr. isnpolyh r nr) \<and> (\<exists>q n1. isnpolyh q n1 \<and> a ^\<^sub>p k' - k *\<^sub>p s = p *\<^sub>p q +\<^sub>p r)

goal:
No subgoals!
[PROOF STEP]
qed