Parsing Amendment Language with Conventional Grammars

Conventional parsers still work when the drafting system is structured enough.

Elias Kunnas

The claim

Legislative amendment language is a semi-formal instruction language embedded in ordinary legal prose. In jurisdictions with mature drafting guidance, many recurring preamble and operative-text forms are regular enough for conventional grammars to parse deterministically.

LawVM demonstrates this on a bounded Finnish corpus, parsing recurring forms with PEG grammars into typed clause structures. The same input produces the same parse, while unsupported or ambiguous cases remain visible for recovery or refusal.

What prior work already exists

Parsing amendment language with conventional tools predates LawVM. Selected examples include:

  • Arnold-Moore (1995) described an ATN-based parser and an architecture for processing Tasmanian amending legislation in the ICAIL paper.
  • Ogawa, Inagaki, and Toyama (2008) formalized Japanese amendment sentences for automatic consolidation; the authors’ publication list records the paper and venue.
  • Bolioli, Mercatali, and Romano (2004) described formal models for explicit text amendment in Italian legislation in this open paper.
  • Smywiński-Pohl et al. (2021) treated amendment detection in Polish statutory law as an information-extraction task in ICAIL’21.

These systems establish prior art for parsing and partial consolidation. LawVM’s narrower contribution is an open replay pipeline that carries admitted parses through typed target resolution, provision timelines, source/witness comparison, and residual evidence on a Finnish corpus.

Why Finnish amendment language suits grammar testing

Finnish legislative drafting follows the Lainkirjoittajan opas (legislative drafting guide), which describes the structure of amendment preambles (johtolause):

  • Actions follow a prescribed order: kumotaan (repeal), muutetaan (amend), lisätään (insert)
  • The preamble ends with seuraavasti: ("as follows:")
  • Target addresses use hierarchical structural paths: lain 12 §:n 2 momentti
  • Multi-part amendments list all affected provisions in the preamble before the operative text
  • The operative text follows the preamble in section order

These conventions support human reading and make recurring forms amenable to grammar-based parsing. They do not remove the need for source-local recovery or explicit refusal when a form falls outside the covered grammar.

The johtolause is, in effect, a domain-specific instruction language. It has a grammar. LawVM exploits that grammar with a PEG parser that extracts clause structure, target addresses, action types, and payload boundaries.

What LawVM adds beyond extraction

Parsing is the first step. The compiler pipeline continues:

  1. Clause surface: typed AST of amendment instructions
  2. Payload extraction: amendment body text isolated and normalized
  3. Elaboration: meaning recovery against the live statute state (what does "2 momentti" mean given the current structure of this section?)
  4. Canonical operations: typed operations (replace, repeal, insert, renumber, text-replace) with resolved targets
  5. Replay: operations applied to statute tree
  6. Timeline construction: provision versions organized temporally
  7. Materialization: point-in-time text produced
  8. Residual classification: divergences from the declared comparison surface are typed and explained

The parse is necessary but not sufficient; the compiler pipeline and evidence surface are the contribution.

Where grammars break

Coverage is incomplete. LawVM encounters:

  • Implicit scope inheritance — "3, 4, 6 ja 7 luku" where bare numbers inherit the trailing "luku" (chapter). A flat parser sees numbers, not chapters.
  • Omission semantics<hcontainer name="omission"/> in XML means different things in different contexts (unchanged prefix, unchanged suffix, unchanged middle).
  • Flattened list items — numbered items encoded as sibling subsections instead of paragraph children.
  • Content-only continuations — split paragraph text across XML elements without labels.
  • Body-root fallbacks — generic preambles that don't name specific targets, forcing whole-section inference.

Selected covered cases use quirks-mode recovery: heuristic normalization with explicit provenance. Unsupported cases can instead remain blocked or unresolved. The architectural rule is that every recovery affecting legal text, structure, target resolution, or timeline selection must be named, witnessed, and rejectable in strict mode. Much of the engineering work in LawVM is turning historical ad hoc repairs into owned, typed recovery rules.

Why Deterministic Replay Matters Now

A deterministic evidence path addresses a requirement highlighted by recent work. A 2025 NLLP study of LLM-based statute consolidation reported high text similarity but much lower exact-match rates on multi-step chains, and recommended rigorous human verification before deployment.

Deterministic parsing and symbolic replay address a different requirement: reproducible text-state compilation where each admitted step is inspectable and each failure is typed. They can therefore serve as infrastructure beneath systems that use statistical or generative methods for other tasks.

Conventional parsers can extract covered structures from a johtolause; the remaining work is resolving targets, replaying effects, and preserving the evidence for every refusal or recovery.