reserve p,P,P1,P2 for Instruction-Sequence of SCM+FSA;
reserve s, S for State of SCM+FSA,
  I, J for Program of SCM+FSA,
  Ig for good Program of SCM+FSA,
  i for good sequential Instruction of SCM+FSA,
  j for sequential Instruction of SCM+FSA,
  a, b for Int-Location,
  f for FinSeq-Location;

theorem Th5: :: Main theorem
 for Ig being good really-closed Program of SCM+FSA
 for J being really-closed Program of SCM+FSA holds
  Ig is_halting_on Initialized s,p & J is_halting_on IExec(Ig,p,s),p
implies IExec(Ig ";" J,p,s) = IExec(J,p,IExec(Ig,p,s))+*
  Start-At(IC IExec(J,p,IExec(Ig,p,s))+card Ig,SCM+FSA)
proof
 let Ig be good really-closed Program of SCM+FSA;
 let J be really-closed Program of SCM+FSA;
  set I = Ig;
  assume that
A1: I is_halting_on Initialized s,p and
A2: J is_halting_on IExec(I,p,s),p;
  set Is = Initialized s, Ip = p;
A3: (Initialized s).intloc 0 = 1 by SCMFSA_M:9;
  set s1 = Initialized s, p1 = p +* I;
A4: I c= p1 by FUNCT_4:25;
  set m1 = LifeSpan(p1,s1);
  s1 = Initialized Is;
  then
A5: s1 = Initialize Is by A3,SCMFSA_M:18;
  set s3 = Initialized Comput(p1,s1,m1), p3 = p1 +* J;
A6: J c= p3 by FUNCT_4:25;
A7: p1 halts_on s1 by A1,A5;
  then
A8: s3 = Initialized Result(p1,s1) by EXTPRO_1:23;
  set s2 = Initialized s,
      p2 = p +* (I ";" J);
A9: I ";" J c= p2 by FUNCT_4:25;
  s2 = Initialized Is;
  then
A10: s2 = Initialize Is by A3,SCMFSA_M:18;
A11: DataPart Is = DataPart s2;
A12: s2.intloc 0 = 1 by A3;
A13: DataPart IExec(I,p,s) = DataPart IExec(I,p,Is) by SCMFSA8C:3
    .= DataPart IExec(I,p2,s2) by A1,A3,A11,SCMFSA8C:20;
  s2 = Initialize s2 by MEMSTR_0:44;
  then
A14: LifeSpan(p2+*I,s2) = m1 by A1,A11,SCMFSA8C:72;
  set JAt = Start-At(0,SCM+FSA);
  Comput(p1,s1,m1).intloc 0 = 1 by A3,A5,SCMFSA8C:68;
  then
A15: s3 = Initialize Comput(p1,s1,m1) by SCMFSA_M:18;
  set m3 = LifeSpan(p3,s3);
  I ";" J is_halting_on Is,Ip by A1,A2,Th2;
  then
A16: p2 halts_on s2 by A10;
A17: IExec(I ";" J,p,s) = Result(p+*(I ";" J),Initialized s) by SCMFSA6B:def 1
    .= Comput(p2,s2,LifeSpan(p2,s2)) by A16,EXTPRO_1:23
    .= Comput(p2,s2,m1+1+m3) by A1,A2,A8,Th4;
A18: DataPart IExec(I,p,s) = DataPart Result(p+*I,Initialized s)
           by SCMFSA6B:def 1
    .= DataPart(Result(p+*I,s+*Initialize((intloc 0).-->1)))
    .= DataPart Comput(p1,s1,LifeSpan(p1,s1)) by A7,EXTPRO_1:23;
  then
   J is_halting_on Comput(p1,s1,LifeSpan(p1,s1)),p1 by A2,SCMFSA8B:5;
  then
A19: p3 halts_on s3 by A15;
  set IEJIs = IExec(J,p,IExec(I,p,s));
  set IAt = Start-At(0,SCM+FSA);
A20: Initialize((intloc 0).-->1) c= s2 by FUNCT_4:25;
  IExec(I,p,s).intloc 0 = 1 by A1,SCMFSA8C:67;
  then
A21: Initialized IExec(I,p,s) = Initialize IExec(I,p,s) by SCMFSA_M:18;
  then  Result(p1+*J,Result(p1, s1) +*
   Initialize((intloc 0).-->1)) =  Result(p+*J,IExec(I,p,s) +*
  Initialize((intloc 0).-->1)) by A2,A15,A18,A8,SCMFSA8C:72;
  then
A22: IC Result(p1+*J,Initialized Result(p1, s1))
    = IC Result(p+*J,Initialized IExec(I,p,s));
A23: Result(p+*J,Initialized IExec(I,p,s)) = Result(p3,s3)
       by A2,A15,A18,A21,SCMFSA8C:72;
A24: IEJIs = Result(p+*J,Initialized IExec(I,p,s)) by SCMFSA6B:def 1
    .= Comput(p3,s3,m3) by A19,A23,EXTPRO_1:23;
A25: I is_halting_on s2,p2 by A1,A11,SCMFSA8B:5;
  reconsider l = IC IEJIs + card I as Element of NAT;
  reconsider s2t = s +* ((intloc 0) .--> 1) as State of SCM+FSA;
