Skip to content

Silicon implementation of new backend-independent counterexample format - #940

Merged
marcoeilers merged 27 commits into
masterfrom
meilers_raoul_counterexamples
Aug 14, 2026
Merged

Silicon implementation of new backend-independent counterexample format#940
marcoeilers merged 27 commits into
masterfrom
meilers_raoul_counterexamples

Conversation

@marcoeilers

@marcoeilers marcoeilers commented Sep 1, 2025

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.

A lot of the code is used to evaluate arbitrary Silicon terms in a state described by a Z3 model, which is used for example to evaluate permission amounts that quantified chunks provide for specific heap locations.

@marcoeilers
marcoeilers marked this pull request as ready for review July 15, 2026 22:32
Comment thread src/main/scala/reporting/Converter.scala Outdated
Comment thread src/main/scala/reporting/SiliconResolvedCounterexample.scala
Comment thread src/main/scala/reporting/SiliconResolvedCounterexample.scala Outdated
Comment thread src/main/scala/reporting/SiliconResolvedCounterexample.scala Outdated
Comment thread src/main/scala/reporting/SiliconResolvedCounterexample.scala Outdated
Comment thread src/main/scala/reporting/SiliconResolvedCounterexample.scala Outdated
Comment thread src/main/scala/reporting/SiliconResolvedCounterexample.scala Outdated
Comment thread src/main/scala/reporting/SiliconResolvedCounterexample.scala Outdated
Comment thread src/main/scala/rules/QuantifiedChunkSupport.scala
Comment thread src/test/scala/GeneralCounterexampleTests.scala Outdated
@marcoeilers
marcoeilers requested a review from AndreaKe July 25, 2026 15:50

@AndreaKe AndreaKe left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Some nitpicky comments, otherwise LGTM

Comment thread src/main/scala/reporting/SiliconResolvedCounterexample.scala Outdated
Comment thread src/main/scala/reporting/SiliconResolvedCounterexample.scala Outdated
Comment thread src/main/scala/reporting/SiliconResolvedCounterexample.scala Outdated
Comment thread src/main/scala/reporting/SiliconResolvedCounterexample.scala
Comment thread src/main/scala/reporting/SiliconResolvedCounterexample.scala Outdated
Comment thread src/main/scala/reporting/SiliconResolvedCounterexample.scala Outdated
Comment thread src/main/scala/reporting/SiliconResolvedCounterexample.scala
Comment thread src/main/scala/reporting/SiliconResolvedCounterexample.scala
Comment thread src/main/scala/reporting/SiliconResolvedCounterexample.scala

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Implements Silicon support for the new backend-independent counterexample format by introducing “raw” and “resolved” counterexample generation from SMT models, extending term evaluation to cover more Silicon term constructs, and wiring the new counterexample modes into symbolic execution.

Changes:

  • Add SiliconResolvedCounterexample/SiliconRawCounterexample to transform Z3 models into Viper counterexamples (including collections/heaps/domains/functions).
  • Extend Converter.evaluateTerm with environment binding and support for additional boolean/int/perm/map operations used by counterexample resolution.
  • Update counterexample plumbing (model kinds, permission-term inlining) and adjust/replace counterexample test suites and Z3 configuration.

Reviewed changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/test/scala/MappedCounterexampleTests.scala Renames/retargets mapped counterexample test suite and annotation wrapper.
src/test/scala/GeneralCounterexampleTests.scala Adds a general/resolved counterexample test suite and verifier config.
src/test/resources/counterexamples/simple-refs.vpr Removes legacy counterexample test input.
src/test/resources/counterexamples/simple-refs-rec.vpr Removes legacy counterexample test input.
src/test/resources/counterexamples/sequence.vpr Removes legacy counterexample test input.
src/test/resources/counterexamples/ref-sequence.vpr Removes legacy counterexample test input.
src/test/resources/counterexamples/predicate.vpr Removes legacy counterexample test input.
src/test/resources/counterexamples/permissions.vpr Removes legacy counterexample test input.
src/test/resources/counterexamples/negative.vpr Removes legacy counterexample test input.
src/test/resources/counterexamples/method-call.vpr Removes legacy counterexample test input.
src/test/resources/counterexamples/lseg.vpr Removes legacy counterexample test input.
src/test/resources/counterexamples/functions.vpr Removes legacy counterexample test input.
src/test/resources/counterexamples/cyclic-ref.vpr Removes legacy counterexample test input.
src/main/scala/rules/SymbolicExecutionRules.scala Wires in Raw/Resolved counterexample modes.
src/main/scala/rules/QuantifiedChunkSupport.scala Avoids macros for permission terms when counterexamples are requested.
src/main/scala/rules/MoreCompleteExhaleSupporter.scala Inlines pTaken term when counterexamples are requested to keep permission arithmetic evaluable.
src/main/scala/reporting/SiliconResolvedCounterexample.scala Introduces raw/resolved counterexample construction from SMT models (large new implementation).
src/main/scala/reporting/Converter.scala Extends term evaluation (env binding + more operations) for counterexample resolution.
src/main/resources/z3config.smt2 Enables partial models in Z3 configuration.
Suppressed comments (1)

src/test/scala/MappedCounterexampleTests.scala:21

  • testDirectories points to counterexample_mapped, but this directory does not exist under src/test/resources in this branch, so this suite will either discover no tests or fail to load resources. Add the missing resource directory/files, or change testDirectories to an existing resource path.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/test/scala/GeneralCounterexampleTests.scala
Comment thread src/main/scala/rules/SymbolicExecutionRules.scala
Comment thread src/main/scala/reporting/SiliconResolvedCounterexample.scala
Comment thread src/main/scala/reporting/Converter.scala
@marcoeilers
marcoeilers merged commit 749852e into master Aug 14, 2026
4 checks passed
@marcoeilers
marcoeilers deleted the meilers_raoul_counterexamples branch August 14, 2026 12:42
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.

3 participants