Studio Matrx Monthly · Volume 1 · Issue 4 · September 2026
Amogh N P
 In loving memory of Amogh N P — Architect · Designer · Visionary 
Encoding a RuleLesson 3.1
Automated Compliance & Rules-as-Code/Module 3 · Rules as Code

Lesson 3.1 · Rules as Code

Encoding a Rule

Take one plain sentence from a byelaw - a corridor must be at least two metres wide in an assembly building - and watch it become structured machine logic, seeing exactly which choices you are forced to make and what quietly gets lost along the way

12 min Interactive lessonFree · open lessonByAmogh N P· Architect & interior designer
The hook

One sentence in a byelaw: 'a corridor shall be at least 2.0 m wide in an assembly building.' Easy to read. What does it take to make a computer check it?

Read that sentence and, if you are trained, you already know what to do with it. You know what a corridor is, what 'clear width' means (the unobstructed dimension between finished faces, not counting a projecting column or a door leaf), what an 'assembly building' is (a cinema, an auditorium, a place where people gather - a defined occupancy class in the code), and that 2.0 metres is a floor, not a target. All of that understanding is implicit. The sentence leans on a trained reader to supply it, and a trained reader obliges without noticing.

A computer supplies none of it. To check this rule automatically, every piece of that implicit understanding has to be made explicit and unambiguous - which elements the rule is about, which property it constrains, how that property is measured, what value it must satisfy, and when the rule even applies. This lesson carries one corridor rule from prose to machine logic and watches, step by step, what the translation demands and what it costs. The clause is small on purpose, because the lesson it teaches - that to encode a rule is already to interpret it - scales to thousands of rules and sits at the foundation of the whole field.

One sentence -> scope + element + property + operator + threshold + action. Runs well IF the model carries the data. But every gap you fill is a choice: encoding IS interpretation.

The prose rule

Start with one sentence a human already understands

Automated compliance begins with a humble act: taking one rule a person can read, and turning it into something a machine can evaluate. Start with a real example, of the kind that fills every building byelaw and the National Building Code: 'the minimum clear width of a corridor in an assembly building shall be 2.0 metres.' A qualified human reads that and, drawing on training and context, knows roughly what to do. They know what a corridor is; they know 'clear width' means the unobstructed dimension, measured between finished faces, not counting a projecting column or a swinging door; they know an 'assembly building' is a defined occupancy class - a place where people gather in numbers; and they know 2.0 metres is a minimum, a floor below which the design must not fall. The sentence works because a human mind quietly fills every gap in it.

A computer fills no gaps. It cannot 'know what a corridor is' - it can only test properties of elements in a structured model. So to check this rule automatically, each piece of that implicit understanding must be rebuilt as an explicit, testable statement. The encoding must spell out, with no room left for interpretation, which elements the rule concerns, which property of them it constrains, how that property is measured, what value it must satisfy, and in which situations the rule applies at all. This is what encoding a rule really is: not translating English into another language, where meaning is presumed to survive, but reconstructing a human understanding as a precise logical structure a machine can run.

Through this whole lesson we carry this single corridor rule from prose to machine logic and watch what the passage demands and what it quietly costs. Every rule ever run against a model made exactly this journey - from a sentence a person interprets to a structure a machine evaluates - and understanding that journey is the foundation of rules-as-code. It is also where the honesty of this course begins: the moment you start to encode, you are already making choices. The rest of this lesson is about seeing those choices clearly, so you neither dismiss automated checking as useless nor over-trust it as if the encoded rule were the law itself. It is neither. It is a careful, revealing, and fallible reconstruction.

Encoding a rule: from one sentence to structured logic PROSE: A corridor in an assembly building shall have a minimum clear width of 2.0 metres. -- encode --> SCOPE occupancy = assembly ELEMENT corridor PROPERTY clear_width OPERATOR >= THRESHOLD 2.0 m FOR EACH element WHERE is_corridor AND space.occupancy = "assembly": IF clear_width >= 2.0 THEN pass ELSE flag(element) action on failure: report a potential non-compliance, not an approval
Zoom
One prose corridor rule decomposed into the anatomy every quantitative encoding shares: scope, element, property, operator, threshold and an action on failure - which only runs if the model carries the data.
Anatomy

