{log}: From a Constraint Logic Programming Language to a Formal Verification Tool
This paper presents a comprehensive overview of {log}, a Constraint Logic Programming language that evolved into an integrated formal verification environment capable of treating state machines as both executable programs and specifications through features like automated theorem proving, verification condition generation, and test case generation.
Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer
Imagine you are building a complex machine, like a robot that organizes a library. Usually, you have to do two very different jobs:
- Write the instructions (the code) that tell the robot how to move its arms.
- Write a separate manual (the specification) that describes what the robot should do, so you can check if the instructions are correct.
Often, these two things don't match perfectly. You might write a manual saying "Pick up the red book," but the code accidentally says "Pick up the red book and the blue one." Checking if they match is hard, slow, and prone to human error.
This paper introduces a tool called {log} (pronounced "setlog") that solves this problem by merging the two jobs into one. It turns the programming language itself into a "proof machine."
Here is a breakdown of how it works, using some everyday analogies:
1. The "Chameleon" Code (Program-Formula Duality)
In most programming languages, code is like a recipe: "Mix flour, add eggs, bake." It's just a list of steps.
In {log}, code is like a Chameleon. It can change its shape depending on how you look at it.
- As a Program: You can run it to make the robot move.
- As a Specification: You can look at the same lines of code and ask, "Does this recipe guarantee that I won't burn the cake?"
Because the code is the specification, you don't need to translate your thoughts from a "human manual" into "computer code." They are the same thing. If the code is correct, the specification is correct, and vice versa.
2. The "Set" Superpower
The secret sauce of {log} is that it treats Sets (groups of things) and Relationships (how things connect) as its native language.
- Imagine you have a box of Lego bricks. In normal programming, you have to write complex loops to find a specific red brick.
- In {log}, you just say, "Give me the red brick," or "Show me all bricks that are connected to the blue one."
The tool has a built-in "math brain" (a solver) that instantly figures out if your request is possible or if it leads to a contradiction. It doesn't just guess; it uses mathematical logic to prove the answer.
3. The "State Machine" (The Story of the Birthday Book)
To prove this works, the authors use a classic example: a Birthday Book.
- The Goal: A system that remembers people's birthdays and reminds you when it's their big day.
- The State Machine: Think of the system as a character in a play. It has a "current state" (who is in the book) and "operations" (adding a name, removing a name, checking a date).
- The Magic: With {log}, you can write the rules for adding a name. Then, you can immediately ask the computer: "If I add a name, will the system break?" or "If I add two people with the same name, does the system handle it gracefully?"
4. The "Safety Inspector" (Verification Condition Generator)
Usually, checking if code is safe requires a human to read it and say, "Hmm, I think this is safe."
{log} has a built-in Safety Inspector (called the VCG).
- When you write a rule (like "You can only add a name if they aren't already in the book"), the Inspector automatically generates a list of "What If" questions.
- Question: "What if the book is empty?"
- Question: "What if the name is a number?"
- The tool then runs a mathematical proof to answer "Yes" or "No." If it says "No, this breaks the rules," it doesn't just stop; it gives you a Counterexample. It says, "Here is a specific scenario where your code fails: Try adding 'Alice' when 'Alice' is already there." This helps you fix the bug instantly.
5. The "Test Case Generator" (The Stress Tester)
Once the code is verified, you need to test it to make sure it works in the real world.
Normally, a human has to think of all the weird things that could go wrong (e.g., "What if I try to add a birthday for a person who doesn't exist?").
{log** has a Stress Tester that does this for you.
- It looks at your rules and automatically generates a list of "Test Scenarios."
- It creates a "Tree" of possibilities: "Try adding a name," "Try adding a duplicate," "Try adding a name with a weird symbol."
- It then runs these tests automatically to ensure your system behaves exactly as the math predicted.
Why is this a big deal?
Think of other tools like Agda or Dafny. They are like high-end, custom-built laboratories. They are powerful, but they require you to learn a new, very strict way of thinking.
{log} is like a Swiss Army Knife.
- It starts as a standard programming language (Constraint Logic Programming).
- But with a few extra tools attached, it becomes a Formal Verification System.
- It doesn't require you to switch between a "coding mode" and a "proving mode." You write once, and the tool handles the rest: running the program, proving it's safe, and testing it.
The Bottom Line
This paper shows that you can take a programming language that loves math (sets and logic) and turn it into a tool that proves its own code is correct. It bridges the gap between "writing software" and "mathematically proving software works," making it easier to build systems that are reliable, secure, and bug-free.
Drowning in papers in your field?
Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.