reserve X,Y for set, x,y,z for object, i,j,n for natural number;

theorem Th17:
  for J being non empty non void Signature
  for S being J-extension Signature
  for T being MSAlgebra over J
  for I being set st I c= (the carrier of S)\the carrier of J
  for X being ManySortedSet of I
  ex Q being MSAlgebra over S st Q is T-extension & (the Sorts of Q)|I = X
  proof
    let J be non empty non void Signature;
    let S be J-extension Signature;
    let T be MSAlgebra over J;
    let I be set; assume
A1: I c= (the carrier of S)\the carrier of J;
    let X be ManySortedSet of I;
    set U = (the ManySortedSet of the carrier of S)+*(the Sorts of T)+*X;
A2: J is Subsignature of S by Def2;
    dom U = dom ((the ManySortedSet of the carrier of S)+*(the Sorts of T))\/
    dom X by FUNCT_4:def 1
    .= dom (the ManySortedSet of the carrier of S) \/ dom (the Sorts of T) \/
    dom X by FUNCT_4:def 1
    .= dom (the ManySortedSet of the carrier of S) \/ dom (the Sorts of T) \/ I
    by PARTFUN1:def 2
    .= dom (the ManySortedSet of the carrier of S) \/ (the carrier of J) \/ I
    by PARTFUN1:def 2
    .= (the carrier of S)\/(the carrier of J)\/I by PARTFUN1:def 2
    .= (the carrier of S) \/ I by A2,INSTALG1:10,XBOOLE_1:12
    .= the carrier of S by A1,XBOOLE_1:1,XBOOLE_1:12;
    then reconsider U as ManySortedSet of the carrier of S
    by RELAT_1:def 18,PARTFUN1:def 2;
    set C = (the ManySortedFunction of U#*the Arity of S,
    U*the ResultSort of S)+*the Charact of T;
    dom C = (dom the ManySortedFunction of U#*the Arity of S,
    U*the ResultSort of S)\/ dom the Charact of T by FUNCT_4:def 1
    .= (the carrier' of S) \/ dom the Charact of T by PARTFUN1:def 2
    .= (the carrier' of S) \/ the carrier' of J by PARTFUN1:def 2
    .= the carrier' of S by A2,INSTALG1:10,XBOOLE_1:12;
    then reconsider C as ManySortedSet of the carrier' of S
    by RELAT_1:def 18,PARTFUN1:def 2;
A3: dom X = I misses the carrier of J by A1,XBOOLE_1:63,79,PARTFUN1:def 2;
    C is ManySortedFunction of U#*the Arity of S, U*the ResultSort of S
    proof
      let o be object; assume
A4:   o in the carrier' of S;
      then reconsider w = o as OperSymbol of S;
      per cases;
      suppose
A5:     o in the carrier' of J;
        then reconsider u = o as OperSymbol of J;
        o in dom the Charact of T by A5,PARTFUN1:def 2;
        then
A6:     C.o = (the Charact of T).o by FUNCT_4:13;
        the Arity of J = (the Arity of S)|the carrier' of J &
        the ResultSort of J = (the ResultSort of S)|the carrier' of J
        by A2,INSTALG1:12;
        then
A7:     (the Arity of J).o = (the Arity of S).o &
        (the ResultSort of J).o = (the ResultSort of S).o by A5,FUNCT_1:49;
A8:    (the Sorts of T)#.the_arity_of u
        = product ((the Sorts of T)*the_arity_of u) &
        U#.the_arity_of w = product (U*the_arity_of w) by FINSEQ_2:def 5;
A9:    dom the Sorts of T = the carrier of J &
        rng the_arity_of u c= the carrier of J
        by PARTFUN1:def 2;
        U*the_arity_of w
        = ((the ManySortedSet of the carrier of S)+*(the Sorts of T))*
        the_arity_of w by A3,A7,A9,XBOOLE_1:63,FUNCT_7:11
        .= (the Sorts of T)*the_arity_of u by A9,A7,AOFA_I00:3;
        then
A10:    (the Sorts of T)#.the_arity_of u = U#.the_arity_of w by A8;
A11:    rng the ResultSort of S c= the carrier of S &
        rng the ResultSort of J c= the carrier of J &
        the carrier of J = dom the Sorts of T
        by PARTFUN1:def 2;
        rng the ResultSort of J misses dom X by A3,XBOOLE_1:63;
        then
A12:    U*the ResultSort of J = ((the ManySortedSet of the carrier of S)+*
        (the Sorts of T))*the ResultSort of J by FUNCT_7:11
        .= (the Sorts of T)*the ResultSort of J by A11,AOFA_I00:3;
        ((the Sorts of T)#*the Arity of J).o
        = (the Sorts of T)#.the_arity_of u &
        (U#*the Arity of S).o = U#.the_arity_of w &
        ((the Sorts of T)*the ResultSort of S).o
        = (the Sorts of T).((the ResultSort of S).o) &
        ((the Sorts of T)*the ResultSort of J).o
        = (the Sorts of T).((the ResultSort of J).o) &
        (U*the ResultSort of S).o = U.((the ResultSort of S).o) &
        (U*the ResultSort of J).o = U.((the ResultSort of J).o)
        by A4,A5,FUNCT_2:15;
        hence thesis by A6,A7,A10,A12;
      end;
      suppose o nin the carrier' of J;
        then o nin dom the Charact of T;
        then C.o = (the ManySortedFunction of U#*the Arity of S,
        U*the ResultSort of S).o by FUNCT_4:11;
        hence thesis;
      end;
    end;
    then reconsider C as ManySortedFunction of
    U#*the Arity of S, U*the ResultSort of S;
    take Q = MSAlgebra(#U,C#);
    thus Q is T-extension
    proof
A13:  Q|J = Q|(J, id the carrier of J, id the carrier' of J) by INSTALG1:def 4;
      id the carrier of J, id the carrier' of J form_morphism_between J,S
      by A2,INSTALG1:def 2;
      then the Sorts of (Q|J) = (the Sorts of Q)*id the carrier of J &
      the Charact of (Q|J) = (the Charact of Q)*id the carrier' of J
      by A13,INSTALG1:def 3;
      then
A14:   the Sorts of (Q|J) = (the Sorts of Q)|the carrier of J &
      the Charact of (Q|J) = (the Charact of Q)|the carrier' of J
      by RELAT_1:65;
A15:   dom the Sorts of T = the carrier of J &
      dom the Charact of T = the carrier' of J by PARTFUN1:def 2;
      the Sorts of (Q|J) = ((the ManySortedSet of the carrier of S)+*
      (the Sorts of T))|the carrier of J by A3,A14,FUNCT_4:72
      .= the Sorts of T by A15;
      hence Q|J = the MSAlgebra of T by A14,A15;
    end;
    dom X = I by PARTFUN1:def 2;
    hence (the Sorts of Q)|I = X;
  end;