Breaking the rule into scope, element, property, operator and threshold

Look closely at what a machine needs, and the single sentence resolves into distinct parts - the anatomy of an encoded rule. First, the scope: when does the rule apply at all? Here, only in an 'assembly' occupancy, so the encoding needs a condition - the element belongs to a space whose occupancy classification equals 'assembly' - and if that is false, the rule is simply not relevant. Get the scope wrong and you either check corridors the rule never governed or miss ones it did. Second, the element: which object in the model does the rule test? A 'corridor' - which means the model must contain objects identified as corridors, not anonymous spaces or a bare run of walls. Third, the property: which measurable attribute is constrained? The 'clear width' - a specific, defined dimension that must exist as data on the element or be computable from its geometry. Fourth, the operator and threshold: what relationship must hold? Clear width must be greater than or equal to 2.0 metres; the operator and the value together form the testable condition.

Put together, the encoded rule reads, in effect: 'for every element that is a corridor AND whose space has occupancy = assembly, check that clear_width is greater than or equal to 2.0 m; if not, flag it as a potential non-compliance.' That skeleton - scope, element, property, operator, threshold, and an action on failure - underlies nearly every quantitative rule you will ever encode. A door clear width, a ramp slope, a travel distance to an exit, a setback, a floor-space ratio: each decomposes the same way - which elements, which property, which comparison, which value, under which conditions.

This is exactly why clear, quantitative rules are the ones that automate well: they already have this shape latent in them, and encoding mostly means making it explicit. But notice what the encoding assumes - that the model actually carries the data the rule reads: a corridor that knows it is a corridor and knows its clear width. If that data is missing or mislabelled, the cleanest encoding returns a wrong or empty answer. The anatomy is only half the story. The model must speak the same structured language the rule expects, or there is nothing to test. Encoding and the structured model are two halves of one mechanism, and neither works alone.

Encoding a rule: from one sentence to structured logic PROSE: A corridor in an assembly building shall have a minimum clear width of 2.0 metres. -- encode --> SCOPE occupancy = assembly ELEMENT corridor PROPERTY clear_width OPERATOR >= THRESHOLD 2.0 m FOR EACH element WHERE is_corridor AND space.occupancy = "assembly": IF clear_width >= 2.0 THEN pass ELSE flag(element) action on failure: report a potential non-compliance, not an approval
Zoom
One prose corridor rule decomposed into the anatomy every quantitative encoding shares: scope, element, property, operator, threshold and an action on failure - which only runs if the model carries the data.
The losses

What gets lost or must be decided in the encoding

Now the honest half. The corridor rule looked mechanical, and its core comparison genuinely is - but even here, encoding forces a string of decisions the prose left comfortably vague, and each decision is an interpretation. Take 'clear width.' Clear of what? A structural column that intrudes into the corridor? A handrail? A door that swings into the space? A skirting, a pipe, a wall-mounted fire extinguisher? The code and its commentary may answer some of these, but the encoder must pin down one precise measurement rule - and if they choose differently from how a plans-examiner would, the automated result and the official view diverge. Take 'corridor.' The model must decide which spaces count; a lobby that widens into a passage, an open route with no walls, a space used for circulation but labelled 'foyer' - each is a classification judgement that decides whether the rule fires at all. Take 'assembly building': occupancy classification is itself interpretive, and mixed-use buildings blur it.

So three things happen in every encoding, and it is vital to see them. First, hidden decisions are forced into the open - the encoder must resolve ambiguities the prose tolerated, and those resolutions are choices, not facts. Second, meaning can be narrowed or lost - a rule whose spirit is 'people must move and escape comfortably' becomes, in code, a single width number, which captures much but not all of the intent; a corridor that meets the number but is cluttered, badly lit or oddly shaped can satisfy the encoding and still fail the purpose. Third, the measurement convention becomes load-bearing - how the property is computed from the model can change the pass or fail outcome as much as the threshold does.

None of this makes the encoding useless. The corridor-width check is genuinely valuable and catches real problems fast. It means the encoded rule is a *model* of the regulation, not the regulation itself - a faithful but lossy representation whose fidelity depends on choices the encoder made. That is why the authoritative rule always remains the actual byelaw and code, read by an accountable human, and why a clean automated 'pass' is a useful signal and never a final verdict on whether the design complies.

