Comprehensive backend-independent counterexamples#883
Open
marcoeilers wants to merge 25 commits into
Open
Conversation
marcoeilers
marked this pull request as ready for review
July 15, 2026 22:33
marcoeilers
commented
Jul 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR introduces a shared, backend-independent counterexample format in Silver, produced by both Silicon and Carbon. A counterexample is built in two layers:
RawCounterexample): the information collected from the backend model in a simple form, with heap resources still identified by backend-internal (SMT) identifiers.ResolvedCounterexample): the human-readable form; heap resources are bound to their AST nodes (fields, predicates, magic wands) and values are ordinary Viper AST expressions.Values are represented as normal Viper AST expressions (
ast.Exp). The two new AST nodesRefLit(a concrete reference) andBackendValueLit(an otherwise opaque backend value) cover things that have no ordinary Viper syntax.Select the layer on the command line:
--counterexample resolved(orraw). Silicon additionally requires--exhaleMode 1.Example:
The resolved counterexample shown to the user:
Seq(10, #undefined),Set(1, 2, 3),Multiset(7, 7, 8),Map(1 := 100));#undefinedmarks an entry the model does not pin down.Other resource kinds render analogously; a magic wand appears as the wand itself, e.g. Magic Wand Entry:
acc(x.f, 1/2) --* acc(x.f, 1/1) (Perm: 1/1), and (domain) function values are listed under a separate section, e.g.The same format is emitted by both Silicon and Carbon, so the two agree modulo backend-internal reference names (
$Ref!val!0vsT@U!val!0).This is the result of @rvandoren's practical work project, with a bunch of additions from me.