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
56165f86
Commit
56165f86
authored
9 years ago
by
Régis Blanc
Committed by
Regis Blanc
9 years ago
Browse files
Options
Downloads
Patches
Plain Diff
guess a number with espilons
parent
0b2aa0d3
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/test/resources/regression/verification/xlang/valid/GuessNumber.scala
+32
-0
32 additions, 0 deletions
...ces/regression/verification/xlang/valid/GuessNumber.scala
testcases/verification/xlang/GuessNumber.scala
+32
-0
32 additions, 0 deletions
testcases/verification/xlang/GuessNumber.scala
with
64 additions
and
0 deletions
src/test/resources/regression/verification/xlang/valid/GuessNumber.scala
0 → 100644
+
32
−
0
View file @
56165f86
import
leon.lang._
import
leon.lang.xlang._
object
GuessNumber
{
def
random
(
min
:
Int
,
max
:
Int
)
:
Int
=
epsilon
((
x
:
Int
)
=>
x
>=
min
&&
x
<=
max
)
def
main
()
:
Unit
=
{
val
choice
=
random
(
0
,
10
)
var
guess
=
random
(
0
,
10
)
var
top
=
10
var
bot
=
0
(
while
(
bot
<
top
)
{
if
(
isGreater
(
guess
,
choice
))
{
top
=
guess
-
1
guess
=
random
(
bot
,
top
)
}
else
if
(
isSmaller
(
guess
,
choice
))
{
bot
=
guess
+
1
guess
=
random
(
bot
,
top
)
}
})
invariant
(
guess
>=
bot
&&
guess
<=
top
&&
bot
>=
0
&&
top
<=
10
&&
bot
<=
top
&&
choice
>=
bot
&&
choice
<=
top
&&
true
)
val
answer
=
bot
assert
(
answer
==
choice
)
}
def
isGreater
(
guess
:
Int
,
choice
:
Int
)
:
Boolean
=
guess
>
choice
def
isSmaller
(
guess
:
Int
,
choice
:
Int
)
:
Boolean
=
guess
<
choice
}
This diff is collapsed.
Click to expand it.
testcases/verification/xlang/GuessNumber.scala
0 → 100644
+
32
−
0
View file @
56165f86
import
leon.lang._
import
leon.lang.xlang._
object
GuessNumber
{
def
random
(
min
:
Int
,
max
:
Int
)
:
Int
=
epsilon
((
x
:
Int
)
=>
x
>=
min
&&
x
<=
max
)
def
main
()
:
Unit
=
{
val
choice
=
random
(
0
,
10
)
var
guess
=
random
(
0
,
10
)
var
top
=
10
var
bot
=
0
(
while
(
bot
<
top
)
{
if
(
isGreater
(
guess
,
choice
))
{
top
=
guess
-
1
guess
=
random
(
bot
,
top
)
}
else
if
(
isSmaller
(
guess
,
choice
))
{
bot
=
guess
+
1
guess
=
random
(
bot
,
top
)
}
})
invariant
(
guess
>=
bot
&&
guess
<=
top
&&
bot
>=
0
&&
top
<=
10
&&
bot
<=
top
&&
choice
>=
bot
&&
choice
<=
top
&&
true
)
val
answer
=
bot
assert
(
answer
==
choice
)
}
def
isGreater
(
guess
:
Int
,
choice
:
Int
)
:
Boolean
=
guess
>
choice
def
isSmaller
(
guess
:
Int
,
choice
:
Int
)
:
Boolean
=
guess
<
choice
}
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