1 Introduction

Artificial intelligence for law is a prolific research area. In this area there have been many works on legal texts (e.g., legislation, regulations, contracts, and case law) modeling. This modeling pursues many goals, such as works on rule interchange issues, interoperability of rules’ systems which lead to proposal of rules’ format [1,2,3,4], legal ontologies construction [5, 6], design principles [7, 8], works on compliance checking problems [9, 10] or automatic formalization of rules [11,12,13], etc. In legal texts which compose corpora for these works, we usually have deontic statements. Some rule representation standards include the modeling of deontic statements [2,3,4]. But there is no reasoning process using these deontic statements. For example using current standards there is no mechanism that one can use to answer questions like Is fishing forbidden near the port of Brest?, or to make inferences like Since going left is forbidden then I must go straight, etc. Our goal in this article is to propose mechanisms for answering deontic questions. Our proposal stands as a first attempt for a proof theory for ontologically modeled deontic rules. Our contributions are:

  • An ontological modeling of deontic statement suitable for automatic reasoning on deontic rules.

  • A first proposal of mechanisms for automatic answering of deontic questions towards a rule base.

  • A first proposal of consistency checking process over a deontic rule base.

The rest of the paper starts with a presentation of related work in Sect. 2. Then, in Sect. 3, we introduce our work with a delimitation of the scope of rules we target. Next, in Sect. 4, we detail our modeling of rules. After that, we present the mechanisms to answer a deontic question and we discuss consistency checking in Sect. 5 and we illustrate them with detailed examples in Sect. 6. Finally, we present future work in Sect. 7. A demo is available at https://tinyurl.com/ydgwznba.

2 Related Work

Rule modeling has been a very active field in the past years and still has a great interest for researchers. During the last years, many authors have proposed modeling languages and formalisms to represent rules and/or legal documents. We present some of their works and we conclude this section with a presentation of works on a proof theory for defeasible rules for propositional logic.

  • Legal Knowledge Interchange Format (LKIF) is a specification that includes a legal core ontology and a legal rule language that can be used to deploy comprehensive legal knowledge management solutions. LKIF was developed in the ESTRELLA project [1, 14, 15]

  • RuleML is a family of languages, whose modular system of schemas for XML favors web rule interchange [2, 16]. The family’s top-level distinction is deliberation rules and reaction rules. Deliberation rules are made of modal and derivation rules, which themselves include facts, queries, and Horn rules. Reaction rules include Complex Event Processing, Knowledge Representation, Event-Condition-Action rules, as well as Production rules. RuleML rules can combine all parts of both derivation and reaction rules. There are many engines built for rulebases for subsets of RuleML (OO jDREWFootnote 1, ProvaFootnote 2, DR-DeviceFootnote 3, NxBREFootnote 4, PSOATransRunFootnote 5, etc.) but none of them infers on deontic rule bases.

  • OWL Judge [17] allows to make deontic inferences on rules modelled in OWL DL by using the LKIF modelling. Using a standard OWL reasoner (Pellet in their case) authors can classify rule instances as “permitted” or “prohibited”. This is similar to our goal of deontic QA but we do not work only at instances’ level and we provide detailed pieces of information (exceptions, related cases, etc.) so that a user can really figure out what the legal texts state on its question.

  • LegalRuleML is a standard (expressed with XML-schema and Relax NG) that is able to represent the particularities of the legal normative rules with a rich, articulated, and meaningful markup language [3]. LegalRuleML models defeasibility of rules and defeasible logic, deontic operators (e.g., obligations, permissions, prohibitions, rights), temporal management of rules and temporality in rules, classification of norms (i.e., constitutive, prescriptive), jurisdiction of norms, isomorphisms between rules and natural language normative provisions, identification of parts of the norms (e.g., bearer, conditions), authorial tracking of rules, etc. Concerning the rules themselves, LegalRuleML models the two main types of rules: (i) constitutive rules which define concepts or constitute activities that cannot exist without such rules, and (ii) prescriptive rules which regulate actions by making them obligatory, permitted, prohibited, recommended. The general shape of a LegalRuleML rule is \(\texttt {body} \implies \texttt {head}\) where, for both constitutive and prescriptive rules, where body is a set of formulas and deontic formulas and head is a formula (more precisely, the head of a constitutive rule is a formula and the one of a prescriptive rule is a set of deontic formulas). In this work, we take advantage of the rich modeling of normative documents within the LegalRuleML ontology and we propose an alternative to the ontological modeling of prescriptive rules. Using this new modeling, we propose mechanisms to answer deontic questions; they stand as a first step for the proposal of a proof theory for ontologically modeled deontic rules.

  • To answer deontic questions, we take into account the defeasibility of rules (i.e., rules can be defeated by stronger ones) and the existence of superiority relation between conflicting rules. Antoniou et al. [18] present a proof theory for defeasible logic, in the frame for propositional logic. They claim that a conclusion in a defeasible theory D is a tagged literal that can have one of the following forms: \(+\varDelta q\) if the proposition q is definitely provable in D, \(+\partial q\) if q is defeasibly provable in D, \(-\varDelta q\) if it is proved that q is not definitely provable in D and \(-\partial q\) if it is proved that q is not defeasibly provable in D. We will see that for a deontic question, we can answer definitely yes/no with or without exceptions or we can answer yes/no for specific cases only, with or without exceptions; there are also some cases where the answer is “unknown,” and finally cases for which the reasoner identifies inconsistencies.

3 Scope of the Modeling

As we mentioned in the related work section, our modeling is in line with LegalRuleML ontology (LRO). Our focus is on rule modeling for deontic reasoning. Our concern is the rules themselves and not the ecosystem around rules i.e., temporal data, jurisdiction, authorial tracking of rules, etc., since they are modeled in ontologies like LRO. The questions we intend to answer are:

  1. 1.

    How can we model rules to ease automated legal reasoning on these rules?

  2. 2.

    How can we perform automated reasoning on deontic rules?

In LegalRuleML specifications, the body of rules can have both simple formulas and deontic formulas. Also, the head of rules can be either a simple formula for constitutive rules or a set of deontic formulas for prescriptive rules. Here we consider prescriptive rules with no deontic formulas in the body part. A generalization to other types of rules is part of our future work (see Sect. 7).

4 Rule Modeling

