set PROJ = { (n proj i) where n, i is Element of NAT : ( 1 <= i & i <= n ) } ;
set prd = PrimRec-Approximation ;
set UP = Union PrimRec-Approximation;
A1: dom PrimRec-Approximation = NAT by FUNCT_2:def 1;
A2: PrimRec-Approximation . 0 = {(0 const 0),(1 succ 1)} \/ { (n proj i) where n, i is Element of NAT : ( 1 <= i & i <= n ) } by Def20;
0 const 0 in {(0 const 0),(1 succ 1)} by TARSKI:def 2;
then 0 const 0 in PrimRec-Approximation . 0 by A2, XBOOLE_0:def 3;
hence 0 const 0 in Union PrimRec-Approximation by A1, CARD_5:2; :: according to COMPUT_1:def 14 :: thesis: ( 1 succ 1 in Union PrimRec-Approximation & ( for n, i being Nat st 1 <= i & i <= n holds
n proj i in Union PrimRec-Approximation ) & Union PrimRec-Approximation is composition_closed & Union PrimRec-Approximation is primitive-recursion_closed )

1 succ 1 in {(0 const 0),(1 succ 1)} by TARSKI:def 2;
then 1 succ 1 in PrimRec-Approximation . 0 by A2, XBOOLE_0:def 3;
hence 1 succ 1 in Union PrimRec-Approximation by A1, CARD_5:2; :: thesis: ( ( for n, i being Nat st 1 <= i & i <= n holds
n proj i in Union PrimRec-Approximation ) & Union PrimRec-Approximation is composition_closed & Union PrimRec-Approximation is primitive-recursion_closed )

hereby :: thesis: ( Union PrimRec-Approximation is composition_closed & Union PrimRec-Approximation is primitive-recursion_closed ) end;
hereby :: according to COMPUT_1:def 12 :: thesis: Union PrimRec-Approximation is primitive-recursion_closed
deffunc H1( Element of NAT ) -> set = { (f * <:F:>) where f is Element of HFuncs NAT, F is with_the_same_arity Element of (HFuncs NAT) * : ( f in PrimRec-Approximation . $1 & arity f = len F & rng F c= PrimRec-Approximation . $1 ) } ;
let f be Element of HFuncs NAT; :: thesis: for F being with_the_same_arity FinSequence of HFuncs NAT st f in Union PrimRec-Approximation & arity f = len F & rng F c= Union PrimRec-Approximation holds
b2 * <:b3:> in Union PrimRec-Approximation

