reserve i,j for Nat;
reserve A,B for Ring;

theorem Th21:
  for p be Polynomial of A for x be Element of B st A is Subring of B holds
  Ext_eval(Leading-Monomial(p),x)
  = In(p.(len p-'1),B) * (power B).(x,len p-'1)
proof
  let p be Polynomial of A;
  let x be Element of B;
     assume
A0:   A is Subring of B;
  set LMp=Leading-Monomial(p);
  consider F be FinSequence of B such that
A1: Ext_eval(LMp,x) = Sum F and
A2: len F = len LMp and
A3: for n be Element of NAT st n in dom F holds
    F.n = In(LMp.(n-'1),B)*(power B).(x,n-'1) by Def1;
A4: len F = len p by A2,POLYNOM4:15;
  per cases;
  suppose
A5: len p > 0; then
A7: len p >= 0+1 by NAT_1:13; then
A6: len p in dom F by A4,FINSEQ_3:25;
    now
A8:   len p-'1 = len p-1 by A5,XREAL_0:def 2;
      let i be Element of NAT;
      assume that
A9:   i in dom F and
A10:  i <> len p;
      i >= 0+1 by A9,FINSEQ_3:25; then
      i-'1 = i-1 by XREAL_0:def 2; then
A11:  i-'1 <> len p-'1 by A10,A8;
      thus F/.i = F.i by A9,PARTFUN1:def 6
        .= In(LMp.(i-'1),B)*(power B).(x,i-'1) by A3,A9
        .= In(0.A,B)*(power B).(x,i-'1) by A11,POLYNOM4:def 1
        .= 0.B *(power B).(x,i-'1) by A0,Lm5
        .= 0.B;
    end;
    then Sum F = F/.(len p) by A4,A7,FINSEQ_3:25,POLYNOM2:3
      .= F.(len p) by A6,PARTFUN1:def 6
      .= In(LMp.(len p-'1),B)*(power B).(x,len p-'1) by A3,A7,A4,FINSEQ_3:25;
    hence thesis by A1,POLYNOM4:def 1;
  end;
  suppose
A12: len p = 0; then
A13: p = 0_.A by POLYNOM4:5;
     LMp = 0_.A by A12,POLYNOM4:12;
     hence Ext_eval(Leading-Monomial(p),x) =
       0.B*(power B).(x,len p-'1) by Th17
    .= In(0.A,B) *(power B).(x,len p-'1) by A0,Lm5
    .= In(p.(len p-'1),B)*(power B).(x,len p-'1) by A13,FUNCOP_1:7;
  end;
end;
