reserve a, b, n for Nat,
  r for Real,
  f for FinSequence of REAL;
reserve p for Prime;
reserve n, m for non zero Nat;

theorem
  for m, n being non zero Nat holds pfexp (n gcd m) = min(pfexp n, pfexp m)
proof
  let m, n be non zero Nat;
  now
    set rhs = min(pfexp n, pfexp m);
    set lhs = pfexp (n gcd m);
    let i be object;
    assume i in SetPrimes;
    then reconsider j = i as prime Element of NAT by NEWTON:def 6;
    set x = j |-count n, y = j |-count m, z = j |-count (n gcd m);
A1: lhs.j = z by Def8;
A2: j <> 1 by INT_2:def 4;
    then
A3: j |^ x divides n by Def7;
A4: n gcd m <> 0 by INT_2:5;
    then
A5: j |^ z divides (n gcd m) by A2,Def7;
A6: not j |^ (z+1) divides (n gcd m) by A2,A4,Def7;
A7: not j |^ (y+1) divides m by A2,Def7;
A8: j |^ y divides m by A2,Def7;
    n gcd m divides m by NAT_D:def 5;
    then
A9: j |^ z divides m by A5,NAT_D:4;
A10: (pfexp n).j = x by Def8;
    n gcd m divides n by NAT_D:def 5;
    then
A11: j |^ z divides n by A5,NAT_D:4;
A12: (pfexp m).j = y by Def8;
A13: not j |^ (x+1) divides n by A2,Def7;
    thus lhs.i = rhs.i
    proof
      per cases;
      suppose
A14:    (pfexp n).j <= (pfexp m).j;
A15:    now
          assume
A16:      z < x;
          then z < y by A10,A12,A14,XXREAL_0:2;
          then
A17:      j |^ (z+1) divides m by A8,Th4;
          j |^ (z+1) divides n by A3,A16,Th4;
          hence contradiction by A6,A17,NAT_D:def 5;
        end;
A18:    z <= x by A13,A11,Th4;
        rhs.j = x by A10,A14,Def3;
        hence thesis by A1,A18,A15,XXREAL_0:1;
      end;
      suppose
A19:    (pfexp n).j > (pfexp m).j;
A20:    now
          assume
A21:      z < y;
          then z < x by A10,A12,A19,XXREAL_0:2;
          then
A22:      j |^ (z+1) divides n by A3,Th4;
          j |^ (z+1) divides m by A8,A21,Th4;
          hence contradiction by A6,A22,NAT_D:def 5;
        end;
A23:    z <= y by A7,A9,Th4;
        rhs.j = y by A12,A19,Def3;
        hence thesis by A1,A23,A20,XXREAL_0:1;
      end;
    end;
  end;
  hence thesis;
end;
