reserve i, I for set,
  f, g, h for Function,
  s for ManySortedSet of I;

theorem
  for F being multMagma-Family of I, G being non empty multMagma st
  i in I & G = F.i & product F is associative holds G is associative
proof
  let F be multMagma-Family of I, G be non empty multMagma such that
A1: i in I and
A2: G = F.i and
A3: for x, y, z being Element of product F holds (x*y)*z = x*(y*z);
  let x, y, z be Element of G;
  defpred Y[object,object] means
($1 = i implies $2 = y) & ($1 <> i implies ex H
  being non empty multMagma, a being Element of H st H = F.$1 & $2 = a);
A4: for j being object st j in I ex k being object st Y[j,k]
  proof
    let j be object such that
A5: j in I;
    per cases;
    suppose
      j = i;
      hence thesis;
    end;
    suppose
A6:   j <> i;
      j in dom F by A5,PARTFUN1:def 2;
      then F.j in rng F by FUNCT_1:def 3;
      then reconsider Fj = F.j as non empty multMagma by Def1;
      set a = the Element of Fj;
      take a;
      thus j = i implies a = y by A6;
      thus thesis;
    end;
  end;
  consider gy being ManySortedSet of I such that
A7: for j being object st j in I holds Y[j,gy.j] from PBOOLE:sch 3(A4);
A8: dom gy = I by PARTFUN1:def 2;
A9: now
    let j be object;
    assume
A10: j in dom gy;
    then
A11: ex R being 1-sorted st R = F.j & (Carrier F).j = the carrier of R
    by PRALG_1:def 15;
    per cases;
    suppose
A12:  i = j;
      then gy.j = y by A7,A10;
      hence gy.j in (Carrier F).j by A2,A11,A12;
    end;
    suppose
      j <> i;
      then ex H being non empty multMagma, a being Element of H st H = F.j &
      gy.j = a by A7,A10;
      hence gy.j in (Carrier F).j by A11;
    end;
  end;
  defpred Z[object,object] means
($1 = i implies $2 = z) & ($1 <> i implies ex H
  being non empty multMagma, a being Element of H st H = F.$1 & $2 = a);
A13: for j being object st j in I ex k being object st Z[j,k]
  proof
    let j be object such that
A14: j in I;
    per cases;
    suppose
      j = i;
      hence thesis;
    end;
    suppose
A15:  j <> i;
      j in dom F by A14,PARTFUN1:def 2;
      then F.j in rng F by FUNCT_1:def 3;
      then reconsider Fj = F.j as non empty multMagma by Def1;
      set a = the Element of Fj;
      take a;
      thus j = i implies a = z by A15;
      thus thesis;
    end;
  end;
  consider gz being ManySortedSet of I such that
A16: for j being object st j in I holds Z[j,gz.j] from PBOOLE:sch 3(A13);
  set GP = product F;
  defpred X[object,object] means
($1 = i implies $2 = x) & ($1 <> i implies ex H
  being non empty multMagma, a being Element of H st H = F.$1 & $2 = a);
A17: for j being object st j in I ex k being object st X[j,k]
  proof
    let j be object such that
A18: j in I;
    per cases;
    suppose
      j = i;
      hence thesis;
    end;
    suppose
A19:  j <> i;
      j in dom F by A18,PARTFUN1:def 2;
      then F.j in rng F by FUNCT_1:def 3;
      then reconsider Fj = F.j as non empty multMagma by Def1;
      set a = the Element of Fj;
      take a;
      thus j = i implies a = x by A19;
      thus thesis;
    end;
  end;
  consider gx being ManySortedSet of I such that
A20: for j being object st j in I holds X[j,gx.j] from PBOOLE:sch 3(A17);
A21: dom gx = I by PARTFUN1:def 2;
A22: now
    let j be object;
    assume
A23: j in dom gx;
    then
A24: ex R being 1-sorted st R = F.j & (Carrier F).j = the carrier of R
    by PRALG_1:def 15;
    per cases;
    suppose
A25:  i = j;
      then gx.j = x by A20,A23;
      hence gx.j in (Carrier F).j by A2,A24,A25;
    end;
    suppose
      j <> i;
      then ex H being non empty multMagma, a being Element of H st H = F.j &
      gx.j = a by A20,A23;
      hence gx.j in (Carrier F).j by A24;
    end;
  end;
A26: dom gz = I by PARTFUN1:def 2;
A27: now
    let j be object;
    assume
A28: j in dom gz;
    then
A29: ex R being 1-sorted st R = F.j & (Carrier F).j = the carrier of R
    by PRALG_1:def 15;
    per cases;
    suppose
A30:  i = j;
      then gz.j = z by A16,A28;
      hence gz.j in (Carrier F).j by A2,A29,A30;
    end;
    suppose
      j <> i;
      then ex H being non empty multMagma, a being Element of H st H = F.j &
      gz.j = a by A16,A28;
      hence gz.j in (Carrier F).j by A29;
    end;
  end;
A31: dom Carrier F = I by PARTFUN1:def 2;
  then reconsider gx as Element of product Carrier F by A21,A22,CARD_3:9;
  reconsider gz as Element of product Carrier F by A26,A31,A27,CARD_3:9;
  reconsider gy as Element of product Carrier F by A8,A31,A9,CARD_3:9;
  reconsider x1 = gx, y1 = gy, z1 = gz as Element of GP by Def2;
  reconsider xy = x1*y1, xyz3 = x1*y1*z1, yz = y1*z1, xyz5 = x1*(y1*z1) as
  Element of product Carrier F by Def2;
  reconsider xyi = xy.i, yzi = yz.i as Element of G by A1,A2,Lm1;
A32: x1 * y1 * z1 = x1 * (y1 * z1) by A3;
A33: gx.i = x by A1,A20;
  then
A34: x * yzi = xyz5.i by A1,A2,Th1;
A35: gz.i = z by A1,A16;
  then
A36: xyi * z = xyz3.i by A1,A2,Th1;
A37: gy.i = y by A1,A7;
  then xy.i = x * y by A1,A2,A33,Th1;
  hence thesis by A1,A2,A32,A37,A35,A36,A34,Th1;
end;
