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 lcm m) = max(pfexp n, pfexp m)
proof
  let m, n be non zero Nat;
  now
    set rhs = max(pfexp n, pfexp m);
    set lhs = pfexp (n lcm m);
    let i be object;
A1: m divides n lcm m by NAT_D:def 4;
    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 lcm m);
A2: lhs.j = z by Def8;
A3: (pfexp n).j = x by Def8;
A4: j > 1 by INT_2:def 4;
    then
A5: not j |^ (x+1) divides n by Def7;
A6: n lcm m <> 0 by INT_2:4;
    then
A7: j |^ z divides (n lcm m) by A4,Def7;
A8: not j |^ (z+1) divides (n lcm m) by A4,A6,Def7;
A9: (pfexp m).j = y by Def8;
A10: n divides n lcm m by NAT_D:def 4;
A11: j |^ x divides n by A4,Def7;
    then
A12: j |^ x divides n lcm m by A10,NAT_D:4;
A13: not j |^ (y+1) divides m by A4,Def7;
A14: j |^ y divides m by A4,Def7;
    then
A15: j |^ y divides n lcm m by A1,NAT_D:4;
    thus lhs.i = rhs.i
    proof
      per cases;
      suppose
A16:    (pfexp n).j <= (pfexp m).j;
A17:    now
          consider p being Nat such that
A18:      y = x+p by A3,A9,A16,NAT_1:10;
          consider t being Nat such that
A19:      n = (j |^ x) * t by A11;
A20:      now
            assume j divides t;
            then consider w being Nat such that
A21:        t = j*w;
            n = (j |^ x) * j * w by A19,A21
              .= (j |^ (x+1)) * w by NEWTON:6;
            hence contradiction by A5;
          end;
          consider u being Nat such that
A22:      n lcm m = n*u by A10;
          assume y < z;
          then j |^ (y+1) divides n lcm m by A7,Th4;
          then consider k being Nat such that
A23:      n lcm m = (j |^ (y+1))*k;
A24:      n lcm m = (j |^ y)*j*k by A23,NEWTON:6
            .= (j |^ y)*(k*j);
          (j |^ x)*((j |^ p) *(k*j)) = ((j |^ x)*(j |^ p)) *(k*j)
            .= (j |^ x)*(t*u) by A24,A19,A22,A18,NEWTON:8;
          then (j |^p)*k*j = t*u by XCMPLX_1:5;
          then j divides t*u;
          then j divides u by A20,NEWTON:80;
          then consider w being Nat such that
A25:      u = j*w;
          (j |^ y)*k*j = n*w*j by A24,A22,A25;
          then (j |^ y)*k = n*w by XCMPLX_1:5;
          then
A26:      n divides (j |^ y)*k;
          consider t being Nat such that
A27:      m = (j |^ y) * t by A14;
A28:      now
            assume j divides t;
            then consider w being Nat such that
A29:        t = j*w;
            m = (j |^ y) * j * w by A27,A29
              .= (j |^ (y+1)) * w by NEWTON:6;
            hence contradiction by A13;
          end;
          consider u being Nat such that
A30:      n lcm m = m*u by A1;
          (j |^ y)*(k*j) = (j |^ y)*(t*u) by A24,A27,A30;
          then k*j = t*u by XCMPLX_1:5;
          then j divides t*u;
          then j divides u by A28,NEWTON:80;
          then consider w being Nat such that
A31:      u = j*w;
          (j |^ y)*k*j = m*w*j by A24,A30,A31;
          then (j |^ y)*k = m*w by XCMPLX_1:5;
          then m divides (j |^ y)*k;
          then
A32:      n lcm m divides (j |^ y)*k by A26,NAT_D:def 4;
          0 <> k by A23,INT_2:4;
          then j |^ (y+1) <= j |^ y by A23,A32,NAT_D:7,XREAL_1:68;
          then (j |^ y) * j <= (j |^ y)*1 by NEWTON:6;
          then j <= 1 by XREAL_1:68;
          hence contradiction by INT_2:def 4;
        end;
A33:    y <= z by A8,A15,Th4;
        rhs.j = y by A9,A16,Def4;
        hence thesis by A2,A33,A17,XXREAL_0:1;
      end;
      suppose
A34:    (pfexp n).j > (pfexp m).j;
A35:    now
          consider p being Nat such that
A36:      x = y+p by A3,A9,A34,NAT_1:10;
          consider t being Nat such that
A37:      m = (j |^ y) * t by A14;
A38:      now
            assume j divides t;
            then consider w being Nat such that
A39:        t = j*w;
            m = (j |^ y) * j * w by A37,A39
              .= (j |^ (y+1)) * w by NEWTON:6;
            hence contradiction by A13;
          end;
          consider u being Nat such that
A40:      n lcm m = m*u by A1;
          assume x < z;
          then j |^ (x+1) divides n lcm m by A7,Th4;
          then consider k being Nat such that
A41:      n lcm m = (j |^ (x+1))*k;
A42:      n lcm m = (j |^ x)*j*k by A41,NEWTON:6
            .= (j |^ x)*(k*j);
          (j |^ y)*((j |^ p) *(k*j)) = (j |^ y)*(j |^ p) *(k*j)
            .= (j|^y)*(t*u) by A42,A37,A40,A36,NEWTON:8;
          then t*u = (j|^p)*k*j by XCMPLX_1:5;
          then j divides t*u;
          then j divides u by A38,NEWTON:80;
          then consider w being Nat such that
A43:      u = j*w;
          (j |^ x)*k*j = m*w*j by A42,A40,A43;
          then (j |^ x)*k = m*w by XCMPLX_1:5;
          then
A44:      m divides (j |^ x)*k;
          consider t being Nat such that
A45:      n = (j |^ x) * t by A11;
A46:      now
            assume j divides t;
            then consider w being Nat such that
A47:        t = j*w;
            n = (j |^ x) * j * w by A45,A47
              .= (j |^ (x+1)) * w by NEWTON:6;
            hence contradiction by A5;
          end;
          consider u being Nat such that
A48:      n lcm m = n*u by A10;
          (j |^ x)*(k*j) = (j |^ x)*(t*u) by A42,A45,A48;
          then k*j = t*u by XCMPLX_1:5;
          then j divides t*u;
          then j divides u by A46,NEWTON:80;
          then consider w being Nat such that
A49:      u = j*w;
          (j |^ x)*k*j = n*w*j by A42,A48,A49;
          then (j |^ x)*k = n*w by XCMPLX_1:5;
          then n divides (j |^ x)*k;
          then
A50:      n lcm m divides (j |^ x)*k by A44,NAT_D:def 4;
          0 <> k by A41,INT_2:4;
          then j |^ (x+1) <= j |^ x by A41,A50,NAT_D:7,XREAL_1:68;
          then (j |^ x) * j <= (j |^ x)*1 by NEWTON:6;
          then j <= 1 by XREAL_1:68;
          hence contradiction by INT_2:def 4;
        end;
A51:    x <= z by A8,A12,Th4;
        rhs.j = x by A3,A34,Def4;
        hence thesis by A2,A51,A35,XXREAL_0:1;
      end;
    end;
  end;
  hence thesis;
end;
