Skip to main content

Bidirectional converter between Prolog and DMN (Decision Model and Notation)

Project description

DMN-Prolog Bidirectional Converter

Test DMN-Prolog-Z3 Converter PyPI - Version

A Python tool for bidirectional conversion between Prolog code and DMN (Decision Model and Notation) for legal/business rule management.

Overview

This tool enables a powerful workflow for converting legal documents into executable decision logic:

Legal Document → LLM → Prolog → DMN → Review → Deploy (Prolog or DMN)
                         ↑                ↓
                         └────────────────┘
                         (Bidirectional)

Why this approach?

  • LLM-Friendly Input: Prolog syntax is simpler and more reliable for LLMs to generate than verbose DMN XML
  • Human-Friendly Review: DMN provides visual decision tables that legal/business specialists can review
  • Flexible Deployment: Deploy as either Prolog (for Prolog engines) or DMN (for DMN engines)
  • Quality Control: Bidirectional conversion ensures consistency and reduces hallucination

Supported Prolog Subset

To ensure DMN compatibility, the converter supports a restricted Prolog subset:

  • Horn clauses only (no negation-as-failure, no cuts)
  • Deterministic rules (single output per input combination)
  • Simple data types (atoms, numbers, strings, booleans)
  • Decision table structure (pattern-matching rules)
  • Limited recursion (≤ 3 levels)
  • FEEL expression compatibility (comparison operators: >=, =<, >, <, ==, \=)

Installation

# Basic installation (conversion only)
pip install dmn-prolog-converter

# With validation support
pip install dmn-prolog-converter[validation]

# With all optional features
pip install dmn-prolog-converter[execution]

See CDMN_INTEGRATION.md for details.

Quick Start

Command Line

After installation, you'll have these commands available:

dmn-prolog          # Main CLI tool with subcommands
prolog2dmn          # Quick shortcut: Prolog → DMN
dmn2prolog          # Quick shortcut: DMN → Prolog
z32dmn              # Quick shortcut: Z3 → DMN
dmn2z3              # Quick shortcut: DMN → Z3

Example usage

# Convert Prolog to DMN
dmn-prolog convert rules.pl rules.dmn

# Convert DMN to Prolog
dmn-prolog convert rules.dmn rules.pl

# Validate DMN
dmn-prolog validate rules.dmn

# Show file info
dmn-prolog info rules.pl
dmn-prolog info rules.smt2

# Quick shortcuts
prolog2dmn input.pl output.dmn
dmn2prolog input.dmn output.pl
z32dmn input.smt2 output.dmn
dmn2z3 input.dmn output.smt2

See CLI_GUIDE.md for complete CLI documentation.

Limitations & Future Work

Current Limitations:

  • No support for complex Prolog features (cuts, negation-as-failure, DCGs)
  • Limited to decision tables (no decision requirement diagrams)
  • No support for DMN business knowledge models or contexts
  • Arithmetic expressions are basic

Future Enhancements:

  • Support for DMN FEEL functions
  • Decision requirement diagram generation
  • Semantic validation of business logic
  • Integration with LLM for natural language descriptions
  • Support for more complex Prolog constructs (via approximation)
  • Visual DMN table editor integration

Use Cases

  1. Legal Document Automation: Convert legal rules to executable format
  2. Business Rule Management: Maintain rules in both technical and business-friendly formats
  3. Legacy Migration: Migrate Prolog expert systems to DMN standard
  4. LLM-Powered Rule Generation: Let LLMs generate Prolog, convert to DMN for review
  5. Dual Deployment: Maintain single source, deploy to both Prolog and DMN engines

Contributing

Contributions welcome! Areas for improvement:

  • Additional test cases
  • Support for more Prolog patterns
  • Enhanced FEEL expression generation
  • Documentation improvements

License

MIT License - see LICENSE file for details

References

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dmn_prolog_converter-1.0.1.tar.gz (31.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dmn_prolog_converter-1.0.1-py3-none-any.whl (32.2 kB view details)

Uploaded Python 3

File details

Details for the file dmn_prolog_converter-1.0.1.tar.gz.

File metadata

  • Download URL: dmn_prolog_converter-1.0.1.tar.gz
  • Upload date:
  • Size: 31.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for dmn_prolog_converter-1.0.1.tar.gz
Algorithm Hash digest
SHA256 83ae4100bdba041cd095d5976164d0b3145747acba68ac4a2a9d4b140fa6feae
MD5 9cd722039603408f5a7cef3bfc59e023
BLAKE2b-256 fad21bfd2219d170a725701e3df4754a1d265489fd9b203d5f0ac509f0f5354f

See more details on using hashes here.

Provenance

The following attestation bundles were made for dmn_prolog_converter-1.0.1.tar.gz:

Publisher: python-publish.yml on NewJerseyStyle/dmn_prolog_converter

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dmn_prolog_converter-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for dmn_prolog_converter-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 46ce95bc5f5a174d350b0124ad061acdfbf99ce496c9f234197c1af5fca94148
MD5 170e90175629fe8071178669bafcdcf1
BLAKE2b-256 5f89544397f98d7eb93775da536b4fba1880d13090931ffb17b61c1e0c2780c8

See more details on using hashes here.

Provenance

The following attestation bundles were made for dmn_prolog_converter-1.0.1-py3-none-any.whl:

Publisher: python-publish.yml on NewJerseyStyle/dmn_prolog_converter

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page