Skip to content

Commit 9624864

Browse files
Put SSL rules for sequences behind a flag and test suite file
1 parent 85bf080 commit 9624864

12 files changed

Lines changed: 55 additions & 15 deletions

File tree

src/main/scala/org/tygus/suslik/synthesis/SynConfig.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ case class SynConfig(
2929
memoization: Boolean = true,
3030
delegatePure: Boolean = false,
3131
extendedPure: Boolean = false,
32+
sequenceRules: Boolean = false,
3233
// Timeout and logging
3334
interactive: Boolean = false,
3435
printStats: Boolean = false,

src/main/scala/org/tygus/suslik/synthesis/SynthesisRunner.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,10 @@ object SynthesisRunner extends SynthesisRunnerUtil {
176176
conf => conf.copy(extendedPure = b, delegatePure = b || conf.delegatePure)
177177
}).text("use extended search space for pure synthesis with CVC4; default: false")
178178

179+
opt[Boolean](name = "sequenceRules").action(cfg { b =>
180+
_.copy(sequenceRules = b)
181+
}).text("use some additional heuristics for synthesis with sequences; default: false")
182+
179183
opt[Boolean]('i', "interactive").action(cfg { b =>
180184
_.copy(interactive = b)
181185
}).text("interactive mode; default: false")

src/main/scala/org/tygus/suslik/synthesis/rules/BranchRules.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ object BranchRules extends PureLogicUtils with SepLogicUtils with RuleUtils {
7878

7979
def atomCandidates(goal: Goal): Seq[Expr] =
8080
for {
81-
lhs <- goal.programVars.filter(v => goal.post.phi.vars.contains(v) && goal.getType(v) == IntType) ++ List(IntConst(0))
82-
rhs <- goal.programVars.filter(v => goal.post.phi.vars.contains(v) && goal.getType(v) == IntType) ++ List(IntConst(0))
81+
lhs <- goal.programVars.filter(v => goal.post.phi.vars.contains(v) && goal.getType(v) == IntType) ++ (if (goal.env.config.sequenceRules) List(IntConst(0)) else List())
82+
rhs <- goal.programVars.filter(v => goal.post.phi.vars.contains(v) && goal.getType(v) == IntType) ++ (if (goal.env.config.sequenceRules) List(IntConst(0)) else List())
8383
if lhs != rhs
8484
} yield lhs |<=| rhs
8585

src/main/scala/org/tygus/suslik/synthesis/rules/FailRules.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,9 @@ object FailRules extends PureLogicUtils with SepLogicUtils with RuleUtils {
5151
def apply(goal: Goal): Seq[RuleResult] = {
5252
val (uniPost, exPost) = goal.splitPost
5353
// If precondition does not contain predicates, we can't get new facts from anywhere
54-
if (!SMTSolving.valid(goal.pre.phi ==> uniPost)) {
54+
if (!SMTSolving.valid(goal.pre.phi ==> uniPost))
5555
// universal post not implied by pre
5656
List(RuleResult(List(goal.unsolvableChild), IdProducer, this, goal))
57-
}
5857
else filterOutValidPost(goal, exPost, uniPost)
5958
}
6059
}

src/main/scala/org/tygus/suslik/synthesis/rules/OperationalRules.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ object OperationalRules extends SepLogicUtils with RuleUtils {
5252

5353

5454
// When do two heaplets match
55-
def isMatch(hl: Heaplet, hr: Heaplet) = sameLhs(hl)(hr) && !sameRhs(hl)(hr) && noGhosts(hr) && noForbiddenExprs(hr)
55+
def isMatch(hl: Heaplet, hr: Heaplet) = sameLhs(hl)(hr) && !sameRhs(hl)(hr) && noGhosts(hr) &&
56+
(!goal.env.config.sequenceRules || noForbiddenExprs(hr))
5657

5758
findMatchingHeaplets(_ => true, isMatch, goal.pre.sigma, goal.post.sigma) match {
5859
case None => Nil

src/main/scala/org/tygus/suslik/synthesis/rules/UnificationRules.scala

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ object UnificationRules extends PureLogicUtils with SepLogicUtils with RuleUtils
115115
Γ ; {φ ; P} ; {ψ ∧ X = l; Q} ---> S
116116
*/
117117
object SubstRight extends SynthesisRule with InvertibleRule {
118-
//object SubstRight extends SynthesisRule {
119118
override def toString: String = "SubstExist"
120119

121120
def apply(goal: Goal): Seq[RuleResult] = {
@@ -129,8 +128,8 @@ object UnificationRules extends PureLogicUtils with SepLogicUtils with RuleUtils
129128
goal.isExistential(x) &&
130129
// if it's a program-level existential, then all vars in d must be program-level
131130
(!goal.isProgramLevelExistential(x) || d.vars.subsetOf(goal.programVars.toSet)) &&
132-
// no forbidden expressions
133-
noForbiddenExprs(d)
131+
// no forbidden expressions if sequenceRules enabled
132+
(!goal.env.config.sequenceRules || noForbiddenExprs(d))
134133
case _ => false
135134
}
136135

@@ -184,7 +183,8 @@ object UnificationRules extends PureLogicUtils with SepLogicUtils with RuleUtils
184183
override def toString: String = "PickExist"
185184

186185
def apply(goal: Goal): Seq[RuleResult] = {
187-
val constants = List(IntConst(0), IntConst(-1), SetLiteral(List()), SequenceLiteral(List()), eTrue, eFalse)
186+
val constants = if (goal.env.config.sequenceRules) List(IntConst(0), IntConst(-1), SetLiteral(List()), SequenceLiteral(List()), eTrue, eFalse)
187+
else List(IntConst(0), SetLiteral(List()), SequenceLiteral(List()), eTrue, eFalse)
188188

189189
val exCandidates = // goal.existentials
190190
if (goal.post.sigma.isEmp) goal.existentials else goal.existentials.intersect(goal.post.sigma.vars)
@@ -205,7 +205,8 @@ object UnificationRules extends PureLogicUtils with SepLogicUtils with RuleUtils
205205
for {
206206
ex <- least(exCandidates) // since all existentials must go, no point trying them in different order
207207
val uni = toSorted(uniCandidates(ex))
208-
v <- uni ++ constants ++ uni.flatMap(x => inductiveCandidates(x, x.getType(goal.gamma).get))
208+
v <- if (goal.env.config.sequenceRules) uni ++ constants ++ uni.flatMap(x => inductiveCandidates(x, x.getType(goal.gamma).get))
209+
else uni ++ constants
209210

210211
if goal.getType(ex) == v.getType(goal.gamma).get
211212
sigma = Map(ex -> v)

src/test/resources/synthesis/sequences/paper-benchmarks/sll/sll-ith.syn

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# -c 1 -o 1 -b true
1+
# -c 1 -o 1 -b true --sequenceRules true
22

33
#####
44

src/test/resources/synthesis/sequences/paper-benchmarks/sll/sll-length.syn

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# -c 1 -o 1
1+
# -c 1 -o 1 --sequenceRules true
22

33
#####
44

src/test/resources/synthesis/sequences/project-benchmarks/llist_ith.syn

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# -c 2 -o 2 -b true
1+
# -c 2 -o 2 -b true --sequenceRules true
22

33
#####
44

src/test/resources/synthesis/sequences/project-benchmarks/sll-ith.syn

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# -c 1 -o 1 -b true
1+
# -c 1 -o 1 -b true --sequenceRules true
22

33
#####
44

0 commit comments

Comments
 (0)