-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Experimental integration of OL- and OCBSL- based simplifiers
- Loading branch information
1 parent
3ef64d0
commit 5dbe1b1
Showing
11 changed files
with
3,999 additions
and
9 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
49 changes: 49 additions & 0 deletions
49
core/src/main/scala/stainless/transformers/LatticesSimplifier.scala
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package stainless | ||
package transformers | ||
|
||
import inox.solvers | ||
|
||
import java.util.concurrent.atomic.AtomicInteger | ||
|
||
// Wrapper that sets up a thread-local algo instance | ||
trait LatticesSimplifier { self => | ||
import LatticesSimplifier._ | ||
val trees: ast.Trees | ||
val symbols: trees.Symbols | ||
val opts: solvers.PurityOptions | ||
val algo: UnderlyingAlgo | ||
|
||
import trees._ | ||
import symbols.{given, _} | ||
|
||
private val coreTL: ThreadLocal[lattices.Core{val trees: self.trees.type; val symbols: self.symbols.type}] = | ||
ThreadLocal.withInitial(() => algo match { | ||
case UnderlyingAlgo.OCBSL => lattices.OCBSL(trees, symbols, opts) | ||
case UnderlyingAlgo.OL => lattices.OL(trees, symbols, opts) | ||
case UnderlyingAlgo.Bland => lattices.Bland(trees, symbols, opts) | ||
}) | ||
|
||
def simplify(e: Expr): Expr = { | ||
val core = coreTL.get() | ||
given core.Env = core.Env.empty | ||
given core.Ctxs = core.Ctxs.empty | ||
given core.LetValSubst = core.LetValSubst.empty | ||
|
||
val resE = core.codeOfExpr(e) | ||
val codeE = resE.selfPlugged(core.Ctxs.empty)._2 | ||
core.uncodeOf(codeE).expr.copiedFrom(e) | ||
} | ||
} | ||
object LatticesSimplifier { | ||
|
||
enum UnderlyingAlgo { | ||
case OCBSL | ||
case OL | ||
case Bland | ||
} | ||
|
||
def apply(t: ast.Trees, s: t.Symbols, opts: solvers.PurityOptions, algo: UnderlyingAlgo): LatticesSimplifier{val trees: t.type; val symbols: s.type} = { | ||
class Impl(override val trees: t.type, override val symbols: s.type, override val opts: solvers.PurityOptions, override val algo: UnderlyingAlgo) extends LatticesSimplifier | ||
new Impl(t, s, opts, algo) | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
core/src/main/scala/stainless/transformers/lattices/Bland.scala
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package stainless | ||
package transformers | ||
package lattices | ||
|
||
import inox.solvers | ||
|
||
trait Bland extends Core { | ||
import trees._ | ||
import symbols.{given, _} | ||
import Opaques.{given, _} | ||
import Purity._ | ||
|
||
override final def impliedImpl(rhs: Code)(using env: Env, ctxs: Ctxs): Boolean = false | ||
|
||
override final def doSimplifyDisjunction(disjs: Seq[Code], polarity: Boolean)(using Env, Ctxs): Seq[Code] = disjs | ||
|
||
override final def checkForDisjunctionContradiction(disjs0: Seq[Code])(using Env, Ctxs): Option[Int] = None | ||
} | ||
|
||
object Bland { | ||
def apply(t: ast.Trees, s: t.Symbols, opts: solvers.PurityOptions): Bland{val trees: t.type; val symbols: s.type} = { | ||
class Impl(override val trees: t.type, override val symbols: s.type, override val opts: solvers.PurityOptions) extends Bland | ||
new Impl(t, s, opts) | ||
} | ||
} |
Oops, something went wrong.