
theorem Th25:
  for n being Element of NAT, T being admissible connected
  TermOrder of n, L being add-associative right_complementable right_zeroed
commutative associative well-unital distributive Abelian almost_left_invertible
non degenerated non empty doubleLoopStr, G being Subset of Polynom-Ring(n,L)
  st not(0_(n,L) in G) holds (for g1,g2 being Polynomial of n,L st g1 in G & g2
  in G holds PolyRedRel(G,T) reduces S-Poly(g1,g2,T),0_(n,L)) implies G
  is_Groebner_basis_wrt T
proof
  let n be Element of NAT, T be admissible connected TermOrder of n, L be
  add-associative right_complementable right_zeroed commutative associative
  well-unital distributive Abelian almost_left_invertible non degenerated non
  empty doubleLoopStr, G be Subset of Polynom-Ring(n,L);
  assume
A1: not 0_(n,L) in G;
  assume
A2: for g1,g2 being Polynomial of n,L st g1 in G & g2 in G holds
  PolyRedRel(G,T) reduces S-Poly(g1,g2,T),0_(n,L);
  now
    let g1,g2 be Polynomial of n,L;
    assume that
    g1 <> g2 and
A3: g1 in G and
A4: g2 in G;
    thus for m1,m2 being Monomial of n,L st HM(m1 *'g1,T) = HM(m2 *'g2,T)
    holds PolyRedRel(G,T) reduces m1 *' g1 - m2 *' g2, 0_(n,L)
    proof
      set a1 = HC(g1,T), a2 = HC(g2,T);
      set t1 = HT(g1,T), t2 = HT(g2,T);
      let m1,m2 be Monomial of n,L;
      assume
A5:   HM(m1 *'g1,T) = HM(m2 *'g2,T);
A6:   a2 <> 0.L by A1,A4,TERMORD:17;
      reconsider g1,g2 as non-zero Polynomial of n,L by A1,A3,A4,POLYNOM7:def 1
;
      set b1 = coefficient(m1), b2 = coefficient(m2);
      set u1 = term(m1), u2 = term(m2);
A7:   a1 <> 0.L by A1,A3,TERMORD:17;
      then reconsider a1,a2 as non zero Element of L by A6,STRUCT_0:def 12;
