:: SCPISORT semantic presentation
:: deftheorem Def1 defines is_FinSequence_on SCPISORT:def 1 :
Lemma2:
for b1 being FinSequence of INT
for b2 being Nat holds b1 is_non_decreasing_on b2,b2
theorem Th1: :: SCPISORT:1
theorem Th2: :: SCPISORT:2
theorem Th3: :: SCPISORT:3
theorem Th4: :: SCPISORT:4
set c1 = the Instruction-Locations of SCMPDS ;
set c2 = SCM-Data-Loc ;
theorem Th5: :: SCPISORT:5
theorem Th6: :: SCPISORT:6
theorem Th7: :: SCPISORT:7
theorem Th8: :: SCPISORT:8
theorem Th9: :: SCPISORT:9
theorem Th10: :: SCPISORT:10
theorem Th11: :: SCPISORT:11
Lemma8:
for b1 being Int_position
for b2 being Integer
for b3 being Nat
for b4 being Program-block holds card (stop (for-down b1,b2,b3,b4)) = (card b4) + 4
Lemma9:
for b1 being Int_position
for b2 being Integer
for b3 being Nat
for b4 being Program-block holds for-down b1,b2,b3,b4 = (b1,b2 <=0_goto ((card b4) + 3)) ';' ((b4 ';' (AddTo b1,b2,(- b3))) ';' (goto (- ((card b4) + 2))))
Lemma10:
for b1 being Program-block
for b2 being Int_position
for b3 being Integer
for b4 being Nat holds Shift (b1 ';' (AddTo b2,b3,(- b4))),1 c= for-down b2,b3,b4,b1
scheme :: SCPISORT:sch 1
s1{
P1[
set ],
F1()
-> State of
SCMPDS ,
F2()
-> shiftable No-StopCode Program-block,
F3()
-> Int_position ,
F4()
-> Integer,
F5()
-> Nat } :
provided
E11:
F5()
> 0
and E12:
P1[
Dstate F1()]
and E13:
for
b1 being
State of
SCMPDS st
P1[
Dstate b1] &
b1 . F3()
= F1()
. F3() &
b1 . (DataLoc (F1() . F3()),F4()) > 0 holds
(
(IExec (F2() ';' (AddTo F3(),F4(),(- F5()))),b1) . F3()
= b1 . F3() &
(IExec (F2() ';' (AddTo F3(),F4(),(- F5()))),b1) . (DataLoc (F1() . F3()),F4()) = (b1 . (DataLoc (F1() . F3()),F4())) - F5() &
F2()
is_closed_on b1 &
F2()
is_halting_on b1 &
P1[
Dstate (IExec (F2() ';' (AddTo F3(),F4(),(- F5()))),b1)] )
scheme :: SCPISORT:sch 2
s2{
P1[
set ],
F1()
-> State of
SCMPDS ,
F2()
-> shiftable No-StopCode Program-block,
F3()
-> Int_position ,
F4()
-> Integer,
F5()
-> Nat } :
( (
P1[
F1()] or not
P1[
F1()] ) &
IExec (for-down F3(),F4(),F5(),F2()),
F1()
= IExec (for-down F3(),F4(),F5(),F2()),
(IExec (F2() ';' (AddTo F3(),F4(),(- F5()))),F1()) )
provided
E11:
F5()
> 0
and E12:
F1()
. (DataLoc (F1() . F3()),F4()) > 0
and E13:
P1[
Dstate F1()]
and E14:
for
b1 being
State of
SCMPDS st
P1[
Dstate b1] &
b1 . F3()
= F1()
. F3() &
b1 . (DataLoc (F1() . F3()),F4()) > 0 holds
(
(IExec (F2() ';' (AddTo F3(),F4(),(- F5()))),b1) . F3()
= b1 . F3() &
(IExec (F2() ';' (AddTo F3(),F4(),(- F5()))),b1) . (DataLoc (F1() . F3()),F4()) = (b1 . (DataLoc (F1() . F3()),F4())) - F5() &
F2()
is_closed_on b1 &
F2()
is_halting_on b1 &
P1[
Dstate (IExec (F2() ';' (AddTo F3(),F4(),(- F5()))),b1)] )
scheme :: SCPISORT:sch 3
s3{
P1[
set ],
F1()
-> State of
SCMPDS ,
F2()
-> shiftable No-StopCode Program-block,
F3()
-> Int_position ,
F4()
-> Integer,
F5()
-> Nat } :
provided
E11:
F5()
> 0
and E12:
P1[
Dstate F1()]
and E13:
for
b1 being
State of
SCMPDS st
P1[
Dstate b1] &
b1 . F3()
= F1()
. F3() &
b1 . (DataLoc (F1() . F3()),F4()) > 0 holds
(
(IExec (F2() ';' (AddTo F3(),F4(),(- F5()))),b1) . F3()
= b1 . F3() &
(IExec (F2() ';' (AddTo F3(),F4(),(- F5()))),b1) . (DataLoc (F1() . F3()),F4()) = (b1 . (DataLoc (F1() . F3()),F4())) - F5() &
F2()
is_closed_on b1 &
F2()
is_halting_on b1 &
P1[
Dstate (IExec (F2() ';' (AddTo F3(),F4(),(- F5()))),b1)] )
theorem Th12: :: SCPISORT:12
for
b1 being
State of
SCMPDS for
b2 being
shiftable No-StopCode Program-block for
b3,
b4,
b5 being
Int_position for
b6,
b7 being
Integer for
b8 being
Nat st
b8 > 0 &
b1 . b4 >= (b1 . b5) + b7 & ( for
b9 being
State of
SCMPDS st
b9 . b4 >= (b9 . b5) + b7 &
b9 . b3 = b1 . b3 &
b9 . (DataLoc (b1 . b3),b6) > 0 holds
(
(IExec (b2 ';' (AddTo b3,b6,(- b8))),b9) . b3 = b9 . b3 &
(IExec (b2 ';' (AddTo b3,b6,(- b8))),b9) . (DataLoc (b1 . b3),b6) = (b9 . (DataLoc (b1 . b3),b6)) - b8 &
b2 is_closed_on b9 &
b2 is_halting_on b9 &
(IExec (b2 ';' (AddTo b3,b6,(- b8))),b9) . b4 >= ((IExec (b2 ';' (AddTo b3,b6,(- b8))),b9) . b5) + b7 ) ) holds
(
for-down b3,
b6,
b8,
b2 is_closed_on b1 &
for-down b3,
b6,
b8,
b2 is_halting_on b1 )
theorem Th13: :: SCPISORT:13
for
b1 being
State of
SCMPDS for
b2 being
shiftable No-StopCode Program-block for
b3,
b4,
b5 being
Int_position for
b6,
b7 being
Integer for
b8 being
Nat st
b8 > 0 &
b1 . b4 >= (b1 . b5) + b7 &
b1 . (DataLoc (b1 . b3),b6) > 0 & ( for
b9 being
State of
SCMPDS st
b9 . b4 >= (b9 . b5) + b7 &
b9 . b3 = b1 . b3 &
b9 . (DataLoc (b1 . b3),b6) > 0 holds
(
(IExec (b2 ';' (AddTo b3,b6,(- b8))),b9) . b3 = b9 . b3 &
(IExec (b2 ';' (AddTo b3,b6,(- b8))),b9) . (DataLoc (b1 . b3),b6) = (b9 . (DataLoc (b1 . b3),b6)) - b8 &
b2 is_closed_on b9 &
b2 is_halting_on b9 &
(IExec (b2 ';' (AddTo b3,b6,(- b8))),b9) . b4 >= ((IExec (b2 ';' (AddTo b3,b6,(- b8))),b9) . b5) + b7 ) ) holds
IExec (for-down b3,b6,b8,b2),
b1 = IExec (for-down b3,b6,b8,b2),
(IExec (b2 ';' (AddTo b3,b6,(- b8))),b1)
theorem Th14: :: SCPISORT:14
for
b1 being
State of
SCMPDS for
b2 being
shiftable No-StopCode Program-block for
b3 being
Int_position for
b4 being
Integer for
b5 being
Nat st
b1 . (DataLoc (b1 . b3),b4) > 0 &
b5 > 0 &
card b2 > 0 &
b3 <> DataLoc (b1 . b3),
b4 & ( for
b6 being
State of
SCMPDS st
b6 . b3 = b1 . b3 holds
(
(IExec b2,b6) . b3 = b6 . b3 &
(IExec b2,b6) . (DataLoc (b1 . b3),b4) = b6 . (DataLoc (b1 . b3),b4) &
b2 is_closed_on b6 &
b2 is_halting_on b6 ) ) holds
(
for-down b3,
b4,
b5,
b2 is_closed_on b1 &
for-down b3,
b4,
b5,
b2 is_halting_on b1 )
definition
let c3,
c4 be
Nat;
func insert-sort c1,
c2 -> Program-block equals :: SCPISORT:def 2
((((GBP := 0) ';' (GBP ,1 := 0)) ';' (GBP ,2 := (a1 - 1))) ';' (GBP ,3 := a2)) ';' (for-down GBP ,2,1,(((((AddTo GBP ,3,1) ';' (GBP ,4 := GBP ,3)) ';' (AddTo GBP ,1,1)) ';' (GBP ,6 := GBP ,1)) ';' (while>0 GBP ,6,(((GBP ,5 := (intpos 4),(- 1)) ';' (SubFrom GBP ,5,(intpos 4),0)) ';' (if>0 GBP ,5,(((((GBP ,5 := (intpos 4),(- 1)) ';' ((intpos 4),(- 1) := (intpos 4),0)) ';' ((intpos 4),0 := GBP ,5)) ';' (AddTo GBP ,4,(- 1))) ';' (AddTo GBP ,6,(- 1))),(Load (GBP ,6 := 0)))))));
coherence
((((GBP := 0) ';' (GBP ,1 := 0)) ';' (GBP ,2 := (c3 - 1))) ';' (GBP ,3 := c4)) ';' (for-down GBP ,2,1,(((((AddTo GBP ,3,1) ';' (GBP ,4 := GBP ,3)) ';' (AddTo GBP ,1,1)) ';' (GBP ,6 := GBP ,1)) ';' (while>0 GBP ,6,(((GBP ,5 := (intpos 4),(- 1)) ';' (SubFrom GBP ,5,(intpos 4),0)) ';' (if>0 GBP ,5,(((((GBP ,5 := (intpos 4),(- 1)) ';' ((intpos 4),(- 1) := (intpos 4),0)) ';' ((intpos 4),0 := GBP ,5)) ';' (AddTo GBP ,4,(- 1))) ';' (AddTo GBP ,6,(- 1))),(Load (GBP ,6 := 0))))))) is Program-block
;
end;
:: deftheorem Def2 defines insert-sort SCPISORT:def 2 :
for
b1,
b2 being
Nat holds
insert-sort b1,
b2 = ((((GBP := 0) ';' (GBP ,1 := 0)) ';' (GBP ,2 := (b1 - 1))) ';' (GBP ,3 := b2)) ';' (for-down GBP ,2,1,(((((AddTo GBP ,3,1) ';' (GBP ,4 := GBP ,3)) ';' (AddTo GBP ,1,1)) ';' (GBP ,6 := GBP ,1)) ';' (while>0 GBP ,6,(((GBP ,5 := (intpos 4),(- 1)) ';' (SubFrom GBP ,5,(intpos 4),0)) ';' (if>0 GBP ,5,(((((GBP ,5 := (intpos 4),(- 1)) ';' ((intpos 4),(- 1) := (intpos 4),0)) ';' ((intpos 4),0 := GBP ,5)) ';' (AddTo GBP ,4,(- 1))) ';' (AddTo GBP ,6,(- 1))),(Load (GBP ,6 := 0)))))));
set c3 = AddTo GBP ,3,1;
set c4 = GBP ,4 := GBP ,3;
set c5 = AddTo GBP ,1,1;
set c6 = GBP ,6 := GBP ,1;
set c7 = GBP ,5 := (intpos 4),(- 1);
set c8 = SubFrom GBP ,5,(intpos 4),0;
set c9 = GBP ,5 := (intpos 4),(- 1);
set c10 = (intpos 4),(- 1) := (intpos 4),0;
set c11 = (intpos 4),0 := GBP ,5;
set c12 = AddTo GBP ,4,(- 1);
set c13 = AddTo GBP ,6,(- 1);
set c14 = Load (GBP ,6 := 0);
set c15 = ((((GBP ,5 := (intpos 4),(- 1)) ';' ((intpos 4),(- 1) := (intpos 4),0)) ';' ((intpos 4),0 := GBP ,5)) ';' (AddTo GBP ,4,(- 1))) ';' (AddTo GBP ,6,(- 1));
set c16 = if>0 GBP ,5,(((((GBP ,5 := (intpos 4),(- 1)) ';' ((intpos 4),(- 1) := (intpos 4),0)) ';' ((intpos 4),0 := GBP ,5)) ';' (AddTo GBP ,4,(- 1))) ';' (AddTo GBP ,6,(- 1))),(Load (GBP ,6 := 0));
set c17 = ((GBP ,5 := (intpos 4),(- 1)) ';' (SubFrom GBP ,5,(intpos 4),0)) ';' (if>0 GBP ,5,(((((GBP ,5 := (intpos 4),(- 1)) ';' ((intpos 4),(- 1) := (intpos 4),0)) ';' ((intpos 4),0 := GBP ,5)) ';' (AddTo GBP ,4,(- 1))) ';' (AddTo GBP ,6,(- 1))),(Load (GBP ,6 := 0)));
set c18 = while>0 GBP ,6,(((GBP ,5 := (intpos 4),(- 1)) ';' (SubFrom GBP ,5,(intpos 4),0)) ';' (if>0 GBP ,5,(((((GBP ,5 := (intpos 4),(- 1)) ';' ((intpos 4),(- 1) := (intpos 4),0)) ';' ((intpos 4),0 := GBP ,5)) ';' (AddTo GBP ,4,(- 1))) ';' (AddTo GBP ,6,(- 1))),(Load (GBP ,6 := 0))));
set c19 = (((AddTo GBP ,3,1) ';' (GBP ,4 := GBP ,3)) ';' (AddTo GBP ,1,1)) ';' (GBP ,6 := GBP ,1);
set c20 = ((((AddTo GBP ,3,1) ';' (GBP ,4 := GBP ,3)) ';' (AddTo GBP ,1,1)) ';' (GBP ,6 := GBP ,1)) ';' (while>0 GBP ,6,(((GBP ,5 := (intpos 4),(- 1)) ';' (SubFrom GBP ,5,(intpos 4),0)) ';' (if>0 GBP ,5,(((((GBP ,5 := (intpos 4),(- 1)) ';' ((intpos 4),(- 1) := (intpos 4),0)) ';' ((intpos 4),0 := GBP ,5)) ';' (AddTo GBP ,4,(- 1))) ';' (AddTo GBP ,6,(- 1))),(Load (GBP ,6 := 0)))));
set c21 = for-down GBP ,2,1,(((((AddTo GBP ,3,1) ';' (GBP ,4 := GBP ,3)) ';' (AddTo GBP ,1,1)) ';' (GBP ,6 := GBP ,1)) ';' (while>0 GBP ,6,(((GBP ,5 := (intpos 4),(- 1)) ';' (SubFrom GBP ,5,(intpos 4),0)) ';' (if>0 GBP ,5,(((((GBP ,5 := (intpos 4),(- 1)) ';' ((intpos 4),(- 1) := (intpos 4),0)) ';' ((intpos 4),0 := GBP ,5)) ';' (AddTo GBP ,4,(- 1))) ';' (AddTo GBP ,6,(- 1))),(Load (GBP ,6 := 0))))));
Lemma13:
card (((GBP ,5 := (intpos 4),(- 1)) ';' (SubFrom GBP ,5,(intpos 4),0)) ';' (if>0 GBP ,5,(((((GBP ,5 := (intpos 4),(- 1)) ';' ((intpos 4),(- 1) := (intpos 4),0)) ';' ((intpos 4),0 := GBP ,5)) ';' (AddTo GBP ,4,(- 1))) ';' (AddTo GBP ,6,(- 1))),(Load (GBP ,6 := 0)))) = 10
Lemma14:
card (((((AddTo GBP ,3,1) ';' (GBP ,4 := GBP ,3)) ';' (AddTo GBP ,1,1)) ';' (GBP ,6 := GBP ,1)) ';' (while>0 GBP ,6,(((GBP ,5 := (intpos 4),(- 1)) ';' (SubFrom GBP ,5,(intpos 4),0)) ';' (if>0 GBP ,5,(((((GBP ,5 := (intpos 4),(- 1)) ';' ((intpos 4),(- 1) := (intpos 4),0)) ';' ((intpos 4),0 := GBP ,5)) ';' (AddTo GBP ,4,(- 1))) ';' (AddTo GBP ,6,(- 1))),(Load (GBP ,6 := 0)))))) = 16
set c22 = intpos 1;
set c23 = intpos 2;
set c24 = intpos 3;
set c25 = intpos 4;
set c26 = intpos 5;
set c27 = intpos 6;
Lemma15:
for b1 being State of SCMPDS st b1 . (intpos 4) >= 7 + (b1 . (intpos 6)) & b1 . GBP = 0 & b1 . (intpos 6) > 0 holds
( (IExec (((GBP ,5 := (intpos 4),(- 1)) ';' (SubFrom GBP ,5,(intpos 4),0)) ';' (if>0 GBP ,5,(((((GBP ,5 := (intpos 4),(- 1)) ';' ((intpos 4),(- 1) := (intpos 4),0)) ';' ((intpos 4),0 := GBP ,5)) ';' (AddTo GBP ,4,(- 1))) ';' (AddTo GBP ,6,(- 1))),(Load (GBP ,6 := 0)))),b1) . GBP = 0 & (IExec (((GBP ,5 := (intpos 4),(- 1)) ';' (SubFrom GBP ,5,(intpos 4),0)) ';' (if>0 GBP ,5,(((((GBP ,5 := (intpos 4),(- 1)) ';' ((intpos 4),(- 1) := (intpos 4),0)) ';' ((intpos 4),0 := GBP ,5)) ';' (AddTo GBP ,4,(- 1))) ';' (AddTo GBP ,6,(- 1))),(Load (GBP ,6 := 0)))),b1) . (intpos 1) = b1 . (intpos 1) & (IExec (((GBP ,5 := (intpos 4),(- 1)) ';' (SubFrom GBP ,5,(intpos 4),0)) ';' (if>0 GBP ,5,(((((GBP ,5 := (intpos 4),(- 1)) ';' ((intpos 4),(- 1) := (intpos 4),0)) ';' ((intpos 4),0 := GBP ,5)) ';' (AddTo GBP ,4,(- 1))) ';' (AddTo GBP ,6,(- 1))),(Load (GBP ,6 := 0)))),b1) . (intpos 2) = b1 . (intpos 2) & (IExec (((GBP ,5 := (intpos 4),(- 1)) ';' (SubFrom GBP ,5,(intpos 4),0)) ';' (if>0 GBP ,5,(((((GBP ,5 := (intpos 4),(- 1)) ';' ((intpos 4),(- 1) := (intpos 4),0)) ';' ((intpos 4),0 := GBP ,5)) ';' (AddTo GBP ,4,(- 1))) ';' (AddTo GBP ,6,(- 1))),(Load (GBP ,6 := 0)))),b1) . (intpos 3) = b1 . (intpos 3) & (IExec (((GBP ,5 := (intpos 4),(- 1)) ';' (SubFrom GBP ,5,(intpos 4),0)) ';' (if>0 GBP ,5,(((((GBP ,5 := (intpos 4),(- 1)) ';' ((intpos 4),(- 1) := (intpos 4),0)) ';' ((intpos 4),0 := GBP ,5)) ';' (AddTo GBP ,4,(- 1))) ';' (AddTo GBP ,6,(- 1))),(Load (GBP ,6 := 0)))),b1) . (intpos 6) < b1 . (intpos 6) & (IExec (((GBP ,5 := (intpos 4),(- 1)) ';' (SubFrom GBP ,5,(intpos 4),0)) ';' (if>0 GBP ,5,(((((GBP ,5 := (intpos 4),(- 1)) ';' ((intpos 4),(- 1) := (intpos 4),0)) ';' ((intpos 4),0 := GBP ,5)) ';' (AddTo GBP ,4,(- 1))) ';' (AddTo GBP ,6,(- 1))),(Load (GBP ,6 := 0)))),b1) . (intpos 4) >= 7 + ((IExec (((GBP ,5 := (intpos 4),(- 1)) ';' (SubFrom GBP ,5,(intpos 4),0)) ';' (if>0 GBP ,5,(((((GBP ,5 := (intpos 4),(- 1)) ';' ((intpos 4),(- 1) := (intpos 4),0)) ';' ((intpos 4),0 := GBP ,5)) ';' (AddTo GBP ,4,(- 1))) ';' (AddTo GBP ,6,(- 1))),(Load (GBP ,6 := 0)))),b1) . (intpos 6)) & ( for b2 being Nat st b2 >= 7 & b2 <> (b1 . (intpos 4)) - 1 & b2 <> b1 . (intpos 4) holds
(IExec (((GBP ,5 := (intpos 4),(- 1)) ';' (SubFrom GBP ,5,(intpos 4),0)) ';' (if>0 GBP ,5,(((((GBP ,5 := (intpos 4),(- 1)) ';' ((intpos 4),(- 1) := (intpos 4),0)) ';' ((intpos 4),0 := GBP ,5)) ';' (AddTo GBP ,4,(- 1))) ';' (AddTo GBP ,6,(- 1))),(Load (GBP ,6 := 0)))),b1) . (intpos b2) = b1 . (intpos b2) ) & ( b1 . (DataLoc (b1 . (intpos 4)),(- 1)) > b1 . (DataLoc (b1 . (intpos 4)),0) implies ( (IExec (((GBP ,5 := (intpos 4),(- 1)) ';' (SubFrom GBP ,5,(intpos 4),0)) ';' (if>0 GBP ,5,(((((GBP ,5 := (intpos 4),(- 1)) ';' ((intpos 4),(- 1) := (intpos 4),0)) ';' ((intpos 4),0 := GBP ,5)) ';' (AddTo GBP ,4,(- 1))) ';' (AddTo GBP ,6,(- 1))),(Load (GBP ,6 := 0)))),b1) . (DataLoc (b1 . (intpos 4)),(- 1)) = b1 . (DataLoc (b1 . (intpos 4)),0) & (IExec (((GBP ,5 := (intpos 4),(- 1)) ';' (SubFrom GBP ,5,(intpos 4),0)) ';' (if>0 GBP ,5,(((((GBP ,5 := (intpos 4),(- 1)) ';' ((intpos 4),(- 1) := (intpos 4),0)) ';' ((intpos 4),0 := GBP ,5)) ';' (AddTo GBP ,4,(- 1))) ';' (AddTo GBP ,6,(- 1))),(Load (GBP ,6 := 0)))),b1) . (DataLoc (b1 . (intpos 4)),0) = b1 . (DataLoc (b1 . (intpos 4)),(- 1)) & (IExec (((GBP ,5 := (intpos 4),(- 1)) ';' (SubFrom GBP ,5,(intpos 4),0)) ';' (if>0 GBP ,5,(((((GBP ,5 := (intpos 4),(- 1)) ';' ((intpos 4),(- 1) := (intpos 4),0)) ';' ((intpos 4),0 := GBP ,5)) ';' (AddTo GBP ,4,(- 1))) ';' (AddTo GBP ,6,(- 1))),(Load (GBP ,6 := 0)))),b1) . (intpos 6) = (b1 . (intpos 6)) - 1 & (IExec (((GBP ,5 := (intpos 4),(- 1)) ';' (SubFrom GBP ,5,(intpos 4),0)) ';' (if>0 GBP ,5,(((((GBP ,5 := (intpos 4),(- 1)) ';' ((intpos 4),(- 1) := (intpos 4),0)) ';' ((intpos 4),0 := GBP ,5)) ';' (AddTo GBP ,4,(- 1))) ';' (AddTo GBP ,6,(- 1))),(Load (GBP ,6 := 0)))),b1) . (intpos 4) = (b1 . (intpos 4)) - 1 ) ) & ( b1 . (DataLoc (b1 . (intpos 4)),(- 1)) <= b1 . (DataLoc (b1 . (intpos 4)),0) implies ( (IExec (((GBP ,5 := (intpos 4),(- 1)) ';' (SubFrom GBP ,5,(intpos 4),0)) ';' (if>0 GBP ,5,(((((GBP ,5 := (intpos 4),(- 1)) ';' ((intpos 4),(- 1) := (intpos 4),0)) ';' ((intpos 4),0 := GBP ,5)) ';' (AddTo GBP ,4,(- 1))) ';' (AddTo GBP ,6,(- 1))),(Load (GBP ,6 := 0)))),b1) . (DataLoc (b1 . (intpos 4)),(- 1)) = b1 . (DataLoc (b1 . (intpos 4)),(- 1)) & (IExec (((GBP ,5 := (intpos 4),(- 1)) ';' (SubFrom GBP ,5,(intpos 4),0)) ';' (if>0 GBP ,5,(((((GBP ,5 := (intpos 4),(- 1)) ';' ((intpos 4),(- 1) := (intpos 4),0)) ';' ((intpos 4),0 := GBP ,5)) ';' (AddTo GBP ,4,(- 1))) ';' (AddTo GBP ,6,(- 1))),(Load (GBP ,6 := 0)))),b1) . (DataLoc (b1 . (intpos 4)),0) = b1 . (DataLoc (b1 . (intpos 4)),0) & (IExec (((GBP ,5 := (intpos 4),(- 1)) ';' (SubFrom GBP ,5,(intpos 4),0)) ';' (if>0 GBP ,5,(((((GBP ,5 := (intpos 4),(- 1)) ';' ((intpos 4),(- 1) := (intpos 4),0)) ';' ((intpos 4),0 := GBP ,5)) ';' (AddTo GBP ,4,(- 1))) ';' (AddTo GBP ,6,(- 1))),(Load (GBP ,6 := 0)))),b1) . (intpos 6) = 0 ) ) )
Lemma16:
for b1 being State of SCMPDS st b1 . (intpos 4) >= 7 + (b1 . (DataLoc (b1 . GBP ),6)) & b1 . GBP = 0 holds
( while>0 GBP ,6,(((GBP ,5 := (intpos 4),(- 1)) ';' (SubFrom GBP ,5,(intpos 4),0)) ';' (if>0 GBP ,5,(((((GBP ,5 := (intpos 4),(- 1)) ';' ((intpos 4),(- 1) := (intpos 4),0)) ';' ((intpos 4),0 := GBP ,5)) ';' (AddTo GBP ,4,(- 1))) ';' (AddTo GBP ,6,(- 1))),(Load (GBP ,6 := 0)))) is_closed_on b1 & while>0 GBP ,6,(((GBP ,5 := (intpos 4),(- 1)) ';' (SubFrom GBP ,5,(intpos 4),0)) ';' (if>0 GBP ,5,(((((GBP ,5 := (intpos 4),(- 1)) ';' ((intpos 4),(- 1) := (intpos 4),0)) ';' ((intpos 4),0 := GBP ,5)) ';' (AddTo GBP ,4,(- 1))) ';' (AddTo GBP ,6,(- 1))),(Load (GBP ,6 := 0)))) is_halting_on b1 )
Lemma17:
for b1 being State of SCMPDS st b1 . (intpos 4) >= 7 + (b1 . (DataLoc (b1 . GBP ),6)) & b1 . GBP = 0 holds
( (IExec (while>0 GBP ,6,(((GBP ,5 := (intpos 4),(- 1)) ';' (SubFrom GBP ,5,(intpos 4),0)) ';' (if>0 GBP ,5,(((((GBP ,5 := (intpos 4),(- 1)) ';' ((intpos 4),(- 1) := (intpos 4),0)) ';' ((intpos 4),0 := GBP ,5)) ';' (AddTo GBP ,4,(- 1))) ';' (AddTo GBP ,6,(- 1))),(Load (GBP ,6 := 0))))),b1) . GBP = 0 & (IExec (while>0 GBP ,6,(((GBP ,5 := (intpos 4),(- 1)) ';' (SubFrom GBP ,5,(intpos 4),0)) ';' (if>0 GBP ,5,(((((GBP ,5 := (intpos 4),(- 1)) ';' ((intpos 4),(- 1) := (intpos 4),0)) ';' ((intpos 4),0 := GBP ,5)) ';' (AddTo GBP ,4,(- 1))) ';' (AddTo GBP ,6,(- 1))),(Load (GBP ,6 := 0))))),b1) . (intpos 1) = b1 . (intpos 1) & (IExec (while>0 GBP ,6,(((GBP ,5 := (intpos 4),(- 1)) ';' (SubFrom GBP ,5,(intpos 4),0)) ';' (if>0 GBP ,5,(((((GBP ,5 := (intpos 4),(- 1)) ';' ((intpos 4),(- 1) := (intpos 4),0)) ';' ((intpos 4),0 := GBP ,5)) ';' (AddTo GBP ,4,(- 1))) ';' (AddTo GBP ,6,(- 1))),(Load (GBP ,6 := 0))))),b1) . (intpos 2) = b1 . (intpos 2) & (IExec (while>0 GBP ,6,(((GBP ,5 := (intpos 4),(- 1)) ';' (SubFrom GBP ,5,(intpos 4),0)) ';' (if>0 GBP ,5,(((((GBP ,5 := (intpos 4),(- 1)) ';' ((intpos 4),(- 1) := (intpos 4),0)) ';' ((intpos 4),0 := GBP ,5)) ';' (AddTo GBP ,4,(- 1))) ';' (AddTo GBP ,6,(- 1))),(Load (GBP ,6 := 0))))),b1) . (intpos 3) = b1 . (intpos 3) )
Lemma18:
for b1 being State of SCMPDS st b1 . GBP = 0 holds
( (IExec ((((AddTo GBP ,3,1) ';' (GBP ,4 := GBP ,3)) ';' (AddTo GBP ,1,1)) ';' (GBP ,6 := GBP ,1)),b1) . GBP = 0 & (IExec ((((AddTo GBP ,3,1) ';' (GBP ,4 := GBP ,3)) ';' (AddTo GBP ,1,1)) ';' (GBP ,6 := GBP ,1)),b1) . (intpos 1) = (b1 . (intpos 1)) + 1 & (IExec ((((AddTo GBP ,3,1) ';' (GBP ,4 := GBP ,3)) ';' (AddTo GBP ,1,1)) ';' (GBP ,6 := GBP ,1)),b1) . (intpos 2) = b1 . (intpos 2) & (IExec ((((AddTo GBP ,3,1) ';' (GBP ,4 := GBP ,3)) ';' (AddTo GBP ,1,1)) ';' (GBP ,6 := GBP ,1)),b1) . (intpos 3) = (b1 . (intpos 3)) + 1 & (IExec ((((AddTo GBP ,3,1) ';' (GBP ,4 := GBP ,3)) ';' (AddTo GBP ,1,1)) ';' (GBP ,6 := GBP ,1)),b1) . (intpos 4) = (b1 . (intpos 3)) + 1 & (IExec ((((AddTo GBP ,3,1) ';' (GBP ,4 := GBP ,3)) ';' (AddTo GBP ,1,1)) ';' (GBP ,6 := GBP ,1)),b1) . (intpos 6) = (b1 . (intpos 1)) + 1 & ( for b2 being Nat st b2 >= 7 holds
(IExec ((((AddTo GBP ,3,1) ';' (GBP ,4 := GBP ,3)) ';' (AddTo GBP ,1,1)) ';' (GBP ,6 := GBP ,1)),b1) . (intpos b2) = b1 . (intpos b2) ) )
set c28 = AddTo GBP ,2,(- 1);
set c29 = (((((AddTo GBP ,3,1) ';' (GBP ,4 := GBP ,3)) ';' (AddTo GBP ,1,1)) ';' (GBP ,6 := GBP ,1)) ';' (while>0 GBP ,6,(((GBP ,5 := (intpos 4),(- 1)) ';' (SubFrom GBP ,5,(intpos 4),0)) ';' (if>0 GBP ,5,(((((GBP ,5 := (intpos 4),(- 1)) ';' ((intpos 4),(- 1) := (intpos 4),0)) ';' ((intpos 4),0 := GBP ,5)) ';' (AddTo GBP ,4,(- 1))) ';' (AddTo GBP ,6,(- 1))),(Load (GBP ,6 := 0)))))) ';' (AddTo GBP ,2,(- 1));
Lemma19:
for b1 being State of SCMPDS st b1 . (intpos 3) >= (b1 . (intpos 1)) + 7 & b1 . GBP = 0 holds
( (IExec ((((((AddTo GBP ,3,1) ';' (GBP ,4 := GBP ,3)) ';' (AddTo GBP ,1,1)) ';' (GBP ,6 := GBP ,1)) ';' (while>0 GBP ,6,(((GBP ,5 := (intpos 4),(- 1)) ';' (SubFrom GBP ,5,(intpos 4),0)) ';' (if>0 GBP ,5,(((((GBP ,5 := (intpos 4),(- 1)) ';' ((intpos 4),(- 1) := (intpos 4),0)) ';' ((intpos 4),0 := GBP ,5)) ';' (AddTo GBP ,4,(- 1))) ';' (AddTo GBP ,6,(- 1))),(Load (GBP ,6 := 0)))))) ';' (AddTo GBP ,2,(- 1))),b1) . GBP = 0 & (IExec ((((((AddTo GBP ,3,1) ';' (GBP ,4 := GBP ,3)) ';' (AddTo GBP ,1,1)) ';' (GBP ,6 := GBP ,1)) ';' (while>0 GBP ,6,(((GBP ,5 := (intpos 4),(- 1)) ';' (SubFrom GBP ,5,(intpos 4),0)) ';' (if>0 GBP ,5,(((((GBP ,5 := (intpos 4),(- 1)) ';' ((intpos 4),(- 1) := (intpos 4),0)) ';' ((intpos 4),0 := GBP ,5)) ';' (AddTo GBP ,4,(- 1))) ';' (AddTo GBP ,6,(- 1))),(Load (GBP ,6 := 0)))))) ';' (AddTo GBP ,2,(- 1))),b1) . (intpos 2) = (b1 . (intpos 2)) - 1 & (IExec ((((((AddTo GBP ,3,1) ';' (GBP ,4 := GBP ,3)) ';' (AddTo GBP ,1,1)) ';' (GBP ,6 := GBP ,1)) ';' (while>0 GBP ,6,(((GBP ,5 := (intpos 4),(- 1)) ';' (SubFrom GBP ,5,(intpos 4),0)) ';' (if>0 GBP ,5,(((((GBP ,5 := (intpos 4),(- 1)) ';' ((intpos 4),(- 1) := (intpos 4),0)) ';' ((intpos 4),0 := GBP ,5)) ';' (AddTo GBP ,4,(- 1))) ';' (AddTo GBP ,6,(- 1))),(Load (GBP ,6 := 0)))))) ';' (AddTo GBP ,2,(- 1))),b1) . (intpos 3) = (b1 . (intpos 3)) + 1 & (IExec ((((((AddTo GBP ,3,1) ';' (GBP ,4 := GBP ,3)) ';' (AddTo GBP ,1,1)) ';' (GBP ,6 := GBP ,1)) ';' (while>0 GBP ,6,(((GBP ,5 := (intpos 4),(- 1)) ';' (SubFrom GBP ,5,(intpos 4),0)) ';' (if>0 GBP ,5,(((((GBP ,5 := (intpos 4),(- 1)) ';' ((intpos 4),(- 1) := (intpos 4),0)) ';' ((intpos 4),0 := GBP ,5)) ';' (AddTo GBP ,4,(- 1))) ';' (AddTo GBP ,6,(- 1))),(Load (GBP ,6 := 0)))))) ';' (AddTo GBP ,2,(- 1))),b1) . (intpos 1) = (b1 . (intpos 1)) + 1 & ( for b2 being Nat st b2 <> 2 holds
(IExec ((((((AddTo GBP ,3,1) ';' (GBP ,4 := GBP ,3)) ';' (AddTo GBP ,1,1)) ';' (GBP ,6 := GBP ,1)) ';' (while>0 GBP ,6,(((GBP ,5 := (intpos 4),(- 1)) ';' (SubFrom GBP ,5,(intpos 4),0)) ';' (if>0 GBP ,5,(((((GBP ,5 := (intpos 4),(- 1)) ';' ((intpos 4),(- 1) := (intpos 4),0)) ';' ((intpos 4),0 := GBP ,5)) ';' (AddTo GBP ,4,(- 1))) ';' (AddTo GBP ,6,(- 1))),(Load (GBP ,6 := 0)))))) ';' (AddTo GBP ,2,(- 1))),b1) . (intpos b2) = (IExec (while>0 GBP ,6,(((GBP ,5 := (intpos 4),(- 1)) ';' (SubFrom GBP ,5,(intpos 4),0)) ';' (if>0 GBP ,5,(((((GBP ,5 := (intpos 4),(- 1)) ';' ((intpos 4),(- 1) := (intpos 4),0)) ';' ((intpos 4),0 := GBP ,5)) ';' (AddTo GBP ,4,(- 1))) ';' (AddTo GBP ,6,(- 1))),(Load (GBP ,6 := 0))))),(IExec ((((AddTo GBP ,3,1) ';' (GBP ,4 := GBP ,3)) ';' (AddTo GBP ,1,1)) ';' (GBP ,6 := GBP ,1)),b1)) . (intpos b2) ) )
Lemma20:
for b1 being State of SCMPDS st b1 . (intpos 3) >= (b1 . (intpos 1)) + 7 & b1 . GBP = 0 holds
( for-down GBP ,2,1,(((((AddTo GBP ,3,1) ';' (GBP ,4 := GBP ,3)) ';' (AddTo GBP ,1,1)) ';' (GBP ,6 := GBP ,1)) ';' (while>0 GBP ,6,(((GBP ,5 := (intpos 4),(- 1)) ';' (SubFrom GBP ,5,(intpos 4),0)) ';' (if>0 GBP ,5,(((((GBP ,5 := (intpos 4),(- 1)) ';' ((intpos 4),(- 1) := (intpos 4),0)) ';' ((intpos 4),0 := GBP ,5)) ';' (AddTo GBP ,4,(- 1))) ';' (AddTo GBP ,6,(- 1))),(Load (GBP ,6 := 0)))))) is_closed_on b1 & for-down GBP ,2,1,(((((AddTo GBP ,3,1) ';' (GBP ,4 := GBP ,3)) ';' (AddTo GBP ,1,1)) ';' (GBP ,6 := GBP ,1)) ';' (while>0 GBP ,6,(((GBP ,5 := (intpos 4),(- 1)) ';' (SubFrom GBP ,5,(intpos 4),0)) ';' (if>0 GBP ,5,(((((GBP ,5 := (intpos 4),(- 1)) ';' ((intpos 4),(- 1) := (intpos 4),0)) ';' ((intpos 4),0 := GBP ,5)) ';' (AddTo GBP ,4,(- 1))) ';' (AddTo GBP ,6,(- 1))),(Load (GBP ,6 := 0)))))) is_halting_on b1 )
Lemma21:
for b1 being State of SCMPDS st b1 . (intpos 3) >= (b1 . (intpos 1)) + 7 & b1 . GBP = 0 & b1 . (intpos 2) > 0 holds
IExec (for-down GBP ,2,1,(((((AddTo GBP ,3,1) ';' (GBP ,4 := GBP ,3)) ';' (AddTo GBP ,1,1)) ';' (GBP ,6 := GBP ,1)) ';' (while>0 GBP ,6,(((GBP ,5 := (intpos 4),(- 1)) ';' (SubFrom GBP ,5,(intpos 4),0)) ';' (if>0 GBP ,5,(((((GBP ,5 := (intpos 4),(- 1)) ';' ((intpos 4),(- 1) := (intpos 4),0)) ';' ((intpos 4),0 := GBP ,5)) ';' (AddTo GBP ,4,(- 1))) ';' (AddTo GBP ,6,(- 1))),(Load (GBP ,6 := 0))))))),b1 = IExec (for-down GBP ,2,1,(((((AddTo GBP ,3,1) ';' (GBP ,4 := GBP ,3)) ';' (AddTo GBP ,1,1)) ';' (GBP ,6 := GBP ,1)) ';' (while>0 GBP ,6,(((GBP ,5 := (intpos 4),(- 1)) ';' (SubFrom GBP ,5,(intpos 4),0)) ';' (if>0 GBP ,5,(((((GBP ,5 := (intpos 4),(- 1)) ';' ((intpos 4),(- 1) := (intpos 4),0)) ';' ((intpos 4),0 := GBP ,5)) ';' (AddTo GBP ,4,(- 1))) ';' (AddTo GBP ,6,(- 1))),(Load (GBP ,6 := 0))))))),(IExec ((((((AddTo GBP ,3,1) ';' (GBP ,4 := GBP ,3)) ';' (AddTo GBP ,1,1)) ';' (GBP ,6 := GBP ,1)) ';' (while>0 GBP ,6,(((GBP ,5 := (intpos 4),(- 1)) ';' (SubFrom GBP ,5,(intpos 4),0)) ';' (if>0 GBP ,5,(((((GBP ,5 := (intpos 4),(- 1)) ';' ((intpos 4),(- 1) := (intpos 4),0)) ';' ((intpos 4),0 := GBP ,5)) ';' (AddTo GBP ,4,(- 1))) ';' (AddTo GBP ,6,(- 1))),(Load (GBP ,6 := 0)))))) ';' (AddTo GBP ,2,(- 1))),b1)
theorem Th15: :: SCPISORT:15
theorem Th16: :: SCPISORT:16
Lemma22:
for b1 being State of SCMPDS st b1 . (intpos 4) >= 7 + (b1 . (intpos 6)) & b1 . GBP = 0 & b1 . (intpos 6) > 0 holds
IExec (while>0 GBP ,6,(((GBP ,5 := (intpos 4),(- 1)) ';' (SubFrom GBP ,5,(intpos 4),0)) ';' (if>0 GBP ,5,(((((GBP ,5 := (intpos 4),(- 1)) ';' ((intpos 4),(- 1) := (intpos 4),0)) ';' ((intpos 4),0 := GBP ,5)) ';' (AddTo GBP ,4,(- 1))) ';' (AddTo GBP ,6,(- 1))),(Load (GBP ,6 := 0))))),b1 = IExec (while>0 GBP ,6,(((GBP ,5 := (intpos 4),(- 1)) ';' (SubFrom GBP ,5,(intpos 4),0)) ';' (if>0 GBP ,5,(((((GBP ,5 := (intpos 4),(- 1)) ';' ((intpos 4),(- 1) := (intpos 4),0)) ';' ((intpos 4),0 := GBP ,5)) ';' (AddTo GBP ,4,(- 1))) ';' (AddTo GBP ,6,(- 1))),(Load (GBP ,6 := 0))))),(IExec (((GBP ,5 := (intpos 4),(- 1)) ';' (SubFrom GBP ,5,(intpos 4),0)) ';' (if>0 GBP ,5,(((((GBP ,5 := (intpos 4),(- 1)) ';' ((intpos 4),(- 1) := (intpos 4),0)) ';' ((intpos 4),0 := GBP ,5)) ';' (AddTo GBP ,4,(- 1))) ';' (AddTo GBP ,6,(- 1))),(Load (GBP ,6 := 0)))),b1)
set c30 = while>0 GBP ,6,(((GBP ,5 := (intpos 4),(- 1)) ';' (SubFrom GBP ,5,(intpos 4),0)) ';' (if>0 GBP ,5,(((((GBP ,5 := (intpos 4),(- 1)) ';' ((intpos 4),(- 1) := (intpos 4),0)) ';' ((intpos 4),0 := GBP ,5)) ';' (AddTo GBP ,4,(- 1))) ';' (AddTo GBP ,6,(- 1))),(Load (GBP ,6 := 0))));
theorem Th17: :: SCPISORT:17
for
b1 being
State of
SCMPDS for
b2,
b3 being
FinSequence of
INT for
b4,
b5 being
Nat st
b1 . (intpos 4) >= 7
+ (b1 . (intpos 6)) &
b1 . GBP = 0 &
b5 = b1 . (intpos 6) &
b4 = ((b1 . (intpos 4)) - (b1 . (intpos 6))) - 1 &
b2 is_FinSequence_on b1,
b4 &
b3 is_FinSequence_on IExec (while>0 GBP ,6,(((GBP ,5 := (intpos 4),(- 1)) ';' (SubFrom GBP ,5,(intpos 4),0)) ';' (if>0 GBP ,5,(((((GBP ,5 := (intpos 4),(- 1)) ';' ((intpos 4),(- 1) := (intpos 4),0)) ';' ((intpos 4),0 := GBP ,5)) ';' (AddTo GBP ,4,(- 1))) ';' (AddTo GBP ,6,(- 1))),(Load (GBP ,6 := 0))))),
b1,
b4 &
len b2 = len b3 &
len b2 > b5 &
b2 is_non_decreasing_on 1,
b5 holds
(
b2,
b3 are_fiberwise_equipotent &
b3 is_non_decreasing_on 1,
b5 + 1 & ( for
b6 being
Nat st
b6 > b5 + 1 &
b6 <= len b2 holds
b2 . b6 = b3 . b6 ) & ( for
b6 being
Nat st 1
<= b6 &
b6 <= b5 + 1 holds
ex
b7 being
Nat st
( 1
<= b7 &
b7 <= b5 + 1 &
b3 . b6 = b2 . b7 ) ) )
Lemma24:
for b1 being State of SCMPDS
for b2, b3 being FinSequence of INT
for b4, b5 being Nat st b1 . GBP = 0 & b1 . (intpos 2) = b5 - 1 & b1 . (intpos 3) = b4 + 1 & b1 . (intpos 1) = 0 & b4 >= 6 & b2 is_FinSequence_on b1,b4 & b3 is_FinSequence_on IExec (for-down GBP ,2,1,(((((AddTo GBP ,3,1) ';' (GBP ,4 := GBP ,3)) ';' (AddTo GBP ,1,1)) ';' (GBP ,6 := GBP ,1)) ';' (while>0 GBP ,6,(((GBP ,5 := (intpos 4),(- 1)) ';' (SubFrom GBP ,5,(intpos 4),0)) ';' (if>0 GBP ,5,(((((GBP ,5 := (intpos 4),(- 1)) ';' ((intpos 4),(- 1) := (intpos 4),0)) ';' ((intpos 4),0 := GBP ,5)) ';' (AddTo GBP ,4,(- 1))) ';' (AddTo GBP ,6,(- 1))),(Load (GBP ,6 := 0))))))),b1,b4 & len b2 = b5 & len b3 = b5 holds
( b2,b3 are_fiberwise_equipotent & b3 is_non_decreasing_on 1,b5 )
theorem Th18: :: SCPISORT:18