Defeasible disjunctive datalog Matthew Morris1[0000−0003−3337−7229] , Tala Ross1[0000−0002−4856−9410] , and Thomas Meyer1,2[0000−0003−2204−6969] 1 University of Cape Town, Cape Town, South Africa 2 CAIR, South Africa Abstract. Datalog is a declarative logic programming language that uses classical logical reasoning as its basic form of reasoning. Defeasible reasoning is a form of non-classical reasoning that is able to deal with exceptions to general assertions in a formal manner. The KLM approach to defeasible reasoning is an axiomatic approach based on the concept of plausible inference. Since Datalog uses classical reasoning, it is currently not able to handle defeasible implications and exceptions. We aim to extend the expressivity of Datalog by incorporating KLM-style defeasi- ble reasoning into classical Datalog. We present a systematic approach to extending the KLM properties and a well-known form of defeasible entailment: Rational Closure. We conclude by exploring Datalog exten- sions of less conservative forms of defeasible entailment: Relevant and Lexicographic Closure. 1 Introduction The KLM approach, proposed by Kraus, Lehmann and Magidor [8], is a well- known framework for defeasible reasoning. The KLM properties can be used to determine the rationality of different forms of defeasible entailment. The frame- work has been discussed at length in the literature for propositional logic [8,9,10] and description logics [2,3,11,14]. We present what we believe to be the first the- oretical approach for extending the KLM framework to Datalog. We consider an extended form of Datalog, Disjunctive Datalog, which allows for disjunction in the head of Datalog clauses. We do not consider a semantic characterisation, in terms of a class of ranked interpretations, for the Datalog case. We instead provide an algorithmic definition. There are two well-known forms of defeasible entailment satisfying the KLM properties: Rational Closure (RC) [10] and Lexicographic Closure (LC) [9]. Both are rational [4], with RC being the most conservative form of rational defeasible entailment, and LC a more permissive form. Another form of defeasible entail- ment, Relevant Closure (RelC) [2], has been proposed for description logics. It intuitively seems rational but does not satisfy all of the KLM properties. We provide algorithmic definitions of RC, LC and RelC, showing that RC and LC are still rational when converted to Datalog and that RelC is not. In the next section we provide the relevant background material, after which we present our work on KLM-style defeasible entailment for the Datalog case. We conclude with a discussion of related work and suggestions for future work. Copyright © 2019 for this paper by its authors. Use permitted under Creative Commons License Attribution 4.0 International (CC BY 4.0) 2 M. Morris et al. 2 Background 2.1 Propositional Logic Propositional logic [1] is a simple logic which is built up from a finite set P of propositional atoms, denoted by meta-variables p, q, . . .. The language L of propositional logic is the set of all formulas, denoted by α, β, . . ., which are recursively defined as usual: α ::= > | ⊥ | p | ¬α | α ∧ α | α ∨ α | α → α | α ↔ α. An interpretation is a function I : P → {T, F } which assigns a single truth value to each atom. A formula α ∈ L is satisfied by an interpretation I, denoted I α, if it can be evaluated to true by I in the usual recursive truth-functional way. We define the models of a finite set of formulas X to be JXK = {I : I α, α ∈ X}. We say that a set of formulas X entails a formula α, denoted by X |= α, if JXK ⊆ J{α}K. 2.2 KLM-style Defeasible Entailment The KLM approach [8] is based on the concept of plausible inference, which is represented by defeasible implication operators of the form α |∼ β. This is read as “typically, if α, then β”. Let a knowledge base K be a finite set of defeasible implications. The KLM framework answers the question: “What does it mean for a defeasible implication α |∼ β to be entailed by a knowledge base K?”. This is referred to as defeasible entailment, and denoted by K |≈ α |∼ β. Unlike classical entailment, it is well-accepted that defeasible entailment is not unique. There are multiple formalizations of defeasible entailment, such as Rational Closure [10], Lexicographic Closure [9], and Relevant Closure [2]. Lehmann and Magidor [10] proposed a set of rationality properties known as the KLM properties. They argue that if a defeasible entailment algorithm satisfies all the properties it is believed to be an acceptable form of defeasible entail- ment. We adopt this approach and refer to these forms of defeasible entailment as LM-rational. The KLM properties for propositional logic are stated below: α ≡ β, K |≈ α |∼ γ (Ref) K |≈ α |∼ α (LLE) K |≈ β |∼ γ K |≈ α |∼ β, β |= γ K |≈ α |∼ β, K |≈ α |∼ γ (RW) (And) K |≈ α |∼ γ K |≈ α |∼ β ∧ γ K |≈ α |∼ γ, K |≈ β |∼ γ K |≈ α |∼ β, K |≈ α |∼ γ (Or) (CM) K |≈ α ∨ β |∼ γ K |≈ α ∧ β |∼ γ K |≈ α |∼ γ, K |6≈ α |∼ ¬β (RM) K |≈ α ∧ β |∼ γ Defeasible disjunctive datalog 3 2.3 Rational Closure Rational closure is the most conservative form of defeasible entailment. We use the algorithmic definition [6], which we refer to as the Rational Closure Algo- rithm, as the sole definition of Rational Closure. The algorithm is split into two distinct sub-algorithms, proposed by Casini et al. [4]. The BaseRank algorithm → − is used to construct a ranking of the classical versions ( K ) of the statements in the defeasible knowledge base (K), according to typicality of the statements. Algorithm 1: BaseRank Input: A knowledge base K Output: An ordered tuple (R0 , . . . , Rn−1 , R∞ , n) 1 i := 0; − → 2 E0 := K := {α → β | α |∼ β ∈ K}; 3 repeat 4 Ei+1 := {α → β ∈ Ei | Ei |= ¬α}; 5 Ri := Ei \ Ei+1 ; 6 i := i + 1; 7 until Ei−1 = Ei ; 8 R∞ := Ei−1 ; 9 if Ei−1 = ∅ then 10 n := i − 1; 11 else 12 n := i; 13 return (R0 , . . . , Rn−1 , R∞ , n) The RationalClosure algorithm is used to compute whether a defeasible implication is entailed by the knowledge base and uses the BaseRank algorithm. Algorithm 2: RationalClosure Input: A knowledge base K and a defeasible implication α |∼ β Output: true, if K |≈ α |∼ β, and false, otherwise 1 (R0 , . . . , Rn−1 , R∞ , n) := BaseRank(K); 2 i := 0; Sj of K Output: true, if K |≈ α |∼ β, and false, otherwise 1 (R0 , . . . , Rn−1 , R∞ , n) := BaseRank(K); 2 i := 0; 0 3 R := R; − 0 0 4 while R∞ ∪ R ∪ R |= ¬α and R 6= ∅ do 0 0 5 R := R \ {Ri ∩ R}; 6 i := i + 1; 7 return R∞ ∪ R− ∪ R0 |= α → β; In the partition < R, R− > of K, R represents all statements relevant to the query α |∼ β. When throwing away statements from a level, the algorithm only considers these statements in R as eligible for removal. We say that a statement α |∼ β is in the Relevant Closure of K if and only if the RelevantClosure algorithm returns true when given α |∼ β and K. 6.3 Defining Relevance Now that the algorithm has been defined, the only work remaining is to define how to calculate the partition < R, R− > for a given query α |∼ β. Based on the ideas explored by Casini et al. [2], we would want R to contain exactly all the statements used to prove ¬α. To formalize this, we present a sequence of definitions to gradually build up the idea of relevance. Definition 1. α is said to be exceptional for K if K |= ¬α. Definition 2. Let K be a knowledge base, J ⊆ K such that J only contains defeasible implications, and α a propositional sentence. Then J is said to be an α-justification w.r.t.K if α is exceptional for J and for any J 0 ⊂ J , α is not exceptional for J 0 . 10 M. Morris et al. Definition 3. For a sentence α and knowledge base K, let J K (α) = {J | J is an α-justification w.r.t. K}. Then α |∼ β is said toSbe in the Basic Relevant Closure of K if it is in the Relevant Closure of K w.r.t. J K (α). 6.4 Minimal Relevant Closure It could be argued that for Basic Relevant Closure, we are still considering too many statements as relevant to the query. This is because we consider all the statements in all α-justifications as relevant to proving that α is exceptional. However, we could instead consider only the statements of minimal rank from each α-justification as relevant, and still fix the exceptionality of α. K Definition 4. For some set of justifications J ⊆ K, let Jmin = {α |∼ β | rK (α) ≤ rK (γ) for every γ |∼ λ ∈ J }.S K K For a sentence α, let Jmin (α) = J ∈J K (α) Jmin . Then α |∼ β is said to be in Sthe Minimal Relevant Closure of K if it is in K the Relevant Closure of K w.r.t. Jmin (α). 6.5 Relevant Closure for Datalog In terms of adapting the RelevantClosure algorithm for Datalog, no further work needs to be done beyond what has already been said for Rational Closure. To define a molecule α being exceptional, we simply need to be able to check entailment of negated molecules, which is something we already know how to do. The remainder of the definitions for both Basic and Minimal Relevant Closure only entail manipulating sets and checking the rankings of statements. 6.6 LM-Rationality For this, we will use Minimal Relevant Closure as the definition for Relevant Closure. As shown by Casini et al. [2], Relevant Closure for propositional logic satisfies the properties Ref, LLE, And, and RW, and does not satisfy Or, CM, or RM. We will show that the same holds true for Relevant Closure for Datalog. Let us consider the proofs that show that Rational Closure fulfills the KLM properties of Ref, RW, and And. The only difference RelevantClosure has from RationalClosure is the inclusion of the “relevance partition”. Thus, the proofs can be re-used without editing, provided that the relevance partition is the same throughout the various queries. The relevance partition is fully determined by the antecedent of the query (e.g. α in α |∼ β), as can be seen in the definition of Minimal Relevant Closure. In the aforementioned properties, the antecedent is the same in all queries made to the algorithm. Hence, the proofs can be directly re-used to show that Relevant Closure fulfills the KLM properties of Ref, RW, and And. The proof for satisfaction of the property LLE and the counter-examples for satisfaction of the properties Or, CM, and RM can be found in Appendix F. The counter-examples were adapted from the ALC case [2]. Defeasible disjunctive datalog 11 7 Conclusions The main focus of this paper was to provide versions of defeasible reasoning for Disjunctive Datalog. To be able to express the KLM properties and the algorithm in Datalog, we motivated for extensions that would have to be made to the syntax and semantics of Datalog. We proved that Rational Closure for Datalog was LM-rational (i.e. it conforms to the KLM properties). We introduced Relevant Closure and Lexicographic Closure as alternatives for computing defeasible entailment and adapted both of the algorithms for Datalog. We found that Lexicographic Closure is still LM-rational, but that Relevant Closure does not satisfy some of the KLM properties. 8 Future Work Future work on this topic would most likely include finding a semantic defini- tion of Rational Closure for Datalog, based on minimal models. Other future work could include an attempted adaptation of the Relevant Closure method for computing defeasible entailment, done in such a way that it satisfies the KLM properties, while still maintaining the basic ideas of Relevant Closure. As another option, Casini et al. [4] showed that LM-rationality is necessary but not sufficient. The additional properties for Basic Defeasible Entailment pro- posed by Casini et al. [4] can be extended to Datalog. Furthermore, other prop- erties that are specific to defeasible entailment for Datalog should be explored. Finally, there is also potential for an implementation of defeasible reasoning in Datalog. In a paper submitted to this conference, Harrison and Meyer present an implementation of a defeasible Datalog reasoner for Rational Closure. 9 Appendices This full paper, with appendices, can be accessed online here. 12 M. Morris et al. References 1. Ben-Ari, M.: Mathematical Logic for Computer Science. Springer Science & Busi- ness Media, Rehovot, Israel (2012) 2. Casini, G., Meyer, T., Moodley, K., Nortje, R.: Relevant closure: A new form of defeasible reasoning for description logics. In: JELIA 2014: Logics in Artificial Intelligence. pp. 92–106. Springer, Funchal, Madeira, Portugal (2014) 3. Casini, G., Meyer, T., Moodley, K., Varzinczak, I.: Towards practical defeasible reasoning for description logics. In: Proceedings of the 26th International Workshop on Description Logics. pp. 587–599. CEUR Workshop Proceedings, Ulm, Germany (2013) 4. Casini, G., Meyer, T., Varzinczak, I.: Taking defeasible entailment beyond rational closure. In: JELIA 2019: Logics in Artificial Intelligence. pp. 182–197. Springer, Rende, Italy (2019) 5. Ceri, S., Gottlob, G., Tanca, L.: What you always wanted to know about datalog (and never dared to ask). IEEE Transactions on Knowledge and Data Engineering 1, 146–166 (1989) 6. Freund, M.: Preferential reasoning in the perspective of Poole default logic. Arti- ficial Intelligence 98, 209–235 (1998) 7. Genesereth, M., Eric, K.: Introduction to Logic. Morgan & Claypool, Stanford, California (2013) 8. Kraus, S., Lehmann, D., Magidor, M.: Nonmonotonic reasoning, preferential mod- els and cumulative logics. Artificial Intelligence 44, 167–207 (1990) 9. Lehmann, D.: Another perspective on default reasoning. Annals of Mathematics and Artificial Intelligence 15(1), 61–82 (1995) 10. Lehmann, D., Magidor, M.: What does a conditional knowledge base entail? Arti- ficial Intelligence 55, 1–60 (1992) 11. Moodley, K.: Practical Reasoning for Defeasible Description Logics. Ph.D. thesis, University of KwaZulu-Natal (2015). https://doi.org/10.31237/OSF.IO/DW5P2, https://thesiscommons.org/dw5p2/ 12. Pasarella, E., Lobo, J.: A Datalog Framework for Modeling Relationship- based Access Control Policies. In: Proceedings of the 22nd ACM on Sym- posium on Access Control Models and Technologies - SACMAT ’17 Ab- stracts. pp. 91–102. ACM Press, New York, New York, USA (2017). https://doi.org/10.1145/3078861.3078871 13. Shkapsky, A., Yang, M., Interlandi, M., Chiu, H., Condie, T., Zaniolo, C.: Big Data Analytics with Datalog Queries on Spark. In: Proceedings of the 2016 International Conference on Management of Data - SIGMOD ’16. pp. 1135–1149. ACM Press, New York, New York, USA (2016). https://doi.org/10.1145/2882903.2915229, http://dl.acm.org/citation.cfm?doid=2882903.2915229 14. Straccia, U., Casini, G.: Defeasible inheritance-based description logics. Journal of Artificial Intelligence Research 48, 415–473 (2013)