knowsys / rulewerk

Java library based on the VLog rule engine
Apache License 2.0
32 stars 13 forks source link

Disjunctions in Rules #192

Open monsterkrampe opened 3 years ago

monsterkrampe commented 3 years ago

This PR adds support for Disjunctions in Rule heads and bodies within the rulewerk-core package.
The changes in the other packages were necessary to fit the adjustments in rulewerk-core.

To maintain a certain flexibility especially in existing code and also to achieve a pleasant usage of the Rule interface, the following basic inheritance structure is introduced:

Disjunction <-- Conjunction <-- Literal 

In this sense, a Conjunction can implicitly be treated as a singleton Disjunction and a Literal can implicitly be treated as a singleton Conjunction (and in turn as a Disjunction). A Rule then just consists of two Disjunctions of Conjunctions of (Positive)Literals. The three interfaces also expect generic type arguments to clarify the concrete types of Conjunctions and Literals especially. Because of that, the structure may seem a bit complicated in the source code but from a usage point of view I guess that this would be convenient.

Note that this is currently still WIP and I'm am going to evaluate how the current implementation suits the needs of an application I'm currently developing using the rulewerk library. Also, I still need to implement some tests. Any kind of feedback is very much appreciated and I'm happy to discuss the design decisions :)