reserve i,j,n,n1,n2,m,k,u for Nat,
        r,r1,r2 for Real,
        x,y for Integer,
        a,b for non trivial Nat;

theorem Th25:
  Px(a,|.x+y.|) = Px(a,|.x.|)*Px(a,|.y.|) +
         (a^2-'1) * sgn(x)*Py(a,|.x.|)*sgn(y)*Py(a,|.y.|) &
  sgn(x+y)*Py(a,|.x+y.|) = Px(a,|.x.|)*sgn(y)*Py(a,|.y.|) +
          sgn(x)*Py(a,|.x.|)*Px(a,|.y.|)
proof
  set i=x,j=y,I=|.x.|,J=|.y.|,IJ = |.x+y.|;
  set A=a^2-'1,S = sqrt A;
A1: a^2 -'1 = a^2 -1 by NAT_1:14,XREAL_1:233;
A2: S^2= A by SQUARE_1:def 2;
A3: 1 = ((a + S)*(a - S)) |^I by A2,A1
       .= ((a + S) |^I)*((a - S) |^I) by NEWTON:7;
A4: 1 = ((a + S)*(a - S)) |^J by A2,A1
       .= ((a + S) |^J)*((a - S) |^J) by NEWTON:7;
  deffunc PX(Integer) = Px(a,|.$1.|);
  deffunc PY(Integer) = sgn($1)*Py(a,|.$1.|);
  per cases;
  suppose
A5:   i>=0 & j >=0;
    then
A6:   i = I & j=J   by ABSVALUE:def 1;
A7:   PY(i) = Py(a,I) by Th23,A5;
A8:   PY(j) = Py(a,J) by A5,Th23;
A9:   IJ=i+j by A5,ABSVALUE:def 1;
    PY(i+j) = Py(a,IJ) by Th23,A5;
    then PX(i+j) + PY(i+j) * S  = (a+ S) |^ IJ by Th11
      .= ((a+ S) |^ I) * ((a+ S) |^ J) by A6,A9,NEWTON:8
      .= (PX(i) + PY(i) * S) * ((a+ S) |^ J) by A7,Th11
      .= (PX(i) + PY(i) * S) * (PX(j) + PY(j) * S) by A8,Th11
      .= PX(i)*PX(j) + A * PY(i)*PY(j) +
    S* (PX(i)*PY(j) + PY(i)*PX(j)) by A2;
    hence thesis by PELLS_EQ:3;
  end;
  suppose
A10:  i <0 & j >=0;
    then
A11:  -i = I & j=J   by ABSVALUE:def 1;
A12:  PY(i) = -Py(a,I) by A10,Th24;
A13:  PY(j) = Py(a,J) by A10,Th23;
    per cases;
    suppose
A14:    i+j>=0;
      then IJ=i+j by ABSVALUE:def 1;
      then
A15:    IJ+I = J by A11;
      PY(i+j) = Py(a,IJ) by A14,Th23;
      then PX(i+j) + PY(i+j) * S  = ((a+ S) |^ IJ) *
      (((a + S) |^I)*((a - S) |^I)) by Th11,A3
        .= ((a+ S) |^ IJ) * ((a + S) |^I)* ((a - S) |^I)
        .= ((a+ S) |^ J)* ((a - S) |^I) by A15,NEWTON:8
        .= (PX(j) + PY(j) * S)* ((a - S) |^I) by A13,Th11
        .= (PX(j) + PY(j) * S)* (PX(i) + PY(i)*S) by A12,Th11
        .= PX(i)*PX(j) + A * PY(i)*PY(j) +
      S* (PX(i)*PY(j) + PY(i)*PX(j)) by A2;
      hence thesis by PELLS_EQ:3;
    end;
    suppose
A16:i+j <0;
      then IJ=-(i+j) by ABSVALUE:def 1;
      then
A17: IJ+J = I by A11;
      PY(i+j) = -Py(a,IJ) by A16,Th24;
      then PX(i+j) + PY(i+j) * S
        = ((a- S) |^ IJ) * (((a + S) |^J)*((a - S) |^J)) by Th11,A4
        .= ((a- S) |^ IJ) * ((a - S) |^J)* ((a + S) |^J)
        .= ((a- S) |^ I)* ((a + S) |^J) by A17,NEWTON:8
        .= (PX(i) + PY(i) * S)* ((a + S) |^J) by A12,Th11
        .= (PX(i) + PY(i) * S)* (PX(j) + PY(j)*S) by A13,Th11
        .= PX(i)*PX(j) + A * PY(i)*PY(j) +
      S* (PX(i)*PY(j) + PY(i)*PX(j)) by A2;
      hence thesis by PELLS_EQ:3;
    end;
  end;
  suppose
A18:  i >=0 & j <0;
    then
A19:  i = I & -j=J   by ABSVALUE:def 1;
A20:  PY(i) = Py(a,I) by Th23,A18;
A21:  PY(j) = -Py(a,J) by A18,Th24;
    per cases;
    suppose
A22:    i+j>=0;
      then IJ=i+j by ABSVALUE:def 1;
      then
A23:    IJ+J = I by A19;
      PY(i+j) = Py(a,IJ) by A22,Th23;
      then PX(i+j) + PY(i+j) * S  =
      ((a+ S) |^ IJ) * (((a + S) |^J)*((a - S) |^J)) by A4,Th11
        .= ((a+ S) |^ IJ) * ((a + S) |^J)* ((a - S) |^J)
        .= ((a+ S) |^ I)* ((a - S) |^J) by A23,NEWTON:8
        .= (PX(i) + PY(i) * S)* ((a - S) |^J) by A20,Th11
        .= (PX(i) + PY(i) * S)* (PX(j) + PY(j)*S) by A21,Th11
        .= PX(i)*PX(j) + A * PY(i)*PY(j) +
      S* (PX(i)*PY(j) + PY(i)*PX(j)) by A2;
      hence thesis by PELLS_EQ:3;
    end;
    suppose
A24:i+j <0;
      then IJ=-(i+j) by ABSVALUE:def 1;
      then
A25: IJ+I = J by A19;
      PY(i+j) = -Py(a,IJ) by A24,Th24;
      then PX(i+j) + PY(i+j) * S  =
      ((a- S) |^ IJ) * (((a - S) |^I)*((a + S) |^I)) by Th11,A3
        .= ((a- S) |^ IJ) * ((a - S) |^I)* ((a + S) |^I)
        .= ((a- S) |^ J)* ((a + S) |^I) by A25,NEWTON:8
        .= (PX(j) + PY(j) * S)* ((a + S) |^I) by A21,Th11
        .= (PX(j) + PY(j) * S)* (PX(i) + PY(i)*S) by A20,Th11
        .= PX(i)*PX(j) + A * PY(i)*PY(j) +
      S* (PX(i)*PY(j) + PY(i)*PX(j)) by A2;
      hence thesis by PELLS_EQ:3;
    end;
  end;
  suppose
A26: i<0 & j <0;
    then
A27:  -i = I & -j=J   by ABSVALUE:def 1;
A28:  PY(i) = -Py(a,I) by A26,Th24;
A29:  PY(j) = -Py(a,J) by A26,Th24;
A30:  IJ=-(i+j) by A26,ABSVALUE:def 1;
A31:  IJ = I+J by A27,A30;
    PX(i+j) + PY(i+j) * S  = PX(i+j) + (-Py(a,IJ)) * S by A26,Th24
      .= (a- S) |^ IJ by Th11
      .= ((a- S) |^ I) * ((a- S) |^ J) by A31,NEWTON:8
      .= (PX(i) + PY(i) * S) * ((a- S) |^ J) by A28,Th11
      .= (PX(i) + PY(i) * S) * (PX(j) + PY(j) * S) by A29,Th11
      .= PX(i)*PX(j) + A * PY(i)*PY(j) +
    S* (PX(i)*PY(j) + PY(i)*PX(j)) by A2;
    hence thesis by PELLS_EQ:3;
  end;
end;
