Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
inox
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LARA
inox
Commits
5ff3fe12
Commit
5ff3fe12
authored
12 years ago
by
Etienne Kneuss
Committed by
Philippe Suter
12 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Test to highlight bug in CEGIS synthesis.
parent
eeb719e7
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/test/scala/leon/test/synthesis/SynthesisSuite.scala
+57
-4
57 additions, 4 deletions
src/test/scala/leon/test/synthesis/SynthesisSuite.scala
with
57 additions
and
4 deletions
src/test/scala/leon/test/synthesis/SynthesisSuite.scala
+
57
−
4
View file @
5ff3fe12
...
...
@@ -46,9 +46,22 @@ class SynthesisSuite extends FunSuite {
}
}
def
assertRuleSuccess
(
sctx
:
SynthesisContext
,
rr
:
Traversable
[
RuleInstantiation
])
{
assert
(
rr
.
isEmpty
===
false
,
"No rule alternative while the rule should have succeeded"
)
assert
(
rr
.
exists
(
alt
=>
alt
.
apply
(
sctx
).
isInstanceOf
[
RuleSuccess
])
===
true
,
"Rule did not succeed"
)
def
assertAllAlternativesSucceed
(
sctx
:
SynthesisContext
,
rr
:
Traversable
[
RuleInstantiation
])
{
assert
(!
rr
.
isEmpty
)
for
(
r
<-
rr
)
{
assertRuleSuccess
(
sctx
,
r
)
}
}
def
assertRuleSuccess
(
sctx
:
SynthesisContext
,
rr
:
RuleInstantiation
)
:
Option
[
Solution
]
=
{
rr
.
apply
(
sctx
)
match
{
case
RuleSuccess
(
sol
)
=>
Some
(
sol
)
case
_
=>
assert
(
false
,
"Rule did not succeed"
)
None
}
}
...
...
@@ -89,7 +102,47 @@ object Injection {
case
(
solver
,
fd
,
p
)
=>
val
sctx
=
SynthesisContext
(
solver
,
new
SilentReporter
,
new
java
.
util
.
concurrent
.
atomic
.
AtomicBoolean
)
assert
Rule
Succe
ss
(
sctx
,
rules
.
CEGIS
.
instantiateOn
(
sctx
,
p
))
assert
AllAlternatives
Succe
ed
(
sctx
,
rules
.
CEGIS
.
instantiateOn
(
sctx
,
p
))
assertFastEnough
(
sctx
,
rules
.
CEGIS
.
instantiateOn
(
sctx
,
p
),
100
)
}
forProgram
(
"Cegis 2"
)(
"""
import scala.collection.immutable.Set
import leon.Annotations._
import leon.Utils._
object Injection {
sealed abstract class List
case class Cons(head: Int, tail: List) extends List
case class Nil() extends List
// simulates input/output spec.
def tail(in: List) = choose {
(out: List) =>
(in != Cons(0, Nil()) || out == Nil()) &&
(in != Cons(0, Cons(1, Nil())) || out == Cons(1, Nil())) &&
(in != Cons(0, Cons(1, Cons(2, Nil()))) || out == Cons(1, Cons(2, Nil())))
}
}
"""
)
{
case
(
solver
,
fd
,
p
)
=>
val
sctx
=
SynthesisContext
(
solver
,
new
DefaultReporter
,
new
java
.
util
.
concurrent
.
atomic
.
AtomicBoolean
)
rules
.
CEGIS
.
instantiateOn
(
sctx
,
p
).
head
.
apply
(
sctx
)
match
{
case
RuleSuccess
(
sol
)
=>
assert
(
false
,
"CEGIS should have failed, but found : %s"
.
format
(
sol
))
case
_
=>
}
rules
.
ADTSplit
.
instantiateOn
(
sctx
,
p
).
head
.
apply
(
sctx
)
match
{
case
RuleDecomposed
(
subs
)
=>
for
(
sub
<-
subs
;
alt
<-
rules
.
CEGIS
.
instantiateOn
(
sctx
,
sub
))
{
println
(
assertRuleSuccess
(
sctx
,
alt
))
}
case
_
=>
assert
(
false
,
"Woot?"
)
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment