Domain-specific language for encoding statutes as executable bytes.
Paper · Docs · Status matrix · Encoded library
Yuho is a formally verified 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.
In specific, Yuho mainly comprises a statute DSL compiler that transpiles .yh statute encodings (specified in Yuho's grammer spec) into a typed AST.
This means you can run syntax, semantic and lint checks on .yh code.
Yuho also additionally emits reviewable artefacts in JSON, Plaintext English,
Note
See the feature status matrix for stable, partial, experimental and presently unsupported surfaces.
| Surface | Capability |
|---|---|
| Grammar | Tree-sitter grammar for statute blocks, structs, functions, tests, imports, cross-section predicates, penalty combinators, and exception priority |
| Analysis | yuho check, yuho lint, formatting, AST visualization, source diagnostics |
| Transpilers | JSON, English, LaTeX, Mermaid, Alloy, DOCX, Akoma Ntoso, LegalRuleML |
| Verification | Z3/Alloy backends via yuho verify, plus Lean structural-diff checks |
| Corpus tools | AKN round-trip, runtime test sweep, reference graph via yuho refs |
| Corpora | library/penal_code Singapore canonical corpus, library/bharatiya_nyaya_sanhita BNS 2023 replacement corpus for IPC, library/indian_penal_code raw IPC snapshot, library/malaysia_penal_code and library/pakistan_penal_code IPC-lineage proof-of-concept corpora |
One of my gripes with most Legal DSLs presently available (in the current year 2024) are their lack of examples of the DSL actually in use or application.
With this specific trauma in mind, Yuho provides a thoroughly encoded corpus of all 524 sections of the
Singapore Penal Code 1871 are encoded at library/penal_code/.
The easiest way to get started with Yuho is via PyPI installation from the CLI.
$ uv tool install 'yuho[dev]'
$ yuho doctor
$ yuho init yuho-starterAlternatively run the below.
$ git clone https://github.com/gongahkia/yuho && cd yuho
$ ./install.sh --devThe below instructions are for locally using and running Yuho.
$ uv venv --python 3.13 .venv
$ source .venv/bin/activate
$ uv pip install -e '.[dev]'
$ yuho doctor
$ yuho --help
$ yuho doctor
$ yuho init yuho-starter
$ yuho check library/penal_code/s415_cheating/statute.yh
$ yuho lint library/penal_code/s415_cheating/statute.yh
$ yuho ast library/penal_code/s415_cheating/statute.yh --stats --depth 3
$ yuho verify --capabilitiesYuho optionally provides shell completion for most popular shells.
$ yuho completion zsh --install
$ yuho completion bash --install
$ yuho completion fish --install- Documentation index
- Getting started
- 5-minute tour
- Syntax reference
- Canonical semantics
- Contributor architecture
You can find my paper Yuho: A Domain-Specific Language for Encoding the Singapore Penal Code as Executable Statute published on Zenodo here.
If you use Yuho or its encoded library in academic work, cite the below.
@software{yuho_2026,
author = {Gabriel Ong Zhe Mian},
title = {Yuho: A Domain-Specific Language for Encoding the Singapore Penal Code as Executable Statute},
year = {2026},
url = {https://github.com/gongahkia/yuho},
version = {5.1.0}
}Yuho is open-source. Contribution guidelines are found at CONTRIBUTING.md.
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.
Yuho stands on the shoulders of past research and academia.
- A Logic for Statutes by Sarah B Lawsky
- An End-to-End Pipeline from Law Text to Logical Formulas by Aarne Ranta, Inari Listenmaa, Jerrold Soh and Meng Weng Wong
- Symbolic and automatic differentiation of languages by Conal Elliott
- Legal Rules, Legal Reasoning, and Nonmonotonic Logic by Adam W Rigoni
- Law and logic: A review from an argumentation perspective by Henry Prakken and Giovanni Sartor
- Rules as code: Seven levels of digitisation by Meng Weng Wong
- Defeasible semantics for L4 by Guido Governatori and Meng Weng Wong
- CLAWs and Effect by Alexis N Chun
- The LKIF Core Ontology of Basic Legal Concepts by Rinke Hoekstra, Joost Breuker, Marcello Di Bello and Alexander Boer
- ChatGPT, Large Language Models, and Law by Harry Surden
- Scaling Laws for Neural Language Models by Jared Kaplan, Sam McCandlish, Tom Henighan, Tom B Brown, Benjamin Chess, Rewon Child, Scott Gray, Alec Radford, Jeffrey Wu and Dario Amodei
- Large Language Models in Law: A Survey by Jinqi Lai, Wensheng Gan, Jiayang Wu, Zhenlian Qi and Philip S Yu
- Automating Defeasible Reasoning in Law with Answer Set Programming by Lim How Khang, Avishkar Mahajan, Martin Strecker and Meng Weng Wong
- User Guided Abductive Proof Generation for Answer Set Programming Queries by Avishkar Mahajan, Martin Strecker and Meng Weng Wong
- Computer-Readable Legislation Project: What might an IDE-like drafting tool look like? by Matthew Waddington, Laurence Diver and Tin San Leon Qiu
- Normalized Legal Drafting and the Query Method by Layman E Allen and C Rudy Engholm
- An IDE-like tool for legislative drafting by crlp-jerseyldo.github.io
- The Grammar And Structure Of Legal Texts by Risto Hiltunen
- Does Justice Have a Syntax? by Steven L Winter
- The syntax of legal exceptions: how the absence of proof is a proof of absence thereof by Kyriakos N Kotsoglou
- The British Nationality Act as a logic program by M Sergot, F Sadri, R Kowalski, F Kriwaczek, P Hammond and H T Cory