We model a rule as a four-dimensional object: We consider that a rule is made of target(s), condition(s), context(s) and requirement(s). We provide the definition of these terms and illustrate them using the rule The captain of any ship, called upon to assist or tow a ship carrying oil or gaseous hydrocarbon residues in French territorial waters, shall immediately inform CROSS.Footnote 6

  • Target. The target of a rule is the entity towards which the rule is directed. It is the answer to the question “Who is the rule aimed at?”. In our example, the target is The captain of any ship.

  • Requirement. The requirement is what the target should do. In the example, the requirement is shall immediately inform CROSS.

  • Context. To find the context of a rule we answer the question “In which situation should be the target to execute the requirement of the rule?”. In our example, the context is that the captain of the ship being called upon to assist or tow a ship carrying oil or gaseous hydrocarbon residues.

  • Condition. Conditions are criteria that must be fulfilled so that the target is able to execute the requirement. In our example, the condition is that the ship (calling for assistance) facing an emergency is in French territorial waters.

We use the class shom:DeonticRule, the properties shom:ruleTarget,shom:ruleContext, shom:ruleRequirement, shom:ruleCondition andshom:deonticAction to model a rule. We use these entities to extend LRO as we show in Fig. 1Footnote 7.

Fig. 1.
figure 1

The Graffoo diagram summarizing the extension of LegalRuleml ontology.

In addition to the description of rules, LRO is able to describe the superiority relation that can exist between rules. Indeed, in some legal corpora we find conflicting rules and the ability of having a superiority relation avoids inconsistencies. In Sect. 6 we provide detail examples where we can see how LRO models the superiority relation and how this relation impacts inferences. It is crucial to have such priority relation to drive the right conclusion from a rule base.

5 Answering Deontic Questions

In this section, our goal is to draw a conclusion to answer the generic question “Is it OP to follow the requirement \(\mathcal {R}\) for target \(\mathcal {T}\) within the context \(\mathcal {C}\) and under the condition \(\mathcal {K}\)?” where OP denotes the correct form of one of the deontic terms mandatory, permitted, prohibited or recommended. We introduce this section with notation elements and mechanisms to answer a deontic question (Sect. 5.1) and then we detail the concepts introduced to present these mechanisms (Sects. 5.2 and 5.3).

5.1 Drawing a Deontic Conclusion

We use the following notation:

  • \(\mathcal {Q}_{\mathcal {C}, \mathcal {K}, \mathcal {T}, \texttt {OP}, \mathcal {R}}\) represents the question: “Is it OP to follow the requirement \(\mathcal {R}\) for target \(\mathcal {T}\) within the context \(\mathcal {C}\) and under conditions \(\mathcal {K}\)”. We use \(\mathcal {Q}\) for the shorten form of \(\mathcal {Q}_{\mathcal {C}, \mathcal {K}, \mathcal {T}, \texttt {OP}, \mathcal {R}}\)

  • \(+\mathfrak {C}_{\mathcal {C}, \mathcal {K}, \mathcal {T}, \texttt {OP}, \mathcal {R}}\) denotes the fact that we conclude “yes” to \(\mathcal {Q}_{\mathcal {C}, \mathcal {K}, \mathcal {T}, \texttt {OP}, \mathcal {R}}\).\(-\mathfrak {C}_{\mathcal {C}, \mathcal {K}, \mathcal {T}, \texttt {OP}, \mathcal {R}}\) stands for the answer “no” to \(\mathcal {Q}_{\mathcal {C}, \mathcal {K}, \mathcal {T}, \texttt {OP}, \mathcal {R}}\). Their shortened forms are \(+\mathfrak {C}\) and \(-\mathfrak {C}\). We write \(+\mathfrak {c}\) or \(-\mathfrak {c}\) when the “yes” or “no” answer partially holds, i.e., only for specific cases (to be determined in practice). \(+\mathfrak {C}_E\), \(-\mathfrak {C}_E\), \(+\mathfrak {c}_E\) and \(-\mathfrak {c}_E\) denote the fact that \(+\mathfrak {C}\), \(-\mathfrak {C}\), \(+\mathfrak {c}\) and \(-\mathfrak {c}\) are augmented with the list of exceptions.

  • \(\varDelta \mathrm {Pros}(\mathcal {Q})\) is the set of rules that support a “yes” to \(\mathcal {Q}\), i.e., that support a conclusion \(+\mathfrak {C}\). \(\varDelta \mathrm {Cons}(\mathcal {Q})\) is the set of rules that support a “no” to \(\mathcal {Q}\), i.e., that elements of \(\varDelta \mathrm {Cons}(\mathcal {Q})\) support \(-\mathfrak {C}\).

  • For two sets of rules \(R_1\) and \(R_2\), \(R_1> R_2 \Leftrightarrow \forall r_2 \in R_2, \exists r_1 \in R_1 : r_1 \ne r_2 \ and \ r_1 > r_2\) (i.e. \(r_1\) overrules \(r_2\)).

  • \(\partial \mathrm {Pros}(\mathcal {Q})\) is the set of rules that partially support a “yes” to \(\mathcal {Q}\), i.e., that support a conclusion \(+\mathfrak {c}\). Similarly, \(\partial \mathrm {Cons}(\mathcal {Q})\) is the set of rules that partially support a “no” to \(\mathcal {Q}\), i.e., that support a conclusion \(-\mathfrak {c}\).

To answer the question \(\mathcal {Q}_{\mathcal {C}, \mathcal {K}, \mathcal {T}, \texttt {OP}, \mathcal {R}}\) (a.k.a. \(\mathcal {Q}\)), we proceed as follows:

  1. 1.

    We build \(\varDelta \mathrm {Pros}(\mathcal {Q})\) and \(\varDelta \mathrm {Cons}(\mathcal {Q})\). Hence, four scenarios can arise:

    1. (a)

      \(\varDelta \mathrm {Pros}(\mathcal {Q}) \ne \emptyset \) and \(\varDelta \mathrm {Cons}(\mathcal {Q}) \ne \emptyset \).

      • If \(\varDelta \mathrm {Pros}(\mathcal {Q}) > \varDelta \mathrm {Cons}(\mathcal {Q})\) then \(+\mathfrak {C}_E\)

      • Else if \(\varDelta \mathrm {Cons}(\mathcal {Q}) > \varDelta \mathrm {Pros}(\mathcal {Q})\), then \(-\mathfrak {C}_E\)

      • Else "unknown (potential inconsistencies)"

      For \(+\mathfrak {C}_E\) and \(-\mathfrak {C}_E\), the procedure to get exceptions is given in part Sect. 5.3

    2. (b)

      \(\varDelta \mathrm {Pros}(\mathcal {Q}) \ne \emptyset \) and \(\varDelta \mathrm {Cons}(\mathcal {Q}) = \emptyset \). We conclude \(+\mathfrak {C}_E\)

    3. (c)

      \(\varDelta \mathrm {Pros}(\mathcal {Q}) = \emptyset \) and \(\varDelta \mathrm {Cons}(\mathcal {Q}) \ne \emptyset \). We conclude \(-\mathfrak {C}_E\)

    4. (d)

      \(\varDelta \mathrm {Pros}(\mathcal {Q})= \emptyset \) and \(\varDelta \mathrm {Cons}(\mathcal {Q}) = \emptyset \). We go to step (2)

  2. 2.

    If \(\varDelta \mathrm {Pros}(\mathcal {Q}) = \varDelta \mathrm {Cons}(\mathcal {Q}) = \emptyset \), we find if there are rules which support the partial conclusions \(+\mathfrak {c}\) or \(-\mathfrak {c}\). So, we build \(\partial \mathrm {Pros}(\mathcal {Q})\) and \(\partial \mathrm {Cons}(\mathcal {Q})\) and:

    1. (a)

      If \(\partial \mathrm {Pros}(\mathcal {Q}) \ne \emptyset \) and \(\partial \mathrm {Cons}(\mathcal {Q}) \ne \emptyset \): we conclude both \(+\mathfrak {c}_E\) and \(-\mathfrak {c}_E\)

    2. (b)

      If \(\partial \mathrm {Pros}(\mathcal {Q}) \ne \emptyset \) and \(\partial \mathrm {Cons}(\mathcal {Q}) = \emptyset \). We conclude \(+\mathfrak {c}\) (it cannot have any exception, since at this stage \(\partial \mathrm {Cons}(\mathcal {Q}) = \varDelta \mathrm {Cons}(\mathcal {Q}) = \emptyset \))

    3. (c)

      \(\partial \mathrm {Pros}(\mathcal {Q}) = \emptyset \) and \(\partial \mathrm {Cons}(\mathcal {Q}) \ne \emptyset \). We conclude \(-\mathfrak {c}\)

    4. (d)

      \(\partial \mathrm {Pros}(\mathcal {Q}) = \emptyset \) and \(\partial \mathrm {Cons}(\mathcal {Q}) = \emptyset \). Since \(\varDelta \mathrm {Pros}(\mathcal {Q}) =\varDelta \mathrm {Cons}(\mathcal {Q}) = \emptyset \) we answer "unknown"

In the next sections, we detail the construction of sets \(\varDelta \mathrm {Pros}(\mathcal {Q})\), \(\varDelta \mathrm {Cons}(\mathcal {Q})\), \(\partial \mathrm {Pros}(\mathcal {Q})\) and \(\partial \mathrm {Cons}(\mathcal {Q})\) (Sect. 5.2) and the way we find exceptions to a conclusion (Sect. 5.3).

5.2 Building of \(\varDelta \mathrm {Pros}(\mathcal {Q})\), \(\varDelta \mathrm {Cons}(\mathcal {Q})\), \(\partial \mathrm {Pros}(\mathcal {Q})\) and \(\partial \mathrm {Cons}(\mathcal {Q})\)

In this section we give the formal expressions of \(\varDelta \mathrm {Pros}(\mathcal {Q})\), \(\varDelta \mathrm {Cons}(\mathcal {Q})\), \(\partial \mathrm {Pros}(\mathcal {Q})\) and \(\partial \mathrm {Cons}(\mathcal {Q})\). These expressions use the following notation:

  • \(A\ \texttt {a}\ B\) represents the assertion “A rdf:type B”.

  • \(A \subseteq ^+ B\) means one of “\(A\ \texttt {rdfs:subClassOf}\ B\),” “\(A\ \texttt {owl:sameAs}\ B\),” “\(A\ \texttt {a}\ B\)” is true. In this case we say that A is included in B or A is narrower than B or B contains A or B is broader than A. The relation \(\subseteq ^+\) is reflexive

  • \(A \subseteq ^{\tau }B\) means “\(\exists C\) so that \(C \subseteq ^+ A\) and \(C \subseteq ^+ B\)” is true. A specific case of this relation is when A and B are both superclasses of a third class C. In this case, we say that A and B share a common sub-entity.

  • \(A \subseteq ^* B\) means one of “\(A \subseteq ^+ B\)” or “\(B \subseteq ^+ A\)” or “\(A \subseteq ^{\tau }B\)” is true. In this case we say that A is related to B.

  • \((A_1, \dots , A_i, \dots , A_n) \,\mathfrak {R}\, (B_1, \dots , B_i, \dots , B_n) \equiv \forall \,i\in [1,n], A_i \,\mathfrak {R}\, B_i\), where \(\mathfrak {R}\) represents the relations \(\subseteq ^+\) or \(\subseteq ^*\) or \(\subseteq ^{\tau }\).

  • We call parameters of an entity the quadruple made of its context \(\mathcal {C}\), its condition \(\mathcal {K}\), its target \(\mathcal {T}\) and its requirement \(\mathcal {R}\). Here the term “entity” refers to a question \(\mathcal {Q}_{\mathcal {C}, \mathcal {K}, \mathcal {T}, \texttt {OP}, \mathcal {R}}\), or to a conclusion \(\pm \mathfrak {C}_{\mathcal {C}, \mathcal {K}, \mathcal {T}, \texttt {OP}, \mathcal {R}}\) or to an instance r of shom:DeonticRule. We note the parameters of an entity E as \((\mathcal {C}_{E}, \mathcal {K}_{E}, \mathcal {T}_{E}, \mathcal {R}_{E})\).

  • We define the notion of conflicting deontic operator. For each type of deontic operator, Table 1 gives the ones that are in conflict with it.

Table 1. Operations on deontic operators. PER: permission, PRO: prohibition, OBL: obligation, REC: recommendation, RIG: right

