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
39185b06
Commit
39185b06
authored
12 years ago
by
Régis Blanc
Browse files
Options
Downloads
Patches
Plain Diff
really no crash this time
parent
f947b2d3
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.scala
+50
-26
50 additions, 26 deletions
src/main/scala/leon/synthesis/Rules.scala
with
50 additions
and
26 deletions
src/main/scala/leon/synthesis/Rules.scala
+
50
−
26
View file @
39185b06
...
...
@@ -527,40 +527,64 @@ class IntegerEquation(synth: Synthesizer) extends Rule("Integer Equation", synth
val
formula
=
p
.
phi
val
(
eqs
,
others
)
=
exprs
.
partition
(
_
.
isInstanceOf
[
Equals
])
var
candidates
:
Seq
[
Expr
]
=
eqs
var
allOthers
:
Seq
[
Expr
]
=
others
var
vars
:
Set
[
Identifier
]
=
Set
()
var
eqas
:
Set
[
Identifier
]
=
Set
()
var
eqxs
:
List
[
Identifier
]
=
List
()
var
ys
:
Set
[
Identifier
]
=
Set
()
var
optionNormalizedEq
:
Option
[
List
[
Expr
]]
=
None
while
(!
candidates
.
isEmpty
&&
optionNormalizedEq
==
None
)
{
val
eq
@Equals
(
_
,
_
)
=
candidates
.
head
candidates
=
candidates
.
tail
vars
=
variablesOf
(
eq
)
eqas
=
as
.
toSet
.
intersect
(
vars
)
if
(!
eqs
.
isEmpty
)
{
eqxs
=
xs
.
toSet
.
intersect
(
vars
).
toList
ys
=
xs
.
toSet
.
diff
(
vars
)
val
(
eq
@Equals
(
_
,
_
),
rest
)
=
(
eqs
.
head
,
eqs
.
tail
)
val
allOthers
=
rest
++
others
val
vars
:
Set
[
Identifier
]
=
variablesOf
(
eq
)
val
eqas
:
Set
[
Identifier
]
=
as
.
toSet
.
intersect
(
vars
)
try
{
optionNormalizedEq
=
Some
(
ArithmeticNormalization
(
Minus
(
eq
.
left
,
eq
.
right
),
eqxs
.
toArray
).
toList
)
}
catch
{
case
ArithmeticNormalization
.
NonLinearExpressionException
(
_
)
=>
}
}
val
eqxs
:
List
[
Identifier
]
=
xs
.
toSet
.
intersect
(
vars
).
toList
val
ys
:
Set
[
Identifier
]
=
xs
.
toSet
.
diff
(
vars
)
optionNormalizedEq
match
{
case
None
=>
RuleInapplicable
case
Some
(
normalizedEq0
)
=>
{
val
(
neqxs
,
normalizedEq
)
=
eqxs
.
zip
(
normalizedEq0
.
tail
).
filterNot
{
case
(
_
,
IntLiteral
(
0
))
=>
true
case
_
=>
false
}.
unzip
val
normalizedEq
:
List
[
Expr
]
=
ArithmeticNormalization
(
Minus
(
eq
.
left
,
eq
.
right
),
eqxs
.
toArray
).
toList
val
(
eqPre
,
eqWitness
,
eqFreshVars
)
=
elimVariable
(
eqas
,
normalizedEq
)
if
(
normalizedEq
.
size
==
1
)
{
val
eqSubstMap
:
Map
[
Expr
,
Expr
]
=
eqxs
.
zip
(
eqWitness
).
map
{
case
(
id
,
e
)
=>
(
Variable
(
id
),
simplify
(
e
))}.
toMap
val
freshFormula
=
simplify
(
replace
(
eqSubstMap
,
And
(
allOthers
)))
(
eqPre
,
freshFormula
)
val
newProblem
=
Problem
(
as
,
And
(
eqPre
,
p
.
c
),
freshFormula
,
eqFreshVars
)
}
else
{
val
onSuccess
:
List
[
Solution
]
=>
Solution
=
{
case
List
(
Solution
(
pre
,
defs
,
term
))
=>
if
(
eqFreshVars
.
isEmpty
)
{
Solution
(
pre
,
defs
,
replace
(
eqSubstMap
,
Tuple
(
eqxs
.
map
(
Variable
(
_
)))))
}
else
{
Solution
(
pre
,
defs
,
LetTuple
(
eqFreshVars
,
term
,
replace
(
eqSubstMap
,
Tuple
(
eqxs
.
map
(
Variable
(
_
))))))
}
case
_
=>
Solution
.
none
}
val
(
eqPre
,
eqWitness
,
eqFreshVars
)
=
elimVariable
(
eqas
,
normalizedEq
)
RuleStep
(
List
(
newProblem
),
onSuccess
)
}
else
{
RuleInapplicable
val
eqSubstMap
:
Map
[
Expr
,
Expr
]
=
neqxs
.
zip
(
eqWitness
).
map
{
case
(
id
,
e
)
=>
(
Variable
(
id
),
simplify
(
e
))}.
toMap
val
freshFormula
=
simplify
(
replace
(
eqSubstMap
,
And
(
allOthers
)))
}
(
eqPre
,
freshFormula
)
val
newProblem
=
Problem
(
as
,
And
(
eqPre
,
p
.
c
),
freshFormula
,
eqFreshVars
)
val
onSuccess
:
List
[
Solution
]
=>
Solution
=
{
case
List
(
Solution
(
pre
,
defs
,
term
))
=>
if
(
eqFreshVars
.
isEmpty
)
{
Solution
(
pre
,
defs
,
replace
(
eqSubstMap
,
Tuple
(
neqxs
.
map
(
Variable
(
_
)))))
}
else
{
Solution
(
pre
,
defs
,
LetTuple
(
eqFreshVars
,
term
,
replace
(
eqSubstMap
,
Tuple
(
neqxs
.
map
(
Variable
(
_
))))))
}
case
_
=>
Solution
.
none
}
RuleStep
(
List
(
newProblem
),
onSuccess
)
}
}
}
}
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