A8:   HC(m1*'g1,T) = coefficient(HM(m1*'g1,T)) by TERMORD:22
        .= HC(m2*'g2,T) by A5,TERMORD:22;
      now
        per cases;
        case
A9:       b1 = 0.L or b2 = 0.L;
          now
            per cases by A9;
            case
              b1 = 0.L;
              then HC(m1,T) = 0.L by TERMORD:23;
              then m1 = 0_(n,L) by TERMORD:17;
              then
A10:          m1 *' g1 = 0_(n,L) by POLYRED:5;
              then HC(m2*'g2,T) = 0.L by A8,TERMORD:17;
              then m2 *' g2 = 0_(n,L) by TERMORD:17;
              then m1 *' g1 - m2 *' g2 = 0_(n,L) by A10,POLYRED:4;
              hence thesis by REWRITE1:12;
            end;
            case
              b2 = 0.L;
              then HC(m2,T) = 0.L by TERMORD:23;
              then m2 = 0_(n,L) by TERMORD:17;
              then
A11:          m2 *' g2 = 0_(n,L) by POLYRED:5;
              then HC(m1*'g1,T) = 0.L by A8,TERMORD:17;
              then m1 *' g1 = 0_(n,L) by TERMORD:17;
              then m1 *' g1 - m2 *' g2 = 0_(n,L) by A11,POLYRED:4;
              hence thesis by REWRITE1:12;
            end;
          end;
          hence thesis;
        end;
        case
A12:      b1 <> 0.L & b2 <> 0.L;
          then reconsider b1,b2 as non zero Element of L by STRUCT_0:def 12;
          b2 * a2 <> 0.L by VECTSP_2:def 1;
          then
A13:      b2 * a2 is non zero;
          t1 divides lcm(t1,t2) by Th3;
          then consider s1 being bag of n such that
A14:      t1 + s1 = lcm(t1,t2) by TERMORD:1;
          HC(m2,T) <> 0.L by A12,TERMORD:23;
          then
A15:      m2 <> 0_(n,L) by TERMORD:17;
          HC(m1,T) <> 0.L by A12,TERMORD:23;
          then m1 <> 0_(n,L) by TERMORD:17;
          then reconsider m1,m2 as non-zero Monomial of n,L by A15,
POLYNOM7:def 1;
A16:      Monom(b1*a1,u1+t1) = Monom(b1,u1) *' Monom(a1,t1) by TERMORD:3
            .= m1 *' Monom(a1,t1) by POLYNOM7:11
            .= HM(m1,T) *' Monom(a1,t1) by TERMORD:23
            .= HM(m1,T) *' HM(g1,T) by TERMORD:def 8
            .= HM(m2*'g2,T) by A5,TERMORD:33
            .= HM(m2,T) *' HM(g2,T) by TERMORD:33
            .= HM(m2,T) *' Monom(a2,t2) by TERMORD:def 8
            .= m2 *' Monom(a2,t2) by TERMORD:23
            .= Monom(b2,u2) *' Monom(a2,t2) by POLYNOM7:11
            .= Monom(b2*a2,u2+t2) by TERMORD:3;
          then b1*a1 = coefficient(Monom(b2*a2,u2+t2)) by POLYNOM7:9
            .= b2 * a2 by POLYNOM7:9;
          then (b1 * a1) / a2 = (b2 * a2) * a2"
            .= b2 * (a2 * a2") by GROUP_1:def 3
            .= b2 * 1.L by A6,VECTSP_1:def 10;
          then
A17:      b2 / a1 = ((b1 * a1) / a2) / a1
            .= ((b1 * a1) * a2") / a1
            .= ((b1 * a1) * a2") * a1"
            .= ((b1 * a2") * a1) * a1" by GROUP_1:def 3
            .= (b1 * a2") * (a1 * a1") by GROUP_1:def 3
            .= (b1 * a2") * 1.L by A7,VECTSP_1:def 10
            .= b1 * a2"
            .= b1 / a2;
          b1 * a1 <> 0.L by VECTSP_2:def 1;
          then b1 * a1 is non zero;
          then
A18:      u1 + t1 = term(Monom(b2*a2,u2+t2)) by A16,POLYNOM7:10
            .= u2 + t2 by A13,POLYNOM7:10;
          then t1 divides u1 + t1 & t2 divides u1 + t1 by TERMORD:1;
          then lcm(t1,t2) divides u1 + t1 by Th4;
          then consider v being bag of n such that
A19:      u1 + t1 = lcm(t1,t2) + v by TERMORD:1;
          u1 + t1 = (v + s1) + t1 by A14,A19,PRE_POLY:35;
          then
A20:      u1 = ((v + s1) + t1) -' t1 by PRE_POLY:48
            .= v + s1 by PRE_POLY:48;
          t2 divides lcm(t1,t2) by Th3;
          then consider s2 being bag of n such that
A21:      t2 + s2 = lcm(t1,t2) by TERMORD:1;
          u2 + t2 = (v + s2) + t2 by A18,A21,A19,PRE_POLY:35;
          then
A22:      u2 = ((v + s2) + t2) -' t2 by PRE_POLY:48
            .= v + s2 by PRE_POLY:48;
          HT(g2,T) divides lcm(HT(g1,T),HT(g2,T)) by Th3;
          then
A23:      s2 = lcm(HT(g1,T),HT(g2,T))/HT(g2,T) by A21,Def1;
A24:      (b2/a1)*a1 = (b2*a1")*a1
            .= b2*(a1"*a1) by GROUP_1:def 3
            .= b2*1.L by A7,VECTSP_1:def 10
            .= b2;
          HT(g1,T) divides lcm(HT(g1,T),HT(g2,T)) by Th3;
          then
A25:      s1 = lcm(HT(g1,T),HT(g2,T))/HT(g1,T) by A14,Def1;
A26:      (b1/a2)*a2 = (b1*a2")*a2
            .= b1*(a2"*a2) by GROUP_1:def 3
            .= b1*1.L by A6,VECTSP_1:def 10;
          m1 *' g1 - m2 *' g2 = Monom(b1,u1) *' g1 - m2 *' g2 by POLYNOM7:11
            .= Monom(b1,u1) *' g1 - Monom(b2,u2) *' g2 by POLYNOM7:11
            .= b1 * ((v+s1) *' g1) - Monom(b2,v+s2) *' g2 by A20,A22,POLYRED:22
            .= b1 * (v *' (s1 *' g1)) - Monom(b2,v+s2) *' g2 by POLYRED:18
            .= b1 * (v *' (s1 *' g1)) - b2 * ((v+s2) *' g2) by POLYRED:22
            .= b1 * (v *' (s1 *' g1)) - b2 * (v *' (s2 *' g2)) by POLYRED:18
            .= b1 * (v *' (s1 *' g1)) + -(b2 * (v *' (s2 *' g2))) by
POLYNOM1:def 7
            .= b1 * (v *' (s1 *' g1)) + b2 * (-(v *' (s2 *' g2))) by POLYRED:9
            .= ((b1/a2) * a2) * (v*'(s1*'g1)) + ((b2/a1) * a1) * (-(v*'(s2*'
          g2))) by A26,A24
            .= ((b1/a2) * a2) * (v*'(s1*'g1)) + ((b2/a1) * a1) * (v*'(-(s2*'
          g2))) by Th13
            .= ((b1/a2) * a2) * (v*'(s1*'g1)) + (b1/a2) * (a1 * (v*'-(s2*'g2
          ))) by A17,POLYRED:11
            .= (b1/a2) * (a2 * (v*'(s1*'g1))) + (b1/a2) * (a1 * (v*'-(s2*'g2
          ))) by POLYRED:11
            .= (b1/a2) * (a2 * (v*'(s1*'g1)) + a1 * (v*'-(s2*'g2))) by Th15
            .= (b1/a2) * (a2 * (v*'(s1*'g1)) + v *' (a1*(-(s2*'g2)))) by Th14
            .= (b1/a2) * (a2 * (v*'(s1*'g1)) + v *' (-(a1*(s2*'g2)))) by
POLYRED:9
            .= (b1/a2) * (v *' (a2*(s1*'g1)) + v *' (-(a1*(s2*'g2)))) by Th14
            .= (b1/a2) * (v *' (a2*(s1*'g1) + (-(a1*(s2*'g2))))) by Th12
            .= (b1/a2) * v *' S-Poly(g1,g2,T) by A25,A23,POLYNOM1:def 7
            .= Monom(b1/a2,v) *' S-Poly(g1,g2,T) by POLYRED:22;
          hence thesis by A2,A3,A4,POLYRED:48;
        end;
      end;
      hence thesis;
    end;
  end;
  hence thesis by Th17;
end;