What the encoder must decide - and what can be lost FORCED DECISIONS Clear of what? column, handrail, door swing, pipe, skirting? Which spaces count as a corridor? (foyer, lobby, open route?) Is this occupancy really assembly? (mixed use blurs it) How exactly is width measured from the model geometry? Each answer is a choice, not a fact. WHAT CAN BE LOST Intent: people move and escape comfortably -> shrinks to one number. A corridor can meet the number and still be cluttered, dark or awkward. Measurement convention becomes as load-bearing as the threshold. The encoded rule is a MODEL of the regulation - faithful but lossy. The law stays the authority.
Zoom
Encoding forces decisions the prose left vague (left) and can lose or narrow the rule's intent (right); the encoded rule is a faithful-but-lossy model of the regulation, and the law stays the authority.
The honest read

Encoding is a chain of decisions, not a neutral translation

Step back from the single clause to the principle it teaches. Encoding a rule is not a neutral act of translation, like rendering a sentence from one language into another where the meaning is presumed to survive intact. It is a chain of decisions, each of which fixes something the prose left open. Where does the rule apply? Which elements does it govern? What exactly is measured, and how? What counts as the boundary of an element, or the moment a space becomes a corridor? Every one of these is answered by a person - the encoder - and the machine then executes their answers with perfect, literal obedience. The computer never interprets; it only applies the interpretation someone already baked in. This is the single most important idea in rules-as-code, and the rest of this module builds on it: encoding is interpretation, performed once, up front, by whoever writes the code, and then frozen into the tool.

That has three practical consequences to carry forward. First, the quality of an automated check is bounded by the quality of the encoding, which is a human, fallible, contestable artefact - it can be wrong, out of date, or reasonable-but-different from the authority's reading. Second, transparency matters enormously: if you cannot see how a rule was encoded - what it assumed, how it measures, where it applies - you cannot judge whether to trust its verdict, which is why open, inspectable encodings are far safer than opaque ones. Third, accountability cannot move to the software: a 'pass' or 'fail' is the tool reporting the consequence of someone's interpretation against your model data, not the law speaking.

The competent designer treats an encoded rule the way a good engineer treats any model - as a powerful, revealing simplification, used with full awareness of its assumptions - and keeps the binding judgement of what the rule really requires with the qualified professional, the approving authority and the actual code. Encode the checkable, yes; but never forget that you encoded it, and that the encoding is a claim about the rule, not the rule.

What the encoder must decide - and what can be lost FORCED DECISIONS Clear of what? column, handrail, door swing, pipe, skirting? Which spaces count as a corridor? (foyer, lobby, open route?) Is this occupancy really assembly? (mixed use blurs it) How exactly is width measured from the model geometry? Each answer is a choice, not a fact. WHAT CAN BE LOST Intent: people move and escape comfortably -> shrinks to one number. A corridor can meet the number and still be cluttered, dark or awkward. Measurement convention becomes as load-bearing as the threshold. The encoded rule is a MODEL of the regulation - faithful but lossy. The law stays the authority.
Zoom
Encoding forces decisions the prose left vague (left) and can lose or narrow the rule's intent (right); the encoded rule is a faithful-but-lossy model of the regulation, and the law stays the authority.
Verify-this: the encoding is a claim about the rule, never the rule itself

Anatomy of an encoded rule

Scope, element, property, operator, threshold

Every quantitative rule decomposes into which elements it governs, which property it constrains, which comparison and value, under which conditions, plus an action on failure. Making that explicit is the encoding. Modules 3.3, 4.2.

Encoding is interpretation

Decisions forced by encoding

Turning prose into runnable logic forces choices the prose left vague (clear of what? which spaces count?). Those choices are the encoder's, applied literally by the machine. Modules 3.2, 3.4, 9.2.

The authoritative rule is the law

Encoded rule versus real regulation

The binding rule is the actual byelaw, NBC or IS standard, read by an accountable human - never its encoded version, which may be wrong, lossy or out of date. Modules 3.4, 8.2.

Hands-on workshop

Workshop - encode one real rule by hand and list what you had to decide

