Skip to Content

Specify with Quint, prove with Lean

• Written by:Gabriela Moreira
Cover image for Specify with Quint, prove with Lean

There are different formal methods tools, and we believe the main strength of Quint is that developers can understand the specs. That’s partly because the syntax is familiar, but also because the tools help them execute the spec and learn what behaviors it defines. The post Understanding Solana’s Alpenglow with Quint  shows how we can use the tooling to understand a spec.

Meanwhile, other tools can offer stronger formal guarantees. Lean has been rightfully recognized for its strength in many online conversations lately, as the need to verify AI-generated code keeps rising. However, one question that often comes up is: “How do we know whether we are proving the right things?”

We close that gap today by embedding Quint in Lean (via Veil), which allows properties in Quint, about models in Quint, to be proven in Lean. Veil is a Lean framework that describes a state machine the way that Quint does, so the Veil team was responsible for closing most of this gap, and we’re just tying things together. We chose an embedding rather than transpilation to Veil to make this work as seamless and bug-free as possible. Here’s how a Quint spec can be used inside Lean:

module public import Quint quint_module "my_spec.qnt" theorem my_property_holds : holds% my_property := by sorry -- your proof goes here

Moreover, Veil 2.0 shipped an amazing model checker, and we are adding integration with it too:

quint verify my_spec.qnt --backend veil

In this post, we’ll show our proposed approach to verification with a two-phase commit example, where an agent picks a method for each property together with the user. We don’t expect everyone using formal methods to understand each verification method in enough depth to know which one to apply to each scenario. We split the post into two parts:

  1. How to use Quint tools and skills to find and use the best technique for each of your properties.
  2. What tools and techniques are involved.

If we got part 1 right, you shouldn’t need part 2 at all, but we still wrote it because we find it very interesting.

Part 1: Finding the right technique for each property

The example: two-phase commit

Let’s start with the protocol that we’re going to verify. Two-phase commit is a procedure in which a coordinator gets a set of participants to agree on one outcome for a transaction: either every participant commits it, or every participant aborts it. Here’s the heart of the spec:

module two_phase_commit { const participants: Set[str] var stages: str -> Stage var coordinatorStage: Stage var votes: Set[str] var messages: Set[Message] /// Participant p commits, because the coordinator committed action commits(p: str): bool = all { messages.contains(CoordinatorCommit), stages' = stages.put(p, Committed), messages' = messages } /// No participant commits while another aborts invariant consistency = tuples(participants, participants).forall(((p1, p2)) => not(stages.get(p1) == Committed and stages.get(p2) == Aborted) ) /// Once the coordinator commits, it never changes its decision temporal commitStays = always(coordinatorStage == Committed implies always(coordinatorStage == Committed)) }

The set of participants is a constant, participants, which works as a parameter to the state machine. In other words, the spec describes two-phase commit for any number of participants. It states two properties:

  • consistency is the property that really matters: no participant commits while another aborts.
  • commitStays is a temporal property. Once the coordinator decides to commit, it never changes its mind.

To run the spec, we fix the participants in an instance. two_phase_commit_3 is the instance with three of them:

module two_phase_commit_3 { import two_phase_commit(participants = Set("p1", "p2", "p3")).* }

Choosing the verification technique with an agent

There are several ways to check a property, especially now that we have the possibility of writing Lean proofs. Each verification strategy can make a different claim, with a different trust surface and different cost. Some techniques don’t work for all specs.

