
theorem Th2:
  for X,Y,Z,D being set st D c= Funcs([:X,Y:], Z) ex F being
ManySortedSet of D st F is currying & ((Y = {} implies X = {}) implies rng F c=
  Funcs(X, Funcs(Y, Z)))
proof
  let X,Y,Z,D be set;
  assume
A1: D c= Funcs([:X,Y:], Z);
  per cases;
  suppose
    D is empty;
    then reconsider F={} as ManySortedSet of D by PARTFUN1:def 2,RELAT_1:38
,def 18;
    take F;
    thus F is currying;
    assume Y = {} implies X = {};
    thus thesis;
  end;
  suppose
    D is non empty;
    then reconsider E=D as non empty functional set by A1;
    deffunc F(Function) = curry $1;
    consider F being ManySortedSet of E such that
A2: for d being Element of E holds F.d = F(d) from PBOOLE:sch 5;
    reconsider F1=F as ManySortedSet of D;
    take F1;
    thus F1 is currying
    proof
      hereby
        let x be set;
        assume x in dom F1;
        then
A3:     x in D;
        hence x is Function by A1;
        ex x1 being Function st x1=x & dom x1=[:X,Y:] &
        rng x1 c= Z by A3,A1,FUNCT_2:def 2;
        hence proj1 x is Relation;
      end;
      let f be Function;
      assume f in dom F1;
      then reconsider d=f as Element of E;
      thus F1.f = F.d .= curry f by A2;
    end;
    assume
A4: Y = {} implies X = {};
    thus rng F1 c= Funcs(X, Funcs(Y, Z))
    proof
      let y be object;
      assume y in rng F1;
      then consider x being object such that
A5:   x in dom F1 and
A6:   y = F1.x by FUNCT_1:def 3;
      reconsider d=x as Element of E by A5;
A7:   y = curry d by A2,A6;
A8:   d in Funcs([:X,Y:], Z) by A1;
      per cases;
      suppose
A9:     [:X,Y:] = {};
        then
A10:    d is Function of {}, Z by A8,FUNCT_2:66;
        now
          assume
A11:      X = {};
          then y is Function of X, Funcs(Y,Z) by A7,A10,FUNCT_5:42,RELSET_1:12;
          hence thesis by A11,FUNCT_2:8;
        end;
        hence thesis by A4,A9;
      end;
      suppose
        [:X,Y:] <> {};
        hence thesis by A7,A8,FUNCT_6:10;
      end;
    end;
  end;
end;
