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 Th22:
  for f being FinSeq-Location holds UsedI*Loc (bubble-sort f) = {f}
proof
  let f be FinSeq-Location;
  set i1= a4:=a3, i2= SubFrom(a3,a0), i3= (a5:=(f,a3)), i4= (a6:=(f,a4)),
  i5= SubFrom(a6,a5), i6= ((f,a3):=a6), i7= ((f,a4):=a5),
  ifc=if>0(a6,i4 ";" i6 ";" i7,Stop SCM+FSA), Sif= UsedI*Loc ifc,
  body2= i1 ";" i2 ";" i3 ";" i4 ";" i5 ";" ifc;
A1: Sif = UsedI*Loc (i4 ";" i6 ";" i7) \/ {} by SCMFSA9A:4,10
    .= UsedI*Loc (i4 ";" i6) \/ UsedInt*Loc i7 by SF_MASTR:46
    .= UsedI*Loc (i4 ";" i6) \/ {f} by SF_MASTR:33
    .= UsedInt*Loc i4 \/ UsedInt*Loc i6 \/ {f} by SF_MASTR:47
    .= UsedInt*Loc i4 \/ {f} \/ {f} by SF_MASTR:33
    .= {f} \/ {f} \/ {f} by SF_MASTR:33
    .= {f};
A2: UsedI*Loc body2 = UsedI*Loc (i1 ";" i2 ";"i3 ";"i4 ";" i5)
  \/ Sif by SF_MASTR:43
    .= UsedI*Loc (i1 ";" i2 ";"i3 ";" i4) \/ UsedInt*Loc i5 \/ Sif
  by SF_MASTR:46
    .= UsedI*Loc (i1 ";" i2 ";"i3 ";" i4) \/ {} \/ Sif by SF_MASTR:32
    .= UsedI*Loc (i1 ";" i2 ";"i3 ) \/ UsedInt*Loc i4 \/ Sif by SF_MASTR:46
    .= UsedI*Loc (i1 ";" i2 ";"i3 ) \/ {f} \/ Sif by SF_MASTR:33
    .= UsedI*Loc (i1 ";" i2 ";"i3 ) \/ ({f} \/ {f}) by A1,XBOOLE_1:4
    .= UsedI*Loc (i1 ";" i2 ) \/ UsedInt*Loc i3 \/ {f} by SF_MASTR:46
    .= UsedI*Loc (i1 ";" i2 ) \/ {f} \/ {f} by SF_MASTR:33
    .= UsedInt*Loc i1 \/ UsedInt*Loc i2 \/ {f} \/ {f} by SF_MASTR:47
    .= UsedInt*Loc i1 \/ {} \/ {f} \/ {f} by SF_MASTR:32
    .= {} \/ {} \/ {f} \/ {f} by SF_MASTR:32
    .= {f};
  set j1= a2 := a1, j2= SubFrom(a2,a0), j3= (a3:=len f),
  Sfor= UsedI*Loc Times(a2,body2),
  body1= j1 ";" j2 ";" j3 ";" Times(a2,body2);
A3: Sfor={f} by A2,SCMFSA9A:45;
A4: UsedI*Loc body1 = UsedI*Loc (j1 ";" j2 ";"j3) \/ Sfor by SF_MASTR:43
    .= UsedI*Loc (j1 ";" j2) \/ UsedInt*Loc j3 \/ Sfor by SF_MASTR:46
    .= UsedI*Loc (j1 ";" j2) \/ {f} \/ Sfor by SF_MASTR:34
    .= UsedInt*Loc j1 \/ UsedInt*Loc j2 \/ {f} \/ Sfor by SF_MASTR:47
    .= {} \/ UsedInt*Loc j2 \/ {f} \/ Sfor by SF_MASTR:32
    .= {} \/ {} \/ {f} \/ Sfor by SF_MASTR:32
    .= {f} by A3;
  set k2= a2:= a0, k3= a3:= a0, k4= a4:= a0, k5= a5:= a0;
A5: UsedI*Loc initializeWorkMem = UsedI*Loc (k2 ";" k3 ";" k4 ";" k5)
  \/ UsedInt*Loc (a6:= a0) by SF_MASTR:46
    .= UsedI*Loc (k2 ";" k3 ";" k4 ";" k5) \/ {} by SF_MASTR:32
    .= UsedI*Loc (k2 ";" k3 ";" k4) \/ UsedInt*Loc k5 by SF_MASTR:46
    .= UsedI*Loc (k2 ";" k3 ";" k4) \/ {} by SF_MASTR:32
    .= UsedI*Loc (k2 ";" k3 ) \/ UsedInt*Loc k4 by SF_MASTR:46
    .= UsedI*Loc (k2 ";" k3 ) \/ {} by SF_MASTR:32
    .= UsedInt*Loc k2 \/ UsedInt*Loc k3 by SF_MASTR:47
    .= UsedInt*Loc k2 \/ {} by SF_MASTR:32
    .= {} by SF_MASTR:32;
  set k7=(a1:=len f) , Ut=UsedI*Loc Times(a1,body1);
  thus UsedI*Loc (bubble-sort f)
  =UsedI*Loc ( initializeWorkMem ";" k7 ) \/ Ut by SF_MASTR:43
    .=UsedI*Loc initializeWorkMem \/ UsedInt*Loc k7 \/ Ut by SF_MASTR:46
    .={f} \/ Ut by A5,SF_MASTR:34
    .={f} \/ {f} by A4,SCMFSA9A:45
    .={f};
end;