  • A simulation runs many executions and is not considered formal verification.
  • Model checking covers every execution of three participants, or some other predefined number of participants.
  • Proofs require more work, but can guarantee the property for any number of participants, and also have the smallest trust surface.
  • Inductive invariants sit in between.

Instead of having to learn everything about these methods to be able to decide when and how to use each of them, we propose you try our skills, which will explain what each method could do for your particular specification.

In Claude Code, you install them with the Quint plugin:

/plugin marketplace add quint-co/quint /plugin install quint@quint

For other agents, such as Cursor, Codex and Gemini, the GitHub CLI installs them:

gh skill install quint-co/quint quint-verification --pin main

The skills README  has the other ways to install them. Then you ask your agent to plan the verification of the spec:

> Plan the verification of two_phase_commit.qnt

The agent starts with a short probe of each method on each property, using the quint command. For two-phase commit, all the probes together took about 7 minutes on our machine, most of which was spent on Veil’s invariant synthesizer, which we explain below. Then it shows you one table for each property, with the claim that each method can make, and below the table, it recommends one method. Here’s what it showed us for consistency (claims shortened):

MethodPossibleClaimDrawback, or why notProbe
model checkingyesholds in every reachable state with 3 participantscovers only 3 participants288 states in 21.8 s, no violation
inductionyesholds in every reachable state, for any number of participantsnot inductive on its own, so the run checks it together with the synthesizer’s clausesthe step fails after aborts, and Veil’s synthesizer found 9 clauses in 6.7 min
leanyesholds in every reachable state, for any number of participantsyou or your agent write the proof, which can take hours
simulationyesno violation is seen in 10000 traces with 3 participantscovers only 3 participants, and misses a violation that no trace reaches1000 traces in 0.7 s, no violation

Recommended: induction, with the 9 clauses that the synthesizer found. It makes the claim for any number of participants, and the synthesizer has already found the clauses. The run is just one check.

The induction row is the interesting one. On its own, consistency isn’t inductive. So, while it makes the plan, the agent looks for the invariants that make consistency inductive. First it runs Veil’s invariant synthesizer. In this case, it found 9 extra clauses, enough to make consistency inductive. If they hadn’t been enough, the agent would have proposed the missing invariants itself. If the agent’s search had failed too, we would have fallen back to two bounded checks: model checking of consistency for 3 participants and a symbolic check of every short execution.

The table of the other property, commitStays, has the same shape:

commitStays: model checking is recommended
MethodPossibleClaimDrawback, or why notProbe
model checkingyesholds on every execution with 3 participantscovers only 3 participantsnot probed, since a temporal property gets a run of its own
inductionnoInduction proves only invariants.
leanyesholds on every execution, for any number of participantsyou or your agent write the proof, which is longer than for an invariant and needs the invariants it assumes
simulationnoSimulation doesn’t check temporal properties.

Recommended: model checking. It checks commitStays on every execution with 3 participants in one run, with no proof to write. Lean is offered as well, if you want the claim for any number of participants.

Below the tables, the agent also tells you whether a proof in Lean would trust the SMT solver, and how to change that. For two-phase commit, it said:

Lean proofs trust the SMT solver (--trust-smt), since two-phase commit is a protocol at a high level. Say if you want Lean’s kernel to check every answer instead, and the flag is left out.

We agreed to the recommended plan. The agent then ran the checks and wrote a report. From the first probe to the report, the whole run took about 10 minutes on our machine, and two thirds of that time was the synthesizer’s search:

PropertyMethodResultHolds forTime
consistencyinductionprovedany number of participants17.1 s
commitStaysmodel checkingchecked3 participants49.0 s

The report makes precise claims

You might have seen formal verification experts questioning folks who claimed they formally verified some software, as that barely means anything. We need to be able to state exactly what was verified and be aware of the trust surface. The skill produces a report with all this information, so the claims are precise.

For example, here’s the section for consistency:

### consistency: proved, by induction Claim: consistency holds in every reachable state, for any number of participants. Trust surface: the embedding of Quint in Lean, Veil, and the SMT solver, whose answers Lean's kernel doesn't check. Veil's synthesizer certified its clauses with Lean's kernel, but the check of their Quint translation trusts the solver. How it was found: by Veil's invariant synthesizer, which found 9 clauses in 6.7 minutes. To check it again: quint verify two_phase_commit.strengthened.qnt --backend veil --main two_phase_commit --inductive-invariant 'consistency and ic3_0 and ic3_1 and ic3_2 and ic3_3 and ic3_4 and ic3_5 and ic3_6 and ic3_7 and ic3_8' --invariants consistency

The report lists the 9 invariants after this section, and the agent offers to add them to your spec.

If you chose to prove consistency in Lean instead, the agent would write a Lean file that states the theorem, with sorry in place of the proof:

quint_module "two_phase_commit.qnt" (main := two_phase_commit) (invariants := [consistency]) /-- `consistency` holds in every reachable state, for any number of participants. -/ theorem consistency_holds : holds% consistency := by sorry

You can write the proof yourself or ask an agent of your choice to write it for you. The skill has some helpful instructions for writing proofs about Quint properties. You can use the Lean CLI to check the proof, but we recommend you do it via quint verify, because it requires the proof to establish the exact same theorem as originally stated. This prevents an agent struggling with the proof from quietly changing the theorem into one that is easier to prove. The check refuses a proof in each of these cases:

