reserve p for preProgram of SCM+FSA,
  ic for Instruction of SCM+FSA,
  i,j,k for Nat,
  fa,f for FinSeq-Location,
  a,b,da,db for Int-Location,
  la,lb for Nat;
reserve p1,p2,q for Instruction-Sequence of SCM+FSA;
reserve n for Nat;

theorem Th29:
  for w being FinSequence of INT holds
  Initialized ((fsloc 0) .--> w) is Bubble-Sort-Algorithm-autonomic
proof
  let w be FinSequence of INT;
  set p=Initialized((fsloc 0) .--> w), q=Bubble-Sort-Algorithm;
A1: for P,Q being Instruction-Sequence of SCM+FSA
  st q c= P & q c= Q
 for s1,s2 being State of SCM+FSA,i st  p c= s1 &  p c= s2 &
    i <= 10 holds
  Comput(P,s1,i).intloc 0 = Comput(Q,s2,i).intloc 0
&
  Comput(P,s1,i).IC SCM+FSA = Comput(Q,s2,i).IC
SCM+FSA &
  Comput(P,s1,i).fsloc 0 = Comput(Q,s2,i).fsloc 0
  proof
   let P,Q being Instruction-Sequence of SCM+FSA
   such that
A2: q c= P & q c= Q;
    let s1,s2 be State of SCM+FSA,i;
    assume that
A3:  p c= s1 and
A4:  p c= s2 and
A5: i <= 10;
A6: q c= P by A2;
A7: q c= Q by A2;
A8: s1 is 0-started by A3,MEMSTR_0:17;
A9: s2 is 0-started by A4,MEMSTR_0:17;
A10: s1.intloc 0 =1 by A3,SCMFSA_M:33
      .= s2.intloc 0 by A4,SCMFSA_M:33;
A11: s1.fsloc 0 =w by A3,SCMFSA_M:33
      .=s2.fsloc 0 by A4,SCMFSA_M:33;
A12: IC s1 =  0 by A8
      .= IC s2 by A9;
    i = 0 or ... or i = 10 by A5;
    then per cases;
    suppose
A13:  i = 0;
      hence Comput(P,s1,i).intloc 0 = Comput(Q,s2,i).intloc 0 by A10;
      thus
      (Comput(P,s1,i)).IC SCM+FSA = (Comput(Q,s2,i)).IC SCM+FSA by A12,A13;
      thus thesis by A11,A13;
    end;
    suppose
A14:  i = 1;
      hence Comput(P,s1,i).intloc 0 = s1.intloc 0 by A2,A8,Lm21
        .= Comput(Q,s2,i).intloc 0 by A2,A9,A10,A14,Lm21;
      thus (Comput(P,s1,i)).IC SCM+FSA =  1 by A2,A8,A14,Lm21
        .= (Comput(Q,s2,i)).IC SCM+FSA by A7,A9,A14,Lm21;
      thus Comput(P,s1,i).fsloc 0 = s1.fsloc 0
         by A6,A8,A14,Lm21
        .= Comput(Q,s2,i).fsloc 0 by A2,A9,A11,A14,Lm21;
    end;
    suppose
A15:  i = 2;
      hence Comput(P,s1,i).intloc 0 = s1.intloc 0
      by A6,A8,Lm21
        .= Comput(Q,s2,i).intloc 0 by A2,A9,A10,A15,Lm21;
      thus (Comput(P,s1,i)).IC SCM+FSA =  2 by A2,A8,A15,Lm21
        .= (Comput(Q,s2,i)).IC SCM+FSA by A2,A9,A15,Lm21;
      thus Comput(P,s1,i).fsloc 0 = s1.fsloc 0 by A2,A8,A15,Lm21
        .= Comput(Q,s2,i).fsloc 0 by A2,A9,A11,A15,Lm21;
    end;
    suppose
