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
73e18588
Commit
73e18588
authored
12 years ago
by
Etienne Kneuss
Browse files
Options
Downloads
Patches
Plain Diff
False progress
parent
93f0ed37
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
testcases/SortedTree.scala
+54
-7
54 additions, 7 deletions
testcases/SortedTree.scala
with
54 additions
and
7 deletions
testcases/SortedTree.scala
+
54
−
7
View file @
73e18588
...
@@ -23,7 +23,7 @@ object SortedTree {
...
@@ -23,7 +23,7 @@ object SortedTree {
})
ensuring
(
res
=>
res
>=
0
)
})
ensuring
(
res
=>
res
>=
0
)
def
content
(
t
:
Tree
)
:
Set
[
Int
]
=
t
match
{
def
content
(
t
:
Tree
)
:
Set
[
Int
]
=
t
match
{
case
Leaf
()
=>
Set
()
case
Leaf
()
=>
Set
.
empty
[
Int
]
case
Node
(
v
,
l
,
r
)
=>
Set
(
v
)
++
content
(
l
)
++
content
(
r
)
case
Node
(
v
,
l
,
r
)
=>
Set
(
v
)
++
content
(
l
)
++
content
(
r
)
}
}
...
@@ -113,7 +113,7 @@ object SortedTree {
...
@@ -113,7 +113,7 @@ object SortedTree {
allGreaterThan
(
r
,
min
)
&&
allGreaterThan
(
r
,
min
)
&&
v
>
min
v
>
min
case
Leaf
()
=>
true
case
Leaf
()
=>
true
})
ensuring
(
!
_
||
!(
content
(
t
)
contains
min
))
})
ensuring
(
res
=>
!
res
||
!(
content
(
t
)
contains
min
))
@induct
@induct
def
ltLemma
(
t
:
Tree
,
v1
:
Int
,
v2
:
Int
)
:
Boolean
=
{
def
ltLemma
(
t
:
Tree
,
v1
:
Int
,
v2
:
Int
)
:
Boolean
=
{
...
@@ -139,6 +139,55 @@ object SortedTree {
...
@@ -139,6 +139,55 @@ object SortedTree {
}
}
}).
holds
}).
holds
@induct
def
sortedLemma2
(
t
:
Tree
)
=
({
require
(
isSorted
(
t
))
t
match
{
case
Node
(
v
,
l
,
r
)
=>
!(
content
(
l
)
contains
v
)
&&
!(
content
(
r
)
contains
v
)
case
Leaf
()
=>
true
}
}).
holds
def
sortedLemma3
(
v
:
Int
,
l
:
Tree
,
r
:
Tree
)
=
{
require
(
isSorted
(
Node
(
v
,
l
,
r
)))
!((
content
(
l
)
++
content
(
r
))
contains
v
)
}
holds
// Proving is apparently difficult. Who knew.
@induct
def
allLessThanAllOf
(
t
:
Tree
,
top
:
Int
,
of
:
Tree
)
:
Boolean
=
{
require
(
isSorted
(
Node
(
top
,
t
,
of
)))
t
match
{
case
Node
(
v
,
l
,
r
)
=>
top
>
v
&&
allLessThanAllOf
(
l
,
v
,
of
)
&&
allLessThanAllOf
(
r
,
v
,
of
)
&&
allGreaterThan
(
of
,
v
)
case
Leaf
()
=>
true
}
}
ensuring
{
res
=>
!
res
||
(
allLessThan
(
t
,
top
)
&&
allGreaterThan
(
of
,
top
))}
// Ne marche pas encore vraiment... c'est difficile ce truc :(
// PS
def
separation
(
v
:
Int
,
l
:
Tree
,
r
:
Tree
)
:
Boolean
=
{
require
(
isSorted
(
Node
(
v
,
l
,
r
)))
(
l
match
{
case
Leaf
()
=>
true
case
Node
(
vl
,
ll
,
rl
)
=>
separation
(
vl
,
ll
,
rl
)
})
&&
(
r
match
{
case
Leaf
()
=>
true
case
Node
(
vr
,
lr
,
rr
)
=>
separation
(
vr
,
lr
,
rr
)
})
}
ensuring
(
res
=>
!
res
||
(
content
(
l
)
**
content
(
r
))
==
Set
.
empty
[
Int
])
//
//
// OPERATIONS:
// OPERATIONS:
//
//
...
@@ -205,16 +254,16 @@ object SortedTree {
...
@@ -205,16 +254,16 @@ object SortedTree {
}
}
})}
ensuring
(
_
==
(
content
(
t
)
contains
searchV
))
})}
ensuring
(
_
==
(
content
(
t
)
contains
searchV
))
def
contains
3
(
t
:
Tree
,
searchV
:
Int
)
:
Boolean
=
{
def
contains
Invalid
(
t
:
Tree
,
searchV
:
Int
)
:
Boolean
=
{
require
(
isSorted
(
t
))
require
(
isSorted
(
t
))
(
t
match
{
(
t
match
{
case
Leaf
()
=>
false
case
Leaf
()
=>
false
case
Node
(
v
,
l
,
r
)
=>
case
Node
(
v
,
l
,
r
)
=>
if
(
searchV
>
v
)
{
if
(
searchV
>
v
)
{
contains
3
(
r
,
searchV
)
contains
Invalid
(
r
,
searchV
)
}
else
if
(
searchV
<
v
)
{
}
else
if
(
searchV
<
v
)
{
contains
3
(
l
,
searchV
)
contains
Invalid
(
l
,
searchV
)
}
else
{
}
else
{
true
true
}
}
...
@@ -227,10 +276,8 @@ object SortedTree {
...
@@ -227,10 +276,8 @@ object SortedTree {
case
Leaf
()
=>
false
case
Leaf
()
=>
false
case
Node
(
v
,
l
,
r
)
=>
case
Node
(
v
,
l
,
r
)
=>
if
(
searchV
>
v
)
{
if
(
searchV
>
v
)
{
contains4
(
l
,
searchV
)
&&
contains4
(
r
,
searchV
)
contains4
(
r
,
searchV
)
}
else
if
(
searchV
<
v
)
{
}
else
if
(
searchV
<
v
)
{
contains4
(
r
,
searchV
)
&&
contains4
(
l
,
searchV
)
contains4
(
l
,
searchV
)
}
else
{
}
else
{
true
true
...
...
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