Professional Documents
Culture Documents
Description Logic As Programming Language
Description Logic As Programming Language
net/publication/277892587
CITATIONS READS
0 52
1 author:
James Skene
Auckland University of Technology
28 PUBLICATIONS 991 CITATIONS
SEE PROFILE
Some of the authors of this publication are also working on these related projects:
TAPAS - Trusted and quality-of-service Aware Provision of Application Services View project
All content following this page was uploaded by James Skene on 24 May 2016.
James Skene
Auckland University of Technology, New Zealand
jskene@aut.ac.nz
This is computation in the same sense that another lan- We had some conceptual modelling choices to make
guage might calculate from the expression 1 + 2 the value 3 when writing this program. We have chosen to represent
yielding a result equal to the original but more explicit. What Fred’s doghood by an atomic concept, but could equally
it means to be explicit in the context of ALP is discussed in have expressed it in terms of her relationship to the author,
more detail in the next section, but note that achieving it in i.e. she is his dog.
this case requires some non-trivial work on the part of the ComputerScientist
interpreter – in particular the possibility that Fred is simul- some dog Female
taneously both awake and not awake must be investigated,
Now we have lost the concept of ownership from the
found to be inconsistent and discounted.
model. Maybe it was significant, in that everything the
Now let us look at a system of two objects – the author
author owns is shabby, including poor Fred. We can get
and his dog. We could use an extra variable james by adding
back the ownership role for fred using a role-value mapping
a role assertion owner(james, fred) to the program for this
dog ⊆ owns, which in the concrete syntax is represented us-
purpose, but instead we will shift the focus of the program
ing a colon, and may be interpreted as ‘the author’s dogs are
to the author.
things he owns’. The rule about the condition of the things
(ComputerScientist and the author owns can be stated using a value restriction (∀).
some owns (Dog and Female)) (james)
all owns Shabby
Here some owns (Dog and Female) is the concrete syntax some dog Female
equivalent of ∃owns.(Dog u Female). Note that the instance dog : owns
variable fred has disappeared, and Fred’s existence is merely Here dog : owns is acting a bit like a type declaration for
implied by the description of james. But we will expect a field in a traditional OO language, or alternatively like the
the interpreter to make Fred’s existence explicit again by statement that the class of dogs of the author is a subclass of
inventing an instance variable to represent Fred and using the things he owns. The value restriction works like a class
it in sentences that describe Fred directly. We will come to definition, in that it gives at least part of the nature of what he
refer to each subprogram calculated as an output, so this owns without stating that he owns anything. The subprogram
program will have two as follows. . . for the dog will now look like this on output:
ComputerScientist (james) Shabby (a 2)
owns(james, a 2) Female (a 2)
. . . and. . . dog(a 1, a 2)
owns(a 1, a 2)
Dog (a 2)
Female (a 2) Multiple value restrictions may be applied to an instance
owns(james, a 2) across any and each of several roles. Perhaps the author
adopts the policy of only owning female dogs. If we express
Fred is now represented by the automatically generated
this rule using a value restriction, then it is only necessary
variable a 2 – but as we have stated the choice of variable
to state that he owns a dog, with no more information given
name is not meaningful. During execution the processing of
about it. Here something represents the top concept >.
the existential quantification (∃) will act a bit like the new
operator in an object-oriented program, causing something all owns Shabby
that we know must exist to occupy some space in working all dog Female
memory. Since we can always use this trick (and others) to some dog something
dog : owns
generate multiple objects, our interpreter only accepts a sin-
gle (usually complex) concept as input, which it assumes ap- This demonstrates a pleasing compositional nature for
plies to an instance a 1. Programs may therefore be written ALP programs. If we discover more facts about the enti-
using only the concept language of ALP not the sentential ties being described, they can be added providing they are
forms, although these will appear in output. We would pre- consistent with what has already been stated. For example,
fer to give the program above as follows, taking advantage maybe the author does not care to bathe dogs. We could ap-
of some syntactic sugar that groups consecutive concepts pend all dog Dirty to the above program and then Dirty (a 2)
would form part of the output. This hints at possible uses for be qualified as a dog, giving rise to a subprogram a 4 for her
this kind of language in software engineering by refinement puppies eventually.
of specification. This program now models a dog dynasty extending in-
Although we expect the interpreter to generate a subpro- finitely into the future – among other possibilities, such as a
gram to represent Fred, having stated she exists, in fact the dog that is her own mother – and it may not be reasonable
above program states that the author has at least one dog, and to expect execution of it to terminate. It demonstrates where
therefore also describes situations in which he has more than a lot of the expressive power of ALP comes from, beyond
one (provided they are all shabby and female). This could propositional reasoning about individual instances. The con-
be corrected by a number restriction #dog <= 1, although cept dog.puppy : dog results in a composite role being rela-
this in no way globally restricts the total number of dogs, belled to an atomic one, fetching a new member of the clo-
only the relationship between owner and dog; the description sure of the relationship puppy back into a direct relationship
would still apply to other owners of of other dogs, provided dog with a 1, which then qualifies it with a description that
they each owned only one. Hence number restrictions do not again extends the graph of instances.
eliminate the class/object duality for subprograms, although Leaving dogs behind, can we now write more useful
the role dog now identifies one object from the perspective programs? Unfortunately ALP has no direct support for
of any object conforming to a 1. arithmetic, so conventional data processing is inconvenient.
Consider the following program, in which fred is now a But it is not impossible. In the following we define two
role rather than a variable. three digit numbers with the intention that each digit will be
#fred <= 1
described by a distinct subprogram, linked by the next role
some fred Female identifying the next more significant digit. The numbers are
fred : dog x = 210, y = 102.
#lassie <= 1 some x {
some lassie something Zero some next {
lassie : dog One some next {
Two all next nothing }}}
Now it seems reasonable enough to assume that the au-
some y {
thor has two dogs, Fred and Lassie, and instance variables, Two some next {
say a 2 and a 3 will be introduced to stand for them. And Zero some next {
such a scenario is described by the above program, but it One all next nothing }}}
also describes a situation in which the author has only one
dog that may be referred to as Fred or Lassie, and even one in Note the use of all next nothing to deny the existence of
which the author considers himself to be a dog and refers to more significant digits, with nothing representing the bottom
himself by those names. This because no logical reason has concept ⊥ that contains no objects. Now we will try to
yet been given for any objects to be distinct in the domain. add these two numbers together. To structure the algorithm
If necessary the program could be made somewhat less am- we will model things with the ability to add two digits
biguous by asserting #dog <= 1, forcing facts about Fred together, and other things that can recursively add two lists
and Lassie to be unified into a single subprogram, or alterna- of digits together, handling carry in from the addition of less
tively all all lassie not Female forcing them to remain apart. significant digits if necessary, and making use of the first lot
Here is a way to get a lot of dogs: of things. By analogy to digital electronics we will call these
half adders and full adders respectively. Here is a definition
all dog { for the half adders.
Female all ternary half adder {
some puppy something
} ({ all a Zero ({ all b Zero some r Zero some c Zero } or
dog.puppy : dog ({ all b One some r One some c Zero } or
some dog something { all b Two some r Two some c Zero }))} or
({ all a One ({ all b Zero some r One some c Zero } or
A reasonable execution strategy would be to invent a ({ all b One some r Two some c Zero } or
dog a 2 in relation dog(a 1, a 2) to the first object a 1, which { all b Two some r Zero some c One }))} or
now perhaps stands for the author or maybe just the situation { all a Two ({ all b Zero some r Two some c Zero } or
under discussion. This will then be qualified by the value re- ({ all b One some r Zero some c One } or
striction, resulting eventually in some puppy something(a 2) { all b Two some r One some c One }))}))
which will then yield puppy(a 2, a 3). Now because the }
role assertions dog (a 1, a 2) and puppy(a 2, a 3) hold then Apparently we are dealing with ternary (base 3) numbers.
dog.puppy(a 1, a 3) also holds and so the role-value map- We could now try to add the first digits of x and y together
ping can be applied to determine dog(a 1, a 3). Now a 3 can as follows. . .
#a half adder <= 1 next.r : r.next
a half adder : ternary half adder } or
x : a half adder.a {
y : a half adder.b // Or we are done and the carry is the msd
all a.next nothing
Here we do not need to say some a half adder something. all input adder.c all next nothing
This is because qualifying x with the role a half adder.a must input adder.c : r.next
result in an intermediate object, the half adder, being hy- })
pothesised. Subsequently we would expect the result to be }
given by a half adder.r with any carry out referred to by
a half adder.c. But in this case we would be disappointed. In full adder.next : full adder
fact, what would result are nine alternatives representing ev- adder : full adder
ery possible sum. This is because we have not yet stated that all adder some c in Zero
Zero, One, and Two are mutually exclusive concepts. What For simplicity this adder assumes its parameters have the
is needed is some type information for our numbers. same number of digits, but places no limit on what that
all ternary number { length might be. The first carry in is wired to Zero in the
definition of adder. Interestingly this is a generic adder – it
({ Zero not One not Two } or will add numbers with any natural base, but it needs to be
({ not Zero One not Two } or specialised with an appropriate half adder. This is another
{ not Zero not One Two })) example of the flexibility of abstractions in ALP.
#next <= 1
} ternary adder : adder
ternary number.next : ternary number ternary adder.half adder : ternary half adder
20. (green ⊆ next ◦ yellow u (yellow ⊆ next . . . M∀1 (19, 2) a_2 a_8
21. green ⊆ next ◦ yellow(a4 ) Du1 (20)
22. (yellow ⊆ next ◦ red u red ⊆ next ◦ green . . .
23. yellow ⊆ next ◦ red(a4 ) Du1 (22) Figure 4. Eight instances from the traffic-light example.
24. red ⊆ next ◦ green(a4 )
25. next ◦ red(a4 , a2 ) M⊆1 (23, 17)
26. next(a4 , a5 ) M◦1 (25)
a1 has passed it. The subprograms for the states contain
no guard sentences, so are never open to roles, so become
27. red(a5 , a2 )
ready once objective and standing, and shortly thereafter
28. traffic light ◦ next(a1 , a5 ) M◦2 (26, 4, 19) exhausted. The subprograms for a1 and a2 never become
Instance a4 ready and exhausted. ready, the former because it always remains open to the role
traffic light ◦ next so that it can apply its value restriction,
Figure 3. Initial execution of the traffic-light example. and the latter because it always has a subjective referrer,
i.e. the subprogram for the next state currently being cal-
As execution progresses the subprograms for each state of culated. The order and timing in which subprograms for
the traffic light become available for output and subsequent states are output and cleared from memory can vary depend-
garbage collection. Here are the sentences that will be output ing on the order in which deductions are applied, due to a
for a3 : race between Mu1 and M⊆1 in the processing of the state
for green, but provided neither of these rules is systemati-
cally deferred the subprograms will be output promptly and
8. traffic light(a1 , a3 )
in order. The memory footprint of the program is hence con-
9. green(a3 , a2 )
stantly bounded with at most two states in memory at once.
11. green ⊆ next ◦ yellow(a3 ) With such a small memory footprint this program is ac-
13. next ◦ yellow(a3 , a2 ) tually not a good benchmark for the interpreter, since hav-
14. yellow ⊆ next ◦ red(a3 ) ing large numbers of facts to process is the principal chal-
15. red ⊆ next ◦ green(a3 ) lenge for algorithms that apply the deductive rules and cal-
culate readiness. Nevertheless we note that our implementa-
16. next(a3 , a4 )
tion, written in Prolog and executed using SWIProlog on an
Intel I7 PC running at 2.7 GHz (with one core being utilised)
Note that a1 swiftly becomes objective, having no ref- will output ∼440 state subprograms per CPU second, corre-
erents of its own. Then each state becomes objective once sponding to ∼4400 deductions per second. This is obviously
very slow when we consider how a simple implementation gramming languages, e.g. the example in Section 3 in which
of the same simulation written in machine-code would run. the dogs of the author are a type of thing he owns.
But on the other hand it suggests that execution of ALP Other constructors were also selected in part for their con-
programs is not beyond the bounds of practicality. ceptual modelling appeal and similarity to OO languages –
value restrictions for example, are a bit like classes; negation
is obviously desirable for denying bad properties; unions fol-
low inevitably if you want negation and intersection and to
9. Related work
avoid artificial constraints on the way that concepts are com-
ALP introduces no new constructors or sentential forms to bined – and in part from experience writing programs – max-
the field of Description Logic. All have been considered be- imum number restrictions have a role in achieving efficient
fore, and with the exception of role-value maps, frequently. calculation since they allow two subprograms in the same
Tableau algorithms are also the usual approach for reason- role to be merged avoiding repeated calculations, provided
ing with expressive DLs [2], and our proof of completeness R#≤1 is promptly applied.
follows a typical pattern. However they are usually used to Another point of difference from other DL work is our
find contradictions in order to establish the validity of some focus on instance and role assertions as the main senten-
complementary fact, for example proving the subsumption tial forms rather than terminological axioms, which describe
of one concept by another by disproving the existence of an subsumption relationships between the membership of con-
object asserted to be a member of the former but not the lat- cepts as a whole. So with a terminological axiom it would
ter. Explicitness is hence not usually proven, but is no doubt be possible to assert that all dogs are female, for example.
a property of most such algorithms. It seems clear that the ALP programs can give general rules for the dogs of the
method works to find contradictions by first making argu- author say, but not for all dogs. This limitation is intended
ments explicit. to avoid two potential software engineering problems: first
What is perhaps novel about ALP is the particular set combining ALP programs will hopefully be less problem-
of choices that it embodies. Most DLs are not, by virtue atic due to conflicting uses of the same terminology, since
of the constructors chosen, Turing complete, because this the meaning of some name only applies within a local col-
would make the decision procedures desired in their appli- lection of connected subprograms (although more work on
cations undecidable. But we want Turing completeness so as modularity is also needed); second, programs, regarded as
not to restrict the set of algorithms that can be implemented models of part or all of some system containing elements
in the language. The (logical) completeness result of Theo- of problem and solution domains, need not also define the
rem 6 establishes the semi-decidability of ALP. If we were boundary of the system domain, which would be required
to also show that ALP could simulate any TM, and hope- to make statements such as all dogs are female make sense,
fully the examples we have shown suggest that this is a re- since all dogs are manifestly not female.
alistic prospect, then it would be clear that ALP is also un- The other notable fragment of FOL that has been used
decidable, and this is essentially due in ALP as in TMs to as a basis for programming is Horn clauses, which under-
the halting problem, as illustrated by Theorem 1. However, pins the semantics of Prolog, the best-known logic program-
thanks to the results presented in Section 6, ALP programs ming language [9]. The Closed World Assumption (CWA)
do not have to terminate to produce useful output in finite informs the semantics of Prolog such that if a fact is not
time. a consequence of a Prolog program K then it is denied.
Role-value maps contribute profoundly to the expressive- For example given the program thing a(A). the queries
ness of ALP. We have seen that they allow programs to ?- thing a(a(1)), ?- thing a(a(2)), . . . succeed but
progress by repeatedly qualifying newly discovered mem- ?- thing b(b(1)) fails. Note that if we take the world of
bers of the closure of a relationship. Role-value maps are the program to be the set of terms satisfying the rule then
considered so undesirable from a computational perspec- this program has an infinite world, which is closed only in
tive that the standard nomenclature for DLs, which com- terms of the kinds of things it can contain.
bines the letters AL with a suffix consisting of letters indi- This is clearly not the case for the semantics of ALP as
cating the additional concept constructors does not include we have presented them. Suppose K = {A(a)}, then K 6|=
one for them [1]. However, if we represent role-value maps B(b) but in any interpretation satisfying K there may be an
with R then the language would be called ALUCEFR◦ . object participating in B or not. So we state that ALP is
Notwithstanding that this might be shortened by consider- designed according to the Open World Assumption (OWA).
ing equivalences between some of the constructors, we find This seems to us to be preferable for the following reason at
this unwieldy, hence our use of ALP which may be con- least: if the abstractions presented in a program also model
sidered to stand for attributive language for programming. the problem domain, then the CWA is problematic, because
Role-value maps are for us a convenient and natural way additional detail is denied. At whatever level of detail the au-
to obtain the repetition needed in most algorithms, and they thor models his dog in Prolog you can still claim that his Pro-
also closely resemble type declarations in conventional pro-
log program does not represent her by identifying something more conventionally object-oriented than Alloy or ALP,
true about her that he has not stated, and pointing out that namely structural type information in the form of classes, in-
his program denies that fact. There is a sense in which ALP heritance relationships, fields and/or associations with mul-
is also more open-world than FOL. In FOL we can make tiplicity constraints, and some other constraints such as vis-
statements such as ∀x.(Dog(x) → Female(x)), which is the ibility, ordering and containment. OCL adds the ability to
equivalent to the terminological axiom discussed above, and define object invariants and pre- and post-conditions for
has the effect of closing the domain against all male dogs. methods. These elements match closely the specification el-
Description logic has been combined with logic program- ements available from programming languages such as C++
ming with Horn clauses in several works. In [6] a restricted and Java, which embody the structural elements in their type
DL is translated into Horn clauses. In [3] the Prolog environ- systems and support the specification of invariants and pre-
ment can transfer control to a DL reasoner to check special and post-conditions by means of assertions. Hence specifi-
predicates. Both works are aiming to provide execution plat- cation elements find use in static or runtime checking, with
forms for semantic web languages that specify rules and on- type information also useful for generating objects or code.
tologies. The DLs considered are less expressive than ALP In contrast in ALP the line between type information and
and control is due to the rules. object-invariant is blurred because every subprogram gives a
Another relevant fragment of FOL is relational logic, description of a non-empty category of immutable objects
which underpins the semantics of the model finder Alloy [7]. at some level of abstraction, making distinctions between
Alloy generates and visualises possible satisfying domains, type and value information somewhat arbitrary. For exam-
up to some limit on the number of objects present, to help ple, we can state Number(a1 ) or Three(a1 ) using the same
the programmer to verify that a specification indeed mod- kinds of concepts and sentences, in this case atomic concepts
els the domains it expects. By making some possible do- and instance assertions. And of course in ALP there is no
mains explicit Alloy achieves something similar to our ex- distinction between this kind of structural information and
ecution algorithm, relying on the resolution-based model- commands that advance the state of the computation.
finder KodKod [15] rather than a tableau method. Alloy’s A recent work to attempt executable OO specifications
results are delivered as examples rather than descriptions of is [10], which integrates Kodkod into Java, transferring con-
required categories of objects, so where ALP might output trol to the model finder to accomplish some calculations,
two subprograms related by a role Alloy would deliver a set but this can only be used to implement steps in long run-
of pairs of some finite cardinality; this supports the checking ning executions. This work uses a specification language that
of more complex constraints on the cardinality of a relation supports in syntax the notion that objects may change state,
than ALP can express, but it happens whether those con- whereas again Alloy and ALP must model state changes
straints are present or not. where necessary using more generic kinds of relationships
Alloy’s language is more expressive than ALP in other between immutable objects.
ways too, however it has not been intended for programming
so the Alloy interpreter currently only attempts to realise fi-
nite domains in a non-interactive manner. However, since
10. Conclusion
Alloy preceded this work and has a similar perspective on The intent of this paper is to establish some initial credibility
declarative OO specification to our own, would it or rela- for the use of Description Logic as a programming language.
tional logics have been better places for us to start looking We have only shown a language that captures the semantics
for a programming language than DLs? Perhaps, but the sim- of objects for our purposes. Although this is almost certainly
plicity of ALP has certainly been an advantage in showing enough for Turing completeness for practical purposes and
that explicitness and output prior to termination can be ac- to harness the power of modern computing platforms a more
complished, and perhaps these properties can now be sought expressive language, including innate support for arithmetic,
for more expressive logics and systems. Moreover, in com- string manipulation, etc. will need to be built on these foun-
parison to DLs there is not for us such a compelling rela- dations.
tionship between the semantics of relational logic, given in Alan Perlis’s 54th Epigram of Programming is Beware of
terms of tuples of atoms, and the problem domain; and the the Turing tar-pit in which everything is possible but nothing
mapping from Alloy’s syntax to relational logic is also not of interest is easy [14]. Will DLs prove to be a tar-pit or
simple. It is not so obvious what the procedure is for deter- tar sands, newly ripe for exploitation? We believe that any
mining whether a real world situation conforms to an Alloy programming language will stand or fall depending on how
specification. the structures that it offers align with how the programmer
UML class diagrams in tandem with the Object Con- wants to think about its problems and solutions. In other
straint Language (OCL) [12] form another expressive spec- words, how intuitive the provided building blocks are. In
ification language the uses of which fall short of full exe- this respect DLs seem to have considerable potential due
cutability. The specification elements in class diagrams are to their ability to directly model a problem domain, and
in a way that can then be put into operation to generate
useful results, as we have seen in the examples presented [6] B. N. Grosof, I. Horrocks, R. Volz, and S. Decker. Description
in this paper. The fact that tableau algorithms can generate logic programs: Combining logic programs with description
concise explicit descriptions of domains of objects from an logic. In Proceedings of the 12th International Conference on
open-world logical language – while taking account of the World Wide Web, WWW ’03, pages 48–57. ACM, 2003.
structure of the domain to deliver results in a piecemeal [7] D. Jackson. Software Abstractions: Logic, Language, and
fashion and manage memory usage – seems like too good Analysis. The MIT Press, 2006.
a prospect to ignore. [8] D. E. Knuth. The Art of Computer Programming, Volume 1
(3rd Ed.): Fundamental Algorithms. Addison Wesley, 1997.
Acknowledgments [9] R. Kowalski. Predicate logic as programming language.
Some of this work was accomplished while the author was Information Processing Letters, 74:569 – 574, 1974.
employed at Auckland University, first as a visiting fellow [10] A. Milicevic, D. Rayside, K. Yessenov, and D. Jackson.
and then funded by the New Zealand Foundation for Re- Unifying execution of imperative and declarative code. In
search, Science and Technology (grant UOAX0903), which Proceedings of the 33rd International Conference on Software
Engineering, ICSE ’11, pages 511–520. ACM, 2011.
became part of the Ministry for Research, Science and Tech-
nology in 2011. Thanks for support to both these institutions, [11] D. Nardi and R. J. Brachman. An introduction to description
in addition to AUT, the author’s current employer. The exam- logics. In F. Baader, D. Calvanese, D. L. McGuinness,
D. Nardi, and P. F. Patel-Schneider, editors, The Description
ple of the author’s dog was inspired by the novel Spurious by
Logic Handbook, pages 1 – 44. Cambridge, second edition,
Lars Iyer. 2007.
[12] Object Constraint Language – OMG Available Specification
References
– Version 2.0. The Object Management Group (OMG),
[1] F. Baader. A. description logic terminology. In F. Baader, formal/2006-05-01 edition, May 2005.
D. Calvanese, D. L. McGuinness, D. Nardi, and P. F. Patel-
[13] OMG Unified Modeling Language (OMG UML), Superstruc-
Schneider, editors, The Description Logic Handbook, pages
ture – Version 2.4.1. The Object Management Group (OMG),
525 – 536. Cambridge, second edition, 2007.
formal/2011-08-06 edition, 2011.
[2] F. Baader and U. Sattler. An overview of tableau algorithms
[14] A. J. Perlis. Epigrams on programming. SIGPLAN Notices,
for description logics. Studia Logica, 69(1):5–40, 2001.
17(9):7–13, 1982.
[3] T. Eiter, G. Ianni, T. Lukasiewicz, and R. Schindlauer. Well-
[15] E. Torlak. A Constraint Solver for Software Engineering:
founded semantics for description logic programs in the
Finding Models and Cores of Large Relational Specifications.
semantic web. ACM Transactions on Computational Logic
PhD thesis, Massachusetts Institute of Technology, 2009.
(TOCL), 12(2):1 – 41, Jan. 2011.
[16] P. van Emde Boas. Machine models and simulation. In
[4] D. Frankel. Model Driven Architecture - Applying MDA to
J. van Leeuwen, editor, Handbook of Theoretical Computer
Enterprise Computing. OMG Press. Wiley Publishing, Inc.,
Science, Volume A: Algorithms and Complexity (A), pages
2003.
1–66. Elsevier, 1990.
[5] E. R. Gansner and S. C. North. An open graph visualization
system and its applications to software engineering. Software
- Practice and Experience, 30(11):1203–1233, 2000.