reserve i, j, k, c, m, n for Nat,
  a, x, y, z, X, Y for set,
  D, E for non empty set,
  R for Relation,
  f, g for Function,
  p, q for FinSequence;
reserve f1, f2 for non empty homogeneous to-naturals NAT*-defined Function,
  e1, e2 for homogeneous to-naturals NAT*-defined Function,
  p for Element of (arity f1+1)-tuples_on NAT;
reserve P for primitive-recursively_closed non empty Subset of HFuncs NAT;

theorem Th75:
  Union PrimRec-Approximation is primitive-recursively_closed
proof
  set PROJ = {n proj i where n,i is Element of NAT: 1 <= i & i <= n};
  set prd = PrimRec-Approximation;
  set UP = Union prd;
A1: dom prd = NAT by FUNCT_2:def 1;
A2: prd.0 = {0 const 0, 1 succ 1} \/ PROJ by Def20;
  0 const 0 in {0 const 0, 1 succ 1} by TARSKI:def 2;
  then 0 const 0 in prd.0 by A2,XBOOLE_0:def 3;
  hence 0 const 0 in UP by A1,CARD_5:2;
  1 succ 1 in {0 const 0, 1 succ 1} by TARSKI:def 2;
  then 1 succ 1 in prd.0 by A2,XBOOLE_0:def 3;
  hence 1 succ 1 in UP by A1,CARD_5:2;
  hereby
    let n,i;
    assume that
A3: 1 <= i and
A4: i <= n;
    n in NAT & i in NAT by ORDINAL1:def 12;
    then n proj i in PROJ by A3,A4;
    then n proj i in prd.0 by A2,XBOOLE_0:def 3;
    hence n proj i in UP by A1,CARD_5:2;
  end;
  hereby
    deffunc mcocl(Element of NAT) = {f*<:F:> where f is Element of HFuncs NAT,
F is with_the_same_arity Element of (HFuncs NAT)*: f in prd.$1 & arity f = len
    F & rng F c= prd.$1};
    let f be Element of HFuncs NAT, F be with_the_same_arity FinSequence of
    HFuncs NAT such that
A5: f in UP and
A6: arity f = len F and
A7: rng F c= UP;
    consider kf being object such that
A8: kf in dom prd and
A9: f in prd.kf by A5,CARD_5:2;
    reconsider kf as Element of NAT by A8;
    per cases;
    suppose
      arity f = 0;
      then F = {} by A6;
      then
A10:  rng F c= prd.kf;
      F is with_the_same_arity Element of (HFuncs NAT)* by FINSEQ_1:def 11;
      then f*<:F:> in mcocl(kf) by A6,A9,A10;
      then f*<:F:> in prd.kf \/ mcocl(kf) by XBOOLE_0:def 3;
      then f*<:F:> in PR-closure (prd.kf) \/ composition-closure(prd.kf) by
XBOOLE_0:def 3;
      then f*<:F:> in prd.(kf+1) by Def20;
      hence f*<:F:> in UP by A1,CARD_5:2;
    end;
    suppose
A11:  arity f <> 0;
      defpred B[object,object] means
ex k being Element of NAT st F.$1 in prd.k & $2
      = k;
A12:  for x being object st x in Seg len F ex y being Element of NAT st B[x,y]
      proof
        let x be object;
        assume x in Seg len F;
        then x in dom F by FINSEQ_1:def 3;
        then F.x in rng F by FUNCT_1:def 3;
        then consider k being object such that
A13:    k in dom prd and
A14:    F.x in prd.k by A7,CARD_5:2;
        reconsider k as Element of NAT by A13;
        take k;
        take k1 = k;
        thus F.x in prd.k1 by A14;
        thus thesis;
      end;
      consider fKF being Function of Seg len F, NAT such that
A15:  for x being object st x in Seg len F holds B[x,fKF.x] from
      MONOID_1:sch 1(A12);
      set KF = rng fKF;
      reconsider KF as non empty finite Subset of NAT by A6,A11,RELAT_1:def 19;
      set K = max KF;
      set k = max(kf, K);
      reconsider k as Element of NAT by ORDINAL1:def 12;
A16:  dom fKF = Seg len F by FUNCT_2:def 1;
A17:  rng F c= prd.k
      proof
        let x be object;
A18:    K <= k by XXREAL_0:25;
        assume x in rng F;
        then consider d being object such that
A19:    d in dom F and
A20:    x = F.d by FUNCT_1:def 3;
A21:    d in Seg len F by A19,FINSEQ_1:def 3;
        then consider m being Element of NAT such that
A22:    F.d in prd.m and
A23:    fKF.d = m by A15;
        m in KF by A16,A21,A23,FUNCT_1:3;
        then m <= K by XXREAL_2:def 8;
        then prd.m c= prd.k by A18,Th74,XXREAL_0:2;
        hence thesis by A20,A22;
      end;
A24:  F is with_the_same_arity Element of (HFuncs NAT)* by FINSEQ_1:def 11;
      prd.kf c= prd.k by Th74,XXREAL_0:25;
      then f*<:F:> in mcocl(k) by A6,A9,A17,A24;
      then f*<:F:> in prd.k \/ mcocl(k) by XBOOLE_0:def 3;
      then f*<:F:> in PR-closure (prd.k) \/ composition-closure(prd.k)
      by XBOOLE_0:def 3;
      then f*<:F:> in prd.(k+1) by Def20;
      hence f*<:F:> in UP by A1,CARD_5:2;
    end;
  end;
  deffunc mprcl(Element of NAT) = {g where g is Element of HFuncs NAT: ex f1,
f2 being Element of HFuncs NAT, i being Element of NAT st f1 in prd.$1 & f2 in
  prd.$1 & g is_primitive-recursively_expressed_by f1,f2,i};
  let g, f1, f2 be Element of HFuncs NAT, i be Nat such that
A25: g is_primitive-recursively_expressed_by f1,f2,i and
A26: f1 in UP and
A27: f2 in UP;
B1: i in NAT by ORDINAL1:def 12;
  consider k2 being object such that
A28: k2 in dom prd and
A29: f2 in prd.k2 by A27,CARD_5:2;
  reconsider k2 as Element of NAT by A28;
  consider k1 being object such that
A30: k1 in dom prd and
A31: f1 in prd.k1 by A26,CARD_5:2;
  reconsider k1 as Element of NAT by A30;
  per cases;
  suppose
    k1 <= k2;
    then prd.k1 c= prd.k2 by Th74;
    then g in mprcl(k2) by A25,A31,A29,B1;
    then g in prd.k2 \/ mprcl(k2) by XBOOLE_0:def 3;
    then g in PR-closure (prd.k2) \/ composition-closure(prd.k2)
    by XBOOLE_0:def 3;
    then g in prd.(k2+1) by Def20;
    hence thesis by A1,CARD_5:2;
  end;
  suppose
    k2 <= k1;
    then prd.k2 c= prd.k1 by Th74;
    then g in mprcl(k1) by A25,A31,A29,B1;
    then g in prd.k1 \/ mprcl(k1) by XBOOLE_0:def 3;
    then g in PR-closure (prd.k1) \/ composition-closure(prd.k1)
    by XBOOLE_0:def 3;
    then g in prd.(k1+1) by Def20;
    hence thesis by A1,CARD_5:2;
  end;
end;
