Skip to main content

A domain-specific language for encoding legal statutes

Project description

PyPI

Yuho

Yuho is a domain-specific language dedicated to simplifying legalese by providing a programmatic representation of Singapore Law.

Current applications are focused on Singapore Criminal Law but really can be applied to any jurisdiction that relies on statutes.

Rationale

The law is innately complex.

Statutes are not always easy to understand, especially for incoming law students new to legalese and its logical structure.

Criminal Law is often a foundational module most students take in their first year of law school. In particular, Singapore Criminal Law is nearly entirely statute-based, largely focusing on the Penal Code.

Yuho is a DSL that seeks to help law students better understand statutes by providing a flexible syntax which affords a programmatic representation of Singapore Criminal Law. By allowing users to decide how to represent statutory provisions in .yh code, the hope is that the statute's key elements and its underlying conditional relationships surface themselves. These representations can be coarse or granular, entirely scoped by their use-cases.

Getting into the specifics, Yuho provides the following five products.

  1. Yuho, a DSL made to be readable and codeable by law students and lawyers
  2. Formalised semantics for legal reasoning modelled after the syntactical patterns of the law
  3. CLI tool for interacting with Yuho's primary functions in the CLI
  4. LSP for editor integration with diagnostics, completion, and hover
  5. Transpiler that transpiles to multiple targets

Output formats

Target Usage
JSON Machine-readable structured representation for tooling integration
JSON-LD Linked data format for semantic web applications
English Human-readable plain English explanation of statutory logic
LaTeX PDF generation of formatted statute documents
Alloy Formal verification with Alloy Analyzer
Mermaid Diagrammatic representations of statutory logic (mindmap, flowchart)
GraphQL Schema definitions for building legal statute APIs
Blocks Visual block-based representation for drag-and-drop editing

Sold on Yuho? Check out the quickstart guide.

[!TIP] More transpilation outputs can be added. Open an issue to contribute suggestions!

Nerd stuff

For those interested, Yuho v5 provides:

  • Tree-sitter based parser for robust, incremental parsing with excellent error recovery
  • Full LSP implementation with diagnostics, completion, hover, go-to-definition, and references
  • Property-based testing with Hypothesis for thorough validation
  • Formal verification integration with Alloy and Z3
  • LLM integration for statute explanation and analysis (local-first with Ollama, cloud fallback)
  • MCP server exposing all functionality via Model Context Protocol

Yuho is grammatically-validated, exception-validated, and language-agnostic, transpiling from one formally-specified source of truth to multiple target outputs.

Want to find out more? See Yuho's documentation.

Documentation

Quickstart

Yuho v5.0: Install via pip and start using immediately:

pip install yuho
yuho --help

Learn Yuho: Understand the basics in 5 minutes at 5_MINUTES.md.

Legacy versions: See archive/ for v1-v4 implementations.

Roadmap

For more details on what's being implemented in the future, refer to ROADMAP.md.

Scope

Development is currently scoped by the following statutes at SCOPE.md.

Contribute

Yuho is open-source. Contribution guidelines are found at CONTRIBUTING.md.

References

Analogues

Yuho takes much inspiration from the following projects.

  • Natural L4: Language with an English-like syntax that transpiles to multiple targets, focused on codification of Singapore law at large and Contract Law in specific.
  • Catala: Language syntax that explicitly mimicks logical structure of the Law, focused on general Socio-fiscal legislature in most jurisidictions.
  • Blawx: User-friendly web-based tool for Rules as Code, a declarative logic knowledge representation tool for encoding, testing and using rules.
  • Morphir: Technology agnostic toolkit for digitisation of business models and their underlying decision logic, enabling automation in fintech.
  • OpenFisca: Open-source platform for modelling social policies through tax and benefits systems across jurisdictions.
  • Docassemble: Document automation system for generating guided interview documents through a question-and-answer interface.
  • Akoma Ntoso: Standardised XML schema for representing parliamentary, legislative and judiciary documents across jurisdictions.

Research

Yuho stands on the shoulders of past research and academia.

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

yuho-5.1.0.tar.gz (265.4 kB view details)

Uploaded Source

Built Distribution

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

yuho-5.1.0-py3-none-any.whl (248.6 kB view details)

Uploaded Python 3

File details

Details for the file yuho-5.1.0.tar.gz.

File metadata

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

File hashes

Hashes for yuho-5.1.0.tar.gz
Algorithm Hash digest
SHA256 74bf1e5e02e57915eb4f74fd52c662f501d4e4876b4b9aa800f7ca9e674cfc29
MD5 f84afe584c8a1cb76dd90922ecf8668b
BLAKE2b-256 2d0417e569b989012d21bd323f334f14582614d547fdc5dbd38421b128f1cafe

See more details on using hashes here.

Provenance

The following attestation bundles were made for yuho-5.1.0.tar.gz:

Publisher: release.yml on gongahkia/yuho

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

File details

Details for the file yuho-5.1.0-py3-none-any.whl.

File metadata

  • Download URL: yuho-5.1.0-py3-none-any.whl
  • Upload date:
  • Size: 248.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for yuho-5.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 26777a2abf4872cec4b097d36a8c370139ed7a8c3dd8426f5f68aa485f31fe93
MD5 db7c7ddc2b1432cbec34f51d32dfceeb
BLAKE2b-256 8dcf8c1840d3221c5312d4c0725266377b656b5439374da815b2a99074f53d0b

See more details on using hashes here.

Provenance

The following attestation bundles were made for yuho-5.1.0-py3-none-any.whl:

Publisher: release.yml on gongahkia/yuho

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