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
c9a9a67d
Commit
c9a9a67d
authored
10 years ago
by
Emmanouil (Manos) Koukoutos
Committed by
Etienne Kneuss
10 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Try to salvage erroneous/ugly name handling in Guided Match split
parent
1675d9f2
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/scala/leon/synthesis/rules/GuidedDecomp.scala
+53
-24
53 additions, 24 deletions
src/main/scala/leon/synthesis/rules/GuidedDecomp.scala
with
53 additions
and
24 deletions
src/main/scala/leon/synthesis/rules/GuidedDecomp.scala
+
53
−
24
View file @
c9a9a67d
...
@@ -52,40 +52,69 @@ case object GuidedDecomp extends Rule("Guided Decomp") {
...
@@ -52,40 +52,69 @@ case object GuidedDecomp extends Rule("Guided Decomp") {
Some
(
RuleInstantiation
.
immediateDecomp
(
p
,
this
,
List
(
sub1
,
sub2
),
onSuccess
,
"Guided If-Split on '"
+
c
+
"'"
))
Some
(
RuleInstantiation
.
immediateDecomp
(
p
,
this
,
List
(
sub1
,
sub2
),
onSuccess
,
"Guided If-Split on '"
+
c
+
"'"
))
case
m
@
MatchExpr
(
scrut
,
cs
)
=>
case
m
@
MatchExpr
(
scrut0
,
cs
)
=>
var
pcSoFar
:
Expr
=
BooleanLiteral
(
true
)
val
scrut
=
scrut0
match
{
case
v
:
Variable
=>
v
case
_
=>
Variable
(
FreshIdentifier
(
"scrut"
,
true
).
setType
(
scrut0
.
getType
))
}
var
pcSoFar
:
Expr
=
if
(
scrut
==
scrut0
)
BooleanLiteral
(
true
)
else
Equals
(
scrut0
,
scrut
)
val
subs
=
for
(
c
<-
cs
)
yield
{
val
subs
=
for
(
c
<-
cs
)
yield
{
val
s
=
scrut
match
{
case
Variable
(
_
)
=>
scrut
//println("="*40)
case
_
=>
Variable
(
FreshIdentifier
(
"scrut"
,
true
).
setType
(
scrut
.
getType
))
}
val
localScrut
=
c
.
pattern
.
binder
.
map
(
Variable
)
getOrElse
scrut
val
sConstr
=
scrut
match
{
//println("PC so far:")
case
Variable
(
_
)
=>
BooleanLiteral
(
true
)
//println(replace(Map(scrut -> localScrut), pcSoFar))
case
_
=>
Equals
(
s
,
scrut
)
val
scrutConstraint
=
if
(
localScrut
==
scrut
)
BooleanLiteral
(
true
)
else
Equals
(
localScrut
,
scrut
)
}
val
substs
=
patternSubstitutions
(
localScrut
,
c
.
pattern
)
val
substs
=
patternSubstitutions
(
s
,
c
.
pattern
)
val
cond
=
conditionForPattern
(
scrut
,
c
.
pattern
)
//println("Pattern : " + c.pattern)
//println("SUBST")
//substs foreach println
val
cond
=
conditionForPattern
(
localScrut
,
c
.
pattern
)
//println("cond: " + cond)
val
g
=
c
.
theGuard
.
getOrElse
(
BooleanLiteral
(
true
))
val
g
=
c
.
theGuard
.
getOrElse
(
BooleanLiteral
(
true
))
val
pc
=
simplify
(
doSubstitute
(
substs
,
And
(
Seq
(
pcSoFar
,
g
,
sConstr
,
replace
(
Map
(
m
->
c
.
rhs
),
p
.
pc
)))))
val
pc
=
simplify
(
doSubstitute
(
substs
,
And
(
Seq
(
scrutConstraint
,
replace
(
Map
(
scrut
->
localScrut
),
pcSoFar
),
cond
,
g
,
replace
(
Map
(
m
->
c
.
rhs
),
p
.
pc
)
))
))
//println("PC")
//println(pc)
val
phi
=
doSubstitute
(
substs
,
p
.
phi
)
val
phi
=
doSubstitute
(
substs
,
p
.
phi
)
val
free
=
variablesOf
(
And
(
pc
,
phi
))
--
p
.
xs
val
free
=
variablesOf
(
And
(
pc
,
phi
))
--
p
.
xs
val
guardSafe
=
replaceFromIDs
(
mapForPattern
(
scrut
,
c
.
pattern
),
g
)
pcSoFar
=
And
(
pcSoFar
,
Not
(
cond
))
val
condSafe
=
conditionForPattern
(
scrut
,
c
.
pattern
)
//println("GUARD SAFE:")
//println(guardSafe)
//println("="*40)
pcSoFar
=
simplify
(
And
(
Not
(
And
(
condSafe
,
guardSafe
)),
pcSoFar
))
val
asPrefix
=
p
.
as
.
filter
(
free
)
val
asPrefix
=
p
.
as
.
filter
(
free
)
Problem
(
asPrefix
++
(
free
--
asPrefix
),
pc
,
phi
,
p
.
xs
)
Problem
(
asPrefix
++
(
free
--
asPrefix
),
pc
,
phi
,
p
.
xs
)
}
}
val
onSuccess
:
List
[
Solution
]
=>
Option
[
Solution
]
=
{
val
onSuccess
:
List
[
Solution
]
=>
Option
[
Solution
]
=
{
subs
=>
case
subs
=>
val
cases
=
for
((
c
,
s
)
<-
cs
zip
subs
)
yield
{
val
cases
=
for
((
c
,
s
)
<-
cs
zip
subs
)
yield
{
c
match
{
c
match
{
case
SimpleCase
(
c
,
rhs
)
=>
SimpleCase
(
c
,
s
.
term
)
case
SimpleCase
(
c
,
rhs
)
=>
SimpleCase
(
c
,
s
.
term
)
case
GuardedCase
(
c
,
g
,
rhs
)
=>
GuardedCase
(
c
,
g
,
s
.
term
)
case
GuardedCase
(
c
,
g
,
rhs
)
=>
GuardedCase
(
c
,
g
,
s
.
term
)
}
}
}
}
Some
(
Solution
(
Or
(
subs
.
map
(
_
.
pre
)),
subs
.
map
(
_
.
defs
).
foldLeft
(
Set
[
FunDef
]())(
_
++
_
),
MatchExpr
(
scrut
,
cases
)))
Some
(
Solution
(
Or
(
subs
.
map
(
_
.
pre
)),
subs
.
map
(
_
.
defs
).
foldLeft
(
Set
[
FunDef
]())(
_
++
_
),
Let
(
scrut
.
id
,
scrut0
,
MatchExpr
(
scrut
,
cases
))
))
}
}
Some
(
RuleInstantiation
.
immediateDecomp
(
p
,
this
,
subs
.
toList
,
onSuccess
,
"Guided Match-Split"
))
Some
(
RuleInstantiation
.
immediateDecomp
(
p
,
this
,
subs
.
toList
,
onSuccess
,
"Guided Match-Split"
))
...
...
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