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
bd54cb6f
Commit
bd54cb6f
authored
12 years ago
by
Régis Blanc
Browse files
Options
Downloads
Patches
Plain Diff
fix Sec2Time
parent
9f7dc493
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/synthesis/rules/IntegerEquation.scala
+1
-1
1 addition, 1 deletion
src/main/scala/leon/synthesis/rules/IntegerEquation.scala
src/main/scala/leon/synthesis/rules/IntegerInequalities.scala
+11
-8
11 additions, 8 deletions
...main/scala/leon/synthesis/rules/IntegerInequalities.scala
with
12 additions
and
9 deletions
src/main/scala/leon/synthesis/rules/IntegerEquation.scala
+
1
−
1
View file @
bd54cb6f
...
...
@@ -11,7 +11,7 @@ import purescala.Definitions._
import
LinearEquations.elimVariable
class
IntegerEquation
(
synth
:
Synthesizer
)
extends
Rule
(
"Integer Equation"
,
synth
,
300
)
{
def
attemptToApplyOn
(
problem
:
Problem
)
:
RuleResult
=
{
def
attemptToApplyOn
(
problem
:
Problem
)
:
RuleResult
=
if
(
problem
.
xs
.
isEmpty
)
RuleInapplicable
else
{
val
TopLevelAnds
(
exprs
)
=
problem
.
phi
...
...
This diff is collapsed.
Click to expand it.
src/main/scala/leon/synthesis/rules/IntegerInequalities.scala
+
11
−
8
View file @
bd54cb6f
...
...
@@ -34,14 +34,16 @@ class IntegerInequalities(synth: Synthesizer) extends Rule("Integer Inequalities
val
processedVar
=
candidateVars
.
head
val
otherVars
:
List
[
Identifier
]
=
problem
.
xs
.
filterNot
(
_
==
processedVar
)
println
(
"lhsSides: "
+
lhsSides
)
val
normalizedLhs
:
List
[
List
[
Expr
]]
=
lhsSides
.
map
(
ArithmeticNormalization
(
_
,
Array
(
processedVar
)).
toList
)
println
(
"normalized: "
+
normalizedLhs
.
mkString
(
"\n"
))
var
upperBounds
:
List
[(
Expr
,
Int
)]
=
Nil
// (t, c) means c*x <= t
var
lowerBounds
:
List
[(
Expr
,
Int
)]
=
Nil
// (t, c) means t <= c*x
normalizedLhs
.
foreach
{
case
List
(
t
,
IntLiteral
(
i
))
=>
if
(
i
>
0
)
upperBounds
::=
(
simplifyArithmetic
(
UMinus
(
t
)),
i
)
else
if
(
i
<
0
)
lowerBounds
::=
(
simplify
(
t
),
-
i
)
else
/*if (i == 0)*/
exprNotUsed
::=
LessEquals
(
t
,
IntLiteral
(
0
))
else
if
(
i
<
0
)
lowerBounds
::=
(
simplify
Arithmetic
(
t
),
-
i
)
else
exprNotUsed
::=
LessEquals
(
t
,
IntLiteral
(
0
))
//TODO: make sure that these are added as preconditions
case
err
=>
sys
.
error
(
"unexpected from normal form: "
+
err
)
}
...
...
@@ -92,9 +94,10 @@ class IntegerInequalities(synth: Synthesizer) extends Rule("Integer Inequalities
}
if
(
otherVars
.
isEmpty
)
{
//here we can simply evaluate the precondition and return a witness
val
pre
=
And
(
for
((
ub
,
uc
)
<-
upperBounds
;
(
lb
,
lc
)
<-
lowerBounds
)
yield
LessEquals
(
ceilingDiv
(
lb
,
IntLiteral
(
lc
)),
floorDiv
(
ub
,
IntLiteral
(
uc
))))
val
constraints
:
List
[
Expr
]
=
for
((
ub
,
uc
)
<-
upperBounds
;
(
lb
,
lc
)
<-
lowerBounds
)
yield
LessEquals
(
ceilingDiv
(
lb
,
IntLiteral
(
lc
)),
floorDiv
(
ub
,
IntLiteral
(
uc
)))
val
pre
=
And
(
exprNotUsed
++
constraints
)
RuleFastSuccess
(
Solution
(
pre
,
Set
(),
witness
))
}
else
{
val
L
=
lcm
((
upperBounds
:::
lowerBounds
).
map
(
_
.
_2
))
...
...
@@ -104,7 +107,7 @@ class IntegerInequalities(synth: Synthesizer) extends Rule("Integer Inequalities
val
remainderIds
:
List
[
Identifier
]
=
newUpperBounds
.
map
(
_
=>
FreshIdentifier
(
"k"
,
true
).
setType
(
Int32Type
))
val
quotientIds
:
List
[
Identifier
]
=
newUpperBounds
.
map
(
_
=>
FreshIdentifier
(
"l"
,
true
).
setType
(
Int32Type
))
val
subProblemFormula
=
simplify
(
And
(
val
subProblemFormula
=
simplify
Arithmetic
(
And
(
newUpperBounds
.
zip
(
remainderIds
).
zip
(
quotientIds
).
flatMap
{
case
((
b
,
k
),
l
)
=>
Equals
(
b
,
Plus
(
Times
(
IntLiteral
(
L
),
Variable
(
l
)),
Variable
(
k
)))
::
newLowerBounds
.
map
(
lbound
=>
LessEquals
(
Variable
(
k
),
Minus
(
b
,
lbound
)))
...
...
@@ -140,7 +143,7 @@ class IntegerInequalities(synth: Synthesizer) extends Rule("Integer Inequalities
val
concreteTerm
=
replace
(
Map
(
Variable
(
k
)
->
loopCounter
),
term
)
val
returnType
=
TupleType
(
problem
.
xs
.
map
(
_
.
getType
))
val
funDef
=
new
FunDef
(
FreshIdentifier
(
"rec"
,
true
),
returnType
,
Seq
(
VarDecl
(
loopCounter
.
id
,
Int32Type
)))
val
funBody
=
IfExpr
(
val
funBody
=
simplifyArithmetic
(
IfExpr
(
LessThan
(
loopCounter
,
IntLiteral
(
0
)),
Error
(
"No solution exists"
),
IfExpr
(
...
...
@@ -151,7 +154,7 @@ class IntegerInequalities(synth: Synthesizer) extends Rule("Integer Inequalities
),
FunctionInvocation
(
funDef
,
Seq
(
Minus
(
loopCounter
,
IntLiteral
(
1
))))
)
)
)
)
funDef
.
body
=
Some
(
funBody
)
Solution
(
pre
,
defs
+
funDef
,
FunctionInvocation
(
funDef
,
Seq
(
IntLiteral
(
L
-
1
))))
...
...
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