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
  f>0 & g>0 & (f gcd g)=1 & a|^f=b|^g implies ex e st a=e|^g & b=e|^f
proof
  assume that
A1: f>0 and
A2: g>0 and
A3: (f gcd g)=1 and
A4: a|^f=b|^g;
  now
    per cases;
    suppose
A5:   a=0;
      then a|^f=0 by A1,NAT_1:14,NEWTON:11;
      then
A6:   b=0|^f by A4,A5,CARD_4:3;
      a=0|^g by A2,A5,CARD_4:3;
      hence thesis by A6;
    end;
    suppose
A7:   b=0;
      then b|^g=0 by A2,NAT_1:14,NEWTON:11;
      then
A8:  a=0|^g by A4,A7,CARD_4:3;
      b=0|^f by A1,A7,CARD_4:3;
      hence thesis by A8;
    end;
    suppose
A9:  a<>0 & b<>0;
      consider c,d such that
A10:  f*c-g*d=1 by A1,A2,A3,Th31;
      reconsider q=(b|^c)/(a|^d) as Rational;
      a=a #Z 1 by PREPOWER:35
        .=(a |^ (f*c))/(a |^ (d*g)) by A9,A10,PREPOWER:43
        .=((a |^ f) |^ c)/(a |^ (d*g)) by NEWTON:9
        .=((b |^ g) |^ c)/((a |^ d) |^ g) by A4,NEWTON:9
        .=(b |^ (g*c))/((a |^ d) |^ g) by NEWTON:9
        .=((b |^ c) |^ g)/((a |^ d) |^ g) by NEWTON:9
        .=q|^g by PREPOWER:8;
      then consider h such that
A11:  a=h|^g by Th25;
      b|^g=h|^(f*g) by A4,A11,NEWTON:9
        .=(h|^f)|^g by NEWTON:9;
      then b=h|^f by A2,Th3;
      hence thesis by A11;
    end;
  end;
  hence thesis;
end;