A16:  i = 3;
      hence Comput(P,s1,i).intloc 0 = s1.intloc 0 by A2,A8,Lm21
        .= Comput(Q,s2,i).intloc 0 by A2,A9,A10,A16,Lm21;
      thus (Comput(P,s1,i)).IC SCM+FSA =  3 by A2,A8,A16,Lm21
        .= (Comput(Q,s2,i)).IC SCM+FSA by A2,A9,A16,Lm21;
      thus Comput(P,s1,i).fsloc 0 = s1.fsloc 0
      by A6,A8,A16,Lm21
        .= Comput(Q,s2,i).fsloc 0 by A2,A9,A11,A16,Lm21;
    end;
    suppose
A17:  i = 4;
      hence Comput(P,s1,i).intloc 0 = s1.intloc 0
      by A6,A8,Lm21
        .= Comput(Q,s2,i).intloc 0 by A2,A9,A10,A17,Lm21;
      thus (Comput(P,s1,i)).IC SCM+FSA =  4 by A2,A8,A17,Lm21
        .= (Comput(Q,s2,i)).IC SCM+FSA by A2,A9,A17,Lm21;
      thus Comput(P,s1,i).fsloc 0 = s1.fsloc 0 by A2,A8,A17,Lm21
        .= Comput(Q,s2,i).fsloc 0 by A2,A9,A11,A17,Lm21;
    end;
    suppose
A18:  i = 5;
      hence Comput(P,s1,i).intloc 0 = s1.intloc 0
      by A6,A8,Lm21
        .= Comput(Q,s2,i).intloc 0 by A2,A9,A10,A18,Lm21;
      thus (Comput(P,s1,i)).IC SCM+FSA =  5 by A2,A8,A18,Lm21
        .= (Comput(Q,s2,i)).IC SCM+FSA by A2,A9,A18,Lm21;
      thus Comput(P,s1,i).fsloc 0 = s1.fsloc 0 by A2,A8,A18,Lm21
        .= Comput(Q,s2,i).fsloc 0 by A2,A9,A11,A18,Lm21;
    end;
    suppose
A19:  i = 6;
      hence Comput(P,s1,i).intloc 0 = s1.intloc 0 by A2,A8,Lm21
        .= Comput(Q,s2,i).intloc 0 by A2,A9,A10,A19,Lm21;
      thus (Comput(P,s1,i)).IC SCM+FSA =  6 by A2,A8,A19,Lm21
        .= (Comput(Q,s2,i)).IC SCM+FSA by A2,A9,A19,Lm21;
      thus Comput(P,s1,i).fsloc 0 = s1.fsloc 0 by A2,A8,A19,Lm21
        .= Comput(Q,s2,i).fsloc 0 by A2,A9,A11,A19,Lm21;
    end;
    suppose
A20:  i = 7;
      hence Comput(P,s1,i).intloc 0 = s1.intloc 0
      by A6,A8,Lm21
        .= Comput(Q,s2,i).intloc 0 by A2,A9,A10,A20,Lm21;
      thus (Comput(P,s1,i)).IC SCM+FSA =  7 by A2,A8,A20,Lm21
        .= (Comput(Q,s2,i)).IC SCM+FSA by A2,A9,A20,Lm21;
      thus Comput(P,s1,i).fsloc 0 = s1.fsloc 0 by A2,A8,A20,Lm21
        .= Comput(Q,s2,i).fsloc 0 by A2,A9,A11,A20,Lm21;
    end;
    suppose
A21:  i = 8;
      hence Comput(P,s1,i).intloc 0 = s1.intloc 0 by A2,A8,Lm21
        .= Comput(Q,s2,i).intloc 0 by A2,A9,A10,A21,Lm21;
      thus (Comput(P,s1,i)).IC SCM+FSA =  8 by A2,A8,A21,Lm21
        .= (Comput(Q,s2,i)).IC SCM+FSA by A2,A9,A21,Lm21;
      thus Comput(P,s1,i).fsloc 0 = s1.fsloc 0 by A2,A8,A21,Lm21
        .= Comput(Q,s2,i).fsloc 0 by A2,A9,A11,A21,Lm21;
    end;
    suppose
