reserve s for State of SCM+FSA,
  a, c for read-write Int-Location,
  aa, bb, cc,
  dd, x for Int-Location,
  f for FinSeq-Location,
  I, J for MacroInstruction of SCM+FSA,
  Ig for good MacroInstruction of SCM+FSA,
  i, k for Nat,
  p for Instruction-Sequence of SCM+FSA;
reserve I for MacroInstruction of SCM+FSA;

theorem Th22:
 for I being really-closed MacroInstruction of SCM+FSA holds
  s.intloc 0 = 1 & s.bb > s.cc implies (for x st x <> a & x in {bb
  , cc} \/ UsedILoc I holds IExec(for-up(a, bb, cc, I),p,s).x = s.x) &
  for f
  holds IExec(for-up(a, bb, cc, I),p,s).f = s.f
proof let I be really-closed MacroInstruction of SCM+FSA;
  assume that
A1: s.intloc 0 = 1 and
A2: s.bb > s.cc;
  cc = intloc 0 or cc is read-write by SCMFSA_M:def 2;
  then
A3: (Initialized s).cc = s.cc by A1,SCMFSA_M:9,37;
  set MI = for-up(a, bb, cc, I);
  set i3 = a := bb;
  set aux = 1-stRWNotIn ({a, bb, cc} \/ UsedILoc I);
  set i0 = aux := cc;
  set i1 = SubFrom(aux, bb);
  set i2 = AddTo(aux, intloc 0);
  set IB = I ";" AddTo(a, intloc 0) ";" SubFrom(aux, intloc 0);
  set I4 = while>0( aux, IB);
  set I03 = i0 ";" i1 ";" i2 ";" i3;
  set s1 = IExec(I03,p,s),
      p1 = p;
  set s2 = s+*(aux, s.cc-s.bb+1)+*(a, s.bb);
A4: IExec(i0 ";" i1,p,s).intloc 0 = Exec(i1, Exec(i0, Initialized s)).intloc 0
  by SCMFSA6C:8
    .= Exec(i0, Initialized s).intloc 0 by SCMFSA_2:65
    .= (Initialized s).intloc 0 by SCMFSA_2:63
    .= 1 by SCMFSA_M:9;
  bb = intloc 0 or bb is read-write by SCMFSA_M:def 2;
  then
A5: (Initialized s).bb = s.bb by A1,SCMFSA_M:9,37;
A6: s1.intloc 0 = Exec(i3, IExec(i0 ";" i1 ";" i2,p,s)).intloc 0 by SCMFSA6C:6
    .= IExec(i0 ";" i1 ";" i2,p,s).intloc 0 by SCMFSA_2:63
    .= Exec(i2, IExec(i0 ";" i1,p,s)).intloc 0 by SCMFSA6C:6
    .= 1 by A4,SCMFSA_2:64;
  s.bb -s.bb > s.cc-s.bb by A2,XREAL_1:9;
  then s.cc-s.bb <= -1 by INT_1:8;
  then
A7: s.cc-s.bb+1 <= -1+1 by XREAL_1:6;
  set s3 = IExec(MI,p,s);
  a in {a, bb, cc} by ENUMSET1:def 1;
  then a in {a, bb, cc} \/ UsedILoc I by XBOOLE_0:def 3;
  then
A8: a <> aux by SCMFSA_M:25;
  bb in {a, bb, cc} by ENUMSET1:def 1;
  then bb in {a, bb, cc} \/ UsedILoc I by XBOOLE_0:def 3;
  then
A9: bb <> aux by SCMFSA_M:25;
A10: s1.aux = Exec(i3, IExec(i0 ";" i1 ";" i2,p,s)).aux by SCMFSA6C:6
    .= IExec(i0 ";" i1 ";" i2,p,s).aux by A8,SCMFSA_2:63
    .= Exec(i2, IExec(i0 ";" i1,p,s)).aux by SCMFSA6C:6
    .= IExec(i0 ";" i1,p,s).aux + 1 by A4,SCMFSA_2:64
    .= Exec(i1, Exec(i0, Initialized s)).aux +1 by SCMFSA6C:8
    .= Exec(i0, Initialized s).aux - Exec(i0, Initialized s).bb +1
    by SCMFSA_2:65
    .= (Initialized s).cc - Exec(i0, Initialized s).bb +1 by SCMFSA_2:63
    .= s.cc-s.bb+1 by A9,A3,A5,SCMFSA_2:63;
  then I4 is_halting_on s1,p1 by A7,SCMFSA_9:38;
  then
A11: DataPart IExec(MI,p,s) = DataPart IExec(I4,p1,s1) by SFMASTR1:9
    .= DataPart s1 by A10,A7,A6,SCMFSA9A:35
    .= DataPart s2 by A1,Th14;
  hereby
    let x be Int-Location such that
A12: x <> a and
A13: x in {bb, cc} \/ UsedILoc I;
    x in {a, bb, cc} \/ UsedILoc I
    proof
      per cases by A13,XBOOLE_0:def 3;
      suppose
        x in {bb, cc};
        then x = bb or x = cc by TARSKI:def 2;
        then x in {a, bb, cc} by ENUMSET1:def 1;
        hence thesis by XBOOLE_0:def 3;
      end;
      suppose
        x in UsedILoc I;
        hence thesis by XBOOLE_0:def 3;
      end;
    end;
    then
A14: x <> aux by SCMFSA_M:25;
    thus s3.x = s2.x by A11,SCMFSA_M:2
      .= (s+*(aux, s.cc-s.bb+1)).x by A12,FUNCT_7:32
      .= s.x by A14,FUNCT_7:32;
  end;
  let x be FinSeq-Location;
  thus s3.x = s2.x by A11,SCMFSA_M:2
    .= (s+*(aux, s.cc-s.bb+1)).x by FUNCT_7:32,SCMFSA_2:58
    .= s.x by FUNCT_7:32,SCMFSA_2:58;
end;
