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
1126592b
Commit
1126592b
authored
12 years ago
by
Régis Blanc
Browse files
Options
Downloads
Patches
Plain Diff
apply simplification using the new expand and group simplification
parent
5e222f54
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/rules/IntegerInequalities.scala
+6
-16
6 additions, 16 deletions
...main/scala/leon/synthesis/rules/IntegerInequalities.scala
with
6 additions
and
16 deletions
src/main/scala/leon/synthesis/rules/IntegerInequalities.scala
+
6
−
16
View file @
1126592b
...
@@ -49,14 +49,13 @@ case object IntegerInequalities extends Rule("Integer Inequalities", 600) {
...
@@ -49,14 +49,13 @@ case object IntegerInequalities extends Rule("Integer Inequalities", 600) {
var
lowerBounds
:
List
[(
Expr
,
Int
)]
=
Nil
// (t, c) means t <= c*x
var
lowerBounds
:
List
[(
Expr
,
Int
)]
=
Nil
// (t, c) means t <= c*x
normalizedLhs
.
foreach
{
normalizedLhs
.
foreach
{
case
List
(
t
,
IntLiteral
(
i
))
=>
case
List
(
t
,
IntLiteral
(
i
))
=>
if
(
i
>
0
)
upperBounds
::=
(
s
implifyArithmetic
(
UMinus
(
t
)),
i
)
if
(
i
>
0
)
upperBounds
::=
(
expandAndS
implifyArithmetic
(
UMinus
(
t
)),
i
)
else
if
(
i
<
0
)
lowerBounds
::=
(
s
implifyArithmetic
(
t
),
-
i
)
else
if
(
i
<
0
)
lowerBounds
::=
(
expandAndS
implifyArithmetic
(
t
),
-
i
)
else
exprNotUsed
::=
LessEquals
(
t
,
IntLiteral
(
0
))
//TODO: make sure that these are added as preconditions
else
exprNotUsed
::=
LessEquals
(
t
,
IntLiteral
(
0
))
//TODO: make sure that these are added as preconditions
case
err
=>
sys
.
error
(
"unexpected from normal form: "
+
err
)
case
err
=>
sys
.
error
(
"unexpected from normal form: "
+
err
)
}
}
val
L
=
if
(
upperBounds
.
isEmpty
&&
lowerBounds
.
isEmpty
)
-
1
else
lcm
((
upperBounds
:::
lowerBounds
).
map
(
_
.
_2
))
val
L
=
if
(
upperBounds
.
isEmpty
&&
lowerBounds
.
isEmpty
)
-
1
else
lcm
((
upperBounds
:::
lowerBounds
).
map
(
_
.
_2
))
println
(
"LCM: "
+
L
)
//optimization when coef = 1 and when ub - lb is a constant greater than LCM
//optimization when coef = 1 and when ub - lb is a constant greater than LCM
upperBounds
=
upperBounds
.
filterNot
{
case
(
ub
,
uc
)
=>
if
(
uc
==
1
)
{
upperBounds
=
upperBounds
.
filterNot
{
case
(
ub
,
uc
)
=>
if
(
uc
==
1
)
{
...
@@ -73,21 +72,12 @@ case object IntegerInequalities extends Rule("Integer Inequalities", 600) {
...
@@ -73,21 +72,12 @@ case object IntegerInequalities extends Rule("Integer Inequalities", 600) {
}
}
upperBounds
=
upperBounds
.
filterNot
{
case
(
ub
,
uc
)
=>
{
upperBounds
=
upperBounds
.
filterNot
{
case
(
ub
,
uc
)
=>
{
lowerBounds
.
forall
{
case
(
lb
,
lc
)
=>
{
lowerBounds
.
forall
{
case
(
lb
,
lc
)
=>
{
println
(
simplifyArithmetic
(
Minus
(
ub
,
lb
)))
expandAndSimplifyArithmetic
(
Minus
(
ub
,
lb
))
match
{
simplifyArithmetic
(
Minus
(
ub
,
lb
))
match
{
case
IntLiteral
(
n
)
=>
L
-
1
<=
n
case
IntLiteral
(
n
)
=>
println
(
"found N: "
+
n
);
L
-
1
<=
n
case
_
=>
false
case
_
=>
false
}}}
}}}
}}
}}
println
(
"lowerBounds: "
+
lowerBounds
)
println
(
"upperBounds: "
+
upperBounds
)
println
(
"exprNotUsed: "
+
exprNotUsed
)
//lowerBounds.exists{case (lb, lc) => {
// if(uc == 1)
//}}}
//define max function
//define max function
val
maxVarDecls
:
Seq
[
VarDecl
]
=
lowerBounds
.
map
(
_
=>
VarDecl
(
FreshIdentifier
(
"b"
),
Int32Type
))
val
maxVarDecls
:
Seq
[
VarDecl
]
=
lowerBounds
.
map
(
_
=>
VarDecl
(
FreshIdentifier
(
"b"
),
Int32Type
))
val
maxFun
=
new
FunDef
(
FreshIdentifier
(
"max"
),
Int32Type
,
maxVarDecls
)
val
maxFun
=
new
FunDef
(
FreshIdentifier
(
"max"
),
Int32Type
,
maxVarDecls
)
...
@@ -162,7 +152,7 @@ case object IntegerInequalities extends Rule("Integer Inequalities", 600) {
...
@@ -162,7 +152,7 @@ case object IntegerInequalities extends Rule("Integer Inequalities", 600) {
val
newLowerBounds
:
List
[
Expr
]
=
lowerBounds
.
map
{
case
(
bound
,
coef
)
=>
Times
(
IntLiteral
(
L
/
coef
),
bound
)}
val
newLowerBounds
:
List
[
Expr
]
=
lowerBounds
.
map
{
case
(
bound
,
coef
)
=>
Times
(
IntLiteral
(
L
/
coef
),
bound
)}
val
subProblemFormula
=
s
implifyArithmetic
(
And
(
val
subProblemFormula
=
expandAndS
implifyArithmetic
(
And
(
newUpperBounds
.
zip
(
remainderIds
).
zip
(
quotientIds
).
flatMap
{
newUpperBounds
.
zip
(
remainderIds
).
zip
(
quotientIds
).
flatMap
{
case
((
b
,
k
),
l
)
=>
Equals
(
b
,
Plus
(
Times
(
IntLiteral
(
L
),
Variable
(
l
)),
Variable
(
k
)))
::
case
((
b
,
k
),
l
)
=>
Equals
(
b
,
Plus
(
Times
(
IntLiteral
(
L
),
Variable
(
l
)),
Variable
(
k
)))
::
newLowerBounds
.
map
(
lbound
=>
LessEquals
(
Variable
(
k
),
Minus
(
b
,
lbound
)))
newLowerBounds
.
map
(
lbound
=>
LessEquals
(
Variable
(
k
),
Minus
(
b
,
lbound
)))
...
@@ -188,7 +178,7 @@ case object IntegerInequalities extends Rule("Integer Inequalities", 600) {
...
@@ -188,7 +178,7 @@ case object IntegerInequalities extends Rule("Integer Inequalities", 600) {
val
concreteTerm
=
replace
(
Map
(
Variable
(
k
)
->
loopCounter
),
term
)
val
concreteTerm
=
replace
(
Map
(
Variable
(
k
)
->
loopCounter
),
term
)
val
returnType
=
TupleType
(
problem
.
xs
.
map
(
_
.
getType
))
val
returnType
=
TupleType
(
problem
.
xs
.
map
(
_
.
getType
))
val
funDef
=
new
FunDef
(
FreshIdentifier
(
"rec"
,
true
),
returnType
,
Seq
(
VarDecl
(
loopCounter
.
id
,
Int32Type
)))
val
funDef
=
new
FunDef
(
FreshIdentifier
(
"rec"
,
true
),
returnType
,
Seq
(
VarDecl
(
loopCounter
.
id
,
Int32Type
)))
val
funBody
=
s
implifyArithmetic
(
IfExpr
(
val
funBody
=
expandAndS
implifyArithmetic
(
IfExpr
(
LessThan
(
loopCounter
,
IntLiteral
(
0
)),
LessThan
(
loopCounter
,
IntLiteral
(
0
)),
Error
(
"No solution exists"
),
Error
(
"No solution exists"
),
IfExpr
(
IfExpr
(
...
...
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