Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Equivalence checking as a component #1378

Merged
merged 4 commits into from Mar 7, 2023

Conversation

mario-bucev
Copy link
Collaborator

Equivalence checking is now a component, activated with --equivchk. As before, it requires --models and --comparefuns to be fed with a list of model function(s) and candidate function(s) respectively, and optionally accept a --norm=<fn name> for normalization function. Note that @traceInduct functions need not to run with the --equivchk option.
New options:

  • --equivchk-n=<int> (default: 3): specify the N hyperparameter
  • --equivchk-init-score=<int> (default: 200): specify the initial score for models
  • --equivchk-max-perm=<int> (default: 16): maximum number of matching for auxiliary functions
  • --silent-verification=<bool> (default: false): do not print any message when a VC fails to verify (whether due to invalidity or timeout).

This PR:

  • ⚠️ factors unificationConstraint from oo.TypeOps to ast.TypeOps. oo.TypeOps overrides ast.TypeOps for oo constructs.
  • splits Trace into EquivalenceChecker and TraceInductElimination.
  • adds a test suite for equivalence checking, so the nightly CI will run for longer

Copy link
Collaborator Author

@mario-bucev mario-bucev left a comment

Choose a reason for hiding this comment

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

This is not stack-safe:

def examination(): Future[ec.Results] = {
ec.pickNextExamination() match {
case ec.NextExamination.Done(pruned, res) =>
debugPruned(ec)(pruned)
printResults(ec)(res)
context.options.findOption(equivchk.optEquivalenceOutput) match {
case Some(out) => dumpResultsJson(out, ec)(res)
case None => ()
}
Future.successful(res)
case ec.NextExamination.NewCandidate(cand, model, strat, pruned) =>
debugPruned(ec)(pruned)
debugNewCandidate(ec)(cand, model, strat)
round()
}
}
def round(): Future[ec.Results] = {
val generated = ec.prepareRound()
val allFns = (ec.symbols.functions -- generated.map(_.id)).values.toSeq ++ generated
val syms: trace.trees.Symbols = trace.trees.NoSymbols
.withSorts(ec.symbols.sorts.values.map(identity.transform).toSeq)
.withFunctions(allFns.map(identity.transform))
val plainSyms = tracePostPipeline.extract(syms)._1
underlyingRun.execute(generated.map(_.id), plainSyms, ExtractionSummary.NoSummary)
.flatMap { analysis =>
val concl = ec.concludeRound(analysis)
concl match {
case ec.RoundConclusion.NextRound(cand, model, strat, prunedSubFnsPairs) =>
debugNewRound(ec)(cand, model, strat)
debugPrunedSubFnsPairs(prunedSubFnsPairs)
round()
case ec.RoundConclusion.CandidateClassified(cand, classification, prunedSubFnsPairs) =>
debugClassified(ec)(cand, classification)
debugPrunedSubFnsPairs(prunedSubFnsPairs)
examination()
}
}
}

Edit: it is stack-safe as long as the ExecutionContext is stack-safe (see scala/bug#11256) which was not the case when parallelism is disabled because the currentThreadExecutionContext runs the runnable (the docs seems to recommand to avoid this):
private lazy val currentThreadExecutionContext: ExecutionContext =
ExecutionContext.fromExecutor(new java.util.concurrent.Executor {
def execute(runnable: Runnable): Unit = { runnable.run() }
})

Changing it to:
private lazy val singleThreadExecutionContext: ExecutionContext =
ExecutionContext.fromExecutor(Executors.newFixedThreadPool(1))

@mario-bucev mario-bucev marked this pull request as draft February 23, 2023 10:46
@mario-bucev mario-bucev marked this pull request as ready for review March 6, 2023 12:46
@mario-bucev mario-bucev merged commit 33a990a into epfl-lara:main Mar 7, 2023
@mario-bucev mario-bucev deleted the equiv-chk-extra-matching branch March 7, 2023 19:22
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.

None yet

3 participants