Skip to content

Silicon implementation of new backend-independent counterexample format#940

Open
marcoeilers wants to merge 20 commits into
masterfrom
meilers_raoul_counterexamples
Open

Silicon implementation of new backend-independent counterexample format#940
marcoeilers wants to merge 20 commits into
masterfrom
meilers_raoul_counterexamples

Conversation

@marcoeilers

Copy link
Copy Markdown
Contributor

Silicon implementation of the new backend-independent counterexample format (see viperproject/silver#883), written by @rvandoren in his practical work project.

@marcoeilers
marcoeilers marked this pull request as ready for review July 15, 2026 22:32
case AtMost(t0, t1) => intComparison(t0, t1, model, env)(_ <= _)
case AtLeast(t0, t1) => intComparison(t0, t1, model, env)(_ >= _)
case Less(t0, t1) => intComparison(t0, t1, model, env)(_ < _)
case t: Greater => intComparison(t.p0, t.p1, model, env)(_ > _)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

case Greater(t0, t1) =>

@@ -0,0 +1,1157 @@
package viper.silicon.reporting

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Header

import viper.silver.verifier.Rational

/**
* Transforms a counterexample returned by Boogie back to a Viper counterexample. The programmer can choose between an

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adjust names here and in comment below

}

/**
* CounterexampleGenerator class used for generating an "intermediate" CE.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

intermediate -> raw

}
case c@MagicWandChunk(_, _, _, _, _, _, _) =>
heap += detMagicWand(model, c)
case _ => //println("This case is not supported in detHeap")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drop, add quantified wand chunk case

/**
* Compare the snapshot of a predicate to its actual body (accessed through its ast node).
*/
def evalBody(exp: Exp, value: ModelEntry, lookup: scala.collection.immutable.Map[Exp, ModelEntry]): (Exp, ModelEntry) = {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adjust naming to clarify difference between this and term evaluation above.

}
}

def evalSnap(term: Term, model: Model): Seq[ModelEntry] = term match {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this still needed?

/**
* Evaluates a Term to a value of the counterexample from the SMT solver.
*/
def evalTermToModelEntry(value: Term, model: Model): Option[ModelEntry] = {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this still needed?

// Inline pTaken (instead of defining a macro) when a counterexample is requested, so that the
// chunk's permission term contains proper permission arithmetic the counterexample machinery
// can evaluate, rather than an opaque macro application.
val declareMacro = s.functionRecorder == NoopFunctionRecorder && Verifier.config.counterexample.toOption.isEmpty // && !Verifier.config.useFlyweight

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also for MCE?

// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
//
// Copyright (c) 2011-2025 ETH Zurich.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adjust

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant