reserve k,m,n for Nat,
  a, b, c for object,
  x, y, X, Y, Z for set,
  D for non empty set;
reserve p, q, r, s, t, u, v for FinSequence;
reserve P, Q, R, P1, P2, Q1, Q2, R1, R2 for FinSequence-membered set;
reserve S, T for non empty FinSequence-membered set;
reserve A for Function of P, NAT;
reserve U, V, W for Subset of P*;

theorem Th27:
  for P, A, n, q st q in (Polish-expression-set(P, A))^^n
      ex m st q in (Polish-expression-hierarchy(P, A, m))^^n
proof
  let P, A;
  defpred S[ Nat ] means
      for q st q in (Polish-expression-set(P, A))^^$1
          ex m st q in (Polish-expression-hierarchy(P, A, m))^^$1;
  A1: S[ 0 ]
    proof
    let q;
    assume q in (Polish-expression-set(P, A))^^0;
    then q in {{}} by Def3;
    then q in (Polish-expression-hierarchy(P, A, 0))^^0 by Def3;
    hence thesis;
    end;
  A2: for k holds S[ k ] implies S[ k + 1 ]
    proof
    let k;
    assume A3: S[ k ];
    set X = the set of all Polish-expression-hierarchy(P, A, n) where
      n is Nat;
    let q;
    assume q in (Polish-expression-set(P, A))^^(k+1);
    then q in ((Polish-expression-set(P, A))^^k)^
        Polish-expression-set(P, A) by Th6;
    then consider r, s such that
    A6: q = r^s and A7: r in (Polish-expression-set(P, A))^^k and
    A8: s in Polish-expression-set(P, A) by Def2;
    consider m such that
    A9: r in Polish-expression-hierarchy(P, A, m)^^k by A3, A7;
    consider Y such that A10: s in Y and A11: Y in X by A8, TARSKI:def 4;
    consider m1 being Nat such that
    A12: Y = Polish-expression-hierarchy(P, A, m1) by A11;
    A14: Polish-expression-hierarchy(P, A, m)^^k
          c= Polish-expression-hierarchy(P, A, m+m1)^^k by Th17, Th25;
    s in Polish-expression-hierarchy(P, A, m+m1)
        by A10, A12, Th25, TARSKI:def 3;
    then r^s in (Polish-expression-hierarchy(P, A, m+m1)^^k)
            ^Polish-expression-hierarchy(P, A,m+m1) by A9, A14, Def2;
    then q in (Polish-expression-hierarchy(P, A, m+m1))^^(k+1) by A6, Th6;
    hence thesis;
    end;
  for k holds S[ k ] from NAT_1:sch 2(A1, A2);
  hence thesis;
end;