To understand Table 1 let us take for instance the first deontic operator: \(\lnot (\texttt {PER}) = \{\texttt {PRO}\}\) means that everything that is prohibited (in a given context, conditions, and for a given target), is not permitted (in that same context, under those same conditions and for that same target).

Definition 1

The sup-rules of \((\mathcal {C}, \mathcal {K}, \mathcal {T}, \mathtt{OP},\mathcal {R})\), are the rules having a deontic operator equal to OP and whose parameters are broader than \((\mathcal {C}, \mathcal {K}, \mathcal {T}, \mathcal {R})\), i.e.,

$$\text {sup-rules}(\mathcal {C}, \mathcal {K}, \mathcal {T}, \mathtt{OP},\mathcal {R})= \{r, (\mathcal {C}, \mathcal {K}, \mathcal {T}, \mathcal {R})\subseteq ^+ (\mathcal {C}_{r}, \mathcal {K}_{r}, \mathcal {T}_{r}, \mathcal {R}_{r}) \wedge {\mathtt{OP}_r} = \mathtt{OP}\}.$$

Definition 2

The neg-sup-rules of \((\mathcal {C}, \mathcal {K}, \mathcal {T}, \mathtt{OP},\mathcal {R})\), are the rules having a deontic operator that conflicts OP and whose parameters are broader than \((\mathcal {C}, \mathcal {K}, \mathcal {T}, \mathcal {R})\), i.e.,

$$\begin{aligned} \text {neg-sup-rules}(\mathcal {C}, \mathcal {K}, \mathcal {T}, \mathtt{OP},\mathcal {R})&= \{r,(\mathcal {C}, \mathcal {K}, \mathcal {T}, \mathcal {R})\subseteq ^+ (\mathcal {C}_{r}, \mathcal {K}_{r}, \mathcal {T}_{r}, \mathcal {R}_{r}) \wedge \mathtt{OP}_r \in \lnot (\mathtt{OP})\}&\\&=\bigcup _{\mathtt{OP}'\,\in \, \lnot (\mathtt{OP})} \text {sup-rules}(\mathcal {C}, \mathcal {K}, \mathcal {T}, \mathtt{OP}', \mathcal {R}).&\end{aligned}$$

The sup-rules of \((\mathcal {C}, \mathcal {K}, \mathcal {T}, \mathtt{OP},\mathcal {R})\) are the rules that (fully) endorse the veracity of the assertion In context \(\mathcal {C}\), and under conditions \(\mathcal {K}\), the target \(\mathcal {T}\) is OP to (do/have/follow) \(\mathcal {R}\). This endorsement relies on the fact that each parameter of a rule of \(\textit{sup-rules}(\mathcal {C}, \mathcal {K}, \mathcal {T}, \mathtt{OP},\mathcal {R})\) is broader than its corresponding parameter in \((\mathcal {C}, \mathcal {K}, \mathcal {T}, \mathcal {R})\) and that the operator of the rule equals OP. On the other hand, neg-sup-rules are the rules that counter-attack the aforementioned assertion.

Definition 3

The rel-rules of \((\mathcal {C}, \mathcal {K}, \mathcal {T}, \mathtt{OP},\mathcal {R})\) are the rules having a deontic operator equal to OP and whose parameters are related to \((\mathcal {C}, \mathcal {K}, \mathcal {T}, \mathcal {R})\), i.e.,

$$\text {rel-rules}(\mathcal {C}, \mathcal {K}, \mathcal {T}, \mathtt{OP},\mathcal {R})= \{r,(\mathcal {C}, \mathcal {K}, \mathcal {T}, \mathcal {R})\subseteq ^* (\mathcal {C}_{r}, \mathcal {K}_{r}, \mathcal {T}_{r}, \mathcal {R}_{r}) \wedge \mathtt{OP}_r = \mathtt{OP}\}.$$

Definition 4

The neg-rel-rules of \((\mathcal {C}, \mathcal {K}, \mathcal {T}, \mathtt{OP},\mathcal {R})\) are the rules having a deontic operator that conflicts OP and whose parameters are related to \((\mathcal {C}, \mathcal {K}, \mathcal {T}, \mathcal {R})\), i.e.,

$$\begin{aligned} \text {neg-rel-rules}(\mathcal {C}, \mathcal {K}, \mathcal {T}, \mathtt{OP},\mathcal {R})&= \{r, (\mathcal {C}, \mathcal {K}, \mathcal {T}, \mathcal {R})\subseteq ^* (\mathcal {C}_{r}, \mathcal {K}_{r}, \mathcal {T}_{r}, \mathcal {R}_{r}) \wedge \mathtt{Op}_r \in \lnot (\mathtt{OP})\}&\\&=\bigcup _{\mathtt{OP}'\,\in \, \lnot (\mathtt{OP})} \text {rel-rules}(\mathcal {C}, \mathcal {K}, \mathcal {T}, \mathtt{OP}', \mathcal {R}).&\end{aligned}$$

A rule \(\rho \) is an element of \(rel-rules (\mathcal {C}, \mathcal {K}, \mathcal {T}, \mathtt{OP},\mathcal {R})\) if each of its parameters \((\mathcal {C}_{\rho }, \mathcal {K}_{\rho }, \mathcal {T}_{\rho }, \mathcal {R}_{\rho })\) is related, i.e., is broader or narrower than, or shares a common sub-entity with, the corresponding parameter from \((\mathcal {C}, \mathcal {K}, \mathcal {T}, \mathcal {R})\). So when we put all parameters of \(\rho \) together, either: (i) \((\mathcal {C}, \mathcal {K}, \mathcal {T}, \mathcal {R})\subseteq ^+(\mathcal {C}_{\rho }, \mathcal {K}_{\rho }, \mathcal {T}_{\rho }, \mathcal {R}_{\rho })\) or (ii) there is at least a parameter of \(\rho \) that is strictly narrower thanFootnote 8 the respective one in \((\mathcal {C}, \mathcal {K}, \mathcal {T}, \mathcal {R})\). Hence, “related” rules in case (i) are also member of \(sup-rules (\mathcal {C}, \mathcal {K}, \mathcal {T}, \mathtt{OP},\mathcal {R})\) and those in case (ii) support partially, because of their “strictly narrow” parameters, the assertion behind \((\mathcal {C}, \mathcal {K}, \mathcal {T}, \mathtt{OP},\mathcal {R})\): we use them to define \(\partial \mathrm {Pros}\).

