Metodología de desarrollo para aplicaciones SOA
5.3. Extensión al proceso base para desarrollo SOA
5.3.2. Disciplina Diseño
Let P = P ∪ C be an CNLP, and Lf /1 a rule layering function of P. An atom layering function ALf /1 is a function defined over the atoms of P, assigning each atom a ∈ HP
an ordinal, such that
ALf (a) =
(
lubr∈P:head(r)=a(Lf (r)) if ∃r∈Phead(r) = a
0 otherwise
where lub stands for the least upper bound — in this case, the least upper bound of all the rule layer ordinals for layers containing a rule with the atom a as head.
An atom layering of program P is a partition . . . , AiP, . . . of the set of atoms of P
— HP — such that AiP contains all atoms a having ALf (a) = i. We write A<αP as an abbreviation of S
β<αAβP, and A≤αP as an abbreviation of A<αP ∪ AαP, and define A<0P = ∅.
It follows immediately that HP =S
αAαP=
S
αA≤αP , and also that the ≤ relation between
layers of atoms is a total-order in the sense that AiP ≤ AjP iff i ≤ j.
Amongst the several possible atom layerings of a program P we can always find the least one corresponding to the definition of “atom layering function” ALf /1 based upon the program’s least rule layering function Lf /1.
N.B.: In the following, when referring to the program’s “atom layering”, we mean just such least atom layering, and we will explicitly mention “atom”, as in “atom layering” to make the distinction from (rule) layering.
This notion of atom layering is a generalization of level-mapping [120, 123] because, as explained in [123],
“Level mappings are mappings from Herbrand bases to ordinals, i.e. they in- duce orderings on the set of all ground atoms while disallowing infinite de- scending chains”
and the atom layering notion does allow for infinite descending chains. Atom layerings are always defined, and in this sense they are generalizations of stratifications — partially because atom layerings are applicable also when there are loops in the program, in which cases there are no stratifications. Rule layerings are also always defined, and they capture all syntactic structure of the program. Also, due to the definition of dependency, in gen- eral, atom layerings do not coincide with stratifications [24], nor do rule layers coincide with the layers definition of [209]. When a program is not stratified there are nonetheless
27
atom layerings. However, when the program at hand is stratified (according to [24]) it can easily be seen that there is a relation between its atom layerings and its stratifications. Notice that a stratification, applicable to atoms, may put two atoms in the same stratum if one of them only depends through positive arcs on the other (without any reciprocal de- pendency), whereas, in the same conditions, an atom layering would put them in different layers — cf. Example 3.3 below concerning rule z ← f . So, for each stratification there is an atom layering, possibly with more layers than the strata there are in the stratification. On the other hand, assuming the program is stratified, for each atom layering there is a stratification. Moreover, there is a clear correspondence between a stratification and the least atom layering for acyclic programs — in this case the only difference relates to the atoms whose rules have only positive dependencies on some other atom.
The motivation for this difference between layering and stratification in what positive non-reciprocal dependencies are concerned is mainly a matter of uniformity and simplicity of the definition of layering. Both rule and atom layerings are particular cases of the general case of graph layering (cf. Definition 2.11), and in that general case there is no notion of “positive” or “negative” dependency: a vertex either depends on another or it does not, and if the dependency is non-reciprocal then those vertices are placed in different layers.
Example 3.3. Atom Layering example. Consider again the program from Exam-
ple 3.2, now depicted along with both its least rule layering and least atom layering:
Rule Layer Atom Layer Layer Index
P3= {b ← not b d ← not c c ← not d, not y, not a} A3P = {b, c, d} 3
P2= {b ← not x y ← not x z ← f } A2P = {y, z} 2
P1= {x ← not x e ← e f } A1P = {x, e, f } 1
P0= ∅ A0P = {a} 0
Figure 3.2: NLP’s rules and atoms distributed along the program’s Rule and Atom least Lay- erings.
Atom a has no rules, therefore it is placed in atom-layer 0: A0P. Atoms x, e, f have only one rule in Layer 1, therefore they are placed in atom-layer 1: A1P. Atoms y, z have only one rule in Layer 2, and therefore they are placed in atom-layer 2: A2P. Atom b has two rules: one in Layer 2 and the other in Layer 3, therefore it is placed in atom-layer 3 which is the maximum of its rules’ layers: A3P. Atoms c, d only have rules in Layer 3: they are placed in A3P.
Due to the definition of (least) atom layering — based on the (least) rule layering — there is a close relation between the atom layering of an atom and the rule layering for the rules having that atom as head. This relation is captured by the following proposition:
Proposition 3.1. The least atom layering of an atom identifies the highest layer with rules for the atom. Let P be an CNLP, Lf /1 its least rule layering function, and ALf /1 its least atom layering function.
∀a∈HPALf (a) = α ⇔
∀r∈P:head(r)=ar ∈ P≤α∧ (α 6= 0 ⇔ ∃r0∈Pαhead(r0)=a)
Proposition 3.2. A rule’s layer is greater than or equal to each of the body’s literals’ atom-layering. Let P be an CNLP, Lf /1 its least rule layering function, and ALf /1 its least atom layering function.
∀ r∈P a∈|body(r)|
Lf (r) ≥ ALf (a)
3.2.1 Layers and Strongly Connected Components of Rules
We now turn to analyze the relationship between SCCs of rules and layers.
Proposition 3.3. Rules in the same SCC are in the same layer. Let P be a
CNLP.
∀r,r0∈P(r r0∧ r0 r) ⇒ Lf (r) = Lf (r0)
Proposition 3.4. Layering of SCCs. Let P be a CNLP. If there is an edge from
SCC1 to SCC2, with SCC16= SCC2, in the SCCG(P) then ∀r1∈SCC1 r2∈SCC2
Lf (r2) > Lf (r1).
3.2.1.1 Layers and bodies of rules
The (least) atom layering of a program allows us to partition the body of any given rule into atom-layer indexed subsets.