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
fd2c6cec
Commit
fd2c6cec
authored
8 years ago
by
Régis Blanc
Browse files
Options
Downloads
Patches
Plain Diff
update some outdated xlang testcases
parent
643d6fb5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
testcases/verification/xlang/MaxSum.scala
+5
-43
5 additions, 43 deletions
testcases/verification/xlang/MaxSum.scala
testcases/verification/xlang/Sums.scala
+28
-0
28 additions, 0 deletions
testcases/verification/xlang/Sums.scala
with
33 additions
and
43 deletions
testcases/verification/xlang/MaxSum.scala
+
5
−
43
View file @
fd2c6cec
...
@@ -4,8 +4,10 @@ import leon.lang._
...
@@ -4,8 +4,10 @@ import leon.lang._
object
MaxSum
{
object
MaxSum
{
def
maxSum
(
a
:
Array
[
Int
])
:
(
Int
,
Int
)
=
({
//not valid because of Int, unfortunately conversion between big int and
require
(
a
.
length
>=
0
&&
isPositive
(
a
))
//int does not work and we cannot compute a.length * Max (Int * BigInt)
def
maxSum
(
a
:
Array
[
Int
])
:
(
Int
,
Int
)
=
{
require
(
a
.
length
>=
0
)
var
sum
=
0
var
sum
=
0
var
max
=
0
var
max
=
0
var
i
=
0
var
i
=
0
...
@@ -16,46 +18,6 @@ object MaxSum {
...
@@ -16,46 +18,6 @@ object MaxSum {
i
=
i
+
1
i
=
i
+
1
})
invariant
(
sum
<=
i
*
max
&&
i
>=
0
&&
i
<=
a
.
length
)
})
invariant
(
sum
<=
i
*
max
&&
i
>=
0
&&
i
<=
a
.
length
)
(
sum
,
max
)
(
sum
,
max
)
})
ensuring
(
res
=>
res
.
_1
<=
a
.
length
*
res
.
_2
)
}
ensuring
(
res
=>
res
.
_1
<=
a
.
length
*
res
.
_2
)
def
isPositive
(
a
:
Array
[
Int
])
:
Boolean
=
{
require
(
a
.
length
>=
0
)
def
rec
(
i
:
Int
)
:
Boolean
=
{
require
(
i
>=
0
)
if
(
i
>=
a
.
length
)
true
else
{
if
(
a
(
i
)
<
0
)
false
else
rec
(
i
+
1
)
}
}
rec
(
0
)
}
def
summ
(
to
:
Int
)
:
Int
=
({
require
(
to
>=
0
)
var
i
=
0
var
s
=
0
(
while
(
i
<
to
)
{
s
=
s
+
i
i
=
i
+
1
})
invariant
(
s
>=
0
&&
i
>=
0
&&
s
==
i
*(
i
-
1
)/
2
&&
i
<=
to
)
s
})
ensuring
(
res
=>
res
>=
0
&&
res
==
to
*(
to
-
1
)/
2
)
def
sumsq
(
to
:
Int
)
:
Int
=
({
require
(
to
>=
0
)
var
i
=
0
var
s
=
0
(
while
(
i
<
to
)
{
s
=
s
+
i
*
i
i
=
i
+
1
})
invariant
(
s
>=
0
&&
i
>=
0
&&
s
==
(
i
-
1
)*
i
*(
2
*
i
-
1
)/
6
&&
i
<=
to
)
s
})
ensuring
(
res
=>
res
>=
0
&&
res
==
(
to
-
1
)*
to
*(
2
*
to
-
1
)/
6
)
}
}
This diff is collapsed.
Click to expand it.
testcases/verification/xlang/Sums.scala
0 → 100644
+
28
−
0
View file @
fd2c6cec
import
leon.lang._
object
Sums
{
def
summ
(
to
:
BigInt
)
:
BigInt
=
({
require
(
to
>=
0
)
var
i
:
BigInt
=
0
var
s
:
BigInt
=
0
(
while
(
i
<
to
)
{
s
=
s
+
i
i
=
i
+
1
})
invariant
(
s
>=
0
&&
i
>=
0
&&
s
==
i
*(
i
-
1
)/
2
&&
i
<=
to
)
s
})
ensuring
(
res
=>
res
>=
0
&&
res
==
to
*(
to
-
1
)/
2
)
def
sumsq
(
to
:
BigInt
)
:
BigInt
=
({
require
(
to
>=
0
)
var
i
:
BigInt
=
0
var
s
:
BigInt
=
0
(
while
(
i
<
to
)
{
s
=
s
+
i
*
i
i
=
i
+
1
})
invariant
(
s
>=
0
&&
i
>=
0
&&
s
==
(
i
-
1
)*
i
*(
2
*
i
-
1
)/
6
&&
i
<=
to
)
s
})
ensuring
(
res
=>
res
>=
0
&&
res
==
(
to
-
1
)*
to
*(
2
*
to
-
1
)/
6
)
}
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