
theorem Th27:
for I being really-closed MacroInstruction of SCM+FSA, a being Int-Location,
     k being Nat st k <= card I
  holds Macro(a=0_goto k) ';' I is really-closed
proof let I be really-closed MacroInstruction of SCM+FSA,
  a be Int-Location, l being Nat;
 assume
A1: l <= card I;
   set F = Macro(a=0_goto l); set G = I; set S = SCM+FSA;
   set P = F ';' I, k = card F -' 1;
    let f be Nat such that
A2: f in dom P;
A3: dom P = dom CutLastLoc F \/ dom Reloc(G,k) by FUNCT_4:def 1;
A4: dom Reloc(G,k) = {(m+k) where m is Nat: m in dom IncAddr(G,k)}
    by VALUED_1:def 12;
    let x be object;
    assume x in NIC(P/.f,f);
    then consider s2 being Element of product the_Values_of S
    such that
A5: x = IC Exec(P/.f,s2) and
A6: IC s2 = f;
A7: P/.f = P.f by A2,PARTFUN1:def 6;
    per cases by A2,A3,XBOOLE_0:def 3;
    suppose
A8:   f in dom CutLastLoc F;
      then
A9:   f < card CutLastLoc F by AFINSQ_1:66;
      card CutLastLoc F = card F - 1 by VALUED_1:38
           .= 2 - 1 by COMPOS_1:56;
      then
A10:   f = 0 by A9,NAT_1:14;
      dom CutLastLoc F misses dom Reloc(G,card F -' 1) by COMPOS_1:18;
     then
A11:  not f in dom Reloc(G,k) by A8,XBOOLE_0:3;
     P/.f = (CutLastLoc F).0 by A10,FUNCT_4:11,A11,A7
       .= a=0_goto l;
     then
A12:   x = IC Exec(a=0_goto l,s2) by A5;
    s2.a = 0 or s2.a <> 0;
    then x = l or x = IC s2 + 1 by SCMFSA_2:70,A12;
    then per cases;
    suppose
A13:  x  = l;
      card P = card F + card I - 1 by COMPOS_1:20
         .= 2 + card I - 1 by COMPOS_1:56
         .= card I + 1;
      then card I < card P by XREAL_1:29;
      then l < card P by A1,XXREAL_0:2;
     hence x in dom P by AFINSQ_1:66,A13;
    end;
    suppose x  = IC s2 + 1;
      then
A14:    x = f + 1 by A6;
      f < card F - 1 by A9,VALUED_1:38;
      then f + 1 < card F by XREAL_1:20;
      then
A15:    x in dom F by A14,AFINSQ_1:66;
      dom F c= dom P by COMPOS_1:21;
     hence thesis by A15;
    end;
    end;
    suppose
A16:  f in dom Reloc(G,k);
      then consider m being Nat such that
A17:  f = m+k and
A18:  m in dom IncAddr(G,k) by A4;
A19:  m in dom G by A18,COMPOS_1:def 21;
      then
A20:  NIC(G/.m,m) c= dom G by AMISTD_1:def 9;
A21:  Values IC S = NAT by MEMSTR_0:def 6;
      reconsider m as Element of NAT by ORDINAL1:def 12;
      reconsider v = IC S .--> m as PartState of S by A21;
      set s1 = s2 +* v;
A22:  P/.f = Reloc(G,k).f by A7,A16,FUNCT_4:13
        .= IncAddr(G,k).m by A17,A18,VALUED_1:def 12;
A23:  (IC S .--> m).IC S = m by FUNCOP_1:72;
A24:  IC S in {IC S} by TARSKI:def 1;
A25:  dom (IC S .--> m) = {IC S};
      reconsider w = IC S .--> (IC s1 + k) as PartState of S by A21;
A26:  dom (s1 +* (IC S .--> (IC s1 + k))) = the carrier of S by PARTFUN1:def 2;
A27:    dom s2 = the carrier of S by PARTFUN1:def 2;
      for a being object st a in dom s2 holds
      s2.a = (s1 +* (IC S .--> (IC s1 + k))).a
      proof
        let a be object such that a in dom s2;
A28:    dom (IC S .--> (IC s1 + k)) = {IC S};
        per cases;
        suppose
A29:      a = IC S;
          hence s2.a = IC s1 + k by A6,A17,A25,A23,A24,FUNCT_4:13
            .= (IC S .--> (IC s1 + k)).a by A29,FUNCOP_1:72
            .= (s1 +* (IC S .--> (IC s1 + k))).a by A24,A28,A29,FUNCT_4:13;
        end;
        suppose
A30:      a <> IC S;
          then
A31:      not a in dom (IC S .--> (IC s1 + k)) by TARSKI:def 1;
          not a in dom (IC S .--> m) by A30,TARSKI:def 1;
          then s1.a = s2.a by FUNCT_4:11;
          hence thesis by A31,FUNCT_4:11;
        end;
      end;
      then
A32:  s2 = IncIC(s1,k) by A26,A27,FUNCT_1:2;
      set s3 = s1;
A33:  IC s3 = m by A23,A24,A25,FUNCT_4:13;
      reconsider s3 as Element of product the_Values_of S by CARD_3:107;
      reconsider k,m as Element of NAT;
A34:  x = IC Exec(IncAddr(G/.m,k),s2) by A5,A19,A22,COMPOS_1:def 21
        .= IC Exec(G/.m, s3) + k by A32,AMISTD_2:7;
      IC Exec(G/.m, s3) in NIC(G/.m,m) by A33;
      then IC Exec(G/.m, s3) in dom G by A20;
      then IC Exec(G/.m, s3) in dom IncAddr(G,k) by COMPOS_1:def 21;
      then x in dom Reloc(G,k) by A4,A34;
      hence thesis by A3,XBOOLE_0:def 3;
    end;
  end;