  • The statement of a theorem was changed.
  • The proof rests on a sorry, or on an axiom beyond Lean’s three standard ones.
  • The quint_module line sets an option that changes the spec.

Once the proof checks, the row for consistency in the report looks like this:

PropertyMethodResultHolds forTime
consistencyleanprovedany number of participants8.8 s

Part 2: The tools and techniques underneath

The rest of this post is, in my opinion, more entertaining. We are going to discuss the techniques themselves. We’ll follow the methods of the plan, from model checking to proofs in Lean, and look at what’s interesting about each one.

Model checking, with Veil’s compiled checker

Let’s start with the first thing that the integration brings: Veil’s model checker. Veil 2.0 shipped an explicit-state model checker, which compiles a spec into a native binary before it searches. In our benchmark below, it was faster than TLC on three of four large checks. And its search is verified: Veil proves in Lean that every violation it reports comes with a valid trace, and that a search that finishes has seen every reachable state, as long as no two states share a fingerprint. We’re really excited about it, and we’re considering it as the default backend of quint verify. For now, it’s a new option for the --backend flag:

$ quint verify two_phase_commit.qnt --main two_phase_commit_7 --invariant consistency --backend veil [Veil] Running Veil's model checker, which is compiled at the first check of a spec... [Veil] Explored 296448 states. [ok] No violation found (532ms).

This is super straightforward. The command writes a Lean file that loads the spec with quint_module, and Veil compiles its checker from the module that Lean loaded:

module public import Quint quint_module "two_phase_commit.qnt" (main := two_phase_commit_7) #model_check compiled {} {}

In other words, the model checker runs on the spec exactly as Lean loaded it. See more about that in the next section.

To give you a sense of the timings, we ran quint verify with TLC, Apalache and Veil on five examples from the Quint repository. We made most of them large enough that TLC’s search takes a minute or more, so that starting TLC’s JVM and compiling Veil’s checker do not dominate the timings. TLC and Veil were both given 20 cores.

Bar chart of wall times for five checks. On two-phase commit with two participants, TLC took 13 seconds, Veil took 0.7 seconds with its checker compiled and Apalache took 27 seconds at a 7-step bound.
The wall time of quint verify on each check.
The numbers behind the chart, in seconds
CheckDistinct statesTLCVeil, first checkVeil, compiledApalache, bounded
two_phase_commit_25613.019.90.727.5 (7 steps)
two_phase_commit_910,340,352132.353.229.0—
DiningPhilosophers1413,811,712109.888.666.065.4 (7 steps)
ewd840_1015,730,686180.1103.979.991.9 (14 steps)
teaching_d1431,132,83161.599.581.141.0 (10 steps)

These checks are completely automated, which is great. But every model checker has the same limit, whether it’s TLC, Apalache or Veil’s. The parameters of a spec have to be fixed, because a model checker always checks one specific state machine. Its answer is about three participants, or seven participants, but never about any number of them.

The instances also grow fast. Each participant multiplies the number of states by more than five, and eight participants already make 1,745,408 states. Nine make the 10,340,352 states of the benchmark above. A real deployment has as many participants as it has, and no number of checked instances adds up to “any number”. To say something about every set of participants, the participants have to stay a parameter, and a claim about every value of a parameter needs a proof.

Getting the spec into Lean

In order to use Lean’s tactics and its SMT solvers, we need to get the Quint spec into Lean. There are two ways to do that: transpiling and embedding.

A transpiler would take the spec as input and produce Lean code as output. That gives you a second copy of the spec, and consequently the two copies may drift apart:

