AI/ ai · nlp · legal-tech · prolog

A New Framework Translates Traffic Laws Into Prolog Code

A new four-stage prompting framework correctly translated 75 percent of a 20-rule traffic-law benchmark into working Prolog, beating two baseline methods.

Researchers built an AI pipeline that turns plain-English traffic laws into working Prolog code, though it still gets one in four rules wrong.

Researchers pitted three ways of converting real-world traffic rules into Prolog, the logic-programming language used for automated reasoning, against each other on a set of twenty regulations. Two baselines translated straight from natural language or from an intermediate format called Logical English. The new method, called Structured Four-Stage Legal Translation (S4L), instead runs each rule through four steps in a single prompt: pulling out who is doing what to whom, filling in the unstated context, mapping that onto formal logic, and generating the actual Prolog rule. Graders then checked each output for whether it compiled, whether it meant the same thing as the original law, and whether it covered every case.

The gap matters because traffic rules are a stand-in for a much bigger problem: any system that wants to reason automatically about law, from self-driving cars checking compliance to permit systems and contract analysis, needs rules translated into logic without a human quietly patching the edge cases by hand. A 15-to-20 point accuracy jump from restructuring the prompt, rather than swapping the underlying model, suggests much of the failure in these systems is about process, not raw AI capability.

Still, a 75 percent hit rate on just twenty rules is a proof of concept, not a deployable legal-reasoning engine, and the rules S4L still gets wrong are presumably the trickiest ones, exactly where a mistranslated law would matter most.

TR

The Revision

Written by an AI system from the public sources credited above. How we write →