Article SCMISORT, MML version 4.99.1005
:: SCMISORT:funcreg 1
registration
let a1 be good Element of the Instructions of SCM+FSA;
cluster Macro a1 -> finite programmed initial good;
end;
:: SCMISORT:funcreg 2
registration
let a1 be read-write Int-Location;
let a2 be Int-Location;
cluster AddTo(a1,a2) -> good;
end;
:: SCMISORT:th 2
theorem
for b1 being finite programmed Element of sproduct the Object-Kind of SCM+FSA
for b2 being Instruction-Location of SCM+FSA
for b3 being Element of the Instructions of SCM+FSA
st b2 in proj1 b1 &
(ex b4 being Element of the Instructions of SCM+FSA st
b4 = b1 . b2 & UsedIntLoc b4 = UsedIntLoc b3)
holds UsedIntLoc b1 = UsedIntLoc (b1 +* (b2 .--> b3));
:: SCMISORT:th 3
theorem
for b1 being Int-Location
for b2 being finite programmed initial Element of sproduct the Object-Kind of SCM+FSA holds
(if>0(b1,b2 ';' Goto insloc 0,SCM+FSA-Stop)) . ((card b2) + 4) = goto insloc ((card b2) + 4);
:: SCMISORT:th 4
theorem
for b1 being finite programmed Element of sproduct the Object-Kind of SCM+FSA
for b2 being Instruction-Location of SCM+FSA
for b3 being Element of the Instructions of SCM+FSA
st b2 in proj1 b1 &
(ex b4 being Element of the Instructions of SCM+FSA st
b4 = b1 . b2 & UsedInt*Loc b4 = UsedInt*Loc b3)
holds UsedInt*Loc b1 = UsedInt*Loc (b1 +* (b2 .--> b3));
:: SCMISORT:th 6
theorem
for b1 being Element of product the Object-Kind of SCM+FSA
for b2 being finite programmed initial Element of sproduct the Object-Kind of SCM+FSA
st b1 . intloc 0 = 1 & IC b1 = insloc 0
holds b1 +* b2 = b1 +* Initialized b2;
:: SCMISORT:th 7
theorem
for b1 being finite programmed initial Element of sproduct the Object-Kind of SCM+FSA
for b2, b3 being Int-Location
st b1 does_not_destroy b3
holds while>0(b2,b1) does_not_destroy b3;
:: SCMISORT:th 10
theorem
for b1 being Element of product the Object-Kind of SCM+FSA
for b2 being finite programmed initial Element of sproduct the Object-Kind of SCM+FSA
st b2 is_halting_on Initialize b1
for b3 being Int-Location holds
(IExec(b2,b1)) . b3 = (Computation((Initialize b1) +* (b2 +* Start-At insloc 0),LifeSpan ((Initialize b1) +* (b2 +* Start-At insloc 0)))) . b3;
:: SCMISORT:th 11
theorem
for b1, b2 being Element of product the Object-Kind of SCM+FSA
for b3 being finite programmed initial InitHalting Element of sproduct the Object-Kind of SCM+FSA
st Initialized b3 c= b1 & Initialized b3 c= b2 & b1,b2 equal_outside NAT
for b4 being Element of NAT holds
Computation(b1,b4),Computation(b2,b4) equal_outside NAT & CurInstr Computation(b1,b4) = CurInstr Computation(b2,b4);
:: SCMISORT:th 12
theorem
for b1, b2 being Element of product the Object-Kind of SCM+FSA
for b3 being finite programmed initial InitHalting Element of sproduct the Object-Kind of SCM+FSA
st Initialized b3 c= b1 & Initialized b3 c= b2 & b1,b2 equal_outside NAT
holds LifeSpan b1 = LifeSpan b2 & Result b1,Result b2 equal_outside NAT;
:: SCMISORT:th 13
theorem
for b1 being finite programmed initial Element of sproduct the Object-Kind of SCM+FSA
for b2 being FinSeq-Location holds
not b2 in proj1 b1;
:: SCMISORT:th 14
theorem
for b1 being finite programmed initial Element of sproduct the Object-Kind of SCM+FSA
for b2 being Int-Location holds
not b2 in proj1 b1;
:: SCMISORT:th 16
theorem
for b1 being Element of product the Object-Kind of SCM+FSA
for b2 being finite programmed initial Element of sproduct the Object-Kind of SCM+FSA
for b3 being read-write Int-Location
st b1 . b3 <= 0
holds while>0(b3,b2) is_halting_onInit b1 & while>0(b3,b2) is_closed_onInit b1;
:: SCMISORT:th 17
theorem
for b1 being Int-Location
for b2 being finite programmed initial Element of sproduct the Object-Kind of SCM+FSA
for b3 being Element of product the Object-Kind of SCM+FSA
for b4 being Element of NAT
st b2 is_closed_onInit b3 &
b2 is_halting_onInit b3 &
b4 < LifeSpan (b3 +* Initialized b2) &
IC Computation(b3 +* Initialized while>0(b1,b2),1 + b4) = (IC Computation(b3 +* Initialized b2,b4)) + 4 &
(Computation(b3 +* Initialized while>0(b1,b2),1 + b4)) | (Int-Locations \/ FinSeq-Locations) = (Computation(b3 +* Initialized b2,b4)) | (Int-Locations \/ FinSeq-Locations)
holds IC Computation(b3 +* Initialized while>0(b1,b2),(1 + b4) + 1) = (IC Computation(b3 +* Initialized b2,b4 + 1)) + 4 &
(Computation(b3 +* Initialized while>0(b1,b2),(1 + b4) + 1)) | (Int-Locations \/ FinSeq-Locations) = (Computation(b3 +* Initialized b2,b4 + 1)) | (Int-Locations \/ FinSeq-Locations);
:: SCMISORT:th 18
theorem
for b1 being Int-Location
for b2 being finite programmed initial Element of sproduct the Object-Kind of SCM+FSA
for b3 being Element of product the Object-Kind of SCM+FSA
st b2 is_closed_onInit b3 &
b2 is_halting_onInit b3 &
IC Computation(b3 +* Initialized while>0(b1,b2),1 + LifeSpan (b3 +* Initialized b2)) = (IC Computation(b3 +* Initialized b2,LifeSpan (b3 +* Initialized b2))) + 4
holds CurInstr Computation(b3 +* Initialized while>0(b1,b2),1 + LifeSpan (b3 +* Initialized b2)) = goto insloc ((card b2) + 4);
:: SCMISORT:th 19
theorem
for b1 being Element of product the Object-Kind of SCM+FSA
for b2 being finite programmed initial Element of sproduct the Object-Kind of SCM+FSA
for b3 being read-write Int-Location
st b2 is_closed_onInit b1 & b2 is_halting_onInit b1 & 0 < b1 . b3
holds IC Computation(b1 +* Initialized while>0(b3,b2),(LifeSpan (b1 +* Initialized b2)) + 3) = insloc 0 &
(for b4 being Element of NAT
st b4 <= (LifeSpan (b1 +* Initialized b2)) + 3
holds IC Computation(b1 +* Initialized while>0(b3,b2),b4) in proj1 while>0(b3,b2));
:: SCMISORT:th 20
theorem
for b1 being Element of product the Object-Kind of SCM+FSA
for b2 being finite programmed initial Element of sproduct the Object-Kind of SCM+FSA
for b3 being read-write Int-Location
st b2 is_closed_onInit b1 & b2 is_halting_onInit b1 & 0 < b1 . b3
for b4 being Element of NAT
st b4 <= (LifeSpan (b1 +* Initialized b2)) + 3
holds IC Computation(b1 +* Initialized while>0(b3,b2),b4) in proj1 while>0(b3,b2);
:: SCMISORT:th 21
theorem
for b1 being Element of product the Object-Kind of SCM+FSA
for b2 being finite programmed initial Element of sproduct the Object-Kind of SCM+FSA
for b3 being read-write Int-Location
st b2 is_closed_onInit b1 & b2 is_halting_onInit b1 & 0 < b1 . b3
holds IC Computation(b1 +* Initialized while>0(b3,b2),(LifeSpan (b1 +* Initialized b2)) + 3) = insloc 0 &
(Computation(b1 +* Initialized while>0(b3,b2),(LifeSpan (b1 +* Initialized b2)) + 3)) | (Int-Locations \/ FinSeq-Locations) = (Computation(b1 +* Initialized b2,LifeSpan (b1 +* Initialized b2))) | (Int-Locations \/ FinSeq-Locations);
:: SCMISORT:th 22
theorem
for b1 being Element of product the Object-Kind of SCM+FSA
for b2 being finite programmed initial InitHalting Element of sproduct the Object-Kind of SCM+FSA
for b3 being read-write Int-Location
st 0 < b1 . b3
holds ex b4 being Element of product the Object-Kind of SCM+FSA st
ex b5 being Element of NAT st
b4 = b1 +* Initialized while>0(b3,b2) &
b5 = (LifeSpan (b1 +* Initialized b2)) + 3 &
IC Computation(b4,b5) = insloc 0 &
(for b6 being Int-Location holds
(Computation(b4,b5)) . b6 = (IExec(b2,b1)) . b6) &
(for b6 being FinSeq-Location holds
(Computation(b4,b5)) . b6 = (IExec(b2,b1)) . b6);
:: SCMISORT:funcnot 1 => SCMISORT:func 1
definition
let a1 be Element of product the Object-Kind of SCM+FSA;
let a2 be finite programmed initial Element of sproduct the Object-Kind of SCM+FSA;
let a3 be read-write Int-Location;
func StepWhile>0(A3,A1,A2) -> Function-like quasi_total Relation of NAT,product the Object-Kind of SCM+FSA means
it . 0 = a1 &
(for b1 being natural set holds
it . (b1 + 1) = Computation((it . b1) +* Initialized while>0(a3,a2),(LifeSpan ((it . b1) +* Initialized a2)) + 3));
end;
:: SCMISORT:def 1
theorem
for b1 being Element of product the Object-Kind of SCM+FSA
for b2 being finite programmed initial Element of sproduct the Object-Kind of SCM+FSA
for b3 being read-write Int-Location
for b4 being Function-like quasi_total Relation of NAT,product the Object-Kind of SCM+FSA holds
b4 = StepWhile>0(b3,b1,b2)
iff
b4 . 0 = b1 &
(for b5 being natural set holds
b4 . (b5 + 1) = Computation((b4 . b5) +* Initialized while>0(b3,b2),(LifeSpan ((b4 . b5) +* Initialized b2)) + 3));
:: SCMISORT:th 25
theorem
for b1 being Element of product the Object-Kind of SCM+FSA
for b2 being finite programmed initial Element of sproduct the Object-Kind of SCM+FSA
for b3 being read-write Int-Location
for b4 being Element of NAT holds
(StepWhile>0(b3,b1,b2)) . (b4 + 1) = (StepWhile>0(b3,(StepWhile>0(b3,b1,b2)) . b4,b2)) . 1;
:: SCMISORT:th 26
theorem
for b1 being finite programmed initial Element of sproduct the Object-Kind of SCM+FSA
for b2 being read-write Int-Location
for b3 being Element of product the Object-Kind of SCM+FSA holds
(StepWhile>0(b2,b3,b1)) . (0 + 1) = Computation(b3 +* Initialized while>0(b2,b1),(LifeSpan (b3 +* Initialized b1)) + 3);
:: SCMISORT:th 27
theorem
for b1 being finite programmed initial Element of sproduct the Object-Kind of SCM+FSA
for b2 being read-write Int-Location
for b3 being Element of product the Object-Kind of SCM+FSA
for b4, b5 being Element of NAT
st IC ((StepWhile>0(b2,b3,b1)) . b4) = insloc 0 &
(StepWhile>0(b2,b3,b1)) . b4 = Computation(b3 +* Initialized while>0(b2,b1),b5) &
((StepWhile>0(b2,b3,b1)) . b4) . intloc 0 = 1
holds (StepWhile>0(b2,b3,b1)) . b4 = ((StepWhile>0(b2,b3,b1)) . b4) +* Initialized while>0(b2,b1) &
(StepWhile>0(b2,b3,b1)) . (b4 + 1) = Computation(b3 +* Initialized while>0(b2,b1),b5 + ((LifeSpan (((StepWhile>0(b2,b3,b1)) . b4) +* Initialized b1)) + 3));
:: SCMISORT:th 28
theorem
for b1 being finite programmed initial Element of sproduct the Object-Kind of SCM+FSA
for b2 being read-write Int-Location
for b3 being Element of product the Object-Kind of SCM+FSA
st ex b4 being Function-like quasi_total Relation of product the Object-Kind of SCM+FSA,NAT st
for b5 being Element of NAT holds
(b4 . ((StepWhile>0(b2,b3,b1)) . b5) = 0 or b4 . ((StepWhile>0(b2,b3,b1)) . (b5 + 1)) < b4 . ((StepWhile>0(b2,b3,b1)) . b5) &
b1 is_closed_onInit (StepWhile>0(b2,b3,b1)) . b5 &
b1 is_halting_onInit (StepWhile>0(b2,b3,b1)) . b5) &
((StepWhile>0(b2,b3,b1)) . (b5 + 1)) . intloc 0 = 1 &
(b4 . ((StepWhile>0(b2,b3,b1)) . b5) = 0 implies ((StepWhile>0(b2,b3,b1)) . b5) . b2 <= 0) &
(((StepWhile>0(b2,b3,b1)) . b5) . b2 <= 0 implies b4 . ((StepWhile>0(b2,b3,b1)) . b5) = 0)
holds while>0(b2,b1) is_halting_onInit b3 & while>0(b2,b1) is_closed_onInit b3;
:: SCMISORT:th 29
theorem
for b1 being finite programmed initial good InitHalting Element of sproduct the Object-Kind of SCM+FSA
for b2 being read-write Int-Location
st for b3 being Element of product the Object-Kind of SCM+FSA
st 0 < b3 . b2
holds (IExec(b1,b3)) . b2 < b3 . b2
holds while>0(b2,b1) is InitHalting;
:: SCMISORT:th 30
theorem
for b1 being finite programmed initial good InitHalting Element of sproduct the Object-Kind of SCM+FSA
for b2 being read-write Int-Location
st for b3 being Element of product the Object-Kind of SCM+FSA
st b3 . b2 <= (IExec(b1,b3)) . b2
holds (IExec(b1,b3)) . b2 <= 0
holds while>0(b2,b1) is InitHalting;
:: SCMISORT:th 31
theorem
for b1 being finite programmed initial good InitHalting Element of sproduct the Object-Kind of SCM+FSA
for b2 being read-write Int-Location
st ex b3 being Function-like quasi_total Relation of product the Object-Kind of SCM+FSA,INT st
for b4, b5 being Element of product the Object-Kind of SCM+FSA holds
(0 < b3 . b4 implies b3 . IExec(b1,b4) < b3 . b4) &
(b4 | (Int-Locations \/ FinSeq-Locations) = b5 | (Int-Locations \/ FinSeq-Locations) implies b3 . b4 = b3 . b5) &
(b3 . b4 <= 0 implies b4 . b2 <= 0) &
(b4 . b2 <= 0 implies b3 . b4 <= 0)
holds while>0(b2,b1) is InitHalting;
:: SCMISORT:th 32
theorem
for b1 being Element of product the Object-Kind of SCM+FSA
for b2 being finite programmed initial Element of sproduct the Object-Kind of SCM+FSA
for b3 being read-write Int-Location
st b1 . b3 <= 0
holds (IExec(while>0(b3,b2),b1)) | (Int-Locations \/ FinSeq-Locations) = (Initialize b1) | (Int-Locations \/ FinSeq-Locations);
:: SCMISORT:th 33
theorem
for b1 being Element of product the Object-Kind of SCM+FSA
for b2 being finite programmed initial good InitHalting Element of sproduct the Object-Kind of SCM+FSA
for b3 being read-write Int-Location
st 0 < b1 . b3 & while>0(b3,b2) is InitHalting
holds (IExec(while>0(b3,b2),b1)) | (Int-Locations \/ FinSeq-Locations) = (IExec(while>0(b3,b2),IExec(b2,b1))) | (Int-Locations \/ FinSeq-Locations);
:: SCMISORT:th 34
theorem
for b1 being Element of product the Object-Kind of SCM+FSA
for b2 being finite programmed initial Element of sproduct the Object-Kind of SCM+FSA
for b3 being FinSeq-Location
for b4 being read-write Int-Location
st b1 . b4 <= 0
holds (IExec(while>0(b4,b2),b1)) . b3 = b1 . b3;
:: SCMISORT:th 35
theorem
for b1 being Element of product the Object-Kind of SCM+FSA
for b2 being finite programmed initial Element of sproduct the Object-Kind of SCM+FSA
for b3 being Int-Location
for b4 being read-write Int-Location
st b1 . b4 <= 0
holds (IExec(while>0(b4,b2),b1)) . b3 = (Initialize b1) . b3;
:: SCMISORT:th 36
theorem
for b1 being Element of product the Object-Kind of SCM+FSA
for b2 being finite programmed initial good InitHalting Element of sproduct the Object-Kind of SCM+FSA
for b3 being FinSeq-Location
for b4 being read-write Int-Location
st 0 < b1 . b4 & while>0(b4,b2) is InitHalting
holds (IExec(while>0(b4,b2),b1)) . b3 = (IExec(while>0(b4,b2),IExec(b2,b1))) . b3;
:: SCMISORT:th 37
theorem
for b1 being Element of product the Object-Kind of SCM+FSA
for b2 being finite programmed initial good InitHalting Element of sproduct the Object-Kind of SCM+FSA
for b3 being Int-Location
for b4 being read-write Int-Location
st 0 < b1 . b4 & while>0(b4,b2) is InitHalting
holds (IExec(while>0(b4,b2),b1)) . b3 = (IExec(while>0(b4,b2),IExec(b2,b1))) . b3;
:: SCMISORT:funcnot 2 => SCMISORT:func 2
definition
let a1 be FinSeq-Location;
func insert-sort A1 -> finite programmed initial Element of sproduct the Object-Kind of SCM+FSA equals
((((((((intloc 2) := intloc 0) ';' ((intloc 3) := intloc 0)) ';' ((intloc 4) := intloc 0)) ';' ((intloc 5) := intloc 0)) ';' ((intloc 6) := intloc 0)) ';' ((intloc 1) :=len a1)) ';' SubFrom(intloc 1,intloc 0)) ';' Times(intloc 1,((((((((intloc 2) :=len a1) ';' SubFrom(intloc 2,intloc 1)) ';' ((intloc 3) := intloc 2)) ';' AddTo(intloc 3,intloc 0)) ';' ((intloc 6) :=(a1,intloc 3))) ';' SubFrom(intloc 4,intloc 4)) ';' while>0(intloc 2,(((intloc 5) :=(a1,intloc 2)) ';' SubFrom(intloc 5,intloc 6)) ';' if>0(intloc 5,Macro SubFrom(intloc 2,intloc 2),(AddTo(intloc 4,intloc 0)) ';' SubFrom(intloc 2,intloc 0)))) ';' Times(intloc 4,((((((intloc 2) := intloc 3) ';' SubFrom(intloc 3,intloc 0)) ';' ((intloc 5) :=(a1,intloc 2))) ';' ((intloc 6) :=(a1,intloc 3))) ';' ((a1,intloc 2):= intloc 6)) ';' ((a1,intloc 3):= intloc 5)));
end;
:: SCMISORT:def 2
theorem
for b1 being FinSeq-Location holds
insert-sort b1 = ((((((((intloc 2) := intloc 0) ';' ((intloc 3) := intloc 0)) ';' ((intloc 4) := intloc 0)) ';' ((intloc 5) := intloc 0)) ';' ((intloc 6) := intloc 0)) ';' ((intloc 1) :=len b1)) ';' SubFrom(intloc 1,intloc 0)) ';' Times(intloc 1,((((((((intloc 2) :=len b1) ';' SubFrom(intloc 2,intloc 1)) ';' ((intloc 3) := intloc 2)) ';' AddTo(intloc 3,intloc 0)) ';' ((intloc 6) :=(b1,intloc 3))) ';' SubFrom(intloc 4,intloc 4)) ';' while>0(intloc 2,(((intloc 5) :=(b1,intloc 2)) ';' SubFrom(intloc 5,intloc 6)) ';' if>0(intloc 5,Macro SubFrom(intloc 2,intloc 2),(AddTo(intloc 4,intloc 0)) ';' SubFrom(intloc 2,intloc 0)))) ';' Times(intloc 4,((((((intloc 2) := intloc 3) ';' SubFrom(intloc 3,intloc 0)) ';' ((intloc 5) :=(b1,intloc 2))) ';' ((intloc 6) :=(b1,intloc 3))) ';' ((b1,intloc 2):= intloc 6)) ';' ((b1,intloc 3):= intloc 5)));
:: SCMISORT:funcnot 3 => SCMISORT:func 3
definition
func Insert-Sort-Algorithm -> finite programmed initial Element of sproduct the Object-Kind of SCM+FSA equals
insert-sort fsloc 0;
end;
:: SCMISORT:def 3
theorem
Insert-Sort-Algorithm = insert-sort fsloc 0;
:: SCMISORT:th 38
theorem
for b1 being FinSeq-Location holds
UsedIntLoc insert-sort b1 = {intloc 0,intloc 1,intloc 2,intloc 3,intloc 4,intloc 5,intloc 6};
:: SCMISORT:th 39
theorem
for b1 being FinSeq-Location holds
UsedInt*Loc insert-sort b1 = {b1};
:: SCMISORT:th 40
theorem
for b1, b2, b3, b4 being Element of the Instructions of SCM+FSA holds
card (((b1 ';' b2) ';' b3) ';' b4) = 8;
:: SCMISORT:th 41
theorem
for b1, b2, b3, b4, b5 being Element of the Instructions of SCM+FSA holds
card ((((b1 ';' b2) ';' b3) ';' b4) ';' b5) = 10;
:: SCMISORT:th 42
theorem
for b1 being FinSeq-Location holds
card insert-sort b1 = 82;
:: SCMISORT:th 43
theorem
for b1 being FinSeq-Location
for b2 being Element of NAT
st b2 < 82
holds insloc b2 in proj1 insert-sort b1;
:: SCMISORT:th 44
theorem
insert-sort fsloc 0 is keepInt0_1 & insert-sort fsloc 0 is InitHalting;
:: SCMISORT:th 45
theorem
for b1 being Element of product the Object-Kind of SCM+FSA holds
b1 . fsloc 0,(IExec(insert-sort fsloc 0,b1)) . fsloc 0 are_fiberwise_equipotent &
(for b2, b3 being Element of NAT
st 1 <= b2 & b3 <= len (b1 . fsloc 0) & b2 < b3
for b4, b5 being integer set
st b4 = ((IExec(insert-sort fsloc 0,b1)) . fsloc 0) . b2 &
b5 = ((IExec(insert-sort fsloc 0,b1)) . fsloc 0) . b3
holds b5 <= b4);
:: SCMISORT:th 46
theorem
for b1 being Element of NAT
for b2 being Element of product the Object-Kind of SCM+FSA
for b3 being FinSequence of INT
st (Initialized Insert-Sort-Algorithm) +* ((fsloc 0) .--> b3) c= b2
holds IC Computation(b2,b1) in proj1 Insert-Sort-Algorithm;
:: SCMISORT:th 47
theorem
for b1 being Element of product the Object-Kind of SCM+FSA
for b2 being FinSequence of INT
st (Initialized Insert-Sort-Algorithm) +* ((fsloc 0) .--> b2) c= b1
holds ex b3 being FinSequence of REAL st
b2,b3 are_fiberwise_equipotent & b3 is non-increasing & b3 is FinSequence of INT & (Result b1) . fsloc 0 = b3;
:: SCMISORT:th 48
theorem
for b1 being FinSequence of INT holds
(Initialized Insert-Sort-Algorithm) +* ((fsloc 0) .--> b1) is autonomic(NAT, {INT,INT *}, SCM+FSA);
:: SCMISORT:th 49
theorem
Initialized Insert-Sort-Algorithm computes Sorting-Function;