Your First Rule
How to become a rule-maker
1.1 A Single Legal Obligation
Let's start with something every lawyer understands: a simple legal obligation.
Example: "A registered charity must file an annual return."
In L4, like in legal documents, we need to first set up the basic types and terms:
IMPORT prelude
-- Define basic types first. More on this later.
DECLARE RegisteredCharity
HAS name IS A STRING
registrationNumber IS A STRING
isRegistered IS A BOOLEAN
DECLARE Actor IS ONE OF
CharityActor HAS charity IS A RegisteredCharity
DECLARE Action IS ONE OF
FileAnnualReturn
-- Now we can write our first legal obligation
GIVEN charity IS A RegisteredCharity
GIVETH A PROVISION Actor Action
`charity annual return obligation` MEANS
PARTY CharityActor charity
MUST FileAnnualReturn
WITHIN 365
HENCE FULFILLEDTry it out in the online-editor
Let's break this down:
IMPORT prelude- Imports basic L4 functions we use in this projectDECLAREstatements - Define the types we'll useGIVEN charity IS A RegisteredCharity- This rule applies to registered charitiesGIVETH A PROVISION Actor Action- This function returns a contractPARTY CharityActor charity- The charity is the one with the obligationMUST FileAnnualReturn- This is what they must doWITHIN 365- They have 365 daysHENCE FULFILLED- What happens when they comply
Try it yourself: Write a rule that says "A solicitor must maintain client confidentiality."
1.2 Adding Conditions and Consequences
Real legal rules have conditions and consequences. Let's make our charity rule more realistic:
New elements:
IF charity's isRegistered EQUALS TRUE- Adds a condition using proper boolean comparisonWITHIN 60- Sets a deadline (60 days = approximately 2 months)HENCE FULFILLED- What happens if they complyLEST FULFILLED- What happens if they don't complyELSE FULFILLED- Alternative path if condition not met
The Legal Logic: This captures the complete legal structure: who, what, when, and consequences.
1.3 Your First Simulation
Let's test our rule with some data:
What This Does: L4 can calculate that this charity must file by February 28, 2024 (2 months after December 31, 2023).
Success Check: You can now write a basic legal obligation, add conditions and deadlines, and test it with data.
Last updated
