reserve x,y,z for set;

theorem Th14:
  for S being non void Signature for X being non-empty
ManySortedSet of the carrier of S for t being Term of S, X holds S variables_in
  t c= X
proof
  let S be non void Signature;
  let X be non-empty ManySortedSet of the carrier of S;
  defpred P[DecoratedTree] means S variables_in $1 c= X;
A1: for o being OperSymbol of S, p being ArgumentSeq of Sym(o,X) st for t
being Term of S,X st t in rng p holds P[t] holds P[[o,the carrier of S]-tree p]
  proof
    let o be OperSymbol of S, p be ArgumentSeq of Sym(o,X) such that
A2: for t being Term of S,X st t in rng p holds S variables_in t c= X;
    set q = [o, the carrier of S]-tree p;
    thus S variables_in q c= X
    proof
      let s9 be object;
      assume s9 in the carrier of S;
      then reconsider z = s9 as SortSymbol of S;
      let x be object;
      assume x in (S variables_in q).s9;
      then consider t being DecoratedTree such that
A3:   t in rng p and
A4:   x in (S variables_in t).z by Th11;
      consider i being object such that
A5:   i in dom p and
A6:   t = p.i by A3,FUNCT_1:def 3;
      reconsider i as Nat by A5;
      reconsider t = p.i as Term of S,X by A5,MSATERM:22;
      S variables_in t c= X by A2,A3,A6;
      then (S variables_in t).z c= X.z;
      hence thesis by A4,A6;
    end;
  end;
A7: for s being SortSymbol of S, v being Element of X.s holds P[root-tree [v
  ,s]]
  proof
    let s be SortSymbol of S, v be Element of X.s;
    thus S variables_in root-tree [v,s] c= X
    proof
      let s9 be object;
      assume s9 in the carrier of S;
      then reconsider z = s9 as SortSymbol of S;
      let x be object;
      assume
A8:   x in (S variables_in root-tree [v,s]).s9;
      then
A9:   s <> z implies x in {} by Th10;
      s = z implies x in {v} by A8,Th10;
      hence thesis by A9;
    end;
  end;
  for t being Term of S,X holds P[t] from MSATERM:sch 1(A7,A1);
  hence thesis;
end;
