寻找可检测Datalog程序P1是否包含于P2的工具/库
Hey there! Let's break down how to check if Datalog program P1 is contained in P2, with tools/libraries that work across different programming languages:
Soufflé (C++)
This high-performance Datalog compiler is a great go-to for this task. You can frame the containment check as a query: construct a Soufflé program that finds all facts derivable from P1 but not from P2. If this query returns an empty set, that means P1 is contained in P2.
You can integrate this directly into C++ code using Soufflé's API to get a boolean result, or run it via the command line and parse the output from any language that can spawn subprocesses.PyDatalog (Python)
For Python developers, PyDatalog offers a lightweight way to handle this—especially if your Datalog programs operate on a finite domain. The approach here is dynamic: run both P1 and P2 to collect all their derived facts, then check if every fact from P1 exists in P2's result set.
Keep in mind: this method won't work for programs with infinite domains, so opt for a static analysis tool if that's your use case.DDlog (Rust & Cross-Language)
DDlog is built for incremental Datalog computation, but it also has robust static analysis capabilities for program equivalence and containment. Convert your P1 and P2 into DDlog programs, then use its built-in tools to verify if P1 is a subset of P2.
DDlog can generate code for multiple languages (like C++ and Rust), making it easy to embed this check into your existing project and get a boolean output directly.LogicBlox (Java/Scala)
If you're working with enterprise-scale Datalog programs, LogicBlox is a mature choice. It provides dedicated static analysis APIs (for Java and Scala) that let you submit two Datalog programs and get a boolean result for containment.
It’s designed to handle complex, large-scale Datalog logic reliably, so it’s perfect for production-grade use cases.Datalog Educational System (DES)
Even though it’s a teaching-focused tool, DES has built-in support for Datalog containment checks. It’s a command-line utility, so you can call it from any programming language via subprocesses. Just parse its output—if it confirms P1 is contained in P2, returntrue; otherwise,false.
Quick Notes
- Datalog program containment is semi-decidable, so some tools might not be able to give a definitive answer for certain recursive programs. Make sure to test the tool against your specific use case.
- If you only need query containment (rather than full program containment), most Datalog engines support this natively, and you can extend it to full program containment by checking all derived facts/queries.
内容的提问来源于stack exchange,提问作者Shevach

