reserve x,y for set,
  n for Nat;

theorem Th6:
  for f be non empty FinSequence of NAT,D be non empty
  disjoint_with_NAT set holds FreeGenSetNSG(f,D) is free
proof
  let f be non empty FinSequence of NAT, D be non empty disjoint_with_NAT set;
  set fgs = FreeGenSetNSG(f,D), fua = FreeUnivAlgNSG(f,D);
  let U1 be Universal_Algebra;
  assume
A1: fua,U1 are_similar;
  set A = DTConUA(f,D), c1 = the carrier of U1, cf = the carrier of fua;
  let F be Function of fgs,the carrier of U1;
  deffunc F(Symbol of A) = pi(F,$1);
  deffunc G(Symbol of A,FinSequence,set) = (oper(@$1,U1))/.$3;
  consider ff being Function of TS(A), c1 such that
A2: for t being Symbol of A st t in Terminals A holds ff.(root-tree t) =
  F(t) and
A3: for nt being Symbol of A, ts being FinSequence of TS(A) st nt ==>
  roots ts holds ff.(nt-tree ts) = G(nt,roots ts,ff * ts) from DTCONSTR:sch 8;
  reconsider ff as Function of fua,U1;
  take ff;
  for n being Nat st n in dom the charact of(fua) for o1 be
operation of fua, o2 be operation of U1 st o1=(the charact of fua).n & o2=(the
  charact of U1).n for x be FinSequence of fua st x in dom o1 holds ff.(o1.x) =
  o2.(ff*x)
  proof
A4: Seg len the charact of U1 = dom the charact of U1 by FINSEQ_1:def 3;
    let n be Nat;
    assume
A5: n in dom the charact of fua;
    let o1 be operation of fua, o2 be operation of U1;
    assume that
A6: o1=(the charact of fua).n and
A7: o2=(the charact of U1).n;
    let x be FinSequence of fua;
    assume
A8: x in dom o1;
    reconsider xa = x as FinSequence of TS(A);
    dom (roots xa) = dom xa by TREES_3:def 18
      .= Seg len xa by FINSEQ_1:def 3;
    then
A9: len (roots xa) = len xa by FINSEQ_1:def 3;
    reconsider xa as FinSequence of FinTrees the carrier of A;
    reconsider rxa = roots xa as FinSequence of ((dom f) \/ D);
    reconsider rxa as Element of ((dom f) \/ D)* by FINSEQ_1:def 11;
    dom o1 = (arity o1)-tuples_on cf by MARGREL1:22
      .= {w where w is Element of cf* : len w = arity o1};
    then
A10: ex w be Element of cf* st x = w & len w = arity o1 by A8;
A11: o1 = FreeOpNSG(n,f,D) by A5,A6,Def11;
    reconsider fx = ff*x as Element of c1*;
A12: dom o2 = (arity o2)-tuples_on c1 by MARGREL1:22
      .= {v where v is Element of c1*: len v = arity o2};
A13: len the charact of(fua) = len the charact of(U1) & Seg len the
    charact of( fua) = dom the charact of(fua) by A1,FINSEQ_1:def 3,UNIALG_2:1;
A14: dom FreeOpSeqNSG(f,D) = Seg len FreeOpSeqNSG(f,D) by FINSEQ_1:def 3;
A15: len FreeOpSeqNSG(f,D) = len f & Seg len f = dom f by Def11,FINSEQ_1:def 3;
    then reconsider nt = n as Symbol of A by A5,A14,XBOOLE_0:def 3;
    reconsider nd = n as Element of ((dom f) \/ D) by A5,A15,A14,XBOOLE_0:def 3
    ;
A16: f = signature fua by Th4;
    then
A17: (signature fua).n = arity o1 by A5,A6,A15,A14,UNIALG_1:def 4;
    then [nd,rxa] in REL(f,D) by A5,A15,A14,A16,A10,A9,Def7;
    then
A18: nt ==> (roots xa) by LANG1:def 1;
    then
A19: ff.(nt-tree xa) = (oper(@nt,U1))/.(ff*x) by A3;
    @nt = n by A18,Def15;
    then
A20: oper(@nt,U1) = o2 by A5,A7,A13,A4,Def3;
    signature fua = signature U1 by A1;
    then len (ff*x) = len x & arity o2 = len x by A5,A7,A15,A14,A16,A10,A17,
FINSEQ_3:120,UNIALG_1:def 4;
    then
A21: fx in {v where v is Element of c1*: len v = arity o2};
    reconsider xa as Element of (TS A)* by FINSEQ_1:def 11;
    Sym(n,f,D) = nt by A5,A15,A14,Def9;
    then o1.x = nt-tree xa by A5,A8,A15,A14,A11,Def10;
    hence thesis by A19,A20,A12,A21,PARTFUN1:def 6;
  end;
  hence ff is_homomorphism by A1,ALG_1:def 1;
A22: (the carrier of fua) /\ fgs = fgs by XBOOLE_1:28;
A23: dom (ff|fgs) = dom ff /\ fgs & dom ff = (the carrier of fua) by
FUNCT_2:def 1,RELAT_1:61;
A24: now
    let x be object;
    assume
A25: x in dom F;
    then x in {root-tree t where t is Symbol of A: t in Terminals A};
    then consider s be Symbol of A such that
A26: x = root-tree s & s in Terminals A;
    thus (ff|fgs).x = ff.x by A23,A22,A25,FUNCT_1:47
      .= pi(F,s) by A2,A26
      .= F.x by A26,Def14;
  end;
  fgs = dom F by FUNCT_2:def 1;
  hence thesis by A23,A22,A24,FUNCT_1:2;
end;
