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
07e55590
Commit
07e55590
authored
12 years ago
by
Régis Blanc
Browse files
Options
Downloads
Patches
Plain Diff
fix the commit
parent
3212cdf7
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/IntegerEquation.scala
+40
-28
40 additions, 28 deletions
src/main/scala/leon/synthesis/rules/IntegerEquation.scala
with
40 additions
and
28 deletions
src/main/scala/leon/synthesis/rules/IntegerEquation.scala
+
40
−
28
View file @
07e55590
...
@@ -14,21 +14,16 @@ import ArithmeticNormalization.simplify
...
@@ -14,21 +14,16 @@ import ArithmeticNormalization.simplify
class
IntegerEquation
(
synth
:
Synthesizer
)
extends
Rule
(
"Integer Equation"
,
synth
,
300
)
{
class
IntegerEquation
(
synth
:
Synthesizer
)
extends
Rule
(
"Integer Equation"
,
synth
,
300
)
{
def
applyOn
(
task
:
Task
)
:
RuleResult
=
{
def
applyOn
(
task
:
Task
)
:
RuleResult
=
{
val
p
=
task
.
problem
val
p
roblem
=
task
.
problem
val
TopLevelAnds
(
exprs
)
=
p
.
phi
val
TopLevelAnds
(
exprs
)
=
problem
.
phi
val
xs
=
p
.
xs
val
as
=
p
.
as
val
formula
=
p
.
phi
val
(
eqs
,
others
)
=
exprs
.
partition
(
_
.
isInstanceOf
[
Equals
])
val
(
eqs
,
others
)
=
exprs
.
partition
(
_
.
isInstanceOf
[
Equals
])
var
candidates
:
Seq
[
Expr
]
=
eqs
var
candidates
:
Seq
[
Expr
]
=
eqs
var
allOthers
:
Seq
[
Expr
]
=
others
var
allOthers
:
Seq
[
Expr
]
=
others
var
vars
:
Set
[
Identifier
]
=
Set
()
var
vars
:
Set
[
Identifier
]
=
Set
()
var
eqas
:
Set
[
Identifier
]
=
Set
()
var
eqxs
:
List
[
Identifier
]
=
List
()
var
eqxs
:
List
[
Identifier
]
=
List
()
var
ys
:
Set
[
Identifier
]
=
Set
()
var
optionNormalizedEq
:
Option
[
List
[
Expr
]]
=
None
var
optionNormalizedEq
:
Option
[
List
[
Expr
]]
=
None
while
(!
candidates
.
isEmpty
&&
optionNormalizedEq
==
None
)
{
while
(!
candidates
.
isEmpty
&&
optionNormalizedEq
==
None
)
{
...
@@ -36,48 +31,65 @@ class IntegerEquation(synth: Synthesizer) extends Rule("Integer Equation", synth
...
@@ -36,48 +31,65 @@ class IntegerEquation(synth: Synthesizer) extends Rule("Integer Equation", synth
candidates
=
candidates
.
tail
candidates
=
candidates
.
tail
vars
=
variablesOf
(
eq
)
vars
=
variablesOf
(
eq
)
eqas
=
as
.
toSet
.
intersect
(
vars
)
eqxs
=
problem
.
xs
.
toSet
.
intersect
(
vars
).
toList
eqxs
=
xs
.
toSet
.
intersect
(
vars
).
toList
ys
=
xs
.
toSet
.
diff
(
vars
)
try
{
try
{
optionNormalizedEq
=
Some
(
ArithmeticNormalization
(
Minus
(
eq
.
left
,
eq
.
right
),
eqxs
.
toArray
).
toList
)
optionNormalizedEq
=
Some
(
ArithmeticNormalization
(
Minus
(
eq
.
left
,
eq
.
right
),
eqxs
.
toArray
).
toList
)
}
catch
{
}
catch
{
case
ArithmeticNormalization
.
NonLinearExpressionException
(
_
)
=>
case
ArithmeticNormalization
.
NonLinearExpressionException
(
_
)
=>
allOthers
=
allOthers
:+
eq
}
}
}
}
allOthers
=
allOthers
++
candidates
optionNormalizedEq
match
{
optionNormalizedEq
match
{
case
None
=>
RuleInapplicable
case
None
=>
RuleInapplicable
case
Some
(
normalizedEq0
)
=>
{
case
Some
(
normalizedEq0
)
=>
{
val
(
neqxs
,
normalizedEq
)
=
eqxs
.
zip
(
normalizedEq0
.
tail
).
filterNot
{
case
(
_
,
IntLiteral
(
0
))
=>
true
case
_
=>
false
}.
unzip
//if(normalizedEq.size == 1) {
val
eqas
=
problem
.
as
.
toSet
.
intersect
(
vars
)
val
(
neqxs
,
normalizedEq1
)
=
eqxs
.
zip
(
normalizedEq0
.
tail
).
filterNot
{
case
(
_
,
IntLiteral
(
0
))
=>
true
case
_
=>
false
}.
unzip
val
normalizedEq
=
normalizedEq0
.
head
::
normalizedEq1
if
(
normalizedEq
.
size
==
1
)
{
val
eqPre
=
Equals
(
normalizedEq
.
head
,
IntLiteral
(
0
))
val
newProblem
=
Problem
(
problem
.
as
,
And
(
eqPre
,
problem
.
c
),
And
(
allOthers
),
problem
.
xs
)
val
onSuccess
:
List
[
Solution
]
=>
Solution
=
{
case
List
(
Solution
(
pre
,
defs
,
term
))
=>
{
Solution
(
And
(
eqPre
,
pre
),
defs
,
term
)
}
case
_
=>
Solution
.
none
}
//} else {
RuleStep
(
List
(
newProblem
),
onSuccess
)
val
(
eqPre
,
eqWitness
,
eqFreshVars
)
=
elimVariable
(
eqas
,
normalizedEq
)
}
else
{
val
(
eqPre
,
eqWitness
,
freshxs
)
=
elimVariable
(
eqas
,
normalizedEq
)
val
eqSubstMap
:
Map
[
Expr
,
Expr
]
=
neqxs
.
zip
(
eqWitness
).
map
{
case
(
id
,
e
)
=>
(
Variable
(
id
),
simplify
(
e
))}.
toMap
val
eqSubstMap
:
Map
[
Expr
,
Expr
]
=
neqxs
.
zip
(
eqWitness
).
map
{
case
(
id
,
e
)
=>
(
Variable
(
id
),
simplify
(
e
))}.
toMap
val
freshFormula
=
simplify
(
replace
(
eqSubstMap
,
And
(
allOthers
)))
val
freshFormula
=
simplify
(
replace
(
eqSubstMap
,
And
(
allOthers
)))
//}
//(eqPre, freshFormula)
val
newProblem
=
Problem
(
as
,
And
(
eqPre
,
p
.
c
),
freshFormula
,
eqFreshVars
)
val
ys
:
List
[
Identifier
]
=
problem
.
xs
.
filterNot
(
neqxs
.
contains
(
_
))
val
subproblemxs
:
List
[
Identifier
]
=
freshxs
++
ys
val
onSuccess
:
List
[
Solution
]
=>
Solution
=
{
val
newProblem
=
Problem
(
problem
.
as
,
And
(
eqPre
,
problem
.
c
),
freshFormula
,
subproblemxs
)
case
List
(
Solution
(
pre
,
defs
,
term
))
=>
if
(
eqFreshVars
.
isEmpty
)
{
val
onSuccess
:
List
[
Solution
]
=>
Solution
=
{
Solution
(
pre
,
defs
,
replace
(
eqSubstMap
,
Tuple
(
neqxs
.
map
(
Variable
(
_
)))))
case
List
(
Solution
(
pre
,
defs
,
term
))
=>
{
}
else
{
val
freshsubxs
=
subproblemxs
.
map
(
id
=>
FreshIdentifier
(
id
.
name
).
setType
(
id
.
getType
))
Solution
(
pre
,
defs
,
LetTuple
(
eqFreshVars
,
term
,
replace
(
eqSubstMap
,
Tuple
(
neqxs
.
map
(
Variable
(
_
))))))
val
id2res
:
Map
[
Expr
,
Expr
]
=
freshsubxs
.
zip
(
subproblemxs
).
map
{
case
(
id1
,
id2
)
=>
(
Variable
(
id1
),
Variable
(
id2
))}.
toMap
++
neqxs
.
map
(
id
=>
(
Variable
(
id
),
eqSubstMap
(
Variable
(
id
)))).
toMap
Solution
(
And
(
eqPre
,
pre
),
defs
,
LetTuple
(
subproblemxs
,
term
,
replace
(
id2res
,
Tuple
(
problem
.
xs
.
map
(
Variable
(
_
))))))
}
}
case
_
=>
Solution
.
none
case
_
=>
Solution
.
none
}
RuleStep
(
List
(
newProblem
),
onSuccess
)
}
}
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