
theorem LemmaTo57:
  for m, n being non zero Nat st
    m is_quadratic_residue_mod n holds
      ex i being Nat st ArProg (m,n).i is square
  proof
    let m, n be non zero Nat;
    assume m is_quadratic_residue_mod n; then
    consider xx being Integer such that
B1: (xx^2 - m) mod n = 0 by INT_5:def 2;
    reconsider x = |.xx.| as Nat;
    x ^2 = xx ^2 by COMPLEX1:75; then
    n divides (x ^2 - m) by B1,INT_1:62; then
    consider ii being Integer such that
B3: x ^2 - m = ii * n;
B4: ii * n + m = x ^2 by B3;
    per cases;
    suppose ii >= 0; then
      ii in NAT by INT_1:3; then
      reconsider ii as Nat;
      take i = ii;
      thus thesis by B4,NUMBER06:7;
    end;
    suppose
DD:    ii < 0; then
      -ii in NAT by INT_1:3; then
      reconsider mm = -ii as Nat;
      set b = m;
      set a = n;
      set k = ii;
So:   (mm * a + x) ^2 = a * (mm ^2 * a) + a * 2 * mm * x + x ^2
          .= a * (mm ^2 * a + 2 * mm * x + k) + b by B3;
      mm * a + 2 * x >= 1 + 0 by DD,NAT_1:13; then
      mm * (mm * a + 2 * x) >= 1 * (-ii) by XREAL_1:64; then
      mm * (mm * a + 2 * x) + ii >= -ii + ii by XREAL_1:6; then
      mm * (mm * a + 2 * x) + ii >= 0; then
      reconsider wa = mm ^2 * a + 2 * mm * x + ii as Nat;
      take wa;
      thus thesis by NUMBER06:7,So;
    end;
  end;
