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
0388ab39
Commit
0388ab39
authored
12 years ago
by
Etienne Kneuss
Browse files
Options
Downloads
Patches
Plain Diff
Plop
parent
c7105dbd
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/scala/leon/purescala/TypeTrees.scala
+4
-0
4 additions, 0 deletions
src/main/scala/leon/purescala/TypeTrees.scala
src/main/scala/leon/synthesis/Heuristics.scala
+26
-16
26 additions, 16 deletions
src/main/scala/leon/synthesis/Heuristics.scala
with
30 additions
and
16 deletions
src/main/scala/leon/purescala/TypeTrees.scala
+
4
−
0
View file @
0388ab39
...
...
@@ -87,6 +87,10 @@ object TypeTrees {
case
_
=>
None
}
def
isSubtypeOf
(
t1
:
TypeTree
,
t2
:
TypeTree
)
:
Boolean
=
{
leastUpperBound
(
t1
,
t2
)
==
Some
(
t2
)
}
// returns the number of distinct values that inhabit a type
sealed
abstract
class
TypeSize
extends
Serializable
case
class
FiniteSize
(
size
:
Int
)
extends
TypeSize
...
...
This diff is collapsed.
Click to expand it.
src/main/scala/leon/synthesis/Heuristics.scala
+
26
−
16
View file @
0388ab39
...
...
@@ -248,16 +248,23 @@ class CEGISOnSteroids(synth: Synthesizer) extends Rule("cegis w. gen.", synth, 5
g
}
def
inputAlternatives
(
t
:
TypeTree
)
:
List
[(
Expr
,
Set
[
Identifier
])]
=
{
p
.
as
.
filter
(
a
=>
isSubtypeOf
(
a
.
getType
,
t
)).
map
(
id
=>
(
Variable
(
id
)
:
Expr
,
Set
[
Identifier
]()))
}
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
alts
=
gen
.
altBuilder
()
:::
inputAlternatives
(
recId
.
getType
)
println
(
"For "
+
recId
.
getType
+
": "
+
alts
)
val
altsWithBranches
=
alts
.
map
(
alt
=>
FreshIdentifier
(
"b"
,
true
).
setType
(
BooleanType
)
->
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}]
val
pre
=
Or
(
alts
WithBranches
.
map
{
case
(
id
,
_
)
=>
Variable
(
id
)
})
// b1 OR b2
val
cases
=
for
((
bid
,
(
ex
,
rec
))
<-
alts
WithBranches
.
toList
)
yield
{
// b1 => E(gen1, gen2) [b1 -> {gen1, gen2}]
if
(!
rec
.
isEmpty
)
{
newRecTerms
+=
bid
->
rec
}
...
...
@@ -276,34 +283,37 @@ class CEGISOnSteroids(synth: Synthesizer) extends Rule("cegis w. gen.", synth, 5
var
result
:
Option
[
RuleResult
]
=
None
var
ass
=
p
.
as
.
toSet
var
xss
=
p
.
xs
.
toSet
var
lastF
=
TentativeFormula
(
p
.
phi
,
Map
()
++
p
.
xs
.
map
(
x
=>
x
->
Set
(
x
)))
var
lastF
=
TentativeFormula
(
And
(
p
.
c
,
p
.
phi
)
,
Map
()
++
p
.
xs
.
map
(
x
=>
x
->
Set
(
x
)))
var
currentF
=
lastF
.
unroll
var
unrolings
=
0
val
maxUnrolings
=
2
do
{
println
(
"Was: "
+
lastF
.
closedFormula
)
println
(
"Now Trying : "
+
currentF
.
closedFormula
)
val
tpe
=
TupleType
(
p
.
xs
.
map
(
_
.
getType
))
var
i
=
0
;
var
maxTries
=
10
;
var
predicates
:
Seq
[
Expr
]
=
Seq
()
var
continue
=
true
while
(
result
.
isEmpty
&&
i
<
maxTries
)
{
while
(
result
.
isEmpty
&&
continue
)
{
val
phi
=
And
(
currentF
.
closedFormula
+:
predicates
)
synth
.
solver
.
solveSAT
(
phi
)
match
{
case
(
Some
(
true
),
satModel
)
=>
va
l
notA
ss
=
satModel
.
keySet
.
filterNot
(
ass
)
val
satXsModel
=
satModel
.
filterKeys
(
notAss
)
va
r
b
ss
=
satModel
.
keySet
.
filterNot
(
xss
++
ass
)
println
(
"Found candidate!: "
+
satModel
)
val
newPhi
=
valuateWithModelIn
(
phi
,
notAss
,
satModel
)
val
newPhi
=
valuateWithModelIn
(
phi
,
bss
++
xss
,
satModel
)
println
(
"new Phi: "
+
newPhi
)
synth
.
solver
.
solveSAT
(
Not
(
newPhi
))
match
{
case
(
Some
(
true
),
invalidModel
)
=>
// Found as such as the xs break, refine predicates
predicates
=
valuateWithModelIn
(
phi
,
ass
,
invalidModel
)
+:
predicates
println
(
"Found counter EX: "
+
invalidModel
)
predicates
=
valuateWithModelIn
(
currentF
.
closedFormula
,
ass
,
invalidModel
)
+:
predicates
println
(
valuateWithModelIn
(
currentF
.
closedFormula
,
ass
,
invalidModel
))
case
(
Some
(
false
),
_
)
=>
result
=
Some
(
RuleSuccess
(
Solution
(
BooleanLiteral
(
true
),
Tuple
(
p
.
xs
.
map
(
valuateWithModel
(
satModel
))).
setType
(
tpe
))))
...
...
@@ -312,16 +322,16 @@ class CEGISOnSteroids(synth: Synthesizer) extends Rule("cegis w. gen.", synth, 5
}
case
(
Some
(
false
),
_
)
=>
continue
=
false
case
_
=>
continue
=
false
}
i
+=
1
}
lastF
=
currentF
currentF
=
las
tF
.
unroll
currentF
=
curren
tF
.
unroll
unrolings
+=
1
}
while
(
unrolings
<
5
&&
lastF
!=
currentF
&&
result
.
isEmpty
)
}
while
(
unrolings
<
maxUnrolings
&&
lastF
!=
currentF
&&
result
.
isEmpty
)
result
.
getOrElse
(
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