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
f947b2d3
Commit
f947b2d3
authored
12 years ago
by
Régis Blanc
Browse files
Options
Downloads
Patches
Plain Diff
do not crash on non linear arithmetic expressions !
parent
fd68ef89
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/ArithmeticNormalization.scala
+5
-3
5 additions, 3 deletions
src/main/scala/leon/synthesis/ArithmeticNormalization.scala
with
5 additions
and
3 deletions
src/main/scala/leon/synthesis/ArithmeticNormalization.scala
+
5
−
3
View file @
f947b2d3
...
...
@@ -10,6 +10,8 @@ import leon.purescala.Common._
object
ArithmeticNormalization
{
case
class
NonLinearExpressionException
(
msg
:
String
)
extends
Exception
//assume the function is an arithmetic expression, not a relation
//return a normal form where the [t a1 ... an] where
//expr = t + a1*x1 + ... + an*xn and xs = [x1 ... xn]
...
...
@@ -19,7 +21,7 @@ object ArithmeticNormalization {
case
Times
(
e1
,
e2
)
=>
containsId
(
e1
,
id
)
||
containsId
(
e2
,
id
)
case
IntLiteral
(
_
)
=>
false
case
Variable
(
id2
)
=>
id
==
id2
case
_
=>
sys
.
error
(
"unexpected format
: "
+
e
)
case
err
=>
throw
NonLinearExpressionException
(
"unexpected in containsId
: "
+
e
rr
)
}
def
group
(
es
:
Seq
[
Expr
],
id
:
Identifier
)
:
Expr
=
{
...
...
@@ -53,7 +55,7 @@ object ArithmeticNormalization {
def
rec
(
e
:
Expr
)
:
Unit
=
e
match
{
case
IntLiteral
(
i
)
=>
coef
=
coef
*
i
case
Variable
(
id2
)
=>
if
(
id
.
isEmpty
)
id
=
Some
(
id2
)
else
sys
.
error
(
"multiple variable
s
"
)
case
Variable
(
id2
)
=>
if
(
id
.
isEmpty
)
id
=
Some
(
id2
)
else
throw
NonLinearExpressionException
(
"multiple variable"
)
case
Times
(
e1
,
e2
)
=>
rec
(
e1
);
rec
(
e2
)
}
...
...
@@ -75,7 +77,7 @@ object ArithmeticNormalization {
case
Times
(
es1
,
es2
)
=>
multiply
(
expand
(
es1
),
expand
(
es2
))
case
v
@Variable
(
_
)
=>
Seq
(
v
)
case
n
@IntLiteral
(
_
)
=>
Seq
(
n
)
case
err
=>
sys
.
error
(
"
U
nexpected in expand: "
+
err
)
case
err
=>
throw
NonLinearExpressionException
(
"
u
nexpected in expand: "
+
err
)
}
//simple, local simplifications
...
...
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