1 Introduction

Many branches of research in knowledge representation and reasoning [5] are theoretical in nature and researchers usually do not put effort in implementation and empirical evaluation. To address this issue we developed the Tweety libraries for logical aspects of artificial intelligence and knowledge representation that provide a common infrastructure for experimental evaluation of logical frameworks within these fields.

Approaches to knowledge representation follow almost always a specific pattern. Starting from a formal syntax one can build formulas which are collected in knowledge bases. Using knowledge bases one can derive new information using either the underlying semantics of the language or a specific reasoner. For example, propositional logic is the most basic form for knowledge representation. Given some set of propositions (or atoms) one can build complex formulas using disjunction, conjunction, or negation. A set of propositional formulas, i.e., a knowledge base, can be used to derive new propositional formulas as conclusions. For instance, this can be done using the standard model-theoretic semantics of propositional logic or more sophisticated reasoning techniques such as paraconsistent reasoning.

The Tweety libraries support the implementation of such approaches in Java by providing a couple of abstract classes and interfaces for components such as Formula, BeliefBase, and Reasoner. Moreover, many strictly logic-based approaches to knowledge representation can also utilize further classes such as Predicate, Atom, and Variable, to name just a few. Currently, Tweety already contains implementations of over 18 different approaches to knowledge representation such as propositional logic, first-order logic, several approaches to probabilistic logics, and several approaches to computational models of argumentation.

The webpage of TweetyFootnote 1 provides details on all libraries, installation manuals, and further documentation. A previous paper with a description of the Tweety libraries can also be found in [34].

2 Project Overview

Tweety aims at providing a common framework for implementing different approaches to logical approaches of artificial intelligence in general and knowledge representation in particular. It can be used by undergraduate students to better understand logical approaches to knowledge representation by actually working with them in a familiar object-oriented manner. Moreover, the main purpose of Tweety is to allow the easy implementation of new approaches by following a given strict framework and with the benefit of easily integrating concepts and methods of other formalisms. This allows for early testing of ideas and experimental evaluation in terms of feasibility studies.

Most implementation works related to knowledge representation and reasoning are usually specific-purpose works and aim at providing effective reasoning procedures or appealing user interfaces for a single formalism. Examples of those are protégé Footnote 2 for ontology editing, BContractor Footnote 3 for belief change in classical logic, or Alchemy Footnote 4 for Markov Logic Networks. Tweety, however, provides a common framework to implement a wide variety of different approaches and does not focus on user interfaces or effective algorithms (although direct implementations and bridges to other implementations of effective algorithms are available as well).

In the following, we briefly discuss the architecture of Tweety and give an overview on its functionalities.

2.1 Software Architecture

Tweety is organized as a modular collection of Java libraries with a clear dependence structure. Each knowledge representation formalism has a dedicated Tweety library (ranging from a library on propositional logic to libraries on computational models of argumentation) which provides implementations for both syntactic and semantic constructs of the given formalism as well as reasoning capabilities. Several libraries provide basic functionalities that can be used in other libraries. Among those is the Tweety Commons library which contains abstract classes and interfaces for all kinds of knowledge representation formalisms. Moreover, the library Math contains classes for dealing with mathematical problems such as constraint satisfaction or optimization problems that often occur, in particular, in probabilistic approaches to reasoning. Most other Tweety projects deal with specific approaches to knowledge representation. Each Tweety library is organized as a MavenFootnote 5 project. Most libraries can be used right away as they only have dependencies to other Tweety libraries. Some libraries provide bridges to third-party libraries such as numerical optimization solvers which are not automatically found by Maven and have to be installed beforehand. However, all necessary third-party libraries can be installed by executing a single install file located within the Tweety distribution.

Table 1 Overview on the Tweety libraries (the general package prefix is net.sf.tweety)

2.2 Libraries

An overview of the Tweety libraries is given in Table 1 which provides both the name of a library and its Java root package name. Furthermore, the final column lists references to original literature and the implemented reasoning mechanisms and solvers. There, a dagger (\(\dagger\)) indicates that the particular reasoning mechanism has been directly implemented from the original literature, a double dagger (\(\ddagger\)) means that a wrapper for the existing original implementation is provided, and an asterisk (\(^*\)) refers to related literature.

All libraries dealing with specific knowledge representation formalisms also provide reasoning capabilities, either via direct implementations or bridges to other software solutions. As the libraries are mainly designed to be used by developers and researchers, all functionalities are exposed through APIsFootnote 6 but several user interfaces—such as a general command line interface (located in the package net.sf.tweety.cli) and specific web interfaces such as for inconsistency measurementFootnote 7—are also available. A detailed description of the functionalities of each library is out of the scope of this paper, see http://tweetyproject.org/lib for more information.

3 Example

Specific parts of libraries have been empirically evaluated in other works such as in [26] where opponent models for strategic argumentation are compared or in [33] where measures of coherence are applied to Markov Logic Networks.

Due to the small scope of this paper we only give a short example on propositional logic in Tweety. Consider the code snippet provided in Fig. 1.

Fig. 1
figure 1

Code snippet for determining MUSes and MCSes from propositional knowledge bases

There, a propositional knowledge base (PlBeliefSet) consisting of the four propositional formulas a, b, \(\lnot a \vee \lnot b\), and \(\lnot a\) is defined (the propositional letters do not have any specific meaning here). Afterwards, all minimal unsatisfiable sets (MUS)—i. e., subset-minimal subsets of the knowledge base that are inconsistent—and all maximal consistent sets (MCS)—i. e., subset-maximal subsets of the knowledge base that are still consistent—are determined using a naive approach based on SAT4jFootnote 8. The output of running this code snippet is

figure b

Determining MUSes and MCSes is a subtask in many approaches to inconsistent-tolerant reasoning and the approaches for enumerating those in Tweety can be easily used and customized (there are also further approaches integrated than the one illustrated).

4 Conclusions

To the best of our knowledge, Tweety is the first attempt to provide a general-purpose framework for a broad variety of knowledge representation formalisms. It is an open source projectFootnote 9 \(^,\) Footnote 10 and can therefore be used and extended by everyone. Although Tweety is implemented in an object-oriented programming language it follows a strict declarative formal way to define concepts from theoretical knowledge representation research. Tweety is available under the GNU Lesser General Public License version 3.0. In order to contribute to Tweety contact contribute@tweetyproject.org.