reserve a,b,m,x,y,i1,i2,i3,i for Integer,
  k,p,q,n for Nat,
  c,c1,c2 for Element of NAT,
  z for set;

theorem
  p*q mod p*n = p*(q mod n)
proof
  per cases;
  suppose
A1: n=0;
    then q mod n = 0 by NAT_D:def 2;
    hence thesis by A1,NAT_D:def 2;
  end;
  suppose
A2: n>0;
    then
A3: p*q = p*(n * (q div n) + (q mod n)) by NAT_D:2
      .= (p*n)*(q div n) + p*(q mod n);
    per cases;
    suppose
      p=0;
      hence thesis by NAT_D:def 2;
    end;
    suppose
      p>0;
      then p*(q mod n) < p*n by A2,NAT_D:1,XREAL_1:68;
      hence thesis by A3,NAT_D:def 2;
    end;
  end;
end;