  • When the Quint spec changes, the Lean file is out of date until someone runs the transpiler again.
  • When someone edits the Lean file, it no longer matches the Quint spec, and the edit is lost the next time that the transpiler runs.
  • A proof is about the Lean output, and you have to trust that the output means what the Quint spec means.

That’s why we chose an embedding instead. quint_module is a Lean command that reads the spec every time the Lean file is checked:

import Quint quint_module "two_phase_commit.qnt" (main := two_phase_commit) (smt := true)

There’s no second copy to keep up to date, and whenever we check a proof, the check is made against the current version of the spec, which can avoid mistakes. The translation itself is direct, since Veil and Quint are both heavily based on the TLA⁺ way of describing a system.

If you’re curious, the embedding lives in lean/Quint/Embed.lean . It maps each Quint operator to a function in our Lean library, which defines Quint’s builtins in plain Lean. Here’s how it handles Quint’s map operators get, put and set, and the definition that put and set map to:

-- lean/Quint/Embed.lean | "get" => do let (m, k) ← args2 op args; `(Quint.Map.get $m $k) | "put" | "set" => do let (m, k, v) ← args3 op args; `(Quint.Map.put $m $k $v) -- lean/Quint/Builtins.lean def put (m : Map κ ν) (k : κ) (v : ν) : Map κ ν := Std.ExtTreeMap.insert m k v

That’s how a Lean proof of a Quint spec starts.

Leveraging the power of SMT

With the spec in Lean, Veil’s SMT backend gives us two ways to check consistency for any number of participants: a bounded check and induction.

Both go through our SMT encoding. With (smt := true), quint_module will use a special representation of values in Lean that SMT solvers can work with (since they only accept certain kinds of values) and Veil’s SMT backend then hands the questions to the solver. Our encoding doesn’t cover all of Quint yet and still needs a lot of work, but this should offer a glimpse of what is possible for some specs now and will be possible for all (or most) specs once the encoding is completed.

Apalache’s SMT encoding covers much more of Quint than ours does today, accepting almost the whole language. Ours is more complete than Veil’s own encodings for the set of Quint examples we tried, which is why we are shipping it. But it is still limited, and we’re exploring different SMT encodings to close that gap. If you’re a researcher working on this kind of problem, we’d love your help!

A bounded symbolic check for any number of participants

The first strategy leverages SMT to allow the participant count to remain a parameter, bounding the length of the executions instead. This is checked by adding an unsat trace query to the Lean file, right after the quint_module line above:

unsat trace { any 8 actions assert ¬ consistency }

This query asks the solver for an execution of up to eight steps. To do this via the Quint CLI, use the --symbolic flag, which will run this query for each length of execution, from 0 to --max-steps:

$ quint verify two_phase_commit.qnt --backend veil --main two_phase_commit --invariants consistency --symbolic --max-steps 8 [Veil] Added stages.keys() == participants (from init) to the invariants of this check; it is proved together with them. [Veil] Checking consistency, stages.keys() == participants in every execution of up to 8 steps, for every value of the constants... ✓ consistency holds in every execution of up to 8 steps ✓ stages.keys() == participants holds in every execution of up to 8 steps [ok] No violation found (28850ms).

The solver cannot satisfy this unsat statement because there is no execution that breaks consistency. That is, consistency holds in every execution of up to eight steps, for any number of participants!

Induction: an inductive invariant

Induction removes the need for a bound: the proof extends to executions of any length. But, for that, we can’t check any kind of invariant. It has to be an inductive invariant. A property is inductive when it holds for the initial states, and every step preserves the property: if it starts in a state (any state!) that satisfies that property, it will always end in a state that satisfies it too. Therefore, an inductive property holds in every reachable state, by induction on the steps. quint verify checks this with Veil’s SMT backend, but consistency alone doesn’t pass it, because it is not inductive:

$ quint verify two_phase_commit.qnt --main two_phase_commit --backend veil --inductive-invariant consistency [Veil] Added stages.keys() == participants (from init) to the invariants of this check; it is proved together with them. [...] [violation] Found an issue (6920ms). error: the inductive invariant fails after aborts

The output, which we shortened above, shows a step of aborts that starts in a state that satisfies consistency, but after the aborts step, the property is false. That’s not a bug in the protocol, though. The state from which aborts starts is not one we consider valid: one participant has committed while there’s an abort message from the coordinator. This should be impossible! The state is unreachable, but nothing in consistency enforces that, so the tool finds an example that doesn’t respect this and aborts causes an issue.

The property needs strengthening, meaning more invariants that rule out unreachable states like this one, and that are inductive together with the property. How to Write Inductive Invariants  offers a more complete explanation of this.

Good news: In some cases, like this one, Veil can help us synthesize those invariants. #updr is an invariant synthesizer (IC3/PDR for first-order logic). On top of the limits of the encoding, it only finds clauses that are universal statements over names, enumerations and integers (it would be amazing to have this expanded!). To call it from a Lean file, we simply write:

#updr certify

To do it via the CLI, use the --synthesize-invariant option:

$ quint verify two_phase_commit.qnt --backend veil --main two_phase_commit --synthesize-invariant consistency [Veil] Added stages.keys() == participants (from init) to the invariants of this check; it is proved together with them. [Veil] Searching with #updr for invariants that make consistency inductive, for every value of the constants... Veil's solver calls: 537, 313.8 s (preprocessing 159.5 s, elaboration 13.3 s, solving 131.5 s, decoding 2.2 s); transition relation normalized once in 0.1 s Veil found 9 strengthening clauses, at frame 5: invariant [ic3_0] coordinatorStage = Committed ∨ ¬ messages_CoordinatorCommit invariant [ic3_1] coordinatorStage = Aborted ∨ ¬ messages_CoordinatorAbort invariant [ic3_2] ¬ messages_CoordinatorAbort ∨ ¬ messages_CoordinatorCommit invariant [ic3_3] ∀ (x0 : str), ¬ stages x0 = Committed ∨ messages_CoordinatorCommit ∨ ¬ participants x0 invariant [ic3_4] ∀ (x0 : str), ¬ votes x0 ∨ messages_ParticipantPrepared x0 invariant [ic3_5] ∀ (x0 : str) (x1 : str), votes x1 ∨ ¬ messages_CoordinatorCommit ∨ ¬ participants x0 ∨ ¬ participants x1 ∨ x0 = x1 invariant [ic3_6] ∀ (x0 : str), ¬ stages x0 = Working ∨ ¬ messages_ParticipantPrepared x0 invariant [ic3_7] ∀ (x0 : str), ¬ stages x0 = Aborted ∨ messages_CoordinatorAbort ∨ ¬ messages_ParticipantPrepared x0 invariant [ic3_8] ∀ (x0 : str) (x1 : str), ¬ stages x1 = Aborted ∨ ¬ messages_CoordinatorCommit ∨ ¬ participants x0 ∨ ¬ participants x1 ∨ x0 = x1 Certified: theorem two_phase_commit.ic3_safe, on the axioms propext, Classical.choice, Quot.sound; kernel-checked, standard axioms only. [ok] Found an inductive invariant that proves consistency (400861ms).

The clauses that it found read as facts about the protocol:

