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
eda946cc
Commit
eda946cc
authored
10 years ago
by
Samuel Gruetter
Browse files
Options
Downloads
Patches
Plain Diff
replace case IntegerType in size func by abs(expr), does not work on mytests/Termination2.scala
parent
5062da61
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
mytests/Termination2.scala
+14
-0
14 additions, 0 deletions
mytests/Termination2.scala
src/main/scala/leon/termination/StructuralSize.scala
+13
-0
13 additions, 0 deletions
src/main/scala/leon/termination/StructuralSize.scala
with
27 additions
and
0 deletions
mytests/Termination2.scala
0 → 100644
+
14
−
0
View file @
eda946cc
object
Test
{
def
f
(
x
:
BigInt
)
:
BigInt
=
{
if
(
x
==
0
)
{
0
}
else
if
(
x
>
0
)
{
f
(
x
-
1
)+
2
}
else
if
(
x
<
0
)
{
f
(
x
+
1
)-
2
}
else
{
33
}
}
ensuring
(
_
==
x
*
2
)
}
This diff is collapsed.
Click to expand it.
src/main/scala/leon/termination/StructuralSize.scala
+
13
−
0
View file @
eda946cc
...
@@ -15,6 +15,16 @@ import scala.collection.mutable.{Map => MutableMap}
...
@@ -15,6 +15,16 @@ import scala.collection.mutable.{Map => MutableMap}
trait
StructuralSize
{
trait
StructuralSize
{
private
val
sizeCache
:
MutableMap
[
TypeTree
,
FunDef
]
=
MutableMap
.
empty
private
val
sizeCache
:
MutableMap
[
TypeTree
,
FunDef
]
=
MutableMap
.
empty
private
val
absFun
=
new
FunDef
(
FreshIdentifier
(
"abs"
,
alwaysShowUniqueID
=
true
),
Seq
(),
// no type params
IntegerType
,
// returns BigInt
Seq
(
ValDef
(
FreshIdentifier
(
"x"
,
IntegerType
,
alwaysShowUniqueID
=
true
))),
DefType
.
MethodDef
)
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
=
{
...
@@ -66,6 +76,9 @@ trait StructuralSize {
...
@@ -66,6 +76,9 @@ trait StructuralSize {
case
TupleType
(
argTypes
)
=>
argTypes
.
zipWithIndex
.
map
({
case
TupleType
(
argTypes
)
=>
argTypes
.
zipWithIndex
.
map
({
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
=>
println
(
"here"
)
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