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
f0a4f518
Commit
f0a4f518
authored
9 years ago
by
Manos Koukoutos
Browse files
Options
Downloads
Patches
Plain Diff
Slightly enrich Path API/improve style
parent
b1749d96
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/purescala/Path.scala
+9
-8
9 additions, 8 deletions
src/main/scala/leon/purescala/Path.scala
with
9 additions
and
8 deletions
src/main/scala/leon/purescala/Path.scala
+
9
−
8
View file @
f0a4f518
...
...
@@ -7,7 +7,6 @@ import Common._
import
Definitions._
import
Expressions._
import
Constructors._
import
Extractors._
import
ExprOps._
import
Types._
...
...
@@ -31,7 +30,7 @@ object Path {
* could introduce non-sensical equations.
*/
class
Path
private
[
purescala
](
private
[
purescala
]
val
elements
:
Seq
[
Either
[(
Identifier
,
Expr
)
,
Expr
]])
{
private
[
purescala
]
val
elements
:
Seq
[
Either
[(
Identifier
,
Expr
)
,
Expr
]])
extends
Printable
{
def
withBinding
(
p
:
(
Identifier
,
Expr
))
=
new
Path
(
elements
:+
Left
(
p
))
def
withBindings
(
ps
:
Iterable
[(
Identifier
,
Expr
)])
=
new
Path
(
elements
++
ps
.
map
(
Left
(
_
)))
...
...
@@ -69,10 +68,10 @@ class Path private[purescala](
*
* A path is empty iff it contains no let-bindings and its path condition is trivial.
*/
def
isEmpty
=
elements
.
f
ilter
{
case
Right
(
BooleanLiteral
(
true
))
=>
fals
e
case
_
=>
tru
e
}
.
isEmpty
def
isEmpty
=
elements
.
f
orall
{
case
Right
(
BooleanLiteral
(
true
))
=>
tru
e
case
_
=>
fals
e
}
/** Returns the negation of a path
*
...
...
@@ -116,6 +115,8 @@ class Path private[purescala](
)(
elements
)
lazy
val
bindings
:
Seq
[(
Identifier
,
Expr
)]
=
elements
.
collect
{
case
Left
(
p
)
=>
p
}
lazy
val
boundIds
=
bindings
map
(
_
.
_1
)
lazy
val
bindingsAsEqs
=
bindings
map
{
case
(
id
,
e
)
=>
Equals
(
id
.
toVariable
,
e
)
}
lazy
val
conditions
:
Seq
[
Expr
]
=
elements
.
collect
{
case
Right
(
e
)
=>
e
}
def
isBound
(
id
:
Identifier
)
:
Boolean
=
bindings
.
exists
(
p
=>
p
.
_1
==
id
)
...
...
@@ -149,7 +150,7 @@ class Path private[purescala](
def
and
(
base
:
Expr
)
=
distributiveClause
(
base
,
Constructors
.
and
(
_
,
_
))
/** Fold the path into an implication of `base`, namely `path ==> base` */
def
implies
(
base
:
Expr
)
=
distributiveClause
(
base
,
Constructors
.
implies
(
_
,
_
)
)
def
implies
(
base
:
Expr
)
=
distributiveClause
(
base
,
Constructors
.
implies
)
/** Folds the path into a `require` wrapping the expression `body`
*
...
...
@@ -184,7 +185,7 @@ class Path private[purescala](
/** Like [[toClause]] but doesn't simplify final path through constructors
* from [[leon.purescala.Constructors]] */
lazy
val
fullClause
:
Expr
=
fold
[
Expr
](
BooleanLiteral
(
true
),
Let
(
_
,
_
,
_
)
,
And
(
_
,
_
))(
elements
)
lazy
val
fullClause
:
Expr
=
fold
[
Expr
](
BooleanLiteral
(
true
),
Let
,
And
(
_
,
_
))(
elements
)
/** Folds the path into a boolean proposition where let-bindings are
* replaced by equations.
...
...
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