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;

theorem Th52:
  for F,g,x holds
    doms (F^<* g^<*x*> *>) = doms (F^<* g *>) \/
      {f^<*1 + len g*> where f is Element of doms F:f in doms F}
proof
  let F,g,x;
  set S={f^<*1 + len g*> where f is Element of doms F:f in doms F};
  set gx= g^<*x*>;
A1: len (F^<* gx *>) = 1 + len F & len (F^<* g *>)= 1+len F by FINSEQ_2:16;
  thus doms (F^<* gx *>) c= doms (F^<* g *>)\/S
  proof
    let y;
    assume y in doms (F^<* gx *>);
    then consider p be FinSequence such that
A2:   p=y & len p = len (F^<* gx *>) and
A3:   for i st i in dom p holds p.i in dom ((F^<* gx *>).i) by Def8;
    per cases;
    suppose
A4:     p.(1+len F) in dom g;
      for i st i in dom p holds p.i in dom ((F^<* g *>).i)
      proof
        let i such that
A5:       i in dom p;
        per cases;
        suppose i = 1+len F;
          hence thesis by A4;
        end;
        suppose
A6:         i<> 1+len F;
A7:         1<=i <=len p by A5,FINSEQ_3:25;
          then i < len F+1 by A6,A2,A1,XXREAL_0:1;
          then i <= len F by NAT_1:13;
          then i in dom F by A7,FINSEQ_3:25;
          then (F^<* gx *>).i = F.i & (F^<* g *>).i = F.i by FINSEQ_1:def 7;
          hence thesis by A5,A3;
        end;
      end;
      then p in doms (F^<* g *>) by A2,A1,Th47;
      hence thesis by A2,XBOOLE_0:def 3;
    end;
    suppose
A8:     not p.(1+len F) in dom g;
      1<= 1+len F by NAT_1:11;
      then p.(1+len F) in dom ((F^<* gx *>).(1+len F)) by A3,A2,A1,FINSEQ_3:25;
      then consider n such that
A9:     n in dom <*x*> & p.(1+len F) = len g + n by A8,FINSEQ_1:25;
      set pL=p|len F;
      n in Seg 1 by A9,FINSEQ_1:38;
      then n=1 by FINSEQ_1:2,TARSKI:def 1;
      then
A10:    p = pL^ <* 1 + len g *> by A9,FINSEQ_3:55,A2,FINSEQ_2:16;
A11:    len pL = len F by A2,A1,FINSEQ_3:53;
      for i st i in dom pL holds pL.i in dom (F.i)
      proof
        let i such that
A12:      i in dom pL;
        dom F = Seg (len F) by FINSEQ_1:def 3;
        then
A13:      i in dom p & i in dom F by A12,RELAT_1:57;
        then p.i in dom ((F^<* gx *>).i) by A3;
        then p.i in dom (F.i) by A13,FINSEQ_1:def 7;
        hence thesis by A12,FUNCT_1:47;
      end;
      then pL in doms F by A11,Th47;
      then p in S by A10;
      hence thesis by A2,XBOOLE_0:def 3;
    end;
  end;
  let y such that
A14: y in doms (F^<* g *>)\/S;
  set L= 1 + len g;
  per cases;
  suppose y in S;
    then consider f be Element of doms F such that
A15:  y = f^<*L*> & f in doms F;
A16: len f = len F & len (f^<*L*>) = len f +1 & len gx= L
      by A15,Th47,FINSEQ_2:16;
    then
A17:  dom f=dom F by FINSEQ_3:30;
    for i st i in dom (f^<*L*>) holds (f^<*L*>).i in dom ((F^<* gx *>).i)
    proof
      let i such that
A18:    i in dom (f^<*L*>);
      per cases by A18,FINSEQ_1:25;
      suppose i in dom f;
        then f.i in dom (F.i) & (f^<*L*>).i = f.i & (F^<* gx *>).i = F.i
          by A17,A15,Th47,FINSEQ_1:def 7;
        hence thesis;
      end;
      suppose ex n st n in dom <*L*> & i=len f + n;
        then consider n such that
A19:      n in dom <*L*> & i=len f + n;
A20:      1 <= L by NAT_1:11;
        n in Seg 1 by A19,FINSEQ_1:def 8;
        then n=1 by TARSKI:def 1, FINSEQ_1:2;
        hence thesis by A19,A16,FINSEQ_3:25,A20;
      end;
    end;
    hence thesis by A15,A16,A1,Th47;
  end;
  suppose not y in S;
    then y in doms (F^<* g *>) by A14,XBOOLE_0:def 3;
    then consider p be FinSequence such that
A21:  p=y & len p = len (F^<* g*>) and
A22:  for i st i in dom p holds p.i in dom ((F^<* g*>).i) by Def8;
A23: dom p = dom (F^<* g*>) by A21,FINSEQ_3:30;
    for i st i in dom p holds p.i in dom ((F^<* gx*>).i)
    proof
      let i such that
A24:    i in dom p;
      per cases;
      suppose i in dom F;
        then (F^<* g*>).i = F.i = (F^<* gx*>).i by FINSEQ_1:def 7;
        hence thesis by A24,A22;
      end;
      suppose not i in dom F;
        then consider n such that
A25:      n in dom <*g*> & i = len F+n by A24,A23,FINSEQ_1:25;
        n in Seg 1 by A25,FINSEQ_1:38;
        then
A26:      n=1 by FINSEQ_1:2,TARSKI:def 1;
        then (F^<* g*>).i = g by A25;
        then p.i in dom g by A24,A22;
        hence thesis by A26,A25,FINSEQ_1:26,TARSKI:def 3;
      end;
    end;
    hence y in doms (F^<* gx *>) by A1,Th47,A21;
  end;
end;
