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;
reserve fp,fp1 for FinSequence of NAT,

  b,c,d, n for Element of NAT,
  a for Nat;
reserve i,m,m1,m2,m3,r,s,a,b,c,c1,c2,x,y for Integer;

theorem Th46:
  for n1,n2,n3 being non zero Nat holds (n1 gcd n3) lcm
  (n2 gcd n3) = (n1 lcm n2) gcd n3
proof
  let n1,n2,n3 be non zero Nat;
  set d1 = n1 gcd n3;
  set d2 = n2 gcd n3;
  set M = n1 lcm n2;
  reconsider d = M gcd n3 as non zero Nat by INT_2:5;
  reconsider M as non zero Nat by INT_2:4;
  d1 divides n3 & d2 divides n3 by NAT_D:def 5;
  then
A1: (d1 lcm d2) divides n3 by NAT_D:def 4;
  d2 divides n2 & n2 divides M by NAT_D:def 4,def 5;
  then
A2: d2 divides M by NAT_D:4;
A3: for p being Nat st p in support pfexp d holds (ppf d).p
  divides n1 or (ppf d).p divides n2
  proof
    let p be Nat;
    assume that
A4: p in support pfexp d and
A5: not (ppf d).p divides n1 and
A6: not (ppf d).p divides n2;
A7: not p|^(p |-count d) divides n2 by A4,A6,NAT_3:def 9;
A8: p is Prime by A4,NAT_3:34;
A9: not p|^(p |-count d) divides n1 by A4,A5,NAT_3:def 9;
A10: p |-count d > p |-count M
    proof
A11:  p |-count M = (pfexp M).p by A8,NAT_3:def 8
        .= (max(pfexp n1,pfexp n2)).p by NAT_3:54;
      per cases;
      suppose
        (pfexp n1).p <= (pfexp n2).p;
        then p |-count M = (pfexp n2).p by A11,NAT_3:def 4
          .= p |-count n2 by A8,NAT_3:def 8;
        hence thesis by A7,A8,MOEBIUS1:9;
      end;
      suppose
        (pfexp n1).p > (pfexp n2).p;
        then p |-count M = (pfexp n1).p by A11,NAT_3:def 4
          .= p |-count n1 by A8,NAT_3:def 8;
        hence thesis by A9,A8,MOEBIUS1:9;
      end;
    end;
    d divides M by NAT_D:def 5;
    hence contradiction by A8,A10,NAT_3:30;
  end;
A12: for p being Nat st p in support pfexp d holds (ppf d).p
  divides (d1 lcm d2)
  proof
A13: d2 divides (d1 lcm d2) by NAT_D:def 4;
    let p be Nat;
A14: d1 divides (d1 lcm d2) by NAT_D:def 4;
    assume
A15: p in support pfexp d;
    then
A16: p is Prime by NAT_3:34;
    d divides n3 by NAT_D:def 5;
    then (p |-count d) <= (p |-count n3) by A16,NAT_3:30;
    then p |^ (p |-count d) divides p |^ (p |-count n3) by NEWTON:89;
    then
A17: (ppf d).p divides p|^(p |-count n3) by A15,NAT_3:def 9;
    p<>1 by A16,INT_2:def 4;
    then p|^(p |-count n3) divides n3 by NAT_3:def 7;
    then
A18: (ppf d).p divides n3 by A17,NAT_D:4;
    per cases by A3,A15;
    suppose
      (ppf d).p divides n1;
      then (ppf d).p divides d1 by A18,NAT_D:def 5;
      hence thesis by A14,NAT_D:4;
    end;
    suppose
      (ppf d).p divides n2;
      then (ppf d).p divides d2 by A18,NAT_D:def 5;
      hence thesis by A13,NAT_D:4;
    end;
  end;
  Product ppf d divides (d1 lcm d2)
  proof
    set g = ppf d;
    set K = canFS(support g);
    consider f being FinSequence of COMPLEX such that
A19: Product g = Product f and
A20: f = g*K by NAT_3:def 5;
    rng f c= NAT by A20,VALUED_0:def 6;
    then reconsider f as FinSequence of NAT by FINSEQ_1:def 4;
A21: rng K = support g by FUNCT_2:def 3;
    then rng K c= NAT by XBOOLE_1:1;
    then reconsider K as FinSequence of NAT by FINSEQ_1:def 4;
A22: for m,n being Element of NAT st m in dom f & n in dom f & m<>n holds
    (f.m gcd f.n)=1
    proof
      let m,n be Element of NAT;
      assume that
A23:  m in dom f and
A24:  n in dom f and
A25:  m<>n;
A26:  m in dom K by A20,A23,FUNCT_1:11;
      then K.m in support g by A21,FUNCT_1:3;
      then
A27:  K.m in support pfexp d by NAT_3:def 9;
      then
A28:  K.m is prime by NAT_3:34;
A29:  n in dom K by A20,A24,FUNCT_1:11;
      then K.n in support g by A21,FUNCT_1:3;
      then
A30:  K.n in support pfexp d by NAT_3:def 9;
      then
A31:  K.n is prime by NAT_3:34;
      f.n = g.(K.n) by A20,A24,FUNCT_1:12;
      then
A32:  f.n = (K.n)|^((K.n) |-count d) by A30,NAT_3:def 9;
      f.m = g.(K.m) by A20,A23,FUNCT_1:12;
      then
A33:  f.m = (K.m)|^((K.m) |-count d) by A27,NAT_3:def 9;
      K.m <> K.n by A25,A26,A29,FUNCT_1:def 4;
      then
A34:  K.n,((K.m)|^((K.m) |-count d)) are_coprime by A28,A31,EULER_2:17
,INT_2:30;
A35:  K.n > 0 by A30,NAT_3:34;
      K.m > 0 by A27,NAT_3:34;
      then ((K.n)|^((K.n) |-count d)),((K.m)|^((K.m) |-count d))
      are_coprime by A35,A34,EULER_2:17;
      hence thesis by A33,A32,INT_2:def 3;
    end;
    for m being Element of NAT st m in dom f holds f.m divides (d1 lcm d2 )
    proof
      let m be Element of NAT;
      assume
A36:  m in dom f;
      then m in dom K by A20,FUNCT_1:11;
      then K.m in support g by A21,FUNCT_1:3;
      then K.m in support pfexp d by NAT_3:def 9;
      then g.(K.m) divides (d1 lcm d2) by A12;
      hence thesis by A20,A36,FUNCT_1:12;
    end;
    hence thesis by A19,A22,Th38;
  end;
  then
A37: d divides (d1 lcm d2) by NAT_3:61;
  d1 divides n1 & n1 divides M by NAT_D:def 4,def 5;
  then d1 divides M by NAT_D:4;
  then (d1 lcm d2) divides M by A2,NAT_D:def 4;
  then (d1 lcm d2) divides d by A1,NAT_D:def 5;
  hence thesis by A37,NAT_D:5;
end;
