reserve s for State of SCM+FSA,
  I for MacroInstruction of SCM+FSA,
  a for read-write Int-Location;
reserve i,j,k,n for Nat;
reserve P,P1,P2,Q for Instruction-Sequence of SCM+FSA;

theorem Th27:
  for s be State of SCM+FSA,t be FinSequence of INT, P st
  Initialize((intloc 0).-->1) +*(fsloc 0 .--> t) c= s &
  Insert-Sort-Algorithm c= P
   ex u being FinSequence of
  REAL st t,u are_fiberwise_equipotent & u is non-increasing & u is FinSequence
  of INT & (Result(P,s)).(fsloc 0) = u
proof
  let s be State of SCM+FSA,t be FinSequence of INT, P;
  set Ia=Insert-Sort-Algorithm, p=Initialize((intloc 0).-->1),
  x=fsloc 0 .--> t,
   z=IExec(insert-sort f0,P,s).f0;
  assume that
A1: p+*x c= s and
A2: Ia c= P;
A3: P +* Ia = P by A2,FUNCT_4:98;
  reconsider u=z as FinSequence of REAL by FINSEQ_3:117;
  take u;
A5: f0 in dom x by TARSKI:def 1;
  then f0 in dom (p+*x) by FUNCT_4:12;
  then s.f0=(p+*x).f0 by A1,GRFUNC_1:2
    .=x.f0 by A5,FUNCT_4:13
    .=t by FUNCOP_1:72;
  hence t, u are_fiberwise_equipotent by Th25;
  s.f0, z are_fiberwise_equipotent by Th25;
  then
A6: dom (s.f0) = dom u by RFINSEQ:3;
  now
    let i,j be Nat;
    assume that
A7: i in dom u and
A8: j in dom u and
A9: i<j;
A10: i>=1 by A7,FINSEQ_3:25;
    j<=len (s.f0) by A6,A8,FINSEQ_3:25;
    hence u.i>=u.j by A9,A10,Th25;
    reconsider y2=z.j as Integer;
    reconsider y1=z.i as Integer;
  end;
  hence u is non-increasing by RFINSEQ:19;
  thus u is FinSequence of INT;
A11: dom p = {intloc 0,IC SCM+FSA} by SCMFSA_M:11;
  f0 <> intloc 0 & f0 <> IC SCM+FSA by SCMFSA_2:57,58;
  then not f0 in dom p by A11,TARSKI:def 2;
  then dom p misses dom x by ZFMISC_1:50;
  then p c=p+*x by FUNCT_4:32;
  then
A12:  p c= s by A1,XBOOLE_1:1;
  Initialize((intloc 0).-->1) c= s by A12;
  then s = s +* Initialize((intloc 0).-->1) by FUNCT_4:98;
  then
A13: s = Initialized s;
   Result(P +* Ia,Initialized s).fsloc 0
      = IExec(Ia,P,s).(fsloc 0) by SCMBSORT:33;
  hence thesis by A3,A13;
end;
