On the Design of a Periodic Table of VDM Specifications
Mário Antunes
ATNoG@IT Aveiro
June 22, 2012
On the Design of a Periodic Table of VDM Specifications
June 22, 2012
1 / 16
Outline
1
Motivation
2
Divide-and-Conquer pattern
3
Relation approach to Divide-and-Conquer
4
Example: merge sort
5
Conclusion
On the Design of a Periodic Table of VDM Specifications
June 22, 2012
2 / 16
Motivation
Where is the borderline between invention and sheer routine-work in
formal modelling?
To answer this it is necessary a repository of specifications
By factoring standard algorithms it is possible to identify elementary
algorithm components
The paper presents a analysis and classification of standard algorithm
in a tabular structure (Periodic Table)
On the Design of a Periodic Table of VDM Specifications
June 22, 2012
3 / 16
Motivation: factorization versus calculation
Consider the following equation
x=
756
792
Solving it by calculation, with a brute force approach, the result is
x=
756
= 0.95454545...
792
Instead it is possible to represent each value of the fraction with a prime
factorization
756 = 22 × 33 × 7
792 = 23 × 32 × 11
Now the equation can be solved
x=
756
22 × 33 × 7
21
= 3
= 22 × 2−3 × 33 × 3−2 × 7 × 11−1 =
2
792
2 × 3 × 11
22
On the Design of a Periodic Table of VDM Specifications
June 22, 2012
4 / 16
Divide-and-Conquer pattern
Computing is related to problem solving
General strategy to solve a problem is to divide it into tractable pieces
Merge Sort
Insertion Sort
void mergesort(int low, int high) { void insertionSort(int[] arr) {
if (low < high) {
int i, j, newValue;
int middle = (low + high) / 2;
for (i=1; i < arr.length; i++) {
mergesort(low, middle);
newValue = arr[i];
mergesort(middle + 1, high);
j = i;
merge(low, middle, high);
while (j>0 && arr[j - 1]
}
> newValue) {
}
arr[j] = arr[j - 1];
j--;
}
arr[j] = newValue;
}
}
On the Design of a Periodic Table of VDM Specifications
June 22, 2012
5 / 16
Divide-and-Conquer pattern
Computing is related to problem solving
General strategy to solve a problem is to divide it into tractable pieces
On the Design of a Periodic Table of VDM Specifications
June 22, 2012
6 / 16
Relation approach to Divide-and-Conquer
The Divide-and-Conquer pattern can be modelled in relation algebra
S: divide step
FX: solve step / atomic solution step
R: conquer step
(1)
X = R · (FX ) · S
On the Design of a Periodic Table of VDM Specifications
June 22, 2012
7 / 16
Relation approach to Divide-and-Conquer
On the Design of a Periodic Table of VDM Specifications
June 22, 2012
8 / 16
Relation approach to Divide-and-Conquer
X = R · (FX ) · S
Assuming that the algorithm can be
divided into multiple steps
X = X1 · X2
The model can be expanded with the
following algebra
T
C←
− FC
On the Design of a Periodic Table of VDM Specifications
June 22, 2012
9 / 16
Relation approach to Divide-and-Conquer
S must be “well-founded” and T
must be bijective over the data type
defined by F
C = µF
µF is the virtual structure used
internally by the algorithm
in
µF ←
− F (µF )
Applying this the solutions in terms
of (R · FX · S) is
µX .(R · FX · S) = (|R|) · (|S°|)°
On the Design of a Periodic Table of VDM Specifications
June 22, 2012
10 / 16
Example: merge sort
mergeSort : seq of
mergeSort (l) ==
cases l :
[] -> l, -[e] -> l, -other -> let
int -> seq of int
| not considered in the example
| represented by singl
l1 ^ l2 in set(l)
be st abs(len l1 -len l2) < 2
-- | represented by pconc°
in let l_l = mergeSort(l1)
l_r = mergeSort(l2)
in lmerge (l_l, l_r)
end;
On the Design of a Periodic Table of VDM Specifications
June 22, 2012
11 / 16
Example: merge sort
Based on the expression X = R · (FX ) · S the merge sort algorithm can be
defined as:
mergeSort = [singl , lmerge · (mergeSort × mergeSort)] · S
mergeSort = [singl , lmerge] · (id + mergeSort × mergeSort) · S
Where it is possible to identify
R = [singl , lmerge]
Ff = id + f × f
FX = int + X × X
(represents a Leaf Tree)
S is defined by extracting “what
remains”
S = [singl , pconc]°
On the Design of a Periodic Table of VDM Specifications
June 22, 2012
12 / 16
Conclusion
The paper presents a classification of several standard algorithm based
on their implicit virtual structure
The paper also presents a second table, a formal classification of
divide and conquer
On the Design of a Periodic Table of VDM Specifications
June 22, 2012
13 / 16
Conclusion
On the Design of a Periodic Table of VDM Specifications
June 22, 2012
14 / 16
Conclusion
On the Design of a Periodic Table of VDM Specifications
June 22, 2012
15 / 16
End
Questions.
On the Design of a Periodic Table of VDM Specifications
June 22, 2012
16 / 16
© Copyright 2026 Paperzz