A similar discourse holds for \(neg-rel-rules (\mathcal {C}, \mathcal {K}, \mathcal {T}, \mathtt{OP},\mathcal {R})\).

Definition 5

We say that a rule r (fully) supports a “yes” to \(\mathcal {Q}\) if (i) \(\mathtt{OP}_r = \mathtt{OP}_{\mathcal {Q}}\) and (ii) \((\mathcal {C}_{\mathcal {Q}}, \mathcal {K}_{\mathcal {Q}}, \mathcal {T}_{\mathcal {Q}}, \mathcal {R}_{\mathcal {Q}}) \subseteq ^+ (\mathcal {C}_{r}, \mathcal {K}_{r}, \mathcal {T}_{r}, \mathcal {R}_{r})\). In other words, if r belongs to \(\textit{sup-rules}(\mathcal {Q})\). Hence,

$$\begin{aligned} \varDelta \mathrm {Pros}(\mathcal {Q}) = \textit{sup-rules}(\mathcal {Q}). \end{aligned}$$
(1)

Definition 6

We say that a rule r (fully) supports a “no” to \(\mathcal {Q}\) if (i) \(r\in neg(\mathcal {Q})\) and (ii) \((\mathcal {C}_{\mathcal {Q}}, \mathcal {K}_{\mathcal {Q}}, \mathcal {T}_{\mathcal {Q}}, \mathcal {R}_{\mathcal {Q}}) \subseteq ^+ (\mathcal {C}_{r}, \mathcal {K}_{r}, \mathcal {T}_{r}, \mathcal {R}_{r})\). In other words, if r belongs to \(\textit{neg-sup-rules}(\mathcal {Q})\). So,

$$\begin{aligned} \varDelta \mathrm {Cons}(\mathcal {Q}) = \textit{neg-sup-rules}(\mathcal {Q}). \end{aligned}$$
(2)

Definition 7

We say that a rule r partially supports a “yes” to \(\mathcal {Q}\) if (i) \(\mathtt{OP}_r = \mathtt{OP}_{\mathcal {Q}}\), (ii) \((\mathcal {C}_{\mathcal {Q}}, \mathcal {K}_{\mathcal {Q}}, \mathcal {T}_{\mathcal {Q}}, \mathcal {R}_{\mathcal {Q}}) \subseteq ^* (\mathcal {C}_{r}, \mathcal {K}_{r}, \mathcal {T}_{r}, \mathcal {R}_{r})\) and (iii) \(r \notin \textit{sup-rule}(\mathcal {Q})\). Thus,

$$\begin{aligned} \partial \mathrm {Pros}(\mathcal {Q}) = \textit{rel-rules}(\mathcal {Q}) \setminus \textit{sup-rules}(\mathcal {Q}). \end{aligned}$$
(3)

Definition 8

We say that a rule r partially supports a “no” to \(\mathcal {Q}\) if (i) \(\mathtt{OP}_r\in neg(\mathcal {Q})\), (ii) \((\mathcal {C}_{\mathcal {Q}}, \mathcal {K}_{\mathcal {Q}}, \mathcal {T}_{\mathcal {Q}}, \mathcal {R}_{\mathcal {Q}}) \subseteq ^* (\mathcal {C}_{r}, \mathcal {K}_{r}, \mathcal {T}_{r}, \mathcal {R}_{r})\) and (iii) \(r \notin \textit{neg-sup-rule}(\mathcal {Q})\). Therefore,

$$\begin{aligned} \partial \mathrm {Cons}(\mathcal {Q}) = \textit{neg-rel-rules}(\mathcal {Q}) \setminus \textit{neg-sup-rules}(\mathcal {Q}). \end{aligned}$$
(4)

We use the SPARQL query of Listing 1.1 to retrieve elements of \(\textit{sup-rules}(\mathcal {Q})\). The WHERE clause of this SPARQL query strictly follows the expression given in Definition 1. In this SPARQL query, \(\mathrm {Class}(\texttt {OP})\) represents the class of the deontic operator OP, i.e., a sub-class of lrmlmm:DeoncticSpecification as shown in Fig. 1. Definition 6 gives two equivalent expressions of \(\textit{neg-sup-rules}(\mathcal {Q})\), where the second reuses \(\textit{sup-rules}(\mathcal {Q})\). Therefore we can adapt the SPARQL of Listing 1.1 with the suitable parameters, to build \(\textit{neg-sup-rules}(\mathcal {Q})\).

figure a

We rely on the SPARQL query of Listing 1.2 to build the set \(\textit{rel-rules}(\mathcal {Q})\). This query follows the expression of \(\textit{rel-rules}(\mathcal {Q})\) given in Definition 3. Also, following its second expression in Definition 4, we can retrieve elements of \(\textit{neg-rel-rules}(\mathcal {Q})\) using the SPARQL query of \(\textit{rel-rules}(\mathcal {Q})\).

figure b

Having detailed how to obtain \(\varDelta \mathrm {Pros}(\mathcal {Q})\), \(\varDelta \mathrm {Cons}(\mathcal {Q})\), \(\partial \mathrm {Pros}(\mathcal {Q})\) and \(\partial \mathrm {Cons}(\mathcal {Q})\), we move to the next section where we present how to obtain exceptions to a conclusion.

5.3 Exceptions to a Conclusion

In some cases there are specific rules that counter-attack the conclusions \(+\mathfrak {C}\), \(-\mathfrak {C}\), \(+\mathfrak {c}\) or \(-\mathfrak {c}\). These rules are called “exceptions”. In Definition 9 below, \(\mathfrak {C}\) represents a conclusion, which can be \(+\mathfrak {C}\), \(-\mathfrak {C}\), \(+\mathfrak {c}\) or \(-\mathfrak {c}\).

Definition 9