  • An abort message is out only once the coordinator has aborted, and a commit message only once it has committed.
  • The coordinator never sends both decisions, which rules out the state that caused the failure above.
  • If a participant has committed, the commit message went out.
  • A vote comes with the participant’s prepared message, and once the commit message is out, every participant has voted.
  • A participant that sent its prepared message isn’t working anymore.
  • If a participant prepared and then aborted, the abort message went out.
  • Once the commit message is out, no participant has aborted.

This search took 6.7 minutes on our machine. The result is a theorem, ic3_safe, which states that every reachable state satisfies consistency. The agent then writes the 9 clauses as Quint invariants, ic3_0 to ic3_8, in a copy of the spec. For example, the clause ic3_3 becomes this definition:

val ic3_3 = participants.forall(x0 => not(stages.get(x0) == Committed) or messages.contains(CoordinatorCommit) or not(participants.contains(x0)) )

quint verify proves them inductive together with consistency, for every number of participants:

$ quint verify two_phase_commit.strengthened.qnt --backend veil --main two_phase_commit --invariants consistency \ --inductive-invariant 'consistency and ic3_0 and ic3_1 and ic3_2 and ic3_3 and ic3_4 and ic3_5 and ic3_6 and ic3_7 and ic3_8' [Veil] Added stages.keys() == participants (from init) to the invariants of this check; it is proved together with them. > [1/3] Checking whether the inductive invariant 'consistency and [...]' holds in the initial state(s) defined by 'init'... > [2/3] Checking whether 'step' preserves the inductive invariant 'consistency and [...]'... > [3/3] Checking whether the inductive invariant 'consistency and [...]' implies 'consistency'... [ok] No violation found (14446ms).

Apalache checks inductive invariants too, with the same --inductive-invariant option, but on an instance. Its claim is about a specific number of participants. Veil’s answer is about every number of them, because the participants stay a parameter that the solver reasons about. Apalache also needs the candidate to bound each state variable, the way TLA⁺‘s TypeOK does, so for Apalache we put four bounds before the ten invariants, such as stages.in(setOfMaps(participants, Set(Working, Prepared, Committed, Aborted))). The two checks took about the same amount of time (but Veil’s makes a stronger claim):

CheckerChecked forTime
Apalache3 participants12.5 s
Veilany number of participants14.4 s

Proofs in Lean

The induction check above trusts the SMT solver, while a proof in Lean needs to trust only Lean’s kernel, a small program that checks every step of the proof. If you want even more assurance, you can also download con-leche  and check the proof with it, on top of Lean’s kernel. Con-leche is an external checker of Lean proofs, which is itself proved in Lean never to accept a proof of False.

Our proofs go over the steps of the spec, with the help of our command #gen_steps. It states the steps (transitions) of the spec as plain Lean, with one case for each action, and it proves reachable_induction, which carries a property of the steps to every reachable state. In other words, it breaks the final goal into smaller goals. The final goal is that the property holds in every reachable state, and the smaller goals are that it holds in every initial state and that every step keeps it. Lean’s grind tactic is often enough to close each case. We built this shape with agents in mind, so that they (hopefully) write much less Lean. Our skill guides them to use it.

Let’s look at the proof of consistency that an agent wrote for the Lean row of Part 1. As we saw above, consistency isn’t inductive on its own, so the structure Inv states it together with 7 invariants that make it inductive. The agent wrote those invariants as fields of a Lean structure. Then inv_init and inv_step show that Inv holds initially and that every step keeps it, each with cases, constructor and grind. Finally, reachable_induction closes the theorem that the skill stated, holds% consistency. It says that consistency holds in every reachable state, for every value of the constants:

quint_module "two_phase_commit.qnt" (main := two_phase_commit) (invariants := [consistency]) #gen_steps structure Inv (ps : Std.ExtTreeSet String compare) (s : State (FieldAbstractType ps)) : Prop where consistency : ∀ q ∈ Quint.Set.tuples2 ps ps, ¬(Quint.Map.get s.stages q.1 = .Committed ∧ Quint.Map.get s.stages q.2 = .Aborted) stageDomain : ∀ p, p ∈ s.stages ↔ p ∈ ps votesSent : ∀ p ∈ s.votes, Message.ParticipantPrepared p ∈ s.messages commitMsg : Message.CoordinatorCommit ∈ s.messages → s.coordinatorStage = .Committed abortMsg : Message.CoordinatorAbort ∈ s.messages → s.coordinatorStage = .Aborted committedMsg : ∀ p ∈ ps, Quint.Map.get s.stages p = .Committed → Message.CoordinatorCommit ∈ s.messages preparedWaits : ∀ p ∈ ps, Message.ParticipantPrepared p ∈ s.messages → s.coordinatorStage = .Working → Quint.Map.get s.stages p = .Prepared commitPrepared : Message.CoordinatorCommit ∈ s.messages → ∀ p ∈ ps, Quint.Map.get s.stages p = .Prepared ∨ Quint.Map.get s.stages p = .Committed theorem inv_init {ps} {th : Theory ps} {s} (h : Initial th s) : Inv ps s := by cases h constructor <;> grind theorem inv_step {ps} {th : Theory ps} {s s'} (h : Inv ps s) (hs : Step th s s') : Inv ps s' := by rcases h with ⟨h0, h1, h2, h3, h4, h5, h6, h7⟩ cases hs <;> constructor <;> grind theorem consistency_holds : holds% consistency := by intro ps th st hr exact (reachable_induction (P := fun _ s => Inv ps s) (fun _ _ _ hi => inv_init hi) (fun _ _ _ _ hP hst => inv_step hP hst) th st hr).consistency

The proof checked on the agent’s first try with quint verify --proofs. Like ic3_safe, the theorem quantifies over every set of participants.

The solver, for what grind can’t close

A larger spec needs more than one grind for each step, so it can use some help from the solver. However, the solver works on Veil’s own goals, and it doesn’t close the goals of #gen_steps yet. Veil states one goal for each invariant and each action, which says that the action keeps the invariant, and Veil’s command #gen_theorems declares each goal as a Lean theorem. Then holds_by_invariants closes holds% consistency from those theorems.

By default, Veil trusts that the solver is correct and accepts its proofs. With set_option veil.smt.trust false, Veil asks the solver for a proof as well, and a tool called lean-smt replays that proof as a Lean proof, which Lean’s kernel checks. Under this setting, Veil trusts only Lean’s three standard axioms:

'two_phase_commit.commits_consistency' depends on axioms: [propext, Classical.choice, Quot.sound]

With quint verify --proofs, we also need to decide whether to trust the SMT solver. Use --trust-smt to opt in. Next steps of our integration work include making the solver work on the goals of #gen_steps, so that one proof can mix grind and the solver.

Temporal properties

In Part 1, we checked commitStays with three participants: once the coordinator commits, it never changes its decision. Let’s prove the same property for any number of participants.

temporal commitStays = always(coordinatorStage == Committed implies always(coordinatorStage == Committed))

We use Veil’s prove_temporal_by, which works in the proof mode of the Lentil  temporal logic library. This is what the proof looks like:

prove_temporal_by [commitStays] tclear hInit hInv ttoggle_goal_under_always tintro hCommitted trewrite [always_induction] tsplit_ands · tassumption tclear hCommitted ttoggle_goal_under_always unveil_temporal grind theorem commitStays_holds : holds_temporal% commitStays := by holds_by_temporal_proof

For a liveness example, see the proof for Dijkstra’s termination detection algorithm . That proof shows that once all nodes are inactive, node 0 eventually detects termination under a fairness assumption.

Trying it

Everything in this post is open source! In the Quint repository, you’ll find the embedding, the Veil backend of quint verify, the quint-verification skill and the examples. The embedding lives in lean/Quint, and lean/README.md explains more about what we need to trust (basically: Quint’s parser and typechecker and the definitions that the embedding gives to Quint’s builtins). Below those, it trusts Veil and Lean’s kernel.

Take a spec you already have (or use Quint Studio to write some specs from your code!) and ask the skills to help you find the best verification strategy for your scenarios. This is early and we didn’t want to hold off on releasing it, so consider opening issues if you don’t like the results from the skill.

So, how do we know that we’re proving the right things? With Quint, you play with the spec and convince yourself you agree with the behaviors it defines. With Lean, you prove things about that same spec you already understand. Or you verify things in some automated way. After verifying, you’ll get a report stating precisely what was verified, and you can then tell the world how great it is to check things with Quint and Lean!