[PLUGIN] Add lib_deontic: a defeasible deontic logic reasoning engine#180
Open
MesTTo wants to merge 2 commits into
Open
[PLUGIN] Add lib_deontic: a defeasible deontic logic reasoning engine#180MesTTo wants to merge 2 commits into
MesTTo wants to merge 2 commits into
Conversation
A non-monotonic + normative reasoner — Defeasible Logic DL(d) (Nute; Antoniou et al.), Standard Deontic Logic (Governatori: O/P/F, F p =def O not-p, contrary-to-duty reparation chains, dilemmas), Event Calculus + the 13 Allen interval relations + temporal deadlines, and weakest-link trust. Complements lib_nal/lib_pln: they grade how much a fact is believed; this decides what defeasibly holds and what one ought to do. Theories and plans are ordinary .metta files read by PeTTa's native loader (no bespoke parser; .dfl arrow syntax also accepted). API: dl-run / dl-run-deontic / dl-run-at, deontic-compliance / deontic-dilemmas, the non-monotonic queries (dl-what-if / dl-why-not / dl-abduce / dl-requires), Event Calculus, and trust. Golden test suite under tests/deontic/. Docs: docs/reference-lib-deontic.md.
The same theory runs through either the fast indexed Prolog kernel or the atomspace-native MeTTa engine (ground.metta / reason.metta) with identical conclusions; select with (dl-engine! native) or $OMEGACLAW_DL_ENGINE=native. Native grounding uses a semi-naive frontier fixpoint. prolog stays the default — native grounding is ~4-5x slower on grounding-heavy theories (per-operation MeTTa-eval overhead, see the perf note in ground.metta), while native is ideal for propositional plans and inspection. Docs: docs/deontic/README.md.
This was referenced Jun 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds lib_deontic, a reasoning engine for the cases that belief-grading does not cover. NAL and PLN already say how strongly to believe a fact. This says what actually follows when rules conflict, and what an agent is obligated, permitted or forbidden to do.
At its core it is a defeasible logic engine. Rules normally hold, but a more specific or higher-priority rule can override them, and the engine works out which conclusions survive. Every literal ends up with one of four standard provability tags: definitely provable, definitely refuted, defeasibly provable, or defeasibly refuted.
On top of that it does normative reasoning. There are obligations, permissions and prohibitions, with the standard reading that forbidding something is the same as obligating its negation. It handles contrary-to-duty obligations, meaning what becomes obligatory once a duty has already been broken, and it detects real dilemmas where two obligations conflict and neither outranks the other. It also reasons about time through the Event Calculus and the thirteen Allen interval relations, and it carries a weakest-link trust value over the proof, computed from per-source weights.
Theories are ordinary .metta files. There is no separate parser, since PeTTa reads them directly, and a textbook-style arrow notation is accepted as well. The main entry points are dl-run, dl-run-deontic and dl-run-at, together with deontic-compliance and deontic-dilemmas for the normative side and a handful of what-if style queries.
The same theory can run through either of two backends that give identical conclusions. One is a fast Prolog kernel, which is the default. The other is a native MeTTa engine in which every rule and derived fact is an inspectable atom. You choose between them with dl-engine or the OMEGACLAW_DL_ENGINE environment variable.
A golden test suite under tests/deontic covers all of this and passes on both backends. The documentation is in docs/deontic/README.md and docs/reference-lib-deontic.md.