Article SCMBSORT, MML version 4.99.1005
:: SCMBSORT:th 3
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 & b2 <> b3
holds Times(b2,b1) does_not_destroy b3;
:: SCMBSORT:th 8
theorem
for b1 being Element of product the Object-Kind of SCM+FSA
for b2 being FinSeq-Location
for b3, b4 being Int-Location holds
(Exec(b4 :=(b2,b3),b1)) . b4 = (b1 . b2) /. abs (b1 . b3);
:: SCMBSORT:th 9
theorem
for b1 being Element of product the Object-Kind of SCM+FSA
for b2 being FinSeq-Location
for b3, b4 being Int-Location holds
(Exec((b2,b3):= b4,b1)) . b2 = (b1 . b2) +*(abs (b1 . b3),b1 . b4);
:: SCMBSORT:th 10
theorem
for b1 being Element of product the Object-Kind of SCM+FSA
for b2 being FinSeq-Location
for b3, b4 being Element of NAT
for b5 being Int-Location
st b3 <> b4 + 1
holds (Exec((intloc b3) :=(b2,b5),Initialize b1)) . intloc (b4 + 1) = b1 . intloc (b4 + 1);
:: SCMBSORT:th 11
theorem
for b1 being Element of product the Object-Kind of SCM+FSA
for b2, b3 being Element of NAT
for b4 being Int-Location
st b2 <> b3 + 1
holds (Exec((intloc b2) := b4,Initialize b1)) . intloc (b3 + 1) = b1 . intloc (b3 + 1);
:: SCMBSORT:th 12
theorem
for b1 being Element of product the Object-Kind of SCM+FSA
for b2 being FinSeq-Location
for b3 being read-write Int-Location holds
(IExec(SCM+FSA-Stop,b1)) . b3 = b1 . b3 &
(IExec(SCM+FSA-Stop,b1)) . b2 = b1 . b2;
:: SCMBSORT:th 16
theorem
for b1 being finite programmed Element of sproduct the Object-Kind of SCM+FSA
for b2 being Element of the Instructions of SCM+FSA
for b3, b4 being Int-Location
st b2 in proj2 b1 &
(b2 <> b3 := b4 & b2 <> AddTo(b3,b4) & b2 <> SubFrom(b3,b4) & b2 <> MultBy(b3,b4) implies b2 = Divide(b3,b4))
holds b3 in UsedIntLoc b1 & b4 in UsedIntLoc b1;
:: SCMBSORT:th 17
theorem
for b1 being finite programmed Element of sproduct the Object-Kind of SCM+FSA
for b2 being Element of the Instructions of SCM+FSA
for b3 being Int-Location
for b4 being Instruction-Location of SCM+FSA
st b2 in proj2 b1 & (b2 = b3 =0_goto b4 or b2 = b3 >0_goto b4)
holds b3 in UsedIntLoc b1;
:: SCMBSORT:th 18
theorem
for b1 being finite programmed Element of sproduct the Object-Kind of SCM+FSA
for b2 being Element of the Instructions of SCM+FSA
for b3 being FinSeq-Location
for b4, b5 being Int-Location
st b2 in proj2 b1 &
(b2 = b4 :=(b3,b5) or b2 = (b3,b5):= b4)
holds b5 in UsedIntLoc b1 & b4 in UsedIntLoc b1;
:: SCMBSORT:th 19
theorem
for b1 being finite programmed Element of sproduct the Object-Kind of SCM+FSA
for b2 being Element of the Instructions of SCM+FSA
for b3 being FinSeq-Location
for b4, b5 being Int-Location
st b2 in proj2 b1 &
(b2 = b4 :=(b3,b5) or b2 = (b3,b5):= b4)
holds b3 in UsedInt*Loc b1;
:: SCMBSORT:th 20
theorem
for b1 being finite programmed Element of sproduct the Object-Kind of SCM+FSA
for b2 being Element of the Instructions of SCM+FSA
for b3 being FinSeq-Location
for b4 being Int-Location
st b2 in proj2 b1 & (b2 = b4 :=len b3 or b2 = b3 :=<0,...,0> b4)
holds b4 in UsedIntLoc b1;
:: SCMBSORT:th 21
theorem
for b1 being finite programmed Element of sproduct the Object-Kind of SCM+FSA
for b2 being Element of the Instructions of SCM+FSA
for b3 being FinSeq-Location
for b4 being Int-Location
st b2 in proj2 b1 & (b2 = b4 :=len b3 or b2 = b3 :=<0,...,0> b4)
holds b3 in UsedInt*Loc b1;
:: SCMBSORT:th 23
theorem
for b1 being finite Element of sproduct the Object-Kind of SCM+FSA
for b2 being finite programmed initial Element of sproduct the Object-Kind of SCM+FSA
for b3 being set
st proj1 b1 c= Int-Locations \/ FinSeq-Locations &
b3 in ((proj1 b1) \/ UsedInt*Loc b2) \/ UsedIntLoc b2 &
b3 is not Int-Location
holds b3 is FinSeq-Location;
:: SCMBSORT:th 25
theorem
for b1, b2 being Element of NAT
for b3 being finite Element of sproduct the Object-Kind of SCM+FSA
for b4 being finite programmed initial Element of sproduct the Object-Kind of SCM+FSA
for b5, b6 being Element of product the Object-Kind of SCM+FSA
st b2 <= b1 &
b4 c= b5 &
b4 c= b6 &
proj1 b3 c= Int-Locations \/ FinSeq-Locations &
(for b7 being Element of NAT holds
IC Computation(b5,b7) in proj1 b4 & IC Computation(b6,b7) in proj1 b4) &
(Computation(b5,b2)) . IC SCM+FSA = (Computation(b6,b2)) . IC SCM+FSA &
(Computation(b5,b2)) | (((proj1 b3) \/ UsedInt*Loc b4) \/ UsedIntLoc b4) = (Computation(b6,b2)) | (((proj1 b3) \/ UsedInt*Loc b4) \/ UsedIntLoc b4)
holds (Computation(b5,b1)) . IC SCM+FSA = (Computation(b6,b1)) . IC SCM+FSA &
(Computation(b5,b1)) | (((proj1 b3) \/ UsedInt*Loc b4) \/ UsedIntLoc b4) = (Computation(b6,b1)) | (((proj1 b3) \/ UsedInt*Loc b4) \/ UsedIntLoc b4);
:: SCMBSORT:th 26
theorem
for b1, b2 being Element of NAT
for b3 being finite programmed initial Element of sproduct the Object-Kind of SCM+FSA
for b4, b5 being Element of product the Object-Kind of SCM+FSA
st b2 <= b1 &
b3 c= b4 &
b3 c= b5 &
(for b6 being Element of NAT holds
IC Computation(b4,b6) in proj1 b3 & IC Computation(b5,b6) in proj1 b3) &
(Computation(b4,b2)) . IC SCM+FSA = (Computation(b5,b2)) . IC SCM+FSA &
(Computation(b4,b2)) | ((UsedInt*Loc b3) \/ UsedIntLoc b3) = (Computation(b5,b2)) | ((UsedInt*Loc b3) \/ UsedIntLoc b3)
holds (Computation(b4,b1)) . IC SCM+FSA = (Computation(b5,b1)) . IC SCM+FSA &
(Computation(b4,b1)) | ((UsedInt*Loc b3) \/ UsedIntLoc b3) = (Computation(b5,b1)) | ((UsedInt*Loc b3) \/ UsedIntLoc b3);
:: SCMBSORT:th 29
theorem
for b1, b2 being finite programmed initial Element of sproduct the Object-Kind of SCM+FSA
for b3 being Int-Location holds
UsedIntLoc if=0(b3,b1,b2) = ({b3} \/ UsedIntLoc b1) \/ UsedIntLoc b2 &
UsedIntLoc if>0(b3,b1,b2) = ({b3} \/ UsedIntLoc b1) \/ UsedIntLoc b2;
:: SCMBSORT:th 30
theorem
for b1 being finite programmed initial Element of sproduct the Object-Kind of SCM+FSA
for b2 being Instruction-Location of SCM+FSA holds
UsedIntLoc Directed(b1,b2) = UsedIntLoc b1;
:: SCMBSORT:th 31
theorem
for b1 being Int-Location
for b2 being finite programmed initial Element of sproduct the Object-Kind of SCM+FSA holds
UsedIntLoc Times(b1,b2) = (UsedIntLoc b2) \/ {b1,intloc 0};
:: SCMBSORT:th 35
theorem
for b1, b2 being finite programmed initial Element of sproduct the Object-Kind of SCM+FSA
for b3 being Int-Location holds
UsedInt*Loc if=0(b3,b1,b2) = (UsedInt*Loc b1) \/ UsedInt*Loc b2 &
UsedInt*Loc if>0(b3,b1,b2) = (UsedInt*Loc b1) \/ UsedInt*Loc b2;
:: SCMBSORT:th 36
theorem
for b1 being finite programmed initial Element of sproduct the Object-Kind of SCM+FSA
for b2 being Instruction-Location of SCM+FSA holds
UsedInt*Loc Directed(b1,b2) = UsedInt*Loc b1;
:: SCMBSORT:th 37
theorem
for b1 being Int-Location
for b2 being finite programmed initial Element of sproduct the Object-Kind of SCM+FSA holds
UsedInt*Loc Times(b1,b2) = UsedInt*Loc b2;
:: SCMBSORT:funcnot 1 => SCMBSORT:func 1
definition
let a1 be FinSeq-Location;
let a2 be FinSequence of INT;
redefine func a1 .--> a2 -> finite Element of sproduct the Object-Kind of SCM+FSA;
end;
:: SCMBSORT:th 38
theorem
for b1 being FinSequence of INT holds
b1 is FinSequence of REAL;
:: SCMBSORT:th 39
theorem
for b1 being FinSequence of INT holds
ex b2 being FinSequence of REAL st
b1,b2 are_fiberwise_equipotent & b2 is FinSequence of INT & b2 is non-increasing;
:: SCMBSORT:th 40
theorem
proj1 (((intloc 0) .--> 1) +* Start-At insloc 0) = {intloc 0,IC SCM+FSA};
:: SCMBSORT:th 41
theorem
for b1 being finite programmed initial Element of sproduct the Object-Kind of SCM+FSA holds
proj1 Initialized b1 = (proj1 b1) \/ {intloc 0,IC SCM+FSA};
:: SCMBSORT:th 42
theorem
for b1 being FinSequence of INT
for b2 being FinSeq-Location
for b3 being finite programmed initial Element of sproduct the Object-Kind of SCM+FSA holds
proj1 ((Initialized b3) +* (b2 .--> b1)) = (proj1 b3) \/ {intloc 0,IC SCM+FSA,b2};
:: SCMBSORT:th 43
theorem
for b1 being Instruction-Location of SCM+FSA holds
IC SCM+FSA <> b1;
:: SCMBSORT:th 44
theorem
for b1 being Int-Location
for b2 being finite programmed initial Element of sproduct the Object-Kind of SCM+FSA holds
card Times(b1,b2) = (card b2) + 12;
:: SCMBSORT:th 45
theorem
for b1, b2, b3 being Element of the Instructions of SCM+FSA holds
card ((b1 ';' b2) ';' b3) = 6;
:: SCMBSORT:th 46
theorem
for b1 being FinSequence of INT
for b2 being FinSeq-Location
for b3 being finite programmed initial Element of sproduct the Object-Kind of SCM+FSA holds
proj1 Initialized b3 misses proj1 (b2 .--> b1);
:: SCMBSORT:th 47
theorem
for b1 being FinSequence of INT
for b2 being FinSeq-Location
for b3 being finite programmed initial Element of sproduct the Object-Kind of SCM+FSA holds
(Initialized b3) +* (b2 .--> b1) starts_at 0;
:: SCMBSORT:th 48
theorem
for b1, b2 being finite programmed initial Element of sproduct the Object-Kind of SCM+FSA
for b3 being Element of NAT
for b4 being Element of the Instructions of SCM+FSA
st b3 < card b2 & b4 = b2 . insloc b3
holds (b1 ';' b2) . insloc ((card b1) + b3) = IncAddr(b4,card b1);
:: SCMBSORT:th 49
theorem
for b1 being Element of the Instructions of SCM+FSA
for b2 being FinSeq-Location
for b3, b4 being Int-Location
for b5 being Instruction-Location of SCM+FSA
st (b1 <> b3 := b4 & b1 <> AddTo(b3,b4) & b1 <> SubFrom(b3,b4) & b1 <> MultBy(b3,b4) & b1 <> Divide(b3,b4) & b1 <> goto b5 & b1 <> b3 =0_goto b5 & b1 <> b3 >0_goto b5 & b1 <> b4 :=(b2,b3) & b1 <> (b2,b3):= b4 & b1 <> b3 :=len b2 implies b1 = b2 :=<0,...,0> b3)
holds b1 <> halt SCM+FSA;
:: SCMBSORT:th 50
theorem
for b1, b2 being finite programmed initial Element of sproduct the Object-Kind of SCM+FSA
for b3 being Element of NAT
for b4 being Element of the Instructions of SCM+FSA
st (for b5 being Element of NAT holds
IncAddr(b4,b5) = b4) &
b4 <> halt SCM+FSA &
b3 = card b1
holds ((b1 ';' b4) ';' b2) . insloc b3 = b4 &
((b1 ';' b4) ';' b2) . insloc (b3 + 1) = goto insloc ((card b1) + 2);
:: SCMBSORT:th 51
theorem
for b1, b2 being Int-Location
for b3, b4 being finite programmed initial Element of sproduct the Object-Kind of SCM+FSA
for b5 being Element of NAT
st b5 = card b3
holds ((b3 ';' (b1 := b2)) ';' b4) . insloc b5 = b1 := b2 &
((b3 ';' (b1 := b2)) ';' b4) . insloc (b5 + 1) = goto insloc ((card b3) + 2);
:: SCMBSORT:th 52
theorem
for b1 being FinSeq-Location
for b2 being Int-Location
for b3, b4 being finite programmed initial Element of sproduct the Object-Kind of SCM+FSA
for b5 being Element of NAT
st b5 = card b3
holds ((b3 ';' (b2 :=len b1)) ';' b4) . insloc b5 = b2 :=len b1 &
((b3 ';' (b2 :=len b1)) ';' b4) . insloc (b5 + 1) = goto insloc ((card b3) + 2);
:: SCMBSORT:th 53
theorem
for b1 being FinSequence of INT
for b2 being FinSeq-Location
for b3 being Element of product the Object-Kind of SCM+FSA
for b4 being finite programmed initial Element of sproduct the Object-Kind of SCM+FSA
st (Initialized b4) +* (b2 .--> b1) c= b3
holds b4 c= b3;
:: SCMBSORT:th 54
theorem
for b1 being FinSequence of INT
for b2 being FinSeq-Location
for b3 being Element of product the Object-Kind of SCM+FSA
for b4 being finite programmed initial Element of sproduct the Object-Kind of SCM+FSA
st (Initialized b4) +* (b2 .--> b1) c= b3
holds b3 . b2 = b1 & b3 . intloc 0 = 1;
:: SCMBSORT:th 55
theorem
for b1 being FinSeq-Location
for b2 being Int-Location
for b3 being Element of product the Object-Kind of SCM+FSA holds
{b2,IC SCM+FSA,b1} c= proj1 b3;
:: SCMBSORT:th 56
theorem
for b1 being finite programmed initial Element of sproduct the Object-Kind of SCM+FSA
for b2 being Element of product the Object-Kind of SCM+FSA holds
(UsedInt*Loc b1) \/ UsedIntLoc b1 c= proj1 b2;
:: SCMBSORT:th 57
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 holds
(Result (b1 +* Initialized b2)) . b3 = (IExec(b2,b1)) . b3;
:: SCMBSORT:funcnot 2 => SCMBSORT:func 2
definition
let a1 be FinSeq-Location;
func bubble-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)) ';' Times(intloc 1,((((intloc 2) := intloc 1) ';' SubFrom(intloc 2,intloc 0)) ';' ((intloc 3) :=len a1)) ';' Times(intloc 2,((((((intloc 4) := intloc 3) ';' SubFrom(intloc 3,intloc 0)) ';' ((intloc 5) :=(a1,intloc 3))) ';' ((intloc 6) :=(a1,intloc 4))) ';' SubFrom(intloc 6,intloc 5)) ';' if>0(intloc 6,(((intloc 6) :=(a1,intloc 4)) ';' ((a1,intloc 3):= intloc 6)) ';' ((a1,intloc 4):= intloc 5),SCM+FSA-Stop)));
end;
:: SCMBSORT:def 1
theorem
for b1 being FinSeq-Location holds
bubble-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)) ';' Times(intloc 1,((((intloc 2) := intloc 1) ';' SubFrom(intloc 2,intloc 0)) ';' ((intloc 3) :=len b1)) ';' Times(intloc 2,((((((intloc 4) := intloc 3) ';' SubFrom(intloc 3,intloc 0)) ';' ((intloc 5) :=(b1,intloc 3))) ';' ((intloc 6) :=(b1,intloc 4))) ';' SubFrom(intloc 6,intloc 5)) ';' if>0(intloc 6,(((intloc 6) :=(b1,intloc 4)) ';' ((b1,intloc 3):= intloc 6)) ';' ((b1,intloc 4):= intloc 5),SCM+FSA-Stop)));
:: SCMBSORT:funcnot 3 => SCMBSORT:func 3
definition
func Bubble-Sort-Algorithm -> finite programmed initial Element of sproduct the Object-Kind of SCM+FSA equals
bubble-sort fsloc 0;
end;
:: SCMBSORT:def 2
theorem
Bubble-Sort-Algorithm = bubble-sort fsloc 0;
:: SCMBSORT:th 58
theorem
for b1 being FinSeq-Location holds
UsedIntLoc bubble-sort b1 = {intloc 0,intloc 1,intloc 2,intloc 3,intloc 4,intloc 5,intloc 6};
:: SCMBSORT:th 59
theorem
for b1 being FinSeq-Location holds
UsedInt*Loc bubble-sort b1 = {b1};
:: SCMBSORT:funcnot 4 => SCMBSORT:func 4
definition
func Sorting-Function -> Function-like Relation of FinPartSt SCM+FSA,FinPartSt SCM+FSA means
for b1, b2 being finite Element of sproduct the Object-Kind of SCM+FSA holds
[b1,b2] in it
iff
ex b3 being FinSequence of INT st
ex b4 being FinSequence of REAL st
b3,b4 are_fiberwise_equipotent & b4 is FinSequence of INT & b4 is non-increasing & b1 = (fsloc 0) .--> b3 & b2 = (fsloc 0) .--> b4;
end;
:: SCMBSORT:def 3
theorem
for b1 being Function-like Relation of FinPartSt SCM+FSA,FinPartSt SCM+FSA holds
b1 = Sorting-Function
iff
for b2, b3 being finite Element of sproduct the Object-Kind of SCM+FSA holds
[b2,b3] in b1
iff
ex b4 being FinSequence of INT st
ex b5 being FinSequence of REAL st
b4,b5 are_fiberwise_equipotent & b5 is FinSequence of INT & b5 is non-increasing & b2 = (fsloc 0) .--> b4 & b3 = (fsloc 0) .--> b5;
:: SCMBSORT:th 60
theorem
for b1 being set holds
b1 in proj1 Sorting-Function
iff
ex b2 being FinSequence of INT st
b1 = (fsloc 0) .--> b2;
:: SCMBSORT:th 61
theorem
for b1 being FinSequence of INT holds
ex b2 being FinSequence of REAL st
b1,b2 are_fiberwise_equipotent &
b2 is non-increasing &
b2 is FinSequence of INT &
Sorting-Function . ((fsloc 0) .--> b1) = (fsloc 0) .--> b2;
:: SCMBSORT:th 62
theorem
for b1 being FinSeq-Location holds
card bubble-sort b1 = 63;
:: SCMBSORT:th 63
theorem
for b1 being FinSeq-Location
for b2 being Element of NAT
st b2 < 63
holds insloc b2 in proj1 bubble-sort b1;
:: SCMBSORT:th 64
theorem
bubble-sort fsloc 0 is keepInt0_1 & bubble-sort fsloc 0 is InitHalting;
:: SCMBSORT:th 65
theorem
for b1 being Element of product the Object-Kind of SCM+FSA holds
b1 . fsloc 0,(IExec(bubble-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(bubble-sort fsloc 0,b1)) . fsloc 0) . b2 &
b5 = ((IExec(bubble-sort fsloc 0,b1)) . fsloc 0) . b3
holds b5 <= b4);
:: SCMBSORT:th 66
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 Bubble-Sort-Algorithm) +* ((fsloc 0) .--> b3) c= b2
holds IC Computation(b2,b1) in proj1 Bubble-Sort-Algorithm;
:: SCMBSORT:th 67
theorem
for b1 being Element of product the Object-Kind of SCM+FSA
for b2 being FinSequence of INT
st (Initialized Bubble-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;
:: SCMBSORT:th 68
theorem
for b1 being FinSequence of INT holds
(Initialized Bubble-Sort-Algorithm) +* ((fsloc 0) .--> b1) is autonomic(NAT, {INT,INT *}, SCM+FSA);
:: SCMBSORT:th 69
theorem
Initialized Bubble-Sort-Algorithm computes Sorting-Function;