GRATgen

Conflict analysis and lemma marking.

Conflict Analysis and Lemma Marking

The idea of backwards checking is to certify the lemmas backwards, marking those lemmas that have actually been used for a certification. This way, unmarked lemmas can be skipped.

In order to realize backwards checking, one has to analyze the trail in the state after unit propagation found a conflict, and find out which lemmas have actually been used to derive the conflict.

The first relevant conflict is the root conflict after all lemmas have been added. Thus, before backward checking, the checker goes forwards over the lemmas, adds them to the formula, and then does unit propagation to find a conflict. The state of the trail after this conflict has been found is called forward trail.

Once a conflict has been found, all involved lemmas needs to be marked. For this reason, each literal on the trail is associated with a reason, that is the unit clause due to which the literal has been set. Note that the reason is null, if the literal was set on initiating a RUP or RAT check, i.e., as one of the negated literals in the lemma to be proved.

A naive approach to conflict analysis would be to mark all reasons on the current trail. However, in practice, not all lemmas on the trail are actually required to derive the conflict. Thus, a more precise method is used: Only the reasons for setting the literals of the conflict clause are marked, and the reasons for setting their literals, and so on.

This is realized by a depth first search procedure: Each entry on the trail gets an additional visited flag (called vmarked), indicating that the reasons for the trail entry's literal have already been marked. Moreover, to quickly find the trail entries corresponding to the literals of a clause, we store a map from assigned variables to trail positions.

The DFS search is realized by the mutually recursive functions Verifier::mark_var() and Verifier::mark_clause(), which mark all the (recursive) reasons for a variable being set and for the literals of a clause being assigned. Verifier::mark_clause() additionally marks the clause, indicating that it needs to be certified when the backwards check arrives there.

Extracting the Certificate

Finally, a certificate has to be extracted. Again, there are two places where certificates has to be extracted:

  1. After a successful RUP or RAT candidate check, a sequence of unit clause ids has to be emitted. These correspond exactly to the vmarked items that have been added to the trail during the RUP or RAT candidate check, and the list can be extracted during backtracking.
  2. When extracting the overall proof, unit propagations that led to the root conflict have to be recorded, and they must be correctly interleaved with the proofs for the lemmas! To this end, each lemma is associated with the trail size at which it was processed in the forward pass. During emitting the lemmas, the corresponding entries on the forward trail that are vmarked are emitted as unit-propagation items.