An exception to a conclusion \(\mathfrak {C}\) is any rule r that (i) is partially in favor of an opposite conclusion \(\mathfrak {C}'\) to the one actually made (i.e., \(\mathfrak {C}\)), and (ii) is not overruled by a rule that fully supports the conclusion \(\mathfrak {C}\).

Since an exception supports an opposite conclusion to the one actually made we must distinguish the case where the current conclusion is \(+\mathfrak {C}\) or \(+\mathfrak {c}\), and the case where it is \(-\mathfrak {C}\) or \(-\mathfrak {c}\). This is necessary because the criteria to be opposed to those two groups of conclusions are not the same:

  1. 1.

    A rule that counter-attacks \(+\mathfrak {C}\) or \(+\mathfrak {c}\) necessarily has a deontic operator that is in conflict with the one of the conclusion. Hence, in this case, a formal transcription of Definition 9 tells us that the set of exceptions equals to:

    $$\begin{aligned} \bigg \{ r\,\in \overbrace{\{\bigcup _{\texttt {OP}'\,\in \, neg(\texttt {OP}_{\mathfrak {C}})} \partial \mathrm {Pros}(\mathcal {Q}_{\mathcal {C}_{\mathfrak {C}}, \mathcal {K}_{\mathfrak {C}}, \mathcal {T}_{\mathfrak {C}}, \texttt {OP}', \mathcal {R}_{\mathfrak {C}}})\}}^\mathrm{(i)} \quad \quad \quad \quad \quad \quad \quad \quad \qquad \qquad \nonumber \\ \underbrace{\wedge \quad \not \exists \, r'\,\in \varDelta \mathrm {Pros}(\mathcal {Q}_{\mathcal {C}_{\mathfrak {C}}, \mathcal {K}_{\mathfrak {C}}, \mathcal {T}_{\mathfrak {C}}, \texttt {OP}_\mathfrak {C}, \mathcal {R}_{\mathfrak {C}}}), r'>r}_\mathrm{(ii)}\bigg \}. \end{aligned}$$
    (5)

    In Eq. 5:

    • Part (i) represents the formal expression of item (i) of Definition 9. There, we mention that a rule that is an exception to a “positive” conclusion (i.e., \(+\mathfrak {C}\) or \(+\mathfrak {c}\)) necessarily has a partial support to a “yes” at any question with parameters related to those of the conclusion, but with a conflicting deontic operator.

    • Part (ii) represents the fact that the rule must not be overruled by another rule (fully) in favor of the conclusion (hence the use of \(\varDelta \mathrm {Pros}\)). It corresponds to item (ii) of Definition 9.

  2. 2.

    A rule that counter-attacks \(-\mathfrak {C}\) or \(-\mathfrak {c}\) must have a deontic operator that is the same as the one in the conclusion. Hence, similar to Eq. 5, a formal representation of Definition 9 tells us that, in this case, the set of exceptions equals to:

    $$\begin{aligned} \bigg \{ r\,\in \overbrace{\{ \partial \mathrm {Pros}(\mathcal {C}_{\mathfrak {C}}, \mathcal {K}_{\mathfrak {C}}, \mathcal {T}_{\mathfrak {C}}, \texttt {OP}_{\mathfrak {C}}, \mathcal {R}_{\mathfrak {C}})\}}^\mathrm{(i)} \underbrace{\wedge \, \not \exists \, r'\,\in \varDelta \mathrm {Cons}(\mathcal {Q}_{\mathcal {C}_{\mathfrak {C}}, \mathcal {K}_{\mathfrak {C}}, \mathcal {T}_{\mathfrak {C}}, \texttt {OP}_\mathfrak {C}, \mathcal {R}_{\mathfrak {C}}}), r'>r}_\mathrm{(ii)}\bigg \}. \end{aligned}$$
    (6)

It is important to notice that we must find exceptions to rules recursively. In other words, for rules that partially attack a conclusion, we must investigate whether these rules have exceptions in their turn, and so on.

In Fig. 2, we summarize the steps of our deontic reasoning process as it is implemented to answer a deontic question. In this figure:

  • All steps before the dashed line map the process described in Sect. 5.1 where we identify the conclusion to the question.

  • The processes labeled ➊ and ➋ correspond to Eqs. 5 and 6 respectively.

  • In the process ➌, we recursively find exceptions, and then in ➍ we build the exceptions dependency graph \(\mathcal {G}\). \(\mathcal {G}\) is oriented. Vertices of \(\mathcal {G}\) are the rules used to answer the question (i.e., \(\varDelta \mathrm {Pros}\) and \(\varDelta \mathrm {Cons}\) if non empty or \(\partial \mathrm {Pros}\) and \(\partial \mathrm {Cons}\) otherwise), including the exceptions identified during step ➌. Furthermore, \((r,\rho )\) is an edge of \(\mathcal {G}\) if \(\rho \) is an exception of r. Hence, a cycle in \(\mathcal {G}\) is equivalent to an inconsistency.

  • Step ➎ is a user friendly output of the answer.

Fig. 2.
figure 2

Pipeline to answer a deontic question. (Color figure online)

Checking the consistency of a deontic rule base By analyzing the structure of the exceptions dependency graph we can now detect inconsistencies. But this holds only for the subset of rules, including their exceptions, that are used to answer a given deontic question. Therefore, the challenge is to ask a question \(\mathcal {Q}_{\Omega }\) that embraces all rules of the base, like: Whatever the context, the condition and the target, is it permitted to do something?. Formally, all the parameters of \(\mathcal {Q}_{\Omega }\) are equal to owl:Thing, so it is immediate to see that each rule of the base is related (in the meaning of the operator \(\subseteq ^*\)). Consequently, according to Fig. 2, one of the following will always be true:

  • We reach the red node so the inconsistency of the base is immediate.

  • We reach one of the orange nodes, so there is no exception to a “yes” or “no” to \(\mathcal {Q}_{\Omega }\) and then no inconsistency is possible.

  • We reach the yellow node, which means the rule base is empty, since parameters of any rule are necessarily related to those of \(\mathcal {Q}_{\Omega }\), in which case we can conclude that the base is not inconsistent.

  • We reach a conclusion which requires to find exceptions (i.e., \(+\mathfrak {C}_E\), \(-\mathfrak {C}_E\), \(+\mathfrak {c}_E\) and \(-\mathfrak {c}_E\)), and knowing that the parameters of any rule are related to those of \(\mathcal {Q}_{\Omega }\), the recursive search of exceptions will involve every rule of the base; having a cycle in this graph is equivalent to the presence of inconsistent requirements in the base.

6 Detailed Examples

We use the following excerpt of the French arrêté préfectoral n\({}^{\text {o}}\) 96/2015Footnote 9 to illustrate how we draw conclusions from a deontic rule base:

  • Article 1: It is forbidden to navigate near the Paluel nuclear center (PNC).

  • Article 2: In derogation to Article 1, are allowed to sail near the PNC: Military vessels; any vessel in need of assistance.

