Skip to content

[PLUGIN] Add lib_deontic: a defeasible deontic logic reasoning engine#180

Open
MesTTo wants to merge 2 commits into
asi-alliance:mainfrom
MesTTo:deontic-core
Open

[PLUGIN] Add lib_deontic: a defeasible deontic logic reasoning engine#180
MesTTo wants to merge 2 commits into
asi-alliance:mainfrom
MesTTo:deontic-core

Conversation

@MesTTo

@MesTTo MesTTo commented Jun 18, 2026

Copy link
Copy Markdown

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.

MesTTo added 2 commits June 19, 2026 05:39
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.
@vsbogd vsbogd changed the title Add lib_deontic: a defeasible deontic logic reasoning engine [PLUGIN] Add lib_deontic: a defeasible deontic logic reasoning engine Jul 15, 2026
@vsbogd vsbogd added the plugin label Jul 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants