L4 Language Documentation
L4 is a domain-specific language for law that enables computer-readable formalizations of contracts, legislation, and regulations.
Getting Started
New to L4? Start here:
- Get L4 - Download the L4 VS Code extension with Legalese AI and MCP tools
- Your First L4 File - Hands-on in 15 minutes
- Composing L4 with AI - Draft L4 from prose using Legalese AI
- Exporting Rules for Deployment - Deploy L4 rules as REST APIs and use with MCP
Documentation Types
Our documentation is organized by what you need:
| Type | Purpose | When to Use |
|---|---|---|
| Courses | Learning-oriented | "Teach me L4" |
| Tutorials | Task-oriented | "How do I do X?" |
| Reference | Information-oriented | "What is X?" |
| Concepts | Understanding-oriented | "Why does X work this way?" |
Courses
Structured learning paths from beginner to advanced:
Foundation Course
Learn L4 from scratch. No prior programming experience required.
- Module 0: Introduction - What is L4?
- Module 1: Your First Legal Rule
- Module 2: Legal Entities and Relationships
- Module 3: Control Flow
- Module 4: Decision Logic
- Module 5: Functions
- Module 6: Regulative Rules (Obligations & Permissions)
- Module 7: Capstone Project
Advanced Course
Deep dives for production use.
- Module A1: Real Regulatory Schemes
- Module A2: Cross-Cutting Concerns
- Module A3: Complex Contracts
- Module A4: Production Patterns
Prerequisites: Foundation Course
Tutorials
Task-focused guides for specific goals:
Getting Started
- Your First L4 File - Create, run, test
- Using the l4 CLI - Install and drive the command-line tools
- Testing Your Rules - #EVAL, #CHECK, #ASSERT, and #TRACE
- Debugging Type Errors - Read and fix common compiler errors
- Encoding Legislation - Turn legal text into L4
- Wedding Vows Example - Fun intro to regulative rules
- Version Control for Rules - Git workflow for legal rules
Deployment and Legalese Cloud
- Exporting Rules for Deployment - Deploy L4 rules as REST APIs and use with MCP
- Using Rules from Claude - End-to-end: deployed rules called from Claude and Cursor via MCP
- OpenAI- and Anthropic-Compatible AI APIs - Chat with a deployment's rules from any OpenAI or Anthropic client
- MCP Server - Expose deployed rules as Model Context Protocol tools
- WebMCP Embed Script - Serve your rules from your own website
- RESTful OpenAPI Specification - Generate REST clients from the spec
LLM Integration
- Getting Started with LLM - Hybrid AI + formal reasoning
- Legislative Ingestion - LLM-assisted encoding
Reference
Look up specific features:
- Syntax Reference - Complete syntax guide
- Types - L4 Types
- Functions - Functions as rules
- Control Flow - IF and CONSIDER
- Regulative - Regulative language
- Built-ins - Built-in functions
- Libraries - Standard library
- Operators - Operators and precedence
- Patterns - Common and advanced encoding patterns
- Errors - Troubleshooting compiler diagnostics
- Cheat Sheet - One-page syntax summary
Concepts
Understand the "why" behind L4:
- Design Principles - Why L4 works this way
- Linguistic Syntax - How L4 reads like legal English
- Regulative Rules - Obligations, permissions, prohibitions
- Constitutive vs Regulative Rules - Defining vs directing
- Default Reasoning - Exceptions and defeasibility with UNLESS
- Algebraic Types - L4's type system
- Exhaustiveness - Totality as a legal-safety property
Community & Support
- Discord - Chat with the community
- GitHub Issues - Report bugs, request features
- Legalese Services - Professional implementation services
Developer Resources
- Latest Stable Build -
- L4 IDE Repository - Open-Source code
L4 is published under the Apache-2.0 License.