A27: I +* (I ";" J) = I ";" J by SCMFSA6A:18;
A28: p2 +* I +* (I ";" J) = p2 +* (I +* (I ";" J)) by FUNCT_4:14;
A29: I c= p2 +* I by FUNCT_4:25;
A30: p1+*(I ";" J) = p2 by A27,FUNCT_4:14;
A31:  Comput(p1,s1,m1) =  Comput(p2, s2,m1) by A7,Th3,A4,A30;
  s2 = Initialize s2 by MEMSTR_0:44;
  then p2+*I halts_on s2 by A25;
  then  Comput(p2+*I, s2,m1) =  Comput(p2+*I+*(I ";" J),s2,m1)
     by A14,Th3,A29;
  then DataPart Comput(p2+*I, s2,m1)
     = DataPart Comput(p2+*I+*(I ";" J),s2,m1)
    .= DataPart Comput(p2+*I+*(I ";" J), s2,m1)
    .= DataPart Comput(p2+*(I ";" J), s2,m1) by A27,A28
    .= DataPart Comput(p2, s2,m1)
    .= DataPart Comput(p1,s1,m1)
           by A31;
  then
A32: DataPart(Comput(p2+*I, s2,m1) +* Initialize((intloc 0).-->1)) =
DataPart
  Comput(p1,s1,m1) +* DataPart (Initialize((intloc 0).-->1)) by FUNCT_4:71
    .= DataPart (Comput(p1,s1,m1) +* Initialize((intloc 0).-->1))
     by FUNCT_4:71;
A33: J is_halting_on IExec(I,p2,s2),p2 by A2,A13,SCMFSA8B:5;
  then
A34: DataPart Comput(p2,s2,m1+1) = DataPart Initialized Comput(p2+*I, s2,m1)
     by A20,A25,A14,A12,Lm1,A9;
   Reloc(J, card I) c= I ";" J by SCMFSA6A:38;
   then
A35: Reloc(J, card I) c= p2 by A9,XBOOLE_1:1;
A36: IC Comput(p2,s2,m1+1) =  card I by A20,A25,A14,A12,A33,Lm1,A9;
  then
A37: DataPart Comput(p2, Comput(p2,s2,m1+1),m3)
   = DataPart Comput(p3,s3, m3) by A32,A34,A6,A35,SCMFSA8C:16;
A38: DataPart IExec(I ";" J,p,s) = DataPart Comput(p2,s2,m1+1+m3)
by A17
    .= DataPart Comput(p3,s3,m3) by A37,EXTPRO_1:4
    .= DataPart IEJIs by A24;
A39: IC Comput(p2, Comput(p2,s2,m1+1),m3) = IC Comput(p3,s3,m3) + card
  I by A32,A36,A34,A6,A35,SCMFSA8C:16;
A40: s3 = Initialized Result(p1, s1) by A7,EXTPRO_1:23;
A41: IC IExec(I ";" J,p,s)
 = IC Result(p+*(I ";" J),Initialized s) by SCMFSA6B:def 1
    .= IC Comput(p2,s2,LifeSpan(p2,s2)) by A16,EXTPRO_1:23
    .= IC Comput(p2,s2,m1+1+m3) by A1,A2,A8,Th4
    .= IC Comput(p3,s3,m3) + card I by A39,EXTPRO_1:4
    .= IC Result(p3,s3) + card I by A19,EXTPRO_1:23
    .= IC IEJIs + card I by A22,A40,SCMFSA6B:def 1;
A42: now
    let x be object;
    assume
A43: x in dom IExec(I ";" J,p,s);
    per cases by A43,SCMFSA_M:1;
    suppose
A44:  x is Int-Location;
      then x <> IC SCM+FSA by SCMFSA_2:56;
      then
A45:  not x in dom Start-At(l,SCM+FSA) by TARSKI:def 1;
      IExec(I ";" J,p,s).x = IEJIs.x by A38,A44,SCMFSA_M:2;
      hence IExec(I ";" J,p,s).x =
       (IEJIs +* Start-At (IC IEJIs + card I,SCM+FSA)).x by A45,FUNCT_4:11;
    end;
    suppose
A46:  x is FinSeq-Location;
      then x <> IC SCM+FSA by SCMFSA_2:57;
      then
A47:  not x in dom Start-At(l,SCM+FSA) by TARSKI:def 1;
      IExec(I ";" J,p,s).x = IEJIs.x by A38,A46,SCMFSA_M:2;
      hence IExec(I ";" J,p,s).x =
       (IEJIs +* Start-At (IC IEJIs + card I,SCM+FSA)).x by A47,FUNCT_4:11;
    end;
    suppose
A48:  x = IC SCM+FSA;
      then x in {IC SCM+FSA} by TARSKI:def 1;
      then
A49:  x in dom Start-At(l,SCM+FSA);
      thus IExec(I ";" J,p,s).x = (Start-At(l,SCM+FSA)).IC SCM+FSA
      by A41,A48,FUNCOP_1:72
        .= (IEJIs +* Start-At (IC IEJIs + card I,SCM+FSA)).x
        by A48,A49,FUNCT_4:13;
    end;
  end;
  dom IExec(I ";" J,p,s) = the carrier of SCM+FSA by PARTFUN1:def 2
    .= dom (IEJIs +* Start-At (IC IEJIs + card I,SCM+FSA)) by PARTFUN1:def 2;
  hence thesis by A42,FUNCT_1:2;
end;
