reserve d,i,j,k,m,n,p,q,x,k1,k2 for Nat,
  a,c,i1,i2,i3,i5 for Integer;

theorem
  i <> 0 implies i^2 mod (i+1) = 1
proof
  assume
A1: i <> 0;
  then
A2: i+1 > 0+1 by XREAL_1:6;
  i >= 1 by A1,NAT_1:14;
  then i-1 >= 1-1 by XREAL_1:9;
  then reconsider I = i-1 as Element of NAT by INT_1:3;
  reconsider II = (i+1)*I as Element of NAT;
  i^2 mod (i+1) = (II + 1) mod (i+1)
    .= (II mod (i+1) + 1) mod (i+1) by NAT_D:22
    .= (0 + 1) mod (i+1) by NAT_D:13
    .= 1 by A2,NAT_D:24;
  hence thesis;
end;
