Article SCPISORT, MML version 4.99.1005
:: SCPISORT:prednot 1 => SCPISORT:pred 1
definition
let a1 be FinSequence of INT;
let a2 be Element of product the Object-Kind of SCMPDS;
let a3 be Element of NAT;
pred A1 is_FinSequence_on A2,A3 means
for b1 being Element of NAT
st 1 <= b1 & b1 <= len a1
holds a1 . b1 = a2 . intpos (a3 + b1);
end;
:: SCPISORT:dfs 1
definiens
let a1 be FinSequence of INT;
let a2 be Element of product the Object-Kind of SCMPDS;
let a3 be Element of NAT;
To prove
a1 is_FinSequence_on a2,a3
it is sufficient to prove
thus for b1 being Element of NAT
st 1 <= b1 & b1 <= len a1
holds a1 . b1 = a2 . intpos (a3 + b1);
:: SCPISORT:def 1
theorem
for b1 being FinSequence of INT
for b2 being Element of product the Object-Kind of SCMPDS
for b3 being Element of NAT holds
b1 is_FinSequence_on b2,b3
iff
for b4 being Element of NAT
st 1 <= b4 & b4 <= len b1
holds b1 . b4 = b2 . intpos (b3 + b4);
:: SCPISORT:th 1
theorem
for b1 being FinSequence of INT
for b2, b3 being Element of NAT
st b3 <= b2
holds b1 is_non_decreasing_on b2,b3;
:: SCPISORT:th 2
theorem
for b1 being Element of product the Object-Kind of SCMPDS
for b2, b3 being Element of NAT holds
ex b4 being FinSequence of INT st
len b4 = b2 &
(for b5 being Element of NAT
st 1 <= b5 & b5 <= len b4
holds b4 . b5 = b1 . intpos (b3 + b5));
:: SCPISORT:th 3
theorem
for b1 being Element of product the Object-Kind of SCMPDS
for b2, b3 being Element of NAT holds
ex b4 being FinSequence of INT st
len b4 = b2 & b4 is_FinSequence_on b1,b3;
:: SCPISORT:th 4
theorem
for b1, b2 being FinSequence of INT
for b3, b4 being Element of NAT
st 1 <= b4 &
b4 <= len b1 &
1 <= b3 &
b3 <= len b1 &
len b1 = len b2 &
b1 . b3 = b2 . b4 &
b1 . b4 = b2 . b3 &
(for b5 being Element of NAT
st b5 <> b3 & b5 <> b4 & 1 <= b5 & b5 <= len b1
holds b1 . b5 = b2 . b5)
holds b1,b2 are_fiberwise_equipotent;
:: SCPISORT:th 5
theorem
for b1, b2 being Element of product the Object-Kind of SCMPDS
st for b3 being Int_position holds
b1 . b3 = b2 . b3
holds Dstate b1 = Dstate b2;
:: SCPISORT:th 6
theorem
for b1 being Element of product the Object-Kind of SCMPDS
for b2 being finite programmed initial No-StopCode Element of sproduct the Object-Kind of SCMPDS
for b3 being shiftable parahalting Element of the Instructions of SCMPDS
st b2 is_closed_on b1 & b2 is_halting_on b1
holds b2 ';' b3 is_closed_on b1 & b2 ';' b3 is_halting_on b1;
:: SCPISORT:th 7
theorem
for b1 being Element of product the Object-Kind of SCMPDS
for b2 being finite programmed initial No-StopCode Element of sproduct the Object-Kind of SCMPDS
for b3 being finite programmed initial parahalting shiftable Element of sproduct the Object-Kind of SCMPDS
for b4 being Int_position
st b2 is_closed_on b1 & b2 is_halting_on b1
holds (IExec(b2 ';' b3,b1)) . b4 = (IExec(b3,IExec(b2,b1))) . b4;
:: SCPISORT:th 8
theorem
for b1 being Element of product the Object-Kind of SCMPDS
for b2 being finite programmed initial parahalting No-StopCode Element of sproduct the Object-Kind of SCMPDS
for b3 being finite programmed initial shiftable Element of sproduct the Object-Kind of SCMPDS
for b4 being Int_position
st b3 is_closed_on IExec(b2,b1) & b3 is_halting_on IExec(b2,b1)
holds (IExec(b2 ';' b3,b1)) . b4 = (IExec(b3,IExec(b2,b1))) . b4;
:: SCPISORT:th 9
theorem
for b1 being Element of product the Object-Kind of SCMPDS
for b2 being finite programmed initial Element of sproduct the Object-Kind of SCMPDS
for b3 being finite programmed initial parahalting shiftable Element of sproduct the Object-Kind of SCMPDS
st b2 is_closed_on b1 & b2 is_halting_on b1
holds b2 ';' b3 is_closed_on b1 & b2 ';' b3 is_halting_on b1;
:: SCPISORT:th 10
theorem
for b1 being Element of product the Object-Kind of SCMPDS
for b2 being finite programmed initial parahalting Element of sproduct the Object-Kind of SCMPDS
for b3 being finite programmed initial shiftable Element of sproduct the Object-Kind of SCMPDS
st b3 is_closed_on IExec(b2,b1) & b3 is_halting_on IExec(b2,b1)
holds b2 ';' b3 is_closed_on b1 & b2 ';' b3 is_halting_on b1;
:: SCPISORT:th 11
theorem
for b1 being Element of product the Object-Kind of SCMPDS
for b2 being finite programmed initial Element of sproduct the Object-Kind of SCMPDS
for b3 being shiftable parahalting Element of the Instructions of SCMPDS
st b2 is_closed_on b1 & b2 is_halting_on b1
holds b2 ';' b3 is_closed_on b1 & b2 ';' b3 is_halting_on b1;
:: SCPISORT:sch 1
scheme SCPISORT:sch 1
{F1 -> Element of product the Object-Kind of SCMPDS,
F2 -> finite programmed initial shiftable No-StopCode Element of sproduct the Object-Kind of SCMPDS,
F3 -> Int_position,
F4 -> integer set,
F5 -> Element of NAT}:
(not (P1[F1()]) implies not (P1[F1()])) & for-down(F3(),F4(),F5(),F2()) is_closed_on F1() & for-down(F3(),F4(),F5(),F2()) is_halting_on F1()
provided
0 < F5()
and
P1[Dstate F1()]
and
for b1 being Element of product the Object-Kind of SCMPDS
st P1[Dstate b1] & b1 . F3() = F1() . F3() & 0 < b1 . DataLoc(F1() . F3(),F4())
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)];
:: SCPISORT:sch 2
scheme SCPISORT:sch 2
{F1 -> Element of product the Object-Kind of SCMPDS,
F2 -> finite programmed initial shiftable No-StopCode Element of sproduct the Object-Kind of SCMPDS,
F3 -> Int_position,
F4 -> integer set,
F5 -> Element of NAT}:
(not (P1[F1()]) implies 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
0 < F5()
and
0 < F1() . DataLoc(F1() . F3(),F4())
and
P1[Dstate F1()]
and
for b1 being Element of product the Object-Kind of SCMPDS
st P1[Dstate b1] & b1 . F3() = F1() . F3() & 0 < b1 . DataLoc(F1() . F3(),F4())
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)];
:: SCPISORT:sch 3
scheme SCPISORT:sch 3
{F1 -> Element of product the Object-Kind of SCMPDS,
F2 -> finite programmed initial shiftable No-StopCode Element of sproduct the Object-Kind of SCMPDS,
F3 -> Int_position,
F4 -> integer set,
F5 -> Element of NAT}:
(not (P1[F1()]) implies not (P1[F1()])) &
(IExec(for-down(F3(),F4(),F5(),F2()),F1())) . DataLoc(F1() . F3(),F4()) <= 0 &
P1[Dstate IExec(for-down(F3(),F4(),F5(),F2()),F1())]
provided
0 < F5()
and
P1[Dstate F1()]
and
for b1 being Element of product the Object-Kind of SCMPDS
st P1[Dstate b1] & b1 . F3() = F1() . F3() & 0 < b1 . DataLoc(F1() . F3(),F4())
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)];
:: SCPISORT:th 12
theorem
for b1 being Element of product the Object-Kind of SCMPDS
for b2 being finite programmed initial shiftable No-StopCode Element of sproduct the Object-Kind of SCMPDS
for b3, b4, b5 being Int_position
for b6, b7 being integer set
for b8 being Element of NAT
st 0 < b8 &
(b1 . b5) + b7 <= b1 . b4 &
(for b9 being Element of product the Object-Kind of SCMPDS
st (b9 . b5) + b7 <= b9 . b4 &
b9 . b3 = b1 . b3 &
0 < b9 . DataLoc(b1 . b3,b6)
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)) . b5) + b7 <= (IExec(b2 ';' AddTo(b3,b6,- b8),b9)) . b4)
holds for-down(b3,b6,b8,b2) is_closed_on b1 & for-down(b3,b6,b8,b2) is_halting_on b1;
:: SCPISORT:th 13
theorem
for b1 being Element of product the Object-Kind of SCMPDS
for b2 being finite programmed initial shiftable No-StopCode Element of sproduct the Object-Kind of SCMPDS
for b3, b4, b5 being Int_position
for b6, b7 being integer set
for b8 being Element of NAT
st 0 < b8 &
(b1 . b5) + b7 <= b1 . b4 &
0 < b1 . DataLoc(b1 . b3,b6) &
(for b9 being Element of product the Object-Kind of SCMPDS
st (b9 . b5) + b7 <= b9 . b4 &
b9 . b3 = b1 . b3 &
0 < b9 . DataLoc(b1 . b3,b6)
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)) . b5) + b7 <= (IExec(b2 ';' AddTo(b3,b6,- b8),b9)) . b4)
holds IExec(for-down(b3,b6,b8,b2),b1) = IExec(for-down(b3,b6,b8,b2),IExec(b2 ';' AddTo(b3,b6,- b8),b1));
:: SCPISORT:th 14
theorem
for b1 being Element of product the Object-Kind of SCMPDS
for b2 being finite programmed initial shiftable No-StopCode Element of sproduct the Object-Kind of SCMPDS
for b3 being Int_position
for b4 being integer set
for b5 being Element of NAT
st 0 < b1 . DataLoc(b1 . b3,b4) &
0 < b5 &
0 < card b2 &
b3 <> DataLoc(b1 . b3,b4) &
(for b6 being Element of product the Object-Kind 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;
:: SCPISORT:funcnot 1 => SCPISORT:func 1
definition
let a1, a2 be Element of NAT;
func insert-sort(A1,A2) -> finite programmed initial Element of sproduct the Object-Kind of SCMPDS equals
((((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))));
end;
:: SCPISORT:def 2
theorem
for b1, b2 being Element of 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))));
:: SCPISORT:th 15
theorem
for b1, b2 being Element of NAT holds
card insert-sort(b1,b2) = 23;
:: SCPISORT:th 16
theorem
for b1, b2 being Element of NAT
st 7 <= b1
holds insert-sort(b2,b1) is parahalting;
:: SCPISORT:th 17
theorem
for b1 being Element of product the Object-Kind of SCMPDS
for b2, b3 being FinSequence of INT
for b4, b5 being Element of NAT
st 7 + (b1 . intpos 6) <= b1 . intpos 4 &
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 &
b5 < len b2 &
b2 is_non_decreasing_on 1,b5
holds b2,b3 are_fiberwise_equipotent &
b3 is_non_decreasing_on 1,b5 + 1 &
(for b6 being Element of NAT
st b5 + 1 < b6 & b6 <= len b2
holds b2 . b6 = b3 . b6) &
(for b6 being Element of NAT
st 1 <= b6 & b6 <= b5 + 1
holds ex b7 being Element of NAT st
1 <= b7 & b7 <= b5 + 1 & b3 . b6 = b2 . b7);
:: SCPISORT:th 18
theorem
for b1 being Element of product the Object-Kind of SCMPDS
for b2, b3 being FinSequence of INT
for b4, b5 being Element of NAT
st 6 <= b4 &
len b2 = b5 &
len b3 = b5 &
b2 is_FinSequence_on b1,b4 &
b3 is_FinSequence_on IExec(insert-sort(b5,b4 + 1),b1),b4
holds b2,b3 are_fiberwise_equipotent & b3 is_non_decreasing_on 1,b5;