A22:  i = 9;
      hence Comput(P,s1,i).intloc 0 = s1.intloc 0 by A2,A8,Lm21
        .= Comput(Q,s2,i).intloc 0 by A2,A9,A10,A22,Lm21;
      thus (Comput(P,s1,i)).IC SCM+FSA =  9 by A2,A8,A22,Lm21
        .= (Comput(Q,s2,i)).IC SCM+FSA by A2,A9,A22,Lm21;
      thus Comput(P,s1,i).fsloc 0 = s1.fsloc 0 by A2,A8,A22,Lm21
        .= Comput(Q,s2,i).fsloc 0 by A2,A9,A11,A22,Lm21;
    end;
    suppose
A23:  i = 10;
      hence Comput(P,s1,i).intloc 0 = s1.intloc 0 by A2,A8,Lm21
        .= Comput(Q,s2,i).intloc 0 by A2,A9,A10,A23,Lm21;
      thus (Comput(P,s1,i)).IC SCM+FSA =  10 by A2,A8,A23,Lm21
        .= (Comput(Q,s2,i)).IC SCM+FSA by A2,A9,A23,Lm21;
      thus Comput(P,s1,i).fsloc 0 = s1.fsloc 0 by A2,A8,A23,Lm21
        .= Comput(Q,s2,i).fsloc 0 by A2,A9,A11,A23,Lm21;
    end;
  end;
  set UD={fsloc 0,a0,a1,a2,a3,a4,a5,a6}, Us=UsedI*Loc q \/ UsedILoc q;
A24: UsedI*Loc q ={fsloc 0} by Th22;
A25: UsedILoc q ={a0,a1,a2,a3,a4,a5,a6} by Th21;
  then
A26: Us = UD by A24,ENUMSET1:22;
A27: for P,Q being Instruction-Sequence of SCM+FSA
   st q c= P & q c= Q
  for i being Nat,s1,s2 being State of SCM+FSA
  st 11 <= i &  p c= s1 &  p c= s2
  holds Comput(P,s1,i) | Us = Comput(Q,s2,i) | Us &
  Comput(P,s1,i).IC SCM+FSA = Comput(Q,s2,i).IC SCM+FSA
  proof
   let P,Q be Instruction-Sequence of SCM+FSA
   such that
A28:  q c= P & q c= Q;
    let i be Nat,s1,s2 be State of SCM+FSA such that
A29: 11 <= i and
A30:  p c= s1 and
A31:  p c= s2;
    set Cs11= Comput(P, s1,11), Cs21= Comput(Q,s2,11);
A32: s1 is 0-started by A30,MEMSTR_0:17;
A33: s2 is 0-started by A31,MEMSTR_0:17;
A34: s1.intloc 0 =1 by A30,SCMFSA_M:33
      .= s2.intloc 0 by A31,SCMFSA_M:33;
A35: s1.fsloc 0 =w by A30,SCMFSA_M:33
      .=s2.fsloc 0 by A31,SCMFSA_M:33;
A36: Us c= dom(Cs11) by Th19;
A37: Us c= dom(Cs21) by Th19;
    now
      let x be set;
      assume x in Us;
      then
A38:  x in UD by A24,A25,ENUMSET1:22;
      per cases by A38,ENUMSET1:def 6;
      suppose
A39:    x = fsloc 0;
        hence Cs11.x =s1.fsloc 0 by A32,A28,Lm21
          .=Cs21.x by A33,A28,A35,A39,Lm21;
      end;
      suppose
A40:    x = a0;
        hence Cs11.x =s1.a0 by A32,A28,Lm21
          .=Cs21.x by A33,A28,A34,A40,Lm21;
      end;
      suppose
A41:    x = a1;
        hence Cs11.x=len(s1.fsloc 0) by A32,A28,Lm21
          .=Cs21.x by A33,A28,A35,A41,Lm21;
      end;
      suppose