From these two articles, we extract the following rules and priority relations:

figure c

Hence, for the three rules R1, R2 and R3 above, we have:

figure d

The following relations between R1, R2 and R3 hold

$$\begin{aligned} (\mathcal {C}_{\texttt {R2}}, \mathcal {K}_{\texttt {R2}}, \mathcal {T}_{\texttt {R2}}, \mathcal {R}_{\texttt {R2}}) \subseteq ^+(\mathcal {C}_{\texttt {R1}}, \mathcal {K}_{\texttt {R1}}, \mathcal {T}_{\texttt {R1}}, \mathcal {R}_{\texttt {R1}}) \end{aligned}$$
(7)
$$\begin{aligned} (\mathcal {C}_{\texttt {R3}}, \mathcal {K}_{\texttt {R3}}, \mathcal {T}_{\texttt {R3}}, \mathcal {R}_{\texttt {R3}})\subseteq ^+(\mathcal {C}_{\texttt {R1}}, \mathcal {K}_{\texttt {R1}}, \mathcal {T}_{\texttt {R1}}, \mathcal {R}_{\texttt {R1}}) \end{aligned}$$
(8)
$$\begin{aligned} (\mathcal {C}_{\texttt {R2}}, \mathcal {K}_{\texttt {R2}}, \mathcal {T}_{\texttt {R2}}, \mathcal {R}_{\texttt {R2}}) \subseteq ^* (\mathcal {C}_{\texttt {R1}}, \mathcal {K}_{\texttt {R1}}, \mathcal {T}_{\texttt {R1}}, \mathcal {R}_{\texttt {R1}}) \end{aligned}$$
(9)
$$\begin{aligned} (\mathcal {C}_{\texttt {R3}}, \mathcal {K}_{\texttt {R3}}, \mathcal {T}_{\texttt {R3}}, \mathcal {R}_{\texttt {R3}}) \subseteq ^* (\mathcal {C}_{\texttt {R1}}, \mathcal {K}_{\texttt {R1}}, \mathcal {T}_{\texttt {R1}}, \mathcal {R}_{\texttt {R1}}) \end{aligned}$$
(10)

Also, we recall that \(\subseteq ^+\) and \(\subseteq ^*\) are reflexive relations.

6.1 \(\mathcal {Q}^{a}\) Is it Allowed to Navigate Near the PNC for Military Vessels?

We have: \(\mathcal {C}_{\mathcal {Q}^{a}}=\texttt {owl:Thing}\), \(\mathcal {K}_{\mathcal {Q}^{a}}=\texttt {owl:Thing}\), \(\mathcal {T}_{\mathcal {Q}^{a}}=\texttt {:MilitaryVessel}\), \(\texttt {OP}_{\mathcal {Q}^{a}}=\texttt {PER}\), and \(\mathcal {R}_{\mathcal {Q}^{a}}=\texttt {:NavPaluel}\). We note that \(\mathcal {Q}^{a}\) and \(\texttt {R2}\) have the same parameters, and the same deontic parameters, so Eqs. 7 and 9 above hold with \(\mathcal {Q}^{a}\) playing the role of R2. A rule \(\rho \) belongs to \(\varDelta \mathrm {Pros}(\mathcal {Q}^{a})\) if and only if \((\mathcal {C}_{\mathcal {Q}^{a}}, \mathcal {K}_{\mathcal {Q}^{a}}, \mathcal {T}_{\mathcal {Q}^{a}}, \mathcal {R}_{\mathcal {Q}^{a}})\subseteq ^+(\mathcal {C}_{\rho }, \mathcal {K}_{\rho }, \mathcal {T}_{\rho }, \mathcal {R}_{\rho })\) and \(\texttt {OP}_{\mathcal {Q}^{a}} = \texttt {OP}_{\rho }\). So we have \(\varDelta \mathrm {Pros}(\mathcal {Q}^{a}) = \{\texttt {R2}\}\). Also, \(\gamma \in \varDelta \mathrm {Cons}(\mathcal {Q}^{a})\) if and only if \((\mathcal {C}_{\mathcal {Q}^{a}}, \mathcal {K}_{\mathcal {Q}^{a}}, \mathcal {T}_{\mathcal {Q}^{a}}, \mathcal {R}_{\mathcal {Q}^{a}})\subseteq ^+(\mathcal {C}_{\gamma }, \mathcal {K}_{\gamma }, \mathcal {T}_{\gamma }, \mathcal {R}_{\gamma })\) and \(\texttt {OP}_{\gamma } \in neg(\texttt {OP}_{\mathcal {Q}^{a}})\). So \(\varDelta \mathrm {Cons}(\mathcal {Q}^{a})=\{\texttt {R1}\}\) (thanks to Eq. 7). Now we must see whether one of \(\varDelta \mathrm {Pros}(\mathcal {Q}^{a})\) or \(\varDelta \mathrm {Cons}(\mathcal {Q}^{a})\) overrules the other. Line 18 of the Listing 1.3 implies \(\varDelta \mathrm {Pros}(\mathcal {Q}^{a}) > \varDelta \mathrm {Cons}(\mathcal {Q}^{a})\). So we conclude that we have \(+\mathfrak {C}_E\), i.e., Yes, it is allowed to do so. Next, we need to identify potential exceptions. Based on Eq. 5, we say that \(\eta \) is an exception to the above conclusion if \((\mathcal {C}_{\eta }, \mathcal {K}_{\eta }, \mathcal {T}_{\eta }, \mathcal {R}_{\eta })\subseteq ^*(\mathcal {C}_{\mathcal {Q}^{a}}, \mathcal {K}_{\mathcal {Q}^{a}}, \mathcal {T}_{\mathcal {Q}^{a}}, \mathcal {R}_{\mathcal {Q}^{a}})\), \((\mathcal {C}_{\mathcal {Q}^{a}}, \mathcal {K}_{\mathcal {Q}^{a}}, \mathcal {T}_{\mathcal {Q}^{a}}, \mathcal {R}_{\mathcal {Q}^{a}})\not \subseteq ^+(\mathcal {C}_{\eta }, \mathcal {K}_{\eta }, \mathcal {T}_{\eta }, \mathcal {R}_{\eta })\), and \(\texttt {OP}_{\eta }\in neg(\texttt {OP}_{\mathcal {Q}^{a}})\). No rule in the base meets this criteria, so the answer to \(\mathcal {Q}^{a}\) remains unchanged (no exception added).

