The law is the oldest source code humanity has ever written — and until now, it had no compiler.
Today we released Legalis-RS 0.1.0 — a Pure Rust framework for parsing, analyzing, and simulating legal statutes, transforming natural-language law into structured, machine-verifiable code.
No C. No C++. No Fortran. No JVM. No Python runtime in the core. The legal-tech world has long been split between opaque closed SaaS legal platforms you cannot inspect and academic tools like Catala, the Z3 SMT solver, and assorted Java/Python legal-reasoning stacks that nobody can actually deploy. Legalis-RS is Pure Rust — it compiles to a single static binary (or WASM) you can run anywhere, audit fully, and trust completely. This is what we call The Architecture of Generative Jurisprudence: Governance as Code, Justice as Narrative.
Its philosophical core is a single, deliberate constraint: not everything should be computable. Legalis-RS preserves the distinction between Deterministic Logic — computable outcomes like ages, income thresholds, and deadlines — and Judicial Discretion — the human interpretation that no machine should arrogate to itself.
Why 0.1.0 matters
Legal logic today lives locked inside PDFs, buried in opaque SaaS platforms, or trapped in academic prototypes that never leave a research lab. When a statute contains a contradiction — a benefit that can never be granted, a condition that can never be satisfied, a circular cross-reference — there is no compiler to catch it. We ship legal bugs straight into law and discover them only when a citizen falls through the gap.
Legalis-RS treats statutes the way we treat software. Concrete wins in this first release:
- Deterministic vs. Judicial separation. The core
LegalResult<T>enum forces every rule to declare whether its outcome is mechanically computable or must defer to human judgment. Automation stops exactly where it should. - Dead-statute and circular-reference detection. The formal verifier finds unsatisfiable conditions and circular references before a rule is enacted.
- Population simulation. Run a proposed rule against a generated population and watch who it actually affects, before it becomes law.
- Multi-jurisdiction from day one. Japan, Germany, France, and the USA ship in 0.1.0.
- A single binary. No JVM, no Python environment, no SaaS subscription — one auditable artifact.
Technical Deep Dive: the Legalis-RS layers
Legalis-RS ships as 16 core crates plus 4 jurisdiction packs, organized into layers.
Core Layer. legalis-core holds the foundational types — LegalResult, Statute, Condition, Effect. legalis-dsl provides the Legal DSL parser together with an LSP server, so statutes get real IDE support. legalis-registry is a statute registry with Git-based version control, tags, and cross-reference resolution.
Intelligence Layer. legalis-llm is a multi-provider LLM integration framework (OpenAI, Anthropic, Google) that can compile law from natural language, with cost analytics and streaming. legalis-verifier performs formal verification: circular-reference detection, dead-statute detection of unsatisfiable conditions, constitutional-compliance checking, and complexity metrics — with an optional Z3 SMT solver integration for rigorous proofs.
Simulation & Analysis Layer. legalis-sim is an async simulation engine with population-based testing, temporal simulations, and economic-impact modeling on an ECS-like architecture. legalis-diff handles statute comparison and change detection — structural diffing and impact analysis.
Internationalization & Porting Layer. legalis-i18n provides multi-language and locale support plus a jurisdiction registry. legalis-porting enables cross-jurisdiction law transfer with cultural adaptation — a “Soft ODA” approach built on equivalence mapping.
Interoperability Layer. legalis-interop imports and exports Catala, Stipula, and L4 formats, with custom DSL converters.
Output Layer. legalis-viz renders decision trees, flowcharts, and 3D legal-space visualizations with SVG/PNG export. legalis-chain exports smart contracts to Solidity, WASM, and Ink!/Substrate. legalis-lod produces Linked Open Data — RDF/Turtle, SPARQL, and legal knowledge graphs.
Infrastructure Layer. legalis-audit provides immutable decision logging, forensic analysis, and partitioned storage with SQL/PostgreSQL backends. legalis-api serves REST and gRPC APIs with streaming, GraphQL, rate limiting, and OpenTelemetry. And legalis is the CLI itself — an interactive REPL, batch processing, LSP integration, and profiling.
The shipped jurisdictions are legalis-jp (Japan), legalis-de (Germany), legalis-fr (France), and legalis-us (USA).
Getting Started
Legalis-RS is a library-first framework. Add the core crate:
cargo add legalis-core
The framework also ships a legalis CLI binary — an interactive REPL with batch processing, LSP integration, and profiling.
Here is a statute built two ways — parsed from the Legal DSL, and constructed programmatically:
use legalis_core::{Statute, Condition, Effect, EffectType, ComparisonOp};
use legalis_dsl::LegalDslParser;
// Parse a statute from the Legal DSL
let parser = LegalDslParser::new();
let statute = parser.parse_statute(r#"
STATUTE adult-rights: "Adult Rights Act" {
WHEN AGE >= 18
THEN GRANT "Full legal capacity"
}
"#)?;
// Or build it programmatically
let statute = Statute::new(
"voting-rights",
"Voting Rights Act",
Effect::new(EffectType::Grant, "Right to vote in elections"),
)
.with_precondition(Condition::Age {
operator: ComparisonOp::GreaterOrEqual,
value: 18,
});
The heart of the framework is the LegalResult<T> enum — the type that encodes not everything should be computable:
pub enum LegalResult<T> {
Deterministic(T), // Automated processing possible
JudicialDiscretion { /* … */ }, // Human judgment required
Void { reason: String }, // Logical inconsistency detected
}
And verifying a body of statutes before you trust it:
use legalis_verifier::StatuteVerifier;
let verifier = StatuteVerifier::new();
let result = verifier.verify(&statutes);
if !result.passed {
for error in result.errors {
eprintln!("Verification error: {}", error);
}
}
Built with Rust 1.85+ / Edition 2024.
What’s inside
- A Legal DSL with IDE support — write statutes in a readable domain language, backed by an LSP server.
- A statute registry — Git-based version control, tags, and cross-reference resolution for whole bodies of law.
- A formal verifier — catches circular references, dead statutes, and unsatisfiable conditions; checks constitutional compliance; an optional Z3 backend adds rigorous SMT proofs.
- LLM-assisted authoring — compile law from natural language across OpenAI, Anthropic, and Google, with cost analytics and streaming.
- A simulation engine — population-based, temporal, and economic-impact testing before a rule ever becomes law.
- Diffing — structural comparison and impact analysis between statute versions.
- Internationalization and cross-jurisdiction porting — multi-locale support plus cultural-adaptation transfer between legal systems.
- Interoperability — import/export with Catala, Stipula, and L4.
- Rich output — decision-tree and 3D visualization, smart-contract export (Solidity, WASM, Ink!/Substrate), and Linked Open Data (RDF/Turtle, SPARQL).
- Production infrastructure — immutable audit logging with SQL/PostgreSQL backends, and REST + gRPC + GraphQL API servers.
- Four jurisdictions — Japan, Germany, France, and the USA.
- 24 comprehensive examples — a 3D visualization of the Japanese Constitution, welfare-benefits eligibility, tort law (Minpo Article 709), comparative tort law across jurisdictions, drone regulations, GDPR compliance, employment law, tax law, and more.
Tips
- Plain
cargo buildalready gives you REST + gRPC.legalis-apinow includesgrpcin its default features, so a plain build works cross-platform on macOS, Linux, and Windows without--all-featuresand without any Z3 install. - Want rigorous SMT proofs? Opt in. Enable the optional
z3-solverfeature onlegalis-verifier. It requires a system Z3 install —brew install z3— followed bysource setup-z3-env.sh. Everything else works without it. - Mark the human boundary explicitly. Use
LegalResult::JudicialDiscretionwherever a rule must defer to a human. This is the seam between what you automate and what you must not. - Simulate before you enact. Run
legalis-simagainst a generated population to see who a proposed rule actually affects before it becomes law. - Bridge to the academic ecosystem. Export to Catala or L4 via
legalis-interopto interoperate with existing formal-legal tooling.
A few honest caveats for a 0.1.0: the optional Z3 integration requires manual environment setup; a handful of examples still have dependency conflicts we are addressing; performance optimization is ongoing; and the documentation is English-only for now, with multilingual support planned.
Joining the COOLJAPAN family
Legalis-RS is a new Pure-Rust member of the COOLJAPAN ecosystem. It stands on its own — 0.1.0 has no COOLJAPAN crate dependencies — but it shares the same sovereign, Pure-Rust philosophy as siblings like SciRS2 for scientific computing: C/C++/Fortran-free, auditable, and self-contained.
Repository: https://github.com/cool-japan/legalis
Star the repo if you believe the law deserves a compiler too — and if you do, try modeling a statute you know and run the verifier against it.
Pure Rust legal-tech is here — fast, safe, and sovereign.
— KitaSan at COOLJAPAN OÜ January 5, 2026