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
5f18731b
Commit
5f18731b
authored
12 years ago
by
Etienne Kneuss
Browse files
Options
Downloads
Patches
Plain Diff
Return an expression, not a formula
parent
e16ab22c
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/TreeOps.scala
+7
-2
7 additions, 2 deletions
src/main/scala/leon/purescala/TreeOps.scala
src/main/scala/leon/synthesis/Rules.scala
+24
-4
24 additions, 4 deletions
src/main/scala/leon/synthesis/Rules.scala
with
31 additions
and
6 deletions
src/main/scala/leon/purescala/TreeOps.scala
+
7
−
2
View file @
5f18731b
...
...
@@ -1303,8 +1303,13 @@ object TreeOps {
rec
(
expr
,
Nil
)
}
def
valuateWithModel
(
expr
:
Expr
,
vars
:
Set
[
Identifier
],
model
:
Map
[
Identifier
,
Expr
])
=
{
replace
(
vars
.
map
(
id
=>
Variable
(
id
)
->
model
.
getOrElse
(
id
,
simplestValue
(
id
.
getType
))).
toMap
,
expr
)
def
valuateWithModel
(
model
:
Map
[
Identifier
,
Expr
])(
id
:
Identifier
)
:
Expr
=
{
model
.
getOrElse
(
id
,
simplestValue
(
id
.
getType
))
}
def
valuateWithModelIn
(
expr
:
Expr
,
vars
:
Set
[
Identifier
],
model
:
Map
[
Identifier
,
Expr
])
:
Expr
=
{
val
valuator
=
valuateWithModel
(
model
)
_
replace
(
vars
.
map
(
id
=>
Variable
(
id
)
->
valuator
(
id
)).
toMap
,
expr
)
}
}
This diff is collapsed.
Click to expand it.
src/main/scala/leon/synthesis/Rules.scala
+
24
−
4
View file @
5f18731b
...
...
@@ -32,6 +32,7 @@ abstract class Rule(val name: String, val synth: Synthesizer, val priority: Prio
def
applyOn
(
task
:
Task
)
:
RuleResult
def
subst
(
what
:
Tuple2
[
Identifier
,
Expr
],
in
:
Expr
)
:
Expr
=
replace
(
Map
(
Variable
(
what
.
_1
)
->
what
.
_2
),
in
)
def
substAll
(
what
:
Map
[
Identifier
,
Expr
],
in
:
Expr
)
:
Expr
=
replace
(
what
.
map
(
w
=>
Variable
(
w
.
_1
)
->
w
.
_2
),
in
)
val
forward
:
List
[
Solution
]
=>
Solution
=
{
case
List
(
s
)
=>
s
...
...
@@ -90,7 +91,7 @@ class Ground(synth: Synthesizer) extends Rule("Ground", synth, 500) {
synth
.
solveSAT
(
p
.
phi
)
match
{
case
(
Some
(
true
),
model
)
=>
RuleSuccess
(
Solution
(
BooleanLiteral
(
true
),
Tuple
(
p
.
xs
.
map
(
id
=>
model
.
getOrElse
(
id
,
simplestValue
(
Variable
(
id
))
))).
setType
(
tpe
)))
RuleSuccess
(
Solution
(
BooleanLiteral
(
true
),
Tuple
(
p
.
xs
.
map
(
valuateWithModel
(
model
))).
setType
(
tpe
)))
case
(
Some
(
false
),
model
)
=>
RuleSuccess
(
Solution
(
BooleanLiteral
(
false
),
Error
(
p
.
phi
+
" is UNSAT!"
).
setType
(
tpe
)))
case
_
=>
...
...
@@ -124,15 +125,15 @@ class OptimisticGround(synth: Synthesizer) extends Rule("Optimistic Ground", syn
case
(
Some
(
true
),
satModel
)
=>
val
satXsModel
=
satModel
.
filterKeys
(
xss
)
val
newPhi
=
valuateWithModel
(
phi
,
xss
,
satModel
)
val
newPhi
=
valuateWithModel
In
(
phi
,
xss
,
satModel
)
synth
.
solveSAT
(
Not
(
newPhi
))
match
{
case
(
Some
(
true
),
invalidModel
)
=>
// Found as such as the xs break, refine predicates
predicates
=
valuateWithModel
(
phi
,
ass
,
invalidModel
)
+:
predicates
predicates
=
valuateWithModel
In
(
phi
,
ass
,
invalidModel
)
+:
predicates
case
(
Some
(
false
),
_
)
=>
result
=
Some
(
RuleSuccess
(
Solution
(
BooleanLiteral
(
true
),
newPhi
)))
result
=
Some
(
RuleSuccess
(
Solution
(
BooleanLiteral
(
true
),
Tuple
(
p
.
xs
.
map
(
valuateWithModel
(
satModel
))).
setType
(
tpe
)
)))
case
_
=>
result
=
Some
(
RuleInapplicable
)
...
...
@@ -330,3 +331,22 @@ class ADTDual(synth: Synthesizer) extends Rule("ADTDual", synth, 200) {
}
}
}
object
Heuristics
{
class
IntInduction
(
synth
:
Synthesizer
)
extends
Rule
(
"Int Induction"
,
synth
,
80
)
{
def
applyOn
(
task
:
Task
)
:
RuleResult
=
{
val
p
=
task
.
problem
p
.
as
.
find
(
_
.
getType
==
Int32Type
)
match
{
case
Some
(
inductOn
)
=>
val
subBase
=
Problem
(
p
.
as
.
filterNot
(
_
==
inductOn
),
subst
(
inductOn
->
IntLiteral
(
0
),
p
.
phi
),
p
.
xs
)
// val subGT = Problem(p.as + tmpGT, And(Seq(p.phi, GreaterThan(Variable(inductOn), IntLiteral(0)), subst(inductOn -> IntLiteral(0), p.phi), p.xs)
RuleDecomposed
(
List
(
subBase
),
forward
)
case
None
=>
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