6.2 \(\mathcal {Q}^{b}\) Is Any Vessel Allowed to Navigate Near the PNC?

We have: \(\mathcal {C}_{\mathcal {Q}^{b}}=\texttt {owl:Thing}\), \(\mathcal {K}_{\mathcal {Q}^{b}}=\texttt {owl:Thing}\), \(\mathcal {T}_{\mathcal {Q}^{b}}=\texttt {:Vessel}\), \(\texttt {OP}_{\mathcal {Q}^{b}}=\texttt {PER}\), \(\mathcal {R}_{\mathcal {Q}^{b}}=\texttt {:NavPaluel}\). We note that \(\mathcal {Q}^{b}\) and R1 have the same parameters but have conflicting deontic operators. \(\varDelta \mathrm {Pros}(\mathcal {Q}^{b}) = \emptyset \) and \(\varDelta \mathrm {Cons}(\mathcal {Q}^{b}) = \{\texttt {R1}\}\). Hence, we conclude \(-\mathfrak {C}_E\) (see item 1c), i.e., No, it is not allowed. Let us now find exceptions. In this case, we refer to Eq. 6, so \(\eta \) is an exception to the above conclusion if \((\mathcal {C}_{\eta }, \mathcal {K}_{\eta }, \mathcal {T}_{\eta }, \mathcal {R}_{\eta })\subseteq ^*(\mathcal {C}_{\mathcal {Q}^{b}}, \mathcal {K}_{\mathcal {Q}^{b}}, \mathcal {T}_{\mathcal {Q}^{b}}, \mathcal {R}_{\mathcal {Q}^{b}})\), \((\mathcal {C}_{\mathcal {Q}^{b}}, \mathcal {K}_{\mathcal {Q}^{b}}, \mathcal {T}_{\mathcal {Q}^{b}}, \mathcal {R}_{\mathcal {Q}^{b}})\not \subseteq ^+(\mathcal {C}_{\eta }, \mathcal {K}_{\eta }, \mathcal {T}_{\eta }, \mathcal {R}_{\eta })\), and \(\texttt {OP}_{\eta }=\texttt {OP}_{\mathcal {Q}^{b}}\). Thanks to Eqs. 710 we see that R2 and R3 meet these criteria. To be definitely considered as exceptions, they must not be overruled by any element of \(\varDelta \mathrm {Cons}(\mathcal {Q}^{b})\), i.e., R1. Actually this is the case, so they are exceptions to \(-\mathfrak {C}_E\). A (recursive) search of exceptions to them remains unsuccessful. So the final answer to \(\mathcal {Q}^{b}\) is No, it is not allowed to do so, but there are exceptions: – Military vessels are authorized to do so (Rule R2) – Any vessel in need of assistance does so (Rule R3).

6.3 \(\mathcal {Q}^{c}\) Is it Prohibited to Any Vessel to Navigate Near the PNC?

We use this question to illustrate partial conclusion. We assume for this case that the rule base contains only R2 and R3. We have: \(\mathcal {C}_{\mathcal {Q}^{c}}=\texttt {owl:Thing}\), \(\mathcal {K}_{\mathcal {Q}^{c}}=\texttt {owl:Thing}\), \(\mathcal {T}_{\mathcal {Q}^{c}}=\texttt {:Vessel}\), \(\texttt {OP}_{\mathcal {Q}^{c}}=\texttt {PRO}\), \(\mathcal {R}_{\mathcal {Q}^{c}}=\texttt {:NavPaluel}\). With R1 discarded from the base, we have \(\varDelta \mathrm {Pros}(\mathcal {Q}^{c}) = \varDelta \mathrm {Cons}(\mathcal {Q}^{c}) = \emptyset \). Hence, we must find partial support and counter-attack, i.e., \(\partial \mathrm {Pros}(\mathcal {Q}^{c})\) and \(\partial \mathrm {Cons}(\mathcal {Q}^{c})\), to the assertion denoted by \(\mathcal {Q}^{c}\). We have \(\partial \mathrm {Pros}(\mathcal {Q}^{c})=\emptyset \) and \(\partial \mathrm {Cons}(\mathcal {Q}^{c}) = \{\texttt {R2}, \texttt {R3}\}\). Hence we conclude that we have \(-\mathfrak {c}\), i.e., No, it is not prohibited to do so, but rules in the base cover only specific parts of this case: – Military vessels are authorized to do so (Rule R2) – Any vessel in need of assistance is authorized to do so (Rule R3).

7 Future Work

As further developments of this work, we intend to perform the following tasks.

  • Broadening the scope of the rules. As mentioned in Sect. 3, the scope of rules considered in this work is the one of prescriptive with not deontic formula in their body. We need to cover all types of prescriptive rules, i.e., also the case of constitutive rules. Hence, we must propose a modeling that take into account this extension. An interesting starting point for the modeling of constitutive rules would be the decompositions The concept X counts as Y or The concept X counts as Y in context C proposed by Searle [19].

  • Towards a proof theory. We mentioned in the previous point the extension of the scope of rules. This implies updating the mechanisms of answering to deontic questions. Also we intend to propose a proof theory, i.e., how deontic and non deontic assertions are derived in a base made of constitutive and prescriptive rules.

  • Automatic question answering. Currently we manually identify question parts (i.e., context, condition, target, deontic operator and requirement). It would be very useful to propose an approach to automatically decompose questions into their formal parts and then answer them automatically.

8 Conclusion

In this paper, we address the problem of deontic reasoning for legal ontologies. We tackle this issue in terms of deontic questions answering. First, we propose a new deontic rule modeling paradigm for prescriptive rules and then we use this modeling to present mechanisms for deontic question answering. The possible answers we provide to deontic questions, are as diverse as the ones given by a human, i.e., we are able to answer yes/no for the whole question or only for specific cases, with or without exceptions. We also provide answer unknown when there is no evidence in the rule base allowing to answer the question or unknown (potential inconsistencies) if they are unresolved conflicting rules. This work is a first step towards a proof theory for a deontic rule base.