let F be with_the_same_arity FinSequence of HFuncs NAT; :: thesis: ( f in Union PrimRec-Approximation & arity f = len F & rng F c= Union PrimRec-Approximation implies b1 * <:b2:> in Union PrimRec-Approximation )
assume that
A5: f in Union PrimRec-Approximation and
A6: arity f = len F and
A7: rng F c= Union PrimRec-Approximation ; :: thesis: b1 * <:b2:> in Union PrimRec-Approximation
consider kf being object such that
A8: kf in dom PrimRec-Approximation and
A9: f in PrimRec-Approximation . kf by A5, CARD_5:2;
reconsider kf = kf as Element of NAT by A8;
per cases ( arity f = 0 or arity f <> 0 ) ;
suppose A11: arity f <> 0 ; :: thesis: b1 * <:b2:> in Union PrimRec-Approximation
defpred S2[ object , object ] means ex k being Element of NAT st
( F . $1 in PrimRec-Approximation . k & $2 = k );
A12: for x being object st x in Seg (len F) holds
ex y being Element of NAT st S2[x,y]
proof
let x be object ; :: thesis: ( x in Seg (len F) implies ex y being Element of NAT st S2[x,y] )
assume x in Seg (len F) ; :: thesis: ex y being Element of NAT st S2[x,y]
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 PrimRec-Approximation and
A14: F . x in PrimRec-Approximation . k by A7, CARD_5:2;
reconsider k = k as Element of NAT by A13;
take k ; :: thesis: S2[x,k]
take k1 = k; :: thesis: ( F . x in PrimRec-Approximation . k1 & k = k1 )
thus F . x in PrimRec-Approximation . k1 by A14; :: thesis: k = k1
thus k = k1 ; :: thesis: verum
end;
consider fKF being Function of (Seg (len F)),NAT such that
A15: for x being object st x in Seg (len F) holds
S2[x,fKF . x] from MONOID_1:sch 1(A12);
set KF = rng fKF;
reconsider KF = rng fKF as non empty finite Subset of NAT by A6, A11, RELAT_1:def 19;
set K = max KF;
set k = max (kf,(max KF));
reconsider k = max (kf,(max KF)) as Element of NAT by ORDINAL1:def 12;
A16: dom fKF = Seg (len F) by FUNCT_2:def 1;
A17: rng F c= PrimRec-Approximation . k
proof
let x be object ; :: according to TARSKI:def 3 :: thesis: ( not x in rng F or x in PrimRec-Approximation . k )
A18: max KF <= k by XXREAL_0:25;
assume x in rng F ; :: thesis: x in PrimRec-Approximation . k
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 PrimRec-Approximation . m and
A23: fKF . d = m by A15;
m in KF by A16, A21, A23, FUNCT_1:3;
then m <= max KF by XXREAL_2:def 8;
then PrimRec-Approximation . m c= PrimRec-Approximation . k by A18, Th74, XXREAL_0:2;
hence x in PrimRec-Approximation . k by A20, A22; :: thesis: verum
end;
A24: F is with_the_same_arity Element of (HFuncs NAT) * by FINSEQ_1:def 11;
PrimRec-Approximation . kf c= PrimRec-Approximation . k by Th74, XXREAL_0:25;
then f * <:F:> in H1(k) by A6, A9, A17, A24;
then f * <:F:> in (PrimRec-Approximation . k) \/ H1(k) by XBOOLE_0:def 3;
then f * <:F:> in (PR-closure (PrimRec-Approximation . k)) \/ (composition-closure (PrimRec-Approximation . k)) by XBOOLE_0:def 3;
then f * <:F:> in PrimRec-Approximation . (k + 1) by Def20;
hence f * <:F:> in Union PrimRec-Approximation by A1, CARD_5:2; :: thesis: verum
end;
end;
end;
deffunc H1( Element of NAT ) -> set = { g where g is Element of HFuncs NAT : ex f1, f2 being Element of HFuncs NAT ex i being Element of NAT st
( f1 in PrimRec-Approximation . $1 & f2 in PrimRec-Approximation . $1 & g is_primitive-recursively_expressed_by f1,f2,i )
}
;
let g, f1, f2 be Element of HFuncs NAT; :: according to COMPUT_1:def 13 :: thesis: for i being Nat st g is_primitive-recursively_expressed_by f1,f2,i & f1 in Union PrimRec-Approximation & f2 in Union PrimRec-Approximation holds
g in Union PrimRec-Approximation

let i be Nat; :: thesis: ( g is_primitive-recursively_expressed_by f1,f2,i & f1 in Union PrimRec-Approximation & f2 in Union PrimRec-Approximation implies g in Union PrimRec-Approximation )
assume that
A25: g is_primitive-recursively_expressed_by f1,f2,i and
A26: f1 in Union PrimRec-Approximation and
A27: f2 in Union PrimRec-Approximation ; :: thesis: g in Union PrimRec-Approximation
B1: i in NAT by ORDINAL1:def 12;
consider k2 being object such that
A28: k2 in dom PrimRec-Approximation and
A29: f2 in PrimRec-Approximation . k2 by A27, CARD_5:2;
reconsider k2 = k2 as Element of NAT by A28;
consider k1 being object such that
A30: k1 in dom PrimRec-Approximation and
A31: f1 in PrimRec-Approximation . k1 by A26, CARD_5:2;
reconsider k1 = k1 as Element of NAT by A30;
per cases ( k1 <= k2 or k2 <= k1 ) ;
end;