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
5992df36
Commit
5992df36
authored
10 years ago
by
Samuel Gruetter
Browse files
Options
Downloads
Patches
Plain Diff
implement body of abs function --> Termination2 works
parent
eda946cc
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/scala/leon/termination/RelationProcessor.scala
+2
-1
2 additions, 1 deletion
src/main/scala/leon/termination/RelationProcessor.scala
src/main/scala/leon/termination/StructuralSize.scala
+14
-6
14 additions, 6 deletions
src/main/scala/leon/termination/StructuralSize.scala
with
16 additions
and
7 deletions
src/main/scala/leon/termination/RelationProcessor.scala
+
2
−
1
View file @
5992df36
...
@@ -24,7 +24,8 @@ class RelationProcessor(
...
@@ -24,7 +24,8 @@ class RelationProcessor(
reporter
.
debug
(
"- Strengthening applications"
)
reporter
.
debug
(
"- Strengthening applications"
)
checker
.
strengthenApplications
(
problem
.
funSet
)(
this
)
checker
.
strengthenApplications
(
problem
.
funSet
)(
this
)
val
formulas
=
problem
.
funDefs
.
map
({
funDef
=>
val
formulas
:
Set
[(
FunDef
,
Set
[(
FunDef
,
(
Expr
,
Expr
))])]
=
problem
.
funDefs
.
map
({
funDef
=>
funDef
->
checker
.
getRelations
(
funDef
).
collect
({
funDef
->
checker
.
getRelations
(
funDef
).
collect
({
case
Relation
(
_
,
path
,
FunctionInvocation
(
tfd
,
args
),
_
)
if
problem
.
funSet
(
tfd
.
fd
)
=>
case
Relation
(
_
,
path
,
FunctionInvocation
(
tfd
,
args
),
_
)
if
problem
.
funSet
(
tfd
.
fd
)
=>
val
(
e1
,
e2
)
=
(
tupleWrap
(
funDef
.
params
.
map
(
_
.
toVariable
)),
tupleWrap
(
args
))
val
(
e1
,
e2
)
=
(
tupleWrap
(
funDef
.
params
.
map
(
_
.
toVariable
)),
tupleWrap
(
args
))
...
...
This diff is collapsed.
Click to expand it.
src/main/scala/leon/termination/StructuralSize.scala
+
14
−
6
View file @
5992df36
...
@@ -16,16 +16,25 @@ trait StructuralSize {
...
@@ -16,16 +16,25 @@ trait StructuralSize {
private
val
sizeCache
:
MutableMap
[
TypeTree
,
FunDef
]
=
MutableMap
.
empty
private
val
sizeCache
:
MutableMap
[
TypeTree
,
FunDef
]
=
MutableMap
.
empty
private
val
absFun
=
new
FunDef
(
// function abs(x: BigInt): BigInt = if (x >= 0) x else -x
val
typedAbsFun
=
makeAbsFun
def
makeAbsFun
:
TypedFunDef
=
{
val
x
=
FreshIdentifier
(
"x"
,
IntegerType
,
alwaysShowUniqueID
=
true
)
val
absFun
=
new
FunDef
(
FreshIdentifier
(
"abs"
,
alwaysShowUniqueID
=
true
),
FreshIdentifier
(
"abs"
,
alwaysShowUniqueID
=
true
),
Seq
(),
// no type params
Seq
(),
// no type params
IntegerType
,
// returns BigInt
IntegerType
,
// returns BigInt
Seq
(
ValDef
(
FreshIdentifier
(
"x"
,
IntegerType
,
alwaysShowUniqueID
=
true
)
)),
Seq
(
ValDef
(
x
)),
DefType
.
MethodDef
DefType
.
MethodDef
)
)
absFun
.
body
=
Some
(
IfExpr
(
GreaterEquals
(
Variable
(
x
),
InfiniteIntegerLiteral
(
0
)),
Variable
(
x
),
Minus
(
InfiniteIntegerLiteral
(
0
),
Variable
(
x
))))
TypedFunDef
(
absFun
,
Seq
())
// Seq() because no generic type params
}
private
val
typedAbsFun
=
TypedFunDef
(
absFun
,
Seq
(
IntegerType
))
def
size
(
expr
:
Expr
)
:
Expr
=
{
def
size
(
expr
:
Expr
)
:
Expr
=
{
def
funDef
(
ct
:
ClassType
,
cases
:
ClassType
=>
Seq
[
MatchCase
])
:
FunDef
=
{
def
funDef
(
ct
:
ClassType
,
cases
:
ClassType
=>
Seq
[
MatchCase
])
:
FunDef
=
{
// we want to reuse generic size functions for sub-types
// we want to reuse generic size functions for sub-types
...
@@ -77,7 +86,6 @@ trait StructuralSize {
...
@@ -77,7 +86,6 @@ trait StructuralSize {
case
(
_
,
index
)
=>
size
(
tupleSelect
(
expr
,
index
+
1
,
true
))
case
(
_
,
index
)
=>
size
(
tupleSelect
(
expr
,
index
+
1
,
true
))
}).
foldLeft
[
Expr
](
InfiniteIntegerLiteral
(
0
))(
Plus
)
}).
foldLeft
[
Expr
](
InfiniteIntegerLiteral
(
0
))(
Plus
)
case
IntegerType
=>
case
IntegerType
=>
println
(
"here"
)
FunctionInvocation
(
typedAbsFun
,
Seq
(
expr
))
FunctionInvocation
(
typedAbsFun
,
Seq
(
expr
))
case
_
=>
InfiniteIntegerLiteral
(
0
)
case
_
=>
InfiniteIntegerLiteral
(
0
)
}
}
...
...
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