reserve S for non empty non void ManySortedSign;
reserve X for non-empty ManySortedSet of S;
reserve x,y,z for set, i,j for Nat;
reserve
  A0 for (X,S)-terms non-empty MSAlgebra over S,
  A1 for all_vars_including (X,S)-terms MSAlgebra over S,
  A2 for all_vars_including inheriting_operations (X,S)-terms MSAlgebra over S,
  A for all_vars_including inheriting_operations free_in_itself
  (X,S)-terms MSAlgebra over S;
reserve X0 for non-empty countable ManySortedSet of S;
reserve A0 for all_vars_including inheriting_operations free_in_itself
  (X0,S)-terms MSAlgebra over S;

theorem Th82:
  for p,q being FinSequence holds (p^<*x*>^q)+*(len p+1,y) = p^<*y*>^q
  proof
    let p,q be FinSequence;
A1: dom (p^<*x*>^q) = Seg len(p^<*x*>^q) by FINSEQ_1:def 3
    .= Seg(len(p^<*x*>)+len q) by FINSEQ_1:22
    .= Seg(len p + len <*x*>+len q) by FINSEQ_1:22
    .= Seg(len p+1+len q) by FINSEQ_1:40;
A2: dom (p^<*y*>^q) = Seg len(p^<*y*>^q) by FINSEQ_1:def 3
    .= Seg(len(p^<*y*>)+len q) by FINSEQ_1:22
    .= Seg(len p + len <*y*>+len q) by FINSEQ_1:22
    .= Seg(len p+1+len q) by FINSEQ_1:40;
A3: dom((p^<*x*>^q)+*(len p+1,y)) = dom (p^<*x*>^q) by FUNCT_7:30;
    now let a be object;
      assume
A4:   a in dom(p^<*x*>^q);
      then reconsider i = a as Nat;
A5:   i >= 1 & i <= len(p^<*x*>^q) by A4,FINSEQ_3:25;
      per cases by XXREAL_0:1;
      suppose
A6:     i < len p+1;
        then i <= len p by NAT_1:13;
        then i in dom p & dom p c= dom(p^<*x*>) & dom p c= dom(p^<*y*>)
        by A5,FINSEQ_1:26,FINSEQ_3:25;
        then (p^<*x*>).i = p.i & (p^<*x*>^q).i = (p^<*x*>).i &
        len p+1 <> i & (p^<*y*>).i = p.i & (p^<*y*>^q).i = (p^<*y*>).i
        by A6,FINSEQ_1:def 7;
        hence (p^<*x*>^q)+*(len p+1,y).a = (p^<*y*>^q).a by FUNCT_7:32;
      end;
      suppose
A7:     i = len p+1;
        len <*x*> = 1 & len <*y*> = 1 by FINSEQ_1:40;
        then i >= 1 & len(p^<*x*>) = len p+1 & len(p^<*y*>) = len p+1
        by A7,FINSEQ_1:22,NAT_1:11;
        then i in dom (p^<*x*>) & i in dom(p^<*y*>) by A7,FINSEQ_3:25;
        then (p^<*x*>^q).i = (p^<*x*>).i & (p^<*x*>).i = x &
        (p^<*y*>^q).i = (p^<*y*>).i & (p^<*y*>).i = y by A7,FINSEQ_1:def 7,42;
        hence (p^<*x*>^q)+*(len p+1,y).a = (p^<*y*>^q).a by A4,A7,FUNCT_7:31;
      end;
      suppose
A8:     i > len p+1;
        then i >= len p+1+1 by NAT_1:13;
        then consider j being Nat such that
A9:     i = len p+1+1+j by NAT_1:10;
A10:     i = len p+1+(1+j) by A9;
        len <*x*> = 1 & len <*y*> = 1 by FINSEQ_1:40;
        then
A11:     len(p^<*x*>) = len p+1 & len(p^<*y*>) = len p+1 by FINSEQ_1:22;
        then len(p^<*x*>^q) = len p+1+len q by FINSEQ_1:22;
        then 1 <= 1+j & 1+j <= len q by A10,A4,FINSEQ_3:25,XREAL_1:6,NAT_1:11;
        then 1+j in dom q by FINSEQ_3:25;
        then (p^<*x*>^q).i = q.(1+j) & (p^<*y*>^q).i = q.(1+j)
        by A10,A11,FINSEQ_1:def 7;
        hence (p^<*x*>^q)+*(len p+1,y).a = (p^<*y*>^q).a by A8,FUNCT_7:32;
      end;
    end;
    hence (p^<*x*>^q)+*(len p+1,y) = p^<*y*>^q by A1,A2,A3;
  end;
