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
7d7d96fc
Commit
7d7d96fc
authored
12 years ago
by
Etienne Kneuss
Browse files
Options
Downloads
Patches
Plain Diff
Work on the new CEGIS
parent
71ad4bf8
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/main/scala/leon/synthesis/Heuristics.scala
+87
-1
87 additions, 1 deletion
src/main/scala/leon/synthesis/Heuristics.scala
with
87 additions
and
1 deletion
src/main/scala/leon/synthesis/Heuristics.scala
+
87
−
1
View file @
7d7d96fc
...
@@ -11,7 +11,8 @@ import purescala.Definitions._
...
@@ -11,7 +11,8 @@ import purescala.Definitions._
object
Heuristics
{
object
Heuristics
{
def
all
=
Set
[
Synthesizer
=>
Rule
](
def
all
=
Set
[
Synthesizer
=>
Rule
](
new
OptimisticGround
(
_
),
new
OptimisticGround
(
_
),
new
IntInduction
(
_
),
//new IntInduction(_),
new
CEGISOnSteroids
(
_
),
new
OptimisticInjection
(
_
)
new
OptimisticInjection
(
_
)
)
)
}
}
...
@@ -195,3 +196,88 @@ class SelectiveInlining(synth: Synthesizer) extends Rule("Sel. Inlining", synth,
...
@@ -195,3 +196,88 @@ class SelectiveInlining(synth: Synthesizer) extends Rule("Sel. Inlining", synth,
}
}
}
}
}
}
class
CEGISOnSteroids
(
synth
:
Synthesizer
)
extends
Rule
(
"cegis w. gen."
,
synth
,
50
)
with
Heuristic
{
def
applyOn
(
task
:
Task
)
:
RuleResult
=
{
val
p
=
task
.
problem
case
class
Generator
(
tpe
:
TypeTree
,
altBuilder
:
()
=>
List
[(
Expr
,
Set
[
Identifier
])]);
var
generators
=
Map
[
TypeTree
,
Generator
]()
def
getGenerator
(
t
:
TypeTree
)
:
Generator
=
generators
.
get
(
t
)
match
{
case
Some
(
g
)
=>
g
case
None
=>
val
alternatives
:
()
=>
List
[(
Expr
,
Set
[
Identifier
])]
=
t
match
{
case
BooleanType
=>
{
()
=>
List
((
BooleanLiteral
(
true
),
Set
()),
(
BooleanLiteral
(
false
),
Set
()))
}
case
Int32Type
=>
{
()
=>
List
((
IntLiteral
(
0
),
Set
()),
(
IntLiteral
(
1
),
Set
()))
}
case
TupleType
(
tps
)
=>
{
()
=>
val
ids
=
tps
.
map
(
t
=>
FreshIdentifier
(
"t"
,
true
).
setType
(
t
))
List
((
Tuple
(
ids
.
map
(
Variable
(
_
))),
ids
.
toSet
))
}
case
CaseClassType
(
cd
)
=>
{
()
=>
val
ids
=
cd
.
fieldsIds
.
map
(
i
=>
FreshIdentifier
(
"c"
,
true
).
setType
(
i
.
getType
))
List
((
CaseClass
(
cd
,
ids
.
map
(
Variable
(
_
))),
ids
.
toSet
))
}
case
AbstractClassType
(
cd
)
=>
{
()
=>
val
alts
:
Seq
[(
Expr
,
Set
[
Identifier
])]
=
cd
.
knownDescendents
.
flatMap
(
i
=>
i
match
{
case
acd
:
AbstractClassDef
=>
synth
.
reporter
.
error
(
"Unnexpected abstract class in descendants!"
)
None
case
cd
:
CaseClassDef
=>
val
ids
=
cd
.
fieldsIds
.
map
(
i
=>
FreshIdentifier
(
"c"
,
true
).
setType
(
i
.
getType
))
Some
((
CaseClass
(
cd
,
ids
.
map
(
Variable
(
_
))),
ids
.
toSet
))
})
alts
.
toList
}
case
_
=>
synth
.
reporter
.
error
(
"Can't construct generator. Unsupported type: "
+
t
+
"["
+
t
.
getClass
+
"]"
);
{
()
=>
Nil
}
}
val
g
=
Generator
(
t
,
alternatives
)
generators
+=
t
->
g
g
}
case
class
TentativeFormula
(
f
:
Expr
,
recTerms
:
Map
[
Identifier
,
Set
[
Identifier
]])
{
def
unroll
:
TentativeFormula
=
{
var
newF
=
this
.
f
var
newRecTerms
=
Map
[
Identifier
,
Set
[
Identifier
]]()
for
((
_
,
recIds
)
<-
recTerms
;
recId
<-
recIds
)
{
val
gen
=
getGenerator
(
recId
.
getType
)
val
alts
=
gen
.
altBuilder
().
map
(
alt
=>
FreshIdentifier
(
"b"
,
true
)
->
alt
)
val
pre
=
Or
(
alts
.
map
{
case
(
id
,
_
)
=>
Variable
(
id
)
})
// b1 OR b2
val
cases
=
for
((
bid
,
(
ex
,
rec
))
<-
alts
.
toList
)
yield
{
// b1 => E(gen1, gen2) [b1 -> {gen1, gen2}]
if
(!
rec
.
isEmpty
)
{
newRecTerms
+=
bid
->
rec
}
Implies
(
Variable
(
bid
),
Equals
(
Variable
(
recId
),
ex
))
}
newF
=
And
(
newF
,
And
(
pre
::
cases
))
}
TentativeFormula
(
newF
,
newRecTerms
)
}
def
closedFormula
=
And
(
f
::
recTerms
.
keySet
.
map
(
id
=>
Not
(
Variable
(
id
))).
toList
)
}
println
(
"Formula is: "
+
p
.
phi
)
val
initF
=
TentativeFormula
(
p
.
phi
,
Map
()
++
p
.
xs
.
map
(
x
=>
x
->
Set
(
x
)))
// Set to expand on xs
println
(
"unroll 1: "
+
initF
.
unroll
.
closedFormula
)
println
(
"unroll 2: "
+
initF
.
unroll
.
unroll
.
closedFormula
)
RuleInapplicable
}
}
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