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
  Bubble-Sort-Algorithm, Initialize((intloc 0).-->1)
      computes Sorting-Function
proof
  let x be set;
  assume x in dom Sorting-Function;
  then consider w being FinSequence of INT such that
A1: x = fsloc 0 .--> w by SCMFSA_M:35;
  reconsider d = x as FinPartState of SCM+FSA by A1;
  set q = Bubble-Sort-Algorithm,
   p = Initialize((intloc 0).-->1);
A2: dom d = { fsloc 0 } by A1;
  take d;
  thus x = d;
A3: dom d misses {IC SCM+FSA} by A2,SCMFSA_2:57,ZFMISC_1:11;
A4: dom d misses {intloc 0} by A2,SCMFSA_2:58,ZFMISC_1:11;
    dom p = dom ((intloc 0).-->1) \/ {IC SCM+FSA} by MEMSTR_0:42
       .= {IC SCM+FSA} \/ {intloc 0};
    then
A5: dom d misses dom p by A3,A4,XBOOLE_1:70;
A6: d +* p = p +* d by A5,FUNCT_4:35;
   Initialized d = d +* p
        .= p +* d by A5,FUNCT_4:35
        .= (p +* d)
        .= p +* d;
   then
A7: p +* d is q-autonomic by A1,Th29;
  now
    let t be State of SCM+FSA;
    assume
A8:  (p+*d) c= t;
    let P be Instruction-Sequence of SCM+FSA
    such that
A9:  q c= P;
    set bf=bubble-sort fsloc 0;
    Initialize((intloc 0).-->1) c= (p+*d) by A6,FUNCT_4:25;
    then Initialize((intloc 0).-->1) c= t by A8,XBOOLE_1:1;
   hence P halts_on t by Lm26,A9,SCM_HALT:def 2;
  end;
  then
A10: p +* d is q-halted;
  thus
A11:  p +* d is Autonomy of q by A10,A7,EXTPRO_1:def 12;
  consider z being FinSequence of REAL such that
A12: w,z are_fiberwise_equipotent and
A13: z is non-increasing
  and z is FinSequence of INT and
A14: Sorting-Function.d = fsloc 0 .--> z by A1,SCMFSA_M:36;
  consider t being State of SCM+FSA such that
A15: p +* d c= t by PBOOLE:141;
  consider T being Instruction-Sequence of SCM+FSA such that
A16: q c= T by PBOOLE:145;
  consider u being FinSequence of REAL such that
A17: w,u are_fiberwise_equipotent and
A18: u is non-increasing
  and
 u is FinSequence of INT and
A19: (Result(T,t)).(fsloc 0) = u by Th28,A1,A15,A16;
A20: u=z by A12,A13,A17,A18,CLASSES1:76,RFINSEQ:23;
  fsloc 0 in the carrier of SCM+FSA;
  then
A21: fsloc 0 in dom Result(T,t) by PARTFUN1:def 2;
  d c= p +* d by FUNCT_4:25;
  then
A22: dom d c= dom(p +* d) by RELAT_1:11;
A23: dom(fsloc 0 .--> z) = { fsloc 0 };
  Result(q,p +* d) = (Result(T,t))|dom(p +* d)
         by A11,A15,A16,EXTPRO_1:def 13;
 hence Sorting-Function.d c= Result(q,p+* d)
   by A2,A14,A19,A20,A21,A23,A22,FUNCT_4:85,RELAT_1:151;
end;