The fastest way to feel that encoding is interpretation is to encode a rule yourself and notice every choice you are forced to make. In this workshop you take a single quantitative rule and rebuild it as explicit machine logic - on paper, no software - then honestly catalogue the decisions and losses.

Just one real rule and a notebook. No software - the point is to feel the interpretive choices by hand; the engines and tools come later, and binding compliance always stays with the professional, the authority and the actual code.

Given & goal
Goal: turn one prose rule into structured logic and expose its hidden choices
Inputs: one quantitative rule from a byelaw, the NBC or an accessibility standard, plus a notebook
Time: ~40 minutes
  1. 1Pick one clear quantitative rule (a corridor or door width, a ramp slope, a travel distance, a setback). Write its exact prose wording down.
  2. 2Decompose it: name the scope (when it applies), the element (what it tests), the property (what is measured), the operator and the threshold, and the action on failure. Write it as one plain-language machine rule: 'for every X where CONDITION, check PROPERTY OPERATOR VALUE; else flag.'
  3. 3List the model data it needs: exactly what each element must 'know' about itself for the rule to run (a corridor that knows it is a corridor and knows its clear width).
  4. 4Catalogue the forced decisions: every ambiguity you had to resolve to make it runnable (clear of what? which spaces count? which occupancy?), and note that each is a choice a different encoder might make differently.
  5. 5Write a short reflection: what part of the rule's intent the single number does NOT capture, and why the authoritative rule and its interpretation must stay with the professional, the authority and the actual code - flagged as reasoning.

You’ll walk away with
A one-page encoding: the prose rule, its decomposition into scope/element/property/operator/threshold, its model-data needs, a list of the interpretive decisions it forced, and a reflection on what was lost - framed as reasoning, not as a compliance determination.

The worked example

Three altitudes on the same idea

Read the band that fits you — or all three.

For the architectUsing automated checking for early feedback and self-checking - while you and the authority stay accountable

When you use an encoded rule for early feedback, you are trusting someone's decomposition of a clause into scope, element, property, operator and threshold - so read that decomposition, do not just read the green tick. For clear quantitative rules (corridor and door widths, ramp slopes, travel distances, setbacks, coverage) encoding works well and gives you fast, consistent, early self-checking against a structured model. But the value depends on choices the encoder made: what 'clear width' is measured clear of, which spaces count as corridors, how occupancy was classified. Prefer tools whose encodings you can inspect, and treat a pass as 'no flaggable issue in this data under this encoding', not as compliance. You and the approving authority stay accountable; the authoritative rule is the actual byelaw and NBC, never its encoded version, and binding interpretation stays with you, the authority and the law.

For the interior designerWhere automated rule-checking helps interiors (accessibility, fire, egress) and where judgement is required

Many interior obligations encode cleanly - door clear widths, accessible-route widths, wheelchair turning space, aisle and corridor widths, ramp slopes - which is exactly why they are worth checking early, and exactly why the encoding's assumptions matter to you. When a tool flags an under-width doorway, it is applying someone's rule for what 'clear opening' means (clear of the leaf? the frame? at what angle of swing?). Learn to ask how a checked property is measured and which elements the rule was scoped to, because a mislabelled 'foyer' or an unclassified opening can make a real problem invisible or a compliant detail fail. Use encoded checks as an early-warning assistant on the quantitative rules, and keep the judgement that real usability and accessibility demand. Binding fire, egress and accessibility compliance stays with the qualified professionals, the authority and the governing code (NBC India, accessibility standards).

For the studentHow regulations become machine-readable rules - and why many rules resist being coded at all

This lesson is the clearest window in the course into how regulation becomes machine logic - and why many rules resist it. Take one sentence, 'a corridor in an assembly building shall have a clear width of at least 2.0 m', and watch it decompose into scope (occupancy = assembly), element (corridor), property (clear_width), operator (greater-than-or-equal) and threshold (2.0 m), plus an action on failure. That structure is the skeleton of every quantitative rule. Then see the honest half: encoding forces decisions the prose left vague (clear of what? which spaces are corridors?), can narrow the rule's intent to a single number, and makes the measurement convention decisive. The one idea to carry: encoding is interpretation, done once by the encoder and then run literally by the machine - which is why data quality, transparency and human accountability all matter, and why a check is never an approval.

