reserve I,X,x,d,i for set;
reserve M for ManySortedSet of I;
reserve EqR1,EqR2 for Equivalence_Relation of X;
reserve I for non empty set;
reserve M for ManySortedSet of I;
reserve EqR,EqR1,EqR2,EqR3,EqR4 for Equivalence_Relation of M;
reserve S for non void non empty ManySortedSign;
reserve A for non-empty MSAlgebra over S;

theorem Th12:
  for o be OperSymbol of S for C1,C2 being MSCongruence of A for
x1,y1 be set for a1,b1 be FinSequence holds [x1,y1] in C1.((the_arity_of o)/.(
len a1 + 1)) \/ C2.((the_arity_of o)/.(len a1 + 1)) implies for x,y be Element
of Args(o,A) st x = (a1 ^ <*x1*> ^ b1) & y = (a1 ^ <*y1*> ^ b1) holds [Den(o,A)
  .x,Den(o,A).y] in C1.(the_result_sort_of o) \/ C2.(the_result_sort_of o)
proof
  let o be OperSymbol of S;
  let C1,C2 be MSCongruence of A;
  let x1,y1 be set;
  let a1,b1 be FinSequence;
  assume
A1: [x1,y1] in C1.((the_arity_of o)/.(len a1 + 1)) \/ C2.((the_arity_of
  o)/.(len a1 + 1));
  let x,y be Element of Args(o,A);
  assume that
A2: x = (a1 ^ <*x1*> ^ b1) and
A3: y = (a1 ^ <*y1*> ^ b1);
A4: y = a1 ^ (<*y1*> ^ b1) by A3,FINSEQ_1:32;
A5: x = a1 ^ (<*x1*> ^ b1) by A2,FINSEQ_1:32;
  now
    per cases by A1,XBOOLE_0:def 3;
    suppose
A6:   [x1,y1] in C1.((the_arity_of o)/.(len a1 + 1));
      for n be Nat st n in dom x holds [x.n,y.n] in C1.((the_arity_of o)/. n)
      proof
        let n be Nat;
        assume
A7:     n in dom x;
        then reconsider dz = dom (the_arity_of o) as non empty set by
MSUALG_3:6;
A8:     n in dom (the_arity_of o) by A7,MSUALG_3:6;
        then
A9:     n in dom ((the Sorts of A) * (the_arity_of o)) by PARTFUN1:def 2;
        reconsider so = (the Sorts of A) * (the_arity_of o) as non-empty
        ManySortedSet of dz;
