reserve i,j,n,k,m for Nat,
     a,b,x,y,z for object,
     F,G for FinSequence-yielding FinSequence,
     f,g,p,q for FinSequence,
     X,Y for set,
     D for non empty set;
reserve
  B,A,M for BinOp of D,
  F,G for D* -valued FinSequence,
  f for FinSequence of D,
  d,d1,d2 for Element of D;
reserve
  F,G for non-empty non empty FinSequence of D*,
  f for non empty FinSequence of D;

theorem Th67:
  M is commutative associative & A is commutative associative &
    M is_left_distributive_wrt A
  implies
   for fM be Function of dom f,D st
     for x st x in dom f holds
         fM.x = M.( M$$ ([#]dom F, A "**" F), f.x) holds
   M $$ ([#]dom (F^<*f*>), A "**" (F^<*f*>))= A $$ ([#]dom f,fM)
proof
  assume
A1: M is commutative associative & A is commutative associative &
    M is_left_distributive_wrt A;
  defpred P[Nat] means for f st len f=$1
    for fM be Function of dom f,D st
      for x st x in dom f holds fM.x = M.( M$$ ([#]dom F, A "**" F), f.x)
      holds
        M $$ ([#]dom (F^<*f*>), A "**" (F^<*f*>))= A $$ ([#]dom f,fM);
A2: P[0];
A3: P[n] implies P[n+1]
  proof
    assume
A4:   P[n];
    set n1=n+1;
    let f such that
A5:   len f=n1;
    let fM be Function of dom f,D such that
A6:   for x st x in dom f holds fM.x = M.( M$$ ([#]dom F, A "**" F), f.x);
A7:   1<=n1 by NAT_1:11;
    then n1 in dom f by A5,FINSEQ_3:25;
    then f.n1 in rng f c= D by FUNCT_1:def 3;
    then reconsider fn1=f.n1 as Element of D;
    reconsider N1=n1 as Element of dom f by A7,A5,FINSEQ_3:25;
    dom <*f*> = Seg 1 & 1 in {1} by FINSEQ_1:38,TARSKI:def 1;
    then reconsider O=1 as Element of dom <*f*> by FINSEQ_1:2;
A8:   M $$ ([#]dom <*f*>, A "**" <*f*>) = A "**" f by A1,Th66;
    per cases by NAT_1:14;
    suppose
A9:     n=0;
      then f= <*f.n1*> by A5,FINSEQ_1:40;
      then
A10:    A"**"f = fn1 by FINSOP_1:11;
      dom f = {n1} by A9,A5,FINSEQ_1:2,def 3;
      hence A $$ ([#]dom f,fM) = fM.N1 by A1,SETWISEO:17
        .= M.( M$$ ([#]dom F, A "**" F), A"**"f) by A10,A6
        .= M $$ ([#]dom (F^<*f*>), A "**" (F^<*f*>)) by A8,A1,Th65;
    end;
    suppose
A11:    n>=1;
A12:    n < n1 by NAT_1:13;
      then
A13:    len (f|n) =n by FINSEQ_1:59,A5;
      reconsider fn=f|n as non empty FinSequence of D by A11;
A14:    f = fn^<*fn1*> by A5,FINSEQ_3:55;
      set fM1 = fM|(dom fn);
A15:    dom fn c= dom f by A14,FINSEQ_1:26;
      then reconsider dfn=dom fn as Element of Fin dom f by FINSUB_1:def 5;
      dom fM = dom f by FUNCT_2:def 1;
      then
A16:    dom fM1 = dom fn by A14,FINSEQ_1:26,RELAT_1:62;
      rng fM1 c= D;
      then reconsider fM1 as Function of dom fn,D by A16,FUNCT_2:2;
A17:    fM1|(dom fn) = fM1;
      for x st x in dom fn holds
        fM1.x = M.( M$$ ([#]dom F, A "**" F), fn.x)
      proof
        let x such that
A18:      x in dom fn;
        x in dom f & fM.x = fM1.x & fn.x=f.x by A15,A18,FUNCT_1:47,49;
        hence thesis by A6;
      end;
      then M $$ ([#]dom (F^<*fn*>), A "**" (F^<*fn*>))= A $$ ([#]dom fn,fM1)
          by A4,A13
        .= A $$ (dfn,fM) by A17,A1,Th1;
      then
A19:    A $$ (dfn,fM)
          = M.(M $$ ([#]dom F, A "**" F), M $$ ([#]dom <*fn*>, A "**" <*fn*>))
            by A1,Th65
         .= M.(M $$ ([#]dom F, A "**" F),A "**" fn) by A1,Th66;
      A20: not N1 in dom fn by A12,A13,FINSEQ_3:25;
      A21: dom f = Seg n1 by A5,FINSEQ_1:def 3
        .= Seg n \/{N1} by FINSEQ_1:9
        .= dfn \/{N1} by A13,FINSEQ_1:def 3;
      A"**"f = A.(A"**"fn,fn1) by A14, FINSOP_1:4,A11,A13;
      hence M $$ ([#]dom (F^<*f*>), A "**" (F^<*f*>))
         = M.(M $$ ([#]dom F, A "**" F), A.(A"**"fn,fn1)) by A8,A1,Th65
        .= A.(M.(M $$ ([#]dom F, A "**" F), A"**"fn),
              M.(M $$ ([#]dom F, A "**" F), fn1)) by BINOP_1:def 9,A1
        .= A.(A $$ (dfn,fM),fM.N1) by A19,A6
        .= A $$ ([#]dom f,fM) by A21,A1,A20,SETWOP_2:2;
    end;
  end;
  P[n] from NAT_1:sch 2(A2,A3);
  then P[len f];
  hence thesis;
end;
