reserve x,y,z for Real,
  a,b,c,d,e,f,g,h for Nat,
  k,l,m,n,m1,n1,m2,n2 for Integer,
  q for Rational;
reserve fs,fs1,fs2,fs3 for FinSequence;
reserve D for non empty set,
  v,v1,v2,v3 for object,
  fp for FinSequence of NAT,
  fr,fr1,fr2 for FinSequence of INT,
  ft for FinSequence of REAL;

theorem Th27:
  ex m,n st a gcd b = a*m+b*n
proof
A1: ex m,n st 0 gcd c =0*m+c*n
  proof
    take 0,1;
    thus thesis by NEWTON:52;
  end;
  now
    per cases;
    suppose
      a=0;
      hence thesis by A1;
    end;
    suppose
A2:   b=0;
      then ex m,n st (a gcd b)=0*m+a*n by A1;
      hence thesis by A2;
    end;
    suppose
A3:   a<>0 & b<>0;
      defpred P[set] means ex m,n st $1=a*m+b*n & $1<>0;
      a+b=a*1+b*1;
      then
A4:   ex c be Nat st P[c] by A3;
      consider d being Nat such that
A5:   P[d] & for c being Nat st P[c] holds d<=c from NAT_1:sch 5(A4);
      consider e,f be Nat such that
A6:   a=d*e+f and
A7:   f<d by A5,NAT_1:17;
      consider m,n such that
A8:   d=a*m+b*n by A5;
A9:   now
        assume
A10:    f<>0;
        f=a-d*e by A6
          .=a*(1-m*e)+b*(-(n*e)) by A8;
        hence contradiction by A5,A7,A10;
      end;
      consider e,f be Nat such that
A11:  b=d*e+f and
A12:  f<d by A5,NAT_1:17;
      now
        assume
A13:    f<>0;
        f=b-d*e by A11
          .=b*(1-n*e)+a*(-(m*e)) by A8;
        hence contradiction by A5,A12,A13;
      end;
      then
A14:  d divides b by A11;
      d divides a by A6,A9;
      then
A15:  d divides (a gcd b) by A14,NAT_D:def 5;
      (a gcd b) divides a & (a gcd b) divides b by NAT_D:def 5;
      then (a gcd b) divides (d qua Integer) by A8,Th5;
      hence thesis by A8,A15,NAT_D:5;
    end;
  end;
  hence thesis;
end;