Misconception check

Encoding a rule is basically translation - you take the sentence in the byelaw and rewrite it as code, and as long as you are careful the code says exactly what the law says. So a well-encoded rule is just the law in another form, and a 'pass' from it means the design meets that rule.

Encoding is not neutral translation; it is a chain of interpretive decisions, and this is true even for a rule as apparently mechanical as a corridor width. To make 'clear width of at least 2.0 m' runnable, someone must decide what the width is measured clear of (column, handrail, door swing, skirting, pipe), which spaces in the model count as corridors, whether the occupancy is really 'assembly', and exactly how the dimension is computed from the geometry. The prose tolerated these ambiguities because a trained human resolves them in context; the machine cannot, so the encoder resolves them once, up front, and the computer then applies those resolutions with literal obedience. Different reasonable encoders can produce different encodings of the same clause, and the automated result can diverge from how a plans-examiner would read it. The encoded rule is therefore a MODEL of the regulation - faithful but lossy - not the regulation itself. It can also be wrong, out of date, or run against incomplete or mislabelled model data. So a 'pass' means only that, under this encoding and this data, no flaggable issue was found - not that the design complies. The authoritative rule is always the actual byelaw, code or law, read by an accountable human; the encoder made choices, and the qualified professional of record and the approving authority remain responsible for what the rule truly requires.
Try it

Do it yourself

No software needed - reason it through.

  1. 1Take 'a corridor in an assembly building shall have a clear width of at least 2.0 m' and name its scope, element, property, operator and threshold.
  2. 2What must a corridor element in the model 'know' about itself for this rule to be checkable?
  3. 3List three decisions the encoder is forced to make that the prose left vague, and say why each is an interpretation.
  4. 4Give one way a corridor could satisfy the encoded rule and still fail the rule's real intent.
  5. 5Explain why an automated 'pass' on this rule is not a determination that the design complies, and who stays accountable.
Take this with you

The one line to carry out

Encoding a rule decomposes a prose regulation into an explicit, testable structure - scope, element, property, operator, threshold and an action on failure - which is why clear quantitative rules automate well; but the translation is a chain of interpretive decisions that can narrow the rule's intent and make the measurement convention decisive, so the encoded rule is a faithful-but-lossy model of the regulation, never the regulation itself, and the authoritative rule and its interpretation stay with the professional, the authority and the actual code.
Take it further
References & further reading

Peer-reviewed journals & authoritative standards

  1. 01Rules as codeWikipedia - Rules as code, 2026.
  2. 02Formal specificationWikipedia - Formal specification, 2026.
  3. 03Building codeWikipedia - Building code, 2026.
  4. 04Decision tableWikipedia - Decision table, 2026.
Related lessons
Recap
To encode a rule is to take one sentence a trained human reads and quietly completes - 'a corridor in an assembly building shall have a minimum clear width of 2.0 metres' - and rebuild it as logic a machine can run. That means making the implicit explicit: the scope (occupancy = assembly), the element (corridor), the property (clear_width), the operator and threshold (greater than or equal to 2.0 m), and an action on failure (flag it). Decomposed like this, the rule becomes the skeleton shared by nearly every quantitative requirement, and it runs well - but only if the structured model carries the data the rule reads. The honest half is that encoding forces decisions the prose left vague (clear of what? which spaces count as corridors? is the occupancy really assembly?), can narrow a rule whose intent is comfortable, safe movement into a single number, and makes the measurement convention as decisive as the threshold. So the encoded rule is a model of the regulation - faithful but lossy - and encoding is itself interpretation, performed once by the encoder and then applied literally by the machine. The authoritative rule is always the actual byelaw and code, read by an accountable human, and a 'pass' is a useful early signal, never a legal determination that the design complies.
Carry forward →

Having watched one rule become logic, we can name the bigger idea it belongs to - regulation given a second, executable form - its movement, its goals, and the deep risk that encoding is interpretation. That is the rule-as-code idea, next.

A

The author

Amogh N P

Architect, interior designer, and creative polymath. Studio Matrx began in his notebooks — his vision of design made honest, useful, and open to everyone. Its Academy is written and taught in his memory, and free, forever.

More about Amogh →