A42:    x = a2;
        hence Cs11.x=s1.a0 by A32,A28,Lm21
          .=Cs21.x by A33,A28,A34,A42,Lm21;
      end;
      suppose
A43:    x = a3;
        hence Cs11.x=s1.a0 by A32,A28,Lm21
          .=Cs21.x by A33,A28,A34,A43,Lm21;
      end;
      suppose
A44:    x = a4;
        hence Cs11.x=s1.a0 by A32,A28,Lm21
          .=Cs21.x by A33,A28,A34,A44,Lm21;
      end;
      suppose
A45:    x = a5;
        hence Cs11.x=s1.a0 by A32,A28,Lm21
          .=Cs21.x by A33,A28,A34,A45,Lm21;
      end;
      suppose
A46:    x = a6;
        hence Cs11.x=s1.a0 by A32,A28,Lm21
          .=Cs21.x by A33,A28,A34,A46,Lm21;
      end;
    end;
    then
A47: Cs11 | Us = Cs21 | Us by A36,A37,FUNCT_1:95;
A48: Cs11.IC SCM+FSA =  11 by A32,A28,Lm21
      .=Cs21.IC SCM+FSA by A33,A28,Lm21;
A49: for i holds IC Comput(P,s1,i) in dom q by A30,Th27,A28;
    for i holds IC Comput(Q,s2,i) in dom q by A31,Th27,A28;
    hence thesis by A29,A47,A48,A49,Th14,A28;
  end;
  set DD={intloc 0,IC SCM+FSA,fsloc 0};
    let P,Q be Instruction-Sequence of SCM+FSA
    such that
A50:  q c= P & q c= Q;
    let s1,s2 be State of SCM+FSA;
    assume that
A51:  p c= s1 and
A52:  p c= s2;
    let i be Nat;
     reconsider i as Nat;
    set Cs1i=Comput(P,s1,i), Cs2i=Comput(Q,s2,i);
A53: dom  p = DD by SCMFSA_M:31;
A54: DD c= dom Cs1i by SCMFSA_M:34;
A55: DD c= dom Cs2i by SCMFSA_M:34;
A56: intloc 0 in Us by A26,ENUMSET1:def 6;
A57: fsloc 0 in Us by A26,ENUMSET1:def 6;
A58: Us c= dom(Cs1i) by Th19;
A59: Us c= dom(Cs2i) by Th19;
A60: i>10 implies 10+1 < i+1 by XREAL_1:6;
    now
      let x be set;
      assume
A61:  x in DD;
      per cases by A61,ENUMSET1:def 1;
      suppose
A62:    x=intloc 0;
        per cases;
          suppose i<=10;
            hence Cs1i.x=Cs2i.x by A1,A51,A52,A62,A50;
          end;
          suppose i>10;
            then 11 <= i by A60,NAT_1:13;
            then Cs1i | Us = Cs2i | Us by A27,A51,A52,A50;
            hence Cs1i.x=Cs2i.x by A56,A58,A59,A62,FUNCT_1:95;
          end;
      end;
      suppose
A63:    x=IC SCM+FSA;
        per cases;
          suppose i<=10;
            hence Cs1i.x=Cs2i.x by A1,A51,A52,A63,A50;
          end;
          suppose i>10;
            then 11 <= i by A60,NAT_1:13;
            hence Cs1i.x=Cs2i.x by A27,A51,A52,A63,A50;
          end;
      end;
      suppose
A64:    x=fsloc 0;
        per cases;
          suppose i<=10;
            hence Cs1i.x=Cs2i.x by A1,A51,A52,A64,A50;
          end;
          suppose i>10;
            then 11 <= i by A60,NAT_1:13;
            then Cs1i | Us = Cs2i | Us by A27,A51,A52,A50;
            hence Cs1i.x=Cs2i.x by A57,A58,A59,A64,FUNCT_1:95;
          end;
      end;
    end;
 hence thesis by A53,A54,A55,FUNCT_1:95;
end;