A10:    product so is non empty;
        pi(Args(o,A),n) = pi(((the Sorts of A)# * the Arity of S).o,n) by
MSUALG_1:def 4
          .= pi((the Sorts of A)# . ((the Arity of S).o),n) by FUNCT_2:15
          .= pi((the Sorts of A)# . (the_arity_of o),n) by MSUALG_1:def 1
          .= pi(product((the Sorts of A) * (the_arity_of o)),n) by
FINSEQ_2:def 5
          .= ((the Sorts of A) * (the_arity_of o)).n by A9,A10,CARD_3:12
          .= (the Sorts of A) . ((the_arity_of o).n) by A8,FUNCT_1:13
          .= (the Sorts of A) . ((the_arity_of o)/.n) by A8,PARTFUN1:def 6;
        then
A11:    x.n in (the Sorts of A).((the_arity_of o)/.n) by CARD_3:def 6;
A12:    n in dom (a1 ^ <*x1*>) or ex k be Nat st k in dom b1 & n = len (
        a1 ^ <*x1*>) + k by A2,A7,FINSEQ_1:25;
        now
          per cases by A12,FINSEQ_1:25;
          suppose
A13:        n in dom a1;
            then
A14:        y.n = a1.n by A4,FINSEQ_1:def 7;
            x.n = a1.n by A5,A13,FINSEQ_1:def 7;
            hence thesis by A11,A14,EQREL_1:5;
          end;
          suppose
            ex m be Nat st m in dom <*x1*> & n = len a1 + m;
            then consider m be Nat such that
A15:        m in dom <*x1*> and
A16:        n = len a1 + m;
A17:        m in Seg 1 by A15,FINSEQ_1:38;
            then
A18:        m = 1 by FINSEQ_1:2,TARSKI:def 1;
            then
A19:        n in Seg (len a1 + 1) by A16,FINSEQ_1:4;
            then n in Seg (len a1 + len <*y1*>) by FINSEQ_1:40;
            then n in Seg len (a1 ^ <*y1*>) by FINSEQ_1:22;
            then n in dom (a1 ^ <*y1*>) by FINSEQ_1:def 3;
            then
A20:        y.n = (a1 ^ <*y1*>).(len a1 + 1) by A3,A16,A18,FINSEQ_1:def 7
              .= y1 by FINSEQ_1:42;
            n in Seg (len a1 + len <*x1*>) by A19,FINSEQ_1:40;
            then n in Seg len (a1 ^ <*x1*>) by FINSEQ_1:22;
            then n in dom (a1 ^ <*x1*>) by FINSEQ_1:def 3;
            then x.n = (a1 ^ <*x1*>).(len a1 + 1) by A2,A16,A18,FINSEQ_1:def 7
              .= x1 by FINSEQ_1:42;
            hence thesis by A6,A16,A17,A20,FINSEQ_1:2,TARSKI:def 1;
          end;
          suppose
            ex k be Element of NAT st k in dom b1 & n = len (a1 ^ <* x1*>) + k;
            then consider k be Element of NAT such that
A21:        k in dom b1 and
A22:        n = len (a1 ^ <*x1*>) + k;
            n = len a1 + len <*x1*> + k by A22,FINSEQ_1:22;
            then n = len a1 + 1 + k by FINSEQ_1:40;
            then n = len a1 + len <*y1*> + k by FINSEQ_1:40;
            then n = len (a1 ^ <*y1*>) + k by FINSEQ_1:22;
            then
A23:        y.n = b1.k by A3,A21,FINSEQ_1:def 7;
            x.n = b1.k by A2,A21,A22,FINSEQ_1:def 7;
            hence thesis by A11,A23,EQREL_1:5;
          end;
        end;
        hence thesis;
      end;
      then [Den(o,A).x,Den(o,A).y] in C1.(the_result_sort_of o) by
MSUALG_4:def 4;
      hence thesis by XBOOLE_0:def 3;
    end;
    suppose
A24:  [x1,y1] in C2.((the_arity_of o)/.(len a1 + 1));
      for n be Nat st n in dom x holds [x.n,y.n] in C2.((the_arity_of o) /.n)
      proof
        let n be Nat;
        assume
A25:    n in dom x;
        then reconsider dz = dom (the_arity_of o) as non empty set by
MSUALG_3:6;
A26:    n in dom (the_arity_of o) by A25,MSUALG_3:6;
        then
A27:    n in dom ((the Sorts of A) * (the_arity_of o)) by PARTFUN1:def 2;
        reconsider so = (the Sorts of A) * (the_arity_of o) as non-empty
        ManySortedSet of dz;
A28:    product so is non empty;
        pi(Args(o,A),n) = pi(((the Sorts of A)# * the Arity of S).o,n) by
MSUALG_1:def 4
          .= pi((the Sorts of A)# . ((the Arity of S).o),n) by FUNCT_2:15
          .= pi((the Sorts of A)# . (the_arity_of o),n) by MSUALG_1:def 1
          .= pi(product((the Sorts of A) * (the_arity_of o)),n) by
FINSEQ_2:def 5
          .= ((the Sorts of A) * (the_arity_of o)).n by A27,A28,CARD_3:12
          .= (the Sorts of A) . ((the_arity_of o).n) by A26,FUNCT_1:13
          .= (the Sorts of A) . ((the_arity_of o)/.n) by A26,PARTFUN1:def 6;
        then
A29:    x.n in (the Sorts of A).((the_arity_of o)/.n) by CARD_3:def 6;
A30:    n in dom (a1 ^ <*x1*>) or ex k be Nat st k in dom b1 & n = len (
        a1 ^ <*x1*>) + k by A2,A25,FINSEQ_1:25;
        now
          per cases by A30,FINSEQ_1:25;
          suppose
A31:        n in dom a1;
            then
A32:        y.n = a1.n by A4,FINSEQ_1:def 7;
            x.n = a1.n by A5,A31,FINSEQ_1:def 7;
            hence thesis by A29,A32,EQREL_1:5;
          end;
          suppose
            ex m be Nat st m in dom <*x1*> & n = len a1 + m;
            then consider m be Nat such that
A33:        m in dom <*x1*> and
A34:        n = len a1 + m;
A35:        m in Seg 1 by A33,FINSEQ_1:38;
            then
A36:        m = 1 by FINSEQ_1:2,TARSKI:def 1;
            then
A37:        n in Seg (len a1 + 1) by A34,FINSEQ_1:4;
            then n in Seg (len a1 + len <*y1*>) by FINSEQ_1:40;
            then n in Seg len (a1 ^ <*y1*>) by FINSEQ_1:22;
            then n in dom (a1 ^ <*y1*>) by FINSEQ_1:def 3;
            then
A38:        y.n = (a1 ^ <*y1*>).(len a1 + 1) by A3,A34,A36,FINSEQ_1:def 7
              .= y1 by FINSEQ_1:42;
            n in Seg (len a1 + len <*x1*>) by A37,FINSEQ_1:40;
            then n in Seg len (a1 ^ <*x1*>) by FINSEQ_1:22;
            then n in dom (a1 ^ <*x1*>) by FINSEQ_1:def 3;
            then x.n = (a1 ^ <*x1*>).(len a1 + 1) by A2,A34,A36,FINSEQ_1:def 7
              .= x1 by FINSEQ_1:42;
            hence thesis by A24,A34,A35,A38,FINSEQ_1:2,TARSKI:def 1;
          end;
          suppose
            ex k be Element of NAT st k in dom b1 & n = len (a1 ^ <* x1*>) + k;
            then consider k be Element of NAT such that
A39:        k in dom b1 and
A40:        n = len (a1 ^ <*x1*>) + k;
            n = len a1 + len <*x1*> + k by A40,FINSEQ_1:22;
            then n = len a1 + 1 + k by FINSEQ_1:40;
            then n = len a1 + len <*y1*> + k by FINSEQ_1:40;
            then n = len (a1 ^ <*y1*>) + k by FINSEQ_1:22;
            then
A41:        y.n = b1.k by A3,A39,FINSEQ_1:def 7;
            x.n = b1.k by A2,A39,A40,FINSEQ_1:def 7;
            hence thesis by A29,A41,EQREL_1:5;
          end;
        end;
        hence thesis;
      end;
      then [Den(o,A).x,Den(o,A).y] in C2.(the_result_sort_of o) by
MSUALG_4:def 4;
      hence thesis by XBOOLE_0:def 3;
    end;
  end;
  hence thesis;
end;
